@levo-so/studio 0.3.9 → 0.3.11
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/{KBChatWidget-Cgsubvuk.js → KBChatWidget-aK7vt64V.js} +407 -402
- package/index.d.ts +1 -1
- package/index.js +1 -1
- package/kbChat-DfcTNf0n.js +173 -0
- package/package.json +4 -4
- package/pillChrome-QDjBETmP.js +50 -0
- package/studio.css +1 -1
- package/kbChat-QDHdRejh.js +0 -173
- package/pillChrome-CYoMtUAv.js +0 -30
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import {
|
|
3
|
-
import { Children as
|
|
4
|
-
import { Fragment as
|
|
5
|
-
import { ArrowUp as
|
|
6
|
-
import { ActionBarPrimitive as
|
|
2
|
+
import { S as e, _ as t, a as n, b as r, c as i, f as a, g as o, h as s, i as c, l, m as u, n as d, o as f, r as p, s as m, t as h, u as g, v as _, x as v, y } from "./pillChrome-QDjBETmP.js";
|
|
3
|
+
import { Children as b, createContext as x, isValidElement as S, useCallback as C, useContext as w, useEffect as T, useLayoutEffect as ee, useRef as E, useState as D } from "react";
|
|
4
|
+
import { Fragment as O, jsx as k, jsxs as A } from "react/jsx-runtime";
|
|
5
|
+
import { ArrowUp as j, Check as M, ChevronDown as N, Copy as P, MessageSquarePlus as F, Mic as I, RefreshCw as L, Sparkles as te, Square as R, X as z } from "lucide-react";
|
|
6
|
+
import { ActionBarPrimitive as B, AssistantRuntimeProvider as ne, ComposerPrimitive as V, MessagePrimitive as H, ThreadPrimitive as U, WebSpeechDictationAdapter as re, useAui as W, useAuiState as G } from "@assistant-ui/react";
|
|
7
7
|
import { AssistantChatTransport as ie, useChatRuntime as ae } from "@assistant-ui/react-ai-sdk";
|
|
8
8
|
import { MarkdownTextPrimitive as oe } from "@assistant-ui/react-markdown";
|
|
9
9
|
import se from "remark-gfm";
|
|
10
10
|
//#region ../../libraries/ai-chat/src/FollowUpChips.tsx
|
|
11
|
-
var
|
|
11
|
+
var K = ({ chips: e, onSelect: t, size: n = "comfortable", className: r, chipClassName: i }) => {
|
|
12
12
|
if (e.length === 0) return null;
|
|
13
13
|
let a = [
|
|
14
14
|
"rounded-full border border-zinc-200 bg-white text-zinc-700",
|
|
15
15
|
"transition-all duration-150 hover:border-zinc-300 hover:bg-zinc-50 hover:text-zinc-900 active:scale-95",
|
|
16
16
|
n === "compact" ? "px-2.5 py-1 text-[11px] leading-none" : "px-3.5 py-1.5 text-xs"
|
|
17
17
|
].join(" ");
|
|
18
|
-
return /* @__PURE__ */
|
|
18
|
+
return /* @__PURE__ */ k("div", {
|
|
19
19
|
className: ["flex flex-wrap gap-1.5", r].filter(Boolean).join(" "),
|
|
20
|
-
children: e.map((e, n) => /* @__PURE__ */
|
|
20
|
+
children: e.map((e, n) => /* @__PURE__ */ k("button", {
|
|
21
21
|
type: "button",
|
|
22
22
|
onClick: () => t(e),
|
|
23
23
|
className: ["ai-chat-chip", i ?? a].join(" "),
|
|
@@ -37,10 +37,10 @@ var H = ({ chips: e, onSelect: t, size: n = "comfortable", className: r, chipCla
|
|
|
37
37
|
}
|
|
38
38
|
})
|
|
39
39
|
}), le = (e) => {
|
|
40
|
-
let t =
|
|
40
|
+
let t = E(null), n = E(null);
|
|
41
41
|
return n.current !== (e ?? null) && (n.current = e ?? null, t.current = null), {
|
|
42
42
|
conversationIdRef: t,
|
|
43
|
-
handleFinish:
|
|
43
|
+
handleFinish: C(({ message: e }) => {
|
|
44
44
|
let n = e.metadata;
|
|
45
45
|
if (!n || typeof n != "object") return;
|
|
46
46
|
let r = n.conversation_id;
|
|
@@ -48,33 +48,33 @@ var H = ({ chips: e, onSelect: t, size: n = "comfortable", className: r, chipCla
|
|
|
48
48
|
let i = r.trim();
|
|
49
49
|
i.length !== 0 && t.current !== i && (t.current = i);
|
|
50
50
|
}, []),
|
|
51
|
-
reset:
|
|
51
|
+
reset: C(() => {
|
|
52
52
|
t.current = null;
|
|
53
53
|
}, [])
|
|
54
54
|
};
|
|
55
55
|
}, ue = (e = []) => {
|
|
56
|
-
let [t, n] =
|
|
56
|
+
let [t, n] = D(e);
|
|
57
57
|
return {
|
|
58
58
|
followUps: t,
|
|
59
59
|
setFollowUps: n,
|
|
60
|
-
clearOnSend:
|
|
61
|
-
handleData:
|
|
60
|
+
clearOnSend: C(() => n([]), []),
|
|
61
|
+
handleData: C((e) => {
|
|
62
62
|
if (e.type !== "data-follow_ups") return !1;
|
|
63
63
|
let t = e.data?.suggestions;
|
|
64
64
|
return Array.isArray(t) ? (n(t.filter((e) => typeof e == "string")), !0) : !1;
|
|
65
65
|
}, [])
|
|
66
66
|
};
|
|
67
|
-
}, de = (e) => e instanceof Error && e.message.includes("intelligence.site_agent.NO_ACTIVE_AGENT"),
|
|
67
|
+
}, de = (e) => e instanceof Error && e.message.includes("intelligence.site_agent.NO_ACTIVE_AGENT"), q = x({ agentUnavailable: !1 }), fe = () => w(q), pe = (...e) => e.filter(Boolean).join(" "), me = "inline-flex items-center justify-center gap-1.5 transition-all duration-200", he = "rounded-full border border-zinc-200 bg-white/95 px-3 py-1.5 font-medium text-xs text-zinc-500 shadow-lg backdrop-blur-sm hover:text-zinc-900", ge = ({ onClick: e, isRunning: t = !1, iconOnly: n = !1, icon: r = /* @__PURE__ */ k(N, { className: "h-3 w-3" }), className: i = he }) => /* @__PURE__ */ A("button", {
|
|
68
68
|
type: "button",
|
|
69
69
|
"aria-label": "Scroll to bottom",
|
|
70
70
|
onClick: e,
|
|
71
|
-
className: pe(me,
|
|
72
|
-
children: [
|
|
71
|
+
className: pe(me, i),
|
|
72
|
+
children: [r, !n && (t ? "New messages" : "Scroll to bottom")]
|
|
73
73
|
}), _e = ({ endpoint: e, headers: t, fallback: n, enabled: r = !0 }) => {
|
|
74
|
-
let [i, a] =
|
|
74
|
+
let [i, a] = D(null), o = t ? JSON.stringify(t) : "", s = E(t);
|
|
75
75
|
s.current = t;
|
|
76
|
-
let c =
|
|
77
|
-
return c.current = n,
|
|
76
|
+
let c = E(n);
|
|
77
|
+
return c.current = n, T(() => {
|
|
78
78
|
if (!r || !e) {
|
|
79
79
|
a([...c.current]);
|
|
80
80
|
return;
|
|
@@ -104,10 +104,10 @@ var H = ({ chips: e, onSelect: t, size: n = "comfortable", className: r, chipCla
|
|
|
104
104
|
o
|
|
105
105
|
]), i;
|
|
106
106
|
}, ve = 36, ye = 80, be = ({ viewportRef: e, isRunning: t, onRunStart: n, anchorOnRunStart: r = !0, atBottomThreshold: i }) => {
|
|
107
|
-
let a =
|
|
107
|
+
let a = E(!1), [o, s] = D(!0), c = E(n);
|
|
108
108
|
c.current = n;
|
|
109
|
-
let l =
|
|
110
|
-
return l.current = i,
|
|
109
|
+
let l = E(i);
|
|
110
|
+
return l.current = i, T(() => {
|
|
111
111
|
let n = a.current;
|
|
112
112
|
if (a.current = t, !t || n || (c.current?.(), !r)) return;
|
|
113
113
|
let i = null, o = null;
|
|
@@ -128,7 +128,7 @@ var H = ({ chips: e, onSelect: t, size: n = "comfortable", className: r, chipCla
|
|
|
128
128
|
t,
|
|
129
129
|
e,
|
|
130
130
|
r
|
|
131
|
-
]),
|
|
131
|
+
]), T(() => {
|
|
132
132
|
let t = e.current;
|
|
133
133
|
if (!t) return;
|
|
134
134
|
let n = () => {
|
|
@@ -151,7 +151,7 @@ var H = ({ chips: e, onSelect: t, size: n = "comfortable", className: r, chipCla
|
|
|
151
151
|
});
|
|
152
152
|
}
|
|
153
153
|
};
|
|
154
|
-
},
|
|
154
|
+
}, J = (...e) => e.filter(Boolean).join(" "), xe = ({ onStop: e }) => /* @__PURE__ */ k("button", {
|
|
155
155
|
type: "button",
|
|
156
156
|
onClick: e,
|
|
157
157
|
"aria-label": "Stop generating",
|
|
@@ -160,36 +160,36 @@ var H = ({ chips: e, onSelect: t, size: n = "comfortable", className: r, chipCla
|
|
|
160
160
|
backgroundColor: "var(--color-brand, #0a0a0a)",
|
|
161
161
|
color: "var(--color-brand-foreground, #fff)"
|
|
162
162
|
},
|
|
163
|
-
children: /* @__PURE__ */
|
|
164
|
-
}),
|
|
163
|
+
children: /* @__PURE__ */ k(R, { className: "h-3.5 w-3.5 fill-current" })
|
|
164
|
+
}), Se = () => /* @__PURE__ */ A(O, { children: [/* @__PURE__ */ k(V.If, {
|
|
165
165
|
dictation: !1,
|
|
166
|
-
children: /* @__PURE__ */
|
|
166
|
+
children: /* @__PURE__ */ k(V.Dictate, {
|
|
167
167
|
className: "flex h-8 w-8 items-center justify-center rounded-md text-zinc-500 transition-colors hover:bg-zinc-100 hover:text-zinc-900",
|
|
168
|
-
children: /* @__PURE__ */
|
|
168
|
+
children: /* @__PURE__ */ k(I, { className: "h-4 w-4" })
|
|
169
169
|
})
|
|
170
|
-
}), /* @__PURE__ */
|
|
170
|
+
}), /* @__PURE__ */ k(V.If, {
|
|
171
171
|
dictation: !0,
|
|
172
|
-
children: /* @__PURE__ */
|
|
172
|
+
children: /* @__PURE__ */ k(V.StopDictation, {
|
|
173
173
|
className: "flex h-8 w-8 animate-pulse items-center justify-center rounded-md bg-red-500/15 text-red-500 transition-colors hover:bg-red-500/25",
|
|
174
|
-
children: /* @__PURE__ */
|
|
174
|
+
children: /* @__PURE__ */ k(R, { className: "h-3 w-3 fill-current" })
|
|
175
175
|
})
|
|
176
|
-
})] }),
|
|
176
|
+
})] }), Ce = () => /* @__PURE__ */ k(V.Send, {
|
|
177
177
|
"aria-label": "Send message",
|
|
178
178
|
className: "flex h-9 w-9 items-center justify-center rounded-md shadow-md transition-all duration-300 hover:scale-110 active:scale-95 disabled:cursor-not-allowed disabled:opacity-40 disabled:shadow-none disabled:hover:scale-100",
|
|
179
179
|
style: {
|
|
180
180
|
backgroundColor: "var(--color-brand, #0a0a0a)",
|
|
181
181
|
color: "var(--color-brand-foreground, #fff)"
|
|
182
182
|
},
|
|
183
|
-
children: /* @__PURE__ */
|
|
184
|
-
}),
|
|
183
|
+
children: /* @__PURE__ */ k(j, { className: "h-5 w-5 stroke-[2.5px]" })
|
|
184
|
+
}), we = ({ variant: e, isRunning: t, onStop: n }) => {
|
|
185
185
|
let r = (e) => {
|
|
186
186
|
e.nativeEvent.isComposing || t && e.key === "Enter" && !e.shiftKey && e.preventDefault();
|
|
187
187
|
};
|
|
188
|
-
return e === "expanded" ? /* @__PURE__ */
|
|
188
|
+
return e === "expanded" ? /* @__PURE__ */ A("div", {
|
|
189
189
|
className: "rounded-lg border border-zinc-200 bg-white shadow-sm transition-colors focus-within:border-[var(--color-brand,#a1a1aa)]",
|
|
190
|
-
children: [/* @__PURE__ */
|
|
190
|
+
children: [/* @__PURE__ */ k(V.Input, {
|
|
191
191
|
"data-ai-chat-composer": "",
|
|
192
|
-
className:
|
|
192
|
+
className: J("ai-chat-textarea w-full resize-none overflow-y-auto bg-transparent px-6 pt-4 text-base text-zinc-900 leading-relaxed placeholder:text-zinc-500 focus:outline-none", "max-h-[160px]"),
|
|
193
193
|
placeholder: "Ask anything about this site…",
|
|
194
194
|
rows: 1,
|
|
195
195
|
submitMode: "enter",
|
|
@@ -197,18 +197,18 @@ var H = ({ chips: e, onSelect: t, size: n = "comfortable", className: r, chipCla
|
|
|
197
197
|
autoCorrect: "off",
|
|
198
198
|
autoCapitalize: "none",
|
|
199
199
|
inputMode: "text",
|
|
200
|
-
onInput: (e) =>
|
|
200
|
+
onInput: (e) => _(e.currentTarget),
|
|
201
201
|
onKeyDown: r
|
|
202
|
-
}), /* @__PURE__ */
|
|
202
|
+
}), /* @__PURE__ */ A("div", {
|
|
203
203
|
className: "flex items-center justify-between px-3 pt-1 pb-2",
|
|
204
|
-
children: [/* @__PURE__ */
|
|
204
|
+
children: [/* @__PURE__ */ k(Se, {}), t ? /* @__PURE__ */ k(xe, { onStop: n }) : /* @__PURE__ */ k(Ce, {})]
|
|
205
205
|
})]
|
|
206
|
-
}) : /* @__PURE__ */
|
|
206
|
+
}) : /* @__PURE__ */ A("div", {
|
|
207
207
|
className: "flex items-end gap-2 rounded-lg border border-zinc-200 bg-white p-2 shadow-sm transition-colors focus-within:border-[var(--color-brand,#a1a1aa)]",
|
|
208
208
|
children: [
|
|
209
|
-
/* @__PURE__ */
|
|
209
|
+
/* @__PURE__ */ k(V.Input, {
|
|
210
210
|
"data-ai-chat-composer": "",
|
|
211
|
-
className:
|
|
211
|
+
className: J("ai-chat-textarea min-w-0 flex-1 resize-none overflow-y-auto bg-transparent px-2 py-1.5 text-base text-zinc-900 leading-relaxed placeholder:text-zinc-500 focus:outline-none", "max-h-[120px]"),
|
|
212
212
|
placeholder: "Ask a follow-up…",
|
|
213
213
|
rows: 1,
|
|
214
214
|
submitMode: "enter",
|
|
@@ -216,36 +216,40 @@ var H = ({ chips: e, onSelect: t, size: n = "comfortable", className: r, chipCla
|
|
|
216
216
|
autoCorrect: "off",
|
|
217
217
|
autoCapitalize: "none",
|
|
218
218
|
inputMode: "text",
|
|
219
|
-
onInput: (e) =>
|
|
219
|
+
onInput: (e) => _(e.currentTarget),
|
|
220
220
|
onKeyDown: r
|
|
221
221
|
}),
|
|
222
|
-
/* @__PURE__ */
|
|
223
|
-
t ? /* @__PURE__ */
|
|
222
|
+
/* @__PURE__ */ k(Se, {}),
|
|
223
|
+
t ? /* @__PURE__ */ k(xe, { onStop: n }) : /* @__PURE__ */ k(Ce, {})
|
|
224
224
|
]
|
|
225
225
|
});
|
|
226
|
-
},
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
className:
|
|
230
|
-
children: /* @__PURE__ */
|
|
226
|
+
}, Te = "rounded-2xl border border-zinc-200 bg-zinc-100 px-3.5 py-2.5", Ee = "ai-chat-textarea w-full resize-none bg-transparent text-base text-zinc-900 leading-relaxed placeholder:text-zinc-500 focus:outline-none", De = "rounded-md px-2 py-1 text-xs text-zinc-500 transition-colors hover:bg-zinc-100", Oe = "rounded-md px-2 py-1 text-xs transition-opacity hover:opacity-80", ke = ({ autoGrowMax: e, boxClassName: n = Te, inputClassName: r = Ee, cancelClassName: i = De, sendClassName: a = Oe, sendStyle: o }) => {
|
|
227
|
+
let s = G((e) => e.thread.isRunning);
|
|
228
|
+
return /* @__PURE__ */ k(H.Root, {
|
|
229
|
+
className: "mb-4 pr-2 pl-0",
|
|
230
|
+
children: /* @__PURE__ */ A(V.Root, { children: [/* @__PURE__ */ k("div", {
|
|
231
231
|
className: n,
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
className:
|
|
239
|
-
children:
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
232
|
+
children: /* @__PURE__ */ k(V.Input, {
|
|
233
|
+
className: r,
|
|
234
|
+
rows: 1,
|
|
235
|
+
onInput: (t) => _(t.currentTarget, e)
|
|
236
|
+
})
|
|
237
|
+
}), /* @__PURE__ */ A("div", {
|
|
238
|
+
className: "mt-2 flex justify-end gap-1.5",
|
|
239
|
+
children: [/* @__PURE__ */ k(V.Cancel, {
|
|
240
|
+
className: i,
|
|
241
|
+
children: "Cancel"
|
|
242
|
+
}), /* @__PURE__ */ k(V.Send, {
|
|
243
|
+
disabled: s,
|
|
244
|
+
className: `${a} ${t}`,
|
|
245
|
+
style: o,
|
|
246
|
+
children: "Save"
|
|
247
|
+
})]
|
|
248
|
+
})] })
|
|
249
|
+
});
|
|
250
|
+
}, Ae = ({ idleClassName: e = "text-zinc-500 hover:text-zinc-900", copiedClassName: t = "text-emerald-500", errorClassName: n = "text-rose-500", className: r = "rounded p-1.5 transition-colors", iconClassName: i = "h-3 w-3" }) => {
|
|
251
|
+
let [a, o] = D("idle"), s = G((e) => e.message);
|
|
252
|
+
T(() => {
|
|
249
253
|
if (a === "idle") return;
|
|
250
254
|
let e = setTimeout(() => o("idle"), 1500);
|
|
251
255
|
return () => clearTimeout(e);
|
|
@@ -257,59 +261,59 @@ var H = ({ chips: e, onSelect: t, size: n = "comfortable", className: r, chipCla
|
|
|
257
261
|
} catch {
|
|
258
262
|
o("error");
|
|
259
263
|
}
|
|
260
|
-
}, l = a === "copied" ? t ?? e : a === "error" ? n ?? e : e, u = a === "copied" ? "Copied" : a === "error" ? "Copy failed" : "Copy message", d = a === "copied" ?
|
|
261
|
-
return /* @__PURE__ */
|
|
264
|
+
}, l = a === "copied" ? t ?? e : a === "error" ? n ?? e : e, u = a === "copied" ? "Copied" : a === "error" ? "Copy failed" : "Copy message", d = a === "copied" ? M : a === "error" ? z : P;
|
|
265
|
+
return /* @__PURE__ */ k("button", {
|
|
262
266
|
type: "button",
|
|
263
267
|
"aria-label": u,
|
|
264
268
|
onClick: c,
|
|
265
269
|
className: [r, l].filter(Boolean).join(" "),
|
|
266
|
-
children: /* @__PURE__ */
|
|
270
|
+
children: /* @__PURE__ */ k(d, { className: i })
|
|
267
271
|
});
|
|
268
|
-
},
|
|
269
|
-
let [t, n] =
|
|
270
|
-
return
|
|
271
|
-
if (
|
|
272
|
+
}, je = ({ children: e }) => {
|
|
273
|
+
let [t, n] = D(!1), r = "plaintext", i = "";
|
|
274
|
+
return b.forEach(e, (e) => {
|
|
275
|
+
if (S(e)) {
|
|
272
276
|
let t = e.props, n = /language-(\w+)/.exec(t.className ?? "");
|
|
273
277
|
n && (r = n[1] ?? r), typeof t.children == "string" && (i = t.children.trim());
|
|
274
278
|
}
|
|
275
|
-
}), /* @__PURE__ */
|
|
279
|
+
}), /* @__PURE__ */ A("div", {
|
|
276
280
|
className: "ai-chat-code not-prose my-4 overflow-hidden rounded-xl border",
|
|
277
|
-
children: [/* @__PURE__ */
|
|
281
|
+
children: [/* @__PURE__ */ A("div", {
|
|
278
282
|
className: "ai-chat-code__header flex items-center justify-between px-4 py-2",
|
|
279
|
-
children: [/* @__PURE__ */
|
|
283
|
+
children: [/* @__PURE__ */ k("span", {
|
|
280
284
|
className: "ai-chat-code__label font-mono text-[10px] uppercase tracking-widest",
|
|
281
285
|
children: r
|
|
282
|
-
}), /* @__PURE__ */
|
|
286
|
+
}), /* @__PURE__ */ k("button", {
|
|
283
287
|
type: "button",
|
|
284
288
|
onClick: () => navigator.clipboard.writeText(i).then(() => {
|
|
285
289
|
n(!0), setTimeout(() => n(!1), 2e3);
|
|
286
290
|
}).catch(() => {}),
|
|
287
291
|
className: "ai-chat-code__copy flex items-center gap-1.5 rounded px-2 py-0.5 text-[10px] transition-colors",
|
|
288
|
-
children: t ? /* @__PURE__ */
|
|
292
|
+
children: t ? /* @__PURE__ */ A(O, { children: [/* @__PURE__ */ k(M, { className: "h-3 w-3 text-emerald-500" }), /* @__PURE__ */ k("span", { children: "Copied!" })] }) : /* @__PURE__ */ A(O, { children: [/* @__PURE__ */ k(P, { className: "h-3 w-3" }), /* @__PURE__ */ k("span", { children: "Copy" })] })
|
|
289
293
|
})]
|
|
290
|
-
}), /* @__PURE__ */
|
|
294
|
+
}), /* @__PURE__ */ k("pre", {
|
|
291
295
|
className: "ai-chat-code__pre overflow-x-auto px-4 py-4 font-mono text-sm leading-relaxed",
|
|
292
296
|
children: e
|
|
293
297
|
})]
|
|
294
298
|
});
|
|
295
|
-
},
|
|
299
|
+
}, Me = (e) => /* @__PURE__ */ k("a", {
|
|
296
300
|
...e,
|
|
297
301
|
target: "_blank",
|
|
298
302
|
rel: "noopener noreferrer"
|
|
299
|
-
}),
|
|
303
|
+
}), Ne = ({ className: e, ...t }) => /* @__PURE__ */ k("div", {
|
|
300
304
|
className: "w-full max-w-full overflow-x-auto",
|
|
301
|
-
children: /* @__PURE__ */
|
|
305
|
+
children: /* @__PURE__ */ k("table", {
|
|
302
306
|
...t,
|
|
303
307
|
className: ["w-max min-w-full [&_td]:max-w-[20rem] [&_th]:max-w-[20rem]", e].filter(Boolean).join(" ")
|
|
304
308
|
})
|
|
305
|
-
}),
|
|
309
|
+
}), Pe = () => /* @__PURE__ */ k(oe, {
|
|
306
310
|
remarkPlugins: [se],
|
|
307
311
|
components: {
|
|
308
|
-
pre:
|
|
309
|
-
a:
|
|
310
|
-
table:
|
|
312
|
+
pre: je,
|
|
313
|
+
a: Me,
|
|
314
|
+
table: Ne
|
|
311
315
|
}
|
|
312
|
-
}),
|
|
316
|
+
}), Fe = [
|
|
313
317
|
"Thinking",
|
|
314
318
|
"Pondering",
|
|
315
319
|
"Drafting",
|
|
@@ -323,12 +327,12 @@ var H = ({ chips: e, onSelect: t, size: n = "comfortable", className: r, chipCla
|
|
|
323
327
|
"Untangling",
|
|
324
328
|
"Threading the needle",
|
|
325
329
|
"Lining up ideas"
|
|
326
|
-
],
|
|
330
|
+
], Ie = (e) => {
|
|
327
331
|
let t = Math.floor(e / 60), n = e % 60;
|
|
328
332
|
return t > 0 ? `${t}m ${n.toString().padStart(2, "0")}s` : `${n}s`;
|
|
329
|
-
},
|
|
330
|
-
let [a, o] =
|
|
331
|
-
|
|
333
|
+
}, Le = ({ phrases: e = Fe, textClassName: t = "ai-thinking-text", timerClassName: n = "text-xs text-zinc-500/70 tabular-nums", longRunningClassName: r = "ml-1.5 text-zinc-500/45", longRunningHint: i = "· hang tight" }) => {
|
|
334
|
+
let [a, o] = D(() => e.length > 0 ? Math.floor(Math.random() * e.length) : 0), [s, c] = D(0);
|
|
335
|
+
T(() => {
|
|
332
336
|
let t = e.length > 0 ? setInterval(() => {
|
|
333
337
|
o((t) => (t + 1) % e.length);
|
|
334
338
|
}, 2800) : null, n = setInterval(() => {
|
|
@@ -339,167 +343,169 @@ var H = ({ chips: e, onSelect: t, size: n = "comfortable", className: r, chipCla
|
|
|
339
343
|
};
|
|
340
344
|
}, [e.length]);
|
|
341
345
|
let l = e[a] ?? "Thinking", u = s >= 3, d = s >= 30;
|
|
342
|
-
return /* @__PURE__ */
|
|
343
|
-
className: "flex items-center gap-3 py-1",
|
|
344
|
-
children: [
|
|
345
|
-
|
|
346
|
+
return /* @__PURE__ */ A("div", {
|
|
347
|
+
className: "flex flex-wrap items-center gap-x-3 gap-y-0.5 py-1",
|
|
348
|
+
children: [/* @__PURE__ */ A("div", {
|
|
349
|
+
className: "flex min-w-0 items-center gap-3",
|
|
350
|
+
children: [/* @__PURE__ */ A("div", {
|
|
346
351
|
className: "ai-dust",
|
|
347
352
|
children: [
|
|
348
|
-
/* @__PURE__ */
|
|
353
|
+
/* @__PURE__ */ k("span", { style: {
|
|
349
354
|
left: "4px",
|
|
350
355
|
"--delay": ".3s"
|
|
351
356
|
} }),
|
|
352
|
-
/* @__PURE__ */
|
|
357
|
+
/* @__PURE__ */ k("span", { style: {
|
|
353
358
|
left: "12px",
|
|
354
359
|
"--delay": "0s"
|
|
355
360
|
} }),
|
|
356
|
-
/* @__PURE__ */
|
|
361
|
+
/* @__PURE__ */ k("span", { style: {
|
|
357
362
|
left: "20px",
|
|
358
363
|
"--delay": ".6s"
|
|
359
364
|
} })
|
|
360
365
|
]
|
|
361
|
-
}),
|
|
362
|
-
|
|
363
|
-
className: `${t} font-semibold text-sm transition-opacity duration-500`,
|
|
366
|
+
}), /* @__PURE__ */ A("span", {
|
|
367
|
+
className: `${t} min-w-0 truncate font-semibold text-sm transition-opacity duration-500`,
|
|
364
368
|
children: [l, "…"]
|
|
365
|
-
})
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
]
|
|
369
|
+
})]
|
|
370
|
+
}), u && /* @__PURE__ */ A("span", {
|
|
371
|
+
className: `${n} min-w-0 truncate`,
|
|
372
|
+
children: [Ie(s), d && /* @__PURE__ */ k("span", {
|
|
373
|
+
className: r,
|
|
374
|
+
children: i
|
|
375
|
+
})]
|
|
376
|
+
})]
|
|
374
377
|
});
|
|
375
|
-
},
|
|
376
|
-
let
|
|
377
|
-
className:
|
|
378
|
-
children: /* @__PURE__ */
|
|
379
|
-
Text:
|
|
380
|
-
tools: { Fallback:
|
|
378
|
+
}, Re = () => null, ze = "max-w-none text-sm text-zinc-900 leading-relaxed [&>*:first-child]:mt-0 [&>*:last-child]:mb-0 [&_a:hover]:text-sky-700 [&_a]:break-words [&_a]:font-medium [&_a]:text-sky-600 [&_a]:underline [&_a]:underline-offset-2 [&_li]:text-sm [&_ol]:my-2 [&_ol]:list-decimal [&_ol]:pl-5 [&_p]:my-2 [&_p]:text-sm [&_strong]:font-semibold [&_ul]:my-2 [&_ul]:list-disc [&_ul]:pl-5", Be = "group pr-4 pb-6", Ve = "mt-2 flex items-center gap-2 opacity-0 transition-opacity group-focus-within:opacity-100 group-hover:opacity-100", He = "text-xs text-zinc-500/60", Ue = "rounded p-1.5 text-zinc-500 transition-colors hover:text-zinc-900", We = ({ tools: t = Re, Parts: n, thinkingIndicator: i = /* @__PURE__ */ k(Le, {}), rootClassName: a = Be, contentClassName: o = ze, metaClassName: s = Ve, wrapContent: c, metaSlot: l, copyIdleClassName: u, copyCopiedClassName: d, reloadClassName: f = Ue, timeClassName: p = He, timeFormatOptions: m, readOnly: h = !1, belowContent: g, footerSlot: _ }) => {
|
|
379
|
+
let y = G((e) => e.message), b = e(y), x = n ?? H.Content, S = y.status?.type === "running", C = /* @__PURE__ */ k("div", {
|
|
380
|
+
className: o,
|
|
381
|
+
children: /* @__PURE__ */ k(x, { components: {
|
|
382
|
+
Text: Pe,
|
|
383
|
+
tools: { Fallback: t }
|
|
381
384
|
} })
|
|
382
385
|
});
|
|
383
|
-
return /* @__PURE__ */
|
|
384
|
-
className:
|
|
385
|
-
children: /* @__PURE__ */
|
|
386
|
+
return /* @__PURE__ */ k(H.Root, {
|
|
387
|
+
className: a,
|
|
388
|
+
children: /* @__PURE__ */ A("div", {
|
|
386
389
|
className: "flex min-w-0 flex-col",
|
|
387
390
|
children: [
|
|
388
|
-
|
|
389
|
-
|
|
391
|
+
c ? c(C) : C,
|
|
392
|
+
S && /* @__PURE__ */ k("div", {
|
|
390
393
|
className: "mt-1",
|
|
391
|
-
children:
|
|
394
|
+
children: i
|
|
392
395
|
}),
|
|
393
|
-
!
|
|
396
|
+
!S && g && /* @__PURE__ */ k("div", {
|
|
394
397
|
className: "mt-2",
|
|
395
|
-
children:
|
|
398
|
+
children: g
|
|
396
399
|
}),
|
|
397
|
-
!
|
|
398
|
-
className:
|
|
400
|
+
!S && /* @__PURE__ */ A("div", {
|
|
401
|
+
className: s,
|
|
399
402
|
children: [
|
|
400
|
-
/* @__PURE__ */
|
|
401
|
-
className:
|
|
402
|
-
|
|
403
|
+
/* @__PURE__ */ k("span", {
|
|
404
|
+
className: p,
|
|
405
|
+
title: r(b) || void 0,
|
|
406
|
+
children: v(b, m)
|
|
403
407
|
}),
|
|
404
|
-
|
|
405
|
-
/* @__PURE__ */
|
|
408
|
+
l,
|
|
409
|
+
/* @__PURE__ */ A(B.Root, {
|
|
406
410
|
className: "flex items-center gap-0.5",
|
|
407
|
-
children: [/* @__PURE__ */
|
|
408
|
-
idleClassName:
|
|
409
|
-
copiedClassName:
|
|
410
|
-
}), !
|
|
411
|
-
className:
|
|
412
|
-
children: /* @__PURE__ */
|
|
411
|
+
children: [/* @__PURE__ */ k(Ae, {
|
|
412
|
+
idleClassName: u,
|
|
413
|
+
copiedClassName: d
|
|
414
|
+
}), !h && /* @__PURE__ */ k(B.Reload, {
|
|
415
|
+
className: `${f} disabled:cursor-not-allowed disabled:opacity-40`,
|
|
416
|
+
children: /* @__PURE__ */ k(L, { className: "h-3 w-3" })
|
|
413
417
|
})]
|
|
414
418
|
})
|
|
415
419
|
]
|
|
416
420
|
}),
|
|
417
|
-
!
|
|
421
|
+
!S && _
|
|
418
422
|
]
|
|
419
423
|
})
|
|
420
424
|
});
|
|
421
|
-
},
|
|
422
|
-
let
|
|
423
|
-
return /* @__PURE__ */
|
|
424
|
-
className:
|
|
425
|
+
}, Ge = "group flex flex-col items-end pb-4 pl-12", Ke = "rounded-2xl border border-zinc-200 bg-zinc-100 px-3.5 py-2.5 text-sm text-zinc-900 leading-relaxed", qe = "mt-1 flex items-center gap-2 opacity-0 transition-opacity group-focus-within:opacity-100 group-hover:opacity-100", Je = "text-xs text-zinc-500/60", Ye = "rounded px-2 py-1 font-medium text-xs text-zinc-500 transition-colors hover:text-zinc-900", Xe = ({ attachmentsSlot: t, rootClassName: n = Ge, bubbleClassName: i = Ke, contentSlot: a, metaClassName: o = qe, timeClassName: s = Je, editClassName: c = Ye, copyIdleClassName: l, copyCopiedClassName: u, timeFormatOptions: d, readOnly: f = !1 }) => {
|
|
426
|
+
let p = G((e) => e.message), m = G((e) => e.thread.isRunning), h = e(p);
|
|
427
|
+
return /* @__PURE__ */ A(H.Root, {
|
|
428
|
+
className: n,
|
|
425
429
|
"data-user-message": "true",
|
|
426
430
|
children: [
|
|
427
|
-
|
|
428
|
-
/* @__PURE__ */
|
|
429
|
-
className: n,
|
|
430
|
-
children: r ?? /* @__PURE__ */ E(R.Content, {})
|
|
431
|
-
}),
|
|
432
|
-
/* @__PURE__ */ D("div", {
|
|
431
|
+
t,
|
|
432
|
+
/* @__PURE__ */ k("div", {
|
|
433
433
|
className: i,
|
|
434
|
-
children:
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
434
|
+
children: a ?? /* @__PURE__ */ k(H.Content, {})
|
|
435
|
+
}),
|
|
436
|
+
/* @__PURE__ */ A("div", {
|
|
437
|
+
className: o,
|
|
438
|
+
children: [/* @__PURE__ */ k("span", {
|
|
439
|
+
className: s,
|
|
440
|
+
title: r(h) || void 0,
|
|
441
|
+
children: v(h, d)
|
|
442
|
+
}), /* @__PURE__ */ A(B.Root, {
|
|
438
443
|
className: "flex items-center gap-0.5",
|
|
439
|
-
children: [/* @__PURE__ */
|
|
440
|
-
idleClassName:
|
|
441
|
-
copiedClassName:
|
|
442
|
-
}), !
|
|
443
|
-
|
|
444
|
+
children: [/* @__PURE__ */ k(Ae, {
|
|
445
|
+
idleClassName: l,
|
|
446
|
+
copiedClassName: u
|
|
447
|
+
}), !f && /* @__PURE__ */ k(B.Edit, {
|
|
448
|
+
disabled: m,
|
|
449
|
+
className: `${c} disabled:cursor-not-allowed disabled:opacity-40`,
|
|
444
450
|
children: "Edit"
|
|
445
451
|
})]
|
|
446
452
|
})]
|
|
447
453
|
})
|
|
448
454
|
]
|
|
449
455
|
});
|
|
450
|
-
},
|
|
456
|
+
}, Ze = () => /* @__PURE__ */ k(ke, { sendStyle: {
|
|
451
457
|
backgroundColor: "var(--color-brand, #0a0a0a)",
|
|
452
458
|
color: "var(--color-brand-foreground, #fff)"
|
|
453
|
-
} }),
|
|
459
|
+
} }), Qe = [
|
|
454
460
|
"What do you offer?",
|
|
455
461
|
"How much does it cost?",
|
|
456
462
|
"Why should I choose you?",
|
|
457
463
|
"How do I get in touch?"
|
|
458
|
-
],
|
|
464
|
+
], $e = [
|
|
459
465
|
"w-3/4",
|
|
460
466
|
"w-4/5",
|
|
461
467
|
"w-2/3",
|
|
462
468
|
"w-3/5"
|
|
463
|
-
],
|
|
464
|
-
let l =
|
|
469
|
+
], et = ({ workspaceId: e, siteName: t, siteLogo: n, apiBaseUrl: r, authHeaders: i, agentId: a, followUps: s, hideComposer: c = !1 }) => {
|
|
470
|
+
let l = W(), u = G((e) => e.thread.isRunning), { agentUnavailable: d } = fe(), f = E(null), { isAtBottom: p, scrollToBottom: m } = be({
|
|
465
471
|
viewportRef: f,
|
|
466
472
|
isRunning: u
|
|
467
473
|
}), h = _e({
|
|
468
|
-
endpoint:
|
|
469
|
-
headers:
|
|
470
|
-
...
|
|
471
|
-
"Levo-Workspace":
|
|
474
|
+
endpoint: e ? `${r}/suggestions${a ? `?agent_id=${encodeURIComponent(a)}` : ""}` : void 0,
|
|
475
|
+
headers: e ? {
|
|
476
|
+
...o(i),
|
|
477
|
+
"Levo-Workspace": e
|
|
472
478
|
} : void 0,
|
|
473
|
-
fallback:
|
|
474
|
-
}), g =
|
|
475
|
-
|
|
476
|
-
}, [l]), _ =
|
|
477
|
-
return
|
|
479
|
+
fallback: Qe
|
|
480
|
+
}), g = C((e) => {
|
|
481
|
+
y(l.thread.composer(), e);
|
|
482
|
+
}, [l]), _ = C(() => l.thread.cancelRun(), [l]), v = E(u);
|
|
483
|
+
return T(() => {
|
|
478
484
|
v.current = u;
|
|
479
|
-
}, [u]),
|
|
485
|
+
}, [u]), T(() => {
|
|
480
486
|
let e = (e) => {
|
|
481
487
|
e.key !== "Escape" || e.isComposing || !v.current || (e.preventDefault(), e.stopImmediatePropagation(), l.thread.cancelRun());
|
|
482
488
|
};
|
|
483
489
|
return window.addEventListener("keydown", e, !0), () => window.removeEventListener("keydown", e, !0);
|
|
484
|
-
}, [l]), /* @__PURE__ */
|
|
490
|
+
}, [l]), /* @__PURE__ */ A(U.Root, {
|
|
485
491
|
className: "relative flex flex-1 flex-col overflow-hidden",
|
|
486
492
|
children: [
|
|
487
|
-
/* @__PURE__ */
|
|
493
|
+
/* @__PURE__ */ k(U.If, {
|
|
488
494
|
empty: !0,
|
|
489
|
-
children: /* @__PURE__ */
|
|
495
|
+
children: /* @__PURE__ */ k("div", {
|
|
490
496
|
className: "pointer-events-none absolute inset-0 z-0 overflow-hidden",
|
|
491
|
-
children: /* @__PURE__ */
|
|
497
|
+
children: /* @__PURE__ */ k("div", {
|
|
492
498
|
className: "absolute inset-0",
|
|
493
499
|
style: { background: ["radial-gradient(at 12% 18%, color-mix(in oklch, var(--color-brand, #4691e8) 12%, transparent) 0px, transparent 55%)", "radial-gradient(at 88% 82%, color-mix(in oklch, var(--color-brand-secondary, #db646d) 8%, transparent) 0px, transparent 55%)"].join(", ") }
|
|
494
500
|
})
|
|
495
501
|
})
|
|
496
502
|
}),
|
|
497
|
-
d && /* @__PURE__ */
|
|
503
|
+
d && /* @__PURE__ */ k("div", {
|
|
498
504
|
role: "alert",
|
|
499
505
|
className: "relative z-20 shrink-0 border-amber-200 border-b bg-amber-50 px-4 py-2.5 text-amber-800 text-xs",
|
|
500
506
|
children: "This conversation is no longer available. Please refresh the page to start a new chat."
|
|
501
507
|
}),
|
|
502
|
-
/* @__PURE__ */
|
|
508
|
+
/* @__PURE__ */ A(U.Viewport, {
|
|
503
509
|
ref: f,
|
|
504
510
|
turnAnchor: "top",
|
|
505
511
|
className: "relative z-10 flex-1 overflow-y-auto",
|
|
@@ -507,20 +513,20 @@ var H = ({ chips: e, onSelect: t, size: n = "comfortable", className: r, chipCla
|
|
|
507
513
|
scrollToBottomOnRunStart: !1,
|
|
508
514
|
scrollToBottomOnInitialize: !1,
|
|
509
515
|
scrollToBottomOnThreadSwitch: !1,
|
|
510
|
-
children: [/* @__PURE__ */
|
|
516
|
+
children: [/* @__PURE__ */ k(U.Empty, { children: /* @__PURE__ */ A("div", {
|
|
511
517
|
className: "flex min-h-full flex-col items-center justify-center px-6 py-6",
|
|
512
|
-
children: [/* @__PURE__ */
|
|
518
|
+
children: [/* @__PURE__ */ A("div", {
|
|
513
519
|
className: "mb-5 flex flex-col items-center gap-2 text-center",
|
|
514
520
|
children: [
|
|
515
|
-
|
|
516
|
-
src:
|
|
517
|
-
alt:
|
|
521
|
+
n ? /* @__PURE__ */ k("img", {
|
|
522
|
+
src: n,
|
|
523
|
+
alt: t ?? "Site logo",
|
|
518
524
|
className: "mb-1 h-12 w-auto max-w-[180px] object-contain"
|
|
519
|
-
}) : /* @__PURE__ */
|
|
525
|
+
}) : /* @__PURE__ */ k("span", {
|
|
520
526
|
className: "font-semibold text-lg text-zinc-900 tracking-tight",
|
|
521
|
-
children:
|
|
527
|
+
children: t ?? "This site"
|
|
522
528
|
}),
|
|
523
|
-
/* @__PURE__ */
|
|
529
|
+
/* @__PURE__ */ k("p", {
|
|
524
530
|
className: "mt-1 text-2xl text-zinc-900 tracking-tight",
|
|
525
531
|
style: {
|
|
526
532
|
fontFamily: "var(--font-heading, inherit)",
|
|
@@ -528,18 +534,18 @@ var H = ({ chips: e, onSelect: t, size: n = "comfortable", className: r, chipCla
|
|
|
528
534
|
},
|
|
529
535
|
children: "Ask anything"
|
|
530
536
|
}),
|
|
531
|
-
/* @__PURE__ */
|
|
537
|
+
/* @__PURE__ */ k("p", {
|
|
532
538
|
className: "text-sm text-zinc-500",
|
|
533
539
|
style: { fontFamily: "var(--font-heading, inherit)" },
|
|
534
540
|
children: "Get instant answers about products, pricing, and how to get started."
|
|
535
541
|
})
|
|
536
542
|
]
|
|
537
|
-
}), /* @__PURE__ */
|
|
543
|
+
}), /* @__PURE__ */ k("div", {
|
|
538
544
|
className: "flex w-full max-w-md flex-col gap-2",
|
|
539
|
-
children: h === null ?
|
|
545
|
+
children: h === null ? $e.map((e, t) => /* @__PURE__ */ k("div", {
|
|
540
546
|
className: "flex h-[42px] items-center rounded-xl border border-zinc-200 bg-white px-4",
|
|
541
|
-
children: /* @__PURE__ */
|
|
542
|
-
}, `skeleton-${t}`)) : h.map((e, t) => /* @__PURE__ */
|
|
547
|
+
children: /* @__PURE__ */ k("span", { className: `block h-3 animate-pulse rounded bg-zinc-200 ${e}` })
|
|
548
|
+
}, `skeleton-${t}`)) : h.map((e, t) => /* @__PURE__ */ k("button", {
|
|
543
549
|
type: "button",
|
|
544
550
|
onClick: () => g(e),
|
|
545
551
|
className: "ai-chat-suggestion rounded-xl border border-zinc-200 bg-white px-4 py-2.5 text-left text-sm text-zinc-700 transition-[border-color,background-color,transform] duration-150 hover:border-zinc-300 hover:bg-zinc-50 active:scale-[0.98]",
|
|
@@ -547,70 +553,70 @@ var H = ({ chips: e, onSelect: t, size: n = "comfortable", className: r, chipCla
|
|
|
547
553
|
children: e
|
|
548
554
|
}, e))
|
|
549
555
|
})]
|
|
550
|
-
}) }), /* @__PURE__ */
|
|
556
|
+
}) }), /* @__PURE__ */ k(U.If, {
|
|
551
557
|
empty: !1,
|
|
552
|
-
children: /* @__PURE__ */
|
|
558
|
+
children: /* @__PURE__ */ k("div", {
|
|
553
559
|
className: "ai-chat-kb-messages mx-auto max-w-3xl px-6 py-6 pt-8",
|
|
554
|
-
children: /* @__PURE__ */
|
|
555
|
-
UserMessage:
|
|
556
|
-
AssistantMessage:
|
|
557
|
-
EditComposer:
|
|
560
|
+
children: /* @__PURE__ */ k(U.Messages, { components: {
|
|
561
|
+
UserMessage: Xe,
|
|
562
|
+
AssistantMessage: We,
|
|
563
|
+
EditComposer: Ze
|
|
558
564
|
} })
|
|
559
565
|
})
|
|
560
566
|
})]
|
|
561
567
|
}),
|
|
562
|
-
!c && /* @__PURE__ */
|
|
568
|
+
!c && /* @__PURE__ */ k("div", {
|
|
563
569
|
className: "relative z-10 shrink-0 border-zinc-200 border-t bg-white/95 backdrop-blur-sm",
|
|
564
|
-
children: /* @__PURE__ */
|
|
570
|
+
children: /* @__PURE__ */ A("div", {
|
|
565
571
|
className: "relative mx-auto max-w-3xl px-4 pt-3 pb-3",
|
|
566
572
|
children: [
|
|
567
|
-
!p && /* @__PURE__ */
|
|
573
|
+
!p && /* @__PURE__ */ k("div", {
|
|
568
574
|
className: "pointer-events-none absolute inset-x-0 -top-9 z-20 flex justify-center",
|
|
569
|
-
children: /* @__PURE__ */
|
|
575
|
+
children: /* @__PURE__ */ k(ge, {
|
|
570
576
|
onClick: m,
|
|
571
577
|
isRunning: u,
|
|
572
578
|
className: "pointer-events-auto rounded-full border border-zinc-200 bg-white/95 px-3 py-1.5 font-medium text-xs text-zinc-500 shadow-lg backdrop-blur-sm hover:text-zinc-900"
|
|
573
579
|
})
|
|
574
580
|
}),
|
|
575
|
-
s.length > 0 && !u && /* @__PURE__ */
|
|
581
|
+
s.length > 0 && !u && /* @__PURE__ */ k("div", {
|
|
576
582
|
className: "mb-2",
|
|
577
|
-
children: /* @__PURE__ */
|
|
583
|
+
children: /* @__PURE__ */ k(K, {
|
|
578
584
|
chips: s,
|
|
579
585
|
onSelect: g,
|
|
580
586
|
size: "compact"
|
|
581
587
|
})
|
|
582
588
|
}),
|
|
583
|
-
/* @__PURE__ */
|
|
584
|
-
/* @__PURE__ */
|
|
589
|
+
/* @__PURE__ */ A(V.Root, { children: [
|
|
590
|
+
/* @__PURE__ */ k(U.If, {
|
|
585
591
|
empty: !0,
|
|
586
|
-
children: /* @__PURE__ */
|
|
592
|
+
children: /* @__PURE__ */ k(we, {
|
|
587
593
|
variant: "expanded",
|
|
588
594
|
isRunning: u,
|
|
589
595
|
onStop: _
|
|
590
596
|
})
|
|
591
597
|
}),
|
|
592
|
-
/* @__PURE__ */
|
|
598
|
+
/* @__PURE__ */ k(U.If, {
|
|
593
599
|
empty: !1,
|
|
594
|
-
children: /* @__PURE__ */
|
|
600
|
+
children: /* @__PURE__ */ k(we, {
|
|
595
601
|
variant: "compact",
|
|
596
602
|
isRunning: u,
|
|
597
603
|
onStop: _
|
|
598
604
|
})
|
|
599
605
|
}),
|
|
600
|
-
/* @__PURE__ */
|
|
606
|
+
/* @__PURE__ */ k(V.If, {
|
|
601
607
|
dictation: !0,
|
|
602
|
-
children: /* @__PURE__ */
|
|
608
|
+
children: /* @__PURE__ */ A("div", {
|
|
603
609
|
className: "mt-2 flex items-center justify-center gap-2",
|
|
604
|
-
children: [/* @__PURE__ */
|
|
610
|
+
children: [/* @__PURE__ */ k("span", { className: "h-1.5 w-1.5 animate-pulse rounded-full bg-red-500" }), /* @__PURE__ */ k("span", {
|
|
605
611
|
className: "font-medium text-red-500 text-xs tracking-wide",
|
|
606
612
|
children: "Listening… speak now"
|
|
607
613
|
})]
|
|
608
614
|
})
|
|
609
615
|
})
|
|
610
616
|
] }),
|
|
611
|
-
/* @__PURE__ */
|
|
617
|
+
/* @__PURE__ */ k(U.If, {
|
|
612
618
|
empty: !1,
|
|
613
|
-
children: /* @__PURE__ */
|
|
619
|
+
children: /* @__PURE__ */ k("p", {
|
|
614
620
|
className: "mt-2 text-center text-[10px] text-zinc-500/70",
|
|
615
621
|
children: "Answers can be inaccurate. Verify before relying on them."
|
|
616
622
|
})
|
|
@@ -620,88 +626,87 @@ var H = ({ chips: e, onSelect: t, size: n = "comfortable", className: r, chipCla
|
|
|
620
626
|
})
|
|
621
627
|
]
|
|
622
628
|
});
|
|
623
|
-
},
|
|
629
|
+
}, Y = 4096, tt = 400, nt = 300, rt = 2e3, it = (e) => document.querySelector(e)?.content?.trim() || void 0, at = (e) => {
|
|
624
630
|
for (let t of e) {
|
|
625
|
-
let e =
|
|
631
|
+
let e = it(t);
|
|
626
632
|
if (e) return e;
|
|
627
633
|
}
|
|
628
|
-
},
|
|
634
|
+
}, ot = (e, t) => e.length > t ? `${e.slice(0, t - 1).trimEnd()}…` : e, X = (e) => JSON.stringify(e).length, st = () => {
|
|
629
635
|
if (typeof window > "u" || typeof document > "u") return;
|
|
630
636
|
let e = {}, t = window.location?.href;
|
|
631
637
|
t && (e.url = t);
|
|
632
|
-
let n = document.title?.trim() ||
|
|
633
|
-
n && (e.page_title =
|
|
634
|
-
let r =
|
|
638
|
+
let n = document.title?.trim() || at(["meta[property=\"og:title\"]", "meta[name=\"twitter:title\"]"]);
|
|
639
|
+
n && (e.page_title = ot(n, nt));
|
|
640
|
+
let r = at([
|
|
635
641
|
"meta[name=\"description\"]",
|
|
636
642
|
"meta[property=\"og:description\"]",
|
|
637
643
|
"meta[name=\"twitter:description\"]"
|
|
638
644
|
]);
|
|
639
|
-
r && (e.description =
|
|
645
|
+
r && (e.description = ot(r, tt));
|
|
640
646
|
let i = document.referrer?.trim();
|
|
641
|
-
if (i && (e.referrer = i), Object.keys(e).length !== 0) return e.description &&
|
|
642
|
-
},
|
|
643
|
-
let
|
|
644
|
-
|
|
645
|
-
let
|
|
646
|
-
|
|
647
|
-
let { followUps:
|
|
647
|
+
if (i && (e.referrer = i), Object.keys(e).length !== 0) return e.description && X(e) > Y && delete e.description, e.referrer && X(e) > Y && delete e.referrer, e.url && X(e) > Y && (e.url = e.url.slice(0, rt)), e;
|
|
648
|
+
}, ct = ({ workspaceId: e, siteName: t, siteLogo: n, agentId: r, apiBaseUrl: i, authHeaders: a, children: s }) => {
|
|
649
|
+
let c = E(e);
|
|
650
|
+
c.current = e;
|
|
651
|
+
let l = E(r);
|
|
652
|
+
l.current = r;
|
|
653
|
+
let { followUps: u, clearOnSend: d, handleData: f } = ue(), [p, m] = D(!1), { conversationIdRef: h, handleFinish: g, reset: _ } = le(e), v = ae({
|
|
648
654
|
joinStrategy: "none",
|
|
649
655
|
transport: ce({
|
|
650
656
|
api: `${i}/stream`,
|
|
651
657
|
credentials: "include",
|
|
652
|
-
headers: a,
|
|
653
658
|
onSendStart: () => {
|
|
654
|
-
|
|
659
|
+
d(), m(!1);
|
|
655
660
|
},
|
|
656
661
|
getHeaders: () => {
|
|
657
|
-
let e = {};
|
|
658
|
-
return
|
|
662
|
+
let e = { ...o(a) };
|
|
663
|
+
return c.current && (e["Levo-Workspace"] = c.current), e;
|
|
659
664
|
},
|
|
660
665
|
getBody: (e) => {
|
|
661
666
|
let t = {
|
|
662
667
|
messages: e.messages,
|
|
663
|
-
workspace_id:
|
|
668
|
+
workspace_id: c.current
|
|
664
669
|
};
|
|
665
|
-
|
|
666
|
-
let n =
|
|
670
|
+
h.current && (t.conversation_id = h.current), l.current && (t.agent_id = l.current);
|
|
671
|
+
let n = st();
|
|
667
672
|
return n && (t.context = n), t;
|
|
668
673
|
}
|
|
669
674
|
}),
|
|
670
675
|
adapters: { dictation: new re({ interimResults: !1 }) },
|
|
671
|
-
onData:
|
|
672
|
-
onFinish:
|
|
676
|
+
onData: f,
|
|
677
|
+
onFinish: g,
|
|
673
678
|
onError: (e) => {
|
|
674
|
-
de(e) ?
|
|
679
|
+
de(e) ? m(!0) : console.warn("[levo-kb-chat] stream error:", e);
|
|
675
680
|
}
|
|
676
|
-
}),
|
|
677
|
-
|
|
681
|
+
}), y = C(() => {
|
|
682
|
+
v.threads.switchToNewThread().catch((e) => {
|
|
678
683
|
console.warn("[levo-kb-chat] switchToNewThread failed:", e);
|
|
679
|
-
}),
|
|
684
|
+
}), _(), d(), m(!1);
|
|
680
685
|
}, [
|
|
686
|
+
v,
|
|
681
687
|
_,
|
|
682
|
-
|
|
683
|
-
u
|
|
688
|
+
d
|
|
684
689
|
]);
|
|
685
|
-
return /* @__PURE__ */
|
|
686
|
-
runtime:
|
|
687
|
-
children: /* @__PURE__ */
|
|
688
|
-
value: { agentUnavailable:
|
|
689
|
-
children:
|
|
690
|
-
followUps:
|
|
691
|
-
onResetChat:
|
|
692
|
-
}) : /* @__PURE__ */
|
|
690
|
+
return /* @__PURE__ */ k(ne, {
|
|
691
|
+
runtime: v,
|
|
692
|
+
children: /* @__PURE__ */ k(q.Provider, {
|
|
693
|
+
value: { agentUnavailable: p },
|
|
694
|
+
children: s ? s({
|
|
695
|
+
followUps: u,
|
|
696
|
+
onResetChat: y
|
|
697
|
+
}) : /* @__PURE__ */ k(et, {
|
|
693
698
|
workspaceId: e,
|
|
694
699
|
siteName: t,
|
|
695
700
|
siteLogo: n,
|
|
696
701
|
apiBaseUrl: i,
|
|
697
702
|
authHeaders: a,
|
|
698
703
|
agentId: r,
|
|
699
|
-
followUps:
|
|
704
|
+
followUps: u
|
|
700
705
|
})
|
|
701
706
|
})
|
|
702
707
|
});
|
|
703
|
-
},
|
|
704
|
-
|
|
708
|
+
}, lt = (e, t, n) => {
|
|
709
|
+
T(() => {
|
|
705
710
|
if (!e) return;
|
|
706
711
|
let r = (e) => {
|
|
707
712
|
if (e.key !== "Escape" || e.isComposing) return;
|
|
@@ -718,16 +723,16 @@ var H = ({ chips: e, onSelect: t, size: n = "comfortable", className: r, chipCla
|
|
|
718
723
|
t,
|
|
719
724
|
n
|
|
720
725
|
]);
|
|
721
|
-
},
|
|
722
|
-
let [e, t] =
|
|
723
|
-
return
|
|
724
|
-
let e = window.matchMedia(
|
|
726
|
+
}, Z = "(max-width: 639px)", ut = () => {
|
|
727
|
+
let [e, t] = D(() => typeof window < "u" && window.matchMedia(Z).matches);
|
|
728
|
+
return T(() => {
|
|
729
|
+
let e = window.matchMedia(Z), n = () => t(e.matches);
|
|
725
730
|
return n(), e.addEventListener("change", n), () => e.removeEventListener("change", n);
|
|
726
731
|
}, []), e;
|
|
727
|
-
},
|
|
728
|
-
|
|
732
|
+
}, dt = (e, t) => {
|
|
733
|
+
T(() => {
|
|
729
734
|
let n = t.current, r = window.visualViewport;
|
|
730
|
-
if (!e || !n || !r || !window.matchMedia(
|
|
735
|
+
if (!e || !n || !r || !window.matchMedia(Z).matches) return;
|
|
731
736
|
let i = () => {
|
|
732
737
|
n.style.setProperty("--ai-vv-top", `${r.offsetTop}px`), n.style.setProperty("--ai-vv-height", `${r.height}px`);
|
|
733
738
|
};
|
|
@@ -735,8 +740,8 @@ var H = ({ chips: e, onSelect: t, size: n = "comfortable", className: r, chipCla
|
|
|
735
740
|
r.removeEventListener("resize", i), r.removeEventListener("scroll", i), n.style.removeProperty("--ai-vv-top"), n.style.removeProperty("--ai-vv-height");
|
|
736
741
|
};
|
|
737
742
|
}, [e, t]);
|
|
738
|
-
},
|
|
739
|
-
|
|
743
|
+
}, ft = (e, t, n) => {
|
|
744
|
+
T(() => {
|
|
740
745
|
if (!e) return;
|
|
741
746
|
let r = (e) => {
|
|
742
747
|
let r = e.composedPath();
|
|
@@ -748,68 +753,68 @@ var H = ({ chips: e, onSelect: t, size: n = "comfortable", className: r, chipCla
|
|
|
748
753
|
t,
|
|
749
754
|
n
|
|
750
755
|
]);
|
|
751
|
-
}, Q = (...e) => e.filter(Boolean).join(" "),
|
|
752
|
-
let _ =
|
|
753
|
-
|
|
754
|
-
|
|
756
|
+
}, Q = (...e) => e.filter(Boolean).join(" "), pt = ({ open: e, onToggle: t, askLabel: r, panelId: o, initialDraft: s }) => {
|
|
757
|
+
let _ = W(), v = ut(), y = G((e) => e.thread.isRunning), b = G((e) => e.thread.messages.length > 0), x = G((e) => e.composer.text), S = x.trim().length > 0, [C, w] = D(!1);
|
|
758
|
+
T(() => {
|
|
759
|
+
s && _.thread.composer().setText(s);
|
|
755
760
|
}, []);
|
|
756
|
-
let M =
|
|
757
|
-
|
|
761
|
+
let M = E(null), N = E(null), P = E(!1);
|
|
762
|
+
ee(() => {
|
|
758
763
|
let e = M.current;
|
|
759
|
-
!e || document.activeElement === e || (
|
|
760
|
-
}, []),
|
|
761
|
-
let t = M.current, n =
|
|
764
|
+
!e || document.activeElement === e || (P.current = !0, e.focus({ preventScroll: !0 }));
|
|
765
|
+
}, []), ee(() => {
|
|
766
|
+
let t = M.current, n = N.current;
|
|
762
767
|
if (!(!t || !n)) {
|
|
763
768
|
if (!e) {
|
|
764
|
-
t.style.height = "",
|
|
769
|
+
t.style.height = "", w(!1);
|
|
765
770
|
return;
|
|
766
771
|
}
|
|
767
|
-
|
|
772
|
+
w(u(n, t));
|
|
768
773
|
}
|
|
769
|
-
}, [
|
|
770
|
-
let
|
|
771
|
-
|
|
772
|
-
let t =
|
|
773
|
-
|
|
774
|
+
}, [x, e]);
|
|
775
|
+
let F = E(e);
|
|
776
|
+
T(() => {
|
|
777
|
+
let t = F.current;
|
|
778
|
+
F.current = e;
|
|
774
779
|
let n = M.current;
|
|
775
780
|
e || !t || !n || document.activeElement === n && n.blur();
|
|
776
781
|
}, [e]);
|
|
777
|
-
let
|
|
778
|
-
|
|
779
|
-
let e = !
|
|
780
|
-
|
|
782
|
+
let L = E(y);
|
|
783
|
+
T(() => {
|
|
784
|
+
let e = !L.current && y;
|
|
785
|
+
L.current = y, v && e && M.current?.blur();
|
|
781
786
|
}, [y, v]);
|
|
782
|
-
let z = b ? "Continue conversation" :
|
|
783
|
-
return /* @__PURE__ */
|
|
784
|
-
className: Q(
|
|
785
|
-
children: /* @__PURE__ */
|
|
786
|
-
ref:
|
|
787
|
-
className: Q(
|
|
787
|
+
let z = b ? "Continue conversation" : r;
|
|
788
|
+
return /* @__PURE__ */ k("div", {
|
|
789
|
+
className: Q(d, e ? m : i),
|
|
790
|
+
children: /* @__PURE__ */ A("div", {
|
|
791
|
+
ref: N,
|
|
792
|
+
className: Q(g, C && "ai-chat-pill-surface--stacked"),
|
|
788
793
|
children: [
|
|
789
|
-
/* @__PURE__ */
|
|
794
|
+
/* @__PURE__ */ k("button", {
|
|
790
795
|
type: "button",
|
|
791
|
-
onClick:
|
|
796
|
+
onClick: t,
|
|
792
797
|
"aria-label": e ? "Collapse AI chat" : "Expand AI chat",
|
|
793
798
|
"aria-expanded": e,
|
|
794
|
-
"aria-controls":
|
|
795
|
-
className:
|
|
796
|
-
children: /* @__PURE__ */
|
|
799
|
+
"aria-controls": o,
|
|
800
|
+
className: l,
|
|
801
|
+
children: /* @__PURE__ */ k(te, { className: "h-5 w-5" })
|
|
797
802
|
}),
|
|
798
|
-
/* @__PURE__ */
|
|
799
|
-
className:
|
|
800
|
-
children: [/* @__PURE__ */
|
|
803
|
+
/* @__PURE__ */ A("div", {
|
|
804
|
+
className: p,
|
|
805
|
+
children: [/* @__PURE__ */ k(V.Input, {
|
|
801
806
|
ref: M,
|
|
802
807
|
"data-ai-chat-composer": "",
|
|
803
808
|
placeholder: e ? "Ask anything…" : "",
|
|
804
809
|
onFocus: () => {
|
|
805
|
-
if (
|
|
806
|
-
|
|
810
|
+
if (P.current) {
|
|
811
|
+
P.current = !1;
|
|
807
812
|
return;
|
|
808
813
|
}
|
|
809
|
-
e ||
|
|
814
|
+
e || t();
|
|
810
815
|
},
|
|
811
816
|
onKeyDown: (e) => {
|
|
812
|
-
e.nativeEvent.isComposing || e.key !== "Enter" || e.shiftKey || (e.preventDefault(), !y &&
|
|
817
|
+
e.nativeEvent.isComposing || e.key !== "Enter" || e.shiftKey || (e.preventDefault(), !y && S && _.thread.composer().send());
|
|
813
818
|
},
|
|
814
819
|
rows: 1,
|
|
815
820
|
submitMode: "enter",
|
|
@@ -820,74 +825,74 @@ var H = ({ chips: e, onSelect: t, size: n = "comfortable", className: r, chipCla
|
|
|
820
825
|
autoCorrect: "off",
|
|
821
826
|
autoCapitalize: "none",
|
|
822
827
|
inputMode: "text",
|
|
823
|
-
className: Q(
|
|
824
|
-
}), /* @__PURE__ */
|
|
825
|
-
className: Q(
|
|
828
|
+
className: Q(a, "transition-opacity duration-200", !e && "opacity-0")
|
|
829
|
+
}), /* @__PURE__ */ k("span", {
|
|
830
|
+
className: Q(c, "transition-opacity duration-150", e && "opacity-0"),
|
|
826
831
|
"aria-hidden": !0,
|
|
827
832
|
children: z
|
|
828
833
|
})]
|
|
829
834
|
}),
|
|
830
|
-
/* @__PURE__ */
|
|
831
|
-
className:
|
|
832
|
-
children: [e && /* @__PURE__ */
|
|
835
|
+
/* @__PURE__ */ A("div", {
|
|
836
|
+
className: h,
|
|
837
|
+
children: [e && /* @__PURE__ */ A(O, { children: [/* @__PURE__ */ k(V.If, {
|
|
833
838
|
dictation: !1,
|
|
834
|
-
children: /* @__PURE__ */
|
|
839
|
+
children: /* @__PURE__ */ k(V.Dictate, {
|
|
835
840
|
"aria-label": "Start dictation",
|
|
836
841
|
className: "ai-chat-icon-btn flex h-11 w-11 flex-shrink-0 items-center justify-center rounded-full transition-colors active:scale-95",
|
|
837
|
-
children: /* @__PURE__ */
|
|
842
|
+
children: /* @__PURE__ */ k(I, { className: "h-5 w-5" })
|
|
838
843
|
})
|
|
839
|
-
}), /* @__PURE__ */
|
|
844
|
+
}), /* @__PURE__ */ k(V.If, {
|
|
840
845
|
dictation: !0,
|
|
841
|
-
children: /* @__PURE__ */
|
|
846
|
+
children: /* @__PURE__ */ k(V.StopDictation, {
|
|
842
847
|
"aria-label": "Stop dictation",
|
|
843
848
|
className: "flex h-11 w-11 flex-shrink-0 animate-pulse items-center justify-center rounded-full bg-red-500/15 text-red-500 transition-colors hover:bg-red-500/25",
|
|
844
|
-
children: /* @__PURE__ */
|
|
849
|
+
children: /* @__PURE__ */ k(R, { className: "h-4 w-4 fill-current" })
|
|
845
850
|
})
|
|
846
|
-
})] }), e ? y ? /* @__PURE__ */
|
|
851
|
+
})] }), e ? y ? /* @__PURE__ */ k("button", {
|
|
847
852
|
type: "button",
|
|
848
853
|
onClick: () => _.thread.cancelRun(),
|
|
849
854
|
"aria-label": "Stop generating",
|
|
850
|
-
className:
|
|
851
|
-
style:
|
|
852
|
-
children: /* @__PURE__ */
|
|
853
|
-
}) : /* @__PURE__ */
|
|
855
|
+
className: n,
|
|
856
|
+
style: f,
|
|
857
|
+
children: /* @__PURE__ */ k(R, { className: "h-4 w-4 fill-current" })
|
|
858
|
+
}) : /* @__PURE__ */ k(V.Send, {
|
|
854
859
|
"aria-label": "Send message",
|
|
855
|
-
className: Q(
|
|
856
|
-
style:
|
|
857
|
-
children: /* @__PURE__ */
|
|
858
|
-
}) : /* @__PURE__ */
|
|
860
|
+
className: Q(n, "disabled:cursor-not-allowed disabled:opacity-40 disabled:shadow-none disabled:hover:scale-100"),
|
|
861
|
+
style: f,
|
|
862
|
+
children: /* @__PURE__ */ k(j, { className: "h-5 w-5 stroke-[2.5px]" })
|
|
863
|
+
}) : /* @__PURE__ */ k("button", {
|
|
859
864
|
type: "button",
|
|
860
|
-
onClick:
|
|
865
|
+
onClick: t,
|
|
861
866
|
"aria-label": "Open AI chat",
|
|
862
|
-
className:
|
|
863
|
-
style:
|
|
864
|
-
children: /* @__PURE__ */
|
|
867
|
+
className: n,
|
|
868
|
+
style: f,
|
|
869
|
+
children: /* @__PURE__ */ k(j, { className: "h-5 w-5 stroke-[2.5px]" })
|
|
865
870
|
})]
|
|
866
871
|
})
|
|
867
872
|
]
|
|
868
873
|
})
|
|
869
874
|
});
|
|
870
|
-
},
|
|
871
|
-
let [f, p] =
|
|
872
|
-
|
|
875
|
+
}, mt = "linear-gradient(to right, color-mix(in oklch, var(--ai-chat-thinking-1, oklch(0.65 0.15 253.81)) 40%, transparent), color-mix(in oklch, var(--ai-chat-thinking-2, oklch(0.65 0.15 17.5826)) 40%, transparent))", $ = (...e) => e.filter(Boolean).join(" "), ht = ({ workspaceId: e, siteName: t, siteLogo: n, siteIcon: r, siteSlug: i, agentId: a, apiBaseUrl: o, authHeaders: c, initialOpen: l, initialDraft: u, showBranding: d = !0 }) => {
|
|
876
|
+
let [f, p] = D(!1);
|
|
877
|
+
T(() => {
|
|
873
878
|
if (!l) return;
|
|
874
879
|
let e = requestAnimationFrame(() => p(!0));
|
|
875
880
|
return () => cancelAnimationFrame(e);
|
|
876
881
|
}, [l]);
|
|
877
|
-
let m = `kb-chat-panel-${e ?? "default"}`, h =
|
|
878
|
-
|
|
879
|
-
let v =
|
|
880
|
-
return /* @__PURE__ */
|
|
882
|
+
let m = `kb-chat-panel-${e ?? "default"}`, h = E(null), g = E(null), _ = C(() => p(!1), []);
|
|
883
|
+
lt(f, g, _), ft(f, h, _), dt(f, h);
|
|
884
|
+
let v = s(t);
|
|
885
|
+
return /* @__PURE__ */ k("div", {
|
|
881
886
|
ref: h,
|
|
882
887
|
className: $("ai-chat-launcher pointer-events-none fixed bottom-5 left-1/2 z-[60] flex -translate-x-1/2 flex-col", "ai-chat-kb-wrap", f ? "w-[min(34rem,calc(100vw-1.5rem))]" : "ai-chat-kb-wrap-closed w-[19.5rem]"),
|
|
883
|
-
children: /* @__PURE__ */
|
|
888
|
+
children: /* @__PURE__ */ k(ct, {
|
|
884
889
|
workspaceId: e,
|
|
885
890
|
siteName: t,
|
|
886
891
|
siteLogo: n,
|
|
887
|
-
agentId:
|
|
888
|
-
apiBaseUrl:
|
|
892
|
+
agentId: a,
|
|
893
|
+
apiBaseUrl: o,
|
|
889
894
|
authHeaders: c,
|
|
890
|
-
children: ({ followUps:
|
|
895
|
+
children: ({ followUps: s, onResetChat: l }) => /* @__PURE__ */ k(_t, {
|
|
891
896
|
open: f,
|
|
892
897
|
onToggle: () => p((e) => !e),
|
|
893
898
|
threadStateRef: g,
|
|
@@ -899,119 +904,119 @@ var H = ({ chips: e, onSelect: t, size: n = "comfortable", className: r, chipCla
|
|
|
899
904
|
siteSlug: i,
|
|
900
905
|
initialDraft: u,
|
|
901
906
|
showBranding: d,
|
|
902
|
-
followUps:
|
|
903
|
-
thread: /* @__PURE__ */
|
|
907
|
+
followUps: s,
|
|
908
|
+
thread: /* @__PURE__ */ k(et, {
|
|
904
909
|
workspaceId: e,
|
|
905
910
|
siteName: t,
|
|
906
911
|
siteLogo: n,
|
|
907
|
-
agentId:
|
|
908
|
-
apiBaseUrl:
|
|
912
|
+
agentId: a,
|
|
913
|
+
apiBaseUrl: o,
|
|
909
914
|
authHeaders: c,
|
|
910
|
-
followUps:
|
|
915
|
+
followUps: s,
|
|
911
916
|
hideComposer: !0
|
|
912
917
|
})
|
|
913
918
|
})
|
|
914
919
|
})
|
|
915
920
|
});
|
|
916
|
-
},
|
|
921
|
+
}, gt = [
|
|
917
922
|
"rounded-full border border-zinc-200 bg-white text-zinc-700",
|
|
918
923
|
"px-3 py-1 text-[13px] leading-snug",
|
|
919
924
|
"transition-[border-color,background-color,color,transform] duration-150 hover:border-zinc-300 hover:bg-zinc-50 hover:text-zinc-900 active:scale-95"
|
|
920
|
-
].join(" "),
|
|
921
|
-
let
|
|
922
|
-
|
|
923
|
-
isRunning:
|
|
924
|
-
cancelRun: () =>
|
|
925
|
+
].join(" "), _t = ({ open: e, onToggle: t, threadStateRef: n, onResetChat: r, askLabel: i, panelId: a, siteName: o, siteIcon: s, siteSlug: c, initialDraft: l, showBranding: u, followUps: d, thread: f }) => {
|
|
926
|
+
let p = W(), m = G((e) => e.thread.isRunning), h = G((e) => e.thread.messages.length > 0), g = ut() ? d.slice(0, 2) : d;
|
|
927
|
+
T(() => (n.current = {
|
|
928
|
+
isRunning: m,
|
|
929
|
+
cancelRun: () => p.thread.cancelRun()
|
|
925
930
|
}, () => {
|
|
926
|
-
|
|
931
|
+
n.current = null;
|
|
927
932
|
}), [
|
|
928
|
-
h,
|
|
929
933
|
m,
|
|
930
|
-
|
|
934
|
+
p,
|
|
935
|
+
n
|
|
931
936
|
]);
|
|
932
|
-
let
|
|
933
|
-
|
|
934
|
-
}, [
|
|
935
|
-
return /* @__PURE__ */
|
|
936
|
-
/* @__PURE__ */
|
|
937
|
+
let _ = C((e) => {
|
|
938
|
+
y(p.thread.composer(), e);
|
|
939
|
+
}, [p]), v = o ?? "Ask AI", b = `https://levo.so/?utm_source=${encodeURIComponent(c || "website")}&utm_term=Powered%20By%20levo.so&utm_campaign=site_agent&utm_medium=organic_site_agent`;
|
|
940
|
+
return /* @__PURE__ */ A(O, { children: [
|
|
941
|
+
/* @__PURE__ */ k("div", {
|
|
937
942
|
"aria-hidden": !0,
|
|
938
|
-
className: $("absolute inset-0",
|
|
943
|
+
className: $("absolute inset-0", e ? "pointer-events-auto" : "pointer-events-none"),
|
|
939
944
|
style: { filter: "drop-shadow(0 16px 32px rgba(0,0,0,0.16)) drop-shadow(0 2px 8px rgba(0,0,0,0.08))" },
|
|
940
|
-
children: /* @__PURE__ */
|
|
941
|
-
className: $("ai-chat-kb-surface h-full w-full p-[2px]", !
|
|
942
|
-
style: { background:
|
|
943
|
-
children: /* @__PURE__ */
|
|
945
|
+
children: /* @__PURE__ */ k("div", {
|
|
946
|
+
className: $("ai-chat-kb-surface h-full w-full p-[2px]", !e && "ai-chat-kb-surface-closed"),
|
|
947
|
+
style: { background: mt },
|
|
948
|
+
children: /* @__PURE__ */ k("div", { className: "h-full w-full rounded-t-[26px] rounded-b-[40px] bg-white" })
|
|
944
949
|
})
|
|
945
950
|
}),
|
|
946
|
-
/* @__PURE__ */
|
|
947
|
-
id:
|
|
951
|
+
/* @__PURE__ */ A("section", {
|
|
952
|
+
id: a,
|
|
948
953
|
"aria-label": "AI chat",
|
|
949
|
-
inert: !
|
|
950
|
-
className: $("relative z-10 flex min-h-0 flex-col", "ai-chat-kb-content",
|
|
954
|
+
inert: !e,
|
|
955
|
+
className: $("relative z-10 flex min-h-0 flex-col", "ai-chat-kb-content", e ? "pointer-events-auto" : "ai-chat-kb-content-closed pointer-events-none"),
|
|
951
956
|
children: [
|
|
952
|
-
/* @__PURE__ */
|
|
957
|
+
/* @__PURE__ */ A("header", {
|
|
953
958
|
className: "flex h-14 w-full shrink-0 items-center justify-between gap-2 px-4",
|
|
954
|
-
children: [/* @__PURE__ */
|
|
959
|
+
children: [/* @__PURE__ */ A("div", {
|
|
955
960
|
className: "flex min-w-0 items-center gap-2",
|
|
956
|
-
children: [
|
|
957
|
-
src:
|
|
961
|
+
children: [s ? /* @__PURE__ */ k("img", {
|
|
962
|
+
src: s,
|
|
958
963
|
alt: "",
|
|
959
964
|
className: "h-6 w-6 shrink-0 rounded-sm object-contain"
|
|
960
|
-
}) : null, /* @__PURE__ */
|
|
965
|
+
}) : null, /* @__PURE__ */ k("span", {
|
|
961
966
|
className: "truncate font-semibold text-sm text-zinc-900",
|
|
962
|
-
children:
|
|
967
|
+
children: v
|
|
963
968
|
})]
|
|
964
|
-
}), /* @__PURE__ */
|
|
969
|
+
}), /* @__PURE__ */ A("div", {
|
|
965
970
|
className: "flex flex-shrink-0 items-center gap-1",
|
|
966
|
-
children: [
|
|
971
|
+
children: [h && /* @__PURE__ */ k("button", {
|
|
967
972
|
type: "button",
|
|
968
|
-
onClick:
|
|
973
|
+
onClick: r,
|
|
969
974
|
"aria-label": "Start new chat",
|
|
970
975
|
title: "Start new chat",
|
|
971
976
|
className: "ai-chat-icon-btn flex h-8 w-8 flex-shrink-0 items-center justify-center rounded-full transition-[background-color,color,transform] duration-150 active:scale-95",
|
|
972
|
-
children: /* @__PURE__ */
|
|
973
|
-
}), /* @__PURE__ */
|
|
977
|
+
children: /* @__PURE__ */ k(F, { className: "h-4 w-4" })
|
|
978
|
+
}), /* @__PURE__ */ k("button", {
|
|
974
979
|
type: "button",
|
|
975
|
-
onClick:
|
|
980
|
+
onClick: t,
|
|
976
981
|
"aria-label": "Close AI chat",
|
|
977
982
|
className: "ai-chat-icon-btn flex h-8 w-8 flex-shrink-0 items-center justify-center rounded-full transition-[background-color,color,transform] duration-150 active:scale-95",
|
|
978
|
-
children: /* @__PURE__ */
|
|
983
|
+
children: /* @__PURE__ */ k(z, { className: "h-4 w-4" })
|
|
979
984
|
})]
|
|
980
985
|
})]
|
|
981
986
|
}),
|
|
982
|
-
/* @__PURE__ */
|
|
983
|
-
/* @__PURE__ */
|
|
987
|
+
/* @__PURE__ */ k("div", { className: "mx-4 h-px shrink-0 bg-zinc-100" }),
|
|
988
|
+
/* @__PURE__ */ k("div", {
|
|
984
989
|
className: "ai-chat-kb-thread flex max-h-[min(60vh,32rem)] min-h-0 flex-col overflow-hidden",
|
|
985
|
-
children:
|
|
990
|
+
children: f
|
|
986
991
|
}),
|
|
987
|
-
|
|
992
|
+
g.length > 0 && !m && /* @__PURE__ */ k("div", {
|
|
988
993
|
className: "shrink-0 px-4 pt-1 pb-2",
|
|
989
|
-
children: /* @__PURE__ */
|
|
990
|
-
chips:
|
|
991
|
-
onSelect:
|
|
992
|
-
chipClassName:
|
|
994
|
+
children: /* @__PURE__ */ k(K, {
|
|
995
|
+
chips: g,
|
|
996
|
+
onSelect: _,
|
|
997
|
+
chipClassName: gt
|
|
993
998
|
})
|
|
994
999
|
})
|
|
995
1000
|
]
|
|
996
1001
|
}),
|
|
997
|
-
/* @__PURE__ */
|
|
1002
|
+
/* @__PURE__ */ k("div", {
|
|
998
1003
|
className: "ai-chat-kb-pillbox pointer-events-auto relative z-20 mx-3 mt-1",
|
|
999
|
-
children: /* @__PURE__ */
|
|
1000
|
-
open:
|
|
1001
|
-
onToggle:
|
|
1002
|
-
askLabel:
|
|
1003
|
-
panelId:
|
|
1004
|
-
initialDraft:
|
|
1004
|
+
children: /* @__PURE__ */ k(pt, {
|
|
1005
|
+
open: e,
|
|
1006
|
+
onToggle: t,
|
|
1007
|
+
askLabel: i,
|
|
1008
|
+
panelId: a,
|
|
1009
|
+
initialDraft: l
|
|
1005
1010
|
})
|
|
1006
1011
|
}),
|
|
1007
|
-
|
|
1008
|
-
className: $("pointer-events-none relative z-20 grid shrink-0 transition-[grid-template-rows] duration-[450ms] ease-[cubic-bezier(0.32,0.72,0,1)]",
|
|
1009
|
-
children: /* @__PURE__ */
|
|
1012
|
+
u && /* @__PURE__ */ k("div", {
|
|
1013
|
+
className: $("pointer-events-none relative z-20 grid shrink-0 transition-[grid-template-rows] duration-[450ms] ease-[cubic-bezier(0.32,0.72,0,1)]", e ? "grid-rows-[1fr]" : "grid-rows-[0fr]"),
|
|
1014
|
+
children: /* @__PURE__ */ k("div", {
|
|
1010
1015
|
className: "overflow-hidden",
|
|
1011
|
-
children: /* @__PURE__ */
|
|
1016
|
+
children: /* @__PURE__ */ A("p", {
|
|
1012
1017
|
className: "pt-2 text-center text-[11px] text-zinc-400",
|
|
1013
|
-
children: ["Powered by ", /* @__PURE__ */
|
|
1014
|
-
href:
|
|
1018
|
+
children: ["Powered by ", /* @__PURE__ */ k("a", {
|
|
1019
|
+
href: b,
|
|
1015
1020
|
target: "_blank",
|
|
1016
1021
|
rel: "noopener noreferrer",
|
|
1017
1022
|
className: "pointer-events-auto font-medium text-zinc-500 underline-offset-2 transition-colors hover:text-zinc-700 hover:underline",
|
|
@@ -1020,8 +1025,8 @@ var H = ({ chips: e, onSelect: t, size: n = "comfortable", className: r, chipCla
|
|
|
1020
1025
|
})
|
|
1021
1026
|
})
|
|
1022
1027
|
}),
|
|
1023
|
-
/* @__PURE__ */
|
|
1028
|
+
/* @__PURE__ */ k("div", { className: "h-3" })
|
|
1024
1029
|
] });
|
|
1025
1030
|
};
|
|
1026
1031
|
//#endregion
|
|
1027
|
-
export {
|
|
1032
|
+
export { ht as KBChatWidget };
|