@brainbase-labs/chat-widget 0.1.0 → 0.1.1
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.cjs +4 -4
- package/dist/index.d.ts +3 -1
- package/dist/index.js +703 -607
- package/dist/styles.css +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,94 +1,94 @@
|
|
|
1
|
-
import { useState as
|
|
2
|
-
import { jsxs as
|
|
3
|
-
const
|
|
4
|
-
function
|
|
1
|
+
import { useState as I, useRef as R, useEffect as U, useCallback as x, useMemo as ee } from "react";
|
|
2
|
+
import { jsxs as i, jsx as e } from "react/jsx-runtime";
|
|
3
|
+
const te = "bb-chat-";
|
|
4
|
+
function ie(o) {
|
|
5
5
|
try {
|
|
6
|
-
const t = sessionStorage.getItem(`${
|
|
6
|
+
const t = sessionStorage.getItem(`${te}${o}`);
|
|
7
7
|
return t ? JSON.parse(t) : null;
|
|
8
8
|
} catch {
|
|
9
9
|
return null;
|
|
10
10
|
}
|
|
11
11
|
}
|
|
12
|
-
function
|
|
12
|
+
function ne(o, t) {
|
|
13
13
|
try {
|
|
14
14
|
sessionStorage.setItem(
|
|
15
|
-
`${
|
|
15
|
+
`${te}${o}`,
|
|
16
16
|
JSON.stringify(t)
|
|
17
17
|
);
|
|
18
18
|
} catch {
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
|
-
function
|
|
21
|
+
function se(o) {
|
|
22
22
|
try {
|
|
23
|
-
sessionStorage.removeItem(`${
|
|
23
|
+
sessionStorage.removeItem(`${te}${o}`);
|
|
24
24
|
} catch {
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
|
-
function
|
|
27
|
+
function le(o) {
|
|
28
28
|
const {
|
|
29
29
|
config: t,
|
|
30
30
|
apiClient: s,
|
|
31
31
|
mockMode: r,
|
|
32
|
-
onSessionStart:
|
|
33
|
-
onSessionEnd:
|
|
34
|
-
onMessage:
|
|
35
|
-
onError:
|
|
36
|
-
} =
|
|
37
|
-
|
|
38
|
-
if (
|
|
39
|
-
|
|
40
|
-
const _ =
|
|
41
|
-
_ && _.status === "active" && (
|
|
42
|
-
}, [t.embedId]),
|
|
43
|
-
|
|
44
|
-
sessionId:
|
|
32
|
+
onSessionStart: d,
|
|
33
|
+
onSessionEnd: u,
|
|
34
|
+
onMessage: c,
|
|
35
|
+
onError: m
|
|
36
|
+
} = o, [l, n] = I([]), [C, M] = I([]), [j, S] = I(!1), [q, P] = I(null), [g, H] = I(null), T = R(0), V = R(!1);
|
|
37
|
+
U(() => {
|
|
38
|
+
if (V.current) return;
|
|
39
|
+
V.current = !0;
|
|
40
|
+
const _ = ie(t.embedId);
|
|
41
|
+
_ && _.status === "active" && (H(_.sessionId), n(_.messages), M(_.toolCalls), T.current = _.startTime);
|
|
42
|
+
}, [t.embedId]), U(() => {
|
|
43
|
+
g && l.length > 0 && ne(t.embedId, {
|
|
44
|
+
sessionId: g,
|
|
45
45
|
deploymentId: t.deploymentId,
|
|
46
46
|
workerId: t.workerId,
|
|
47
47
|
flowId: t.flowId,
|
|
48
|
-
startTime:
|
|
49
|
-
messages:
|
|
48
|
+
startTime: T.current,
|
|
49
|
+
messages: l,
|
|
50
50
|
toolCalls: C,
|
|
51
51
|
status: "active"
|
|
52
52
|
});
|
|
53
|
-
}, [
|
|
54
|
-
const K = x(async () => (
|
|
55
|
-
(_,
|
|
53
|
+
}, [g, l, C, t]);
|
|
54
|
+
const K = x(async () => (T.current = Date.now(), H(null), n([]), M([]), se(t.embedId), ""), [t.embedId]), B = x(
|
|
55
|
+
(_, b, k) => {
|
|
56
56
|
switch (_.type) {
|
|
57
57
|
case "session": {
|
|
58
|
-
const
|
|
59
|
-
|
|
58
|
+
const p = _.data;
|
|
59
|
+
p.session_id && (k(p.session_id), p.is_new && (T.current = Date.now(), d == null || d(p.session_id)));
|
|
60
60
|
break;
|
|
61
61
|
}
|
|
62
62
|
case "message": {
|
|
63
|
-
const
|
|
64
|
-
|
|
65
|
-
(
|
|
66
|
-
(a) => a.id ===
|
|
63
|
+
const p = _.data;
|
|
64
|
+
p.content && n(
|
|
65
|
+
(h) => h.map(
|
|
66
|
+
(a) => a.id === b ? { ...a, content: p.content, status: "streaming" } : a
|
|
67
67
|
)
|
|
68
68
|
);
|
|
69
69
|
break;
|
|
70
70
|
}
|
|
71
71
|
case "tool_call": {
|
|
72
|
-
const
|
|
73
|
-
|
|
74
|
-
const a =
|
|
75
|
-
(
|
|
72
|
+
const p = _.data;
|
|
73
|
+
M((h) => {
|
|
74
|
+
const a = h.findIndex(
|
|
75
|
+
(f) => f.name === p.function && f.status === "pending"
|
|
76
76
|
);
|
|
77
|
-
return a !== -1 &&
|
|
78
|
-
(
|
|
77
|
+
return a !== -1 && p.result !== void 0 ? h.map(
|
|
78
|
+
(f, v) => v === a ? { ...f, result: p.result, status: "completed" } : f
|
|
79
79
|
) : a === -1 ? [
|
|
80
|
-
...
|
|
80
|
+
...h,
|
|
81
81
|
{
|
|
82
82
|
id: `tc-${Date.now()}-${Math.random().toString(36).slice(2)}`,
|
|
83
|
-
name:
|
|
84
|
-
arguments:
|
|
83
|
+
name: p.function,
|
|
84
|
+
arguments: p.args ?? {},
|
|
85
85
|
status: "pending",
|
|
86
86
|
timestamp: Date.now()
|
|
87
87
|
}
|
|
88
|
-
] :
|
|
89
|
-
}),
|
|
90
|
-
(
|
|
91
|
-
(a) => a.id ===
|
|
88
|
+
] : h;
|
|
89
|
+
}), p.content && n(
|
|
90
|
+
(h) => h.map(
|
|
91
|
+
(a) => a.id === b ? { ...a, content: p.content, status: "streaming" } : a
|
|
92
92
|
)
|
|
93
93
|
);
|
|
94
94
|
break;
|
|
@@ -96,34 +96,34 @@ function ae(n) {
|
|
|
96
96
|
case "waiting":
|
|
97
97
|
break;
|
|
98
98
|
case "done": {
|
|
99
|
-
|
|
100
|
-
(
|
|
99
|
+
n(
|
|
100
|
+
(p) => p.map((h) => h.id === b ? { ...h, status: "sent" } : h)
|
|
101
101
|
);
|
|
102
102
|
break;
|
|
103
103
|
}
|
|
104
104
|
case "completed": {
|
|
105
|
-
|
|
106
|
-
(
|
|
107
|
-
),
|
|
108
|
-
sessionId:
|
|
105
|
+
n(
|
|
106
|
+
(p) => p.map((h) => h.id === b ? { ...h, status: "sent" } : h)
|
|
107
|
+
), g && ne(t.embedId, {
|
|
108
|
+
sessionId: g,
|
|
109
109
|
deploymentId: t.deploymentId,
|
|
110
110
|
workerId: t.workerId,
|
|
111
111
|
flowId: t.flowId,
|
|
112
|
-
startTime:
|
|
113
|
-
messages:
|
|
112
|
+
startTime: T.current,
|
|
113
|
+
messages: l,
|
|
114
114
|
toolCalls: C,
|
|
115
115
|
status: "completed"
|
|
116
116
|
});
|
|
117
117
|
break;
|
|
118
118
|
}
|
|
119
119
|
case "error": {
|
|
120
|
-
const
|
|
121
|
-
|
|
122
|
-
(
|
|
123
|
-
(a) => a.id ===
|
|
120
|
+
const p = _.data;
|
|
121
|
+
n(
|
|
122
|
+
(h) => h.map(
|
|
123
|
+
(a) => a.id === b ? {
|
|
124
124
|
...a,
|
|
125
125
|
status: "error",
|
|
126
|
-
content:
|
|
126
|
+
content: p.error ?? "An error occurred"
|
|
127
127
|
} : a
|
|
128
128
|
)
|
|
129
129
|
);
|
|
@@ -131,137 +131,137 @@ function ae(n) {
|
|
|
131
131
|
}
|
|
132
132
|
}
|
|
133
133
|
},
|
|
134
|
-
[t,
|
|
135
|
-
),
|
|
136
|
-
async (_,
|
|
137
|
-
const
|
|
134
|
+
[t, g, l, C, d]
|
|
135
|
+
), G = x(
|
|
136
|
+
async (_, b, k) => {
|
|
137
|
+
const p = _.getReader(), h = new TextDecoder();
|
|
138
138
|
let a = "";
|
|
139
139
|
try {
|
|
140
140
|
for (; ; ) {
|
|
141
|
-
const { done:
|
|
142
|
-
if (
|
|
143
|
-
for (a +=
|
|
141
|
+
const { done: f, value: v } = await p.read();
|
|
142
|
+
if (f) break;
|
|
143
|
+
for (a += h.decode(v, { stream: !0 }); a.includes(`
|
|
144
144
|
|
|
145
145
|
`); ) {
|
|
146
|
-
const [
|
|
146
|
+
const [$, ae] = a.split(`
|
|
147
147
|
|
|
148
148
|
`, 2);
|
|
149
|
-
a =
|
|
150
|
-
for (const
|
|
149
|
+
a = ae;
|
|
150
|
+
for (const oe of $.split(`
|
|
151
151
|
`))
|
|
152
|
-
if (
|
|
152
|
+
if (oe.startsWith("data: "))
|
|
153
153
|
try {
|
|
154
|
-
const
|
|
155
|
-
|
|
154
|
+
const ce = JSON.parse(oe.slice(6));
|
|
155
|
+
B(ce, b, k);
|
|
156
156
|
} catch {
|
|
157
157
|
}
|
|
158
158
|
}
|
|
159
159
|
}
|
|
160
160
|
} finally {
|
|
161
|
-
|
|
161
|
+
p.releaseLock();
|
|
162
162
|
}
|
|
163
163
|
},
|
|
164
|
-
[
|
|
165
|
-
),
|
|
164
|
+
[B]
|
|
165
|
+
), J = x(
|
|
166
166
|
async (_) => {
|
|
167
167
|
if (!_.trim()) return;
|
|
168
|
-
const
|
|
168
|
+
const b = {
|
|
169
169
|
id: `user-${Date.now()}`,
|
|
170
170
|
role: "user",
|
|
171
171
|
content: _,
|
|
172
172
|
timestamp: Date.now(),
|
|
173
173
|
status: "sent"
|
|
174
174
|
};
|
|
175
|
-
|
|
176
|
-
const
|
|
177
|
-
id:
|
|
175
|
+
n((a) => [...a, b]), c == null || c(b);
|
|
176
|
+
const k = `assistant-${Date.now()}`, p = {
|
|
177
|
+
id: k,
|
|
178
178
|
role: "assistant",
|
|
179
179
|
content: "",
|
|
180
180
|
timestamp: Date.now(),
|
|
181
181
|
status: "streaming"
|
|
182
182
|
};
|
|
183
|
-
|
|
184
|
-
const
|
|
185
|
-
|
|
183
|
+
n((a) => [...a, p]), S(!0), P(null);
|
|
184
|
+
const h = (a) => {
|
|
185
|
+
H(a);
|
|
186
186
|
};
|
|
187
187
|
try {
|
|
188
188
|
if (r) {
|
|
189
189
|
const a = s.sendMessage(_);
|
|
190
|
-
for await (const
|
|
191
|
-
|
|
190
|
+
for await (const f of a)
|
|
191
|
+
B(f, k, h);
|
|
192
192
|
} else {
|
|
193
193
|
const a = await s.sendMessage({
|
|
194
194
|
embedId: t.embedId,
|
|
195
195
|
message: _,
|
|
196
|
-
sessionId:
|
|
196
|
+
sessionId: g ?? void 0
|
|
197
197
|
});
|
|
198
|
-
await
|
|
198
|
+
await G(a, k, h);
|
|
199
199
|
}
|
|
200
|
-
|
|
200
|
+
n(
|
|
201
201
|
(a) => a.map(
|
|
202
|
-
(
|
|
202
|
+
(f) => f.id === k && f.status === "streaming" ? { ...f, status: "sent" } : f
|
|
203
203
|
)
|
|
204
204
|
);
|
|
205
205
|
} catch (a) {
|
|
206
|
-
const
|
|
207
|
-
|
|
208
|
-
(
|
|
209
|
-
(
|
|
206
|
+
const f = a instanceof Error ? a : new Error("Failed to send message");
|
|
207
|
+
P(f), m == null || m(f), n(
|
|
208
|
+
(v) => v.map(
|
|
209
|
+
($) => $.id === k ? { ...$, status: "error", content: "Failed to get response" } : $
|
|
210
210
|
)
|
|
211
211
|
);
|
|
212
212
|
} finally {
|
|
213
|
-
|
|
213
|
+
S(!1);
|
|
214
214
|
}
|
|
215
215
|
},
|
|
216
216
|
[
|
|
217
|
-
|
|
217
|
+
g,
|
|
218
218
|
s,
|
|
219
219
|
r,
|
|
220
220
|
t.embedId,
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
221
|
+
B,
|
|
222
|
+
G,
|
|
223
|
+
c,
|
|
224
|
+
m
|
|
225
225
|
]
|
|
226
|
-
),
|
|
227
|
-
if (!
|
|
226
|
+
), A = x(async () => {
|
|
227
|
+
if (!g) return;
|
|
228
228
|
const _ = {
|
|
229
|
-
sessionId:
|
|
229
|
+
sessionId: g,
|
|
230
230
|
deploymentId: t.deploymentId,
|
|
231
231
|
workerId: t.workerId,
|
|
232
232
|
flowId: t.flowId,
|
|
233
|
-
startTime:
|
|
234
|
-
messages:
|
|
233
|
+
startTime: T.current,
|
|
234
|
+
messages: l,
|
|
235
235
|
toolCalls: C,
|
|
236
236
|
status: "completed"
|
|
237
237
|
};
|
|
238
|
-
|
|
238
|
+
u == null || u(_), se(t.embedId), H(null), n([]), M([]);
|
|
239
239
|
}, [
|
|
240
|
-
|
|
240
|
+
g,
|
|
241
241
|
t,
|
|
242
|
-
|
|
242
|
+
l,
|
|
243
243
|
C,
|
|
244
|
-
|
|
245
|
-
]),
|
|
246
|
-
|
|
244
|
+
u
|
|
245
|
+
]), z = x(() => {
|
|
246
|
+
n([]), M([]);
|
|
247
247
|
}, []);
|
|
248
248
|
return {
|
|
249
|
-
messages:
|
|
249
|
+
messages: l,
|
|
250
250
|
toolCalls: C,
|
|
251
|
-
isLoading:
|
|
251
|
+
isLoading: j,
|
|
252
252
|
error: q,
|
|
253
|
-
sessionId:
|
|
254
|
-
sendMessage:
|
|
255
|
-
endSession:
|
|
256
|
-
clearMessages:
|
|
253
|
+
sessionId: g,
|
|
254
|
+
sendMessage: J,
|
|
255
|
+
endSession: A,
|
|
256
|
+
clearMessages: z,
|
|
257
257
|
startNewSession: K
|
|
258
258
|
};
|
|
259
259
|
}
|
|
260
|
-
const
|
|
261
|
-
function
|
|
260
|
+
const de = "https://whatsapp-based-server.onrender.com";
|
|
261
|
+
function ue(o = de) {
|
|
262
262
|
return {
|
|
263
263
|
async getDeploymentConfig(t) {
|
|
264
|
-
const s = await fetch(`${
|
|
264
|
+
const s = await fetch(`${o}/chat/config/${t}`);
|
|
265
265
|
if (!s.ok)
|
|
266
266
|
throw new Error(`Failed to fetch deployment config: ${s.status}`);
|
|
267
267
|
const r = await s.json();
|
|
@@ -280,7 +280,7 @@ function ce(n = ie) {
|
|
|
280
280
|
};
|
|
281
281
|
},
|
|
282
282
|
async sendMessage(t) {
|
|
283
|
-
const s = await fetch(`${
|
|
283
|
+
const s = await fetch(`${o}/chat/message`, {
|
|
284
284
|
method: "POST",
|
|
285
285
|
headers: { "Content-Type": "application/json" },
|
|
286
286
|
body: JSON.stringify({
|
|
@@ -300,7 +300,7 @@ function ce(n = ie) {
|
|
|
300
300
|
}
|
|
301
301
|
};
|
|
302
302
|
}
|
|
303
|
-
const
|
|
303
|
+
const me = {
|
|
304
304
|
embedId: "mock-embed-id",
|
|
305
305
|
deploymentId: "mock-deployment-id",
|
|
306
306
|
workerId: "mock-worker-id",
|
|
@@ -310,7 +310,7 @@ const le = {
|
|
|
310
310
|
agentLogoUrl: void 0,
|
|
311
311
|
primaryColor: "#1a1a2e",
|
|
312
312
|
styling: {}
|
|
313
|
-
},
|
|
313
|
+
}, ge = [
|
|
314
314
|
{
|
|
315
315
|
trigger: /hello|hi|hey/i,
|
|
316
316
|
response: "Hello! I'm a demo AI assistant. How can I help you today?",
|
|
@@ -356,82 +356,65 @@ const le = {
|
|
|
356
356
|
delay: 1e3
|
|
357
357
|
}
|
|
358
358
|
];
|
|
359
|
-
function
|
|
360
|
-
return new Promise((t) => setTimeout(t,
|
|
359
|
+
function F(o) {
|
|
360
|
+
return new Promise((t) => setTimeout(t, o));
|
|
361
361
|
}
|
|
362
|
-
function
|
|
363
|
-
const s = { ...
|
|
362
|
+
function pe(o, t) {
|
|
363
|
+
const s = { ...me, ...o }, r = t ?? ge, d = `mock-session-${Date.now()}`;
|
|
364
364
|
return {
|
|
365
|
-
async getDeploymentConfig(
|
|
366
|
-
return await
|
|
365
|
+
async getDeploymentConfig(u) {
|
|
366
|
+
return await F(300), s;
|
|
367
367
|
},
|
|
368
|
-
async *sendMessage(
|
|
368
|
+
async *sendMessage(u) {
|
|
369
369
|
yield {
|
|
370
370
|
type: "session",
|
|
371
|
-
data: { session_id:
|
|
371
|
+
data: { session_id: d, is_new: !0 },
|
|
372
372
|
timestamp: Date.now()
|
|
373
373
|
};
|
|
374
|
-
const
|
|
375
|
-
(
|
|
374
|
+
const c = r.find(
|
|
375
|
+
(n) => typeof n.trigger == "string" ? u.toLowerCase().includes(n.trigger.toLowerCase()) : n.trigger.test(u)
|
|
376
376
|
) ?? r[r.length - 1];
|
|
377
|
-
if (await
|
|
378
|
-
for (const
|
|
377
|
+
if (await F(c.delay ?? 500), c.toolCalls)
|
|
378
|
+
for (const n of c.toolCalls)
|
|
379
379
|
yield {
|
|
380
380
|
type: "tool_call",
|
|
381
381
|
data: {
|
|
382
|
-
function:
|
|
383
|
-
args:
|
|
382
|
+
function: n.name,
|
|
383
|
+
args: n.arguments
|
|
384
384
|
},
|
|
385
385
|
timestamp: Date.now()
|
|
386
|
-
}, await
|
|
386
|
+
}, await F(300), yield {
|
|
387
387
|
type: "tool_call",
|
|
388
388
|
data: {
|
|
389
|
-
function:
|
|
390
|
-
result:
|
|
389
|
+
function: n.name,
|
|
390
|
+
result: n.result
|
|
391
391
|
},
|
|
392
392
|
timestamp: Date.now()
|
|
393
|
-
}, await
|
|
394
|
-
const
|
|
395
|
-
let
|
|
396
|
-
for (const
|
|
397
|
-
|
|
393
|
+
}, await F(200);
|
|
394
|
+
const m = c.response.split(" ");
|
|
395
|
+
let l = "";
|
|
396
|
+
for (const n of m)
|
|
397
|
+
l += (l ? " " : "") + n, yield {
|
|
398
398
|
type: "message",
|
|
399
|
-
data: { content:
|
|
399
|
+
data: { content: l, role: "assistant" },
|
|
400
400
|
timestamp: Date.now()
|
|
401
|
-
}, await
|
|
401
|
+
}, await F(30 + Math.random() * 40);
|
|
402
402
|
yield {
|
|
403
403
|
type: "done",
|
|
404
|
-
data: { session_id:
|
|
404
|
+
data: { session_id: d },
|
|
405
405
|
timestamp: Date.now()
|
|
406
406
|
};
|
|
407
407
|
}
|
|
408
408
|
};
|
|
409
409
|
}
|
|
410
|
-
const
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
agentInfo: _e,
|
|
416
|
-
agentLogo: fe,
|
|
417
|
-
agentLogoPlaceholder: we,
|
|
418
|
-
brainbaseLogo: Ce,
|
|
419
|
-
agentName: be,
|
|
420
|
-
actions: ye,
|
|
421
|
-
actionButton: Ie,
|
|
422
|
-
welcomeText: ve,
|
|
423
|
-
title: ke,
|
|
424
|
-
subtitle: Ne,
|
|
425
|
-
confirmationOverlay: Le,
|
|
426
|
-
confirmationDialog: xe,
|
|
427
|
-
confirmationText: Be,
|
|
428
|
-
confirmationButtons: $e,
|
|
429
|
-
cancelButton: Me,
|
|
430
|
-
confirmButton: Se
|
|
431
|
-
}, He = ({ className: n }) => /* @__PURE__ */ l(
|
|
410
|
+
const Z = ({
|
|
411
|
+
className: o,
|
|
412
|
+
color: t = "currentColor",
|
|
413
|
+
cutoutColor: s = "var(--bb-primary-color)"
|
|
414
|
+
}) => /* @__PURE__ */ i(
|
|
432
415
|
"svg",
|
|
433
416
|
{
|
|
434
|
-
className:
|
|
417
|
+
className: o,
|
|
435
418
|
viewBox: "0 0 800 800",
|
|
436
419
|
fill: "none",
|
|
437
420
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -440,30 +423,30 @@ const me = "_header_tzm7g_1", ge = "_headerBackground_tzm7g_8", he = "_headerCon
|
|
|
440
423
|
"path",
|
|
441
424
|
{
|
|
442
425
|
d: "M400 412C400 405.373 405.373 400 412 400H788C794.627 400 800 405.373 800 412V740C800 773.137 773.137 800 740 800H412C405.373 800 400 794.627 400 788V412Z",
|
|
443
|
-
fill:
|
|
426
|
+
fill: t
|
|
444
427
|
}
|
|
445
428
|
),
|
|
446
|
-
/* @__PURE__ */ e("circle", { cx: "400", cy: "400", r: "400", fill:
|
|
429
|
+
/* @__PURE__ */ e("circle", { cx: "400", cy: "400", r: "400", fill: t }),
|
|
447
430
|
/* @__PURE__ */ e(
|
|
448
431
|
"path",
|
|
449
432
|
{
|
|
450
433
|
d: "M0 60C0 26.8629 26.8629 0 60 0H397.614C398.932 0 400 1.06811 400 2.38569V2.38569C400 221.982 221.982 400 2.38569 400V400C1.06811 400 0 398.932 0 397.614V60Z",
|
|
451
|
-
fill:
|
|
434
|
+
fill: t
|
|
452
435
|
}
|
|
453
436
|
),
|
|
454
437
|
/* @__PURE__ */ e(
|
|
455
438
|
"path",
|
|
456
439
|
{
|
|
457
440
|
d: "M400 412C400 405.373 405.373 400 412 400H738C744.627 400 750 405.373 750 412V725C750 738.807 738.807 750 725 750H412C405.373 750 400 744.627 400 738V412Z",
|
|
458
|
-
fill:
|
|
441
|
+
fill: t
|
|
459
442
|
}
|
|
460
443
|
),
|
|
461
|
-
/* @__PURE__ */ e("circle", { cx: "400", cy: "400", r: "350", fill:
|
|
444
|
+
/* @__PURE__ */ e("circle", { cx: "400", cy: "400", r: "350", fill: t }),
|
|
462
445
|
/* @__PURE__ */ e(
|
|
463
446
|
"path",
|
|
464
447
|
{
|
|
465
448
|
d: "M50 75C50 61.1929 61.1929 50 75 50H388C394.627 50 400 55.3726 400 62V388C400 394.627 394.627 400 388 400H62C55.3726 400 50 394.627 50 388V75Z",
|
|
466
|
-
fill:
|
|
449
|
+
fill: t
|
|
467
450
|
}
|
|
468
451
|
),
|
|
469
452
|
/* @__PURE__ */ e(
|
|
@@ -475,48 +458,66 @@ const me = "_header_tzm7g_1", ge = "_headerBackground_tzm7g_8", he = "_headerCon
|
|
|
475
458
|
height: "270",
|
|
476
459
|
rx: "12",
|
|
477
460
|
transform: "rotate(45 399.919 209)",
|
|
478
|
-
fill:
|
|
461
|
+
fill: s
|
|
479
462
|
}
|
|
480
463
|
)
|
|
481
464
|
]
|
|
482
465
|
}
|
|
483
|
-
),
|
|
484
|
-
|
|
466
|
+
), he = "_header_1p6z5_1", _e = "_compact_1p6z5_9", fe = "_headerBackground_1p6z5_20", be = "_headerContent_1p6z5_59", we = "_topRow_1p6z5_64", ye = "_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", Be = "_welcomeText_1p6z5_183", $e = "_title_1p6z5_202", xe = "_subtitle_1p6z5_210", w = {
|
|
467
|
+
header: he,
|
|
468
|
+
compact: _e,
|
|
469
|
+
headerBackground: fe,
|
|
470
|
+
headerContent: be,
|
|
471
|
+
topRow: we,
|
|
472
|
+
agentInfo: ye,
|
|
473
|
+
agentLogo: Ce,
|
|
474
|
+
agentLogoPlaceholder: ke,
|
|
475
|
+
brainbaseLogo: ve,
|
|
476
|
+
agentName: Ie,
|
|
477
|
+
actions: Ne,
|
|
478
|
+
actionButton: Le,
|
|
479
|
+
welcomeText: Be,
|
|
480
|
+
title: $e,
|
|
481
|
+
subtitle: xe
|
|
482
|
+
}, Me = ({
|
|
483
|
+
agentName: o = "AI Assistant",
|
|
485
484
|
agentLogoUrl: t,
|
|
486
485
|
welcomeTitle: s,
|
|
487
486
|
welcomeSubtitle: r,
|
|
488
|
-
onClose:
|
|
489
|
-
|
|
490
|
-
showNewChatButton:
|
|
487
|
+
onClose: d,
|
|
488
|
+
onNewChatRequest: u,
|
|
489
|
+
showNewChatButton: c = !1,
|
|
490
|
+
compact: m = !1
|
|
491
491
|
}) => {
|
|
492
|
-
const
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
};
|
|
499
|
-
return /* @__PURE__ */ l("div", { className: f.header, children: [
|
|
500
|
-
/* @__PURE__ */ e("div", { className: f.headerBackground }),
|
|
501
|
-
/* @__PURE__ */ l("div", { className: f.headerContent, children: [
|
|
502
|
-
/* @__PURE__ */ l("div", { className: f.topRow, children: [
|
|
503
|
-
/* @__PURE__ */ l("div", { className: f.agentInfo, children: [
|
|
492
|
+
const l = s || "Hello there.", n = r || "How can we help?";
|
|
493
|
+
return /* @__PURE__ */ i("div", { className: `${w.header} ${m ? 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: [
|
|
504
498
|
t ? /* @__PURE__ */ e(
|
|
505
499
|
"img",
|
|
506
500
|
{
|
|
507
501
|
src: t,
|
|
508
|
-
alt:
|
|
509
|
-
className:
|
|
502
|
+
alt: o,
|
|
503
|
+
className: w.agentLogo
|
|
504
|
+
}
|
|
505
|
+
) : /* @__PURE__ */ e("div", { className: w.agentLogoPlaceholder, children: /* @__PURE__ */ e(
|
|
506
|
+
Z,
|
|
507
|
+
{
|
|
508
|
+
className: w.brainbaseLogo,
|
|
509
|
+
color: "white",
|
|
510
|
+
cutoutColor: "var(--bb-primary-color)"
|
|
510
511
|
}
|
|
511
|
-
)
|
|
512
|
-
/* @__PURE__ */ e("span", { className:
|
|
512
|
+
) }),
|
|
513
|
+
/* @__PURE__ */ e("span", { className: w.agentName, children: o })
|
|
513
514
|
] }),
|
|
514
|
-
/* @__PURE__ */
|
|
515
|
-
|
|
515
|
+
/* @__PURE__ */ i("div", { className: w.actions, children: [
|
|
516
|
+
c && u && /* @__PURE__ */ e(
|
|
516
517
|
"button",
|
|
517
518
|
{
|
|
518
|
-
className:
|
|
519
|
-
onClick:
|
|
519
|
+
className: w.actionButton,
|
|
520
|
+
onClick: u,
|
|
520
521
|
"aria-label": "Start new chat",
|
|
521
522
|
type: "button",
|
|
522
523
|
children: /* @__PURE__ */ e("svg", { viewBox: "0 0 24 24", fill: "none", children: /* @__PURE__ */ e(
|
|
@@ -531,11 +532,11 @@ const me = "_header_tzm7g_1", ge = "_headerBackground_tzm7g_8", he = "_headerCon
|
|
|
531
532
|
) })
|
|
532
533
|
}
|
|
533
534
|
),
|
|
534
|
-
|
|
535
|
+
d && /* @__PURE__ */ e(
|
|
535
536
|
"button",
|
|
536
537
|
{
|
|
537
|
-
className:
|
|
538
|
-
onClick:
|
|
538
|
+
className: w.actionButton,
|
|
539
|
+
onClick: d,
|
|
539
540
|
"aria-label": "Close chat",
|
|
540
541
|
type: "button",
|
|
541
542
|
children: /* @__PURE__ */ e("svg", { viewBox: "0 0 24 24", fill: "none", children: /* @__PURE__ */ e(
|
|
@@ -552,124 +553,56 @@ const me = "_header_tzm7g_1", ge = "_headerBackground_tzm7g_8", he = "_headerCon
|
|
|
552
553
|
)
|
|
553
554
|
] })
|
|
554
555
|
] }),
|
|
555
|
-
/* @__PURE__ */
|
|
556
|
-
/* @__PURE__ */ e("h1", { className:
|
|
557
|
-
/* @__PURE__ */ e("p", { className:
|
|
558
|
-
] })
|
|
559
|
-
] }),
|
|
560
|
-
p && /* @__PURE__ */ e("div", { className: f.confirmationOverlay, children: /* @__PURE__ */ l("div", { className: f.confirmationDialog, children: [
|
|
561
|
-
/* @__PURE__ */ e("p", { className: f.confirmationText, children: "End current chat and start a new conversation?" }),
|
|
562
|
-
/* @__PURE__ */ l("div", { className: f.confirmationButtons, children: [
|
|
563
|
-
/* @__PURE__ */ e(
|
|
564
|
-
"button",
|
|
565
|
-
{
|
|
566
|
-
className: f.cancelButton,
|
|
567
|
-
onClick: N,
|
|
568
|
-
type: "button",
|
|
569
|
-
children: "Cancel"
|
|
570
|
-
}
|
|
571
|
-
),
|
|
572
|
-
/* @__PURE__ */ e(
|
|
573
|
-
"button",
|
|
574
|
-
{
|
|
575
|
-
className: f.confirmButton,
|
|
576
|
-
onClick: V,
|
|
577
|
-
type: "button",
|
|
578
|
-
children: "End Chat"
|
|
579
|
-
}
|
|
580
|
-
)
|
|
556
|
+
!m && /* @__PURE__ */ i("div", { className: w.welcomeText, children: [
|
|
557
|
+
/* @__PURE__ */ e("h1", { className: w.title, children: l }),
|
|
558
|
+
/* @__PURE__ */ e("p", { className: w.subtitle, children: n })
|
|
581
559
|
] })
|
|
582
|
-
] })
|
|
560
|
+
] })
|
|
583
561
|
] });
|
|
584
|
-
},
|
|
585
|
-
messageWrapper:
|
|
586
|
-
user:
|
|
587
|
-
assistant:
|
|
588
|
-
avatar:
|
|
589
|
-
avatarPlaceholder:
|
|
590
|
-
brainbaseLogo:
|
|
591
|
-
messageBubble:
|
|
592
|
-
error:
|
|
593
|
-
content:
|
|
594
|
-
cursor:
|
|
595
|
-
errorIndicator:
|
|
596
|
-
},
|
|
597
|
-
|
|
598
|
-
{
|
|
599
|
-
className: n,
|
|
600
|
-
viewBox: "0 0 800 800",
|
|
601
|
-
fill: "none",
|
|
602
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
603
|
-
children: [
|
|
604
|
-
/* @__PURE__ */ e(
|
|
605
|
-
"path",
|
|
606
|
-
{
|
|
607
|
-
d: "M400 412C400 405.373 405.373 400 412 400H788C794.627 400 800 405.373 800 412V740C800 773.137 773.137 800 740 800H412C405.373 800 400 794.627 400 788V412Z",
|
|
608
|
-
fill: "currentColor"
|
|
609
|
-
}
|
|
610
|
-
),
|
|
611
|
-
/* @__PURE__ */ e("circle", { cx: "400", cy: "400", r: "400", fill: "currentColor" }),
|
|
612
|
-
/* @__PURE__ */ e(
|
|
613
|
-
"path",
|
|
614
|
-
{
|
|
615
|
-
d: "M0 60C0 26.8629 26.8629 0 60 0H397.614C398.932 0 400 1.06811 400 2.38569V2.38569C400 221.982 221.982 400 2.38569 400V400C1.06811 400 0 398.932 0 397.614V60Z",
|
|
616
|
-
fill: "currentColor"
|
|
617
|
-
}
|
|
618
|
-
),
|
|
619
|
-
/* @__PURE__ */ e(
|
|
620
|
-
"path",
|
|
621
|
-
{
|
|
622
|
-
d: "M400 412C400 405.373 405.373 400 412 400H738C744.627 400 750 405.373 750 412V725C750 738.807 738.807 750 725 750H412C405.373 750 400 744.627 400 738V412Z",
|
|
623
|
-
fill: "currentColor"
|
|
624
|
-
}
|
|
625
|
-
),
|
|
626
|
-
/* @__PURE__ */ e("circle", { cx: "400", cy: "400", r: "350", fill: "currentColor" }),
|
|
627
|
-
/* @__PURE__ */ e(
|
|
628
|
-
"path",
|
|
629
|
-
{
|
|
630
|
-
d: "M50 75C50 61.1929 61.1929 50 75 50H388C394.627 50 400 55.3726 400 62V388C400 394.627 394.627 400 388 400H62C55.3726 400 50 394.627 50 388V75Z",
|
|
631
|
-
fill: "currentColor"
|
|
632
|
-
}
|
|
633
|
-
),
|
|
634
|
-
/* @__PURE__ */ e(
|
|
635
|
-
"rect",
|
|
636
|
-
{
|
|
637
|
-
x: "399.919",
|
|
638
|
-
y: "209",
|
|
639
|
-
width: "270",
|
|
640
|
-
height: "270",
|
|
641
|
-
rx: "12",
|
|
642
|
-
transform: "rotate(45 399.919 209)",
|
|
643
|
-
fill: "white"
|
|
644
|
-
}
|
|
645
|
-
)
|
|
646
|
-
]
|
|
647
|
-
}
|
|
648
|
-
), Ue = ({
|
|
649
|
-
message: n,
|
|
562
|
+
}, Se = "_messageWrapper_c86gj_1", Te = "_user_c86gj_19", We = "_assistant_c86gj_24", De = "_avatar_c86gj_28", He = "_avatarPlaceholder_c86gj_43", Pe = "_brainbaseLogo_c86gj_53", Ee = "_messageBubble_c86gj_58", je = "_error_c86gj_76", Ve = "_content_c86gj_81", Ae = "_cursor_c86gj_88", ze = "_errorIndicator_c86gj_107", N = {
|
|
563
|
+
messageWrapper: Se,
|
|
564
|
+
user: Te,
|
|
565
|
+
assistant: We,
|
|
566
|
+
avatar: De,
|
|
567
|
+
avatarPlaceholder: He,
|
|
568
|
+
brainbaseLogo: Pe,
|
|
569
|
+
messageBubble: Ee,
|
|
570
|
+
error: je,
|
|
571
|
+
content: Ve,
|
|
572
|
+
cursor: Ae,
|
|
573
|
+
errorIndicator: ze
|
|
574
|
+
}, Fe = ({
|
|
575
|
+
message: o,
|
|
650
576
|
agentName: t,
|
|
651
577
|
agentLogoUrl: s
|
|
652
578
|
}) => {
|
|
653
|
-
const r =
|
|
654
|
-
return /* @__PURE__ */
|
|
579
|
+
const r = o.role === "user", d = o.status === "streaming", u = o.status === "error";
|
|
580
|
+
return /* @__PURE__ */ i(
|
|
655
581
|
"div",
|
|
656
582
|
{
|
|
657
|
-
className: `${
|
|
583
|
+
className: `${N.messageWrapper} ${r ? N.user : N.assistant}`,
|
|
658
584
|
children: [
|
|
659
|
-
!r && /* @__PURE__ */ e("div", { className:
|
|
660
|
-
|
|
585
|
+
!r && /* @__PURE__ */ e("div", { className: N.avatar, children: s ? /* @__PURE__ */ e("img", { src: s, alt: t || "AI" }) : /* @__PURE__ */ e("div", { className: N.avatarPlaceholder, children: /* @__PURE__ */ e(
|
|
586
|
+
Z,
|
|
587
|
+
{
|
|
588
|
+
className: N.brainbaseLogo,
|
|
589
|
+
color: "white",
|
|
590
|
+
cutoutColor: "var(--bb-primary-color)"
|
|
591
|
+
}
|
|
592
|
+
) }) }),
|
|
593
|
+
/* @__PURE__ */ i(
|
|
661
594
|
"div",
|
|
662
595
|
{
|
|
663
|
-
className: `${
|
|
596
|
+
className: `${N.messageBubble} ${u ? N.error : ""}`,
|
|
664
597
|
role: "article",
|
|
665
598
|
"aria-label": `${r ? "Your message" : `${t || "AI"} says`}`,
|
|
666
599
|
children: [
|
|
667
|
-
/* @__PURE__ */
|
|
668
|
-
|
|
669
|
-
|
|
600
|
+
/* @__PURE__ */ i("div", { className: N.content, children: [
|
|
601
|
+
o.content,
|
|
602
|
+
d && /* @__PURE__ */ e("span", { className: N.cursor })
|
|
670
603
|
] }),
|
|
671
|
-
|
|
672
|
-
/* @__PURE__ */
|
|
604
|
+
u && /* @__PURE__ */ i("div", { className: N.errorIndicator, children: [
|
|
605
|
+
/* @__PURE__ */ i("svg", { viewBox: "0 0 24 24", fill: "none", children: [
|
|
673
606
|
/* @__PURE__ */ e("circle", { cx: "12", cy: "12", r: "10", stroke: "currentColor", strokeWidth: "2" }),
|
|
674
607
|
/* @__PURE__ */ e("path", { d: "M12 8V12M12 16H12.01", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round" })
|
|
675
608
|
] }),
|
|
@@ -681,26 +614,26 @@ const me = "_header_tzm7g_1", ge = "_headerBackground_tzm7g_8", he = "_headerCon
|
|
|
681
614
|
]
|
|
682
615
|
}
|
|
683
616
|
);
|
|
684
|
-
},
|
|
685
|
-
toolCall:
|
|
686
|
-
iconWrapper:
|
|
687
|
-
spinner:
|
|
688
|
-
checkIcon:
|
|
689
|
-
errorIcon:
|
|
690
|
-
content:
|
|
691
|
-
label:
|
|
692
|
-
name:
|
|
693
|
-
pending:
|
|
694
|
-
completed:
|
|
695
|
-
error:
|
|
696
|
-
},
|
|
697
|
-
const t =
|
|
698
|
-
return /* @__PURE__ */
|
|
617
|
+
}, Oe = "_toolCall_1wby1_1", Re = "_iconWrapper_1wby1_24", Ue = "_spinner_1wby1_33", Ze = "_checkIcon_1wby1_48", qe = "_errorIcon_1wby1_54", Ke = "_content_1wby1_60", Ge = "_label_1wby1_66", Je = "_name_1wby1_73", Ye = "_pending_1wby1_78", Xe = "_completed_1wby1_82", Qe = "_error_1wby1_54", L = {
|
|
618
|
+
toolCall: Oe,
|
|
619
|
+
iconWrapper: Re,
|
|
620
|
+
spinner: Ue,
|
|
621
|
+
checkIcon: Ze,
|
|
622
|
+
errorIcon: qe,
|
|
623
|
+
content: Ke,
|
|
624
|
+
label: Ge,
|
|
625
|
+
name: Je,
|
|
626
|
+
pending: Ye,
|
|
627
|
+
completed: Xe,
|
|
628
|
+
error: Qe
|
|
629
|
+
}, et = ({ toolCall: o }) => {
|
|
630
|
+
const t = o.status === "pending" || o.status === "executing", s = o.status === "completed", r = o.status === "error", d = (u) => u.replace(/_/g, " ").replace(/([A-Z])/g, " $1").trim().toLowerCase().replace(/^./, (c) => c.toUpperCase());
|
|
631
|
+
return /* @__PURE__ */ i(
|
|
699
632
|
"div",
|
|
700
633
|
{
|
|
701
|
-
className: `${
|
|
634
|
+
className: `${L.toolCall} ${t ? L.pending : ""} ${s ? L.completed : ""} ${r ? L.error : ""}`,
|
|
702
635
|
children: [
|
|
703
|
-
/* @__PURE__ */ e("div", { className:
|
|
636
|
+
/* @__PURE__ */ e("div", { className: L.iconWrapper, children: t ? /* @__PURE__ */ e("div", { className: L.spinner }) : s ? /* @__PURE__ */ e("svg", { viewBox: "0 0 24 24", fill: "none", className: L.checkIcon, children: /* @__PURE__ */ e(
|
|
704
637
|
"path",
|
|
705
638
|
{
|
|
706
639
|
d: "M20 6L9 17L4 12",
|
|
@@ -709,7 +642,7 @@ const me = "_header_tzm7g_1", ge = "_headerBackground_tzm7g_8", he = "_headerCon
|
|
|
709
642
|
strokeLinecap: "round",
|
|
710
643
|
strokeLinejoin: "round"
|
|
711
644
|
}
|
|
712
|
-
) }) : /* @__PURE__ */ e("svg", { viewBox: "0 0 24 24", fill: "none", className:
|
|
645
|
+
) }) : /* @__PURE__ */ e("svg", { viewBox: "0 0 24 24", fill: "none", className: L.errorIcon, children: /* @__PURE__ */ e(
|
|
713
646
|
"path",
|
|
714
647
|
{
|
|
715
648
|
d: "M6 18L18 6M6 6L18 18",
|
|
@@ -719,106 +652,61 @@ const me = "_header_tzm7g_1", ge = "_headerBackground_tzm7g_8", he = "_headerCon
|
|
|
719
652
|
strokeLinejoin: "round"
|
|
720
653
|
}
|
|
721
654
|
) }) }),
|
|
722
|
-
/* @__PURE__ */
|
|
723
|
-
/* @__PURE__ */ e("span", { className:
|
|
724
|
-
/* @__PURE__ */ e("span", { className:
|
|
655
|
+
/* @__PURE__ */ i("div", { className: L.content, children: [
|
|
656
|
+
/* @__PURE__ */ e("span", { className: L.label, children: t ? "Running" : s ? "Completed" : "Failed" }),
|
|
657
|
+
/* @__PURE__ */ e("span", { className: L.name, children: d(o.name) })
|
|
725
658
|
] })
|
|
726
659
|
]
|
|
727
660
|
}
|
|
728
661
|
);
|
|
729
|
-
},
|
|
730
|
-
wrapper:
|
|
731
|
-
avatar:
|
|
732
|
-
avatarPlaceholder:
|
|
733
|
-
brainbaseLogo:
|
|
734
|
-
bubble:
|
|
735
|
-
dot:
|
|
736
|
-
},
|
|
737
|
-
"
|
|
738
|
-
{
|
|
739
|
-
className: n,
|
|
740
|
-
viewBox: "0 0 800 800",
|
|
741
|
-
fill: "none",
|
|
742
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
743
|
-
children: [
|
|
744
|
-
/* @__PURE__ */ e(
|
|
745
|
-
"path",
|
|
746
|
-
{
|
|
747
|
-
d: "M400 412C400 405.373 405.373 400 412 400H788C794.627 400 800 405.373 800 412V740C800 773.137 773.137 800 740 800H412C405.373 800 400 794.627 400 788V412Z",
|
|
748
|
-
fill: "currentColor"
|
|
749
|
-
}
|
|
750
|
-
),
|
|
751
|
-
/* @__PURE__ */ e("circle", { cx: "400", cy: "400", r: "400", fill: "currentColor" }),
|
|
752
|
-
/* @__PURE__ */ e(
|
|
753
|
-
"path",
|
|
754
|
-
{
|
|
755
|
-
d: "M0 60C0 26.8629 26.8629 0 60 0H397.614C398.932 0 400 1.06811 400 2.38569V2.38569C400 221.982 221.982 400 2.38569 400V400C1.06811 400 0 398.932 0 397.614V60Z",
|
|
756
|
-
fill: "currentColor"
|
|
757
|
-
}
|
|
758
|
-
),
|
|
759
|
-
/* @__PURE__ */ e(
|
|
760
|
-
"path",
|
|
761
|
-
{
|
|
762
|
-
d: "M400 412C400 405.373 405.373 400 412 400H738C744.627 400 750 405.373 750 412V725C750 738.807 738.807 750 725 750H412C405.373 750 400 744.627 400 738V412Z",
|
|
763
|
-
fill: "currentColor"
|
|
764
|
-
}
|
|
765
|
-
),
|
|
766
|
-
/* @__PURE__ */ e("circle", { cx: "400", cy: "400", r: "350", fill: "currentColor" }),
|
|
767
|
-
/* @__PURE__ */ e(
|
|
768
|
-
"path",
|
|
769
|
-
{
|
|
770
|
-
d: "M50 75C50 61.1929 61.1929 50 75 50H388C394.627 50 400 55.3726 400 62V388C400 394.627 394.627 400 388 400H62C55.3726 400 50 394.627 50 388V75Z",
|
|
771
|
-
fill: "currentColor"
|
|
772
|
-
}
|
|
773
|
-
),
|
|
774
|
-
/* @__PURE__ */ e(
|
|
775
|
-
"rect",
|
|
776
|
-
{
|
|
777
|
-
x: "399.919",
|
|
778
|
-
y: "209",
|
|
779
|
-
width: "270",
|
|
780
|
-
height: "270",
|
|
781
|
-
rx: "12",
|
|
782
|
-
transform: "rotate(45 399.919 209)",
|
|
783
|
-
fill: "white"
|
|
784
|
-
}
|
|
785
|
-
)
|
|
786
|
-
]
|
|
787
|
-
}
|
|
788
|
-
), mt = ({
|
|
789
|
-
agentName: n = "AI",
|
|
662
|
+
}, tt = "_wrapper_10rss_2", ot = "_avatar_10rss_22", nt = "_avatarPlaceholder_10rss_37", st = "_brainbaseLogo_10rss_47", rt = "_bubble_10rss_52", at = "_dot_10rss_63", W = {
|
|
663
|
+
wrapper: tt,
|
|
664
|
+
avatar: ot,
|
|
665
|
+
avatarPlaceholder: nt,
|
|
666
|
+
brainbaseLogo: st,
|
|
667
|
+
bubble: rt,
|
|
668
|
+
dot: at
|
|
669
|
+
}, ct = ({
|
|
670
|
+
agentName: o = "AI",
|
|
790
671
|
agentLogoUrl: t
|
|
791
|
-
}) => /* @__PURE__ */
|
|
792
|
-
/* @__PURE__ */ e("div", { className:
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
672
|
+
}) => /* @__PURE__ */ i("div", { className: W.wrapper, role: "status", "aria-label": `${o} is typing`, children: [
|
|
673
|
+
/* @__PURE__ */ e("div", { className: W.avatar, children: t ? /* @__PURE__ */ e("img", { src: t, alt: o }) : /* @__PURE__ */ e("div", { className: W.avatarPlaceholder, children: /* @__PURE__ */ e(
|
|
674
|
+
Z,
|
|
675
|
+
{
|
|
676
|
+
className: W.brainbaseLogo,
|
|
677
|
+
color: "white",
|
|
678
|
+
cutoutColor: "var(--bb-primary-color)"
|
|
679
|
+
}
|
|
680
|
+
) }) }),
|
|
681
|
+
/* @__PURE__ */ i("div", { className: W.bubble, children: [
|
|
682
|
+
/* @__PURE__ */ e("span", { className: W.dot }),
|
|
683
|
+
/* @__PURE__ */ e("span", { className: W.dot }),
|
|
684
|
+
/* @__PURE__ */ e("span", { className: W.dot })
|
|
797
685
|
] })
|
|
798
|
-
] }),
|
|
799
|
-
messageList:
|
|
800
|
-
emptyState:
|
|
801
|
-
emptyIcon:
|
|
802
|
-
emptyText:
|
|
803
|
-
},
|
|
804
|
-
messages:
|
|
686
|
+
] }), it = "_messageList_241kk_1", lt = "_emptyState_241kk_29", dt = "_emptyIcon_241kk_40", ut = "_emptyText_241kk_52", Y = {
|
|
687
|
+
messageList: it,
|
|
688
|
+
emptyState: lt,
|
|
689
|
+
emptyIcon: dt,
|
|
690
|
+
emptyText: ut
|
|
691
|
+
}, mt = ({
|
|
692
|
+
messages: o,
|
|
805
693
|
toolCalls: t,
|
|
806
694
|
isLoading: s,
|
|
807
695
|
agentName: r,
|
|
808
|
-
agentLogoUrl:
|
|
696
|
+
agentLogoUrl: d
|
|
809
697
|
}) => {
|
|
810
|
-
var
|
|
811
|
-
const
|
|
812
|
-
|
|
813
|
-
var
|
|
814
|
-
(
|
|
815
|
-
}, [
|
|
816
|
-
const
|
|
817
|
-
(
|
|
698
|
+
var l;
|
|
699
|
+
const u = R(null), c = R(null);
|
|
700
|
+
U(() => {
|
|
701
|
+
var n;
|
|
702
|
+
(n = c.current) == null || n.scrollIntoView({ behavior: "smooth" });
|
|
703
|
+
}, [o, t, s]);
|
|
704
|
+
const m = t.filter(
|
|
705
|
+
(n) => n.status === "pending" || n.status === "executing"
|
|
818
706
|
);
|
|
819
|
-
return /* @__PURE__ */
|
|
820
|
-
|
|
821
|
-
/* @__PURE__ */ e("div", { className:
|
|
707
|
+
return /* @__PURE__ */ i("div", { className: Y.messageList, ref: u, role: "log", "aria-live": "polite", children: [
|
|
708
|
+
o.length === 0 && !s && /* @__PURE__ */ i("div", { className: Y.emptyState, children: [
|
|
709
|
+
/* @__PURE__ */ e("div", { className: Y.emptyIcon, children: /* @__PURE__ */ e("svg", { viewBox: "0 0 24 24", fill: "none", children: /* @__PURE__ */ e(
|
|
822
710
|
"path",
|
|
823
711
|
{
|
|
824
712
|
d: "M8 12H8.01M12 12H12.01M16 12H16.01M21 12C21 16.4183 16.9706 20 12 20C10.4607 20 9.01172 19.6565 7.74467 19.0511L3 20L4.39499 16.28C3.51156 15.0423 3 13.5743 3 12C3 7.58172 7.02944 4 12 4C16.9706 4 21 7.58172 21 12Z",
|
|
@@ -828,62 +716,62 @@ const me = "_header_tzm7g_1", ge = "_headerBackground_tzm7g_8", he = "_headerCon
|
|
|
828
716
|
strokeLinejoin: "round"
|
|
829
717
|
}
|
|
830
718
|
) }) }),
|
|
831
|
-
/* @__PURE__ */ e("p", { className:
|
|
719
|
+
/* @__PURE__ */ e("p", { className: Y.emptyText, children: "Start a conversation" })
|
|
832
720
|
] }),
|
|
833
|
-
|
|
834
|
-
|
|
721
|
+
o.map((n) => /* @__PURE__ */ e(
|
|
722
|
+
Fe,
|
|
835
723
|
{
|
|
836
|
-
message:
|
|
724
|
+
message: n,
|
|
837
725
|
agentName: r,
|
|
838
|
-
agentLogoUrl:
|
|
726
|
+
agentLogoUrl: d
|
|
839
727
|
},
|
|
840
|
-
|
|
728
|
+
n.id
|
|
841
729
|
)),
|
|
842
|
-
|
|
843
|
-
s && ((
|
|
844
|
-
/* @__PURE__ */ e("div", { ref:
|
|
730
|
+
m.map((n) => /* @__PURE__ */ e(et, { toolCall: n }, n.id)),
|
|
731
|
+
s && ((l = o[o.length - 1]) == null ? void 0 : l.role) === "user" && /* @__PURE__ */ e(ct, { agentName: r, agentLogoUrl: d }),
|
|
732
|
+
/* @__PURE__ */ e("div", { ref: c })
|
|
845
733
|
] });
|
|
846
|
-
},
|
|
847
|
-
inputWrapper:
|
|
848
|
-
inputContainer:
|
|
849
|
-
textarea:
|
|
850
|
-
sendButton:
|
|
851
|
-
hint:
|
|
852
|
-
},
|
|
853
|
-
onSend:
|
|
734
|
+
}, gt = "_inputWrapper_5lgg7_1", pt = "_inputContainer_5lgg7_7", ht = "_textarea_5lgg7_23", _t = "_sendButton_5lgg7_50", ft = "_hint_5lgg7_89", O = {
|
|
735
|
+
inputWrapper: gt,
|
|
736
|
+
inputContainer: pt,
|
|
737
|
+
textarea: ht,
|
|
738
|
+
sendButton: _t,
|
|
739
|
+
hint: ft
|
|
740
|
+
}, bt = ({
|
|
741
|
+
onSend: o,
|
|
854
742
|
disabled: t = !1,
|
|
855
743
|
placeholder: s = "Send a message..."
|
|
856
744
|
}) => {
|
|
857
|
-
const [r,
|
|
858
|
-
const
|
|
859
|
-
|
|
745
|
+
const [r, d] = I(""), u = R(null), c = x(() => {
|
|
746
|
+
const n = u.current;
|
|
747
|
+
n && (n.style.height = "auto", n.style.height = `${Math.min(n.scrollHeight, 150)}px`);
|
|
860
748
|
}, []);
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
}, [r,
|
|
864
|
-
const
|
|
865
|
-
(
|
|
866
|
-
|
|
749
|
+
U(() => {
|
|
750
|
+
c();
|
|
751
|
+
}, [r, c]);
|
|
752
|
+
const m = x(
|
|
753
|
+
(n) => {
|
|
754
|
+
n == null || n.preventDefault();
|
|
867
755
|
const C = r.trim();
|
|
868
|
-
C && !t && (
|
|
756
|
+
C && !t && (o(C), d(""), u.current && (u.current.style.height = "auto"));
|
|
869
757
|
},
|
|
870
|
-
[r, t,
|
|
871
|
-
),
|
|
872
|
-
(
|
|
873
|
-
|
|
758
|
+
[r, t, o]
|
|
759
|
+
), l = x(
|
|
760
|
+
(n) => {
|
|
761
|
+
n.key === "Enter" && !n.shiftKey && (n.preventDefault(), m());
|
|
874
762
|
},
|
|
875
|
-
[
|
|
763
|
+
[m]
|
|
876
764
|
);
|
|
877
|
-
return /* @__PURE__ */
|
|
878
|
-
/* @__PURE__ */
|
|
765
|
+
return /* @__PURE__ */ i("form", { className: O.inputWrapper, onSubmit: m, children: [
|
|
766
|
+
/* @__PURE__ */ i("div", { className: O.inputContainer, children: [
|
|
879
767
|
/* @__PURE__ */ e(
|
|
880
768
|
"textarea",
|
|
881
769
|
{
|
|
882
|
-
ref:
|
|
883
|
-
className:
|
|
770
|
+
ref: u,
|
|
771
|
+
className: O.textarea,
|
|
884
772
|
value: r,
|
|
885
|
-
onChange: (
|
|
886
|
-
onKeyDown:
|
|
773
|
+
onChange: (n) => d(n.target.value),
|
|
774
|
+
onKeyDown: l,
|
|
887
775
|
placeholder: s,
|
|
888
776
|
disabled: t,
|
|
889
777
|
rows: 1,
|
|
@@ -894,7 +782,7 @@ const me = "_header_tzm7g_1", ge = "_headerBackground_tzm7g_8", he = "_headerCon
|
|
|
894
782
|
"button",
|
|
895
783
|
{
|
|
896
784
|
type: "submit",
|
|
897
|
-
className:
|
|
785
|
+
className: O.sendButton,
|
|
898
786
|
disabled: t || !r.trim(),
|
|
899
787
|
"aria-label": "Send message",
|
|
900
788
|
children: /* @__PURE__ */ e("svg", { viewBox: "0 0 24 24", fill: "none", children: /* @__PURE__ */ e(
|
|
@@ -910,7 +798,7 @@ const me = "_header_tzm7g_1", ge = "_headerBackground_tzm7g_8", he = "_headerCon
|
|
|
910
798
|
}
|
|
911
799
|
)
|
|
912
800
|
] }),
|
|
913
|
-
/* @__PURE__ */
|
|
801
|
+
/* @__PURE__ */ i("div", { className: O.hint, children: [
|
|
914
802
|
"Press ",
|
|
915
803
|
/* @__PURE__ */ e("kbd", { children: "Enter" }),
|
|
916
804
|
" to send, ",
|
|
@@ -918,15 +806,15 @@ const me = "_header_tzm7g_1", ge = "_headerBackground_tzm7g_8", he = "_headerCon
|
|
|
918
806
|
" for new line"
|
|
919
807
|
] })
|
|
920
808
|
] });
|
|
921
|
-
},
|
|
922
|
-
poweredBy:
|
|
923
|
-
logo:
|
|
924
|
-
poweredText:
|
|
925
|
-
text:
|
|
926
|
-
},
|
|
809
|
+
}, wt = "_poweredBy_9jh5q_1", yt = "_logo_9jh5q_20", Ct = "_poweredText_9jh5q_24", kt = "_text_9jh5q_36", X = {
|
|
810
|
+
poweredBy: wt,
|
|
811
|
+
logo: yt,
|
|
812
|
+
poweredText: Ct,
|
|
813
|
+
text: kt
|
|
814
|
+
}, vt = ({ className: o }) => /* @__PURE__ */ i(
|
|
927
815
|
"svg",
|
|
928
816
|
{
|
|
929
|
-
className:
|
|
817
|
+
className: o,
|
|
930
818
|
viewBox: "0 0 800 800",
|
|
931
819
|
fill: "none",
|
|
932
820
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -975,89 +863,125 @@ const me = "_header_tzm7g_1", ge = "_headerBackground_tzm7g_8", he = "_headerCon
|
|
|
975
863
|
)
|
|
976
864
|
]
|
|
977
865
|
}
|
|
978
|
-
),
|
|
866
|
+
), It = () => /* @__PURE__ */ i(
|
|
979
867
|
"a",
|
|
980
868
|
{
|
|
981
869
|
href: "https://brainbaselabs.com/",
|
|
982
870
|
target: "_blank",
|
|
983
871
|
rel: "noopener noreferrer",
|
|
984
|
-
className:
|
|
872
|
+
className: X.poweredBy,
|
|
985
873
|
"aria-label": "Powered by Brainbase Labs",
|
|
986
874
|
children: [
|
|
987
|
-
/* @__PURE__ */ e("span", { className:
|
|
988
|
-
/* @__PURE__ */ e(
|
|
989
|
-
/* @__PURE__ */ e("span", { className:
|
|
875
|
+
/* @__PURE__ */ e("span", { className: X.poweredText, children: "Powered by" }),
|
|
876
|
+
/* @__PURE__ */ e(vt, { className: X.logo }),
|
|
877
|
+
/* @__PURE__ */ e("span", { className: X.text, children: "Brainbase Labs" })
|
|
990
878
|
]
|
|
991
879
|
}
|
|
992
|
-
), Mt = "
|
|
993
|
-
container:
|
|
994
|
-
body:
|
|
995
|
-
|
|
996
|
-
|
|
880
|
+
), Nt = "_container_m2o9l_1", Lt = "_body_m2o9l_26", Bt = "_confirmationOverlay_m2o9l_35", $t = "_confirmationDialog_m2o9l_56", xt = "_confirmationText_m2o9l_78", Mt = "_confirmationButtons_m2o9l_86", St = "_cancelButton_m2o9l_91", Tt = "_confirmButton_m2o9l_92", D = {
|
|
881
|
+
container: Nt,
|
|
882
|
+
body: Lt,
|
|
883
|
+
confirmationOverlay: Bt,
|
|
884
|
+
confirmationDialog: $t,
|
|
885
|
+
confirmationText: xt,
|
|
886
|
+
confirmationButtons: Mt,
|
|
887
|
+
cancelButton: St,
|
|
888
|
+
confirmButton: Tt
|
|
889
|
+
}, Wt = ({
|
|
890
|
+
config: o,
|
|
997
891
|
messages: t,
|
|
998
892
|
toolCalls: s,
|
|
999
893
|
isLoading: r,
|
|
1000
|
-
onSendMessage:
|
|
1001
|
-
onClose:
|
|
1002
|
-
onNewChat:
|
|
894
|
+
onSendMessage: d,
|
|
895
|
+
onClose: u,
|
|
896
|
+
onNewChat: c
|
|
1003
897
|
}) => {
|
|
1004
|
-
const
|
|
1005
|
-
|
|
898
|
+
const [m, l] = I(!1), n = t.length > 0, C = () => {
|
|
899
|
+
l(!0);
|
|
900
|
+
}, M = () => {
|
|
901
|
+
l(!1), c == null || c();
|
|
902
|
+
}, j = () => {
|
|
903
|
+
l(!1);
|
|
904
|
+
};
|
|
905
|
+
return /* @__PURE__ */ i("div", { className: D.container, role: "dialog", "aria-label": "Chat window", children: [
|
|
1006
906
|
/* @__PURE__ */ e(
|
|
1007
|
-
|
|
907
|
+
Me,
|
|
1008
908
|
{
|
|
1009
|
-
agentName:
|
|
1010
|
-
agentLogoUrl:
|
|
909
|
+
agentName: o.agentName,
|
|
910
|
+
agentLogoUrl: o.agentLogoUrl,
|
|
1011
911
|
welcomeTitle: "Hello there.",
|
|
1012
912
|
welcomeSubtitle: "How can we help?",
|
|
1013
|
-
onClose:
|
|
1014
|
-
|
|
1015
|
-
showNewChatButton:
|
|
913
|
+
onClose: u,
|
|
914
|
+
onNewChatRequest: C,
|
|
915
|
+
showNewChatButton: n,
|
|
916
|
+
compact: n
|
|
1016
917
|
}
|
|
1017
918
|
),
|
|
1018
|
-
/* @__PURE__ */
|
|
919
|
+
/* @__PURE__ */ i("div", { className: D.body, children: [
|
|
1019
920
|
/* @__PURE__ */ e(
|
|
1020
|
-
|
|
921
|
+
mt,
|
|
1021
922
|
{
|
|
1022
923
|
messages: t,
|
|
1023
924
|
toolCalls: s,
|
|
1024
925
|
isLoading: r,
|
|
1025
|
-
agentName:
|
|
1026
|
-
agentLogoUrl:
|
|
926
|
+
agentName: o.agentName,
|
|
927
|
+
agentLogoUrl: o.agentLogoUrl
|
|
1027
928
|
}
|
|
1028
929
|
),
|
|
1029
930
|
/* @__PURE__ */ e(
|
|
1030
|
-
|
|
931
|
+
bt,
|
|
1031
932
|
{
|
|
1032
|
-
onSend:
|
|
933
|
+
onSend: d,
|
|
1033
934
|
disabled: r,
|
|
1034
935
|
placeholder: "Ask a question..."
|
|
1035
936
|
}
|
|
1036
937
|
)
|
|
1037
938
|
] }),
|
|
1038
|
-
/* @__PURE__ */ e(
|
|
939
|
+
/* @__PURE__ */ e(It, {}),
|
|
940
|
+
m && /* @__PURE__ */ e("div", { className: D.confirmationOverlay, children: /* @__PURE__ */ i("div", { className: D.confirmationDialog, children: [
|
|
941
|
+
/* @__PURE__ */ e("p", { className: D.confirmationText, children: "End current chat and start a new conversation?" }),
|
|
942
|
+
/* @__PURE__ */ i("div", { className: D.confirmationButtons, children: [
|
|
943
|
+
/* @__PURE__ */ e(
|
|
944
|
+
"button",
|
|
945
|
+
{
|
|
946
|
+
className: D.cancelButton,
|
|
947
|
+
onClick: j,
|
|
948
|
+
type: "button",
|
|
949
|
+
children: "Cancel"
|
|
950
|
+
}
|
|
951
|
+
),
|
|
952
|
+
/* @__PURE__ */ e(
|
|
953
|
+
"button",
|
|
954
|
+
{
|
|
955
|
+
className: D.confirmButton,
|
|
956
|
+
onClick: M,
|
|
957
|
+
type: "button",
|
|
958
|
+
children: "End Chat"
|
|
959
|
+
}
|
|
960
|
+
)
|
|
961
|
+
] })
|
|
962
|
+
] }) })
|
|
1039
963
|
] });
|
|
1040
|
-
},
|
|
1041
|
-
toggleButton:
|
|
1042
|
-
icon:
|
|
1043
|
-
agentLogo:
|
|
1044
|
-
unreadBadge:
|
|
1045
|
-
},
|
|
1046
|
-
onClick:
|
|
964
|
+
}, Dt = "_toggleButton_11dqz_1", Ht = "_icon_11dqz_31", Pt = "_agentLogo_11dqz_36", Et = "_unreadBadge_11dqz_43", Q = {
|
|
965
|
+
toggleButton: Dt,
|
|
966
|
+
icon: Ht,
|
|
967
|
+
agentLogo: Pt,
|
|
968
|
+
unreadBadge: Et
|
|
969
|
+
}, re = ({
|
|
970
|
+
onClick: o,
|
|
1047
971
|
agentLogoUrl: t,
|
|
1048
972
|
unreadCount: s = 0
|
|
1049
|
-
}) => /* @__PURE__ */
|
|
973
|
+
}) => /* @__PURE__ */ i(
|
|
1050
974
|
"button",
|
|
1051
975
|
{
|
|
1052
|
-
className:
|
|
1053
|
-
onClick:
|
|
976
|
+
className: Q.toggleButton,
|
|
977
|
+
onClick: o,
|
|
1054
978
|
"aria-label": "Open chat",
|
|
1055
979
|
type: "button",
|
|
1056
980
|
children: [
|
|
1057
|
-
t ? /* @__PURE__ */ e("img", { src: t, alt: "", className:
|
|
981
|
+
t ? /* @__PURE__ */ e("img", { src: t, alt: "", className: Q.agentLogo }) : /* @__PURE__ */ e(
|
|
1058
982
|
"svg",
|
|
1059
983
|
{
|
|
1060
|
-
className:
|
|
984
|
+
className: Q.icon,
|
|
1061
985
|
viewBox: "0 0 24 24",
|
|
1062
986
|
fill: "none",
|
|
1063
987
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -1073,140 +997,312 @@ const me = "_header_tzm7g_1", ge = "_headerBackground_tzm7g_8", he = "_headerCon
|
|
|
1073
997
|
)
|
|
1074
998
|
}
|
|
1075
999
|
),
|
|
1076
|
-
s > 0 && /* @__PURE__ */ e("span", { className:
|
|
1000
|
+
s > 0 && /* @__PURE__ */ e("span", { className: Q.unreadBadge, children: s > 9 ? "9+" : s })
|
|
1077
1001
|
]
|
|
1078
1002
|
}
|
|
1079
|
-
), zt = "
|
|
1080
|
-
|
|
1003
|
+
), 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", y = {
|
|
1004
|
+
container: jt,
|
|
1005
|
+
header: Vt,
|
|
1006
|
+
logoWrapper: At,
|
|
1007
|
+
logo: zt,
|
|
1008
|
+
closeButton: Ft,
|
|
1009
|
+
content: Ot,
|
|
1010
|
+
iconWrapper: Rt,
|
|
1011
|
+
errorIcon: Ut,
|
|
1012
|
+
title: Zt,
|
|
1013
|
+
description: qt,
|
|
1014
|
+
retryButton: Kt,
|
|
1015
|
+
footer: Gt,
|
|
1016
|
+
poweredBy: Jt,
|
|
1017
|
+
footerLogo: Yt
|
|
1018
|
+
}, Xt = ({
|
|
1019
|
+
errorType: o,
|
|
1020
|
+
message: t,
|
|
1021
|
+
onRetry: s,
|
|
1022
|
+
onClose: r
|
|
1023
|
+
}) => {
|
|
1024
|
+
const d = () => {
|
|
1025
|
+
switch (o) {
|
|
1026
|
+
case "not_found":
|
|
1027
|
+
return {
|
|
1028
|
+
title: "Chat Not Found",
|
|
1029
|
+
description: t || "This chat widget is not configured correctly. Please check the embed ID.",
|
|
1030
|
+
icon: /* @__PURE__ */ i("svg", { viewBox: "0 0 24 24", fill: "none", className: y.errorIcon, children: [
|
|
1031
|
+
/* @__PURE__ */ e(
|
|
1032
|
+
"circle",
|
|
1033
|
+
{
|
|
1034
|
+
cx: "12",
|
|
1035
|
+
cy: "12",
|
|
1036
|
+
r: "10",
|
|
1037
|
+
stroke: "currentColor",
|
|
1038
|
+
strokeWidth: "1.5"
|
|
1039
|
+
}
|
|
1040
|
+
),
|
|
1041
|
+
/* @__PURE__ */ e(
|
|
1042
|
+
"path",
|
|
1043
|
+
{
|
|
1044
|
+
d: "M12 7V13M12 16V16.5",
|
|
1045
|
+
stroke: "currentColor",
|
|
1046
|
+
strokeWidth: "1.5",
|
|
1047
|
+
strokeLinecap: "round"
|
|
1048
|
+
}
|
|
1049
|
+
)
|
|
1050
|
+
] })
|
|
1051
|
+
};
|
|
1052
|
+
case "network":
|
|
1053
|
+
return {
|
|
1054
|
+
title: "Connection Error",
|
|
1055
|
+
description: t || "Unable to connect to the chat service. Please check your internet connection.",
|
|
1056
|
+
icon: /* @__PURE__ */ i("svg", { viewBox: "0 0 24 24", fill: "none", className: y.errorIcon, children: [
|
|
1057
|
+
/* @__PURE__ */ e(
|
|
1058
|
+
"path",
|
|
1059
|
+
{
|
|
1060
|
+
d: "M12 21C16.9706 21 21 16.9706 21 12C21 7.02944 16.9706 3 12 3C7.02944 3 3 7.02944 3 12C3 16.9706 7.02944 21 12 21Z",
|
|
1061
|
+
stroke: "currentColor",
|
|
1062
|
+
strokeWidth: "1.5"
|
|
1063
|
+
}
|
|
1064
|
+
),
|
|
1065
|
+
/* @__PURE__ */ e(
|
|
1066
|
+
"path",
|
|
1067
|
+
{
|
|
1068
|
+
d: "M8 15L16 9M8 9L16 15",
|
|
1069
|
+
stroke: "currentColor",
|
|
1070
|
+
strokeWidth: "1.5",
|
|
1071
|
+
strokeLinecap: "round"
|
|
1072
|
+
}
|
|
1073
|
+
)
|
|
1074
|
+
] })
|
|
1075
|
+
};
|
|
1076
|
+
default:
|
|
1077
|
+
return {
|
|
1078
|
+
title: "Something Went Wrong",
|
|
1079
|
+
description: t || "An unexpected error occurred. Please try again later.",
|
|
1080
|
+
icon: /* @__PURE__ */ e("svg", { viewBox: "0 0 24 24", fill: "none", className: y.errorIcon, children: /* @__PURE__ */ e(
|
|
1081
|
+
"path",
|
|
1082
|
+
{
|
|
1083
|
+
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",
|
|
1084
|
+
stroke: "currentColor",
|
|
1085
|
+
strokeWidth: "1.5",
|
|
1086
|
+
strokeLinecap: "round"
|
|
1087
|
+
}
|
|
1088
|
+
) })
|
|
1089
|
+
};
|
|
1090
|
+
}
|
|
1091
|
+
}, { title: u, description: c, icon: m } = d();
|
|
1092
|
+
return /* @__PURE__ */ i("div", { className: y.container, children: [
|
|
1093
|
+
/* @__PURE__ */ i("div", { className: y.header, children: [
|
|
1094
|
+
/* @__PURE__ */ e("div", { className: y.logoWrapper, children: /* @__PURE__ */ e(
|
|
1095
|
+
Z,
|
|
1096
|
+
{
|
|
1097
|
+
className: y.logo,
|
|
1098
|
+
color: "white",
|
|
1099
|
+
cutoutColor: "var(--bb-primary-color)"
|
|
1100
|
+
}
|
|
1101
|
+
) }),
|
|
1102
|
+
r && /* @__PURE__ */ e(
|
|
1103
|
+
"button",
|
|
1104
|
+
{
|
|
1105
|
+
className: y.closeButton,
|
|
1106
|
+
onClick: r,
|
|
1107
|
+
"aria-label": "Close",
|
|
1108
|
+
type: "button",
|
|
1109
|
+
children: /* @__PURE__ */ e("svg", { viewBox: "0 0 24 24", fill: "none", children: /* @__PURE__ */ e(
|
|
1110
|
+
"path",
|
|
1111
|
+
{
|
|
1112
|
+
d: "M6 18L18 6M6 6L18 18",
|
|
1113
|
+
stroke: "currentColor",
|
|
1114
|
+
strokeWidth: "2",
|
|
1115
|
+
strokeLinecap: "round"
|
|
1116
|
+
}
|
|
1117
|
+
) })
|
|
1118
|
+
}
|
|
1119
|
+
)
|
|
1120
|
+
] }),
|
|
1121
|
+
/* @__PURE__ */ i("div", { className: y.content, children: [
|
|
1122
|
+
/* @__PURE__ */ e("div", { className: y.iconWrapper, children: m }),
|
|
1123
|
+
/* @__PURE__ */ e("h2", { className: y.title, children: u }),
|
|
1124
|
+
/* @__PURE__ */ e("p", { className: y.description, children: c }),
|
|
1125
|
+
s && /* @__PURE__ */ e("button", { className: y.retryButton, onClick: s, type: "button", children: "Try Again" })
|
|
1126
|
+
] }),
|
|
1127
|
+
/* @__PURE__ */ e("div", { className: y.footer, children: /* @__PURE__ */ i(
|
|
1128
|
+
"a",
|
|
1129
|
+
{
|
|
1130
|
+
href: "https://brainbaselabs.com",
|
|
1131
|
+
target: "_blank",
|
|
1132
|
+
rel: "noopener noreferrer",
|
|
1133
|
+
className: y.poweredBy,
|
|
1134
|
+
children: [
|
|
1135
|
+
"Powered by",
|
|
1136
|
+
" ",
|
|
1137
|
+
/* @__PURE__ */ e(
|
|
1138
|
+
Z,
|
|
1139
|
+
{
|
|
1140
|
+
className: y.footerLogo,
|
|
1141
|
+
color: "var(--bb-text-tertiary)",
|
|
1142
|
+
cutoutColor: "var(--bb-surface-bg)"
|
|
1143
|
+
}
|
|
1144
|
+
),
|
|
1145
|
+
/* @__PURE__ */ e("span", { children: "Brainbase Labs" })
|
|
1146
|
+
]
|
|
1147
|
+
}
|
|
1148
|
+
) })
|
|
1149
|
+
] });
|
|
1150
|
+
}, Qt = "_widget_1ehud_1", eo = "_inline_1ehud_25", E = {
|
|
1151
|
+
widget: Qt,
|
|
1081
1152
|
"bottom-right": "_bottom-right_1ehud_10",
|
|
1082
1153
|
"bottom-left": "_bottom-left_1ehud_17",
|
|
1083
|
-
inline:
|
|
1084
|
-
},
|
|
1085
|
-
embedId:
|
|
1086
|
-
apiBaseUrl: t =
|
|
1154
|
+
inline: eo
|
|
1155
|
+
}, to = "https://whatsapp-based-server.onrender.com", so = ({
|
|
1156
|
+
embedId: o,
|
|
1157
|
+
apiBaseUrl: t = to,
|
|
1087
1158
|
mockMode: s = !1,
|
|
1088
1159
|
mockResponses: r,
|
|
1089
|
-
position:
|
|
1090
|
-
defaultOpen:
|
|
1091
|
-
primaryColor:
|
|
1092
|
-
agentName:
|
|
1093
|
-
welcomeMessage:
|
|
1094
|
-
className:
|
|
1160
|
+
position: d = "bottom-right",
|
|
1161
|
+
defaultOpen: u = !1,
|
|
1162
|
+
primaryColor: c,
|
|
1163
|
+
agentName: m,
|
|
1164
|
+
welcomeMessage: l,
|
|
1165
|
+
className: n,
|
|
1095
1166
|
onSessionStart: C,
|
|
1096
|
-
onSessionEnd:
|
|
1097
|
-
onMessage:
|
|
1098
|
-
onError:
|
|
1167
|
+
onSessionEnd: M,
|
|
1168
|
+
onMessage: j,
|
|
1169
|
+
onError: S
|
|
1099
1170
|
}) => {
|
|
1100
|
-
const [q,
|
|
1101
|
-
{ primaryColor:
|
|
1171
|
+
const [q, P] = I(u), [g, H] = I(null), [T, V] = I(!0), [K, B] = I(null), [G, J] = I(), A = ee(() => s ? pe(
|
|
1172
|
+
{ primaryColor: c, agentName: m, welcomeMessage: l },
|
|
1102
1173
|
r
|
|
1103
|
-
) :
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
})), N == null || N(a);
|
|
1127
|
-
} finally {
|
|
1128
|
-
b && Z(!1);
|
|
1129
|
-
}
|
|
1174
|
+
) : ue(t), [s, c, m, l, r, t]), z = x(async () => {
|
|
1175
|
+
V(!0), B(null), J(void 0);
|
|
1176
|
+
try {
|
|
1177
|
+
const v = await A.getDeploymentConfig(o);
|
|
1178
|
+
H({
|
|
1179
|
+
...v,
|
|
1180
|
+
// Allow prop overrides
|
|
1181
|
+
primaryColor: c ?? v.primaryColor,
|
|
1182
|
+
agentName: m ?? v.agentName,
|
|
1183
|
+
welcomeMessage: l ?? v.welcomeMessage
|
|
1184
|
+
});
|
|
1185
|
+
} catch (v) {
|
|
1186
|
+
const $ = v instanceof Error ? v : new Error("Failed to load config");
|
|
1187
|
+
$.message.includes("404") ? (B("not_found"), J("The chat widget with this embed ID was not found.")) : $.message.includes("Failed to fetch") || $.message.includes("network") ? B("network") : B("unknown"), s && (H({
|
|
1188
|
+
embedId: o,
|
|
1189
|
+
deploymentId: "mock-deployment",
|
|
1190
|
+
workerId: "mock-worker",
|
|
1191
|
+
flowId: "mock-flow",
|
|
1192
|
+
primaryColor: c ?? "#1a1a2e",
|
|
1193
|
+
agentName: m ?? "AI Assistant"
|
|
1194
|
+
}), B(null)), S == null || S($);
|
|
1195
|
+
} finally {
|
|
1196
|
+
V(!1);
|
|
1130
1197
|
}
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
}, [
|
|
1135
|
-
const
|
|
1136
|
-
embedId:
|
|
1198
|
+
}, [o, s, A, c, m, l, S]);
|
|
1199
|
+
U(() => {
|
|
1200
|
+
z();
|
|
1201
|
+
}, [z]);
|
|
1202
|
+
const _ = ee(() => g || {
|
|
1203
|
+
embedId: o,
|
|
1137
1204
|
deploymentId: "",
|
|
1138
1205
|
workerId: "",
|
|
1139
1206
|
flowId: "",
|
|
1140
|
-
primaryColor:
|
|
1141
|
-
agentName:
|
|
1142
|
-
welcomeMessage:
|
|
1143
|
-
}, [
|
|
1144
|
-
config:
|
|
1145
|
-
apiClient:
|
|
1207
|
+
primaryColor: c,
|
|
1208
|
+
agentName: m,
|
|
1209
|
+
welcomeMessage: l
|
|
1210
|
+
}, [g, o, c, m, l]), b = le({
|
|
1211
|
+
config: _,
|
|
1212
|
+
apiClient: A,
|
|
1146
1213
|
mockMode: s,
|
|
1147
1214
|
onSessionStart: C,
|
|
1148
|
-
onSessionEnd:
|
|
1149
|
-
onMessage:
|
|
1150
|
-
onError:
|
|
1151
|
-
}),
|
|
1215
|
+
onSessionEnd: M,
|
|
1216
|
+
onMessage: j,
|
|
1217
|
+
onError: S
|
|
1218
|
+
}), k = ee(
|
|
1152
1219
|
() => ({
|
|
1153
|
-
"--bb-primary-color": (
|
|
1220
|
+
"--bb-primary-color": (g == null ? void 0 : g.primaryColor) ?? c ?? "#1a1a2e"
|
|
1154
1221
|
}),
|
|
1155
|
-
[
|
|
1156
|
-
),
|
|
1157
|
-
|
|
1158
|
-
}
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1222
|
+
[g == null ? void 0 : g.primaryColor, c]
|
|
1223
|
+
), p = () => {
|
|
1224
|
+
b.endSession(), b.startNewSession();
|
|
1225
|
+
}, h = () => {
|
|
1226
|
+
P(!1);
|
|
1227
|
+
}, a = () => {
|
|
1228
|
+
z();
|
|
1229
|
+
}, f = d === "inline";
|
|
1230
|
+
return T ? null : K && !s ? !f && !q ? /* @__PURE__ */ e(
|
|
1231
|
+
"div",
|
|
1232
|
+
{
|
|
1233
|
+
className: `${E.widget} ${E[d]} ${n ?? ""}`,
|
|
1234
|
+
style: k,
|
|
1235
|
+
children: /* @__PURE__ */ e(
|
|
1236
|
+
re,
|
|
1237
|
+
{
|
|
1238
|
+
onClick: () => P(!0),
|
|
1239
|
+
agentName: m
|
|
1240
|
+
}
|
|
1241
|
+
)
|
|
1242
|
+
}
|
|
1243
|
+
) : /* @__PURE__ */ e(
|
|
1244
|
+
"div",
|
|
1245
|
+
{
|
|
1246
|
+
className: `${E.widget} ${E[d]} ${n ?? ""}`,
|
|
1247
|
+
style: k,
|
|
1248
|
+
children: /* @__PURE__ */ e(
|
|
1249
|
+
Xt,
|
|
1250
|
+
{
|
|
1251
|
+
errorType: K,
|
|
1252
|
+
message: G,
|
|
1253
|
+
onRetry: a,
|
|
1254
|
+
onClose: f ? void 0 : h
|
|
1255
|
+
}
|
|
1256
|
+
)
|
|
1257
|
+
}
|
|
1258
|
+
) : /* @__PURE__ */ e(
|
|
1163
1259
|
"div",
|
|
1164
1260
|
{
|
|
1165
|
-
className: `${
|
|
1166
|
-
style:
|
|
1167
|
-
children: q ||
|
|
1168
|
-
|
|
1261
|
+
className: `${E.widget} ${E[d]} ${n ?? ""}`,
|
|
1262
|
+
style: k,
|
|
1263
|
+
children: q || f ? /* @__PURE__ */ e(
|
|
1264
|
+
Wt,
|
|
1169
1265
|
{
|
|
1170
|
-
config:
|
|
1171
|
-
messages:
|
|
1172
|
-
toolCalls:
|
|
1173
|
-
isLoading:
|
|
1174
|
-
onSendMessage:
|
|
1175
|
-
onClose:
|
|
1176
|
-
onNewChat:
|
|
1266
|
+
config: _,
|
|
1267
|
+
messages: b.messages,
|
|
1268
|
+
toolCalls: b.toolCalls,
|
|
1269
|
+
isLoading: b.isLoading,
|
|
1270
|
+
onSendMessage: b.sendMessage,
|
|
1271
|
+
onClose: f ? void 0 : h,
|
|
1272
|
+
onNewChat: p
|
|
1177
1273
|
}
|
|
1178
1274
|
) : /* @__PURE__ */ e(
|
|
1179
|
-
|
|
1275
|
+
re,
|
|
1180
1276
|
{
|
|
1181
|
-
onClick: () =>
|
|
1182
|
-
agentName:
|
|
1183
|
-
agentLogoUrl:
|
|
1277
|
+
onClick: () => P(!0),
|
|
1278
|
+
agentName: g == null ? void 0 : g.agentName,
|
|
1279
|
+
agentLogoUrl: g == null ? void 0 : g.agentLogoUrl
|
|
1184
1280
|
}
|
|
1185
1281
|
)
|
|
1186
1282
|
}
|
|
1187
1283
|
);
|
|
1188
1284
|
};
|
|
1189
|
-
function
|
|
1285
|
+
function ro() {
|
|
1190
1286
|
if (typeof crypto < "u" && crypto.randomUUID)
|
|
1191
1287
|
return `bb-${crypto.randomUUID()}`;
|
|
1192
|
-
const
|
|
1193
|
-
return `bb-${
|
|
1288
|
+
const o = Date.now().toString(36), t = Math.random().toString(36).substring(2, 15), s = Math.random().toString(36).substring(2, 15);
|
|
1289
|
+
return `bb-${o}-${t}${s}`;
|
|
1194
1290
|
}
|
|
1195
1291
|
export {
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1292
|
+
Wt as ChatContainer,
|
|
1293
|
+
Me as ChatHeader,
|
|
1294
|
+
re as ChatToggleButton,
|
|
1295
|
+
so as ChatWidget,
|
|
1296
|
+
Fe as Message,
|
|
1297
|
+
bt as MessageInput,
|
|
1298
|
+
mt as MessageList,
|
|
1299
|
+
et as ToolCallDisplay,
|
|
1300
|
+
ct as TypingIndicator,
|
|
1301
|
+
se as clearSession,
|
|
1302
|
+
ue as createAPIClient,
|
|
1303
|
+
pe as createMockAPIClient,
|
|
1304
|
+
ro as generateSessionId,
|
|
1305
|
+
ie as getStoredSession,
|
|
1306
|
+
ne as storeSession,
|
|
1307
|
+
le as useChat
|
|
1212
1308
|
};
|