@channelhub/widget 0.1.4 → 0.1.6
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/ChannelHubInbox.d.ts.map +1 -1
- package/dist/api.d.ts +4 -0
- package/dist/api.d.ts.map +1 -1
- package/dist/index.cjs +26 -25
- package/dist/index.js +966 -753
- package/dist/types.d.ts +55 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/ChannelHubInbox.tsx +269 -17
- package/src/api.ts +7 -0
- package/src/types.ts +65 -0
package/dist/index.js
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import { jsx as e, jsxs as n, Fragment as
|
|
2
|
-
import { forwardRef as
|
|
3
|
-
import { createPortal as
|
|
1
|
+
import { jsx as e, jsxs as n, Fragment as te } from "react/jsx-runtime";
|
|
2
|
+
import { forwardRef as Le, createElement as Pe, createContext as nt, useRef as ee, useState as g, useMemo as Ee, useCallback as We, useEffect as Y, useImperativeHandle as yt, useContext as Ne, Component as mt } from "react";
|
|
3
|
+
import { createPortal as it } 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 bt = (t) => t.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase(), rt = (...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 xt = {
|
|
18
18
|
xmlns: "http://www.w3.org/2000/svg",
|
|
19
19
|
width: 24,
|
|
20
20
|
height: 24,
|
|
@@ -31,31 +31,31 @@ var lt = {
|
|
|
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 vt = Le(
|
|
35
35
|
({
|
|
36
36
|
color: t = "currentColor",
|
|
37
37
|
size: i = 24,
|
|
38
38
|
strokeWidth: r = 2,
|
|
39
39
|
absoluteStrokeWidth: o,
|
|
40
|
-
className:
|
|
41
|
-
children:
|
|
42
|
-
iconNode:
|
|
43
|
-
...
|
|
44
|
-
}, f) =>
|
|
40
|
+
className: s = "",
|
|
41
|
+
children: C,
|
|
42
|
+
iconNode: m,
|
|
43
|
+
...O
|
|
44
|
+
}, f) => Pe(
|
|
45
45
|
"svg",
|
|
46
46
|
{
|
|
47
47
|
ref: f,
|
|
48
|
-
...
|
|
48
|
+
...xt,
|
|
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: rt("lucide", s),
|
|
54
|
+
...O
|
|
55
55
|
},
|
|
56
56
|
[
|
|
57
|
-
...
|
|
58
|
-
...Array.isArray(
|
|
57
|
+
...m.map(([S, B]) => Pe(S, B)),
|
|
58
|
+
...Array.isArray(C) ? C : [C]
|
|
59
59
|
]
|
|
60
60
|
)
|
|
61
61
|
);
|
|
@@ -65,13 +65,13 @@ const dt = ke(
|
|
|
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
|
|
69
|
-
const r =
|
|
70
|
-
({ className: o, ...
|
|
71
|
-
ref:
|
|
68
|
+
const X = (t, i) => {
|
|
69
|
+
const r = Le(
|
|
70
|
+
({ className: o, ...s }, C) => Pe(vt, {
|
|
71
|
+
ref: C,
|
|
72
72
|
iconNode: i,
|
|
73
|
-
className:
|
|
74
|
-
...
|
|
73
|
+
className: rt(`lucide-${bt(t)}`, o),
|
|
74
|
+
...s
|
|
75
75
|
})
|
|
76
76
|
);
|
|
77
77
|
return r.displayName = `${t}`, r;
|
|
@@ -82,7 +82,7 @@ const P = (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 Ge = X("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 Ae = P("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 ot = X("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 kt = X("ChevronDown", [
|
|
103
103
|
["path", { d: "m6 9 6 6 6-6", key: "qrunsl" }]
|
|
104
104
|
]);
|
|
105
105
|
/**
|
|
@@ -108,7 +108,7 @@ const ct = P("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 wt = X("ChevronRight", [
|
|
112
112
|
["path", { d: "m9 18 6-6-6-6", key: "mthhwq" }]
|
|
113
113
|
]);
|
|
114
114
|
/**
|
|
@@ -117,7 +117,7 @@ const st = P("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 St = X("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 pt = P("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 at = X("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 Xe = P("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 Ct = X("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 ht = P("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 It = X("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 ut = P("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 zt = X("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 ft = P("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 lt = X("LoaderCircle", [
|
|
181
181
|
["path", { d: "M21 12a9 9 0 1 1-6.219-8.56", key: "13zald" }]
|
|
182
182
|
]);
|
|
183
183
|
/**
|
|
@@ -186,7 +186,7 @@ const Ze = P("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 Tt = X("Paperclip", [
|
|
190
190
|
["path", { d: "M13.234 20.252 21 12.3", key: "1cbrk9" }],
|
|
191
191
|
[
|
|
192
192
|
"path",
|
|
@@ -202,7 +202,7 @@ const gt = P("Paperclip", [
|
|
|
202
202
|
* This source code is licensed under the ISC license.
|
|
203
203
|
* See the LICENSE file in the root directory of this source tree.
|
|
204
204
|
*/
|
|
205
|
-
const
|
|
205
|
+
const Rt = X("Play", [
|
|
206
206
|
["polygon", { points: "6 3 20 12 6 21 6 3", key: "1oa8hb" }]
|
|
207
207
|
]);
|
|
208
208
|
/**
|
|
@@ -211,7 +211,7 @@ const yt = P("Play", [
|
|
|
211
211
|
* This source code is licensed under the ISC license.
|
|
212
212
|
* See the LICENSE file in the root directory of this source tree.
|
|
213
213
|
*/
|
|
214
|
-
const
|
|
214
|
+
const Xe = X("Search", [
|
|
215
215
|
["circle", { cx: "11", cy: "11", r: "8", key: "4ej97u" }],
|
|
216
216
|
["path", { d: "m21 21-4.3-4.3", key: "1qie3q" }]
|
|
217
217
|
]);
|
|
@@ -221,7 +221,7 @@ const Oe = P("Search", [
|
|
|
221
221
|
* This source code is licensed under the ISC license.
|
|
222
222
|
* See the LICENSE file in the root directory of this source tree.
|
|
223
223
|
*/
|
|
224
|
-
const
|
|
224
|
+
const Bt = X("Send", [
|
|
225
225
|
[
|
|
226
226
|
"path",
|
|
227
227
|
{
|
|
@@ -237,7 +237,7 @@ const mt = P("Send", [
|
|
|
237
237
|
* This source code is licensed under the ISC license.
|
|
238
238
|
* See the LICENSE file in the root directory of this source tree.
|
|
239
239
|
*/
|
|
240
|
-
const
|
|
240
|
+
const Wt = X("SlidersHorizontal", [
|
|
241
241
|
["line", { x1: "21", x2: "14", y1: "4", y2: "4", key: "obuewd" }],
|
|
242
242
|
["line", { x1: "10", x2: "3", y1: "4", y2: "4", key: "1q6298" }],
|
|
243
243
|
["line", { x1: "21", x2: "12", y1: "12", y2: "12", key: "1iu8h1" }],
|
|
@@ -254,7 +254,7 @@ const bt = P("SlidersHorizontal", [
|
|
|
254
254
|
* This source code is licensed under the ISC license.
|
|
255
255
|
* See the LICENSE file in the root directory of this source tree.
|
|
256
256
|
*/
|
|
257
|
-
const
|
|
257
|
+
const $t = X("Smile", [
|
|
258
258
|
["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }],
|
|
259
259
|
["path", { d: "M8 14s1.5 2 4 2 4-2 4-2", key: "1y1vjs" }],
|
|
260
260
|
["line", { x1: "9", x2: "9.01", y1: "9", y2: "9", key: "yxxnd0" }],
|
|
@@ -266,7 +266,7 @@ const xt = P("Smile", [
|
|
|
266
266
|
* This source code is licensed under the ISC license.
|
|
267
267
|
* See the LICENSE file in the root directory of this source tree.
|
|
268
268
|
*/
|
|
269
|
-
const
|
|
269
|
+
const je = X("X", [
|
|
270
270
|
["path", { d: "M18 6 6 18", key: "1bl5f8" }],
|
|
271
271
|
["path", { d: "m6 6 12 12", key: "d8bk6v" }]
|
|
272
272
|
]);
|
|
@@ -276,7 +276,7 @@ const ze = P("X", [
|
|
|
276
276
|
* This source code is licensed under the ISC license.
|
|
277
277
|
* See the LICENSE file in the root directory of this source tree.
|
|
278
278
|
*/
|
|
279
|
-
const
|
|
279
|
+
const Lt = X("Zap", [
|
|
280
280
|
[
|
|
281
281
|
"path",
|
|
282
282
|
{
|
|
@@ -285,21 +285,21 @@ const vt = P("Zap", [
|
|
|
285
285
|
}
|
|
286
286
|
]
|
|
287
287
|
]);
|
|
288
|
-
class
|
|
288
|
+
class Mt {
|
|
289
289
|
constructor(i, r) {
|
|
290
290
|
this.apiUrl = i, this.token = r;
|
|
291
291
|
}
|
|
292
292
|
async request(i, r, o) {
|
|
293
|
-
const
|
|
293
|
+
const s = {
|
|
294
294
|
authorization: `Bearer ${this.token}`,
|
|
295
295
|
...o ? {} : { "content-type": "application/json" },
|
|
296
296
|
...r == null ? void 0 : r.headers
|
|
297
|
-
},
|
|
297
|
+
}, C = await fetch(`${this.apiUrl}${i}`, {
|
|
298
298
|
...r,
|
|
299
|
-
headers:
|
|
300
|
-
}),
|
|
301
|
-
if (!
|
|
302
|
-
return
|
|
299
|
+
headers: s
|
|
300
|
+
}), m = await C.json().catch(() => null);
|
|
301
|
+
if (!C.ok) throw new Error((m == null ? void 0 : m.message) ?? `Request failed (${C.status})`);
|
|
302
|
+
return m;
|
|
303
303
|
}
|
|
304
304
|
listConnections() {
|
|
305
305
|
return this.request("/v1/connections");
|
|
@@ -334,6 +334,12 @@ class kt {
|
|
|
334
334
|
getNote(i) {
|
|
335
335
|
return this.request(`/v1/conversations/${encodeURIComponent(i)}/note`);
|
|
336
336
|
}
|
|
337
|
+
patchContact(i, r) {
|
|
338
|
+
return this.request(`/v1/contacts/${encodeURIComponent(i)}`, {
|
|
339
|
+
method: "PATCH",
|
|
340
|
+
body: JSON.stringify({ externalId: r })
|
|
341
|
+
});
|
|
342
|
+
}
|
|
337
343
|
upsertNote(i, r) {
|
|
338
344
|
return this.request(`/v1/conversations/${encodeURIComponent(i)}/note`, {
|
|
339
345
|
method: "PUT",
|
|
@@ -350,63 +356,98 @@ class kt {
|
|
|
350
356
|
}
|
|
351
357
|
connectSSE(i) {
|
|
352
358
|
const r = `${this.apiUrl}/v1/events?token=${encodeURIComponent(this.token)}`;
|
|
353
|
-
let o,
|
|
354
|
-
const
|
|
355
|
-
o = new EventSource(r), o.addEventListener("message.new", (
|
|
356
|
-
i("message.new", JSON.parse(
|
|
357
|
-
}), o.addEventListener("conversation.updated", (
|
|
358
|
-
i("conversation.updated", JSON.parse(
|
|
359
|
+
let o, s, C = !1;
|
|
360
|
+
const m = () => {
|
|
361
|
+
o = new EventSource(r), o.addEventListener("message.new", (O) => {
|
|
362
|
+
i("message.new", JSON.parse(O.data));
|
|
363
|
+
}), o.addEventListener("conversation.updated", (O) => {
|
|
364
|
+
i("conversation.updated", JSON.parse(O.data));
|
|
359
365
|
}), o.onerror = () => {
|
|
360
|
-
o.close(),
|
|
366
|
+
o.close(), C || (s = setTimeout(m, 5e3));
|
|
361
367
|
};
|
|
362
368
|
};
|
|
363
|
-
return
|
|
364
|
-
|
|
369
|
+
return m(), () => {
|
|
370
|
+
C = !0, clearTimeout(s), o == null || o.close();
|
|
365
371
|
};
|
|
366
372
|
}
|
|
367
373
|
}
|
|
368
|
-
function
|
|
374
|
+
function dt({ src: t, alt: i = "", fallback: r, style: o }) {
|
|
369
375
|
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 });
|
|
370
376
|
}
|
|
371
|
-
function
|
|
377
|
+
function Ht({ variant: t = "ghost", style: i, ...r }) {
|
|
372
378
|
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 } });
|
|
373
379
|
}
|
|
374
|
-
function
|
|
380
|
+
function Et({ style: t, ...i }) {
|
|
375
381
|
return /* @__PURE__ */ e("input", { ...i, style: { width: "100%", minWidth: 0, border: 0, outline: 0, background: "transparent", font: "inherit", ...t } });
|
|
376
382
|
}
|
|
377
|
-
const
|
|
383
|
+
const ct = Le(
|
|
378
384
|
({ children: t, style: i }, r) => /* @__PURE__ */ e("div", { ref: r, style: { minHeight: 0, overflowY: "auto", overscrollBehavior: "contain", ...i }, children: t })
|
|
379
|
-
),
|
|
385
|
+
), jt = Le(
|
|
380
386
|
function({ style: i, ...r }, o) {
|
|
381
387
|
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 } });
|
|
382
388
|
}
|
|
383
|
-
)
|
|
389
|
+
);
|
|
390
|
+
function At(t) {
|
|
391
|
+
return {
|
|
392
|
+
id: t.contactId ?? t.providerConversationKey,
|
|
393
|
+
name: t.contactName,
|
|
394
|
+
pictureUrl: t.contactPictureUrl,
|
|
395
|
+
providerUserId: t.contactProviderUserId ?? t.providerConversationKey,
|
|
396
|
+
...t.contactExternalId ? { externalId: t.contactExternalId } : {}
|
|
397
|
+
};
|
|
398
|
+
}
|
|
399
|
+
function Ae(t, i) {
|
|
400
|
+
return {
|
|
401
|
+
conversation: t,
|
|
402
|
+
contact: At(t),
|
|
403
|
+
provider: i == null ? void 0 : i.provider,
|
|
404
|
+
recentMessages: i == null ? void 0 : i.recentMessages,
|
|
405
|
+
linkContact: (i == null ? void 0 : i.linkContact) ?? (async () => {
|
|
406
|
+
}),
|
|
407
|
+
refreshContactInfo: (i == null ? void 0 : i.refreshContactInfo) ?? (() => {
|
|
408
|
+
}),
|
|
409
|
+
sendMessage: (i == null ? void 0 : i.sendMessage) ?? (async () => {
|
|
410
|
+
})
|
|
411
|
+
};
|
|
412
|
+
}
|
|
413
|
+
class Ot extends mt {
|
|
414
|
+
constructor() {
|
|
415
|
+
super(...arguments), this.state = { caught: !1 };
|
|
416
|
+
}
|
|
417
|
+
static getDerivedStateFromError() {
|
|
418
|
+
return { caught: !0 };
|
|
419
|
+
}
|
|
420
|
+
render() {
|
|
421
|
+
return this.state.caught ? null : this.props.children;
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
const d = { ink: "#172033", muted: "#718096", line: "#e7ebf2", surface: "#f7f9fc", white: "#fff" }, Je = [
|
|
384
425
|
{ icon: "😊", emojis: ["😀", "😁", "😂", "🤣", "😊", "😇", "🙂", "😉", "😍", "🥰", "😘", "😋", "😎", "🤩", "😏", "😒", "😔", "😢", "😭", "😤", "😠", "🤯", "😱", "🥳", "😴", "🤔", "🤗", "🫡", "😮", "🤧", "🥺", "😶", "🫠", "🤭", "🤫"] },
|
|
385
426
|
{ icon: "👋", emojis: ["👍", "👎", "👏", "🙏", "🤝", "✌️", "🤞", "🫡", "💪", "🤜", "👊", "✊", "🖐", "👌", "🤌", "🤏", "☝️", "👆", "👇", "👉", "👈", "🤙", "💅", "🫶", "❤️", "🧡", "💛", "💚", "💙", "💜", "🖤", "💔", "❣️", "💕", "💯"] },
|
|
386
427
|
{ icon: "🐱", emojis: ["🐶", "🐱", "🐭", "🐹", "🐰", "🦊", "🐻", "🐼", "🐨", "🐯", "🦁", "🐮", "🐷", "🐸", "🐵", "🙈", "🐔", "🐧", "🐦", "🦆", "🦅", "🦉", "🦋", "🐝", "🐛", "🐢", "🦎", "🐬", "🦈", "🐳", "🐙", "🦑"] },
|
|
387
428
|
{ icon: "🍕", emojis: ["🍎", "🍊", "🍋", "🍇", "🍓", "🍒", "🥝", "🥑", "🍔", "🍕", "🌮", "🍜", "🍣", "🍦", "🎂", "🍰", "🧁", "☕", "🧋", "🥤", "🍺", "🥂", "🍾", "🧃", "🧊"] },
|
|
388
429
|
{ icon: "⚽", emojis: ["⚽", "🏀", "🏈", "⚾", "🎾", "🏐", "🏓", "🎮", "🎲", "🎯", "🎳", "🏆", "🥇", "🎖", "🎁", "🎉", "🎊", "🎈", "🎭", "🎨", "🎬", "🎵", "🎸", "🎹", "🎺", "🪗", "🎻"] },
|
|
389
430
|
{ icon: "🌍", emojis: ["🌍", "🌈", "⭐", "🌙", "☀️", "⛅", "🌊", "🔥", "💧", "🌿", "🌸", "🌺", "🌻", "🍀", "🌴", "🏔", "🏖", "🏕", "🌃", "🏙", "🌅", "🌄", "🌠", "🌌", "🌋", "🏝"] }
|
|
390
|
-
],
|
|
391
|
-
function
|
|
431
|
+
], qe = nt(""), st = nt("");
|
|
432
|
+
function Ut() {
|
|
392
433
|
try {
|
|
393
434
|
const t = new AudioContext(), i = t.createOscillator(), r = t.createGain();
|
|
394
435
|
i.connect(r), r.connect(t.destination), i.type = "sine", i.frequency.setValueAtTime(880, t.currentTime), i.frequency.exponentialRampToValueAtTime(660, t.currentTime + 0.12), r.gain.setValueAtTime(0.25, t.currentTime), r.gain.exponentialRampToValueAtTime(1e-3, t.currentTime + 0.35), i.start(t.currentTime), i.stop(t.currentTime + 0.35);
|
|
395
436
|
} catch {
|
|
396
437
|
}
|
|
397
438
|
}
|
|
398
|
-
function
|
|
439
|
+
function Dt(t) {
|
|
399
440
|
if (!(t != null && t.metadata)) return;
|
|
400
441
|
const i = t.metadata, r = i.pageName ?? i.displayName ?? i.username ?? i.name;
|
|
401
442
|
return typeof r == "string" && r ? r : void 0;
|
|
402
443
|
}
|
|
403
|
-
function
|
|
404
|
-
return t === "facebook" ? "Facebook Messenger" : t === "instagram" ? "Instagram" : t === "telegram" ? "Telegram" : t === "zalo" ? "Zalo OA" : "Channel";
|
|
444
|
+
function ht(t) {
|
|
445
|
+
return t === "facebook" ? "Facebook Messenger" : t === "instagram" ? "Instagram" : t === "telegram" ? "Telegram" : t === "zalo" ? "Zalo OA" : t === "livechat" ? "Live Chat" : "Channel";
|
|
405
446
|
}
|
|
406
|
-
function
|
|
407
|
-
return t === "facebook" ? "Facebook" : t === "instagram" ? "Instagram" : t === "telegram" ? "Telegram" : t === "zalo" ? "Zalo" : String(t ?? "");
|
|
447
|
+
function Ye(t) {
|
|
448
|
+
return t === "facebook" ? "Facebook" : t === "instagram" ? "Instagram" : t === "telegram" ? "Telegram" : t === "zalo" ? "Zalo" : t === "livechat" ? "Live Chat" : String(t ?? "");
|
|
408
449
|
}
|
|
409
|
-
const
|
|
450
|
+
const Pt = (t) => {
|
|
410
451
|
var r;
|
|
411
452
|
const i = {
|
|
412
453
|
"application/pdf": "PDF",
|
|
@@ -417,68 +458,85 @@ const Tt = (t) => {
|
|
|
417
458
|
};
|
|
418
459
|
return t ? i[t] ?? ((r = t.split("/")[1]) == null ? void 0 : r.toUpperCase()) ?? "Tệp" : "Tệp đính kèm";
|
|
419
460
|
};
|
|
420
|
-
function
|
|
421
|
-
return t === "read" ? /* @__PURE__ */ e(
|
|
461
|
+
function _e({ status: t }) {
|
|
462
|
+
return t === "read" ? /* @__PURE__ */ e(Ge, { size: 11, strokeWidth: 2, style: { display: "inline", verticalAlign: "middle" } }) : t === "delivered" ? /* @__PURE__ */ e(Ge, { size: 11, strokeWidth: 2, style: { display: "inline", verticalAlign: "middle", opacity: 0.5 } }) : t === "sent" ? /* @__PURE__ */ e(ot, { size: 11, strokeWidth: 2, style: { display: "inline", verticalAlign: "middle" } }) : null;
|
|
422
463
|
}
|
|
423
|
-
const
|
|
424
|
-
var
|
|
425
|
-
const
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
const
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
464
|
+
const pn = Le(function({ apiUrl: i, token: r, theme: o, height: s, defaultConversationId: C, disableAttachments: m, disableNotificationSound: O, hideKeyboardHint: f, locale: S = "vi", extensions: B, onNewMessage: I, onConversationSelect: H }, $) {
|
|
465
|
+
var c, y, b, M, Z;
|
|
466
|
+
const E = ee(new Mt(i, r)), [j, A] = g([]), [F, K] = g([]), [ne, U] = g(), [w, _] = g(), k = ee(void 0), [L, ce] = g(""), [z, D] = g({ provider: "all", unreadOnly: !1 }), [le, v] = g(!1), Q = ee(null), N = ee(null), [x, J] = g(null), [se, h] = g(!0), [T, P] = g(""), [q, ie] = g(() => !!(B != null && B.length)), [re, V] = g(280), [ye, ke] = g(!1), [be, ue] = g(0), G = (o == null ? void 0 : o.primaryColor) ?? "#2563eb", de = Ee(() => new Map(F.map((l) => [l.id, l])), [F]), me = ee(null), [we, Oe] = g(0), Se = We(async (l, u) => {
|
|
467
|
+
l.contactId && await E.current.patchContact(l.contactId, u), A((R) => R.map((W) => W.id === l.id ? { ...W, contactExternalId: u ?? void 0 } : W)), _((R) => R && R.id === l.id ? { ...R, contactExternalId: u ?? void 0 } : R), ue((R) => R + 1);
|
|
468
|
+
}, []), Ce = We(() => {
|
|
469
|
+
ue((l) => l + 1);
|
|
470
|
+
}, []), Ie = Ee(() => {
|
|
471
|
+
const l = new Set(F.map((u) => u.provider));
|
|
472
|
+
return ["facebook", "instagram", "telegram", "zalo", "livechat"].filter((u) => l.has(u));
|
|
473
|
+
}, [F]), pe = Ee(() => {
|
|
474
|
+
var u;
|
|
475
|
+
const l = {};
|
|
476
|
+
for (const R of j) {
|
|
477
|
+
const W = ((u = de.get(R.connectionId)) == null ? void 0 : u.provider) ?? "unknown";
|
|
478
|
+
l[W] = (l[W] ?? 0) + 1;
|
|
434
479
|
}
|
|
435
|
-
return
|
|
436
|
-
}, [j,
|
|
480
|
+
return l;
|
|
481
|
+
}, [j, de]);
|
|
482
|
+
function Me(l) {
|
|
483
|
+
const u = l.clientX, R = re;
|
|
484
|
+
ke(!0), document.body.style.cursor = "col-resize", document.body.style.userSelect = "none";
|
|
485
|
+
function W(xe) {
|
|
486
|
+
const Re = Math.max(200, Math.min(480, R + (u - xe.clientX)));
|
|
487
|
+
V(Re);
|
|
488
|
+
}
|
|
489
|
+
function fe() {
|
|
490
|
+
ke(!1), document.body.style.cursor = "", document.body.style.userSelect = "", document.removeEventListener("mousemove", W), document.removeEventListener("mouseup", fe);
|
|
491
|
+
}
|
|
492
|
+
document.addEventListener("mousemove", W), document.addEventListener("mouseup", fe);
|
|
493
|
+
}
|
|
494
|
+
const oe = We(async (l) => {
|
|
437
495
|
try {
|
|
438
|
-
const
|
|
439
|
-
|
|
440
|
-
} catch (
|
|
441
|
-
|
|
496
|
+
const u = await E.current.listConversations(l);
|
|
497
|
+
A((R) => l ? [...R, ...u.items] : u.items), U(u.nextCursor), !l && u.items.length && _((R) => R ?? (C ? u.items.find((W) => W.id === C) ?? u.items[0] : u.items[0])), P("");
|
|
498
|
+
} catch (u) {
|
|
499
|
+
P(u instanceof Error ? u.message : "Không tải được hội thoại");
|
|
442
500
|
} finally {
|
|
443
|
-
|
|
501
|
+
h(!1);
|
|
444
502
|
}
|
|
445
|
-
}, [
|
|
446
|
-
|
|
447
|
-
}),
|
|
448
|
-
if (
|
|
449
|
-
if (
|
|
450
|
-
const
|
|
451
|
-
if ((
|
|
452
|
-
const
|
|
453
|
-
|
|
454
|
-
|
|
503
|
+
}, [C]);
|
|
504
|
+
Y(() => (E.current.listConnections().then(K).catch(() => {
|
|
505
|
+
}), oe(), E.current.connectSSE((u, R) => {
|
|
506
|
+
if (u === "message.new" || u === "conversation.updated") {
|
|
507
|
+
if (oe(), u === "message.new") {
|
|
508
|
+
const W = typeof R == "object" && R ? R : {}, fe = W.conversationId ? String(W.conversationId) : "", xe = W.messageId ? String(W.messageId) : "";
|
|
509
|
+
if ((W.direction ? String(W.direction) : "") === "inbound" && !O && Ut(), fe && fe === k.current && xe && me.current) {
|
|
510
|
+
const ft = me.current;
|
|
511
|
+
E.current.getMessage(xe).then((gt) => {
|
|
512
|
+
ft(gt);
|
|
455
513
|
}).catch(() => {
|
|
456
514
|
});
|
|
457
515
|
}
|
|
458
|
-
I == null || I(
|
|
516
|
+
I == null || I(fe || k.current || "");
|
|
459
517
|
}
|
|
460
|
-
} else
|
|
461
|
-
})), [
|
|
462
|
-
|
|
463
|
-
}, [
|
|
464
|
-
|
|
518
|
+
} else u === "message.status_updated" && Oe((W) => W + 1);
|
|
519
|
+
})), [oe, I]), Y(() => {
|
|
520
|
+
k.current = w == null ? void 0 : w.id;
|
|
521
|
+
}, [w]), Y(() => {
|
|
522
|
+
w != null && w.unreadCount && E.current.markRead(w.id).then(() => oe()).catch(() => {
|
|
465
523
|
});
|
|
466
|
-
}, [
|
|
467
|
-
if (!
|
|
468
|
-
function
|
|
469
|
-
var
|
|
470
|
-
(
|
|
524
|
+
}, [w == null ? void 0 : w.id]), Y(() => {
|
|
525
|
+
if (!le) return;
|
|
526
|
+
function l(u) {
|
|
527
|
+
var R, W;
|
|
528
|
+
(R = Q.current) != null && R.contains(u.target) || (W = N.current) != null && W.contains(u.target) || v(!1);
|
|
471
529
|
}
|
|
472
|
-
return document.addEventListener("mousedown",
|
|
473
|
-
}, [
|
|
474
|
-
const
|
|
475
|
-
const
|
|
476
|
-
return j.filter((
|
|
477
|
-
var
|
|
478
|
-
const
|
|
479
|
-
return
|
|
530
|
+
return document.addEventListener("mousedown", l), () => document.removeEventListener("mousedown", l);
|
|
531
|
+
}, [le]);
|
|
532
|
+
const ze = Ee(() => {
|
|
533
|
+
const l = L.toLowerCase().trim();
|
|
534
|
+
return j.filter((u) => {
|
|
535
|
+
var Re;
|
|
536
|
+
const R = `${u.contactName ?? ""} ${u.subject ?? ""} ${u.providerConversationKey}`.toLowerCase(), W = ((Re = de.get(u.connectionId)) == null ? void 0 : Re.provider) ?? "unknown", fe = z.provider === "all" || W === z.provider, xe = !z.unreadOnly || (u.unreadCount ?? 0) > 0;
|
|
537
|
+
return fe && xe && (!l || R.includes(l));
|
|
480
538
|
});
|
|
481
|
-
}, [j,
|
|
539
|
+
}, [j, de, z, L]), Te = z.provider !== "all" || z.unreadOnly, ae = S === "en" ? {
|
|
482
540
|
today: "TODAY",
|
|
483
541
|
loadOlder: "↑ Load older messages",
|
|
484
542
|
loading: "Loading messages…",
|
|
@@ -499,357 +557,383 @@ const Zt = ke(function({ apiUrl: i, token: r, theme: o, height: c, defaultConver
|
|
|
499
557
|
send: "Gửi",
|
|
500
558
|
all: "Tất cả"
|
|
501
559
|
};
|
|
502
|
-
|
|
503
|
-
openConversation: (
|
|
504
|
-
const
|
|
505
|
-
|
|
560
|
+
yt($, () => ({
|
|
561
|
+
openConversation: (l) => {
|
|
562
|
+
const u = j.find((R) => R.id === l);
|
|
563
|
+
u && _(u);
|
|
506
564
|
},
|
|
507
|
-
refresh: () => void
|
|
508
|
-
}), [j,
|
|
509
|
-
const
|
|
510
|
-
...
|
|
511
|
-
height:
|
|
512
|
-
...
|
|
565
|
+
refresh: () => void oe()
|
|
566
|
+
}), [j, oe]);
|
|
567
|
+
const He = {
|
|
568
|
+
...p.frame,
|
|
569
|
+
height: s ?? 620,
|
|
570
|
+
...s ? { maxHeight: "none" } : {},
|
|
513
571
|
fontFamily: (o == null ? void 0 : o.fontFamily) ?? "Inter, ui-sans-serif, system-ui, sans-serif",
|
|
514
572
|
borderRadius: (o == null ? void 0 : o.borderRadius) ?? "16px",
|
|
515
|
-
gridTemplateColumns:
|
|
516
|
-
transition: "grid-template-columns 220ms ease"
|
|
573
|
+
gridTemplateColumns: q ? `minmax(260px, 300px) minmax(0, 1fr) ${re}px` : "minmax(260px, 300px) minmax(0, 1fr)",
|
|
574
|
+
transition: ye ? "none" : "grid-template-columns 220ms ease"
|
|
517
575
|
};
|
|
518
|
-
return
|
|
519
|
-
/* @__PURE__ */ e(
|
|
576
|
+
return se ? /* @__PURE__ */ n("div", { style: { ...p.state, borderRadius: (o == null ? void 0 : o.borderRadius) ?? "16px" }, children: [
|
|
577
|
+
/* @__PURE__ */ e(Fe, {}),
|
|
520
578
|
" Đang tải hộp thư…"
|
|
521
|
-
] }) :
|
|
522
|
-
/* @__PURE__ */ e(
|
|
579
|
+
] }) : T && !j.length ? /* @__PURE__ */ n("div", { style: { ...p.state, color: "#b42318", borderRadius: (o == null ? void 0 : o.borderRadius) ?? "16px" }, children: [
|
|
580
|
+
/* @__PURE__ */ e(St, { size: 16, strokeWidth: 2 }),
|
|
523
581
|
" ",
|
|
524
|
-
|
|
525
|
-
/* @__PURE__ */ e("button", { style:
|
|
526
|
-
|
|
582
|
+
T,
|
|
583
|
+
/* @__PURE__ */ e("button", { style: p.retry, onClick: () => {
|
|
584
|
+
h(!0), oe();
|
|
527
585
|
}, children: "Thử lại" })
|
|
528
|
-
] }) : /* @__PURE__ */ e(
|
|
529
|
-
const
|
|
586
|
+
] }) : /* @__PURE__ */ e(qe.Provider, { value: i, children: /* @__PURE__ */ e(st.Provider, { value: r, children: /* @__PURE__ */ n("div", { style: He, onFocusCapture: () => {
|
|
587
|
+
const l = window.scrollY;
|
|
530
588
|
requestAnimationFrame(() => {
|
|
531
|
-
window.scrollY !==
|
|
589
|
+
window.scrollY !== l && window.scrollTo({ top: l, behavior: "instant" });
|
|
532
590
|
});
|
|
533
591
|
}, children: [
|
|
534
|
-
/* @__PURE__ */ n("aside", { style:
|
|
535
|
-
/* @__PURE__ */ n("div", { style:
|
|
536
|
-
/* @__PURE__ */ e("div", { style: { ...
|
|
592
|
+
/* @__PURE__ */ n("aside", { style: p.sidebar, children: [
|
|
593
|
+
/* @__PURE__ */ n("div", { style: p.brand, children: [
|
|
594
|
+
/* @__PURE__ */ e("div", { style: { ...p.brandMark, background: G, overflow: "hidden", padding: 0 }, children: (c = o == null ? void 0 : o.branding) != null && c.logoUrl ? /* @__PURE__ */ e("img", { src: o.branding.logoUrl, alt: "", style: { width: "100%", height: "100%", objectFit: "cover" } }) : ((y = o == null ? void 0 : o.branding) == null ? void 0 : y.mark) ?? "C" }),
|
|
537
595
|
/* @__PURE__ */ n("div", { children: [
|
|
538
|
-
/* @__PURE__ */ e("strong", { children: ((
|
|
539
|
-
!((
|
|
596
|
+
/* @__PURE__ */ e("strong", { children: ((b = o == null ? void 0 : o.branding) == null ? void 0 : b.name) ?? "Hộp thư" }),
|
|
597
|
+
!((M = o == null ? void 0 : o.branding) != null && M.name) && /* @__PURE__ */ e("span", { style: p.eyebrow, children: "CHANNELHUB" })
|
|
540
598
|
] }),
|
|
541
|
-
/* @__PURE__ */ e(
|
|
599
|
+
/* @__PURE__ */ e(Ht, { "aria-label": "Tùy chọn", style: p.iconButton, children: /* @__PURE__ */ e(at, { size: 16, strokeWidth: 2 }) })
|
|
542
600
|
] }),
|
|
543
|
-
/* @__PURE__ */ n("div", { style:
|
|
544
|
-
/* @__PURE__ */ e(
|
|
545
|
-
/* @__PURE__ */ e(
|
|
546
|
-
|
|
601
|
+
/* @__PURE__ */ n("div", { style: p.search, children: [
|
|
602
|
+
/* @__PURE__ */ e(Xe, { size: 16, strokeWidth: 2 }),
|
|
603
|
+
/* @__PURE__ */ e(Et, { "aria-label": ae.searchPlaceholder, value: L, onChange: (l) => ce(l.target.value), placeholder: ae.searchPlaceholder }),
|
|
604
|
+
L && /* @__PURE__ */ e("button", { style: p.clear, onClick: () => ce(""), "aria-label": "Xóa tìm kiếm", children: "×" })
|
|
547
605
|
] }),
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
/* @__PURE__ */ e(
|
|
551
|
-
|
|
552
|
-
/* @__PURE__ */ e("button", { style: { border: 0, background: "none", cursor: "pointer", color:
|
|
606
|
+
Te && /* @__PURE__ */ n("div", { style: { display: "flex", gap: 4, flexWrap: "wrap", padding: "0 14px 8px" }, children: [
|
|
607
|
+
z.provider !== "all" && /* @__PURE__ */ n("span", { style: { display: "inline-flex", alignItems: "center", gap: 4, background: "#eef2ff", color: G, borderRadius: 6, fontSize: 11, padding: "2px 8px", fontWeight: 500 }, children: [
|
|
608
|
+
/* @__PURE__ */ e($e, { provider: z.provider }),
|
|
609
|
+
Ye(z.provider),
|
|
610
|
+
/* @__PURE__ */ e("button", { style: { border: 0, background: "none", cursor: "pointer", color: G, padding: 0, lineHeight: 1, display: "flex" }, onClick: () => D((l) => ({ ...l, provider: "all" })), "aria-label": "Xóa filter kênh", children: /* @__PURE__ */ e(je, { size: 10 }) })
|
|
553
611
|
] }),
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
/* @__PURE__ */ e("button", { style: { border: 0, background: "none", cursor: "pointer", color:
|
|
612
|
+
z.unreadOnly && /* @__PURE__ */ n("span", { style: { display: "inline-flex", alignItems: "center", gap: 4, background: "#eef2ff", color: G, borderRadius: 6, fontSize: 11, padding: "2px 8px", fontWeight: 500 }, children: [
|
|
613
|
+
ae.unreadOnly,
|
|
614
|
+
/* @__PURE__ */ e("button", { style: { border: 0, background: "none", cursor: "pointer", color: G, padding: 0, lineHeight: 1, display: "flex" }, onClick: () => D((l) => ({ ...l, unreadOnly: !1 })), "aria-label": "Xóa filter chưa đọc", children: /* @__PURE__ */ e(je, { size: 10 }) })
|
|
557
615
|
] }),
|
|
558
|
-
/* @__PURE__ */ e("button", { style: { border: 0, background: "none", cursor: "pointer", color: d.muted, fontSize: 11, padding: "2px 4px" }, onClick: () =>
|
|
616
|
+
/* @__PURE__ */ e("button", { style: { border: 0, background: "none", cursor: "pointer", color: d.muted, fontSize: 11, padding: "2px 4px" }, onClick: () => D({ provider: "all", unreadOnly: !1 }), children: "Xóa tất cả" })
|
|
559
617
|
] }),
|
|
560
|
-
/* @__PURE__ */ n("div", { style:
|
|
618
|
+
/* @__PURE__ */ n("div", { style: p.listHeader, children: [
|
|
561
619
|
/* @__PURE__ */ n("span", { children: [
|
|
562
|
-
|
|
620
|
+
ze.length,
|
|
563
621
|
" hội thoại"
|
|
564
622
|
] }),
|
|
565
623
|
/* @__PURE__ */ e(
|
|
566
624
|
"button",
|
|
567
625
|
{
|
|
568
|
-
ref:
|
|
569
|
-
style: { ...
|
|
626
|
+
ref: Q,
|
|
627
|
+
style: { ...p.iconButton, background: Te ? `${G}14` : "transparent", color: Te ? G : d.muted },
|
|
570
628
|
"aria-label": "Bộ lọc",
|
|
571
629
|
onClick: () => {
|
|
572
|
-
var
|
|
573
|
-
if (!
|
|
574
|
-
const
|
|
575
|
-
|
|
630
|
+
var l;
|
|
631
|
+
if (!le) {
|
|
632
|
+
const u = (l = Q.current) == null ? void 0 : l.getBoundingClientRect();
|
|
633
|
+
u && J({ top: u.bottom + 6, left: u.left });
|
|
576
634
|
}
|
|
577
|
-
|
|
635
|
+
v((u) => !u);
|
|
578
636
|
},
|
|
579
|
-
children: /* @__PURE__ */ e(
|
|
637
|
+
children: /* @__PURE__ */ e(Wt, { size: 15, strokeWidth: 2 })
|
|
580
638
|
}
|
|
581
639
|
)
|
|
582
640
|
] }),
|
|
583
|
-
|
|
641
|
+
le && x && it(
|
|
584
642
|
/* @__PURE__ */ n(
|
|
585
643
|
"div",
|
|
586
644
|
{
|
|
587
|
-
ref:
|
|
588
|
-
style: { position: "fixed", top:
|
|
645
|
+
ref: N,
|
|
646
|
+
style: { position: "fixed", top: x.top, left: x.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 },
|
|
589
647
|
children: [
|
|
590
648
|
/* @__PURE__ */ e("div", { style: { fontSize: 10, fontWeight: 700, color: d.muted, letterSpacing: 1, textTransform: "uppercase", marginBottom: 8 }, children: "Kênh" }),
|
|
591
|
-
["all", ...
|
|
592
|
-
/* @__PURE__ */ e("input", { type: "radio", name: "provider-filter", checked:
|
|
593
|
-
|
|
594
|
-
|
|
649
|
+
["all", ...Ie].map((l) => /* @__PURE__ */ n("label", { style: { display: "flex", alignItems: "center", gap: 8, padding: "5px 6px", cursor: "pointer", borderRadius: 6, background: z.provider === l ? `${G}0f` : "transparent" }, children: [
|
|
650
|
+
/* @__PURE__ */ e("input", { type: "radio", name: "provider-filter", checked: z.provider === l, onChange: () => D((u) => ({ ...u, provider: l })), style: { accentColor: G } }),
|
|
651
|
+
l === "all" ? /* @__PURE__ */ n("span", { style: { color: d.ink }, children: [
|
|
652
|
+
ae.all,
|
|
595
653
|
" (",
|
|
596
654
|
j.length,
|
|
597
655
|
")"
|
|
598
656
|
] }) : /* @__PURE__ */ n("span", { style: { display: "flex", alignItems: "center", gap: 5, color: d.ink }, children: [
|
|
599
|
-
/* @__PURE__ */ e(
|
|
600
|
-
|
|
657
|
+
/* @__PURE__ */ e($e, { provider: l }),
|
|
658
|
+
Ye(l),
|
|
601
659
|
" ",
|
|
602
660
|
/* @__PURE__ */ n("span", { style: { color: d.muted }, children: [
|
|
603
661
|
"(",
|
|
604
|
-
|
|
662
|
+
pe[l] ?? 0,
|
|
605
663
|
")"
|
|
606
664
|
] })
|
|
607
665
|
] })
|
|
608
|
-
] },
|
|
666
|
+
] }, l)),
|
|
609
667
|
/* @__PURE__ */ e("div", { style: { borderTop: `1px solid ${d.line}`, margin: "8px 0 6px" } }),
|
|
610
|
-
/* @__PURE__ */ n("label", { style: { display: "flex", alignItems: "center", gap: 8, padding: "5px 6px", cursor: "pointer", borderRadius: 6, background:
|
|
611
|
-
/* @__PURE__ */ e("input", { type: "checkbox", checked:
|
|
612
|
-
/* @__PURE__ */ e("span", { style: { color: d.ink }, children:
|
|
668
|
+
/* @__PURE__ */ n("label", { style: { display: "flex", alignItems: "center", gap: 8, padding: "5px 6px", cursor: "pointer", borderRadius: 6, background: z.unreadOnly ? `${G}0f` : "transparent" }, children: [
|
|
669
|
+
/* @__PURE__ */ e("input", { type: "checkbox", checked: z.unreadOnly, onChange: (l) => D((u) => ({ ...u, unreadOnly: l.target.checked })), style: { accentColor: G } }),
|
|
670
|
+
/* @__PURE__ */ e("span", { style: { color: d.ink }, children: ae.unreadOnly })
|
|
613
671
|
] })
|
|
614
672
|
]
|
|
615
673
|
}
|
|
616
674
|
),
|
|
617
675
|
document.body
|
|
618
676
|
),
|
|
619
|
-
/* @__PURE__ */ n(
|
|
620
|
-
|
|
621
|
-
var
|
|
622
|
-
return /* @__PURE__ */ e(
|
|
623
|
-
|
|
677
|
+
/* @__PURE__ */ n(ct, { style: p.conversationList, children: [
|
|
678
|
+
ze.map((l) => {
|
|
679
|
+
var u;
|
|
680
|
+
return /* @__PURE__ */ e(Nt, { conversation: l, provider: (u = de.get(l.connectionId)) == null ? void 0 : u.provider, selected: (w == null ? void 0 : w.id) === l.id, primary: G, onSelect: () => {
|
|
681
|
+
_(l), H == null || H(l.id), E.current.markRead(l.id).then(() => oe()).catch(() => {
|
|
624
682
|
});
|
|
625
|
-
} },
|
|
683
|
+
} }, l.id);
|
|
626
684
|
}),
|
|
627
|
-
!
|
|
628
|
-
/* @__PURE__ */ e("div", { style:
|
|
685
|
+
!ze.length && /* @__PURE__ */ n("div", { style: p.emptySmall, children: [
|
|
686
|
+
/* @__PURE__ */ e("div", { style: p.emptyIcon, children: /* @__PURE__ */ e(Xe, { size: 16, strokeWidth: 2 }) }),
|
|
629
687
|
/* @__PURE__ */ e("strong", { children: "Không tìm thấy" }),
|
|
630
688
|
/* @__PURE__ */ e("span", { children: "Thử từ khóa hoặc bộ lọc khác." })
|
|
631
689
|
] }),
|
|
632
|
-
|
|
690
|
+
ne && /* @__PURE__ */ e("button", { style: p.loadMore, onClick: () => void oe(ne), children: "Xem thêm hội thoại" })
|
|
633
691
|
] })
|
|
634
692
|
] }),
|
|
635
|
-
/* @__PURE__ */ e("main", { style:
|
|
636
|
-
|
|
693
|
+
/* @__PURE__ */ e("main", { style: p.main, children: w ? /* @__PURE__ */ e(
|
|
694
|
+
Ft,
|
|
637
695
|
{
|
|
638
|
-
conversation:
|
|
639
|
-
provider: (
|
|
640
|
-
connection:
|
|
641
|
-
client:
|
|
642
|
-
primary:
|
|
643
|
-
error:
|
|
644
|
-
onRegisterAppend: (
|
|
645
|
-
|
|
696
|
+
conversation: w,
|
|
697
|
+
provider: (Z = de.get(w.connectionId)) == null ? void 0 : Z.provider,
|
|
698
|
+
connection: de.get(w.connectionId),
|
|
699
|
+
client: E.current,
|
|
700
|
+
primary: G,
|
|
701
|
+
error: T,
|
|
702
|
+
onRegisterAppend: (l) => {
|
|
703
|
+
me.current = l;
|
|
646
704
|
},
|
|
647
|
-
refreshKey:
|
|
648
|
-
infoOpen:
|
|
649
|
-
onToggleInfo: () =>
|
|
650
|
-
t:
|
|
651
|
-
disableAttachments:
|
|
652
|
-
hideKeyboardHint: f
|
|
705
|
+
refreshKey: we,
|
|
706
|
+
infoOpen: q,
|
|
707
|
+
onToggleInfo: () => ie((l) => !l),
|
|
708
|
+
t: ae,
|
|
709
|
+
disableAttachments: m,
|
|
710
|
+
hideKeyboardHint: f,
|
|
711
|
+
extensions: B,
|
|
712
|
+
onLinkContact: (l) => Se(w, l),
|
|
713
|
+
onRefreshContactInfo: Ce
|
|
653
714
|
},
|
|
654
|
-
|
|
655
|
-
) : /* @__PURE__ */ e(
|
|
656
|
-
|
|
657
|
-
|
|
715
|
+
w.id
|
|
716
|
+
) : /* @__PURE__ */ e(Gt, {}) }),
|
|
717
|
+
q && w && /* @__PURE__ */ e(
|
|
718
|
+
qt,
|
|
658
719
|
{
|
|
659
|
-
conversation:
|
|
660
|
-
connection:
|
|
661
|
-
primary:
|
|
662
|
-
onClose: () =>
|
|
663
|
-
client:
|
|
720
|
+
conversation: w,
|
|
721
|
+
connection: de.get(w.connectionId),
|
|
722
|
+
primary: G,
|
|
723
|
+
onClose: () => ie(!1),
|
|
724
|
+
client: E.current,
|
|
725
|
+
onStartResize: Me,
|
|
726
|
+
extensions: B,
|
|
727
|
+
extRefreshKey: be,
|
|
728
|
+
onLinkContact: (l) => Se(w, l),
|
|
729
|
+
onRefreshContactInfo: Ce
|
|
664
730
|
}
|
|
665
731
|
)
|
|
666
732
|
] }) }) });
|
|
667
733
|
});
|
|
668
|
-
function
|
|
669
|
-
const [
|
|
670
|
-
let
|
|
671
|
-
r ?
|
|
672
|
-
const
|
|
673
|
-
...
|
|
674
|
-
background:
|
|
675
|
-
...r ? { boxShadow: `inset 3px 0 0 ${o}` } : f > 0 && !
|
|
734
|
+
function Nt({ conversation: t, provider: i, selected: r, primary: o, onSelect: s }) {
|
|
735
|
+
const [C, m] = g(!1), O = t.contactName ?? t.subject ?? t.providerConversationKey, f = t.unreadCount ?? 0, S = t.lastMessageText ?? "", B = t.lastMessageDirection === "outbound" ? "Bạn: " : "", I = S.length > 60 ? S.slice(0, 60) + "…" : S, H = S ? B + I : "";
|
|
736
|
+
let $ = "transparent";
|
|
737
|
+
r ? $ = "#eef2ff" : C ? $ = "#f7f9fc" : f > 0 && ($ = "#f0f4ff");
|
|
738
|
+
const E = {
|
|
739
|
+
...p.row,
|
|
740
|
+
background: $,
|
|
741
|
+
...r ? { boxShadow: `inset 3px 0 0 ${o}` } : f > 0 && !C ? { boxShadow: `inset 3px 0 0 ${o}` } : {}
|
|
676
742
|
};
|
|
677
743
|
return /* @__PURE__ */ n(
|
|
678
744
|
"button",
|
|
679
745
|
{
|
|
680
|
-
onClick:
|
|
681
|
-
style:
|
|
682
|
-
onMouseEnter: () =>
|
|
683
|
-
onMouseLeave: () =>
|
|
746
|
+
onClick: s,
|
|
747
|
+
style: E,
|
|
748
|
+
onMouseEnter: () => m(!0),
|
|
749
|
+
onMouseLeave: () => m(!1),
|
|
684
750
|
children: [
|
|
685
|
-
/* @__PURE__ */ e(
|
|
686
|
-
/* @__PURE__ */ n("span", { style:
|
|
687
|
-
/* @__PURE__ */ n("span", { style:
|
|
688
|
-
/* @__PURE__ */ e("strong", { style: { minWidth: 0, overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap", fontWeight: f > 0 ? 700 : 500 }, children:
|
|
751
|
+
/* @__PURE__ */ e(pt, { name: O, color: o, image: t.contactPictureUrl, provider: i }),
|
|
752
|
+
/* @__PURE__ */ n("span", { style: p.rowBody, children: [
|
|
753
|
+
/* @__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: O }),
|
|
689
755
|
/* @__PURE__ */ n("span", { style: { display: "flex", alignItems: "center", gap: 4, flexShrink: 0 }, children: [
|
|
690
|
-
/* @__PURE__ */ e("time", { style: { color: d.muted, fontSize: 11, whiteSpace: "nowrap" }, children:
|
|
691
|
-
f > 0 && /* @__PURE__ */ e("span", { "aria-label": `${f} tin nhắn chưa đọc`, style:
|
|
756
|
+
/* @__PURE__ */ e("time", { style: { color: d.muted, fontSize: 11, whiteSpace: "nowrap" }, children: Ke(t.lastMessageAt) }),
|
|
757
|
+
f > 0 && /* @__PURE__ */ e("span", { "aria-label": `${f} tin nhắn chưa đọc`, style: p.unreadBadge, children: f > 99 ? "99+" : f })
|
|
692
758
|
] })
|
|
693
759
|
] }),
|
|
694
|
-
/* @__PURE__ */ e("span", { style: { ...
|
|
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: H || /* @__PURE__ */ e("span", { style: { opacity: 0.5 }, children: "Chưa có tin nhắn" }) }) })
|
|
695
761
|
] })
|
|
696
762
|
]
|
|
697
763
|
}
|
|
698
764
|
);
|
|
699
765
|
}
|
|
700
|
-
function
|
|
701
|
-
var
|
|
702
|
-
const [
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
}, [
|
|
706
|
-
if (!
|
|
707
|
-
function
|
|
708
|
-
var
|
|
709
|
-
(
|
|
766
|
+
function Ft({ conversation: t, provider: i, connection: r, client: o, primary: s, error: C, onRegisterAppend: m, refreshKey: O, infoOpen: f, onToggleInfo: S, t: B, disableAttachments: I, hideKeyboardHint: H, extensions: $, onLinkContact: E, onRefreshContactInfo: j }) {
|
|
767
|
+
var He;
|
|
768
|
+
const [A, F] = g([]), [K, ne] = g(), [U, w] = g(""), [_, k] = g(!0), [L, ce] = g(!1), [z, D] = g(""), le = ee(null), v = t.contactName ?? t.subject ?? t.providerConversationKey, Q = ee(null), N = ee(null), [x, J] = g(null), [se, h] = g(!1), [T, P] = g(!1), [q, ie] = g(!1), [re, V] = g(0), ye = ee(null), ke = ee(null), be = ee(null), [ue, G] = g(!1), [de, me] = g(""), [we, Oe] = g([]), Se = ee(null), Ce = ee(null);
|
|
769
|
+
Y(() => () => {
|
|
770
|
+
x != null && x.objectUrl && URL.revokeObjectURL(x.objectUrl);
|
|
771
|
+
}, [x == null ? void 0 : x.objectUrl]), Y(() => {
|
|
772
|
+
if (!q) return;
|
|
773
|
+
function c(y) {
|
|
774
|
+
var b, M;
|
|
775
|
+
(b = ke.current) != null && b.contains(y.target) || (M = ye.current) != null && M.contains(y.target) || ie(!1);
|
|
710
776
|
}
|
|
711
|
-
return document.addEventListener("mousedown",
|
|
712
|
-
}, [
|
|
713
|
-
o.listCannedResponses().then(
|
|
777
|
+
return document.addEventListener("mousedown", c), () => document.removeEventListener("mousedown", c);
|
|
778
|
+
}, [q]), Y(() => {
|
|
779
|
+
o.listCannedResponses().then(Oe).catch(() => {
|
|
714
780
|
});
|
|
715
|
-
}, [o]),
|
|
716
|
-
if (!
|
|
717
|
-
function
|
|
718
|
-
var
|
|
719
|
-
(
|
|
781
|
+
}, [o]), Y(() => {
|
|
782
|
+
if (!ue) return;
|
|
783
|
+
function c(y) {
|
|
784
|
+
var b, M;
|
|
785
|
+
(b = Ce.current) != null && b.contains(y.target) || (M = Se.current) != null && M.contains(y.target) || G(!1);
|
|
720
786
|
}
|
|
721
|
-
return document.addEventListener("mousedown",
|
|
722
|
-
}, [
|
|
723
|
-
const
|
|
724
|
-
|
|
787
|
+
return document.addEventListener("mousedown", c), () => document.removeEventListener("mousedown", c);
|
|
788
|
+
}, [ue]);
|
|
789
|
+
const Ie = ee(!0), pe = We(async (c, y) => {
|
|
790
|
+
y || (Ie.current = !c);
|
|
725
791
|
try {
|
|
726
|
-
const
|
|
727
|
-
|
|
728
|
-
} catch (
|
|
729
|
-
|
|
792
|
+
const b = await o.listMessages(t.id, c);
|
|
793
|
+
F((M) => c ? [...b.items, ...M] : b.items), ne(b.nextCursor);
|
|
794
|
+
} catch (b) {
|
|
795
|
+
D(b instanceof Error ? b.message : "Không tải được tin nhắn");
|
|
730
796
|
} finally {
|
|
731
|
-
|
|
797
|
+
y || k(!1);
|
|
732
798
|
}
|
|
733
799
|
}, [o, t.id]);
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
}, [
|
|
737
|
-
|
|
738
|
-
}, [
|
|
739
|
-
|
|
740
|
-
const
|
|
741
|
-
|
|
800
|
+
Y(() => {
|
|
801
|
+
k(!0), pe();
|
|
802
|
+
}, [pe]), Y(() => {
|
|
803
|
+
O && pe(void 0, !0);
|
|
804
|
+
}, [O]), Y(() => {
|
|
805
|
+
Ie.current && requestAnimationFrame(() => {
|
|
806
|
+
const c = le.current;
|
|
807
|
+
c && (c.scrollTop = c.scrollHeight);
|
|
742
808
|
});
|
|
743
|
-
}, [
|
|
744
|
-
|
|
809
|
+
}, [A]), Y(() => (m == null || m((c) => {
|
|
810
|
+
Ie.current = !0, F((y) => y.some((b) => b.id === c.id) ? y : [...y, c]);
|
|
745
811
|
}), () => {
|
|
746
|
-
|
|
747
|
-
}), [
|
|
748
|
-
async function
|
|
749
|
-
var
|
|
750
|
-
const
|
|
751
|
-
if (!
|
|
752
|
-
|
|
753
|
-
const
|
|
754
|
-
|
|
812
|
+
m == null || m(null);
|
|
813
|
+
}), [m]);
|
|
814
|
+
async function Me(c) {
|
|
815
|
+
var M;
|
|
816
|
+
const y = (M = c.target.files) == null ? void 0 : M[0];
|
|
817
|
+
if (!y) return;
|
|
818
|
+
c.target.value = "";
|
|
819
|
+
const b = URL.createObjectURL(y);
|
|
820
|
+
J({ file: y, uploading: !0, objectUrl: b });
|
|
755
821
|
try {
|
|
756
|
-
const
|
|
757
|
-
|
|
822
|
+
const Z = await o.uploadAttachment(y);
|
|
823
|
+
J({ file: y, uploading: !1, url: Z.url, mimeType: Z.mimeType, attachmentType: Z.attachmentType, objectUrl: b });
|
|
758
824
|
} catch {
|
|
759
|
-
URL.revokeObjectURL(
|
|
825
|
+
URL.revokeObjectURL(b), J(null), D("Không tải lên được tệp đính kèm");
|
|
760
826
|
}
|
|
761
827
|
}
|
|
762
|
-
async function
|
|
763
|
-
|
|
764
|
-
const
|
|
765
|
-
if (!(!
|
|
766
|
-
|
|
828
|
+
async function oe(c) {
|
|
829
|
+
c.preventDefault();
|
|
830
|
+
const y = U.trim(), b = x != null && x.url ? [{ url: x.url, mimeType: x.mimeType ?? "application/octet-stream", type: x.attachmentType }] : [];
|
|
831
|
+
if (!(!y && !b.length || L)) {
|
|
832
|
+
ce(!0), D("");
|
|
767
833
|
try {
|
|
768
|
-
await o.sendMessage(t.id,
|
|
769
|
-
} catch (
|
|
770
|
-
|
|
834
|
+
await o.sendMessage(t.id, y || void 0, b.length ? b : void 0), x != null && x.objectUrl && URL.revokeObjectURL(x.objectUrl), w(""), J(null), await pe();
|
|
835
|
+
} catch (M) {
|
|
836
|
+
D(M instanceof Error ? M.message : "Không gửi được tin nhắn");
|
|
771
837
|
} finally {
|
|
772
|
-
|
|
838
|
+
ce(!1);
|
|
773
839
|
}
|
|
774
840
|
}
|
|
775
841
|
}
|
|
776
|
-
function
|
|
777
|
-
const
|
|
778
|
-
if (!
|
|
779
|
-
|
|
842
|
+
function ze(c) {
|
|
843
|
+
const y = be.current;
|
|
844
|
+
if (!y) {
|
|
845
|
+
w((l) => l + c), ie(!1);
|
|
780
846
|
return;
|
|
781
847
|
}
|
|
782
|
-
const
|
|
783
|
-
|
|
784
|
-
|
|
848
|
+
const b = y.selectionStart ?? U.length, M = y.selectionEnd ?? U.length, Z = U.slice(0, b) + c + U.slice(M);
|
|
849
|
+
w(Z), ie(!1), requestAnimationFrame(() => {
|
|
850
|
+
y.focus(), y.selectionStart = y.selectionEnd = b + c.length;
|
|
785
851
|
});
|
|
786
852
|
}
|
|
787
|
-
function
|
|
788
|
-
|
|
789
|
-
const
|
|
790
|
-
|
|
853
|
+
function Te(c) {
|
|
854
|
+
w(c), G(!1), me(""), requestAnimationFrame(() => {
|
|
855
|
+
const y = be.current;
|
|
856
|
+
y && (y.focus(), y.selectionStart = y.selectionEnd = c.length);
|
|
791
857
|
});
|
|
792
858
|
}
|
|
793
|
-
const
|
|
794
|
-
return /* @__PURE__ */ n("section", { style:
|
|
795
|
-
/* @__PURE__ */ n("header", { style:
|
|
796
|
-
/* @__PURE__ */ e(
|
|
797
|
-
/* @__PURE__ */ n("div", { style:
|
|
798
|
-
/* @__PURE__ */ e("strong", { style:
|
|
799
|
-
/* @__PURE__ */ e("span", { style:
|
|
859
|
+
const ae = !L && (U.trim().length > 0 || (x == null ? void 0 : x.url) != null && !x.uploading);
|
|
860
|
+
return /* @__PURE__ */ n("section", { style: p.chat, children: [
|
|
861
|
+
/* @__PURE__ */ n("header", { style: p.chatHeader, children: [
|
|
862
|
+
/* @__PURE__ */ e(pt, { name: v, color: s, image: t.contactPictureUrl, provider: i }),
|
|
863
|
+
/* @__PURE__ */ n("div", { style: p.contact, children: [
|
|
864
|
+
/* @__PURE__ */ e("strong", { style: p.contactName, children: v }),
|
|
865
|
+
/* @__PURE__ */ e("span", { style: p.contactMeta, children: Dt(r) ?? ht(i) })
|
|
800
866
|
] }),
|
|
801
|
-
/* @__PURE__ */ n("div", { style:
|
|
802
|
-
/* @__PURE__ */ e("button", { style:
|
|
867
|
+
/* @__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(at, { size: 16, strokeWidth: 2 }) }),
|
|
803
869
|
/* @__PURE__ */ e(
|
|
804
870
|
"button",
|
|
805
871
|
{
|
|
806
872
|
style: {
|
|
807
|
-
...
|
|
808
|
-
background: f ? `${
|
|
809
|
-
color: f ?
|
|
873
|
+
...p.iconButton,
|
|
874
|
+
background: f ? `${s}14` : "transparent",
|
|
875
|
+
color: f ? s : d.muted
|
|
810
876
|
},
|
|
811
877
|
"aria-label": "Thông tin liên hệ",
|
|
812
|
-
onClick:
|
|
813
|
-
children: /* @__PURE__ */ e(
|
|
878
|
+
onClick: S,
|
|
879
|
+
children: /* @__PURE__ */ e(zt, { size: 16, strokeWidth: 2 })
|
|
814
880
|
}
|
|
815
881
|
)
|
|
816
882
|
] })
|
|
817
883
|
] }),
|
|
818
|
-
/* @__PURE__ */ n(
|
|
819
|
-
/* @__PURE__ */ e("div", { style:
|
|
820
|
-
K && /* @__PURE__ */ e("button", { onClick: () => void
|
|
821
|
-
|
|
822
|
-
/* @__PURE__ */ e(
|
|
884
|
+
/* @__PURE__ */ n(ct, { ref: le, style: p.messageArea, children: [
|
|
885
|
+
/* @__PURE__ */ e("div", { style: p.day, children: B.today }),
|
|
886
|
+
K && /* @__PURE__ */ e("button", { onClick: () => void pe(K), style: p.historyButton, children: B.loadOlder }),
|
|
887
|
+
_ && /* @__PURE__ */ n("div", { style: p.messageHint, children: [
|
|
888
|
+
/* @__PURE__ */ e(Fe, {}),
|
|
823
889
|
" ",
|
|
824
|
-
|
|
890
|
+
B.loading
|
|
825
891
|
] }),
|
|
826
|
-
!
|
|
827
|
-
|
|
892
|
+
!_ && !A.length && /* @__PURE__ */ e("div", { style: p.messageHint, children: B.noMessages }),
|
|
893
|
+
A.map((c, y) => {
|
|
894
|
+
const b = ($ == null ? void 0 : $.flatMap((l) => l.messageEnrichments ?? [])) ?? [], M = c.direction === "inbound" && b.length > 0 && y >= A.length - 15, Z = M ? Ae(t, {
|
|
895
|
+
provider: i,
|
|
896
|
+
recentMessages: A.slice(-10),
|
|
897
|
+
linkContact: E,
|
|
898
|
+
refreshContactInfo: j,
|
|
899
|
+
sendMessage: async (l, u) => {
|
|
900
|
+
await o.sendMessage(t.id, l, u), await pe(void 0, !0);
|
|
901
|
+
}
|
|
902
|
+
}) : null;
|
|
903
|
+
return /* @__PURE__ */ n("div", { children: [
|
|
904
|
+
/* @__PURE__ */ e(Kt, { message: c, primary: s }),
|
|
905
|
+
M && Z && b.map((l, u) => {
|
|
906
|
+
var W;
|
|
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);
|
|
911
|
+
})
|
|
828
912
|
] }),
|
|
829
|
-
/* @__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((
|
|
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((c) => /* @__PURE__ */ e(
|
|
830
914
|
"button",
|
|
831
915
|
{
|
|
832
916
|
type: "button",
|
|
833
|
-
onClick: () =>
|
|
917
|
+
onClick: () => w(c),
|
|
834
918
|
style: {
|
|
835
919
|
fontSize: 11,
|
|
836
920
|
padding: "3px 10px",
|
|
837
921
|
borderRadius: 999,
|
|
838
|
-
background: `${
|
|
839
|
-
color:
|
|
840
|
-
border: `1px solid ${
|
|
922
|
+
background: `${s}0f`,
|
|
923
|
+
color: s,
|
|
924
|
+
border: `1px solid ${s}33`,
|
|
841
925
|
cursor: "pointer",
|
|
842
926
|
whiteSpace: "nowrap"
|
|
843
927
|
},
|
|
844
|
-
children:
|
|
928
|
+
children: c
|
|
845
929
|
},
|
|
846
|
-
|
|
930
|
+
c
|
|
847
931
|
)) }),
|
|
848
|
-
/* @__PURE__ */ n("form", { onSubmit:
|
|
849
|
-
|
|
932
|
+
/* @__PURE__ */ n("form", { onSubmit: oe, style: { flex: "0 0 auto", padding: "8px 14px 12px", borderTop: `1px solid ${d.line}`, background: d.white, position: "relative" }, children: [
|
|
933
|
+
q && /* @__PURE__ */ n(
|
|
850
934
|
"div",
|
|
851
935
|
{
|
|
852
|
-
ref:
|
|
936
|
+
ref: ye,
|
|
853
937
|
style: {
|
|
854
938
|
position: "absolute",
|
|
855
939
|
bottom: "calc(100% + 6px)",
|
|
@@ -864,11 +948,11 @@ function Bt({ conversation: t, provider: i, connection: r, client: o, primary: c
|
|
|
864
948
|
fontFamily: "inherit"
|
|
865
949
|
},
|
|
866
950
|
children: [
|
|
867
|
-
/* @__PURE__ */ e("div", { style: { display: "flex", borderBottom: `1px solid ${d.line}`, background: "#f9fafb" }, children:
|
|
951
|
+
/* @__PURE__ */ e("div", { style: { display: "flex", borderBottom: `1px solid ${d.line}`, background: "#f9fafb" }, children: Je.map((c, y) => /* @__PURE__ */ e(
|
|
868
952
|
"button",
|
|
869
953
|
{
|
|
870
954
|
type: "button",
|
|
871
|
-
onClick: () =>
|
|
955
|
+
onClick: () => V(y),
|
|
872
956
|
style: {
|
|
873
957
|
flex: 1,
|
|
874
958
|
border: 0,
|
|
@@ -877,19 +961,19 @@ function Bt({ conversation: t, provider: i, connection: r, client: o, primary: c
|
|
|
877
961
|
fontSize: 16,
|
|
878
962
|
cursor: "pointer",
|
|
879
963
|
lineHeight: 1,
|
|
880
|
-
borderBottom:
|
|
881
|
-
opacity:
|
|
964
|
+
borderBottom: re === y ? `2px solid ${s}` : "2px solid transparent",
|
|
965
|
+
opacity: re === y ? 1 : 0.5,
|
|
882
966
|
transition: "opacity 100ms ease"
|
|
883
967
|
},
|
|
884
|
-
children:
|
|
968
|
+
children: c.icon
|
|
885
969
|
},
|
|
886
|
-
|
|
970
|
+
y
|
|
887
971
|
)) }),
|
|
888
|
-
/* @__PURE__ */ e("div", { style: { display: "grid", gridTemplateColumns: "repeat(8, 1fr)", gap: 2, padding: 8, maxHeight: 180, overflowY: "auto" }, children: (
|
|
972
|
+
/* @__PURE__ */ e("div", { style: { display: "grid", gridTemplateColumns: "repeat(8, 1fr)", gap: 2, padding: 8, maxHeight: 180, overflowY: "auto" }, children: (He = Je[re]) == null ? void 0 : He.emojis.map((c, y) => /* @__PURE__ */ e(
|
|
889
973
|
"button",
|
|
890
974
|
{
|
|
891
975
|
type: "button",
|
|
892
|
-
onClick: () =>
|
|
976
|
+
onClick: () => ze(c),
|
|
893
977
|
style: {
|
|
894
978
|
border: 0,
|
|
895
979
|
background: "transparent",
|
|
@@ -900,23 +984,23 @@ function Bt({ conversation: t, provider: i, connection: r, client: o, primary: c
|
|
|
900
984
|
lineHeight: 1,
|
|
901
985
|
transition: "background 80ms ease"
|
|
902
986
|
},
|
|
903
|
-
onMouseEnter: (
|
|
904
|
-
|
|
987
|
+
onMouseEnter: (b) => {
|
|
988
|
+
b.target.style.background = "#f3f4f6";
|
|
905
989
|
},
|
|
906
|
-
onMouseLeave: (
|
|
907
|
-
|
|
990
|
+
onMouseLeave: (b) => {
|
|
991
|
+
b.target.style.background = "transparent";
|
|
908
992
|
},
|
|
909
|
-
children:
|
|
993
|
+
children: c
|
|
910
994
|
},
|
|
911
|
-
|
|
995
|
+
y
|
|
912
996
|
)) })
|
|
913
997
|
]
|
|
914
998
|
}
|
|
915
999
|
),
|
|
916
|
-
|
|
1000
|
+
ue && /* @__PURE__ */ n(
|
|
917
1001
|
"div",
|
|
918
1002
|
{
|
|
919
|
-
ref:
|
|
1003
|
+
ref: Se,
|
|
920
1004
|
style: {
|
|
921
1005
|
position: "absolute",
|
|
922
1006
|
bottom: "calc(100% + 6px)",
|
|
@@ -937,90 +1021,90 @@ function Bt({ conversation: t, provider: i, connection: r, client: o, primary: c
|
|
|
937
1021
|
autoFocus: !0,
|
|
938
1022
|
type: "text",
|
|
939
1023
|
placeholder: "Tìm template…",
|
|
940
|
-
value:
|
|
941
|
-
onChange: (
|
|
1024
|
+
value: de,
|
|
1025
|
+
onChange: (c) => me(c.target.value),
|
|
942
1026
|
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 }
|
|
943
1027
|
}
|
|
944
1028
|
) }),
|
|
945
1029
|
/* @__PURE__ */ e("div", { style: { maxHeight: 220, overflowY: "auto" }, children: (() => {
|
|
946
|
-
const
|
|
947
|
-
return
|
|
1030
|
+
const c = de.trim().toLowerCase(), y = c ? we.filter((b) => b.title.toLowerCase().includes(c) || b.content.toLowerCase().includes(c) || (b.shortcut ?? "").toLowerCase().includes(c)) : we;
|
|
1031
|
+
return y.length ? y.map((b) => /* @__PURE__ */ n(
|
|
948
1032
|
"button",
|
|
949
1033
|
{
|
|
950
1034
|
type: "button",
|
|
951
|
-
onClick: () =>
|
|
1035
|
+
onClick: () => Te(b.content),
|
|
952
1036
|
style: { display: "block", width: "100%", textAlign: "left", border: 0, borderBottom: `1px solid ${d.line}`, background: "transparent", padding: "9px 12px", cursor: "pointer", fontFamily: "inherit" },
|
|
953
|
-
onMouseEnter: (
|
|
954
|
-
|
|
1037
|
+
onMouseEnter: (M) => {
|
|
1038
|
+
M.currentTarget.style.background = "#f7f9fc";
|
|
955
1039
|
},
|
|
956
|
-
onMouseLeave: (
|
|
957
|
-
|
|
1040
|
+
onMouseLeave: (M) => {
|
|
1041
|
+
M.currentTarget.style.background = "transparent";
|
|
958
1042
|
},
|
|
959
1043
|
children: [
|
|
960
1044
|
/* @__PURE__ */ n("div", { style: { display: "flex", alignItems: "center", gap: 6, marginBottom: 2 }, children: [
|
|
961
|
-
/* @__PURE__ */ e("span", { style: { fontSize: 12, fontWeight: 600, color: d.ink }, children:
|
|
962
|
-
|
|
1045
|
+
/* @__PURE__ */ e("span", { style: { fontSize: 12, fontWeight: 600, color: d.ink }, children: b.title }),
|
|
1046
|
+
b.shortcut && /* @__PURE__ */ e("span", { style: { fontSize: 10, color: s, background: `${s}18`, borderRadius: 4, padding: "1px 5px" }, children: b.shortcut })
|
|
963
1047
|
] }),
|
|
964
|
-
/* @__PURE__ */ e("div", { style: { fontSize: 11, color: d.muted, overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" }, children:
|
|
1048
|
+
/* @__PURE__ */ e("div", { style: { fontSize: 11, color: d.muted, overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" }, children: b.content })
|
|
965
1049
|
]
|
|
966
1050
|
},
|
|
967
|
-
|
|
968
|
-
)) : /* @__PURE__ */ e("div", { style: { padding: "24px 16px", textAlign: "center", color: d.muted, fontSize: 12 }, children:
|
|
1051
|
+
b.id
|
|
1052
|
+
)) : /* @__PURE__ */ e("div", { style: { padding: "24px 16px", textAlign: "center", color: d.muted, fontSize: 12 }, children: we.length === 0 ? "Chưa có template nào" : "Không tìm thấy" });
|
|
969
1053
|
})() })
|
|
970
1054
|
]
|
|
971
1055
|
}
|
|
972
1056
|
),
|
|
973
1057
|
/* @__PURE__ */ n("div", { style: { border: `1.5px solid ${d.line}`, borderRadius: 12, background: d.white, overflow: "hidden" }, children: [
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
/* @__PURE__ */ e(
|
|
1058
|
+
x && /* @__PURE__ */ n("div", { style: { display: "flex", alignItems: "center", gap: 8, padding: "8px 12px", borderBottom: `1px solid ${d.line}`, fontSize: 12 }, children: [
|
|
1059
|
+
x.uploading ? /* @__PURE__ */ n(te, { children: [
|
|
1060
|
+
/* @__PURE__ */ e(Fe, {}),
|
|
977
1061
|
/* @__PURE__ */ e("span", { style: { color: d.muted }, children: "Đang tải lên…" })
|
|
978
|
-
] }) :
|
|
1062
|
+
] }) : x.attachmentType === "image" && x.objectUrl ? /* @__PURE__ */ e("img", { src: x.objectUrl, alt: "", style: { height: 48, width: 48, objectFit: "cover", borderRadius: 6 } }) : /* @__PURE__ */ n("span", { style: { color: d.muted }, children: [
|
|
979
1063
|
"📎 ",
|
|
980
|
-
|
|
1064
|
+
x.file.name,
|
|
981
1065
|
" (",
|
|
982
|
-
Math.round(
|
|
1066
|
+
Math.round(x.file.size / 1024),
|
|
983
1067
|
" KB)"
|
|
984
1068
|
] }),
|
|
985
|
-
!
|
|
986
|
-
|
|
1069
|
+
!x.uploading && /* @__PURE__ */ e("button", { type: "button", onClick: () => {
|
|
1070
|
+
x != null && x.objectUrl && URL.revokeObjectURL(x.objectUrl), J(null);
|
|
987
1071
|
}, style: { marginLeft: "auto", border: 0, background: "none", color: d.muted, cursor: "pointer", fontSize: 16 }, "aria-label": "Xóa tệp đính kèm", children: "✕" })
|
|
988
1072
|
] }),
|
|
989
1073
|
/* @__PURE__ */ n("div", { style: { display: "flex", alignItems: "center", gap: 2, padding: "4px 8px", borderBottom: "1px solid #f3f4f6" }, children: [
|
|
990
1074
|
/* @__PURE__ */ e(
|
|
991
1075
|
"button",
|
|
992
1076
|
{
|
|
993
|
-
ref:
|
|
1077
|
+
ref: ke,
|
|
994
1078
|
type: "button",
|
|
995
1079
|
title: "Chèn emoji",
|
|
996
|
-
onClick: () =>
|
|
997
|
-
style: { ...
|
|
998
|
-
children: /* @__PURE__ */ e(
|
|
1080
|
+
onClick: () => ie((c) => !c),
|
|
1081
|
+
style: { ...p.toolbarBtn, background: q ? `${s}18` : "transparent", color: q ? s : "#9ca3af" },
|
|
1082
|
+
children: /* @__PURE__ */ e($t, { size: 13, strokeWidth: 2 })
|
|
999
1083
|
}
|
|
1000
1084
|
),
|
|
1001
|
-
!
|
|
1002
|
-
var
|
|
1003
|
-
return (
|
|
1004
|
-
}, children: /* @__PURE__ */ e(
|
|
1005
|
-
!
|
|
1006
|
-
var
|
|
1007
|
-
return (
|
|
1008
|
-
}, children: /* @__PURE__ */ e(
|
|
1009
|
-
!
|
|
1010
|
-
/* @__PURE__ */ e("input", { ref:
|
|
1011
|
-
/* @__PURE__ */ e("input", { ref:
|
|
1085
|
+
!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 c;
|
|
1087
|
+
return (c = Q.current) == null ? void 0 : c.click();
|
|
1088
|
+
}, children: /* @__PURE__ */ e(Ct, { size: 13, strokeWidth: 2 }) }),
|
|
1089
|
+
!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 c;
|
|
1091
|
+
return (c = N.current) == null ? void 0 : c.click();
|
|
1092
|
+
}, children: /* @__PURE__ */ e(Tt, { size: 13, strokeWidth: 2 }) }),
|
|
1093
|
+
!I && /* @__PURE__ */ n(te, { children: [
|
|
1094
|
+
/* @__PURE__ */ e("input", { ref: Q, type: "file", style: { display: "none" }, onChange: Me, accept: "image/*,video/mp4" }),
|
|
1095
|
+
/* @__PURE__ */ e("input", { ref: N, 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" })
|
|
1012
1096
|
] }),
|
|
1013
1097
|
/* @__PURE__ */ e(
|
|
1014
1098
|
"button",
|
|
1015
1099
|
{
|
|
1016
|
-
ref:
|
|
1100
|
+
ref: Ce,
|
|
1017
1101
|
type: "button",
|
|
1018
1102
|
title: "Template nhanh",
|
|
1019
1103
|
onClick: () => {
|
|
1020
|
-
|
|
1104
|
+
G((c) => !c), me("");
|
|
1021
1105
|
},
|
|
1022
|
-
style: { ...
|
|
1023
|
-
children: /* @__PURE__ */ e(
|
|
1106
|
+
style: { ...p.toolbarBtn, background: ue ? `${s}18` : "transparent", color: ue ? s : "#9ca3af" },
|
|
1107
|
+
children: /* @__PURE__ */ e(Lt, { size: 13, strokeWidth: 2 })
|
|
1024
1108
|
}
|
|
1025
1109
|
),
|
|
1026
1110
|
/* @__PURE__ */ e("span", { style: { width: 1, height: 14, background: "#e5e7eb", margin: "0 2px" } }),
|
|
@@ -1029,8 +1113,8 @@ function Bt({ conversation: t, provider: i, connection: r, client: o, primary: c
|
|
|
1029
1113
|
{
|
|
1030
1114
|
type: "button",
|
|
1031
1115
|
title: "In đậm",
|
|
1032
|
-
onClick: () =>
|
|
1033
|
-
style: { ...
|
|
1116
|
+
onClick: () => h((c) => !c),
|
|
1117
|
+
style: { ...p.toolbarBtn, fontWeight: 700, fontSize: 12, background: se ? `${s}18` : "transparent", color: se ? s : "#9ca3af", border: se ? `1px solid ${s}33` : "1px solid transparent" },
|
|
1034
1118
|
children: "B"
|
|
1035
1119
|
}
|
|
1036
1120
|
),
|
|
@@ -1039,24 +1123,52 @@ function Bt({ conversation: t, provider: i, connection: r, client: o, primary: c
|
|
|
1039
1123
|
{
|
|
1040
1124
|
type: "button",
|
|
1041
1125
|
title: "Nghiêng",
|
|
1042
|
-
onClick: () =>
|
|
1043
|
-
style: { ...
|
|
1126
|
+
onClick: () => P((c) => !c),
|
|
1127
|
+
style: { ...p.toolbarBtn, fontStyle: "italic", fontSize: 12, background: T ? `${s}18` : "transparent", color: T ? s : "#9ca3af", border: T ? `1px solid ${s}33` : "1px solid transparent" },
|
|
1044
1128
|
children: "I"
|
|
1045
1129
|
}
|
|
1046
|
-
)
|
|
1130
|
+
),
|
|
1131
|
+
$ == null ? void 0 : $.flatMap((c) => c.toolbarActions ?? []).map((c, y) => /* @__PURE__ */ e(
|
|
1132
|
+
"button",
|
|
1133
|
+
{
|
|
1134
|
+
type: "button",
|
|
1135
|
+
title: c.tooltip,
|
|
1136
|
+
style: p.toolbarBtn,
|
|
1137
|
+
onClick: () => {
|
|
1138
|
+
const b = (Z) => {
|
|
1139
|
+
w((l) => l && !l.endsWith(" ") && !l.endsWith(`
|
|
1140
|
+
`) ? `${l} ${Z}` : `${l}${Z}`), requestAnimationFrame(() => {
|
|
1141
|
+
var l;
|
|
1142
|
+
return (l = be.current) == null ? void 0 : l.focus();
|
|
1143
|
+
});
|
|
1144
|
+
}, M = Ae(t, {
|
|
1145
|
+
provider: i,
|
|
1146
|
+
recentMessages: A.slice(-10),
|
|
1147
|
+
linkContact: E,
|
|
1148
|
+
refreshContactInfo: j,
|
|
1149
|
+
sendMessage: async (Z, l) => {
|
|
1150
|
+
await o.sendMessage(t.id, Z, l), await pe(void 0, !0);
|
|
1151
|
+
}
|
|
1152
|
+
});
|
|
1153
|
+
c.onClick({ ...M, insertText: b });
|
|
1154
|
+
},
|
|
1155
|
+
children: c.icon
|
|
1156
|
+
},
|
|
1157
|
+
y
|
|
1158
|
+
))
|
|
1047
1159
|
] }),
|
|
1048
1160
|
/* @__PURE__ */ e(
|
|
1049
|
-
|
|
1161
|
+
jt,
|
|
1050
1162
|
{
|
|
1051
|
-
ref:
|
|
1163
|
+
ref: be,
|
|
1052
1164
|
"aria-label": "Soạn tin nhắn",
|
|
1053
1165
|
rows: 2,
|
|
1054
|
-
value:
|
|
1055
|
-
onChange: (
|
|
1056
|
-
onKeyDown: (
|
|
1057
|
-
|
|
1166
|
+
value: U,
|
|
1167
|
+
onChange: (c) => w(c.target.value),
|
|
1168
|
+
onKeyDown: (c) => {
|
|
1169
|
+
c.key === "Enter" && !c.shiftKey && (c.preventDefault(), oe(c));
|
|
1058
1170
|
},
|
|
1059
|
-
placeholder:
|
|
1171
|
+
placeholder: B.sendPlaceholder,
|
|
1060
1172
|
style: {
|
|
1061
1173
|
display: "block",
|
|
1062
1174
|
width: "100%",
|
|
@@ -1073,26 +1185,26 @@ function Bt({ conversation: t, provider: i, connection: r, client: o, primary: c
|
|
|
1073
1185
|
font: "inherit",
|
|
1074
1186
|
fontSize: 13,
|
|
1075
1187
|
lineHeight: 1.45,
|
|
1076
|
-
fontStyle:
|
|
1077
|
-
fontWeight:
|
|
1188
|
+
fontStyle: T ? "italic" : "normal",
|
|
1189
|
+
fontWeight: se ? 700 : 400
|
|
1078
1190
|
}
|
|
1079
1191
|
}
|
|
1080
1192
|
),
|
|
1081
1193
|
/* @__PURE__ */ n("div", { style: { display: "flex", alignItems: "center", justifyContent: "space-between", padding: "4px 8px 6px 12px" }, children: [
|
|
1082
1194
|
/* @__PURE__ */ n("span", { style: {
|
|
1083
1195
|
fontSize: 11,
|
|
1084
|
-
color:
|
|
1085
|
-
fontWeight:
|
|
1196
|
+
color: U.length > 1e3 ? "#ef4444" : U.length > 900 ? "#f59e0b" : "#9ca3af",
|
|
1197
|
+
fontWeight: U.length > 1e3 ? 600 : 400
|
|
1086
1198
|
}, children: [
|
|
1087
|
-
|
|
1199
|
+
U.length,
|
|
1088
1200
|
"/1000"
|
|
1089
1201
|
] }),
|
|
1090
1202
|
/* @__PURE__ */ n("div", { style: { display: "flex", alignItems: "center", gap: 6 }, children: [
|
|
1091
|
-
!
|
|
1203
|
+
!H && /* @__PURE__ */ e("span", { style: { fontSize: 10, color: "#9ca3af" }, children: "↵ Gửi · ⇧↵ Xuống dòng" }),
|
|
1092
1204
|
/* @__PURE__ */ n(
|
|
1093
1205
|
"button",
|
|
1094
1206
|
{
|
|
1095
|
-
disabled: !
|
|
1207
|
+
disabled: !ae,
|
|
1096
1208
|
"aria-label": "Gửi tin nhắn",
|
|
1097
1209
|
style: {
|
|
1098
1210
|
display: "flex",
|
|
@@ -1103,15 +1215,15 @@ function Bt({ conversation: t, provider: i, connection: r, client: o, primary: c
|
|
|
1103
1215
|
borderRadius: 999,
|
|
1104
1216
|
fontSize: 12,
|
|
1105
1217
|
fontWeight: 600,
|
|
1106
|
-
background:
|
|
1107
|
-
color:
|
|
1108
|
-
cursor:
|
|
1109
|
-
boxShadow:
|
|
1218
|
+
background: ae ? `linear-gradient(135deg,${s},#0ea5e9)` : "#e5e7eb",
|
|
1219
|
+
color: ae ? "#fff" : "#9ca3af",
|
|
1220
|
+
cursor: ae ? "pointer" : "not-allowed",
|
|
1221
|
+
boxShadow: ae ? "0 2px 8px rgba(37,99,235,0.25)" : "none",
|
|
1110
1222
|
transition: "all 150ms ease"
|
|
1111
1223
|
},
|
|
1112
1224
|
children: [
|
|
1113
|
-
|
|
1114
|
-
|
|
1225
|
+
L ? /* @__PURE__ */ e(lt, { size: 12, style: { animation: "channelhub-spin .7s linear infinite" } }) : /* @__PURE__ */ e(Bt, { size: 12, strokeWidth: 2 }),
|
|
1226
|
+
B.send
|
|
1115
1227
|
]
|
|
1116
1228
|
}
|
|
1117
1229
|
)
|
|
@@ -1119,163 +1231,264 @@ function Bt({ conversation: t, provider: i, connection: r, client: o, primary: c
|
|
|
1119
1231
|
] })
|
|
1120
1232
|
] })
|
|
1121
1233
|
] }),
|
|
1122
|
-
(
|
|
1234
|
+
(z || C) && /* @__PURE__ */ e("div", { role: "alert", style: p.error, children: z || C })
|
|
1123
1235
|
] });
|
|
1124
1236
|
}
|
|
1125
|
-
function
|
|
1126
|
-
var
|
|
1127
|
-
const r =
|
|
1128
|
-
|
|
1129
|
-
|
|
1237
|
+
function Kt({ message: t, primary: i }) {
|
|
1238
|
+
var K, ne, U, w, _;
|
|
1239
|
+
const r = Ne(qe), o = Ne(st), s = (k) => k.startsWith("/v1/media/proxy") ? `${r}${k}&tok=${encodeURIComponent(o)}` : k, C = t.direction === "outbound", m = ((K = t.attachments) == null ? void 0 : K.filter((k) => k.type === "image")) ?? [], O = ((ne = t.attachments) == null ? void 0 : ne.filter((k) => k.type === "sticker")) ?? [], f = ((U = t.attachments) == null ? void 0 : U.filter((k) => k.type === "video")) ?? [], S = ((w = t.attachments) == null ? void 0 : w.filter((k) => k.type === "audio")) ?? [], B = ((_ = t.attachments) == null ? void 0 : _.filter((k) => k.type === "file")) ?? [], [I, H] = g(null), $ = C ? "flex-end" : "flex-start", E = /* @__PURE__ */ n("time", { style: { display: "block", marginTop: 4, fontSize: 10, opacity: 0.65, textAlign: "right", letterSpacing: 0.2, userSelect: "none" }, children: [
|
|
1240
|
+
Ke(t.occurredAt, !0),
|
|
1241
|
+
C && /* @__PURE__ */ n(te, { children: [
|
|
1130
1242
|
" ",
|
|
1131
|
-
/* @__PURE__ */ e(
|
|
1243
|
+
/* @__PURE__ */ e(_e, { status: t.status })
|
|
1132
1244
|
] })
|
|
1133
|
-
] }),
|
|
1134
|
-
|
|
1135
|
-
|
|
1245
|
+
] }), j = /* @__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
|
+
Ke(t.occurredAt, !0),
|
|
1247
|
+
C && /* @__PURE__ */ n(te, { children: [
|
|
1136
1248
|
" ",
|
|
1137
|
-
/* @__PURE__ */ e(
|
|
1249
|
+
/* @__PURE__ */ e(_e, { status: t.status })
|
|
1138
1250
|
] })
|
|
1139
|
-
] }) }),
|
|
1140
|
-
return /* @__PURE__ */ n("div", { style: { ...
|
|
1141
|
-
|
|
1142
|
-
/* @__PURE__ */ e("img", { src:
|
|
1143
|
-
|
|
1144
|
-
] }, `s${
|
|
1145
|
-
|
|
1146
|
-
/* @__PURE__ */ e("img", { src:
|
|
1147
|
-
|
|
1148
|
-
] },
|
|
1149
|
-
f.map((
|
|
1150
|
-
/* @__PURE__ */ e("video", { src:
|
|
1151
|
-
/* @__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(
|
|
1152
|
-
|
|
1153
|
-
] },
|
|
1154
|
-
(
|
|
1155
|
-
|
|
1156
|
-
|
|
1251
|
+
] }) }), A = C ? { ...p.bubbleOut, background: i, color: "#fff", border: "1px solid transparent" } : p.bubbleIn, F = !t.text && S.length === 0 && B.length === 0;
|
|
1252
|
+
return /* @__PURE__ */ n("div", { style: { ...p.messageLine, justifyContent: $, flexDirection: "column", alignItems: $ }, children: [
|
|
1253
|
+
O.map((k, L) => /* @__PURE__ */ n("div", { style: { position: "relative", marginBottom: 2 }, children: [
|
|
1254
|
+
/* @__PURE__ */ e("img", { src: s(k.url), alt: "sticker", style: { display: "block", maxWidth: 128, maxHeight: 128, objectFit: "contain" } }),
|
|
1255
|
+
F && m.length === 0 && f.length === 0 && L === O.length - 1 && j
|
|
1256
|
+
] }, `s${L}`)),
|
|
1257
|
+
m.map((k, L) => /* @__PURE__ */ n("div", { style: { position: "relative", marginBottom: 2, cursor: "zoom-in" }, onClick: () => H({ url: s(k.url), kind: "image" }), children: [
|
|
1258
|
+
/* @__PURE__ */ e("img", { src: s(k.url), alt: "", style: { display: "block", maxWidth: 260, maxHeight: 260, borderRadius: 12, objectFit: "cover" } }),
|
|
1259
|
+
F && L === m.length - 1 && f.length === 0 && j
|
|
1260
|
+
] }, L)),
|
|
1261
|
+
f.map((k, L) => /* @__PURE__ */ n("div", { style: { position: "relative", marginBottom: 2, cursor: "pointer" }, onClick: () => H({ url: s(k.url), kind: "video" }), children: [
|
|
1262
|
+
/* @__PURE__ */ e("video", { src: s(k.url), style: { display: "block", maxWidth: 260, maxHeight: 200, borderRadius: 12, objectFit: "cover" } }),
|
|
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(Rt, { size: 16, fill: "#172033", color: "#172033", style: { marginLeft: 2 } }) }) }),
|
|
1264
|
+
F && L === f.length - 1 && j
|
|
1265
|
+
] }, L)),
|
|
1266
|
+
(S.length > 0 || B.length > 0 || t.text || !m.length && !f.length && !O.length && !t.text) && /* @__PURE__ */ n("div", { style: A, children: [
|
|
1267
|
+
S.map((k, L) => /* @__PURE__ */ e("audio", { src: s(k.url), controls: !0, style: { display: "block", width: "100%", marginBottom: 4 } }, L)),
|
|
1268
|
+
B.map((k, L) => /* @__PURE__ */ n("a", { href: s(k.url), target: "_blank", rel: "noreferrer", style: { display: "block", fontSize: 12, color: C ? "#fff" : "#2563eb", textDecoration: "underline", marginBottom: 4 }, children: [
|
|
1157
1269
|
"📎 ",
|
|
1158
|
-
|
|
1159
|
-
] },
|
|
1270
|
+
Pt(k.mimeType)
|
|
1271
|
+
] }, L)),
|
|
1160
1272
|
t.text && /* @__PURE__ */ e("p", { style: { margin: 0, whiteSpace: "pre-wrap", wordBreak: "break-word" }, children: t.text }),
|
|
1161
|
-
!
|
|
1162
|
-
|
|
1273
|
+
!S.length && !B.length && !t.text && /* @__PURE__ */ e("p", { style: { margin: 0, opacity: 0.5 }, children: "[attachment]" }),
|
|
1274
|
+
E
|
|
1163
1275
|
] }),
|
|
1164
|
-
|
|
1165
|
-
/* @__PURE__ */ n("div", { onClick: () =>
|
|
1166
|
-
|
|
1167
|
-
/* @__PURE__ */ e("button", { onClick: () =>
|
|
1276
|
+
I && it(
|
|
1277
|
+
/* @__PURE__ */ n("div", { onClick: () => H(null), style: { position: "fixed", inset: 0, zIndex: 1e4, background: "rgba(0,0,0,.88)", display: "flex", alignItems: "center", justifyContent: "center", cursor: "zoom-out" }, children: [
|
|
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: (k) => k.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: (k) => k.stopPropagation() }),
|
|
1279
|
+
/* @__PURE__ */ e("button", { onClick: () => H(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 }) })
|
|
1168
1280
|
] }),
|
|
1169
1281
|
document.body
|
|
1170
1282
|
)
|
|
1171
1283
|
] });
|
|
1172
1284
|
}
|
|
1173
|
-
function
|
|
1285
|
+
function qt({
|
|
1174
1286
|
conversation: t,
|
|
1175
1287
|
connection: i,
|
|
1176
1288
|
primary: r,
|
|
1177
1289
|
onClose: o,
|
|
1178
|
-
client:
|
|
1290
|
+
client: s,
|
|
1291
|
+
onStartResize: C,
|
|
1292
|
+
extensions: m,
|
|
1293
|
+
extRefreshKey: O,
|
|
1294
|
+
onLinkContact: f,
|
|
1295
|
+
onRefreshContactInfo: S
|
|
1179
1296
|
}) {
|
|
1180
|
-
const
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1297
|
+
const B = t.contactName ?? t.subject ?? t.providerConversationKey, I = i == null ? void 0 : i.provider, H = !!(m != null && m.some((v) => v.contactInfoRows)), [$, E] = g({ channel: !0, stats: !1, extra: !0 }), j = (v) => E((Q) => ({ ...Q, [v]: !Q[v] })), [A, F] = g(""), [K, ne] = g(!1), [U, w] = g(!1), [_, k] = g(""), [L, ce] = g([]), [z, D] = g(!1);
|
|
1298
|
+
Y(() => {
|
|
1299
|
+
F(""), w(!1), k(""), s.getNote(t.id).then((v) => {
|
|
1300
|
+
v && F(v.content);
|
|
1184
1301
|
}).catch(() => {
|
|
1185
1302
|
});
|
|
1186
|
-
}, [t.id,
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1303
|
+
}, [t.id, s]), Y(() => {
|
|
1304
|
+
if (!H || !m) return;
|
|
1305
|
+
let v = !1;
|
|
1306
|
+
const Q = Ae(t, {
|
|
1307
|
+
provider: I,
|
|
1308
|
+
linkContact: f,
|
|
1309
|
+
refreshContactInfo: S,
|
|
1310
|
+
sendMessage: async (N, x) => {
|
|
1311
|
+
await s.sendMessage(t.id, N, x);
|
|
1312
|
+
}
|
|
1313
|
+
});
|
|
1314
|
+
return D(!0), Promise.allSettled(
|
|
1315
|
+
m.filter((N) => N.contactInfoRows).map((N) => N.contactInfoRows(Q))
|
|
1316
|
+
).then((N) => {
|
|
1317
|
+
if (v) return;
|
|
1318
|
+
const x = N.filter((J) => J.status === "fulfilled").flatMap((J) => J.value);
|
|
1319
|
+
ce(x), D(!1);
|
|
1320
|
+
}), () => {
|
|
1321
|
+
v = !0;
|
|
1322
|
+
};
|
|
1323
|
+
}, [t.id, t.contactExternalId, m, O, H, I, f, S, s]);
|
|
1324
|
+
async function le() {
|
|
1325
|
+
if (!(!A.trim() || K)) {
|
|
1326
|
+
ne(!0), k("");
|
|
1190
1327
|
try {
|
|
1191
|
-
await
|
|
1328
|
+
await s.upsertNote(t.id, A.trim()), w(!0), setTimeout(() => w(!1), 2e3);
|
|
1192
1329
|
} catch {
|
|
1193
|
-
|
|
1330
|
+
k("Lưu thất bại");
|
|
1194
1331
|
} finally {
|
|
1195
|
-
|
|
1332
|
+
ne(!1);
|
|
1196
1333
|
}
|
|
1197
1334
|
}
|
|
1198
1335
|
}
|
|
1199
|
-
return /* @__PURE__ */ n("aside", { style:
|
|
1200
|
-
/* @__PURE__ */
|
|
1336
|
+
return /* @__PURE__ */ n("aside", { style: { ...p.infoPanel, position: "relative" }, children: [
|
|
1337
|
+
/* @__PURE__ */ e(
|
|
1338
|
+
"div",
|
|
1339
|
+
{
|
|
1340
|
+
onMouseDown: C,
|
|
1341
|
+
style: { position: "absolute", left: 0, top: 0, bottom: 0, width: 4, cursor: "col-resize", zIndex: 1 },
|
|
1342
|
+
onMouseEnter: (v) => {
|
|
1343
|
+
v.currentTarget.style.background = "rgba(0,0,0,0.07)";
|
|
1344
|
+
},
|
|
1345
|
+
onMouseLeave: (v) => {
|
|
1346
|
+
v.currentTarget.style.background = "";
|
|
1347
|
+
}
|
|
1348
|
+
}
|
|
1349
|
+
),
|
|
1350
|
+
/* @__PURE__ */ n("div", { style: p.infoPanelHeader, children: [
|
|
1201
1351
|
/* @__PURE__ */ e("span", { style: { fontWeight: 600, fontSize: 13, color: d.ink }, children: "Thông tin liên hệ" }),
|
|
1202
|
-
/* @__PURE__ */ e("button", { style:
|
|
1352
|
+
/* @__PURE__ */ e("button", { style: p.iconButton, onClick: o, "aria-label": "Đóng", children: /* @__PURE__ */ e(je, { size: 16, strokeWidth: 2 }) })
|
|
1203
1353
|
] }),
|
|
1204
1354
|
/* @__PURE__ */ n("div", { style: { overflowY: "auto", flex: 1 }, children: [
|
|
1205
|
-
/* @__PURE__ */ n("div", { style:
|
|
1206
|
-
/* @__PURE__ */ n("span", { style: { ...
|
|
1355
|
+
/* @__PURE__ */ n("div", { style: p.infoPanelIdentity, children: [
|
|
1356
|
+
/* @__PURE__ */ n("span", { style: { ...p.avatarWrap, width: 48, height: 48 }, children: [
|
|
1207
1357
|
/* @__PURE__ */ e(
|
|
1208
|
-
|
|
1358
|
+
dt,
|
|
1209
1359
|
{
|
|
1210
1360
|
src: t.contactPictureUrl,
|
|
1211
|
-
fallback:
|
|
1212
|
-
style: { ...
|
|
1361
|
+
fallback: ut(B),
|
|
1362
|
+
style: { ...p.avatar, width: 48, height: 48, fontSize: 16 }
|
|
1213
1363
|
}
|
|
1214
1364
|
),
|
|
1215
|
-
/* @__PURE__ */ e("span", { style: { ...
|
|
1365
|
+
/* @__PURE__ */ e("span", { style: { ...p.providerBadge, width: 20, height: 20 }, children: /* @__PURE__ */ e($e, { provider: I }) })
|
|
1216
1366
|
] }),
|
|
1217
|
-
/* @__PURE__ */ e("strong", { style: { marginTop: 10, fontSize: 15, color: d.ink, textAlign: "center" }, children:
|
|
1367
|
+
/* @__PURE__ */ e("strong", { style: { marginTop: 10, fontSize: 15, color: d.ink, textAlign: "center" }, children: B }),
|
|
1218
1368
|
/* @__PURE__ */ e("span", { style: { fontSize: 11, color: d.muted, fontFamily: "monospace", textAlign: "center" }, children: t.providerConversationKey })
|
|
1219
1369
|
] }),
|
|
1220
|
-
/* @__PURE__ */ n(
|
|
1221
|
-
/* @__PURE__ */ e(
|
|
1222
|
-
/* @__PURE__ */ e(
|
|
1223
|
-
/* @__PURE__ */ e("span", { children:
|
|
1370
|
+
/* @__PURE__ */ n(Ue, { label: "KÊNH", sectionKey: "channel", expanded: $.channel, onToggle: () => j("channel"), children: [
|
|
1371
|
+
/* @__PURE__ */ e(he, { label: "Nền tảng", children: /* @__PURE__ */ n("span", { style: { display: "flex", alignItems: "center", gap: 5 }, children: [
|
|
1372
|
+
/* @__PURE__ */ e($e, { provider: I }),
|
|
1373
|
+
/* @__PURE__ */ e("span", { children: ht(I) })
|
|
1224
1374
|
] }) }),
|
|
1225
|
-
/* @__PURE__ */ n(
|
|
1375
|
+
/* @__PURE__ */ n(he, { label: "ID hội thoại", children: [
|
|
1226
1376
|
/* @__PURE__ */ n("span", { style: { fontFamily: "monospace", fontSize: 11 }, children: [
|
|
1227
1377
|
t.id.slice(0, 8),
|
|
1228
1378
|
"…"
|
|
1229
1379
|
] }),
|
|
1230
|
-
/* @__PURE__ */ e(
|
|
1380
|
+
/* @__PURE__ */ e(Vt, { value: t.id })
|
|
1231
1381
|
] })
|
|
1232
1382
|
] }),
|
|
1233
|
-
/* @__PURE__ */ n(
|
|
1234
|
-
/* @__PURE__ */ e(
|
|
1235
|
-
(t.unreadCount ?? 0) > 0 && /* @__PURE__ */ e(
|
|
1383
|
+
/* @__PURE__ */ n(Ue, { label: "THỐNG KÊ", sectionKey: "stats", expanded: $.stats, onToggle: () => j("stats"), children: [
|
|
1384
|
+
/* @__PURE__ */ e(he, { label: "Tin nhắn", value: String(t.messageCount ?? 0) }),
|
|
1385
|
+
(t.unreadCount ?? 0) > 0 && /* @__PURE__ */ e(he, { label: "Chưa đọc", value: String(t.unreadCount), valueColor: "#ef4444" }),
|
|
1236
1386
|
/* @__PURE__ */ e(
|
|
1237
|
-
|
|
1387
|
+
he,
|
|
1238
1388
|
{
|
|
1239
1389
|
label: "Gần nhất",
|
|
1240
1390
|
value: t.lastMessageAt ? new Date(t.lastMessageAt).toLocaleDateString("vi-VN", { day: "2-digit", month: "2-digit", year: "numeric" }) : "—"
|
|
1241
1391
|
}
|
|
1242
1392
|
),
|
|
1243
|
-
/* @__PURE__ */ e(
|
|
1393
|
+
/* @__PURE__ */ e(he, { label: "Lần đầu", value: "—" })
|
|
1244
1394
|
] }),
|
|
1245
|
-
/* @__PURE__ */ n(
|
|
1246
|
-
/* @__PURE__ */
|
|
1247
|
-
|
|
1248
|
-
|
|
1395
|
+
/* @__PURE__ */ n(Ue, { label: "THÔNG TIN BỔ SUNG", sectionKey: "extra", expanded: $.extra, onToggle: () => j("extra"), children: [
|
|
1396
|
+
!H && /* @__PURE__ */ n(te, { children: [
|
|
1397
|
+
/* @__PURE__ */ e(he, { label: "Điện thoại", value: "— chưa có", valueMuted: !0 }),
|
|
1398
|
+
/* @__PURE__ */ e(he, { label: "Email", value: "— chưa có", valueMuted: !0 }),
|
|
1399
|
+
/* @__PURE__ */ e(he, { label: "Nhãn", value: "— chưa có", valueMuted: !0 })
|
|
1400
|
+
] }),
|
|
1401
|
+
z && L.length === 0 && /* @__PURE__ */ e("div", { style: { fontSize: 12, color: d.muted, padding: "6px 0" }, children: "Đang tải hồ sơ CRM…" }),
|
|
1402
|
+
L.map((v) => /* @__PURE__ */ e(he, { label: v.label, children: /* @__PURE__ */ n("span", { style: { display: "inline-flex", alignItems: "center", gap: 6, flexWrap: "wrap", justifyContent: "flex-end" }, children: [
|
|
1403
|
+
v.onClick ? /* @__PURE__ */ e(
|
|
1404
|
+
"button",
|
|
1405
|
+
{
|
|
1406
|
+
type: "button",
|
|
1407
|
+
onClick: v.onClick,
|
|
1408
|
+
style: { border: 0, background: "none", padding: 0, color: r, fontSize: 12, fontWeight: 600, cursor: "pointer", textDecoration: "underline" },
|
|
1409
|
+
children: v.value
|
|
1410
|
+
}
|
|
1411
|
+
) : v.href ? /* @__PURE__ */ e("a", { href: v.href, target: "_blank", rel: "noopener noreferrer", style: { color: r, fontSize: 12, fontWeight: 600 }, children: v.value }) : /* @__PURE__ */ e("span", { style: { fontSize: 12, fontWeight: 500, color: d.ink }, children: v.value }),
|
|
1412
|
+
v.badge && /* @__PURE__ */ e(
|
|
1413
|
+
"span",
|
|
1414
|
+
{
|
|
1415
|
+
style: {
|
|
1416
|
+
fontSize: 10.5,
|
|
1417
|
+
fontWeight: 700,
|
|
1418
|
+
padding: "1px 7px",
|
|
1419
|
+
borderRadius: 999,
|
|
1420
|
+
color: v.badge.color ?? r,
|
|
1421
|
+
background: v.badge.bg ?? `${r}14`
|
|
1422
|
+
},
|
|
1423
|
+
children: v.badge.text
|
|
1424
|
+
}
|
|
1425
|
+
)
|
|
1426
|
+
] }) }, v.label))
|
|
1249
1427
|
] }),
|
|
1250
1428
|
/* @__PURE__ */ n("div", { style: { padding: "12px 16px", display: "flex", flexDirection: "column", gap: 8 }, children: [
|
|
1251
|
-
/* @__PURE__ */ e("button", { style: { ...
|
|
1252
|
-
|
|
1253
|
-
|
|
1429
|
+
!(m != null && m.length) && /* @__PURE__ */ e("button", { style: { ...p.ghostButton, color: r, borderColor: `${r}33` }, children: "Xem lịch sử" }),
|
|
1430
|
+
m == null ? void 0 : m.flatMap((v) => v.sidebarActions ?? []).map((v, Q) => {
|
|
1431
|
+
const N = v.variant === "primary";
|
|
1432
|
+
return /* @__PURE__ */ n(
|
|
1433
|
+
"button",
|
|
1434
|
+
{
|
|
1435
|
+
style: {
|
|
1436
|
+
...p.ghostButton,
|
|
1437
|
+
background: N ? r : "#fff",
|
|
1438
|
+
color: N ? "#fff" : d.ink,
|
|
1439
|
+
borderColor: N ? r : d.line,
|
|
1440
|
+
fontWeight: N ? 700 : 600,
|
|
1441
|
+
display: "flex",
|
|
1442
|
+
alignItems: "center",
|
|
1443
|
+
justifyContent: "center",
|
|
1444
|
+
gap: 6
|
|
1445
|
+
},
|
|
1446
|
+
onClick: () => {
|
|
1447
|
+
const x = Ae(t, {
|
|
1448
|
+
provider: I,
|
|
1449
|
+
linkContact: f,
|
|
1450
|
+
refreshContactInfo: S,
|
|
1451
|
+
sendMessage: async (J, se) => {
|
|
1452
|
+
await s.sendMessage(t.id, J, se);
|
|
1453
|
+
}
|
|
1454
|
+
});
|
|
1455
|
+
v.onClick(x);
|
|
1456
|
+
},
|
|
1457
|
+
children: [
|
|
1458
|
+
v.icon,
|
|
1459
|
+
v.label
|
|
1460
|
+
]
|
|
1461
|
+
},
|
|
1462
|
+
Q
|
|
1463
|
+
);
|
|
1464
|
+
}),
|
|
1465
|
+
/* @__PURE__ */ n("div", { style: { border: "1.5px solid #000", borderRadius: 10, background: "#fff", overflow: "hidden" }, children: [
|
|
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ộ" }),
|
|
1254
1467
|
/* @__PURE__ */ e(
|
|
1255
1468
|
"textarea",
|
|
1256
1469
|
{
|
|
1257
|
-
value:
|
|
1258
|
-
onChange: (
|
|
1470
|
+
value: A,
|
|
1471
|
+
onChange: (v) => F(v.target.value),
|
|
1259
1472
|
placeholder: "Nhập ghi chú...",
|
|
1260
1473
|
rows: 3,
|
|
1261
1474
|
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 }
|
|
1262
1475
|
}
|
|
1263
1476
|
),
|
|
1264
1477
|
/* @__PURE__ */ n("div", { style: { display: "flex", alignItems: "center", justifyContent: "space-between", padding: "4px 10px 6px" }, children: [
|
|
1265
|
-
|
|
1266
|
-
/* @__PURE__ */ e(
|
|
1478
|
+
U ? /* @__PURE__ */ n("span", { style: { display: "flex", alignItems: "center", gap: 4, fontSize: 11, color: "#16a34a" }, children: [
|
|
1479
|
+
/* @__PURE__ */ e(ot, { size: 11, strokeWidth: 2.5 }),
|
|
1267
1480
|
" Đã lưu"
|
|
1268
|
-
] }) :
|
|
1481
|
+
] }) : _ ? /* @__PURE__ */ e("span", { style: { fontSize: 11, color: "#ef4444" }, children: _ }) : /* @__PURE__ */ e("span", {}),
|
|
1269
1482
|
/* @__PURE__ */ e(
|
|
1270
1483
|
"button",
|
|
1271
1484
|
{
|
|
1272
1485
|
type: "button",
|
|
1273
1486
|
onClick: () => {
|
|
1274
|
-
|
|
1487
|
+
le();
|
|
1275
1488
|
},
|
|
1276
|
-
disabled: !
|
|
1277
|
-
style: { padding: "4px 12px", border: 0, borderRadius: 7, fontSize: 12, fontWeight: 600, background:
|
|
1278
|
-
children:
|
|
1489
|
+
disabled: !A.trim() || K,
|
|
1490
|
+
style: { padding: "4px 12px", border: 0, borderRadius: 7, fontSize: 12, fontWeight: 600, background: A.trim() && !K ? "linear-gradient(135deg,#f59e0b,#fbbf24)" : "#e5e7eb", color: A.trim() && !K ? "#fff" : "#9ca3af", cursor: A.trim() && !K ? "pointer" : "not-allowed" },
|
|
1491
|
+
children: K ? "Đang lưu…" : "Lưu ghi chú"
|
|
1279
1492
|
}
|
|
1280
1493
|
)
|
|
1281
1494
|
] })
|
|
@@ -1284,31 +1497,31 @@ function $t({
|
|
|
1284
1497
|
] })
|
|
1285
1498
|
] });
|
|
1286
1499
|
}
|
|
1287
|
-
function
|
|
1288
|
-
const
|
|
1500
|
+
function Ue({ label: t, children: i, sectionKey: r, expanded: o, onToggle: s }) {
|
|
1501
|
+
const C = !!s, m = o ?? !0;
|
|
1289
1502
|
return /* @__PURE__ */ n("div", { style: { borderTop: `1px solid ${d.line}` }, children: [
|
|
1290
1503
|
/* @__PURE__ */ n(
|
|
1291
1504
|
"div",
|
|
1292
1505
|
{
|
|
1293
|
-
style: { display: "flex", alignItems: "center", justifyContent: "space-between", padding: "10px 16px 6px", fontSize: 10, fontWeight: 700, letterSpacing: 1, color: d.muted, textTransform: "uppercase", cursor:
|
|
1294
|
-
onClick:
|
|
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: C ? "pointer" : "default" },
|
|
1507
|
+
onClick: s,
|
|
1295
1508
|
children: [
|
|
1296
1509
|
/* @__PURE__ */ e("span", { children: t }),
|
|
1297
|
-
|
|
1510
|
+
C && (m ? /* @__PURE__ */ e(kt, { size: 12, strokeWidth: 2 }) : /* @__PURE__ */ e(wt, { size: 12, strokeWidth: 2 }))
|
|
1298
1511
|
]
|
|
1299
1512
|
}
|
|
1300
1513
|
),
|
|
1301
|
-
|
|
1514
|
+
m && i
|
|
1302
1515
|
] });
|
|
1303
1516
|
}
|
|
1304
|
-
function
|
|
1517
|
+
function he({ label: t, value: i, children: r, valueColor: o, valueMuted: s }) {
|
|
1305
1518
|
return /* @__PURE__ */ n("div", { style: { display: "flex", justifyContent: "space-between", alignItems: "center", padding: "3px 16px", fontSize: 12, gap: 8 }, children: [
|
|
1306
1519
|
/* @__PURE__ */ e("span", { style: { color: d.muted, flexShrink: 0 }, children: t }),
|
|
1307
|
-
/* @__PURE__ */ e("span", { style: { color: o ?? (
|
|
1520
|
+
/* @__PURE__ */ e("span", { style: { color: o ?? (s ? d.muted : d.ink), textAlign: "right", minWidth: 0, overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap", display: "flex", alignItems: "center", gap: 4 }, children: r ?? i })
|
|
1308
1521
|
] });
|
|
1309
1522
|
}
|
|
1310
|
-
function
|
|
1311
|
-
const [i, r] =
|
|
1523
|
+
function Vt({ value: t }) {
|
|
1524
|
+
const [i, r] = g(!1);
|
|
1312
1525
|
return /* @__PURE__ */ e(
|
|
1313
1526
|
"button",
|
|
1314
1527
|
{
|
|
@@ -1324,41 +1537,41 @@ function Lt({ value: t }) {
|
|
|
1324
1537
|
}
|
|
1325
1538
|
);
|
|
1326
1539
|
}
|
|
1327
|
-
function
|
|
1328
|
-
return /* @__PURE__ */ n("div", { style:
|
|
1329
|
-
/* @__PURE__ */ e("div", { style:
|
|
1540
|
+
function Gt() {
|
|
1541
|
+
return /* @__PURE__ */ n("div", { style: p.empty, children: [
|
|
1542
|
+
/* @__PURE__ */ e("div", { style: p.emptyHero, children: /* @__PURE__ */ e(It, { size: 16, strokeWidth: 2 }) }),
|
|
1330
1543
|
/* @__PURE__ */ e("h2", { children: "Chọn một hội thoại" }),
|
|
1331
1544
|
/* @__PURE__ */ e("p", { children: "Chọn hội thoại bên trái để xem và trả lời tin nhắn." })
|
|
1332
1545
|
] });
|
|
1333
1546
|
}
|
|
1334
|
-
function
|
|
1335
|
-
return /* @__PURE__ */ n("span", { style:
|
|
1336
|
-
/* @__PURE__ */ e(
|
|
1337
|
-
o && /* @__PURE__ */ e("span", { style:
|
|
1547
|
+
function pt({ name: t, color: i, image: r, provider: o }) {
|
|
1548
|
+
return /* @__PURE__ */ n("span", { style: p.avatarWrap, children: [
|
|
1549
|
+
/* @__PURE__ */ e(Xt, { name: t, color: i, image: r }),
|
|
1550
|
+
o && /* @__PURE__ */ e("span", { style: p.providerBadge, children: /* @__PURE__ */ e($e, { provider: o }) })
|
|
1338
1551
|
] });
|
|
1339
1552
|
}
|
|
1340
|
-
function
|
|
1341
|
-
return /* @__PURE__ */ e(
|
|
1553
|
+
function Xt({ name: t, color: i, image: r }) {
|
|
1554
|
+
return /* @__PURE__ */ e(dt, { src: r, fallback: ut(t), style: { ...p.avatar, background: `${i}18`, color: i } });
|
|
1342
1555
|
}
|
|
1343
|
-
function
|
|
1344
|
-
return /* @__PURE__ */ e(
|
|
1556
|
+
function Fe() {
|
|
1557
|
+
return /* @__PURE__ */ e(lt, { size: 14, style: p.spinner, "aria-hidden": "true" });
|
|
1345
1558
|
}
|
|
1346
|
-
function
|
|
1559
|
+
function ut(t) {
|
|
1347
1560
|
return t.split(/\s+/).filter(Boolean).slice(-2).map((i) => i[0]).join("").toUpperCase() || "?";
|
|
1348
1561
|
}
|
|
1349
|
-
const
|
|
1350
|
-
function
|
|
1351
|
-
const i =
|
|
1562
|
+
const Jt = { livechat: "web" };
|
|
1563
|
+
function $e({ provider: t }) {
|
|
1564
|
+
const i = Ne(qe), r = 14;
|
|
1352
1565
|
if (!t) return null;
|
|
1353
|
-
const o =
|
|
1566
|
+
const o = Jt[t] ?? t;
|
|
1354
1567
|
return /* @__PURE__ */ e("img", { src: `${i}/static/logos/${o}.avif`, alt: t, width: r, height: r, style: { borderRadius: "50%", objectFit: "cover", display: "block" } });
|
|
1355
1568
|
}
|
|
1356
|
-
function
|
|
1569
|
+
function Ke(t, i = !1) {
|
|
1357
1570
|
if (!t) return "";
|
|
1358
1571
|
const r = new Date(t);
|
|
1359
1572
|
return r.toDateString() === (/* @__PURE__ */ new Date()).toDateString() ? r.toLocaleTimeString("vi-VN", { hour: "2-digit", minute: "2-digit" }) : r.toLocaleDateString("vi-VN", { day: "2-digit", month: "2-digit" });
|
|
1360
1573
|
}
|
|
1361
|
-
const
|
|
1574
|
+
const p = {
|
|
1362
1575
|
frame: { display: "grid", gridTemplateRows: "minmax(0, 1fr)", height: 620, maxHeight: "calc(100dvh - 220px)", minHeight: 0, overflow: "hidden", border: `1px solid ${d.line}`, background: d.white, color: d.ink, boxShadow: "0 18px 50px rgba(31,45,72,.10)" },
|
|
1363
1576
|
sidebar: { display: "flex", flexDirection: "column", minWidth: 0, minHeight: 0, borderRight: `1px solid ${d.line}`, background: d.white },
|
|
1364
1577
|
brand: { display: "flex", alignItems: "center", gap: 10, padding: "20px 18px 16px" },
|
|
@@ -1405,14 +1618,14 @@ const u = {
|
|
|
1405
1618
|
infoPanelHeader: { display: "flex", alignItems: "center", justifyContent: "space-between", padding: "16px 16px 12px", borderBottom: `1px solid ${d.line}`, flex: "0 0 auto" },
|
|
1406
1619
|
infoPanelIdentity: { display: "flex", flexDirection: "column", alignItems: "center", padding: "20px 16px 16px", gap: 4 },
|
|
1407
1620
|
ghostButton: { width: "100%", padding: "8px 12px", border: `1px solid ${d.line}`, borderRadius: 8, background: "transparent", fontSize: 12, cursor: "pointer", textAlign: "center" }
|
|
1408
|
-
},
|
|
1621
|
+
}, Yt = {
|
|
1409
1622
|
facebook: "#dbeafe",
|
|
1410
1623
|
zalo: "#e0f2fe",
|
|
1411
1624
|
instagram: "#fce7f3",
|
|
1412
1625
|
telegram: "#cffafe",
|
|
1413
1626
|
livechat: "#ede9fe",
|
|
1414
1627
|
whatsapp: "#dcfce7"
|
|
1415
|
-
},
|
|
1628
|
+
}, _t = {
|
|
1416
1629
|
facebook: "facebook",
|
|
1417
1630
|
instagram: "instagram",
|
|
1418
1631
|
telegram: "telegram",
|
|
@@ -1420,8 +1633,8 @@ const u = {
|
|
|
1420
1633
|
livechat: "web",
|
|
1421
1634
|
whatsapp: "web"
|
|
1422
1635
|
};
|
|
1423
|
-
function
|
|
1424
|
-
const o =
|
|
1636
|
+
function ge({ provider: t, apiUrl: i, size: r = 40 }) {
|
|
1637
|
+
const o = Yt[t] ?? "#f1f5f9", s = _t[t], C = i.replace(/\/$/, "");
|
|
1425
1638
|
return /* @__PURE__ */ e(
|
|
1426
1639
|
"div",
|
|
1427
1640
|
{
|
|
@@ -1436,10 +1649,10 @@ function le({ provider: t, apiUrl: i, size: r = 40 }) {
|
|
|
1436
1649
|
flexShrink: 0,
|
|
1437
1650
|
overflow: "hidden"
|
|
1438
1651
|
},
|
|
1439
|
-
children:
|
|
1652
|
+
children: s ? /* @__PURE__ */ e(
|
|
1440
1653
|
"img",
|
|
1441
1654
|
{
|
|
1442
|
-
src: `${
|
|
1655
|
+
src: `${C}/static/logos/${s}.avif`,
|
|
1443
1656
|
alt: t,
|
|
1444
1657
|
width: Math.round(r * 0.65),
|
|
1445
1658
|
height: Math.round(r * 0.65),
|
|
@@ -1449,14 +1662,14 @@ function le({ provider: t, apiUrl: i, size: r = 40 }) {
|
|
|
1449
1662
|
}
|
|
1450
1663
|
);
|
|
1451
1664
|
}
|
|
1452
|
-
const
|
|
1665
|
+
const Be = {
|
|
1453
1666
|
facebook: "Facebook",
|
|
1454
1667
|
zalo: "Zalo OA",
|
|
1455
1668
|
instagram: "Instagram",
|
|
1456
1669
|
telegram: "Telegram",
|
|
1457
1670
|
livechat: "Live Chat",
|
|
1458
1671
|
whatsapp: "WhatsApp"
|
|
1459
|
-
},
|
|
1672
|
+
}, Zt = {
|
|
1460
1673
|
facebook: "#dbeafe",
|
|
1461
1674
|
zalo: "#e0f2fe",
|
|
1462
1675
|
instagram: "#fce7f3",
|
|
@@ -1464,12 +1677,12 @@ const xe = {
|
|
|
1464
1677
|
livechat: "#ede9fe",
|
|
1465
1678
|
whatsapp: "#dcfce7"
|
|
1466
1679
|
};
|
|
1467
|
-
function
|
|
1680
|
+
function Ve(t) {
|
|
1468
1681
|
const i = t.metadata;
|
|
1469
1682
|
return String(i.displayName ?? i.pageName ?? i.username ?? i.name ?? t.externalAccountId);
|
|
1470
1683
|
}
|
|
1471
|
-
function
|
|
1472
|
-
const i =
|
|
1684
|
+
function Qt(t) {
|
|
1685
|
+
const i = Be[t.provider] ?? t.provider, r = String(t.metadata.username ?? t.metadata.pageName ?? "");
|
|
1473
1686
|
return r ? `${i} · ${r}` : i;
|
|
1474
1687
|
}
|
|
1475
1688
|
const a = {
|
|
@@ -1747,264 +1960,264 @@ const a = {
|
|
|
1747
1960
|
fontFamily: "inherit"
|
|
1748
1961
|
}
|
|
1749
1962
|
};
|
|
1750
|
-
function
|
|
1963
|
+
function Ze() {
|
|
1751
1964
|
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" }) });
|
|
1752
1965
|
}
|
|
1753
|
-
function
|
|
1966
|
+
function ve() {
|
|
1754
1967
|
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" }) });
|
|
1755
1968
|
}
|
|
1756
|
-
function
|
|
1969
|
+
function Qe() {
|
|
1757
1970
|
return /* @__PURE__ */ n("svg", { width: "12", height: "12", viewBox: "0 0 12 12", fill: "none", children: [
|
|
1758
1971
|
/* @__PURE__ */ e("rect", { x: "4", y: "4", width: "7", height: "7", rx: "1.5", stroke: "currentColor", strokeWidth: "1.3" }),
|
|
1759
1972
|
/* @__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" })
|
|
1760
1973
|
] });
|
|
1761
1974
|
}
|
|
1762
|
-
function
|
|
1975
|
+
function et() {
|
|
1763
1976
|
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" }) });
|
|
1764
1977
|
}
|
|
1765
|
-
function
|
|
1978
|
+
function en() {
|
|
1766
1979
|
return /* @__PURE__ */ n("svg", { width: "14", height: "14", viewBox: "0 0 14 14", fill: "none", style: { flexShrink: 0 }, children: [
|
|
1767
1980
|
/* @__PURE__ */ e("circle", { cx: "5", cy: "6", r: "3.5", stroke: "#ca8a04", strokeWidth: "1.4" }),
|
|
1768
1981
|
/* @__PURE__ */ e("path", { d: "M8 7.5l4.5 4.5M10.5 10l1.5 1.5", stroke: "#ca8a04", strokeWidth: "1.4", strokeLinecap: "round" })
|
|
1769
1982
|
] });
|
|
1770
1983
|
}
|
|
1771
|
-
function
|
|
1984
|
+
function tn() {
|
|
1772
1985
|
return /* @__PURE__ */ n("svg", { width: "14", height: "14", viewBox: "0 0 14 14", fill: "none", style: { flexShrink: 0, marginTop: 1 }, children: [
|
|
1773
1986
|
/* @__PURE__ */ e("circle", { cx: "7", cy: "7", r: "6", stroke: "currentColor", strokeWidth: "1.5" }),
|
|
1774
1987
|
/* @__PURE__ */ e("path", { d: "M7 6v5M7 4.5v.01", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round" })
|
|
1775
1988
|
] });
|
|
1776
1989
|
}
|
|
1777
|
-
let
|
|
1778
|
-
function
|
|
1779
|
-
if (
|
|
1780
|
-
|
|
1990
|
+
let tt = !1;
|
|
1991
|
+
function nn() {
|
|
1992
|
+
if (tt || typeof document > "u") return;
|
|
1993
|
+
tt = !0;
|
|
1781
1994
|
const t = document.createElement("style");
|
|
1782
1995
|
t.textContent = "@keyframes ch-spin{to{transform:rotate(360deg)}}", document.head.appendChild(t);
|
|
1783
1996
|
}
|
|
1784
|
-
function
|
|
1785
|
-
const o = t.replace(/\/$/, ""), [
|
|
1786
|
-
|
|
1787
|
-
const
|
|
1997
|
+
function un({ apiUrl: t, token: i, onConnectionChange: r }) {
|
|
1998
|
+
const o = t.replace(/\/$/, ""), [s, C] = g([]), [m, O] = g(!0), [f, S] = g({ name: "list" }), [B, I] = g(null), [H, $] = g(!1), [E, j] = g(""), [A, F] = g(""), [K, ne] = g(""), [U, w] = g(""), [_, k] = g(!1), [L, ce] = g(!1), z = ee(null);
|
|
1999
|
+
nn();
|
|
2000
|
+
const D = We(async () => {
|
|
1788
2001
|
try {
|
|
1789
|
-
const
|
|
2002
|
+
const h = await fetch(`${o}/v1/connections`, {
|
|
1790
2003
|
headers: { authorization: `Bearer ${i}` }
|
|
1791
2004
|
});
|
|
1792
|
-
if (!
|
|
1793
|
-
const T = await
|
|
1794
|
-
|
|
1795
|
-
} catch (
|
|
1796
|
-
|
|
2005
|
+
if (!h.ok) throw new Error("Không tải được kênh");
|
|
2006
|
+
const T = await h.json();
|
|
2007
|
+
C(T), r == null || r(T);
|
|
2008
|
+
} catch (h) {
|
|
2009
|
+
I(h instanceof Error ? h.message : "Lỗi tải dữ liệu");
|
|
1797
2010
|
} finally {
|
|
1798
|
-
|
|
2011
|
+
O(!1);
|
|
1799
2012
|
}
|
|
1800
2013
|
}, [o, i, r]);
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
}, [
|
|
1804
|
-
if (!
|
|
1805
|
-
const
|
|
1806
|
-
return () => clearTimeout(
|
|
1807
|
-
}, [
|
|
1808
|
-
|
|
2014
|
+
Y(() => {
|
|
2015
|
+
D();
|
|
2016
|
+
}, [D]), Y(() => {
|
|
2017
|
+
if (!B) return;
|
|
2018
|
+
const h = setTimeout(() => I(null), 5e3);
|
|
2019
|
+
return () => clearTimeout(h);
|
|
2020
|
+
}, [B]), Y(() => () => {
|
|
2021
|
+
z.current && window.removeEventListener("message", z.current);
|
|
1809
2022
|
}, []);
|
|
1810
|
-
async function
|
|
2023
|
+
async function le(h, T) {
|
|
1811
2024
|
if (confirm(`Bạn chắc chắn muốn ngắt kết nối "${T}"?
|
|
1812
2025
|
|
|
1813
2026
|
Hành động này không thể hoàn tác.`))
|
|
1814
2027
|
try {
|
|
1815
|
-
if (!(await fetch(`${o}/v1/connections/${
|
|
2028
|
+
if (!(await fetch(`${o}/v1/connections/${h}`, {
|
|
1816
2029
|
method: "DELETE",
|
|
1817
2030
|
headers: { authorization: `Bearer ${i}` }
|
|
1818
2031
|
})).ok) throw new Error("Không thể ngắt kết nối");
|
|
1819
|
-
await
|
|
1820
|
-
} catch (
|
|
1821
|
-
|
|
2032
|
+
await D();
|
|
2033
|
+
} catch (P) {
|
|
2034
|
+
I(P instanceof Error ? P.message : "Lỗi ngắt kết nối");
|
|
1822
2035
|
}
|
|
1823
2036
|
}
|
|
1824
|
-
async function
|
|
1825
|
-
if (!
|
|
1826
|
-
|
|
2037
|
+
async function v() {
|
|
2038
|
+
if (!E.trim()) {
|
|
2039
|
+
I("Vui lòng nhập Bot Token");
|
|
1827
2040
|
return;
|
|
1828
2041
|
}
|
|
1829
|
-
if (!/^\d+:[A-Za-z0-9_-]+$/.test(
|
|
1830
|
-
|
|
2042
|
+
if (!/^\d+:[A-Za-z0-9_-]+$/.test(E.trim())) {
|
|
2043
|
+
I("Token không đúng định dạng");
|
|
1831
2044
|
return;
|
|
1832
2045
|
}
|
|
1833
|
-
|
|
2046
|
+
$(!0), I(null);
|
|
1834
2047
|
try {
|
|
1835
|
-
const
|
|
2048
|
+
const h = await fetch(`${o}/v1/connect/telegram/start`, {
|
|
1836
2049
|
method: "POST",
|
|
1837
2050
|
headers: { authorization: `Bearer ${i}`, "content-type": "application/json" },
|
|
1838
|
-
body: JSON.stringify({ botToken:
|
|
1839
|
-
}), T = await
|
|
1840
|
-
if (!
|
|
1841
|
-
|
|
1842
|
-
} catch (
|
|
1843
|
-
|
|
2051
|
+
body: JSON.stringify({ botToken: E.trim(), displayName: A.trim() || void 0 })
|
|
2052
|
+
}), T = await h.json();
|
|
2053
|
+
if (!h.ok || !T.connectionId) throw new Error(T.message ?? "Không thể kết nối Telegram");
|
|
2054
|
+
j(""), F(""), await D(), S({ name: "list" });
|
|
2055
|
+
} catch (h) {
|
|
2056
|
+
I(h instanceof Error ? h.message : "Lỗi kết nối");
|
|
1844
2057
|
} finally {
|
|
1845
|
-
|
|
2058
|
+
$(!1);
|
|
1846
2059
|
}
|
|
1847
2060
|
}
|
|
1848
2061
|
async function Q() {
|
|
1849
|
-
if (!
|
|
1850
|
-
|
|
2062
|
+
if (!K.trim()) {
|
|
2063
|
+
I("Vui lòng nhập tên widget");
|
|
1851
2064
|
return;
|
|
1852
2065
|
}
|
|
1853
|
-
|
|
2066
|
+
$(!0), I(null);
|
|
1854
2067
|
try {
|
|
1855
|
-
const
|
|
2068
|
+
const h = U.split(/[\n,]+/).map((q) => q.trim()).filter(Boolean), T = await fetch(`${o}/v1/connect/livechat/start`, {
|
|
1856
2069
|
method: "POST",
|
|
1857
2070
|
headers: { authorization: `Bearer ${i}`, "content-type": "application/json" },
|
|
1858
|
-
body: JSON.stringify({ displayName:
|
|
1859
|
-
}),
|
|
1860
|
-
if (!T.ok || !
|
|
1861
|
-
|
|
2071
|
+
body: JSON.stringify({ displayName: K.trim(), allowedDomains: h.length ? h : void 0 })
|
|
2072
|
+
}), P = await T.json();
|
|
2073
|
+
if (!T.ok || !P.connectionId || !P.embedScript) throw new Error(P.message ?? "Không thể tạo widget");
|
|
2074
|
+
ne(""), w(""), await D(), S({
|
|
1862
2075
|
name: "livechat-result",
|
|
1863
|
-
connectionId:
|
|
1864
|
-
embedScript:
|
|
1865
|
-
identitySecret:
|
|
1866
|
-
allowedDomains:
|
|
2076
|
+
connectionId: P.connectionId,
|
|
2077
|
+
embedScript: P.embedScript,
|
|
2078
|
+
identitySecret: P.identitySecret ?? "",
|
|
2079
|
+
allowedDomains: P.allowedDomains ?? []
|
|
1867
2080
|
});
|
|
1868
|
-
} catch (
|
|
1869
|
-
|
|
2081
|
+
} catch (h) {
|
|
2082
|
+
I(h instanceof Error ? h.message : "Lỗi tạo widget");
|
|
1870
2083
|
} finally {
|
|
1871
|
-
|
|
2084
|
+
$(!1);
|
|
1872
2085
|
}
|
|
1873
2086
|
}
|
|
1874
|
-
async function
|
|
1875
|
-
|
|
2087
|
+
async function N(h) {
|
|
2088
|
+
I(null);
|
|
1876
2089
|
try {
|
|
1877
|
-
const T = `${o}/static/oauth-popup.html`,
|
|
2090
|
+
const T = `${o}/static/oauth-popup.html`, P = await fetch(`${o}/v1/connect/${h}/start`, {
|
|
1878
2091
|
method: "POST",
|
|
1879
2092
|
headers: { authorization: `Bearer ${i}`, "content-type": "application/json" },
|
|
1880
2093
|
body: JSON.stringify({ callbackUrl: T })
|
|
1881
|
-
}),
|
|
1882
|
-
if (!
|
|
1883
|
-
const
|
|
1884
|
-
|
|
1885
|
-
const
|
|
1886
|
-
if (
|
|
1887
|
-
if (
|
|
1888
|
-
|
|
2094
|
+
}), q = await P.json();
|
|
2095
|
+
if (!P.ok || !q.authorizationUrl) throw new Error(q.message ?? "Không thể bắt đầu kết nối");
|
|
2096
|
+
const ie = window.open(q.authorizationUrl, "channelhub-oauth", "width=600,height=700,scrollbars=yes,resizable=yes");
|
|
2097
|
+
S({ name: "oauth-waiting", provider: h, popup: ie }), z.current && window.removeEventListener("message", z.current);
|
|
2098
|
+
const re = (V) => {
|
|
2099
|
+
if (V.data) {
|
|
2100
|
+
if (V.data.type === "channelhub:oauth-select") {
|
|
2101
|
+
S({
|
|
1889
2102
|
name: "oauth-select",
|
|
1890
|
-
provider:
|
|
1891
|
-
sessionId: String(
|
|
1892
|
-
pages:
|
|
1893
|
-
popup:
|
|
2103
|
+
provider: V.data.provider,
|
|
2104
|
+
sessionId: String(V.data.sessionId ?? ""),
|
|
2105
|
+
pages: V.data.pages ?? [],
|
|
2106
|
+
popup: ie
|
|
1894
2107
|
});
|
|
1895
2108
|
return;
|
|
1896
2109
|
}
|
|
1897
|
-
|
|
2110
|
+
V.data.type === "channelhub:oauth" && (window.removeEventListener("message", re), z.current = null, V.data.status === "active" ? (D(), S({ name: "list" })) : (I("Kết nối thất bại: " + String(V.data.error ?? "Không xác định")), S({ name: "list" })));
|
|
1898
2111
|
}
|
|
1899
2112
|
};
|
|
1900
|
-
|
|
2113
|
+
z.current = re, window.addEventListener("message", re);
|
|
1901
2114
|
} catch (T) {
|
|
1902
|
-
|
|
2115
|
+
I(T instanceof Error ? T.message : "Lỗi kết nối"), S({ name: "list" });
|
|
1903
2116
|
}
|
|
1904
2117
|
}
|
|
1905
|
-
function
|
|
1906
|
-
navigator.clipboard.writeText(
|
|
1907
|
-
T === "script" ? (
|
|
2118
|
+
function x(h, T) {
|
|
2119
|
+
navigator.clipboard.writeText(h).then(() => {
|
|
2120
|
+
T === "script" ? (k(!0), setTimeout(() => k(!1), 2e3)) : (ce(!0), setTimeout(() => ce(!1), 2e3));
|
|
1908
2121
|
});
|
|
1909
2122
|
}
|
|
1910
|
-
function
|
|
1911
|
-
const
|
|
1912
|
-
if (
|
|
2123
|
+
function J() {
|
|
2124
|
+
const h = f.name === "oauth-waiting" || f.name === "oauth-select" ? f.popup : null;
|
|
2125
|
+
if (h)
|
|
1913
2126
|
try {
|
|
1914
|
-
|
|
2127
|
+
h.close();
|
|
1915
2128
|
} catch {
|
|
1916
2129
|
}
|
|
1917
|
-
|
|
2130
|
+
z.current && (window.removeEventListener("message", z.current), z.current = null), S({ name: "add" });
|
|
1918
2131
|
}
|
|
1919
|
-
async function se(
|
|
2132
|
+
async function se(h) {
|
|
1920
2133
|
if (f.name !== "oauth-select") return;
|
|
1921
|
-
const { provider: T, sessionId:
|
|
1922
|
-
|
|
1923
|
-
const
|
|
2134
|
+
const { provider: T, sessionId: P, popup: q } = f;
|
|
2135
|
+
$(!0), I(null);
|
|
2136
|
+
const ie = {
|
|
1924
2137
|
facebook: `${o}/v1/connect/facebook/select-page`,
|
|
1925
2138
|
instagram: `${o}/v1/connect/instagram/select-account`,
|
|
1926
2139
|
zalo: `${o}/v1/connect/zalo/select-oa`
|
|
1927
|
-
},
|
|
2140
|
+
}, re = {
|
|
1928
2141
|
facebook: "pageId",
|
|
1929
2142
|
instagram: "accountId",
|
|
1930
2143
|
zalo: "oaId"
|
|
1931
2144
|
};
|
|
1932
2145
|
try {
|
|
1933
|
-
const
|
|
2146
|
+
const V = await fetch(ie[T] ?? `${o}/v1/connect/${T}/select-page`, {
|
|
1934
2147
|
method: "POST",
|
|
1935
2148
|
headers: { authorization: `Bearer ${i}`, "content-type": "application/json" },
|
|
1936
|
-
body: JSON.stringify({ sessionId:
|
|
1937
|
-
}),
|
|
1938
|
-
if (!
|
|
1939
|
-
if (
|
|
2149
|
+
body: JSON.stringify({ sessionId: P, [re[T] ?? "pageId"]: h })
|
|
2150
|
+
}), ye = await V.json();
|
|
2151
|
+
if (!V.ok || !ye.connectionId) throw new Error(ye.message ?? "Không thể kết nối");
|
|
2152
|
+
if (q)
|
|
1940
2153
|
try {
|
|
1941
|
-
|
|
2154
|
+
q.postMessage({ type: "channelhub:close-popup" }, "*");
|
|
1942
2155
|
} catch {
|
|
1943
2156
|
}
|
|
1944
|
-
|
|
1945
|
-
} catch (
|
|
1946
|
-
|
|
2157
|
+
z.current && (window.removeEventListener("message", z.current), z.current = null), await D(), S({ name: "list" });
|
|
2158
|
+
} catch (V) {
|
|
2159
|
+
I(V instanceof Error ? V.message : "Lỗi kết nối");
|
|
1947
2160
|
} finally {
|
|
1948
|
-
|
|
2161
|
+
$(!1);
|
|
1949
2162
|
}
|
|
1950
2163
|
}
|
|
1951
2164
|
return /* @__PURE__ */ n("div", { style: a.root, children: [
|
|
1952
|
-
|
|
1953
|
-
f.name === "list" && /* @__PURE__ */ n(
|
|
2165
|
+
B && /* @__PURE__ */ e("div", { style: a.errorBanner, children: B }),
|
|
2166
|
+
f.name === "list" && /* @__PURE__ */ n(te, { children: [
|
|
1954
2167
|
/* @__PURE__ */ n("div", { style: a.header, children: [
|
|
1955
2168
|
/* @__PURE__ */ e("div", { style: a.headerLeft, children: /* @__PURE__ */ n("div", { children: [
|
|
1956
2169
|
/* @__PURE__ */ e("div", { style: a.title, children: "Kênh kết nối" }),
|
|
1957
|
-
/* @__PURE__ */ e("div", { style: a.subtitle, children:
|
|
2170
|
+
/* @__PURE__ */ e("div", { style: a.subtitle, children: m ? "Đang tải…" : `${s.filter((h) => h.status === "active").length} kênh đang hoạt động` })
|
|
1958
2171
|
] }) }),
|
|
1959
|
-
/* @__PURE__ */ n("button", { style: a.addBtn, onClick: () =>
|
|
1960
|
-
/* @__PURE__ */ e(
|
|
2172
|
+
/* @__PURE__ */ n("button", { style: a.addBtn, onClick: () => S({ name: "add" }), children: [
|
|
2173
|
+
/* @__PURE__ */ e(Ze, {}),
|
|
1961
2174
|
/* @__PURE__ */ e("span", { children: "Thêm kênh" })
|
|
1962
2175
|
] })
|
|
1963
2176
|
] }),
|
|
1964
2177
|
/* @__PURE__ */ e("div", { style: a.divider }),
|
|
1965
|
-
/* @__PURE__ */ e("div", { style: a.body, children: !
|
|
1966
|
-
/* @__PURE__ */ e("div", { style: { width: 64, height: 64, borderRadius: 16, background: "#f1f5f9", display: "flex", alignItems: "center", justifyContent: "center" }, children: /* @__PURE__ */ e(
|
|
2178
|
+
/* @__PURE__ */ e("div", { style: a.body, children: !m && s.length === 0 ? /* @__PURE__ */ n("div", { style: a.empty, children: [
|
|
2179
|
+
/* @__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 }) }),
|
|
1967
2180
|
/* @__PURE__ */ e("div", { style: a.emptyTitle, children: "Chưa có kênh nào được kết nối" }),
|
|
1968
2181
|
/* @__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." }),
|
|
1969
|
-
/* @__PURE__ */ n("button", { style: a.emptyCta, onClick: () =>
|
|
1970
|
-
/* @__PURE__ */ e(
|
|
2182
|
+
/* @__PURE__ */ n("button", { style: a.emptyCta, onClick: () => S({ name: "add" }), children: [
|
|
2183
|
+
/* @__PURE__ */ e(Ze, {}),
|
|
1971
2184
|
"Kết nối kênh đầu tiên"
|
|
1972
2185
|
] })
|
|
1973
|
-
] }) : /* @__PURE__ */ e("div", { children:
|
|
1974
|
-
|
|
2186
|
+
] }) : /* @__PURE__ */ e("div", { children: s.map((h) => /* @__PURE__ */ e(
|
|
2187
|
+
an,
|
|
1975
2188
|
{
|
|
1976
|
-
conn:
|
|
2189
|
+
conn: h,
|
|
1977
2190
|
apiUrl: o,
|
|
1978
|
-
onDisconnect: () => void
|
|
2191
|
+
onDisconnect: () => void le(h.id, Ve(h))
|
|
1979
2192
|
},
|
|
1980
|
-
|
|
2193
|
+
h.id
|
|
1981
2194
|
)) }) })
|
|
1982
2195
|
] }),
|
|
1983
|
-
f.name === "add" && /* @__PURE__ */ n(
|
|
2196
|
+
f.name === "add" && /* @__PURE__ */ n(te, { children: [
|
|
1984
2197
|
/* @__PURE__ */ e("div", { style: a.header, children: /* @__PURE__ */ n("div", { style: a.headerLeft, children: [
|
|
1985
|
-
/* @__PURE__ */ e("button", { style: a.backBtn, onClick: () =>
|
|
2198
|
+
/* @__PURE__ */ e("button", { style: a.backBtn, onClick: () => S({ name: "list" }), children: /* @__PURE__ */ e(ve, {}) }),
|
|
1986
2199
|
/* @__PURE__ */ n("div", { children: [
|
|
1987
2200
|
/* @__PURE__ */ e("div", { style: a.title, children: "Thêm kênh mới" }),
|
|
1988
2201
|
/* @__PURE__ */ e("div", { style: a.subtitle, children: "Chọn nền tảng bạn muốn kết nối" })
|
|
1989
2202
|
] })
|
|
1990
2203
|
] }) }),
|
|
1991
2204
|
/* @__PURE__ */ e("div", { style: a.divider }),
|
|
1992
|
-
/* @__PURE__ */ e("div", { style: a.body, children: /* @__PURE__ */ e("div", { style: a.providerGrid, children:
|
|
1993
|
-
|
|
2205
|
+
/* @__PURE__ */ e("div", { style: a.body, children: /* @__PURE__ */ e("div", { style: a.providerGrid, children: ln.map((h) => /* @__PURE__ */ e(
|
|
2206
|
+
dn,
|
|
1994
2207
|
{
|
|
1995
|
-
provider:
|
|
2208
|
+
provider: h,
|
|
1996
2209
|
apiUrl: o,
|
|
1997
2210
|
onClick: () => {
|
|
1998
|
-
|
|
2211
|
+
h.type === "oauth" ? N(h.id) : h.id === "telegram" ? S({ name: "connect-telegram" }) : S({ name: "connect-livechat" });
|
|
1999
2212
|
}
|
|
2000
2213
|
},
|
|
2001
|
-
|
|
2214
|
+
h.id
|
|
2002
2215
|
)) }) })
|
|
2003
2216
|
] }),
|
|
2004
|
-
f.name === "connect-telegram" && /* @__PURE__ */ n(
|
|
2217
|
+
f.name === "connect-telegram" && /* @__PURE__ */ n(te, { children: [
|
|
2005
2218
|
/* @__PURE__ */ n("div", { style: a.connectHeader, children: [
|
|
2006
|
-
/* @__PURE__ */ e("button", { style: a.backBtn, onClick: () =>
|
|
2007
|
-
/* @__PURE__ */ e(
|
|
2219
|
+
/* @__PURE__ */ e("button", { style: a.backBtn, onClick: () => S({ name: "add" }), children: /* @__PURE__ */ e(ve, {}) }),
|
|
2220
|
+
/* @__PURE__ */ e(ge, { provider: "telegram", apiUrl: o, size: 44 }),
|
|
2008
2221
|
/* @__PURE__ */ n("div", { children: [
|
|
2009
2222
|
/* @__PURE__ */ e("div", { style: a.connectTitle, children: "Kết nối Telegram Bot" }),
|
|
2010
2223
|
/* @__PURE__ */ e("div", { style: a.connectDesc, children: "Nhập Bot Token để bắt đầu nhận tin nhắn" })
|
|
@@ -2012,7 +2225,7 @@ Hành động này không thể hoàn tác.`))
|
|
|
2012
2225
|
] }),
|
|
2013
2226
|
/* @__PURE__ */ n("div", { style: a.form, children: [
|
|
2014
2227
|
/* @__PURE__ */ n("div", { style: a.infoBox, children: [
|
|
2015
|
-
/* @__PURE__ */ e(
|
|
2228
|
+
/* @__PURE__ */ e(tn, {}),
|
|
2016
2229
|
/* @__PURE__ */ n("div", { children: [
|
|
2017
2230
|
"Tạo bot mới bằng cách nhắn tin cho ",
|
|
2018
2231
|
/* @__PURE__ */ e("strong", { children: "@BotFather" }),
|
|
@@ -2031,8 +2244,8 @@ Hành động này không thể hoàn tác.`))
|
|
|
2031
2244
|
{
|
|
2032
2245
|
style: a.input,
|
|
2033
2246
|
type: "text",
|
|
2034
|
-
value:
|
|
2035
|
-
onChange: (
|
|
2247
|
+
value: E,
|
|
2248
|
+
onChange: (h) => j(h.target.value),
|
|
2036
2249
|
placeholder: "1234567890:AAExxxxxxxxxxxxxxxxxxxxxxxx",
|
|
2037
2250
|
autoComplete: "off",
|
|
2038
2251
|
spellCheck: !1
|
|
@@ -2055,22 +2268,22 @@ Hành động này không thể hoàn tác.`))
|
|
|
2055
2268
|
{
|
|
2056
2269
|
style: a.input,
|
|
2057
2270
|
type: "text",
|
|
2058
|
-
value:
|
|
2059
|
-
onChange: (
|
|
2271
|
+
value: A,
|
|
2272
|
+
onChange: (h) => F(h.target.value),
|
|
2060
2273
|
placeholder: "VD: Bot hỗ trợ cửa hàng"
|
|
2061
2274
|
}
|
|
2062
2275
|
)
|
|
2063
2276
|
] }),
|
|
2064
2277
|
/* @__PURE__ */ n("div", { style: a.formActions, children: [
|
|
2065
|
-
/* @__PURE__ */ e("button", { style: a.btnSecondary, onClick: () =>
|
|
2066
|
-
/* @__PURE__ */ e("button", { style: a.btnPrimary, disabled:
|
|
2278
|
+
/* @__PURE__ */ e("button", { style: a.btnSecondary, onClick: () => S({ name: "add" }), children: "Hủy" }),
|
|
2279
|
+
/* @__PURE__ */ e("button", { style: a.btnPrimary, disabled: H, onClick: () => void v(), children: H ? "Đang kết nối…" : "Kết nối Telegram" })
|
|
2067
2280
|
] })
|
|
2068
2281
|
] })
|
|
2069
2282
|
] }),
|
|
2070
|
-
f.name === "connect-livechat" && /* @__PURE__ */ n(
|
|
2283
|
+
f.name === "connect-livechat" && /* @__PURE__ */ n(te, { children: [
|
|
2071
2284
|
/* @__PURE__ */ n("div", { style: a.connectHeader, children: [
|
|
2072
|
-
/* @__PURE__ */ e("button", { style: a.backBtn, onClick: () =>
|
|
2073
|
-
/* @__PURE__ */ e(
|
|
2285
|
+
/* @__PURE__ */ e("button", { style: a.backBtn, onClick: () => S({ name: "add" }), children: /* @__PURE__ */ e(ve, {}) }),
|
|
2286
|
+
/* @__PURE__ */ e(ge, { provider: "livechat", apiUrl: o, size: 44 }),
|
|
2074
2287
|
/* @__PURE__ */ n("div", { children: [
|
|
2075
2288
|
/* @__PURE__ */ e("div", { style: a.connectTitle, children: "Tạo Live Chat Widget" }),
|
|
2076
2289
|
/* @__PURE__ */ e("div", { style: a.connectDesc, children: "Nhúng vào website để nhận tin nhắn từ khách hàng" })
|
|
@@ -2087,8 +2300,8 @@ Hành động này không thể hoàn tác.`))
|
|
|
2087
2300
|
{
|
|
2088
2301
|
style: a.input,
|
|
2089
2302
|
type: "text",
|
|
2090
|
-
value:
|
|
2091
|
-
onChange: (
|
|
2303
|
+
value: K,
|
|
2304
|
+
onChange: (h) => ne(h.target.value),
|
|
2092
2305
|
placeholder: "VD: Hỗ trợ website hanashop.vn"
|
|
2093
2306
|
}
|
|
2094
2307
|
)
|
|
@@ -2102,8 +2315,8 @@ Hành động này không thể hoàn tác.`))
|
|
|
2102
2315
|
"textarea",
|
|
2103
2316
|
{
|
|
2104
2317
|
style: { ...a.input, resize: "vertical", minHeight: 80, lineHeight: 1.5 },
|
|
2105
|
-
value:
|
|
2106
|
-
onChange: (
|
|
2318
|
+
value: U,
|
|
2319
|
+
onChange: (h) => w(h.target.value),
|
|
2107
2320
|
placeholder: `https://myshop.com
|
|
2108
2321
|
https://www.myshop.com`,
|
|
2109
2322
|
spellCheck: !1
|
|
@@ -2112,15 +2325,15 @@ https://www.myshop.com`,
|
|
|
2112
2325
|
/* @__PURE__ */ e("div", { style: a.inputHint, children: "Mỗi domain một dòng. Để trống để cho phép tất cả." })
|
|
2113
2326
|
] }),
|
|
2114
2327
|
/* @__PURE__ */ n("div", { style: a.formActions, children: [
|
|
2115
|
-
/* @__PURE__ */ e("button", { style: a.btnSecondary, onClick: () =>
|
|
2116
|
-
/* @__PURE__ */ e("button", { style: a.btnPrimary, disabled:
|
|
2328
|
+
/* @__PURE__ */ e("button", { style: a.btnSecondary, onClick: () => S({ name: "add" }), children: "Hủy" }),
|
|
2329
|
+
/* @__PURE__ */ e("button", { style: a.btnPrimary, disabled: H, onClick: () => void Q(), children: H ? "Đang tạo…" : "Tạo widget" })
|
|
2117
2330
|
] })
|
|
2118
2331
|
] })
|
|
2119
2332
|
] }),
|
|
2120
|
-
f.name === "livechat-result" && /* @__PURE__ */ n(
|
|
2333
|
+
f.name === "livechat-result" && /* @__PURE__ */ n(te, { children: [
|
|
2121
2334
|
/* @__PURE__ */ n("div", { style: a.connectHeader, children: [
|
|
2122
|
-
/* @__PURE__ */ e("button", { style: a.backBtn, onClick: () =>
|
|
2123
|
-
/* @__PURE__ */ e(
|
|
2335
|
+
/* @__PURE__ */ e("button", { style: a.backBtn, onClick: () => S({ name: "list" }), children: /* @__PURE__ */ e(ve, {}) }),
|
|
2336
|
+
/* @__PURE__ */ e(ge, { provider: "livechat", apiUrl: o, size: 44 }),
|
|
2124
2337
|
/* @__PURE__ */ n("div", { children: [
|
|
2125
2338
|
/* @__PURE__ */ e("div", { style: a.connectTitle, children: "Widget đã được tạo!" }),
|
|
2126
2339
|
/* @__PURE__ */ e("div", { style: a.connectDesc, children: "Sao chép mã nhúng và dán vào website của bạn" })
|
|
@@ -2140,11 +2353,11 @@ https://www.myshop.com`,
|
|
|
2140
2353
|
/* @__PURE__ */ e("div", { style: a.codeLabel, children: "Mã nhúng" }),
|
|
2141
2354
|
/* @__PURE__ */ n("div", { style: a.codeBlock, children: [
|
|
2142
2355
|
/* @__PURE__ */ e("pre", { style: a.codePre, children: f.embedScript }),
|
|
2143
|
-
/* @__PURE__ */ e("button", { style: { ...a.copyBtn, ..._ ? { background: "#166534", borderColor: "#166534", color: "#bbf7d0" } : {} }, onClick: () =>
|
|
2144
|
-
/* @__PURE__ */ e(
|
|
2356
|
+
/* @__PURE__ */ e("button", { style: { ...a.copyBtn, ..._ ? { background: "#166534", borderColor: "#166534", color: "#bbf7d0" } : {} }, onClick: () => x(f.embedScript, "script"), children: _ ? /* @__PURE__ */ n(te, { children: [
|
|
2357
|
+
/* @__PURE__ */ e(et, {}),
|
|
2145
2358
|
" Đã sao chép"
|
|
2146
|
-
] }) : /* @__PURE__ */ n(
|
|
2147
|
-
/* @__PURE__ */ e(
|
|
2359
|
+
] }) : /* @__PURE__ */ n(te, { children: [
|
|
2360
|
+
/* @__PURE__ */ e(Qe, {}),
|
|
2148
2361
|
" Sao chép"
|
|
2149
2362
|
] }) })
|
|
2150
2363
|
] })
|
|
@@ -2155,40 +2368,40 @@ https://www.myshop.com`,
|
|
|
2155
2368
|
/* @__PURE__ */ e("span", { style: { ...a.labelHint, color: "#dc2626", fontWeight: 600 }, children: "Lưu ngay — chỉ hiển thị một lần" })
|
|
2156
2369
|
] }),
|
|
2157
2370
|
/* @__PURE__ */ n("div", { style: a.secretRow, children: [
|
|
2158
|
-
/* @__PURE__ */ e(
|
|
2371
|
+
/* @__PURE__ */ e(en, {}),
|
|
2159
2372
|
/* @__PURE__ */ e("span", { style: a.secretLabel, children: "Secret:" }),
|
|
2160
2373
|
/* @__PURE__ */ e("span", { style: a.secretValue, children: f.identitySecret }),
|
|
2161
2374
|
/* @__PURE__ */ e(
|
|
2162
2375
|
"button",
|
|
2163
2376
|
{
|
|
2164
|
-
onClick: () =>
|
|
2165
|
-
style: { border: "none", background: "transparent", cursor: "pointer", color:
|
|
2166
|
-
children:
|
|
2377
|
+
onClick: () => x(f.identitySecret, "secret"),
|
|
2378
|
+
style: { border: "none", background: "transparent", cursor: "pointer", color: L ? "#059669" : "#ca8a04", padding: 2, display: "flex", alignItems: "center" },
|
|
2379
|
+
children: L ? /* @__PURE__ */ e(et, {}) : /* @__PURE__ */ e(Qe, {})
|
|
2167
2380
|
}
|
|
2168
2381
|
)
|
|
2169
2382
|
] }),
|
|
2170
2383
|
/* @__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." })
|
|
2171
2384
|
] }),
|
|
2172
2385
|
/* @__PURE__ */ n("div", { style: a.formActions, children: [
|
|
2173
|
-
/* @__PURE__ */ e("button", { style: a.btnSecondary, onClick: () =>
|
|
2174
|
-
/* @__PURE__ */ e("button", { style: a.btnPrimary, onClick: () =>
|
|
2386
|
+
/* @__PURE__ */ e("button", { style: a.btnSecondary, onClick: () => S({ name: "list" }), children: "Về danh sách" }),
|
|
2387
|
+
/* @__PURE__ */ e("button", { style: a.btnPrimary, onClick: () => S({ name: "add" }), children: "Thêm kênh khác" })
|
|
2175
2388
|
] })
|
|
2176
2389
|
] })
|
|
2177
2390
|
] }),
|
|
2178
|
-
f.name === "oauth-waiting" && /* @__PURE__ */ n(
|
|
2391
|
+
f.name === "oauth-waiting" && /* @__PURE__ */ n(te, { children: [
|
|
2179
2392
|
/* @__PURE__ */ e("div", { style: a.header, children: /* @__PURE__ */ n("div", { style: a.headerLeft, children: [
|
|
2180
|
-
/* @__PURE__ */ e("button", { style: a.backBtn, onClick:
|
|
2393
|
+
/* @__PURE__ */ e("button", { style: a.backBtn, onClick: J, children: /* @__PURE__ */ e(ve, {}) }),
|
|
2181
2394
|
/* @__PURE__ */ n("div", { children: [
|
|
2182
2395
|
/* @__PURE__ */ n("div", { style: a.title, children: [
|
|
2183
2396
|
"Đang xác thực ",
|
|
2184
|
-
|
|
2397
|
+
Be[f.provider]
|
|
2185
2398
|
] }),
|
|
2186
2399
|
/* @__PURE__ */ e("div", { style: a.subtitle, children: "Vui lòng hoàn thành trong cửa sổ bật lên" })
|
|
2187
2400
|
] })
|
|
2188
2401
|
] }) }),
|
|
2189
2402
|
/* @__PURE__ */ n("div", { style: a.oauthWaiting, children: [
|
|
2190
2403
|
/* @__PURE__ */ n("div", { style: { position: "relative", width: 72, height: 72 }, children: [
|
|
2191
|
-
/* @__PURE__ */ e("div", { style: { width: 72, height: 72, borderRadius: 20, background:
|
|
2404
|
+
/* @__PURE__ */ e("div", { style: { width: 72, height: 72, borderRadius: 20, background: Zt[f.provider] ?? "#f1f5f9", display: "flex", alignItems: "center", justifyContent: "center" }, children: /* @__PURE__ */ e(ge, { provider: f.provider, apiUrl: o, size: 48 }) }),
|
|
2192
2405
|
/* @__PURE__ */ n(
|
|
2193
2406
|
"svg",
|
|
2194
2407
|
{
|
|
@@ -2217,21 +2430,21 @@ https://www.myshop.com`,
|
|
|
2217
2430
|
] }),
|
|
2218
2431
|
/* @__PURE__ */ n("div", { style: a.oauthTitle, children: [
|
|
2219
2432
|
"Đang chờ xác thực với ",
|
|
2220
|
-
|
|
2433
|
+
Be[f.provider]
|
|
2221
2434
|
] }),
|
|
2222
2435
|
/* @__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." }),
|
|
2223
2436
|
/* @__PURE__ */ n("div", { style: { display: "flex", flexDirection: "column", gap: 8, alignItems: "flex-start", width: "100%", maxWidth: 280 }, children: [
|
|
2224
|
-
/* @__PURE__ */ e(
|
|
2225
|
-
/* @__PURE__ */ e(
|
|
2226
|
-
/* @__PURE__ */ e(
|
|
2437
|
+
/* @__PURE__ */ e(De, { done: !0, label: `Đã mở cửa sổ ${Be[f.provider]}` }),
|
|
2438
|
+
/* @__PURE__ */ e(De, { active: !0, label: "Đang chờ bạn đăng nhập & cấp quyền" }),
|
|
2439
|
+
/* @__PURE__ */ e(De, { label: "Lưu kết nối & quay về" })
|
|
2227
2440
|
] }),
|
|
2228
|
-
/* @__PURE__ */ e("button", { style: a.oauthCancel, onClick:
|
|
2441
|
+
/* @__PURE__ */ e("button", { style: a.oauthCancel, onClick: J, children: "Hủy và quay lại" })
|
|
2229
2442
|
] })
|
|
2230
2443
|
] }),
|
|
2231
|
-
f.name === "oauth-select" && /* @__PURE__ */ n(
|
|
2444
|
+
f.name === "oauth-select" && /* @__PURE__ */ n(te, { children: [
|
|
2232
2445
|
/* @__PURE__ */ n("div", { style: a.connectHeader, children: [
|
|
2233
|
-
/* @__PURE__ */ e("button", { style: a.backBtn, onClick:
|
|
2234
|
-
/* @__PURE__ */ e(
|
|
2446
|
+
/* @__PURE__ */ e("button", { style: a.backBtn, onClick: J, children: /* @__PURE__ */ e(ve, {}) }),
|
|
2447
|
+
/* @__PURE__ */ e(ge, { provider: f.provider, apiUrl: o, size: 44 }),
|
|
2235
2448
|
/* @__PURE__ */ n("div", { children: [
|
|
2236
2449
|
/* @__PURE__ */ n("div", { style: a.connectTitle, children: [
|
|
2237
2450
|
"Chọn ",
|
|
@@ -2239,16 +2452,16 @@ https://www.myshop.com`,
|
|
|
2239
2452
|
] }),
|
|
2240
2453
|
/* @__PURE__ */ n("div", { style: a.connectDesc, children: [
|
|
2241
2454
|
"Chọn ",
|
|
2242
|
-
|
|
2455
|
+
Be[f.provider],
|
|
2243
2456
|
" bạn muốn kết nối với ChannelHub"
|
|
2244
2457
|
] })
|
|
2245
2458
|
] })
|
|
2246
2459
|
] }),
|
|
2247
|
-
/* @__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((
|
|
2460
|
+
/* @__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(
|
|
2248
2461
|
"button",
|
|
2249
2462
|
{
|
|
2250
|
-
disabled:
|
|
2251
|
-
onClick: () => void se(
|
|
2463
|
+
disabled: H,
|
|
2464
|
+
onClick: () => void se(h.id),
|
|
2252
2465
|
style: {
|
|
2253
2466
|
display: "flex",
|
|
2254
2467
|
alignItems: "center",
|
|
@@ -2257,26 +2470,26 @@ https://www.myshop.com`,
|
|
|
2257
2470
|
borderRadius: 12,
|
|
2258
2471
|
border: "1.5px solid #e2e8f0",
|
|
2259
2472
|
background: "#fff",
|
|
2260
|
-
cursor:
|
|
2261
|
-
opacity:
|
|
2473
|
+
cursor: H ? "not-allowed" : "pointer",
|
|
2474
|
+
opacity: H ? 0.6 : 1,
|
|
2262
2475
|
textAlign: "left",
|
|
2263
2476
|
fontFamily: "inherit",
|
|
2264
2477
|
transition: "border-color .15s, background .15s"
|
|
2265
2478
|
},
|
|
2266
2479
|
children: [
|
|
2267
2480
|
/* @__PURE__ */ n("div", { children: [
|
|
2268
|
-
/* @__PURE__ */ e("div", { style: { fontSize: 14, fontWeight: 600, color: "#0f172a" }, children:
|
|
2269
|
-
/* @__PURE__ */ e("div", { style: { fontSize: 11, color: "#94a3b8", fontFamily: "monospace", marginTop: 2 }, children:
|
|
2481
|
+
/* @__PURE__ */ e("div", { style: { fontSize: 14, fontWeight: 600, color: "#0f172a" }, children: h.name }),
|
|
2482
|
+
/* @__PURE__ */ e("div", { style: { fontSize: 11, color: "#94a3b8", fontFamily: "monospace", marginTop: 2 }, children: h.id })
|
|
2270
2483
|
] }),
|
|
2271
|
-
/* @__PURE__ */ e("span", { style: { fontSize: 13, color: "#2563eb", fontWeight: 500 }, children:
|
|
2484
|
+
/* @__PURE__ */ e("span", { style: { fontSize: 13, color: "#2563eb", fontWeight: 500 }, children: H ? "Đang kết nối…" : "Chọn →" })
|
|
2272
2485
|
]
|
|
2273
2486
|
},
|
|
2274
|
-
|
|
2487
|
+
h.id
|
|
2275
2488
|
)) }) })
|
|
2276
2489
|
] })
|
|
2277
2490
|
] });
|
|
2278
2491
|
}
|
|
2279
|
-
function
|
|
2492
|
+
function rn(t) {
|
|
2280
2493
|
const i = t.metadata;
|
|
2281
2494
|
if (typeof i.pictureUrl == "string") return i.pictureUrl;
|
|
2282
2495
|
if (t.provider === "facebook")
|
|
@@ -2287,26 +2500,26 @@ function Ft(t) {
|
|
|
2287
2500
|
}
|
|
2288
2501
|
return null;
|
|
2289
2502
|
}
|
|
2290
|
-
function
|
|
2291
|
-
const [o,
|
|
2292
|
-
return
|
|
2503
|
+
function on({ conn: t, apiUrl: i, size: r = 40 }) {
|
|
2504
|
+
const [o, s] = g(!1), C = rn(t), m = Math.round(r * 0.28);
|
|
2505
|
+
return C && !o ? /* @__PURE__ */ e(
|
|
2293
2506
|
"img",
|
|
2294
2507
|
{
|
|
2295
|
-
src:
|
|
2296
|
-
alt:
|
|
2508
|
+
src: C,
|
|
2509
|
+
alt: Ve(t),
|
|
2297
2510
|
referrerPolicy: "no-referrer",
|
|
2298
|
-
onError: () =>
|
|
2299
|
-
style: { width: r, height: r, borderRadius:
|
|
2511
|
+
onError: () => s(!0),
|
|
2512
|
+
style: { width: r, height: r, borderRadius: m, objectFit: "cover", flexShrink: 0, display: "block" }
|
|
2300
2513
|
}
|
|
2301
|
-
) : /* @__PURE__ */ e(
|
|
2514
|
+
) : /* @__PURE__ */ e(ge, { provider: t.provider, apiUrl: i, size: r });
|
|
2302
2515
|
}
|
|
2303
|
-
function
|
|
2304
|
-
const [o,
|
|
2516
|
+
function an({ conn: t, apiUrl: i, onDisconnect: r }) {
|
|
2517
|
+
const [o, s] = g(!1);
|
|
2305
2518
|
return /* @__PURE__ */ n("div", { style: a.channelItem, children: [
|
|
2306
|
-
/* @__PURE__ */ e(
|
|
2519
|
+
/* @__PURE__ */ e(on, { conn: t, apiUrl: i, size: 40 }),
|
|
2307
2520
|
/* @__PURE__ */ n("div", { style: a.channelInfo, children: [
|
|
2308
|
-
/* @__PURE__ */ e("div", { style: a.channelName, children:
|
|
2309
|
-
/* @__PURE__ */ e("div", { style: a.channelMeta, children:
|
|
2521
|
+
/* @__PURE__ */ e("div", { style: a.channelName, children: Ve(t) }),
|
|
2522
|
+
/* @__PURE__ */ e("div", { style: a.channelMeta, children: Qt(t) })
|
|
2310
2523
|
] }),
|
|
2311
2524
|
/* @__PURE__ */ n("div", { style: a.channelActions, children: [
|
|
2312
2525
|
/* @__PURE__ */ e("span", { style: t.status === "active" ? a.badgeActive : a.badgeInactive, children: t.status === "active" ? "Hoạt động" : t.status }),
|
|
@@ -2317,8 +2530,8 @@ function qt({ conn: t, apiUrl: i, onDisconnect: r }) {
|
|
|
2317
2530
|
...a.disconnectBtn,
|
|
2318
2531
|
...o ? { background: "#fef2f2", borderColor: "#fca5a5", color: "#dc2626" } : {}
|
|
2319
2532
|
},
|
|
2320
|
-
onMouseEnter: () =>
|
|
2321
|
-
onMouseLeave: () =>
|
|
2533
|
+
onMouseEnter: () => s(!0),
|
|
2534
|
+
onMouseLeave: () => s(!1),
|
|
2322
2535
|
onClick: r,
|
|
2323
2536
|
children: "Ngắt kết nối"
|
|
2324
2537
|
}
|
|
@@ -2326,15 +2539,15 @@ function qt({ conn: t, apiUrl: i, onDisconnect: r }) {
|
|
|
2326
2539
|
] })
|
|
2327
2540
|
] });
|
|
2328
2541
|
}
|
|
2329
|
-
const
|
|
2542
|
+
const ln = [
|
|
2330
2543
|
{ id: "facebook", name: "Facebook", desc: "Fanpage & Messenger", type: "oauth" },
|
|
2331
2544
|
{ id: "zalo", name: "Zalo OA", desc: "Official Account", type: "oauth" },
|
|
2332
2545
|
{ id: "instagram", name: "Instagram", desc: "DM & Comments", type: "oauth" },
|
|
2333
2546
|
{ id: "telegram", name: "Telegram", desc: "Bot token", type: "token" },
|
|
2334
2547
|
{ id: "livechat", name: "Live Chat", desc: "Website widget", type: "livechat" }
|
|
2335
2548
|
];
|
|
2336
|
-
function
|
|
2337
|
-
const [o,
|
|
2549
|
+
function dn({ provider: t, apiUrl: i, onClick: r }) {
|
|
2550
|
+
const [o, s] = g(!1);
|
|
2338
2551
|
return /* @__PURE__ */ n(
|
|
2339
2552
|
"div",
|
|
2340
2553
|
{
|
|
@@ -2343,10 +2556,10 @@ function Gt({ provider: t, apiUrl: i, onClick: r }) {
|
|
|
2343
2556
|
...o ? { background: "#fff", borderColor: "#e2e8f0", boxShadow: "0 2px 8px rgba(0,0,0,.07)", transform: "translateY(-1px)" } : {}
|
|
2344
2557
|
},
|
|
2345
2558
|
onClick: r,
|
|
2346
|
-
onMouseEnter: () =>
|
|
2347
|
-
onMouseLeave: () =>
|
|
2559
|
+
onMouseEnter: () => s(!0),
|
|
2560
|
+
onMouseLeave: () => s(!1),
|
|
2348
2561
|
children: [
|
|
2349
|
-
/* @__PURE__ */ e(
|
|
2562
|
+
/* @__PURE__ */ e(ge, { provider: t.id, apiUrl: i, size: 44 }),
|
|
2350
2563
|
/* @__PURE__ */ n("div", { children: [
|
|
2351
2564
|
/* @__PURE__ */ e("div", { style: a.providerName, children: t.name }),
|
|
2352
2565
|
/* @__PURE__ */ e("div", { style: a.providerDesc, children: t.desc })
|
|
@@ -2355,7 +2568,7 @@ function Gt({ provider: t, apiUrl: i, onClick: r }) {
|
|
|
2355
2568
|
}
|
|
2356
2569
|
);
|
|
2357
2570
|
}
|
|
2358
|
-
function
|
|
2571
|
+
function De({ done: t, active: i, label: r }) {
|
|
2359
2572
|
return /* @__PURE__ */ n("div", { style: { display: "flex", alignItems: "center", gap: 10, fontSize: 13, color: t ? "#059669" : i ? "#0f172a" : "#94a3b8" }, children: [
|
|
2360
2573
|
/* @__PURE__ */ e("div", { style: {
|
|
2361
2574
|
width: 10,
|
|
@@ -2368,9 +2581,9 @@ function Be({ done: t, active: i, label: r }) {
|
|
|
2368
2581
|
r
|
|
2369
2582
|
] });
|
|
2370
2583
|
}
|
|
2371
|
-
console.log("[ChannelHub] widget v0.1.
|
|
2584
|
+
console.log("[ChannelHub] widget v0.1.6 loaded");
|
|
2372
2585
|
export {
|
|
2373
|
-
|
|
2374
|
-
|
|
2375
|
-
|
|
2586
|
+
un as ChannelHubChannels,
|
|
2587
|
+
Mt as ChannelHubClient,
|
|
2588
|
+
pn as ChannelHubInbox
|
|
2376
2589
|
};
|