@channelhub/widget 0.1.10 → 0.1.11

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,5 +1,5 @@
1
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";
2
+ import { forwardRef as Pe, createElement as et, createContext as wt, useRef as J, useState as g, useMemo as $e, useEffect as X, useCallback as we, useImperativeHandle as Bt, useContext as tt, Component as Lt } from "react";
3
3
  import { createPortal as St } from "react-dom";
4
4
  /**
5
5
  * @license lucide-react v0.468.0 - ISC
@@ -31,7 +31,7 @@ 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 At = Pe(
35
35
  ({
36
36
  color: t = "currentColor",
37
37
  size: i = 24,
@@ -39,8 +39,8 @@ const jt = Pe(
39
39
  absoluteStrokeWidth: o,
40
40
  className: h = "",
41
41
  children: S,
42
- iconNode: m,
43
- ...M
42
+ iconNode: b,
43
+ ...$
44
44
  }, w) => et(
45
45
  "svg",
46
46
  {
@@ -51,10 +51,10 @@ const jt = Pe(
51
51
  stroke: t,
52
52
  strokeWidth: o ? Number(r) * 24 / Number(i) : r,
53
53
  className: Ct("lucide", h),
54
- ...M
54
+ ...$
55
55
  },
56
56
  [
57
- ...m.map(([v, W]) => et(v, W)),
57
+ ...b.map(([y, W]) => et(y, W)),
58
58
  ...Array.isArray(S) ? S : [S]
59
59
  ]
60
60
  )
@@ -67,7 +67,7 @@ const jt = Pe(
67
67
  */
