@channelhub/widget 0.1.3 → 0.1.4

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