@levo-so/site-runtime 0.3.11 → 0.3.13
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-CXIsQEgj.js → KBChatWidget-DCj3mo3P.js} +280 -211
- package/{PopupBody-BI-MJqmd-DW3qWKam.js → PopupBody-BI-MJqmd-DgTQEzda.js} +1 -1
- package/{PopupRenderer-D66Gx63H-BnOmWsyj.js → PopupRenderer-D66Gx63H-Cd9xJv33.js} +1 -1
- package/blog-content.d.ts +31 -0
- package/{rich-text.js → blog-content.js} +3 -3
- package/{dist-Cl_sKk9y.js → dist-6AIgW_iB.js} +1 -1
- package/{dist-BdNHqoWi.js → dist-CEdznbFW.js} +59 -54
- package/index.d.ts +177 -11
- package/index.js +634 -534
- package/{kbChat-jqrzqmaT.js → kbChat-BIzoQwEC.js} +1 -1
- package/package.json +6 -6
- package/popups.js +1 -1
- package/styles.css +1 -1
- package/rich-text.d.ts +0 -25
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
"use client";
|
|
2
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
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
|
|
5
|
-
import { ArrowUp as
|
|
6
|
-
import { ActionBarPrimitive as
|
|
7
|
-
import { AssistantChatTransport as
|
|
8
|
-
import { MarkdownTextPrimitive as
|
|
9
|
-
import
|
|
4
|
+
import { Children as C, createContext as w, isValidElement as T, useCallback as E, useContext as D, useEffect as O, useLayoutEffect as ee, useRef as k, useState as A } from "react";
|
|
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
|
+
import { AssistantChatTransport as ie, useChatRuntime as ae } from "@assistant-ui/react-ai-sdk";
|
|
8
|
+
import { MarkdownTextPrimitive as oe } from "@assistant-ui/react-markdown";
|
|
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",
|
|
@@ -25,7 +25,7 @@ var q = ({ chips: e, onSelect: t, size: n = "comfortable", className: r, chipCla
|
|
|
25
25
|
children: e
|
|
26
26
|
}, `${n}-${e}`))
|
|
27
27
|
});
|
|
28
|
-
},
|
|
28
|
+
}, ce = ({ api: e, headers: t, credentials: n, getBody: r, getHeaders: i, onSendStart: a }) => new ie({
|
|
29
29
|
api: e,
|
|
30
30
|
headers: t,
|
|
31
31
|
credentials: n,
|
|
@@ -36,8 +36,8 @@ var q = ({ chips: e, onSelect: t, size: n = "comfortable", className: r, chipCla
|
|
|
36
36
|
...i?.(e)
|
|
37
37
|
}
|
|
38
38
|
})
|
|
39
|
-
}),
|
|
40
|
-
let t =
|
|
39
|
+
}), le = (e) => {
|
|
40
|
+
let t = k(null), n = k(null);
|
|
41
41
|
return n.current !== (e ?? null) && (n.current = e ?? null, t.current = null), {
|
|
42
42
|
conversationIdRef: t,
|
|
43
43
|
handleFinish: E(({ message: e }) => {
|
|
@@ -52,8 +52,8 @@ var q = ({ chips: e, onSelect: t, size: n = "comfortable", className: r, chipCla
|
|
|
52
52
|
t.current = null;
|
|
53
53
|
}, [])
|
|
54
54
|
};
|
|
55
|
-
},
|
|
56
|
-
let [t, n] =
|
|
55
|
+
}, ue = (e = []) => {
|
|
56
|
+
let [t, n] = A(e);
|
|
57
57
|
return {
|
|
58
58
|
followUps: t,
|
|
59
59
|
setFollowUps: n,
|
|
@@ -64,16 +64,16 @@ var q = ({ chips: e, onSelect: t, size: n = "comfortable", className: r, chipCla
|
|
|
64
64
|
return Array.isArray(t) ? (n(t.filter((e) => typeof e == "string")), !0) : !1;
|
|
65
65
|
}, [])
|
|
66
66
|
};
|
|
67
|
-
},
|
|
67
|
+
}, de = (e) => e instanceof Error && e.message.includes("intelligence.site_agent.NO_ACTIVE_AGENT"), q = w({ agentUnavailable: !1 }), fe = () => D(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__ */ x(N, { className: "h-3 w-3" }), className: i = he }) => /* @__PURE__ */ S("button", {
|
|
68
68
|
type: "button",
|
|
69
69
|
"aria-label": "Scroll to bottom",
|
|
70
70
|
onClick: e,
|
|
71
|
-
className:
|
|
71
|
+
className: pe(me, i),
|
|
72
72
|
children: [r, !n && (t ? "New messages" : "Scroll to bottom")]
|
|
73
|
-
}),
|
|
74
|
-
let [i, a] =
|
|
73
|
+
}), _e = ({ endpoint: e, headers: t, fallback: n, enabled: r = !0 }) => {
|
|
74
|
+
let [i, a] = A(null), o = t ? JSON.stringify(t) : "", s = k(t);
|
|
75
75
|
s.current = t;
|
|
76
|
-
let c =
|
|
76
|
+
let c = k(n);
|
|
77
77
|
return c.current = n, O(() => {
|
|
78
78
|
if (!r || !e) {
|
|
79
79
|
a([...c.current]);
|
|
@@ -103,10 +103,10 @@ var q = ({ chips: e, onSelect: t, size: n = "comfortable", className: r, chipCla
|
|
|
103
103
|
r,
|
|
104
104
|
o
|
|
105
105
|
]), i;
|
|
106
|
-
},
|
|
107
|
-
let a =
|
|
106
|
+
}, ve = 36, ye = 80, be = ({ viewportRef: e, isRunning: t, onRunStart: n, anchorOnRunStart: r = !0, atBottomThreshold: i }) => {
|
|
107
|
+
let a = k(!1), [o, s] = A(!0), c = k(n);
|
|
108
108
|
c.current = n;
|
|
109
|
-
let l =
|
|
109
|
+
let l = k(i);
|
|
110
110
|
return l.current = i, O(() => {
|
|
111
111
|
let n = a.current;
|
|
112
112
|
if (a.current = t, !t || n || (c.current?.(), !r)) return;
|
|
@@ -115,7 +115,7 @@ var q = ({ 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 - ve);
|
|
119
119
|
n > t.clientHeight * .3 && t.scrollTo({
|
|
120
120
|
top: n,
|
|
121
121
|
behavior: "smooth"
|
|
@@ -132,7 +132,7 @@ var q = ({ chips: e, onSelect: t, size: n = "comfortable", className: r, chipCla
|
|
|
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) ?? ye;
|
|
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 q = ({ chips: e, onSelect: t, size: n = "comfortable", className: r, chipCla
|
|
|
151
151
|
});
|
|
152
152
|
}
|
|
153
153
|
};
|
|
154
|
-
},
|
|
154
|
+
}, xe = (...e) => e.filter(Boolean).join(" "), Se = ({ onStop: e }) => /* @__PURE__ */ x("button", {
|
|
155
155
|
type: "button",
|
|
156
156
|
onClick: e,
|
|
157
157
|
"aria-label": "Stop generating",
|
|
@@ -160,36 +160,36 @@ var q = ({ 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__ */ x(
|
|
164
|
-
}),
|
|
163
|
+
children: /* @__PURE__ */ x(R, { className: "h-3.5 w-3.5 fill-current" })
|
|
164
|
+
}), Ce = () => /* @__PURE__ */ S(b, { children: [/* @__PURE__ */ x(V.If, {
|
|
165
165
|
dictation: !1,
|
|
166
|
-
children: /* @__PURE__ */ x(
|
|
166
|
+
children: /* @__PURE__ */ x(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__ */ x(
|
|
168
|
+
children: /* @__PURE__ */ x(I, { className: "h-4 w-4" })
|
|
169
169
|
})
|
|
170
|
-
}), /* @__PURE__ */ x(
|
|
170
|
+
}), /* @__PURE__ */ x(V.If, {
|
|
171
171
|
dictation: !0,
|
|
172
|
-
children: /* @__PURE__ */ x(
|
|
172
|
+
children: /* @__PURE__ */ x(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__ */ x(
|
|
174
|
+
children: /* @__PURE__ */ x(R, { className: "h-3 w-3 fill-current" })
|
|
175
175
|
})
|
|
176
|
-
})] }),
|
|
176
|
+
})] }), we = () => /* @__PURE__ */ x(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__ */ x(
|
|
184
|
-
}),
|
|
183
|
+
children: /* @__PURE__ */ x(j, { className: "h-5 w-5 stroke-[2.5px]" })
|
|
184
|
+
}), Te = ({ 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
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__ */ x(
|
|
190
|
+
children: [/* @__PURE__ */ x(V.Input, {
|
|
191
191
|
"data-ai-chat-composer": "",
|
|
192
|
-
className:
|
|
192
|
+
className: xe("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",
|
|
@@ -201,14 +201,14 @@ var q = ({ chips: e, onSelect: t, size: n = "comfortable", className: r, chipCla
|
|
|
201
201
|
onKeyDown: r
|
|
202
202
|
}), /* @__PURE__ */ S("div", {
|
|
203
203
|
className: "flex items-center justify-between px-3 pt-1 pb-2",
|
|
204
|
-
children: [/* @__PURE__ */ x(
|
|
204
|
+
children: [/* @__PURE__ */ x(Ce, {}), t ? /* @__PURE__ */ x(Se, { onStop: n }) : /* @__PURE__ */ x(we, {})]
|
|
205
205
|
})]
|
|
206
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__ */ x(
|
|
209
|
+
/* @__PURE__ */ x(V.Input, {
|
|
210
210
|
"data-ai-chat-composer": "",
|
|
211
|
-
className:
|
|
211
|
+
className: xe("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",
|
|
@@ -219,27 +219,27 @@ var q = ({ chips: e, onSelect: t, size: n = "comfortable", className: r, chipCla
|
|
|
219
219
|
onInput: (e) => _(e.currentTarget),
|
|
220
220
|
onKeyDown: r
|
|
221
221
|
}),
|
|
222
|
-
/* @__PURE__ */ x(
|
|
223
|
-
t ? /* @__PURE__ */ x(
|
|
222
|
+
/* @__PURE__ */ x(Ce, {}),
|
|
223
|
+
t ? /* @__PURE__ */ x(Se, { onStop: n }) : /* @__PURE__ */ x(we, {})
|
|
224
224
|
]
|
|
225
225
|
});
|
|
226
|
-
},
|
|
227
|
-
let s =
|
|
228
|
-
return /* @__PURE__ */ x(
|
|
226
|
+
}, Ee = "rounded-2xl border border-zinc-200 bg-zinc-100 px-3.5 py-2.5", De = "ai-chat-textarea w-full resize-none bg-transparent text-base text-zinc-900 leading-relaxed placeholder:text-zinc-500 focus:outline-none", Oe = "rounded-md px-2 py-1 text-xs text-zinc-500 transition-colors hover:bg-zinc-100", ke = "rounded-md px-2 py-1 text-xs transition-opacity hover:opacity-80", Ae = ({ autoGrowMax: e, boxClassName: n = Ee, inputClassName: r = De, cancelClassName: i = Oe, sendClassName: a = ke, sendStyle: o }) => {
|
|
227
|
+
let s = G((e) => e.thread.isRunning);
|
|
228
|
+
return /* @__PURE__ */ x(H.Root, {
|
|
229
229
|
className: "mb-4 pr-2 pl-0",
|
|
230
|
-
children: /* @__PURE__ */ S(
|
|
230
|
+
children: /* @__PURE__ */ S(V.Root, { children: [/* @__PURE__ */ x("div", {
|
|
231
231
|
className: n,
|
|
232
|
-
children: /* @__PURE__ */ x(
|
|
232
|
+
children: /* @__PURE__ */ x(V.Input, {
|
|
233
233
|
className: r,
|
|
234
234
|
rows: 1,
|
|
235
235
|
onInput: (t) => _(t.currentTarget, e)
|
|
236
236
|
})
|
|
237
237
|
}), /* @__PURE__ */ S("div", {
|
|
238
238
|
className: "mt-2 flex justify-end gap-1.5",
|
|
239
|
-
children: [/* @__PURE__ */ x(
|
|
239
|
+
children: [/* @__PURE__ */ x(V.Cancel, {
|
|
240
240
|
className: i,
|
|
241
241
|
children: "Cancel"
|
|
242
|
-
}), /* @__PURE__ */ x(
|
|
242
|
+
}), /* @__PURE__ */ x(V.Send, {
|
|
243
243
|
disabled: s,
|
|
244
244
|
className: `${a} ${t}`,
|
|
245
245
|
style: o,
|
|
@@ -247,34 +247,92 @@ var q = ({ chips: e, onSelect: t, size: n = "comfortable", className: r, chipCla
|
|
|
247
247
|
})]
|
|
248
248
|
})] })
|
|
249
249
|
});
|
|
250
|
-
},
|
|
251
|
-
let [
|
|
252
|
-
O(() => {
|
|
253
|
-
if (
|
|
254
|
-
let
|
|
255
|
-
return () => clearTimeout(
|
|
256
|
-
}, [
|
|
257
|
-
|
|
250
|
+
}, je = 1500, Me = () => {
|
|
251
|
+
let [e, t] = A("idle");
|
|
252
|
+
return O(() => {
|
|
253
|
+
if (e === "idle") return;
|
|
254
|
+
let n = setTimeout(() => t("idle"), je);
|
|
255
|
+
return () => clearTimeout(n);
|
|
256
|
+
}, [e]), {
|
|
257
|
+
state: e,
|
|
258
|
+
run: E(async (e) => {
|
|
259
|
+
try {
|
|
260
|
+
await e(), t("copied");
|
|
261
|
+
} catch {
|
|
262
|
+
t("error");
|
|
263
|
+
}
|
|
264
|
+
}, [])
|
|
265
|
+
};
|
|
266
|
+
}, Ne = {
|
|
267
|
+
idle: {
|
|
268
|
+
Icon: P,
|
|
269
|
+
label: "Copy"
|
|
270
|
+
},
|
|
271
|
+
copied: {
|
|
272
|
+
Icon: M,
|
|
273
|
+
label: "Copied",
|
|
274
|
+
tone: "text-emerald-500"
|
|
275
|
+
},
|
|
276
|
+
error: {
|
|
277
|
+
Icon: z,
|
|
278
|
+
label: "Copy failed",
|
|
279
|
+
tone: "text-rose-500"
|
|
280
|
+
}
|
|
281
|
+
}, Pe = ({ onCopy: e, idleLabel: t, className: n }) => {
|
|
282
|
+
let { state: r, run: i } = Me(), { Icon: a, label: o, tone: s } = Ne[r], c = r === "idle" ? t : o;
|
|
283
|
+
return /* @__PURE__ */ S("button", {
|
|
284
|
+
type: "button",
|
|
285
|
+
"aria-label": c,
|
|
286
|
+
onClick: () => i(e),
|
|
287
|
+
className: `${n} flex items-center gap-1.5 rounded px-2 py-0.5 text-[10px] transition-colors`,
|
|
288
|
+
children: [/* @__PURE__ */ x(a, { className: ["h-3 w-3", s].filter(Boolean).join(" ") }), /* @__PURE__ */ x("span", { children: c })]
|
|
289
|
+
});
|
|
290
|
+
}, Fe = ({ 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" }) => {
|
|
291
|
+
let { state: a, run: o } = Me(), s = G((e) => e.message), c = () => {
|
|
258
292
|
let e = s.content.filter((e) => e.type === "text").map((e) => e.text).join("");
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
}
|
|
293
|
+
return o(() => navigator.clipboard.writeText(e));
|
|
294
|
+
}, { Icon: l, label: u } = Ne[a], d = {
|
|
295
|
+
idle: e,
|
|
296
|
+
copied: t,
|
|
297
|
+
error: n
|
|
298
|
+
}[a];
|
|
265
299
|
return /* @__PURE__ */ x("button", {
|
|
266
300
|
type: "button",
|
|
267
|
-
"aria-label": u,
|
|
301
|
+
"aria-label": a === "idle" ? "Copy message" : u,
|
|
268
302
|
onClick: c,
|
|
269
|
-
className:
|
|
270
|
-
children: /* @__PURE__ */ x(
|
|
303
|
+
className: `${r} ${d}`,
|
|
304
|
+
children: /* @__PURE__ */ x(l, { className: i })
|
|
271
305
|
});
|
|
272
|
-
},
|
|
273
|
-
|
|
306
|
+
}, Ie = /^[=@]|^[+-](?![\d.,\s])/, Le = (e) => Ie.test(e) ? `'${e}` : e, Re = (e) => Le((e.innerText || e.textContent || "").replace(/\s+/g, " ").trim()), ze = (e) => Array.from(e.rows).map((e) => Array.from(e.cells).map(Re).join(" ")).join("\n"), Be = new Set([
|
|
307
|
+
"colspan",
|
|
308
|
+
"rowspan",
|
|
309
|
+
"href",
|
|
310
|
+
"title",
|
|
311
|
+
"align",
|
|
312
|
+
"scope"
|
|
313
|
+
]), Ve = (e) => {
|
|
314
|
+
let t = e.cloneNode(!0);
|
|
315
|
+
for (let e of [t, ...Array.from(t.querySelectorAll("*"))]) for (let t of Array.from(e.attributes, (e) => e.name)) Be.has(t.toLowerCase()) || e.removeAttribute(t);
|
|
316
|
+
for (let e of Array.from(t.querySelectorAll("th, td"))) Ie.test((e.textContent ?? "").trim()) && e.insertBefore(t.ownerDocument.createTextNode("'"), e.firstChild);
|
|
317
|
+
return `<meta charset="utf-8">${t.outerHTML}`;
|
|
318
|
+
}, He = async (e) => {
|
|
319
|
+
if (!e) throw Error("No table to copy");
|
|
320
|
+
let t = ze(e);
|
|
321
|
+
try {
|
|
322
|
+
if (typeof ClipboardItem > "u" || !navigator.clipboard?.write) throw Error("Rich clipboard unavailable");
|
|
323
|
+
await navigator.clipboard.write([new ClipboardItem({
|
|
324
|
+
"text/html": new Blob([Ve(e)], { type: "text/html" }),
|
|
325
|
+
"text/plain": new Blob([t], { type: "text/plain" })
|
|
326
|
+
})]);
|
|
327
|
+
} catch {
|
|
328
|
+
await navigator.clipboard.writeText(t);
|
|
329
|
+
}
|
|
330
|
+
}, Ue = ({ children: e }) => {
|
|
331
|
+
let t = "plaintext", n = "";
|
|
274
332
|
return C.forEach(e, (e) => {
|
|
275
333
|
if (T(e)) {
|
|
276
|
-
let
|
|
277
|
-
|
|
334
|
+
let r = e.props, i = /language-(\w+)/.exec(r.className ?? "");
|
|
335
|
+
i && (t = i[1] ?? t), typeof r.children == "string" && (n = r.children.trim());
|
|
278
336
|
}
|
|
279
337
|
}), /* @__PURE__ */ S("div", {
|
|
280
338
|
className: "ai-chat-code not-prose my-4 overflow-hidden rounded-xl border",
|
|
@@ -282,38 +340,49 @@ var q = ({ chips: e, onSelect: t, size: n = "comfortable", className: r, chipCla
|
|
|
282
340
|
className: "ai-chat-code__header flex items-center justify-between px-4 py-2",
|
|
283
341
|
children: [/* @__PURE__ */ x("span", {
|
|
284
342
|
className: "ai-chat-code__label font-mono text-[10px] uppercase tracking-widest",
|
|
285
|
-
children:
|
|
286
|
-
}), /* @__PURE__ */ x(
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
}).catch(() => {}),
|
|
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__ */ 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" })] })
|
|
343
|
+
children: t
|
|
344
|
+
}), /* @__PURE__ */ x(Pe, {
|
|
345
|
+
idleLabel: "Copy",
|
|
346
|
+
onCopy: () => navigator.clipboard.writeText(n),
|
|
347
|
+
className: "ai-chat-code__copy"
|
|
293
348
|
})]
|
|
294
349
|
}), /* @__PURE__ */ x("pre", {
|
|
295
350
|
className: "ai-chat-code__pre overflow-x-auto px-4 py-4 font-mono text-sm leading-relaxed",
|
|
296
351
|
children: e
|
|
297
352
|
})]
|
|
298
353
|
});
|
|
299
|
-
},
|
|
354
|
+
}, We = (e) => /* @__PURE__ */ x("a", {
|
|
300
355
|
...e,
|
|
301
356
|
target: "_blank",
|
|
302
357
|
rel: "noopener noreferrer"
|
|
303
|
-
}),
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
358
|
+
}), Ge = ({ className: e, ...t }) => {
|
|
359
|
+
let n = k(null);
|
|
360
|
+
return /* @__PURE__ */ S("div", {
|
|
361
|
+
className: "w-full",
|
|
362
|
+
children: [/* @__PURE__ */ x("div", {
|
|
363
|
+
className: "not-prose mb-1 flex justify-end",
|
|
364
|
+
children: /* @__PURE__ */ x(Pe, {
|
|
365
|
+
idleLabel: "Copy table",
|
|
366
|
+
onCopy: () => He(n.current),
|
|
367
|
+
className: "ai-chat-table__copy"
|
|
368
|
+
})
|
|
369
|
+
}), /* @__PURE__ */ x("div", {
|
|
370
|
+
className: "w-full max-w-full overflow-x-auto",
|
|
371
|
+
children: /* @__PURE__ */ x("table", {
|
|
372
|
+
...t,
|
|
373
|
+
ref: n,
|
|
374
|
+
className: ["w-max min-w-full [&_td]:max-w-[20rem] [&_th]:max-w-[20rem]", e].filter(Boolean).join(" ")
|
|
375
|
+
})
|
|
376
|
+
})]
|
|
377
|
+
});
|
|
378
|
+
}, Ke = () => /* @__PURE__ */ x(oe, {
|
|
379
|
+
remarkPlugins: [se],
|
|
311
380
|
components: {
|
|
312
|
-
pre:
|
|
313
|
-
a:
|
|
314
|
-
table:
|
|
381
|
+
pre: Ue,
|
|
382
|
+
a: We,
|
|
383
|
+
table: Ge
|
|
315
384
|
}
|
|
316
|
-
}),
|
|
385
|
+
}), qe = [
|
|
317
386
|
"Thinking",
|
|
318
387
|
"Pondering",
|
|
319
388
|
"Drafting",
|
|
@@ -327,11 +396,11 @@ var q = ({ chips: e, onSelect: t, size: n = "comfortable", className: r, chipCla
|
|
|
327
396
|
"Untangling",
|
|
328
397
|
"Threading the needle",
|
|
329
398
|
"Lining up ideas"
|
|
330
|
-
],
|
|
399
|
+
], Je = (e) => {
|
|
331
400
|
let t = Math.floor(e / 60), n = e % 60;
|
|
332
401
|
return t > 0 ? `${t}m ${n.toString().padStart(2, "0")}s` : `${n}s`;
|
|
333
|
-
},
|
|
334
|
-
let [a, o] =
|
|
402
|
+
}, Ye = ({ phrases: e = qe, 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" }) => {
|
|
403
|
+
let [a, o] = A(() => e.length > 0 ? Math.floor(Math.random() * e.length) : 0), [s, c] = A(0);
|
|
335
404
|
O(() => {
|
|
336
405
|
let t = e.length > 0 ? setInterval(() => {
|
|
337
406
|
o((t) => (t + 1) % e.length);
|
|
@@ -369,21 +438,21 @@ var q = ({ chips: e, onSelect: t, size: n = "comfortable", className: r, chipCla
|
|
|
369
438
|
})]
|
|
370
439
|
}), u && /* @__PURE__ */ S("span", {
|
|
371
440
|
className: `${n} min-w-0 truncate`,
|
|
372
|
-
children: [
|
|
441
|
+
children: [Je(s), d && /* @__PURE__ */ x("span", {
|
|
373
442
|
className: r,
|
|
374
443
|
children: i
|
|
375
444
|
})]
|
|
376
445
|
})]
|
|
377
446
|
});
|
|
378
|
-
},
|
|
379
|
-
let y =
|
|
447
|
+
}, Xe = () => 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", Qe = "group pr-4 pb-6", $e = "mt-2 flex items-center gap-2 opacity-0 transition-opacity group-focus-within:opacity-100 group-hover:opacity-100", et = "text-xs text-zinc-500/60", tt = "rounded p-1.5 text-zinc-500 transition-colors hover:text-zinc-900", nt = ({ tools: t = Xe, Parts: n, thinkingIndicator: i = /* @__PURE__ */ x(Ye, {}), rootClassName: a = Qe, contentClassName: o = Ze, metaClassName: s = $e, wrapContent: c, metaSlot: l, copyIdleClassName: u, copyCopiedClassName: d, reloadClassName: f = tt, timeClassName: p = et, timeFormatOptions: m, readOnly: h = !1, belowContent: g, footerSlot: _ }) => {
|
|
448
|
+
let y = G((e) => e.message), b = e(y), C = n ?? H.Content, w = y.status?.type === "running", T = /* @__PURE__ */ x("div", {
|
|
380
449
|
className: o,
|
|
381
450
|
children: /* @__PURE__ */ x(C, { components: {
|
|
382
|
-
Text:
|
|
451
|
+
Text: Ke,
|
|
383
452
|
tools: { Fallback: t }
|
|
384
453
|
} })
|
|
385
454
|
});
|
|
386
|
-
return /* @__PURE__ */ x(
|
|
455
|
+
return /* @__PURE__ */ x(H.Root, {
|
|
387
456
|
className: a,
|
|
388
457
|
children: /* @__PURE__ */ S("div", {
|
|
389
458
|
className: "flex min-w-0 flex-col",
|
|
@@ -406,14 +475,14 @@ var q = ({ chips: e, onSelect: t, size: n = "comfortable", className: r, chipCla
|
|
|
406
475
|
children: v(b, m)
|
|
407
476
|
}),
|
|
408
477
|
l,
|
|
409
|
-
/* @__PURE__ */ S(
|
|
478
|
+
/* @__PURE__ */ S(B.Root, {
|
|
410
479
|
className: "flex items-center gap-0.5",
|
|
411
|
-
children: [/* @__PURE__ */ x(
|
|
480
|
+
children: [/* @__PURE__ */ x(Fe, {
|
|
412
481
|
idleClassName: u,
|
|
413
482
|
copiedClassName: d
|
|
414
|
-
}), !h && /* @__PURE__ */ x(
|
|
483
|
+
}), !h && /* @__PURE__ */ x(B.Reload, {
|
|
415
484
|
className: `${f} disabled:cursor-not-allowed disabled:opacity-40`,
|
|
416
|
-
children: /* @__PURE__ */ x(
|
|
485
|
+
children: /* @__PURE__ */ x(L, { className: "h-3 w-3" })
|
|
417
486
|
})]
|
|
418
487
|
})
|
|
419
488
|
]
|
|
@@ -422,16 +491,16 @@ var q = ({ chips: e, onSelect: t, size: n = "comfortable", className: r, chipCla
|
|
|
422
491
|
]
|
|
423
492
|
})
|
|
424
493
|
});
|
|
425
|
-
},
|
|
426
|
-
let p =
|
|
427
|
-
return /* @__PURE__ */ S(
|
|
494
|
+
}, rt = "group flex flex-col items-end pb-4 pl-12", it = "rounded-2xl border border-zinc-200 bg-zinc-100 px-3.5 py-2.5 text-sm text-zinc-900 leading-relaxed", at = "mt-1 flex items-center gap-2 opacity-0 transition-opacity group-focus-within:opacity-100 group-hover:opacity-100", ot = "text-xs text-zinc-500/60", st = "rounded px-2 py-1 font-medium text-xs text-zinc-500 transition-colors hover:text-zinc-900", ct = ({ attachmentsSlot: t, rootClassName: n = rt, bubbleClassName: i = it, contentSlot: a, metaClassName: o = at, timeClassName: s = ot, editClassName: c = st, copyIdleClassName: l, copyCopiedClassName: u, timeFormatOptions: d, readOnly: f = !1 }) => {
|
|
495
|
+
let p = G((e) => e.message), m = G((e) => e.thread.isRunning), h = e(p);
|
|
496
|
+
return /* @__PURE__ */ S(H.Root, {
|
|
428
497
|
className: n,
|
|
429
498
|
"data-user-message": "true",
|
|
430
499
|
children: [
|
|
431
500
|
t,
|
|
432
501
|
/* @__PURE__ */ x("div", {
|
|
433
502
|
className: i,
|
|
434
|
-
children: a ?? /* @__PURE__ */ x(
|
|
503
|
+
children: a ?? /* @__PURE__ */ x(H.Content, {})
|
|
435
504
|
}),
|
|
436
505
|
/* @__PURE__ */ S("div", {
|
|
437
506
|
className: o,
|
|
@@ -439,12 +508,12 @@ var q = ({ chips: e, onSelect: t, size: n = "comfortable", className: r, chipCla
|
|
|
439
508
|
className: s,
|
|
440
509
|
title: r(h) || void 0,
|
|
441
510
|
children: v(h, d)
|
|
442
|
-
}), /* @__PURE__ */ S(
|
|
511
|
+
}), /* @__PURE__ */ S(B.Root, {
|
|
443
512
|
className: "flex items-center gap-0.5",
|
|
444
|
-
children: [/* @__PURE__ */ x(
|
|
513
|
+
children: [/* @__PURE__ */ x(Fe, {
|
|
445
514
|
idleClassName: l,
|
|
446
515
|
copiedClassName: u
|
|
447
|
-
}), !f && /* @__PURE__ */ x(
|
|
516
|
+
}), !f && /* @__PURE__ */ x(B.Edit, {
|
|
448
517
|
disabled: m,
|
|
449
518
|
className: `${c} disabled:cursor-not-allowed disabled:opacity-40`,
|
|
450
519
|
children: "Edit"
|
|
@@ -453,33 +522,33 @@ var q = ({ chips: e, onSelect: t, size: n = "comfortable", className: r, chipCla
|
|
|
453
522
|
})
|
|
454
523
|
]
|
|
455
524
|
});
|
|
456
|
-
},
|
|
525
|
+
}, lt = () => /* @__PURE__ */ x(Ae, { sendStyle: {
|
|
457
526
|
backgroundColor: "var(--color-brand, #0a0a0a)",
|
|
458
527
|
color: "var(--color-brand-foreground, #fff)"
|
|
459
|
-
} }),
|
|
528
|
+
} }), ut = [
|
|
460
529
|
"What do you offer?",
|
|
461
530
|
"How much does it cost?",
|
|
462
531
|
"Why should I choose you?",
|
|
463
532
|
"How do I get in touch?"
|
|
464
|
-
],
|
|
533
|
+
], dt = [
|
|
465
534
|
"w-3/4",
|
|
466
535
|
"w-4/5",
|
|
467
536
|
"w-2/3",
|
|
468
537
|
"w-3/5"
|
|
469
|
-
],
|
|
470
|
-
let l =
|
|
538
|
+
], ft = ({ workspaceId: e, siteName: t, siteLogo: n, apiBaseUrl: r, authHeaders: i, agentId: a, followUps: s, hideComposer: c = !1 }) => {
|
|
539
|
+
let l = W(), u = G((e) => e.thread.isRunning), { agentUnavailable: d } = fe(), f = k(null), { isAtBottom: p, scrollToBottom: m } = be({
|
|
471
540
|
viewportRef: f,
|
|
472
541
|
isRunning: u
|
|
473
|
-
}), h =
|
|
542
|
+
}), h = _e({
|
|
474
543
|
endpoint: e ? `${r}/suggestions${a ? `?agent_id=${encodeURIComponent(a)}` : ""}` : void 0,
|
|
475
544
|
headers: e ? {
|
|
476
545
|
...o(i),
|
|
477
546
|
"Levo-Workspace": e
|
|
478
547
|
} : void 0,
|
|
479
|
-
fallback:
|
|
548
|
+
fallback: ut
|
|
480
549
|
}), g = E((e) => {
|
|
481
550
|
y(l.thread.composer(), e);
|
|
482
|
-
}, [l]), _ = E(() => l.thread.cancelRun(), [l]), v =
|
|
551
|
+
}, [l]), _ = E(() => l.thread.cancelRun(), [l]), v = k(u);
|
|
483
552
|
return O(() => {
|
|
484
553
|
v.current = u;
|
|
485
554
|
}, [u]), O(() => {
|
|
@@ -487,10 +556,10 @@ var q = ({ chips: e, onSelect: t, size: n = "comfortable", className: r, chipCla
|
|
|
487
556
|
e.key !== "Escape" || e.isComposing || !v.current || (e.preventDefault(), e.stopImmediatePropagation(), l.thread.cancelRun());
|
|
488
557
|
};
|
|
489
558
|
return window.addEventListener("keydown", e, !0), () => window.removeEventListener("keydown", e, !0);
|
|
490
|
-
}, [l]), /* @__PURE__ */ S(
|
|
559
|
+
}, [l]), /* @__PURE__ */ S(U.Root, {
|
|
491
560
|
className: "relative flex flex-1 flex-col overflow-hidden",
|
|
492
561
|
children: [
|
|
493
|
-
/* @__PURE__ */ x(
|
|
562
|
+
/* @__PURE__ */ x(U.If, {
|
|
494
563
|
empty: !0,
|
|
495
564
|
children: /* @__PURE__ */ x("div", {
|
|
496
565
|
className: "pointer-events-none absolute inset-0 z-0 overflow-hidden",
|
|
@@ -505,7 +574,7 @@ var q = ({ chips: e, onSelect: t, size: n = "comfortable", className: r, chipCla
|
|
|
505
574
|
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
575
|
children: "This conversation is no longer available. Please refresh the page to start a new chat."
|
|
507
576
|
}),
|
|
508
|
-
/* @__PURE__ */ S(
|
|
577
|
+
/* @__PURE__ */ S(U.Viewport, {
|
|
509
578
|
ref: f,
|
|
510
579
|
turnAnchor: "top",
|
|
511
580
|
className: "relative z-10 flex-1 overflow-y-auto",
|
|
@@ -513,7 +582,7 @@ var q = ({ chips: e, onSelect: t, size: n = "comfortable", className: r, chipCla
|
|
|
513
582
|
scrollToBottomOnRunStart: !1,
|
|
514
583
|
scrollToBottomOnInitialize: !1,
|
|
515
584
|
scrollToBottomOnThreadSwitch: !1,
|
|
516
|
-
children: [/* @__PURE__ */ x(
|
|
585
|
+
children: [/* @__PURE__ */ x(U.Empty, { children: /* @__PURE__ */ S("div", {
|
|
517
586
|
className: "flex min-h-full flex-col items-center justify-center px-6 py-6",
|
|
518
587
|
children: [/* @__PURE__ */ S("div", {
|
|
519
588
|
className: "mb-5 flex flex-col items-center gap-2 text-center",
|
|
@@ -542,7 +611,7 @@ var q = ({ chips: e, onSelect: t, size: n = "comfortable", className: r, chipCla
|
|
|
542
611
|
]
|
|
543
612
|
}), /* @__PURE__ */ x("div", {
|
|
544
613
|
className: "flex w-full max-w-md flex-col gap-2",
|
|
545
|
-
children: h === null ?
|
|
614
|
+
children: h === null ? dt.map((e, t) => /* @__PURE__ */ x("div", {
|
|
546
615
|
className: "flex h-[42px] items-center rounded-xl border border-zinc-200 bg-white px-4",
|
|
547
616
|
children: /* @__PURE__ */ x("span", { className: `block h-3 animate-pulse rounded bg-zinc-200 ${e}` })
|
|
548
617
|
}, `skeleton-${t}`)) : h.map((e, t) => /* @__PURE__ */ x("button", {
|
|
@@ -553,14 +622,14 @@ var q = ({ chips: e, onSelect: t, size: n = "comfortable", className: r, chipCla
|
|
|
553
622
|
children: e
|
|
554
623
|
}, e))
|
|
555
624
|
})]
|
|
556
|
-
}) }), /* @__PURE__ */ x(
|
|
625
|
+
}) }), /* @__PURE__ */ x(U.If, {
|
|
557
626
|
empty: !1,
|
|
558
627
|
children: /* @__PURE__ */ x("div", {
|
|
559
628
|
className: "ai-chat-kb-messages mx-auto max-w-3xl px-6 py-6 pt-8",
|
|
560
|
-
children: /* @__PURE__ */ x(
|
|
561
|
-
UserMessage:
|
|
562
|
-
AssistantMessage:
|
|
563
|
-
EditComposer:
|
|
629
|
+
children: /* @__PURE__ */ x(U.Messages, { components: {
|
|
630
|
+
UserMessage: ct,
|
|
631
|
+
AssistantMessage: nt,
|
|
632
|
+
EditComposer: lt
|
|
564
633
|
} })
|
|
565
634
|
})
|
|
566
635
|
})]
|
|
@@ -572,7 +641,7 @@ var q = ({ chips: e, onSelect: t, size: n = "comfortable", className: r, chipCla
|
|
|
572
641
|
children: [
|
|
573
642
|
!p && /* @__PURE__ */ x("div", {
|
|
574
643
|
className: "pointer-events-none absolute inset-x-0 -top-9 z-20 flex justify-center",
|
|
575
|
-
children: /* @__PURE__ */ x(
|
|
644
|
+
children: /* @__PURE__ */ x(ge, {
|
|
576
645
|
onClick: m,
|
|
577
646
|
isRunning: u,
|
|
578
647
|
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"
|
|
@@ -580,30 +649,30 @@ var q = ({ chips: e, onSelect: t, size: n = "comfortable", className: r, chipCla
|
|
|
580
649
|
}),
|
|
581
650
|
s.length > 0 && !u && /* @__PURE__ */ x("div", {
|
|
582
651
|
className: "mb-2",
|
|
583
|
-
children: /* @__PURE__ */ x(
|
|
652
|
+
children: /* @__PURE__ */ x(K, {
|
|
584
653
|
chips: s,
|
|
585
654
|
onSelect: g,
|
|
586
655
|
size: "compact"
|
|
587
656
|
})
|
|
588
657
|
}),
|
|
589
|
-
/* @__PURE__ */ S(
|
|
590
|
-
/* @__PURE__ */ x(
|
|
658
|
+
/* @__PURE__ */ S(V.Root, { children: [
|
|
659
|
+
/* @__PURE__ */ x(U.If, {
|
|
591
660
|
empty: !0,
|
|
592
|
-
children: /* @__PURE__ */ x(
|
|
661
|
+
children: /* @__PURE__ */ x(Te, {
|
|
593
662
|
variant: "expanded",
|
|
594
663
|
isRunning: u,
|
|
595
664
|
onStop: _
|
|
596
665
|
})
|
|
597
666
|
}),
|
|
598
|
-
/* @__PURE__ */ x(
|
|
667
|
+
/* @__PURE__ */ x(U.If, {
|
|
599
668
|
empty: !1,
|
|
600
|
-
children: /* @__PURE__ */ x(
|
|
669
|
+
children: /* @__PURE__ */ x(Te, {
|
|
601
670
|
variant: "compact",
|
|
602
671
|
isRunning: u,
|
|
603
672
|
onStop: _
|
|
604
673
|
})
|
|
605
674
|
}),
|
|
606
|
-
/* @__PURE__ */ x(
|
|
675
|
+
/* @__PURE__ */ x(V.If, {
|
|
607
676
|
dictation: !0,
|
|
608
677
|
children: /* @__PURE__ */ S("div", {
|
|
609
678
|
className: "mt-2 flex items-center justify-center gap-2",
|
|
@@ -614,7 +683,7 @@ var q = ({ chips: e, onSelect: t, size: n = "comfortable", className: r, chipCla
|
|
|
614
683
|
})
|
|
615
684
|
})
|
|
616
685
|
] }),
|
|
617
|
-
/* @__PURE__ */ x(
|
|
686
|
+
/* @__PURE__ */ x(U.If, {
|
|
618
687
|
empty: !1,
|
|
619
688
|
children: /* @__PURE__ */ x("p", {
|
|
620
689
|
className: "mt-2 text-center text-[10px] text-zinc-500/70",
|
|
@@ -626,33 +695,33 @@ var q = ({ chips: e, onSelect: t, size: n = "comfortable", className: r, chipCla
|
|
|
626
695
|
})
|
|
627
696
|
]
|
|
628
697
|
});
|
|
629
|
-
},
|
|
698
|
+
}, J = 4096, pt = 400, mt = 300, ht = 2e3, gt = (e) => document.querySelector(e)?.content?.trim() || void 0, _t = (e) => {
|
|
630
699
|
for (let t of e) {
|
|
631
|
-
let e =
|
|
700
|
+
let e = gt(t);
|
|
632
701
|
if (e) return e;
|
|
633
702
|
}
|
|
634
|
-
},
|
|
703
|
+
}, vt = (e, t) => e.length > t ? `${e.slice(0, t - 1).trimEnd()}…` : e, Y = (e) => JSON.stringify(e).length, yt = () => {
|
|
635
704
|
if (typeof window > "u" || typeof document > "u") return;
|
|
636
705
|
let e = {}, t = window.location?.href;
|
|
637
706
|
t && (e.url = t);
|
|
638
|
-
let n = document.title?.trim() ||
|
|
639
|
-
n && (e.page_title =
|
|
640
|
-
let r =
|
|
707
|
+
let n = document.title?.trim() || _t(["meta[property=\"og:title\"]", "meta[name=\"twitter:title\"]"]);
|
|
708
|
+
n && (e.page_title = vt(n, mt));
|
|
709
|
+
let r = _t([
|
|
641
710
|
"meta[name=\"description\"]",
|
|
642
711
|
"meta[property=\"og:description\"]",
|
|
643
712
|
"meta[name=\"twitter:description\"]"
|
|
644
713
|
]);
|
|
645
|
-
r && (e.description =
|
|
714
|
+
r && (e.description = vt(r, pt));
|
|
646
715
|
let i = document.referrer?.trim();
|
|
647
|
-
if (i && (e.referrer = i), Object.keys(e).length !== 0) return e.description &&
|
|
648
|
-
},
|
|
649
|
-
let c =
|
|
716
|
+
if (i && (e.referrer = i), Object.keys(e).length !== 0) return e.description && Y(e) > J && delete e.description, e.referrer && Y(e) > J && delete e.referrer, e.url && Y(e) > J && (e.url = e.url.slice(0, ht)), e;
|
|
717
|
+
}, bt = ({ workspaceId: e, siteName: t, siteLogo: n, agentId: r, apiBaseUrl: i, authHeaders: a, children: s }) => {
|
|
718
|
+
let c = k(e);
|
|
650
719
|
c.current = e;
|
|
651
|
-
let l =
|
|
720
|
+
let l = k(r);
|
|
652
721
|
l.current = r;
|
|
653
|
-
let { followUps: u, clearOnSend: d, handleData: f } =
|
|
722
|
+
let { followUps: u, clearOnSend: d, handleData: f } = ue(), [p, m] = A(!1), { conversationIdRef: h, handleFinish: g, reset: _ } = le(e), v = ae({
|
|
654
723
|
joinStrategy: "none",
|
|
655
|
-
transport:
|
|
724
|
+
transport: ce({
|
|
656
725
|
api: `${i}/stream`,
|
|
657
726
|
credentials: "include",
|
|
658
727
|
onSendStart: () => {
|
|
@@ -668,15 +737,15 @@ var q = ({ chips: e, onSelect: t, size: n = "comfortable", className: r, chipCla
|
|
|
668
737
|
workspace_id: c.current
|
|
669
738
|
};
|
|
670
739
|
h.current && (t.conversation_id = h.current), l.current && (t.agent_id = l.current);
|
|
671
|
-
let n =
|
|
740
|
+
let n = yt();
|
|
672
741
|
return n && (t.context = n), t;
|
|
673
742
|
}
|
|
674
743
|
}),
|
|
675
|
-
adapters: { dictation: new
|
|
744
|
+
adapters: { dictation: new re({ interimResults: !1 }) },
|
|
676
745
|
onData: f,
|
|
677
746
|
onFinish: g,
|
|
678
747
|
onError: (e) => {
|
|
679
|
-
|
|
748
|
+
de(e) ? m(!0) : console.warn("[levo-kb-chat] stream error:", e);
|
|
680
749
|
}
|
|
681
750
|
}), y = E(() => {
|
|
682
751
|
v.threads.switchToNewThread().catch((e) => {
|
|
@@ -687,14 +756,14 @@ var q = ({ chips: e, onSelect: t, size: n = "comfortable", className: r, chipCla
|
|
|
687
756
|
_,
|
|
688
757
|
d
|
|
689
758
|
]);
|
|
690
|
-
return /* @__PURE__ */ x(
|
|
759
|
+
return /* @__PURE__ */ x(ne, {
|
|
691
760
|
runtime: v,
|
|
692
|
-
children: /* @__PURE__ */ x(
|
|
761
|
+
children: /* @__PURE__ */ x(q.Provider, {
|
|
693
762
|
value: { agentUnavailable: p },
|
|
694
763
|
children: s ? s({
|
|
695
764
|
followUps: u,
|
|
696
765
|
onResetChat: y
|
|
697
|
-
}) : /* @__PURE__ */ x(
|
|
766
|
+
}) : /* @__PURE__ */ x(ft, {
|
|
698
767
|
workspaceId: e,
|
|
699
768
|
siteName: t,
|
|
700
769
|
siteLogo: n,
|
|
@@ -705,7 +774,7 @@ var q = ({ chips: e, onSelect: t, size: n = "comfortable", className: r, chipCla
|
|
|
705
774
|
})
|
|
706
775
|
})
|
|
707
776
|
});
|
|
708
|
-
},
|
|
777
|
+
}, xt = (e, t, n) => {
|
|
709
778
|
O(() => {
|
|
710
779
|
if (!e) return;
|
|
711
780
|
let r = (e) => {
|
|
@@ -723,16 +792,16 @@ var q = ({ chips: e, onSelect: t, size: n = "comfortable", className: r, chipCla
|
|
|
723
792
|
t,
|
|
724
793
|
n
|
|
725
794
|
]);
|
|
726
|
-
},
|
|
727
|
-
let [e, t] =
|
|
795
|
+
}, X = "(max-width: 639px)", Z = () => {
|
|
796
|
+
let [e, t] = A(() => typeof window < "u" && window.matchMedia(X).matches);
|
|
728
797
|
return O(() => {
|
|
729
|
-
let e = window.matchMedia(
|
|
798
|
+
let e = window.matchMedia(X), n = () => t(e.matches);
|
|
730
799
|
return n(), e.addEventListener("change", n), () => e.removeEventListener("change", n);
|
|
731
800
|
}, []), e;
|
|
732
|
-
},
|
|
801
|
+
}, St = (e, t) => {
|
|
733
802
|
O(() => {
|
|
734
803
|
let n = t.current, r = window.visualViewport;
|
|
735
|
-
if (!e || !n || !r || !window.matchMedia(
|
|
804
|
+
if (!e || !n || !r || !window.matchMedia(X).matches) return;
|
|
736
805
|
let i = () => {
|
|
737
806
|
n.style.setProperty("--ai-vv-top", `${r.offsetTop}px`), n.style.setProperty("--ai-vv-height", `${r.height}px`);
|
|
738
807
|
};
|
|
@@ -740,7 +809,7 @@ var q = ({ chips: e, onSelect: t, size: n = "comfortable", className: r, chipCla
|
|
|
740
809
|
r.removeEventListener("resize", i), r.removeEventListener("scroll", i), n.style.removeProperty("--ai-vv-top"), n.style.removeProperty("--ai-vv-height");
|
|
741
810
|
};
|
|
742
811
|
}, [e, t]);
|
|
743
|
-
},
|
|
812
|
+
}, Ct = (e, t, n) => {
|
|
744
813
|
O(() => {
|
|
745
814
|
if (!e) return;
|
|
746
815
|
let r = (e) => {
|
|
@@ -753,17 +822,17 @@ var q = ({ chips: e, onSelect: t, size: n = "comfortable", className: r, chipCla
|
|
|
753
822
|
t,
|
|
754
823
|
n
|
|
755
824
|
]);
|
|
756
|
-
}, Q = (...e) => e.filter(Boolean).join(" "),
|
|
757
|
-
let _ =
|
|
825
|
+
}, Q = (...e) => e.filter(Boolean).join(" "), wt = ({ open: e, onToggle: t, askLabel: r, panelId: o, initialDraft: s }) => {
|
|
826
|
+
let _ = W(), v = Z(), y = G((e) => e.thread.isRunning), C = G((e) => e.thread.messages.length > 0), w = G((e) => e.composer.text), T = w.trim().length > 0, [E, D] = A(!1);
|
|
758
827
|
O(() => {
|
|
759
828
|
s && _.thread.composer().setText(s);
|
|
760
829
|
}, []);
|
|
761
|
-
let
|
|
762
|
-
|
|
763
|
-
let e =
|
|
764
|
-
!e || document.activeElement === e || (
|
|
765
|
-
}, []),
|
|
766
|
-
let t =
|
|
830
|
+
let M = k(null), N = k(null), P = k(!1);
|
|
831
|
+
ee(() => {
|
|
832
|
+
let e = M.current;
|
|
833
|
+
!e || document.activeElement === e || (P.current = !0, e.focus({ preventScroll: !0 }));
|
|
834
|
+
}, []), ee(() => {
|
|
835
|
+
let t = M.current, n = N.current;
|
|
767
836
|
if (!(!t || !n)) {
|
|
768
837
|
if (!e) {
|
|
769
838
|
t.style.height = "", D(!1);
|
|
@@ -772,23 +841,23 @@ var q = ({ chips: e, onSelect: t, size: n = "comfortable", className: r, chipCla
|
|
|
772
841
|
D(u(n, t));
|
|
773
842
|
}
|
|
774
843
|
}, [w, e]);
|
|
775
|
-
let
|
|
844
|
+
let F = k(e);
|
|
776
845
|
O(() => {
|
|
777
|
-
let t =
|
|
778
|
-
|
|
779
|
-
let n =
|
|
846
|
+
let t = F.current;
|
|
847
|
+
F.current = e;
|
|
848
|
+
let n = M.current;
|
|
780
849
|
e || !t || !n || document.activeElement === n && n.blur();
|
|
781
850
|
}, [e]);
|
|
782
|
-
let
|
|
851
|
+
let L = k(y);
|
|
783
852
|
O(() => {
|
|
784
|
-
let e = !
|
|
785
|
-
|
|
853
|
+
let e = !L.current && y;
|
|
854
|
+
L.current = y, v && e && M.current?.blur();
|
|
786
855
|
}, [y, v]);
|
|
787
|
-
let
|
|
856
|
+
let z = C ? "Continue conversation" : r;
|
|
788
857
|
return /* @__PURE__ */ x("div", {
|
|
789
858
|
className: Q(d, e ? m : i),
|
|
790
859
|
children: /* @__PURE__ */ S("div", {
|
|
791
|
-
ref:
|
|
860
|
+
ref: N,
|
|
792
861
|
className: Q(g, E && "ai-chat-pill-surface--stacked"),
|
|
793
862
|
children: [
|
|
794
863
|
/* @__PURE__ */ x("button", {
|
|
@@ -798,17 +867,17 @@ var q = ({ chips: e, onSelect: t, size: n = "comfortable", className: r, chipCla
|
|
|
798
867
|
"aria-expanded": e,
|
|
799
868
|
"aria-controls": o,
|
|
800
869
|
className: l,
|
|
801
|
-
children: /* @__PURE__ */ x(
|
|
870
|
+
children: /* @__PURE__ */ x(te, { className: "h-5 w-5" })
|
|
802
871
|
}),
|
|
803
872
|
/* @__PURE__ */ S("div", {
|
|
804
873
|
className: p,
|
|
805
|
-
children: [/* @__PURE__ */ x(
|
|
806
|
-
ref:
|
|
874
|
+
children: [/* @__PURE__ */ x(V.Input, {
|
|
875
|
+
ref: M,
|
|
807
876
|
"data-ai-chat-composer": "",
|
|
808
877
|
placeholder: e ? "Ask anything…" : "",
|
|
809
878
|
onFocus: () => {
|
|
810
|
-
if (
|
|
811
|
-
|
|
879
|
+
if (P.current) {
|
|
880
|
+
P.current = !1;
|
|
812
881
|
return;
|
|
813
882
|
}
|
|
814
883
|
e || t();
|
|
@@ -829,24 +898,24 @@ var q = ({ chips: e, onSelect: t, size: n = "comfortable", className: r, chipCla
|
|
|
829
898
|
}), /* @__PURE__ */ x("span", {
|
|
830
899
|
className: Q(c, "transition-opacity duration-150", e && "opacity-0"),
|
|
831
900
|
"aria-hidden": !0,
|
|
832
|
-
children:
|
|
901
|
+
children: z
|
|
833
902
|
})]
|
|
834
903
|
}),
|
|
835
904
|
/* @__PURE__ */ S("div", {
|
|
836
905
|
className: h,
|
|
837
|
-
children: [e && /* @__PURE__ */ S(b, { children: [/* @__PURE__ */ x(
|
|
906
|
+
children: [e && /* @__PURE__ */ S(b, { children: [/* @__PURE__ */ x(V.If, {
|
|
838
907
|
dictation: !1,
|
|
839
|
-
children: /* @__PURE__ */ x(
|
|
908
|
+
children: /* @__PURE__ */ x(V.Dictate, {
|
|
840
909
|
"aria-label": "Start dictation",
|
|
841
910
|
className: "ai-chat-icon-btn flex h-11 w-11 flex-shrink-0 items-center justify-center rounded-full transition-colors active:scale-95",
|
|
842
|
-
children: /* @__PURE__ */ x(
|
|
911
|
+
children: /* @__PURE__ */ x(I, { className: "h-5 w-5" })
|
|
843
912
|
})
|
|
844
|
-
}), /* @__PURE__ */ x(
|
|
913
|
+
}), /* @__PURE__ */ x(V.If, {
|
|
845
914
|
dictation: !0,
|
|
846
|
-
children: /* @__PURE__ */ x(
|
|
915
|
+
children: /* @__PURE__ */ x(V.StopDictation, {
|
|
847
916
|
"aria-label": "Stop dictation",
|
|
848
917
|
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",
|
|
849
|
-
children: /* @__PURE__ */ x(
|
|
918
|
+
children: /* @__PURE__ */ x(R, { className: "h-4 w-4 fill-current" })
|
|
850
919
|
})
|
|
851
920
|
})] }), e ? y ? /* @__PURE__ */ x("button", {
|
|
852
921
|
type: "button",
|
|
@@ -854,45 +923,45 @@ var q = ({ chips: e, onSelect: t, size: n = "comfortable", className: r, chipCla
|
|
|
854
923
|
"aria-label": "Stop generating",
|
|
855
924
|
className: n,
|
|
856
925
|
style: f,
|
|
857
|
-
children: /* @__PURE__ */ x(
|
|
858
|
-
}) : /* @__PURE__ */ x(
|
|
926
|
+
children: /* @__PURE__ */ x(R, { className: "h-4 w-4 fill-current" })
|
|
927
|
+
}) : /* @__PURE__ */ x(V.Send, {
|
|
859
928
|
"aria-label": "Send message",
|
|
860
929
|
className: Q(n, "disabled:cursor-not-allowed disabled:opacity-40 disabled:shadow-none disabled:hover:scale-100"),
|
|
861
930
|
style: f,
|
|
862
|
-
children: /* @__PURE__ */ x(
|
|
931
|
+
children: /* @__PURE__ */ x(j, { className: "h-5 w-5 stroke-[2.5px]" })
|
|
863
932
|
}) : /* @__PURE__ */ x("button", {
|
|
864
933
|
type: "button",
|
|
865
934
|
onClick: t,
|
|
866
935
|
"aria-label": "Open AI chat",
|
|
867
936
|
className: n,
|
|
868
937
|
style: f,
|
|
869
|
-
children: /* @__PURE__ */ x(
|
|
938
|
+
children: /* @__PURE__ */ x(j, { className: "h-5 w-5 stroke-[2.5px]" })
|
|
870
939
|
})]
|
|
871
940
|
})
|
|
872
941
|
]
|
|
873
942
|
})
|
|
874
943
|
});
|
|
875
|
-
},
|
|
876
|
-
let [f, p] =
|
|
944
|
+
}, Tt = "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(" "), Et = ({ workspaceId: e, siteName: t, siteLogo: n, siteIcon: r, siteSlug: i, agentId: a, apiBaseUrl: o, authHeaders: c, initialOpen: l, initialDraft: u, showBranding: d = !0 }) => {
|
|
945
|
+
let [f, p] = A(!1);
|
|
877
946
|
O(() => {
|
|
878
947
|
if (!l) return;
|
|
879
948
|
let e = requestAnimationFrame(() => p(!0));
|
|
880
949
|
return () => cancelAnimationFrame(e);
|
|
881
950
|
}, [l]);
|
|
882
|
-
let m = `kb-chat-panel-${e ?? "default"}`, h =
|
|
883
|
-
|
|
951
|
+
let m = `kb-chat-panel-${e ?? "default"}`, h = k(null), g = k(null), _ = E(() => p(!1), []);
|
|
952
|
+
xt(f, g, _), Ct(f, h, _), St(f, h);
|
|
884
953
|
let v = s(t);
|
|
885
954
|
return /* @__PURE__ */ x("div", {
|
|
886
955
|
ref: h,
|
|
887
956
|
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]"),
|
|
888
|
-
children: /* @__PURE__ */ x(
|
|
957
|
+
children: /* @__PURE__ */ x(bt, {
|
|
889
958
|
workspaceId: e,
|
|
890
959
|
siteName: t,
|
|
891
960
|
siteLogo: n,
|
|
892
961
|
agentId: a,
|
|
893
962
|
apiBaseUrl: o,
|
|
894
963
|
authHeaders: c,
|
|
895
|
-
children: ({ followUps: s, onResetChat: l }) => /* @__PURE__ */ x(
|
|
964
|
+
children: ({ followUps: s, onResetChat: l }) => /* @__PURE__ */ x(Ot, {
|
|
896
965
|
open: f,
|
|
897
966
|
onToggle: () => p((e) => !e),
|
|
898
967
|
threadStateRef: g,
|
|
@@ -905,7 +974,7 @@ var q = ({ chips: e, onSelect: t, size: n = "comfortable", className: r, chipCla
|
|
|
905
974
|
initialDraft: u,
|
|
906
975
|
showBranding: d,
|
|
907
976
|
followUps: s,
|
|
908
|
-
thread: /* @__PURE__ */ x(
|
|
977
|
+
thread: /* @__PURE__ */ x(ft, {
|
|
909
978
|
workspaceId: e,
|
|
910
979
|
siteName: t,
|
|
911
980
|
siteLogo: n,
|
|
@@ -918,12 +987,12 @@ var q = ({ chips: e, onSelect: t, size: n = "comfortable", className: r, chipCla
|
|
|
918
987
|
})
|
|
919
988
|
})
|
|
920
989
|
});
|
|
921
|
-
},
|
|
990
|
+
}, Dt = [
|
|
922
991
|
"rounded-full border border-zinc-200 bg-white text-zinc-700",
|
|
923
992
|
"px-3 py-1 text-[13px] leading-snug",
|
|
924
993
|
"transition-[border-color,background-color,color,transform] duration-150 hover:border-zinc-300 hover:bg-zinc-50 hover:text-zinc-900 active:scale-95"
|
|
925
|
-
].join(" "),
|
|
926
|
-
let p =
|
|
994
|
+
].join(" "), Ot = ({ 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 }) => {
|
|
995
|
+
let p = W(), m = G((e) => e.thread.isRunning), h = G((e) => e.thread.messages.length > 0), g = Z() ? d.slice(0, 2) : d;
|
|
927
996
|
O(() => (n.current = {
|
|
928
997
|
isRunning: m,
|
|
929
998
|
cancelRun: () => p.thread.cancelRun()
|
|
@@ -944,7 +1013,7 @@ var q = ({ chips: e, onSelect: t, size: n = "comfortable", className: r, chipCla
|
|
|
944
1013
|
style: { filter: "drop-shadow(0 16px 32px rgba(0,0,0,0.16)) drop-shadow(0 2px 8px rgba(0,0,0,0.08))" },
|
|
945
1014
|
children: /* @__PURE__ */ x("div", {
|
|
946
1015
|
className: $("ai-chat-kb-surface h-full w-full p-[2px]", !e && "ai-chat-kb-surface-closed"),
|
|
947
|
-
style: { background:
|
|
1016
|
+
style: { background: Tt },
|
|
948
1017
|
children: /* @__PURE__ */ x("div", { className: "h-full w-full rounded-t-[26px] rounded-b-[40px] bg-white" })
|
|
949
1018
|
})
|
|
950
1019
|
}),
|
|
@@ -974,13 +1043,13 @@ var q = ({ chips: e, onSelect: t, size: n = "comfortable", className: r, chipCla
|
|
|
974
1043
|
"aria-label": "Start new chat",
|
|
975
1044
|
title: "Start new chat",
|
|
976
1045
|
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",
|
|
977
|
-
children: /* @__PURE__ */ x(
|
|
1046
|
+
children: /* @__PURE__ */ x(F, { className: "h-4 w-4" })
|
|
978
1047
|
}), /* @__PURE__ */ x("button", {
|
|
979
1048
|
type: "button",
|
|
980
1049
|
onClick: t,
|
|
981
1050
|
"aria-label": "Close AI chat",
|
|
982
1051
|
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",
|
|
983
|
-
children: /* @__PURE__ */ x(
|
|
1052
|
+
children: /* @__PURE__ */ x(z, { className: "h-4 w-4" })
|
|
984
1053
|
})]
|
|
985
1054
|
})]
|
|
986
1055
|
}),
|
|
@@ -991,17 +1060,17 @@ var q = ({ chips: e, onSelect: t, size: n = "comfortable", className: r, chipCla
|
|
|
991
1060
|
}),
|
|
992
1061
|
g.length > 0 && !m && /* @__PURE__ */ x("div", {
|
|
993
1062
|
className: "shrink-0 px-4 pt-1 pb-2",
|
|
994
|
-
children: /* @__PURE__ */ x(
|
|
1063
|
+
children: /* @__PURE__ */ x(K, {
|
|
995
1064
|
chips: g,
|
|
996
1065
|
onSelect: _,
|
|
997
|
-
chipClassName:
|
|
1066
|
+
chipClassName: Dt
|
|
998
1067
|
})
|
|
999
1068
|
})
|
|
1000
1069
|
]
|
|
1001
1070
|
}),
|
|
1002
1071
|
/* @__PURE__ */ x("div", {
|
|
1003
1072
|
className: "ai-chat-kb-pillbox pointer-events-auto relative z-20 mx-3 mt-1",
|
|
1004
|
-
children: /* @__PURE__ */ x(
|
|
1073
|
+
children: /* @__PURE__ */ x(wt, {
|
|
1005
1074
|
open: e,
|
|
1006
1075
|
onToggle: t,
|
|
1007
1076
|
askLabel: i,
|
|
@@ -1029,4 +1098,4 @@ var q = ({ chips: e, onSelect: t, size: n = "comfortable", className: r, chipCla
|
|
|
1029
1098
|
] });
|
|
1030
1099
|
};
|
|
1031
1100
|
//#endregion
|
|
1032
|
-
export {
|
|
1101
|
+
export { Et as KBChatWidget };
|