68
68
  const Y = (t, i) => {
69
69
  const r = Pe(
70
- ({ className: o, ...h }, S) => et(jt, {
70
+ ({ className: o, ...h }, S) => et(At, {
71
71
  ref: S,
72
72
  iconNode: i,
73
73
  className: Ct(`lucide-${Mt(t)}`, o),
@@ -108,7 +108,7 @@ const nt = Y("ChevronDown", [
108
108
  * This source code is licensed under the ISC license.
109
109
  * See the LICENSE file in the root directory of this source tree.
110
110
  */
111
- const At = Y("ChevronRight", [
111
+ const jt = Y("ChevronRight", [
112
112
  ["path", { d: "m9 18 6-6-6-6", key: "mthhwq" }]
113
113
  ]);
114
114
  /**
@@ -139,7 +139,7 @@ const It = Y("Ellipsis", [
139
139
  * This source code is licensed under the ISC license.
140
140
  * See the LICENSE file in the root directory of this source tree.
141
141
  */
142
- const Ut = Y("Image", [
142
+ const Ot = Y("Image", [
143
143
  ["rect", { width: "18", height: "18", x: "3", y: "3", rx: "2", ry: "2", key: "1m3agn" }],
144
144
  ["circle", { cx: "9", cy: "9", r: "2", key: "af1f0g" }],
145
145
  ["path", { d: "m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21", key: "1xmnt7" }]
@@ -150,7 +150,7 @@ const Ut = Y("Image", [
150
150
  * This source code is licensed under the ISC license.
151
151
  * See the LICENSE file in the root directory of this source tree.
152
152
  */
153
- const Ot = Y("Inbox", [
153
+ const Ut = Y("Inbox", [
154
154
  ["polyline", { points: "22 12 16 12 14 15 10 15 8 12 2 12", key: "o97t9d" }],
155
155
  [
156
156
  "path",
@@ -298,7 +298,7 @@ const ft = Y("UserPlus", [
298
298
  * This source code is licensed under the ISC license.
299
299
  * See the LICENSE file in the root directory of this source tree.
300
300
  */
301
- const Oe = Y("X", [
301
+ const Ue = Y("X", [
302
302
  ["path", { d: "M18 6 6 18", key: "1bl5f8" }],
303
303
  ["path", { d: "m6 6 12 12", key: "d8bk6v" }]
304
304
  ]);
@@ -329,9 +329,9 @@ class it {
329
329
  }, S = await fetch(`${this.apiUrl}${i}`, {
330
330
  ...r,
331
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;
332
+ }), b = await S.json().catch(() => null);
333
+ if (!S.ok) throw new Error((b == null ? void 0 : b.message) ?? `Request failed (${S.status})`);
334
+ return b;
335
335
  }
336
336
  getSessionMe() {
337
337
  return this.request("/v1/auth/session/me");
@@ -398,16 +398,16 @@ class it {
398
398
  connectSSE(i) {
399
399
  const r = `${this.apiUrl}/v1/events?token=${encodeURIComponent(this.token)}`;
400
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));
401
+ const b = () => {
402
+ o = new EventSource(r), o.addEventListener("message.new", ($) => {
403
+ i("message.new", JSON.parse($.data));
404
+ }), o.addEventListener("conversation.updated", ($) => {
405
+ i("conversation.updated", JSON.parse($.data));
406
406
  }), o.onerror = () => {
407
- o.close(), S || (h = setTimeout(m, 5e3));
407
+ o.close(), S || (h = setTimeout(b, 5e3));
408
408
  };
409
409
  };
410
- return m(), () => {
410
+ return b(), () => {
411
411
  S = !0, clearTimeout(h), o == null || o.close();
412
412
  };
413
413
  }
@@ -421,7 +421,7 @@ function Xt({ variant: t = "ghost", style: i, ...r }) {
421
421
  function Yt({ style: t, ...i }) {
422
422
  return /* @__PURE__ */ e("input", { ...i, style: { width: "100%", minWidth: 0, border: 0, outline: 0, background: "transparent", font: "inherit", ...t } });
423
423
  }
424
- const Rt = Pe(
424
+ const Tt = Pe(
425
425
  ({ children: t, style: i }, r) => /* @__PURE__ */ e("div", { ref: r, style: { minHeight: 0, overflowY: "auto", overscrollBehavior: "contain", ...i }, children: t })
426
426
  ), Jt = Pe(
427
427
  function({ style: i, ...r }, o) {
@@ -469,7 +469,7 @@ const d = { ink: "#172033", muted: "#718096", line: "#e7ebf2", surface: "#f7f9fc
469
469
  { icon: "🍕", emojis: ["🍎", "🍊", "🍋", "🍇", "🍓", "🍒", "🥝", "🥑", "🍔", "🍕", "🌮", "🍜", "🍣", "🍦", "🎂", "🍰", "🧁", "☕", "🧋", "🥤", "🍺", "🥂", "🍾", "🧃", "🧊"] },
470
470
  { icon: "⚽", emojis: ["⚽", "🏀", "🏈", "⚾", "🎾", "🏐", "🏓", "🎮", "🎲", "🎯", "🎳", "🏆", "🥇", "🎖", "🎁", "🎉", "🎊", "🎈", "🎭", "🎨", "🎬", "🎵", "🎸", "🎹", "🎺", "🪗", "🎻"] },
471
471
  { icon: "🌍", emojis: ["🌍", "🌈", "⭐", "🌙", "☀️", "⛅", "🌊", "🔥", "💧", "🌿", "🌸", "🌺", "🌻", "🍀", "🌴", "🏔", "🏖", "🏕", "🌃", "🏙", "🌅", "🌄", "🌠", "🌌", "🌋", "🏝"] }
472
- ], st = wt(""), Tt = wt("");
472
+ ], st = wt(""), Rt = wt("");
473
473
  function Qt() {
474
474
  try {
475
475
  const t = new AudioContext(), i = t.createOscillator(), r = t.createGain();
@@ -506,33 +506,33 @@ function rt(t) {
506
506
  const i = t.trim().split(/\s+/).filter(Boolean);
507
507
  return i.length <= 2 ? t.trim() : i.slice(-2).join(" ");
508
508
  }
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;
509
+ const Wn = Pe(function({ apiUrl: i, token: r, theme: o, height: h, defaultConversationId: S, disableAttachments: b, disableNotificationSound: $, hideKeyboardHint: w, locale: y = "vi", extensions: W, currentAgent: z, teamAgents: j, onNewMessage: B, onConversationSelect: C }, D) {
510
+ var k, A, K, U, re;
511
+ const I = J(new it(i, r)), [M, P] = g([]), [q, te] = g([]), [Q, L] = g(), [v, x] = g(), E = J(void 0), [V, ne] = g(""), [de, T] = g("all"), [oe, Z] = g(null), [O, ee] = g({ provider: "all", unreadOnly: !1 }), [se, c] = g(!1), H = J(null), N = J(null), [ae, ce] = g(null), [ye, F] = g(!0), [he, Se] = g(""), [Me, He] = g(() => !!(W != null && W.length)), [Ae, Ce] = g(280), [ve, Ie] = g(!1), [Ne, me] = g(0), _ = (o == null ? void 0 : o.primaryColor) ?? "#2563eb", ue = $e(() => new Map(q.map((l) => [l.id, l])), [q]), ze = J(null), [Fe, je] = g(0), G = z ?? oe ?? null;
512
512
  X(() => {
513
- I.current = new it(i, r), T || I.current.getSessionMe().then((l) => {
513
+ I.current = new it(i, r), z || I.current.getSessionMe().then((l) => {
514
514
  l != null && l.agent && Z(l.agent);
515
515
  }).catch(() => {
516
516
  });
517
- }, [i, r, T]);
517
+ }, [i, r, z]);
518
518
  const Ke = $e(() => {
519
519
  var p;
520
520
  const l = /* @__PURE__ */ new Map();
521
521
  G != null && G.id && l.set(G.id, G);
522
- for (const u of A ?? [])
522
+ for (const u of j ?? [])
523
523
  u != null && u.id && !l.has(u.id) && l.set(u.id, u);
524
- for (const u of L)
524
+ for (const u of M)
525
525
  (p = u.assignedAgent) != null && p.id && !l.has(u.assignedAgent.id) && l.set(u.assignedAgent.id, u.assignedAgent);
526
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);
527
+ }, [G, j, M]), qe = we(async (l, p) => {
528
+ P((u) => u.map((R) => R.id === l.id ? { ...R, assignedAgent: p } : R)), x((u) => u && u.id === l.id ? { ...u, assignedAgent: p } : u), me((u) => u + 1);
529
529
  try {
530
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);
531
+ P((R) => R.map((le) => le.id === l.id ? { ...le, ...u, assignedAgent: u.assignedAgent ?? p } : le)), x((R) => R && R.id === l.id ? { ...R, ...u, assignedAgent: u.assignedAgent ?? p } : R), me((R) => R + 1);
532
532
  } catch {
533
533
  }
534
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);
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)), x((u) => u && u.id === l.id ? { ...u, contactExternalId: p ?? void 0 } : u), me((u) => u + 1);
536
536
  }, []), fe = we(() => {
537
537
  me((l) => l + 1);
538
538
  }, []), Ve = $e(() => {
@@ -541,14 +541,14 @@ const Wn = Pe(function({ apiUrl: i, token: r, theme: o, height: h, defaultConver
541
541
  }, [q]), Ge = $e(() => {
542
542
  var p;
543
543
  const l = {};
544
- for (const u of L) {
544
+ for (const u of M) {
545
545
  const R = ((p = ue.get(u.connectionId)) == null ? void 0 : p.provider) ?? "unknown";
546
546
  l[R] = (l[R] ?? 0) + 1;
547
547
  }
548
548
  return l;
549
- }, [L, ue]);
549
+ }, [M, ue]);
550
550
  function Ze(l) {
551
- const p = l.clientX, u = je;
551
+ const p = l.clientX, u = Ae;
552
552
  Ie(!0), document.body.style.cursor = "col-resize", document.body.style.userSelect = "none";
553
553
  function R(We) {
554
554
  const Ee = Math.max(200, Math.min(480, u + (p - We.clientX)));
@@ -562,7 +562,7 @@ const Wn = Pe(function({ apiUrl: i, token: r, theme: o, height: h, defaultConver
562
562
  const pe = we(async (l) => {
563
563
  try {
564
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("");
565
+ P((u) => l ? [...u, ...p.items] : p.items), L(p.nextCursor), !l && p.items.length && x((u) => u ?? (S ? p.items.find((R) => R.id === S) ?? p.items[0] : p.items[0])), Se("");
566
566
  } catch (p) {
567
567
  Se(p instanceof Error ? p.message : "Không tải được hội thoại");
568
568
  } finally {
@@ -574,22 +574,22 @@ const Wn = Pe(function({ apiUrl: i, token: r, theme: o, height: h, defaultConver
574
574
  if (p === "message.new" || p === "conversation.updated") {
575
575
  if (pe(), p === "message.new") {
576
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) {
577
+ if ((R.direction ? String(R.direction) : "") === "inbound" && !$ && Qt(), le && le === E.current && We && ze.current) {
578
578
  const Xe = ze.current;
579
579
  I.current.getMessage(We).then((Ye) => {
580
580
  Xe(Ye);
581
581
  }).catch(() => {
582
582
  });
583
583
  }
584
- $ == null || $(le || E.current || "");
584
+ B == null || B(le || E.current || "");
585
585
  }
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(() => {
586
+ } else p === "message.status_updated" && je((R) => R + 1);
587
+ })), [pe, B]), X(() => {
588
+ E.current = v == null ? void 0 : v.id;
589
+ }, [v]), X(() => {
590
+ v != null && v.unreadCount && I.current.markRead(v.id).then(() => pe()).catch(() => {
591
591
  });
592
- }, [x == null ? void 0 : x.id]), X(() => {
592
+ }, [v == null ? void 0 : v.id]), X(() => {
593
593
  if (!se) return;
594
594
  function l(p) {
595
595
  var u, R;
@@ -598,23 +598,23 @@ const Wn = Pe(function({ apiUrl: i, token: r, theme: o, height: h, defaultConver
598
598
  return document.addEventListener("mousedown", l), () => document.removeEventListener("mousedown", l);
599
599
  }, [se]);
600
600
  const be = $e(() => {
601
- const l = G ? L.filter((u) => {
601
+ const l = G ? M.filter((u) => {
602
602
  var R;
603
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(() => {
604
+ }).length : 0, p = M.filter((u) => !u.assignedAgent).length;
605
+ return { all: M.length, mine: l, unassigned: p };
606
+ }, [M, G]), Te = $e(() => {
607
607
  const l = V.toLowerCase().trim();
608
- return L.filter((p) => {
608
+ return M.filter((p) => {
609
609
  var Ee, Xe, Ye;
610
610
  if (de === "mine") {
611
611
  if (!G || ((Ee = p.assignedAgent) == null ? void 0 : Ee.id) !== G.id) return !1;
612
612
  } else if (de === "unassigned" && p.assignedAgent)
613
613
  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;
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 = O.provider === "all" || R === O.provider, We = !O.unreadOnly || (p.unreadCount ?? 0) > 0;
615
615
  return le && We && (!l || u.includes(l));
616
616
  });
617
- }, [L, ue, U, V, de, G]), Te = U.provider !== "all" || U.unreadOnly, a = v === "en" ? {
617
+ }, [M, ue, O, V, de, G]), Re = O.provider !== "all" || O.unreadOnly, a = y === "en" ? {
618
618
  today: "TODAY",
619
619
  loadOlder: "↑ Load older messages",
620
620
  loading: "Loading messages…",
@@ -637,31 +637,31 @@ const Wn = Pe(function({ apiUrl: i, token: r, theme: o, height: h, defaultConver
637
637
  };
638
638
  Bt(D, () => ({
639
639
  openConversation: (l) => {
640
- const p = L.find((u) => u.id === l);
641
- p && b(p);
640
+ const p = M.find((u) => u.id === l);
641
+ p && x(p);
642
642
  },
643
643
  refresh: () => void pe()
644
- }), [L, pe]);
645
- const g = {
644
+ }), [M, pe]);
645
+ const m = {
646
646
  ...f.frame,
647
647
  height: h ?? 620,
648
648
  ...h ? { maxHeight: "none" } : {},
649
649
  fontFamily: (o == null ? void 0 : o.fontFamily) ?? "Inter, ui-sans-serif, system-ui, sans-serif",
650
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)",
651
+ gridTemplateColumns: Me ? `minmax(260px, 300px) minmax(0, 1fr) ${Ae}px` : "minmax(260px, 300px) minmax(0, 1fr)",
652
652
  transition: ve ? "none" : "grid-template-columns 220ms ease"
653
653
  };
654
654
  return ye ? /* @__PURE__ */ n("div", { style: { ...f.state, borderRadius: (o == null ? void 0 : o.borderRadius) ?? "16px" }, children: [
655
655
  /* @__PURE__ */ e(ot, {}),
656
656
  " Đ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: [
657
+ ] }) : he && !M.length ? /* @__PURE__ */ n("div", { style: { ...f.state, color: "#b42318", borderRadius: (o == null ? void 0 : o.borderRadius) ?? "16px" }, children: [
658
658
  /* @__PURE__ */ e(Et, { size: 16, strokeWidth: 2 }),
659
659
  " ",
660
660
  he,
661
661
  /* @__PURE__ */ e("button", { style: f.retry, onClick: () => {
662
662
  F(!0), pe();
663
663
  }, 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: () => {
664
+ ] }) : /* @__PURE__ */ e(st.Provider, { value: i, children: /* @__PURE__ */ e(Rt.Provider, { value: r, children: /* @__PURE__ */ n("div", { style: m, onFocusCapture: () => {
665
665
  const l = window.scrollY;
666
666
  requestAnimationFrame(() => {
667
667
  window.scrollY !== l && window.scrollTo({ top: l, behavior: "instant" });
@@ -669,10 +669,10 @@ const Wn = Pe(function({ apiUrl: i, token: r, theme: o, height: h, defaultConver
669
669
  }, children: [
670
670
  /* @__PURE__ */ n("aside", { style: f.sidebar, children: [
671
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" }),
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" } }) : ((A = o == null ? void 0 : o.branding) == null ? void 0 : A.mark) ?? "C" }),
673
673
  /* @__PURE__ */ n("div", { children: [
674
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" })
675
+ !((U = o == null ? void 0 : o.branding) != null && U.name) && /* @__PURE__ */ e("span", { style: f.eyebrow, children: "CHANNELHUB" })
676
676
  ] }),
677
677
  /* @__PURE__ */ e(Xt, { "aria-label": "Tùy chọn", style: f.iconButton, children: /* @__PURE__ */ e(It, { size: 16, strokeWidth: 2 }) })
678
678
  ] }),
@@ -697,9 +697,9 @@ const Wn = Pe(function({ apiUrl: i, token: r, theme: o, height: h, defaultConver
697
697
  background: d.surface
698
698
  },
699
699
  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 }
700
+ { key: "all", label: y === "en" ? "All" : "Tất cả", count: be.all },
701
+ { key: "mine", label: y === "en" ? "Mine" : "Của tôi", count: be.mine },
702
+ { key: "unassigned", label: y === "en" ? "Unassigned" : "Chưa nhận", count: be.unassigned }
703
703
  ].map((l) => {
704
704
  const p = de === l.key;
705
705
  return /* @__PURE__ */ n(
@@ -708,7 +708,7 @@ const Wn = Pe(function({ apiUrl: i, token: r, theme: o, height: h, defaultConver
708
708
  type: "button",
709
709
  role: "tab",
710
710
  "aria-selected": p,
711
- onClick: () => z(l.key),
711
+ onClick: () => T(l.key),
712
712
  style: {
713
713
  border: 0,
714
714
  borderRadius: 6,
@@ -739,28 +739,28 @@ const Wn = Pe(function({ apiUrl: i, token: r, theme: o, height: h, defaultConver
739
739
  })
740
740
  }
741
741
  ),
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 }) })
742
+ Re && /* @__PURE__ */ n("div", { style: { display: "flex", gap: 4, flexWrap: "wrap", padding: "0 14px 8px" }, children: [
743
+ O.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: O.provider }),
745
+ yt(O.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(Ue, { size: 10 }) })
747
747
  ] }),
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: [
748
+ O.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
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 }) })
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(Ue, { size: 10 }) })
751
751
  ] }),
752
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ả" })
753
753
  ] }),
754
754
  /* @__PURE__ */ n("div", { style: f.listHeader, children: [
755
755
  /* @__PURE__ */ n("span", { children: [
756
- Re.length,
756
+ Te.length,
757
757
  " hội thoại"
758
758
  ] }),
759
759
  /* @__PURE__ */ e(
760
760
  "button",
761
761
  {
762
762
  ref: H,
763
- style: { ...f.iconButton, background: Te ? `${_}14` : "transparent", color: Te ? _ : d.muted },
763
+ style: { ...f.iconButton, background: Re ? `${_}14` : "transparent", color: Re ? _ : d.muted },
764
764
  "aria-label": "Bộ lọc",
765
765
  onClick: () => {
766
766
  var l;
@@ -782,12 +782,12 @@ const Wn = Pe(function({ apiUrl: i, token: r, theme: o, height: h, defaultConver
782
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 },
783
783
  children: [
784
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: _ } }),
785
+ ["all", ...Ve].map((l) => /* @__PURE__ */ n("label", { style: { display: "flex", alignItems: "center", gap: 8, padding: "5px 6px", cursor: "pointer", borderRadius: 6, background: O.provider === l ? `${_}0f` : "transparent" }, children: [
786
+ /* @__PURE__ */ e("input", { type: "radio", name: "provider-filter", checked: O.provider === l, onChange: () => ee((p) => ({ ...p, provider: l })), style: { accentColor: _ } }),
787
787
  l === "all" ? /* @__PURE__ */ n("span", { style: { color: d.ink }, children: [
788
788
  a.all,
789
789
  " (",
790
- L.length,
790
+ M.length,
791
791
  ")"
792
792
  ] }) : /* @__PURE__ */ n("span", { style: { display: "flex", alignItems: "center", gap: 5, color: d.ink }, children: [
793
793
  /* @__PURE__ */ e(De, { provider: l }),
@@ -801,8 +801,8 @@ const Wn = Pe(function({ apiUrl: i, token: r, theme: o, height: h, defaultConver
801
801
  ] })
802
802
  ] }, l)),
803
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: _ } }),
804
+ /* @__PURE__ */ n("label", { style: { display: "flex", alignItems: "center", gap: 8, padding: "5px 6px", cursor: "pointer", borderRadius: 6, background: O.unreadOnly ? `${_}0f` : "transparent" }, children: [
805
+ /* @__PURE__ */ e("input", { type: "checkbox", checked: O.unreadOnly, onChange: (l) => ee((p) => ({ ...p, unreadOnly: l.target.checked })), style: { accentColor: _ } }),
806
806
  /* @__PURE__ */ e("span", { style: { color: d.ink }, children: a.unreadOnly })
807
807
  ] })
808
808
  ]
@@ -810,15 +810,15 @@ const Wn = Pe(function({ apiUrl: i, token: r, theme: o, height: h, defaultConver
810
810
  ),
811
811
  document.body
812
812
  ),
813
- /* @__PURE__ */ n(Rt, { style: f.conversationList, children: [
814
- Re.map((l) => {
813
+ /* @__PURE__ */ n(Tt, { style: f.conversationList, children: [
814
+ Te.map((l) => {
815
815
  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(() => {
816
+ return /* @__PURE__ */ e(nn, { conversation: l, provider: (p = ue.get(l.connectionId)) == null ? void 0 : p.provider, selected: (v == null ? void 0 : v.id) === l.id, primary: _, currentAgent: G, onSelect: () => {
817
+ x(l), C == null || C(l.id), I.current.markRead(l.id).then(() => pe()).catch(() => {
818
818
  });
819
819
  } }, l.id);
820
820
  }),
821
- !Re.length && /* @__PURE__ */ n("div", { style: f.emptySmall, children: [
821
+ !Te.length && /* @__PURE__ */ n("div", { style: f.emptySmall, children: [
822
822
  /* @__PURE__ */ e("div", { style: f.emptyIcon, children: /* @__PURE__ */ e(ut, { size: 16, strokeWidth: 2 }) }),
823
823
  /* @__PURE__ */ e("strong", { children: "Không tìm thấy" }),
824
824
  /* @__PURE__ */ e("span", { children: "Thử từ khóa hoặc bộ lọc khác." })
@@ -826,12 +826,12 @@ const Wn = Pe(function({ apiUrl: i, token: r, theme: o, height: h, defaultConver
826
826
  Q && /* @__PURE__ */ e("button", { style: f.loadMore, onClick: () => void pe(Q), children: "Xem thêm hội thoại" })
827
827
  ] })
828
828
  ] }),
829
- /* @__PURE__ */ e("main", { style: f.main, children: x ? /* @__PURE__ */ e(
829
+ /* @__PURE__ */ e("main", { style: f.main, children: v ? /* @__PURE__ */ e(
830
830
  rn,
831
831
  {
832
- conversation: x,
833
- provider: (re = ue.get(x.connectionId)) == null ? void 0 : re.provider,
834
- connection: ue.get(x.connectionId),
832
+ conversation: v,
833
+ provider: (re = ue.get(v.connectionId)) == null ? void 0 : re.provider,
834
+ connection: ue.get(v.connectionId),
835
835
  client: I.current,
836
836
  primary: _,
837
837
  error: he,
@@ -842,62 +842,62 @@ const Wn = Pe(function({ apiUrl: i, token: r, theme: o, height: h, defaultConver
842
842
  infoOpen: Me,
843
843
  onToggleInfo: () => He((l) => !l),
844
844
  t: a,
845
- disableAttachments: m,
845
+ disableAttachments: b,
846
846
  hideKeyboardHint: w,
847
847
  extensions: W,
848
848
  currentAgent: G,
849
849
  teamAgents: Ke,
850
- onAssignAgent: (l) => qe(x, l),
851
- onLinkContact: (l) => ke(x, l),
850
+ onAssignAgent: (l) => qe(v, l),
851
+ onLinkContact: (l) => ke(v, l),
852
852
  onRefreshContactInfo: fe
853
853
  },
854
- x.id
854
+ v.id
855
855
  ) : /* @__PURE__ */ e(dn, {}) }),
856
- Me && x && /* @__PURE__ */ e(
856
+ Me && v && /* @__PURE__ */ e(
857
857
  an,
858
858
  {
859
- conversation: x,
860
- connection: ue.get(x.connectionId),
859
+ conversation: v,
860
+ connection: ue.get(v.connectionId),
861
861
  primary: _,
862
862
  onClose: () => He(!1),
863
863
  client: I.current,
864
864
  onStartResize: Ze,
865
865
  extensions: W,
866
866
  extRefreshKey: Ne,
867
- onLinkContact: (l) => ke(x, l),
867
+ onLinkContact: (l) => ke(v, l),
868
868
  onRefreshContactInfo: fe
869
869
  }
870
870
  )
871
871
  ] }) }) });
872
872
  });
873
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);
874
+ const [b, $] = g(!1), w = t.contactName ?? t.subject ?? t.providerConversationKey, y = t.unreadCount ?? 0, W = t.lastMessageText ?? "", z = t.lastMessageDirection === "outbound" ? "Bạn: " : "", j = W.length > 60 ? W.slice(0, 60) + "…" : W, B = W ? z + j : "", C = t.assignedAgent ?? null, D = !!(C && h && C.id === h.id);
875
875
  let I = "transparent";
876
- r ? I = "#eef2ff" : m ? I = "#f7f9fc" : v > 0 && (I = "#f0f4ff");
877
- const L = {
876
+ r ? I = "#eef2ff" : b ? I = "#f7f9fc" : y > 0 && (I = "#f0f4ff");
877
+ const M = {
878
878
  ...f.row,
879
879
  background: I,
880
- ...r ? { boxShadow: `inset 3px 0 0 ${o}` } : v > 0 && !m ? { boxShadow: `inset 3px 0 0 ${o}` } : {}
880
+ ...r ? { boxShadow: `inset 3px 0 0 ${o}` } : y > 0 && !b ? { boxShadow: `inset 3px 0 0 ${o}` } : {}
881
881
  };
882
882
  return /* @__PURE__ */ n(
883
883
  "button",
884
884
  {
885
885
  onClick: S,
886
- style: L,
887
- onMouseEnter: () => M(!0),
888
- onMouseLeave: () => M(!1),
886
+ style: M,
887
+ onMouseEnter: () => $(!0),
888
+ onMouseLeave: () => $(!1),
889
889
  children: [
890
890
  /* @__PURE__ */ e($t, { name: w, color: o, image: t.contactPictureUrl, provider: i }),
891
891
  /* @__PURE__ */ n("span", { style: f.rowBody, children: [
892
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 }),
893
+ /* @__PURE__ */ e("strong", { style: { minWidth: 0, overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap", fontWeight: y > 0 ? 700 : 500 }, children: w }),
894
894
  /* @__PURE__ */ n("span", { style: { display: "flex", alignItems: "center", gap: 4, flexShrink: 0 }, children: [
895
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 })
896
+ y > 0 && /* @__PURE__ */ e("span", { "aria-label": `${y} tin nhắn chưa đọc`, style: f.unreadBadge, children: y > 99 ? "99+" : y })
897
897
  ] })
898
898
  ] }),
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" }) }),
899
+ /* @__PURE__ */ n("span", { style: { ...f.rowBottom, justifyContent: "space-between", alignItems: "center", gap: 6, color: y > 0 && !r ? "#4a5568" : d.muted }, children: [
900
+ /* @__PURE__ */ e("span", { style: { flex: 1, minWidth: 0, whiteSpace: "nowrap", overflow: "hidden", textOverflow: "ellipsis" }, children: B || /* @__PURE__ */ e("span", { style: { opacity: 0.5 }, children: "Chưa có tin nhắn" }) }),
901
901
  C ? /* @__PURE__ */ n(
902
902
  "span",
903
903
  {
@@ -938,7 +938,7 @@ function nn({ conversation: t, provider: i, selected: r, primary: o, currentAgen
938
938
  /* @__PURE__ */ e("span", { style: { maxWidth: 68, overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" }, children: rt(C.name) })
939
939
  ]
940
940
  }
941
- ) : v > 0 ? /* @__PURE__ */ e(
941
+ ) : y > 0 ? /* @__PURE__ */ e(
942
942
  "span",
943
943
  {
944
944
  style: {
@@ -961,23 +961,23 @@ function nn({ conversation: t, provider: i, selected: r, primary: o, currentAgen
961
961
  }
962
962
  );
963
963
  }
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);
964
+ function rn({ conversation: t, provider: i, connection: r, client: o, primary: h, error: S, onRegisterAppend: b, refreshKey: $, infoOpen: w, onToggleInfo: y, t: W, disableAttachments: z, hideKeyboardHint: j, extensions: B, currentAgent: C, teamAgents: D, onAssignAgent: I, onLinkContact: M, onRefreshContactInfo: P }) {
965
+ var Te, Re;
966
+ const [q, te] = g([]), [Q, L] = g(), [v, x] = g(""), [E, V] = g(!0), [ne, de] = g(!1), [T, oe] = g(""), Z = J(null), O = t.contactName ?? t.subject ?? t.providerConversationKey, ee = J(null), se = J(null), [c, H] = g(null), [N, ae] = g(!1), [ce, ye] = g(!1), [F, he] = g(!1), [Se, Me] = g(0), He = J(null), Ae = J(null), Ce = J(null), [ve, Ie] = g(!1), [Ne, me] = g(""), [_, ue] = g([]), ze = J(null), Fe = J(null), [je, G] = g(!1), Ke = J(null), qe = J(null);
967
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);
968
+ if (!je) return;
969
+ function a(m) {
970
+ var k, A;
971
+ (k = Ke.current) != null && k.contains(m.target) || (A = qe.current) != null && A.contains(m.target) || G(!1);
972
972
  }
973
973
  return document.addEventListener("mousedown", a), () => document.removeEventListener("mousedown", a);
974
- }, [Ae]), X(() => () => {
974
+ }, [je]), X(() => () => {
975
975
  c != null && c.objectUrl && URL.revokeObjectURL(c.objectUrl);
976
976
  }, [c == null ? void 0 : c.objectUrl]), X(() => {
977
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);
978
+ function a(m) {
979
+ var k, A;
980
+ (k = Ae.current) != null && k.contains(m.target) || (A = He.current) != null && A.contains(m.target) || he(!1);
981
981
  }
982
982
  return document.addEventListener("mousedown", a), () => document.removeEventListener("mousedown", a);
983
983
  }, [F]), X(() => {
@@ -985,104 +985,104 @@ function rn({ conversation: t, provider: i, connection: r, client: o, primary: h
985
985
  });
986
986
  }, [o]), X(() => {
987
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);
988
+ function a(m) {
989
+ var k, A;
990
+ (k = Fe.current) != null && k.contains(m.target) || (A = ze.current) != null && A.contains(m.target) || Ie(!1);
991
991
  }
992
992
  return document.addEventListener("mousedown", a), () => document.removeEventListener("mousedown", a);
993
993
  }, [ve]);
994
- const ke = J(!0), fe = we(async (a, g) => {
995
- g || (ke.current = !a);
994
+ const ke = J(!0), fe = we(async (a, m) => {
995
+ m || (ke.current = !a);
996
996
  try {
997
997
  const k = await o.listMessages(t.id, a);
998
- te((j) => a ? [...k.items, ...j] : k.items), B(k.nextCursor);
998
+ te((A) => a ? [...k.items, ...A] : k.items), L(k.nextCursor);
999
999
  } catch (k) {
1000
1000
  oe(k instanceof Error ? k.message : "Không tải được tin nhắn");
1001
1001
  } finally {
1002
- g || V(!1);
1002
+ m || V(!1);
1003
1003
  }
1004
1004
  }, [o, t.id]);
1005
1005
  X(() => {
1006
1006
  V(!0), fe();
1007
1007
  }, [fe]), X(() => {
1008
- M && fe(void 0, !0);
1009
- }, [M]), X(() => {
1008
+ $ && fe(void 0, !0);
1009
+ }, [$]), X(() => {
1010
1010
  ke.current && requestAnimationFrame(() => {
1011
1011
  const a = Z.current;
1012
1012
  a && (a.scrollTop = a.scrollHeight);
1013
1013
  });
1014
- }, [q]), X(() => (m == null || m((a) => {
1015
- ke.current = !0, te((g) => g.some((k) => k.id === a.id) ? g : [...g, a]);
1014
+ }, [q]), X(() => (b == null || b((a) => {
1015
+ ke.current = !0, te((m) => m.some((k) => k.id === a.id) ? m : [...m, a]);
1016
1016
  }), () => {
1017
- m == null || m(null);
1018
- }), [m]);
1017
+ b == null || b(null);
1018
+ }), [b]);
1019
1019
  async function Ve(a) {
1020
- var j;
1021
- const g = (j = a.target.files) == null ? void 0 : j[0];
1022
- if (!g) return;
1020
+ var A;
1021
+ const m = (A = a.target.files) == null ? void 0 : A[0];
1022
+ if (!m) return;
1023
1023
  a.target.value = "";
1024
- const k = URL.createObjectURL(g);
1025
- H({ file: g, uploading: !0, objectUrl: k });
1024
+ const k = URL.createObjectURL(m);
1025
+ H({ file: m, uploading: !0, objectUrl: k });
1026
1026
  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 });
1027
+ const K = await o.uploadAttachment(m);
1028
+ H({ file: m, uploading: !1, url: K.url, mimeType: K.mimeType, attachmentType: K.attachmentType, objectUrl: k });
1029
1029
  } catch {
1030
1030
  URL.revokeObjectURL(k), H(null), oe("Không tải lên được tệp đính kèm");
1031
1031
  }
1032
1032
  }
1033
1033
  async function Ge(a) {
1034
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;
1035
+ const m = v.trim(), k = c != null && c.url ? [{ url: c.url, mimeType: c.mimeType ?? "application/octet-stream", type: c.attachmentType }] : [];
1036
+ if (!m && !k.length || ne) return;
1037
1037
  de(!0), oe(""), !t.assignedAgent && C && I(C);
1038
- const j = `optimistic-${Date.now()}`;
1038
+ const A = `optimistic-${Date.now()}`;
1039
1039
  C && (ke.current = !0, te((K) => [
1040
1040
  ...K,
1041
1041
  {
1042
- id: j,
1042
+ id: A,
1043
1043
  direction: "outbound",
1044
1044
  status: "sending",
1045
- text: g || void 0,
1045
+ text: m || void 0,
1046
1046
  attachments: k.length ? k : void 0,
1047
1047
  occurredAt: (/* @__PURE__ */ new Date()).toISOString(),
1048
1048
  senderAgent: C
1049
1049
  }
1050
1050
  ]));
1051
1051
  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) => {
1052
+ await o.sendMessage(t.id, m || void 0, k.length ? k : void 0), c != null && c.objectUrl && URL.revokeObjectURL(c.objectUrl), x(""), H(null), await fe(), C && te((K) => {
1053
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;
1054
+ const U = K.filter((u) => u.id !== A), re = U.length - 1;
1055
+ return re >= 0 && ((l = U[re]) == null ? void 0 : l.direction) === "outbound" && !((p = U[re]) != null && p.senderAgent) ? U.map((u, R) => R === re ? { ...u, senderAgent: C } : u) : U;
1056
1056
  });
1057
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");
1058
+ te((U) => U.filter((re) => re.id !== A)), oe(K instanceof Error ? K.message : "Không gửi được tin nhắn");
1059
1059
  } finally {
1060
1060
  de(!1);
1061
1061
  }
1062
1062
  }
1063
1063
  function Ze(a) {
1064
- const g = Ce.current;
1065
- if (!g) {
1066
- b((O) => O + a), he(!1);
1064
+ const m = Ce.current;
1065
+ if (!m) {
1066
+ x((U) => U + a), he(!1);
1067
1067
  return;
1068
1068
  }
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;
1069
+ const k = m.selectionStart ?? v.length, A = m.selectionEnd ?? v.length, K = v.slice(0, k) + a + v.slice(A);
1070
+ x(K), he(!1), requestAnimationFrame(() => {
1071
+ m.focus(), m.selectionStart = m.selectionEnd = k + a.length;
1072
1072
  });
1073
1073
  }
1074
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);
1075
+ x(a), Ie(!1), me(""), requestAnimationFrame(() => {
1076
+ const m = Ce.current;
1077
+ m && (m.focus(), m.selectionStart = m.selectionEnd = a.length);
1078
1078
  });
1079
1079
  }
1080
- const be = !ne && (x.trim().length > 0 || (c == null ? void 0 : c.url) != null && !c.uploading);
1080
+ const be = !ne && (v.trim().length > 0 || (c == null ? void 0 : c.url) != null && !c.uploading);
1081
1081
  return /* @__PURE__ */ n("section", { style: f.chat, children: [
1082
1082
  /* @__PURE__ */ n("header", { style: f.chatHeader, children: [
1083
- /* @__PURE__ */ e($t, { name: U, color: h, image: t.contactPictureUrl, provider: i }),
1083
+ /* @__PURE__ */ e($t, { name: O, color: h, image: t.contactPictureUrl, provider: i }),
1084
1084
  /* @__PURE__ */ n("div", { style: f.contact, children: [
1085
- /* @__PURE__ */ e("strong", { style: f.contactName, children: U }),
1085
+ /* @__PURE__ */ e("strong", { style: f.contactName, children: O }),
1086
1086
  /* @__PURE__ */ e("span", { style: f.contactMeta, children: en(r) ?? Wt(i) })
1087
1087
  ] }),
1088
1088
  /* @__PURE__ */ n("div", { style: { ...f.headerActions, alignItems: "center", gap: 6 }, children: [
@@ -1181,7 +1181,7 @@ function rn({ conversation: t, provider: i, connection: r, client: o, primary: h
1181
1181
  ]
1182
1182
  }
1183
1183
  ),
1184
- Ae && /* @__PURE__ */ n(
1184
+ je && /* @__PURE__ */ n(
1185
1185
  "div",
1186
1186
  {
1187
1187
  ref: qe,
@@ -1200,7 +1200,7 @@ function rn({ conversation: t, provider: i, connection: r, client: o, primary: h
1200
1200
  },
1201
1201
  children: [
1202
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(
1203
+ C && ((Te = t.assignedAgent) == null ? void 0 : Te.id) !== C.id && /* @__PURE__ */ n(
1204
1204
  "button",
1205
1205
  {
1206
1206
  type: "button",
@@ -1235,7 +1235,7 @@ function rn({ conversation: t, provider: i, connection: r, client: o, primary: h
1235
1235
  ),
1236
1236
  /* @__PURE__ */ e("div", { style: { maxHeight: 200, overflowY: "auto" }, children: (D ?? []).map((a) => {
1237
1237
  var k;
1238
- const g = ((k = t.assignedAgent) == null ? void 0 : k.id) === a.id;
1238
+ const m = ((k = t.assignedAgent) == null ? void 0 : k.id) === a.id;
1239
1239
  return /* @__PURE__ */ n(
1240
1240
  "button",
1241
1241
  {
@@ -1251,7 +1251,7 @@ function rn({ conversation: t, provider: i, connection: r, client: o, primary: h
1251
1251
  width: "100%",
1252
1252
  border: 0,
1253
1253
  borderRadius: 7,
1254
- background: g ? "#f1f5f9" : "transparent",
1254
+ background: m ? "#f1f5f9" : "transparent",
1255
1255
  color: d.ink,
1256
1256
  padding: "6px 8px",
1257
1257
  cursor: "pointer",
@@ -1283,7 +1283,7 @@ function rn({ conversation: t, provider: i, connection: r, client: o, primary: h
1283
1283
  a.title && /* @__PURE__ */ e("span", { style: { display: "block", fontSize: 10.5, color: d.muted }, children: a.title })
1284
1284
  ] })
1285
1285
  ] }),
1286
- g && /* @__PURE__ */ e(lt, { size: 13, color: h, strokeWidth: 2.5 })
1286
+ m && /* @__PURE__ */ e(lt, { size: 13, color: h, strokeWidth: 2.5 })
1287
1287
  ]
1288
1288
  },
1289
1289
  a.id
@@ -1314,7 +1314,7 @@ function rn({ conversation: t, provider: i, connection: r, client: o, primary: h
1314
1314
  textAlign: "left"
1315
1315
  },
1316
1316
  children: [
1317
- /* @__PURE__ */ e(Oe, { size: 13 }),
1317
+ /* @__PURE__ */ e(Ue, { size: 13 }),
1318
1318
  /* @__PURE__ */ e("span", { children: "Bỏ phân công (Chưa có người nhận)" })
1319
1319
  ]
1320
1320
  }
@@ -1334,13 +1334,13 @@ function rn({ conversation: t, provider: i, connection: r, client: o, primary: h
1334
1334
  color: w ? h : d.muted
1335
1335
  },
1336
1336
  "aria-label": "Thông tin liên hệ",
1337
- onClick: v,
1337
+ onClick: y,
1338
1338
  children: /* @__PURE__ */ e(Dt, { size: 16, strokeWidth: 2 })
1339
1339
  }
1340
1340
  )
1341
1341
  ] })
1342
1342
  ] }),
1343
- /* @__PURE__ */ n(Rt, { ref: Z, style: f.messageArea, children: [
1343
+ /* @__PURE__ */ n(Tt, { ref: Z, style: f.messageArea, children: [
1344
1344
  /* @__PURE__ */ e("div", { style: f.day, children: W.today }),
1345
1345
  Q && /* @__PURE__ */ e("button", { onClick: () => void fe(Q), style: f.historyButton, children: W.loadOlder }),
1346
1346
  E && /* @__PURE__ */ n("div", { style: f.messageHint, children: [
@@ -1349,23 +1349,23 @@ function rn({ conversation: t, provider: i, connection: r, client: o, primary: h
1349
1349
  W.loading
1350
1350
  ] }),
1351
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, {
1352
+ q.map((a, m) => {
1353
+ const k = (B == null ? void 0 : B.flatMap((re) => re.messageEnrichments ?? [])) ?? [], A = a.direction === "inbound" && k.length > 0 && m >= q.length - 15, K = A ? Je(t, {
1354
1354
  provider: i,
1355
1355
  recentMessages: q.slice(-10),
1356
- linkContact: L,
1356
+ linkContact: M,
1357
1357
  refreshContactInfo: P,
1358
1358
  sendMessage: async (re, l) => {
1359
1359
  await o.sendMessage(t.id, re, l), await fe(void 0, !0);
1360
1360
  }
1361
- }) : null, O = j && K ? k.map((re, l) => {
1361
+ }) : null, U = A && K ? k.map((re, l) => {
1362
1362
  var u;
1363
1363
  const p = (u = a.text) == null ? void 0 : u.match(re.pattern);
1364
1364
  return p ? /* @__PURE__ */ e(_t, { children: re.render(p, K, a) }, `${a.id}-${l}`) : null;
1365
1365
  }).filter(Boolean) : [];
1366
1366
  return /* @__PURE__ */ n("div", { children: [
1367
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 })
1368
+ U.length > 0 && /* @__PURE__ */ e("div", { style: { maxWidth: "min(70%, 480px)", marginTop: -4, marginBottom: 10, display: "flex", flexDirection: "column", gap: 6 }, children: U })
1369
1369
  ] }, a.id);
1370
1370
  })
1371
1371
  ] }),
@@ -1373,7 +1373,7 @@ function rn({ conversation: t, provider: i, connection: r, client: o, primary: h
1373
1373
  "button",
1374
1374
  {
1375
1375
  type: "button",
1376
- onClick: () => b(a),
1376
+ onClick: () => x(a),
1377
1377
  style: {
1378
1378
  fontSize: 11,
1379
1379
  padding: "3px 10px",
@@ -1407,11 +1407,11 @@ function rn({ conversation: t, provider: i, connection: r, client: o, primary: h
1407
1407
  fontFamily: "inherit"
1408
1408
  },
1409
1409
  children: [
1410
- /* @__PURE__ */ e("div", { style: { display: "flex", borderBottom: `1px solid ${d.line}`, background: "#f9fafb" }, children: gt.map((a, g) => /* @__PURE__ */ e(
1410
+ /* @__PURE__ */ e("div", { style: { display: "flex", borderBottom: `1px solid ${d.line}`, background: "#f9fafb" }, children: gt.map((a, m) => /* @__PURE__ */ e(
1411
1411
  "button",
1412
1412
  {
1413
1413
  type: "button",
1414
- onClick: () => Me(g),
1414
+ onClick: () => Me(m),
1415
1415
  style: {
1416
1416
  flex: 1,
1417
1417
  border: 0,
@@ -1420,15 +1420,15 @@ function rn({ conversation: t, provider: i, connection: r, client: o, primary: h
1420
1420
  fontSize: 16,
1421
1421
  cursor: "pointer",
1422
1422
  lineHeight: 1,
1423
- borderBottom: Se === g ? `2px solid ${h}` : "2px solid transparent",
1424
- opacity: Se === g ? 1 : 0.5,
1423
+ borderBottom: Se === m ? `2px solid ${h}` : "2px solid transparent",
1424
+ opacity: Se === m ? 1 : 0.5,
1425
1425
  transition: "opacity 100ms ease"
1426
1426
  },
1427
1427
  children: a.icon
1428
1428
  },
1429
- g
1429
+ m
1430
1430
  )) }),
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(
1431
+ /* @__PURE__ */ e("div", { style: { display: "grid", gridTemplateColumns: "repeat(8, 1fr)", gap: 2, padding: 8, maxHeight: 180, overflowY: "auto" }, children: (Re = gt[Se]) == null ? void 0 : Re.emojis.map((a, m) => /* @__PURE__ */ e(
1432
1432
  "button",
1433
1433
  {
1434
1434
  type: "button",
@@ -1451,7 +1451,7 @@ function rn({ conversation: t, provider: i, connection: r, client: o, primary: h
1451
1451
  },
1452
1452
  children: a
1453
1453
  },
1454
- g
1454
+ m
1455
1455
  )) })
1456
1456
  ]
1457
1457
  }
@@ -1486,18 +1486,18 @@ function rn({ conversation: t, provider: i, connection: r, client: o, primary: h
1486
1486
  }
1487
1487
  ) }),
1488
1488
  /* @__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(
1489
+ const a = Ne.trim().toLowerCase(), m = a ? _.filter((k) => k.title.toLowerCase().includes(a) || k.content.toLowerCase().includes(a) || (k.shortcut ?? "").toLowerCase().includes(a)) : _;
1490
+ return m.length ? m.map((k) => /* @__PURE__ */ n(
1491
1491
  "button",
1492
1492
  {
1493
1493
  type: "button",
1494
1494
  onClick: () => pe(k.content),
1495
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";
1496
+ onMouseEnter: (A) => {
1497
+ A.currentTarget.style.background = "#f7f9fc";
1498
1498
  },
1499
- onMouseLeave: (j) => {
1500
- j.currentTarget.style.background = "transparent";
1499
+ onMouseLeave: (A) => {
1500
+ A.currentTarget.style.background = "transparent";
1501
1501
  },
1502
1502
  children: [
1503
1503
  /* @__PURE__ */ n("div", { style: { display: "flex", alignItems: "center", gap: 6, marginBottom: 2 }, children: [
@@ -1533,7 +1533,7 @@ function rn({ conversation: t, provider: i, connection: r, client: o, primary: h
1533
1533
  /* @__PURE__ */ e(
1534
1534
  "button",
1535
1535
  {
1536
- ref: je,
1536
+ ref: Ae,
1537
1537
  type: "button",
1538
1538
  title: "Chèn emoji",
1539
1539
  onClick: () => he((a) => !a),
@@ -1541,15 +1541,15 @@ function rn({ conversation: t, provider: i, connection: r, client: o, primary: h
1541
1541
  children: /* @__PURE__ */ e(qt, { size: 13, strokeWidth: 2 })
1542
1542
  }
1543
1543
  ),
1544
- !T && /* @__PURE__ */ e("button", { type: "button", title: "Gửi ảnh / video", "aria-label": "Gửi ảnh hoặc video", style: f.toolbarBtn, onClick: () => {
1544
+ !z && /* @__PURE__ */ e("button", { type: "button", title: "Gửi ảnh / video", "aria-label": "Gửi ảnh hoặc video", style: f.toolbarBtn, onClick: () => {
1545
1545
  var a;
1546
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: () => {
1547
+ }, children: /* @__PURE__ */ e(Ot, { size: 13, strokeWidth: 2 }) }),
1548
+ !z && /* @__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
1549
  var a;
1550
1550
  return (a = se.current) == null ? void 0 : a.click();
1551
1551
  }, children: /* @__PURE__ */ e(Pt, { size: 13, strokeWidth: 2 }) }),
1552
- !T && /* @__PURE__ */ n(ie, { children: [
1552
+ !z && /* @__PURE__ */ n(ie, { children: [
1553
1553
  /* @__PURE__ */ e("input", { ref: ee, type: "file", style: { display: "none" }, onChange: Ve, accept: "image/*,video/mp4" }),
1554
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" })
1555
1555
  ] }),
@@ -1587,11 +1587,11 @@ function rn({ conversation: t, provider: i, connection: r, client: o, primary: h
1587
1587
  children: "I"
1588
1588
  }
1589
1589
  ),
1590
- !!($ != null && $.some((a) => {
1591
- var g;
1592
- return (((g = a.toolbarActions) == null ? void 0 : g.length) ?? 0) > 0;
1590
+ !!(B != null && B.some((a) => {
1591
+ var m;
1592
+ return (((m = a.toolbarActions) == null ? void 0 : m.length) ?? 0) > 0;
1593
1593
  })) && /* @__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(
1594
+ B == null ? void 0 : B.flatMap((a) => a.toolbarActions ?? []).map((a, m) => /* @__PURE__ */ n(
1595
1595
  "button",
1596
1596
  {
1597
1597
  type: "button",
@@ -1613,28 +1613,28 @@ function rn({ conversation: t, provider: i, connection: r, client: o, primary: h
1613
1613
  } : f.toolbarBtn,
1614
1614
  onClick: () => {
1615
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();
1616
+ x((U) => U && !U.endsWith(" ") && !U.endsWith(`
1617
+ `) ? `${U} ${K}` : `${U}${K}`), requestAnimationFrame(() => {
1618
+ var U;
1619
+ return (U = Ce.current) == null ? void 0 : U.focus();
1620
1620
  });
1621
- }, j = Je(t, {
1621
+ }, A = Je(t, {
1622
1622
  provider: i,
1623
1623
  recentMessages: q.slice(-10),
1624
- linkContact: L,
1624
+ linkContact: M,
1625
1625
  refreshContactInfo: P,
1626
- sendMessage: async (K, O) => {
1627
- await o.sendMessage(t.id, K, O), await fe(void 0, !0);
1626
+ sendMessage: async (K, U) => {
1627
+ await o.sendMessage(t.id, K, U), await fe(void 0, !0);
1628
1628
  }
1629
1629
  });
1630
- a.onClick({ ...j, insertText: k });
1630
+ a.onClick({ ...A, insertText: k });
1631
1631
  },
1632
1632
  children: [
1633
1633
  a.icon,
1634
1634
  a.label && /* @__PURE__ */ e("span", { children: a.label })
1635
1635
  ]
1636
1636
  },
1637
- g
1637
+ m
1638
1638
  ))
1639
1639
  ] }),
1640
1640
  /* @__PURE__ */ e(
@@ -1643,8 +1643,8 @@ function rn({ conversation: t, provider: i, connection: r, client: o, primary: h
1643
1643
  ref: Ce,
1644
1644
  "aria-label": "Soạn tin nhắn",
1645
1645
  rows: 2,
1646
- value: x,
1647
- onChange: (a) => b(a.target.value),
1646
+ value: v,
1647
+ onChange: (a) => x(a.target.value),
1648
1648
  onKeyDown: (a) => {
1649
1649
  a.key === "Enter" && !a.shiftKey && (a.preventDefault(), Ge(a));
1650
1650
  },
@@ -1673,14 +1673,14 @@ function rn({ conversation: t, provider: i, connection: r, client: o, primary: h
1673
1673
  /* @__PURE__ */ n("div", { style: { display: "flex", alignItems: "center", justifyContent: "space-between", padding: "4px 8px 6px 12px" }, children: [
1674
1674
  /* @__PURE__ */ n("span", { style: {
1675
1675
  fontSize: 11,
1676
- color: x.length > 1e3 ? "#ef4444" : x.length > 900 ? "#f59e0b" : "#9ca3af",
1677
- fontWeight: x.length > 1e3 ? 600 : 400
1676
+ color: v.length > 1e3 ? "#ef4444" : v.length > 900 ? "#f59e0b" : "#9ca3af",
1677
+ fontWeight: v.length > 1e3 ? 600 : 400
1678
1678
  }, children: [
1679
- x.length,
1679
+ v.length,
1680
1680
  "/1000"
1681
1681
  ] }),
1682
1682
  /* @__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" }),
1683
+ !j && /* @__PURE__ */ e("span", { style: { fontSize: 10, color: "#9ca3af" }, children: "↵ Gửi · ⇧↵ Xuống dòng" }),
1684
1684
  /* @__PURE__ */ n(
1685
1685
  "button",
1686
1686
  {
@@ -1711,12 +1711,12 @@ function rn({ conversation: t, provider: i, connection: r, client: o, primary: h
1711
1711
  ] })
1712
1712
  ] })
1713
1713
  ] }),
1714
- (z || S) && /* @__PURE__ */ e("div", { role: "alert", style: f.error, children: z || S })
1714
+ (T || S) && /* @__PURE__ */ e("div", { role: "alert", style: f.error, children: T || S })
1715
1715
  ] });
1716
1716
  }
1717
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: [
1718
+ var q, te, Q, L, v;
1719
+ const r = tt(st), o = tt(Rt), h = (x) => x.startsWith("/v1/media/proxy") ? `${r}${x}&tok=${encodeURIComponent(o)}` : x, S = t.direction === "outbound", b = ((q = t.attachments) == null ? void 0 : q.filter((x) => x.type === "image")) ?? [], $ = ((te = t.attachments) == null ? void 0 : te.filter((x) => x.type === "sticker")) ?? [], w = ((Q = t.attachments) == null ? void 0 : Q.filter((x) => x.type === "video")) ?? [], y = ((L = t.attachments) == null ? void 0 : L.filter((x) => x.type === "audio")) ?? [], W = ((v = t.attachments) == null ? void 0 : v.filter((x) => x.type === "file")) ?? [], [z, j] = g(null), B = 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
1720
  C && /* @__PURE__ */ n(
1721
1721
  "span",
1722
1722
  {
@@ -1760,35 +1760,35 @@ function on({ message: t, primary: i }) {
1760
1760
  " ",
1761
1761
  /* @__PURE__ */ e(bt, { status: t.status })
1762
1762
  ] })
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
1763
+ ] }) }), M = S ? { ...f.bubbleOut, background: i, color: "#fff", border: "1px solid transparent" } : f.bubbleIn, P = !t.text && y.length === 0 && W.length === 0;
1764
+ return /* @__PURE__ */ n("div", { style: { ...f.messageLine, justifyContent: B, flexDirection: "column", alignItems: B }, children: [
1765
+ $.map((x, E) => /* @__PURE__ */ n("div", { style: { position: "relative", marginBottom: 2 }, children: [
1766
+ /* @__PURE__ */ e("img", { src: h(x.url), alt: "sticker", style: { display: "block", maxWidth: 128, maxHeight: 128, objectFit: "contain" } }),
1767
+ P && b.length === 0 && w.length === 0 && E === $.length - 1 && I
1768
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
1769
+ b.map((x, E) => /* @__PURE__ */ n("div", { style: { position: "relative", marginBottom: 2, cursor: "zoom-in" }, onClick: () => j({ url: h(x.url), kind: "image" }), children: [
1770
+ /* @__PURE__ */ e("img", { src: h(x.url), alt: "", style: { display: "block", maxWidth: 260, maxHeight: 260, borderRadius: 12, objectFit: "cover" } }),
1771
+ P && E === b.length - 1 && w.length === 0 && I
1772
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" } }),
1773
+ w.map((x, E) => /* @__PURE__ */ n("div", { style: { position: "relative", marginBottom: 2, cursor: "pointer" }, onClick: () => j({ url: h(x.url), kind: "video" }), children: [
1774
+ /* @__PURE__ */ e("video", { src: h(x.url), style: { display: "block", maxWidth: 260, maxHeight: 200, borderRadius: 12, objectFit: "cover" } }),
1775
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
1776
  P && E === w.length - 1 && I
1777
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: [
1778
+ (y.length > 0 || W.length > 0 || t.text || !b.length && !w.length && !$.length && !t.text) && /* @__PURE__ */ n("div", { style: M, children: [
1779
+ y.map((x, E) => /* @__PURE__ */ e("audio", { src: h(x.url), controls: !0, style: { display: "block", width: "100%", marginBottom: 4 } }, E)),
1780
+ W.map((x, E) => /* @__PURE__ */ n("a", { href: h(x.url), target: "_blank", rel: "noreferrer", style: { display: "block", fontSize: 12, color: S ? "#fff" : "#2563eb", textDecoration: "underline", marginBottom: 4 }, children: [
1781
1781
  "📎 ",
1782
- tn(b.mimeType)
1782
+ tn(x.mimeType)
1783
1783
  ] }, E)),
1784
1784
  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]" }),
1785
+ !y.length && !W.length && !t.text && /* @__PURE__ */ e("p", { style: { margin: 0, opacity: 0.5 }, children: "[attachment]" }),
1786
1786
  D
1787
1787
  ] }),
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 }) })
1788
+ z && St(
1789
+ /* @__PURE__ */ n("div", { onClick: () => j(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
+ z.kind === "image" ? /* @__PURE__ */ e("img", { src: z.url, alt: "", style: { maxWidth: "90vw", maxHeight: "90vh", borderRadius: 8, objectFit: "contain", boxShadow: "0 8px 40px rgba(0,0,0,.5)" }, onClick: (x) => x.stopPropagation() }) : /* @__PURE__ */ e("video", { src: z.url, controls: !0, autoPlay: !0, style: { maxWidth: "90vw", maxHeight: "90vh", borderRadius: 8, boxShadow: "0 8px 40px rgba(0,0,0,.5)" }, onClick: (x) => x.stopPropagation() }),
1791
+ /* @__PURE__ */ e("button", { onClick: () => j(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(Ue, { size: 18 }) })
1792
1792
  ] }),
1793
1793
  document.body
1794
1794
  )
@@ -1801,45 +1801,45 @@ function an({
1801
1801
  onClose: o,
1802
1802
  client: h,
1803
1803
  onStartResize: S,
1804
- extensions: m,
1805
- extRefreshKey: M,
1804
+ extensions: b,
1805
+ extRefreshKey: $,
1806
1806
  onLinkContact: w,
1807
- onRefreshContactInfo: v
1807
+ onRefreshContactInfo: y
1808
1808
  }) {
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);
1809
+ const W = t.contactName ?? t.subject ?? t.providerConversationKey, z = i == null ? void 0 : i.provider, j = !!(b != null && b.some((T) => T.contactInfoRows)), [B, C] = g({ channel: !0, stats: !1, extra: !0 }), D = (T) => C((oe) => ({ ...oe, [T]: !oe[T] })), [I, M] = g(""), [P, q] = g(!1), [te, Q] = g(!1), [L, v] = g(""), [x, E] = g([]), [V, ne] = g(!1);
1810
1810
  X(() => {
1811
- L(""), Q(!1), x(""), h.getNote(t.id).then((z) => {
1812
- z && L(z.content);
1811
+ M(""), Q(!1), v(""), h.getNote(t.id).then((T) => {
1812
+ T && M(T.content);
1813
1813
  }).catch(() => {
1814
1814
  });
1815
1815
  }, [t.id, h]), X(() => {
1816
- if (!A || !m) return;
1817
- let z = !1;
1816
+ if (!j || !b) return;
1817
+ let T = !1;
1818
1818
  const oe = Je(t, {
1819
- provider: T,
1819
+ provider: z,
1820
1820
  linkContact: w,
1821
- refreshContactInfo: v,
1822
- sendMessage: async (Z, U) => {
1823
- await h.sendMessage(t.id, Z, U);
1821
+ refreshContactInfo: y,
1822
+ sendMessage: async (Z, O) => {
1823
+ await h.sendMessage(t.id, Z, O);
1824
1824
  }
1825
1825
  });
1826
1826
  return ne(!0), Promise.allSettled(
1827
- m.filter((Z) => Z.contactInfoRows).map((Z) => Z.contactInfoRows(oe))
1827
+ b.filter((Z) => Z.contactInfoRows).map((Z) => Z.contactInfoRows(oe))
1828
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);
1829
+ if (T) return;
1830
+ const O = Z.filter((ee) => ee.status === "fulfilled").flatMap((ee) => ee.value);
1831
+ E(O), ne(!1);
1832
1832
  }), () => {
1833
- z = !0;
1833
+ T = !0;
1834
1834
  };
1835
- }, [t.id, t.contactExternalId, m, M, A, T, w, v, h]);
1835
+ }, [t.id, t.contactExternalId, b, $, j, z, w, y, h]);
1836
1836
  async function de() {
1837
1837
  if (!(!I.trim() || P)) {
1838
- q(!0), x("");
1838
+ q(!0), v("");
1839
1839
  try {
1840
1840
  await h.upsertNote(t.id, I.trim()), Q(!0), setTimeout(() => Q(!1), 2e3);
1841
1841
  } catch {
1842
- x("Lưu thất bại");
1842
+ v("Lưu thất bại");
1843
1843
  } finally {
1844
1844
  q(!1);
1845
1845
  }
@@ -1851,17 +1851,17 @@ function an({
1851
1851
  {
1852
1852
  onMouseDown: S,
1853
1853
  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)";
1854
+ onMouseEnter: (T) => {
1855
+ T.currentTarget.style.background = "rgba(0,0,0,0.07)";
1856
1856
  },
1857
- onMouseLeave: (z) => {
1858
- z.currentTarget.style.background = "";
1857
+ onMouseLeave: (T) => {
1858
+ T.currentTarget.style.background = "";
1859
1859
  }
1860
1860
  }
1861
1861
  ),
1862
1862
  /* @__PURE__ */ n("div", { style: f.infoPanelHeader, children: [
1863
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 }) })
1864
+ /* @__PURE__ */ e("button", { style: f.iconButton, onClick: o, "aria-label": "Đóng", children: /* @__PURE__ */ e(Ue, { size: 16, strokeWidth: 2 }) })
1865
1865
  ] }),
1866
1866
  /* @__PURE__ */ n("div", { style: { overflowY: "auto", flex: 1 }, children: [
1867
1867
  /* @__PURE__ */ n("div", { style: f.infoPanelIdentity, children: [
@@ -1874,15 +1874,15 @@ function an({
1874
1874
  style: { ...f.avatar, width: 48, height: 48, fontSize: 16 }
1875
1875
  }
1876
1876
  ),
1877
- /* @__PURE__ */ e("span", { style: { ...f.providerBadge, width: 20, height: 20 }, children: /* @__PURE__ */ e(De, { provider: T }) })
1877
+ /* @__PURE__ */ e("span", { style: { ...f.providerBadge, width: 20, height: 20 }, children: /* @__PURE__ */ e(De, { provider: z }) })
1878
1878
  ] }),
1879
1879
  /* @__PURE__ */ e("strong", { style: { marginTop: 10, fontSize: 15, color: d.ink, textAlign: "center" }, children: W }),
1880
1880
  /* @__PURE__ */ e("span", { style: { fontSize: 11, color: d.muted, fontFamily: "monospace", textAlign: "center" }, children: t.providerConversationKey })
1881
1881
  ] }),
1882
- /* @__PURE__ */ n(_e, { label: "KÊNH", sectionKey: "channel", expanded: $.channel, onToggle: () => D("channel"), children: [
1882
+ /* @__PURE__ */ n(_e, { label: "KÊNH", sectionKey: "channel", expanded: B.channel, onToggle: () => D("channel"), children: [
1883
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) })
1884
+ /* @__PURE__ */ e(De, { provider: z }),
1885
+ /* @__PURE__ */ e("span", { children: Wt(z) })
1886
1886
  ] }) }),
1887
1887
  /* @__PURE__ */ n(ge, { label: "ID hội thoại", children: [
1888
1888
  /* @__PURE__ */ n("span", { style: { fontFamily: "monospace", fontSize: 11 }, children: [
@@ -1892,7 +1892,7 @@ function an({
1892
1892
  /* @__PURE__ */ e(ln, { value: t.id })
1893
1893
  ] })
1894
1894
  ] }),
1895
- /* @__PURE__ */ n(_e, { label: "THỐNG KÊ", sectionKey: "stats", expanded: $.stats, onToggle: () => D("stats"), children: [
1895
+ /* @__PURE__ */ n(_e, { label: "THỐNG KÊ", sectionKey: "stats", expanded: B.stats, onToggle: () => D("stats"), children: [
1896
1896
  /* @__PURE__ */ e(ge, { label: "Tin nhắn", value: String(t.messageCount ?? 0) }),
1897
1897
  (t.unreadCount ?? 0) > 0 && /* @__PURE__ */ e(ge, { label: "Chưa đọc", value: String(t.unreadCount), valueColor: "#ef4444" }),
1898
1898
  /* @__PURE__ */ e(
@@ -1904,24 +1904,24 @@ function an({
1904
1904
  ),
1905
1905
  /* @__PURE__ */ e(ge, { label: "Lần đầu", value: "—" })
1906
1906
  ] }),
1907
- /* @__PURE__ */ n(_e, { label: "THÔNG TIN BỔ SUNG", sectionKey: "extra", expanded: $.extra, onToggle: () => D("extra"), children: [
1908
- !A && /* @__PURE__ */ n(ie, { children: [
1907
+ /* @__PURE__ */ n(_e, { label: "THÔNG TIN BỔ SUNG", sectionKey: "extra", expanded: B.extra, onToggle: () => D("extra"), children: [
1908
+ !j && /* @__PURE__ */ n(ie, { children: [
1909
1909
  /* @__PURE__ */ e(ge, { label: "Điện thoại", value: "— chưa có", valueMuted: !0 }),
1910
1910
  /* @__PURE__ */ e(ge, { label: "Email", value: "— chưa có", valueMuted: !0 }),
1911
1911
  /* @__PURE__ */ e(ge, { label: "Nhãn", value: "— chưa có", valueMuted: !0 })
1912
1912
  ] }),
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(
1913
+ V && x.length === 0 && /* @__PURE__ */ e("div", { style: { fontSize: 12, color: d.muted, padding: "6px 0" }, children: "Đang tải hồ sơ CRM…" }),
1914
+ x.map((T) => /* @__PURE__ */ e(ge, { label: T.label, children: /* @__PURE__ */ n("span", { style: { display: "inline-flex", alignItems: "center", gap: 6, flexWrap: "wrap", justifyContent: "flex-end" }, children: [
1915
+ T.onClick ? /* @__PURE__ */ e(
1916
1916
  "button",
1917
1917
  {
1918
1918
  type: "button",
1919
- onClick: z.onClick,
1919
+ onClick: T.onClick,
1920
1920
  style: { border: 0, background: "none", padding: 0, color: r, fontSize: 12, fontWeight: 600, cursor: "pointer", textDecoration: "underline" },
1921
- children: z.value
1921
+ children: T.value
1922
1922
  }
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(
1923
+ ) : T.href ? /* @__PURE__ */ e("a", { href: T.href, target: "_blank", rel: "noopener noreferrer", style: { color: r, fontSize: 12, fontWeight: 600 }, children: T.value }) : /* @__PURE__ */ e("span", { style: { fontSize: 12, fontWeight: 500, color: d.ink }, children: T.value }),
1924
+ T.badge && /* @__PURE__ */ e(
1925
1925
  "span",
1926
1926
  {
1927
1927
  style: {
@@ -1929,18 +1929,18 @@ function an({
1929
1929
  fontWeight: 700,
1930
1930
  padding: "1px 7px",
1931
1931
  borderRadius: 999,
1932
- color: z.badge.color ?? r,
1933
- background: z.badge.bg ?? `${r}14`
1932
+ color: T.badge.color ?? r,
1933
+ background: T.badge.bg ?? `${r}14`
1934
1934
  },
1935
- children: z.badge.text
1935
+ children: T.badge.text
1936
1936
  }
1937
1937
  )
1938
- ] }) }, z.label))
1938
+ ] }) }, T.label))
1939
1939
  ] }),
1940
1940
  /* @__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";
1941
+ !(b != null && b.length) && /* @__PURE__ */ e("button", { style: { ...f.ghostButton, color: r, borderColor: `${r}33` }, children: "Xem lịch sử" }),
1942
+ b == null ? void 0 : b.flatMap((T) => T.sidebarActions ?? []).map((T, oe) => {
1943
+ const Z = T.variant === "primary";
1944
1944
  return /* @__PURE__ */ n(
1945
1945
  "button",
1946
1946
  {
@@ -1956,19 +1956,19 @@ function an({
1956
1956
  gap: 6
1957
1957
  },
1958
1958
  onClick: () => {
1959
- const U = Je(t, {
1960
- provider: T,
1959
+ const O = Je(t, {
1960
+ provider: z,
1961
1961
  linkContact: w,
1962
- refreshContactInfo: v,
1962
+ refreshContactInfo: y,
1963
1963
  sendMessage: async (ee, se) => {
1964
1964
  await h.sendMessage(t.id, ee, se);
1965
1965
  }
1966
1966
  });
1967
- z.onClick(U);
1967
+ T.onClick(O);
1968
1968
  },
1969
1969
  children: [
1970
- z.icon,
1971
- z.label
1970
+ T.icon,
1971
+ T.label
1972
1972
  ]
1973
1973
  },
1974
1974
  oe
@@ -1980,7 +1980,7 @@ function an({
1980
1980
  "textarea",
1981
1981
  {
1982
1982
  value: I,
1983
- onChange: (z) => L(z.target.value),
1983
+ onChange: (T) => M(T.target.value),
1984
1984
  placeholder: "Nhập ghi chú...",
1985
1985
  rows: 3,
1986
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 }
@@ -1990,7 +1990,7 @@ function an({
1990
1990
  te ? /* @__PURE__ */ n("span", { style: { display: "flex", alignItems: "center", gap: 4, fontSize: 11, color: "#16a34a" }, children: [
1991
1991
  /* @__PURE__ */ e(lt, { size: 11, strokeWidth: 2.5 }),
1992
1992
  " Đã lưu"
1993
- ] }) : B ? /* @__PURE__ */ e("span", { style: { fontSize: 11, color: "#ef4444" }, children: B }) : /* @__PURE__ */ e("span", {}),
1993
+ ] }) : L ? /* @__PURE__ */ e("span", { style: { fontSize: 11, color: "#ef4444" }, children: L }) : /* @__PURE__ */ e("span", {}),
1994
1994
  /* @__PURE__ */ e(
1995
1995
  "button",
1996
1996
  {
@@ -2010,7 +2010,7 @@ function an({
2010
2010
  ] });
2011
2011
  }
2012
2012
  function _e({ label: t, children: i, sectionKey: r, expanded: o, onToggle: h }) {
2013
- const S = !!h, m = o ?? !0;
2013
+ const S = !!h, b = o ?? !0;
2014
2014
  return /* @__PURE__ */ n("div", { style: { borderTop: `1px solid ${d.line}` }, children: [
2015
2015
  /* @__PURE__ */ n(
2016
2016
  "div",
@@ -2019,11 +2019,11 @@ function _e({ label: t, children: i, sectionKey: r, expanded: o, onToggle: h })
2019
2019
  onClick: h,
2020
2020
  children: [
2021
2021
  /* @__PURE__ */ e("span", { children: t }),
2022
- S && (m ? /* @__PURE__ */ e(nt, { size: 12, strokeWidth: 2 }) : /* @__PURE__ */ e(At, { size: 12, strokeWidth: 2 }))
2022
+ S && (b ? /* @__PURE__ */ e(nt, { size: 12, strokeWidth: 2 }) : /* @__PURE__ */ e(jt, { size: 12, strokeWidth: 2 }))
2023
2023
  ]
2024
2024
  }
2025
2025
  ),
2026
- m && i
2026
+ b && i
2027
2027
  ] });
2028
2028
  }
2029
2029
  function ge({ label: t, value: i, children: r, valueColor: o, valueMuted: h }) {
@@ -2033,7 +2033,7 @@ function ge({ label: t, value: i, children: r, valueColor: o, valueMuted: h }) {
2033
2033
  ] });
2034
2034
  }
2035
2035
  function ln({ value: t }) {
2036
- const [i, r] = y(!1);
2036
+ const [i, r] = g(!1);
2037
2037
  return /* @__PURE__ */ e(
2038
2038
  "button",
2039
2039
  {
@@ -2051,7 +2051,7 @@ function ln({ value: t }) {
2051
2051
  }
2052
2052
  function dn() {
2053
2053
  return /* @__PURE__ */ n("div", { style: f.empty, children: [
2054
- /* @__PURE__ */ e("div", { style: f.emptyHero, children: /* @__PURE__ */ e(Ot, { size: 16, strokeWidth: 2 }) }),
2054
+ /* @__PURE__ */ e("div", { style: f.emptyHero, children: /* @__PURE__ */ e(Ut, { size: 16, strokeWidth: 2 }) }),
2055
2055
  /* @__PURE__ */ e("h2", { children: "Chọn một hội thoại" }),
2056
2056
  /* @__PURE__ */ e("p", { children: "Chọn hội thoại bên trái để xem và trả lời tin nhắn." })
2057
2057
  ] });
@@ -2174,7 +2174,7 @@ function xe({ provider: t, apiUrl: i, size: r = 40 }) {
2174
2174
  }
2175
2175
  );
2176
2176
  }
2177
- const Ue = {
2177
+ const Oe = {
2178
2178
  facebook: "Facebook",
2179
2179
  zalo: "Zalo OA",
2180
2180
  instagram: "Instagram",
@@ -2194,8 +2194,25 @@ function ct(t) {
2194
2194
  return String(i.displayName ?? i.pageName ?? i.username ?? i.name ?? t.externalAccountId);
2195
2195
  }
2196
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;
2197
+ const i = t.metadata;
2198
+ switch (t.provider) {
2199
+ case "facebook":
2200
+ return `Fanpage · ID ${t.externalAccountId}`;
2201
+ case "instagram":
2202
+ return `@${String(i.username ?? t.externalAccountId)}`;
2203
+ case "zalo":
2204
+ return `Zalo OA · ID ${t.externalAccountId}`;
2205
+ case "telegram": {
2206
+ const r = String(i.username ?? "");
2207
+ return r ? `@${r}` : `Bot · ${t.externalAccountId}`;
2208
+ }
2209
+ case "livechat":
2210
+ return `Widget ID: ${t.id}`;
2211
+ default: {
2212
+ const r = Oe[t.provider] ?? t.provider, o = String(i.username ?? i.pageName ?? "");
2213
+ return o ? `${r} · ${o}` : r;
2214
+ }
2215
+ }
2199
2216
  }
2200
2217
  const s = {
2201
2218
  root: {
@@ -2507,7 +2524,7 @@ function bn() {
2507
2524
  t.textContent = "@keyframes ch-spin{to{transform:rotate(360deg)}}", document.head.appendChild(t);
2508
2525
  }
2509
2526
  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);
2527
+ const o = t.replace(/\/$/, ""), [h, S] = g([]), [b, $] = g(!0), [w, y] = g({ name: "list" }), [W, z] = g(null), [j, B] = g(!1), [C, D] = g(""), [I, M] = g(""), [P, q] = g(""), [te, Q] = g(""), [L, v] = g(!1), [x, E] = g(!1), V = J(null);
2511
2528
  bn();
2512
2529
  const ne = we(async () => {
2513
2530
  try {
@@ -2518,16 +2535,16 @@ function $n({ apiUrl: t, token: i, onConnectionChange: r }) {
2518
2535
  const H = await c.json();
2519
2536
  S(H), r == null || r(H);
2520
2537
  } catch (c) {
2521
- T(c instanceof Error ? c.message : "Lỗi tải dữ liệu");
2538
+ z(c instanceof Error ? c.message : "Lỗi tải dữ liệu");
2522
2539
  } finally {
2523
- M(!1);
2540
+ $(!1);
2524
2541
  }
2525
2542
  }, [o, i, r]);
2526
2543
  X(() => {
2527
2544
  ne();
2528
2545
  }, [ne]), X(() => {
2529
2546
  if (!W) return;
2530
- const c = setTimeout(() => T(null), 5e3);
2547
+ const c = setTimeout(() => z(null), 5e3);
2531
2548
  return () => clearTimeout(c);
2532
2549
  }, [W]), X(() => () => {
2533
2550
  V.current && window.removeEventListener("message", V.current);
@@ -2543,19 +2560,19 @@ Hành động này không thể hoàn tác.`))
2543
2560
  })).ok) throw new Error("Không thể ngắt kết nối");
2544
2561
  await ne();
2545
2562
  } catch (N) {
2546
- T(N instanceof Error ? N.message : "Lỗi ngắt kết nối");
2563
+ z(N instanceof Error ? N.message : "Lỗi ngắt kết nối");
2547
2564
  }
2548
2565
  }
2549
- async function z() {
2566
+ async function T() {
2550
2567
  if (!C.trim()) {
2551
- T("Vui lòng nhập Bot Token");
2568
+ z("Vui lòng nhập Bot Token");
2552
2569
  return;
2553
2570
  }
2554
2571
  if (!/^\d+:[A-Za-z0-9_-]+$/.test(C.trim())) {
2555
- T("Token không đúng định dạng");
2572
+ z("Token không đúng định dạng");
2556
2573
  return;
2557
2574
  }
2558
- $(!0), T(null);
2575
+ B(!0), z(null);
2559
2576
  try {
2560
2577
  const c = await fetch(`${o}/v1/connect/telegram/start`, {
2561
2578
  method: "POST",
@@ -2563,19 +2580,19 @@ Hành động này không thể hoàn tác.`))
2563
2580
  body: JSON.stringify({ botToken: C.trim(), displayName: I.trim() || void 0 })
2564
2581
  }), H = await c.json();
2565
2582
  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" });
2583
+ D(""), M(""), await ne(), y({ name: "list" });
2567
2584
  } catch (c) {
2568
- T(c instanceof Error ? c.message : "Lỗi kết nối");
2585
+ z(c instanceof Error ? c.message : "Lỗi kết nối");
2569
2586
  } finally {
2570
- $(!1);
2587
+ B(!1);
2571
2588
  }
2572
2589
  }
2573
2590
  async function oe() {
2574
2591
  if (!P.trim()) {
2575
- T("Vui lòng nhập tên widget");
2592
+ z("Vui lòng nhập tên widget");
2576
2593
  return;
2577
2594
  }
2578
- $(!0), T(null);
2595
+ B(!0), z(null);
2579
2596
  try {
2580
2597
  const c = te.split(/[\n,]+/).map((ae) => ae.trim()).filter(Boolean), H = await fetch(`${o}/v1/connect/livechat/start`, {
2581
2598
  method: "POST",
@@ -2583,7 +2600,7 @@ Hành động này không thể hoàn tác.`))
2583
2600
  body: JSON.stringify({ displayName: P.trim(), allowedDomains: c.length ? c : void 0 })
2584
2601
  }), N = await H.json();
2585
2602
  if (!H.ok || !N.connectionId || !N.embedScript) throw new Error(N.message ?? "Không thể tạo widget");
2586
- q(""), Q(""), await ne(), v({
2603
+ q(""), Q(""), await ne(), y({
2587
2604
  name: "livechat-result",
2588
2605
  connectionId: N.connectionId,
2589
2606
  embedScript: N.embedScript,
@@ -2591,13 +2608,13 @@ Hành động này không thể hoàn tác.`))
2591
2608
  allowedDomains: N.allowedDomains ?? []
2592
2609
  });
2593
2610
  } catch (c) {
2594
- T(c instanceof Error ? c.message : "Lỗi tạo widget");
2611
+ z(c instanceof Error ? c.message : "Lỗi tạo widget");
2595
2612
  } finally {
2596
- $(!1);
2613
+ B(!1);
2597
2614
  }
2598
2615
  }
2599
2616
  async function Z(c) {
2600
- T(null);
2617
+ z(null);
2601
2618
  try {
2602
2619
  const H = `${o}/static/oauth-popup.html`, N = await fetch(`${o}/v1/connect/${c}/start`, {
2603
2620
  method: "POST",
@@ -2606,11 +2623,11 @@ Hành động này không thể hoàn tác.`))
2606
2623
  }), ae = await N.json();
2607
2624
  if (!N.ok || !ae.authorizationUrl) throw new Error(ae.message ?? "Không thể bắt đầu kết nối");
2608
2625
  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);
2626
+ y({ name: "oauth-waiting", provider: c, popup: ce }), V.current && window.removeEventListener("message", V.current);
2610
2627
  const ye = (F) => {
2611
2628
  if (F.data) {
2612
2629
  if (F.data.type === "channelhub:oauth-select") {
2613
- v({
2630
+ y({
2614
2631
  name: "oauth-select",
2615
2632
  provider: F.data.provider,
2616
2633
  sessionId: String(F.data.sessionId ?? ""),
@@ -2619,17 +2636,17 @@ Hành động này không thể hoàn tác.`))
2619
2636
  });
2620
2637
  return;
2621
2638
  }
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" })));
2639
+ F.data.type === "channelhub:oauth" && (window.removeEventListener("message", ye), V.current = null, F.data.status === "active" ? (ne(), y({ name: "list" })) : (z("Kết nối thất bại: " + String(F.data.error ?? "Không xác định")), y({ name: "list" })));
2623
2640
  }
2624
2641
  };
2625
2642
  V.current = ye, window.addEventListener("message", ye);
2626
2643
  } catch (H) {
2627
- T(H instanceof Error ? H.message : "Lỗi kết nối"), v({ name: "list" });
2644
+ z(H instanceof Error ? H.message : "Lỗi kết nối"), y({ name: "list" });
2628
2645
  }
2629
2646
  }
2630
- function U(c, H) {
2647
+ function O(c, H) {
2631
2648
  navigator.clipboard.writeText(c).then(() => {
2632
- H === "script" ? (x(!0), setTimeout(() => x(!1), 2e3)) : (E(!0), setTimeout(() => E(!1), 2e3));
2649
+ H === "script" ? (v(!0), setTimeout(() => v(!1), 2e3)) : (E(!0), setTimeout(() => E(!1), 2e3));
2633
2650
  });
2634
2651
  }
2635
2652
  function ee() {
@@ -2639,12 +2656,12 @@ Hành động này không thể hoàn tác.`))
2639
2656
  c.close();
2640
2657
  } catch {
2641
2658
  }
2642
- V.current && (window.removeEventListener("message", V.current), V.current = null), v({ name: "add" });
2659
+ V.current && (window.removeEventListener("message", V.current), V.current = null), y({ name: "add" });
2643
2660
  }
2644
2661
  async function se(c) {
2645
2662
  if (w.name !== "oauth-select") return;
2646
2663
  const { provider: H, sessionId: N, popup: ae } = w;
2647
- $(!0), T(null);
2664
+ B(!0), z(null);
2648
2665
  const ce = {
2649
2666
  facebook: `${o}/v1/connect/facebook/select-page`,
2650
2667
  instagram: `${o}/v1/connect/instagram/select-account`,
@@ -2666,11 +2683,11 @@ Hành động này không thể hoàn tác.`))
2666
2683
  ae.postMessage({ type: "channelhub:close-popup" }, "*");
2667
2684
  } catch {
2668
2685
  }
2669
- V.current && (window.removeEventListener("message", V.current), V.current = null), await ne(), v({ name: "list" });
2686
+ V.current && (window.removeEventListener("message", V.current), V.current = null), await ne(), y({ name: "list" });
2670
2687
  } catch (F) {
2671
- T(F instanceof Error ? F.message : "Lỗi kết nối");
2688
+ z(F instanceof Error ? F.message : "Lỗi kết nối");
2672
2689
  } finally {
2673
- $(!1);
2690
+ B(!1);
2674
2691
  }
2675
2692
  }
2676
2693
  return /* @__PURE__ */ n("div", { style: s.root, children: [
@@ -2679,19 +2696,19 @@ Hành động này không thể hoàn tác.`))
2679
2696
  /* @__PURE__ */ n("div", { style: s.header, children: [
2680
2697
  /* @__PURE__ */ e("div", { style: s.headerLeft, children: /* @__PURE__ */ n("div", { children: [
2681
2698
  /* @__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` })
2699
+ /* @__PURE__ */ e("div", { style: s.subtitle, children: b ? "Đang tải…" : `${h.filter((c) => c.status === "active").length} kênh đang hoạt động` })
2683
2700
  ] }) }),
2684
- /* @__PURE__ */ n("button", { style: s.addBtn, onClick: () => v({ name: "add" }), children: [
2701
+ /* @__PURE__ */ n("button", { style: s.addBtn, onClick: () => y({ name: "add" }), children: [
2685
2702
  /* @__PURE__ */ e(mt, {}),
2686
2703
  /* @__PURE__ */ e("span", { children: "Thêm kênh" })
2687
2704
  ] })
2688
2705
  ] }),
2689
2706
  /* @__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: [
2707
+ /* @__PURE__ */ e("div", { style: s.body, children: !b && h.length === 0 ? /* @__PURE__ */ n("div", { style: s.empty, children: [
2691
2708
  /* @__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 }) }),
2692
2709
  /* @__PURE__ */ e("div", { style: s.emptyTitle, children: "Chưa có kênh nào được kết nối" }),
2693
2710
  /* @__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: [
2711
+ /* @__PURE__ */ n("button", { style: s.emptyCta, onClick: () => y({ name: "add" }), children: [
2695
2712
  /* @__PURE__ */ e(mt, {}),
2696
2713
  "Kết nối kênh đầu tiên"
2697
2714
  ] })
@@ -2707,7 +2724,7 @@ Hành động này không thể hoàn tác.`))
2707
2724
  ] }),
2708
2725
  w.name === "add" && /* @__PURE__ */ n(ie, { children: [
2709
2726
  /* @__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, {}) }),
2727
+ /* @__PURE__ */ e("button", { style: s.backBtn, onClick: () => y({ name: "list" }), children: /* @__PURE__ */ e(Be, {}) }),
2711
2728
  /* @__PURE__ */ n("div", { children: [
2712
2729
  /* @__PURE__ */ e("div", { style: s.title, children: "Thêm kênh mới" }),
2713
2730
  /* @__PURE__ */ e("div", { style: s.subtitle, children: "Chọn nền tảng bạn muốn kết nối" })
@@ -2720,7 +2737,7 @@ Hành động này không thể hoàn tác.`))
2720
2737
  provider: c,
2721
2738
  apiUrl: o,
2722
2739
  onClick: () => {
2723
- c.type === "oauth" ? Z(c.id) : c.id === "telegram" ? v({ name: "connect-telegram" }) : v({ name: "connect-livechat" });
2740
+ c.type === "oauth" ? Z(c.id) : c.id === "telegram" ? y({ name: "connect-telegram" }) : y({ name: "connect-livechat" });
2724
2741
  }
2725
2742
  },
2726
2743
  c.id
@@ -2728,7 +2745,7 @@ Hành động này không thể hoàn tác.`))
2728
2745
  ] }),
2729
2746
  w.name === "connect-telegram" && /* @__PURE__ */ n(ie, { children: [
2730
2747
  /* @__PURE__ */ n("div", { style: s.connectHeader, children: [
2731
- /* @__PURE__ */ e("button", { style: s.backBtn, onClick: () => v({ name: "add" }), children: /* @__PURE__ */ e(Be, {}) }),
2748
+ /* @__PURE__ */ e("button", { style: s.backBtn, onClick: () => y({ name: "add" }), children: /* @__PURE__ */ e(Be, {}) }),
2732
2749
  /* @__PURE__ */ e(xe, { provider: "telegram", apiUrl: o, size: 44 }),
2733
2750
  /* @__PURE__ */ n("div", { children: [
2734
2751
  /* @__PURE__ */ e("div", { style: s.connectTitle, children: "Kết nối Telegram Bot" }),
@@ -2781,20 +2798,20 @@ Hành động này không thể hoàn tác.`))
2781
2798
  style: s.input,
2782
2799
  type: "text",
2783
2800
  value: I,
2784
- onChange: (c) => L(c.target.value),
2801
+ onChange: (c) => M(c.target.value),
2785
2802
  placeholder: "VD: Bot hỗ trợ cửa hàng"
2786
2803
  }
2787
2804
  )
2788
2805
  ] }),
2789
2806
  /* @__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" })
2807
+ /* @__PURE__ */ e("button", { style: s.btnSecondary, onClick: () => y({ name: "add" }), children: "Hủy" }),
2808
+ /* @__PURE__ */ e("button", { style: s.btnPrimary, disabled: j, onClick: () => void T(), children: j ? "Đang kết nối…" : "Kết nối Telegram" })
2792
2809
  ] })
2793
2810
  ] })
2794
2811
  ] }),
2795
2812
  w.name === "connect-livechat" && /* @__PURE__ */ n(ie, { children: [
2796
2813
  /* @__PURE__ */ n("div", { style: s.connectHeader, children: [
2797
- /* @__PURE__ */ e("button", { style: s.backBtn, onClick: () => v({ name: "add" }), children: /* @__PURE__ */ e(Be, {}) }),
2814
+ /* @__PURE__ */ e("button", { style: s.backBtn, onClick: () => y({ name: "add" }), children: /* @__PURE__ */ e(Be, {}) }),
2798
2815
  /* @__PURE__ */ e(xe, { provider: "livechat", apiUrl: o, size: 44 }),
2799
2816
  /* @__PURE__ */ n("div", { children: [
2800
2817
  /* @__PURE__ */ e("div", { style: s.connectTitle, children: "Tạo Live Chat Widget" }),
@@ -2837,14 +2854,14 @@ https://www.myshop.com`,
2837
2854
  /* @__PURE__ */ e("div", { style: s.inputHint, children: "Mỗi domain một dòng. Để trống để cho phép tất cả." })
2838
2855
  ] }),
2839
2856
  /* @__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" })
2857
+ /* @__PURE__ */ e("button", { style: s.btnSecondary, onClick: () => y({ name: "add" }), children: "Hủy" }),
2858
+ /* @__PURE__ */ e("button", { style: s.btnPrimary, disabled: j, onClick: () => void oe(), children: j ? "Đang tạo…" : "Tạo widget" })
2842
2859
  ] })
2843
2860
  ] })
2844
2861
  ] }),
2845
2862
  w.name === "livechat-result" && /* @__PURE__ */ n(ie, { children: [
2846
2863
  /* @__PURE__ */ n("div", { style: s.connectHeader, children: [
2847
- /* @__PURE__ */ e("button", { style: s.backBtn, onClick: () => v({ name: "list" }), children: /* @__PURE__ */ e(Be, {}) }),
2864
+ /* @__PURE__ */ e("button", { style: s.backBtn, onClick: () => y({ name: "list" }), children: /* @__PURE__ */ e(Be, {}) }),
2848
2865
  /* @__PURE__ */ e(xe, { provider: "livechat", apiUrl: o, size: 44 }),
2849
2866
  /* @__PURE__ */ n("div", { children: [
2850
2867
  /* @__PURE__ */ e("div", { style: s.connectTitle, children: "Widget đã được tạo!" }),
@@ -2865,7 +2882,7 @@ https://www.myshop.com`,
2865
2882
  /* @__PURE__ */ e("div", { style: s.codeLabel, children: "Mã nhúng" }),
2866
2883
  /* @__PURE__ */ n("div", { style: s.codeBlock, children: [
2867
2884
  /* @__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: [
2885
+ /* @__PURE__ */ e("button", { style: { ...s.copyBtn, ...L ? { background: "#166534", borderColor: "#166534", color: "#bbf7d0" } : {} }, onClick: () => O(w.embedScript, "script"), children: L ? /* @__PURE__ */ n(ie, { children: [
2869
2886
  /* @__PURE__ */ e(vt, {}),
2870
2887
  " Đã sao chép"
2871
2888
  ] }) : /* @__PURE__ */ n(ie, { children: [
@@ -2886,17 +2903,17 @@ https://www.myshop.com`,
2886
2903
  /* @__PURE__ */ e(
2887
2904
  "button",
2888
2905
  {
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, {})
2906
+ onClick: () => O(w.identitySecret, "secret"),
2907
+ style: { border: "none", background: "transparent", cursor: "pointer", color: x ? "#059669" : "#ca8a04", padding: 2, display: "flex", alignItems: "center" },
2908
+ children: x ? /* @__PURE__ */ e(vt, {}) : /* @__PURE__ */ e(xt, {})
2892
2909
  }
2893
2910
  )
2894
2911
  ] }),
2895
2912
  /* @__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
2913
  ] }),
2897
2914
  /* @__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" })
2915
+ /* @__PURE__ */ e("button", { style: s.btnSecondary, onClick: () => y({ name: "list" }), children: "Về danh sách" }),
2916
+ /* @__PURE__ */ e("button", { style: s.btnPrimary, onClick: () => y({ name: "add" }), children: "Thêm kênh khác" })
2900
2917
  ] })
2901
2918
  ] })
2902
2919
  ] }),
@@ -2906,7 +2923,7 @@ https://www.myshop.com`,
2906
2923
  /* @__PURE__ */ n("div", { children: [
2907
2924
  /* @__PURE__ */ n("div", { style: s.title, children: [
2908
2925
  "Đang xác thực ",
2909
- Ue[w.provider]
2926
+ Oe[w.provider]
2910
2927
  ] }),
2911
2928
  /* @__PURE__ */ e("div", { style: s.subtitle, children: "Vui lòng hoàn thành trong cửa sổ bật lên" })
2912
2929
  ] })
@@ -2942,11 +2959,11 @@ https://www.myshop.com`,
2942
2959
  ] }),
2943
2960
  /* @__PURE__ */ n("div", { style: s.oauthTitle, children: [
2944
2961
  "Đang chờ xác thực với ",
2945
- Ue[w.provider]
2962
+ Oe[w.provider]
2946
2963
  ] }),
2947
2964
  /* @__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
2965
  /* @__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]}` }),
2966
+ /* @__PURE__ */ e(Qe, { done: !0, label: `Đã mở cửa sổ ${Oe[w.provider]}` }),
2950
2967
  /* @__PURE__ */ e(Qe, { active: !0, label: "Đang chờ bạn đăng nhập & cấp quyền" }),
2951
2968
  /* @__PURE__ */ e(Qe, { label: "Lưu kết nối & quay về" })
2952
2969
  ] }),
@@ -2964,7 +2981,7 @@ https://www.myshop.com`,
2964
2981
  ] }),
2965
2982
  /* @__PURE__ */ n("div", { style: s.connectDesc, children: [
2966
2983
  "Chọn ",
2967
- Ue[w.provider],
2984
+ Oe[w.provider],
2968
2985
  " bạn muốn kết nối với ChannelHub"
2969
2986
  ] })
2970
2987
  ] })
@@ -2972,7 +2989,7 @@ https://www.myshop.com`,
2972
2989
  /* @__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(
2973
2990
  "button",
2974
2991
  {
2975
- disabled: A,
2992
+ disabled: j,
2976
2993
  onClick: () => void se(c.id),
2977
2994
  style: {
2978
2995
  display: "flex",
@@ -2982,8 +2999,8 @@ https://www.myshop.com`,
2982
2999
  borderRadius: 12,
2983
3000
  border: "1.5px solid #e2e8f0",
2984
3001
  background: "#fff",
2985
- cursor: A ? "not-allowed" : "pointer",
2986
- opacity: A ? 0.6 : 1,
3002
+ cursor: j ? "not-allowed" : "pointer",
3003
+ opacity: j ? 0.6 : 1,
2987
3004
  textAlign: "left",
2988
3005
  fontFamily: "inherit",
2989
3006
  transition: "border-color .15s, background .15s"
@@ -2993,7 +3010,7 @@ https://www.myshop.com`,
2993
3010
  /* @__PURE__ */ e("div", { style: { fontSize: 14, fontWeight: 600, color: "#0f172a" }, children: c.name }),
2994
3011
  /* @__PURE__ */ e("div", { style: { fontSize: 11, color: "#94a3b8", fontFamily: "monospace", marginTop: 2 }, children: c.id })
2995
3012
  ] }),
2996
- /* @__PURE__ */ e("span", { style: { fontSize: 13, color: "#2563eb", fontWeight: 500 }, children: A ? "Đang kết nối…" : "Chọn →" })
3013
+ /* @__PURE__ */ e("span", { style: { fontSize: 13, color: "#2563eb", fontWeight: 500 }, children: j ? "Đang kết nối…" : "Chọn →" })
2997
3014
  ]
2998
3015
  },
2999
3016
  c.id
@@ -3013,7 +3030,7 @@ function mn(t) {
3013
3030
  return null;
3014
3031
  }
3015
3032
  function xn({ conn: t, apiUrl: i, size: r = 40 }) {
3016
- const [o, h] = y(!1), S = mn(t), m = Math.round(r * 0.28);
3033
+ const [o, h] = g(!1), S = mn(t), b = Math.round(r * 0.28);
3017
3034
  return S && !o ? /* @__PURE__ */ e(
3018
3035
  "img",
3019
3036
  {
@@ -3021,33 +3038,89 @@ function xn({ conn: t, apiUrl: i, size: r = 40 }) {
3021
3038
  alt: ct(t),
3022
3039
  referrerPolicy: "no-referrer",
3023
3040
  onError: () => h(!0),
3024
- style: { width: r, height: r, borderRadius: m, objectFit: "cover", flexShrink: 0, display: "block" }
3041
+ style: { width: r, height: r, borderRadius: b, objectFit: "cover", flexShrink: 0, display: "block" }
3025
3042
  }
3026
3043
  ) : /* @__PURE__ */ e(xe, { provider: t.provider, apiUrl: i, size: r });
3027
3044
  }
3028
3045
  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) })
3046
+ const [o, h] = g(!1), [S, b] = g(!1), [$, w] = g(!1), y = t.provider === "livechat", W = i.replace(/\/$/, ""), z = y ? `<script src="${W}/static/livechat.js" data-widget-id="${t.id}" defer><\/script>` : null, j = () => {
3047
+ z && navigator.clipboard.writeText(z).then(() => {
3048
+ w(!0), setTimeout(() => w(!1), 2e3);
3049
+ });
3050
+ };
3051
+ return /* @__PURE__ */ n("div", { style: { ...s.channelItem, flexDirection: "column", alignItems: "stretch", gap: 0 }, children: [
3052
+ /* @__PURE__ */ n("div", { style: { display: "flex", alignItems: "center", gap: 12 }, children: [
3053
+ /* @__PURE__ */ e(xn, { conn: t, apiUrl: i, size: 40 }),
3054
+ /* @__PURE__ */ n("div", { style: s.channelInfo, children: [
3055
+ /* @__PURE__ */ e("div", { style: s.channelName, children: ct(t) }),
3056
+ /* @__PURE__ */ e("div", { style: { ...s.channelMeta, userSelect: "text" }, children: fn(t) })
3057
+ ] }),
3058
+ /* @__PURE__ */ n("div", { style: s.channelActions, children: [
3059
+ /* @__PURE__ */ e("span", { style: t.status === "active" ? s.badgeActive : s.badgeInactive, children: t.status === "active" ? "Hoạt động" : t.status }),
3060
+ y && /* @__PURE__ */ e(
3061
+ "button",
3062
+ {
3063
+ style: {
3064
+ ...s.disconnectBtn,
3065
+ ...S ? { background: "#ede9fe", borderColor: "#c4b5fd", color: "#7c3aed" } : {}
3066
+ },
3067
+ onClick: () => b((B) => !B),
3068
+ children: "Mã nhúng"
3069
+ }
3070
+ ),
3071
+ /* @__PURE__ */ e(
3072
+ "button",
3073
+ {
3074
+ style: {
3075
+ ...s.disconnectBtn,
3076
+ ...o ? { background: "#fef2f2", borderColor: "#fca5a5", color: "#dc2626" } : {}
3077
+ },
3078
+ onMouseEnter: () => h(!0),
3079
+ onMouseLeave: () => h(!1),
3080
+ onClick: r,
3081
+ children: "Ngắt kết nối"
3082
+ }
3083
+ )
3084
+ ] })
3035
3085
  ] }),
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
- )
3086
+ y && S && z && /* @__PURE__ */ n("div", { style: { marginTop: 10, borderTop: "1px solid #f1f5f9", paddingTop: 10 }, children: [
3087
+ /* @__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>" }),
3088
+ /* @__PURE__ */ n("div", { style: { position: "relative" }, children: [
3089
+ /* @__PURE__ */ e("pre", { style: {
3090
+ margin: 0,
3091
+ padding: "10px 12px",
3092
+ background: "#f8f7ff",
3093
+ border: "1px solid #e9d5ff",
3094
+ borderRadius: 8,
3095
+ fontSize: 12,
3096
+ color: "#3b0764",
3097
+ overflowX: "auto",
3098
+ fontFamily: "ui-monospace, SFMono-Regular, monospace",
3099
+ lineHeight: 1.5,
3100
+ userSelect: "text"
3101
+ }, children: z }),
3102
+ /* @__PURE__ */ e(
3103
+ "button",
3104
+ {
3105
+ onClick: j,
3106
+ style: {
3107
+ position: "absolute",
3108
+ top: 6,
3109
+ right: 6,
3110
+ fontSize: 11,
3111
+ fontWeight: 600,
3112
+ padding: "3px 10px",
3113
+ borderRadius: 6,
3114
+ border: "1px solid",
3115
+ borderColor: $ ? "#059669" : "#c4b5fd",
3116
+ background: $ ? "#d1fae5" : "#fff",
3117
+ color: $ ? "#059669" : "#7c3aed",
3118
+ cursor: "pointer"
3119
+ },
3120
+ children: $ ? "✓ Đã sao chép" : "Sao chép"
3121
+ }
3122
+ )
3123
+ ] })
3051
3124
  ] })
3052
3125
  ] });
3053
3126
  }
@@ -3059,7 +3132,7 @@ const kn = [
3059
3132
  { id: "livechat", name: "Live Chat", desc: "Website widget", type: "livechat" }
3060
3133
  ];
3061
3134
  function wn({ provider: t, apiUrl: i, onClick: r }) {
3062
- const [o, h] = y(!1);
3135
+ const [o, h] = g(!1);
3063
3136
  return /* @__PURE__ */ n(
3064
3137
  "div",
3065
3138
  {
@@ -3109,28 +3182,28 @@ function Bn({
3109
3182
  icon: h,
3110
3183
  onConversationSelect: S
3111
3184
  }) {
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 () => {
3185
+ const b = (r == null ? void 0 : r.primaryColor) ?? "#2563eb", $ = typeof h == "function" ? h({ size: 20, color: "currentColor" }) : h ?? /* @__PURE__ */ e(pt, { size: 20, strokeWidth: 1.8 }), w = J(new it(t, i)), [y, W] = g(!1), [z, j] = g([]), B = J(null), C = J(null), D = z.filter((L) => (L.unreadCount ?? 0) > 0), I = D.reduce((L, v) => L + (v.unreadCount ?? 0), 0), M = we(async () => {
3113
3186
  try {
3114
- const B = await w.current.listConversations();
3115
- A(B.items);
3187
+ const L = await w.current.listConversations();
3188
+ j(L.items);
3116
3189
  } catch {
3117
3190
  }
3118
3191
  }, []);
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);
3192
+ X(() => (M(), w.current.connectSSE((v) => {
3193
+ (v === "message.new" || v === "conversation.updated") && M();
3194
+ })), [M]), X(() => {
3195
+ if (!y) return;
3196
+ const L = (v) => {
3197
+ var x, E;
3198
+ (x = B.current) != null && x.contains(v.target) || (E = C.current) != null && E.contains(v.target) || W(!1);
3126
3199
  };
3127
- 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)
3200
+ return document.addEventListener("mousedown", L), () => document.removeEventListener("mousedown", L);
3201
+ }, [y]);
3202
+ const P = async (L) => {
3203
+ if (W(!1), S == null || S(L.id, L), (L.unreadCount ?? 0) > 0)
3131
3204
  try {
3132
- await w.current.markRead(B.id), A(
3133
- (x) => x.map((b) => b.id === B.id ? { ...b, unreadCount: 0 } : b)
3205
+ await w.current.markRead(L.id), j(
3206
+ (v) => v.map((x) => x.id === L.id ? { ...x, unreadCount: 0 } : x)
3134
3207
  );
3135
3208
  } catch {
3136
3209
  }
@@ -3139,11 +3212,11 @@ function Bn({
3139
3212
  /* @__PURE__ */ n(
3140
3213
  "button",
3141
3214
  {
3142
- ref: $,
3215
+ ref: B,
3143
3216
  "aria-label": q,
3144
3217
  "aria-haspopup": "true",
3145
- "aria-expanded": v,
3146
- onClick: () => W((B) => !B),
3218
+ "aria-expanded": y,
3219
+ onClick: () => W((L) => !L),
3147
3220
  style: {
3148
3221
  position: "relative",
3149
3222
  display: "inline-grid",
@@ -3152,13 +3225,13 @@ function Bn({
3152
3225
  height: 40,
3153
3226
  border: 0,
3154
3227
  borderRadius: "50%",
3155
- background: v ? `${m}18` : "transparent",
3156
- color: v ? m : "#6b7280",
3228
+ background: y ? `${b}18` : "transparent",
3229
+ color: y ? b : "#6b7280",
3157
3230
  cursor: "pointer",
3158
3231
  transition: "background 150ms ease, color 150ms ease"
3159
3232
  },
3160
3233
  children: [
3161
- M,
3234
+ $,
3162
3235
  I > 0 && /* @__PURE__ */ e(
3163
3236
  "span",
3164
3237
  {
@@ -3186,7 +3259,7 @@ function Bn({
3186
3259
  ]
3187
3260
  }
3188
3261
  ),
3189
- v && /* @__PURE__ */ n(
3262
+ y && /* @__PURE__ */ n(
3190
3263
  "div",
3191
3264
  {
3192
3265
  ref: C,
@@ -3219,8 +3292,8 @@ function Bn({
3219
3292
  I > 0 && /* @__PURE__ */ n("span", { style: {
3220
3293
  fontSize: 11,
3221
3294
  fontWeight: 600,
3222
- background: `${m}14`,
3223
- color: m,
3295
+ background: `${b}14`,
3296
+ color: b,
3224
3297
  borderRadius: 999,
3225
3298
  padding: "2px 8px"
3226
3299
  }, children: [
@@ -3239,15 +3312,15 @@ function Bn({
3239
3312
  }, children: [
3240
3313
  /* @__PURE__ */ e(pt, { size: 28, strokeWidth: 1.5 }),
3241
3314
  /* @__PURE__ */ e("span", { style: { fontSize: 13 }, children: te })
3242
- ] }) : D.map((B) => /* @__PURE__ */ e(
3315
+ ] }) : D.map((L) => /* @__PURE__ */ e(
3243
3316
  In,
3244
3317
  {
3245
- conversation: B,
3246
- primary: m,
3318
+ conversation: L,
3319
+ primary: b,
3247
3320
  apiUrl: t,
3248
3321
  onSelect: P
3249
3322
  },
3250
- B.id
3323
+ L.id
3251
3324
  )) })
3252
3325
  ]
3253
3326
  }
@@ -3260,7 +3333,7 @@ function In({
3260
3333
  apiUrl: r,
3261
3334
  onSelect: o
3262
3335
  }) {
3263
- const [h, S] = y(!1), m = t.contactName ?? t.providerConversationKey, M = t.unreadCount ?? 0;
3336
+ const [h, S] = g(!1), b = t.contactName ?? t.providerConversationKey, $ = t.unreadCount ?? 0;
3264
3337
  return /* @__PURE__ */ n(
3265
3338
  "button",
3266
3339
  {
@@ -3274,7 +3347,7 @@ function In({
3274
3347
  padding: "10px 16px",
3275
3348
  border: 0,
3276
3349
  borderBottom: "1px solid #f1f5f9",
3277
- background: h ? "#f7f9fc" : M > 0 ? "#f0f4ff" : "#fff",
3350
+ background: h ? "#f7f9fc" : $ > 0 ? "#f0f4ff" : "#fff",
3278
3351
  textAlign: "left",
3279
3352
  cursor: "pointer",
3280
3353
  transition: "background 100ms ease",
@@ -3286,7 +3359,7 @@ function In({
3286
3359
  dt,
3287
3360
  {
3288
3361
  src: t.contactPictureUrl,
3289
- fallback: Sn(m),
3362
+ fallback: Sn(b),
3290
3363
  style: {
3291
3364
  width: 42,
3292
3365
  height: 42,
@@ -3307,15 +3380,15 @@ function In({
3307
3380
  /* @__PURE__ */ n("span", { style: { display: "flex", justifyContent: "space-between", alignItems: "center", gap: 6 }, children: [
3308
3381
  /* @__PURE__ */ e("span", { style: {
3309
3382
  fontSize: 13,
3310
- fontWeight: M > 0 ? 700 : 500,
3383
+ fontWeight: $ > 0 ? 700 : 500,
3311
3384
  color: "#172033",
3312
3385
  overflow: "hidden",
3313
3386
  textOverflow: "ellipsis",
3314
3387
  whiteSpace: "nowrap"
3315
- }, children: m }),
3388
+ }, children: b }),
3316
3389
  /* @__PURE__ */ n("span", { style: { display: "flex", alignItems: "center", gap: 5, flexShrink: 0 }, children: [
3317
3390
  /* @__PURE__ */ e("time", { style: { fontSize: 11, color: "#9aa5b5", whiteSpace: "nowrap" }, children: Cn(t.lastMessageAt) }),
3318
- M > 0 && /* @__PURE__ */ e("span", { style: {
3391
+ $ > 0 && /* @__PURE__ */ e("span", { style: {
3319
3392
  display: "inline-grid",
3320
3393
  placeItems: "center",
3321
3394
  minWidth: 18,
@@ -3326,15 +3399,15 @@ function In({
3326
3399
  fontSize: 10,
3327
3400
  fontWeight: 800,
3328
3401
  padding: "0 4px"
3329
- }, children: M > 99 ? "99+" : M })
3402
+ }, children: $ > 99 ? "99+" : $ })
3330
3403
  ] })
3331
3404
  ] }),
3332
3405
  /* @__PURE__ */ n("span", { style: {
3333
3406
  display: "block",
3334
3407
  marginTop: 2,
3335
3408
  fontSize: 12,
3336
- color: M > 0 ? "#374151" : "#9aa5b5",
3337
- fontWeight: M > 0 ? 500 : 400,
3409
+ color: $ > 0 ? "#374151" : "#9aa5b5",
3410
+ fontWeight: $ > 0 ? 500 : 400,
3338
3411
  overflow: "hidden",
3339
3412
  textOverflow: "ellipsis",
3340
3413
  whiteSpace: "nowrap"
@@ -3347,7 +3420,7 @@ function In({
3347
3420
  }
3348
3421
  );
3349
3422
  }
3350
- console.log("[ChannelHub] widget v0.1.10 loaded");
3423
+ console.log("[ChannelHub] widget v0.1.11 loaded");
3351
3424
  export {
3352
3425
  $n as ChannelHubChannels,
3353
3426
  it as ChannelHubClient,