@channelhub/widget 0.1.10 → 0.1.12

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/index.js CHANGED
@@ -1,20 +1,20 @@
1
- import { jsx as e, jsxs as n, Fragment as ie } from "react/jsx-runtime";
2
- import { forwardRef as Pe, createElement as et, createContext as wt, useRef as J, useState as y, useMemo as $e, useEffect as X, useCallback as we, useImperativeHandle as Bt, useContext as tt, Component as Lt } from "react";
3
- import { createPortal as St } from "react-dom";
1
+ import { jsx as e, jsxs as n, Fragment as ne } from "react/jsx-runtime";
2
+ import { forwardRef as Xe, createElement as dt, createContext as Ht, useRef as X, useState as u, useMemo as We, useEffect as K, useCallback as Te, useImperativeHandle as Ft, useContext as st, Component as Kt } from "react";
3
+ import { createPortal as At } 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 Mt = (t) => t.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase(), Ct = (...t) => t.filter((i, r, o) => !!i && i.trim() !== "" && o.indexOf(i) === r).join(" ").trim();
10
+ const qt = (t) => t.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase(), jt = (...t) => t.filter((i, o, r) => !!i && i.trim() !== "" && r.indexOf(i) === o).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 Ht = {
17
+ var Vt = {
18
18
  xmlns: "http://www.w3.org/2000/svg",
19
19
  width: 24,
20
20
  height: 24,
@@ -31,31 +31,31 @@ var Ht = {
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 jt = Pe(
34
+ const Gt = Xe(
35
35
  ({
36
36
  color: t = "currentColor",
37
37
  size: i = 24,
38
- strokeWidth: r = 2,
39
- absoluteStrokeWidth: o,
40
- className: h = "",
41
- children: S,
42
- iconNode: m,
43
- ...M
44
- }, w) => et(
38
+ strokeWidth: o = 2,
39
+ absoluteStrokeWidth: r,
40
+ className: c = "",
41
+ children: C,
42
+ iconNode: y,
43
+ ...L
44
+ }, w) => dt(
45
45
  "svg",
46
46
  {
47
47
  ref: w,
48
- ...Ht,
48
+ ...Vt,
49
49
  width: i,
50
50
  height: i,
51
51
  stroke: t,
52
- strokeWidth: o ? Number(r) * 24 / Number(i) : r,
53
- className: Ct("lucide", h),
54
- ...M
52
+ strokeWidth: r ? Number(o) * 24 / Number(i) : o,
53
+ className: jt("lucide", c),
54
+ ...L
55
55
  },
56
56
  [
57
- ...m.map(([v, W]) => et(v, W)),
58
- ...Array.isArray(S) ? S : [S]
57
+ ...y.map(([g, $]) => dt(g, $)),
58
+ ...Array.isArray(C) ? C : [C]
59
59
  ]
60
60
  )
61
61
  );
@@ -66,15 +66,15 @@ const jt = Pe(
66
66
  * See the LICENSE file in the root directory of this source tree.
67
67
  */
68
68
  const Y = (t, i) => {
69
- const r = Pe(
70
- ({ className: o, ...h }, S) => et(jt, {
71
- ref: S,
69
+ const o = Xe(
70
+ ({ className: r, ...c }, C) => dt(Gt, {
71
+ ref: C,
72
72
  iconNode: i,
73
- className: Ct(`lucide-${Mt(t)}`, o),
74
- ...h
73
+ className: jt(`lucide-${qt(t)}`, r),
74
+ ...c
75
75
  })
76
76
  );
77
- return r.displayName = `${t}`, r;
77
+ return o.displayName = `${t}`, o;
78
78
  };
79
79
  /**
80
80
  * @license lucide-react v0.468.0 - ISC
@@ -82,7 +82,17 @@ const Y = (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 ht = Y("CheckCheck", [
85
+ const Xt = Y("ArrowLeft", [
86
+ ["path", { d: "m12 19-7-7 7-7", key: "1l729n" }],
87
+ ["path", { d: "M19 12H5", key: "x3x0zl" }]
88
+ ]);
89
+ /**
90
+ * @license lucide-react v0.468.0 - ISC
91
+ *
92
+ * This source code is licensed under the ISC license.
93
+ * See the LICENSE file in the root directory of this source tree.
94
+ */
95
+ const wt = Y("CheckCheck", [
86
96
  ["path", { d: "M18 6 7 17l-5-5", key: "116fxf" }],
87
97
  ["path", { d: "m22 10-7.5 7.5L13 16", key: "ke71qq" }]
88
98
  ]);
@@ -92,14 +102,14 @@ const ht = Y("CheckCheck", [
92
102
  * This source code is licensed under the ISC license.
93
103
  * See the LICENSE file in the root directory of this source tree.
94
104
  */
95
- const lt = Y("Check", [["path", { d: "M20 6 9 17l-5-5", key: "1gmf2c" }]]);
105
+ const gt = Y("Check", [["path", { d: "M20 6 9 17l-5-5", key: "1gmf2c" }]]);
96
106
  /**
97
107
  * @license lucide-react v0.468.0 - ISC
98
108
  *
99
109
  * This source code is licensed under the ISC license.
100
110
  * See the LICENSE file in the root directory of this source tree.
101
111
  */
102
- const nt = Y("ChevronDown", [
112
+ const ct = Y("ChevronDown", [
103
113
  ["path", { d: "m6 9 6 6 6-6", key: "qrunsl" }]
104
114
  ]);
105
115
  /**
@@ -108,7 +118,7 @@ const nt = Y("ChevronDown", [
108
118
  * This source code is licensed under the ISC license.
109
119
  * See the LICENSE file in the root directory of this source tree.
110
120
  */
111
- const At = Y("ChevronRight", [
121
+ const Yt = Y("ChevronRight", [
112
122
  ["path", { d: "m9 18 6-6-6-6", key: "mthhwq" }]
113
123
  ]);
114
124
  /**
@@ -117,7 +127,7 @@ const At = Y("ChevronRight", [
117
127
  * This source code is licensed under the ISC license.
118
128
  * See the LICENSE file in the root directory of this source tree.
119
129
  */
120
- const Et = Y("CircleAlert", [
130
+ const Jt = Y("CircleAlert", [
121
131
  ["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }],
122
132
  ["line", { x1: "12", x2: "12", y1: "8", y2: "12", key: "1pkeuh" }],
123
133
  ["line", { x1: "12", x2: "12.01", y1: "16", y2: "16", key: "4dfq90" }]
@@ -128,7 +138,7 @@ const Et = Y("CircleAlert", [
128
138
  * This source code is licensed under the ISC license.
129
139
  * See the LICENSE file in the root directory of this source tree.
130
140
  */
131
- const It = Y("Ellipsis", [
141
+ const Et = Y("Ellipsis", [
132
142
  ["circle", { cx: "12", cy: "12", r: "1", key: "41hilf" }],
133
143
  ["circle", { cx: "19", cy: "12", r: "1", key: "1wjl8i" }],
134
144
  ["circle", { cx: "5", cy: "12", r: "1", key: "1pcz8c" }]
@@ -139,7 +149,7 @@ const It = Y("Ellipsis", [
139
149
  * This source code is licensed under the ISC license.
140
150
  * See the LICENSE file in the root directory of this source tree.
141
151
  */
142
- const Ut = Y("Image", [
152
+ const Zt = Y("Image", [
143
153
  ["rect", { width: "18", height: "18", x: "3", y: "3", rx: "2", ry: "2", key: "1m3agn" }],
144
154
  ["circle", { cx: "9", cy: "9", r: "2", key: "af1f0g" }],
145
155
  ["path", { d: "m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21", key: "1xmnt7" }]
@@ -150,7 +160,7 @@ const Ut = Y("Image", [
150
160
  * This source code is licensed under the ISC license.
151
161
  * See the LICENSE file in the root directory of this source tree.
152
162
  */
153
- const Ot = Y("Inbox", [
163
+ const _t = Y("Inbox", [
154
164
  ["polyline", { points: "22 12 16 12 14 15 10 15 8 12 2 12", key: "o97t9d" }],
155
165
  [
156
166
  "path",
@@ -166,7 +176,7 @@ const Ot = Y("Inbox", [
166
176
  * This source code is licensed under the ISC license.
167
177
  * See the LICENSE file in the root directory of this source tree.
168
178
  */
169
- const Dt = Y("Info", [
179
+ const Qt = Y("Info", [
170
180
  ["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }],
171
181
  ["path", { d: "M12 16v-4", key: "1dtifu" }],
172
182
  ["path", { d: "M12 8h.01", key: "e9boi3" }]
@@ -177,7 +187,7 @@ const Dt = Y("Info", [
177
187
  * This source code is licensed under the ISC license.
178
188
  * See the LICENSE file in the root directory of this source tree.
179
189
  */
180
- const zt = Y("LoaderCircle", [
190
+ const Ot = Y("LoaderCircle", [
181
191
  ["path", { d: "M21 12a9 9 0 1 1-6.219-8.56", key: "13zald" }]
182
192
  ]);
183
193
  /**
@@ -186,7 +196,7 @@ const zt = Y("LoaderCircle", [
186
196
  * This source code is licensed under the ISC license.
187
197
  * See the LICENSE file in the root directory of this source tree.
188
198
  */
189
- const pt = Y("MessageCircle", [
199
+ const St = Y("MessageCircle", [
190
200
  ["path", { d: "M7.9 20A9 9 0 1 0 4 16.1L2 22Z", key: "vv11sd" }]
191
201
  ]);
192
202
  /**
@@ -195,7 +205,7 @@ const pt = Y("MessageCircle", [
195
205
  * This source code is licensed under the ISC license.
196
206
  * See the LICENSE file in the root directory of this source tree.
197
207
  */
198
- const Pt = Y("Paperclip", [
208
+ const en = Y("Paperclip", [
199
209
  ["path", { d: "M13.234 20.252 21 12.3", key: "1cbrk9" }],
200
210
  [
201
211
  "path",
@@ -211,7 +221,7 @@ const Pt = Y("Paperclip", [
211
221
  * This source code is licensed under the ISC license.
212
222
  * See the LICENSE file in the root directory of this source tree.
213
223
  */
214
- const Nt = Y("Play", [
224
+ const tn = Y("Play", [
215
225
  ["polygon", { points: "6 3 20 12 6 21 6 3", key: "1oa8hb" }]
216
226
  ]);
217
227
  /**
@@ -220,7 +230,7 @@ const Nt = Y("Play", [
220
230
  * This source code is licensed under the ISC license.
221
231
  * See the LICENSE file in the root directory of this source tree.
222
232
  */
223
- const ut = Y("Search", [
233
+ const Ct = Y("Search", [
224
234
  ["circle", { cx: "11", cy: "11", r: "8", key: "4ej97u" }],
225
235
  ["path", { d: "m21 21-4.3-4.3", key: "1qie3q" }]
226
236
  ]);
@@ -230,7 +240,7 @@ const ut = Y("Search", [
230
240
  * This source code is licensed under the ISC license.
231
241
  * See the LICENSE file in the root directory of this source tree.
232
242
  */
233
- const Ft = Y("Send", [
243
+ const nn = Y("Send", [
234
244
  [
235
245
  "path",
236
246
  {
@@ -246,7 +256,7 @@ const Ft = Y("Send", [
246
256
  * This source code is licensed under the ISC license.
247
257
  * See the LICENSE file in the root directory of this source tree.
248
258
  */
249
- const Kt = Y("SlidersHorizontal", [
259
+ const on = Y("SlidersHorizontal", [
250
260
  ["line", { x1: "21", x2: "14", y1: "4", y2: "4", key: "obuewd" }],
251
261
  ["line", { x1: "10", x2: "3", y1: "4", y2: "4", key: "1q6298" }],
252
262
  ["line", { x1: "21", x2: "12", y1: "12", y2: "12", key: "1iu8h1" }],
@@ -263,7 +273,7 @@ const Kt = Y("SlidersHorizontal", [
263
273
  * This source code is licensed under the ISC license.
264
274
  * See the LICENSE file in the root directory of this source tree.
265
275
  */
266
- const qt = Y("Smile", [
276
+ const rn = Y("Smile", [
267
277
  ["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }],
268
278
  ["path", { d: "M8 14s1.5 2 4 2 4-2 4-2", key: "1y1vjs" }],
269
279
  ["line", { x1: "9", x2: "9.01", y1: "9", y2: "9", key: "yxxnd0" }],
@@ -275,7 +285,7 @@ const qt = Y("Smile", [
275
285
  * This source code is licensed under the ISC license.
276
286
  * See the LICENSE file in the root directory of this source tree.
277
287
  */
278
- const Vt = Y("UserCheck", [
288
+ const an = Y("UserCheck", [
279
289
  ["path", { d: "M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2", key: "1yyitq" }],
280
290
  ["circle", { cx: "9", cy: "7", r: "4", key: "nufk8" }],
281
291
  ["polyline", { points: "16 11 18 13 22 9", key: "1pwet4" }]
@@ -286,7 +296,7 @@ const Vt = Y("UserCheck", [
286
296
  * This source code is licensed under the ISC license.
287
297
  * See the LICENSE file in the root directory of this source tree.
288
298
  */
289
- const ft = Y("UserPlus", [
299
+ const It = Y("UserPlus", [
290
300
  ["path", { d: "M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2", key: "1yyitq" }],
291
301
  ["circle", { cx: "9", cy: "7", r: "4", key: "nufk8" }],
292
302
  ["line", { x1: "19", x2: "19", y1: "8", y2: "14", key: "1bvyxn" }],
@@ -298,7 +308,7 @@ const ft = Y("UserPlus", [
298
308
  * This source code is licensed under the ISC license.
299
309
  * See the LICENSE file in the root directory of this source tree.
300
310
  */
301
- const Oe = Y("X", [
311
+ const Ve = Y("X", [
302
312
  ["path", { d: "M18 6 6 18", key: "1bl5f8" }],
303
313
  ["path", { d: "m6 6 12 12", key: "d8bk6v" }]
304
314
  ]);
@@ -308,7 +318,7 @@ const Oe = Y("X", [
308
318
  * This source code is licensed under the ISC license.
309
319
  * See the LICENSE file in the root directory of this source tree.
310
320
  */
311
- const Gt = Y("Zap", [
321
+ const ln = Y("Zap", [
312
322
  [
313
323
  "path",
314
324
  {
@@ -317,29 +327,29 @@ const Gt = Y("Zap", [
317
327
  }
318
328
  ]
319
329
  ]);
320
- class it {
321
- constructor(i, r) {
322
- this.apiUrl = i, this.token = r;
330
+ class ht {
331
+ constructor(i, o) {
332
+ this.apiUrl = i, this.token = o;
323
333
  }
324
- async request(i, r, o) {
325
- const h = {
334
+ async request(i, o, r) {
335
+ const c = {
326
336
  authorization: `Bearer ${this.token}`,
327
- ...o ? {} : { "content-type": "application/json" },
328
- ...r == null ? void 0 : r.headers
329
- }, S = await fetch(`${this.apiUrl}${i}`, {
330
- ...r,
331
- headers: h
332
- }), m = await S.json().catch(() => null);
333
- if (!S.ok) throw new Error((m == null ? void 0 : m.message) ?? `Request failed (${S.status})`);
334
- return m;
337
+ ...r ? {} : { "content-type": "application/json" },
338
+ ...o == null ? void 0 : o.headers
339
+ }, C = await fetch(`${this.apiUrl}${i}`, {
340
+ ...o,
341
+ headers: c
342
+ }), y = await C.json().catch(() => null);
343
+ if (!C.ok) throw new Error((y == null ? void 0 : y.message) ?? `Request failed (${C.status})`);
344
+ return y;
335
345
  }
336
346
  getSessionMe() {
337
347
  return this.request("/v1/auth/session/me");
338
348
  }
339
- assignConversation(i, r) {
349
+ assignConversation(i, o) {
340
350
  return this.request(`/v1/conversations/${encodeURIComponent(i)}/assignee`, {
341
351
  method: "PUT",
342
- body: JSON.stringify({ agent: r })
352
+ body: JSON.stringify({ agent: o })
343
353
  });
344
354
  }
345
355
  listConnections() {
@@ -348,87 +358,87 @@ class it {
348
358
  listConversations(i) {
349
359
  return this.request(`/v1/conversations${i ? `?cursor=${encodeURIComponent(i)}` : ""}`);
350
360
  }
351
- listMessages(i, r) {
352
- return this.request(`/v1/conversations/${encodeURIComponent(i)}/messages${r ? `?cursor=${encodeURIComponent(r)}` : ""}`);
361
+ listMessages(i, o) {
362
+ return this.request(`/v1/conversations/${encodeURIComponent(i)}/messages${o ? `?cursor=${encodeURIComponent(o)}` : ""}`);
353
363
  }
354
364
  getMessage(i) {
355
365
  return this.request(`/v1/messages/${encodeURIComponent(i)}`);
356
366
  }
357
- sendMessage(i, r, o) {
367
+ sendMessage(i, o, r) {
358
368
  return this.request(`/v1/conversations/${encodeURIComponent(i)}/messages`, {
359
369
  method: "POST",
360
370
  headers: { "idempotency-key": crypto.randomUUID() },
361
- body: JSON.stringify({ text: r, attachments: o })
371
+ body: JSON.stringify({ text: o, attachments: r })
362
372
  });
363
373
  }
364
374
  async markRead(i) {
365
- const r = await fetch(`${this.apiUrl}/v1/conversations/${encodeURIComponent(i)}/mark-read`, {
375
+ const o = await fetch(`${this.apiUrl}/v1/conversations/${encodeURIComponent(i)}/mark-read`, {
366
376
  method: "POST",
367
377
  headers: { authorization: `Bearer ${this.token}` }
368
378
  });
369
- if (!r.ok && r.status !== 204) throw new Error(`markRead failed (${r.status})`);
379
+ if (!o.ok && o.status !== 204) throw new Error(`markRead failed (${o.status})`);
370
380
  }
371
381
  listCannedResponses(i) {
372
- const r = i != null && i.trim() ? `?search=${encodeURIComponent(i)}` : "";
373
- return this.request(`/v1/canned-responses${r}`);
382
+ const o = i != null && i.trim() ? `?search=${encodeURIComponent(i)}` : "";
383
+ return this.request(`/v1/canned-responses${o}`);
374
384
  }
375
385
  getNote(i) {
376
386
  return this.request(`/v1/conversations/${encodeURIComponent(i)}/note`);
377
387
  }
378
- patchContact(i, r) {
388
+ patchContact(i, o) {
379
389
  return this.request(`/v1/contacts/${encodeURIComponent(i)}`, {
380
390
  method: "PATCH",
381
- body: JSON.stringify({ externalId: r })
391
+ body: JSON.stringify({ externalId: o })
382
392
  });
383
393
  }
384
- upsertNote(i, r) {
394
+ upsertNote(i, o) {
385
395
  return this.request(`/v1/conversations/${encodeURIComponent(i)}/note`, {
386
396
  method: "PUT",
387
- body: JSON.stringify({ content: r })
397
+ body: JSON.stringify({ content: o })
388
398
  });
389
399
  }
390
400
  async uploadAttachment(i) {
391
- const r = new FormData();
392
- return r.append("file", i), this.request(
401
+ const o = new FormData();
402
+ return o.append("file", i), this.request(
393
403
  "/v1/attachments",
394
- { method: "POST", body: r },
404
+ { method: "POST", body: o },
395
405
  !0
396
406
  );
397
407
  }
398
408
  connectSSE(i) {
399
- const r = `${this.apiUrl}/v1/events?token=${encodeURIComponent(this.token)}`;
400
- let o, h, S = !1;
401
- const m = () => {
402
- o = new EventSource(r), o.addEventListener("message.new", (M) => {
403
- i("message.new", JSON.parse(M.data));
404
- }), o.addEventListener("conversation.updated", (M) => {
405
- i("conversation.updated", JSON.parse(M.data));
406
- }), o.onerror = () => {
407
- o.close(), S || (h = setTimeout(m, 5e3));
409
+ const o = `${this.apiUrl}/v1/events?token=${encodeURIComponent(this.token)}`;
410
+ let r, c, C = !1;
411
+ const y = () => {
412
+ r = new EventSource(o), r.addEventListener("message.new", (L) => {
413
+ i("message.new", JSON.parse(L.data));
414
+ }), r.addEventListener("conversation.updated", (L) => {
415
+ i("conversation.updated", JSON.parse(L.data));
416
+ }), r.onerror = () => {
417
+ r.close(), C || (c = setTimeout(y, 5e3));
408
418
  };
409
419
  };
410
- return m(), () => {
411
- S = !0, clearTimeout(h), o == null || o.close();
420
+ return y(), () => {
421
+ C = !0, clearTimeout(c), r == null || r.close();
412
422
  };
413
423
  }
414
424
  }
415
- function dt({ src: t, alt: i = "", fallback: r, style: o }) {
416
- 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 });
425
+ function bt({ src: t, alt: i = "", fallback: o, style: r }) {
426
+ return t ? /* @__PURE__ */ e("img", { src: t, alt: i, style: { width: 38, height: 38, borderRadius: "50%", objectFit: "cover", ...r } }) : /* @__PURE__ */ e("span", { style: { display: "grid", placeItems: "center", width: 38, height: 38, borderRadius: "50%", ...r }, children: o });
417
427
  }
418
- function Xt({ variant: t = "ghost", style: i, ...r }) {
419
- 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 } });
428
+ function dn({ variant: t = "ghost", style: i, ...o }) {
429
+ return /* @__PURE__ */ e("button", { ...o, 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 } });
420
430
  }
421
- function Yt({ style: t, ...i }) {
431
+ function sn({ style: t, ...i }) {
422
432
  return /* @__PURE__ */ e("input", { ...i, style: { width: "100%", minWidth: 0, border: 0, outline: 0, background: "transparent", font: "inherit", ...t } });
423
433
  }
424
- const Rt = Pe(
425
- ({ children: t, style: i }, r) => /* @__PURE__ */ e("div", { ref: r, style: { minHeight: 0, overflowY: "auto", overscrollBehavior: "contain", ...i }, children: t })
426
- ), Jt = Pe(
427
- function({ style: i, ...r }, o) {
428
- 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 } });
434
+ const Ut = Xe(
435
+ ({ children: t, style: i }, o) => /* @__PURE__ */ e("div", { ref: o, style: { minHeight: 0, overflowY: "auto", overscrollBehavior: "contain", ...i }, children: t })
436
+ ), cn = Xe(
437
+ function({ style: i, ...o }, r) {
438
+ return /* @__PURE__ */ e("textarea", { ref: r, ...o, style: { display: "block", width: "100%", minWidth: 0, boxSizing: "border-box", resize: "vertical", border: 0, outline: 0, background: "transparent", font: "inherit", ...i } });
429
439
  }
430
440
  );
431
- function Zt(t) {
441
+ function hn(t) {
432
442
  return {
433
443
  id: t.contactId ?? t.providerConversationKey,
434
444
  name: t.contactName,
@@ -437,10 +447,10 @@ function Zt(t) {
437
447
  ...t.contactExternalId ? { externalId: t.contactExternalId } : {}
438
448
  };
439
449
  }
440
- function Je(t, i) {
450
+ function ot(t, i) {
441
451
  return {
442
452
  conversation: t,
443
- contact: Zt(t),
453
+ contact: hn(t),
444
454
  provider: i == null ? void 0 : i.provider,
445
455
  recentMessages: i == null ? void 0 : i.recentMessages,
446
456
  linkContact: (i == null ? void 0 : i.linkContact) ?? (async () => {
@@ -451,7 +461,7 @@ function Je(t, i) {
451
461
  })
452
462
  };
453
463
  }
454
- class _t extends Lt {
464
+ class pn extends Kt {
455
465
  constructor() {
456
466
  super(...arguments), this.state = { caught: !1 };
457
467
  }
@@ -462,34 +472,34 @@ class _t extends Lt {
462
472
  return this.state.caught ? null : this.props.children;
463
473
  }
464
474
  }
465
- const d = { ink: "#172033", muted: "#718096", line: "#e7ebf2", surface: "#f7f9fc", white: "#fff" }, gt = [
475
+ const a = { ink: "#172033", muted: "#718096", line: "#e7ebf2", surface: "#f7f9fc", white: "#fff" }, zt = [
466
476
  { icon: "😊", emojis: ["😀", "😁", "😂", "🤣", "😊", "😇", "🙂", "😉", "😍", "🥰", "😘", "😋", "😎", "🤩", "😏", "😒", "😔", "😢", "😭", "😤", "😠", "🤯", "😱", "🥳", "😴", "🤔", "🤗", "🫡", "😮", "🤧", "🥺", "😶", "🫠", "🤭", "🤫"] },
467
477
  { icon: "👋", emojis: ["👍", "👎", "👏", "🙏", "🤝", "✌️", "🤞", "🫡", "💪", "🤜", "👊", "✊", "🖐", "👌", "🤌", "🤏", "☝️", "👆", "👇", "👉", "👈", "🤙", "💅", "🫶", "❤️", "🧡", "💛", "💚", "💙", "💜", "🖤", "💔", "❣️", "💕", "💯"] },
468
478
  { icon: "🐱", emojis: ["🐶", "🐱", "🐭", "🐹", "🐰", "🦊", "🐻", "🐼", "🐨", "🐯", "🦁", "🐮", "🐷", "🐸", "🐵", "🙈", "🐔", "🐧", "🐦", "🦆", "🦅", "🦉", "🦋", "🐝", "🐛", "🐢", "🦎", "🐬", "🦈", "🐳", "🐙", "🦑"] },
469
479
  { icon: "🍕", emojis: ["🍎", "🍊", "🍋", "🍇", "🍓", "🍒", "🥝", "🥑", "🍔", "🍕", "🌮", "🍜", "🍣", "🍦", "🎂", "🍰", "🧁", "☕", "🧋", "🥤", "🍺", "🥂", "🍾", "🧃", "🧊"] },
470
480
  { icon: "⚽", emojis: ["⚽", "🏀", "🏈", "⚾", "🎾", "🏐", "🏓", "🎮", "🎲", "🎯", "🎳", "🏆", "🥇", "🎖", "🎁", "🎉", "🎊", "🎈", "🎭", "🎨", "🎬", "🎵", "🎸", "🎹", "🎺", "🪗", "🎻"] },
471
481
  { icon: "🌍", emojis: ["🌍", "🌈", "⭐", "🌙", "☀️", "⛅", "🌊", "🔥", "💧", "🌿", "🌸", "🌺", "🌻", "🍀", "🌴", "🏔", "🏖", "🏕", "🌃", "🏙", "🌅", "🌄", "🌠", "🌌", "🌋", "🏝"] }
472
- ], st = wt(""), Tt = wt("");
473
- function Qt() {
482
+ ], yt = Ht(""), Dt = Ht("");
483
+ function un() {
474
484
  try {
475
- const t = new AudioContext(), i = t.createOscillator(), r = t.createGain();
476
- 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);
485
+ const t = new AudioContext(), i = t.createOscillator(), o = t.createGain();
486
+ i.connect(o), o.connect(t.destination), i.type = "sine", i.frequency.setValueAtTime(880, t.currentTime), i.frequency.exponentialRampToValueAtTime(660, t.currentTime + 0.12), o.gain.setValueAtTime(0.25, t.currentTime), o.gain.exponentialRampToValueAtTime(1e-3, t.currentTime + 0.35), i.start(t.currentTime), i.stop(t.currentTime + 0.35);
477
487
  } catch {
478
488
  }
479
489
  }
480
- function en(t) {
490
+ function fn(t) {
481
491
  if (!(t != null && t.metadata)) return;
482
- const i = t.metadata, r = i.pageName ?? i.displayName ?? i.username ?? i.name;
483
- return typeof r == "string" && r ? r : void 0;
492
+ const i = t.metadata, o = i.pageName ?? i.displayName ?? i.username ?? i.name;
493
+ return typeof o == "string" && o ? o : void 0;
484
494
  }
485
- function Wt(t) {
495
+ function Nt(t) {
486
496
  return t === "facebook" ? "Facebook Messenger" : t === "instagram" ? "Instagram" : t === "telegram" ? "Telegram" : t === "zalo" ? "Zalo OA" : t === "livechat" ? "Live Chat" : "Channel";
487
497
  }
488
- function yt(t) {
498
+ function Rt(t) {
489
499
  return t === "facebook" ? "Facebook" : t === "instagram" ? "Instagram" : t === "telegram" ? "Telegram" : t === "zalo" ? "Zalo" : t === "livechat" ? "Live Chat" : String(t ?? "");
490
500
  }
491
- const tn = (t) => {
492
- var r;
501
+ const gn = (t) => {
502
+ var o;
493
503
  const i = {
494
504
  "application/pdf": "PDF",
495
505
  "video/mp4": "Video MP4",
@@ -497,124 +507,138 @@ const tn = (t) => {
497
507
  "audio/ogg": "Audio OGG",
498
508
  "application/octet-stream": "Tệp đính kèm"
499
509
  };
500
- return t ? i[t] ?? ((r = t.split("/")[1]) == null ? void 0 : r.toUpperCase()) ?? "Tệp" : "Tệp đính kèm";
510
+ return t ? i[t] ?? ((o = t.split("/")[1]) == null ? void 0 : o.toUpperCase()) ?? "Tệp" : "Tệp đính kèm";
501
511
  };
502
- function bt({ status: t }) {
503
- return t === "read" ? /* @__PURE__ */ e(ht, { size: 11, strokeWidth: 2, style: { display: "inline", verticalAlign: "middle" } }) : t === "delivered" ? /* @__PURE__ */ e(ht, { size: 11, strokeWidth: 2, style: { display: "inline", verticalAlign: "middle", opacity: 0.5 } }) : t === "sent" ? /* @__PURE__ */ e(lt, { size: 11, strokeWidth: 2, style: { display: "inline", verticalAlign: "middle" } }) : null;
512
+ function Wt({ status: t }) {
513
+ return t === "read" ? /* @__PURE__ */ e(wt, { size: 11, strokeWidth: 2, style: { display: "inline", verticalAlign: "middle" } }) : t === "delivered" ? /* @__PURE__ */ e(wt, { size: 11, strokeWidth: 2, style: { display: "inline", verticalAlign: "middle", opacity: 0.5 } }) : t === "sent" ? /* @__PURE__ */ e(gt, { size: 11, strokeWidth: 2, style: { display: "inline", verticalAlign: "middle" } }) : null;
504
514
  }
505
- function rt(t) {
515
+ function pt(t) {
506
516
  const i = t.trim().split(/\s+/).filter(Boolean);
507
517
  return i.length <= 2 ? t.trim() : i.slice(-2).join(" ");
508
518
  }
509
- const Wn = Pe(function({ apiUrl: i, token: r, theme: o, height: h, defaultConversationId: S, disableAttachments: m, disableNotificationSound: M, hideKeyboardHint: w, locale: v = "vi", extensions: W, currentAgent: T, teamAgents: A, onNewMessage: $, onConversationSelect: C }, D) {
510
- var k, j, K, O, re;
511
- const I = J(new it(i, r)), [L, P] = y([]), [q, te] = y([]), [Q, B] = y(), [x, b] = y(), E = J(void 0), [V, ne] = y(""), [de, z] = y("all"), [oe, Z] = y(null), [U, ee] = y({ provider: "all", unreadOnly: !1 }), [se, c] = y(!1), H = J(null), N = J(null), [ae, ce] = y(null), [ye, F] = y(!0), [he, Se] = y(""), [Me, He] = y(() => !!(W != null && W.length)), [je, Ce] = y(280), [ve, Ie] = y(!1), [Ne, me] = y(0), _ = (o == null ? void 0 : o.primaryColor) ?? "#2563eb", ue = $e(() => new Map(q.map((l) => [l.id, l])), [q]), ze = J(null), [Fe, Ae] = y(0), G = T ?? oe ?? null;
512
- X(() => {
513
- I.current = new it(i, r), T || I.current.getSessionMe().then((l) => {
514
- l != null && l.agent && Z(l.agent);
519
+ const Nn = Xe(function({ apiUrl: i, token: o, theme: r, height: c, defaultConversationId: C, disableAttachments: y, disableNotificationSound: L, hideKeyboardHint: w, locale: g = "vi", extensions: $, currentAgent: T, teamAgents: E, onNewMessage: M, onConversationSelect: I }, q) {
520
+ var ge, tt, xt, vt, kt;
521
+ const R = X(new ht(i, o)), [H, J] = u([]), [F, re] = u([]), [V, B] = u(), [b, S] = u(), D = X(void 0), [j, Z] = u(""), [pe, ve] = u("all"), [fe, se] = u(null), [G, k] = u({ provider: "all", unreadOnly: !1 }), [ie, h] = u(!1), A = X(null), U = X(null), [z, ce] = u(null), [de, Q] = u(!0), [he, Ye] = u(""), ke = X(null), [Ie, Ee] = u(() => typeof window < "u" ? window.innerWidth : 1200), ee = Ie < 640 ? "mobile" : Ie < 1024 ? "tablet" : "desktop", [Oe, $e] = u(() => C ? "chat" : "list"), [we, ue] = u(() => typeof window < "u" && window.innerWidth < 1024 ? !1 : !!($ != null && $.length)), Be = X(ee), [Ue, De] = u(280), [Ne, Je] = u(!1), [Pe, ze] = u(0), _ = (r == null ? void 0 : r.primaryColor) ?? "#2563eb", oe = We(() => new Map(F.map((d) => [d.id, d])), [F]), Le = X(null), [Ze, Me] = u(0);
522
+ K(() => {
523
+ const d = ke.current;
524
+ if (!d || typeof ResizeObserver > "u") return;
525
+ const p = new ResizeObserver((m) => {
526
+ for (const W of m) {
527
+ const le = W.contentRect.width;
528
+ le > 0 && Ee(le);
529
+ }
530
+ });
531
+ return p.observe(d), () => p.disconnect();
532
+ }, [de, he]), K(() => {
533
+ Be.current === "desktop" && ee !== "desktop" && ue(!1), Be.current = ee;
534
+ }, [ee]);
535
+ const ye = We(() => H.filter((d) => d.id !== (b == null ? void 0 : b.id) && (d.unreadCount ?? 0) > 0).length, [H, b == null ? void 0 : b.id]), te = T ?? fe ?? null;
536
+ K(() => {
537
+ R.current = new ht(i, o), T || R.current.getSessionMe().then((d) => {
538
+ d != null && d.agent && se(d.agent);
515
539
  }).catch(() => {
516
540
  });
517
- }, [i, r, T]);
518
- const Ke = $e(() => {
541
+ }, [i, o, T]);
542
+ const _e = We(() => {
519
543
  var p;
520
- const l = /* @__PURE__ */ new Map();
521
- G != null && G.id && l.set(G.id, G);
522
- for (const u of A ?? [])
523
- u != null && u.id && !l.has(u.id) && l.set(u.id, u);
524
- for (const u of L)
525
- (p = u.assignedAgent) != null && p.id && !l.has(u.assignedAgent.id) && l.set(u.assignedAgent.id, u.assignedAgent);
526
- return [...l.values()];
527
- }, [G, A, L]), qe = we(async (l, p) => {
528
- P((u) => u.map((R) => R.id === l.id ? { ...R, assignedAgent: p } : R)), b((u) => u && u.id === l.id ? { ...u, assignedAgent: p } : u), me((u) => u + 1);
544
+ const d = /* @__PURE__ */ new Map();
545
+ te != null && te.id && d.set(te.id, te);
546
+ for (const m of E ?? [])
547
+ m != null && m.id && !d.has(m.id) && d.set(m.id, m);
548
+ for (const m of H)
549
+ (p = m.assignedAgent) != null && p.id && !d.has(m.assignedAgent.id) && d.set(m.assignedAgent.id, m.assignedAgent);
550
+ return [...d.values()];
551
+ }, [te, E, H]), rt = Te(async (d, p) => {
552
+ J((m) => m.map((W) => W.id === d.id ? { ...W, assignedAgent: p } : W)), S((m) => m && m.id === d.id ? { ...m, assignedAgent: p } : m), ze((m) => m + 1);
529
553
  try {
530
- const u = await I.current.assignConversation(l.id, p);
531
- P((R) => R.map((le) => le.id === l.id ? { ...le, ...u, assignedAgent: u.assignedAgent ?? p } : le)), b((R) => R && R.id === l.id ? { ...R, ...u, assignedAgent: u.assignedAgent ?? p } : R), me((R) => R + 1);
554
+ const m = await R.current.assignConversation(d.id, p);
555
+ J((W) => W.map((le) => le.id === d.id ? { ...le, ...m, assignedAgent: m.assignedAgent ?? p } : le)), S((W) => W && W.id === d.id ? { ...W, ...m, assignedAgent: m.assignedAgent ?? p } : W), ze((W) => W + 1);
532
556
  } catch {
533
557
  }
534
- }, []), ke = we(async (l, p) => {
535
- l.contactId && await I.current.patchContact(l.contactId, p), P((u) => u.map((R) => R.id === l.id ? { ...R, contactExternalId: p ?? void 0 } : R)), b((u) => u && u.id === l.id ? { ...u, contactExternalId: p ?? void 0 } : u), me((u) => u + 1);
536
- }, []), fe = we(() => {
537
- me((l) => l + 1);
538
- }, []), Ve = $e(() => {
539
- const l = new Set(q.map((p) => p.provider));
540
- return ["facebook", "instagram", "telegram", "zalo", "livechat"].filter((p) => l.has(p));
541
- }, [q]), Ge = $e(() => {
558
+ }, []), Fe = Te(async (d, p) => {
559
+ d.contactId && await R.current.patchContact(d.contactId, p), J((m) => m.map((W) => W.id === d.id ? { ...W, contactExternalId: p ?? void 0 } : W)), S((m) => m && m.id === d.id ? { ...m, contactExternalId: p ?? void 0 } : m), ze((m) => m + 1);
560
+ }, []), me = Te(() => {
561
+ ze((d) => d + 1);
562
+ }, []), xe = We(() => {
563
+ const d = new Set(F.map((p) => p.provider));
564
+ return ["facebook", "instagram", "telegram", "zalo", "livechat"].filter((p) => d.has(p));
565
+ }, [F]), Qe = We(() => {
542
566
  var p;
543
- const l = {};
544
- for (const u of L) {
545
- const R = ((p = ue.get(u.connectionId)) == null ? void 0 : p.provider) ?? "unknown";
546
- l[R] = (l[R] ?? 0) + 1;
567
+ const d = {};
568
+ for (const m of H) {
569
+ const W = ((p = oe.get(m.connectionId)) == null ? void 0 : p.provider) ?? "unknown";
570
+ d[W] = (d[W] ?? 0) + 1;
547
571
  }
548
- return l;
549
- }, [L, ue]);
550
- function Ze(l) {
551
- const p = l.clientX, u = je;
552
- Ie(!0), document.body.style.cursor = "col-resize", document.body.style.userSelect = "none";
553
- function R(We) {
554
- const Ee = Math.max(200, Math.min(480, u + (p - We.clientX)));
555
- Ce(Ee);
572
+ return d;
573
+ }, [H, oe]);
574
+ function et(d) {
575
+ const p = d.clientX, m = Ue;
576
+ Je(!0), document.body.style.cursor = "col-resize", document.body.style.userSelect = "none";
577
+ function W(He) {
578
+ const Ke = Math.max(200, Math.min(480, m + (p - He.clientX)));
579
+ De(Ke);
556
580
  }
557
581
  function le() {
558
- Ie(!1), document.body.style.cursor = "", document.body.style.userSelect = "", document.removeEventListener("mousemove", R), document.removeEventListener("mouseup", le);
582
+ Je(!1), document.body.style.cursor = "", document.body.style.userSelect = "", document.removeEventListener("mousemove", W), document.removeEventListener("mouseup", le);
559
583
  }
560
- document.addEventListener("mousemove", R), document.addEventListener("mouseup", le);
584
+ document.addEventListener("mousemove", W), document.addEventListener("mouseup", le);
561
585
  }
562
- const pe = we(async (l) => {
586
+ const l = Te(async (d) => {
563
587
  try {
564
- const p = await I.current.listConversations(l);
565
- P((u) => l ? [...u, ...p.items] : p.items), B(p.nextCursor), !l && p.items.length && b((u) => u ?? (S ? p.items.find((R) => R.id === S) ?? p.items[0] : p.items[0])), Se("");
588
+ const p = await R.current.listConversations(d);
589
+ J((m) => d ? [...m, ...p.items] : p.items), B(p.nextCursor), !d && p.items.length && S((m) => m ?? (C ? p.items.find((W) => W.id === C) ?? p.items[0] : p.items[0])), Ye("");
566
590
  } catch (p) {
567
- Se(p instanceof Error ? p.message : "Không tải được hội thoại");
591
+ Ye(p instanceof Error ? p.message : "Không tải được hội thoại");
568
592
  } finally {
569
- F(!1);
593
+ Q(!1);
570
594
  }
571
- }, [S]);
572
- X(() => (I.current.listConnections().then(te).catch(() => {
573
- }), pe(), I.current.connectSSE((p, u) => {
595
+ }, [C]);
596
+ K(() => (R.current.listConnections().then(re).catch(() => {
597
+ }), l(), R.current.connectSSE((p, m) => {
574
598
  if (p === "message.new" || p === "conversation.updated") {
575
- if (pe(), p === "message.new") {
576
- const R = typeof u == "object" && u ? u : {}, le = R.conversationId ? String(R.conversationId) : "", We = R.messageId ? String(R.messageId) : "";
577
- if ((R.direction ? String(R.direction) : "") === "inbound" && !M && Qt(), le && le === E.current && We && ze.current) {
578
- const Xe = ze.current;
579
- I.current.getMessage(We).then((Ye) => {
580
- Xe(Ye);
599
+ if (l(), p === "message.new") {
600
+ const W = typeof m == "object" && m ? m : {}, le = W.conversationId ? String(W.conversationId) : "", He = W.messageId ? String(W.messageId) : "";
601
+ if ((W.direction ? String(W.direction) : "") === "inbound" && !L && un(), le && le === D.current && He && Le.current) {
602
+ const nt = Le.current;
603
+ R.current.getMessage(He).then((it) => {
604
+ nt(it);
581
605
  }).catch(() => {
582
606
  });
583
607
  }
584
- $ == null || $(le || E.current || "");
608
+ M == null || M(le || D.current || "");
585
609
  }
586
- } else p === "message.status_updated" && Ae((R) => R + 1);
587
- })), [pe, $]), X(() => {
588
- E.current = x == null ? void 0 : x.id;
589
- }, [x]), X(() => {
590
- x != null && x.unreadCount && I.current.markRead(x.id).then(() => pe()).catch(() => {
610
+ } else p === "message.status_updated" && Me((W) => W + 1);
611
+ })), [l, M]), K(() => {
612
+ D.current = b == null ? void 0 : b.id;
613
+ }, [b]), K(() => {
614
+ b != null && b.unreadCount && R.current.markRead(b.id).then(() => l()).catch(() => {
591
615
  });
592
- }, [x == null ? void 0 : x.id]), X(() => {
593
- if (!se) return;
594
- function l(p) {
595
- var u, R;
596
- (u = H.current) != null && u.contains(p.target) || (R = N.current) != null && R.contains(p.target) || c(!1);
616
+ }, [b == null ? void 0 : b.id]), K(() => {
617
+ if (!ie) return;
618
+ function d(p) {
619
+ var m, W;
620
+ (m = A.current) != null && m.contains(p.target) || (W = U.current) != null && W.contains(p.target) || h(!1);
597
621
  }
598
- return document.addEventListener("mousedown", l), () => document.removeEventListener("mousedown", l);
599
- }, [se]);
600
- const be = $e(() => {
601
- const l = G ? L.filter((u) => {
602
- var R;
603
- return ((R = u.assignedAgent) == null ? void 0 : R.id) === G.id;
604
- }).length : 0, p = L.filter((u) => !u.assignedAgent).length;
605
- return { all: L.length, mine: l, unassigned: p };
606
- }, [L, G]), Re = $e(() => {
607
- const l = V.toLowerCase().trim();
608
- return L.filter((p) => {
609
- var Ee, Xe, Ye;
610
- if (de === "mine") {
611
- if (!G || ((Ee = p.assignedAgent) == null ? void 0 : Ee.id) !== G.id) return !1;
612
- } else if (de === "unassigned" && p.assignedAgent)
622
+ return document.addEventListener("mousedown", d), () => document.removeEventListener("mousedown", d);
623
+ }, [ie]);
624
+ const f = We(() => {
625
+ const d = te ? H.filter((m) => {
626
+ var W;
627
+ return ((W = m.assignedAgent) == null ? void 0 : W.id) === te.id;
628
+ }).length : 0, p = H.filter((m) => !m.assignedAgent).length;
629
+ return { all: H.length, mine: d, unassigned: p };
630
+ }, [H, te]), v = We(() => {
631
+ const d = j.toLowerCase().trim();
632
+ return H.filter((p) => {
633
+ var Ke, nt, it;
634
+ if (pe === "mine") {
635
+ if (!te || ((Ke = p.assignedAgent) == null ? void 0 : Ke.id) !== te.id) return !1;
636
+ } else if (pe === "unassigned" && p.assignedAgent)
613
637
  return !1;
614
- const u = `${p.contactName ?? ""} ${p.subject ?? ""} ${p.providerConversationKey} ${((Xe = p.assignedAgent) == null ? void 0 : Xe.name) ?? ""}`.toLowerCase(), R = ((Ye = ue.get(p.connectionId)) == null ? void 0 : Ye.provider) ?? "unknown", le = U.provider === "all" || R === U.provider, We = !U.unreadOnly || (p.unreadCount ?? 0) > 0;
615
- return le && We && (!l || u.includes(l));
638
+ const m = `${p.contactName ?? ""} ${p.subject ?? ""} ${p.providerConversationKey} ${((nt = p.assignedAgent) == null ? void 0 : nt.name) ?? ""}`.toLowerCase(), W = ((it = oe.get(p.connectionId)) == null ? void 0 : it.provider) ?? "unknown", le = G.provider === "all" || W === G.provider, He = !G.unreadOnly || (p.unreadCount ?? 0) > 0;
639
+ return le && He && (!d || m.includes(d));
616
640
  });
617
- }, [L, ue, U, V, de, G]), Te = U.provider !== "all" || U.unreadOnly, a = v === "en" ? {
641
+ }, [H, oe, G, j, pe, te]), O = G.provider !== "all" || G.unreadOnly, N = g === "en" ? {
618
642
  today: "TODAY",
619
643
  loadOlder: "↑ Load older messages",
620
644
  loading: "Loading messages…",
@@ -635,51 +659,55 @@ const Wn = Pe(function({ apiUrl: i, token: r, theme: o, height: h, defaultConver
635
659
  send: "Gửi",
636
660
  all: "Tất cả"
637
661
  };
638
- Bt(D, () => ({
639
- openConversation: (l) => {
640
- const p = L.find((u) => u.id === l);
641
- p && b(p);
662
+ Ft(q, () => ({
663
+ openConversation: (d) => {
664
+ const p = H.find((m) => m.id === d);
665
+ p && (S(p), $e("chat"));
642
666
  },
643
- refresh: () => void pe()
644
- }), [L, pe]);
645
- const g = {
646
- ...f.frame,
647
- height: h ?? 620,
648
- ...h ? { maxHeight: "none" } : {},
649
- fontFamily: (o == null ? void 0 : o.fontFamily) ?? "Inter, ui-sans-serif, system-ui, sans-serif",
650
- borderRadius: (o == null ? void 0 : o.borderRadius) ?? "16px",
651
- gridTemplateColumns: Me ? `minmax(260px, 300px) minmax(0, 1fr) ${je}px` : "minmax(260px, 300px) minmax(0, 1fr)",
652
- transition: ve ? "none" : "grid-template-columns 220ms ease"
667
+ refresh: () => void l()
668
+ }), [H, l]);
669
+ const P = ee === "mobile" ? "minmax(0, 1fr)" : ee === "tablet" ? "minmax(240px, 270px) minmax(0, 1fr)" : we ? `minmax(260px, 300px) minmax(0, 1fr) ${Ue}px` : "minmax(260px, 300px) minmax(0, 1fr)", ae = {
670
+ ...x.frame,
671
+ position: "relative",
672
+ height: c ?? 620,
673
+ ...c ? { maxHeight: "none" } : {},
674
+ fontFamily: (r == null ? void 0 : r.fontFamily) ?? "Inter, ui-sans-serif, system-ui, sans-serif",
675
+ borderRadius: (r == null ? void 0 : r.borderRadius) ?? "16px",
676
+ gridTemplateColumns: P,
677
+ transition: Ne ? "none" : "grid-template-columns 220ms ease"
653
678
  };
654
- return ye ? /* @__PURE__ */ n("div", { style: { ...f.state, borderRadius: (o == null ? void 0 : o.borderRadius) ?? "16px" }, children: [
655
- /* @__PURE__ */ e(ot, {}),
679
+ if (de) return /* @__PURE__ */ n("div", { style: { ...x.state, borderRadius: (r == null ? void 0 : r.borderRadius) ?? "16px" }, children: [
680
+ /* @__PURE__ */ e(ut, {}),
656
681
  " Đang tải hộp thư…"
657
- ] }) : he && !L.length ? /* @__PURE__ */ n("div", { style: { ...f.state, color: "#b42318", borderRadius: (o == null ? void 0 : o.borderRadius) ?? "16px" }, children: [
658
- /* @__PURE__ */ e(Et, { size: 16, strokeWidth: 2 }),
682
+ ] });
683
+ if (he && !H.length) return /* @__PURE__ */ n("div", { style: { ...x.state, color: "#b42318", borderRadius: (r == null ? void 0 : r.borderRadius) ?? "16px" }, children: [
684
+ /* @__PURE__ */ e(Jt, { size: 16, strokeWidth: 2 }),
659
685
  " ",
660
686
  he,
661
- /* @__PURE__ */ e("button", { style: f.retry, onClick: () => {
662
- F(!0), pe();
687
+ /* @__PURE__ */ e("button", { style: x.retry, onClick: () => {
688
+ Q(!0), l();
663
689
  }, children: "Thử lại" })
664
- ] }) : /* @__PURE__ */ e(st.Provider, { value: i, children: /* @__PURE__ */ e(Tt.Provider, { value: r, children: /* @__PURE__ */ n("div", { style: g, onFocusCapture: () => {
665
- const l = window.scrollY;
690
+ ] });
691
+ const Se = ee !== "mobile" || Oe === "list" || !b, Re = ee !== "mobile" || Oe === "chat" && !!b;
692
+ return /* @__PURE__ */ e(yt.Provider, { value: i, children: /* @__PURE__ */ e(Dt.Provider, { value: o, children: /* @__PURE__ */ n("div", { ref: ke, style: ae, onFocusCapture: () => {
693
+ const d = window.scrollY;
666
694
  requestAnimationFrame(() => {
667
- window.scrollY !== l && window.scrollTo({ top: l, behavior: "instant" });
695
+ window.scrollY !== d && window.scrollTo({ top: d, behavior: "instant" });
668
696
  });
669
697
  }, children: [
670
- /* @__PURE__ */ n("aside", { style: f.sidebar, children: [
671
- /* @__PURE__ */ n("div", { style: f.brand, children: [
672
- /* @__PURE__ */ e("div", { style: { ...f.brandMark, background: _, overflow: "hidden", padding: 0 }, children: (k = o == null ? void 0 : o.branding) != null && k.logoUrl ? /* @__PURE__ */ e("img", { src: o.branding.logoUrl, alt: "", style: { width: "100%", height: "100%", objectFit: "cover" } }) : ((j = o == null ? void 0 : o.branding) == null ? void 0 : j.mark) ?? "C" }),
698
+ Se && /* @__PURE__ */ n("aside", { style: { ...x.sidebar, ...ee === "mobile" ? { borderRight: 0 } : {} }, children: [
699
+ /* @__PURE__ */ n("div", { style: x.brand, children: [
700
+ /* @__PURE__ */ e("div", { style: { ...x.brandMark, background: _, overflow: "hidden", padding: 0 }, children: (ge = r == null ? void 0 : r.branding) != null && ge.logoUrl ? /* @__PURE__ */ e("img", { src: r.branding.logoUrl, alt: "", style: { width: "100%", height: "100%", objectFit: "cover" } }) : ((tt = r == null ? void 0 : r.branding) == null ? void 0 : tt.mark) ?? "C" }),
673
701
  /* @__PURE__ */ n("div", { children: [
674
- /* @__PURE__ */ e("strong", { children: ((K = o == null ? void 0 : o.branding) == null ? void 0 : K.name) ?? "Hộp thư" }),
675
- !((O = o == null ? void 0 : o.branding) != null && O.name) && /* @__PURE__ */ e("span", { style: f.eyebrow, children: "CHANNELHUB" })
702
+ /* @__PURE__ */ e("strong", { children: ((xt = r == null ? void 0 : r.branding) == null ? void 0 : xt.name) ?? "Hộp thư" }),
703
+ !((vt = r == null ? void 0 : r.branding) != null && vt.name) && /* @__PURE__ */ e("span", { style: x.eyebrow, children: "CHANNELHUB" })
676
704
  ] }),
677
- /* @__PURE__ */ e(Xt, { "aria-label": "Tùy chọn", style: f.iconButton, children: /* @__PURE__ */ e(It, { size: 16, strokeWidth: 2 }) })
705
+ /* @__PURE__ */ e(dn, { "aria-label": "Tùy chọn", style: x.iconButton, children: /* @__PURE__ */ e(Et, { size: 16, strokeWidth: 2 }) })
678
706
  ] }),
679
- /* @__PURE__ */ n("div", { style: f.search, children: [
680
- /* @__PURE__ */ e(ut, { size: 16, strokeWidth: 2 }),
681
- /* @__PURE__ */ e(Yt, { "aria-label": a.searchPlaceholder, value: V, onChange: (l) => ne(l.target.value), placeholder: a.searchPlaceholder }),
682
- V && /* @__PURE__ */ e("button", { style: f.clear, onClick: () => ne(""), "aria-label": "Xóa tìm kiếm", children: "×" })
707
+ /* @__PURE__ */ n("div", { style: x.search, children: [
708
+ /* @__PURE__ */ e(Ct, { size: 16, strokeWidth: 2 }),
709
+ /* @__PURE__ */ e(sn, { "aria-label": N.searchPlaceholder, value: j, onChange: (d) => Z(d.target.value), placeholder: N.searchPlaceholder, style: { fontSize: ee === "mobile" ? 16 : 12 } }),
710
+ j && /* @__PURE__ */ e("button", { style: x.clear, onClick: () => Z(""), "aria-label": "Xóa tìm kiếm", children: "×" })
683
711
  ] }),
684
712
  /* @__PURE__ */ e(
685
713
  "div",
@@ -693,30 +721,30 @@ const Wn = Pe(function({ apiUrl: i, token: r, theme: o, height: h, defaultConver
693
721
  margin: "0 14px 10px",
694
722
  padding: 3,
695
723
  borderRadius: 9,
696
- border: `1px solid ${d.line}`,
697
- background: d.surface
724
+ border: `1px solid ${a.line}`,
725
+ background: a.surface
698
726
  },
699
727
  children: [
700
- { key: "all", label: v === "en" ? "All" : "Tất cả", count: be.all },
701
- { key: "mine", label: v === "en" ? "Mine" : "Của tôi", count: be.mine },
702
- { key: "unassigned", label: v === "en" ? "Unassigned" : "Chưa nhận", count: be.unassigned }
703
- ].map((l) => {
704
- const p = de === l.key;
728
+ { key: "all", label: g === "en" ? "All" : "Tất cả", count: f.all },
729
+ { key: "mine", label: g === "en" ? "Mine" : "Của tôi", count: f.mine },
730
+ { key: "unassigned", label: g === "en" ? "Unassigned" : "Chưa nhận", count: f.unassigned }
731
+ ].map((d) => {
732
+ const p = pe === d.key;
705
733
  return /* @__PURE__ */ n(
706
734
  "button",
707
735
  {
708
736
  type: "button",
709
737
  role: "tab",
710
738
  "aria-selected": p,
711
- onClick: () => z(l.key),
739
+ onClick: () => ve(d.key),
712
740
  style: {
713
741
  border: 0,
714
742
  borderRadius: 6,
715
743
  padding: "5px 4px",
716
744
  fontSize: 11,
717
745
  fontWeight: p ? 700 : 500,
718
- background: p ? d.white : "transparent",
719
- color: p ? _ : d.muted,
746
+ background: p ? a.white : "transparent",
747
+ color: p ? _ : a.muted,
720
748
  boxShadow: p ? "0 1px 3px rgba(23,32,51,.08)" : "none",
721
749
  cursor: "pointer",
722
750
  whiteSpace: "nowrap",
@@ -725,183 +753,230 @@ const Wn = Pe(function({ apiUrl: i, token: r, theme: o, height: h, defaultConver
725
753
  transition: "all 120ms ease"
726
754
  },
727
755
  children: [
728
- l.label,
756
+ d.label,
729
757
  " ",
730
758
  /* @__PURE__ */ n("span", { style: { opacity: 0.75 }, children: [
731
759
  "(",
732
- l.count,
760
+ d.count,
733
761
  ")"
734
762
  ] })
735
763
  ]
736
764
  },
737
- l.key
765
+ d.key
738
766
  );
739
767
  })
740
768
  }
741
769
  ),
742
- Te && /* @__PURE__ */ n("div", { style: { display: "flex", gap: 4, flexWrap: "wrap", padding: "0 14px 8px" }, children: [
743
- U.provider !== "all" && /* @__PURE__ */ n("span", { style: { display: "inline-flex", alignItems: "center", gap: 4, background: "#eef2ff", color: _, borderRadius: 6, fontSize: 11, padding: "2px 8px", fontWeight: 500 }, children: [
744
- /* @__PURE__ */ e(De, { provider: U.provider }),
745
- yt(U.provider),
746
- /* @__PURE__ */ e("button", { style: { border: 0, background: "none", cursor: "pointer", color: _, padding: 0, lineHeight: 1, display: "flex" }, onClick: () => ee((l) => ({ ...l, provider: "all" })), "aria-label": "Xóa filter kênh", children: /* @__PURE__ */ e(Oe, { size: 10 }) })
770
+ O && /* @__PURE__ */ n("div", { style: { display: "flex", gap: 4, flexWrap: "wrap", padding: "0 14px 8px" }, children: [
771
+ G.provider !== "all" && /* @__PURE__ */ n("span", { style: { display: "inline-flex", alignItems: "center", gap: 4, background: "#eef2ff", color: _, borderRadius: 6, fontSize: 11, padding: "2px 8px", fontWeight: 500 }, children: [
772
+ /* @__PURE__ */ e(Ge, { provider: G.provider }),
773
+ Rt(G.provider),
774
+ /* @__PURE__ */ e("button", { style: { border: 0, background: "none", cursor: "pointer", color: _, padding: 0, lineHeight: 1, display: "flex" }, onClick: () => k((d) => ({ ...d, provider: "all" })), "aria-label": "Xóa filter kênh", children: /* @__PURE__ */ e(Ve, { size: 10 }) })
747
775
  ] }),
748
- U.unreadOnly && /* @__PURE__ */ n("span", { style: { display: "inline-flex", alignItems: "center", gap: 4, background: "#eef2ff", color: _, borderRadius: 6, fontSize: 11, padding: "2px 8px", fontWeight: 500 }, children: [
749
- a.unreadOnly,
750
- /* @__PURE__ */ e("button", { style: { border: 0, background: "none", cursor: "pointer", color: _, padding: 0, lineHeight: 1, display: "flex" }, onClick: () => ee((l) => ({ ...l, unreadOnly: !1 })), "aria-label": "Xóa filter chưa đọc", children: /* @__PURE__ */ e(Oe, { size: 10 }) })
776
+ G.unreadOnly && /* @__PURE__ */ n("span", { style: { display: "inline-flex", alignItems: "center", gap: 4, background: "#eef2ff", color: _, borderRadius: 6, fontSize: 11, padding: "2px 8px", fontWeight: 500 }, children: [
777
+ N.unreadOnly,
778
+ /* @__PURE__ */ e("button", { style: { border: 0, background: "none", cursor: "pointer", color: _, padding: 0, lineHeight: 1, display: "flex" }, onClick: () => k((d) => ({ ...d, unreadOnly: !1 })), "aria-label": "Xóa filter chưa đọc", children: /* @__PURE__ */ e(Ve, { size: 10 }) })
751
779
  ] }),
752
- /* @__PURE__ */ e("button", { style: { border: 0, background: "none", cursor: "pointer", color: d.muted, fontSize: 11, padding: "2px 4px" }, onClick: () => ee({ provider: "all", unreadOnly: !1 }), children: "Xóa tất cả" })
780
+ /* @__PURE__ */ e("button", { style: { border: 0, background: "none", cursor: "pointer", color: a.muted, fontSize: 11, padding: "2px 4px" }, onClick: () => k({ provider: "all", unreadOnly: !1 }), children: "Xóa tất cả" })
753
781
  ] }),
754
- /* @__PURE__ */ n("div", { style: f.listHeader, children: [
782
+ /* @__PURE__ */ n("div", { style: x.listHeader, children: [
755
783
  /* @__PURE__ */ n("span", { children: [
756
- Re.length,
784
+ v.length,
757
785
  " hội thoại"
758
786
  ] }),
759
787
  /* @__PURE__ */ e(
760
788
  "button",
761
789
  {
762
- ref: H,
763
- style: { ...f.iconButton, background: Te ? `${_}14` : "transparent", color: Te ? _ : d.muted },
790
+ ref: A,
791
+ style: { ...x.iconButton, background: O ? `${_}14` : "transparent", color: O ? _ : a.muted },
764
792
  "aria-label": "Bộ lọc",
765
793
  onClick: () => {
766
- var l;
767
- if (!se) {
768
- const p = (l = H.current) == null ? void 0 : l.getBoundingClientRect();
794
+ var d;
795
+ if (!ie) {
796
+ const p = (d = A.current) == null ? void 0 : d.getBoundingClientRect();
769
797
  p && ce({ top: p.bottom + 6, left: p.left });
770
798
  }
771
- c((p) => !p);
799
+ h((p) => !p);
772
800
  },
773
- children: /* @__PURE__ */ e(Kt, { size: 15, strokeWidth: 2 })
801
+ children: /* @__PURE__ */ e(on, { size: 15, strokeWidth: 2 })
774
802
  }
775
803
  )
776
804
  ] }),
777
- se && ae && St(
805
+ ie && z && At(
778
806
  /* @__PURE__ */ n(
779
807
  "div",
780
808
  {
781
- ref: N,
782
- style: { position: "fixed", top: ae.top, left: ae.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 },
809
+ ref: U,
810
+ style: { position: "fixed", top: z.top, left: Math.min(z.left, (typeof window < "u" ? window.innerWidth : 1200) - 230), zIndex: 9999, background: a.white, border: `1px solid ${a.line}`, borderRadius: 10, padding: "12px 14px", boxShadow: "0 8px 24px rgba(23,32,51,.14)", minWidth: 210, fontFamily: (r == null ? void 0 : r.fontFamily) ?? "Inter, ui-sans-serif, system-ui, sans-serif", fontSize: 13 },
783
811
  children: [
784
- /* @__PURE__ */ e("div", { style: { fontSize: 10, fontWeight: 700, color: d.muted, letterSpacing: 1, textTransform: "uppercase", marginBottom: 8 }, children: "Kênh" }),
785
- ["all", ...Ve].map((l) => /* @__PURE__ */ n("label", { style: { display: "flex", alignItems: "center", gap: 8, padding: "5px 6px", cursor: "pointer", borderRadius: 6, background: U.provider === l ? `${_}0f` : "transparent" }, children: [
786
- /* @__PURE__ */ e("input", { type: "radio", name: "provider-filter", checked: U.provider === l, onChange: () => ee((p) => ({ ...p, provider: l })), style: { accentColor: _ } }),
787
- l === "all" ? /* @__PURE__ */ n("span", { style: { color: d.ink }, children: [
788
- a.all,
812
+ /* @__PURE__ */ e("div", { style: { fontSize: 10, fontWeight: 700, color: a.muted, letterSpacing: 1, textTransform: "uppercase", marginBottom: 8 }, children: "Kênh" }),
813
+ ["all", ...xe].map((d) => /* @__PURE__ */ n("label", { style: { display: "flex", alignItems: "center", gap: 8, padding: "5px 6px", cursor: "pointer", borderRadius: 6, background: G.provider === d ? `${_}0f` : "transparent" }, children: [
814
+ /* @__PURE__ */ e("input", { type: "radio", name: "provider-filter", checked: G.provider === d, onChange: () => k((p) => ({ ...p, provider: d })), style: { accentColor: _ } }),
815
+ d === "all" ? /* @__PURE__ */ n("span", { style: { color: a.ink }, children: [
816
+ N.all,
789
817
  " (",
790
- L.length,
818
+ H.length,
791
819
  ")"
792
- ] }) : /* @__PURE__ */ n("span", { style: { display: "flex", alignItems: "center", gap: 5, color: d.ink }, children: [
793
- /* @__PURE__ */ e(De, { provider: l }),
794
- yt(l),
820
+ ] }) : /* @__PURE__ */ n("span", { style: { display: "flex", alignItems: "center", gap: 5, color: a.ink }, children: [
821
+ /* @__PURE__ */ e(Ge, { provider: d }),
822
+ Rt(d),
795
823
  " ",
796
- /* @__PURE__ */ n("span", { style: { color: d.muted }, children: [
824
+ /* @__PURE__ */ n("span", { style: { color: a.muted }, children: [
797
825
  "(",
798
- Ge[l] ?? 0,
826
+ Qe[d] ?? 0,
799
827
  ")"
800
828
  ] })
801
829
  ] })
802
- ] }, l)),
803
- /* @__PURE__ */ e("div", { style: { borderTop: `1px solid ${d.line}`, margin: "8px 0 6px" } }),
804
- /* @__PURE__ */ n("label", { style: { display: "flex", alignItems: "center", gap: 8, padding: "5px 6px", cursor: "pointer", borderRadius: 6, background: U.unreadOnly ? `${_}0f` : "transparent" }, children: [
805
- /* @__PURE__ */ e("input", { type: "checkbox", checked: U.unreadOnly, onChange: (l) => ee((p) => ({ ...p, unreadOnly: l.target.checked })), style: { accentColor: _ } }),
806
- /* @__PURE__ */ e("span", { style: { color: d.ink }, children: a.unreadOnly })
830
+ ] }, d)),
831
+ /* @__PURE__ */ e("div", { style: { borderTop: `1px solid ${a.line}`, margin: "8px 0 6px" } }),
832
+ /* @__PURE__ */ n("label", { style: { display: "flex", alignItems: "center", gap: 8, padding: "5px 6px", cursor: "pointer", borderRadius: 6, background: G.unreadOnly ? `${_}0f` : "transparent" }, children: [
833
+ /* @__PURE__ */ e("input", { type: "checkbox", checked: G.unreadOnly, onChange: (d) => k((p) => ({ ...p, unreadOnly: d.target.checked })), style: { accentColor: _ } }),
834
+ /* @__PURE__ */ e("span", { style: { color: a.ink }, children: N.unreadOnly })
807
835
  ] })
808
836
  ]
809
837
  }
810
838
  ),
811
839
  document.body
812
840
  ),
813
- /* @__PURE__ */ n(Rt, { style: f.conversationList, children: [
814
- Re.map((l) => {
841
+ /* @__PURE__ */ n(Ut, { style: x.conversationList, children: [
842
+ v.map((d) => {
815
843
  var p;
816
- return /* @__PURE__ */ e(nn, { conversation: l, provider: (p = ue.get(l.connectionId)) == null ? void 0 : p.provider, selected: (x == null ? void 0 : x.id) === l.id, primary: _, currentAgent: G, onSelect: () => {
817
- b(l), C == null || C(l.id), I.current.markRead(l.id).then(() => pe()).catch(() => {
844
+ return /* @__PURE__ */ e(bn, { conversation: d, provider: (p = oe.get(d.connectionId)) == null ? void 0 : p.provider, selected: (b == null ? void 0 : b.id) === d.id, primary: _, currentAgent: te, onSelect: () => {
845
+ S(d), $e("chat"), I == null || I(d.id), R.current.markRead(d.id).then(() => l()).catch(() => {
818
846
  });
819
- } }, l.id);
847
+ } }, d.id);
820
848
  }),
821
- !Re.length && /* @__PURE__ */ n("div", { style: f.emptySmall, children: [
822
- /* @__PURE__ */ e("div", { style: f.emptyIcon, children: /* @__PURE__ */ e(ut, { size: 16, strokeWidth: 2 }) }),
849
+ !v.length && /* @__PURE__ */ n("div", { style: x.emptySmall, children: [
850
+ /* @__PURE__ */ e("div", { style: x.emptyIcon, children: /* @__PURE__ */ e(Ct, { size: 16, strokeWidth: 2 }) }),
823
851
  /* @__PURE__ */ e("strong", { children: "Không tìm thấy" }),
824
852
  /* @__PURE__ */ e("span", { children: "Thử từ khóa hoặc bộ lọc khác." })
825
853
  ] }),
826
- Q && /* @__PURE__ */ e("button", { style: f.loadMore, onClick: () => void pe(Q), children: "Xem thêm hội thoại" })
854
+ V && /* @__PURE__ */ e("button", { style: x.loadMore, onClick: () => void l(V), children: "Xem thêm hội thoại" })
827
855
  ] })
828
856
  ] }),
829
- /* @__PURE__ */ e("main", { style: f.main, children: x ? /* @__PURE__ */ e(
830
- rn,
857
+ Re && /* @__PURE__ */ e("main", { style: x.main, children: b ? /* @__PURE__ */ e(
858
+ yn,
831
859
  {
832
- conversation: x,
833
- provider: (re = ue.get(x.connectionId)) == null ? void 0 : re.provider,
834
- connection: ue.get(x.connectionId),
835
- client: I.current,
860
+ conversation: b,
861
+ provider: (kt = oe.get(b.connectionId)) == null ? void 0 : kt.provider,
862
+ connection: oe.get(b.connectionId),
863
+ client: R.current,
836
864
  primary: _,
837
865
  error: he,
838
- onRegisterAppend: (l) => {
839
- ze.current = l;
866
+ onRegisterAppend: (d) => {
867
+ Le.current = d;
840
868
  },
841
- refreshKey: Fe,
842
- infoOpen: Me,
843
- onToggleInfo: () => He((l) => !l),
844
- t: a,
845
- disableAttachments: m,
869
+ refreshKey: Ze,
870
+ infoOpen: we,
871
+ onToggleInfo: () => ue((d) => !d),
872
+ t: N,
873
+ disableAttachments: y,
846
874
  hideKeyboardHint: w,
847
- extensions: W,
848
- currentAgent: G,
849
- teamAgents: Ke,
850
- onAssignAgent: (l) => qe(x, l),
851
- onLinkContact: (l) => ke(x, l),
852
- onRefreshContactInfo: fe
875
+ extensions: $,
876
+ currentAgent: te,
877
+ teamAgents: _e,
878
+ onAssignAgent: (d) => rt(b, d),
879
+ onLinkContact: (d) => Fe(b, d),
880
+ onRefreshContactInfo: me,
881
+ layoutMode: ee,
882
+ onBackToList: () => $e("list"),
883
+ totalUnreadCount: ye
853
884
  },
854
- x.id
855
- ) : /* @__PURE__ */ e(dn, {}) }),
856
- Me && x && /* @__PURE__ */ e(
857
- an,
885
+ b.id
886
+ ) : /* @__PURE__ */ e(vn, {}) }),
887
+ we && b && (ee === "desktop" ? /* @__PURE__ */ e(
888
+ Tt,
858
889
  {
859
- conversation: x,
860
- connection: ue.get(x.connectionId),
890
+ conversation: b,
891
+ connection: oe.get(b.connectionId),
861
892
  primary: _,
862
- onClose: () => He(!1),
863
- client: I.current,
864
- onStartResize: Ze,
865
- extensions: W,
866
- extRefreshKey: Ne,
867
- onLinkContact: (l) => ke(x, l),
868
- onRefreshContactInfo: fe
893
+ onClose: () => ue(!1),
894
+ client: R.current,
895
+ onStartResize: et,
896
+ extensions: $,
897
+ extRefreshKey: Pe,
898
+ onLinkContact: (d) => Fe(b, d),
899
+ onRefreshContactInfo: me,
900
+ layoutMode: ee
869
901
  }
870
- )
902
+ ) : /* @__PURE__ */ e(
903
+ "div",
904
+ {
905
+ onClick: () => ue(!1),
906
+ style: {
907
+ position: "absolute",
908
+ inset: 0,
909
+ zIndex: 50,
910
+ background: "rgba(15, 23, 42, 0.32)",
911
+ display: "flex",
912
+ justifyContent: "flex-end"
913
+ },
914
+ children: /* @__PURE__ */ e(
915
+ "div",
916
+ {
917
+ onClick: (d) => d.stopPropagation(),
918
+ style: {
919
+ width: ee === "mobile" ? "100%" : "min(320px, 85%)",
920
+ height: "100%",
921
+ background: a.white,
922
+ boxShadow: "-8px 0 24px rgba(15, 23, 42, 0.14)",
923
+ display: "flex",
924
+ flexDirection: "column"
925
+ },
926
+ children: /* @__PURE__ */ e(
927
+ Tt,
928
+ {
929
+ conversation: b,
930
+ connection: oe.get(b.connectionId),
931
+ primary: _,
932
+ onClose: () => ue(!1),
933
+ client: R.current,
934
+ onStartResize: void 0,
935
+ extensions: $,
936
+ extRefreshKey: Pe,
937
+ onLinkContact: (d) => Fe(b, d),
938
+ onRefreshContactInfo: me,
939
+ layoutMode: ee
940
+ }
941
+ )
942
+ }
943
+ )
944
+ }
945
+ ))
871
946
  ] }) }) });
872
947
  });
873
- function nn({ conversation: t, provider: i, selected: r, primary: o, currentAgent: h, onSelect: S }) {
874
- const [m, M] = y(!1), w = t.contactName ?? t.subject ?? t.providerConversationKey, v = t.unreadCount ?? 0, W = t.lastMessageText ?? "", T = t.lastMessageDirection === "outbound" ? "Bạn: " : "", A = W.length > 60 ? W.slice(0, 60) + "…" : W, $ = W ? T + A : "", C = t.assignedAgent ?? null, D = !!(C && h && C.id === h.id);
875
- let I = "transparent";
876
- r ? I = "#eef2ff" : m ? I = "#f7f9fc" : v > 0 && (I = "#f0f4ff");
877
- const L = {
878
- ...f.row,
879
- background: I,
880
- ...r ? { boxShadow: `inset 3px 0 0 ${o}` } : v > 0 && !m ? { boxShadow: `inset 3px 0 0 ${o}` } : {}
948
+ function bn({ conversation: t, provider: i, selected: o, primary: r, currentAgent: c, onSelect: C }) {
949
+ const [y, L] = u(!1), w = t.contactName ?? t.subject ?? t.providerConversationKey, g = t.unreadCount ?? 0, $ = t.lastMessageText ?? "", T = t.lastMessageDirection === "outbound" ? "Bạn: " : "", E = $.length > 60 ? $.slice(0, 60) + "…" : $, M = $ ? T + E : "", I = t.assignedAgent ?? null, q = !!(I && c && I.id === c.id);
950
+ let R = "transparent";
951
+ o ? R = "#eef2ff" : y ? R = "#f7f9fc" : g > 0 && (R = "#f0f4ff");
952
+ const H = {
953
+ ...x.row,
954
+ background: R,
955
+ ...o ? { boxShadow: `inset 3px 0 0 ${r}` } : g > 0 && !y ? { boxShadow: `inset 3px 0 0 ${r}` } : {}
881
956
  };
882
957
  return /* @__PURE__ */ n(
883
958
  "button",
884
959
  {
885
- onClick: S,
886
- style: L,
887
- onMouseEnter: () => M(!0),
888
- onMouseLeave: () => M(!1),
960
+ onClick: C,
961
+ style: H,
962
+ onMouseEnter: () => L(!0),
963
+ onMouseLeave: () => L(!1),
889
964
  children: [
890
- /* @__PURE__ */ e($t, { name: w, color: o, image: t.contactPictureUrl, provider: i }),
891
- /* @__PURE__ */ n("span", { style: f.rowBody, children: [
892
- /* @__PURE__ */ n("span", { style: f.rowTop, children: [
893
- /* @__PURE__ */ e("strong", { style: { minWidth: 0, overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap", fontWeight: v > 0 ? 700 : 500 }, children: w }),
965
+ /* @__PURE__ */ e(Pt, { name: w, color: r, image: t.contactPictureUrl, provider: i }),
966
+ /* @__PURE__ */ n("span", { style: x.rowBody, children: [
967
+ /* @__PURE__ */ n("span", { style: x.rowTop, children: [
968
+ /* @__PURE__ */ e("strong", { style: { minWidth: 0, overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap", fontWeight: g > 0 ? 700 : 500 }, children: w }),
894
969
  /* @__PURE__ */ n("span", { style: { display: "flex", alignItems: "center", gap: 4, flexShrink: 0 }, children: [
895
- /* @__PURE__ */ e("time", { style: { color: d.muted, fontSize: 11, whiteSpace: "nowrap" }, children: at(t.lastMessageAt) }),
896
- v > 0 && /* @__PURE__ */ e("span", { "aria-label": `${v} tin nhắn chưa đọc`, style: f.unreadBadge, children: v > 99 ? "99+" : v })
970
+ /* @__PURE__ */ e("time", { style: { color: a.muted, fontSize: 11, whiteSpace: "nowrap" }, children: ft(t.lastMessageAt) }),
971
+ g > 0 && /* @__PURE__ */ e("span", { "aria-label": `${g} tin nhắn chưa đọc`, style: x.unreadBadge, children: g > 99 ? "99+" : g })
897
972
  ] })
898
973
  ] }),
899
- /* @__PURE__ */ n("span", { style: { ...f.rowBottom, justifyContent: "space-between", alignItems: "center", gap: 6, color: v > 0 && !r ? "#4a5568" : d.muted }, children: [
900
- /* @__PURE__ */ e("span", { style: { flex: 1, minWidth: 0, whiteSpace: "nowrap", overflow: "hidden", textOverflow: "ellipsis" }, children: $ || /* @__PURE__ */ e("span", { style: { opacity: 0.5 }, children: "Chưa có tin nhắn" }) }),
901
- C ? /* @__PURE__ */ n(
974
+ /* @__PURE__ */ n("span", { style: { ...x.rowBottom, justifyContent: "space-between", alignItems: "center", gap: 6, color: g > 0 && !o ? "#4a5568" : a.muted }, children: [
975
+ /* @__PURE__ */ e("span", { style: { flex: 1, minWidth: 0, whiteSpace: "nowrap", overflow: "hidden", textOverflow: "ellipsis" }, children: M || /* @__PURE__ */ e("span", { style: { opacity: 0.5 }, children: "Chưa có tin nhắn" }) }),
976
+ I ? /* @__PURE__ */ n(
902
977
  "span",
903
978
  {
904
- title: `Phụ trách: ${C.name}${C.title ? ` (${C.title})` : ""}`,
979
+ title: `Phụ trách: ${I.name}${I.title ? ` (${I.title})` : ""}`,
905
980
  style: {
906
981
  display: "inline-flex",
907
982
  alignItems: "center",
@@ -911,9 +986,9 @@ function nn({ conversation: t, provider: i, selected: r, primary: o, currentAgen
911
986
  fontSize: 10,
912
987
  fontWeight: 600,
913
988
  flexShrink: 0,
914
- background: D ? `${o}18` : "#f1f5f9",
915
- color: D ? o : "#475569",
916
- border: D ? `1px solid ${o}33` : "1px solid #e2e8f0"
989
+ background: q ? `${r}18` : "#f1f5f9",
990
+ color: q ? r : "#475569",
991
+ border: q ? `1px solid ${r}33` : "1px solid #e2e8f0"
917
992
  },
918
993
  children: [
919
994
  /* @__PURE__ */ e(
@@ -923,7 +998,7 @@ function nn({ conversation: t, provider: i, selected: r, primary: o, currentAgen
923
998
  width: 14,
924
999
  height: 14,
925
1000
  borderRadius: "50%",
926
- background: D ? o : "#64748b",
1001
+ background: q ? r : "#64748b",
927
1002
  color: "#fff",
928
1003
  fontSize: 8,
929
1004
  fontWeight: 700,
@@ -932,13 +1007,13 @@ function nn({ conversation: t, provider: i, selected: r, primary: o, currentAgen
932
1007
  overflow: "hidden",
933
1008
  flexShrink: 0
934
1009
  },
935
- children: C.avatarUrl ? /* @__PURE__ */ e("img", { src: C.avatarUrl, alt: "", style: { width: "100%", height: "100%", objectFit: "cover" } }) : Le(C.name)
1010
+ children: I.avatarUrl ? /* @__PURE__ */ e("img", { src: I.avatarUrl, alt: "", style: { width: "100%", height: "100%", objectFit: "cover" } }) : je(I.name)
936
1011
  }
937
1012
  ),
938
- /* @__PURE__ */ e("span", { style: { maxWidth: 68, overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" }, children: rt(C.name) })
1013
+ /* @__PURE__ */ e("span", { style: { maxWidth: 68, overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" }, children: pt(I.name) })
939
1014
  ]
940
1015
  }
941
- ) : v > 0 ? /* @__PURE__ */ e(
1016
+ ) : g > 0 ? /* @__PURE__ */ e(
942
1017
  "span",
943
1018
  {
944
1019
  style: {
@@ -961,142 +1036,184 @@ function nn({ conversation: t, provider: i, selected: r, primary: o, currentAgen
961
1036
  }
962
1037
  );
963
1038
  }
964
- function rn({ conversation: t, provider: i, connection: r, client: o, primary: h, error: S, onRegisterAppend: m, refreshKey: M, infoOpen: w, onToggleInfo: v, t: W, disableAttachments: T, hideKeyboardHint: A, extensions: $, currentAgent: C, teamAgents: D, onAssignAgent: I, onLinkContact: L, onRefreshContactInfo: P }) {
965
- var Re, Te;
966
- const [q, te] = y([]), [Q, B] = y(), [x, b] = y(""), [E, V] = y(!0), [ne, de] = y(!1), [z, oe] = y(""), Z = J(null), U = t.contactName ?? t.subject ?? t.providerConversationKey, ee = J(null), se = J(null), [c, H] = y(null), [N, ae] = y(!1), [ce, ye] = y(!1), [F, he] = y(!1), [Se, Me] = y(0), He = J(null), je = J(null), Ce = J(null), [ve, Ie] = y(!1), [Ne, me] = y(""), [_, ue] = y([]), ze = J(null), Fe = J(null), [Ae, G] = y(!1), Ke = J(null), qe = J(null);
967
- X(() => {
968
- if (!Ae) return;
969
- function a(g) {
970
- var k, j;
971
- (k = Ke.current) != null && k.contains(g.target) || (j = qe.current) != null && j.contains(g.target) || G(!1);
1039
+ function yn({ conversation: t, provider: i, connection: o, client: r, primary: c, error: C, onRegisterAppend: y, refreshKey: L, infoOpen: w, onToggleInfo: g, t: $, disableAttachments: T, hideKeyboardHint: E, extensions: M, currentAgent: I, teamAgents: q, onAssignAgent: R, onLinkContact: H, onRefreshContactInfo: J, layoutMode: F = "desktop", onBackToList: re, totalUnreadCount: V = 0 }) {
1040
+ var Qe, et;
1041
+ const [B, b] = u([]), [S, D] = u(), [j, Z] = u(""), [pe, ve] = u(!0), [fe, se] = u(!1), [G, k] = u(""), ie = X(null), h = t.contactName ?? t.subject ?? t.providerConversationKey, A = X(null), U = X(null), [z, ce] = u(null), [de, Q] = u(!1), [he, Ye] = u(!1), [ke, Ie] = u(!1), [Ee, ee] = u(0), Oe = X(null), $e = X(null), we = X(null), [ue, Be] = u(!1), [Ue, De] = u(""), [Ne, Je] = u([]), Pe = X(null), ze = X(null), [_, oe] = u(!1), Le = X(null), Ze = X(null);
1042
+ K(() => {
1043
+ if (!_) return;
1044
+ function l(f) {
1045
+ var v, O;
1046
+ (v = Le.current) != null && v.contains(f.target) || (O = Ze.current) != null && O.contains(f.target) || oe(!1);
972
1047
  }
973
- return document.addEventListener("mousedown", a), () => document.removeEventListener("mousedown", a);
974
- }, [Ae]), X(() => () => {
975
- c != null && c.objectUrl && URL.revokeObjectURL(c.objectUrl);
976
- }, [c == null ? void 0 : c.objectUrl]), X(() => {
977
- if (!F) return;
978
- function a(g) {
979
- var k, j;
980
- (k = je.current) != null && k.contains(g.target) || (j = He.current) != null && j.contains(g.target) || he(!1);
1048
+ return document.addEventListener("mousedown", l), () => document.removeEventListener("mousedown", l);
1049
+ }, [_]), K(() => () => {
1050
+ z != null && z.objectUrl && URL.revokeObjectURL(z.objectUrl);
1051
+ }, [z == null ? void 0 : z.objectUrl]), K(() => {
1052
+ if (!ke) return;
1053
+ function l(f) {
1054
+ var v, O;
1055
+ (v = $e.current) != null && v.contains(f.target) || (O = Oe.current) != null && O.contains(f.target) || Ie(!1);
981
1056
  }
982
- return document.addEventListener("mousedown", a), () => document.removeEventListener("mousedown", a);
983
- }, [F]), X(() => {
984
- o.listCannedResponses().then(ue).catch(() => {
1057
+ return document.addEventListener("mousedown", l), () => document.removeEventListener("mousedown", l);
1058
+ }, [ke]), K(() => {
1059
+ r.listCannedResponses().then(Je).catch(() => {
985
1060
  });
986
- }, [o]), X(() => {
987
- if (!ve) return;
988
- function a(g) {
989
- var k, j;
990
- (k = Fe.current) != null && k.contains(g.target) || (j = ze.current) != null && j.contains(g.target) || Ie(!1);
1061
+ }, [r]), K(() => {
1062
+ if (!ue) return;
1063
+ function l(f) {
1064
+ var v, O;
1065
+ (v = ze.current) != null && v.contains(f.target) || (O = Pe.current) != null && O.contains(f.target) || Be(!1);
991
1066
  }
992
- return document.addEventListener("mousedown", a), () => document.removeEventListener("mousedown", a);
993
- }, [ve]);
994
- const ke = J(!0), fe = we(async (a, g) => {
995
- g || (ke.current = !a);
1067
+ return document.addEventListener("mousedown", l), () => document.removeEventListener("mousedown", l);
1068
+ }, [ue]);
1069
+ const Me = X(!0), ye = Te(async (l, f) => {
1070
+ f || (Me.current = !l);
996
1071
  try {
997
- const k = await o.listMessages(t.id, a);
998
- te((j) => a ? [...k.items, ...j] : k.items), B(k.nextCursor);
999
- } catch (k) {
1000
- oe(k instanceof Error ? k.message : "Không tải được tin nhắn");
1072
+ const v = await r.listMessages(t.id, l);
1073
+ b((O) => l ? [...v.items, ...O] : v.items), D(v.nextCursor);
1074
+ } catch (v) {
1075
+ k(v instanceof Error ? v.message : "Không tải được tin nhắn");
1001
1076
  } finally {
1002
- g || V(!1);
1077
+ f || ve(!1);
1003
1078
  }
1004
- }, [o, t.id]);
1005
- X(() => {
1006
- V(!0), fe();
1007
- }, [fe]), X(() => {
1008
- M && fe(void 0, !0);
1009
- }, [M]), X(() => {
1010
- ke.current && requestAnimationFrame(() => {
1011
- const a = Z.current;
1012
- a && (a.scrollTop = a.scrollHeight);
1079
+ }, [r, t.id]);
1080
+ K(() => {
1081
+ ve(!0), ye();
1082
+ }, [ye]), K(() => {
1083
+ L && ye(void 0, !0);
1084
+ }, [L]), K(() => {
1085
+ Me.current && requestAnimationFrame(() => {
1086
+ const l = ie.current;
1087
+ l && (l.scrollTop = l.scrollHeight);
1013
1088
  });
1014
- }, [q]), X(() => (m == null || m((a) => {
1015
- ke.current = !0, te((g) => g.some((k) => k.id === a.id) ? g : [...g, a]);
1089
+ }, [B]), K(() => (y == null || y((l) => {
1090
+ Me.current = !0, b((f) => f.some((v) => v.id === l.id) ? f : [...f, l]);
1016
1091
  }), () => {
1017
- m == null || m(null);
1018
- }), [m]);
1019
- async function Ve(a) {
1020
- var j;
1021
- const g = (j = a.target.files) == null ? void 0 : j[0];
1022
- if (!g) return;
1023
- a.target.value = "";
1024
- const k = URL.createObjectURL(g);
1025
- H({ file: g, uploading: !0, objectUrl: k });
1092
+ y == null || y(null);
1093
+ }), [y]);
1094
+ async function te(l) {
1095
+ var O;
1096
+ const f = (O = l.target.files) == null ? void 0 : O[0];
1097
+ if (!f) return;
1098
+ l.target.value = "";
1099
+ const v = URL.createObjectURL(f);
1100
+ ce({ file: f, uploading: !0, objectUrl: v });
1026
1101
  try {
1027
- const K = await o.uploadAttachment(g);
1028
- H({ file: g, uploading: !1, url: K.url, mimeType: K.mimeType, attachmentType: K.attachmentType, objectUrl: k });
1102
+ const N = await r.uploadAttachment(f);
1103
+ ce({ file: f, uploading: !1, url: N.url, mimeType: N.mimeType, attachmentType: N.attachmentType, objectUrl: v });
1029
1104
  } catch {
1030
- URL.revokeObjectURL(k), H(null), oe("Không tải lên được tệp đính kèm");
1105
+ URL.revokeObjectURL(v), ce(null), k("Không tải lên được tệp đính kèm");
1031
1106
  }
1032
1107
  }
1033
- async function Ge(a) {
1034
- a.preventDefault();
1035
- const g = x.trim(), k = c != null && c.url ? [{ url: c.url, mimeType: c.mimeType ?? "application/octet-stream", type: c.attachmentType }] : [];
1036
- if (!g && !k.length || ne) return;
1037
- de(!0), oe(""), !t.assignedAgent && C && I(C);
1038
- const j = `optimistic-${Date.now()}`;
1039
- C && (ke.current = !0, te((K) => [
1040
- ...K,
1108
+ async function _e(l) {
1109
+ l.preventDefault();
1110
+ const f = j.trim(), v = z != null && z.url ? [{ url: z.url, mimeType: z.mimeType ?? "application/octet-stream", type: z.attachmentType }] : [];
1111
+ if (!f && !v.length || fe) return;
1112
+ se(!0), k(""), !t.assignedAgent && I && R(I);
1113
+ const O = `optimistic-${Date.now()}`;
1114
+ I && (Me.current = !0, b((N) => [
1115
+ ...N,
1041
1116
  {
1042
- id: j,
1117
+ id: O,
1043
1118
  direction: "outbound",
1044
1119
  status: "sending",
1045
- text: g || void 0,
1046
- attachments: k.length ? k : void 0,
1120
+ text: f || void 0,
1121
+ attachments: v.length ? v : void 0,
1047
1122
  occurredAt: (/* @__PURE__ */ new Date()).toISOString(),
1048
- senderAgent: C
1123
+ senderAgent: I
1049
1124
  }
1050
1125
  ]));
1051
1126
  try {
1052
- await o.sendMessage(t.id, g || void 0, k.length ? k : void 0), c != null && c.objectUrl && URL.revokeObjectURL(c.objectUrl), b(""), H(null), await fe(), C && te((K) => {
1053
- var l, p;
1054
- const O = K.filter((u) => u.id !== j), re = O.length - 1;
1055
- return re >= 0 && ((l = O[re]) == null ? void 0 : l.direction) === "outbound" && !((p = O[re]) != null && p.senderAgent) ? O.map((u, R) => R === re ? { ...u, senderAgent: C } : u) : O;
1127
+ await r.sendMessage(t.id, f || void 0, v.length ? v : void 0), z != null && z.objectUrl && URL.revokeObjectURL(z.objectUrl), Z(""), ce(null), await ye(), I && b((N) => {
1128
+ var Se, Re;
1129
+ const P = N.filter((ge) => ge.id !== O), ae = P.length - 1;
1130
+ return ae >= 0 && ((Se = P[ae]) == null ? void 0 : Se.direction) === "outbound" && !((Re = P[ae]) != null && Re.senderAgent) ? P.map((ge, tt) => tt === ae ? { ...ge, senderAgent: I } : ge) : P;
1056
1131
  });
1057
- } catch (K) {
1058
- te((O) => O.filter((re) => re.id !== j)), oe(K instanceof Error ? K.message : "Không gửi được tin nhắn");
1132
+ } catch (N) {
1133
+ b((P) => P.filter((ae) => ae.id !== O)), k(N instanceof Error ? N.message : "Không gửi được tin nhắn");
1059
1134
  } finally {
1060
- de(!1);
1135
+ se(!1);
1061
1136
  }
1062
1137
  }
1063
- function Ze(a) {
1064
- const g = Ce.current;
1065
- if (!g) {
1066
- b((O) => O + a), he(!1);
1138
+ function rt(l) {
1139
+ const f = we.current;
1140
+ if (!f) {
1141
+ Z((P) => P + l), Ie(!1);
1067
1142
  return;
1068
1143
  }
1069
- const k = g.selectionStart ?? x.length, j = g.selectionEnd ?? x.length, K = x.slice(0, k) + a + x.slice(j);
1070
- b(K), he(!1), requestAnimationFrame(() => {
1071
- g.focus(), g.selectionStart = g.selectionEnd = k + a.length;
1144
+ const v = f.selectionStart ?? j.length, O = f.selectionEnd ?? j.length, N = j.slice(0, v) + l + j.slice(O);
1145
+ Z(N), Ie(!1), requestAnimationFrame(() => {
1146
+ f.focus(), f.selectionStart = f.selectionEnd = v + l.length;
1072
1147
  });
1073
1148
  }
1074
- function pe(a) {
1075
- b(a), Ie(!1), me(""), requestAnimationFrame(() => {
1076
- const g = Ce.current;
1077
- g && (g.focus(), g.selectionStart = g.selectionEnd = a.length);
1149
+ function Fe(l) {
1150
+ Z(l), Be(!1), De(""), requestAnimationFrame(() => {
1151
+ const f = we.current;
1152
+ f && (f.focus(), f.selectionStart = f.selectionEnd = l.length);
1078
1153
  });
1079
1154
  }
1080
- const be = !ne && (x.trim().length > 0 || (c == null ? void 0 : c.url) != null && !c.uploading);
1081
- return /* @__PURE__ */ n("section", { style: f.chat, children: [
1082
- /* @__PURE__ */ n("header", { style: f.chatHeader, children: [
1083
- /* @__PURE__ */ e($t, { name: U, color: h, image: t.contactPictureUrl, provider: i }),
1084
- /* @__PURE__ */ n("div", { style: f.contact, children: [
1085
- /* @__PURE__ */ e("strong", { style: f.contactName, children: U }),
1086
- /* @__PURE__ */ e("span", { style: f.contactMeta, children: en(r) ?? Wt(i) })
1155
+ const me = !fe && (j.trim().length > 0 || (z == null ? void 0 : z.url) != null && !z.uploading), xe = F === "desktop" ? x.toolbarBtn : { ...x.toolbarBtn, width: 32, height: 32 };
1156
+ return /* @__PURE__ */ n("section", { style: x.chat, children: [
1157
+ /* @__PURE__ */ n("header", { style: { ...x.chatHeader, ...F === "mobile" ? { padding: "0 10px 0 8px", gap: 8 } : {} }, children: [
1158
+ F === "mobile" && /* @__PURE__ */ n(
1159
+ "button",
1160
+ {
1161
+ type: "button",
1162
+ onClick: re,
1163
+ "aria-label": "Quay lại danh sách",
1164
+ style: {
1165
+ ...x.iconButton,
1166
+ width: 36,
1167
+ height: 36,
1168
+ marginLeft: 0,
1169
+ position: "relative",
1170
+ flexShrink: 0,
1171
+ color: a.ink
1172
+ },
1173
+ children: [
1174
+ /* @__PURE__ */ e(Xt, { size: 18, strokeWidth: 2.2 }),
1175
+ V > 0 && /* @__PURE__ */ e(
1176
+ "span",
1177
+ {
1178
+ style: {
1179
+ position: "absolute",
1180
+ top: 3,
1181
+ right: 3,
1182
+ minWidth: 15,
1183
+ height: 15,
1184
+ borderRadius: 999,
1185
+ background: "#ef4444",
1186
+ color: "#fff",
1187
+ fontSize: 9,
1188
+ fontWeight: 800,
1189
+ display: "inline-grid",
1190
+ placeItems: "center",
1191
+ padding: "0 3px",
1192
+ border: `1.5px solid ${a.white}`
1193
+ },
1194
+ children: V > 99 ? "99+" : V
1195
+ }
1196
+ )
1197
+ ]
1198
+ }
1199
+ ),
1200
+ /* @__PURE__ */ e(Pt, { name: h, color: c, image: t.contactPictureUrl, provider: i }),
1201
+ /* @__PURE__ */ n("div", { style: x.contact, children: [
1202
+ /* @__PURE__ */ e("strong", { style: x.contactName, children: h }),
1203
+ /* @__PURE__ */ e("span", { style: x.contactMeta, children: fn(o) ?? Nt(i) })
1087
1204
  ] }),
1088
- /* @__PURE__ */ n("div", { style: { ...f.headerActions, alignItems: "center", gap: 6 }, children: [
1089
- /* @__PURE__ */ n("div", { ref: Ke, style: { position: "relative", display: "inline-flex", alignItems: "center", gap: 4 }, children: [
1090
- !t.assignedAgent && C ? /* @__PURE__ */ n("div", { style: { display: "inline-flex", alignItems: "center", borderRadius: 999, border: `1px solid ${h}40`, background: `${h}0d`, overflow: "hidden" }, children: [
1205
+ /* @__PURE__ */ n("div", { style: { ...x.headerActions, alignItems: "center", gap: 6 }, children: [
1206
+ /* @__PURE__ */ n("div", { ref: Le, style: { position: "relative", display: "inline-flex", alignItems: "center", gap: 4 }, children: [
1207
+ !t.assignedAgent && I ? /* @__PURE__ */ n("div", { style: { display: "inline-flex", alignItems: "center", borderRadius: 999, border: `1px solid ${c}40`, background: `${c}0d`, overflow: "hidden" }, children: [
1091
1208
  /* @__PURE__ */ n(
1092
1209
  "button",
1093
1210
  {
1094
1211
  type: "button",
1095
- onClick: () => void I(C),
1212
+ onClick: () => void R(I),
1096
1213
  style: {
1097
1214
  border: 0,
1098
1215
  background: "transparent",
1099
- color: h,
1216
+ color: c,
1100
1217
  padding: "4px 9px",
1101
1218
  fontSize: 11.5,
1102
1219
  fontWeight: 600,
@@ -1107,51 +1224,51 @@ function rn({ conversation: t, provider: i, connection: r, client: o, primary: h
1107
1224
  whiteSpace: "nowrap"
1108
1225
  },
1109
1226
  children: [
1110
- /* @__PURE__ */ e(ft, { size: 12, strokeWidth: 2.2 }),
1111
- /* @__PURE__ */ e("span", { children: "+ Nhận phụ trách" })
1227
+ /* @__PURE__ */ e(It, { size: 12, strokeWidth: 2.2 }),
1228
+ /* @__PURE__ */ e("span", { children: F === "mobile" ? "+ Nhận" : "+ Nhận phụ trách" })
1112
1229
  ]
1113
1230
  }
1114
1231
  ),
1115
- ((D == null ? void 0 : D.length) ?? 0) > 1 && /* @__PURE__ */ e(
1232
+ ((q == null ? void 0 : q.length) ?? 0) > 1 && /* @__PURE__ */ e(
1116
1233
  "button",
1117
1234
  {
1118
1235
  type: "button",
1119
1236
  "aria-label": "Chọn nhân viên phụ trách",
1120
- onClick: () => G((a) => !a),
1237
+ onClick: () => oe((l) => !l),
1121
1238
  style: {
1122
1239
  border: 0,
1123
- borderLeft: `1px solid ${h}30`,
1240
+ borderLeft: `1px solid ${c}30`,
1124
1241
  background: "transparent",
1125
- color: h,
1242
+ color: c,
1126
1243
  padding: "4px 6px",
1127
1244
  cursor: "pointer",
1128
1245
  display: "inline-flex",
1129
1246
  alignItems: "center"
1130
1247
  },
1131
- children: /* @__PURE__ */ e(nt, { size: 12, strokeWidth: 2.2 })
1248
+ children: /* @__PURE__ */ e(ct, { size: 12, strokeWidth: 2.2 })
1132
1249
  }
1133
1250
  )
1134
1251
  ] }) : /* @__PURE__ */ n(
1135
1252
  "button",
1136
1253
  {
1137
1254
  type: "button",
1138
- onClick: () => G((a) => !a),
1255
+ onClick: () => oe((l) => !l),
1139
1256
  style: {
1140
1257
  display: "inline-flex",
1141
1258
  alignItems: "center",
1142
1259
  gap: 6,
1143
1260
  padding: "3px 9px 3px 4px",
1144
1261
  borderRadius: 999,
1145
- border: `1px solid ${d.line}`,
1146
- background: d.surface,
1147
- color: d.ink,
1262
+ border: `1px solid ${a.line}`,
1263
+ background: a.surface,
1264
+ color: a.ink,
1148
1265
  fontSize: 11.5,
1149
1266
  fontWeight: 600,
1150
1267
  cursor: "pointer",
1151
1268
  whiteSpace: "nowrap"
1152
1269
  },
1153
1270
  children: [
1154
- t.assignedAgent ? /* @__PURE__ */ n(ie, { children: [
1271
+ t.assignedAgent ? /* @__PURE__ */ n(ne, { children: [
1155
1272
  /* @__PURE__ */ e(
1156
1273
  "span",
1157
1274
  {
@@ -1159,7 +1276,7 @@ function rn({ conversation: t, provider: i, connection: r, client: o, primary: h
1159
1276
  width: 18,
1160
1277
  height: 18,
1161
1278
  borderRadius: "50%",
1162
- background: h,
1279
+ background: c,
1163
1280
  color: "#fff",
1164
1281
  fontSize: 9,
1165
1282
  fontWeight: 700,
@@ -1168,44 +1285,44 @@ function rn({ conversation: t, provider: i, connection: r, client: o, primary: h
1168
1285
  overflow: "hidden",
1169
1286
  flexShrink: 0
1170
1287
  },
1171
- children: t.assignedAgent.avatarUrl ? /* @__PURE__ */ e("img", { src: t.assignedAgent.avatarUrl, alt: "", style: { width: "100%", height: "100%", objectFit: "cover" } }) : Le(t.assignedAgent.name)
1288
+ children: t.assignedAgent.avatarUrl ? /* @__PURE__ */ e("img", { src: t.assignedAgent.avatarUrl, alt: "", style: { width: "100%", height: "100%", objectFit: "cover" } }) : je(t.assignedAgent.name)
1172
1289
  }
1173
1290
  ),
1174
- /* @__PURE__ */ e("span", { style: { color: d.muted, fontWeight: 500 }, children: "Phụ trách:" }),
1175
- /* @__PURE__ */ e("span", { style: { maxWidth: 110, overflow: "hidden", textOverflow: "ellipsis" }, children: rt(t.assignedAgent.name) })
1176
- ] }) : /* @__PURE__ */ n(ie, { children: [
1177
- /* @__PURE__ */ e(Vt, { size: 13, color: d.muted }),
1178
- /* @__PURE__ */ e("span", { style: { color: d.muted }, children: "Chưa phân công" })
1291
+ F !== "mobile" && /* @__PURE__ */ e("span", { style: { color: a.muted, fontWeight: 500 }, children: "Phụ trách:" }),
1292
+ /* @__PURE__ */ e("span", { style: { maxWidth: F === "mobile" ? 76 : 110, overflow: "hidden", textOverflow: "ellipsis" }, children: pt(t.assignedAgent.name) })
1293
+ ] }) : /* @__PURE__ */ n(ne, { children: [
1294
+ /* @__PURE__ */ e(an, { size: 13, color: a.muted }),
1295
+ /* @__PURE__ */ e("span", { style: { color: a.muted }, children: "Chưa phân công" })
1179
1296
  ] }),
1180
- /* @__PURE__ */ e(nt, { size: 12, color: d.muted })
1297
+ /* @__PURE__ */ e(ct, { size: 12, color: a.muted })
1181
1298
  ]
1182
1299
  }
1183
1300
  ),
1184
- Ae && /* @__PURE__ */ n(
1301
+ _ && /* @__PURE__ */ n(
1185
1302
  "div",
1186
1303
  {
1187
- ref: qe,
1304
+ ref: Ze,
1188
1305
  style: {
1189
1306
  position: "absolute",
1190
1307
  top: "calc(100% + 6px)",
1191
1308
  right: 0,
1192
1309
  zIndex: 200,
1193
1310
  minWidth: 230,
1194
- background: d.white,
1195
- border: `1px solid ${d.line}`,
1311
+ background: a.white,
1312
+ border: `1px solid ${a.line}`,
1196
1313
  borderRadius: 11,
1197
1314
  boxShadow: "0 10px 28px rgba(23,32,51,.15)",
1198
1315
  padding: 6,
1199
1316
  fontSize: 12
1200
1317
  },
1201
1318
  children: [
1202
- /* @__PURE__ */ e("div", { style: { padding: "4px 8px 6px", fontSize: 10, fontWeight: 700, color: d.muted, letterSpacing: 0.8, textTransform: "uppercase" }, children: "Người phụ trách hội thoại" }),
1203
- C && ((Re = t.assignedAgent) == null ? void 0 : Re.id) !== C.id && /* @__PURE__ */ n(
1319
+ /* @__PURE__ */ e("div", { style: { padding: "4px 8px 6px", fontSize: 10, fontWeight: 700, color: a.muted, letterSpacing: 0.8, textTransform: "uppercase" }, children: "Người phụ trách hội thoại" }),
1320
+ I && ((Qe = t.assignedAgent) == null ? void 0 : Qe.id) !== I.id && /* @__PURE__ */ n(
1204
1321
  "button",
1205
1322
  {
1206
1323
  type: "button",
1207
1324
  onClick: () => {
1208
- G(!1), I(C);
1325
+ oe(!1), R(I);
1209
1326
  },
1210
1327
  style: {
1211
1328
  display: "flex",
@@ -1214,8 +1331,8 @@ function rn({ conversation: t, provider: i, connection: r, client: o, primary: h
1214
1331
  width: "100%",
1215
1332
  border: 0,
1216
1333
  borderRadius: 7,
1217
- background: `${h}10`,
1218
- color: h,
1334
+ background: `${c}10`,
1335
+ color: c,
1219
1336
  padding: "6px 8px",
1220
1337
  marginBottom: 4,
1221
1338
  fontWeight: 600,
@@ -1224,24 +1341,24 @@ function rn({ conversation: t, provider: i, connection: r, client: o, primary: h
1224
1341
  textAlign: "left"
1225
1342
  },
1226
1343
  children: [
1227
- /* @__PURE__ */ e(ft, { size: 13 }),
1344
+ /* @__PURE__ */ e(It, { size: 13 }),
1228
1345
  /* @__PURE__ */ n("span", { children: [
1229
1346
  "Nhận phụ trách cho tôi (",
1230
- rt(C.name),
1347
+ pt(I.name),
1231
1348
  ")"
1232
1349
  ] })
1233
1350
  ]
1234
1351
  }
1235
1352
  ),
1236
- /* @__PURE__ */ e("div", { style: { maxHeight: 200, overflowY: "auto" }, children: (D ?? []).map((a) => {
1237
- var k;
1238
- const g = ((k = t.assignedAgent) == null ? void 0 : k.id) === a.id;
1353
+ /* @__PURE__ */ e("div", { style: { maxHeight: 200, overflowY: "auto" }, children: (q ?? []).map((l) => {
1354
+ var v;
1355
+ const f = ((v = t.assignedAgent) == null ? void 0 : v.id) === l.id;
1239
1356
  return /* @__PURE__ */ n(
1240
1357
  "button",
1241
1358
  {
1242
1359
  type: "button",
1243
1360
  onClick: () => {
1244
- G(!1), I(a);
1361
+ oe(!1), R(l);
1245
1362
  },
1246
1363
  style: {
1247
1364
  display: "flex",
@@ -1251,8 +1368,8 @@ function rn({ conversation: t, provider: i, connection: r, client: o, primary: h
1251
1368
  width: "100%",
1252
1369
  border: 0,
1253
1370
  borderRadius: 7,
1254
- background: g ? "#f1f5f9" : "transparent",
1255
- color: d.ink,
1371
+ background: f ? "#f1f5f9" : "transparent",
1372
+ color: a.ink,
1256
1373
  padding: "6px 8px",
1257
1374
  cursor: "pointer",
1258
1375
  textAlign: "left"
@@ -1266,8 +1383,8 @@ function rn({ conversation: t, provider: i, connection: r, client: o, primary: h
1266
1383
  width: 22,
1267
1384
  height: 22,
1268
1385
  borderRadius: "50%",
1269
- background: `${h}18`,
1270
- color: h,
1386
+ background: `${c}18`,
1387
+ color: c,
1271
1388
  fontSize: 10,
1272
1389
  fontWeight: 700,
1273
1390
  display: "inline-grid",
@@ -1275,28 +1392,28 @@ function rn({ conversation: t, provider: i, connection: r, client: o, primary: h
1275
1392
  overflow: "hidden",
1276
1393
  flexShrink: 0
1277
1394
  },
1278
- children: a.avatarUrl ? /* @__PURE__ */ e("img", { src: a.avatarUrl, alt: "", style: { width: "100%", height: "100%", objectFit: "cover" } }) : Le(a.name)
1395
+ children: l.avatarUrl ? /* @__PURE__ */ e("img", { src: l.avatarUrl, alt: "", style: { width: "100%", height: "100%", objectFit: "cover" } }) : je(l.name)
1279
1396
  }
1280
1397
  ),
1281
1398
  /* @__PURE__ */ n("span", { style: { minWidth: 0 }, children: [
1282
- /* @__PURE__ */ e("span", { style: { display: "block", fontWeight: 600, whiteSpace: "nowrap", overflow: "hidden", textOverflow: "ellipsis" }, children: a.name }),
1283
- a.title && /* @__PURE__ */ e("span", { style: { display: "block", fontSize: 10.5, color: d.muted }, children: a.title })
1399
+ /* @__PURE__ */ e("span", { style: { display: "block", fontWeight: 600, whiteSpace: "nowrap", overflow: "hidden", textOverflow: "ellipsis" }, children: l.name }),
1400
+ l.title && /* @__PURE__ */ e("span", { style: { display: "block", fontSize: 10.5, color: a.muted }, children: l.title })
1284
1401
  ] })
1285
1402
  ] }),
1286
- g && /* @__PURE__ */ e(lt, { size: 13, color: h, strokeWidth: 2.5 })
1403
+ f && /* @__PURE__ */ e(gt, { size: 13, color: c, strokeWidth: 2.5 })
1287
1404
  ]
1288
1405
  },
1289
- a.id
1406
+ l.id
1290
1407
  );
1291
1408
  }) }),
1292
- t.assignedAgent && /* @__PURE__ */ n(ie, { children: [
1293
- /* @__PURE__ */ e("div", { style: { borderTop: `1px solid ${d.line}`, margin: "5px 0" } }),
1409
+ t.assignedAgent && /* @__PURE__ */ n(ne, { children: [
1410
+ /* @__PURE__ */ e("div", { style: { borderTop: `1px solid ${a.line}`, margin: "5px 0" } }),
1294
1411
  /* @__PURE__ */ n(
1295
1412
  "button",
1296
1413
  {
1297
1414
  type: "button",
1298
1415
  onClick: () => {
1299
- G(!1), I(null);
1416
+ oe(!1), R(null);
1300
1417
  },
1301
1418
  style: {
1302
1419
  display: "flex",
@@ -1314,7 +1431,7 @@ function rn({ conversation: t, provider: i, connection: r, client: o, primary: h
1314
1431
  textAlign: "left"
1315
1432
  },
1316
1433
  children: [
1317
- /* @__PURE__ */ e(Oe, { size: 13 }),
1434
+ /* @__PURE__ */ e(Ve, { size: 13 }),
1318
1435
  /* @__PURE__ */ e("span", { children: "Bỏ phân công (Chưa có người nhận)" })
1319
1436
  ]
1320
1437
  }
@@ -1324,94 +1441,96 @@ function rn({ conversation: t, provider: i, connection: r, client: o, primary: h
1324
1441
  }
1325
1442
  )
1326
1443
  ] }),
1327
- /* @__PURE__ */ e("button", { style: f.iconButton, "aria-label": "Thêm tùy chọn", children: /* @__PURE__ */ e(It, { size: 16, strokeWidth: 2 }) }),
1444
+ F !== "mobile" && /* @__PURE__ */ e("button", { style: x.iconButton, "aria-label": "Thêm tùy chọn", children: /* @__PURE__ */ e(Et, { size: 16, strokeWidth: 2 }) }),
1328
1445
  /* @__PURE__ */ e(
1329
1446
  "button",
1330
1447
  {
1331
1448
  style: {
1332
- ...f.iconButton,
1333
- background: w ? `${h}14` : "transparent",
1334
- color: w ? h : d.muted
1449
+ ...x.iconButton,
1450
+ background: w ? `${c}14` : "transparent",
1451
+ color: w ? c : a.muted
1335
1452
  },
1336
1453
  "aria-label": "Thông tin liên hệ",
1337
- onClick: v,
1338
- children: /* @__PURE__ */ e(Dt, { size: 16, strokeWidth: 2 })
1454
+ onClick: g,
1455
+ children: /* @__PURE__ */ e(Qt, { size: 16, strokeWidth: 2 })
1339
1456
  }
1340
1457
  )
1341
1458
  ] })
1342
1459
  ] }),
1343
- /* @__PURE__ */ n(Rt, { ref: Z, style: f.messageArea, children: [
1344
- /* @__PURE__ */ e("div", { style: f.day, children: W.today }),
1345
- Q && /* @__PURE__ */ e("button", { onClick: () => void fe(Q), style: f.historyButton, children: W.loadOlder }),
1346
- E && /* @__PURE__ */ n("div", { style: f.messageHint, children: [
1347
- /* @__PURE__ */ e(ot, {}),
1460
+ /* @__PURE__ */ n(Ut, { ref: ie, style: x.messageArea, children: [
1461
+ /* @__PURE__ */ e("div", { style: x.day, children: $.today }),
1462
+ S && /* @__PURE__ */ e("button", { onClick: () => void ye(S), style: x.historyButton, children: $.loadOlder }),
1463
+ pe && /* @__PURE__ */ n("div", { style: x.messageHint, children: [
1464
+ /* @__PURE__ */ e(ut, {}),
1348
1465
  " ",
1349
- W.loading
1466
+ $.loading
1350
1467
  ] }),
1351
- !E && !q.length && /* @__PURE__ */ e("div", { style: f.messageHint, children: W.noMessages }),
1352
- q.map((a, g) => {
1353
- const k = ($ == null ? void 0 : $.flatMap((re) => re.messageEnrichments ?? [])) ?? [], j = a.direction === "inbound" && k.length > 0 && g >= q.length - 15, K = j ? Je(t, {
1468
+ !pe && !B.length && /* @__PURE__ */ e("div", { style: x.messageHint, children: $.noMessages }),
1469
+ B.map((l, f) => {
1470
+ const v = (M == null ? void 0 : M.flatMap((ae) => ae.messageEnrichments ?? [])) ?? [], O = l.direction === "inbound" && v.length > 0 && f >= B.length - 15, N = O ? ot(t, {
1354
1471
  provider: i,
1355
- recentMessages: q.slice(-10),
1356
- linkContact: L,
1357
- refreshContactInfo: P,
1358
- sendMessage: async (re, l) => {
1359
- await o.sendMessage(t.id, re, l), await fe(void 0, !0);
1472
+ recentMessages: B.slice(-10),
1473
+ linkContact: H,
1474
+ refreshContactInfo: J,
1475
+ sendMessage: async (ae, Se) => {
1476
+ await r.sendMessage(t.id, ae, Se), await ye(void 0, !0);
1360
1477
  }
1361
- }) : null, O = j && K ? k.map((re, l) => {
1362
- var u;
1363
- const p = (u = a.text) == null ? void 0 : u.match(re.pattern);
1364
- return p ? /* @__PURE__ */ e(_t, { children: re.render(p, K, a) }, `${a.id}-${l}`) : null;
1478
+ }) : null, P = O && N ? v.map((ae, Se) => {
1479
+ var ge;
1480
+ const Re = (ge = l.text) == null ? void 0 : ge.match(ae.pattern);
1481
+ return Re ? /* @__PURE__ */ e(pn, { children: ae.render(Re, N, l) }, `${l.id}-${Se}`) : null;
1365
1482
  }).filter(Boolean) : [];
1366
1483
  return /* @__PURE__ */ n("div", { children: [
1367
- /* @__PURE__ */ e(on, { message: a, primary: h }),
1368
- O.length > 0 && /* @__PURE__ */ e("div", { style: { maxWidth: "min(70%, 480px)", marginTop: -4, marginBottom: 10, display: "flex", flexDirection: "column", gap: 6 }, children: O })
1369
- ] }, a.id);
1484
+ /* @__PURE__ */ e(mn, { message: l, primary: c }),
1485
+ P.length > 0 && /* @__PURE__ */ e("div", { style: { maxWidth: "min(70%, 480px)", marginTop: -4, marginBottom: 10, display: "flex", flexDirection: "column", gap: 6 }, children: P })
1486
+ ] }, l.id);
1370
1487
  })
1371
1488
  ] }),
1372
- /* @__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((a) => /* @__PURE__ */ e(
1489
+ /* @__PURE__ */ e("div", { style: { display: "flex", gap: 6, flexWrap: "nowrap", overflowX: "auto", WebkitOverflowScrolling: "touch", scrollbarWidth: "none", padding: "6px 14px 2px", borderTop: `1px solid ${a.line}` }, children: ["Cảm ơn bạn đã liên hệ 🙏", "Mình sẽ kiểm tra ngay", "Vui lòng chờ 1-2 phút"].map((l) => /* @__PURE__ */ e(
1373
1490
  "button",
1374
1491
  {
1375
1492
  type: "button",
1376
- onClick: () => b(a),
1493
+ onClick: () => Z(l),
1377
1494
  style: {
1378
1495
  fontSize: 11,
1379
1496
  padding: "3px 10px",
1380
1497
  borderRadius: 999,
1381
- background: `${h}0f`,
1382
- color: h,
1383
- border: `1px solid ${h}33`,
1498
+ background: `${c}0f`,
1499
+ color: c,
1500
+ border: `1px solid ${c}33`,
1384
1501
  cursor: "pointer",
1385
- whiteSpace: "nowrap"
1502
+ whiteSpace: "nowrap",
1503
+ flexShrink: 0
1386
1504
  },
1387
- children: a
1505
+ children: l
1388
1506
  },
1389
- a
1507
+ l
1390
1508
  )) }),
1391
- /* @__PURE__ */ n("form", { onSubmit: Ge, style: { flex: "0 0 auto", padding: "8px 14px 12px", borderTop: `1px solid ${d.line}`, background: d.white, position: "relative" }, children: [
1392
- F && /* @__PURE__ */ n(
1509
+ /* @__PURE__ */ n("form", { onSubmit: _e, style: { flex: "0 0 auto", padding: "8px 14px 12px", borderTop: `1px solid ${a.line}`, background: a.white, position: "relative" }, children: [
1510
+ ke && /* @__PURE__ */ n(
1393
1511
  "div",
1394
1512
  {
1395
- ref: He,
1513
+ ref: Oe,
1396
1514
  style: {
1397
1515
  position: "absolute",
1398
1516
  bottom: "calc(100% + 6px)",
1399
1517
  left: 0,
1400
1518
  zIndex: 100,
1401
- background: d.white,
1402
- border: `1px solid ${d.line}`,
1519
+ background: a.white,
1520
+ border: `1px solid ${a.line}`,
1403
1521
  borderRadius: 12,
1404
1522
  boxShadow: "0 8px 24px rgba(23,32,51,.14)",
1405
1523
  width: 280,
1524
+ maxWidth: "calc(100vw - 28px)",
1406
1525
  overflow: "hidden",
1407
1526
  fontFamily: "inherit"
1408
1527
  },
1409
1528
  children: [
1410
- /* @__PURE__ */ e("div", { style: { display: "flex", borderBottom: `1px solid ${d.line}`, background: "#f9fafb" }, children: gt.map((a, g) => /* @__PURE__ */ e(
1529
+ /* @__PURE__ */ e("div", { style: { display: "flex", borderBottom: `1px solid ${a.line}`, background: "#f9fafb" }, children: zt.map((l, f) => /* @__PURE__ */ e(
1411
1530
  "button",
1412
1531
  {
1413
1532
  type: "button",
1414
- onClick: () => Me(g),
1533
+ onClick: () => ee(f),
1415
1534
  style: {
1416
1535
  flex: 1,
1417
1536
  border: 0,
@@ -1420,19 +1539,19 @@ function rn({ conversation: t, provider: i, connection: r, client: o, primary: h
1420
1539
  fontSize: 16,
1421
1540
  cursor: "pointer",
1422
1541
  lineHeight: 1,
1423
- borderBottom: Se === g ? `2px solid ${h}` : "2px solid transparent",
1424
- opacity: Se === g ? 1 : 0.5,
1542
+ borderBottom: Ee === f ? `2px solid ${c}` : "2px solid transparent",
1543
+ opacity: Ee === f ? 1 : 0.5,
1425
1544
  transition: "opacity 100ms ease"
1426
1545
  },
1427
- children: a.icon
1546
+ children: l.icon
1428
1547
  },
1429
- g
1548
+ f
1430
1549
  )) }),
1431
- /* @__PURE__ */ e("div", { style: { display: "grid", gridTemplateColumns: "repeat(8, 1fr)", gap: 2, padding: 8, maxHeight: 180, overflowY: "auto" }, children: (Te = gt[Se]) == null ? void 0 : Te.emojis.map((a, g) => /* @__PURE__ */ e(
1550
+ /* @__PURE__ */ e("div", { style: { display: "grid", gridTemplateColumns: "repeat(8, 1fr)", gap: 2, padding: 8, maxHeight: 180, overflowY: "auto" }, children: (et = zt[Ee]) == null ? void 0 : et.emojis.map((l, f) => /* @__PURE__ */ e(
1432
1551
  "button",
1433
1552
  {
1434
1553
  type: "button",
1435
- onClick: () => Ze(a),
1554
+ onClick: () => rt(l),
1436
1555
  style: {
1437
1556
  border: 0,
1438
1557
  background: "transparent",
@@ -1443,127 +1562,128 @@ function rn({ conversation: t, provider: i, connection: r, client: o, primary: h
1443
1562
  lineHeight: 1,
1444
1563
  transition: "background 80ms ease"
1445
1564
  },
1446
- onMouseEnter: (k) => {
1447
- k.target.style.background = "#f3f4f6";
1565
+ onMouseEnter: (v) => {
1566
+ v.target.style.background = "#f3f4f6";
1448
1567
  },
1449
- onMouseLeave: (k) => {
1450
- k.target.style.background = "transparent";
1568
+ onMouseLeave: (v) => {
1569
+ v.target.style.background = "transparent";
1451
1570
  },
1452
- children: a
1571
+ children: l
1453
1572
  },
1454
- g
1573
+ f
1455
1574
  )) })
1456
1575
  ]
1457
1576
  }
1458
1577
  ),
1459
- ve && /* @__PURE__ */ n(
1578
+ ue && /* @__PURE__ */ n(
1460
1579
  "div",
1461
1580
  {
1462
- ref: ze,
1581
+ ref: Pe,
1463
1582
  style: {
1464
1583
  position: "absolute",
1465
1584
  bottom: "calc(100% + 6px)",
1466
1585
  left: 0,
1467
1586
  zIndex: 100,
1468
- background: d.white,
1469
- border: `1px solid ${d.line}`,
1587
+ background: a.white,
1588
+ border: `1px solid ${a.line}`,
1470
1589
  borderRadius: 12,
1471
1590
  boxShadow: "0 8px 24px rgba(23,32,51,.14)",
1472
1591
  width: 300,
1592
+ maxWidth: "calc(100vw - 28px)",
1473
1593
  overflow: "hidden",
1474
1594
  fontFamily: "inherit"
1475
1595
  },
1476
1596
  children: [
1477
- /* @__PURE__ */ e("div", { style: { padding: "8px 10px", borderBottom: `1px solid ${d.line}` }, children: /* @__PURE__ */ e(
1597
+ /* @__PURE__ */ e("div", { style: { padding: "8px 10px", borderBottom: `1px solid ${a.line}` }, children: /* @__PURE__ */ e(
1478
1598
  "input",
1479
1599
  {
1480
1600
  autoFocus: !0,
1481
1601
  type: "text",
1482
1602
  placeholder: "Tìm template…",
1483
- value: Ne,
1484
- onChange: (a) => me(a.target.value),
1485
- 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 }
1603
+ value: Ue,
1604
+ onChange: (l) => De(l.target.value),
1605
+ style: { width: "100%", boxSizing: "border-box", border: `1px solid ${a.line}`, borderRadius: 7, padding: "5px 8px", fontSize: 12, outline: "none", fontFamily: "inherit", color: a.ink }
1486
1606
  }
1487
1607
  ) }),
1488
1608
  /* @__PURE__ */ e("div", { style: { maxHeight: 220, overflowY: "auto" }, children: (() => {
1489
- const a = Ne.trim().toLowerCase(), g = a ? _.filter((k) => k.title.toLowerCase().includes(a) || k.content.toLowerCase().includes(a) || (k.shortcut ?? "").toLowerCase().includes(a)) : _;
1490
- return g.length ? g.map((k) => /* @__PURE__ */ n(
1609
+ const l = Ue.trim().toLowerCase(), f = l ? Ne.filter((v) => v.title.toLowerCase().includes(l) || v.content.toLowerCase().includes(l) || (v.shortcut ?? "").toLowerCase().includes(l)) : Ne;
1610
+ return f.length ? f.map((v) => /* @__PURE__ */ n(
1491
1611
  "button",
1492
1612
  {
1493
1613
  type: "button",
1494
- onClick: () => pe(k.content),
1495
- style: { display: "block", width: "100%", textAlign: "left", border: 0, borderBottom: `1px solid ${d.line}`, background: "transparent", padding: "9px 12px", cursor: "pointer", fontFamily: "inherit" },
1496
- onMouseEnter: (j) => {
1497
- j.currentTarget.style.background = "#f7f9fc";
1614
+ onClick: () => Fe(v.content),
1615
+ style: { display: "block", width: "100%", textAlign: "left", border: 0, borderBottom: `1px solid ${a.line}`, background: "transparent", padding: "9px 12px", cursor: "pointer", fontFamily: "inherit" },
1616
+ onMouseEnter: (O) => {
1617
+ O.currentTarget.style.background = "#f7f9fc";
1498
1618
  },
1499
- onMouseLeave: (j) => {
1500
- j.currentTarget.style.background = "transparent";
1619
+ onMouseLeave: (O) => {
1620
+ O.currentTarget.style.background = "transparent";
1501
1621
  },
1502
1622
  children: [
1503
1623
  /* @__PURE__ */ n("div", { style: { display: "flex", alignItems: "center", gap: 6, marginBottom: 2 }, children: [
1504
- /* @__PURE__ */ e("span", { style: { fontSize: 12, fontWeight: 600, color: d.ink }, children: k.title }),
1505
- k.shortcut && /* @__PURE__ */ e("span", { style: { fontSize: 10, color: h, background: `${h}18`, borderRadius: 4, padding: "1px 5px" }, children: k.shortcut })
1624
+ /* @__PURE__ */ e("span", { style: { fontSize: 12, fontWeight: 600, color: a.ink }, children: v.title }),
1625
+ v.shortcut && /* @__PURE__ */ e("span", { style: { fontSize: 10, color: c, background: `${c}18`, borderRadius: 4, padding: "1px 5px" }, children: v.shortcut })
1506
1626
  ] }),
1507
- /* @__PURE__ */ e("div", { style: { fontSize: 11, color: d.muted, overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" }, children: k.content })
1627
+ /* @__PURE__ */ e("div", { style: { fontSize: 11, color: a.muted, overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" }, children: v.content })
1508
1628
  ]
1509
1629
  },
1510
- k.id
1511
- )) : /* @__PURE__ */ e("div", { style: { padding: "24px 16px", textAlign: "center", color: d.muted, fontSize: 12 }, children: _.length === 0 ? "Chưa có template nào" : "Không tìm thấy" });
1630
+ v.id
1631
+ )) : /* @__PURE__ */ e("div", { style: { padding: "24px 16px", textAlign: "center", color: a.muted, fontSize: 12 }, children: Ne.length === 0 ? "Chưa có template nào" : "Không tìm thấy" });
1512
1632
  })() })
1513
1633
  ]
1514
1634
  }
1515
1635
  ),
1516
- /* @__PURE__ */ n("div", { style: { border: `1.5px solid ${d.line}`, borderRadius: 12, background: d.white, overflow: "hidden" }, children: [
1517
- c && /* @__PURE__ */ n("div", { style: { display: "flex", alignItems: "center", gap: 8, padding: "8px 12px", borderBottom: `1px solid ${d.line}`, fontSize: 12 }, children: [
1518
- c.uploading ? /* @__PURE__ */ n(ie, { children: [
1519
- /* @__PURE__ */ e(ot, {}),
1520
- /* @__PURE__ */ e("span", { style: { color: d.muted }, children: "Đang tải lên…" })
1521
- ] }) : c.attachmentType === "image" && c.objectUrl ? /* @__PURE__ */ e("img", { src: c.objectUrl, alt: "", style: { height: 48, width: 48, objectFit: "cover", borderRadius: 6 } }) : /* @__PURE__ */ n("span", { style: { color: d.muted }, children: [
1636
+ /* @__PURE__ */ n("div", { style: { border: `1.5px solid ${a.line}`, borderRadius: 12, background: a.white, overflow: "hidden" }, children: [
1637
+ z && /* @__PURE__ */ n("div", { style: { display: "flex", alignItems: "center", gap: 8, padding: "8px 12px", borderBottom: `1px solid ${a.line}`, fontSize: 12 }, children: [
1638
+ z.uploading ? /* @__PURE__ */ n(ne, { children: [
1639
+ /* @__PURE__ */ e(ut, {}),
1640
+ /* @__PURE__ */ e("span", { style: { color: a.muted }, children: "Đang tải lên…" })
1641
+ ] }) : z.attachmentType === "image" && z.objectUrl ? /* @__PURE__ */ e("img", { src: z.objectUrl, alt: "", style: { height: 48, width: 48, objectFit: "cover", borderRadius: 6 } }) : /* @__PURE__ */ n("span", { style: { color: a.muted }, children: [
1522
1642
  "📎 ",
1523
- c.file.name,
1643
+ z.file.name,
1524
1644
  " (",
1525
- Math.round(c.file.size / 1024),
1645
+ Math.round(z.file.size / 1024),
1526
1646
  " KB)"
1527
1647
  ] }),
1528
- !c.uploading && /* @__PURE__ */ e("button", { type: "button", onClick: () => {
1529
- c != null && c.objectUrl && URL.revokeObjectURL(c.objectUrl), H(null);
1530
- }, style: { marginLeft: "auto", border: 0, background: "none", color: d.muted, cursor: "pointer", fontSize: 16 }, "aria-label": "Xóa tệp đính kèm", children: "✕" })
1648
+ !z.uploading && /* @__PURE__ */ e("button", { type: "button", onClick: () => {
1649
+ z != null && z.objectUrl && URL.revokeObjectURL(z.objectUrl), ce(null);
1650
+ }, style: { marginLeft: "auto", border: 0, background: "none", color: a.muted, cursor: "pointer", fontSize: 16 }, "aria-label": "Xóa tệp đính kèm", children: "✕" })
1531
1651
  ] }),
1532
1652
  /* @__PURE__ */ n("div", { style: { display: "flex", alignItems: "center", gap: 2, padding: "4px 8px", borderBottom: "1px solid #f3f4f6" }, children: [
1533
1653
  /* @__PURE__ */ e(
1534
1654
  "button",
1535
1655
  {
1536
- ref: je,
1656
+ ref: $e,
1537
1657
  type: "button",
1538
1658
  title: "Chèn emoji",
1539
- onClick: () => he((a) => !a),
1540
- style: { ...f.toolbarBtn, background: F ? `${h}18` : "transparent", color: F ? h : "#9ca3af" },
1541
- children: /* @__PURE__ */ e(qt, { size: 13, strokeWidth: 2 })
1659
+ onClick: () => Ie((l) => !l),
1660
+ style: { ...xe, background: ke ? `${c}18` : "transparent", color: ke ? c : "#9ca3af" },
1661
+ children: /* @__PURE__ */ e(rn, { size: 13, strokeWidth: 2 })
1542
1662
  }
1543
1663
  ),
1544
- !T && /* @__PURE__ */ e("button", { type: "button", title: "Gửi ảnh / video", "aria-label": "Gửi ảnh hoặc video", style: f.toolbarBtn, onClick: () => {
1545
- var a;
1546
- return (a = ee.current) == null ? void 0 : a.click();
1547
- }, children: /* @__PURE__ */ e(Ut, { size: 13, strokeWidth: 2 }) }),
1548
- !T && /* @__PURE__ */ e("button", { type: "button", title: "Gửi tệp đính kèm", "aria-label": "Gửi tệp đính kèm", style: f.toolbarBtn, onClick: () => {
1549
- var a;
1550
- return (a = se.current) == null ? void 0 : a.click();
1551
- }, children: /* @__PURE__ */ e(Pt, { size: 13, strokeWidth: 2 }) }),
1552
- !T && /* @__PURE__ */ n(ie, { children: [
1553
- /* @__PURE__ */ e("input", { ref: ee, type: "file", style: { display: "none" }, onChange: Ve, accept: "image/*,video/mp4" }),
1554
- /* @__PURE__ */ e("input", { ref: se, type: "file", style: { display: "none" }, onChange: Ve, accept: ".pdf,audio/mpeg,audio/ogg,application/octet-stream,application/zip,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document" })
1664
+ !T && /* @__PURE__ */ e("button", { type: "button", title: "Gửi ảnh / video", "aria-label": "Gửi ảnh hoặc video", style: xe, onClick: () => {
1665
+ var l;
1666
+ return (l = A.current) == null ? void 0 : l.click();
1667
+ }, children: /* @__PURE__ */ e(Zt, { size: 13, strokeWidth: 2 }) }),
1668
+ !T && /* @__PURE__ */ e("button", { type: "button", title: "Gửi tệp đính kèm", "aria-label": "Gửi tệp đính kèm", style: xe, onClick: () => {
1669
+ var l;
1670
+ return (l = U.current) == null ? void 0 : l.click();
1671
+ }, children: /* @__PURE__ */ e(en, { size: 13, strokeWidth: 2 }) }),
1672
+ !T && /* @__PURE__ */ n(ne, { children: [
1673
+ /* @__PURE__ */ e("input", { ref: A, type: "file", style: { display: "none" }, onChange: te, accept: "image/*,video/mp4" }),
1674
+ /* @__PURE__ */ e("input", { ref: U, type: "file", style: { display: "none" }, onChange: te, accept: ".pdf,audio/mpeg,audio/ogg,application/octet-stream,application/zip,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document" })
1555
1675
  ] }),
1556
1676
  /* @__PURE__ */ e(
1557
1677
  "button",
1558
1678
  {
1559
- ref: Fe,
1679
+ ref: ze,
1560
1680
  type: "button",
1561
1681
  title: "Template nhanh",
1562
1682
  onClick: () => {
1563
- Ie((a) => !a), me("");
1683
+ Be((l) => !l), De("");
1564
1684
  },
1565
- style: { ...f.toolbarBtn, background: ve ? `${h}18` : "transparent", color: ve ? h : "#9ca3af" },
1566
- children: /* @__PURE__ */ e(Gt, { size: 13, strokeWidth: 2 })
1685
+ style: { ...xe, background: ue ? `${c}18` : "transparent", color: ue ? c : "#9ca3af" },
1686
+ children: /* @__PURE__ */ e(ln, { size: 13, strokeWidth: 2 })
1567
1687
  }
1568
1688
  ),
1569
1689
  /* @__PURE__ */ e("span", { style: { width: 1, height: 14, background: "#e5e7eb", margin: "0 2px" } }),
@@ -1572,8 +1692,8 @@ function rn({ conversation: t, provider: i, connection: r, client: o, primary: h
1572
1692
  {
1573
1693
  type: "button",
1574
1694
  title: "In đậm",
1575
- onClick: () => ae((a) => !a),
1576
- style: { ...f.toolbarBtn, fontWeight: 700, fontSize: 12, background: N ? `${h}18` : "transparent", color: N ? h : "#9ca3af", border: N ? `1px solid ${h}33` : "1px solid transparent" },
1695
+ onClick: () => Q((l) => !l),
1696
+ style: { ...xe, fontWeight: 700, fontSize: 12, background: de ? `${c}18` : "transparent", color: de ? c : "#9ca3af", border: de ? `1px solid ${c}33` : "1px solid transparent" },
1577
1697
  children: "B"
1578
1698
  }
1579
1699
  ),
@@ -1582,73 +1702,73 @@ function rn({ conversation: t, provider: i, connection: r, client: o, primary: h
1582
1702
  {
1583
1703
  type: "button",
1584
1704
  title: "Nghiêng",
1585
- onClick: () => ye((a) => !a),
1586
- style: { ...f.toolbarBtn, fontStyle: "italic", fontSize: 12, background: ce ? `${h}18` : "transparent", color: ce ? h : "#9ca3af", border: ce ? `1px solid ${h}33` : "1px solid transparent" },
1705
+ onClick: () => Ye((l) => !l),
1706
+ style: { ...xe, fontStyle: "italic", fontSize: 12, background: he ? `${c}18` : "transparent", color: he ? c : "#9ca3af", border: he ? `1px solid ${c}33` : "1px solid transparent" },
1587
1707
  children: "I"
1588
1708
  }
1589
1709
  ),
1590
- !!($ != null && $.some((a) => {
1591
- var g;
1592
- return (((g = a.toolbarActions) == null ? void 0 : g.length) ?? 0) > 0;
1710
+ !!(M != null && M.some((l) => {
1711
+ var f;
1712
+ return (((f = l.toolbarActions) == null ? void 0 : f.length) ?? 0) > 0;
1593
1713
  })) && /* @__PURE__ */ e("span", { style: { width: 1, height: 14, background: "#e5e7eb", margin: "0 4px" } }),
1594
- $ == null ? void 0 : $.flatMap((a) => a.toolbarActions ?? []).map((a, g) => /* @__PURE__ */ n(
1714
+ M == null ? void 0 : M.flatMap((l) => l.toolbarActions ?? []).map((l, f) => /* @__PURE__ */ n(
1595
1715
  "button",
1596
1716
  {
1597
1717
  type: "button",
1598
- title: a.tooltip,
1599
- style: a.label ? {
1718
+ title: l.tooltip,
1719
+ style: l.label ? {
1600
1720
  display: "inline-flex",
1601
1721
  alignItems: "center",
1602
1722
  gap: 5,
1603
1723
  padding: "3px 9px",
1604
1724
  borderRadius: 999,
1605
- border: `1px solid ${h}33`,
1606
- background: `${h}0f`,
1607
- color: h,
1725
+ border: `1px solid ${c}33`,
1726
+ background: `${c}0f`,
1727
+ color: c,
1608
1728
  fontSize: 11.5,
1609
1729
  fontWeight: 600,
1610
1730
  cursor: "pointer",
1611
1731
  lineHeight: 1.2,
1612
1732
  whiteSpace: "nowrap"
1613
- } : f.toolbarBtn,
1733
+ } : xe,
1614
1734
  onClick: () => {
1615
- const k = (K) => {
1616
- b((O) => O && !O.endsWith(" ") && !O.endsWith(`
1617
- `) ? `${O} ${K}` : `${O}${K}`), requestAnimationFrame(() => {
1618
- var O;
1619
- return (O = Ce.current) == null ? void 0 : O.focus();
1735
+ const v = (N) => {
1736
+ Z((P) => P && !P.endsWith(" ") && !P.endsWith(`
1737
+ `) ? `${P} ${N}` : `${P}${N}`), requestAnimationFrame(() => {
1738
+ var P;
1739
+ return (P = we.current) == null ? void 0 : P.focus();
1620
1740
  });
1621
- }, j = Je(t, {
1741
+ }, O = ot(t, {
1622
1742
  provider: i,
1623
- recentMessages: q.slice(-10),
1624
- linkContact: L,
1625
- refreshContactInfo: P,
1626
- sendMessage: async (K, O) => {
1627
- await o.sendMessage(t.id, K, O), await fe(void 0, !0);
1743
+ recentMessages: B.slice(-10),
1744
+ linkContact: H,
1745
+ refreshContactInfo: J,
1746
+ sendMessage: async (N, P) => {
1747
+ await r.sendMessage(t.id, N, P), await ye(void 0, !0);
1628
1748
  }
1629
1749
  });
1630
- a.onClick({ ...j, insertText: k });
1750
+ l.onClick({ ...O, insertText: v });
1631
1751
  },
1632
1752
  children: [
1633
- a.icon,
1634
- a.label && /* @__PURE__ */ e("span", { children: a.label })
1753
+ l.icon,
1754
+ l.label && /* @__PURE__ */ e("span", { children: l.label })
1635
1755
  ]
1636
1756
  },
1637
- g
1757
+ f
1638
1758
  ))
1639
1759
  ] }),
1640
1760
  /* @__PURE__ */ e(
1641
- Jt,
1761
+ cn,
1642
1762
  {
1643
- ref: Ce,
1763
+ ref: we,
1644
1764
  "aria-label": "Soạn tin nhắn",
1645
1765
  rows: 2,
1646
- value: x,
1647
- onChange: (a) => b(a.target.value),
1648
- onKeyDown: (a) => {
1649
- a.key === "Enter" && !a.shiftKey && (a.preventDefault(), Ge(a));
1766
+ value: j,
1767
+ onChange: (l) => Z(l.target.value),
1768
+ onKeyDown: (l) => {
1769
+ l.key === "Enter" && !l.shiftKey && (l.preventDefault(), _e(l));
1650
1770
  },
1651
- placeholder: W.sendPlaceholder,
1771
+ placeholder: $.sendPlaceholder,
1652
1772
  style: {
1653
1773
  display: "block",
1654
1774
  width: "100%",
@@ -1660,31 +1780,31 @@ function rn({ conversation: t, provider: i, connection: r, client: o, primary: h
1660
1780
  border: 0,
1661
1781
  outline: 0,
1662
1782
  background: "transparent",
1663
- color: d.ink,
1783
+ color: a.ink,
1664
1784
  padding: "8px 12px 4px",
1665
1785
  font: "inherit",
1666
- fontSize: 13,
1786
+ fontSize: F === "mobile" ? 16 : 13,
1667
1787
  lineHeight: 1.45,
1668
- fontStyle: ce ? "italic" : "normal",
1669
- fontWeight: N ? 700 : 400
1788
+ fontStyle: he ? "italic" : "normal",
1789
+ fontWeight: de ? 700 : 400
1670
1790
  }
1671
1791
  }
1672
1792
  ),
1673
1793
  /* @__PURE__ */ n("div", { style: { display: "flex", alignItems: "center", justifyContent: "space-between", padding: "4px 8px 6px 12px" }, children: [
1674
1794
  /* @__PURE__ */ n("span", { style: {
1675
1795
  fontSize: 11,
1676
- color: x.length > 1e3 ? "#ef4444" : x.length > 900 ? "#f59e0b" : "#9ca3af",
1677
- fontWeight: x.length > 1e3 ? 600 : 400
1796
+ color: j.length > 1e3 ? "#ef4444" : j.length > 900 ? "#f59e0b" : "#9ca3af",
1797
+ fontWeight: j.length > 1e3 ? 600 : 400
1678
1798
  }, children: [
1679
- x.length,
1799
+ j.length,
1680
1800
  "/1000"
1681
1801
  ] }),
1682
1802
  /* @__PURE__ */ n("div", { style: { display: "flex", alignItems: "center", gap: 6 }, children: [
1683
- !A && /* @__PURE__ */ e("span", { style: { fontSize: 10, color: "#9ca3af" }, children: "↵ Gửi · ⇧↵ Xuống dòng" }),
1803
+ !E && F === "desktop" && /* @__PURE__ */ e("span", { style: { fontSize: 10, color: "#9ca3af" }, children: "↵ Gửi · ⇧↵ Xuống dòng" }),
1684
1804
  /* @__PURE__ */ n(
1685
1805
  "button",
1686
1806
  {
1687
- disabled: !be,
1807
+ disabled: !me,
1688
1808
  "aria-label": "Gửi tin nhắn",
1689
1809
  style: {
1690
1810
  display: "flex",
@@ -1695,15 +1815,15 @@ function rn({ conversation: t, provider: i, connection: r, client: o, primary: h
1695
1815
  borderRadius: 999,
1696
1816
  fontSize: 12,
1697
1817
  fontWeight: 600,
1698
- background: be ? `linear-gradient(135deg,${h},#0ea5e9)` : "#e5e7eb",
1699
- color: be ? "#fff" : "#9ca3af",
1700
- cursor: be ? "pointer" : "not-allowed",
1701
- boxShadow: be ? "0 2px 8px rgba(37,99,235,0.25)" : "none",
1818
+ background: me ? `linear-gradient(135deg,${c},#0ea5e9)` : "#e5e7eb",
1819
+ color: me ? "#fff" : "#9ca3af",
1820
+ cursor: me ? "pointer" : "not-allowed",
1821
+ boxShadow: me ? "0 2px 8px rgba(37,99,235,0.25)" : "none",
1702
1822
  transition: "all 150ms ease"
1703
1823
  },
1704
1824
  children: [
1705
- ne ? /* @__PURE__ */ e(zt, { size: 12, style: { animation: "channelhub-spin .7s linear infinite" } }) : /* @__PURE__ */ e(Ft, { size: 12, strokeWidth: 2 }),
1706
- W.send
1825
+ fe ? /* @__PURE__ */ e(Ot, { size: 12, style: { animation: "channelhub-spin .7s linear infinite" } }) : /* @__PURE__ */ e(nn, { size: 12, strokeWidth: 2 }),
1826
+ $.send
1707
1827
  ]
1708
1828
  }
1709
1829
  )
@@ -1711,16 +1831,16 @@ function rn({ conversation: t, provider: i, connection: r, client: o, primary: h
1711
1831
  ] })
1712
1832
  ] })
1713
1833
  ] }),
1714
- (z || S) && /* @__PURE__ */ e("div", { role: "alert", style: f.error, children: z || S })
1834
+ (G || C) && /* @__PURE__ */ e("div", { role: "alert", style: x.error, children: G || C })
1715
1835
  ] });
1716
1836
  }
1717
- function on({ message: t, primary: i }) {
1718
- var q, te, Q, B, x;
1719
- const r = tt(st), o = tt(Tt), h = (b) => b.startsWith("/v1/media/proxy") ? `${r}${b}&tok=${encodeURIComponent(o)}` : b, S = t.direction === "outbound", m = ((q = t.attachments) == null ? void 0 : q.filter((b) => b.type === "image")) ?? [], M = ((te = t.attachments) == null ? void 0 : te.filter((b) => b.type === "sticker")) ?? [], w = ((Q = t.attachments) == null ? void 0 : Q.filter((b) => b.type === "video")) ?? [], v = ((B = t.attachments) == null ? void 0 : B.filter((b) => b.type === "audio")) ?? [], W = ((x = t.attachments) == null ? void 0 : x.filter((b) => b.type === "file")) ?? [], [T, A] = y(null), $ = S ? "flex-end" : "flex-start", C = S ? t.senderAgent ?? null : null, D = /* @__PURE__ */ n("div", { style: { display: "flex", alignItems: "center", justifyContent: S ? "flex-end" : "flex-start", gap: 5, marginTop: 4, fontSize: 10, opacity: 0.78, letterSpacing: 0.2, userSelect: "none" }, children: [
1720
- C && /* @__PURE__ */ n(
1837
+ function mn({ message: t, primary: i }) {
1838
+ var F, re, V, B, b;
1839
+ const o = st(yt), r = st(Dt), c = (S) => S.startsWith("/v1/media/proxy") ? `${o}${S}&tok=${encodeURIComponent(r)}` : S, C = t.direction === "outbound", y = ((F = t.attachments) == null ? void 0 : F.filter((S) => S.type === "image")) ?? [], L = ((re = t.attachments) == null ? void 0 : re.filter((S) => S.type === "sticker")) ?? [], w = ((V = t.attachments) == null ? void 0 : V.filter((S) => S.type === "video")) ?? [], g = ((B = t.attachments) == null ? void 0 : B.filter((S) => S.type === "audio")) ?? [], $ = ((b = t.attachments) == null ? void 0 : b.filter((S) => S.type === "file")) ?? [], [T, E] = u(null), M = C ? "flex-end" : "flex-start", I = C ? t.senderAgent ?? null : null, q = /* @__PURE__ */ n("div", { style: { display: "flex", alignItems: "center", justifyContent: C ? "flex-end" : "flex-start", gap: 5, marginTop: 4, fontSize: 10, opacity: 0.78, letterSpacing: 0.2, userSelect: "none" }, children: [
1840
+ I && /* @__PURE__ */ n(
1721
1841
  "span",
1722
1842
  {
1723
- title: C.title ? `${C.name} (${C.title})` : C.name,
1843
+ title: I.title ? `${I.name} (${I.title})` : I.name,
1724
1844
  style: { display: "inline-flex", alignItems: "center", gap: 3.5, fontWeight: 600 },
1725
1845
  children: [
1726
1846
  /* @__PURE__ */ e(
@@ -1739,189 +1859,192 @@ function on({ message: t, primary: i }) {
1739
1859
  overflow: "hidden",
1740
1860
  flexShrink: 0
1741
1861
  },
1742
- children: C.avatarUrl ? /* @__PURE__ */ e("img", { src: C.avatarUrl, alt: "", style: { width: "100%", height: "100%", objectFit: "cover" } }) : Le(C.name)
1862
+ children: I.avatarUrl ? /* @__PURE__ */ e("img", { src: I.avatarUrl, alt: "", style: { width: "100%", height: "100%", objectFit: "cover" } }) : je(I.name)
1743
1863
  }
1744
1864
  ),
1745
- /* @__PURE__ */ e("span", { children: C.name }),
1865
+ /* @__PURE__ */ e("span", { children: I.name }),
1746
1866
  /* @__PURE__ */ e("span", { style: { opacity: 0.6 }, children: "•" })
1747
1867
  ]
1748
1868
  }
1749
1869
  ),
1750
1870
  /* @__PURE__ */ n("time", { children: [
1751
- at(t.occurredAt, !0),
1752
- S && /* @__PURE__ */ n(ie, { children: [
1871
+ ft(t.occurredAt, !0),
1872
+ C && /* @__PURE__ */ n(ne, { children: [
1753
1873
  " ",
1754
- /* @__PURE__ */ e(bt, { status: t.status })
1874
+ /* @__PURE__ */ e(Wt, { status: t.status })
1755
1875
  ] })
1756
1876
  ] })
1757
- ] }), I = /* @__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: [
1758
- at(t.occurredAt, !0),
1759
- S && /* @__PURE__ */ n(ie, { children: [
1877
+ ] }), R = /* @__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: [
1878
+ ft(t.occurredAt, !0),
1879
+ C && /* @__PURE__ */ n(ne, { children: [
1760
1880
  " ",
1761
- /* @__PURE__ */ e(bt, { status: t.status })
1881
+ /* @__PURE__ */ e(Wt, { status: t.status })
1762
1882
  ] })
1763
- ] }) }), L = S ? { ...f.bubbleOut, background: i, color: "#fff", border: "1px solid transparent" } : f.bubbleIn, P = !t.text && v.length === 0 && W.length === 0;
1764
- return /* @__PURE__ */ n("div", { style: { ...f.messageLine, justifyContent: $, flexDirection: "column", alignItems: $ }, children: [
1765
- M.map((b, E) => /* @__PURE__ */ n("div", { style: { position: "relative", marginBottom: 2 }, children: [
1766
- /* @__PURE__ */ e("img", { src: h(b.url), alt: "sticker", style: { display: "block", maxWidth: 128, maxHeight: 128, objectFit: "contain" } }),
1767
- P && m.length === 0 && w.length === 0 && E === M.length - 1 && I
1768
- ] }, `s${E}`)),
1769
- m.map((b, E) => /* @__PURE__ */ n("div", { style: { position: "relative", marginBottom: 2, cursor: "zoom-in" }, onClick: () => A({ url: h(b.url), kind: "image" }), children: [
1770
- /* @__PURE__ */ e("img", { src: h(b.url), alt: "", style: { display: "block", maxWidth: 260, maxHeight: 260, borderRadius: 12, objectFit: "cover" } }),
1771
- P && E === m.length - 1 && w.length === 0 && I
1772
- ] }, E)),
1773
- w.map((b, E) => /* @__PURE__ */ n("div", { style: { position: "relative", marginBottom: 2, cursor: "pointer" }, onClick: () => A({ url: h(b.url), kind: "video" }), children: [
1774
- /* @__PURE__ */ e("video", { src: h(b.url), style: { display: "block", maxWidth: 260, maxHeight: 200, borderRadius: 12, objectFit: "cover" } }),
1775
- /* @__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(Nt, { size: 16, fill: "#172033", color: "#172033", style: { marginLeft: 2 } }) }) }),
1776
- P && E === w.length - 1 && I
1777
- ] }, E)),
1778
- (v.length > 0 || W.length > 0 || t.text || !m.length && !w.length && !M.length && !t.text) && /* @__PURE__ */ n("div", { style: L, children: [
1779
- v.map((b, E) => /* @__PURE__ */ e("audio", { src: h(b.url), controls: !0, style: { display: "block", width: "100%", marginBottom: 4 } }, E)),
1780
- W.map((b, E) => /* @__PURE__ */ n("a", { href: h(b.url), target: "_blank", rel: "noreferrer", style: { display: "block", fontSize: 12, color: S ? "#fff" : "#2563eb", textDecoration: "underline", marginBottom: 4 }, children: [
1883
+ ] }) }), H = C ? { ...x.bubbleOut, background: i, color: "#fff", border: "1px solid transparent" } : x.bubbleIn, J = !t.text && g.length === 0 && $.length === 0;
1884
+ return /* @__PURE__ */ n("div", { style: { ...x.messageLine, justifyContent: M, flexDirection: "column", alignItems: M }, children: [
1885
+ L.map((S, D) => /* @__PURE__ */ n("div", { style: { position: "relative", marginBottom: 2 }, children: [
1886
+ /* @__PURE__ */ e("img", { src: c(S.url), alt: "sticker", style: { display: "block", maxWidth: 128, maxHeight: 128, objectFit: "contain" } }),
1887
+ J && y.length === 0 && w.length === 0 && D === L.length - 1 && R
1888
+ ] }, `s${D}`)),
1889
+ y.map((S, D) => /* @__PURE__ */ n("div", { style: { position: "relative", marginBottom: 2, cursor: "zoom-in" }, onClick: () => E({ url: c(S.url), kind: "image" }), children: [
1890
+ /* @__PURE__ */ e("img", { src: c(S.url), alt: "", style: { display: "block", maxWidth: 260, maxHeight: 260, borderRadius: 12, objectFit: "cover" } }),
1891
+ J && D === y.length - 1 && w.length === 0 && R
1892
+ ] }, D)),
1893
+ w.map((S, D) => /* @__PURE__ */ n("div", { style: { position: "relative", marginBottom: 2, cursor: "pointer" }, onClick: () => E({ url: c(S.url), kind: "video" }), children: [
1894
+ /* @__PURE__ */ e("video", { src: c(S.url), style: { display: "block", maxWidth: 260, maxHeight: 200, borderRadius: 12, objectFit: "cover" } }),
1895
+ /* @__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(tn, { size: 16, fill: "#172033", color: "#172033", style: { marginLeft: 2 } }) }) }),
1896
+ J && D === w.length - 1 && R
1897
+ ] }, D)),
1898
+ (g.length > 0 || $.length > 0 || t.text || !y.length && !w.length && !L.length && !t.text) && /* @__PURE__ */ n("div", { style: H, children: [
1899
+ g.map((S, D) => /* @__PURE__ */ e("audio", { src: c(S.url), controls: !0, style: { display: "block", width: "100%", marginBottom: 4 } }, D)),
1900
+ $.map((S, D) => /* @__PURE__ */ n("a", { href: c(S.url), target: "_blank", rel: "noreferrer", style: { display: "block", fontSize: 12, color: C ? "#fff" : "#2563eb", textDecoration: "underline", marginBottom: 4 }, children: [
1781
1901
  "📎 ",
1782
- tn(b.mimeType)
1783
- ] }, E)),
1902
+ gn(S.mimeType)
1903
+ ] }, D)),
1784
1904
  t.text && /* @__PURE__ */ e("p", { style: { margin: 0, whiteSpace: "pre-wrap", wordBreak: "break-word" }, children: t.text }),
1785
- !v.length && !W.length && !t.text && /* @__PURE__ */ e("p", { style: { margin: 0, opacity: 0.5 }, children: "[attachment]" }),
1786
- D
1905
+ !g.length && !$.length && !t.text && /* @__PURE__ */ e("p", { style: { margin: 0, opacity: 0.5 }, children: "[attachment]" }),
1906
+ q
1787
1907
  ] }),
1788
- T && St(
1789
- /* @__PURE__ */ n("div", { onClick: () => A(null), style: { position: "fixed", inset: 0, zIndex: 1e4, background: "rgba(0,0,0,.88)", display: "flex", alignItems: "center", justifyContent: "center", cursor: "zoom-out" }, children: [
1790
- T.kind === "image" ? /* @__PURE__ */ e("img", { src: T.url, alt: "", style: { maxWidth: "90vw", maxHeight: "90vh", borderRadius: 8, objectFit: "contain", boxShadow: "0 8px 40px rgba(0,0,0,.5)" }, onClick: (b) => b.stopPropagation() }) : /* @__PURE__ */ e("video", { src: T.url, controls: !0, autoPlay: !0, style: { maxWidth: "90vw", maxHeight: "90vh", borderRadius: 8, boxShadow: "0 8px 40px rgba(0,0,0,.5)" }, onClick: (b) => b.stopPropagation() }),
1791
- /* @__PURE__ */ e("button", { onClick: () => A(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(Oe, { size: 18 }) })
1908
+ T && At(
1909
+ /* @__PURE__ */ n("div", { onClick: () => E(null), style: { position: "fixed", inset: 0, zIndex: 1e4, background: "rgba(0,0,0,.88)", display: "flex", alignItems: "center", justifyContent: "center", cursor: "zoom-out" }, children: [
1910
+ T.kind === "image" ? /* @__PURE__ */ e("img", { src: T.url, alt: "", style: { maxWidth: "90vw", maxHeight: "90vh", borderRadius: 8, objectFit: "contain", boxShadow: "0 8px 40px rgba(0,0,0,.5)" }, onClick: (S) => S.stopPropagation() }) : /* @__PURE__ */ e("video", { src: T.url, controls: !0, autoPlay: !0, style: { maxWidth: "90vw", maxHeight: "90vh", borderRadius: 8, boxShadow: "0 8px 40px rgba(0,0,0,.5)" }, onClick: (S) => S.stopPropagation() }),
1911
+ /* @__PURE__ */ e("button", { onClick: () => E(null), style: { position: "absolute", top: 16, right: 16, background: "rgba(255,255,255,.15)", border: "none", borderRadius: "50%", width: 36, height: 36, cursor: "pointer", display: "flex", alignItems: "center", justifyContent: "center", color: "#fff" }, children: /* @__PURE__ */ e(Ve, { size: 18 }) })
1792
1912
  ] }),
1793
1913
  document.body
1794
1914
  )
1795
1915
  ] });
1796
1916
  }
1797
- function an({
1917
+ function Tt({
1798
1918
  conversation: t,
1799
1919
  connection: i,
1800
- primary: r,
1801
- onClose: o,
1802
- client: h,
1803
- onStartResize: S,
1804
- extensions: m,
1805
- extRefreshKey: M,
1920
+ primary: o,
1921
+ onClose: r,
1922
+ client: c,
1923
+ onStartResize: C,
1924
+ extensions: y,
1925
+ extRefreshKey: L,
1806
1926
  onLinkContact: w,
1807
- onRefreshContactInfo: v
1927
+ onRefreshContactInfo: g,
1928
+ layoutMode: $ = "desktop"
1808
1929
  }) {
1809
- const W = t.contactName ?? t.subject ?? t.providerConversationKey, T = i == null ? void 0 : i.provider, A = !!(m != null && m.some((z) => z.contactInfoRows)), [$, C] = y({ channel: !0, stats: !1, extra: !0 }), D = (z) => C((oe) => ({ ...oe, [z]: !oe[z] })), [I, L] = y(""), [P, q] = y(!1), [te, Q] = y(!1), [B, x] = y(""), [b, E] = y([]), [V, ne] = y(!1);
1810
- X(() => {
1811
- L(""), Q(!1), x(""), h.getNote(t.id).then((z) => {
1812
- z && L(z.content);
1930
+ const T = t.contactName ?? t.subject ?? t.providerConversationKey, E = i == null ? void 0 : i.provider, M = !!(y != null && y.some((k) => k.contactInfoRows)), [I, q] = u({ channel: !0, stats: !1, extra: !0 }), R = (k) => q((ie) => ({ ...ie, [k]: !ie[k] })), [H, J] = u(""), [F, re] = u(""), [V, B] = u(!1), [b, S] = u(!1), [D, j] = u(""), [Z, pe] = u([]), [ve, fe] = u(!1);
1931
+ K(() => {
1932
+ J(""), re(""), S(!1), j(""), c.getNote(t.id).then((k) => {
1933
+ k && (J(k.content), re(k.content));
1813
1934
  }).catch(() => {
1814
1935
  });
1815
- }, [t.id, h]), X(() => {
1816
- if (!A || !m) return;
1817
- let z = !1;
1818
- const oe = Je(t, {
1819
- provider: T,
1936
+ }, [t.id, c]), K(() => {
1937
+ if (!M || !y) return;
1938
+ let k = !1;
1939
+ const ie = ot(t, {
1940
+ provider: E,
1820
1941
  linkContact: w,
1821
- refreshContactInfo: v,
1822
- sendMessage: async (Z, U) => {
1823
- await h.sendMessage(t.id, Z, U);
1942
+ refreshContactInfo: g,
1943
+ sendMessage: async (h, A) => {
1944
+ await c.sendMessage(t.id, h, A);
1824
1945
  }
1825
1946
  });
1826
- return ne(!0), Promise.allSettled(
1827
- m.filter((Z) => Z.contactInfoRows).map((Z) => Z.contactInfoRows(oe))
1828
- ).then((Z) => {
1829
- if (z) return;
1830
- const U = Z.filter((ee) => ee.status === "fulfilled").flatMap((ee) => ee.value);
1831
- E(U), ne(!1);
1947
+ return fe(!0), Promise.allSettled(
1948
+ y.filter((h) => h.contactInfoRows).map((h) => h.contactInfoRows(ie))
1949
+ ).then((h) => {
1950
+ if (k) return;
1951
+ const A = h.filter((U) => U.status === "fulfilled").flatMap((U) => U.value);
1952
+ pe(A), fe(!1);
1832
1953
  }), () => {
1833
- z = !0;
1954
+ k = !0;
1834
1955
  };
1835
- }, [t.id, t.contactExternalId, m, M, A, T, w, v, h]);
1836
- async function de() {
1837
- if (!(!I.trim() || P)) {
1838
- q(!0), x("");
1956
+ }, [t.id, t.contactExternalId, y, L, M, E, w, g, c]);
1957
+ const se = H.trim() !== F.trim() && H.trim().length > 0;
1958
+ async function G() {
1959
+ if (!(!se || V)) {
1960
+ B(!0), j("");
1839
1961
  try {
1840
- await h.upsertNote(t.id, I.trim()), Q(!0), setTimeout(() => Q(!1), 2e3);
1962
+ const k = H.trim();
1963
+ await c.upsertNote(t.id, k), re(k), S(!0), setTimeout(() => S(!1), 2e3);
1841
1964
  } catch {
1842
- x("Lưu thất bại");
1965
+ j("Lưu thất bại");
1843
1966
  } finally {
1844
- q(!1);
1967
+ B(!1);
1845
1968
  }
1846
1969
  }
1847
1970
  }
1848
- return /* @__PURE__ */ n("aside", { style: { ...f.infoPanel, position: "relative" }, children: [
1849
- /* @__PURE__ */ e(
1971
+ return /* @__PURE__ */ n("aside", { style: { ...x.infoPanel, position: "relative", ...$ !== "desktop" ? { flex: 1, borderLeft: 0 } : {} }, children: [
1972
+ C && /* @__PURE__ */ e(
1850
1973
  "div",
1851
1974
  {
1852
- onMouseDown: S,
1975
+ onMouseDown: C,
1853
1976
  style: { position: "absolute", left: 0, top: 0, bottom: 0, width: 4, cursor: "col-resize", zIndex: 1 },
1854
- onMouseEnter: (z) => {
1855
- z.currentTarget.style.background = "rgba(0,0,0,0.07)";
1977
+ onMouseEnter: (k) => {
1978
+ k.currentTarget.style.background = "rgba(0,0,0,0.07)";
1856
1979
  },
1857
- onMouseLeave: (z) => {
1858
- z.currentTarget.style.background = "";
1980
+ onMouseLeave: (k) => {
1981
+ k.currentTarget.style.background = "";
1859
1982
  }
1860
1983
  }
1861
1984
  ),
1862
- /* @__PURE__ */ n("div", { style: f.infoPanelHeader, children: [
1863
- /* @__PURE__ */ e("span", { style: { fontWeight: 600, fontSize: 13, color: d.ink }, children: "Thông tin liên hệ" }),
1864
- /* @__PURE__ */ e("button", { style: f.iconButton, onClick: o, "aria-label": "Đóng", children: /* @__PURE__ */ e(Oe, { size: 16, strokeWidth: 2 }) })
1985
+ /* @__PURE__ */ n("div", { style: x.infoPanelHeader, children: [
1986
+ /* @__PURE__ */ e("span", { style: { fontWeight: 600, fontSize: 13, color: a.ink }, children: "Thông tin liên hệ" }),
1987
+ /* @__PURE__ */ e("button", { style: x.iconButton, onClick: r, "aria-label": "Đóng", children: /* @__PURE__ */ e(Ve, { size: 16, strokeWidth: 2 }) })
1865
1988
  ] }),
1866
1989
  /* @__PURE__ */ n("div", { style: { overflowY: "auto", flex: 1 }, children: [
1867
- /* @__PURE__ */ n("div", { style: f.infoPanelIdentity, children: [
1868
- /* @__PURE__ */ n("span", { style: { ...f.avatarWrap, width: 48, height: 48 }, children: [
1990
+ /* @__PURE__ */ n("div", { style: x.infoPanelIdentity, children: [
1991
+ /* @__PURE__ */ n("span", { style: { ...x.avatarWrap, width: 48, height: 48 }, children: [
1869
1992
  /* @__PURE__ */ e(
1870
- dt,
1993
+ bt,
1871
1994
  {
1872
1995
  src: t.contactPictureUrl,
1873
- fallback: Le(W),
1874
- style: { ...f.avatar, width: 48, height: 48, fontSize: 16 }
1996
+ fallback: je(T),
1997
+ style: { ...x.avatar, width: 48, height: 48, fontSize: 16 }
1875
1998
  }
1876
1999
  ),
1877
- /* @__PURE__ */ e("span", { style: { ...f.providerBadge, width: 20, height: 20 }, children: /* @__PURE__ */ e(De, { provider: T }) })
2000
+ /* @__PURE__ */ e("span", { style: { ...x.providerBadge, width: 20, height: 20 }, children: /* @__PURE__ */ e(Ge, { provider: E }) })
1878
2001
  ] }),
1879
- /* @__PURE__ */ e("strong", { style: { marginTop: 10, fontSize: 15, color: d.ink, textAlign: "center" }, children: W }),
1880
- /* @__PURE__ */ e("span", { style: { fontSize: 11, color: d.muted, fontFamily: "monospace", textAlign: "center" }, children: t.providerConversationKey })
2002
+ /* @__PURE__ */ e("strong", { style: { marginTop: 10, fontSize: 15, color: a.ink, textAlign: "center" }, children: T }),
2003
+ /* @__PURE__ */ e("span", { style: { fontSize: 11, color: a.muted, fontFamily: "monospace", textAlign: "center" }, children: t.providerConversationKey })
1881
2004
  ] }),
1882
- /* @__PURE__ */ n(_e, { label: "KÊNH", sectionKey: "channel", expanded: $.channel, onToggle: () => D("channel"), children: [
1883
- /* @__PURE__ */ e(ge, { label: "Nền tảng", children: /* @__PURE__ */ n("span", { style: { display: "flex", alignItems: "center", gap: 5 }, children: [
1884
- /* @__PURE__ */ e(De, { provider: T }),
1885
- /* @__PURE__ */ e("span", { children: Wt(T) })
2005
+ /* @__PURE__ */ n(at, { label: "KÊNH", sectionKey: "channel", expanded: I.channel, onToggle: () => R("channel"), children: [
2006
+ /* @__PURE__ */ e(be, { label: "Nền tảng", children: /* @__PURE__ */ n("span", { style: { display: "flex", alignItems: "center", gap: 5 }, children: [
2007
+ /* @__PURE__ */ e(Ge, { provider: E }),
2008
+ /* @__PURE__ */ e("span", { children: Nt(E) })
1886
2009
  ] }) }),
1887
- /* @__PURE__ */ n(ge, { label: "ID hội thoại", children: [
2010
+ /* @__PURE__ */ n(be, { label: "ID hội thoại", children: [
1888
2011
  /* @__PURE__ */ n("span", { style: { fontFamily: "monospace", fontSize: 11 }, children: [
1889
2012
  t.id.slice(0, 8),
1890
2013
  "…"
1891
2014
  ] }),
1892
- /* @__PURE__ */ e(ln, { value: t.id })
2015
+ /* @__PURE__ */ e(xn, { value: t.id })
1893
2016
  ] })
1894
2017
  ] }),
1895
- /* @__PURE__ */ n(_e, { label: "THỐNG KÊ", sectionKey: "stats", expanded: $.stats, onToggle: () => D("stats"), children: [
1896
- /* @__PURE__ */ e(ge, { label: "Tin nhắn", value: String(t.messageCount ?? 0) }),
1897
- (t.unreadCount ?? 0) > 0 && /* @__PURE__ */ e(ge, { label: "Chưa đọc", value: String(t.unreadCount), valueColor: "#ef4444" }),
2018
+ /* @__PURE__ */ n(at, { label: "THỐNG KÊ", sectionKey: "stats", expanded: I.stats, onToggle: () => R("stats"), children: [
2019
+ /* @__PURE__ */ e(be, { label: "Tin nhắn", value: String(t.messageCount ?? 0) }),
2020
+ (t.unreadCount ?? 0) > 0 && /* @__PURE__ */ e(be, { label: "Chưa đọc", value: String(t.unreadCount), valueColor: "#ef4444" }),
1898
2021
  /* @__PURE__ */ e(
1899
- ge,
2022
+ be,
1900
2023
  {
1901
2024
  label: "Gần nhất",
1902
2025
  value: t.lastMessageAt ? new Date(t.lastMessageAt).toLocaleDateString("vi-VN", { day: "2-digit", month: "2-digit", year: "numeric" }) : "—"
1903
2026
  }
1904
2027
  ),
1905
- /* @__PURE__ */ e(ge, { label: "Lần đầu", value: "—" })
2028
+ /* @__PURE__ */ e(be, { label: "Lần đầu", value: "—" })
1906
2029
  ] }),
1907
- /* @__PURE__ */ n(_e, { label: "THÔNG TIN BỔ SUNG", sectionKey: "extra", expanded: $.extra, onToggle: () => D("extra"), children: [
1908
- !A && /* @__PURE__ */ n(ie, { children: [
1909
- /* @__PURE__ */ e(ge, { label: "Điện thoại", value: "— chưa có", valueMuted: !0 }),
1910
- /* @__PURE__ */ e(ge, { label: "Email", value: "— chưa có", valueMuted: !0 }),
1911
- /* @__PURE__ */ e(ge, { label: "Nhãn", value: "— chưa có", valueMuted: !0 })
2030
+ /* @__PURE__ */ n(at, { label: "THÔNG TIN BỔ SUNG", sectionKey: "extra", expanded: I.extra, onToggle: () => R("extra"), children: [
2031
+ !M && /* @__PURE__ */ n(ne, { children: [
2032
+ /* @__PURE__ */ e(be, { label: "Điện thoại", value: "— chưa có", valueMuted: !0 }),
2033
+ /* @__PURE__ */ e(be, { label: "Email", value: "— chưa có", valueMuted: !0 }),
2034
+ /* @__PURE__ */ e(be, { label: "Nhãn", value: "— chưa có", valueMuted: !0 })
1912
2035
  ] }),
1913
- V && b.length === 0 && /* @__PURE__ */ e("div", { style: { fontSize: 12, color: d.muted, padding: "6px 0" }, children: "Đang tải hồ sơ CRM…" }),
1914
- b.map((z) => /* @__PURE__ */ e(ge, { label: z.label, children: /* @__PURE__ */ n("span", { style: { display: "inline-flex", alignItems: "center", gap: 6, flexWrap: "wrap", justifyContent: "flex-end" }, children: [
1915
- z.onClick ? /* @__PURE__ */ e(
2036
+ ve && Z.length === 0 && /* @__PURE__ */ e("div", { style: { fontSize: 12, color: a.muted, padding: "6px 0" }, children: "Đang tải hồ sơ CRM…" }),
2037
+ Z.map((k) => /* @__PURE__ */ e(be, { label: k.label, children: /* @__PURE__ */ n("span", { style: { display: "inline-flex", alignItems: "center", gap: 6, flexWrap: "wrap", justifyContent: "flex-end" }, children: [
2038
+ k.onClick ? /* @__PURE__ */ e(
1916
2039
  "button",
1917
2040
  {
1918
2041
  type: "button",
1919
- onClick: z.onClick,
1920
- style: { border: 0, background: "none", padding: 0, color: r, fontSize: 12, fontWeight: 600, cursor: "pointer", textDecoration: "underline" },
1921
- children: z.value
2042
+ onClick: k.onClick,
2043
+ style: { border: 0, background: "none", padding: 0, color: o, fontSize: 12, fontWeight: 600, cursor: "pointer", textDecoration: "underline" },
2044
+ children: k.value
1922
2045
  }
1923
- ) : z.href ? /* @__PURE__ */ e("a", { href: z.href, target: "_blank", rel: "noopener noreferrer", style: { color: r, fontSize: 12, fontWeight: 600 }, children: z.value }) : /* @__PURE__ */ e("span", { style: { fontSize: 12, fontWeight: 500, color: d.ink }, children: z.value }),
1924
- z.badge && /* @__PURE__ */ e(
2046
+ ) : k.href ? /* @__PURE__ */ e("a", { href: k.href, target: "_blank", rel: "noopener noreferrer", style: { color: o, fontSize: 12, fontWeight: 600 }, children: k.value }) : /* @__PURE__ */ e("span", { style: { fontSize: 12, fontWeight: 500, color: a.ink }, children: k.value }),
2047
+ k.badge && /* @__PURE__ */ e(
1925
2048
  "span",
1926
2049
  {
1927
2050
  style: {
@@ -1929,78 +2052,87 @@ function an({
1929
2052
  fontWeight: 700,
1930
2053
  padding: "1px 7px",
1931
2054
  borderRadius: 999,
1932
- color: z.badge.color ?? r,
1933
- background: z.badge.bg ?? `${r}14`
2055
+ color: k.badge.color ?? o,
2056
+ background: k.badge.bg ?? `${o}14`
1934
2057
  },
1935
- children: z.badge.text
2058
+ children: k.badge.text
1936
2059
  }
1937
2060
  )
1938
- ] }) }, z.label))
2061
+ ] }) }, k.label))
1939
2062
  ] }),
1940
2063
  /* @__PURE__ */ n("div", { style: { padding: "12px 16px", display: "flex", flexDirection: "column", gap: 8 }, children: [
1941
- !(m != null && m.length) && /* @__PURE__ */ e("button", { style: { ...f.ghostButton, color: r, borderColor: `${r}33` }, children: "Xem lịch sử" }),
1942
- m == null ? void 0 : m.flatMap((z) => z.sidebarActions ?? []).map((z, oe) => {
1943
- const Z = z.variant === "primary";
2064
+ !(y != null && y.length) && /* @__PURE__ */ e("button", { style: { ...x.ghostButton, color: o, borderColor: `${o}33` }, children: "Xem lịch sử" }),
2065
+ y == null ? void 0 : y.flatMap((k) => k.sidebarActions ?? []).map((k, ie) => {
2066
+ const h = k.variant === "primary";
1944
2067
  return /* @__PURE__ */ n(
1945
2068
  "button",
1946
2069
  {
1947
2070
  style: {
1948
- ...f.ghostButton,
1949
- background: Z ? r : "#fff",
1950
- color: Z ? "#fff" : d.ink,
1951
- borderColor: Z ? r : d.line,
1952
- fontWeight: Z ? 700 : 600,
2071
+ ...x.ghostButton,
2072
+ background: h ? o : "#fff",
2073
+ color: h ? "#fff" : a.ink,
2074
+ borderColor: h ? o : a.line,
2075
+ fontWeight: h ? 700 : 600,
1953
2076
  display: "flex",
1954
2077
  alignItems: "center",
1955
2078
  justifyContent: "center",
1956
2079
  gap: 6
1957
2080
  },
1958
2081
  onClick: () => {
1959
- const U = Je(t, {
1960
- provider: T,
2082
+ const A = ot(t, {
2083
+ provider: E,
1961
2084
  linkContact: w,
1962
- refreshContactInfo: v,
1963
- sendMessage: async (ee, se) => {
1964
- await h.sendMessage(t.id, ee, se);
2085
+ refreshContactInfo: g,
2086
+ sendMessage: async (U, z) => {
2087
+ await c.sendMessage(t.id, U, z);
1965
2088
  }
1966
2089
  });
1967
- z.onClick(U);
2090
+ k.onClick(A);
1968
2091
  },
1969
2092
  children: [
1970
- z.icon,
1971
- z.label
2093
+ k.icon,
2094
+ k.label
1972
2095
  ]
1973
2096
  },
1974
- oe
2097
+ ie
1975
2098
  );
1976
2099
  }),
1977
- /* @__PURE__ */ n("div", { style: { border: `1px solid ${d.line}`, borderRadius: 10, background: "#fff", overflow: "hidden" }, children: [
1978
- /* @__PURE__ */ e("div", { style: { display: "flex", alignItems: "center", gap: 6, padding: "7px 10px", borderBottom: "1px solid #fde68a", background: "#fffbeb", fontSize: 11, fontWeight: 600, color: "#92400e" }, children: "Ghi chú nội bộ" }),
2100
+ /* @__PURE__ */ n("div", { style: { border: `1px solid ${a.line}`, borderRadius: 10, background: a.white, overflow: "hidden" }, children: [
2101
+ /* @__PURE__ */ e("div", { style: { display: "flex", alignItems: "center", gap: 6, padding: "7px 10px", borderBottom: `1px solid ${a.line}`, background: a.surface, fontSize: 11, fontWeight: 600, color: a.muted }, children: "Ghi chú nội bộ" }),
1979
2102
  /* @__PURE__ */ e(
1980
2103
  "textarea",
1981
2104
  {
1982
- value: I,
1983
- onChange: (z) => L(z.target.value),
2105
+ value: H,
2106
+ onChange: (k) => J(k.target.value),
1984
2107
  placeholder: "Nhập ghi chú...",
1985
2108
  rows: 3,
1986
- 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 }
2109
+ style: { display: "block", width: "100%", boxSizing: "border-box", border: 0, outline: 0, background: a.white, resize: "none", padding: "8px 10px", font: "inherit", fontSize: $ === "mobile" ? 16 : 12, color: a.ink, lineHeight: 1.5 }
1987
2110
  }
1988
2111
  ),
1989
2112
  /* @__PURE__ */ n("div", { style: { display: "flex", alignItems: "center", justifyContent: "space-between", padding: "4px 10px 6px" }, children: [
1990
- te ? /* @__PURE__ */ n("span", { style: { display: "flex", alignItems: "center", gap: 4, fontSize: 11, color: "#16a34a" }, children: [
1991
- /* @__PURE__ */ e(lt, { size: 11, strokeWidth: 2.5 }),
2113
+ b ? /* @__PURE__ */ n("span", { style: { display: "flex", alignItems: "center", gap: 4, fontSize: 11, color: "#16a34a" }, children: [
2114
+ /* @__PURE__ */ e(gt, { size: 11, strokeWidth: 2.5 }),
1992
2115
  " Đã lưu"
1993
- ] }) : B ? /* @__PURE__ */ e("span", { style: { fontSize: 11, color: "#ef4444" }, children: B }) : /* @__PURE__ */ e("span", {}),
2116
+ ] }) : D ? /* @__PURE__ */ e("span", { style: { fontSize: 11, color: "#ef4444" }, children: D }) : /* @__PURE__ */ e("span", {}),
1994
2117
  /* @__PURE__ */ e(
1995
2118
  "button",
1996
2119
  {
1997
2120
  type: "button",
1998
2121
  onClick: () => {
1999
- de();
2122
+ G();
2000
2123
  },
2001
- disabled: !I.trim() || P,
2002
- style: { padding: "4px 12px", border: 0, borderRadius: 7, fontSize: 12, fontWeight: 600, background: I.trim() && !P ? "linear-gradient(135deg,#f59e0b,#fbbf24)" : "#e5e7eb", color: I.trim() && !P ? "#fff" : "#9ca3af", cursor: I.trim() && !P ? "pointer" : "not-allowed" },
2003
- children: P ? "Đang lưu…" : "Lưu ghi chú"
2124
+ disabled: !se || V,
2125
+ style: {
2126
+ padding: "4px 12px",
2127
+ border: 0,
2128
+ borderRadius: 7,
2129
+ fontSize: 12,
2130
+ fontWeight: 600,
2131
+ background: se && !V ? o : "#f1f5f9",
2132
+ color: se && !V ? "#fff" : "#94a3b8",
2133
+ cursor: se && !V ? "pointer" : "not-allowed"
2134
+ },
2135
+ children: V ? "Đang lưu…" : "Lưu ghi chú"
2004
2136
  }
2005
2137
  )
2006
2138
  ] })
@@ -2009,39 +2141,39 @@ function an({
2009
2141
  ] })
2010
2142
  ] });
2011
2143
  }
2012
- function _e({ label: t, children: i, sectionKey: r, expanded: o, onToggle: h }) {
2013
- const S = !!h, m = o ?? !0;
2014
- return /* @__PURE__ */ n("div", { style: { borderTop: `1px solid ${d.line}` }, children: [
2144
+ function at({ label: t, children: i, sectionKey: o, expanded: r, onToggle: c }) {
2145
+ const C = !!c, y = r ?? !0;
2146
+ return /* @__PURE__ */ n("div", { style: { borderTop: `1px solid ${a.line}` }, children: [
2015
2147
  /* @__PURE__ */ n(
2016
2148
  "div",
2017
2149
  {
2018
- style: { display: "flex", alignItems: "center", justifyContent: "space-between", padding: "10px 16px 6px", fontSize: 10, fontWeight: 700, letterSpacing: 1, color: d.muted, textTransform: "uppercase", cursor: S ? "pointer" : "default" },
2019
- onClick: h,
2150
+ style: { display: "flex", alignItems: "center", justifyContent: "space-between", padding: "10px 16px 6px", fontSize: 10, fontWeight: 700, letterSpacing: 1, color: a.muted, textTransform: "uppercase", cursor: C ? "pointer" : "default" },
2151
+ onClick: c,
2020
2152
  children: [
2021
2153
  /* @__PURE__ */ e("span", { children: t }),
2022
- S && (m ? /* @__PURE__ */ e(nt, { size: 12, strokeWidth: 2 }) : /* @__PURE__ */ e(At, { size: 12, strokeWidth: 2 }))
2154
+ C && (y ? /* @__PURE__ */ e(ct, { size: 12, strokeWidth: 2 }) : /* @__PURE__ */ e(Yt, { size: 12, strokeWidth: 2 }))
2023
2155
  ]
2024
2156
  }
2025
2157
  ),
2026
- m && i
2158
+ y && i
2027
2159
  ] });
2028
2160
  }
2029
- function ge({ label: t, value: i, children: r, valueColor: o, valueMuted: h }) {
2161
+ function be({ label: t, value: i, children: o, valueColor: r, valueMuted: c }) {
2030
2162
  return /* @__PURE__ */ n("div", { style: { display: "flex", justifyContent: "space-between", alignItems: "flex-start", padding: "5px 16px", fontSize: 12, gap: 10 }, children: [
2031
- /* @__PURE__ */ e("span", { style: { color: d.muted, flexShrink: 0, lineHeight: 1.4 }, children: t }),
2032
- /* @__PURE__ */ e("span", { style: { color: o ?? (h ? d.muted : d.ink), textAlign: "right", minWidth: 0, display: "flex", alignItems: "center", justifyContent: "flex-end", flexWrap: "wrap", gap: 4, lineHeight: 1.4 }, children: r ?? i })
2163
+ /* @__PURE__ */ e("span", { style: { color: a.muted, flexShrink: 0, lineHeight: 1.4 }, children: t }),
2164
+ /* @__PURE__ */ e("span", { style: { color: r ?? (c ? a.muted : a.ink), textAlign: "right", minWidth: 0, display: "flex", alignItems: "center", justifyContent: "flex-end", flexWrap: "wrap", gap: 4, lineHeight: 1.4 }, children: o ?? i })
2033
2165
  ] });
2034
2166
  }
2035
- function ln({ value: t }) {
2036
- const [i, r] = y(!1);
2167
+ function xn({ value: t }) {
2168
+ const [i, o] = u(!1);
2037
2169
  return /* @__PURE__ */ e(
2038
2170
  "button",
2039
2171
  {
2040
- style: { border: 0, background: "none", cursor: "pointer", color: d.muted, padding: 2, lineHeight: 1 },
2172
+ style: { border: 0, background: "none", cursor: "pointer", color: a.muted, padding: 2, lineHeight: 1 },
2041
2173
  title: "Sao chép",
2042
2174
  onClick: () => {
2043
2175
  navigator.clipboard.writeText(t).then(() => {
2044
- r(!0), setTimeout(() => r(!1), 1500);
2176
+ o(!0), setTimeout(() => o(!1), 1500);
2045
2177
  });
2046
2178
  },
2047
2179
  "aria-label": "Sao chép ID",
@@ -2049,52 +2181,52 @@ function ln({ value: t }) {
2049
2181
  }
2050
2182
  );
2051
2183
  }
2052
- function dn() {
2053
- return /* @__PURE__ */ n("div", { style: f.empty, children: [
2054
- /* @__PURE__ */ e("div", { style: f.emptyHero, children: /* @__PURE__ */ e(Ot, { size: 16, strokeWidth: 2 }) }),
2184
+ function vn() {
2185
+ return /* @__PURE__ */ n("div", { style: x.empty, children: [
2186
+ /* @__PURE__ */ e("div", { style: x.emptyHero, children: /* @__PURE__ */ e(_t, { size: 16, strokeWidth: 2 }) }),
2055
2187
  /* @__PURE__ */ e("h2", { children: "Chọn một hội thoại" }),
2056
2188
  /* @__PURE__ */ e("p", { children: "Chọn hội thoại bên trái để xem và trả lời tin nhắn." })
2057
2189
  ] });
2058
2190
  }
2059
- function $t({ name: t, color: i, image: r, provider: o }) {
2060
- return /* @__PURE__ */ n("span", { style: f.avatarWrap, children: [
2061
- /* @__PURE__ */ e(sn, { name: t, color: i, image: r }),
2062
- o && /* @__PURE__ */ e("span", { style: f.providerBadge, children: /* @__PURE__ */ e(De, { provider: o }) })
2191
+ function Pt({ name: t, color: i, image: o, provider: r }) {
2192
+ return /* @__PURE__ */ n("span", { style: x.avatarWrap, children: [
2193
+ /* @__PURE__ */ e(kn, { name: t, color: i, image: o }),
2194
+ r && /* @__PURE__ */ e("span", { style: x.providerBadge, children: /* @__PURE__ */ e(Ge, { provider: r }) })
2063
2195
  ] });
2064
2196
  }
2065
- function sn({ name: t, color: i, image: r }) {
2066
- return /* @__PURE__ */ e(dt, { src: r, fallback: Le(t), style: { ...f.avatar, background: `${i}18`, color: i } });
2197
+ function kn({ name: t, color: i, image: o }) {
2198
+ return /* @__PURE__ */ e(bt, { src: o, fallback: je(t), style: { ...x.avatar, background: `${i}18`, color: i } });
2067
2199
  }
2068
- function ot() {
2069
- return /* @__PURE__ */ e(zt, { size: 14, style: f.spinner, "aria-hidden": "true" });
2200
+ function ut() {
2201
+ return /* @__PURE__ */ e(Ot, { size: 14, style: x.spinner, "aria-hidden": "true" });
2070
2202
  }
2071
- function Le(t) {
2203
+ function je(t) {
2072
2204
  return t.split(/\s+/).filter(Boolean).slice(-2).map((i) => i[0]).join("").toUpperCase() || "?";
2073
2205
  }
2074
- const cn = { livechat: "web" };
2075
- function De({ provider: t }) {
2076
- const i = tt(st), r = 14;
2206
+ const wn = { livechat: "web" };
2207
+ function Ge({ provider: t }) {
2208
+ const i = st(yt), o = 14;
2077
2209
  if (!t) return null;
2078
- const o = cn[t] ?? t;
2079
- return /* @__PURE__ */ e("img", { src: `${i}/static/logos/${o}.avif`, alt: t, width: r, height: r, style: { borderRadius: "50%", objectFit: "cover", display: "block" } });
2210
+ const r = wn[t] ?? t;
2211
+ return /* @__PURE__ */ e("img", { src: `${i}/static/logos/${r}.avif`, alt: t, width: o, height: o, style: { borderRadius: "50%", objectFit: "cover", display: "block" } });
2080
2212
  }
2081
- function at(t, i = !1) {
2213
+ function ft(t, i = !1) {
2082
2214
  if (!t) return "";
2083
- const r = new Date(t);
2084
- 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" });
2215
+ const o = new Date(t);
2216
+ return o.toDateString() === (/* @__PURE__ */ new Date()).toDateString() ? o.toLocaleTimeString("vi-VN", { hour: "2-digit", minute: "2-digit" }) : o.toLocaleDateString("vi-VN", { day: "2-digit", month: "2-digit" });
2085
2217
  }
2086
- const f = {
2087
- 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)" },
2088
- sidebar: { display: "flex", flexDirection: "column", minWidth: 0, minHeight: 0, borderRight: `1px solid ${d.line}`, background: d.white },
2218
+ const x = {
2219
+ frame: { display: "grid", gridTemplateRows: "minmax(0, 1fr)", height: 620, maxHeight: "calc(100dvh - 220px)", minHeight: 0, overflow: "hidden", border: `1px solid ${a.line}`, background: a.white, color: a.ink, boxShadow: "0 18px 50px rgba(31,45,72,.10)" },
2220
+ sidebar: { display: "flex", flexDirection: "column", minWidth: 0, minHeight: 0, borderRight: `1px solid ${a.line}`, background: a.white },
2089
2221
  brand: { display: "flex", alignItems: "center", gap: 10, padding: "20px 18px 16px" },
2090
2222
  brandMark: { display: "grid", placeItems: "center", width: 32, height: 32, borderRadius: 10, color: "#fff", fontWeight: 800 },
2091
- eyebrow: { display: "block", marginTop: 2, fontSize: 9, letterSpacing: 1.3, color: d.muted },
2092
- iconButton: { display: "inline-grid", placeItems: "center", width: 32, height: 32, marginLeft: "auto", border: 0, borderRadius: 8, background: "transparent", color: d.muted, cursor: "pointer" },
2093
- search: { display: "flex", alignItems: "center", gap: 8, margin: "0 14px 12px", padding: "9px 10px", border: `1px solid ${d.line}`, borderRadius: 9, color: d.muted, background: d.surface },
2094
- clear: { border: 0, background: "none", color: d.muted, cursor: "pointer", fontSize: 18 },
2095
- listHeader: { display: "flex", alignItems: "center", padding: "10px 18px", borderTop: `1px solid ${d.line}`, borderBottom: `1px solid ${d.line}`, color: d.muted, fontSize: 11, fontWeight: 700, letterSpacing: 0.4, textTransform: "uppercase" },
2223
+ eyebrow: { display: "block", marginTop: 2, fontSize: 9, letterSpacing: 1.3, color: a.muted },
2224
+ iconButton: { display: "inline-grid", placeItems: "center", width: 32, height: 32, marginLeft: "auto", border: 0, borderRadius: 8, background: "transparent", color: a.muted, cursor: "pointer" },
2225
+ search: { display: "flex", alignItems: "center", gap: 8, margin: "0 14px 12px", padding: "9px 10px", border: `1px solid ${a.line}`, borderRadius: 9, color: a.muted, background: a.surface },
2226
+ clear: { border: 0, background: "none", color: a.muted, cursor: "pointer", fontSize: 18 },
2227
+ listHeader: { display: "flex", alignItems: "center", padding: "10px 18px", borderTop: `1px solid ${a.line}`, borderBottom: `1px solid ${a.line}`, color: a.muted, fontSize: 11, fontWeight: 700, letterSpacing: 0.4, textTransform: "uppercase" },
2096
2228
  conversationList: { overflowY: "auto", flex: 1, minHeight: 0 },
2097
- row: { display: "flex", width: "100%", gap: 11, padding: "16px 14px", border: 0, borderBottom: `1px solid ${d.line}`, background: "transparent", textAlign: "left", cursor: "pointer", transition: "background 120ms ease" },
2229
+ row: { display: "flex", width: "100%", gap: 11, padding: "16px 14px", border: 0, borderBottom: `1px solid ${a.line}`, background: "transparent", textAlign: "left", cursor: "pointer", transition: "background 120ms ease" },
2098
2230
  avatarWrap: { position: "relative", flex: "0 0 auto", width: 44, height: 44 },
2099
2231
  avatar: { flex: "0 0 auto", width: 44, height: 44, display: "grid", placeItems: "center", borderRadius: "50%", objectFit: "cover", fontSize: 14, fontWeight: 800 },
2100
2232
  providerBadge: { position: "absolute", left: -3, bottom: -3, display: "grid", placeItems: "center", width: 17, height: 17, border: "2px solid #fff", borderRadius: "50%", background: "#fff", color: "#64748b" },
@@ -2103,41 +2235,41 @@ const f = {
2103
2235
  rowBottom: { display: "flex", marginTop: 4, fontSize: 12, minWidth: 0, overflow: "hidden", lineHeight: 1.4 },
2104
2236
  unreadBadge: { display: "inline-grid", placeItems: "center", minWidth: 18, height: 18, borderRadius: 999, background: "#ef4444", color: "#fff", fontSize: 10, fontWeight: 800, padding: "0 5px" },
2105
2237
  loadMore: { width: "100%", border: 0, background: "transparent", color: "#4c72ca", padding: 14, cursor: "pointer", fontSize: 12 },
2106
- emptySmall: { display: "grid", justifyItems: "center", gap: 7, padding: "56px 24px", color: d.muted, fontSize: 12, textAlign: "center" },
2107
- emptyIcon: { display: "grid", placeItems: "center", width: 40, height: 40, borderRadius: 12, background: d.surface },
2108
- main: { minWidth: 0, minHeight: 0, overflow: "hidden", background: d.surface },
2238
+ emptySmall: { display: "grid", justifyItems: "center", gap: 7, padding: "56px 24px", color: a.muted, fontSize: 12, textAlign: "center" },
2239
+ emptyIcon: { display: "grid", placeItems: "center", width: 40, height: 40, borderRadius: 12, background: a.surface },
2240
+ main: { minWidth: 0, minHeight: 0, overflow: "hidden", background: a.surface },
2109
2241
  chat: { display: "flex", flexDirection: "column", height: "100%", minWidth: 0, minHeight: 0 },
2110
- chatHeader: { flex: "0 0 auto", display: "flex", alignItems: "center", gap: 10, padding: "0 16px 0 18px", height: 56, borderBottom: `1px solid ${d.line}`, background: d.white },
2242
+ chatHeader: { flex: "0 0 auto", display: "flex", alignItems: "center", gap: 10, padding: "0 16px 0 18px", height: 56, borderBottom: `1px solid ${a.line}`, background: a.white },
2111
2243
  contact: { display: "grid", gap: 3, minWidth: 0, flex: 1 },
2112
- contactName: { fontSize: 14, fontWeight: 600, color: d.ink, whiteSpace: "nowrap", overflow: "hidden", textOverflow: "ellipsis" },
2113
- contactMeta: { display: "flex", alignItems: "center", gap: 5, fontSize: 11, color: d.muted },
2244
+ contactName: { fontSize: 14, fontWeight: 600, color: a.ink, whiteSpace: "nowrap", overflow: "hidden", textOverflow: "ellipsis" },
2245
+ contactMeta: { display: "flex", alignItems: "center", gap: 5, fontSize: 11, color: a.muted },
2114
2246
  headerActions: { display: "flex", gap: 2, marginLeft: "auto" },
2115
2247
  messageArea: { flex: 1, minHeight: 0, overflowY: "auto", overscrollBehavior: "contain", padding: "20px clamp(16px,5vw,56px)", background: "linear-gradient(180deg,#f9fbfe 0%,#f4f7fb 100%)" },
2116
2248
  day: { margin: "0 auto 18px", color: "#a1acbb", fontSize: 10, letterSpacing: 1.2, fontWeight: 700, textAlign: "center" },
2117
- historyButton: { display: "block", margin: "0 auto 18px", border: `1px solid ${d.line}`, borderRadius: 20, padding: "6px 12px", background: d.white, color: d.muted, cursor: "pointer", fontSize: 11 },
2118
- messageHint: { display: "flex", justifyContent: "center", alignItems: "center", gap: 8, padding: 40, color: d.muted, fontSize: 12 },
2249
+ historyButton: { display: "block", margin: "0 auto 18px", border: `1px solid ${a.line}`, borderRadius: 20, padding: "6px 12px", background: a.white, color: a.muted, cursor: "pointer", fontSize: 11 },
2250
+ messageHint: { display: "flex", justifyContent: "center", alignItems: "center", gap: 8, padding: 40, color: a.muted, fontSize: 12 },
2119
2251
  messageLine: { display: "flex", marginBottom: 10 },
2120
2252
  bubbleOut: { maxWidth: "min(70%,480px)", padding: "9px 13px", borderRadius: "14px 14px 3px 14px", boxShadow: "0 2px 5px rgba(30,43,65,.03)", fontSize: 14, lineHeight: 1.55 },
2121
- bubbleIn: { maxWidth: "min(70%,480px)", padding: "9px 13px", borderRadius: "14px 14px 14px 3px", border: `1px solid ${d.line}`, background: d.surface, boxShadow: "0 2px 5px rgba(30,43,65,.03)", fontSize: 14, lineHeight: 1.55 },
2253
+ bubbleIn: { maxWidth: "min(70%,480px)", padding: "9px 13px", borderRadius: "14px 14px 14px 3px", border: `1px solid ${a.line}`, background: a.surface, boxShadow: "0 2px 5px rgba(30,43,65,.03)", fontSize: 14, lineHeight: 1.55 },
2122
2254
  error: { padding: "8px 18px", background: "#fff2f0", color: "#b42318", fontSize: 12 },
2123
- empty: { display: "grid", placeItems: "center", alignContent: "center", height: "100%", padding: 30, textAlign: "center", color: d.muted },
2255
+ empty: { display: "grid", placeItems: "center", alignContent: "center", height: "100%", padding: 30, textAlign: "center", color: a.muted },
2124
2256
  emptyHero: { display: "grid", placeItems: "center", width: 64, height: 64, marginBottom: 16, borderRadius: 20, background: "#eaf0ff", color: "#5277d7" },
2125
- state: { display: "flex", alignItems: "center", justifyContent: "center", gap: 10, minHeight: 180, border: `1px solid ${d.line}`, background: d.white, color: d.muted, fontSize: 13 },
2257
+ state: { display: "flex", alignItems: "center", justifyContent: "center", gap: 10, minHeight: 180, border: `1px solid ${a.line}`, background: a.white, color: a.muted, fontSize: 13 },
2126
2258
  retry: { border: 0, borderRadius: 7, padding: "7px 10px", background: "#eff4ff", color: "#315dbb", cursor: "pointer" },
2127
2259
  spinner: { display: "inline-block", width: 14, height: 14, border: "2px solid #dbe3f3", borderTopColor: "#5277d7", borderRadius: "50%", animation: "channelhub-spin .7s linear infinite" },
2128
2260
  toolbarBtn: { display: "inline-grid", placeItems: "center", width: 26, height: 26, border: "1px solid transparent", borderRadius: 6, background: "transparent", color: "#9ca3af", cursor: "pointer", padding: 0, lineHeight: 1 },
2129
- infoPanel: { display: "flex", flexDirection: "column", borderLeft: `1px solid ${d.line}`, background: d.white, minHeight: 0, overflow: "hidden" },
2130
- infoPanelHeader: { display: "flex", alignItems: "center", justifyContent: "space-between", padding: "16px 16px 12px", borderBottom: `1px solid ${d.line}`, flex: "0 0 auto" },
2261
+ infoPanel: { display: "flex", flexDirection: "column", borderLeft: `1px solid ${a.line}`, background: a.white, minHeight: 0, overflow: "hidden" },
2262
+ infoPanelHeader: { display: "flex", alignItems: "center", justifyContent: "space-between", padding: "16px 16px 12px", borderBottom: `1px solid ${a.line}`, flex: "0 0 auto" },
2131
2263
  infoPanelIdentity: { display: "flex", flexDirection: "column", alignItems: "center", padding: "20px 16px 16px", gap: 4 },
2132
- ghostButton: { width: "100%", padding: "8px 12px", border: `1px solid ${d.line}`, borderRadius: 8, background: "transparent", fontSize: 12, cursor: "pointer", textAlign: "center" }
2133
- }, hn = {
2264
+ ghostButton: { width: "100%", padding: "8px 12px", border: `1px solid ${a.line}`, borderRadius: 8, background: "transparent", fontSize: 12, cursor: "pointer", textAlign: "center" }
2265
+ }, Sn = {
2134
2266
  facebook: "#dbeafe",
2135
2267
  zalo: "#e0f2fe",
2136
2268
  instagram: "#fce7f3",
2137
2269
  telegram: "#cffafe",
2138
2270
  livechat: "#ede9fe",
2139
2271
  whatsapp: "#dcfce7"
2140
- }, pn = {
2272
+ }, Cn = {
2141
2273
  facebook: "facebook",
2142
2274
  instagram: "instagram",
2143
2275
  telegram: "telegram",
@@ -2145,43 +2277,43 @@ const f = {
2145
2277
  livechat: "web",
2146
2278
  whatsapp: "web"
2147
2279
  };
2148
- function xe({ provider: t, apiUrl: i, size: r = 40 }) {
2149
- const o = hn[t] ?? "#f1f5f9", h = pn[t], S = i.replace(/\/$/, "");
2280
+ function Ce({ provider: t, apiUrl: i, size: o = 40 }) {
2281
+ const r = Sn[t] ?? "#f1f5f9", c = Cn[t], C = i.replace(/\/$/, "");
2150
2282
  return /* @__PURE__ */ e(
2151
2283
  "div",
2152
2284
  {
2153
2285
  style: {
2154
- width: r,
2155
- height: r,
2156
- borderRadius: Math.round(r * 0.28),
2157
- background: o,
2286
+ width: o,
2287
+ height: o,
2288
+ borderRadius: Math.round(o * 0.28),
2289
+ background: r,
2158
2290
  display: "flex",
2159
2291
  alignItems: "center",
2160
2292
  justifyContent: "center",
2161
2293
  flexShrink: 0,
2162
2294
  overflow: "hidden"
2163
2295
  },
2164
- children: h ? /* @__PURE__ */ e(
2296
+ children: c ? /* @__PURE__ */ e(
2165
2297
  "img",
2166
2298
  {
2167
- src: `${S}/static/logos/${h}.avif`,
2299
+ src: `${C}/static/logos/${c}.avif`,
2168
2300
  alt: t,
2169
- width: Math.round(r * 0.65),
2170
- height: Math.round(r * 0.65),
2301
+ width: Math.round(o * 0.65),
2302
+ height: Math.round(o * 0.65),
2171
2303
  style: { objectFit: "contain", display: "block" }
2172
2304
  }
2173
- ) : /* @__PURE__ */ e("span", { style: { fontSize: Math.round(r * 0.45), fontWeight: 700, color: "#64748b", textTransform: "uppercase" }, children: t.slice(0, 1) })
2305
+ ) : /* @__PURE__ */ e("span", { style: { fontSize: Math.round(o * 0.45), fontWeight: 700, color: "#64748b", textTransform: "uppercase" }, children: t.slice(0, 1) })
2174
2306
  }
2175
2307
  );
2176
2308
  }
2177
- const Ue = {
2309
+ const qe = {
2178
2310
  facebook: "Facebook",
2179
2311
  zalo: "Zalo OA",
2180
2312
  instagram: "Instagram",
2181
2313
  telegram: "Telegram",
2182
2314
  livechat: "Live Chat",
2183
2315
  whatsapp: "WhatsApp"
2184
- }, un = {
2316
+ }, In = {
2185
2317
  facebook: "#dbeafe",
2186
2318
  zalo: "#e0f2fe",
2187
2319
  instagram: "#fce7f3",
@@ -2189,13 +2321,30 @@ const Ue = {
2189
2321
  livechat: "#ede9fe",
2190
2322
  whatsapp: "#dcfce7"
2191
2323
  };
2192
- function ct(t) {
2324
+ function mt(t) {
2193
2325
  const i = t.metadata;
2194
2326
  return String(i.displayName ?? i.pageName ?? i.username ?? i.name ?? t.externalAccountId);
2195
2327
  }
2196
- function fn(t) {
2197
- const i = Ue[t.provider] ?? t.provider, r = String(t.metadata.username ?? t.metadata.pageName ?? "");
2198
- return r ? `${i} · ${r}` : i;
2328
+ function zn(t) {
2329
+ const i = t.metadata;
2330
+ switch (t.provider) {
2331
+ case "facebook":
2332
+ return `Fanpage · ID ${t.externalAccountId}`;
2333
+ case "instagram":
2334
+ return `@${String(i.username ?? t.externalAccountId)}`;
2335
+ case "zalo":
2336
+ return `Zalo OA · ID ${t.externalAccountId}`;
2337
+ case "telegram": {
2338
+ const o = String(i.username ?? "");
2339
+ return o ? `@${o}` : `Bot · ${t.externalAccountId}`;
2340
+ }
2341
+ case "livechat":
2342
+ return `Widget ID: ${t.id}`;
2343
+ default: {
2344
+ const o = qe[t.provider] ?? t.provider, r = String(i.username ?? i.pageName ?? "");
2345
+ return r ? `${o} · ${r}` : o;
2346
+ }
2347
+ }
2199
2348
  }
2200
2349
  const s = {
2201
2350
  root: {
@@ -2472,264 +2621,264 @@ const s = {
2472
2621
  fontFamily: "inherit"
2473
2622
  }
2474
2623
  };
2475
- function mt() {
2624
+ function $t() {
2476
2625
  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" }) });
2477
2626
  }
2478
- function Be() {
2627
+ function Ae() {
2479
2628
  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" }) });
2480
2629
  }
2481
- function xt() {
2630
+ function Bt() {
2482
2631
  return /* @__PURE__ */ n("svg", { width: "12", height: "12", viewBox: "0 0 12 12", fill: "none", children: [
2483
2632
  /* @__PURE__ */ e("rect", { x: "4", y: "4", width: "7", height: "7", rx: "1.5", stroke: "currentColor", strokeWidth: "1.3" }),
2484
2633
  /* @__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" })
2485
2634
  ] });
2486
2635
  }
2487
- function vt() {
2636
+ function Lt() {
2488
2637
  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" }) });
2489
2638
  }
2490
- function gn() {
2639
+ function Rn() {
2491
2640
  return /* @__PURE__ */ n("svg", { width: "14", height: "14", viewBox: "0 0 14 14", fill: "none", style: { flexShrink: 0 }, children: [
2492
2641
  /* @__PURE__ */ e("circle", { cx: "5", cy: "6", r: "3.5", stroke: "#ca8a04", strokeWidth: "1.4" }),
2493
2642
  /* @__PURE__ */ e("path", { d: "M8 7.5l4.5 4.5M10.5 10l1.5 1.5", stroke: "#ca8a04", strokeWidth: "1.4", strokeLinecap: "round" })
2494
2643
  ] });
2495
2644
  }
2496
- function yn() {
2645
+ function Wn() {
2497
2646
  return /* @__PURE__ */ n("svg", { width: "14", height: "14", viewBox: "0 0 14 14", fill: "none", style: { flexShrink: 0, marginTop: 1 }, children: [
2498
2647
  /* @__PURE__ */ e("circle", { cx: "7", cy: "7", r: "6", stroke: "currentColor", strokeWidth: "1.5" }),
2499
2648
  /* @__PURE__ */ e("path", { d: "M7 6v5M7 4.5v.01", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round" })
2500
2649
  ] });
2501
2650
  }
2502
- let kt = !1;
2503
- function bn() {
2504
- if (kt || typeof document > "u") return;
2505
- kt = !0;
2651
+ let Mt = !1;
2652
+ function Tn() {
2653
+ if (Mt || typeof document > "u") return;
2654
+ Mt = !0;
2506
2655
  const t = document.createElement("style");
2507
2656
  t.textContent = "@keyframes ch-spin{to{transform:rotate(360deg)}}", document.head.appendChild(t);
2508
2657
  }
2509
- function $n({ apiUrl: t, token: i, onConnectionChange: r }) {
2510
- const o = t.replace(/\/$/, ""), [h, S] = y([]), [m, M] = y(!0), [w, v] = y({ name: "list" }), [W, T] = y(null), [A, $] = y(!1), [C, D] = y(""), [I, L] = y(""), [P, q] = y(""), [te, Q] = y(""), [B, x] = y(!1), [b, E] = y(!1), V = J(null);
2511
- bn();
2512
- const ne = we(async () => {
2658
+ function Pn({ apiUrl: t, token: i, onConnectionChange: o }) {
2659
+ const r = t.replace(/\/$/, ""), [c, C] = u([]), [y, L] = u(!0), [w, g] = u({ name: "list" }), [$, T] = u(null), [E, M] = u(!1), [I, q] = u(""), [R, H] = u(""), [J, F] = u(""), [re, V] = u(""), [B, b] = u(!1), [S, D] = u(!1), j = X(null);
2660
+ Tn();
2661
+ const Z = Te(async () => {
2513
2662
  try {
2514
- const c = await fetch(`${o}/v1/connections`, {
2663
+ const h = await fetch(`${r}/v1/connections`, {
2515
2664
  headers: { authorization: `Bearer ${i}` }
2516
2665
  });
2517
- if (!c.ok) throw new Error("Không tải được kênh");
2518
- const H = await c.json();
2519
- S(H), r == null || r(H);
2520
- } catch (c) {
2521
- T(c instanceof Error ? c.message : "Lỗi tải dữ liệu");
2666
+ if (!h.ok) throw new Error("Không tải được kênh");
2667
+ const A = await h.json();
2668
+ C(A), o == null || o(A);
2669
+ } catch (h) {
2670
+ T(h instanceof Error ? h.message : "Lỗi tải dữ liệu");
2522
2671
  } finally {
2523
- M(!1);
2672
+ L(!1);
2524
2673
  }
2525
- }, [o, i, r]);
2526
- X(() => {
2527
- ne();
2528
- }, [ne]), X(() => {
2529
- if (!W) return;
2530
- const c = setTimeout(() => T(null), 5e3);
2531
- return () => clearTimeout(c);
2532
- }, [W]), X(() => () => {
2533
- V.current && window.removeEventListener("message", V.current);
2674
+ }, [r, i, o]);
2675
+ K(() => {
2676
+ Z();
2677
+ }, [Z]), K(() => {
2678
+ if (!$) return;
2679
+ const h = setTimeout(() => T(null), 5e3);
2680
+ return () => clearTimeout(h);
2681
+ }, [$]), K(() => () => {
2682
+ j.current && window.removeEventListener("message", j.current);
2534
2683
  }, []);
2535
- async function de(c, H) {
2536
- if (confirm(`Bạn chắc chắn muốn ngắt kết nối "${H}"?
2684
+ async function pe(h, A) {
2685
+ if (confirm(`Bạn chắc chắn muốn ngắt kết nối "${A}"?
2537
2686
 
2538
2687
  Hành động này không thể hoàn tác.`))
2539
2688
  try {
2540
- if (!(await fetch(`${o}/v1/connections/${c}`, {
2689
+ if (!(await fetch(`${r}/v1/connections/${h}`, {
2541
2690
  method: "DELETE",
2542
2691
  headers: { authorization: `Bearer ${i}` }
2543
2692
  })).ok) throw new Error("Không thể ngắt kết nối");
2544
- await ne();
2545
- } catch (N) {
2546
- T(N instanceof Error ? N.message : "Lỗi ngắt kết nối");
2693
+ await Z();
2694
+ } catch (U) {
2695
+ T(U instanceof Error ? U.message : "Lỗi ngắt kết nối");
2547
2696
  }
2548
2697
  }
2549
- async function z() {
2550
- if (!C.trim()) {
2698
+ async function ve() {
2699
+ if (!I.trim()) {
2551
2700
  T("Vui lòng nhập Bot Token");
2552
2701
  return;
2553
2702
  }
2554
- if (!/^\d+:[A-Za-z0-9_-]+$/.test(C.trim())) {
2703
+ if (!/^\d+:[A-Za-z0-9_-]+$/.test(I.trim())) {
2555
2704
  T("Token không đúng định dạng");
2556
2705
  return;
2557
2706
  }
2558
- $(!0), T(null);
2707
+ M(!0), T(null);
2559
2708
  try {
2560
- const c = await fetch(`${o}/v1/connect/telegram/start`, {
2709
+ const h = await fetch(`${r}/v1/connect/telegram/start`, {
2561
2710
  method: "POST",
2562
2711
  headers: { authorization: `Bearer ${i}`, "content-type": "application/json" },
2563
- body: JSON.stringify({ botToken: C.trim(), displayName: I.trim() || void 0 })
2564
- }), H = await c.json();
2565
- if (!c.ok || !H.connectionId) throw new Error(H.message ?? "Không thể kết nối Telegram");
2566
- D(""), L(""), await ne(), v({ name: "list" });
2567
- } catch (c) {
2568
- T(c instanceof Error ? c.message : "Lỗi kết nối");
2712
+ body: JSON.stringify({ botToken: I.trim(), displayName: R.trim() || void 0 })
2713
+ }), A = await h.json();
2714
+ if (!h.ok || !A.connectionId) throw new Error(A.message ?? "Không thể kết nối Telegram");
2715
+ q(""), H(""), await Z(), g({ name: "list" });
2716
+ } catch (h) {
2717
+ T(h instanceof Error ? h.message : "Lỗi kết nối");
2569
2718
  } finally {
2570
- $(!1);
2719
+ M(!1);
2571
2720
  }
2572
2721
  }
2573
- async function oe() {
2574
- if (!P.trim()) {
2722
+ async function fe() {
2723
+ if (!J.trim()) {
2575
2724
  T("Vui lòng nhập tên widget");
2576
2725
  return;
2577
2726
  }
2578
- $(!0), T(null);
2727
+ M(!0), T(null);
2579
2728
  try {
2580
- const c = te.split(/[\n,]+/).map((ae) => ae.trim()).filter(Boolean), H = await fetch(`${o}/v1/connect/livechat/start`, {
2729
+ const h = re.split(/[\n,]+/).map((z) => z.trim()).filter(Boolean), A = await fetch(`${r}/v1/connect/livechat/start`, {
2581
2730
  method: "POST",
2582
2731
  headers: { authorization: `Bearer ${i}`, "content-type": "application/json" },
2583
- body: JSON.stringify({ displayName: P.trim(), allowedDomains: c.length ? c : void 0 })
2584
- }), N = await H.json();
2585
- if (!H.ok || !N.connectionId || !N.embedScript) throw new Error(N.message ?? "Không thể tạo widget");
2586
- q(""), Q(""), await ne(), v({
2732
+ body: JSON.stringify({ displayName: J.trim(), allowedDomains: h.length ? h : void 0 })
2733
+ }), U = await A.json();
2734
+ if (!A.ok || !U.connectionId || !U.embedScript) throw new Error(U.message ?? "Không thể tạo widget");
2735
+ F(""), V(""), await Z(), g({
2587
2736
  name: "livechat-result",
2588
- connectionId: N.connectionId,
2589
- embedScript: N.embedScript,
2590
- identitySecret: N.identitySecret ?? "",
2591
- allowedDomains: N.allowedDomains ?? []
2737
+ connectionId: U.connectionId,
2738
+ embedScript: U.embedScript,
2739
+ identitySecret: U.identitySecret ?? "",
2740
+ allowedDomains: U.allowedDomains ?? []
2592
2741
  });
2593
- } catch (c) {
2594
- T(c instanceof Error ? c.message : "Lỗi tạo widget");
2742
+ } catch (h) {
2743
+ T(h instanceof Error ? h.message : "Lỗi tạo widget");
2595
2744
  } finally {
2596
- $(!1);
2745
+ M(!1);
2597
2746
  }
2598
2747
  }
2599
- async function Z(c) {
2748
+ async function se(h) {
2600
2749
  T(null);
2601
2750
  try {
2602
- const H = `${o}/static/oauth-popup.html`, N = await fetch(`${o}/v1/connect/${c}/start`, {
2751
+ const A = `${r}/static/oauth-popup.html`, U = await fetch(`${r}/v1/connect/${h}/start`, {
2603
2752
  method: "POST",
2604
2753
  headers: { authorization: `Bearer ${i}`, "content-type": "application/json" },
2605
- body: JSON.stringify({ callbackUrl: H })
2606
- }), ae = await N.json();
2607
- if (!N.ok || !ae.authorizationUrl) throw new Error(ae.message ?? "Không thể bắt đầu kết nối");
2608
- const ce = window.open(ae.authorizationUrl, "channelhub-oauth", "width=600,height=700,scrollbars=yes,resizable=yes");
2609
- v({ name: "oauth-waiting", provider: c, popup: ce }), V.current && window.removeEventListener("message", V.current);
2610
- const ye = (F) => {
2611
- if (F.data) {
2612
- if (F.data.type === "channelhub:oauth-select") {
2613
- v({
2754
+ body: JSON.stringify({ callbackUrl: A })
2755
+ }), z = await U.json();
2756
+ if (!U.ok || !z.authorizationUrl) throw new Error(z.message ?? "Không thể bắt đầu kết nối");
2757
+ const ce = window.open(z.authorizationUrl, "channelhub-oauth", "width=600,height=700,scrollbars=yes,resizable=yes");
2758
+ g({ name: "oauth-waiting", provider: h, popup: ce }), j.current && window.removeEventListener("message", j.current);
2759
+ const de = (Q) => {
2760
+ if (Q.data) {
2761
+ if (Q.data.type === "channelhub:oauth-select") {
2762
+ g({
2614
2763
  name: "oauth-select",
2615
- provider: F.data.provider,
2616
- sessionId: String(F.data.sessionId ?? ""),
2617
- pages: F.data.pages ?? [],
2764
+ provider: Q.data.provider,
2765
+ sessionId: String(Q.data.sessionId ?? ""),
2766
+ pages: Q.data.pages ?? [],
2618
2767
  popup: ce
2619
2768
  });
2620
2769
  return;
2621
2770
  }
2622
- F.data.type === "channelhub:oauth" && (window.removeEventListener("message", ye), V.current = null, F.data.status === "active" ? (ne(), v({ name: "list" })) : (T("Kết nối thất bại: " + String(F.data.error ?? "Không xác định")), v({ name: "list" })));
2771
+ Q.data.type === "channelhub:oauth" && (window.removeEventListener("message", de), j.current = null, Q.data.status === "active" ? (Z(), g({ name: "list" })) : (T("Kết nối thất bại: " + String(Q.data.error ?? "Không xác định")), g({ name: "list" })));
2623
2772
  }
2624
2773
  };
2625
- V.current = ye, window.addEventListener("message", ye);
2626
- } catch (H) {
2627
- T(H instanceof Error ? H.message : "Lỗi kết nối"), v({ name: "list" });
2774
+ j.current = de, window.addEventListener("message", de);
2775
+ } catch (A) {
2776
+ T(A instanceof Error ? A.message : "Lỗi kết nối"), g({ name: "list" });
2628
2777
  }
2629
2778
  }
2630
- function U(c, H) {
2631
- navigator.clipboard.writeText(c).then(() => {
2632
- H === "script" ? (x(!0), setTimeout(() => x(!1), 2e3)) : (E(!0), setTimeout(() => E(!1), 2e3));
2779
+ function G(h, A) {
2780
+ navigator.clipboard.writeText(h).then(() => {
2781
+ A === "script" ? (b(!0), setTimeout(() => b(!1), 2e3)) : (D(!0), setTimeout(() => D(!1), 2e3));
2633
2782
  });
2634
2783
  }
2635
- function ee() {
2636
- const c = w.name === "oauth-waiting" || w.name === "oauth-select" ? w.popup : null;
2637
- if (c)
2784
+ function k() {
2785
+ const h = w.name === "oauth-waiting" || w.name === "oauth-select" ? w.popup : null;
2786
+ if (h)
2638
2787
  try {
2639
- c.close();
2788
+ h.close();
2640
2789
  } catch {
2641
2790
  }
2642
- V.current && (window.removeEventListener("message", V.current), V.current = null), v({ name: "add" });
2791
+ j.current && (window.removeEventListener("message", j.current), j.current = null), g({ name: "add" });
2643
2792
  }
2644
- async function se(c) {
2793
+ async function ie(h) {
2645
2794
  if (w.name !== "oauth-select") return;
2646
- const { provider: H, sessionId: N, popup: ae } = w;
2647
- $(!0), T(null);
2795
+ const { provider: A, sessionId: U, popup: z } = w;
2796
+ M(!0), T(null);
2648
2797
  const ce = {
2649
- facebook: `${o}/v1/connect/facebook/select-page`,
2650
- instagram: `${o}/v1/connect/instagram/select-account`,
2651
- zalo: `${o}/v1/connect/zalo/select-oa`
2652
- }, ye = {
2798
+ facebook: `${r}/v1/connect/facebook/select-page`,
2799
+ instagram: `${r}/v1/connect/instagram/select-account`,
2800
+ zalo: `${r}/v1/connect/zalo/select-oa`
2801
+ }, de = {
2653
2802
  facebook: "pageId",
2654
2803
  instagram: "accountId",
2655
2804
  zalo: "oaId"
2656
2805
  };
2657
2806
  try {
2658
- const F = await fetch(ce[H] ?? `${o}/v1/connect/${H}/select-page`, {
2807
+ const Q = await fetch(ce[A] ?? `${r}/v1/connect/${A}/select-page`, {
2659
2808
  method: "POST",
2660
2809
  headers: { authorization: `Bearer ${i}`, "content-type": "application/json" },
2661
- body: JSON.stringify({ sessionId: N, [ye[H] ?? "pageId"]: c })
2662
- }), he = await F.json();
2663
- if (!F.ok || !he.connectionId) throw new Error(he.message ?? "Không thể kết nối");
2664
- if (ae)
2810
+ body: JSON.stringify({ sessionId: U, [de[A] ?? "pageId"]: h })
2811
+ }), he = await Q.json();
2812
+ if (!Q.ok || !he.connectionId) throw new Error(he.message ?? "Không thể kết nối");
2813
+ if (z)
2665
2814
  try {
2666
- ae.postMessage({ type: "channelhub:close-popup" }, "*");
2815
+ z.postMessage({ type: "channelhub:close-popup" }, "*");
2667
2816
  } catch {
2668
2817
  }
2669
- V.current && (window.removeEventListener("message", V.current), V.current = null), await ne(), v({ name: "list" });
2670
- } catch (F) {
2671
- T(F instanceof Error ? F.message : "Lỗi kết nối");
2818
+ j.current && (window.removeEventListener("message", j.current), j.current = null), await Z(), g({ name: "list" });
2819
+ } catch (Q) {
2820
+ T(Q instanceof Error ? Q.message : "Lỗi kết nối");
2672
2821
  } finally {
2673
- $(!1);
2822
+ M(!1);
2674
2823
  }
2675
2824
  }
2676
2825
  return /* @__PURE__ */ n("div", { style: s.root, children: [
2677
- W && /* @__PURE__ */ e("div", { style: s.errorBanner, children: W }),
2678
- w.name === "list" && /* @__PURE__ */ n(ie, { children: [
2826
+ $ && /* @__PURE__ */ e("div", { style: s.errorBanner, children: $ }),
2827
+ w.name === "list" && /* @__PURE__ */ n(ne, { children: [
2679
2828
  /* @__PURE__ */ n("div", { style: s.header, children: [
2680
2829
  /* @__PURE__ */ e("div", { style: s.headerLeft, children: /* @__PURE__ */ n("div", { children: [
2681
2830
  /* @__PURE__ */ e("div", { style: s.title, children: "Kênh kết nối" }),
2682
- /* @__PURE__ */ e("div", { style: s.subtitle, children: m ? "Đang tải…" : `${h.filter((c) => c.status === "active").length} kênh đang hoạt động` })
2831
+ /* @__PURE__ */ e("div", { style: s.subtitle, children: y ? "Đang tải…" : `${c.filter((h) => h.status === "active").length} kênh đang hoạt động` })
2683
2832
  ] }) }),
2684
- /* @__PURE__ */ n("button", { style: s.addBtn, onClick: () => v({ name: "add" }), children: [
2685
- /* @__PURE__ */ e(mt, {}),
2833
+ /* @__PURE__ */ n("button", { style: s.addBtn, onClick: () => g({ name: "add" }), children: [
2834
+ /* @__PURE__ */ e($t, {}),
2686
2835
  /* @__PURE__ */ e("span", { children: "Thêm kênh" })
2687
2836
  ] })
2688
2837
  ] }),
2689
2838
  /* @__PURE__ */ e("div", { style: s.divider }),
2690
- /* @__PURE__ */ e("div", { style: s.body, children: !m && h.length === 0 ? /* @__PURE__ */ n("div", { style: s.empty, children: [
2691
- /* @__PURE__ */ e("div", { style: { width: 64, height: 64, borderRadius: 16, background: "#f1f5f9", display: "flex", alignItems: "center", justifyContent: "center" }, children: /* @__PURE__ */ e(xe, { provider: "livechat", apiUrl: o, size: 40 }) }),
2839
+ /* @__PURE__ */ e("div", { style: s.body, children: !y && c.length === 0 ? /* @__PURE__ */ n("div", { style: s.empty, children: [
2840
+ /* @__PURE__ */ e("div", { style: { width: 64, height: 64, borderRadius: 16, background: "#f1f5f9", display: "flex", alignItems: "center", justifyContent: "center" }, children: /* @__PURE__ */ e(Ce, { provider: "livechat", apiUrl: r, size: 40 }) }),
2692
2841
  /* @__PURE__ */ e("div", { style: s.emptyTitle, children: "Chưa có kênh nào được kết nối" }),
2693
2842
  /* @__PURE__ */ e("div", { style: s.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." }),
2694
- /* @__PURE__ */ n("button", { style: s.emptyCta, onClick: () => v({ name: "add" }), children: [
2695
- /* @__PURE__ */ e(mt, {}),
2843
+ /* @__PURE__ */ n("button", { style: s.emptyCta, onClick: () => g({ name: "add" }), children: [
2844
+ /* @__PURE__ */ e($t, {}),
2696
2845
  "Kết nối kênh đầu tiên"
2697
2846
  ] })
2698
- ] }) : /* @__PURE__ */ e("div", { children: h.map((c) => /* @__PURE__ */ e(
2699
- vn,
2847
+ ] }) : /* @__PURE__ */ e("div", { children: c.map((h) => /* @__PURE__ */ e(
2848
+ Ln,
2700
2849
  {
2701
- conn: c,
2702
- apiUrl: o,
2703
- onDisconnect: () => void de(c.id, ct(c))
2850
+ conn: h,
2851
+ apiUrl: r,
2852
+ onDisconnect: () => void pe(h.id, mt(h))
2704
2853
  },
2705
- c.id
2854
+ h.id
2706
2855
  )) }) })
2707
2856
  ] }),
2708
- w.name === "add" && /* @__PURE__ */ n(ie, { children: [
2857
+ w.name === "add" && /* @__PURE__ */ n(ne, { children: [
2709
2858
  /* @__PURE__ */ e("div", { style: s.header, children: /* @__PURE__ */ n("div", { style: s.headerLeft, children: [
2710
- /* @__PURE__ */ e("button", { style: s.backBtn, onClick: () => v({ name: "list" }), children: /* @__PURE__ */ e(Be, {}) }),
2859
+ /* @__PURE__ */ e("button", { style: s.backBtn, onClick: () => g({ name: "list" }), children: /* @__PURE__ */ e(Ae, {}) }),
2711
2860
  /* @__PURE__ */ n("div", { children: [
2712
2861
  /* @__PURE__ */ e("div", { style: s.title, children: "Thêm kênh mới" }),
2713
2862
  /* @__PURE__ */ e("div", { style: s.subtitle, children: "Chọn nền tảng bạn muốn kết nối" })
2714
2863
  ] })
2715
2864
  ] }) }),
2716
2865
  /* @__PURE__ */ e("div", { style: s.divider }),
2717
- /* @__PURE__ */ e("div", { style: s.body, children: /* @__PURE__ */ e("div", { style: s.providerGrid, children: kn.map((c) => /* @__PURE__ */ e(
2718
- wn,
2866
+ /* @__PURE__ */ e("div", { style: s.body, children: /* @__PURE__ */ e("div", { style: s.providerGrid, children: Mn.map((h) => /* @__PURE__ */ e(
2867
+ Hn,
2719
2868
  {
2720
- provider: c,
2721
- apiUrl: o,
2869
+ provider: h,
2870
+ apiUrl: r,
2722
2871
  onClick: () => {
2723
- c.type === "oauth" ? Z(c.id) : c.id === "telegram" ? v({ name: "connect-telegram" }) : v({ name: "connect-livechat" });
2872
+ h.type === "oauth" ? se(h.id) : h.id === "telegram" ? g({ name: "connect-telegram" }) : g({ name: "connect-livechat" });
2724
2873
  }
2725
2874
  },
2726
- c.id
2875
+ h.id
2727
2876
  )) }) })
2728
2877
  ] }),
2729
- w.name === "connect-telegram" && /* @__PURE__ */ n(ie, { children: [
2878
+ w.name === "connect-telegram" && /* @__PURE__ */ n(ne, { children: [
2730
2879
  /* @__PURE__ */ n("div", { style: s.connectHeader, children: [
2731
- /* @__PURE__ */ e("button", { style: s.backBtn, onClick: () => v({ name: "add" }), children: /* @__PURE__ */ e(Be, {}) }),
2732
- /* @__PURE__ */ e(xe, { provider: "telegram", apiUrl: o, size: 44 }),
2880
+ /* @__PURE__ */ e("button", { style: s.backBtn, onClick: () => g({ name: "add" }), children: /* @__PURE__ */ e(Ae, {}) }),
2881
+ /* @__PURE__ */ e(Ce, { provider: "telegram", apiUrl: r, size: 44 }),
2733
2882
  /* @__PURE__ */ n("div", { children: [
2734
2883
  /* @__PURE__ */ e("div", { style: s.connectTitle, children: "Kết nối Telegram Bot" }),
2735
2884
  /* @__PURE__ */ e("div", { style: s.connectDesc, children: "Nhập Bot Token để bắt đầu nhận tin nhắn" })
@@ -2737,7 +2886,7 @@ Hành động này không thể hoàn tác.`))
2737
2886
  ] }),
2738
2887
  /* @__PURE__ */ n("div", { style: s.form, children: [
2739
2888
  /* @__PURE__ */ n("div", { style: s.infoBox, children: [
2740
- /* @__PURE__ */ e(yn, {}),
2889
+ /* @__PURE__ */ e(Wn, {}),
2741
2890
  /* @__PURE__ */ n("div", { children: [
2742
2891
  "Tạo bot mới bằng cách nhắn tin cho ",
2743
2892
  /* @__PURE__ */ e("strong", { children: "@BotFather" }),
@@ -2756,8 +2905,8 @@ Hành động này không thể hoàn tác.`))
2756
2905
  {
2757
2906
  style: s.input,
2758
2907
  type: "text",
2759
- value: C,
2760
- onChange: (c) => D(c.target.value),
2908
+ value: I,
2909
+ onChange: (h) => q(h.target.value),
2761
2910
  placeholder: "1234567890:AAExxxxxxxxxxxxxxxxxxxxxxxx",
2762
2911
  autoComplete: "off",
2763
2912
  spellCheck: !1
@@ -2780,22 +2929,22 @@ Hành động này không thể hoàn tác.`))
2780
2929
  {
2781
2930
  style: s.input,
2782
2931
  type: "text",
2783
- value: I,
2784
- onChange: (c) => L(c.target.value),
2932
+ value: R,
2933
+ onChange: (h) => H(h.target.value),
2785
2934
  placeholder: "VD: Bot hỗ trợ cửa hàng"
2786
2935
  }
2787
2936
  )
2788
2937
  ] }),
2789
2938
  /* @__PURE__ */ n("div", { style: s.formActions, children: [
2790
- /* @__PURE__ */ e("button", { style: s.btnSecondary, onClick: () => v({ name: "add" }), children: "Hủy" }),
2791
- /* @__PURE__ */ e("button", { style: s.btnPrimary, disabled: A, onClick: () => void z(), children: A ? "Đang kết nối…" : "Kết nối Telegram" })
2939
+ /* @__PURE__ */ e("button", { style: s.btnSecondary, onClick: () => g({ name: "add" }), children: "Hủy" }),
2940
+ /* @__PURE__ */ e("button", { style: s.btnPrimary, disabled: E, onClick: () => void ve(), children: E ? "Đang kết nối…" : "Kết nối Telegram" })
2792
2941
  ] })
2793
2942
  ] })
2794
2943
  ] }),
2795
- w.name === "connect-livechat" && /* @__PURE__ */ n(ie, { children: [
2944
+ w.name === "connect-livechat" && /* @__PURE__ */ n(ne, { children: [
2796
2945
  /* @__PURE__ */ n("div", { style: s.connectHeader, children: [
2797
- /* @__PURE__ */ e("button", { style: s.backBtn, onClick: () => v({ name: "add" }), children: /* @__PURE__ */ e(Be, {}) }),
2798
- /* @__PURE__ */ e(xe, { provider: "livechat", apiUrl: o, size: 44 }),
2946
+ /* @__PURE__ */ e("button", { style: s.backBtn, onClick: () => g({ name: "add" }), children: /* @__PURE__ */ e(Ae, {}) }),
2947
+ /* @__PURE__ */ e(Ce, { provider: "livechat", apiUrl: r, size: 44 }),
2799
2948
  /* @__PURE__ */ n("div", { children: [
2800
2949
  /* @__PURE__ */ e("div", { style: s.connectTitle, children: "Tạo Live Chat Widget" }),
2801
2950
  /* @__PURE__ */ e("div", { style: s.connectDesc, children: "Nhúng vào website để nhận tin nhắn từ khách hàng" })
@@ -2812,8 +2961,8 @@ Hành động này không thể hoàn tác.`))
2812
2961
  {
2813
2962
  style: s.input,
2814
2963
  type: "text",
2815
- value: P,
2816
- onChange: (c) => q(c.target.value),
2964
+ value: J,
2965
+ onChange: (h) => F(h.target.value),
2817
2966
  placeholder: "VD: Hỗ trợ website hanashop.vn"
2818
2967
  }
2819
2968
  )
@@ -2827,8 +2976,8 @@ Hành động này không thể hoàn tác.`))
2827
2976
  "textarea",
2828
2977
  {
2829
2978
  style: { ...s.input, resize: "vertical", minHeight: 80, lineHeight: 1.5 },
2830
- value: te,
2831
- onChange: (c) => Q(c.target.value),
2979
+ value: re,
2980
+ onChange: (h) => V(h.target.value),
2832
2981
  placeholder: `https://myshop.com
2833
2982
  https://www.myshop.com`,
2834
2983
  spellCheck: !1
@@ -2837,15 +2986,15 @@ https://www.myshop.com`,
2837
2986
  /* @__PURE__ */ e("div", { style: s.inputHint, children: "Mỗi domain một dòng. Để trống để cho phép tất cả." })
2838
2987
  ] }),
2839
2988
  /* @__PURE__ */ n("div", { style: s.formActions, children: [
2840
- /* @__PURE__ */ e("button", { style: s.btnSecondary, onClick: () => v({ name: "add" }), children: "Hủy" }),
2841
- /* @__PURE__ */ e("button", { style: s.btnPrimary, disabled: A, onClick: () => void oe(), children: A ? "Đang tạo…" : "Tạo widget" })
2989
+ /* @__PURE__ */ e("button", { style: s.btnSecondary, onClick: () => g({ name: "add" }), children: "Hủy" }),
2990
+ /* @__PURE__ */ e("button", { style: s.btnPrimary, disabled: E, onClick: () => void fe(), children: E ? "Đang tạo…" : "Tạo widget" })
2842
2991
  ] })
2843
2992
  ] })
2844
2993
  ] }),
2845
- w.name === "livechat-result" && /* @__PURE__ */ n(ie, { children: [
2994
+ w.name === "livechat-result" && /* @__PURE__ */ n(ne, { children: [
2846
2995
  /* @__PURE__ */ n("div", { style: s.connectHeader, children: [
2847
- /* @__PURE__ */ e("button", { style: s.backBtn, onClick: () => v({ name: "list" }), children: /* @__PURE__ */ e(Be, {}) }),
2848
- /* @__PURE__ */ e(xe, { provider: "livechat", apiUrl: o, size: 44 }),
2996
+ /* @__PURE__ */ e("button", { style: s.backBtn, onClick: () => g({ name: "list" }), children: /* @__PURE__ */ e(Ae, {}) }),
2997
+ /* @__PURE__ */ e(Ce, { provider: "livechat", apiUrl: r, size: 44 }),
2849
2998
  /* @__PURE__ */ n("div", { children: [
2850
2999
  /* @__PURE__ */ e("div", { style: s.connectTitle, children: "Widget đã được tạo!" }),
2851
3000
  /* @__PURE__ */ e("div", { style: s.connectDesc, children: "Sao chép mã nhúng và dán vào website của bạn" })
@@ -2865,11 +3014,11 @@ https://www.myshop.com`,
2865
3014
  /* @__PURE__ */ e("div", { style: s.codeLabel, children: "Mã nhúng" }),
2866
3015
  /* @__PURE__ */ n("div", { style: s.codeBlock, children: [
2867
3016
  /* @__PURE__ */ e("pre", { style: s.codePre, children: w.embedScript }),
2868
- /* @__PURE__ */ e("button", { style: { ...s.copyBtn, ...B ? { background: "#166534", borderColor: "#166534", color: "#bbf7d0" } : {} }, onClick: () => U(w.embedScript, "script"), children: B ? /* @__PURE__ */ n(ie, { children: [
2869
- /* @__PURE__ */ e(vt, {}),
3017
+ /* @__PURE__ */ e("button", { style: { ...s.copyBtn, ...B ? { background: "#166534", borderColor: "#166534", color: "#bbf7d0" } : {} }, onClick: () => G(w.embedScript, "script"), children: B ? /* @__PURE__ */ n(ne, { children: [
3018
+ /* @__PURE__ */ e(Lt, {}),
2870
3019
  " Đã sao chép"
2871
- ] }) : /* @__PURE__ */ n(ie, { children: [
2872
- /* @__PURE__ */ e(xt, {}),
3020
+ ] }) : /* @__PURE__ */ n(ne, { children: [
3021
+ /* @__PURE__ */ e(Bt, {}),
2873
3022
  " Sao chép"
2874
3023
  ] }) })
2875
3024
  ] })
@@ -2880,40 +3029,40 @@ https://www.myshop.com`,
2880
3029
  /* @__PURE__ */ e("span", { style: { ...s.labelHint, color: "#dc2626", fontWeight: 600 }, children: "Lưu ngay — chỉ hiển thị một lần" })
2881
3030
  ] }),
2882
3031
  /* @__PURE__ */ n("div", { style: s.secretRow, children: [
2883
- /* @__PURE__ */ e(gn, {}),
3032
+ /* @__PURE__ */ e(Rn, {}),
2884
3033
  /* @__PURE__ */ e("span", { style: s.secretLabel, children: "Secret:" }),
2885
3034
  /* @__PURE__ */ e("span", { style: s.secretValue, children: w.identitySecret }),
2886
3035
  /* @__PURE__ */ e(
2887
3036
  "button",
2888
3037
  {
2889
- onClick: () => U(w.identitySecret, "secret"),
2890
- style: { border: "none", background: "transparent", cursor: "pointer", color: b ? "#059669" : "#ca8a04", padding: 2, display: "flex", alignItems: "center" },
2891
- children: b ? /* @__PURE__ */ e(vt, {}) : /* @__PURE__ */ e(xt, {})
3038
+ onClick: () => G(w.identitySecret, "secret"),
3039
+ style: { border: "none", background: "transparent", cursor: "pointer", color: S ? "#059669" : "#ca8a04", padding: 2, display: "flex", alignItems: "center" },
3040
+ children: S ? /* @__PURE__ */ e(Lt, {}) : /* @__PURE__ */ e(Bt, {})
2892
3041
  }
2893
3042
  )
2894
3043
  ] }),
2895
3044
  /* @__PURE__ */ e("div", { style: { ...s.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." })
2896
3045
  ] }),
2897
3046
  /* @__PURE__ */ n("div", { style: s.formActions, children: [
2898
- /* @__PURE__ */ e("button", { style: s.btnSecondary, onClick: () => v({ name: "list" }), children: "Về danh sách" }),
2899
- /* @__PURE__ */ e("button", { style: s.btnPrimary, onClick: () => v({ name: "add" }), children: "Thêm kênh khác" })
3047
+ /* @__PURE__ */ e("button", { style: s.btnSecondary, onClick: () => g({ name: "list" }), children: "Về danh sách" }),
3048
+ /* @__PURE__ */ e("button", { style: s.btnPrimary, onClick: () => g({ name: "add" }), children: "Thêm kênh khác" })
2900
3049
  ] })
2901
3050
  ] })
2902
3051
  ] }),
2903
- w.name === "oauth-waiting" && /* @__PURE__ */ n(ie, { children: [
3052
+ w.name === "oauth-waiting" && /* @__PURE__ */ n(ne, { children: [
2904
3053
  /* @__PURE__ */ e("div", { style: s.header, children: /* @__PURE__ */ n("div", { style: s.headerLeft, children: [
2905
- /* @__PURE__ */ e("button", { style: s.backBtn, onClick: ee, children: /* @__PURE__ */ e(Be, {}) }),
3054
+ /* @__PURE__ */ e("button", { style: s.backBtn, onClick: k, children: /* @__PURE__ */ e(Ae, {}) }),
2906
3055
  /* @__PURE__ */ n("div", { children: [
2907
3056
  /* @__PURE__ */ n("div", { style: s.title, children: [
2908
3057
  "Đang xác thực ",
2909
- Ue[w.provider]
3058
+ qe[w.provider]
2910
3059
  ] }),
2911
3060
  /* @__PURE__ */ e("div", { style: s.subtitle, children: "Vui lòng hoàn thành trong cửa sổ bật lên" })
2912
3061
  ] })
2913
3062
  ] }) }),
2914
3063
  /* @__PURE__ */ n("div", { style: s.oauthWaiting, children: [
2915
3064
  /* @__PURE__ */ n("div", { style: { position: "relative", width: 72, height: 72 }, children: [
2916
- /* @__PURE__ */ e("div", { style: { width: 72, height: 72, borderRadius: 20, background: un[w.provider] ?? "#f1f5f9", display: "flex", alignItems: "center", justifyContent: "center" }, children: /* @__PURE__ */ e(xe, { provider: w.provider, apiUrl: o, size: 48 }) }),
3065
+ /* @__PURE__ */ e("div", { style: { width: 72, height: 72, borderRadius: 20, background: In[w.provider] ?? "#f1f5f9", display: "flex", alignItems: "center", justifyContent: "center" }, children: /* @__PURE__ */ e(Ce, { provider: w.provider, apiUrl: r, size: 48 }) }),
2917
3066
  /* @__PURE__ */ n(
2918
3067
  "svg",
2919
3068
  {
@@ -2942,21 +3091,21 @@ https://www.myshop.com`,
2942
3091
  ] }),
2943
3092
  /* @__PURE__ */ n("div", { style: s.oauthTitle, children: [
2944
3093
  "Đang chờ xác thực với ",
2945
- Ue[w.provider]
3094
+ qe[w.provider]
2946
3095
  ] }),
2947
3096
  /* @__PURE__ */ e("div", { style: s.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." }),
2948
3097
  /* @__PURE__ */ n("div", { style: { display: "flex", flexDirection: "column", gap: 8, alignItems: "flex-start", width: "100%", maxWidth: 280 }, children: [
2949
- /* @__PURE__ */ e(Qe, { done: !0, label: `Đã mở cửa sổ ${Ue[w.provider]}` }),
2950
- /* @__PURE__ */ e(Qe, { active: !0, label: "Đang chờ bạn đăng nhập & cấp quyền" }),
2951
- /* @__PURE__ */ e(Qe, { label: "Lưu kết nối & quay về" })
3098
+ /* @__PURE__ */ e(lt, { done: !0, label: `Đã mở cửa sổ ${qe[w.provider]}` }),
3099
+ /* @__PURE__ */ e(lt, { active: !0, label: "Đang chờ bạn đăng nhập & cấp quyền" }),
3100
+ /* @__PURE__ */ e(lt, { label: "Lưu kết nối & quay về" })
2952
3101
  ] }),
2953
- /* @__PURE__ */ e("button", { style: s.oauthCancel, onClick: ee, children: "Hủy và quay lại" })
3102
+ /* @__PURE__ */ e("button", { style: s.oauthCancel, onClick: k, children: "Hủy và quay lại" })
2954
3103
  ] })
2955
3104
  ] }),
2956
- w.name === "oauth-select" && /* @__PURE__ */ n(ie, { children: [
3105
+ w.name === "oauth-select" && /* @__PURE__ */ n(ne, { children: [
2957
3106
  /* @__PURE__ */ n("div", { style: s.connectHeader, children: [
2958
- /* @__PURE__ */ e("button", { style: s.backBtn, onClick: ee, children: /* @__PURE__ */ e(Be, {}) }),
2959
- /* @__PURE__ */ e(xe, { provider: w.provider, apiUrl: o, size: 44 }),
3107
+ /* @__PURE__ */ e("button", { style: s.backBtn, onClick: k, children: /* @__PURE__ */ e(Ae, {}) }),
3108
+ /* @__PURE__ */ e(Ce, { provider: w.provider, apiUrl: r, size: 44 }),
2960
3109
  /* @__PURE__ */ n("div", { children: [
2961
3110
  /* @__PURE__ */ n("div", { style: s.connectTitle, children: [
2962
3111
  "Chọn ",
@@ -2964,16 +3113,16 @@ https://www.myshop.com`,
2964
3113
  ] }),
2965
3114
  /* @__PURE__ */ n("div", { style: s.connectDesc, children: [
2966
3115
  "Chọn ",
2967
- Ue[w.provider],
3116
+ qe[w.provider],
2968
3117
  " bạn muốn kết nối với ChannelHub"
2969
3118
  ] })
2970
3119
  ] })
2971
3120
  ] }),
2972
- /* @__PURE__ */ e("div", { style: s.body, children: w.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: w.pages.map((c) => /* @__PURE__ */ n(
3121
+ /* @__PURE__ */ e("div", { style: s.body, children: w.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: w.pages.map((h) => /* @__PURE__ */ n(
2973
3122
  "button",
2974
3123
  {
2975
- disabled: A,
2976
- onClick: () => void se(c.id),
3124
+ disabled: E,
3125
+ onClick: () => void ie(h.id),
2977
3126
  style: {
2978
3127
  display: "flex",
2979
3128
  alignItems: "center",
@@ -2982,96 +3131,152 @@ https://www.myshop.com`,
2982
3131
  borderRadius: 12,
2983
3132
  border: "1.5px solid #e2e8f0",
2984
3133
  background: "#fff",
2985
- cursor: A ? "not-allowed" : "pointer",
2986
- opacity: A ? 0.6 : 1,
3134
+ cursor: E ? "not-allowed" : "pointer",
3135
+ opacity: E ? 0.6 : 1,
2987
3136
  textAlign: "left",
2988
3137
  fontFamily: "inherit",
2989
3138
  transition: "border-color .15s, background .15s"
2990
3139
  },
2991
3140
  children: [
2992
3141
  /* @__PURE__ */ n("div", { children: [
2993
- /* @__PURE__ */ e("div", { style: { fontSize: 14, fontWeight: 600, color: "#0f172a" }, children: c.name }),
2994
- /* @__PURE__ */ e("div", { style: { fontSize: 11, color: "#94a3b8", fontFamily: "monospace", marginTop: 2 }, children: c.id })
3142
+ /* @__PURE__ */ e("div", { style: { fontSize: 14, fontWeight: 600, color: "#0f172a" }, children: h.name }),
3143
+ /* @__PURE__ */ e("div", { style: { fontSize: 11, color: "#94a3b8", fontFamily: "monospace", marginTop: 2 }, children: h.id })
2995
3144
  ] }),
2996
- /* @__PURE__ */ e("span", { style: { fontSize: 13, color: "#2563eb", fontWeight: 500 }, children: A ? "Đang kết nối…" : "Chọn →" })
3145
+ /* @__PURE__ */ e("span", { style: { fontSize: 13, color: "#2563eb", fontWeight: 500 }, children: E ? "Đang kết nối…" : "Chọn →" })
2997
3146
  ]
2998
3147
  },
2999
- c.id
3148
+ h.id
3000
3149
  )) }) })
3001
3150
  ] })
3002
3151
  ] });
3003
3152
  }
3004
- function mn(t) {
3153
+ function $n(t) {
3005
3154
  const i = t.metadata;
3006
3155
  if (typeof i.pictureUrl == "string") return i.pictureUrl;
3007
3156
  if (t.provider === "facebook")
3008
3157
  return `https://graph.facebook.com/${t.externalAccountId}/picture?type=square`;
3009
3158
  if (t.provider === "instagram") {
3010
- const r = typeof i.pageId == "string" ? i.pageId : null;
3011
- if (r) return `https://graph.facebook.com/${r}/picture?type=square`;
3159
+ const o = typeof i.pageId == "string" ? i.pageId : null;
3160
+ if (o) return `https://graph.facebook.com/${o}/picture?type=square`;
3012
3161
  }
3013
3162
  return null;
3014
3163
  }
3015
- function xn({ conn: t, apiUrl: i, size: r = 40 }) {
3016
- const [o, h] = y(!1), S = mn(t), m = Math.round(r * 0.28);
3017
- return S && !o ? /* @__PURE__ */ e(
3164
+ function Bn({ conn: t, apiUrl: i, size: o = 40 }) {
3165
+ const [r, c] = u(!1), C = $n(t), y = Math.round(o * 0.28);
3166
+ return C && !r ? /* @__PURE__ */ e(
3018
3167
  "img",
3019
3168
  {
3020
- src: S,
3021
- alt: ct(t),
3169
+ src: C,
3170
+ alt: mt(t),
3022
3171
  referrerPolicy: "no-referrer",
3023
- onError: () => h(!0),
3024
- style: { width: r, height: r, borderRadius: m, objectFit: "cover", flexShrink: 0, display: "block" }
3172
+ onError: () => c(!0),
3173
+ style: { width: o, height: o, borderRadius: y, objectFit: "cover", flexShrink: 0, display: "block" }
3025
3174
  }
3026
- ) : /* @__PURE__ */ e(xe, { provider: t.provider, apiUrl: i, size: r });
3175
+ ) : /* @__PURE__ */ e(Ce, { provider: t.provider, apiUrl: i, size: o });
3027
3176
  }
3028
- function vn({ conn: t, apiUrl: i, onDisconnect: r }) {
3029
- const [o, h] = y(!1);
3030
- return /* @__PURE__ */ n("div", { style: s.channelItem, children: [
3031
- /* @__PURE__ */ e(xn, { conn: t, apiUrl: i, size: 40 }),
3032
- /* @__PURE__ */ n("div", { style: s.channelInfo, children: [
3033
- /* @__PURE__ */ e("div", { style: s.channelName, children: ct(t) }),
3034
- /* @__PURE__ */ e("div", { style: s.channelMeta, children: fn(t) })
3177
+ function Ln({ conn: t, apiUrl: i, onDisconnect: o }) {
3178
+ const [r, c] = u(!1), [C, y] = u(!1), [L, w] = u(!1), g = t.provider === "livechat", $ = i.replace(/\/$/, ""), T = g ? `<script src="${$}/static/livechat.js" data-widget-id="${t.id}" defer><\/script>` : null, E = () => {
3179
+ T && navigator.clipboard.writeText(T).then(() => {
3180
+ w(!0), setTimeout(() => w(!1), 2e3);
3181
+ });
3182
+ };
3183
+ return /* @__PURE__ */ n("div", { style: { ...s.channelItem, flexDirection: "column", alignItems: "stretch", gap: 0 }, children: [
3184
+ /* @__PURE__ */ n("div", { style: { display: "flex", alignItems: "center", gap: 12 }, children: [
3185
+ /* @__PURE__ */ e(Bn, { conn: t, apiUrl: i, size: 40 }),
3186
+ /* @__PURE__ */ n("div", { style: s.channelInfo, children: [
3187
+ /* @__PURE__ */ e("div", { style: s.channelName, children: mt(t) }),
3188
+ /* @__PURE__ */ e("div", { style: { ...s.channelMeta, userSelect: "text" }, children: zn(t) })
3189
+ ] }),
3190
+ /* @__PURE__ */ n("div", { style: s.channelActions, children: [
3191
+ /* @__PURE__ */ e("span", { style: t.status === "active" ? s.badgeActive : s.badgeInactive, children: t.status === "active" ? "Hoạt động" : t.status }),
3192
+ g && /* @__PURE__ */ e(
3193
+ "button",
3194
+ {
3195
+ style: {
3196
+ ...s.disconnectBtn,
3197
+ ...C ? { background: "#ede9fe", borderColor: "#c4b5fd", color: "#7c3aed" } : {}
3198
+ },
3199
+ onClick: () => y((M) => !M),
3200
+ children: "Mã nhúng"
3201
+ }
3202
+ ),
3203
+ /* @__PURE__ */ e(
3204
+ "button",
3205
+ {
3206
+ style: {
3207
+ ...s.disconnectBtn,
3208
+ ...r ? { background: "#fef2f2", borderColor: "#fca5a5", color: "#dc2626" } : {}
3209
+ },
3210
+ onMouseEnter: () => c(!0),
3211
+ onMouseLeave: () => c(!1),
3212
+ onClick: o,
3213
+ children: "Ngắt kết nối"
3214
+ }
3215
+ )
3216
+ ] })
3035
3217
  ] }),
3036
- /* @__PURE__ */ n("div", { style: s.channelActions, children: [
3037
- /* @__PURE__ */ e("span", { style: t.status === "active" ? s.badgeActive : s.badgeInactive, children: t.status === "active" ? "Hoạt động" : t.status }),
3038
- /* @__PURE__ */ e(
3039
- "button",
3040
- {
3041
- style: {
3042
- ...s.disconnectBtn,
3043
- ...o ? { background: "#fef2f2", borderColor: "#fca5a5", color: "#dc2626" } : {}
3044
- },
3045
- onMouseEnter: () => h(!0),
3046
- onMouseLeave: () => h(!1),
3047
- onClick: r,
3048
- children: "Ngắt kết nối"
3049
- }
3050
- )
3218
+ g && C && T && /* @__PURE__ */ n("div", { style: { marginTop: 10, borderTop: "1px solid #f1f5f9", paddingTop: 10 }, children: [
3219
+ /* @__PURE__ */ e("div", { style: { fontSize: 11, fontWeight: 600, color: "#7c3aed", marginBottom: 6, textTransform: "uppercase", letterSpacing: "0.05em" }, children: "Mã nhúng — dán vào trước thẻ </body>" }),
3220
+ /* @__PURE__ */ n("div", { style: { position: "relative" }, children: [
3221
+ /* @__PURE__ */ e("pre", { style: {
3222
+ margin: 0,
3223
+ padding: "10px 12px",
3224
+ background: "#f8f7ff",
3225
+ border: "1px solid #e9d5ff",
3226
+ borderRadius: 8,
3227
+ fontSize: 12,
3228
+ color: "#3b0764",
3229
+ overflowX: "auto",
3230
+ fontFamily: "ui-monospace, SFMono-Regular, monospace",
3231
+ lineHeight: 1.5,
3232
+ userSelect: "text"
3233
+ }, children: T }),
3234
+ /* @__PURE__ */ e(
3235
+ "button",
3236
+ {
3237
+ onClick: E,
3238
+ style: {
3239
+ position: "absolute",
3240
+ top: 6,
3241
+ right: 6,
3242
+ fontSize: 11,
3243
+ fontWeight: 600,
3244
+ padding: "3px 10px",
3245
+ borderRadius: 6,
3246
+ border: "1px solid",
3247
+ borderColor: L ? "#059669" : "#c4b5fd",
3248
+ background: L ? "#d1fae5" : "#fff",
3249
+ color: L ? "#059669" : "#7c3aed",
3250
+ cursor: "pointer"
3251
+ },
3252
+ children: L ? "✓ Đã sao chép" : "Sao chép"
3253
+ }
3254
+ )
3255
+ ] })
3051
3256
  ] })
3052
3257
  ] });
3053
3258
  }
3054
- const kn = [
3259
+ const Mn = [
3055
3260
  { id: "facebook", name: "Facebook", desc: "Fanpage & Messenger", type: "oauth" },
3056
3261
  { id: "zalo", name: "Zalo OA", desc: "Official Account", type: "oauth" },
3057
3262
  { id: "instagram", name: "Instagram", desc: "DM & Comments", type: "oauth" },
3058
3263
  { id: "telegram", name: "Telegram", desc: "Bot token", type: "token" },
3059
3264
  { id: "livechat", name: "Live Chat", desc: "Website widget", type: "livechat" }
3060
3265
  ];
3061
- function wn({ provider: t, apiUrl: i, onClick: r }) {
3062
- const [o, h] = y(!1);
3266
+ function Hn({ provider: t, apiUrl: i, onClick: o }) {
3267
+ const [r, c] = u(!1);
3063
3268
  return /* @__PURE__ */ n(
3064
3269
  "div",
3065
3270
  {
3066
3271
  style: {
3067
3272
  ...s.providerCard,
3068
- ...o ? { background: "#fff", borderColor: "#e2e8f0", boxShadow: "0 2px 8px rgba(0,0,0,.07)", transform: "translateY(-1px)" } : {}
3273
+ ...r ? { background: "#fff", borderColor: "#e2e8f0", boxShadow: "0 2px 8px rgba(0,0,0,.07)", transform: "translateY(-1px)" } : {}
3069
3274
  },
3070
- onClick: r,
3071
- onMouseEnter: () => h(!0),
3072
- onMouseLeave: () => h(!1),
3275
+ onClick: o,
3276
+ onMouseEnter: () => c(!0),
3277
+ onMouseLeave: () => c(!1),
3073
3278
  children: [
3074
- /* @__PURE__ */ e(xe, { provider: t.id, apiUrl: i, size: 44 }),
3279
+ /* @__PURE__ */ e(Ce, { provider: t.id, apiUrl: i, size: 44 }),
3075
3280
  /* @__PURE__ */ n("div", { children: [
3076
3281
  /* @__PURE__ */ e("div", { style: s.providerName, children: t.name }),
3077
3282
  /* @__PURE__ */ e("div", { style: s.providerDesc, children: t.desc })
@@ -3080,7 +3285,7 @@ function wn({ provider: t, apiUrl: i, onClick: r }) {
3080
3285
  }
3081
3286
  );
3082
3287
  }
3083
- function Qe({ done: t, active: i, label: r }) {
3288
+ function lt({ done: t, active: i, label: o }) {
3084
3289
  return /* @__PURE__ */ n("div", { style: { display: "flex", alignItems: "center", gap: 10, fontSize: 13, color: t ? "#059669" : i ? "#0f172a" : "#94a3b8" }, children: [
3085
3290
  /* @__PURE__ */ e("div", { style: {
3086
3291
  width: 10,
@@ -3090,60 +3295,60 @@ function Qe({ done: t, active: i, label: r }) {
3090
3295
  flexShrink: 0,
3091
3296
  ...i ? { boxShadow: "0 0 0 3px rgba(37,99,235,.2)" } : {}
3092
3297
  } }),
3093
- r
3298
+ o
3094
3299
  ] });
3095
3300
  }
3096
- function Sn(t) {
3301
+ function An(t) {
3097
3302
  return t.split(/\s+/).filter(Boolean).slice(-2).map((i) => i[0]).join("").toUpperCase() || "?";
3098
3303
  }
3099
- function Cn(t) {
3304
+ function jn(t) {
3100
3305
  if (!t) return "";
3101
3306
  const i = new Date(t);
3102
3307
  return i.toDateString() === (/* @__PURE__ */ new Date()).toDateString() ? i.toLocaleTimeString("vi-VN", { hour: "2-digit", minute: "2-digit" }) : i.toLocaleDateString("vi-VN", { day: "2-digit", month: "2-digit" });
3103
3308
  }
3104
- function Bn({
3309
+ function Fn({
3105
3310
  apiUrl: t,
3106
3311
  token: i,
3107
- theme: r,
3108
- locale: o = "vi",
3109
- icon: h,
3110
- onConversationSelect: S
3312
+ theme: o,
3313
+ locale: r = "vi",
3314
+ icon: c,
3315
+ onConversationSelect: C
3111
3316
  }) {
3112
- const m = (r == null ? void 0 : r.primaryColor) ?? "#2563eb", M = typeof h == "function" ? h({ size: 20, color: "currentColor" }) : h ?? /* @__PURE__ */ e(pt, { size: 20, strokeWidth: 1.8 }), w = J(new it(t, i)), [v, W] = y(!1), [T, A] = y([]), $ = J(null), C = J(null), D = T.filter((B) => (B.unreadCount ?? 0) > 0), I = D.reduce((B, x) => B + (x.unreadCount ?? 0), 0), L = we(async () => {
3317
+ const y = (o == null ? void 0 : o.primaryColor) ?? "#2563eb", L = typeof c == "function" ? c({ size: 20, color: "currentColor" }) : c ?? /* @__PURE__ */ e(St, { size: 20, strokeWidth: 1.8 }), w = X(new ht(t, i)), [g, $] = u(!1), [T, E] = u([]), M = X(null), I = X(null), q = T.filter((B) => (B.unreadCount ?? 0) > 0), R = q.reduce((B, b) => B + (b.unreadCount ?? 0), 0), H = Te(async () => {
3113
3318
  try {
3114
3319
  const B = await w.current.listConversations();
3115
- A(B.items);
3320
+ E(B.items);
3116
3321
  } catch {
3117
3322
  }
3118
3323
  }, []);
3119
- X(() => (L(), w.current.connectSSE((x) => {
3120
- (x === "message.new" || x === "conversation.updated") && L();
3121
- })), [L]), X(() => {
3122
- if (!v) return;
3123
- const B = (x) => {
3124
- var b, E;
3125
- (b = $.current) != null && b.contains(x.target) || (E = C.current) != null && E.contains(x.target) || W(!1);
3324
+ K(() => (H(), w.current.connectSSE((b) => {
3325
+ (b === "message.new" || b === "conversation.updated") && H();
3326
+ })), [H]), K(() => {
3327
+ if (!g) return;
3328
+ const B = (b) => {
3329
+ var S, D;
3330
+ (S = M.current) != null && S.contains(b.target) || (D = I.current) != null && D.contains(b.target) || $(!1);
3126
3331
  };
3127
3332
  return document.addEventListener("mousedown", B), () => document.removeEventListener("mousedown", B);
3128
- }, [v]);
3129
- const P = async (B) => {
3130
- if (W(!1), S == null || S(B.id, B), (B.unreadCount ?? 0) > 0)
3333
+ }, [g]);
3334
+ const J = async (B) => {
3335
+ if ($(!1), C == null || C(B.id, B), (B.unreadCount ?? 0) > 0)
3131
3336
  try {
3132
- await w.current.markRead(B.id), A(
3133
- (x) => x.map((b) => b.id === B.id ? { ...b, unreadCount: 0 } : b)
3337
+ await w.current.markRead(B.id), E(
3338
+ (b) => b.map((S) => S.id === B.id ? { ...S, unreadCount: 0 } : S)
3134
3339
  );
3135
3340
  } catch {
3136
3341
  }
3137
- }, q = o === "en" ? `${I} unread message${I !== 1 ? "s" : ""}` : `${I} tin nhắn chưa đọc`, te = o === "en" ? "No unread messages" : "Không có tin nhắn mới", Q = o === "en" ? "Messages" : "Tin nhắn";
3138
- return /* @__PURE__ */ n("div", { style: { position: "relative", display: "inline-block", fontFamily: (r == null ? void 0 : r.fontFamily) ?? "Inter, ui-sans-serif, system-ui, sans-serif" }, children: [
3342
+ }, F = r === "en" ? `${R} unread message${R !== 1 ? "s" : ""}` : `${R} tin nhắn chưa đọc`, re = r === "en" ? "No unread messages" : "Không có tin nhắn mới", V = r === "en" ? "Messages" : "Tin nhắn";
3343
+ return /* @__PURE__ */ n("div", { style: { position: "relative", display: "inline-block", fontFamily: (o == null ? void 0 : o.fontFamily) ?? "Inter, ui-sans-serif, system-ui, sans-serif" }, children: [
3139
3344
  /* @__PURE__ */ n(
3140
3345
  "button",
3141
3346
  {
3142
- ref: $,
3143
- "aria-label": q,
3347
+ ref: M,
3348
+ "aria-label": F,
3144
3349
  "aria-haspopup": "true",
3145
- "aria-expanded": v,
3146
- onClick: () => W((B) => !B),
3350
+ "aria-expanded": g,
3351
+ onClick: () => $((B) => !B),
3147
3352
  style: {
3148
3353
  position: "relative",
3149
3354
  display: "inline-grid",
@@ -3152,14 +3357,14 @@ function Bn({
3152
3357
  height: 40,
3153
3358
  border: 0,
3154
3359
  borderRadius: "50%",
3155
- background: v ? `${m}18` : "transparent",
3156
- color: v ? m : "#6b7280",
3360
+ background: g ? `${y}18` : "transparent",
3361
+ color: g ? y : "#6b7280",
3157
3362
  cursor: "pointer",
3158
3363
  transition: "background 150ms ease, color 150ms ease"
3159
3364
  },
3160
3365
  children: [
3161
- M,
3162
- I > 0 && /* @__PURE__ */ e(
3366
+ L,
3367
+ R > 0 && /* @__PURE__ */ e(
3163
3368
  "span",
3164
3369
  {
3165
3370
  "aria-hidden": "true",
@@ -3180,18 +3385,18 @@ function Bn({
3180
3385
  border: "2px solid #fff",
3181
3386
  boxSizing: "border-box"
3182
3387
  },
3183
- children: I > 99 ? "99+" : I
3388
+ children: R > 99 ? "99+" : R
3184
3389
  }
3185
3390
  )
3186
3391
  ]
3187
3392
  }
3188
3393
  ),
3189
- v && /* @__PURE__ */ n(
3394
+ g && /* @__PURE__ */ n(
3190
3395
  "div",
3191
3396
  {
3192
- ref: C,
3397
+ ref: I,
3193
3398
  role: "dialog",
3194
- "aria-label": Q,
3399
+ "aria-label": V,
3195
3400
  style: {
3196
3401
  position: "absolute",
3197
3402
  top: "calc(100% + 8px)",
@@ -3215,21 +3420,21 @@ function Bn({
3215
3420
  padding: "14px 16px 10px",
3216
3421
  borderBottom: "1px solid #e7ebf2"
3217
3422
  }, children: [
3218
- /* @__PURE__ */ e("span", { style: { fontSize: 16, fontWeight: 700, color: "#172033" }, children: Q }),
3219
- I > 0 && /* @__PURE__ */ n("span", { style: {
3423
+ /* @__PURE__ */ e("span", { style: { fontSize: 16, fontWeight: 700, color: "#172033" }, children: V }),
3424
+ R > 0 && /* @__PURE__ */ n("span", { style: {
3220
3425
  fontSize: 11,
3221
3426
  fontWeight: 600,
3222
- background: `${m}14`,
3223
- color: m,
3427
+ background: `${y}14`,
3428
+ color: y,
3224
3429
  borderRadius: 999,
3225
3430
  padding: "2px 8px"
3226
3431
  }, children: [
3227
- I,
3432
+ R,
3228
3433
  " ",
3229
- o === "en" ? "unread" : "chưa đọc"
3434
+ r === "en" ? "unread" : "chưa đọc"
3230
3435
  ] })
3231
3436
  ] }),
3232
- /* @__PURE__ */ e("div", { style: { overflowY: "auto", flex: 1 }, children: D.length === 0 ? /* @__PURE__ */ n("div", { style: {
3437
+ /* @__PURE__ */ e("div", { style: { overflowY: "auto", flex: 1 }, children: q.length === 0 ? /* @__PURE__ */ n("div", { style: {
3233
3438
  display: "flex",
3234
3439
  flexDirection: "column",
3235
3440
  alignItems: "center",
@@ -3237,15 +3442,15 @@ function Bn({
3237
3442
  padding: "40px 24px",
3238
3443
  color: "#9aa5b5"
3239
3444
  }, children: [
3240
- /* @__PURE__ */ e(pt, { size: 28, strokeWidth: 1.5 }),
3241
- /* @__PURE__ */ e("span", { style: { fontSize: 13 }, children: te })
3242
- ] }) : D.map((B) => /* @__PURE__ */ e(
3243
- In,
3445
+ /* @__PURE__ */ e(St, { size: 28, strokeWidth: 1.5 }),
3446
+ /* @__PURE__ */ e("span", { style: { fontSize: 13 }, children: re })
3447
+ ] }) : q.map((B) => /* @__PURE__ */ e(
3448
+ En,
3244
3449
  {
3245
3450
  conversation: B,
3246
- primary: m,
3451
+ primary: y,
3247
3452
  apiUrl: t,
3248
- onSelect: P
3453
+ onSelect: J
3249
3454
  },
3250
3455
  B.id
3251
3456
  )) })
@@ -3254,19 +3459,19 @@ function Bn({
3254
3459
  )
3255
3460
  ] });
3256
3461
  }
3257
- function In({
3462
+ function En({
3258
3463
  conversation: t,
3259
3464
  primary: i,
3260
- apiUrl: r,
3261
- onSelect: o
3465
+ apiUrl: o,
3466
+ onSelect: r
3262
3467
  }) {
3263
- const [h, S] = y(!1), m = t.contactName ?? t.providerConversationKey, M = t.unreadCount ?? 0;
3468
+ const [c, C] = u(!1), y = t.contactName ?? t.providerConversationKey, L = t.unreadCount ?? 0;
3264
3469
  return /* @__PURE__ */ n(
3265
3470
  "button",
3266
3471
  {
3267
- onClick: () => o(t),
3268
- onMouseEnter: () => S(!0),
3269
- onMouseLeave: () => S(!1),
3472
+ onClick: () => r(t),
3473
+ onMouseEnter: () => C(!0),
3474
+ onMouseLeave: () => C(!1),
3270
3475
  style: {
3271
3476
  display: "flex",
3272
3477
  width: "100%",
@@ -3274,7 +3479,7 @@ function In({
3274
3479
  padding: "10px 16px",
3275
3480
  border: 0,
3276
3481
  borderBottom: "1px solid #f1f5f9",
3277
- background: h ? "#f7f9fc" : M > 0 ? "#f0f4ff" : "#fff",
3482
+ background: c ? "#f7f9fc" : L > 0 ? "#f0f4ff" : "#fff",
3278
3483
  textAlign: "left",
3279
3484
  cursor: "pointer",
3280
3485
  transition: "background 100ms ease",
@@ -3283,10 +3488,10 @@ function In({
3283
3488
  children: [
3284
3489
  /* @__PURE__ */ n("span", { style: { position: "relative", flex: "0 0 auto", width: 42, height: 42 }, children: [
3285
3490
  /* @__PURE__ */ e(
3286
- dt,
3491
+ bt,
3287
3492
  {
3288
3493
  src: t.contactPictureUrl,
3289
- fallback: Sn(m),
3494
+ fallback: An(y),
3290
3495
  style: {
3291
3496
  width: 42,
3292
3497
  height: 42,
@@ -3307,15 +3512,15 @@ function In({
3307
3512
  /* @__PURE__ */ n("span", { style: { display: "flex", justifyContent: "space-between", alignItems: "center", gap: 6 }, children: [
3308
3513
  /* @__PURE__ */ e("span", { style: {
3309
3514
  fontSize: 13,
3310
- fontWeight: M > 0 ? 700 : 500,
3515
+ fontWeight: L > 0 ? 700 : 500,
3311
3516
  color: "#172033",
3312
3517
  overflow: "hidden",
3313
3518
  textOverflow: "ellipsis",
3314
3519
  whiteSpace: "nowrap"
3315
- }, children: m }),
3520
+ }, children: y }),
3316
3521
  /* @__PURE__ */ n("span", { style: { display: "flex", alignItems: "center", gap: 5, flexShrink: 0 }, children: [
3317
- /* @__PURE__ */ e("time", { style: { fontSize: 11, color: "#9aa5b5", whiteSpace: "nowrap" }, children: Cn(t.lastMessageAt) }),
3318
- M > 0 && /* @__PURE__ */ e("span", { style: {
3522
+ /* @__PURE__ */ e("time", { style: { fontSize: 11, color: "#9aa5b5", whiteSpace: "nowrap" }, children: jn(t.lastMessageAt) }),
3523
+ L > 0 && /* @__PURE__ */ e("span", { style: {
3319
3524
  display: "inline-grid",
3320
3525
  placeItems: "center",
3321
3526
  minWidth: 18,
@@ -3326,15 +3531,15 @@ function In({
3326
3531
  fontSize: 10,
3327
3532
  fontWeight: 800,
3328
3533
  padding: "0 4px"
3329
- }, children: M > 99 ? "99+" : M })
3534
+ }, children: L > 99 ? "99+" : L })
3330
3535
  ] })
3331
3536
  ] }),
3332
3537
  /* @__PURE__ */ n("span", { style: {
3333
3538
  display: "block",
3334
3539
  marginTop: 2,
3335
3540
  fontSize: 12,
3336
- color: M > 0 ? "#374151" : "#9aa5b5",
3337
- fontWeight: M > 0 ? 500 : 400,
3541
+ color: L > 0 ? "#374151" : "#9aa5b5",
3542
+ fontWeight: L > 0 ? 500 : 400,
3338
3543
  overflow: "hidden",
3339
3544
  textOverflow: "ellipsis",
3340
3545
  whiteSpace: "nowrap"
@@ -3347,10 +3552,10 @@ function In({
3347
3552
  }
3348
3553
  );
3349
3554
  }
3350
- console.log("[ChannelHub] widget v0.1.10 loaded");
3555
+ console.log("[ChannelHub] widget v0.1.12 loaded");
3351
3556
  export {
3352
- $n as ChannelHubChannels,
3353
- it as ChannelHubClient,
3354
- Wn as ChannelHubInbox,
3355
- Bn as ChannelHubNotificationBell
3557
+ Pn as ChannelHubChannels,
3558
+ ht as ChannelHubClient,
3559
+ Nn as ChannelHubInbox,
3560
+ Fn as ChannelHubNotificationBell
3356
3561
  };