@brainbase-labs/chat-widget 0.1.10 → 0.1.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/embed/index.js +1 -1
- package/dist/index.cjs +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +88 -89
- package/package.json +8 -9
package/dist/index.js
CHANGED
|
@@ -33,30 +33,30 @@ function le(o) {
|
|
|
33
33
|
onSessionEnd: m,
|
|
34
34
|
onMessage: c,
|
|
35
35
|
onError: g
|
|
36
|
-
} = o, [l, n] = N([]), [
|
|
36
|
+
} = o, [l, n] = N([]), [y, M] = N([]), [A, H] = N(!1), [P, z] = N(null), [b, _] = N(null), S = U(0), K = U(!1);
|
|
37
37
|
Z(() => {
|
|
38
38
|
if (K.current) return;
|
|
39
39
|
K.current = !0;
|
|
40
40
|
const p = ie(t.embedId);
|
|
41
41
|
p && p.status === "active" && (_(p.sessionId), n(p.messages), M(p.toolCalls), S.current = p.startTime);
|
|
42
42
|
}, [t.embedId]), Z(() => {
|
|
43
|
-
|
|
44
|
-
sessionId:
|
|
43
|
+
b && l.length > 0 && se(t.embedId, {
|
|
44
|
+
sessionId: b,
|
|
45
45
|
deploymentId: t.deploymentId,
|
|
46
46
|
workerId: t.workerId,
|
|
47
47
|
flowId: t.flowId,
|
|
48
48
|
startTime: S.current,
|
|
49
49
|
messages: l,
|
|
50
|
-
toolCalls:
|
|
50
|
+
toolCalls: y,
|
|
51
51
|
status: "active"
|
|
52
52
|
});
|
|
53
|
-
}, [
|
|
53
|
+
}, [b, l, y, t]);
|
|
54
54
|
const G = x(async () => (S.current = Date.now(), _(null), n([]), M([]), re(t.embedId), ""), [t.embedId]), E = x(
|
|
55
|
-
(p, I,
|
|
55
|
+
(p, I, k) => {
|
|
56
56
|
switch (p.type) {
|
|
57
57
|
case "session": {
|
|
58
58
|
const d = p.data;
|
|
59
|
-
d.session_id && (
|
|
59
|
+
d.session_id && (k(d.session_id), d.is_new && (S.current = Date.now(), u == null || u(d.session_id)));
|
|
60
60
|
break;
|
|
61
61
|
}
|
|
62
62
|
case "message": {
|
|
@@ -104,14 +104,14 @@ function le(o) {
|
|
|
104
104
|
case "completed": {
|
|
105
105
|
n(
|
|
106
106
|
(d) => d.map((h) => h.id === I ? { ...h, status: "sent" } : h)
|
|
107
|
-
),
|
|
108
|
-
sessionId:
|
|
107
|
+
), b && se(t.embedId, {
|
|
108
|
+
sessionId: b,
|
|
109
109
|
deploymentId: t.deploymentId,
|
|
110
110
|
workerId: t.workerId,
|
|
111
111
|
flowId: t.flowId,
|
|
112
112
|
startTime: S.current,
|
|
113
113
|
messages: l,
|
|
114
|
-
toolCalls:
|
|
114
|
+
toolCalls: y,
|
|
115
115
|
status: "completed"
|
|
116
116
|
});
|
|
117
117
|
break;
|
|
@@ -131,9 +131,9 @@ function le(o) {
|
|
|
131
131
|
}
|
|
132
132
|
}
|
|
133
133
|
},
|
|
134
|
-
[t,
|
|
134
|
+
[t, b, l, y, u]
|
|
135
135
|
), T = x(
|
|
136
|
-
async (p, I,
|
|
136
|
+
async (p, I, k) => {
|
|
137
137
|
const d = p.getReader(), h = new TextDecoder();
|
|
138
138
|
let a = "";
|
|
139
139
|
try {
|
|
@@ -152,7 +152,7 @@ function le(o) {
|
|
|
152
152
|
if (ne.startsWith("data: "))
|
|
153
153
|
try {
|
|
154
154
|
const ce = JSON.parse(ne.slice(6));
|
|
155
|
-
E(ce, I,
|
|
155
|
+
E(ce, I, k);
|
|
156
156
|
} catch {
|
|
157
157
|
}
|
|
158
158
|
}
|
|
@@ -173,8 +173,8 @@ function le(o) {
|
|
|
173
173
|
status: "sent"
|
|
174
174
|
};
|
|
175
175
|
n((a) => [...a, I]), c == null || c(I);
|
|
176
|
-
const
|
|
177
|
-
id:
|
|
176
|
+
const k = `assistant-${Date.now()}`, d = {
|
|
177
|
+
id: k,
|
|
178
178
|
role: "assistant",
|
|
179
179
|
content: "",
|
|
180
180
|
timestamp: Date.now(),
|
|
@@ -188,25 +188,25 @@ function le(o) {
|
|
|
188
188
|
if (r) {
|
|
189
189
|
const a = s.sendMessage(p);
|
|
190
190
|
for await (const f of a)
|
|
191
|
-
E(f,
|
|
191
|
+
E(f, k, h);
|
|
192
192
|
} else {
|
|
193
193
|
const a = await s.sendMessage({
|
|
194
194
|
embedId: t.embedId,
|
|
195
195
|
message: p,
|
|
196
|
-
sessionId:
|
|
196
|
+
sessionId: b ?? void 0
|
|
197
197
|
});
|
|
198
|
-
await T(a,
|
|
198
|
+
await T(a, k, h);
|
|
199
199
|
}
|
|
200
200
|
n(
|
|
201
201
|
(a) => a.map(
|
|
202
|
-
(f) => f.id ===
|
|
202
|
+
(f) => f.id === k && f.status === "streaming" ? { ...f, status: "sent" } : f
|
|
203
203
|
)
|
|
204
204
|
);
|
|
205
205
|
} catch (a) {
|
|
206
206
|
const f = a instanceof Error ? a : new Error("Failed to send message");
|
|
207
207
|
z(f), g == null || g(f), n(
|
|
208
208
|
(B) => B.map(
|
|
209
|
-
(v) => v.id ===
|
|
209
|
+
(v) => v.id === k ? { ...v, status: "error", content: "Failed to get response" } : v
|
|
210
210
|
)
|
|
211
211
|
);
|
|
212
212
|
} finally {
|
|
@@ -214,7 +214,7 @@ function le(o) {
|
|
|
214
214
|
}
|
|
215
215
|
},
|
|
216
216
|
[
|
|
217
|
-
|
|
217
|
+
b,
|
|
218
218
|
s,
|
|
219
219
|
r,
|
|
220
220
|
t.embedId,
|
|
@@ -224,40 +224,40 @@ function le(o) {
|
|
|
224
224
|
g
|
|
225
225
|
]
|
|
226
226
|
), J = x(async () => {
|
|
227
|
-
if (!
|
|
227
|
+
if (!b) return;
|
|
228
228
|
const p = {
|
|
229
|
-
sessionId:
|
|
229
|
+
sessionId: b,
|
|
230
230
|
deploymentId: t.deploymentId,
|
|
231
231
|
workerId: t.workerId,
|
|
232
232
|
flowId: t.flowId,
|
|
233
233
|
startTime: S.current,
|
|
234
234
|
messages: l,
|
|
235
|
-
toolCalls:
|
|
235
|
+
toolCalls: y,
|
|
236
236
|
status: "completed"
|
|
237
237
|
};
|
|
238
238
|
m == null || m(p), re(t.embedId), _(null), n([]), M([]);
|
|
239
239
|
}, [
|
|
240
|
-
|
|
240
|
+
b,
|
|
241
241
|
t,
|
|
242
242
|
l,
|
|
243
|
-
|
|
243
|
+
y,
|
|
244
244
|
m
|
|
245
245
|
]), F = x(() => {
|
|
246
246
|
n([]), M([]);
|
|
247
247
|
}, []);
|
|
248
248
|
return {
|
|
249
249
|
messages: l,
|
|
250
|
-
toolCalls:
|
|
250
|
+
toolCalls: y,
|
|
251
251
|
isLoading: A,
|
|
252
252
|
error: P,
|
|
253
|
-
sessionId:
|
|
253
|
+
sessionId: b,
|
|
254
254
|
sendMessage: ee,
|
|
255
255
|
endSession: J,
|
|
256
256
|
clearMessages: F,
|
|
257
257
|
startNewSession: G
|
|
258
258
|
};
|
|
259
259
|
}
|
|
260
|
-
const de = "https://
|
|
260
|
+
const de = "https://chat-embed-deployment.onrender.com";
|
|
261
261
|
function ue(o = de) {
|
|
262
262
|
return {
|
|
263
263
|
async getDeploymentConfig(t) {
|
|
@@ -463,12 +463,12 @@ const q = ({
|
|
|
463
463
|
)
|
|
464
464
|
]
|
|
465
465
|
}
|
|
466
|
-
), he = "_header_1p6z5_1", _e = "_compact_1p6z5_9", fe = "_headerBackground_1p6z5_20",
|
|
466
|
+
), he = "_header_1p6z5_1", _e = "_compact_1p6z5_9", fe = "_headerBackground_1p6z5_20", ye = "_headerContent_1p6z5_59", be = "_topRow_1p6z5_64", we = "_agentInfo_1p6z5_79", Ce = "_agentLogo_1p6z5_85", ke = "_agentLogoPlaceholder_1p6z5_102", ve = "_brainbaseLogo_1p6z5_123", Ie = "_agentName_1p6z5_137", Ne = "_actions_1p6z5_144", Le = "_actionButton_1p6z5_149", $e = "_welcomeText_1p6z5_183", Be = "_title_1p6z5_202", xe = "_subtitle_1p6z5_210", w = {
|
|
467
467
|
header: he,
|
|
468
468
|
compact: _e,
|
|
469
469
|
headerBackground: fe,
|
|
470
|
-
headerContent:
|
|
471
|
-
topRow:
|
|
470
|
+
headerContent: ye,
|
|
471
|
+
topRow: be,
|
|
472
472
|
agentInfo: we,
|
|
473
473
|
agentLogo: Ce,
|
|
474
474
|
agentLogoPlaceholder: ke,
|
|
@@ -490,33 +490,33 @@ const q = ({
|
|
|
490
490
|
compact: g = !1
|
|
491
491
|
}) => {
|
|
492
492
|
const l = s || "Hello there.", n = r !== void 0 ? r : s ? void 0 : "How can we help?";
|
|
493
|
-
return /* @__PURE__ */ i("div", { className: `${
|
|
494
|
-
/* @__PURE__ */ e("div", { className:
|
|
495
|
-
/* @__PURE__ */ i("div", { className:
|
|
496
|
-
/* @__PURE__ */ i("div", { className:
|
|
497
|
-
/* @__PURE__ */ i("div", { className:
|
|
493
|
+
return /* @__PURE__ */ i("div", { className: `${w.header} ${g ? w.compact : ""}`, children: [
|
|
494
|
+
/* @__PURE__ */ e("div", { className: w.headerBackground }),
|
|
495
|
+
/* @__PURE__ */ i("div", { className: w.headerContent, children: [
|
|
496
|
+
/* @__PURE__ */ i("div", { className: w.topRow, children: [
|
|
497
|
+
/* @__PURE__ */ i("div", { className: w.agentInfo, children: [
|
|
498
498
|
t ? /* @__PURE__ */ e(
|
|
499
499
|
"img",
|
|
500
500
|
{
|
|
501
501
|
src: t,
|
|
502
502
|
alt: o,
|
|
503
|
-
className:
|
|
503
|
+
className: w.agentLogo
|
|
504
504
|
}
|
|
505
|
-
) : /* @__PURE__ */ e("div", { className:
|
|
505
|
+
) : /* @__PURE__ */ e("div", { className: w.agentLogoPlaceholder, children: /* @__PURE__ */ e(
|
|
506
506
|
q,
|
|
507
507
|
{
|
|
508
|
-
className:
|
|
508
|
+
className: w.brainbaseLogo,
|
|
509
509
|
color: "white",
|
|
510
510
|
cutoutColor: "var(--bb-primary-color)"
|
|
511
511
|
}
|
|
512
512
|
) }),
|
|
513
|
-
/* @__PURE__ */ e("span", { className:
|
|
513
|
+
/* @__PURE__ */ e("span", { className: w.agentName, children: o })
|
|
514
514
|
] }),
|
|
515
|
-
/* @__PURE__ */ i("div", { className:
|
|
515
|
+
/* @__PURE__ */ i("div", { className: w.actions, children: [
|
|
516
516
|
c && m && /* @__PURE__ */ e(
|
|
517
517
|
"button",
|
|
518
518
|
{
|
|
519
|
-
className:
|
|
519
|
+
className: w.actionButton,
|
|
520
520
|
onClick: m,
|
|
521
521
|
"aria-label": "Start new chat",
|
|
522
522
|
type: "button",
|
|
@@ -535,7 +535,7 @@ const q = ({
|
|
|
535
535
|
u && /* @__PURE__ */ e(
|
|
536
536
|
"button",
|
|
537
537
|
{
|
|
538
|
-
className:
|
|
538
|
+
className: w.actionButton,
|
|
539
539
|
onClick: u,
|
|
540
540
|
"aria-label": "Close chat",
|
|
541
541
|
type: "button",
|
|
@@ -553,9 +553,9 @@ const q = ({
|
|
|
553
553
|
)
|
|
554
554
|
] })
|
|
555
555
|
] }),
|
|
556
|
-
!g && /* @__PURE__ */ i("div", { className:
|
|
557
|
-
/* @__PURE__ */ e("h1", { className:
|
|
558
|
-
n && /* @__PURE__ */ e("p", { className:
|
|
556
|
+
!g && /* @__PURE__ */ i("div", { className: w.welcomeText, children: [
|
|
557
|
+
/* @__PURE__ */ e("h1", { className: w.title, children: l }),
|
|
558
|
+
n && /* @__PURE__ */ e("p", { className: w.subtitle, children: n })
|
|
559
559
|
] })
|
|
560
560
|
] })
|
|
561
561
|
] });
|
|
@@ -690,7 +690,7 @@ const q = ({
|
|
|
690
690
|
emptyText: ut
|
|
691
691
|
}, mt = ({
|
|
692
692
|
messages: o,
|
|
693
|
-
toolCalls: t,
|
|
693
|
+
toolCalls: t = [],
|
|
694
694
|
isLoading: s,
|
|
695
695
|
agentName: r,
|
|
696
696
|
agentLogoUrl: u
|
|
@@ -737,7 +737,7 @@ const q = ({
|
|
|
737
737
|
textarea: ht,
|
|
738
738
|
sendButton: _t,
|
|
739
739
|
hint: ft
|
|
740
|
-
},
|
|
740
|
+
}, yt = ({
|
|
741
741
|
onSend: o,
|
|
742
742
|
disabled: t = !1,
|
|
743
743
|
placeholder: s = "Send a message..."
|
|
@@ -752,8 +752,8 @@ const q = ({
|
|
|
752
752
|
const g = x(
|
|
753
753
|
(n) => {
|
|
754
754
|
n == null || n.preventDefault();
|
|
755
|
-
const
|
|
756
|
-
|
|
755
|
+
const y = r.trim();
|
|
756
|
+
y && !t && (o(y), u(""), m.current && (m.current.style.height = "auto"));
|
|
757
757
|
},
|
|
758
758
|
[r, t, o]
|
|
759
759
|
), l = x(
|
|
@@ -806,8 +806,8 @@ const q = ({
|
|
|
806
806
|
" for new line"
|
|
807
807
|
] })
|
|
808
808
|
] });
|
|
809
|
-
},
|
|
810
|
-
poweredBy:
|
|
809
|
+
}, bt = "_poweredBy_9jh5q_1", wt = "_logo_9jh5q_20", Ct = "_poweredText_9jh5q_24", kt = "_text_9jh5q_36", X = {
|
|
810
|
+
poweredBy: bt,
|
|
811
811
|
logo: wt,
|
|
812
812
|
poweredText: Ct,
|
|
813
813
|
text: kt
|
|
@@ -889,14 +889,14 @@ const q = ({
|
|
|
889
889
|
}, Wt = ({
|
|
890
890
|
config: o,
|
|
891
891
|
messages: t,
|
|
892
|
-
toolCalls: s,
|
|
892
|
+
toolCalls: s = [],
|
|
893
893
|
isLoading: r,
|
|
894
894
|
onSendMessage: u,
|
|
895
895
|
onClose: m,
|
|
896
896
|
onNewChat: c
|
|
897
897
|
}) => {
|
|
898
898
|
var H;
|
|
899
|
-
const [g, l] = N(!1), n = t.length > 0,
|
|
899
|
+
const [g, l] = N(!1), n = t.length > 0, y = () => {
|
|
900
900
|
l(!0);
|
|
901
901
|
}, M = () => {
|
|
902
902
|
l(!1), c == null || c();
|
|
@@ -912,7 +912,7 @@ const q = ({
|
|
|
912
912
|
welcomeTitle: o.welcomeMessage || "Hello there.",
|
|
913
913
|
welcomeSubtitle: o.welcomeMessage ? void 0 : "How can we help?",
|
|
914
914
|
onClose: m,
|
|
915
|
-
onNewChatRequest:
|
|
915
|
+
onNewChatRequest: y,
|
|
916
916
|
showNewChatButton: n,
|
|
917
917
|
compact: n
|
|
918
918
|
}
|
|
@@ -929,7 +929,7 @@ const q = ({
|
|
|
929
929
|
}
|
|
930
930
|
),
|
|
931
931
|
/* @__PURE__ */ e(
|
|
932
|
-
|
|
932
|
+
yt,
|
|
933
933
|
{
|
|
934
934
|
onSend: u,
|
|
935
935
|
disabled: r,
|
|
@@ -1001,7 +1001,7 @@ const q = ({
|
|
|
1001
1001
|
s > 0 && /* @__PURE__ */ e("span", { className: Q.unreadBadge, children: s > 9 ? "9+" : s })
|
|
1002
1002
|
]
|
|
1003
1003
|
}
|
|
1004
|
-
), jt = "_container_kgfgt_1", Vt = "_header_kgfgt_25", At = "_logoWrapper_kgfgt_38", zt = "_logo_kgfgt_38", Ft = "_closeButton_kgfgt_51", Ot = "_content_kgfgt_74", Rt = "_iconWrapper_kgfgt_84", Ut = "_errorIcon_kgfgt_95", Zt = "_title_kgfgt_101", qt = "_description_kgfgt_109", Kt = "_retryButton_kgfgt_117", Gt = "_footer_kgfgt_139", Jt = "_poweredBy_kgfgt_146", Yt = "_footerLogo_kgfgt_160",
|
|
1004
|
+
), jt = "_container_kgfgt_1", Vt = "_header_kgfgt_25", At = "_logoWrapper_kgfgt_38", zt = "_logo_kgfgt_38", Ft = "_closeButton_kgfgt_51", Ot = "_content_kgfgt_74", Rt = "_iconWrapper_kgfgt_84", Ut = "_errorIcon_kgfgt_95", Zt = "_title_kgfgt_101", qt = "_description_kgfgt_109", Kt = "_retryButton_kgfgt_117", Gt = "_footer_kgfgt_139", Jt = "_poweredBy_kgfgt_146", Yt = "_footerLogo_kgfgt_160", C = {
|
|
1005
1005
|
container: jt,
|
|
1006
1006
|
header: Vt,
|
|
1007
1007
|
logoWrapper: At,
|
|
@@ -1028,7 +1028,7 @@ const q = ({
|
|
|
1028
1028
|
return {
|
|
1029
1029
|
title: "Chat Not Found",
|
|
1030
1030
|
description: t || "This chat widget is not configured correctly. Please check the embed ID.",
|
|
1031
|
-
icon: /* @__PURE__ */ i("svg", { viewBox: "0 0 24 24", fill: "none", className:
|
|
1031
|
+
icon: /* @__PURE__ */ i("svg", { viewBox: "0 0 24 24", fill: "none", className: C.errorIcon, children: [
|
|
1032
1032
|
/* @__PURE__ */ e(
|
|
1033
1033
|
"circle",
|
|
1034
1034
|
{
|
|
@@ -1054,7 +1054,7 @@ const q = ({
|
|
|
1054
1054
|
return {
|
|
1055
1055
|
title: "Connection Error",
|
|
1056
1056
|
description: t || "Unable to connect to the chat service. Please check your internet connection.",
|
|
1057
|
-
icon: /* @__PURE__ */ i("svg", { viewBox: "0 0 24 24", fill: "none", className:
|
|
1057
|
+
icon: /* @__PURE__ */ i("svg", { viewBox: "0 0 24 24", fill: "none", className: C.errorIcon, children: [
|
|
1058
1058
|
/* @__PURE__ */ e(
|
|
1059
1059
|
"path",
|
|
1060
1060
|
{
|
|
@@ -1078,7 +1078,7 @@ const q = ({
|
|
|
1078
1078
|
return {
|
|
1079
1079
|
title: "Something Went Wrong",
|
|
1080
1080
|
description: t || "An unexpected error occurred. Please try again later.",
|
|
1081
|
-
icon: /* @__PURE__ */ e("svg", { viewBox: "0 0 24 24", fill: "none", className:
|
|
1081
|
+
icon: /* @__PURE__ */ e("svg", { viewBox: "0 0 24 24", fill: "none", className: C.errorIcon, children: /* @__PURE__ */ e(
|
|
1082
1082
|
"path",
|
|
1083
1083
|
{
|
|
1084
1084
|
d: "M12 9V13M12 17H12.01M21 12C21 16.9706 16.9706 21 12 21C7.02944 21 3 16.9706 3 12C3 7.02944 7.02944 3 12 3C16.9706 3 21 7.02944 21 12Z",
|
|
@@ -1090,12 +1090,12 @@ const q = ({
|
|
|
1090
1090
|
};
|
|
1091
1091
|
}
|
|
1092
1092
|
}, { title: m, description: c, icon: g } = u();
|
|
1093
|
-
return /* @__PURE__ */ i("div", { className:
|
|
1094
|
-
/* @__PURE__ */ i("div", { className:
|
|
1095
|
-
/* @__PURE__ */ e("div", { className:
|
|
1093
|
+
return /* @__PURE__ */ i("div", { className: C.container, children: [
|
|
1094
|
+
/* @__PURE__ */ i("div", { className: C.header, children: [
|
|
1095
|
+
/* @__PURE__ */ e("div", { className: C.logoWrapper, children: /* @__PURE__ */ e(
|
|
1096
1096
|
q,
|
|
1097
1097
|
{
|
|
1098
|
-
className:
|
|
1098
|
+
className: C.logo,
|
|
1099
1099
|
color: "white",
|
|
1100
1100
|
cutoutColor: "var(--bb-primary-color)"
|
|
1101
1101
|
}
|
|
@@ -1103,7 +1103,7 @@ const q = ({
|
|
|
1103
1103
|
r && /* @__PURE__ */ e(
|
|
1104
1104
|
"button",
|
|
1105
1105
|
{
|
|
1106
|
-
className:
|
|
1106
|
+
className: C.closeButton,
|
|
1107
1107
|
onClick: r,
|
|
1108
1108
|
"aria-label": "Close",
|
|
1109
1109
|
type: "button",
|
|
@@ -1119,26 +1119,26 @@ const q = ({
|
|
|
1119
1119
|
}
|
|
1120
1120
|
)
|
|
1121
1121
|
] }),
|
|
1122
|
-
/* @__PURE__ */ i("div", { className:
|
|
1123
|
-
/* @__PURE__ */ e("div", { className:
|
|
1124
|
-
/* @__PURE__ */ e("h2", { className:
|
|
1125
|
-
/* @__PURE__ */ e("p", { className:
|
|
1126
|
-
s && /* @__PURE__ */ e("button", { className:
|
|
1122
|
+
/* @__PURE__ */ i("div", { className: C.content, children: [
|
|
1123
|
+
/* @__PURE__ */ e("div", { className: C.iconWrapper, children: g }),
|
|
1124
|
+
/* @__PURE__ */ e("h2", { className: C.title, children: m }),
|
|
1125
|
+
/* @__PURE__ */ e("p", { className: C.description, children: c }),
|
|
1126
|
+
s && /* @__PURE__ */ e("button", { className: C.retryButton, onClick: s, type: "button", children: "Try Again" })
|
|
1127
1127
|
] }),
|
|
1128
|
-
/* @__PURE__ */ e("div", { className:
|
|
1128
|
+
/* @__PURE__ */ e("div", { className: C.footer, children: /* @__PURE__ */ i(
|
|
1129
1129
|
"a",
|
|
1130
1130
|
{
|
|
1131
1131
|
href: "https://brainbaselabs.com",
|
|
1132
1132
|
target: "_blank",
|
|
1133
1133
|
rel: "noopener noreferrer",
|
|
1134
|
-
className:
|
|
1134
|
+
className: C.poweredBy,
|
|
1135
1135
|
children: [
|
|
1136
1136
|
"Powered by",
|
|
1137
1137
|
" ",
|
|
1138
1138
|
/* @__PURE__ */ e(
|
|
1139
1139
|
q,
|
|
1140
1140
|
{
|
|
1141
|
-
className:
|
|
1141
|
+
className: C.footerLogo,
|
|
1142
1142
|
color: "var(--bb-text-tertiary)",
|
|
1143
1143
|
cutoutColor: "var(--bb-surface-bg)"
|
|
1144
1144
|
}
|
|
@@ -1164,13 +1164,13 @@ const q = ({
|
|
|
1164
1164
|
agentName: g,
|
|
1165
1165
|
welcomeMessage: l,
|
|
1166
1166
|
showBranding: n,
|
|
1167
|
-
className:
|
|
1167
|
+
className: y,
|
|
1168
1168
|
onSessionStart: M,
|
|
1169
1169
|
onSessionEnd: A,
|
|
1170
1170
|
onMessage: H,
|
|
1171
1171
|
onError: P
|
|
1172
1172
|
}) => {
|
|
1173
|
-
const [z,
|
|
1173
|
+
const [z, b] = N(m), [_, S] = N(null), [K, G] = N(!0), [E, T] = N(null), [ee, J] = N(), F = te(() => s ? pe(
|
|
1174
1174
|
{ primaryColor: c, agentName: g, welcomeMessage: l },
|
|
1175
1175
|
r
|
|
1176
1176
|
) : ue(t), [s, c, g, l, r, t]), p = x(async () => {
|
|
@@ -1217,7 +1217,7 @@ const q = ({
|
|
|
1217
1217
|
styling: n !== void 0 ? {
|
|
1218
1218
|
showBranding: n
|
|
1219
1219
|
} : void 0
|
|
1220
|
-
}, [_, o, c, g, l, n]),
|
|
1220
|
+
}, [_, o, c, g, l, n]), k = le({
|
|
1221
1221
|
config: I,
|
|
1222
1222
|
apiClient: F,
|
|
1223
1223
|
mockMode: s,
|
|
@@ -1231,21 +1231,21 @@ const q = ({
|
|
|
1231
1231
|
}),
|
|
1232
1232
|
[_ == null ? void 0 : _.primaryColor, c]
|
|
1233
1233
|
), h = () => {
|
|
1234
|
-
|
|
1234
|
+
k.endSession(), k.startNewSession();
|
|
1235
1235
|
}, a = () => {
|
|
1236
|
-
|
|
1236
|
+
b(!1);
|
|
1237
1237
|
}, f = () => {
|
|
1238
1238
|
p();
|
|
1239
1239
|
}, B = u === "inline";
|
|
1240
1240
|
return K ? null : E && !s ? !B && !z ? /* @__PURE__ */ e(
|
|
1241
1241
|
"div",
|
|
1242
1242
|
{
|
|
1243
|
-
className: `${V.widget} ${V[u]} ${
|
|
1243
|
+
className: `${V.widget} ${V[u]} ${y ?? ""}`,
|
|
1244
1244
|
style: d,
|
|
1245
1245
|
children: /* @__PURE__ */ e(
|
|
1246
1246
|
ae,
|
|
1247
1247
|
{
|
|
1248
|
-
onClick: () =>
|
|
1248
|
+
onClick: () => b(!0),
|
|
1249
1249
|
agentName: g
|
|
1250
1250
|
}
|
|
1251
1251
|
)
|
|
@@ -1253,7 +1253,7 @@ const q = ({
|
|
|
1253
1253
|
) : /* @__PURE__ */ e(
|
|
1254
1254
|
"div",
|
|
1255
1255
|
{
|
|
1256
|
-
className: `${V.widget} ${V[u]} ${
|
|
1256
|
+
className: `${V.widget} ${V[u]} ${y ?? ""}`,
|
|
1257
1257
|
style: d,
|
|
1258
1258
|
children: /* @__PURE__ */ e(
|
|
1259
1259
|
Xt,
|
|
@@ -1268,23 +1268,22 @@ const q = ({
|
|
|
1268
1268
|
) : /* @__PURE__ */ e(
|
|
1269
1269
|
"div",
|
|
1270
1270
|
{
|
|
1271
|
-
className: `${V.widget} ${V[u]} ${
|
|
1271
|
+
className: `${V.widget} ${V[u]} ${y ?? ""}`,
|
|
1272
1272
|
style: d,
|
|
1273
1273
|
children: z || B ? /* @__PURE__ */ e(
|
|
1274
1274
|
Wt,
|
|
1275
1275
|
{
|
|
1276
1276
|
config: I,
|
|
1277
|
-
messages:
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
onSendMessage: w.sendMessage,
|
|
1277
|
+
messages: k.messages,
|
|
1278
|
+
isLoading: k.isLoading,
|
|
1279
|
+
onSendMessage: k.sendMessage,
|
|
1281
1280
|
onClose: B ? void 0 : a,
|
|
1282
1281
|
onNewChat: h
|
|
1283
1282
|
}
|
|
1284
1283
|
) : /* @__PURE__ */ e(
|
|
1285
1284
|
ae,
|
|
1286
1285
|
{
|
|
1287
|
-
onClick: () =>
|
|
1286
|
+
onClick: () => b(!0),
|
|
1288
1287
|
agentName: _ == null ? void 0 : _.agentName,
|
|
1289
1288
|
agentLogoUrl: _ == null ? void 0 : _.agentLogoUrl
|
|
1290
1289
|
}
|
|
@@ -1304,7 +1303,7 @@ export {
|
|
|
1304
1303
|
ae as ChatToggleButton,
|
|
1305
1304
|
so as ChatWidget,
|
|
1306
1305
|
Fe as Message,
|
|
1307
|
-
|
|
1306
|
+
yt as MessageInput,
|
|
1308
1307
|
mt as MessageList,
|
|
1309
1308
|
et as ToolCallDisplay,
|
|
1310
1309
|
ct as TypingIndicator,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@brainbase-labs/chat-widget",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.12",
|
|
4
4
|
"description": "A React chat widget for embedding Brainbase Labs AI agents in your applications",
|
|
5
5
|
"author": "Brainbase Labs <hello@brainbaselabs.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -69,12 +69,9 @@
|
|
|
69
69
|
},
|
|
70
70
|
"devDependencies": {
|
|
71
71
|
"@eslint/js": "^9.16.0",
|
|
72
|
-
"@storybook/addon-
|
|
73
|
-
"@storybook/
|
|
74
|
-
"@storybook/
|
|
75
|
-
"@storybook/blocks": "^8.4.7",
|
|
76
|
-
"@storybook/react": "^8.4.7",
|
|
77
|
-
"@storybook/react-vite": "^8.4.7",
|
|
72
|
+
"@storybook/addon-links": "^10.1.7",
|
|
73
|
+
"@storybook/react": "^10.1.7",
|
|
74
|
+
"@storybook/react-vite": "^10.1.7",
|
|
78
75
|
"@types/react": "^18.3.12",
|
|
79
76
|
"@types/react-dom": "^18.3.1",
|
|
80
77
|
"@vitejs/plugin-react": "^4.3.4",
|
|
@@ -84,12 +81,14 @@
|
|
|
84
81
|
"globals": "^15.13.0",
|
|
85
82
|
"react": "^18.3.1",
|
|
86
83
|
"react-dom": "^18.3.1",
|
|
87
|
-
"storybook": "^
|
|
84
|
+
"storybook": "^10.1.7",
|
|
88
85
|
"terser": "^5.37.0",
|
|
89
86
|
"typescript": "^5.7.2",
|
|
90
87
|
"typescript-eslint": "^8.16.0",
|
|
91
88
|
"vite": "^6.0.3",
|
|
92
89
|
"vite-plugin-css-injected-by-js": "^3.5.2",
|
|
93
|
-
"vite-plugin-dts": "^4.3.0"
|
|
90
|
+
"vite-plugin-dts": "^4.3.0",
|
|
91
|
+
"eslint-plugin-storybook": "10.1.7",
|
|
92
|
+
"@storybook/addon-docs": "^10.1.7"
|
|
94
93
|
}
|
|
95
94
|
}
|