react-sigma-chatbox 1.0.2 → 1.0.3
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/README.md +37 -41
- package/dist/components/Chatbox/ChatMessages.d.ts +1 -0
- package/dist/index.js +8 -8
- package/dist/index.mjs +308 -297
- package/dist/react-sigma-chatbox.css +1 -1
- package/dist/types.d.ts +10 -5
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
var
|
|
1
|
+
import ce, { useState as R, useRef as ne, useEffect as q, useMemo as K } from "react";
|
|
2
|
+
var H = { exports: {} }, W = {};
|
|
3
3
|
/**
|
|
4
4
|
* @license React
|
|
5
5
|
* react-jsx-runtime.production.js
|
|
@@ -9,29 +9,29 @@ var F = { exports: {} }, $ = {};
|
|
|
9
9
|
* This source code is licensed under the MIT license found in the
|
|
10
10
|
* LICENSE file in the root directory of this source tree.
|
|
11
11
|
*/
|
|
12
|
-
var
|
|
13
|
-
function
|
|
14
|
-
if (
|
|
15
|
-
|
|
12
|
+
var se;
|
|
13
|
+
function de() {
|
|
14
|
+
if (se) return W;
|
|
15
|
+
se = 1;
|
|
16
16
|
var r = Symbol.for("react.transitional.element"), u = Symbol.for("react.fragment");
|
|
17
|
-
function o
|
|
18
|
-
var
|
|
19
|
-
if (c !== void 0 && (
|
|
17
|
+
function s(o, l, c) {
|
|
18
|
+
var x = null;
|
|
19
|
+
if (c !== void 0 && (x = "" + c), l.key !== void 0 && (x = "" + l.key), "key" in l) {
|
|
20
20
|
c = {};
|
|
21
21
|
for (var i in l)
|
|
22
22
|
i !== "key" && (c[i] = l[i]);
|
|
23
23
|
} else c = l;
|
|
24
24
|
return l = c.ref, {
|
|
25
25
|
$$typeof: r,
|
|
26
|
-
type:
|
|
27
|
-
key:
|
|
26
|
+
type: o,
|
|
27
|
+
key: x,
|
|
28
28
|
ref: l !== void 0 ? l : null,
|
|
29
29
|
props: c
|
|
30
30
|
};
|
|
31
31
|
}
|
|
32
|
-
return
|
|
32
|
+
return W.Fragment = u, W.jsx = s, W.jsxs = s, W;
|
|
33
33
|
}
|
|
34
|
-
var
|
|
34
|
+
var Y = {};
|
|
35
35
|
/**
|
|
36
36
|
* @license React
|
|
37
37
|
* react-jsx-runtime.development.js
|
|
@@ -41,26 +41,26 @@ var D = {};
|
|
|
41
41
|
* This source code is licensed under the MIT license found in the
|
|
42
42
|
* LICENSE file in the root directory of this source tree.
|
|
43
43
|
*/
|
|
44
|
-
var
|
|
45
|
-
function
|
|
46
|
-
return
|
|
44
|
+
var ae;
|
|
45
|
+
function ue() {
|
|
46
|
+
return ae || (ae = 1, process.env.NODE_ENV !== "production" && (function() {
|
|
47
47
|
function r(t) {
|
|
48
48
|
if (t == null) return null;
|
|
49
49
|
if (typeof t == "function")
|
|
50
|
-
return t.$$typeof ===
|
|
50
|
+
return t.$$typeof === N ? null : t.displayName || t.name || null;
|
|
51
51
|
if (typeof t == "string") return t;
|
|
52
52
|
switch (t) {
|
|
53
|
-
case
|
|
53
|
+
case T:
|
|
54
54
|
return "Fragment";
|
|
55
|
-
case
|
|
55
|
+
case X:
|
|
56
56
|
return "Profiler";
|
|
57
57
|
case C:
|
|
58
58
|
return "StrictMode";
|
|
59
|
-
case
|
|
59
|
+
case V:
|
|
60
60
|
return "Suspense";
|
|
61
|
-
case
|
|
61
|
+
case J:
|
|
62
62
|
return "SuspenseList";
|
|
63
|
-
case
|
|
63
|
+
case G:
|
|
64
64
|
return "Activity";
|
|
65
65
|
}
|
|
66
66
|
if (typeof t == "object")
|
|
@@ -69,19 +69,19 @@ function ce() {
|
|
|
69
69
|
), t.$$typeof) {
|
|
70
70
|
case _:
|
|
71
71
|
return "Portal";
|
|
72
|
-
case
|
|
72
|
+
case B:
|
|
73
73
|
return t.displayName || "Context";
|
|
74
|
-
case
|
|
74
|
+
case z:
|
|
75
75
|
return (t._context.displayName || "Context") + ".Consumer";
|
|
76
|
-
case
|
|
77
|
-
var
|
|
78
|
-
return t = t.displayName, t || (t =
|
|
79
|
-
case
|
|
80
|
-
return
|
|
81
|
-
case
|
|
82
|
-
|
|
76
|
+
case U:
|
|
77
|
+
var a = t.render;
|
|
78
|
+
return t = t.displayName, t || (t = a.displayName || a.name || "", t = t !== "" ? "ForwardRef(" + t + ")" : "ForwardRef"), t;
|
|
79
|
+
case v:
|
|
80
|
+
return a = t.displayName || null, a !== null ? a : r(t.type) || "Memo";
|
|
81
|
+
case A:
|
|
82
|
+
a = t._payload, t = t._init;
|
|
83
83
|
try {
|
|
84
|
-
return r(t(
|
|
84
|
+
return r(t(a));
|
|
85
85
|
} catch {
|
|
86
86
|
}
|
|
87
87
|
}
|
|
@@ -90,77 +90,77 @@ function ce() {
|
|
|
90
90
|
function u(t) {
|
|
91
91
|
return "" + t;
|
|
92
92
|
}
|
|
93
|
-
function
|
|
93
|
+
function s(t) {
|
|
94
94
|
try {
|
|
95
95
|
u(t);
|
|
96
|
-
var
|
|
96
|
+
var a = !1;
|
|
97
97
|
} catch {
|
|
98
|
-
|
|
98
|
+
a = !0;
|
|
99
99
|
}
|
|
100
|
-
if (
|
|
101
|
-
|
|
102
|
-
var
|
|
103
|
-
return
|
|
104
|
-
|
|
100
|
+
if (a) {
|
|
101
|
+
a = console;
|
|
102
|
+
var f = a.error, p = typeof Symbol == "function" && Symbol.toStringTag && t[Symbol.toStringTag] || t.constructor.name || "Object";
|
|
103
|
+
return f.call(
|
|
104
|
+
a,
|
|
105
105
|
"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
|
|
106
|
-
|
|
106
|
+
p
|
|
107
107
|
), u(t);
|
|
108
108
|
}
|
|
109
109
|
}
|
|
110
|
-
function
|
|
111
|
-
if (t ===
|
|
112
|
-
if (typeof t == "object" && t !== null && t.$$typeof ===
|
|
110
|
+
function o(t) {
|
|
111
|
+
if (t === T) return "<>";
|
|
112
|
+
if (typeof t == "object" && t !== null && t.$$typeof === A)
|
|
113
113
|
return "<...>";
|
|
114
114
|
try {
|
|
115
|
-
var
|
|
116
|
-
return
|
|
115
|
+
var a = r(t);
|
|
116
|
+
return a ? "<" + a + ">" : "<...>";
|
|
117
117
|
} catch {
|
|
118
118
|
return "<...>";
|
|
119
119
|
}
|
|
120
120
|
}
|
|
121
121
|
function l() {
|
|
122
|
-
var t =
|
|
122
|
+
var t = y.A;
|
|
123
123
|
return t === null ? null : t.getOwner();
|
|
124
124
|
}
|
|
125
125
|
function c() {
|
|
126
126
|
return Error("react-stack-top-frame");
|
|
127
127
|
}
|
|
128
|
-
function
|
|
129
|
-
if (
|
|
130
|
-
var
|
|
131
|
-
if (
|
|
128
|
+
function x(t) {
|
|
129
|
+
if (k.call(t, "key")) {
|
|
130
|
+
var a = Object.getOwnPropertyDescriptor(t, "key").get;
|
|
131
|
+
if (a && a.isReactWarning) return !1;
|
|
132
132
|
}
|
|
133
133
|
return t.key !== void 0;
|
|
134
134
|
}
|
|
135
|
-
function i(t,
|
|
136
|
-
function
|
|
137
|
-
|
|
135
|
+
function i(t, a) {
|
|
136
|
+
function f() {
|
|
137
|
+
I || (I = !0, console.error(
|
|
138
138
|
"%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",
|
|
139
|
-
|
|
139
|
+
a
|
|
140
140
|
));
|
|
141
141
|
}
|
|
142
|
-
|
|
143
|
-
get:
|
|
142
|
+
f.isReactWarning = !0, Object.defineProperty(t, "key", {
|
|
143
|
+
get: f,
|
|
144
144
|
configurable: !0
|
|
145
145
|
});
|
|
146
146
|
}
|
|
147
|
-
function
|
|
147
|
+
function h() {
|
|
148
148
|
var t = r(this.type);
|
|
149
|
-
return
|
|
149
|
+
return M[t] || (M[t] = !0, console.error(
|
|
150
150
|
"Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release."
|
|
151
151
|
)), t = this.props.ref, t !== void 0 ? t : null;
|
|
152
152
|
}
|
|
153
|
-
function
|
|
154
|
-
var
|
|
153
|
+
function n(t, a, f, p, F, Q) {
|
|
154
|
+
var g = f.ref;
|
|
155
155
|
return t = {
|
|
156
156
|
$$typeof: S,
|
|
157
157
|
type: t,
|
|
158
|
-
key:
|
|
159
|
-
props:
|
|
160
|
-
_owner:
|
|
161
|
-
}, (
|
|
158
|
+
key: a,
|
|
159
|
+
props: f,
|
|
160
|
+
_owner: p
|
|
161
|
+
}, (g !== void 0 ? g : null) !== null ? Object.defineProperty(t, "ref", {
|
|
162
162
|
enumerable: !1,
|
|
163
|
-
get:
|
|
163
|
+
get: h
|
|
164
164
|
}) : Object.defineProperty(t, "ref", { enumerable: !1, value: null }), t._store = {}, Object.defineProperty(t._store, "validated", {
|
|
165
165
|
configurable: !1,
|
|
166
166
|
enumerable: !1,
|
|
@@ -175,119 +175,119 @@ function ce() {
|
|
|
175
175
|
configurable: !1,
|
|
176
176
|
enumerable: !1,
|
|
177
177
|
writable: !0,
|
|
178
|
-
value:
|
|
178
|
+
value: F
|
|
179
179
|
}), Object.defineProperty(t, "_debugTask", {
|
|
180
180
|
configurable: !1,
|
|
181
181
|
enumerable: !1,
|
|
182
182
|
writable: !0,
|
|
183
|
-
value:
|
|
183
|
+
value: Q
|
|
184
184
|
}), Object.freeze && (Object.freeze(t.props), Object.freeze(t)), t;
|
|
185
185
|
}
|
|
186
|
-
function
|
|
187
|
-
var
|
|
188
|
-
if (
|
|
189
|
-
if (
|
|
190
|
-
if (
|
|
191
|
-
for (
|
|
192
|
-
g
|
|
193
|
-
Object.freeze && Object.freeze(
|
|
186
|
+
function d(t, a, f, p, F, Q) {
|
|
187
|
+
var g = a.children;
|
|
188
|
+
if (g !== void 0)
|
|
189
|
+
if (p)
|
|
190
|
+
if (O(g)) {
|
|
191
|
+
for (p = 0; p < g.length; p++)
|
|
192
|
+
m(g[p]);
|
|
193
|
+
Object.freeze && Object.freeze(g);
|
|
194
194
|
} else
|
|
195
195
|
console.error(
|
|
196
196
|
"React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."
|
|
197
197
|
);
|
|
198
|
-
else g
|
|
199
|
-
if (
|
|
200
|
-
|
|
201
|
-
var
|
|
202
|
-
return
|
|
198
|
+
else m(g);
|
|
199
|
+
if (k.call(a, "key")) {
|
|
200
|
+
g = r(t);
|
|
201
|
+
var P = Object.keys(a).filter(function(ie) {
|
|
202
|
+
return ie !== "key";
|
|
203
203
|
});
|
|
204
|
-
|
|
204
|
+
p = 0 < P.length ? "{key: someKey, " + P.join(": ..., ") + ": ...}" : "{key: someKey}", re[g + p] || (P = 0 < P.length ? "{" + P.join(": ..., ") + ": ...}" : "{}", console.error(
|
|
205
205
|
`A props object containing a "key" prop is being spread into JSX:
|
|
206
206
|
let props = %s;
|
|
207
207
|
<%s {...props} />
|
|
208
208
|
React keys must be passed directly to JSX without using spread:
|
|
209
209
|
let props = %s;
|
|
210
210
|
<%s key={someKey} {...props} />`,
|
|
211
|
-
f,
|
|
212
211
|
p,
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
212
|
+
g,
|
|
213
|
+
P,
|
|
214
|
+
g
|
|
215
|
+
), re[g + p] = !0);
|
|
216
216
|
}
|
|
217
|
-
if (
|
|
218
|
-
|
|
219
|
-
for (var
|
|
220
|
-
|
|
221
|
-
} else
|
|
222
|
-
return
|
|
223
|
-
|
|
217
|
+
if (g = null, f !== void 0 && (s(f), g = "" + f), x(a) && (s(a.key), g = "" + a.key), "key" in a) {
|
|
218
|
+
f = {};
|
|
219
|
+
for (var Z in a)
|
|
220
|
+
Z !== "key" && (f[Z] = a[Z]);
|
|
221
|
+
} else f = a;
|
|
222
|
+
return g && i(
|
|
223
|
+
f,
|
|
224
224
|
typeof t == "function" ? t.displayName || t.name || "Unknown" : t
|
|
225
|
-
),
|
|
225
|
+
), n(
|
|
226
226
|
t,
|
|
227
|
-
|
|
228
|
-
|
|
227
|
+
g,
|
|
228
|
+
f,
|
|
229
229
|
l(),
|
|
230
|
-
|
|
231
|
-
|
|
230
|
+
F,
|
|
231
|
+
Q
|
|
232
232
|
);
|
|
233
233
|
}
|
|
234
|
-
function
|
|
235
|
-
|
|
234
|
+
function m(t) {
|
|
235
|
+
j(t) ? t._store && (t._store.validated = 1) : typeof t == "object" && t !== null && t.$$typeof === A && (t._payload.status === "fulfilled" ? j(t._payload.value) && t._payload.value._store && (t._payload.value._store.validated = 1) : t._store && (t._store.validated = 1));
|
|
236
236
|
}
|
|
237
|
-
function
|
|
237
|
+
function j(t) {
|
|
238
238
|
return typeof t == "object" && t !== null && t.$$typeof === S;
|
|
239
239
|
}
|
|
240
|
-
var
|
|
240
|
+
var b = ce, S = Symbol.for("react.transitional.element"), _ = Symbol.for("react.portal"), T = Symbol.for("react.fragment"), C = Symbol.for("react.strict_mode"), X = Symbol.for("react.profiler"), z = Symbol.for("react.consumer"), B = Symbol.for("react.context"), U = Symbol.for("react.forward_ref"), V = Symbol.for("react.suspense"), J = Symbol.for("react.suspense_list"), v = Symbol.for("react.memo"), A = Symbol.for("react.lazy"), G = Symbol.for("react.activity"), N = Symbol.for("react.client.reference"), y = b.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, k = Object.prototype.hasOwnProperty, O = Array.isArray, D = console.createTask ? console.createTask : function() {
|
|
241
241
|
return null;
|
|
242
242
|
};
|
|
243
|
-
|
|
243
|
+
b = {
|
|
244
244
|
react_stack_bottom_frame: function(t) {
|
|
245
245
|
return t();
|
|
246
246
|
}
|
|
247
247
|
};
|
|
248
|
-
var
|
|
249
|
-
|
|
248
|
+
var I, M = {}, ee = b.react_stack_bottom_frame.bind(
|
|
249
|
+
b,
|
|
250
250
|
c
|
|
251
|
-
)(),
|
|
252
|
-
|
|
253
|
-
var
|
|
254
|
-
return
|
|
251
|
+
)(), te = D(o(c)), re = {};
|
|
252
|
+
Y.Fragment = T, Y.jsx = function(t, a, f) {
|
|
253
|
+
var p = 1e4 > y.recentlyCreatedOwnerStacks++;
|
|
254
|
+
return d(
|
|
255
255
|
t,
|
|
256
|
-
|
|
257
|
-
|
|
256
|
+
a,
|
|
257
|
+
f,
|
|
258
258
|
!1,
|
|
259
|
-
|
|
260
|
-
|
|
259
|
+
p ? Error("react-stack-top-frame") : ee,
|
|
260
|
+
p ? D(o(t)) : te
|
|
261
261
|
);
|
|
262
|
-
},
|
|
263
|
-
var
|
|
264
|
-
return
|
|
262
|
+
}, Y.jsxs = function(t, a, f) {
|
|
263
|
+
var p = 1e4 > y.recentlyCreatedOwnerStacks++;
|
|
264
|
+
return d(
|
|
265
265
|
t,
|
|
266
|
-
|
|
267
|
-
|
|
266
|
+
a,
|
|
267
|
+
f,
|
|
268
268
|
!0,
|
|
269
|
-
|
|
270
|
-
|
|
269
|
+
p ? Error("react-stack-top-frame") : ee,
|
|
270
|
+
p ? D(o(t)) : te
|
|
271
271
|
);
|
|
272
272
|
};
|
|
273
|
-
})()),
|
|
273
|
+
})()), Y;
|
|
274
274
|
}
|
|
275
|
-
var
|
|
276
|
-
function
|
|
277
|
-
return
|
|
275
|
+
var oe;
|
|
276
|
+
function he() {
|
|
277
|
+
return oe || (oe = 1, process.env.NODE_ENV === "production" ? H.exports = de() : H.exports = ue()), H.exports;
|
|
278
278
|
}
|
|
279
|
-
var e =
|
|
280
|
-
const
|
|
279
|
+
var e = he(), E = /* @__PURE__ */ ((r) => (r.TEXT = "text", r.PRODUCT_LIST = "product_list", r.LOADING = "loading", r))(E || {}), w = /* @__PURE__ */ ((r) => (r.USER = "user", r.AI = "ai", r))(w || {});
|
|
280
|
+
const me = ({
|
|
281
281
|
title: r,
|
|
282
282
|
primaryColor: u,
|
|
283
|
-
onClose:
|
|
284
|
-
onReset:
|
|
283
|
+
onClose: s,
|
|
284
|
+
onReset: o,
|
|
285
285
|
onToggleExpand: l,
|
|
286
286
|
isExpanded: c,
|
|
287
|
-
language:
|
|
287
|
+
language: x,
|
|
288
288
|
onLanguageChange: i
|
|
289
289
|
}) => {
|
|
290
|
-
const
|
|
290
|
+
const h = [
|
|
291
291
|
{ value: "en", label: "EN" },
|
|
292
292
|
{ value: "vi", label: "VI" },
|
|
293
293
|
{ value: "ja", label: "JA" }
|
|
@@ -302,7 +302,7 @@ const ue = ({
|
|
|
302
302
|
"img",
|
|
303
303
|
{
|
|
304
304
|
src: "https://fptshop.com.vn/img/bitu/bitu-avatar.png",
|
|
305
|
-
onError: (
|
|
305
|
+
onError: (n) => n.currentTarget.src = "https://cdn-icons-png.flaticon.com/512/4712/4712035.png",
|
|
306
306
|
className: "w-full h-full object-contain",
|
|
307
307
|
alt: "Bot Icon"
|
|
308
308
|
}
|
|
@@ -324,11 +324,11 @@ const ue = ({
|
|
|
324
324
|
/* @__PURE__ */ e.jsx(
|
|
325
325
|
"select",
|
|
326
326
|
{
|
|
327
|
-
value:
|
|
328
|
-
onChange: (
|
|
327
|
+
value: x,
|
|
328
|
+
onChange: (n) => i(n.target.value),
|
|
329
329
|
className: "appearance-none bg-white/50 border border-gray-200 rounded-lg px-2 pr-5 py-1 text-[10px] font-black text-indigo-600 cursor-pointer hover:bg-white transition-all focus:outline-none focus:ring-2 focus:ring-indigo-100 uppercase",
|
|
330
330
|
title: "Select language",
|
|
331
|
-
children:
|
|
331
|
+
children: h.map((n) => /* @__PURE__ */ e.jsx("option", { value: n.value, className: "font-sans font-bold", children: n.label }, n.value))
|
|
332
332
|
}
|
|
333
333
|
),
|
|
334
334
|
/* @__PURE__ */ e.jsx("div", { className: "absolute right-1.5 top-1/2 -translate-y-1/2 pointer-events-none text-indigo-400", children: /* @__PURE__ */ e.jsx("svg", { width: "8", height: "8", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "4", strokeLinecap: "round", strokeLinejoin: "round", children: /* @__PURE__ */ e.jsx("path", { d: "m6 9 6 6 6-6" }) }) })
|
|
@@ -336,7 +336,7 @@ const ue = ({
|
|
|
336
336
|
/* @__PURE__ */ e.jsx(
|
|
337
337
|
"button",
|
|
338
338
|
{
|
|
339
|
-
onClick:
|
|
339
|
+
onClick: o,
|
|
340
340
|
className: "w-8 h-8 flex items-center justify-center rounded-lg hover:bg-white/60 text-gray-500 hover:text-indigo-600 transition-all",
|
|
341
341
|
title: "Reset chat",
|
|
342
342
|
children: /* @__PURE__ */ e.jsxs("svg", { width: "15", height: "15", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2.5", strokeLinecap: "round", strokeLinejoin: "round", children: [
|
|
@@ -369,7 +369,7 @@ const ue = ({
|
|
|
369
369
|
/* @__PURE__ */ e.jsx(
|
|
370
370
|
"button",
|
|
371
371
|
{
|
|
372
|
-
onClick:
|
|
372
|
+
onClick: s,
|
|
373
373
|
className: "w-8 h-8 flex items-center justify-center rounded-lg hover:bg-red-50 text-gray-500 hover:text-red-500 transition-all",
|
|
374
374
|
title: "Close",
|
|
375
375
|
children: /* @__PURE__ */ e.jsxs("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2.5", strokeLinecap: "round", strokeLinejoin: "round", children: [
|
|
@@ -382,7 +382,7 @@ const ue = ({
|
|
|
382
382
|
]
|
|
383
383
|
}
|
|
384
384
|
);
|
|
385
|
-
},
|
|
385
|
+
}, xe = ({ product: r, primaryColor: u }) => /* @__PURE__ */ e.jsxs("div", { className: "min-w-[170px] max-w-[170px] bg-white rounded-xl border border-gray-50 shadow-sm overflow-hidden flex flex-col hover:shadow-lg transition-all duration-300 group", children: [
|
|
386
386
|
/* @__PURE__ */ e.jsxs("div", { className: "relative h-32 w-full bg-white flex items-center justify-center p-2", children: [
|
|
387
387
|
/* @__PURE__ */ e.jsx(
|
|
388
388
|
"img",
|
|
@@ -407,30 +407,30 @@ const ue = ({
|
|
|
407
407
|
{
|
|
408
408
|
className: "w-full py-1.5 rounded-lg text-[11px] font-bold border transition-all duration-300 active:scale-95 shadow-sm",
|
|
409
409
|
style: { borderColor: u, color: u },
|
|
410
|
-
onMouseEnter: (
|
|
411
|
-
|
|
410
|
+
onMouseEnter: (s) => {
|
|
411
|
+
s.currentTarget.style.backgroundColor = u, s.currentTarget.style.color = "white";
|
|
412
412
|
},
|
|
413
|
-
onMouseLeave: (
|
|
414
|
-
|
|
413
|
+
onMouseLeave: (s) => {
|
|
414
|
+
s.currentTarget.style.backgroundColor = "transparent", s.currentTarget.style.color = u;
|
|
415
415
|
},
|
|
416
416
|
children: "Chọn mua"
|
|
417
417
|
}
|
|
418
418
|
)
|
|
419
419
|
] })
|
|
420
|
-
] }),
|
|
420
|
+
] }), $ = (r) => {
|
|
421
421
|
const u = /(\*\*.*?\*\*|\[.*?\]\(.*?\))/g;
|
|
422
|
-
return r.split(u).map((
|
|
423
|
-
if (
|
|
424
|
-
const
|
|
425
|
-
return /* @__PURE__ */ e.jsx("strong", { className: "font-bold text-gray-900", children:
|
|
422
|
+
return r.split(u).map((o, l) => {
|
|
423
|
+
if (o.startsWith("**") && o.endsWith("**")) {
|
|
424
|
+
const x = o.slice(2, -2);
|
|
425
|
+
return /* @__PURE__ */ e.jsx("strong", { className: "font-bold text-gray-900", children: x }, l);
|
|
426
426
|
}
|
|
427
|
-
const c =
|
|
427
|
+
const c = o.match(/\[(.*?)\]\((.*?)\)/);
|
|
428
428
|
if (c) {
|
|
429
|
-
const [
|
|
429
|
+
const [x, i, h] = c;
|
|
430
430
|
return /* @__PURE__ */ e.jsx(
|
|
431
431
|
"a",
|
|
432
432
|
{
|
|
433
|
-
href:
|
|
433
|
+
href: h,
|
|
434
434
|
target: "_blank",
|
|
435
435
|
rel: "noopener noreferrer",
|
|
436
436
|
className: "text-blue-600 hover:underline break-all font-semibold",
|
|
@@ -439,71 +439,72 @@ const ue = ({
|
|
|
439
439
|
l
|
|
440
440
|
);
|
|
441
441
|
}
|
|
442
|
-
return
|
|
442
|
+
return o;
|
|
443
443
|
});
|
|
444
|
-
},
|
|
445
|
-
const u = r.split(`
|
|
446
|
-
`),
|
|
447
|
-
let
|
|
448
|
-
const c = (
|
|
449
|
-
if (
|
|
450
|
-
const
|
|
451
|
-
|
|
452
|
-
/* @__PURE__ */ e.jsx("div", { className: "my-4 overflow-x-auto border border-
|
|
453
|
-
/* @__PURE__ */ e.jsx("thead", { className: "bg-
|
|
454
|
-
/* @__PURE__ */ e.jsx("tbody", { className: "divide-y divide-
|
|
455
|
-
] }) }, `table-${
|
|
456
|
-
),
|
|
444
|
+
}, fe = ({ text: r }) => {
|
|
445
|
+
const u = r.replace(/\r/g, "").split(`
|
|
446
|
+
`), s = [];
|
|
447
|
+
let o = [], l = !1;
|
|
448
|
+
const c = (x) => {
|
|
449
|
+
if (o.length > 0) {
|
|
450
|
+
const h = o.length > 1 && o[1].every((n) => n.trim().match(/^:?-+:?$/)) ? [o[0], ...o.slice(2)] : o;
|
|
451
|
+
h.length > 0 && s.push(
|
|
452
|
+
/* @__PURE__ */ e.jsx("div", { className: "my-4 overflow-x-auto border border-slate-200 rounded-xl shadow-sm bg-white", children: /* @__PURE__ */ e.jsxs("table", { className: "min-w-full border-collapse text-[13px] leading-normal", children: [
|
|
453
|
+
/* @__PURE__ */ e.jsx("thead", { className: "bg-slate-50 border-b border-slate-200", children: /* @__PURE__ */ e.jsx("tr", { children: h[0].map((n, d) => /* @__PURE__ */ e.jsx("th", { className: "px-4 py-3 text-left font-bold text-slate-700 border-r last:border-r-0 border-slate-200 whitespace-nowrap", children: $(n.trim()) }, d)) }) }),
|
|
454
|
+
/* @__PURE__ */ e.jsx("tbody", { className: "divide-y divide-slate-100", children: h.slice(1).map((n, d) => /* @__PURE__ */ e.jsx("tr", { className: "hover:bg-slate-50/50 transition-colors", children: n.map((m, j) => /* @__PURE__ */ e.jsx("td", { className: "px-4 py-3 text-slate-600 border-r last:border-r-0 border-slate-200 align-top", children: $(m.trim()) }, j)) }, d)) })
|
|
455
|
+
] }) }, `table-wrapper-${x}`)
|
|
456
|
+
), o = [], l = !1;
|
|
457
457
|
}
|
|
458
458
|
};
|
|
459
|
-
return u.forEach((
|
|
460
|
-
const
|
|
461
|
-
if (
|
|
462
|
-
|
|
463
|
-
|
|
459
|
+
return u.forEach((x, i) => {
|
|
460
|
+
const h = x.trim();
|
|
461
|
+
if (h.includes("|") && (h.startsWith("|") || h.split("|").length > 1)) {
|
|
462
|
+
let m = h.split("|");
|
|
463
|
+
h.startsWith("|") && m.shift(), h.endsWith("|") && m.pop(), o.push(m), l = !0;
|
|
464
464
|
return;
|
|
465
465
|
} else l && c(i);
|
|
466
|
-
const
|
|
467
|
-
if (
|
|
468
|
-
const
|
|
469
|
-
|
|
466
|
+
const n = h.match(/^(#{1,4})\s+(.*)$/);
|
|
467
|
+
if (n) {
|
|
468
|
+
const m = n[1].length, j = n[2], b = m === 1 ? "text-xl font-bold mb-4 mt-6 first:mt-1" : m === 2 ? "text-lg font-bold mb-3 mt-5" : "text-[13px] font-black mb-2 mt-5 text-indigo-600 uppercase tracking-widest";
|
|
469
|
+
s.push(/* @__PURE__ */ e.jsx("div", { className: b, children: $(j) }, i));
|
|
470
470
|
return;
|
|
471
471
|
}
|
|
472
|
-
const
|
|
473
|
-
if (
|
|
474
|
-
const
|
|
475
|
-
|
|
476
|
-
/* @__PURE__ */ e.jsxs("div", { className: "flex gap-
|
|
477
|
-
/* @__PURE__ */ e.jsx("span", { className: "text-indigo-400 flex-shrink-0 mt-2 w-1.5 h-1.5 bg-indigo-400 rounded-full" }),
|
|
478
|
-
/* @__PURE__ */ e.jsx("div", { className: "flex-1 leading-relaxed text-
|
|
472
|
+
const d = h.match(/^[*+-]\s+(.*)$/);
|
|
473
|
+
if (d) {
|
|
474
|
+
const m = d[1];
|
|
475
|
+
s.push(
|
|
476
|
+
/* @__PURE__ */ e.jsxs("div", { className: "flex gap-3 pl-1 mb-2 items-start group", children: [
|
|
477
|
+
/* @__PURE__ */ e.jsx("span", { className: "text-indigo-400 flex-shrink-0 mt-2 w-1.5 h-1.5 bg-indigo-400 rounded-full group-hover:scale-125 transition-transform" }),
|
|
478
|
+
/* @__PURE__ */ e.jsx("div", { className: "flex-1 leading-relaxed text-slate-700", children: $(m) })
|
|
479
479
|
] }, i)
|
|
480
480
|
);
|
|
481
481
|
return;
|
|
482
482
|
}
|
|
483
|
-
if (
|
|
484
|
-
|
|
483
|
+
if (h === "") {
|
|
484
|
+
s.push(/* @__PURE__ */ e.jsx("div", { className: "h-3" }, i));
|
|
485
485
|
return;
|
|
486
486
|
}
|
|
487
|
-
|
|
488
|
-
/* @__PURE__ */ e.jsx("div", { className: "mb-1 leading-relaxed text-
|
|
487
|
+
s.push(
|
|
488
|
+
/* @__PURE__ */ e.jsx("div", { className: "mb-1.5 leading-relaxed text-slate-700", children: $(x) }, i)
|
|
489
489
|
);
|
|
490
|
-
}), l && c(u.length), /* @__PURE__ */ e.jsx("div", { className: "markdown-
|
|
491
|
-
},
|
|
490
|
+
}), l && c(u.length), /* @__PURE__ */ e.jsx("div", { className: "markdown-render w-full", children: s });
|
|
491
|
+
}, pe = ({
|
|
492
492
|
messages: r,
|
|
493
493
|
isLoading: u,
|
|
494
|
+
description: s,
|
|
494
495
|
quickReplies: o,
|
|
495
|
-
onQuickReply:
|
|
496
|
-
primaryColor:
|
|
497
|
-
renderMarkdown:
|
|
496
|
+
onQuickReply: l,
|
|
497
|
+
primaryColor: c,
|
|
498
|
+
renderMarkdown: x = !1
|
|
498
499
|
}) => {
|
|
499
|
-
const
|
|
500
|
+
const i = "https://fptshop.com.vn/img/bitu/bitu-avatar.png", h = "https://cdn-icons-png.flaticon.com/512/4712/4712035.png";
|
|
500
501
|
return /* @__PURE__ */ e.jsxs("div", { className: "flex flex-col gap-8 pb-4", children: [
|
|
501
|
-
/* @__PURE__ */ e.jsxs("div", { className: "flex flex-col items-center justify-center
|
|
502
|
+
/* @__PURE__ */ e.jsxs("div", { className: "flex flex-col items-center justify-center pt-4 text-center animate-msg", children: [
|
|
502
503
|
/* @__PURE__ */ e.jsx("div", { className: "relative mb-5", children: /* @__PURE__ */ e.jsx("div", { className: "w-20 h-20 flex items-center justify-center", children: /* @__PURE__ */ e.jsx(
|
|
503
504
|
"img",
|
|
504
505
|
{
|
|
505
|
-
src:
|
|
506
|
-
onError: (
|
|
506
|
+
src: i,
|
|
507
|
+
onError: (n) => n.currentTarget.src = h,
|
|
507
508
|
className: "w-full h-full object-contain",
|
|
508
509
|
alt: "Sigma AI Hero"
|
|
509
510
|
}
|
|
@@ -512,58 +513,55 @@ const ue = ({
|
|
|
512
513
|
"Sigma ",
|
|
513
514
|
/* @__PURE__ */ e.jsx("span", { className: "bg-indigo-600 text-white text-[10px] px-1.5 py-0.5 rounded-md leading-none ml-1 uppercase font-bold tracking-tight", children: "AI" })
|
|
514
515
|
] }),
|
|
515
|
-
/* @__PURE__ */ e.jsx("div", { className: "text-[14px] text-gray-600 mt-3 leading-relaxed px-4 max-w-[280px]", children: /* @__PURE__ */ e.
|
|
516
|
-
/* @__PURE__ */ e.jsx("span", { className: "font-bold text-gray-800", children: "Sigma Assistant" }),
|
|
517
|
-
" hỗ trợ bạn mọi lúc mọi nơi"
|
|
518
|
-
] }) })
|
|
516
|
+
/* @__PURE__ */ e.jsx("div", { className: "text-[14px] text-gray-600 mt-3 leading-relaxed px-4 max-w-[280px]", children: s && /* @__PURE__ */ e.jsx("div", { className: "bot-description", children: $(s) }) })
|
|
519
517
|
] }),
|
|
520
|
-
r.map((
|
|
518
|
+
r.map((n, d) => /* @__PURE__ */ e.jsxs(
|
|
521
519
|
"div",
|
|
522
520
|
{
|
|
523
|
-
className: `flex flex-col animate-msg ${
|
|
521
|
+
className: `flex flex-col animate-msg ${n.sender === w.USER ? "items-end" : "items-start"}`,
|
|
524
522
|
style: { animationDelay: `${d * 0.05}s` },
|
|
525
523
|
children: [
|
|
526
|
-
|
|
524
|
+
n.sender === w.AI && /* @__PURE__ */ e.jsxs("div", { className: "flex items-center gap-1.5 mb-2 ml-1", children: [
|
|
527
525
|
/* @__PURE__ */ e.jsx(
|
|
528
526
|
"img",
|
|
529
527
|
{
|
|
530
|
-
src:
|
|
531
|
-
onError: (
|
|
528
|
+
src: i,
|
|
529
|
+
onError: (m) => m.currentTarget.src = h,
|
|
532
530
|
className: "w-4 h-4 object-contain",
|
|
533
531
|
alt: "AI"
|
|
534
532
|
}
|
|
535
533
|
),
|
|
536
534
|
/* @__PURE__ */ e.jsx("span", { className: "text-[11px] font-bold text-gray-400 uppercase tracking-widest", children: "AI Agent" })
|
|
537
535
|
] }),
|
|
538
|
-
/* @__PURE__ */ e.jsxs("div", { className: `flex flex-col ${
|
|
536
|
+
/* @__PURE__ */ e.jsxs("div", { className: `flex flex-col ${n.sender === w.USER ? "items-end" : "items-start"} w-full max-w-[96%]`, children: [
|
|
539
537
|
/* @__PURE__ */ e.jsx(
|
|
540
538
|
"div",
|
|
541
539
|
{
|
|
542
|
-
className: `px-4 py-3 rounded-[20px] shadow-sm border border-black/[0.02] ${
|
|
543
|
-
children:
|
|
540
|
+
className: `px-4 py-3 rounded-[20px] shadow-sm border border-black/[0.02] overflow-hidden ${n.sender === w.USER ? "bg-indigo-600 text-white rounded-tr-none whitespace-pre-line shadow-indigo-100/50" : "bg-white text-slate-800 border-none rounded-tl-none"} ${!x || n.sender === w.USER ? "whitespace-pre-line" : ""}`,
|
|
541
|
+
children: x && n.sender === w.AI ? /* @__PURE__ */ e.jsx(fe, { text: n.content }) : n.content
|
|
544
542
|
}
|
|
545
543
|
),
|
|
546
|
-
|
|
547
|
-
d === 0 && r.length === 1 &&
|
|
544
|
+
n.type === E.PRODUCT_LIST && n.products && /* @__PURE__ */ e.jsx("div", { className: "w-full mt-4 flex gap-4 overflow-x-auto pb-4 pt-1 no-scrollbar snap-x", children: n.products.map((m) => /* @__PURE__ */ e.jsx("div", { className: "product-card-snap", children: /* @__PURE__ */ e.jsx(xe, { product: m, primaryColor: c }) }, m.id)) }),
|
|
545
|
+
d === 0 && r.length === 1 && n.sender === w.AI && /* @__PURE__ */ e.jsx("div", { className: "mt-5 flex flex-wrap gap-2.5 w-full", children: o.map((m, j) => /* @__PURE__ */ e.jsx(
|
|
548
546
|
"button",
|
|
549
547
|
{
|
|
550
|
-
onClick: () =>
|
|
548
|
+
onClick: () => l(m),
|
|
551
549
|
className: "px-4 py-2 rounded-full text-[13px] font-semibold border border-transparent bg-white text-gray-600 hover:text-indigo-600 hover:border-indigo-100 transition-all duration-200 shadow-sm active:scale-95",
|
|
552
|
-
children:
|
|
550
|
+
children: m
|
|
553
551
|
},
|
|
554
|
-
|
|
552
|
+
j
|
|
555
553
|
)) })
|
|
556
554
|
] })
|
|
557
555
|
]
|
|
558
556
|
},
|
|
559
|
-
|
|
557
|
+
n.id
|
|
560
558
|
)),
|
|
561
559
|
u && /* @__PURE__ */ e.jsxs("div", { className: "flex flex-col gap-1.5 items-start animate-msg", children: [
|
|
562
560
|
/* @__PURE__ */ e.jsx("div", { className: "flex items-center gap-1.5 ml-1", children: /* @__PURE__ */ e.jsx(
|
|
563
561
|
"img",
|
|
564
562
|
{
|
|
565
|
-
src:
|
|
566
|
-
onError: (
|
|
563
|
+
src: i,
|
|
564
|
+
onError: (n) => n.currentTarget.src = h,
|
|
567
565
|
className: "w-4 h-4 object-contain",
|
|
568
566
|
alt: "AI Loading"
|
|
569
567
|
}
|
|
@@ -575,19 +573,19 @@ const ue = ({
|
|
|
575
573
|
] })
|
|
576
574
|
] })
|
|
577
575
|
] });
|
|
578
|
-
},
|
|
579
|
-
const [
|
|
580
|
-
|
|
581
|
-
},
|
|
576
|
+
}, ge = ({ placeholder: r, onSendMessage: u, primaryColor: s }) => {
|
|
577
|
+
const [o, l] = R(""), c = () => {
|
|
578
|
+
o.trim() && (u(o), l(""));
|
|
579
|
+
}, x = (i) => {
|
|
582
580
|
i.key === "Enter" && !i.shiftKey && (i.preventDefault(), c());
|
|
583
581
|
};
|
|
584
582
|
return /* @__PURE__ */ e.jsx("div", { className: "p-1", children: /* @__PURE__ */ e.jsxs("div", { className: "relative flex items-center bg-gray-50/50 rounded-2xl border border-gray-100 focus-within:border-indigo-100 focus-within:bg-white transition-all duration-200 pr-2 pl-3 py-1", children: [
|
|
585
583
|
/* @__PURE__ */ e.jsx(
|
|
586
584
|
"textarea",
|
|
587
585
|
{
|
|
588
|
-
value:
|
|
586
|
+
value: o,
|
|
589
587
|
onChange: (i) => l(i.target.value),
|
|
590
|
-
onKeyDown:
|
|
588
|
+
onKeyDown: x,
|
|
591
589
|
placeholder: r,
|
|
592
590
|
rows: 1,
|
|
593
591
|
className: "w-full bg-transparent border-none outline-none focus:ring-0 text-[14px] text-gray-700 font-normal py-3 px-1 resize-none chat-scrollbar min-h-[44px] max-h-[120px] leading-relaxed placeholder:text-gray-400",
|
|
@@ -598,8 +596,8 @@ const ue = ({
|
|
|
598
596
|
"button",
|
|
599
597
|
{
|
|
600
598
|
onClick: c,
|
|
601
|
-
disabled: !
|
|
602
|
-
className: `w-9 h-9 rounded-xl flex-shrink-0 flex items-center justify-center transition-all duration-300 shadow-sm ${
|
|
599
|
+
disabled: !o.trim(),
|
|
600
|
+
className: `w-9 h-9 rounded-xl flex-shrink-0 flex items-center justify-center transition-all duration-300 shadow-sm ${o.trim() ? "bg-indigo-600 text-white hover:bg-indigo-700 active:scale-95" : "bg-gray-200 text-gray-400 cursor-not-allowed"}`,
|
|
603
601
|
children: /* @__PURE__ */ e.jsxs("svg", { width: "18", height: "18", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "3", strokeLinecap: "round", strokeLinejoin: "round", children: [
|
|
604
602
|
/* @__PURE__ */ e.jsx("path", { d: "m5 12 7-7 7 7" }),
|
|
605
603
|
/* @__PURE__ */ e.jsx("path", { d: "M12 19V5" })
|
|
@@ -607,7 +605,7 @@ const ue = ({
|
|
|
607
605
|
}
|
|
608
606
|
)
|
|
609
607
|
] }) });
|
|
610
|
-
},
|
|
608
|
+
}, be = ({ isOpen: r, onClick: u, primaryColor: s, className: o = "" }) => /* @__PURE__ */ e.jsx("div", { className: `fixed bottom-4 right-4 md:bottom-6 md:right-6 z-[100] ${o}`, children: /* @__PURE__ */ e.jsx(
|
|
611
609
|
"button",
|
|
612
610
|
{
|
|
613
611
|
onClick: u,
|
|
@@ -622,129 +620,142 @@ const ue = ({
|
|
|
622
620
|
}
|
|
623
621
|
)
|
|
624
622
|
}
|
|
625
|
-
) }),
|
|
626
|
-
const [
|
|
627
|
-
|
|
623
|
+
) }), le = () => Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15), L = (r, u, s) => typeof r == "object" && r !== null && !Array.isArray(r) ? r[u] || r.en || Object.values(r)[0] || s : r ?? s, je = ({ config: r, onGetAiResponse: u }) => {
|
|
624
|
+
const [s, o] = R(!1), [l, c] = R(!1), [x, i] = R(!1), [h, n] = R(le()), [d, m] = R("en"), [j, b] = R([]), [S, _] = R(!1), T = ne(null), C = ne(0);
|
|
625
|
+
q(() => {
|
|
626
|
+
const v = L(r.welcomeMessage, d, "Hello!");
|
|
627
|
+
b([{
|
|
628
628
|
id: "welcome",
|
|
629
|
-
type:
|
|
630
|
-
sender:
|
|
631
|
-
content:
|
|
629
|
+
type: E.TEXT,
|
|
630
|
+
sender: w.AI,
|
|
631
|
+
content: v,
|
|
632
632
|
timestamp: /* @__PURE__ */ new Date()
|
|
633
|
+
}]);
|
|
634
|
+
}, []);
|
|
635
|
+
const X = K(() => L(r.placeholder, d, "Type a message..."), [r.placeholder, d]), z = K(() => L(r.quickReplies, d, []), [r.quickReplies, d]), B = K(() => L(r.description, d, ""), [r.description, d]);
|
|
636
|
+
q(() => {
|
|
637
|
+
if (j.length === 1 && j[0].id === "welcome") {
|
|
638
|
+
const v = L(r.welcomeMessage, d, "Hello!");
|
|
639
|
+
b([{ ...j[0], content: v }]);
|
|
633
640
|
}
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
return () => clearTimeout(N);
|
|
641
|
+
}, [d]), q(() => {
|
|
642
|
+
if (s) {
|
|
643
|
+
const v = setTimeout(() => i(!0), 50);
|
|
644
|
+
return () => clearTimeout(v);
|
|
639
645
|
} else
|
|
640
646
|
i(!1);
|
|
641
|
-
}, [
|
|
642
|
-
|
|
643
|
-
}, [
|
|
644
|
-
const
|
|
645
|
-
if (!
|
|
646
|
-
const
|
|
647
|
+
}, [s]), q(() => {
|
|
648
|
+
T.current && s && (T.current.scrollTop = T.current.scrollHeight);
|
|
649
|
+
}, [j, s, S]);
|
|
650
|
+
const U = async (v) => {
|
|
651
|
+
if (!v.trim() || S) return;
|
|
652
|
+
const A = ++C.current, G = {
|
|
647
653
|
id: `user-${Date.now()}`,
|
|
648
|
-
type:
|
|
649
|
-
sender:
|
|
650
|
-
content:
|
|
654
|
+
type: E.TEXT,
|
|
655
|
+
sender: w.USER,
|
|
656
|
+
content: v,
|
|
651
657
|
timestamp: /* @__PURE__ */ new Date()
|
|
652
658
|
};
|
|
653
|
-
|
|
659
|
+
b((N) => [...N, G]), _(!0);
|
|
654
660
|
try {
|
|
655
|
-
const
|
|
656
|
-
if (
|
|
657
|
-
let
|
|
658
|
-
const
|
|
659
|
-
for await (const
|
|
660
|
-
if (
|
|
661
|
-
|
|
662
|
-
id:
|
|
663
|
-
type:
|
|
664
|
-
sender:
|
|
661
|
+
const N = u(v, h, d);
|
|
662
|
+
if (N && typeof N == "object" && Symbol.asyncIterator in N) {
|
|
663
|
+
let y = "", k = !1;
|
|
664
|
+
const O = `ai-${Date.now()}`;
|
|
665
|
+
for await (const D of N) {
|
|
666
|
+
if (A !== C.current) return;
|
|
667
|
+
k || (b((I) => [...I, {
|
|
668
|
+
id: O,
|
|
669
|
+
type: E.TEXT,
|
|
670
|
+
sender: w.AI,
|
|
665
671
|
content: "",
|
|
666
672
|
timestamp: /* @__PURE__ */ new Date()
|
|
667
|
-
}]), _(!1),
|
|
668
|
-
(
|
|
673
|
+
}]), _(!1), k = !0), y += D, b((I) => I.map(
|
|
674
|
+
(M) => M.id === O ? { ...M, content: y } : M
|
|
669
675
|
));
|
|
670
676
|
}
|
|
671
677
|
} else {
|
|
672
|
-
const
|
|
673
|
-
if (
|
|
678
|
+
const y = await N;
|
|
679
|
+
if (A !== C.current) return;
|
|
674
680
|
_(!1);
|
|
675
|
-
const
|
|
676
|
-
|
|
681
|
+
const k = typeof y == "string" ? { text: y, products: void 0 } : y;
|
|
682
|
+
b((O) => [...O, {
|
|
677
683
|
id: `ai-${Date.now()}`,
|
|
678
|
-
type:
|
|
679
|
-
sender:
|
|
680
|
-
content:
|
|
681
|
-
products:
|
|
684
|
+
type: k.products ? E.PRODUCT_LIST : E.TEXT,
|
|
685
|
+
sender: w.AI,
|
|
686
|
+
content: k.text,
|
|
687
|
+
products: k.products,
|
|
682
688
|
timestamp: /* @__PURE__ */ new Date()
|
|
683
689
|
}]);
|
|
684
690
|
}
|
|
685
|
-
} catch (
|
|
686
|
-
if (
|
|
687
|
-
console.error("Chatbox Error:",
|
|
691
|
+
} catch (N) {
|
|
692
|
+
if (A !== C.current) return;
|
|
693
|
+
console.error("Chatbox Error:", N), _(!1);
|
|
694
|
+
const y = d === "vi" ? "Hệ thống đang bận, vui lòng thử lại sau." : "System is busy, please try again later.";
|
|
695
|
+
b((k) => [...k, {
|
|
688
696
|
id: `err-${Date.now()}`,
|
|
689
|
-
type:
|
|
690
|
-
sender:
|
|
691
|
-
content:
|
|
697
|
+
type: E.TEXT,
|
|
698
|
+
sender: w.AI,
|
|
699
|
+
content: y,
|
|
692
700
|
timestamp: /* @__PURE__ */ new Date()
|
|
693
701
|
}]);
|
|
694
702
|
}
|
|
695
|
-
},
|
|
696
|
-
C.current++,
|
|
703
|
+
}, V = () => {
|
|
704
|
+
C.current++, n(le());
|
|
705
|
+
const v = L(r.welcomeMessage, d, "Hello!");
|
|
706
|
+
b([{
|
|
697
707
|
id: "welcome",
|
|
698
|
-
type:
|
|
699
|
-
sender:
|
|
700
|
-
content:
|
|
708
|
+
type: E.TEXT,
|
|
709
|
+
sender: w.AI,
|
|
710
|
+
content: v,
|
|
701
711
|
timestamp: /* @__PURE__ */ new Date()
|
|
702
712
|
}]), _(!1), c(!1);
|
|
703
|
-
},
|
|
713
|
+
}, J = `
|
|
704
714
|
fixed z-[99] overflow-hidden flex flex-col border border-white/40 shadow-2xl bg-white animate-chat-pop
|
|
705
|
-
${
|
|
706
|
-
${l ? "bottom-0 right-0 w-full h-full md:bottom-6 md:right-28 md:w-[850px] md:h-[85vh] rounded-none md:rounded-[32px]" : "bottom-0 right-0 w-full h-[80vh] md:bottom-6 md:right-28 md:w-[
|
|
715
|
+
${x ? "transition-[width,height,border-radius,right,bottom] duration-300 ease-in-out" : ""}
|
|
716
|
+
${l ? "bottom-0 right-0 w-full h-full md:bottom-6 md:right-28 md:w-[850px] md:h-[85vh] rounded-none md:rounded-[32px]" : "bottom-0 right-0 w-full h-[80vh] md:bottom-6 md:right-28 md:w-[420px] md:h-[580px] rounded-t-[28px] md:rounded-[28px]"}
|
|
707
717
|
`;
|
|
708
718
|
return /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
|
|
709
719
|
/* @__PURE__ */ e.jsx(
|
|
710
|
-
|
|
720
|
+
be,
|
|
711
721
|
{
|
|
712
|
-
isOpen:
|
|
713
|
-
onClick: () =>
|
|
722
|
+
isOpen: s,
|
|
723
|
+
onClick: () => o(!s),
|
|
714
724
|
primaryColor: r.primaryColor,
|
|
715
|
-
className:
|
|
725
|
+
className: s ? "hidden md:flex" : "flex"
|
|
716
726
|
}
|
|
717
727
|
),
|
|
718
|
-
|
|
728
|
+
s && /* @__PURE__ */ e.jsxs("div", { className: J, style: { left: "auto" }, children: [
|
|
719
729
|
/* @__PURE__ */ e.jsx(
|
|
720
|
-
|
|
730
|
+
me,
|
|
721
731
|
{
|
|
722
732
|
title: r.botName,
|
|
723
733
|
primaryColor: r.primaryColor,
|
|
724
|
-
onClose: () =>
|
|
725
|
-
onReset:
|
|
734
|
+
onClose: () => o(!1),
|
|
735
|
+
onReset: V,
|
|
726
736
|
onToggleExpand: () => c(!l),
|
|
727
737
|
isExpanded: l,
|
|
728
|
-
language:
|
|
729
|
-
onLanguageChange:
|
|
738
|
+
language: d,
|
|
739
|
+
onLanguageChange: m
|
|
730
740
|
}
|
|
731
741
|
),
|
|
732
|
-
/* @__PURE__ */ e.jsx("div", { className: "flex-1 overflow-y-auto chat-scrollbar px-5 py-5 bg-slate-50/30", ref:
|
|
733
|
-
|
|
742
|
+
/* @__PURE__ */ e.jsx("div", { className: "flex-1 overflow-y-auto chat-scrollbar px-5 py-5 bg-slate-50/30", ref: T, children: /* @__PURE__ */ e.jsx(
|
|
743
|
+
pe,
|
|
734
744
|
{
|
|
735
|
-
messages:
|
|
745
|
+
messages: j,
|
|
736
746
|
isLoading: S,
|
|
737
|
-
|
|
738
|
-
|
|
747
|
+
description: B,
|
|
748
|
+
quickReplies: z,
|
|
749
|
+
onQuickReply: (v) => U(v),
|
|
739
750
|
primaryColor: r.primaryColor,
|
|
740
751
|
renderMarkdown: r.renderMarkdown
|
|
741
752
|
}
|
|
742
753
|
) }),
|
|
743
754
|
/* @__PURE__ */ e.jsx("div", { className: "bg-white p-3 border-t border-slate-100", children: /* @__PURE__ */ e.jsx(
|
|
744
|
-
|
|
755
|
+
ge,
|
|
745
756
|
{
|
|
746
|
-
placeholder:
|
|
747
|
-
onSendMessage:
|
|
757
|
+
placeholder: X,
|
|
758
|
+
onSendMessage: U,
|
|
748
759
|
primaryColor: r.primaryColor
|
|
749
760
|
}
|
|
750
761
|
) })
|
|
@@ -752,7 +763,7 @@ const ue = ({
|
|
|
752
763
|
] });
|
|
753
764
|
};
|
|
754
765
|
export {
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
766
|
+
je as Chatbox,
|
|
767
|
+
E as MessageType,
|
|
768
|
+
w as SenderType
|
|
758
769
|
};
|