@channelhub/widget 0.1.4 → 0.1.5

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