research-agent-ui 0.1.293 → 0.1.295
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/README.md +42 -1
- package/dist/ArticleExtractPanel-BPNXuezE.js +389 -0
- package/dist/ArticleExtractPanel-DAPLUpyx.cjs +2 -0
- package/dist/ChatConversationThread-D1RR0Bcx.cjs +17 -0
- package/dist/ChatConversationThread-DMPdu2sr.js +1428 -0
- package/dist/DownloadsDialog-CCPj0hA8.cjs +1 -0
- package/dist/{DownloadsDialog-bTEDe2DI.js → DownloadsDialog-DvS23Dh-.js} +8 -9
- package/dist/api/handlers/autocomplete.d.ts +6 -9
- package/dist/api/handlers/openai-transcription.d.ts +53 -0
- package/dist/api/handlers/transcript.d.ts +33 -0
- package/dist/api/index.d.ts +1 -0
- package/dist/api.cjs +10 -10
- package/dist/api.mjs +373 -182
- package/dist/app/index.d.ts +1 -1
- package/dist/app/useChunkErrorReload.d.ts +13 -2
- package/dist/components/ArticleReader/ArticleReaderMount.d.ts +5 -0
- package/dist/components/ArticleReader/ExtractPanelContext.d.ts +17 -1
- package/dist/components/ChatConversation/MessageBubble/AssistantMessageActions.d.ts +2 -1
- package/dist/components/ChatConversation/background-art.d.ts +3 -1
- package/dist/components/ChatConversation/background-cache.d.ts +41 -0
- package/dist/components/Footer.d.ts +5 -4
- package/dist/components/Footer.stories.d.ts +3 -3
- package/dist/config.cjs +1 -1
- package/dist/config.d.ts +9 -0
- package/dist/config.mjs +4 -3
- package/dist/dialog-7GDz0sWx.cjs +1 -0
- package/dist/dialog-Cufn2u50.js +80 -0
- package/dist/hooks/voice/useKokoroTTS.d.ts +2 -0
- package/dist/hooks/voice/useTextToVoice.d.ts +2 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.mjs +4 -2
- package/dist/lib/file-sources.d.ts +8 -0
- package/dist/lib/google-drive-source.d.ts +100 -0
- package/dist/lib/kokoro.d.ts +14 -2
- package/dist/lib/qwksearch-connect.d.ts +79 -0
- package/dist/settings/index.d.ts +15 -0
- package/dist/src-BqV2Vwpv.js +6375 -0
- package/dist/src-Ckb1ciEL.cjs +34 -0
- package/dist/tooltip-Bl3IdX-I.js +179 -0
- package/dist/tooltip-DmUO6ZUz.cjs +1 -0
- package/dist/types/fileSource.d.ts +9 -0
- package/dist/workspace/QwkSearchWorkspaceApp.d.ts +9 -2
- package/dist/workspace/ResearchWorkspaceView.d.ts +18 -4
- package/dist/workspace.cjs +1 -1
- package/dist/workspace.d.ts +1 -1
- package/dist/workspace.mjs +234 -91
- package/package.json +53 -50
- package/src/app/useChunkErrorReload.ts +92 -0
- package/src/settings/index.ts +23 -0
- package/src/settings/search.json +19 -1
- package/dist/DownloadsDialog-Ca6aRRcP.cjs +0 -1
- package/dist/src-HL9JjPc-.js +0 -8218
- package/dist/src-r4BsCIB4.cjs +0 -51
|
@@ -0,0 +1,1428 @@
|
|
|
1
|
+
import { i as e, n as t, o as n, r, s as i, t as a } from "./dialog-Cufn2u50.js";
|
|
2
|
+
import { a as o, c as s, n as c, r as l, t as u, u as d } from "./tooltip-Bl3IdX-I.js";
|
|
3
|
+
import { G as f, J as p, K as m, Q as h, U as g, V as _, W as v, X as y, Y as b, Z as x, d as S, q as C, tt as w } from "./src-BqV2Vwpv.js";
|
|
4
|
+
import { researchAgentUIConfig as T } from "./config.mjs";
|
|
5
|
+
import { Fragment as E, Suspense as D, lazy as O, memo as k, useCallback as A, useEffect as j, useMemo as M, useRef as N, useState as P } from "react";
|
|
6
|
+
import { Fragment as F, jsx as I, jsxs as L } from "react/jsx-runtime";
|
|
7
|
+
import { animate as R } from "motion/react";
|
|
8
|
+
import { ArrowLeftRight as z, BrainCircuit as B, Check as V, ChevronDown as H, ChevronRight as U, ChevronUp as ee, ClipboardList as W, Cpu as te, Download as ne, ExternalLink as G, File as re, FileDown as ie, FileSpreadsheet as ae, FileText as K, FileType as oe, Image as se, Link2 as ce, Loader2 as q, Pencil as le, Plus as ue, Search as J, StopCircle as de, Trash2 as fe, Video as pe, Volume2 as me } from "lucide-react";
|
|
9
|
+
import { agentSearch as he, getArticle as ge, listProviders as _e } from "qwksearch-api-client";
|
|
10
|
+
import ve from "quantum-sphere-loading-icon/react";
|
|
11
|
+
import ye from "markdown-to-jsx";
|
|
12
|
+
import { convertURLSafeHTMLToHTML as Y } from "extract-webpage/html-to-content/html-utils";
|
|
13
|
+
import * as X from "@radix-ui/react-popover";
|
|
14
|
+
import * as be from "grab-url/animations";
|
|
15
|
+
// src/ui/glowing-effect.tsx
|
|
16
|
+
var Z = k(({ blur: e = 0, inactiveZone: t = .7, proximity: r = 0, spread: i = 20, variant: a = "default", glow: o = !1, className: s, movementDuration: c = 2, borderWidth: l = 1, disabled: u = !0 }) => {
|
|
17
|
+
let d = N(null), f = N({
|
|
18
|
+
x: 0,
|
|
19
|
+
y: 0
|
|
20
|
+
}), p = N(0), m = A((e) => {
|
|
21
|
+
d.current && (p.current && cancelAnimationFrame(p.current), p.current = requestAnimationFrame(() => {
|
|
22
|
+
let n = d.current;
|
|
23
|
+
if (!n) return;
|
|
24
|
+
let { left: i, top: a, width: o, height: s } = n.getBoundingClientRect(), l = e?.x ?? f.current.x, u = e?.y ?? f.current.y;
|
|
25
|
+
e && (f.current = {
|
|
26
|
+
x: l,
|
|
27
|
+
y: u
|
|
28
|
+
});
|
|
29
|
+
let p = [i + o * .5, a + s * .5];
|
|
30
|
+
if (Math.hypot(l - p[0], u - p[1]) < .5 * Math.min(o, s) * t) {
|
|
31
|
+
n.style.setProperty("--active", "0");
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
let m = l > i - r && l < i + o + r && u > a - r && u < a + s + r;
|
|
35
|
+
if (n.style.setProperty("--active", m ? "1" : "0"), !m) return;
|
|
36
|
+
let h = parseFloat(n.style.getPropertyValue("--start")) || 0, g = h + ((180 * Math.atan2(u - p[1], l - p[0]) / Math.PI + 90 - h + 180) % 360 - 180);
|
|
37
|
+
R(h, g, {
|
|
38
|
+
duration: c,
|
|
39
|
+
ease: [
|
|
40
|
+
.16,
|
|
41
|
+
1,
|
|
42
|
+
.3,
|
|
43
|
+
1
|
|
44
|
+
],
|
|
45
|
+
onUpdate: (e) => {
|
|
46
|
+
n.style.setProperty("--start", String(e));
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
}));
|
|
50
|
+
}, [
|
|
51
|
+
t,
|
|
52
|
+
r,
|
|
53
|
+
c
|
|
54
|
+
]);
|
|
55
|
+
return j(() => {
|
|
56
|
+
if (u) return;
|
|
57
|
+
let e = () => m(), t = (e) => m(e);
|
|
58
|
+
return window.addEventListener("scroll", e, { passive: !0 }), document.body.addEventListener("pointermove", t, { passive: !0 }), () => {
|
|
59
|
+
p.current && cancelAnimationFrame(p.current), window.removeEventListener("scroll", e), document.body.removeEventListener("pointermove", t);
|
|
60
|
+
};
|
|
61
|
+
}, [m, u]), /* @__PURE__ */ L(F, { children: [/* @__PURE__ */ I("div", { className: n("pointer-events-none absolute -inset-px hidden rounded-[inherit] border opacity-0 transition-opacity", o && "opacity-100", a === "white" && "border-white", u && "!block") }), /* @__PURE__ */ I("div", {
|
|
62
|
+
ref: d,
|
|
63
|
+
style: {
|
|
64
|
+
"--blur": `${e}px`,
|
|
65
|
+
"--spread": i,
|
|
66
|
+
"--start": "0",
|
|
67
|
+
"--active": "0",
|
|
68
|
+
"--glowingeffect-border-width": `${l}px`,
|
|
69
|
+
"--repeating-conic-gradient-times": "5",
|
|
70
|
+
"--gradient": a === "white" ? "repeating-conic-gradient(\n from 236.84deg at 50% 50%,\n var(--black),\n var(--black) calc(25% / var(--repeating-conic-gradient-times))\n )" : "radial-gradient(circle, #dd7bbb 10%, #dd7bbb00 20%),\n radial-gradient(circle at 40% 40%, #d79f1e 5%, #d79f1e00 15%),\n radial-gradient(circle at 60% 60%, #5a922c 10%, #5a922c00 20%),\n radial-gradient(circle at 40% 60%, #4c7894 10%, #4c789400 20%),\n repeating-conic-gradient(\n from 236.84deg at 50% 50%,\n #dd7bbb 0%,\n #d79f1e calc(25% / var(--repeating-conic-gradient-times)),\n #5a922c calc(50% / var(--repeating-conic-gradient-times)),\n #4c7894 calc(75% / var(--repeating-conic-gradient-times)),\n #dd7bbb calc(100% / var(--repeating-conic-gradient-times))\n )"
|
|
71
|
+
},
|
|
72
|
+
className: n("pointer-events-none absolute inset-0 rounded-[inherit] opacity-100 transition-opacity", o && "opacity-100", e > 0 && "blur-[var(--blur)] ", s, u && "!hidden"),
|
|
73
|
+
children: /* @__PURE__ */ I("div", { className: n("glow", "rounded-[inherit]", "after:content-[\"\"] after:rounded-[inherit] after:absolute after:inset-[calc(-1*var(--glowingeffect-border-width))]", "after:[border:var(--glowingeffect-border-width)_solid_transparent]", "after:[background:var(--gradient)] after:[background-attachment:fixed]", "after:opacity-[var(--active)] after:transition-opacity after:duration-300", "after:[mask-clip:padding-box,border-box]", "after:[mask-composite:intersect]", "after:[mask-image:linear-gradient(#0000,#0000),conic-gradient(from_calc((var(--start)-var(--spread))*1deg),#00000000_0deg,#fff,#00000000_calc(var(--spread)*2deg))]") })
|
|
74
|
+
})] });
|
|
75
|
+
});
|
|
76
|
+
Z.displayName = "GlowingEffect";
|
|
77
|
+
// src/lib/videoPlayback.ts
|
|
78
|
+
function xe(e) {
|
|
79
|
+
try {
|
|
80
|
+
let t = new URL(e);
|
|
81
|
+
return t.protocol === "https:" || t.protocol === "http:";
|
|
82
|
+
} catch {
|
|
83
|
+
return !1;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
function Se(e) {
|
|
87
|
+
return e.iframe_src && xe(e.iframe_src) ? {
|
|
88
|
+
type: "inline",
|
|
89
|
+
src: e.iframe_src
|
|
90
|
+
} : {
|
|
91
|
+
type: "external",
|
|
92
|
+
url: e.url || ""
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
// src/lib/searchResultToDocument.ts
|
|
96
|
+
function Ce(e) {
|
|
97
|
+
return {
|
|
98
|
+
pageContent: e.snippet || e.content || "",
|
|
99
|
+
metadata: {
|
|
100
|
+
title: e.title || "",
|
|
101
|
+
source: e.source || "",
|
|
102
|
+
thumbnail: e.thumbnail || "",
|
|
103
|
+
url: e.url || "",
|
|
104
|
+
...e.img_src && { img_src: e.img_src },
|
|
105
|
+
...e.iframe_src && { iframe_src: e.iframe_src }
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
// src/components/SearchResults/MessageSources.tsx
|
|
110
|
+
var we = p.filter((e) => [
|
|
111
|
+
"general",
|
|
112
|
+
"news",
|
|
113
|
+
"videos",
|
|
114
|
+
"images",
|
|
115
|
+
"science",
|
|
116
|
+
"files"
|
|
117
|
+
].includes(e.code)), Te = ({ sources: r, query: i }) => {
|
|
118
|
+
let [s, c] = P("general"), [l, u] = P(r), [d, f] = P(!1), [p, m] = P(!1), [h, g] = P(1), [_, v] = P(!0), [y, b] = P(!1), [x, S] = P(!1), [C, w] = P(null), T = N(null), E = N(!1), D = N(!1), { openPanel: O, isOpen: k } = o();
|
|
119
|
+
j(() => {
|
|
120
|
+
let e = () => {
|
|
121
|
+
S(localStorage.getItem("searchResultGlow") === "true");
|
|
122
|
+
};
|
|
123
|
+
return e(), window.addEventListener("client-config-changed", e), window.addEventListener("storage", e), () => {
|
|
124
|
+
window.removeEventListener("client-config-changed", e), window.removeEventListener("storage", e);
|
|
125
|
+
};
|
|
126
|
+
}, []);
|
|
127
|
+
let [M, R] = P({});
|
|
128
|
+
j(() => {
|
|
129
|
+
let e = () => {
|
|
130
|
+
b(window.innerWidth >= 1024);
|
|
131
|
+
};
|
|
132
|
+
return e(), window.addEventListener("resize", e), () => window.removeEventListener("resize", e);
|
|
133
|
+
}, []), j(() => {
|
|
134
|
+
u(r), c("general"), g(1), v(!0), R({}), z(r);
|
|
135
|
+
}, [r]);
|
|
136
|
+
let z = A(async (e) => {
|
|
137
|
+
let t = e.filter((e) => e.metadata.url && e.metadata.url !== "File" && !e.metadata.iframe_src);
|
|
138
|
+
for (let e of t) try {
|
|
139
|
+
let { data: t } = await ge({ query: { url: e.metadata.url } });
|
|
140
|
+
t?.cached && t?.article?.html && R((t) => ({
|
|
141
|
+
...t,
|
|
142
|
+
[e.metadata.url]: "loaded"
|
|
143
|
+
}));
|
|
144
|
+
} catch {}
|
|
145
|
+
}, []);
|
|
146
|
+
j(() => {
|
|
147
|
+
if (typeof window < "u") {
|
|
148
|
+
let e = new URLSearchParams(window.location.search).get("extract");
|
|
149
|
+
e && (O(decodeURIComponent(e), ""), D.current = !1);
|
|
150
|
+
}
|
|
151
|
+
}, [O]), j(() => {
|
|
152
|
+
D.current = !1;
|
|
153
|
+
}, [r]), j(() => {
|
|
154
|
+
E.current && !k && (D.current = !0), E.current = k;
|
|
155
|
+
}, [k]), j(() => {
|
|
156
|
+
if (y && l && l.length > 0 && !k && !D.current) {
|
|
157
|
+
let e = l[0];
|
|
158
|
+
e?.metadata?.url && O(e.metadata.url, "");
|
|
159
|
+
}
|
|
160
|
+
}, [l, y]);
|
|
161
|
+
let B = async (e, t) => {
|
|
162
|
+
e.preventDefault(), D.current = !1, R((e) => ({
|
|
163
|
+
...e,
|
|
164
|
+
[t]: "loading"
|
|
165
|
+
})), O(t, "");
|
|
166
|
+
try {
|
|
167
|
+
await ge({ query: { url: t } }), R((e) => ({
|
|
168
|
+
...e,
|
|
169
|
+
[t]: "loaded"
|
|
170
|
+
}));
|
|
171
|
+
} catch {
|
|
172
|
+
R((e) => ({
|
|
173
|
+
...e,
|
|
174
|
+
[t]: "loaded"
|
|
175
|
+
}));
|
|
176
|
+
}
|
|
177
|
+
}, V = A(async () => {
|
|
178
|
+
if (!i || p || !_) return;
|
|
179
|
+
m(!0);
|
|
180
|
+
let e = h + 1, { data: t } = await he({ query: {
|
|
181
|
+
q: i,
|
|
182
|
+
cat: s,
|
|
183
|
+
page: e
|
|
184
|
+
} }), n = t?.results ?? [];
|
|
185
|
+
if (n.length === 0) {
|
|
186
|
+
v(!1), m(!1);
|
|
187
|
+
return;
|
|
188
|
+
}
|
|
189
|
+
let r = n.map((e) => {
|
|
190
|
+
if (e.url) try {
|
|
191
|
+
let t = new URL(e.url);
|
|
192
|
+
(t.pathname === "/" || t.pathname === "") && console.warn("[MessageSources] Search result URL is domain-only:", e.url, "Title:", e.title);
|
|
193
|
+
} catch {
|
|
194
|
+
console.error("[MessageSources] Invalid URL in search result:", e.url);
|
|
195
|
+
}
|
|
196
|
+
return Ce(e);
|
|
197
|
+
});
|
|
198
|
+
u((e) => [...e, ...r]), g(e), m(!1);
|
|
199
|
+
}, [
|
|
200
|
+
i,
|
|
201
|
+
s,
|
|
202
|
+
h,
|
|
203
|
+
p,
|
|
204
|
+
_
|
|
205
|
+
]), H = async (e) => {
|
|
206
|
+
if (e !== s && i) {
|
|
207
|
+
c(e), f(!0), g(1), v(!0);
|
|
208
|
+
try {
|
|
209
|
+
let { data: t } = await he({ query: {
|
|
210
|
+
q: i,
|
|
211
|
+
cat: e,
|
|
212
|
+
page: 1
|
|
213
|
+
} }), n = (t?.results ?? []).map((e) => {
|
|
214
|
+
if (e.url) try {
|
|
215
|
+
let t = new URL(e.url);
|
|
216
|
+
(t.pathname === "/" || t.pathname === "") && console.warn("[MessageSources] Category search result URL is domain-only:", e.url, "Title:", e.title);
|
|
217
|
+
} catch {
|
|
218
|
+
console.error("[MessageSources] Invalid URL in category search result:", e.url);
|
|
219
|
+
}
|
|
220
|
+
return Ce(e);
|
|
221
|
+
});
|
|
222
|
+
u(n);
|
|
223
|
+
} catch (e) {
|
|
224
|
+
console.error("Error searching:", e);
|
|
225
|
+
} finally {
|
|
226
|
+
f(!1);
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
};
|
|
230
|
+
j(() => {
|
|
231
|
+
let e = T.current;
|
|
232
|
+
if (!e) return;
|
|
233
|
+
let t = () => {
|
|
234
|
+
let { scrollTop: t, scrollHeight: n, clientHeight: r } = e;
|
|
235
|
+
n - t - r < 100 && V();
|
|
236
|
+
};
|
|
237
|
+
return e.addEventListener("scroll", t), () => e.removeEventListener("scroll", t);
|
|
238
|
+
}, [V]);
|
|
239
|
+
let U = (e, t) => {
|
|
240
|
+
let n = s === "images", r = s === "videos", i = e.metadata.img_src || e.metadata.thumbnail;
|
|
241
|
+
if (n && i) return /* @__PURE__ */ I("div", {
|
|
242
|
+
className: "relative rounded-lg group",
|
|
243
|
+
children: /* @__PURE__ */ L("a", {
|
|
244
|
+
className: "relative block overflow-hidden rounded-lg cursor-pointer",
|
|
245
|
+
href: e.metadata.url,
|
|
246
|
+
onClick: (t) => B(t, e.metadata.url),
|
|
247
|
+
children: [/* @__PURE__ */ I("img", {
|
|
248
|
+
src: i,
|
|
249
|
+
alt: e.metadata.title,
|
|
250
|
+
className: "w-full h-auto object-cover rounded-lg hover:scale-105 transition-transform duration-200",
|
|
251
|
+
loading: "lazy"
|
|
252
|
+
}), /* @__PURE__ */ L("div", {
|
|
253
|
+
className: "absolute inset-x-0 bottom-0 bg-gradient-to-t from-black/70 to-transparent p-2 opacity-0 group-hover:opacity-100 transition-opacity duration-200",
|
|
254
|
+
children: [/* @__PURE__ */ I("p", {
|
|
255
|
+
className: "text-xs text-white line-clamp-2",
|
|
256
|
+
children: Y(e.metadata.title)
|
|
257
|
+
}), /* @__PURE__ */ I("p", {
|
|
258
|
+
className: "text-[10px] text-white/70 truncate mt-0.5",
|
|
259
|
+
children: e.metadata.source
|
|
260
|
+
})]
|
|
261
|
+
})]
|
|
262
|
+
})
|
|
263
|
+
}, t);
|
|
264
|
+
if (r && i) {
|
|
265
|
+
let n = Se(e.metadata), r = /* @__PURE__ */ L("div", {
|
|
266
|
+
className: "relative",
|
|
267
|
+
children: [/* @__PURE__ */ I("img", {
|
|
268
|
+
src: i,
|
|
269
|
+
alt: e.metadata.title,
|
|
270
|
+
className: "w-full h-24 object-cover"
|
|
271
|
+
}), /* @__PURE__ */ I("div", {
|
|
272
|
+
className: "absolute inset-0 flex items-center justify-center",
|
|
273
|
+
children: /* @__PURE__ */ I("div", {
|
|
274
|
+
className: "w-10 h-10 bg-black/60 rounded-full flex items-center justify-center",
|
|
275
|
+
children: /* @__PURE__ */ I(pe, {
|
|
276
|
+
size: 18,
|
|
277
|
+
className: "text-white ml-0.5"
|
|
278
|
+
})
|
|
279
|
+
})
|
|
280
|
+
})]
|
|
281
|
+
}), a = /* @__PURE__ */ I("p", {
|
|
282
|
+
className: "text-xs line-clamp-2 p-2 text-muted-foreground",
|
|
283
|
+
children: Y(e.metadata.title)
|
|
284
|
+
});
|
|
285
|
+
return /* @__PURE__ */ L("div", {
|
|
286
|
+
className: "relative rounded-xl",
|
|
287
|
+
children: [/* @__PURE__ */ I(Z, {
|
|
288
|
+
spread: 40,
|
|
289
|
+
glow: !0,
|
|
290
|
+
disabled: !x,
|
|
291
|
+
proximity: 64,
|
|
292
|
+
inactiveZone: .01,
|
|
293
|
+
borderWidth: 2
|
|
294
|
+
}), n.type === "inline" ? /* @__PURE__ */ L("button", {
|
|
295
|
+
type: "button",
|
|
296
|
+
className: "relative w-full text-left bg-card text-card-foreground border border-border rounded-xl overflow-hidden flex flex-col cursor-pointer shadow-sm hover:shadow-md transition-all duration-200",
|
|
297
|
+
onClick: () => w({
|
|
298
|
+
src: n.src,
|
|
299
|
+
title: e.metadata.title
|
|
300
|
+
}),
|
|
301
|
+
children: [r, a]
|
|
302
|
+
}) : /* @__PURE__ */ L("a", {
|
|
303
|
+
className: "relative bg-card text-card-foreground border border-border rounded-xl overflow-hidden flex flex-col cursor-pointer shadow-sm hover:shadow-md transition-all duration-200",
|
|
304
|
+
href: n.url,
|
|
305
|
+
target: "_blank",
|
|
306
|
+
rel: "noopener noreferrer",
|
|
307
|
+
children: [r, a]
|
|
308
|
+
})]
|
|
309
|
+
}, t);
|
|
310
|
+
}
|
|
311
|
+
let a = M[e.metadata.url];
|
|
312
|
+
return /* @__PURE__ */ L("div", {
|
|
313
|
+
className: "relative rounded-xl group h-full",
|
|
314
|
+
children: [/* @__PURE__ */ I(Z, {
|
|
315
|
+
spread: 40,
|
|
316
|
+
glow: !0,
|
|
317
|
+
disabled: !x,
|
|
318
|
+
proximity: 64,
|
|
319
|
+
inactiveZone: .01,
|
|
320
|
+
borderWidth: 2
|
|
321
|
+
}), /* @__PURE__ */ L("div", {
|
|
322
|
+
className: "relative bg-card text-card-foreground border border-border rounded-xl p-2.5 flex flex-col font-medium cursor-pointer shadow-sm hover:shadow-md transition-all duration-200 h-full",
|
|
323
|
+
onClick: (t) => B(t, e.metadata.url),
|
|
324
|
+
children: [
|
|
325
|
+
a && /* @__PURE__ */ I("div", {
|
|
326
|
+
className: "absolute top-1.5 left-1.5 p-1 rounded-md bg-background/80 backdrop-blur-sm z-[5]",
|
|
327
|
+
children: a === "loading" ? /* @__PURE__ */ I(q, {
|
|
328
|
+
size: 14,
|
|
329
|
+
className: "text-primary animate-spin"
|
|
330
|
+
}) : /* @__PURE__ */ I(K, {
|
|
331
|
+
size: 14,
|
|
332
|
+
className: "text-green-500"
|
|
333
|
+
})
|
|
334
|
+
}),
|
|
335
|
+
/* @__PURE__ */ I("a", {
|
|
336
|
+
href: e.metadata.url,
|
|
337
|
+
target: "_blank",
|
|
338
|
+
rel: "noopener noreferrer",
|
|
339
|
+
onClick: (e) => e.stopPropagation(),
|
|
340
|
+
className: "absolute top-1.5 right-1.5 p-1 rounded-md bg-secondary/50 opacity-0 group-hover:opacity-100 transition-opacity hover:bg-secondary z-10",
|
|
341
|
+
title: "Open in new tab",
|
|
342
|
+
children: /* @__PURE__ */ I(G, {
|
|
343
|
+
size: 12,
|
|
344
|
+
className: "text-muted-foreground"
|
|
345
|
+
})
|
|
346
|
+
}),
|
|
347
|
+
/* @__PURE__ */ L("p", {
|
|
348
|
+
className: "text-xs line-clamp-4 text-muted-foreground",
|
|
349
|
+
children: [
|
|
350
|
+
/* @__PURE__ */ L("span", {
|
|
351
|
+
className: "inline-flex items-center gap-1 font-semibold text-foreground/70 align-middle",
|
|
352
|
+
children: [e.metadata.url === "File" ? /* @__PURE__ */ I("span", {
|
|
353
|
+
className: "inline-flex items-center justify-center w-3.5 h-3.5 rounded-full bg-secondary flex-shrink-0",
|
|
354
|
+
children: /* @__PURE__ */ I(re, {
|
|
355
|
+
size: 10,
|
|
356
|
+
className: "text-muted-foreground"
|
|
357
|
+
})
|
|
358
|
+
}) : /* @__PURE__ */ I("img", {
|
|
359
|
+
src: `https://s2.googleusercontent.com/s2/favicons?domain_url=${e.metadata.url}`,
|
|
360
|
+
width: 20,
|
|
361
|
+
height: 20,
|
|
362
|
+
alt: "favicon",
|
|
363
|
+
className: "inline rounded h-5 w-5 flex-shrink-0"
|
|
364
|
+
}), e.metadata.source]
|
|
365
|
+
}),
|
|
366
|
+
" ",
|
|
367
|
+
/* @__PURE__ */ I("span", {
|
|
368
|
+
className: "align-middle",
|
|
369
|
+
children: Y(e.metadata.title)
|
|
370
|
+
})
|
|
371
|
+
]
|
|
372
|
+
})
|
|
373
|
+
]
|
|
374
|
+
})]
|
|
375
|
+
}, t);
|
|
376
|
+
};
|
|
377
|
+
return /* @__PURE__ */ L(F, { children: [
|
|
378
|
+
i && /* @__PURE__ */ I("div", {
|
|
379
|
+
className: "flex items-center gap-1 mb-3 overflow-x-auto pb-1",
|
|
380
|
+
children: we.map((e) => /* @__PURE__ */ L("button", {
|
|
381
|
+
onClick: () => H(e.code),
|
|
382
|
+
disabled: d,
|
|
383
|
+
className: n("flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-sm font-medium transition-all duration-200 whitespace-nowrap", s === e.code ? "bg-primary text-primary-foreground" : "bg-secondary/50 text-muted-foreground hover:bg-secondary hover:text-foreground"),
|
|
384
|
+
children: [/* @__PURE__ */ I(e.icon, { className: "w-4 h-4 flex-shrink-0" }), /* @__PURE__ */ I("span", { children: e.name })]
|
|
385
|
+
}, e.code))
|
|
386
|
+
}),
|
|
387
|
+
/* @__PURE__ */ I("div", {
|
|
388
|
+
ref: T,
|
|
389
|
+
className: n("overflow-y-auto pb-2 pr-1", s === "images" ? "max-h-[400px] lg:max-h-[500px]" : "max-h-[180px] lg:max-h-[280px]"),
|
|
390
|
+
children: d ? /* @__PURE__ */ I("div", {
|
|
391
|
+
className: "flex items-center justify-center py-8",
|
|
392
|
+
children: /* @__PURE__ */ I(q, { className: "w-6 h-6 animate-spin text-muted-foreground" })
|
|
393
|
+
}) : l.length > 0 ? /* @__PURE__ */ L(F, { children: [
|
|
394
|
+
/* @__PURE__ */ I("div", {
|
|
395
|
+
className: n(s === "images" ? "columns-2 sm:columns-3 lg:columns-4 gap-2 [&>div]:mb-2 [&>div]:break-inside-avoid" : n("grid gap-3 auto-rows-fr", k && y ? "grid-cols-2" : "grid-cols-3")),
|
|
396
|
+
children: l.map((e, t) => U(e, t))
|
|
397
|
+
}),
|
|
398
|
+
p && /* @__PURE__ */ I("div", {
|
|
399
|
+
className: "flex items-center justify-center py-4",
|
|
400
|
+
children: /* @__PURE__ */ I(q, { className: "w-5 h-5 animate-spin text-muted-foreground" })
|
|
401
|
+
}),
|
|
402
|
+
!_ && l.length > 0 && /* @__PURE__ */ I("div", {
|
|
403
|
+
className: "flex items-center justify-center py-4 text-muted-foreground text-xs",
|
|
404
|
+
children: "No more results"
|
|
405
|
+
})
|
|
406
|
+
] }) : /* @__PURE__ */ I("div", {
|
|
407
|
+
className: "flex items-center justify-center py-8 text-muted-foreground text-sm",
|
|
408
|
+
children: "No results found"
|
|
409
|
+
})
|
|
410
|
+
}),
|
|
411
|
+
/* @__PURE__ */ I(a, {
|
|
412
|
+
open: C !== null,
|
|
413
|
+
onOpenChange: (e) => !e && w(null),
|
|
414
|
+
children: /* @__PURE__ */ L(t, {
|
|
415
|
+
className: "max-w-3xl p-0 overflow-hidden gap-0",
|
|
416
|
+
children: [/* @__PURE__ */ I(e, {
|
|
417
|
+
className: "sr-only",
|
|
418
|
+
children: C?.title || "Video player"
|
|
419
|
+
}), C && /* @__PURE__ */ I("iframe", {
|
|
420
|
+
src: C.src,
|
|
421
|
+
title: C.title || "Video player",
|
|
422
|
+
className: "w-full aspect-video",
|
|
423
|
+
allow: "accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",
|
|
424
|
+
allowFullScreen: !0
|
|
425
|
+
})]
|
|
426
|
+
})
|
|
427
|
+
})
|
|
428
|
+
] });
|
|
429
|
+
}, Ee = {
|
|
430
|
+
extract: "Extract",
|
|
431
|
+
arxiv: "ArXiv",
|
|
432
|
+
"google scholar": "Scholar",
|
|
433
|
+
pubmed: "PubMed",
|
|
434
|
+
wolframalpha: "Wolfram",
|
|
435
|
+
youtube: "YouTube",
|
|
436
|
+
Web: "Web"
|
|
437
|
+
};
|
|
438
|
+
function De(e) {
|
|
439
|
+
return e ? Ee[e] ?? e : "Web";
|
|
440
|
+
}
|
|
441
|
+
function Oe({ queries: e, loading: t }) {
|
|
442
|
+
let r = e.filter((e) => e.status === "done").length, i = e.length, a = t && e.some((e) => e.status === "running");
|
|
443
|
+
return t ? /* @__PURE__ */ L("div", {
|
|
444
|
+
className: "rounded-xl border border-border bg-secondary/20 overflow-hidden text-sm",
|
|
445
|
+
children: [/* @__PURE__ */ L("div", {
|
|
446
|
+
className: "flex items-center justify-between px-3 py-2 border-b border-border/50",
|
|
447
|
+
children: [/* @__PURE__ */ L("div", {
|
|
448
|
+
className: "flex items-center gap-2 text-muted-foreground",
|
|
449
|
+
children: [a ? /* @__PURE__ */ I(q, { className: "w-3.5 h-3.5 animate-spin" }) : /* @__PURE__ */ I(J, { className: "w-3.5 h-3.5" }), /* @__PURE__ */ I("span", {
|
|
450
|
+
className: "font-medium text-foreground",
|
|
451
|
+
children: a ? "Running analysis…" : "Analysis complete"
|
|
452
|
+
})]
|
|
453
|
+
}), i > 0 && /* @__PURE__ */ L("span", {
|
|
454
|
+
className: "text-xs text-muted-foreground tabular-nums",
|
|
455
|
+
children: [
|
|
456
|
+
r,
|
|
457
|
+
"/",
|
|
458
|
+
i,
|
|
459
|
+
" searches"
|
|
460
|
+
]
|
|
461
|
+
})]
|
|
462
|
+
}), e.length > 0 && /* @__PURE__ */ I("div", {
|
|
463
|
+
className: "divide-y divide-border/40",
|
|
464
|
+
children: e.map((e, t) => /* @__PURE__ */ L("div", {
|
|
465
|
+
className: "flex items-center gap-2.5 px-3 py-2",
|
|
466
|
+
children: [e.status === "running" ? /* @__PURE__ */ I(q, { className: "w-3.5 h-3.5 text-muted-foreground animate-spin flex-shrink-0" }) : /* @__PURE__ */ I(J, { className: n("w-3.5 h-3.5 flex-shrink-0", e.status === "done" ? "text-muted-foreground" : "text-muted-foreground/40") }), /* @__PURE__ */ L("div", {
|
|
467
|
+
className: "flex items-baseline gap-1.5 min-w-0 flex-1",
|
|
468
|
+
children: [/* @__PURE__ */ L("span", {
|
|
469
|
+
className: "text-xs text-muted-foreground whitespace-nowrap flex-shrink-0",
|
|
470
|
+
children: [De(e.category), " ·"]
|
|
471
|
+
}), /* @__PURE__ */ I("span", {
|
|
472
|
+
className: "text-foreground/80 truncate",
|
|
473
|
+
children: e.query
|
|
474
|
+
})]
|
|
475
|
+
})]
|
|
476
|
+
}, t))
|
|
477
|
+
})]
|
|
478
|
+
}) : null;
|
|
479
|
+
}
|
|
480
|
+
// src/components/SearchResults/WebCitationBadge.tsx
|
|
481
|
+
var ke = ({ href: e, children: t, sources: n }) => {
|
|
482
|
+
let { openPanel: r } = o(), i = M(() => !n || !e ? null : n.find((t) => t.metadata?.url === e) ?? null, [n, e]), a = M(() => {
|
|
483
|
+
try {
|
|
484
|
+
return new URL(e).hostname.replace("www.", "");
|
|
485
|
+
} catch {
|
|
486
|
+
return i?.metadata?.source || "";
|
|
487
|
+
}
|
|
488
|
+
}, [e, i]), s = i?.metadata?.title || "", d = `https://s2.googleusercontent.com/s2/favicons?domain_url=${e}`;
|
|
489
|
+
return /* @__PURE__ */ L(u, { children: [/* @__PURE__ */ I(l, {
|
|
490
|
+
asChild: !0,
|
|
491
|
+
children: /* @__PURE__ */ I("a", {
|
|
492
|
+
href: e,
|
|
493
|
+
onClick: (t) => {
|
|
494
|
+
t.preventDefault(), r(e, "");
|
|
495
|
+
},
|
|
496
|
+
className: "bg-light-secondary dark:bg-dark-secondary px-1 rounded ml-1 no-underline text-xs text-black/70 dark:text-white/70 relative cursor-pointer hover:bg-black/10 dark:hover:bg-white/20 transition-colors",
|
|
497
|
+
children: t
|
|
498
|
+
})
|
|
499
|
+
}), /* @__PURE__ */ I(c, {
|
|
500
|
+
side: "top",
|
|
501
|
+
className: "max-w-72 p-2.5",
|
|
502
|
+
children: /* @__PURE__ */ L("div", {
|
|
503
|
+
className: "flex items-start gap-2",
|
|
504
|
+
children: [/* @__PURE__ */ I("img", {
|
|
505
|
+
src: d,
|
|
506
|
+
alt: "",
|
|
507
|
+
width: 16,
|
|
508
|
+
height: 16,
|
|
509
|
+
className: "rounded flex-shrink-0 mt-0.5"
|
|
510
|
+
}), /* @__PURE__ */ L("div", {
|
|
511
|
+
className: "min-w-0",
|
|
512
|
+
children: [/* @__PURE__ */ I("p", {
|
|
513
|
+
className: "text-xs font-medium leading-snug line-clamp-2",
|
|
514
|
+
children: s || a
|
|
515
|
+
}), s && /* @__PURE__ */ I("p", {
|
|
516
|
+
className: "text-[10px] opacity-70 truncate mt-0.5",
|
|
517
|
+
children: a
|
|
518
|
+
})]
|
|
519
|
+
})]
|
|
520
|
+
})
|
|
521
|
+
})] });
|
|
522
|
+
}, Ae = ({ content: e, thinkingEnded: t }) => {
|
|
523
|
+
let [n, r] = P(!0);
|
|
524
|
+
return j(() => {
|
|
525
|
+
r(!t);
|
|
526
|
+
}, [t]), /* @__PURE__ */ L("div", {
|
|
527
|
+
className: "my-4 bg-secondary/50 rounded-xl border border-border overflow-hidden",
|
|
528
|
+
children: [/* @__PURE__ */ L("button", {
|
|
529
|
+
onClick: () => r(!n),
|
|
530
|
+
className: "w-full flex items-center justify-between px-4 py-1 text-foreground/90 hover:bg-secondary transition duration-200",
|
|
531
|
+
children: [/* @__PURE__ */ L("div", {
|
|
532
|
+
className: "flex items-center space-x-2",
|
|
533
|
+
children: [/* @__PURE__ */ I(B, {
|
|
534
|
+
size: 20,
|
|
535
|
+
className: "text-accent-foreground"
|
|
536
|
+
}), /* @__PURE__ */ I("p", {
|
|
537
|
+
className: "font-medium text-sm",
|
|
538
|
+
children: "Thinking Process"
|
|
539
|
+
})]
|
|
540
|
+
}), I(n ? ee : H, {
|
|
541
|
+
size: 18,
|
|
542
|
+
className: "text-muted-foreground"
|
|
543
|
+
})]
|
|
544
|
+
}), n && /* @__PURE__ */ I("div", {
|
|
545
|
+
className: "px-4 py-3 text-foreground/80 text-sm border-t border-border bg-muted/50 whitespace-pre-wrap",
|
|
546
|
+
children: e
|
|
547
|
+
})]
|
|
548
|
+
});
|
|
549
|
+
}, je = ({ children: e, thinkingEnded: t }) => /* @__PURE__ */ I(Ae, {
|
|
550
|
+
content: e,
|
|
551
|
+
thinkingEnded: t
|
|
552
|
+
}), Me = [
|
|
553
|
+
"png",
|
|
554
|
+
"jpg",
|
|
555
|
+
"jpeg",
|
|
556
|
+
"gif",
|
|
557
|
+
"webp",
|
|
558
|
+
"svg",
|
|
559
|
+
"bmp",
|
|
560
|
+
"avif"
|
|
561
|
+
], Ne = (e) => {
|
|
562
|
+
let t = (e || "").toLowerCase();
|
|
563
|
+
return Me.includes(t) ? /* @__PURE__ */ I(se, { size: 15 }) : I(t === "url" ? ce : K, { size: 15 });
|
|
564
|
+
}, Pe = ({ file: n }) => {
|
|
565
|
+
let { deleteAttachedFile: i } = d(), [o, s] = P(!1), [c, l] = P(!1);
|
|
566
|
+
return /* @__PURE__ */ L(F, { children: [/* @__PURE__ */ L("div", {
|
|
567
|
+
className: "group inline-flex max-w-full items-center gap-2 rounded-lg border border-border bg-secondary/40 py-1.5 pl-2.5 pr-1.5 text-sm",
|
|
568
|
+
children: [
|
|
569
|
+
/* @__PURE__ */ I("span", {
|
|
570
|
+
className: "text-muted-foreground",
|
|
571
|
+
children: Ne(n.fileExtension)
|
|
572
|
+
}),
|
|
573
|
+
/* @__PURE__ */ I("span", {
|
|
574
|
+
className: "min-w-0 truncate font-medium text-foreground",
|
|
575
|
+
title: n.fileName,
|
|
576
|
+
children: n.fileName
|
|
577
|
+
}),
|
|
578
|
+
n.fileExtension && n.fileExtension !== "url" && /* @__PURE__ */ I("span", {
|
|
579
|
+
className: "hidden shrink-0 text-[10px] font-semibold uppercase tracking-wider text-muted-foreground sm:inline",
|
|
580
|
+
children: n.fileExtension
|
|
581
|
+
}),
|
|
582
|
+
/* @__PURE__ */ I("button", {
|
|
583
|
+
type: "button",
|
|
584
|
+
"aria-label": `Delete ${n.fileName}`,
|
|
585
|
+
onClick: () => s(!0),
|
|
586
|
+
className: "shrink-0 rounded-md p-1 text-muted-foreground transition-colors hover:bg-red-500/10 hover:text-red-500",
|
|
587
|
+
children: /* @__PURE__ */ I(fe, { size: 14 })
|
|
588
|
+
})
|
|
589
|
+
]
|
|
590
|
+
}), /* @__PURE__ */ I(a, {
|
|
591
|
+
open: o,
|
|
592
|
+
onOpenChange: (e) => {
|
|
593
|
+
c || s(e);
|
|
594
|
+
},
|
|
595
|
+
children: /* @__PURE__ */ L(t, {
|
|
596
|
+
className: "w-full max-w-md rounded-2xl",
|
|
597
|
+
children: [
|
|
598
|
+
/* @__PURE__ */ I(e, {
|
|
599
|
+
className: "text-lg font-medium leading-6",
|
|
600
|
+
children: "Delete file"
|
|
601
|
+
}),
|
|
602
|
+
/* @__PURE__ */ L(r, {
|
|
603
|
+
className: "text-sm text-muted-foreground",
|
|
604
|
+
children: [
|
|
605
|
+
"Are you sure you want to delete",
|
|
606
|
+
" ",
|
|
607
|
+
/* @__PURE__ */ I("span", {
|
|
608
|
+
className: "font-medium text-foreground",
|
|
609
|
+
children: n.fileName
|
|
610
|
+
}),
|
|
611
|
+
"? This removes it from the conversation and permanently deletes the upload."
|
|
612
|
+
]
|
|
613
|
+
}),
|
|
614
|
+
/* @__PURE__ */ L("div", {
|
|
615
|
+
className: "mt-6 flex flex-row items-center justify-end gap-4",
|
|
616
|
+
children: [/* @__PURE__ */ I("button", {
|
|
617
|
+
type: "button",
|
|
618
|
+
onClick: () => !c && s(!1),
|
|
619
|
+
className: "text-sm text-muted-foreground transition-colors hover:text-foreground",
|
|
620
|
+
children: "Cancel"
|
|
621
|
+
}), /* @__PURE__ */ L("button", {
|
|
622
|
+
type: "button",
|
|
623
|
+
onClick: async () => {
|
|
624
|
+
l(!0);
|
|
625
|
+
try {
|
|
626
|
+
await i(n.fileId), s(!1);
|
|
627
|
+
} finally {
|
|
628
|
+
l(!1);
|
|
629
|
+
}
|
|
630
|
+
},
|
|
631
|
+
disabled: c,
|
|
632
|
+
className: "inline-flex items-center gap-1.5 text-sm text-red-500 transition-colors hover:text-red-600 disabled:opacity-60",
|
|
633
|
+
children: [c && /* @__PURE__ */ I(q, {
|
|
634
|
+
size: 14,
|
|
635
|
+
className: "animate-spin"
|
|
636
|
+
}), "Delete"]
|
|
637
|
+
})]
|
|
638
|
+
})
|
|
639
|
+
]
|
|
640
|
+
})
|
|
641
|
+
})] });
|
|
642
|
+
}, Fe = ({ files: e }) => !e || e.length === 0 ? null : /* @__PURE__ */ I("div", {
|
|
643
|
+
className: "ml-10 mt-2 flex flex-wrap gap-2",
|
|
644
|
+
children: e.map((e) => /* @__PURE__ */ I(Pe, { file: e }, e.fileId))
|
|
645
|
+
}), Ie = ({ section: e, isExpanded: t, setIsExpanded: r, isEditing: a, setIsEditing: o, editText: s, setEditText: d, handleEditSubmit: f, copiedUserMsg: p, handleCopyUserMsg: m }) => {
|
|
646
|
+
let h = N(null);
|
|
647
|
+
return /* @__PURE__ */ L("div", {
|
|
648
|
+
className: "w-full pt-8 break-words",
|
|
649
|
+
children: [
|
|
650
|
+
/* @__PURE__ */ L("button", {
|
|
651
|
+
onClick: () => r(!t),
|
|
652
|
+
className: "flex items-center gap-3 group text-left w-full",
|
|
653
|
+
children: [/* @__PURE__ */ I("div", {
|
|
654
|
+
className: "flex-shrink-0 p-1.5 rounded-lg bg-secondary/50 group-hover:bg-secondary transition-colors duration-200",
|
|
655
|
+
children: I(t ? H : U, {
|
|
656
|
+
size: 18,
|
|
657
|
+
className: "text-muted-foreground group-hover:text-foreground transition-colors"
|
|
658
|
+
})
|
|
659
|
+
}), /* @__PURE__ */ I("h2", {
|
|
660
|
+
className: "text-foreground font-medium text-lg lg:text-3xl lg:w-9/12 group-hover:text-foreground/80 transition-colors line-clamp-3 lg:line-clamp-none",
|
|
661
|
+
children: e.userMessage.content
|
|
662
|
+
})]
|
|
663
|
+
}),
|
|
664
|
+
/* @__PURE__ */ L("div", {
|
|
665
|
+
className: "flex items-center gap-0.5 mt-1 ml-10",
|
|
666
|
+
children: [
|
|
667
|
+
(() => {
|
|
668
|
+
let t = i(e.userMessage.createdAt);
|
|
669
|
+
return t ? /* @__PURE__ */ I("time", {
|
|
670
|
+
dateTime: new Date(e.userMessage.createdAt).toISOString(),
|
|
671
|
+
className: "mr-1.5 text-xs text-muted-foreground tabular-nums select-none",
|
|
672
|
+
children: t
|
|
673
|
+
}) : null;
|
|
674
|
+
})(),
|
|
675
|
+
/* @__PURE__ */ L(u, { children: [/* @__PURE__ */ I(l, {
|
|
676
|
+
asChild: !0,
|
|
677
|
+
children: /* @__PURE__ */ I("button", {
|
|
678
|
+
onClick: m,
|
|
679
|
+
className: "p-1.5 text-muted-foreground rounded-lg hover:bg-secondary transition-all duration-200 hover:text-foreground",
|
|
680
|
+
children: /* @__PURE__ */ I("span", {
|
|
681
|
+
className: n("flex items-center transition-all duration-300", p ? "scale-110" : "scale-100"),
|
|
682
|
+
children: p ? /* @__PURE__ */ I(V, {
|
|
683
|
+
size: 14,
|
|
684
|
+
className: "text-green-500"
|
|
685
|
+
}) : /* @__PURE__ */ I(W, { size: 14 })
|
|
686
|
+
})
|
|
687
|
+
})
|
|
688
|
+
}), /* @__PURE__ */ I(c, {
|
|
689
|
+
side: "bottom",
|
|
690
|
+
children: p ? "Copied!" : "Copy prompt"
|
|
691
|
+
})] }),
|
|
692
|
+
/* @__PURE__ */ L(u, { children: [/* @__PURE__ */ I(l, {
|
|
693
|
+
asChild: !0,
|
|
694
|
+
children: /* @__PURE__ */ I("button", {
|
|
695
|
+
onClick: () => {
|
|
696
|
+
d(e.userMessage.content), o(!0), setTimeout(() => h.current?.focus(), 50);
|
|
697
|
+
},
|
|
698
|
+
className: "p-1.5 text-muted-foreground rounded-lg hover:bg-secondary transition-all duration-200 hover:text-foreground",
|
|
699
|
+
children: /* @__PURE__ */ I(le, { size: 14 })
|
|
700
|
+
})
|
|
701
|
+
}), /* @__PURE__ */ I(c, {
|
|
702
|
+
side: "bottom",
|
|
703
|
+
children: "Edit & resubmit"
|
|
704
|
+
})] })
|
|
705
|
+
]
|
|
706
|
+
}),
|
|
707
|
+
/* @__PURE__ */ I(Fe, { files: e.userMessage.files }),
|
|
708
|
+
a && /* @__PURE__ */ L("div", {
|
|
709
|
+
className: "mt-3 ml-10 flex flex-col gap-2",
|
|
710
|
+
children: [/* @__PURE__ */ I("textarea", {
|
|
711
|
+
ref: h,
|
|
712
|
+
value: s,
|
|
713
|
+
onChange: (e) => d(e.target.value),
|
|
714
|
+
onKeyDown: (e) => {
|
|
715
|
+
e.key === "Enter" && !e.shiftKey && (e.preventDefault(), f()), e.key === "Escape" && o(!1);
|
|
716
|
+
},
|
|
717
|
+
rows: 3,
|
|
718
|
+
className: "w-full rounded-xl border border-border bg-background p-3 text-sm resize-none focus:outline-none focus:ring-2 focus:ring-primary/30 transition-colors"
|
|
719
|
+
}), /* @__PURE__ */ L("div", {
|
|
720
|
+
className: "flex gap-2 justify-end",
|
|
721
|
+
children: [/* @__PURE__ */ I("button", {
|
|
722
|
+
onClick: () => o(!1),
|
|
723
|
+
className: "px-3 py-1.5 text-sm text-muted-foreground rounded-lg hover:bg-secondary transition-colors duration-200",
|
|
724
|
+
children: "Cancel"
|
|
725
|
+
}), /* @__PURE__ */ I("button", {
|
|
726
|
+
onClick: f,
|
|
727
|
+
disabled: !s.trim(),
|
|
728
|
+
className: "px-3 py-1.5 text-sm bg-primary text-primary-foreground rounded-lg hover:bg-primary/90 disabled:opacity-50 disabled:cursor-not-allowed transition-colors duration-200",
|
|
729
|
+
children: "Resubmit"
|
|
730
|
+
})]
|
|
731
|
+
})]
|
|
732
|
+
})
|
|
733
|
+
]
|
|
734
|
+
});
|
|
735
|
+
}, Le = ({ section: e, initialMessage: t }) => {
|
|
736
|
+
let [n, r] = P(!1);
|
|
737
|
+
return /* @__PURE__ */ L(u, { children: [/* @__PURE__ */ I(l, {
|
|
738
|
+
asChild: !0,
|
|
739
|
+
children: /* @__PURE__ */ I("button", {
|
|
740
|
+
onClick: () => {
|
|
741
|
+
let n = `${t}${e?.sourceMessage?.sources && e.sourceMessage.sources.length > 0 && `\n\nCitations:\n${e.sourceMessage.sources?.map((e, t) => `[${t + 1}] ${e.metadata.url}`).join("\n")}`}`;
|
|
742
|
+
navigator.clipboard.writeText(n), r(!0), setTimeout(() => r(!1), 1e3);
|
|
743
|
+
},
|
|
744
|
+
className: "p-2 text-muted-foreground rounded-full backdrop-blur-md bg-white/10 dark:bg-black/10 hover:bg-white/20 dark:hover:bg-black/20 transition duration-200 hover:text-foreground",
|
|
745
|
+
children: I(n ? V : W, { size: 18 })
|
|
746
|
+
})
|
|
747
|
+
}), /* @__PURE__ */ I(c, {
|
|
748
|
+
side: "bottom",
|
|
749
|
+
children: n ? "Copied!" : "Copy"
|
|
750
|
+
})] });
|
|
751
|
+
};
|
|
752
|
+
// src/ui/popover.tsx
|
|
753
|
+
function Re({ ...e }) {
|
|
754
|
+
return /* @__PURE__ */ I(X.Root, {
|
|
755
|
+
"data-slot": "popover",
|
|
756
|
+
...e
|
|
757
|
+
});
|
|
758
|
+
}
|
|
759
|
+
function ze({ ...e }) {
|
|
760
|
+
return /* @__PURE__ */ I(X.Trigger, {
|
|
761
|
+
"data-slot": "popover-trigger",
|
|
762
|
+
...e
|
|
763
|
+
});
|
|
764
|
+
}
|
|
765
|
+
function Be({ className: e, align: t = "center", sideOffset: r = 4, container: i, ...a }) {
|
|
766
|
+
return /* @__PURE__ */ I(X.Portal, {
|
|
767
|
+
container: i,
|
|
768
|
+
children: /* @__PURE__ */ I(X.Content, {
|
|
769
|
+
"data-slot": "popover-content",
|
|
770
|
+
align: t,
|
|
771
|
+
sideOffset: r,
|
|
772
|
+
className: n("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-72 origin-(--radix-popover-content-transform-origin) rounded-2xl border p-4 shadow-md outline-hidden", e),
|
|
773
|
+
...a
|
|
774
|
+
})
|
|
775
|
+
});
|
|
776
|
+
}
|
|
777
|
+
// src/components/MessageActions/RewriteMessageButton.tsx
|
|
778
|
+
var Ve = ({ messageId: e }) => {
|
|
779
|
+
let { rewrite: t, chatModelProvider: r, setChatModelProvider: i } = d(), [a, o] = P([]), [s, f] = P(!0), [p, m] = P(""), [h, g] = P(!1);
|
|
780
|
+
j(() => {
|
|
781
|
+
h && (async () => {
|
|
782
|
+
try {
|
|
783
|
+
f(!0);
|
|
784
|
+
let { data: e } = await _e();
|
|
785
|
+
o(e?.providers ?? []);
|
|
786
|
+
} catch (e) {
|
|
787
|
+
console.error("Error loading providers:", e);
|
|
788
|
+
} finally {
|
|
789
|
+
f(!1);
|
|
790
|
+
}
|
|
791
|
+
})();
|
|
792
|
+
}, [h]);
|
|
793
|
+
let _ = M(() => {
|
|
794
|
+
if (!r?.providerId) return a;
|
|
795
|
+
let e = a.findIndex((e) => e.id === r.providerId);
|
|
796
|
+
return e === -1 ? a : [a[e], ...a.filter((t, n) => n !== e)];
|
|
797
|
+
}, [a, r]).map((e) => ({
|
|
798
|
+
...e,
|
|
799
|
+
chatModels: (e.chatModels ?? []).filter((t) => t.name.toLowerCase().includes(p.toLowerCase()) || e.name.toLowerCase().includes(p.toLowerCase()))
|
|
800
|
+
})).filter((e) => e.chatModels.length > 0), v = M(() => {
|
|
801
|
+
if (!r.key) return "Rewrite";
|
|
802
|
+
for (let e of a) {
|
|
803
|
+
let t = e.chatModels.find((e) => e.key === r.key);
|
|
804
|
+
if (t) return t.name;
|
|
805
|
+
}
|
|
806
|
+
return r.key;
|
|
807
|
+
}, [a, r.key]), y = (n, r) => {
|
|
808
|
+
i({
|
|
809
|
+
providerId: n,
|
|
810
|
+
key: r
|
|
811
|
+
}), localStorage.setItem("chatModelProviderId", n), localStorage.setItem("chatModelKey", r), g(!1), t(e);
|
|
812
|
+
};
|
|
813
|
+
return /* @__PURE__ */ L(Re, {
|
|
814
|
+
open: h,
|
|
815
|
+
onOpenChange: g,
|
|
816
|
+
children: [/* @__PURE__ */ L(u, { children: [/* @__PURE__ */ I(l, {
|
|
817
|
+
asChild: !0,
|
|
818
|
+
children: /* @__PURE__ */ I(ze, {
|
|
819
|
+
asChild: !0,
|
|
820
|
+
children: /* @__PURE__ */ I("button", {
|
|
821
|
+
className: "p-2 text-muted-foreground rounded-full backdrop-blur-md bg-white/10 dark:bg-black/10 hover:bg-white/20 dark:hover:bg-black/20 transition duration-200 hover:text-foreground",
|
|
822
|
+
children: /* @__PURE__ */ I(z, { size: 18 })
|
|
823
|
+
})
|
|
824
|
+
})
|
|
825
|
+
}), /* @__PURE__ */ L(c, {
|
|
826
|
+
side: "bottom",
|
|
827
|
+
children: ["Rewrite with ", v]
|
|
828
|
+
})] }), /* @__PURE__ */ I(Be, {
|
|
829
|
+
className: "w-[280px] p-0",
|
|
830
|
+
align: "start",
|
|
831
|
+
side: "top",
|
|
832
|
+
sideOffset: 8,
|
|
833
|
+
children: /* @__PURE__ */ L("div", {
|
|
834
|
+
className: "bg-white dark:bg-[#212121] max-h-[400px] border rounded-2xl border-[#DDDDDD] dark:border-[#30302E] w-full flex flex-col shadow-2xl overflow-hidden",
|
|
835
|
+
children: [/* @__PURE__ */ I("div", {
|
|
836
|
+
className: "p-3 border-b border-[#EEEEEE] dark:border-[#30302E]",
|
|
837
|
+
children: /* @__PURE__ */ L("div", {
|
|
838
|
+
className: "relative",
|
|
839
|
+
children: [/* @__PURE__ */ I(J, {
|
|
840
|
+
size: 14,
|
|
841
|
+
className: "absolute left-3 top-1/2 -translate-y-1/2 text-text-400 dark:text-[#999999]"
|
|
842
|
+
}), /* @__PURE__ */ I("input", {
|
|
843
|
+
type: "text",
|
|
844
|
+
placeholder: "Search models...",
|
|
845
|
+
value: p,
|
|
846
|
+
onChange: (e) => m(e.target.value),
|
|
847
|
+
className: "w-full pl-9 pr-3 py-2 text-[13px] bg-bg-100 dark:bg-[#30302E] border border-bg-300 dark:border-[#404040] rounded-lg text-text-100 dark:text-[#ECECEC] placeholder:text-text-400 dark:placeholder:text-[#999999] focus:outline-none focus:ring-2 focus:ring-sky-500/20 focus:border-sky-500/30 transition-all"
|
|
848
|
+
})]
|
|
849
|
+
})
|
|
850
|
+
}), /* @__PURE__ */ I("div", {
|
|
851
|
+
className: "max-h-[320px] overflow-y-auto",
|
|
852
|
+
children: s ? /* @__PURE__ */ I("div", {
|
|
853
|
+
className: "flex items-center justify-center py-12",
|
|
854
|
+
children: /* @__PURE__ */ I(w.Loader2, {
|
|
855
|
+
className: "animate-spin text-text-400 dark:text-[#999999]",
|
|
856
|
+
size: 20
|
|
857
|
+
})
|
|
858
|
+
}) : _.length === 0 ? /* @__PURE__ */ I("div", {
|
|
859
|
+
className: "text-center py-12 px-4 text-text-400 dark:text-[#999999] text-sm",
|
|
860
|
+
children: p ? "No models found" : "No chat models configured"
|
|
861
|
+
}) : /* @__PURE__ */ I("div", {
|
|
862
|
+
className: "flex flex-col",
|
|
863
|
+
children: _.map((e, t) => /* @__PURE__ */ L("div", { children: [
|
|
864
|
+
/* @__PURE__ */ I("div", {
|
|
865
|
+
className: "px-4 py-2 sticky top-0 bg-white dark:bg-[#212121] border-b border-[#EEEEEE]/50 dark:border-[#30302E]/50",
|
|
866
|
+
children: /* @__PURE__ */ I("p", {
|
|
867
|
+
className: "text-[11px] text-text-400 dark:text-[#999999] uppercase tracking-wider font-medium",
|
|
868
|
+
children: e.name
|
|
869
|
+
})
|
|
870
|
+
}),
|
|
871
|
+
/* @__PURE__ */ I("div", {
|
|
872
|
+
className: "flex flex-col px-1.5 py-1.5 space-y-0.5",
|
|
873
|
+
children: e.chatModels.map((t) => /* @__PURE__ */ L("button", {
|
|
874
|
+
onClick: () => y(e.id, t.key),
|
|
875
|
+
type: "button",
|
|
876
|
+
className: n("px-3 py-2 flex items-center justify-between text-start duration-200 cursor-pointer transition rounded-xl group", r?.providerId === e.id && r?.key === t.key ? "bg-sky-50 dark:bg-sky-500/10" : "hover:bg-bg-100 dark:hover:bg-[#30302E]"),
|
|
877
|
+
children: [/* @__PURE__ */ L("div", {
|
|
878
|
+
className: "flex items-center space-x-2.5 min-w-0 flex-1",
|
|
879
|
+
children: [/* @__PURE__ */ I(te, {
|
|
880
|
+
size: 14,
|
|
881
|
+
className: n("shrink-0", r?.providerId === e.id && r?.key === t.key ? "text-sky-500" : "text-text-400 dark:text-[#999999] group-hover:text-text-300 dark:group-hover:text-[#B4B4B4]")
|
|
882
|
+
}), /* @__PURE__ */ I("p", {
|
|
883
|
+
className: n("text-[13px] truncate", r?.providerId === e.id && r?.key === t.key ? "text-sky-600 dark:text-sky-400 font-medium" : "text-text-200 dark:text-[#ECECEC] group-hover:text-text-100 dark:group-hover:text-white"),
|
|
884
|
+
children: t.name
|
|
885
|
+
})]
|
|
886
|
+
}), r?.providerId === e.id && r?.key === t.key && /* @__PURE__ */ I(w.Check, { className: "w-4 h-4 text-sky-500 shrink-0" })]
|
|
887
|
+
}, t.key))
|
|
888
|
+
}),
|
|
889
|
+
t < _.length - 1 && /* @__PURE__ */ I("div", { className: "h-px bg-[#EEEEEE] dark:bg-[#30302E] mx-2" })
|
|
890
|
+
] }, e.id))
|
|
891
|
+
})
|
|
892
|
+
})]
|
|
893
|
+
})
|
|
894
|
+
})]
|
|
895
|
+
});
|
|
896
|
+
}, He = ({ section: e, speechStatus: t, isLoadingTTS: n = !1, start: r, stop: i, handleOpenInLLM: a }) => e.assistantMessage ? /* @__PURE__ */ I("div", {
|
|
897
|
+
className: "flex flex-row items-center justify-end w-full text-foreground py-4 -mx-2",
|
|
898
|
+
children: /* @__PURE__ */ L("div", {
|
|
899
|
+
className: "flex flex-row items-center space-x-1",
|
|
900
|
+
children: [
|
|
901
|
+
/* @__PURE__ */ I(Ve, { messageId: e.assistantMessage.messageId }),
|
|
902
|
+
/* @__PURE__ */ I(Le, {
|
|
903
|
+
initialMessage: e.assistantMessage.content,
|
|
904
|
+
section: e
|
|
905
|
+
}),
|
|
906
|
+
/* @__PURE__ */ L(u, { children: [/* @__PURE__ */ I(l, {
|
|
907
|
+
asChild: !0,
|
|
908
|
+
children: /* @__PURE__ */ I("button", {
|
|
909
|
+
onClick: () => {
|
|
910
|
+
t === "started" ? i() : r();
|
|
911
|
+
},
|
|
912
|
+
disabled: n,
|
|
913
|
+
className: "p-2 text-muted-foreground rounded-full backdrop-blur-md bg-white/10 dark:bg-black/10 hover:bg-white/20 dark:hover:bg-black/20 transition duration-200 hover:text-foreground disabled:opacity-50 disabled:cursor-not-allowed",
|
|
914
|
+
children: n ? /* @__PURE__ */ I(q, {
|
|
915
|
+
size: 18,
|
|
916
|
+
className: "animate-spin"
|
|
917
|
+
}) : I(t === "started" ? de : me, { size: 18 })
|
|
918
|
+
})
|
|
919
|
+
}), /* @__PURE__ */ I(c, {
|
|
920
|
+
side: "bottom",
|
|
921
|
+
children: n ? "Loading TTS..." : t === "started" ? "Stop" : "Read aloud"
|
|
922
|
+
})] }),
|
|
923
|
+
/* @__PURE__ */ L(b, { children: [/* @__PURE__ */ L(u, { children: [/* @__PURE__ */ I(l, {
|
|
924
|
+
asChild: !0,
|
|
925
|
+
children: /* @__PURE__ */ I(h, {
|
|
926
|
+
asChild: !0,
|
|
927
|
+
children: /* @__PURE__ */ I("button", {
|
|
928
|
+
className: "p-2 text-muted-foreground rounded-full backdrop-blur-md bg-white/10 dark:bg-black/10 hover:bg-white/20 dark:hover:bg-black/20 transition duration-200 hover:text-foreground",
|
|
929
|
+
children: /* @__PURE__ */ I(ne, { size: 18 })
|
|
930
|
+
})
|
|
931
|
+
})
|
|
932
|
+
}), /* @__PURE__ */ I(c, {
|
|
933
|
+
side: "bottom",
|
|
934
|
+
children: "Export"
|
|
935
|
+
})] }), /* @__PURE__ */ L(y, {
|
|
936
|
+
align: "end",
|
|
937
|
+
side: "top",
|
|
938
|
+
children: [
|
|
939
|
+
/* @__PURE__ */ L(x, {
|
|
940
|
+
onClick: () => f(e.userMessage.content, e.assistantMessage.content),
|
|
941
|
+
children: [/* @__PURE__ */ I(K, { size: 16 }), "Markdown"]
|
|
942
|
+
}),
|
|
943
|
+
/* @__PURE__ */ L(x, {
|
|
944
|
+
onClick: () => m(e.userMessage.content, e.assistantMessage.content),
|
|
945
|
+
children: [/* @__PURE__ */ I(oe, { size: 16 }), "PDF"]
|
|
946
|
+
}),
|
|
947
|
+
/* @__PURE__ */ L(x, {
|
|
948
|
+
onClick: () => v(e.userMessage.content, e.assistantMessage.content),
|
|
949
|
+
children: [/* @__PURE__ */ I(ie, { size: 16 }), "DOCX"]
|
|
950
|
+
}),
|
|
951
|
+
/* @__PURE__ */ L(x, {
|
|
952
|
+
onClick: () => C(e.userMessage.content, e.assistantMessage.content),
|
|
953
|
+
children: [/* @__PURE__ */ I(ae, { size: 16 }), "Google Docs"]
|
|
954
|
+
})
|
|
955
|
+
]
|
|
956
|
+
})] }),
|
|
957
|
+
/* @__PURE__ */ L(b, { children: [/* @__PURE__ */ L(u, { children: [/* @__PURE__ */ I(l, {
|
|
958
|
+
asChild: !0,
|
|
959
|
+
children: /* @__PURE__ */ I(h, {
|
|
960
|
+
asChild: !0,
|
|
961
|
+
children: /* @__PURE__ */ I("button", {
|
|
962
|
+
className: "p-2 text-muted-foreground rounded-full backdrop-blur-md bg-white/10 dark:bg-black/10 hover:bg-white/20 dark:hover:bg-black/20 transition duration-200 hover:text-foreground",
|
|
963
|
+
children: /* @__PURE__ */ I(G, { size: 18 })
|
|
964
|
+
})
|
|
965
|
+
})
|
|
966
|
+
}), /* @__PURE__ */ I(c, {
|
|
967
|
+
side: "bottom",
|
|
968
|
+
children: "Open in LLM"
|
|
969
|
+
})] }), /* @__PURE__ */ L(y, {
|
|
970
|
+
align: "end",
|
|
971
|
+
side: "top",
|
|
972
|
+
children: [
|
|
973
|
+
/* @__PURE__ */ I(x, {
|
|
974
|
+
onClick: () => a("qwksearch"),
|
|
975
|
+
children: "QwkSearch"
|
|
976
|
+
}),
|
|
977
|
+
/* @__PURE__ */ I(x, {
|
|
978
|
+
onClick: () => a("claude"),
|
|
979
|
+
children: "Claude"
|
|
980
|
+
}),
|
|
981
|
+
/* @__PURE__ */ I(x, {
|
|
982
|
+
onClick: () => a("perplexity"),
|
|
983
|
+
children: "Perplexity"
|
|
984
|
+
}),
|
|
985
|
+
/* @__PURE__ */ I(x, {
|
|
986
|
+
onClick: () => a("gemini"),
|
|
987
|
+
children: "Google Gemini"
|
|
988
|
+
}),
|
|
989
|
+
/* @__PURE__ */ I(x, {
|
|
990
|
+
onClick: () => a("chatgpt"),
|
|
991
|
+
children: "ChatGPT"
|
|
992
|
+
})
|
|
993
|
+
]
|
|
994
|
+
})] })
|
|
995
|
+
]
|
|
996
|
+
})
|
|
997
|
+
}) : null, Ue = ({ section: e, isLast: t, loading: n, sendMessage: r }) => {
|
|
998
|
+
let i = N([]);
|
|
999
|
+
return j(() => {
|
|
1000
|
+
e.suggestions && e.suggestions.length > 0 && (i.current = e.suggestions.slice(0, 5));
|
|
1001
|
+
}, [e.suggestions]), j(() => {
|
|
1002
|
+
let e = (e) => {
|
|
1003
|
+
let t = e.target;
|
|
1004
|
+
if (t.tagName === "INPUT" || t.tagName === "TEXTAREA" || t.isContentEditable) return;
|
|
1005
|
+
let n = e.key, a = parseInt(n);
|
|
1006
|
+
a >= 1 && a <= 5 && i.current.length >= a && (e.preventDefault(), r(i.current[a - 1]));
|
|
1007
|
+
};
|
|
1008
|
+
if (t && i.current.length > 0) return window.addEventListener("keydown", e), () => window.removeEventListener("keydown", e);
|
|
1009
|
+
}, [t, r]), !e.suggestions || e.suggestions.length === 0 || !e.assistantMessage ? null : /* @__PURE__ */ I("div", {
|
|
1010
|
+
className: "mt-8 pt-6 border-t border-border/50",
|
|
1011
|
+
children: /* @__PURE__ */ I("div", {
|
|
1012
|
+
className: "space-y-2",
|
|
1013
|
+
children: e.suggestions?.slice(0, 5).map((e, t) => /* @__PURE__ */ I("button", {
|
|
1014
|
+
onClick: () => r(e),
|
|
1015
|
+
className: "group w-full px-4 py-4 text-left transition-all duration-200 cursor-pointer rounded-lg border border-border/50 hover:border-primary/30 hover:bg-accent/50 hover:shadow-sm",
|
|
1016
|
+
children: /* @__PURE__ */ L("div", {
|
|
1017
|
+
className: "flex items-center gap-3",
|
|
1018
|
+
children: [
|
|
1019
|
+
/* @__PURE__ */ I(_, {
|
|
1020
|
+
variant: "secondary",
|
|
1021
|
+
className: "flex-shrink-0 h-6 w-6 p-0 flex items-center justify-center rounded-full text-sm font-semibold",
|
|
1022
|
+
children: t + 1
|
|
1023
|
+
}),
|
|
1024
|
+
/* @__PURE__ */ I("p", {
|
|
1025
|
+
className: "flex-1 text-base font-medium text-muted-foreground group-hover:text-primary transition-colors duration-200 leading-relaxed",
|
|
1026
|
+
children: e
|
|
1027
|
+
}),
|
|
1028
|
+
/* @__PURE__ */ I(ue, {
|
|
1029
|
+
size: 18,
|
|
1030
|
+
className: "text-muted-foreground/60 group-hover:text-primary transition-colors duration-200 flex-shrink-0"
|
|
1031
|
+
})
|
|
1032
|
+
]
|
|
1033
|
+
})
|
|
1034
|
+
}, t))
|
|
1035
|
+
})
|
|
1036
|
+
});
|
|
1037
|
+
}, We = ({ section: e, dividerRef: t, isLast: r }) => {
|
|
1038
|
+
let { loading: i, sendMessage: a } = d(), [o, s] = P(!0), [c, l] = P(!1), [u, f] = P(!1), [p, m] = P(e.userMessage.content), h = () => {
|
|
1039
|
+
navigator.clipboard.writeText(e.userMessage.content), l(!0), setTimeout(() => l(!1), 1500);
|
|
1040
|
+
}, g = () => {
|
|
1041
|
+
p.trim() && (a(p.trim()), f(!1));
|
|
1042
|
+
}, _ = e.parsedAssistantMessage || "", v = e.speechMessage || "", y = e.thinkingEnded, { speechStatus: b, start: x, stop: C, isLoading: w } = S(v, { enableInterrupt: !0 }), T = (t) => {
|
|
1043
|
+
if (!e.assistantMessage) return;
|
|
1044
|
+
let n = `${e.userMessage.content}\n\n${e.assistantMessage.content}`;
|
|
1045
|
+
navigator.clipboard.writeText(n);
|
|
1046
|
+
let r = {
|
|
1047
|
+
qwksearch: "https://qwksearch.com/?q=",
|
|
1048
|
+
claude: "https://claude.ai/new?q=",
|
|
1049
|
+
perplexity: "https://www.perplexity.ai/?q=",
|
|
1050
|
+
gemini: "https://gemini.google.com/?q=",
|
|
1051
|
+
chatgpt: "https://chat.openai.com/?q="
|
|
1052
|
+
}[t];
|
|
1053
|
+
r && window.open(`${r}${encodeURIComponent(n)}`, "_blank");
|
|
1054
|
+
}, E = { overrides: {
|
|
1055
|
+
think: {
|
|
1056
|
+
component: je,
|
|
1057
|
+
props: { thinkingEnded: y }
|
|
1058
|
+
},
|
|
1059
|
+
citation: {
|
|
1060
|
+
component: ke,
|
|
1061
|
+
props: { sources: e.sourceMessage?.sources || [] }
|
|
1062
|
+
},
|
|
1063
|
+
table: { component: ({ children: e, ...t }) => /* @__PURE__ */ I("div", {
|
|
1064
|
+
className: "not-prose -mx-2 my-4 max-w-full overflow-x-auto sm:mx-0",
|
|
1065
|
+
children: /* @__PURE__ */ I("table", {
|
|
1066
|
+
...t,
|
|
1067
|
+
className: "w-max min-w-full border-collapse text-sm",
|
|
1068
|
+
children: e
|
|
1069
|
+
})
|
|
1070
|
+
}) }
|
|
1071
|
+
} };
|
|
1072
|
+
return /* @__PURE__ */ L("div", {
|
|
1073
|
+
className: "space-y-3",
|
|
1074
|
+
children: [/* @__PURE__ */ I(Ie, {
|
|
1075
|
+
section: e,
|
|
1076
|
+
isExpanded: o,
|
|
1077
|
+
setIsExpanded: s,
|
|
1078
|
+
isEditing: u,
|
|
1079
|
+
setIsEditing: f,
|
|
1080
|
+
editText: p,
|
|
1081
|
+
setEditText: m,
|
|
1082
|
+
handleEditSubmit: g,
|
|
1083
|
+
copiedUserMsg: c,
|
|
1084
|
+
handleCopyUserMsg: h
|
|
1085
|
+
}), /* @__PURE__ */ I("div", {
|
|
1086
|
+
className: n("flex flex-col space-y-3 overflow-hidden transition-all duration-300 ease-in-out", o ? "max-h-[100000px] opacity-100" : "max-h-0 opacity-0"),
|
|
1087
|
+
children: /* @__PURE__ */ L("div", {
|
|
1088
|
+
ref: t,
|
|
1089
|
+
className: "flex flex-col space-y-6 w-full",
|
|
1090
|
+
children: [
|
|
1091
|
+
e.searchingMessage && e.searchingMessage.queries.length > 0 && /* @__PURE__ */ I(Oe, {
|
|
1092
|
+
queries: e.searchingMessage.queries,
|
|
1093
|
+
loading: i && r
|
|
1094
|
+
}),
|
|
1095
|
+
e.sourceMessage && e.sourceMessage.sources.length > 0 && /* @__PURE__ */ I("div", {
|
|
1096
|
+
className: "flex flex-col space-y-2",
|
|
1097
|
+
children: /* @__PURE__ */ I(Te, {
|
|
1098
|
+
sources: e.sourceMessage.sources,
|
|
1099
|
+
query: e.userMessage.content
|
|
1100
|
+
})
|
|
1101
|
+
}),
|
|
1102
|
+
/* @__PURE__ */ I("div", {
|
|
1103
|
+
className: "flex min-w-0 flex-col space-y-2",
|
|
1104
|
+
children: e.assistantMessage && /* @__PURE__ */ L(F, { children: [
|
|
1105
|
+
/* @__PURE__ */ I(ye, {
|
|
1106
|
+
className: n("prose prose-lg prose-h1:mb-3 prose-h2:mb-2 prose-h2:mt-6 prose-h2:font-[800] prose-h3:mt-4 prose-h3:mb-1.5 prose-h3:font-[600] dark:prose-invert prose-p:leading-loose prose-pre:p-0 font-[400]", "min-w-0 max-w-none break-words text-foreground font-inter"),
|
|
1107
|
+
options: E,
|
|
1108
|
+
children: _
|
|
1109
|
+
}),
|
|
1110
|
+
i && r ? null : /* @__PURE__ */ I(He, {
|
|
1111
|
+
section: e,
|
|
1112
|
+
speechStatus: b,
|
|
1113
|
+
isLoadingTTS: w,
|
|
1114
|
+
start: x,
|
|
1115
|
+
stop: C,
|
|
1116
|
+
handleOpenInLLM: T
|
|
1117
|
+
}),
|
|
1118
|
+
/* @__PURE__ */ I(Ue, {
|
|
1119
|
+
section: e,
|
|
1120
|
+
isLast: r,
|
|
1121
|
+
loading: i,
|
|
1122
|
+
sendMessage: a
|
|
1123
|
+
})
|
|
1124
|
+
] })
|
|
1125
|
+
})
|
|
1126
|
+
]
|
|
1127
|
+
})
|
|
1128
|
+
})]
|
|
1129
|
+
});
|
|
1130
|
+
}, Ge = [
|
|
1131
|
+
"default",
|
|
1132
|
+
"circle",
|
|
1133
|
+
"pinwheel",
|
|
1134
|
+
"circle-filled",
|
|
1135
|
+
"ellipsis",
|
|
1136
|
+
"ring",
|
|
1137
|
+
"bars",
|
|
1138
|
+
"infinite"
|
|
1139
|
+
], Ke = "M12 12c-2-2.67-4-4-6-4a4 4 0 1 0 0 8c2 0 4-1.33 6-4Zm0 0c2 2.67 4 4 6 4a4 4 0 0 0 0-8c-2 0-4 1.33-6 4Z", Q = {
|
|
1140
|
+
transformBox: "view-box",
|
|
1141
|
+
transformOrigin: "center"
|
|
1142
|
+
}, qe = [
|
|
1143
|
+
[
|
|
1144
|
+
12,
|
|
1145
|
+
2,
|
|
1146
|
+
12,
|
|
1147
|
+
6
|
|
1148
|
+
],
|
|
1149
|
+
[
|
|
1150
|
+
16.24,
|
|
1151
|
+
7.76,
|
|
1152
|
+
19.07,
|
|
1153
|
+
4.93
|
|
1154
|
+
],
|
|
1155
|
+
[
|
|
1156
|
+
18,
|
|
1157
|
+
12,
|
|
1158
|
+
22,
|
|
1159
|
+
12
|
|
1160
|
+
],
|
|
1161
|
+
[
|
|
1162
|
+
16.24,
|
|
1163
|
+
16.24,
|
|
1164
|
+
19.07,
|
|
1165
|
+
19.07
|
|
1166
|
+
],
|
|
1167
|
+
[
|
|
1168
|
+
12,
|
|
1169
|
+
18,
|
|
1170
|
+
12,
|
|
1171
|
+
22
|
|
1172
|
+
],
|
|
1173
|
+
[
|
|
1174
|
+
4.93,
|
|
1175
|
+
19.07,
|
|
1176
|
+
7.76,
|
|
1177
|
+
16.24
|
|
1178
|
+
],
|
|
1179
|
+
[
|
|
1180
|
+
2,
|
|
1181
|
+
12,
|
|
1182
|
+
6,
|
|
1183
|
+
12
|
|
1184
|
+
],
|
|
1185
|
+
[
|
|
1186
|
+
4.93,
|
|
1187
|
+
4.93,
|
|
1188
|
+
7.76,
|
|
1189
|
+
7.76
|
|
1190
|
+
]
|
|
1191
|
+
], Je = (e) => {
|
|
1192
|
+
switch (e) {
|
|
1193
|
+
case "circle": return /* @__PURE__ */ I("g", {
|
|
1194
|
+
className: "animate-spin",
|
|
1195
|
+
style: Q,
|
|
1196
|
+
children: /* @__PURE__ */ I("path", { d: "M21 12a9 9 0 1 1-6.219-8.56" })
|
|
1197
|
+
});
|
|
1198
|
+
case "pinwheel": return /* @__PURE__ */ L("g", {
|
|
1199
|
+
className: "animate-spin",
|
|
1200
|
+
style: Q,
|
|
1201
|
+
children: [
|
|
1202
|
+
/* @__PURE__ */ I("path", { d: "M22 12a1 1 0 0 1-10 0 1 1 0 0 0-10 0" }),
|
|
1203
|
+
/* @__PURE__ */ I("path", { d: "M7 20.7a1 1 0 1 1 5-8.7 1 1 0 1 0 5-8.6" }),
|
|
1204
|
+
/* @__PURE__ */ I("path", { d: "M7 3.3a1 1 0 1 1 5 8.6 1 1 0 1 0 5 8.6" }),
|
|
1205
|
+
/* @__PURE__ */ I("circle", {
|
|
1206
|
+
cx: "12",
|
|
1207
|
+
cy: "12",
|
|
1208
|
+
r: "10"
|
|
1209
|
+
})
|
|
1210
|
+
]
|
|
1211
|
+
});
|
|
1212
|
+
case "circle-filled": return /* @__PURE__ */ L(F, { children: [/* @__PURE__ */ I("circle", {
|
|
1213
|
+
cx: "12",
|
|
1214
|
+
cy: "12",
|
|
1215
|
+
r: "9",
|
|
1216
|
+
opacity: "0.2"
|
|
1217
|
+
}), /* @__PURE__ */ I("g", {
|
|
1218
|
+
className: "animate-spin",
|
|
1219
|
+
style: Q,
|
|
1220
|
+
children: /* @__PURE__ */ I("path", { d: "M21 12a9 9 0 0 0-9-9" })
|
|
1221
|
+
})] });
|
|
1222
|
+
case "ellipsis": return /* @__PURE__ */ I("g", {
|
|
1223
|
+
fill: "currentColor",
|
|
1224
|
+
stroke: "none",
|
|
1225
|
+
children: [
|
|
1226
|
+
4,
|
|
1227
|
+
12,
|
|
1228
|
+
20
|
|
1229
|
+
].map((e, t) => /* @__PURE__ */ I("circle", {
|
|
1230
|
+
cx: e,
|
|
1231
|
+
cy: "12",
|
|
1232
|
+
r: "2.5",
|
|
1233
|
+
children: /* @__PURE__ */ I("animate", {
|
|
1234
|
+
attributeName: "cy",
|
|
1235
|
+
values: "12;7.5;12",
|
|
1236
|
+
keyTimes: "0;0.5;1",
|
|
1237
|
+
dur: "1.2s",
|
|
1238
|
+
begin: `${t * .16}s`,
|
|
1239
|
+
repeatCount: "indefinite"
|
|
1240
|
+
})
|
|
1241
|
+
}, e))
|
|
1242
|
+
});
|
|
1243
|
+
case "ring": return /* @__PURE__ */ I(F, { children: [0, -.8].map((e) => /* @__PURE__ */ L("circle", {
|
|
1244
|
+
cx: "12",
|
|
1245
|
+
cy: "12",
|
|
1246
|
+
r: "2",
|
|
1247
|
+
children: [/* @__PURE__ */ I("animate", {
|
|
1248
|
+
attributeName: "r",
|
|
1249
|
+
values: "2;11",
|
|
1250
|
+
dur: "1.6s",
|
|
1251
|
+
begin: `${e}s`,
|
|
1252
|
+
repeatCount: "indefinite"
|
|
1253
|
+
}), /* @__PURE__ */ I("animate", {
|
|
1254
|
+
attributeName: "opacity",
|
|
1255
|
+
values: "1;0",
|
|
1256
|
+
dur: "1.6s",
|
|
1257
|
+
begin: `${e}s`,
|
|
1258
|
+
repeatCount: "indefinite"
|
|
1259
|
+
})]
|
|
1260
|
+
}, e)) });
|
|
1261
|
+
case "bars": return /* @__PURE__ */ I("g", {
|
|
1262
|
+
fill: "currentColor",
|
|
1263
|
+
stroke: "none",
|
|
1264
|
+
children: [
|
|
1265
|
+
2.5,
|
|
1266
|
+
10,
|
|
1267
|
+
17.5
|
|
1268
|
+
].map((e, t) => /* @__PURE__ */ L("rect", {
|
|
1269
|
+
x: e,
|
|
1270
|
+
y: "8",
|
|
1271
|
+
width: "4",
|
|
1272
|
+
height: "8",
|
|
1273
|
+
rx: "1.5",
|
|
1274
|
+
children: [/* @__PURE__ */ I("animate", {
|
|
1275
|
+
attributeName: "height",
|
|
1276
|
+
values: "8;18;8",
|
|
1277
|
+
keyTimes: "0;0.5;1",
|
|
1278
|
+
dur: "1.1s",
|
|
1279
|
+
begin: `${t * .18}s`,
|
|
1280
|
+
repeatCount: "indefinite"
|
|
1281
|
+
}), /* @__PURE__ */ I("animate", {
|
|
1282
|
+
attributeName: "y",
|
|
1283
|
+
values: "8;3;8",
|
|
1284
|
+
keyTimes: "0;0.5;1",
|
|
1285
|
+
dur: "1.1s",
|
|
1286
|
+
begin: `${t * .18}s`,
|
|
1287
|
+
repeatCount: "indefinite"
|
|
1288
|
+
})]
|
|
1289
|
+
}, e))
|
|
1290
|
+
});
|
|
1291
|
+
case "infinite": return /* @__PURE__ */ L(F, { children: [/* @__PURE__ */ I("path", {
|
|
1292
|
+
d: Ke,
|
|
1293
|
+
opacity: "0.2"
|
|
1294
|
+
}), /* @__PURE__ */ I("path", {
|
|
1295
|
+
d: Ke,
|
|
1296
|
+
pathLength: "100",
|
|
1297
|
+
strokeDasharray: "25 75",
|
|
1298
|
+
children: /* @__PURE__ */ I("animate", {
|
|
1299
|
+
attributeName: "stroke-dashoffset",
|
|
1300
|
+
values: "100;0",
|
|
1301
|
+
dur: "1.5s",
|
|
1302
|
+
repeatCount: "indefinite"
|
|
1303
|
+
})
|
|
1304
|
+
})] });
|
|
1305
|
+
default: return /* @__PURE__ */ I("g", {
|
|
1306
|
+
className: "animate-spin",
|
|
1307
|
+
style: Q,
|
|
1308
|
+
children: qe.map(([e, t, n, r], i) => /* @__PURE__ */ I("line", {
|
|
1309
|
+
x1: e,
|
|
1310
|
+
y1: t,
|
|
1311
|
+
x2: n,
|
|
1312
|
+
y2: r,
|
|
1313
|
+
opacity: 1 - i * .1
|
|
1314
|
+
}, `${e}-${t}`))
|
|
1315
|
+
});
|
|
1316
|
+
}
|
|
1317
|
+
}, Ye = ({ variant: e = "default", size: t = 24, className: r, ...i }) => /* @__PURE__ */ I("svg", {
|
|
1318
|
+
"aria-hidden": "true",
|
|
1319
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
1320
|
+
viewBox: "0 0 24 24",
|
|
1321
|
+
width: t,
|
|
1322
|
+
height: t,
|
|
1323
|
+
fill: "none",
|
|
1324
|
+
stroke: "currentColor",
|
|
1325
|
+
strokeWidth: 2,
|
|
1326
|
+
strokeLinecap: "round",
|
|
1327
|
+
strokeLinejoin: "round",
|
|
1328
|
+
className: n("shrink-0", r),
|
|
1329
|
+
...i,
|
|
1330
|
+
children: Je(e)
|
|
1331
|
+
}), Xe = "quantumSphere", Ze = "spinner:", Qe = /* @__PURE__ */ new Set([
|
|
1332
|
+
"loadingSpokes",
|
|
1333
|
+
"loadingCircleNotch",
|
|
1334
|
+
"loadingPinwheel",
|
|
1335
|
+
"loadingCircleTrack",
|
|
1336
|
+
"loadingDotsBounce",
|
|
1337
|
+
"loadingPulseRing",
|
|
1338
|
+
"loadingEqualizerBars",
|
|
1339
|
+
"loadingInfiniteDash"
|
|
1340
|
+
]), $e = Object.fromEntries(Object.entries(be).filter(([e, t]) => typeof t == "function" && e.startsWith("loading") && !Qe.has(e))), et = [
|
|
1341
|
+
Xe,
|
|
1342
|
+
...Ge.map((e) => `${Ze}${e}`),
|
|
1343
|
+
...Object.keys($e).sort()
|
|
1344
|
+
], $;
|
|
1345
|
+
function tt() {
|
|
1346
|
+
let e = et.filter((e) => e !== $), t = e.length > 0 ? e : et;
|
|
1347
|
+
return $ = t[Math.floor(Math.random() * t.length)], $;
|
|
1348
|
+
}
|
|
1349
|
+
function nt(e) {
|
|
1350
|
+
if (!e.startsWith("spinner:")) return;
|
|
1351
|
+
let t = e.slice(8);
|
|
1352
|
+
return Ge.find((e) => e === t);
|
|
1353
|
+
}
|
|
1354
|
+
function rt(e, t) {
|
|
1355
|
+
let n = $e[e];
|
|
1356
|
+
return n ? n({
|
|
1357
|
+
size: t,
|
|
1358
|
+
raw: !0
|
|
1359
|
+
}) : "";
|
|
1360
|
+
}
|
|
1361
|
+
// src/components/ChatConversation/RandomLoadingAnimation.tsx
|
|
1362
|
+
var it = ({ size: e = 140, className: t }) => {
|
|
1363
|
+
let [r, i] = P(null);
|
|
1364
|
+
j(() => {
|
|
1365
|
+
i(tt());
|
|
1366
|
+
}, []);
|
|
1367
|
+
let a = r ? nt(r) : void 0;
|
|
1368
|
+
return /* @__PURE__ */ I("div", {
|
|
1369
|
+
role: "status",
|
|
1370
|
+
"aria-label": "Loading",
|
|
1371
|
+
className: n("flex items-center justify-center w-full h-[200px]", t),
|
|
1372
|
+
children: r === "quantumSphere" ? /* @__PURE__ */ I(ve, { autoRandomize: !0 }) : a ? /* @__PURE__ */ I(Ye, {
|
|
1373
|
+
variant: a,
|
|
1374
|
+
size: e,
|
|
1375
|
+
className: "text-muted-foreground"
|
|
1376
|
+
}) : r ? /* @__PURE__ */ I("div", {
|
|
1377
|
+
className: "flex items-center justify-center",
|
|
1378
|
+
dangerouslySetInnerHTML: { __html: rt(r, e) }
|
|
1379
|
+
}) : null
|
|
1380
|
+
});
|
|
1381
|
+
}, at = O(() => import("./ArticleExtractPanel-BPNXuezE.js")), ot = () => {
|
|
1382
|
+
let { sections: e, chatTurns: t, loading: n, messageAppeared: r, newChat: i, chatId: a } = d(), { isOpen: c, panelWidth: l } = o(), { isAuthenticated: u } = s(), [f, p] = P(!1);
|
|
1383
|
+
j(() => {
|
|
1384
|
+
c && p(!0);
|
|
1385
|
+
}, [c]);
|
|
1386
|
+
let [m, h] = P(!1), _ = N(null), v = N(null), y = N(!1);
|
|
1387
|
+
j(() => {
|
|
1388
|
+
let e = () => {
|
|
1389
|
+
h(window.innerWidth >= 1024);
|
|
1390
|
+
};
|
|
1391
|
+
return e(), window.addEventListener("resize", e), () => window.removeEventListener("resize", e);
|
|
1392
|
+
}, []), j(() => {
|
|
1393
|
+
t.length === 1 && (document.title = `${t[0].content.substring(0, 30)} - ${T.appName}`), t[t.length - 1]?.role === "user" && (y.current = !0, v.current?.scrollIntoView({ behavior: "auto" }), setTimeout(() => {
|
|
1394
|
+
y.current = !1;
|
|
1395
|
+
}, 100));
|
|
1396
|
+
}, [t]);
|
|
1397
|
+
let b = m && c ? { width: `calc(100% - ${l}px)` } : {};
|
|
1398
|
+
return /* @__PURE__ */ L(F, { children: [/* @__PURE__ */ L("div", {
|
|
1399
|
+
className: "flex flex-col min-h-full transition-all duration-300",
|
|
1400
|
+
style: b,
|
|
1401
|
+
children: [/* @__PURE__ */ L("div", {
|
|
1402
|
+
className: `flex-1 flex flex-col space-y-3 pb-48 ${m && !c ? "px-0 max-w-[800px] mx-auto w-full" : "px-4 lg:px-8"}`,
|
|
1403
|
+
children: [
|
|
1404
|
+
e.map((t, n) => {
|
|
1405
|
+
let r = n === e.length - 1;
|
|
1406
|
+
return /* @__PURE__ */ L(E, { children: [/* @__PURE__ */ I(We, {
|
|
1407
|
+
section: t,
|
|
1408
|
+
sectionIndex: n,
|
|
1409
|
+
dividerRef: r ? _ : void 0,
|
|
1410
|
+
isLast: r
|
|
1411
|
+
}), !r && /* @__PURE__ */ I("div", { className: "h-px w-full bg-light-secondary dark:bg-dark-secondary" })] }, t.userMessage.messageId);
|
|
1412
|
+
}),
|
|
1413
|
+
n && !r && /* @__PURE__ */ I(it, {}),
|
|
1414
|
+
/* @__PURE__ */ I("div", {
|
|
1415
|
+
ref: v,
|
|
1416
|
+
className: "h-0"
|
|
1417
|
+
})
|
|
1418
|
+
]
|
|
1419
|
+
}), /* @__PURE__ */ I("div", {
|
|
1420
|
+
className: "sticky bottom-[60px] md:bottom-0 z-40 bg-gradient-to-t from-background via-background to-transparent pt-4 pb-2",
|
|
1421
|
+
children: /* @__PURE__ */ I(g, {})
|
|
1422
|
+
})]
|
|
1423
|
+
}), (f || c) && /* @__PURE__ */ I(D, {
|
|
1424
|
+
fallback: null,
|
|
1425
|
+
children: /* @__PURE__ */ I(at, {})
|
|
1426
|
+
})] });
|
|
1427
|
+
};
|
|
1428
|
+
export { ot as default };
|