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