research-agent-ui 0.1.81 → 0.1.83
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api/handlers/chat-title.d.ts +9 -0
- package/dist/api/index.d.ts +1 -0
- package/dist/api.cjs +4 -4
- package/dist/api.mjs +114 -86
- package/dist/components/ArticleReader/ArticleActionButtons.d.ts +4 -0
- package/dist/components/ArticleReader/ArticleContent.d.ts +1 -0
- package/dist/components/ArticleReader/LexicalArticleViewer.d.ts +2 -0
- package/dist/index.cjs +13 -13
- package/dist/index.mjs +789 -625
- package/dist/lib/chatTitle.d.ts +8 -0
- package/dist/lib/relative-time.d.ts +6 -0
- package/dist/types/research.d.ts +2 -0
- package/package.json +6 -6
package/dist/index.mjs
CHANGED
|
@@ -8,40 +8,40 @@ import { clsx as _ } from "clsx";
|
|
|
8
8
|
import { twMerge as v } from "tailwind-merge";
|
|
9
9
|
import y from "markdown-to-jsx";
|
|
10
10
|
import * as b from "lucide-react";
|
|
11
|
-
import { AlertCircle as x, Archive as S, ArrowLeftRight as C, ArrowUp as w, BookMarked as T, Bot as E, BrainCircuit as D, CalendarDays as O, Check as k, CheckIcon as A, ChevronDown as j, ChevronRight as M, ChevronRightIcon as N, ChevronUp as P, Clipboard as F, ClipboardList as I, Clock as L, Cloud as R, CloudIcon as z, Copy as B, Cpu as ee, Download as te, ExternalLink as V, EyeOff as ne, File as re, FileDown as ie, FileSpreadsheet as ae, FileText as oe, FileType as se, FolderOpen as ce, Highlighter as le, History as ue, Link as de, Loader2 as H, Lock as fe, MessageCircleQuestion as pe, Mic as me, Paperclip as he, Pencil as ge, Pin as _e, Plus as ve, Search as ye, Settings as be, Settings2 as xe, Share2 as Se, SlidersHorizontal as Ce, Square as we, SquarePen as Te, Star as Ee, StopCircle as De, Sun as Oe, Trash as ke, Trash2 as Ae, Upload as je, Video as Me, Volume2 as Ne, X as Pe, XIcon as Fe } from "lucide-react";
|
|
12
|
-
import { addFavorite as
|
|
13
|
-
import { convertURLSafeHTMLToHTML as
|
|
14
|
-
import { AnimatePresence as
|
|
11
|
+
import { AlertCircle as x, Archive as S, ArrowLeftRight as C, ArrowUp as w, BookMarked as T, Bot as E, BrainCircuit as D, CalendarDays as O, Check as k, CheckIcon as A, ChevronDown as j, ChevronRight as M, ChevronRightIcon as N, ChevronUp as P, Clipboard as F, ClipboardList as I, Clock as L, Cloud as R, CloudIcon as z, Copy as B, Cpu as ee, Download as te, ExternalLink as V, EyeOff as ne, File as re, FileDown as ie, FileSpreadsheet as ae, FileText as oe, FileType as se, FolderOpen as ce, Highlighter as le, History as ue, Link as de, Loader2 as H, Lock as fe, MessageCircleQuestion as pe, Mic as me, Paperclip as he, Pencil as ge, Pin as _e, Plus as ve, Search as ye, Settings as be, Settings2 as xe, Share2 as Se, SlidersHorizontal as Ce, Square as we, SquarePen as Te, Star as Ee, StopCircle as De, Sun as Oe, Trash as ke, Trash2 as Ae, Upload as je, Video as Me, Volume2 as Ne, X as Pe, XIcon as Fe, ZoomIn as Ie, ZoomOut as Le } from "lucide-react";
|
|
12
|
+
import { addFavorite as Re, agentChat as ze, agentSearch as Be, articleFollowups as Ve, articleQa as He, autocomplete as Ue, createDocument as We, deleteAllChats as Ge, deleteChatById as Ke, getArticle as qe, getChatById as Je, getGoogleDriveFile as Ye, getGoogleToken as Xe, googleDocsAuth as Ze, googleDocsAuthStatus as Qe, listChats as $e, listFavorites as et, listProviders as tt, removeFavorite as nt, saveMessage as rt, searchChats as it, shareChat as at, updateArticle as ot, uploadFiles as st } from "qwksearch-api-client";
|
|
13
|
+
import { convertURLSafeHTMLToHTML as ct } from "extract-webpage/html-to-content/html-utils";
|
|
14
|
+
import { AnimatePresence as lt, animate as ut, motion as dt } from "motion/react";
|
|
15
15
|
import { Fragment as U, jsx as W, jsxs as G } from "react/jsx-runtime";
|
|
16
|
-
import
|
|
16
|
+
import ft from "grab-url";
|
|
17
17
|
import { toast as K } from "sonner";
|
|
18
|
-
import * as
|
|
18
|
+
import * as pt from "@radix-ui/react-tooltip";
|
|
19
19
|
import * as q from "@radix-ui/react-dropdown-menu";
|
|
20
|
-
import * as
|
|
21
|
-
import
|
|
22
|
-
import
|
|
23
|
-
import { Slot as
|
|
24
|
-
import { cva as
|
|
25
|
-
import
|
|
26
|
-
import * as
|
|
27
|
-
import
|
|
28
|
-
import
|
|
29
|
-
import { Streamdown as
|
|
20
|
+
import * as mt from "@radix-ui/react-popover";
|
|
21
|
+
import ht from "html2canvas";
|
|
22
|
+
import gt from "turndown";
|
|
23
|
+
import { Slot as _t } from "@radix-ui/react-slot";
|
|
24
|
+
import { cva as vt } from "class-variance-authority";
|
|
25
|
+
import yt from "quantum-sphere-loading-icon/react";
|
|
26
|
+
import * as bt from "@radix-ui/react-dialog";
|
|
27
|
+
import xt from "dompurify";
|
|
28
|
+
import St from "next/link";
|
|
29
|
+
import { Streamdown as Ct } from "streamdown";
|
|
30
30
|
//#region src/lib/utils.ts
|
|
31
31
|
function J(...e) {
|
|
32
32
|
return v(_(e));
|
|
33
33
|
}
|
|
34
|
-
var
|
|
34
|
+
var wt = (e) => {
|
|
35
35
|
let t = new Date(e);
|
|
36
36
|
return Number.isNaN(t.getTime()) ? "" : t.toLocaleTimeString([], {
|
|
37
37
|
hour: "numeric",
|
|
38
38
|
minute: "2-digit"
|
|
39
39
|
});
|
|
40
|
-
},
|
|
40
|
+
}, Tt = (e, t) => {
|
|
41
41
|
e = new Date(e), t = new Date(t);
|
|
42
42
|
let n = Math.floor(Math.abs(t.getTime() - e.getTime()) / 1e3);
|
|
43
43
|
return n < 60 ? `${n} second${n === 1 ? "" : "s"}` : n < 3600 ? `${Math.floor(n / 60)} minute${Math.floor(n / 60) === 1 ? "" : "s"}` : n < 86400 ? `${Math.floor(n / 3600)} hour${Math.floor(n / 3600) === 1 ? "" : "s"}` : n < 31536e3 ? `${Math.floor(n / 86400)} day${Math.floor(n / 86400) === 1 ? "" : "s"}` : `${Math.floor(n / 31536e3)} year${Math.floor(n / 31536e3) === 1 ? "" : "s"}`;
|
|
44
|
-
},
|
|
44
|
+
}, Et = s(({ blur: e = 0, inactiveZone: t = .7, proximity: n = 0, spread: r = 20, variant: i = "default", glow: a = !1, className: o, movementDuration: s = 2, borderWidth: l = 1, disabled: d = !0 }) => {
|
|
45
45
|
let p = f(null), m = f({
|
|
46
46
|
x: 0,
|
|
47
47
|
y: 0
|
|
@@ -62,7 +62,7 @@ var St = (e) => {
|
|
|
62
62
|
let f = l > i - n && l < i + o + n && u > a - n && u < a + c + n;
|
|
63
63
|
if (r.style.setProperty("--active", f ? "1" : "0"), !f) return;
|
|
64
64
|
let h = parseFloat(r.style.getPropertyValue("--start")) || 0;
|
|
65
|
-
|
|
65
|
+
ut(h, h + ((180 * Math.atan2(u - d[1], l - d[0]) / Math.PI + 90 - h + 180) % 360 - 180), {
|
|
66
66
|
duration: s,
|
|
67
67
|
ease: [
|
|
68
68
|
.16,
|
|
@@ -101,16 +101,16 @@ var St = (e) => {
|
|
|
101
101
|
children: /* @__PURE__ */ W("div", { className: J("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))]") })
|
|
102
102
|
})] });
|
|
103
103
|
});
|
|
104
|
-
|
|
104
|
+
Et.displayName = "GlowingEffect";
|
|
105
105
|
//#endregion
|
|
106
106
|
//#region src/components/ArticleReader/ExtractPanelContext.tsx
|
|
107
|
-
var
|
|
108
|
-
let e = l(
|
|
107
|
+
var Dt = a(void 0), Ot = () => {
|
|
108
|
+
let e = l(Dt);
|
|
109
109
|
if (!e) throw Error("useExtractPanel must be used within an ExtractPanelProvider");
|
|
110
110
|
return e;
|
|
111
|
-
},
|
|
111
|
+
}, kt = ({ children: e }) => {
|
|
112
112
|
let [t, n] = p(!1), [r, i] = p(""), [a, o] = p(""), [s, c] = p(600);
|
|
113
|
-
return /* @__PURE__ */ W(
|
|
113
|
+
return /* @__PURE__ */ W(Dt.Provider, {
|
|
114
114
|
value: {
|
|
115
115
|
isOpen: t,
|
|
116
116
|
url: r,
|
|
@@ -149,7 +149,7 @@ var Tt = a(void 0), Et = () => {
|
|
|
149
149
|
};
|
|
150
150
|
//#endregion
|
|
151
151
|
//#region src/icons/IconSearchWeb.tsx
|
|
152
|
-
function
|
|
152
|
+
function At(e) {
|
|
153
153
|
return /* @__PURE__ */ G("svg", {
|
|
154
154
|
xmlns: "http://www.w3.org/2000/svg",
|
|
155
155
|
xmlnsXlink: "http://www.w3.org/1999/xlink",
|
|
@@ -191,7 +191,7 @@ function Ot(e) {
|
|
|
191
191
|
}
|
|
192
192
|
//#endregion
|
|
193
193
|
//#region src/icons/IconSearchNews.tsx
|
|
194
|
-
function
|
|
194
|
+
function jt(e) {
|
|
195
195
|
return /* @__PURE__ */ G("svg", {
|
|
196
196
|
version: "1.1",
|
|
197
197
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -267,7 +267,7 @@ function kt(e) {
|
|
|
267
267
|
}
|
|
268
268
|
//#endregion
|
|
269
269
|
//#region src/icons/IconSearchVideos.tsx
|
|
270
|
-
function
|
|
270
|
+
function Mt(e) {
|
|
271
271
|
return /* @__PURE__ */ G("svg", {
|
|
272
272
|
version: "1.1",
|
|
273
273
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -508,7 +508,7 @@ function At(e) {
|
|
|
508
508
|
}
|
|
509
509
|
//#endregion
|
|
510
510
|
//#region src/icons/IconSearchImages.tsx
|
|
511
|
-
function
|
|
511
|
+
function Nt(e) {
|
|
512
512
|
return /* @__PURE__ */ W("svg", {
|
|
513
513
|
width: "800px",
|
|
514
514
|
height: "800px",
|
|
@@ -573,7 +573,7 @@ function jt(e) {
|
|
|
573
573
|
}
|
|
574
574
|
//#endregion
|
|
575
575
|
//#region src/icons/IconSearchAcademic.tsx
|
|
576
|
-
function
|
|
576
|
+
function Pt(e) {
|
|
577
577
|
return /* @__PURE__ */ G("svg", {
|
|
578
578
|
width: "800px",
|
|
579
579
|
height: "800px",
|
|
@@ -619,7 +619,7 @@ function Mt(e) {
|
|
|
619
619
|
}
|
|
620
620
|
//#endregion
|
|
621
621
|
//#region src/icons/IconSearchFiles.tsx
|
|
622
|
-
function
|
|
622
|
+
function Ft(e) {
|
|
623
623
|
return /* @__PURE__ */ G("svg", {
|
|
624
624
|
height: "800px",
|
|
625
625
|
width: "800px",
|
|
@@ -672,7 +672,7 @@ function Nt(e) {
|
|
|
672
672
|
}
|
|
673
673
|
//#endregion
|
|
674
674
|
//#region src/icons/IconSearchTech.tsx
|
|
675
|
-
function
|
|
675
|
+
function It(e) {
|
|
676
676
|
return /* @__PURE__ */ G("svg", {
|
|
677
677
|
height: "800px",
|
|
678
678
|
width: "800px",
|
|
@@ -799,51 +799,51 @@ function Pt(e) {
|
|
|
799
799
|
}
|
|
800
800
|
//#endregion
|
|
801
801
|
//#region src/components/SearchConfig/categories.ts
|
|
802
|
-
var
|
|
802
|
+
var Lt = [
|
|
803
803
|
{
|
|
804
804
|
code: "general",
|
|
805
|
-
icon:
|
|
805
|
+
icon: At,
|
|
806
806
|
name: "Web"
|
|
807
807
|
},
|
|
808
808
|
{
|
|
809
809
|
code: "news",
|
|
810
|
-
icon:
|
|
810
|
+
icon: jt,
|
|
811
811
|
name: "News"
|
|
812
812
|
},
|
|
813
813
|
{
|
|
814
814
|
code: "videos",
|
|
815
|
-
icon:
|
|
815
|
+
icon: Mt,
|
|
816
816
|
name: "Videos"
|
|
817
817
|
},
|
|
818
818
|
{
|
|
819
819
|
code: "images",
|
|
820
|
-
icon:
|
|
820
|
+
icon: Nt,
|
|
821
821
|
name: "Images"
|
|
822
822
|
},
|
|
823
823
|
{
|
|
824
824
|
code: "science",
|
|
825
|
-
icon:
|
|
825
|
+
icon: Pt,
|
|
826
826
|
name: "Academic"
|
|
827
827
|
},
|
|
828
828
|
{
|
|
829
829
|
code: "files",
|
|
830
|
-
icon:
|
|
830
|
+
icon: Ft,
|
|
831
831
|
name: "Files"
|
|
832
832
|
},
|
|
833
833
|
{
|
|
834
834
|
code: "it",
|
|
835
|
-
icon:
|
|
835
|
+
icon: It,
|
|
836
836
|
name: "Tech"
|
|
837
837
|
}
|
|
838
|
-
],
|
|
838
|
+
], Rt = Lt.filter((e) => [
|
|
839
839
|
"general",
|
|
840
840
|
"news",
|
|
841
841
|
"videos",
|
|
842
842
|
"images",
|
|
843
843
|
"science",
|
|
844
844
|
"files"
|
|
845
|
-
].includes(e.code)),
|
|
846
|
-
let [n, r] = p("general"), [i, a] = p(e), [o, s] = p(!1), [l, d] = p(!1), [m, h] = p(1), [g, _] = p(!0), [v, y] = p(!1), b = f(null), x = f(!1), S = f(!1), { openPanel: C, isOpen: w } =
|
|
845
|
+
].includes(e.code)), zt = ({ sources: e, query: t }) => {
|
|
846
|
+
let [n, r] = p("general"), [i, a] = p(e), [o, s] = p(!1), [l, d] = p(!1), [m, h] = p(1), [g, _] = p(!0), [v, y] = p(!1), b = f(null), x = f(!1), S = f(!1), { openPanel: C, isOpen: w } = Ot(), [T, E] = p({});
|
|
847
847
|
u(() => {
|
|
848
848
|
let e = () => {
|
|
849
849
|
y(window.innerWidth >= 1024);
|
|
@@ -855,7 +855,7 @@ var Ft = [
|
|
|
855
855
|
let D = c(async (e) => {
|
|
856
856
|
let t = e.filter((e) => e.metadata.url && e.metadata.url !== "File" && !e.metadata.iframe_src);
|
|
857
857
|
for (let e of t) try {
|
|
858
|
-
let { data: t } = await
|
|
858
|
+
let { data: t } = await qe({ query: { url: e.metadata.url } });
|
|
859
859
|
t?.cached && t?.article?.html && E((t) => ({
|
|
860
860
|
...t,
|
|
861
861
|
[e.metadata.url]: "loaded"
|
|
@@ -883,7 +883,7 @@ var Ft = [
|
|
|
883
883
|
[t]: "loading"
|
|
884
884
|
})), C(t, "");
|
|
885
885
|
try {
|
|
886
|
-
await
|
|
886
|
+
await qe({ query: { url: t } }), E((e) => ({
|
|
887
887
|
...e,
|
|
888
888
|
[t]: "loaded"
|
|
889
889
|
}));
|
|
@@ -896,7 +896,7 @@ var Ft = [
|
|
|
896
896
|
}, k = c(async () => {
|
|
897
897
|
if (!t || l || !g) return;
|
|
898
898
|
d(!0);
|
|
899
|
-
let e = m + 1, { data: r } = await
|
|
899
|
+
let e = m + 1, { data: r } = await Be({ query: {
|
|
900
900
|
q: t,
|
|
901
901
|
cat: n,
|
|
902
902
|
page: e
|
|
@@ -934,7 +934,7 @@ var Ft = [
|
|
|
934
934
|
if (!(e === n || !t)) {
|
|
935
935
|
r(e), s(!0), h(1), _(!0);
|
|
936
936
|
try {
|
|
937
|
-
let { data: n } = await
|
|
937
|
+
let { data: n } = await Be({ query: {
|
|
938
938
|
q: t,
|
|
939
939
|
cat: e,
|
|
940
940
|
page: 1
|
|
@@ -992,7 +992,7 @@ var Ft = [
|
|
|
992
992
|
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",
|
|
993
993
|
children: [/* @__PURE__ */ W("p", {
|
|
994
994
|
className: "text-xs text-white line-clamp-2",
|
|
995
|
-
children:
|
|
995
|
+
children: ct(e.metadata.title)
|
|
996
996
|
}), /* @__PURE__ */ W("p", {
|
|
997
997
|
className: "text-[10px] text-white/70 truncate mt-0.5",
|
|
998
998
|
children: e.metadata.source
|
|
@@ -1002,7 +1002,7 @@ var Ft = [
|
|
|
1002
1002
|
}, t);
|
|
1003
1003
|
if (i && a) return /* @__PURE__ */ G("div", {
|
|
1004
1004
|
className: "relative rounded-xl",
|
|
1005
|
-
children: [/* @__PURE__ */ W(
|
|
1005
|
+
children: [/* @__PURE__ */ W(Et, {
|
|
1006
1006
|
spread: 40,
|
|
1007
1007
|
glow: !0,
|
|
1008
1008
|
disabled: !1,
|
|
@@ -1032,14 +1032,14 @@ var Ft = [
|
|
|
1032
1032
|
})]
|
|
1033
1033
|
}), /* @__PURE__ */ W("p", {
|
|
1034
1034
|
className: "text-xs line-clamp-2 p-2 text-muted-foreground",
|
|
1035
|
-
children:
|
|
1035
|
+
children: ct(e.metadata.title)
|
|
1036
1036
|
})]
|
|
1037
1037
|
})]
|
|
1038
1038
|
}, t);
|
|
1039
1039
|
let o = T[e.metadata.url];
|
|
1040
1040
|
return /* @__PURE__ */ G("div", {
|
|
1041
1041
|
className: "relative rounded-xl group h-full",
|
|
1042
|
-
children: [/* @__PURE__ */ W(
|
|
1042
|
+
children: [/* @__PURE__ */ W(Et, {
|
|
1043
1043
|
spread: 40,
|
|
1044
1044
|
glow: !0,
|
|
1045
1045
|
disabled: !1,
|
|
@@ -1094,7 +1094,7 @@ var Ft = [
|
|
|
1094
1094
|
" ",
|
|
1095
1095
|
/* @__PURE__ */ W("span", {
|
|
1096
1096
|
className: "align-middle",
|
|
1097
|
-
children:
|
|
1097
|
+
children: ct(e.metadata.title)
|
|
1098
1098
|
})
|
|
1099
1099
|
]
|
|
1100
1100
|
})
|
|
@@ -1104,7 +1104,7 @@ var Ft = [
|
|
|
1104
1104
|
};
|
|
1105
1105
|
return /* @__PURE__ */ G(U, { children: [t && /* @__PURE__ */ W("div", {
|
|
1106
1106
|
className: "flex items-center gap-1 mb-3 overflow-x-auto pb-1",
|
|
1107
|
-
children:
|
|
1107
|
+
children: Rt.map((e) => /* @__PURE__ */ G("button", {
|
|
1108
1108
|
onClick: () => A(e.code),
|
|
1109
1109
|
disabled: o,
|
|
1110
1110
|
className: J("flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-sm font-medium transition-all duration-200 whitespace-nowrap", n === e.code ? "bg-primary text-primary-foreground" : "bg-secondary/50 text-muted-foreground hover:bg-secondary hover:text-foreground"),
|
|
@@ -1134,7 +1134,7 @@ var Ft = [
|
|
|
1134
1134
|
children: "No results found"
|
|
1135
1135
|
})
|
|
1136
1136
|
})] });
|
|
1137
|
-
},
|
|
1137
|
+
}, Bt = {
|
|
1138
1138
|
extract: "Extract",
|
|
1139
1139
|
arxiv: "ArXiv",
|
|
1140
1140
|
"google scholar": "Scholar",
|
|
@@ -1143,10 +1143,10 @@ var Ft = [
|
|
|
1143
1143
|
youtube: "YouTube",
|
|
1144
1144
|
Web: "Web"
|
|
1145
1145
|
};
|
|
1146
|
-
function
|
|
1147
|
-
return e ?
|
|
1146
|
+
function Vt(e) {
|
|
1147
|
+
return e ? Bt[e] ?? e : "Web";
|
|
1148
1148
|
}
|
|
1149
|
-
function
|
|
1149
|
+
function Ht({ queries: e, loading: t }) {
|
|
1150
1150
|
let n = e.filter((e) => e.status === "done").length, r = e.length, i = t && e.some((e) => e.status === "running");
|
|
1151
1151
|
return t ? /* @__PURE__ */ G("div", {
|
|
1152
1152
|
className: "rounded-xl border border-border bg-secondary/20 overflow-hidden text-sm",
|
|
@@ -1175,7 +1175,7 @@ function Bt({ queries: e, loading: t }) {
|
|
|
1175
1175
|
className: "flex items-baseline gap-1.5 min-w-0 flex-1",
|
|
1176
1176
|
children: [/* @__PURE__ */ G("span", {
|
|
1177
1177
|
className: "text-xs text-muted-foreground whitespace-nowrap flex-shrink-0",
|
|
1178
|
-
children: [
|
|
1178
|
+
children: [Vt(e.category), " ·"]
|
|
1179
1179
|
}), /* @__PURE__ */ W("span", {
|
|
1180
1180
|
className: "text-foreground/80 truncate",
|
|
1181
1181
|
children: e.query
|
|
@@ -1187,57 +1187,57 @@ function Bt({ queries: e, loading: t }) {
|
|
|
1187
1187
|
}
|
|
1188
1188
|
//#endregion
|
|
1189
1189
|
//#region src/lib/kokoro.ts
|
|
1190
|
-
var
|
|
1190
|
+
var Ut = {
|
|
1191
1191
|
device: "webgpu",
|
|
1192
1192
|
dtype: "fp32"
|
|
1193
|
-
},
|
|
1193
|
+
}, Wt = {
|
|
1194
1194
|
device: "wasm",
|
|
1195
1195
|
dtype: "q8"
|
|
1196
|
-
},
|
|
1197
|
-
function
|
|
1196
|
+
}, Gt = "hexgrad/Kokoro-82M", Kt = null, qt = null;
|
|
1197
|
+
function Jt() {
|
|
1198
1198
|
return typeof navigator < "u" && "gpu" in navigator;
|
|
1199
1199
|
}
|
|
1200
|
-
async function
|
|
1201
|
-
if (!
|
|
1200
|
+
async function Yt() {
|
|
1201
|
+
if (!Jt()) return !1;
|
|
1202
1202
|
try {
|
|
1203
1203
|
return await navigator.gpu.requestAdapter() != null;
|
|
1204
1204
|
} catch {
|
|
1205
1205
|
return !1;
|
|
1206
1206
|
}
|
|
1207
1207
|
}
|
|
1208
|
-
async function
|
|
1208
|
+
async function Xt() {
|
|
1209
1209
|
let e = [];
|
|
1210
|
-
await
|
|
1210
|
+
await Yt() && e.push(Ut), e.push(Wt);
|
|
1211
1211
|
let { KokoroTTS: t } = await import("kokoro-js"), n;
|
|
1212
1212
|
for (let r of e) try {
|
|
1213
|
-
let e = await t.from_pretrained(
|
|
1213
|
+
let e = await t.from_pretrained(Gt, {
|
|
1214
1214
|
device: r.device,
|
|
1215
1215
|
dtype: r.dtype
|
|
1216
1216
|
});
|
|
1217
|
-
return
|
|
1217
|
+
return qt = r.device, e;
|
|
1218
1218
|
} catch (e) {
|
|
1219
1219
|
n = e, console.warn(`Kokoro model failed to load on "${r.device}" backend:`, e);
|
|
1220
1220
|
}
|
|
1221
1221
|
throw n instanceof Error ? n : /* @__PURE__ */ Error("Failed to load Kokoro model");
|
|
1222
1222
|
}
|
|
1223
|
-
async function
|
|
1224
|
-
return
|
|
1225
|
-
throw
|
|
1226
|
-
}),
|
|
1223
|
+
async function Zt() {
|
|
1224
|
+
return Kt ||= Xt().catch((e) => {
|
|
1225
|
+
throw Kt = null, e;
|
|
1226
|
+
}), Kt;
|
|
1227
1227
|
}
|
|
1228
|
-
async function
|
|
1229
|
-
return
|
|
1228
|
+
async function Qt() {
|
|
1229
|
+
return Zt();
|
|
1230
1230
|
}
|
|
1231
|
-
async function
|
|
1232
|
-
let e = await
|
|
1231
|
+
async function $t() {
|
|
1232
|
+
let e = await Qt();
|
|
1233
1233
|
return Object.keys(e.voices);
|
|
1234
1234
|
}
|
|
1235
|
-
function
|
|
1236
|
-
return
|
|
1235
|
+
function en() {
|
|
1236
|
+
return qt;
|
|
1237
1237
|
}
|
|
1238
1238
|
//#endregion
|
|
1239
1239
|
//#region src/hooks/voice/useTextToVoice.ts
|
|
1240
|
-
function
|
|
1240
|
+
function tn(e, t) {
|
|
1241
1241
|
let [n, r] = p("stopped"), i = f(null), a = f(null), o = f(null), s = f(t);
|
|
1242
1242
|
s.current = t;
|
|
1243
1243
|
let l = c(() => {
|
|
@@ -1265,7 +1265,7 @@ function $t(e, t) {
|
|
|
1265
1265
|
o.current = t;
|
|
1266
1266
|
try {
|
|
1267
1267
|
if (localStorage.getItem("useTTSKokoro") !== "false") try {
|
|
1268
|
-
let t = await
|
|
1268
|
+
let t = await Qt(), n = localStorage.getItem("kokoroVoice") || "af_heart", a = (await t.generate(e.slice(0, 5e3), { voice: n })).toWav(), o = new Blob([a], { type: "audio/wav" }), s = URL.createObjectURL(o), c = new Audio(s);
|
|
1269
1269
|
i.current = c, c.onended = () => {
|
|
1270
1270
|
r("stopped"), URL.revokeObjectURL(s), i.current = null;
|
|
1271
1271
|
}, c.onerror = () => {
|
|
@@ -1275,7 +1275,7 @@ function $t(e, t) {
|
|
|
1275
1275
|
} catch (e) {
|
|
1276
1276
|
console.debug("Kokoro TTS unavailable, using server-side TTS:", e instanceof Error ? e.message : String(e));
|
|
1277
1277
|
}
|
|
1278
|
-
let n = await
|
|
1278
|
+
let n = await ft("/api/agent/voice", {
|
|
1279
1279
|
method: "POST",
|
|
1280
1280
|
body: {
|
|
1281
1281
|
text: e.slice(0, 5e3),
|
|
@@ -1308,8 +1308,8 @@ function $t(e, t) {
|
|
|
1308
1308
|
}
|
|
1309
1309
|
//#endregion
|
|
1310
1310
|
//#region src/hooks/useChat/chatConfig.ts
|
|
1311
|
-
var
|
|
1312
|
-
let r = localStorage.getItem("chatModelKey"), i = localStorage.getItem("chatModelProviderId"), a = (await
|
|
1311
|
+
var nn = async (e, t, n) => {
|
|
1312
|
+
let r = localStorage.getItem("chatModelKey"), i = localStorage.getItem("chatModelProviderId"), a = (await ft("/api/agent/providers"))?.providers || [];
|
|
1313
1313
|
if (!a || a.length === 0) {
|
|
1314
1314
|
t(!0);
|
|
1315
1315
|
return;
|
|
@@ -1329,47 +1329,52 @@ var en = async (e, t, n) => {
|
|
|
1329
1329
|
key: r,
|
|
1330
1330
|
providerId: i
|
|
1331
1331
|
}), t(!0);
|
|
1332
|
-
},
|
|
1333
|
-
function
|
|
1334
|
-
if (!
|
|
1332
|
+
}, rn = "qwksearch_guest_chats", an = typeof window < "u";
|
|
1333
|
+
function on() {
|
|
1334
|
+
if (!an) return [];
|
|
1335
1335
|
try {
|
|
1336
|
-
let e = localStorage.getItem(
|
|
1336
|
+
let e = localStorage.getItem(rn);
|
|
1337
1337
|
return e ? JSON.parse(e).sort((e, t) => new Date(t.createdAt).getTime() - new Date(e.createdAt).getTime()) : [];
|
|
1338
1338
|
} catch (e) {
|
|
1339
1339
|
return console.error("Failed to get guest chats:", e), [];
|
|
1340
1340
|
}
|
|
1341
1341
|
}
|
|
1342
|
-
function
|
|
1343
|
-
return
|
|
1342
|
+
function sn(e) {
|
|
1343
|
+
return an && on().find((t) => t.id === e) || null;
|
|
1344
1344
|
}
|
|
1345
|
-
function
|
|
1346
|
-
if (
|
|
1347
|
-
let t =
|
|
1348
|
-
n >= 0 ? t[n] = e : t.push(e), localStorage.setItem(
|
|
1345
|
+
function cn(e) {
|
|
1346
|
+
if (an) try {
|
|
1347
|
+
let t = on(), n = t.findIndex((t) => t.id === e.id);
|
|
1348
|
+
n >= 0 ? t[n] = e : t.push(e), localStorage.setItem(rn, JSON.stringify(t));
|
|
1349
1349
|
} catch (e) {
|
|
1350
1350
|
console.error("Failed to save guest chat:", e);
|
|
1351
1351
|
}
|
|
1352
1352
|
}
|
|
1353
|
-
function
|
|
1354
|
-
if (
|
|
1355
|
-
let t =
|
|
1356
|
-
localStorage.setItem(
|
|
1353
|
+
function ln(e) {
|
|
1354
|
+
if (an) try {
|
|
1355
|
+
let t = on().filter((t) => t.id !== e);
|
|
1356
|
+
localStorage.setItem(rn, JSON.stringify(t));
|
|
1357
1357
|
} catch (e) {
|
|
1358
1358
|
console.error("Failed to delete guest chat:", e);
|
|
1359
1359
|
}
|
|
1360
1360
|
}
|
|
1361
|
-
function
|
|
1362
|
-
if (
|
|
1363
|
-
localStorage.removeItem(
|
|
1361
|
+
function un() {
|
|
1362
|
+
if (an) try {
|
|
1363
|
+
localStorage.removeItem(rn);
|
|
1364
1364
|
} catch (e) {
|
|
1365
1365
|
console.error("Failed to clear guest chats:", e);
|
|
1366
1366
|
}
|
|
1367
1367
|
}
|
|
1368
|
+
function dn(e, t) {
|
|
1369
|
+
if (!an) return;
|
|
1370
|
+
let n = sn(e);
|
|
1371
|
+
n && (n.title = t, cn(n));
|
|
1372
|
+
}
|
|
1368
1373
|
//#endregion
|
|
1369
1374
|
//#region src/hooks/useChat/chatMessages.ts
|
|
1370
|
-
var
|
|
1375
|
+
var fn = async (e, t, n, r, i, a, o, s, c) => {
|
|
1371
1376
|
if (!t) {
|
|
1372
|
-
let t =
|
|
1377
|
+
let t = sn(e);
|
|
1373
1378
|
if (t) {
|
|
1374
1379
|
n(t.messages);
|
|
1375
1380
|
let e = t.messages.filter((e) => e.role === "user" || e.role === "assistant"), o = e.map((e) => [e.role, e.content]);
|
|
@@ -1377,7 +1382,7 @@ var ln = async (e, t, n, r, i, a, o, s, c) => {
|
|
|
1377
1382
|
return;
|
|
1378
1383
|
}
|
|
1379
1384
|
try {
|
|
1380
|
-
let { data: t, error: l } = await
|
|
1385
|
+
let { data: t, error: l } = await Je({ path: { id: e } });
|
|
1381
1386
|
if (l) {
|
|
1382
1387
|
let e = l.status;
|
|
1383
1388
|
if (e === 404 || e === 403) {
|
|
@@ -1407,7 +1412,7 @@ var ln = async (e, t, n, r, i, a, o, s, c) => {
|
|
|
1407
1412
|
}
|
|
1408
1413
|
}
|
|
1409
1414
|
try {
|
|
1410
|
-
let { data: t, error: l } = await
|
|
1415
|
+
let { data: t, error: l } = await Je({ path: { id: e } });
|
|
1411
1416
|
if (l) {
|
|
1412
1417
|
let e = l.status;
|
|
1413
1418
|
if (e === 404 || e === 401 || e === 403) {
|
|
@@ -1433,7 +1438,7 @@ var ln = async (e, t, n, r, i, a, o, s, c) => {
|
|
|
1433
1438
|
} catch (e) {
|
|
1434
1439
|
console.error("[chatMessages] Failed to load chat:", e), o(!0), r(!0);
|
|
1435
1440
|
}
|
|
1436
|
-
},
|
|
1441
|
+
}, pn = (e) => {
|
|
1437
1442
|
let t = [];
|
|
1438
1443
|
return e.forEach((n, r) => {
|
|
1439
1444
|
if (n.role === "user") {
|
|
@@ -1465,10 +1470,10 @@ var ln = async (e, t, n, r, i, a, o, s, c) => {
|
|
|
1465
1470
|
});
|
|
1466
1471
|
}
|
|
1467
1472
|
}), t;
|
|
1468
|
-
},
|
|
1473
|
+
}, mn = async (e) => {
|
|
1469
1474
|
let t = localStorage.getItem("chatModelKey"), n = localStorage.getItem("chatModelProviderId"), r = parseInt(localStorage.getItem("maxFollowupQuestions") || "4"), i = e.filter((e) => e.role === "user" || e.role === "assistant");
|
|
1470
1475
|
try {
|
|
1471
|
-
let e = await
|
|
1476
|
+
let e = await ft("agent/suggestions", {
|
|
1472
1477
|
method: "POST",
|
|
1473
1478
|
body: JSON.stringify({
|
|
1474
1479
|
chatHistory: i,
|
|
@@ -1483,15 +1488,15 @@ var ln = async (e, t, n, r, i, a, o, s, c) => {
|
|
|
1483
1488
|
} catch {
|
|
1484
1489
|
return [];
|
|
1485
1490
|
}
|
|
1486
|
-
},
|
|
1487
|
-
async function
|
|
1488
|
-
let { message: r, messageId: i, rewrite: a = !1 } = e, { chatId: o, loading: s, messages: c, fileIds: l, focusMode: u, category: d, optimizationMode: f, chatHistory: p, chatModelProvider: m, isAuthenticated: h, messagesRef: g, abortControllerRef: _, setLoading: v, setMessageAppeared: y, setMessages: b, setChatHistory: x, setChatModelProvider: S } = n, C = typeof window < "u" && localStorage.getItem(
|
|
1491
|
+
}, hn = 3, gn = "Analyze the uploaded file(s) and summarize the key points.", _n = () => Array.from(crypto.getRandomValues(/* @__PURE__ */ new Uint8Array(7)), (e) => e.toString(16).padStart(2, "0")).join(""), vn = "sourceExtractionEnabled", yn = "thinkingTimeLimit";
|
|
1492
|
+
async function bn(e, n) {
|
|
1493
|
+
let { message: r, messageId: i, rewrite: a = !1 } = e, { chatId: o, loading: s, messages: c, fileIds: l, focusMode: u, category: d, optimizationMode: f, chatHistory: p, chatModelProvider: m, isAuthenticated: h, messagesRef: g, abortControllerRef: _, setLoading: v, setMessageAppeared: y, setMessages: b, setChatHistory: x, setChatModelProvider: S } = n, C = typeof window < "u" && localStorage.getItem(vn) === "true", w = typeof window < "u" && Number(localStorage.getItem(yn) ?? "0") || 0;
|
|
1489
1494
|
if (s) return;
|
|
1490
1495
|
let T = r?.trim() ?? "", E = Array.isArray(l) && l.length > 0;
|
|
1491
1496
|
if (!T && !E) return;
|
|
1492
|
-
let D = T ? r :
|
|
1497
|
+
let D = T ? r : gn, O = new AbortController();
|
|
1493
1498
|
_.current = O, v(!0), y(!1), c.length <= 1 && window.history.replaceState(null, "", `/c/${o}`);
|
|
1494
|
-
let k = "", A = !1, j = !1, M = [], N = Date.now(), P = w > 0, F = "", I = "", L = i ??
|
|
1499
|
+
let k = "", A = !1, j = !1, M = [], N = Date.now(), P = w > 0, F = "", I = "", L = i ?? _n();
|
|
1495
1500
|
b((e) => [...e, {
|
|
1496
1501
|
content: D,
|
|
1497
1502
|
messageId: L,
|
|
@@ -1550,9 +1555,9 @@ async function _n(e, n) {
|
|
|
1550
1555
|
role: "source",
|
|
1551
1556
|
sources: M,
|
|
1552
1557
|
createdAt: /* @__PURE__ */ new Date()
|
|
1553
|
-
}]), M.length > 0 && (y(!0), M.slice(0,
|
|
1558
|
+
}]), M.length > 0 && (y(!0), M.slice(0, hn).forEach((e) => {
|
|
1554
1559
|
let t = e?.metadata?.url;
|
|
1555
|
-
t && t !== "File" &&
|
|
1560
|
+
t && t !== "File" && ft(`doc/article?url=${encodeURIComponent(t)}`).catch(() => {});
|
|
1556
1561
|
}))), e.type === "message" && (k += e.data, P ? (F += e.data, I ||= e.messageId, A = !0) : A ? b((t) => t.map((t) => t.messageId === e.messageId && t.role === "assistant" ? {
|
|
1557
1562
|
...t,
|
|
1558
1563
|
content: t.content + e.data
|
|
@@ -1578,7 +1583,7 @@ async function _n(e, n) {
|
|
|
1578
1583
|
let e = g.current[g.current.length - 1];
|
|
1579
1584
|
if (t.getAutoMediaSearch() && (document.getElementById(`search-images-${e.messageId}`)?.click(), document.getElementById(`search-videos-${e.messageId}`)?.click()), !j) {
|
|
1580
1585
|
j = !0;
|
|
1581
|
-
let e = await
|
|
1586
|
+
let e = await mn(g.current), t = _n();
|
|
1582
1587
|
if (b((n) => [...n, {
|
|
1583
1588
|
role: "suggestion",
|
|
1584
1589
|
suggestions: e,
|
|
@@ -1586,7 +1591,7 @@ async function _n(e, n) {
|
|
|
1586
1591
|
createdAt: /* @__PURE__ */ new Date(),
|
|
1587
1592
|
messageId: t
|
|
1588
1593
|
}]), h && e.length > 0) try {
|
|
1589
|
-
await
|
|
1594
|
+
await rt({ body: {
|
|
1590
1595
|
chatId: o,
|
|
1591
1596
|
messageId: t,
|
|
1592
1597
|
role: "suggestion",
|
|
@@ -1605,7 +1610,7 @@ async function _n(e, n) {
|
|
|
1605
1610
|
}
|
|
1606
1611
|
}, z = c.findIndex((e) => e.messageId === L);
|
|
1607
1612
|
try {
|
|
1608
|
-
let { stream: e } = await
|
|
1613
|
+
let { stream: e } = await ze({
|
|
1609
1614
|
signal: O.signal,
|
|
1610
1615
|
body: {
|
|
1611
1616
|
message: {
|
|
@@ -1656,11 +1661,11 @@ async function _n(e, n) {
|
|
|
1656
1661
|
}
|
|
1657
1662
|
//#endregion
|
|
1658
1663
|
//#region src/hooks/useChat/useChatState.ts
|
|
1659
|
-
function
|
|
1664
|
+
function xn(e) {
|
|
1660
1665
|
let [t, n] = p(e), [r, i] = p(!1), [a, o] = p(!1), [s, c] = p(!1), [l, u] = p(!1), [m, h] = p(!1), [g, _] = p(!1), [v, y] = p(!1), [b, x] = p(!1), [S, C] = p([]), [w, T] = p([]), [E, D] = p([]), [O, k] = p([]), [A, j] = p("webSearch"), [M, N] = p("general"), [P, F] = p("speed"), [I, L] = p({
|
|
1661
1666
|
key: "",
|
|
1662
1667
|
providerId: ""
|
|
1663
|
-
}), R = f([]), z = d(() => w.filter((e) => e.role === "user" || e.role === "assistant"), [w]), B = d(() =>
|
|
1668
|
+
}), R = f([]), z = d(() => w.filter((e) => e.role === "user" || e.role === "assistant"), [w]), B = d(() => pn(w), [w]);
|
|
1664
1669
|
return {
|
|
1665
1670
|
state: {
|
|
1666
1671
|
chatId: t,
|
|
@@ -1707,7 +1712,7 @@ function vn(e) {
|
|
|
1707
1712
|
}
|
|
1708
1713
|
//#endregion
|
|
1709
1714
|
//#region src/hooks/useChat/ChatContext.tsx
|
|
1710
|
-
var
|
|
1715
|
+
var Sn = a({
|
|
1711
1716
|
chatHistory: [],
|
|
1712
1717
|
chatId: "",
|
|
1713
1718
|
fileIds: [],
|
|
@@ -1741,19 +1746,41 @@ var yn = a({
|
|
|
1741
1746
|
incognito: !1,
|
|
1742
1747
|
setIncognito: () => {}
|
|
1743
1748
|
});
|
|
1744
|
-
function
|
|
1745
|
-
return l(
|
|
1749
|
+
function Cn() {
|
|
1750
|
+
return l(Sn);
|
|
1746
1751
|
}
|
|
1747
1752
|
//#endregion
|
|
1748
|
-
//#region src/
|
|
1749
|
-
var
|
|
1753
|
+
//#region src/lib/chatTitle.ts
|
|
1754
|
+
var wn = async (e, t) => {
|
|
1755
|
+
let n = localStorage.getItem("chatModelKey"), r = localStorage.getItem("chatModelProviderId"), i = t.filter((e) => e.role === "user" || e.role === "assistant").map((e) => ({
|
|
1756
|
+
role: e.role,
|
|
1757
|
+
content: e.content ?? ""
|
|
1758
|
+
}));
|
|
1759
|
+
if (i.length === 0) return "";
|
|
1760
|
+
try {
|
|
1761
|
+
let t = await ft("agent/chat-title", {
|
|
1762
|
+
method: "POST",
|
|
1763
|
+
body: JSON.stringify({
|
|
1764
|
+
chatId: e,
|
|
1765
|
+
chatHistory: i,
|
|
1766
|
+
chatModel: {
|
|
1767
|
+
providerId: r,
|
|
1768
|
+
key: n
|
|
1769
|
+
}
|
|
1770
|
+
})
|
|
1771
|
+
});
|
|
1772
|
+
return typeof t.title == "string" ? t.title : "";
|
|
1773
|
+
} catch {
|
|
1774
|
+
return "";
|
|
1775
|
+
}
|
|
1776
|
+
}, Tn = a({
|
|
1750
1777
|
user: null,
|
|
1751
1778
|
isLoading: !0,
|
|
1752
1779
|
isAuthenticated: !1,
|
|
1753
1780
|
signIn: () => {},
|
|
1754
1781
|
signOut: async () => {}
|
|
1755
1782
|
});
|
|
1756
|
-
function
|
|
1783
|
+
function En({ children: e, authClient: t, enableGoogleOneTap: n = !0 }) {
|
|
1757
1784
|
let [r, i] = p(null), [a, o] = p(!0);
|
|
1758
1785
|
return u(() => {
|
|
1759
1786
|
(async () => {
|
|
@@ -1775,7 +1802,7 @@ function Sn({ children: e, authClient: t, enableGoogleOneTap: n = !0 }) {
|
|
|
1775
1802
|
a,
|
|
1776
1803
|
r,
|
|
1777
1804
|
n
|
|
1778
|
-
]), /* @__PURE__ */ W(
|
|
1805
|
+
]), /* @__PURE__ */ W(Tn.Provider, {
|
|
1779
1806
|
value: {
|
|
1780
1807
|
user: r,
|
|
1781
1808
|
isLoading: a,
|
|
@@ -1799,23 +1826,23 @@ function Sn({ children: e, authClient: t, enableGoogleOneTap: n = !0 }) {
|
|
|
1799
1826
|
children: e
|
|
1800
1827
|
});
|
|
1801
1828
|
}
|
|
1802
|
-
function
|
|
1803
|
-
let e = l(
|
|
1829
|
+
function Dn() {
|
|
1830
|
+
let e = l(Tn);
|
|
1804
1831
|
if (!e) throw Error("useSession must be used within SessionProvider");
|
|
1805
1832
|
return e;
|
|
1806
1833
|
}
|
|
1807
1834
|
//#endregion
|
|
1808
1835
|
//#region src/hooks/useChat/ChatProvider.tsx
|
|
1809
|
-
function
|
|
1810
|
-
let t = m(), n = g(), r = h(), i = n.get("q"), { isAuthenticated: a, isLoading: o } =
|
|
1836
|
+
function On({ children: e }) {
|
|
1837
|
+
let t = m(), n = g(), r = h(), i = n.get("q"), { isAuthenticated: a, isLoading: o } = Dn(), { state: s, setters: l, messagesRef: d, chatTurns: _, sections: v } = xn(t.chatId), y = f(null), [b, x] = p(!1), S = f({}), C = f(/* @__PURE__ */ new Set());
|
|
1811
1838
|
u(() => {
|
|
1812
|
-
|
|
1839
|
+
nn(l.setChatModelProvider, l.setIsConfigReady, l.setHasError);
|
|
1813
1840
|
}, []), u(() => {
|
|
1814
1841
|
t.chatId && t.chatId !== s.chatId && (l.setChatId(t.chatId), l.setMessages([]), l.setChatHistory([]), l.setFiles([]), l.setFileIds([]), l.setIsMessagesLoaded(!1), l.setNotFound(!1), l.setNewChatCreated(!1));
|
|
1815
1842
|
}, [t.chatId, s.chatId]), u(() => {
|
|
1816
1843
|
if (s.chatId && !s.newChatCreated && !s.isMessagesLoaded && s.messages.length === 0) {
|
|
1817
1844
|
if (o) return;
|
|
1818
|
-
|
|
1845
|
+
fn(s.chatId, a, l.setMessages, l.setIsMessagesLoaded, l.setChatHistory, l.setFocusMode, l.setNotFound, l.setFiles, l.setFileIds);
|
|
1819
1846
|
} else s.chatId || (l.setNewChatCreated(!0), l.setIsMessagesLoaded(!0), l.setChatId(crypto.randomUUID()));
|
|
1820
1847
|
}, [
|
|
1821
1848
|
s.chatId,
|
|
@@ -1828,8 +1855,8 @@ function wn({ children: e }) {
|
|
|
1828
1855
|
if (!b && !a && s.chatId && s.messages.length > 0) {
|
|
1829
1856
|
let e = s.messages.filter((e) => e.role === "user" || e.role === "assistant");
|
|
1830
1857
|
if (e.length > 0) {
|
|
1831
|
-
let t = e[0].content.slice(0, 50);
|
|
1832
|
-
|
|
1858
|
+
let t = S.current[s.chatId] ?? e[0].content.slice(0, 50);
|
|
1859
|
+
cn({
|
|
1833
1860
|
id: s.chatId,
|
|
1834
1861
|
title: t,
|
|
1835
1862
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -1845,19 +1872,39 @@ function wn({ children: e }) {
|
|
|
1845
1872
|
a,
|
|
1846
1873
|
s.focusMode,
|
|
1847
1874
|
s.files
|
|
1875
|
+
]), u(() => {
|
|
1876
|
+
if (b || !s.chatId || !s.isMessagesLoaded || !s.newChatCreated || s.loading || _.filter((e) => e.role === "user").length < 2) return;
|
|
1877
|
+
let e = s.chatId;
|
|
1878
|
+
C.current.has(e) || (C.current.add(e), (async () => {
|
|
1879
|
+
let t = await wn(e, s.messages);
|
|
1880
|
+
if (!t) {
|
|
1881
|
+
C.current.delete(e);
|
|
1882
|
+
return;
|
|
1883
|
+
}
|
|
1884
|
+
S.current[e] = t, a || dn(e, t);
|
|
1885
|
+
})());
|
|
1886
|
+
}, [
|
|
1887
|
+
_,
|
|
1888
|
+
s.messages,
|
|
1889
|
+
s.chatId,
|
|
1890
|
+
s.loading,
|
|
1891
|
+
s.isMessagesLoaded,
|
|
1892
|
+
s.newChatCreated,
|
|
1893
|
+
b,
|
|
1894
|
+
a
|
|
1848
1895
|
]), u(() => {
|
|
1849
1896
|
d.current = s.messages;
|
|
1850
1897
|
}, [s.messages]), u(() => {
|
|
1851
1898
|
s.isMessagesLoaded && s.isConfigReady ? (l.setIsReady(!0), console.debug(/* @__PURE__ */ new Date(), "app:ready")) : l.setIsReady(!1);
|
|
1852
1899
|
}, [s.isMessagesLoaded, s.isConfigReady]), u(() => {
|
|
1853
|
-
s.isReady && i && s.isConfigReady &&
|
|
1900
|
+
s.isReady && i && s.isConfigReady && w(i);
|
|
1854
1901
|
}, [
|
|
1855
1902
|
s.isConfigReady,
|
|
1856
1903
|
s.isReady,
|
|
1857
1904
|
i
|
|
1858
1905
|
]);
|
|
1859
|
-
let
|
|
1860
|
-
s.chatId && await
|
|
1906
|
+
let w = c(async (e, t, n = !1) => {
|
|
1907
|
+
s.chatId && await bn({
|
|
1861
1908
|
message: e,
|
|
1862
1909
|
messageId: t,
|
|
1863
1910
|
rewrite: n
|
|
@@ -1892,20 +1939,20 @@ function wn({ children: e }) {
|
|
|
1892
1939
|
s.chatModelProvider,
|
|
1893
1940
|
a,
|
|
1894
1941
|
d
|
|
1895
|
-
]),
|
|
1942
|
+
]), T = c((e) => {
|
|
1896
1943
|
let t = s.messages.findIndex((t) => t.messageId === e), n = _.findIndex((t) => t.messageId === e);
|
|
1897
1944
|
if (t === -1) return;
|
|
1898
1945
|
let r = _[n - 1];
|
|
1899
|
-
l.setMessages((e) => [...e.slice(0, s.messages.length > 2 ? s.messages.indexOf(r) : 0)]), l.setChatHistory((e) => [...e.slice(0, _.length > 2 ? n - 1 : 0)]),
|
|
1946
|
+
l.setMessages((e) => [...e.slice(0, s.messages.length > 2 ? s.messages.indexOf(r) : 0)]), l.setChatHistory((e) => [...e.slice(0, _.length > 2 ? n - 1 : 0)]), w(r.content, r.messageId, !0);
|
|
1900
1947
|
}, [
|
|
1901
1948
|
s.messages,
|
|
1902
1949
|
_,
|
|
1903
|
-
|
|
1904
|
-
]),
|
|
1950
|
+
w
|
|
1951
|
+
]), E = c(() => {
|
|
1905
1952
|
y.current &&= (y.current.abort(), null);
|
|
1906
|
-
}, []),
|
|
1907
|
-
|
|
1908
|
-
}, [
|
|
1953
|
+
}, []), D = c(() => {
|
|
1954
|
+
E(), l.setMessages([]), l.setChatHistory([]), l.setFiles([]), l.setFileIds([]), l.setChatId(void 0), l.setNewChatCreated(!1), l.setIsMessagesLoaded(!1), l.setNotFound(!1), r.push("/");
|
|
1955
|
+
}, [E, r]), O = {
|
|
1909
1956
|
messages: s.messages,
|
|
1910
1957
|
chatTurns: _,
|
|
1911
1958
|
sections: v,
|
|
@@ -1929,52 +1976,52 @@ function wn({ children: e }) {
|
|
|
1929
1976
|
setFocusMode: l.setFocusMode,
|
|
1930
1977
|
setCategory: l.setCategory,
|
|
1931
1978
|
setOptimizationMode: l.setOptimizationMode,
|
|
1932
|
-
rewrite:
|
|
1933
|
-
sendMessage:
|
|
1979
|
+
rewrite: T,
|
|
1980
|
+
sendMessage: w,
|
|
1934
1981
|
setChatModelProvider: l.setChatModelProvider,
|
|
1935
|
-
stopStreaming:
|
|
1936
|
-
newChat:
|
|
1982
|
+
stopStreaming: E,
|
|
1983
|
+
newChat: D,
|
|
1937
1984
|
setIncognito: x
|
|
1938
1985
|
};
|
|
1939
|
-
return /* @__PURE__ */ W(
|
|
1940
|
-
value:
|
|
1986
|
+
return /* @__PURE__ */ W(Sn.Provider, {
|
|
1987
|
+
value: O,
|
|
1941
1988
|
children: e
|
|
1942
1989
|
});
|
|
1943
1990
|
}
|
|
1944
1991
|
//#endregion
|
|
1945
1992
|
//#region src/ui/tooltip.tsx
|
|
1946
|
-
function
|
|
1947
|
-
return /* @__PURE__ */ W(
|
|
1993
|
+
function kn({ delayDuration: e = 0, ...t }) {
|
|
1994
|
+
return /* @__PURE__ */ W(pt.Provider, {
|
|
1948
1995
|
"data-slot": "tooltip-provider",
|
|
1949
1996
|
delayDuration: e,
|
|
1950
1997
|
...t
|
|
1951
1998
|
});
|
|
1952
1999
|
}
|
|
1953
2000
|
function Y({ ...e }) {
|
|
1954
|
-
return /* @__PURE__ */ W(
|
|
2001
|
+
return /* @__PURE__ */ W(kn, { children: /* @__PURE__ */ W(pt.Root, {
|
|
1955
2002
|
"data-slot": "tooltip",
|
|
1956
2003
|
...e
|
|
1957
2004
|
}) });
|
|
1958
2005
|
}
|
|
1959
2006
|
function X({ ...e }) {
|
|
1960
|
-
return /* @__PURE__ */ W(
|
|
2007
|
+
return /* @__PURE__ */ W(pt.Trigger, {
|
|
1961
2008
|
"data-slot": "tooltip-trigger",
|
|
1962
2009
|
...e
|
|
1963
2010
|
});
|
|
1964
2011
|
}
|
|
1965
2012
|
function Z({ className: e, sideOffset: t = 0, children: n, ...r }) {
|
|
1966
|
-
return /* @__PURE__ */ W(
|
|
2013
|
+
return /* @__PURE__ */ W(pt.Portal, { children: /* @__PURE__ */ G(pt.Content, {
|
|
1967
2014
|
"data-slot": "tooltip-content",
|
|
1968
2015
|
sideOffset: t,
|
|
1969
2016
|
className: J("bg-primary text-primary-foreground animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-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-fit origin-(--radix-tooltip-content-transform-origin) rounded-2xl px-3 py-1.5 text-xs text-balance", e),
|
|
1970
2017
|
...r,
|
|
1971
|
-
children: [n, /* @__PURE__ */ W(
|
|
2018
|
+
children: [n, /* @__PURE__ */ W(pt.Arrow, { className: "bg-primary fill-primary z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]" })]
|
|
1972
2019
|
}) });
|
|
1973
2020
|
}
|
|
1974
2021
|
//#endregion
|
|
1975
2022
|
//#region src/components/SearchResults/WebCitationBadge.tsx
|
|
1976
|
-
var
|
|
1977
|
-
let { openPanel: r } =
|
|
2023
|
+
var An = ({ href: e, children: t, sources: n }) => {
|
|
2024
|
+
let { openPanel: r } = Ot(), i = d(() => !n || !e ? null : n.find((t) => t.metadata?.url === e) ?? null, [n, e]), a = d(() => {
|
|
1978
2025
|
try {
|
|
1979
2026
|
return new URL(e).hostname.replace("www.", "");
|
|
1980
2027
|
} catch {
|
|
@@ -2014,7 +2061,7 @@ var En = ({ href: e, children: t, sources: n }) => {
|
|
|
2014
2061
|
})]
|
|
2015
2062
|
})
|
|
2016
2063
|
})] });
|
|
2017
|
-
},
|
|
2064
|
+
}, jn = ({ content: e, thinkingEnded: t }) => {
|
|
2018
2065
|
let [n, r] = p(!0);
|
|
2019
2066
|
return u(() => {
|
|
2020
2067
|
r(!t);
|
|
@@ -2041,10 +2088,10 @@ var En = ({ href: e, children: t, sources: n }) => {
|
|
|
2041
2088
|
children: e
|
|
2042
2089
|
})]
|
|
2043
2090
|
});
|
|
2044
|
-
},
|
|
2091
|
+
}, Mn = ({ children: e, thinkingEnded: t }) => /* @__PURE__ */ W(jn, {
|
|
2045
2092
|
content: e,
|
|
2046
2093
|
thinkingEnded: t
|
|
2047
|
-
}),
|
|
2094
|
+
}), Nn = ({ section: e, isExpanded: t, setIsExpanded: n, isEditing: r, setIsEditing: i, editText: a, setEditText: o, handleEditSubmit: s, copiedUserMsg: c, handleCopyUserMsg: l }) => {
|
|
2048
2095
|
let u = f(null);
|
|
2049
2096
|
return /* @__PURE__ */ G("div", {
|
|
2050
2097
|
className: "w-full pt-8 break-words",
|
|
@@ -2067,7 +2114,7 @@ var En = ({ href: e, children: t, sources: n }) => {
|
|
|
2067
2114
|
className: "flex items-center gap-0.5 mt-1 ml-10",
|
|
2068
2115
|
children: [
|
|
2069
2116
|
(() => {
|
|
2070
|
-
let t =
|
|
2117
|
+
let t = wt(e.userMessage.createdAt);
|
|
2071
2118
|
return t ? /* @__PURE__ */ W("time", {
|
|
2072
2119
|
dateTime: new Date(e.userMessage.createdAt).toISOString(),
|
|
2073
2120
|
className: "mr-1.5 text-xs text-muted-foreground tabular-nums select-none",
|
|
@@ -2136,19 +2183,19 @@ var En = ({ href: e, children: t, sources: n }) => {
|
|
|
2136
2183
|
};
|
|
2137
2184
|
//#endregion
|
|
2138
2185
|
//#region src/ui/dropdown-menu.tsx
|
|
2139
|
-
function
|
|
2186
|
+
function Pn({ ...e }) {
|
|
2140
2187
|
return /* @__PURE__ */ W(q.Root, {
|
|
2141
2188
|
"data-slot": "dropdown-menu",
|
|
2142
2189
|
...e
|
|
2143
2190
|
});
|
|
2144
2191
|
}
|
|
2145
|
-
function
|
|
2192
|
+
function Fn({ ...e }) {
|
|
2146
2193
|
return /* @__PURE__ */ W(q.Trigger, {
|
|
2147
2194
|
"data-slot": "dropdown-menu-trigger",
|
|
2148
2195
|
...e
|
|
2149
2196
|
});
|
|
2150
2197
|
}
|
|
2151
|
-
function
|
|
2198
|
+
function In({ className: e, sideOffset: t = 4, ...n }) {
|
|
2152
2199
|
return /* @__PURE__ */ W(q.Portal, { children: /* @__PURE__ */ W(q.Content, {
|
|
2153
2200
|
"data-slot": "dropdown-menu-content",
|
|
2154
2201
|
sideOffset: t,
|
|
@@ -2165,7 +2212,7 @@ function Q({ className: e, inset: t, variant: n = "default", ...r }) {
|
|
|
2165
2212
|
...r
|
|
2166
2213
|
});
|
|
2167
2214
|
}
|
|
2168
|
-
function
|
|
2215
|
+
function Ln({ className: e, children: t, checked: n, ...r }) {
|
|
2169
2216
|
return /* @__PURE__ */ G(q.CheckboxItem, {
|
|
2170
2217
|
"data-slot": "dropdown-menu-checkbox-item",
|
|
2171
2218
|
className: J("focus:bg-accent focus:text-accent-foreground relative flex cursor-default items-center gap-2 rounded-2xl py-1.5 pr-2 pl-8 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4", e),
|
|
@@ -2177,7 +2224,7 @@ function Nn({ className: e, children: t, checked: n, ...r }) {
|
|
|
2177
2224
|
}), t]
|
|
2178
2225
|
});
|
|
2179
2226
|
}
|
|
2180
|
-
function
|
|
2227
|
+
function Rn({ className: e, inset: t, ...n }) {
|
|
2181
2228
|
return /* @__PURE__ */ W(q.Label, {
|
|
2182
2229
|
"data-slot": "dropdown-menu-label",
|
|
2183
2230
|
"data-inset": t,
|
|
@@ -2185,20 +2232,20 @@ function Pn({ className: e, inset: t, ...n }) {
|
|
|
2185
2232
|
...n
|
|
2186
2233
|
});
|
|
2187
2234
|
}
|
|
2188
|
-
function
|
|
2235
|
+
function zn({ className: e, ...t }) {
|
|
2189
2236
|
return /* @__PURE__ */ W(q.Separator, {
|
|
2190
2237
|
"data-slot": "dropdown-menu-separator",
|
|
2191
2238
|
className: J("bg-border -mx-1 my-1 h-px", e),
|
|
2192
2239
|
...t
|
|
2193
2240
|
});
|
|
2194
2241
|
}
|
|
2195
|
-
function
|
|
2242
|
+
function Bn({ ...e }) {
|
|
2196
2243
|
return /* @__PURE__ */ W(q.Sub, {
|
|
2197
2244
|
"data-slot": "dropdown-menu-sub",
|
|
2198
2245
|
...e
|
|
2199
2246
|
});
|
|
2200
2247
|
}
|
|
2201
|
-
function
|
|
2248
|
+
function Vn({ className: e, inset: t, children: n, ...r }) {
|
|
2202
2249
|
return /* @__PURE__ */ G(q.SubTrigger, {
|
|
2203
2250
|
"data-slot": "dropdown-menu-sub-trigger",
|
|
2204
2251
|
"data-inset": t,
|
|
@@ -2207,7 +2254,7 @@ function Ln({ className: e, inset: t, children: n, ...r }) {
|
|
|
2207
2254
|
children: [n, /* @__PURE__ */ W(N, { className: "ml-auto size-4" })]
|
|
2208
2255
|
});
|
|
2209
2256
|
}
|
|
2210
|
-
function
|
|
2257
|
+
function Hn({ className: e, ...t }) {
|
|
2211
2258
|
return /* @__PURE__ */ W(q.SubContent, {
|
|
2212
2259
|
"data-slot": "dropdown-menu-sub-content",
|
|
2213
2260
|
className: J("bg-card 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 min-w-[8rem] origin-(--radix-dropdown-menu-content-transform-origin) overflow-hidden rounded-2xl border p-1 shadow-lg", e),
|
|
@@ -2216,7 +2263,7 @@ function Rn({ className: e, ...t }) {
|
|
|
2216
2263
|
}
|
|
2217
2264
|
//#endregion
|
|
2218
2265
|
//#region src/components/MessageActions/CopyMessageButton.tsx
|
|
2219
|
-
var
|
|
2266
|
+
var Un = ({ section: e, initialMessage: t }) => {
|
|
2220
2267
|
let [n, r] = p(!1);
|
|
2221
2268
|
return /* @__PURE__ */ G(Y, { children: [/* @__PURE__ */ W(X, {
|
|
2222
2269
|
asChild: !0,
|
|
@@ -2235,22 +2282,22 @@ var zn = ({ section: e, initialMessage: t }) => {
|
|
|
2235
2282
|
};
|
|
2236
2283
|
//#endregion
|
|
2237
2284
|
//#region src/ui/popover.tsx
|
|
2238
|
-
function
|
|
2239
|
-
return /* @__PURE__ */ W(
|
|
2285
|
+
function Wn({ ...e }) {
|
|
2286
|
+
return /* @__PURE__ */ W(mt.Root, {
|
|
2240
2287
|
"data-slot": "popover",
|
|
2241
2288
|
...e
|
|
2242
2289
|
});
|
|
2243
2290
|
}
|
|
2244
|
-
function
|
|
2245
|
-
return /* @__PURE__ */ W(
|
|
2291
|
+
function Gn({ ...e }) {
|
|
2292
|
+
return /* @__PURE__ */ W(mt.Trigger, {
|
|
2246
2293
|
"data-slot": "popover-trigger",
|
|
2247
2294
|
...e
|
|
2248
2295
|
});
|
|
2249
2296
|
}
|
|
2250
|
-
function
|
|
2251
|
-
return /* @__PURE__ */ W(
|
|
2297
|
+
function Kn({ className: e, align: t = "center", sideOffset: n = 4, container: r, ...i }) {
|
|
2298
|
+
return /* @__PURE__ */ W(mt.Portal, {
|
|
2252
2299
|
container: r,
|
|
2253
|
-
children: /* @__PURE__ */ W(
|
|
2300
|
+
children: /* @__PURE__ */ W(mt.Content, {
|
|
2254
2301
|
"data-slot": "popover-content",
|
|
2255
2302
|
align: t,
|
|
2256
2303
|
sideOffset: n,
|
|
@@ -2295,13 +2342,13 @@ var $ = {
|
|
|
2295
2342
|
...e,
|
|
2296
2343
|
children: /* @__PURE__ */ W("path", { d: "M10.3857 2.50977C14.3486 2.71054 17.5 5.98724 17.5 10C17.5 14.1421 14.1421 17.5 10 17.5C5.85786 17.5 2.5 14.1421 2.5 10C2.5 9.72386 2.72386 9.5 3 9.5C3.27614 9.5 3.5 9.72386 3.5 10C3.5 13.5899 6.41015 16.5 10 16.5C13.5899 16.5 16.5 13.5899 16.5 10C16.5 6.5225 13.7691 3.68312 10.335 3.50879L10 3.5L9.89941 3.49023C9.67145 3.44371 9.5 3.24171 9.5 3C9.5 2.72386 9.72386 2.5 10 2.5L10.3857 2.50977ZM10 5.5C10.2761 5.5 10.5 5.72386 10.5 6V9.69043L13.2236 11.0527C13.4706 11.1762 13.5708 11.4766 13.4473 11.7236C13.3392 11.9397 13.0957 12.0435 12.8711 11.9834L12.7764 11.9473L9.77637 10.4473C9.60698 10.3626 9.5 10.1894 9.5 10V6C9.5 5.72386 9.72386 5.5 10 5.5ZM3.66211 6.94141C4.0273 6.94159 4.32303 7.23735 4.32324 7.60254C4.32324 7.96791 4.02743 8.26446 3.66211 8.26465C3.29663 8.26465 3 7.96802 3 7.60254C3.00021 7.23723 3.29676 6.94141 3.66211 6.94141ZM4.95605 4.29395C5.32146 4.29404 5.61719 4.59063 5.61719 4.95605C5.6171 5.3214 5.3214 5.61709 4.95605 5.61719C4.59063 5.61719 4.29403 5.32146 4.29395 4.95605C4.29395 4.59057 4.59057 4.29395 4.95605 4.29395ZM7.60254 3C7.96802 3 8.26465 3.29663 8.26465 3.66211C8.26446 4.02743 7.96791 4.32324 7.60254 4.32324C7.23736 4.32302 6.94159 4.0273 6.94141 3.66211C6.94141 3.29676 7.23724 3.00022 7.60254 3Z" })
|
|
2297
2344
|
})
|
|
2298
|
-
},
|
|
2299
|
-
let { rewrite: t, chatModelProvider: n, setChatModelProvider: r } =
|
|
2345
|
+
}, qn = ({ messageId: e }) => {
|
|
2346
|
+
let { rewrite: t, chatModelProvider: n, setChatModelProvider: r } = Cn(), [i, a] = p([]), [o, s] = p(!0), [c, l] = p(""), [f, m] = p(!1);
|
|
2300
2347
|
u(() => {
|
|
2301
2348
|
f && (async () => {
|
|
2302
2349
|
try {
|
|
2303
2350
|
s(!0);
|
|
2304
|
-
let { data: e } = await
|
|
2351
|
+
let { data: e } = await tt();
|
|
2305
2352
|
a(e?.providers ?? []);
|
|
2306
2353
|
} catch (e) {
|
|
2307
2354
|
console.error("Error loading providers:", e);
|
|
@@ -2330,12 +2377,12 @@ var $ = {
|
|
|
2330
2377
|
key: i
|
|
2331
2378
|
}), localStorage.setItem("chatModelProviderId", n), localStorage.setItem("chatModelKey", i), m(!1), t(e);
|
|
2332
2379
|
};
|
|
2333
|
-
return /* @__PURE__ */ G(
|
|
2380
|
+
return /* @__PURE__ */ G(Wn, {
|
|
2334
2381
|
open: f,
|
|
2335
2382
|
onOpenChange: m,
|
|
2336
2383
|
children: [/* @__PURE__ */ G(Y, { children: [/* @__PURE__ */ W(X, {
|
|
2337
2384
|
asChild: !0,
|
|
2338
|
-
children: /* @__PURE__ */ W(
|
|
2385
|
+
children: /* @__PURE__ */ W(Gn, {
|
|
2339
2386
|
asChild: !0,
|
|
2340
2387
|
children: /* @__PURE__ */ W("button", {
|
|
2341
2388
|
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",
|
|
@@ -2345,7 +2392,7 @@ var $ = {
|
|
|
2345
2392
|
}), /* @__PURE__ */ G(Z, {
|
|
2346
2393
|
side: "bottom",
|
|
2347
2394
|
children: ["Rewrite with ", g]
|
|
2348
|
-
})] }), /* @__PURE__ */ W(
|
|
2395
|
+
})] }), /* @__PURE__ */ W(Kn, {
|
|
2349
2396
|
className: "w-[280px] p-0",
|
|
2350
2397
|
align: "start",
|
|
2351
2398
|
side: "top",
|
|
@@ -2413,10 +2460,10 @@ var $ = {
|
|
|
2413
2460
|
})
|
|
2414
2461
|
})]
|
|
2415
2462
|
});
|
|
2416
|
-
},
|
|
2417
|
-
function
|
|
2463
|
+
}, Jn = /* @__PURE__ */ new Map();
|
|
2464
|
+
function Yn(e) {
|
|
2418
2465
|
if (typeof window > "u") return Promise.reject(/* @__PURE__ */ Error("CDN scripts require a browser environment"));
|
|
2419
|
-
let t =
|
|
2466
|
+
let t = Jn.get(e);
|
|
2420
2467
|
if (t) return t;
|
|
2421
2468
|
let n = new Promise((t, n) => {
|
|
2422
2469
|
let r = document.querySelector(`script[data-cdn-loader="${e}"]`);
|
|
@@ -2428,34 +2475,34 @@ function Gn(e) {
|
|
|
2428
2475
|
i.src = e, i.async = !0, i.dataset.cdnLoader = e, i.onload = () => {
|
|
2429
2476
|
i.dataset.loaded = "true", t();
|
|
2430
2477
|
}, i.onerror = () => {
|
|
2431
|
-
|
|
2478
|
+
Jn.delete(e), n(/* @__PURE__ */ Error(`Failed to load ${e}`));
|
|
2432
2479
|
}, document.head.appendChild(i);
|
|
2433
2480
|
});
|
|
2434
|
-
return
|
|
2481
|
+
return Jn.set(e, n), n;
|
|
2435
2482
|
}
|
|
2436
|
-
var
|
|
2437
|
-
async function
|
|
2438
|
-
await
|
|
2483
|
+
var Xn = "https://cdn.jsdelivr.net/npm/jspdf@2.5.2/dist/jspdf.umd.min.js", Zn = "https://cdn.jsdelivr.net/npm/docx@9.5.1/build/index.umd.min.js";
|
|
2484
|
+
async function Qn() {
|
|
2485
|
+
await Yn(Xn);
|
|
2439
2486
|
let e = window.jspdf?.jsPDF;
|
|
2440
2487
|
if (!e) throw Error("jsPDF global not found after CDN load");
|
|
2441
2488
|
return e;
|
|
2442
2489
|
}
|
|
2443
|
-
async function
|
|
2444
|
-
await
|
|
2490
|
+
async function $n() {
|
|
2491
|
+
await Yn(Zn);
|
|
2445
2492
|
let e = window.docx;
|
|
2446
2493
|
if (!e) throw Error("docx global not found after CDN load");
|
|
2447
2494
|
return e;
|
|
2448
2495
|
}
|
|
2449
2496
|
//#endregion
|
|
2450
2497
|
//#region src/lib/export.ts
|
|
2451
|
-
async function
|
|
2452
|
-
|
|
2498
|
+
async function er(e, t) {
|
|
2499
|
+
ir(`# ${e}\n\n${new gt({
|
|
2453
2500
|
headingStyle: "atx",
|
|
2454
2501
|
codeBlockStyle: "fenced"
|
|
2455
2502
|
}).turndown(t)}`, `${e}.md`, "text/markdown");
|
|
2456
2503
|
}
|
|
2457
|
-
async function
|
|
2458
|
-
let { Document: n, Paragraph: r, TextRun: i, HeadingLevel: a, Packer: o } = await
|
|
2504
|
+
async function tr(e, t) {
|
|
2505
|
+
let { Document: n, Paragraph: r, TextRun: i, HeadingLevel: a, Packer: o } = await $n(), s = new DOMParser().parseFromString(t, "text/html"), c = [];
|
|
2459
2506
|
c.push(new r({
|
|
2460
2507
|
text: e,
|
|
2461
2508
|
heading: a.HEADING_1,
|
|
@@ -2529,14 +2576,14 @@ async function Zn(e, t) {
|
|
|
2529
2576
|
}] }), d = await o.toBlob(u), f = URL.createObjectURL(d), p = document.createElement("a");
|
|
2530
2577
|
p.href = f, p.download = `${e}.docx`, p.click(), URL.revokeObjectURL(f);
|
|
2531
2578
|
}
|
|
2532
|
-
async function
|
|
2579
|
+
async function nr(e, t) {
|
|
2533
2580
|
let n = document.createElement("div");
|
|
2534
2581
|
n.style.position = "absolute", n.style.left = "-9999px", n.style.width = "210mm", n.style.padding = "20mm", n.style.backgroundColor = "white", n.style.fontFamily = "Arial, sans-serif", n.style.fontSize = "12pt", n.style.lineHeight = "1.6", n.innerHTML = `
|
|
2535
2582
|
<h1 style="font-size: 24pt; margin-bottom: 20px;">${e}</h1>
|
|
2536
2583
|
${t}
|
|
2537
2584
|
`, document.body.appendChild(n);
|
|
2538
2585
|
try {
|
|
2539
|
-
let t = await
|
|
2586
|
+
let t = await Qn(), r = await ht(n, {
|
|
2540
2587
|
scale: 2,
|
|
2541
2588
|
useCORS: !0,
|
|
2542
2589
|
logging: !1
|
|
@@ -2551,27 +2598,27 @@ async function Qn(e, t) {
|
|
|
2551
2598
|
document.body.removeChild(n);
|
|
2552
2599
|
}
|
|
2553
2600
|
}
|
|
2554
|
-
async function
|
|
2601
|
+
async function rr(e, t) {
|
|
2555
2602
|
try {
|
|
2556
|
-
let n = `${e}\n\n${new
|
|
2603
|
+
let n = `${e}\n\n${new gt().turndown(t)}`;
|
|
2557
2604
|
await navigator.clipboard.writeText(n), window.open("https://docs.google.com/document/create", "_blank"), alert("Content copied to clipboard! Paste it into the new Google Doc.");
|
|
2558
2605
|
} catch (e) {
|
|
2559
2606
|
console.error("Failed to export to Google Docs:", e), alert("Failed to copy content to clipboard. Please try again.");
|
|
2560
2607
|
}
|
|
2561
2608
|
}
|
|
2562
|
-
function
|
|
2609
|
+
function ir(e, t, n) {
|
|
2563
2610
|
let r = new Blob([e], { type: n }), i = URL.createObjectURL(r), a = document.createElement("a");
|
|
2564
2611
|
a.href = i, a.download = t, a.click(), URL.revokeObjectURL(i);
|
|
2565
2612
|
}
|
|
2566
2613
|
//#endregion
|
|
2567
2614
|
//#region src/components/ChatConversation/MessageBubble/AssistantMessageActions.tsx
|
|
2568
|
-
var
|
|
2615
|
+
var ar = ({ section: e, speechStatus: t, start: n, stop: r, handleOpenInLLM: i }) => e.assistantMessage ? /* @__PURE__ */ W("div", {
|
|
2569
2616
|
className: "flex flex-row items-center justify-end w-full text-foreground py-4 -mx-2",
|
|
2570
2617
|
children: /* @__PURE__ */ G("div", {
|
|
2571
2618
|
className: "flex flex-row items-center space-x-1",
|
|
2572
2619
|
children: [
|
|
2573
|
-
/* @__PURE__ */ W(
|
|
2574
|
-
/* @__PURE__ */ W(
|
|
2620
|
+
/* @__PURE__ */ W(qn, { messageId: e.assistantMessage.messageId }),
|
|
2621
|
+
/* @__PURE__ */ W(Un, {
|
|
2575
2622
|
initialMessage: e.assistantMessage.content,
|
|
2576
2623
|
section: e
|
|
2577
2624
|
}),
|
|
@@ -2588,9 +2635,9 @@ var tr = ({ section: e, speechStatus: t, start: n, stop: r, handleOpenInLLM: i }
|
|
|
2588
2635
|
side: "bottom",
|
|
2589
2636
|
children: t === "started" ? "Stop" : "Read aloud"
|
|
2590
2637
|
})] }),
|
|
2591
|
-
/* @__PURE__ */ G(
|
|
2638
|
+
/* @__PURE__ */ G(Pn, { children: [/* @__PURE__ */ G(Y, { children: [/* @__PURE__ */ W(X, {
|
|
2592
2639
|
asChild: !0,
|
|
2593
|
-
children: /* @__PURE__ */ W(
|
|
2640
|
+
children: /* @__PURE__ */ W(Fn, {
|
|
2594
2641
|
asChild: !0,
|
|
2595
2642
|
children: /* @__PURE__ */ W("button", {
|
|
2596
2643
|
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",
|
|
@@ -2600,31 +2647,31 @@ var tr = ({ section: e, speechStatus: t, start: n, stop: r, handleOpenInLLM: i }
|
|
|
2600
2647
|
}), /* @__PURE__ */ W(Z, {
|
|
2601
2648
|
side: "bottom",
|
|
2602
2649
|
children: "Export"
|
|
2603
|
-
})] }), /* @__PURE__ */ G(
|
|
2650
|
+
})] }), /* @__PURE__ */ G(In, {
|
|
2604
2651
|
align: "end",
|
|
2605
2652
|
side: "top",
|
|
2606
2653
|
children: [
|
|
2607
2654
|
/* @__PURE__ */ G(Q, {
|
|
2608
|
-
onClick: () =>
|
|
2655
|
+
onClick: () => er(e.userMessage.content, e.assistantMessage.content),
|
|
2609
2656
|
children: [/* @__PURE__ */ W(oe, { size: 16 }), "Markdown"]
|
|
2610
2657
|
}),
|
|
2611
2658
|
/* @__PURE__ */ G(Q, {
|
|
2612
|
-
onClick: () =>
|
|
2659
|
+
onClick: () => nr(e.userMessage.content, e.assistantMessage.content),
|
|
2613
2660
|
children: [/* @__PURE__ */ W(se, { size: 16 }), "PDF"]
|
|
2614
2661
|
}),
|
|
2615
2662
|
/* @__PURE__ */ G(Q, {
|
|
2616
|
-
onClick: () =>
|
|
2663
|
+
onClick: () => tr(e.userMessage.content, e.assistantMessage.content),
|
|
2617
2664
|
children: [/* @__PURE__ */ W(ie, { size: 16 }), "DOCX"]
|
|
2618
2665
|
}),
|
|
2619
2666
|
/* @__PURE__ */ G(Q, {
|
|
2620
|
-
onClick: () =>
|
|
2667
|
+
onClick: () => rr(e.userMessage.content, e.assistantMessage.content),
|
|
2621
2668
|
children: [/* @__PURE__ */ W(ae, { size: 16 }), "Google Docs"]
|
|
2622
2669
|
})
|
|
2623
2670
|
]
|
|
2624
2671
|
})] }),
|
|
2625
|
-
/* @__PURE__ */ G(
|
|
2672
|
+
/* @__PURE__ */ G(Pn, { children: [/* @__PURE__ */ G(Y, { children: [/* @__PURE__ */ W(X, {
|
|
2626
2673
|
asChild: !0,
|
|
2627
|
-
children: /* @__PURE__ */ W(
|
|
2674
|
+
children: /* @__PURE__ */ W(Fn, {
|
|
2628
2675
|
asChild: !0,
|
|
2629
2676
|
children: /* @__PURE__ */ W("button", {
|
|
2630
2677
|
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",
|
|
@@ -2634,7 +2681,7 @@ var tr = ({ section: e, speechStatus: t, start: n, stop: r, handleOpenInLLM: i }
|
|
|
2634
2681
|
}), /* @__PURE__ */ W(Z, {
|
|
2635
2682
|
side: "bottom",
|
|
2636
2683
|
children: "Open in LLM"
|
|
2637
|
-
})] }), /* @__PURE__ */ G(
|
|
2684
|
+
})] }), /* @__PURE__ */ G(In, {
|
|
2638
2685
|
align: "end",
|
|
2639
2686
|
side: "top",
|
|
2640
2687
|
children: [
|
|
@@ -2662,7 +2709,7 @@ var tr = ({ section: e, speechStatus: t, start: n, stop: r, handleOpenInLLM: i }
|
|
|
2662
2709
|
})] })
|
|
2663
2710
|
]
|
|
2664
2711
|
})
|
|
2665
|
-
}) : null,
|
|
2712
|
+
}) : null, or = vt("inline-flex items-center justify-center rounded-2xl border px-3 py-1.5 text-xs font-medium w-fit whitespace-nowrap shrink-0 [&>svg]:size-3 gap-1 [&>svg]:pointer-events-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive transition-[color,box-shadow] overflow-hidden", {
|
|
2666
2713
|
variants: { variant: {
|
|
2667
2714
|
default: "border-transparent bg-primary text-primary-foreground [a&]:hover:bg-primary/90",
|
|
2668
2715
|
secondary: "border-transparent bg-gray-100 text-gray-700 [a&]:hover:bg-gray-200 dark:bg-gray-800 dark:text-gray-300 dark:[a&]:hover:bg-gray-700",
|
|
@@ -2674,16 +2721,16 @@ var tr = ({ section: e, speechStatus: t, start: n, stop: r, handleOpenInLLM: i }
|
|
|
2674
2721
|
} },
|
|
2675
2722
|
defaultVariants: { variant: "default" }
|
|
2676
2723
|
});
|
|
2677
|
-
function
|
|
2678
|
-
return /* @__PURE__ */ W(n ?
|
|
2724
|
+
function sr({ className: e, variant: t, asChild: n = !1, ...r }) {
|
|
2725
|
+
return /* @__PURE__ */ W(n ? _t : "span", {
|
|
2679
2726
|
"data-slot": "badge",
|
|
2680
|
-
className: J(
|
|
2727
|
+
className: J(or({ variant: t }), e),
|
|
2681
2728
|
...r
|
|
2682
2729
|
});
|
|
2683
2730
|
}
|
|
2684
2731
|
//#endregion
|
|
2685
2732
|
//#region src/components/ChatConversation/MessageBubble/FollowUpSuggestions.tsx
|
|
2686
|
-
var
|
|
2733
|
+
var cr = ({ section: e, isLast: t, loading: n, sendMessage: r }) => {
|
|
2687
2734
|
let i = f([]);
|
|
2688
2735
|
return u(() => {
|
|
2689
2736
|
e.suggestions && e.suggestions.length > 0 && (i.current = e.suggestions.slice(0, 5));
|
|
@@ -2705,7 +2752,7 @@ var ir = ({ section: e, isLast: t, loading: n, sendMessage: r }) => {
|
|
|
2705
2752
|
children: /* @__PURE__ */ G("div", {
|
|
2706
2753
|
className: "flex items-center gap-3",
|
|
2707
2754
|
children: [
|
|
2708
|
-
/* @__PURE__ */ W(
|
|
2755
|
+
/* @__PURE__ */ W(sr, {
|
|
2709
2756
|
variant: "secondary",
|
|
2710
2757
|
className: "flex-shrink-0 h-6 w-6 p-0 flex items-center justify-center rounded-full text-sm font-semibold",
|
|
2711
2758
|
children: t + 1
|
|
@@ -2723,12 +2770,12 @@ var ir = ({ section: e, isLast: t, loading: n, sendMessage: r }) => {
|
|
|
2723
2770
|
}, t))
|
|
2724
2771
|
})
|
|
2725
2772
|
});
|
|
2726
|
-
},
|
|
2727
|
-
let { loading: r, sendMessage: i } =
|
|
2773
|
+
}, lr = ({ section: e, dividerRef: t, isLast: n }) => {
|
|
2774
|
+
let { loading: r, sendMessage: i } = Cn(), [a, o] = p(!0), [s, c] = p(!1), [l, u] = p(!1), [d, f] = p(e.userMessage.content), m = () => {
|
|
2728
2775
|
navigator.clipboard.writeText(e.userMessage.content), c(!0), setTimeout(() => c(!1), 1500);
|
|
2729
2776
|
}, h = () => {
|
|
2730
2777
|
d.trim() && (i(d.trim()), u(!1));
|
|
2731
|
-
}, g = e.parsedAssistantMessage || "", _ = e.speechMessage || "", v = e.thinkingEnded, { speechStatus: b, start: x, stop: S } =
|
|
2778
|
+
}, g = e.parsedAssistantMessage || "", _ = e.speechMessage || "", v = e.thinkingEnded, { speechStatus: b, start: x, stop: S } = tn(_, { enableInterrupt: !0 }), C = (t) => {
|
|
2732
2779
|
if (!e.assistantMessage) return;
|
|
2733
2780
|
let n = `${e.userMessage.content}\n\n${e.assistantMessage.content}`;
|
|
2734
2781
|
navigator.clipboard.writeText(n);
|
|
@@ -2742,11 +2789,11 @@ var ir = ({ section: e, isLast: t, loading: n, sendMessage: r }) => {
|
|
|
2742
2789
|
r && window.open(`${r}${encodeURIComponent(n)}`, "_blank");
|
|
2743
2790
|
}, w = { overrides: {
|
|
2744
2791
|
think: {
|
|
2745
|
-
component:
|
|
2792
|
+
component: Mn,
|
|
2746
2793
|
props: { thinkingEnded: v }
|
|
2747
2794
|
},
|
|
2748
2795
|
citation: {
|
|
2749
|
-
component:
|
|
2796
|
+
component: An,
|
|
2750
2797
|
props: { sources: e.sourceMessage?.sources || [] }
|
|
2751
2798
|
},
|
|
2752
2799
|
table: { component: ({ children: e, ...t }) => /* @__PURE__ */ W("div", {
|
|
@@ -2760,7 +2807,7 @@ var ir = ({ section: e, isLast: t, loading: n, sendMessage: r }) => {
|
|
|
2760
2807
|
} };
|
|
2761
2808
|
return /* @__PURE__ */ G("div", {
|
|
2762
2809
|
className: "space-y-3",
|
|
2763
|
-
children: [/* @__PURE__ */ W(
|
|
2810
|
+
children: [/* @__PURE__ */ W(Nn, {
|
|
2764
2811
|
section: e,
|
|
2765
2812
|
isExpanded: a,
|
|
2766
2813
|
setIsExpanded: o,
|
|
@@ -2777,13 +2824,13 @@ var ir = ({ section: e, isLast: t, loading: n, sendMessage: r }) => {
|
|
|
2777
2824
|
ref: t,
|
|
2778
2825
|
className: "flex flex-col space-y-6 w-full",
|
|
2779
2826
|
children: [
|
|
2780
|
-
e.searchingMessage && e.searchingMessage.queries.length > 0 && /* @__PURE__ */ W(
|
|
2827
|
+
e.searchingMessage && e.searchingMessage.queries.length > 0 && /* @__PURE__ */ W(Ht, {
|
|
2781
2828
|
queries: e.searchingMessage.queries,
|
|
2782
2829
|
loading: r && n
|
|
2783
2830
|
}),
|
|
2784
2831
|
e.sourceMessage && e.sourceMessage.sources.length > 0 && /* @__PURE__ */ W("div", {
|
|
2785
2832
|
className: "flex flex-col space-y-2",
|
|
2786
|
-
children: /* @__PURE__ */ W(
|
|
2833
|
+
children: /* @__PURE__ */ W(zt, {
|
|
2787
2834
|
sources: e.sourceMessage.sources,
|
|
2788
2835
|
query: e.userMessage.content
|
|
2789
2836
|
})
|
|
@@ -2796,14 +2843,14 @@ var ir = ({ section: e, isLast: t, loading: n, sendMessage: r }) => {
|
|
|
2796
2843
|
options: w,
|
|
2797
2844
|
children: g
|
|
2798
2845
|
}),
|
|
2799
|
-
r && n ? null : /* @__PURE__ */ W(
|
|
2846
|
+
r && n ? null : /* @__PURE__ */ W(ar, {
|
|
2800
2847
|
section: e,
|
|
2801
2848
|
speechStatus: b,
|
|
2802
2849
|
start: x,
|
|
2803
2850
|
stop: S,
|
|
2804
2851
|
handleOpenInLLM: C
|
|
2805
2852
|
}),
|
|
2806
|
-
/* @__PURE__ */ W(
|
|
2853
|
+
/* @__PURE__ */ W(cr, {
|
|
2807
2854
|
section: e,
|
|
2808
2855
|
isLast: n,
|
|
2809
2856
|
loading: r,
|
|
@@ -2815,7 +2862,7 @@ var ir = ({ section: e, isLast: t, loading: n, sendMessage: r }) => {
|
|
|
2815
2862
|
})
|
|
2816
2863
|
})]
|
|
2817
2864
|
});
|
|
2818
|
-
},
|
|
2865
|
+
}, ur = (e) => {
|
|
2819
2866
|
if (e === 0) return "0 Bytes";
|
|
2820
2867
|
let t = 1024, n = [
|
|
2821
2868
|
"Bytes",
|
|
@@ -2824,7 +2871,7 @@ var ir = ({ section: e, isLast: t, loading: n, sendMessage: r }) => {
|
|
|
2824
2871
|
"GB"
|
|
2825
2872
|
], r = Math.floor(Math.log(e) / Math.log(t));
|
|
2826
2873
|
return parseFloat((e / t ** r).toFixed(2)) + " " + n[r];
|
|
2827
|
-
},
|
|
2874
|
+
}, dr = ({ file: e, onRemove: t }) => /* @__PURE__ */ G("div", {
|
|
2828
2875
|
className: "relative group flex-shrink-0 w-24 h-24 rounded-xl overflow-hidden border border-bg-300 bg-bg-200 animate-fade-in transition-all hover:border-text-400",
|
|
2829
2876
|
children: [
|
|
2830
2877
|
e.type.startsWith("image/") && e.preview ? /* @__PURE__ */ G("div", {
|
|
@@ -2839,7 +2886,7 @@ var ir = ({ section: e, isLast: t, loading: n, sendMessage: r }) => {
|
|
|
2839
2886
|
/* @__PURE__ */ W("span", {
|
|
2840
2887
|
className: "absolute bottom-1 left-1 px-1.5 py-0.5 rounded-md bg-black/60 text-white text-[10px] font-medium leading-none backdrop-blur-sm pointer-events-none",
|
|
2841
2888
|
title: e.file.name,
|
|
2842
|
-
children:
|
|
2889
|
+
children: ur(e.file.size)
|
|
2843
2890
|
})
|
|
2844
2891
|
]
|
|
2845
2892
|
}) : /* @__PURE__ */ G("div", {
|
|
@@ -2861,7 +2908,7 @@ var ir = ({ section: e, isLast: t, loading: n, sendMessage: r }) => {
|
|
|
2861
2908
|
children: e.file.name
|
|
2862
2909
|
}), /* @__PURE__ */ W("p", {
|
|
2863
2910
|
className: "text-[10px] text-text-500",
|
|
2864
|
-
children:
|
|
2911
|
+
children: ur(e.file.size)
|
|
2865
2912
|
})]
|
|
2866
2913
|
})]
|
|
2867
2914
|
}),
|
|
@@ -2879,7 +2926,7 @@ var ir = ({ section: e, isLast: t, loading: n, sendMessage: r }) => {
|
|
|
2879
2926
|
children: /* @__PURE__ */ W($.X, { className: "w-5 h-5 text-red-300" })
|
|
2880
2927
|
})
|
|
2881
2928
|
]
|
|
2882
|
-
}),
|
|
2929
|
+
}), fr = ({ content: e, onRemove: t }) => /* @__PURE__ */ G("div", {
|
|
2883
2930
|
className: "relative group flex-shrink-0 w-28 h-28 rounded-2xl overflow-hidden border border-[#E5E5E5] dark:border-[#30302E] bg-white dark:bg-[#20201F] animate-fade-in p-3 flex flex-col justify-between shadow-[0_1px_2px_rgba(0,0,0,0.05)]",
|
|
2884
2931
|
children: [
|
|
2885
2932
|
/* @__PURE__ */ W("div", {
|
|
@@ -2908,13 +2955,13 @@ var ir = ({ section: e, isLast: t, loading: n, sendMessage: r }) => {
|
|
|
2908
2955
|
});
|
|
2909
2956
|
//#endregion
|
|
2910
2957
|
//#region src/hooks/voice/useSpeechToTranscript.ts
|
|
2911
|
-
function
|
|
2958
|
+
function pr(e, t) {
|
|
2912
2959
|
let [n, r] = p(!1), i = f(null), a = f(null), o = f(null), s = f([]), c = f(!1), l = f(!1), d = typeof window < "u" ? window.SpeechRecognition || window.webkitSpeechRecognition : null, m = () => {
|
|
2913
2960
|
let e = a.current;
|
|
2914
2961
|
e && e.state !== "inactive" ? e.stop() : (o.current?.getTracks().forEach((e) => e.stop()), o.current = null, a.current = null, r(!1), t());
|
|
2915
2962
|
}, h = async (e) => {
|
|
2916
2963
|
let t = new FormData();
|
|
2917
|
-
return t.append("file", e, "speech-input.webm"), t.append("languageCode", "en"), ((await
|
|
2964
|
+
return t.append("file", e, "speech-input.webm"), t.append("languageCode", "en"), ((await ft("/api/agent/transcript", {
|
|
2918
2965
|
method: "POST",
|
|
2919
2966
|
body: t
|
|
2920
2967
|
}))?.text ?? "").trim();
|
|
@@ -2997,28 +3044,28 @@ function lr(e, t) {
|
|
|
2997
3044
|
}
|
|
2998
3045
|
//#endregion
|
|
2999
3046
|
//#region src/components/FileUpload/useFileHandling.ts
|
|
3000
|
-
var
|
|
3047
|
+
var mr = [
|
|
3001
3048
|
"pdf",
|
|
3002
3049
|
"docx",
|
|
3003
3050
|
"txt",
|
|
3004
3051
|
"md",
|
|
3005
3052
|
"html",
|
|
3006
3053
|
"htm"
|
|
3007
|
-
],
|
|
3054
|
+
], hr = 10, gr = 50 * 1024 * 1024, _r = (e, t) => {
|
|
3008
3055
|
if (e && typeof e == "object") {
|
|
3009
3056
|
let t = e.message ?? e.error ?? e.data?.message;
|
|
3010
3057
|
if (typeof t == "string" && t.length > 0) return t;
|
|
3011
3058
|
}
|
|
3012
3059
|
return typeof e == "string" && e.length > 0 ? e : t;
|
|
3013
3060
|
};
|
|
3014
|
-
function
|
|
3061
|
+
function vr({ setMessage: e, contextFiles: t, contextFileIds: n, setContextFiles: r, setContextFileIds: i }) {
|
|
3015
3062
|
let [a, o] = p([]), [s, l] = p([]), [u, d] = p(!1), [f, m] = p(!1), h = c(async (e) => {
|
|
3016
3063
|
let a = Array.from(e);
|
|
3017
|
-
a.length >
|
|
3018
|
-
let s = a.filter((e) => e.size >
|
|
3019
|
-
if (s.length > 0 && (K.error(`${s.map((e) => e.name).join(", ")} exceed${s.length === 1 ? "s" : ""} the 50 MB per-file limit.`), a = a.filter((e) => e.size <=
|
|
3064
|
+
a.length > hr && (K.error(`You can attach up to ${hr} files at a time.`), a = a.slice(0, hr));
|
|
3065
|
+
let s = a.filter((e) => e.size > gr);
|
|
3066
|
+
if (s.length > 0 && (K.error(`${s.map((e) => e.name).join(", ")} exceed${s.length === 1 ? "s" : ""} the 50 MB per-file limit.`), a = a.filter((e) => e.size <= gr)), a.length === 0) return;
|
|
3020
3067
|
let c = a.map((e) => {
|
|
3021
|
-
let t = e.type.startsWith("image/") || /\.(jpg|jpeg|png|gif|webp|svg)$/i.test(e.name), n = e.name.split(".").pop()?.toLowerCase() ?? "", r =
|
|
3068
|
+
let t = e.type.startsWith("image/") || /\.(jpg|jpeg|png|gif|webp|svg)$/i.test(e.name), n = e.name.split(".").pop()?.toLowerCase() ?? "", r = mr.includes(n);
|
|
3022
3069
|
return {
|
|
3023
3070
|
id: Math.random().toString(36).substr(2, 9),
|
|
3024
3071
|
file: e,
|
|
@@ -3028,7 +3075,7 @@ function mr({ setMessage: e, contextFiles: t, contextFileIds: n, setContextFiles
|
|
|
3028
3075
|
_ext: n
|
|
3029
3076
|
};
|
|
3030
3077
|
});
|
|
3031
|
-
o((e) => [...e, ...c]), c.filter((e) => !
|
|
3078
|
+
o((e) => [...e, ...c]), c.filter((e) => !mr.includes(e._ext)).forEach((e) => {
|
|
3032
3079
|
setTimeout(() => {
|
|
3033
3080
|
o((t) => t.map((t) => t.id === e.id ? {
|
|
3034
3081
|
...t,
|
|
@@ -3036,16 +3083,16 @@ function mr({ setMessage: e, contextFiles: t, contextFileIds: n, setContextFiles
|
|
|
3036
3083
|
} : t));
|
|
3037
3084
|
}, 600 + Math.random() * 600);
|
|
3038
3085
|
});
|
|
3039
|
-
let l = c.filter((e) =>
|
|
3086
|
+
let l = c.filter((e) => mr.includes(e._ext));
|
|
3040
3087
|
if (l.length !== 0) try {
|
|
3041
|
-
let { data: e, error: a } = await
|
|
3042
|
-
if (a || !e?.files) throw Error(
|
|
3088
|
+
let { data: e, error: a } = await st({ body: { files: l.map((e) => e.file) } });
|
|
3089
|
+
if (a || !e?.files) throw Error(_r(a ?? e, "Upload failed."));
|
|
3043
3090
|
o((e) => e.map((e) => l.some((t) => t.id === e.id) ? {
|
|
3044
3091
|
...e,
|
|
3045
3092
|
uploadStatus: "complete"
|
|
3046
3093
|
} : e)), r([...t, ...e.files]), i([...n, ...e.files.map((e) => e.fileId)]);
|
|
3047
3094
|
} catch (e) {
|
|
3048
|
-
K.error(
|
|
3095
|
+
K.error(_r(e, "Failed to upload files.")), o((e) => e.map((e) => l.some((t) => t.id === e.id) ? {
|
|
3049
3096
|
...e,
|
|
3050
3097
|
uploadStatus: "error"
|
|
3051
3098
|
} : e));
|
|
@@ -3075,10 +3122,10 @@ function mr({ setMessage: e, contextFiles: t, contextFileIds: n, setContextFiles
|
|
|
3075
3122
|
headers: { "Content-Type": "application/json" },
|
|
3076
3123
|
body: JSON.stringify({ url: a })
|
|
3077
3124
|
})).json();
|
|
3078
|
-
if (!e?.files || e.files.length === 0) throw Error(
|
|
3125
|
+
if (!e?.files || e.files.length === 0) throw Error(_r(e, `Could not extract content from ${a}`));
|
|
3079
3126
|
return r([...t, ...e.files]), i([...n, ...e.files.map((e) => e.fileId)]), K.success(`Added "${e.files[0].fileName}" as context.`), !0;
|
|
3080
3127
|
} catch (e) {
|
|
3081
|
-
return K.error(
|
|
3128
|
+
return K.error(_r(e, "Failed to extract URL.")), !1;
|
|
3082
3129
|
} finally {
|
|
3083
3130
|
m(!1);
|
|
3084
3131
|
}
|
|
@@ -3125,24 +3172,24 @@ function mr({ setMessage: e, contextFiles: t, contextFileIds: n, setContextFiles
|
|
|
3125
3172
|
}
|
|
3126
3173
|
//#endregion
|
|
3127
3174
|
//#region src/components/FileUpload/GoogleDrivePicker.tsx
|
|
3128
|
-
var
|
|
3175
|
+
var yr = () => window.gapi, br = () => window.google, xr = () => {
|
|
3129
3176
|
let e = f(!1), n = f(!1);
|
|
3130
3177
|
return u(() => {
|
|
3131
|
-
|
|
3178
|
+
yr() ? n.current = !0 : (() => {
|
|
3132
3179
|
let e = document.createElement("script");
|
|
3133
3180
|
e.src = "https://apis.google.com/js/api.js", e.onload = () => {
|
|
3134
|
-
|
|
3181
|
+
yr()?.load("client:picker", () => {
|
|
3135
3182
|
n.current = !0;
|
|
3136
3183
|
});
|
|
3137
3184
|
}, document.body.appendChild(e);
|
|
3138
|
-
})(),
|
|
3185
|
+
})(), br()?.picker ? e.current = !0 : (() => {
|
|
3139
3186
|
let t = document.createElement("script");
|
|
3140
3187
|
t.src = "https://www.google.com/jsapi", t.onload = () => {
|
|
3141
3188
|
e.current = !0;
|
|
3142
3189
|
}, document.body.appendChild(t);
|
|
3143
3190
|
})();
|
|
3144
3191
|
}, []), { openPicker: async (e, r, i) => {
|
|
3145
|
-
let a =
|
|
3192
|
+
let a = br();
|
|
3146
3193
|
if (!n.current || !a?.picker) {
|
|
3147
3194
|
i?.("Google Picker API not loaded yet. Please try again.");
|
|
3148
3195
|
return;
|
|
@@ -3159,13 +3206,13 @@ var hr = () => window.gapi, gr = () => window.google, _r = () => {
|
|
|
3159
3206
|
i?.(e.message || "Failed to open Google Picker");
|
|
3160
3207
|
}
|
|
3161
3208
|
} };
|
|
3162
|
-
},
|
|
3163
|
-
let { chatModelProvider: e, setChatModelProvider: t } =
|
|
3209
|
+
}, Sr = () => {
|
|
3210
|
+
let { chatModelProvider: e, setChatModelProvider: t } = Cn(), [n, r] = p([]), [i, a] = p(!0), o = h();
|
|
3164
3211
|
u(() => {
|
|
3165
3212
|
(async () => {
|
|
3166
3213
|
try {
|
|
3167
3214
|
a(!0);
|
|
3168
|
-
let { data: n } = await
|
|
3215
|
+
let { data: n } = await tt(), i = n?.providers ?? [];
|
|
3169
3216
|
if (r(i), !e.key && i.length > 0) {
|
|
3170
3217
|
let e = localStorage.getItem("chatModelKey"), n = localStorage.getItem("chatModelProviderId");
|
|
3171
3218
|
if (e && n) t({
|
|
@@ -3200,7 +3247,7 @@ var hr = () => window.gapi, gr = () => window.google, _r = () => {
|
|
|
3200
3247
|
key: n
|
|
3201
3248
|
}), localStorage.setItem("chatModelProviderId", e), localStorage.setItem("chatModelKey", n);
|
|
3202
3249
|
};
|
|
3203
|
-
return /* @__PURE__ */ G(
|
|
3250
|
+
return /* @__PURE__ */ G(Bn, { children: [/* @__PURE__ */ G(Vn, {
|
|
3204
3251
|
className: "gap-2",
|
|
3205
3252
|
children: [
|
|
3206
3253
|
/* @__PURE__ */ W(ee, { className: "w-4 h-4 flex-shrink-0 text-sky-500" }),
|
|
@@ -3210,7 +3257,7 @@ var hr = () => window.gapi, gr = () => window.google, _r = () => {
|
|
|
3210
3257
|
children: s
|
|
3211
3258
|
})
|
|
3212
3259
|
]
|
|
3213
|
-
}), /* @__PURE__ */ G(
|
|
3260
|
+
}), /* @__PURE__ */ G(Hn, {
|
|
3214
3261
|
className: "w-52 max-h-[400px] overflow-y-auto",
|
|
3215
3262
|
children: [
|
|
3216
3263
|
i ? /* @__PURE__ */ W("div", {
|
|
@@ -3220,7 +3267,7 @@ var hr = () => window.gapi, gr = () => window.google, _r = () => {
|
|
|
3220
3267
|
className: "px-3 py-2 text-xs text-muted-foreground",
|
|
3221
3268
|
children: "No models configured"
|
|
3222
3269
|
}) : n.map((t, r) => /* @__PURE__ */ G("div", { children: [
|
|
3223
|
-
/* @__PURE__ */ W(
|
|
3270
|
+
/* @__PURE__ */ W(Rn, {
|
|
3224
3271
|
className: "text-[10px] uppercase tracking-wider text-muted-foreground font-medium",
|
|
3225
3272
|
children: t.name
|
|
3226
3273
|
}),
|
|
@@ -3247,9 +3294,9 @@ var hr = () => window.gapi, gr = () => window.google, _r = () => {
|
|
|
3247
3294
|
})
|
|
3248
3295
|
]
|
|
3249
3296
|
}, n.key)),
|
|
3250
|
-
r < n.length - 1 && /* @__PURE__ */ W(
|
|
3297
|
+
r < n.length - 1 && /* @__PURE__ */ W(zn, {})
|
|
3251
3298
|
] }, t.id)),
|
|
3252
|
-
/* @__PURE__ */ W(
|
|
3299
|
+
/* @__PURE__ */ W(zn, {}),
|
|
3253
3300
|
/* @__PURE__ */ G(Q, {
|
|
3254
3301
|
onSelect: () => o.push("/settings?section=models"),
|
|
3255
3302
|
className: "gap-2",
|
|
@@ -3257,7 +3304,7 @@ var hr = () => window.gapi, gr = () => window.google, _r = () => {
|
|
|
3257
3304
|
})
|
|
3258
3305
|
]
|
|
3259
3306
|
})] });
|
|
3260
|
-
},
|
|
3307
|
+
}, Cr = [
|
|
3261
3308
|
{
|
|
3262
3309
|
label: "5s",
|
|
3263
3310
|
value: 5
|
|
@@ -3282,28 +3329,28 @@ var hr = () => window.gapi, gr = () => window.google, _r = () => {
|
|
|
3282
3329
|
label: "Unlimited",
|
|
3283
3330
|
value: 0
|
|
3284
3331
|
}
|
|
3285
|
-
],
|
|
3332
|
+
], wr = [
|
|
3286
3333
|
"pdf",
|
|
3287
3334
|
"docx",
|
|
3288
3335
|
"txt",
|
|
3289
3336
|
"md",
|
|
3290
3337
|
"html",
|
|
3291
3338
|
"htm"
|
|
3292
|
-
],
|
|
3293
|
-
let n = h(), { category: i, setCategory: a, incognito: o, setIncognito: s, sections: c, chatId: l } =
|
|
3339
|
+
], Tr = /* @__PURE__ */ "markdown.js.jsx.ts.tsx.py.rb.go.rs.java.c.cpp.h.hpp.cs.swift.kt.sh.bash.zsh.json.yaml.yml.toml.ini.cfg.conf.xml.csv.tsv.log.env.sql.graphql.vue.svelte.astro.css.scss.less.sass.tex.bib.rst.adoc.org".split("."), Er = ({ onFileSelect: e, disabled: t = !1 }) => {
|
|
3340
|
+
let n = h(), { category: i, setCategory: a, incognito: o, setIncognito: s, sections: c, chatId: l } = Cn(), { isAuthenticated: d } = Dn(), f = i ? i.split(",").filter(Boolean) : ["general"], m = Lt.find((e) => e.code === f[0]) || Lt[0], g = (e) => {
|
|
3294
3341
|
let t = i ? i.split(",").filter(Boolean) : ["general"], n = t.includes(e) ? t.filter((t) => t !== e) : [...t, e];
|
|
3295
3342
|
a(n.length > 0 ? n.join(",") : "general");
|
|
3296
3343
|
}, [_, v] = p(!1), [y, b] = p(!1), [x, S] = p(!1), [C, w] = p(!1), [E, D] = p(() => {
|
|
3297
3344
|
if (typeof window > "u") return 5;
|
|
3298
3345
|
let e = Number(localStorage.getItem("thinkingTimeLimit") ?? "5");
|
|
3299
3346
|
return Number.isFinite(e) ? e : 5;
|
|
3300
|
-
}), O = r.useRef(null), { openPicker: k } =
|
|
3347
|
+
}), O = r.useRef(null), { openPicker: k } = xr();
|
|
3301
3348
|
u(() => {
|
|
3302
3349
|
A();
|
|
3303
3350
|
}, []);
|
|
3304
3351
|
let A = async () => {
|
|
3305
3352
|
try {
|
|
3306
|
-
let { data: e } = await
|
|
3353
|
+
let { data: e } = await Qe();
|
|
3307
3354
|
v(e?.isConnected || !1);
|
|
3308
3355
|
} catch {}
|
|
3309
3356
|
}, j = (e) => {
|
|
@@ -3341,8 +3388,8 @@ var hr = () => window.gapi, gr = () => window.google, _r = () => {
|
|
|
3341
3388
|
let n = [];
|
|
3342
3389
|
for await (let r of e.values()) if (r.kind === "file") {
|
|
3343
3390
|
let e = await r.getFile(), i = e.name.split(".").pop()?.toLowerCase() ?? "";
|
|
3344
|
-
if (
|
|
3345
|
-
else if (
|
|
3391
|
+
if (wr.includes(i)) n.push(e);
|
|
3392
|
+
else if (Tr.includes(i)) try {
|
|
3346
3393
|
let r = await e.text(), i = t ? `${t}/${e.name}` : e.name;
|
|
3347
3394
|
n.push(new File([r], `${i.replace(/[/\\]/g, "_")}.txt`, { type: "text/plain" }));
|
|
3348
3395
|
} catch {}
|
|
@@ -3370,7 +3417,7 @@ var hr = () => window.gapi, gr = () => window.google, _r = () => {
|
|
|
3370
3417
|
}, F = async () => {
|
|
3371
3418
|
b(!0);
|
|
3372
3419
|
try {
|
|
3373
|
-
let { data: e } = await
|
|
3420
|
+
let { data: e } = await Ze();
|
|
3374
3421
|
if (e?.success && e?.data?.authUrl) {
|
|
3375
3422
|
let t = e.data.authUrl, n = window.screenX + (window.outerWidth - 600) / 2, r = window.screenY + (window.outerHeight - 700) / 2, i = window.open(t, "Google Drive Authorization", `width=600,height=700,left=${n},top=${r}`), a = (e) => {
|
|
3376
3423
|
e.data.type === "google-drive-connected" && (v(!0), i?.close(), window.removeEventListener("message", a));
|
|
@@ -3384,14 +3431,14 @@ var hr = () => window.gapi, gr = () => window.google, _r = () => {
|
|
|
3384
3431
|
}
|
|
3385
3432
|
}, I = async () => {
|
|
3386
3433
|
try {
|
|
3387
|
-
let { data: t } = await
|
|
3434
|
+
let { data: t } = await Xe();
|
|
3388
3435
|
if (!t?.success || !t.accessToken) throw Error("Failed to get access token");
|
|
3389
3436
|
await k(t.accessToken, async (t) => {
|
|
3390
3437
|
S(!0);
|
|
3391
3438
|
try {
|
|
3392
3439
|
let n = [];
|
|
3393
3440
|
for (let e of t) {
|
|
3394
|
-
let { data: t } = await
|
|
3441
|
+
let { data: t } = await Ye({ query: { fileId: e.id } });
|
|
3395
3442
|
if (t?.success && t?.file) {
|
|
3396
3443
|
let e = atob(t.file.content), r = new Uint8Array(e.length);
|
|
3397
3444
|
for (let t = 0; t < e.length; t++) r[t] = e.charCodeAt(t);
|
|
@@ -3410,11 +3457,11 @@ var hr = () => window.gapi, gr = () => window.google, _r = () => {
|
|
|
3410
3457
|
} catch (e) {
|
|
3411
3458
|
alert(e.message || "Failed to open Google Drive picker");
|
|
3412
3459
|
}
|
|
3413
|
-
}, R =
|
|
3460
|
+
}, R = Cr.find((e) => e.value === E)?.label ?? "Unlimited";
|
|
3414
3461
|
return /* @__PURE__ */ G(U, { children: [
|
|
3415
3462
|
/* @__PURE__ */ G("div", {
|
|
3416
3463
|
className: "relative flex shrink min-w-8 !shrink-0 group",
|
|
3417
|
-
children: [/* @__PURE__ */ G(
|
|
3464
|
+
children: [/* @__PURE__ */ G(Pn, { children: [/* @__PURE__ */ W(Fn, {
|
|
3418
3465
|
asChild: !0,
|
|
3419
3466
|
children: /* @__PURE__ */ W("button", {
|
|
3420
3467
|
disabled: t,
|
|
@@ -3423,27 +3470,27 @@ var hr = () => window.gapi, gr = () => window.google, _r = () => {
|
|
|
3423
3470
|
"aria-label": "Search options",
|
|
3424
3471
|
children: /* @__PURE__ */ W(Ce, { className: "w-5 h-5" })
|
|
3425
3472
|
})
|
|
3426
|
-
}), /* @__PURE__ */ G(
|
|
3473
|
+
}), /* @__PURE__ */ G(In, {
|
|
3427
3474
|
align: "start",
|
|
3428
3475
|
side: "top",
|
|
3429
3476
|
sideOffset: 8,
|
|
3430
3477
|
className: "w-44",
|
|
3431
3478
|
children: [
|
|
3432
|
-
/* @__PURE__ */ G(
|
|
3479
|
+
/* @__PURE__ */ G(Bn, { children: [/* @__PURE__ */ G(Vn, {
|
|
3433
3480
|
className: "gap-2",
|
|
3434
3481
|
children: [m && /* @__PURE__ */ W(m.icon, { className: "w-4 h-4 flex-shrink-0" }), /* @__PURE__ */ W("span", { children: "Category" })]
|
|
3435
|
-
}), /* @__PURE__ */ G(
|
|
3482
|
+
}), /* @__PURE__ */ G(Hn, {
|
|
3436
3483
|
className: "w-44",
|
|
3437
3484
|
children: [
|
|
3438
|
-
/* @__PURE__ */ G(
|
|
3485
|
+
/* @__PURE__ */ G(Ln, {
|
|
3439
3486
|
checked: f.length === 0,
|
|
3440
3487
|
onCheckedChange: () => a("general"),
|
|
3441
3488
|
onSelect: (e) => e.preventDefault(),
|
|
3442
3489
|
className: "gap-2",
|
|
3443
3490
|
children: [/* @__PURE__ */ W("div", { className: "w-3.5 h-3.5 flex-shrink-0" }), /* @__PURE__ */ W("span", { children: "None" })]
|
|
3444
3491
|
}),
|
|
3445
|
-
/* @__PURE__ */ W(
|
|
3446
|
-
|
|
3492
|
+
/* @__PURE__ */ W(zn, {}),
|
|
3493
|
+
Lt.map((e) => /* @__PURE__ */ G(Ln, {
|
|
3447
3494
|
checked: f.includes(e.code),
|
|
3448
3495
|
onCheckedChange: () => g(e.code),
|
|
3449
3496
|
onSelect: (e) => e.preventDefault(),
|
|
@@ -3452,7 +3499,7 @@ var hr = () => window.gapi, gr = () => window.google, _r = () => {
|
|
|
3452
3499
|
}, e.code))
|
|
3453
3500
|
]
|
|
3454
3501
|
})] }),
|
|
3455
|
-
/* @__PURE__ */ G(
|
|
3502
|
+
/* @__PURE__ */ G(Bn, { children: [/* @__PURE__ */ G(Vn, {
|
|
3456
3503
|
className: "gap-2",
|
|
3457
3504
|
children: [
|
|
3458
3505
|
/* @__PURE__ */ W(L, { className: "w-4 h-4 flex-shrink-0 text-muted-foreground" }),
|
|
@@ -3462,9 +3509,9 @@ var hr = () => window.gapi, gr = () => window.google, _r = () => {
|
|
|
3462
3509
|
children: R
|
|
3463
3510
|
})
|
|
3464
3511
|
]
|
|
3465
|
-
}), /* @__PURE__ */ W(
|
|
3512
|
+
}), /* @__PURE__ */ W(Hn, {
|
|
3466
3513
|
className: "w-36",
|
|
3467
|
-
children:
|
|
3514
|
+
children: Cr.map((e) => /* @__PURE__ */ G(Q, {
|
|
3468
3515
|
onSelect: () => j(e.value),
|
|
3469
3516
|
className: J("justify-between", E === e.value && "bg-secondary"),
|
|
3470
3517
|
children: [/* @__PURE__ */ W("span", { children: e.label }), E === e.value && /* @__PURE__ */ W("svg", {
|
|
@@ -3481,13 +3528,13 @@ var hr = () => window.gapi, gr = () => window.google, _r = () => {
|
|
|
3481
3528
|
})]
|
|
3482
3529
|
}, e.value))
|
|
3483
3530
|
})] }),
|
|
3484
|
-
/* @__PURE__ */ W(
|
|
3485
|
-
/* @__PURE__ */ W(
|
|
3486
|
-
/* @__PURE__ */ W(
|
|
3487
|
-
/* @__PURE__ */ G(
|
|
3531
|
+
/* @__PURE__ */ W(zn, {}),
|
|
3532
|
+
/* @__PURE__ */ W(Sr, {}),
|
|
3533
|
+
/* @__PURE__ */ W(zn, {}),
|
|
3534
|
+
/* @__PURE__ */ G(Bn, { children: [/* @__PURE__ */ G(Vn, {
|
|
3488
3535
|
className: "gap-2",
|
|
3489
3536
|
children: [/* @__PURE__ */ W(je, { className: "w-4 h-4 flex-shrink-0 text-muted-foreground" }), /* @__PURE__ */ W("span", { children: "Upload" })]
|
|
3490
|
-
}), /* @__PURE__ */ G(
|
|
3537
|
+
}), /* @__PURE__ */ G(Hn, {
|
|
3491
3538
|
className: "w-44",
|
|
3492
3539
|
children: [
|
|
3493
3540
|
/* @__PURE__ */ G(Q, {
|
|
@@ -3501,8 +3548,8 @@ var hr = () => window.gapi, gr = () => window.google, _r = () => {
|
|
|
3501
3548
|
className: "gap-2",
|
|
3502
3549
|
children: [C ? /* @__PURE__ */ W(H, { className: "h-3.5 w-3.5 animate-spin flex-shrink-0" }) : /* @__PURE__ */ W(ce, { className: "h-3.5 w-3.5 flex-shrink-0" }), /* @__PURE__ */ W("span", { children: C ? "Scanning…" : "Local Folder" })]
|
|
3503
3550
|
}),
|
|
3504
|
-
/* @__PURE__ */ W(
|
|
3505
|
-
/* @__PURE__ */ W(
|
|
3551
|
+
/* @__PURE__ */ W(zn, {}),
|
|
3552
|
+
/* @__PURE__ */ W(Rn, {
|
|
3506
3553
|
className: "text-xs font-normal text-muted-foreground",
|
|
3507
3554
|
children: "Cloud"
|
|
3508
3555
|
}),
|
|
@@ -3519,19 +3566,19 @@ var hr = () => window.gapi, gr = () => window.google, _r = () => {
|
|
|
3519
3566
|
})
|
|
3520
3567
|
]
|
|
3521
3568
|
})] }),
|
|
3522
|
-
/* @__PURE__ */ W(
|
|
3523
|
-
/* @__PURE__ */ G(
|
|
3569
|
+
/* @__PURE__ */ W(zn, {}),
|
|
3570
|
+
/* @__PURE__ */ G(Ln, {
|
|
3524
3571
|
checked: o,
|
|
3525
3572
|
onCheckedChange: s,
|
|
3526
3573
|
onSelect: (e) => e.preventDefault(),
|
|
3527
3574
|
className: "gap-2",
|
|
3528
3575
|
children: [/* @__PURE__ */ W(ne, { className: "w-4 h-4 flex-shrink-0 text-muted-foreground" }), /* @__PURE__ */ W("span", { children: "Private" })]
|
|
3529
3576
|
}),
|
|
3530
|
-
/* @__PURE__ */ W(
|
|
3531
|
-
c.length > 0 && /* @__PURE__ */ G(U, { children: [/* @__PURE__ */ G(
|
|
3577
|
+
/* @__PURE__ */ W(zn, {}),
|
|
3578
|
+
c.length > 0 && /* @__PURE__ */ G(U, { children: [/* @__PURE__ */ G(Bn, { children: [/* @__PURE__ */ G(Vn, {
|
|
3532
3579
|
className: "gap-2",
|
|
3533
3580
|
children: [/* @__PURE__ */ W(Se, { className: "w-4 h-4 flex-shrink-0 text-muted-foreground" }), /* @__PURE__ */ W("span", { children: "Share" })]
|
|
3534
|
-
}), /* @__PURE__ */ G(
|
|
3581
|
+
}), /* @__PURE__ */ G(Hn, {
|
|
3535
3582
|
className: "w-48",
|
|
3536
3583
|
children: [
|
|
3537
3584
|
/* @__PURE__ */ G(Q, {
|
|
@@ -3545,7 +3592,7 @@ var hr = () => window.gapi, gr = () => window.google, _r = () => {
|
|
|
3545
3592
|
return;
|
|
3546
3593
|
}
|
|
3547
3594
|
try {
|
|
3548
|
-
let { data: e, error: t } = await
|
|
3595
|
+
let { data: e, error: t } = await at({ body: { chatId: l } });
|
|
3549
3596
|
if (!t && e?.success && e?.data?.shareUrl) await navigator.clipboard.writeText(e.data.shareUrl), K.success("Chat is now public - link copied to clipboard");
|
|
3550
3597
|
else throw Error(t?.error || "Failed to share chat");
|
|
3551
3598
|
} catch (e) {
|
|
@@ -3561,7 +3608,7 @@ var hr = () => window.gapi, gr = () => window.google, _r = () => {
|
|
|
3561
3608
|
onSelect: async () => {
|
|
3562
3609
|
let e = c[0]?.userMessage?.content || "Chat", t = c.map((e) => `## ${e.userMessage.content}\n\n${e.assistantMessage?.content || ""}`).join("\n\n---\n\n");
|
|
3563
3610
|
try {
|
|
3564
|
-
await
|
|
3611
|
+
await We({ body: {
|
|
3565
3612
|
title: e,
|
|
3566
3613
|
name: e,
|
|
3567
3614
|
content: t,
|
|
@@ -3577,37 +3624,37 @@ var hr = () => window.gapi, gr = () => window.google, _r = () => {
|
|
|
3577
3624
|
className: "gap-2",
|
|
3578
3625
|
children: [/* @__PURE__ */ W(T, { className: "w-4 h-4 flex-shrink-0" }), /* @__PURE__ */ W("span", { children: "Save to QwkDocs" })]
|
|
3579
3626
|
}),
|
|
3580
|
-
/* @__PURE__ */ W(
|
|
3627
|
+
/* @__PURE__ */ W(zn, {}),
|
|
3581
3628
|
/* @__PURE__ */ G(Q, {
|
|
3582
3629
|
onSelect: () => {
|
|
3583
|
-
|
|
3630
|
+
er(c[0]?.userMessage?.content || "Chat", c.map((e) => `<h2>${e.userMessage.content}</h2>${e.assistantMessage?.content || ""}`).join("\n"));
|
|
3584
3631
|
},
|
|
3585
3632
|
className: "gap-2",
|
|
3586
3633
|
children: [/* @__PURE__ */ W(oe, { className: "w-4 h-4 flex-shrink-0" }), /* @__PURE__ */ W("span", { children: "Export as Markdown" })]
|
|
3587
3634
|
}),
|
|
3588
3635
|
/* @__PURE__ */ G(Q, {
|
|
3589
3636
|
onSelect: () => {
|
|
3590
|
-
|
|
3637
|
+
nr(c[0]?.userMessage?.content || "Chat", c.map((e) => `<h2>${e.userMessage.content}</h2>${e.assistantMessage?.content || ""}`).join("\n"));
|
|
3591
3638
|
},
|
|
3592
3639
|
className: "gap-2",
|
|
3593
3640
|
children: [/* @__PURE__ */ W(se, { className: "w-4 h-4 flex-shrink-0" }), /* @__PURE__ */ W("span", { children: "Export as PDF" })]
|
|
3594
3641
|
}),
|
|
3595
3642
|
/* @__PURE__ */ G(Q, {
|
|
3596
3643
|
onSelect: () => {
|
|
3597
|
-
|
|
3644
|
+
tr(c[0]?.userMessage?.content || "Chat", c.map((e) => `<h2>${e.userMessage.content}</h2>${e.assistantMessage?.content || ""}`).join("\n"));
|
|
3598
3645
|
},
|
|
3599
3646
|
className: "gap-2",
|
|
3600
3647
|
children: [/* @__PURE__ */ W(ie, { className: "w-4 h-4 flex-shrink-0" }), /* @__PURE__ */ W("span", { children: "Export as DOCX" })]
|
|
3601
3648
|
}),
|
|
3602
3649
|
/* @__PURE__ */ G(Q, {
|
|
3603
3650
|
onSelect: () => {
|
|
3604
|
-
|
|
3651
|
+
rr(c[0]?.userMessage?.content || "Chat", c.map((e) => `<h2>${e.userMessage.content}</h2>${e.assistantMessage?.content || ""}`).join("\n"));
|
|
3605
3652
|
},
|
|
3606
3653
|
className: "gap-2",
|
|
3607
3654
|
children: [/* @__PURE__ */ W(ae, { className: "w-4 h-4 flex-shrink-0" }), /* @__PURE__ */ W("span", { children: "Export to Google Docs" })]
|
|
3608
3655
|
})
|
|
3609
3656
|
]
|
|
3610
|
-
})] }), /* @__PURE__ */ W(
|
|
3657
|
+
})] }), /* @__PURE__ */ W(zn, {})] }),
|
|
3611
3658
|
/* @__PURE__ */ G(Q, {
|
|
3612
3659
|
onSelect: () => n.push("/library"),
|
|
3613
3660
|
className: "gap-2",
|
|
@@ -3654,7 +3701,7 @@ var hr = () => window.gapi, gr = () => window.google, _r = () => {
|
|
|
3654
3701
|
className: "hidden"
|
|
3655
3702
|
})
|
|
3656
3703
|
] });
|
|
3657
|
-
},
|
|
3704
|
+
}, Dr = o(({ active: e = !1, processing: t = !1, barWidth: n = 3, barHeight: r = 4, barGap: i = 1, barRadius: a = 1.5, barColor: o, fadeEdges: s = !0, fadeWidth: l = 24, height: d = 64, sensitivity: p = 1, smoothingTimeConstant: m = .8, fftSize: h = 256, historySize: g = 60, updateRate: _ = 30, mode: v = "static", onError: y, onStreamReady: b, onStreamEnd: x, className: S, ...C }, w) => {
|
|
3658
3705
|
let T = f(null), E = f(null), D = f(null), O = f(null), k = f(null), A = f(0), j = f([]), M = f(0), N = f(0), P = c(() => {
|
|
3659
3706
|
A.current &&= (cancelAnimationFrame(A.current), 0), k.current &&= (k.current.disconnect(), null), O.current &&= (O.current.getTracks().forEach((e) => e.stop()), null), E.current &&= (E.current.close().catch(() => {}), null), D.current = null, j.current = [], x?.();
|
|
3660
3707
|
}, [x]), F = c((e, t, o, s, c) => {
|
|
@@ -3803,23 +3850,23 @@ var hr = () => window.gapi, gr = () => window.google, _r = () => {
|
|
|
3803
3850
|
})
|
|
3804
3851
|
});
|
|
3805
3852
|
});
|
|
3806
|
-
|
|
3853
|
+
Dr.displayName = "LiveWaveform";
|
|
3807
3854
|
//#endregion
|
|
3808
3855
|
//#region src/components/MessageComposer/ChatInputBox.tsx
|
|
3809
|
-
var
|
|
3856
|
+
var Or = [
|
|
3810
3857
|
"What are you curious to research?",
|
|
3811
3858
|
"Search the latest news...",
|
|
3812
3859
|
"Analyze a video, doc, or URL...",
|
|
3813
3860
|
"Find academic research on...",
|
|
3814
3861
|
"Compare products to buy..."
|
|
3815
|
-
],
|
|
3862
|
+
], kr = {
|
|
3816
3863
|
initial: {},
|
|
3817
3864
|
animate: { transition: { staggerChildren: .025 } },
|
|
3818
3865
|
exit: { transition: {
|
|
3819
3866
|
staggerChildren: .015,
|
|
3820
3867
|
staggerDirection: -1
|
|
3821
3868
|
} }
|
|
3822
|
-
},
|
|
3869
|
+
}, Ar = {
|
|
3823
3870
|
initial: {
|
|
3824
3871
|
opacity: 0,
|
|
3825
3872
|
filter: "blur(12px)",
|
|
@@ -3853,8 +3900,8 @@ var wr = [
|
|
|
3853
3900
|
}
|
|
3854
3901
|
}
|
|
3855
3902
|
}
|
|
3856
|
-
},
|
|
3857
|
-
let { loading: t, sendMessage: n, stopStreaming: r, files: i, fileIds: a, setFiles: o, setFileIds: s, newChat: c, sections: l } =
|
|
3903
|
+
}, jr = ({ onNewChat: e }) => {
|
|
3904
|
+
let { loading: t, sendMessage: n, stopStreaming: r, files: i, fileIds: a, setFiles: o, setFileIds: s, newChat: c, sections: l } = Cn(), [d, m] = p(""), h = f(null), g = f(null), { files: _, setFiles: v, pastedContent: y, setPastedContent: b, isDragging: x, handleFiles: S, onDragOver: C, onDragLeave: w, onDrop: T, handlePaste: E, resetAttachments: D } = vr({
|
|
3858
3905
|
setMessage: m,
|
|
3859
3906
|
contextFiles: i,
|
|
3860
3907
|
contextFileIds: a,
|
|
@@ -3862,7 +3909,7 @@ var wr = [
|
|
|
3862
3909
|
setContextFileIds: s
|
|
3863
3910
|
}), O = () => {
|
|
3864
3911
|
m(""), D(), h.current && (h.current.style.height = "auto");
|
|
3865
|
-
}, { isListening: k, toggleSpeech: A, isSpeechSupported: j } =
|
|
3912
|
+
}, { isListening: k, toggleSpeech: A, isSpeechSupported: j } = pr((e) => m(e), () => {
|
|
3866
3913
|
m((e) => (e.trim() && setTimeout(() => {
|
|
3867
3914
|
n(e), O();
|
|
3868
3915
|
}, 0), e));
|
|
@@ -3882,7 +3929,7 @@ var wr = [
|
|
|
3882
3929
|
let t = new AbortController();
|
|
3883
3930
|
se.current = t;
|
|
3884
3931
|
try {
|
|
3885
|
-
let { data: n, error: r } = await
|
|
3932
|
+
let { data: n, error: r } = await Ue({
|
|
3886
3933
|
query: {
|
|
3887
3934
|
q: e,
|
|
3888
3935
|
limit: 8
|
|
@@ -3929,7 +3976,7 @@ var wr = [
|
|
|
3929
3976
|
if (I || d) return;
|
|
3930
3977
|
let e = setInterval(() => {
|
|
3931
3978
|
F(!1), setTimeout(() => {
|
|
3932
|
-
N((e) => (e + 1) %
|
|
3979
|
+
N((e) => (e + 1) % Or.length), F(!0);
|
|
3933
3980
|
}, 400);
|
|
3934
3981
|
}, 3e3);
|
|
3935
3982
|
return () => clearInterval(e);
|
|
@@ -3979,7 +4026,7 @@ var wr = [
|
|
|
3979
4026
|
onDragLeave: w,
|
|
3980
4027
|
onDrop: T,
|
|
3981
4028
|
children: [
|
|
3982
|
-
/* @__PURE__ */ G(
|
|
4029
|
+
/* @__PURE__ */ G(dt.div, {
|
|
3983
4030
|
ref: g,
|
|
3984
4031
|
className: "!box-content flex flex-col mx-2 md:mx-0 items-stretch relative z-10 rounded-[28px] bg-gray-50 dark:bg-[#30302E] border border-bg-300 dark:border-transparent cursor-text font-sans antialiased",
|
|
3985
4032
|
animate: { boxShadow: I || d ? "0 8px 32px 0 rgba(0,0,0,0.16)" : "0 2px 8px 0 rgba(0,0,0,0.08)" },
|
|
@@ -3992,17 +4039,17 @@ var wr = [
|
|
|
3992
4039
|
children: [
|
|
3993
4040
|
(_.length > 0 || y.length > 0) && /* @__PURE__ */ G("div", {
|
|
3994
4041
|
className: "flex gap-3 overflow-x-auto custom-scrollbar px-3 pt-3 pb-1",
|
|
3995
|
-
children: [y.map((e) => /* @__PURE__ */ W(
|
|
4042
|
+
children: [y.map((e) => /* @__PURE__ */ W(fr, {
|
|
3996
4043
|
content: e,
|
|
3997
4044
|
onRemove: (e) => b((t) => t.filter((t) => t.id !== e))
|
|
3998
|
-
}, e.id)), _.map((e) => /* @__PURE__ */ W(
|
|
4045
|
+
}, e.id)), _.map((e) => /* @__PURE__ */ W(dr, {
|
|
3999
4046
|
file: e,
|
|
4000
4047
|
onRemove: (e) => v((t) => t.filter((t) => t.id !== e))
|
|
4001
4048
|
}, e.id))]
|
|
4002
4049
|
}),
|
|
4003
4050
|
k && /* @__PURE__ */ W("div", {
|
|
4004
4051
|
className: "px-3 pt-2",
|
|
4005
|
-
children: /* @__PURE__ */ W(
|
|
4052
|
+
children: /* @__PURE__ */ W(Dr, {
|
|
4006
4053
|
active: k,
|
|
4007
4054
|
mode: "static",
|
|
4008
4055
|
height: 48,
|
|
@@ -4017,7 +4064,7 @@ var wr = [
|
|
|
4017
4064
|
/* @__PURE__ */ G("div", {
|
|
4018
4065
|
className: "flex items-center gap-2 p-3",
|
|
4019
4066
|
children: [
|
|
4020
|
-
/* @__PURE__ */ W(
|
|
4067
|
+
/* @__PURE__ */ W(Er, {
|
|
4021
4068
|
onFileSelect: S,
|
|
4022
4069
|
disabled: t
|
|
4023
4070
|
}),
|
|
@@ -4039,21 +4086,21 @@ var wr = [
|
|
|
4039
4086
|
})
|
|
4040
4087
|
}), /* @__PURE__ */ W("div", {
|
|
4041
4088
|
className: "absolute left-0 top-0 w-full h-full pointer-events-none flex items-center",
|
|
4042
|
-
children: /* @__PURE__ */ W(
|
|
4089
|
+
children: /* @__PURE__ */ W(lt, {
|
|
4043
4090
|
mode: "wait",
|
|
4044
|
-
children: P && !I && !d && /* @__PURE__ */ W(
|
|
4091
|
+
children: P && !I && !d && /* @__PURE__ */ W(dt.span, {
|
|
4045
4092
|
className: "absolute left-0 top-1/2 -translate-y-1/2 text-text-400 select-none pointer-events-none text-[16px] font-normal",
|
|
4046
4093
|
style: {
|
|
4047
4094
|
whiteSpace: "nowrap",
|
|
4048
4095
|
overflow: "hidden",
|
|
4049
4096
|
textOverflow: "ellipsis"
|
|
4050
4097
|
},
|
|
4051
|
-
variants:
|
|
4098
|
+
variants: kr,
|
|
4052
4099
|
initial: "initial",
|
|
4053
4100
|
animate: "animate",
|
|
4054
4101
|
exit: "exit",
|
|
4055
|
-
children:
|
|
4056
|
-
variants:
|
|
4102
|
+
children: Or[M].split("").map((e, t) => /* @__PURE__ */ W(dt.span, {
|
|
4103
|
+
variants: Ar,
|
|
4057
4104
|
style: { display: "inline-block" },
|
|
4058
4105
|
children: e === " " ? "\xA0" : e
|
|
4059
4106
|
}, t))
|
|
@@ -4132,7 +4179,7 @@ var wr = [
|
|
|
4132
4179
|
})
|
|
4133
4180
|
]
|
|
4134
4181
|
}),
|
|
4135
|
-
/* @__PURE__ */ W(
|
|
4182
|
+
/* @__PURE__ */ W(lt, { children: ne && de > 0 && /* @__PURE__ */ W(dt.div, {
|
|
4136
4183
|
ref: (e) => {
|
|
4137
4184
|
e && g.current && g.current.contains(e);
|
|
4138
4185
|
},
|
|
@@ -4211,40 +4258,40 @@ var wr = [
|
|
|
4211
4258
|
};
|
|
4212
4259
|
//#endregion
|
|
4213
4260
|
//#region src/ui/dialog.tsx
|
|
4214
|
-
function
|
|
4215
|
-
return /* @__PURE__ */ W(
|
|
4261
|
+
function Mr({ ...e }) {
|
|
4262
|
+
return /* @__PURE__ */ W(bt.Root, {
|
|
4216
4263
|
"data-slot": "dialog",
|
|
4217
4264
|
...e
|
|
4218
4265
|
});
|
|
4219
4266
|
}
|
|
4220
|
-
function
|
|
4221
|
-
return /* @__PURE__ */ W(
|
|
4267
|
+
function Nr({ ...e }) {
|
|
4268
|
+
return /* @__PURE__ */ W(bt.Trigger, {
|
|
4222
4269
|
"data-slot": "dialog-trigger",
|
|
4223
4270
|
...e
|
|
4224
4271
|
});
|
|
4225
4272
|
}
|
|
4226
|
-
function
|
|
4227
|
-
return /* @__PURE__ */ W(
|
|
4273
|
+
function Pr({ ...e }) {
|
|
4274
|
+
return /* @__PURE__ */ W(bt.Portal, {
|
|
4228
4275
|
"data-slot": "dialog-portal",
|
|
4229
4276
|
...e
|
|
4230
4277
|
});
|
|
4231
4278
|
}
|
|
4232
|
-
function
|
|
4233
|
-
return /* @__PURE__ */ W(
|
|
4279
|
+
function Fr({ className: e, ...t }) {
|
|
4280
|
+
return /* @__PURE__ */ W(bt.Overlay, {
|
|
4234
4281
|
"data-slot": "dialog-overlay",
|
|
4235
4282
|
className: J("data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50 backdrop-blur-xs", e),
|
|
4236
4283
|
...t
|
|
4237
4284
|
});
|
|
4238
4285
|
}
|
|
4239
|
-
function
|
|
4240
|
-
return /* @__PURE__ */ G(
|
|
4286
|
+
function Ir({ className: e, children: t, hideCloseButton: n = !1, ...r }) {
|
|
4287
|
+
return /* @__PURE__ */ G(Pr, {
|
|
4241
4288
|
"data-slot": "dialog-portal",
|
|
4242
|
-
children: [/* @__PURE__ */ W(
|
|
4289
|
+
children: [/* @__PURE__ */ W(Fr, {}), /* @__PURE__ */ G(bt.Content, {
|
|
4243
4290
|
"data-slot": "dialog-content",
|
|
4244
4291
|
"aria-describedby": r["aria-describedby"] ?? void 0,
|
|
4245
4292
|
className: J("z-[9999] bg-background 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 fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-2xl border p-6 shadow-lg duration-200", e),
|
|
4246
4293
|
...r,
|
|
4247
|
-
children: [t, !n && /* @__PURE__ */ G(
|
|
4294
|
+
children: [t, !n && /* @__PURE__ */ G(bt.Close, {
|
|
4248
4295
|
className: "ring-offset-background focus:ring-ring data-[state=open]:bg-accent data-[state=open]:text-muted-foreground absolute top-4 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
|
4249
4296
|
children: [/* @__PURE__ */ W(Fe, {}), /* @__PURE__ */ W("span", {
|
|
4250
4297
|
className: "sr-only",
|
|
@@ -4254,15 +4301,15 @@ function Mr({ className: e, children: t, hideCloseButton: n = !1, ...r }) {
|
|
|
4254
4301
|
})]
|
|
4255
4302
|
});
|
|
4256
4303
|
}
|
|
4257
|
-
function
|
|
4258
|
-
return /* @__PURE__ */ W(
|
|
4304
|
+
function Lr({ className: e, ...t }) {
|
|
4305
|
+
return /* @__PURE__ */ W(bt.Title, {
|
|
4259
4306
|
"data-slot": "dialog-title",
|
|
4260
4307
|
className: J("text-lg leading-none font-semibold", e),
|
|
4261
4308
|
...t
|
|
4262
4309
|
});
|
|
4263
4310
|
}
|
|
4264
|
-
function
|
|
4265
|
-
return /* @__PURE__ */ W(
|
|
4311
|
+
function Rr({ className: e, ...t }) {
|
|
4312
|
+
return /* @__PURE__ */ W(bt.Description, {
|
|
4266
4313
|
"data-slot": "dialog-description",
|
|
4267
4314
|
className: J("text-muted-foreground text-sm", e),
|
|
4268
4315
|
...t
|
|
@@ -4270,7 +4317,7 @@ function Pr({ className: e, ...t }) {
|
|
|
4270
4317
|
}
|
|
4271
4318
|
//#endregion
|
|
4272
4319
|
//#region src/ui/visually-hidden.tsx
|
|
4273
|
-
var
|
|
4320
|
+
var zr = n.forwardRef(({ className: e, ...t }, n) => /* @__PURE__ */ W("span", {
|
|
4274
4321
|
ref: n,
|
|
4275
4322
|
className: J("absolute w-px h-px p-0 -m-px overflow-hidden whitespace-nowrap border-0", e),
|
|
4276
4323
|
style: {
|
|
@@ -4279,17 +4326,17 @@ var Fr = n.forwardRef(({ className: e, ...t }, n) => /* @__PURE__ */ W("span", {
|
|
|
4279
4326
|
},
|
|
4280
4327
|
...t
|
|
4281
4328
|
}));
|
|
4282
|
-
|
|
4329
|
+
zr.displayName = "VisuallyHidden";
|
|
4283
4330
|
//#endregion
|
|
4284
4331
|
//#region src/components/ArticleReader/ArticlePanelHeader.tsx
|
|
4285
|
-
var
|
|
4332
|
+
var Br = ({ onClose: e }) => /* @__PURE__ */ W("div", {
|
|
4286
4333
|
className: "flex items-center justify-between bg-secondary px-4 py-3 border-b border-border",
|
|
4287
4334
|
children: /* @__PURE__ */ W("button", {
|
|
4288
4335
|
onClick: e,
|
|
4289
4336
|
className: "rounded-md p-1 hover:bg-accent transition-colors",
|
|
4290
4337
|
children: /* @__PURE__ */ W(Pe, { className: "h-5 w-5" })
|
|
4291
4338
|
})
|
|
4292
|
-
}),
|
|
4339
|
+
}), Vr = vt("inline-flex cursor-pointer items-center justify-center gap-2 whitespace-nowrap rounded-2xl text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive", {
|
|
4293
4340
|
variants: {
|
|
4294
4341
|
variant: {
|
|
4295
4342
|
default: "bg-primary text-primary-foreground hover:bg-primary/90",
|
|
@@ -4311,10 +4358,10 @@ var Ir = ({ onClose: e }) => /* @__PURE__ */ W("div", {
|
|
|
4311
4358
|
size: "default"
|
|
4312
4359
|
}
|
|
4313
4360
|
});
|
|
4314
|
-
function
|
|
4315
|
-
return /* @__PURE__ */ W(r ?
|
|
4361
|
+
function Hr({ className: e, variant: t, size: n, asChild: r = !1, ...i }) {
|
|
4362
|
+
return /* @__PURE__ */ W(r ? _t : "button", {
|
|
4316
4363
|
"data-slot": "button",
|
|
4317
|
-
className: J(
|
|
4364
|
+
className: J(Vr({
|
|
4318
4365
|
variant: t,
|
|
4319
4366
|
size: n,
|
|
4320
4367
|
className: e
|
|
@@ -4324,79 +4371,110 @@ function Rr({ className: e, variant: t, size: n, asChild: r = !1, ...i }) {
|
|
|
4324
4371
|
}
|
|
4325
4372
|
//#endregion
|
|
4326
4373
|
//#region src/components/ArticleReader/ArticleActionButtons.tsx
|
|
4327
|
-
var
|
|
4328
|
-
|
|
4329
|
-
|
|
4330
|
-
|
|
4331
|
-
|
|
4332
|
-
|
|
4333
|
-
|
|
4334
|
-
|
|
4335
|
-
|
|
4336
|
-
|
|
4337
|
-
className: "
|
|
4338
|
-
children:
|
|
4339
|
-
|
|
4340
|
-
|
|
4341
|
-
|
|
4342
|
-
|
|
4343
|
-
|
|
4344
|
-
|
|
4345
|
-
|
|
4346
|
-
|
|
4347
|
-
|
|
4348
|
-
className: "
|
|
4349
|
-
children: "
|
|
4350
|
-
|
|
4351
|
-
|
|
4352
|
-
|
|
4353
|
-
|
|
4354
|
-
|
|
4355
|
-
|
|
4356
|
-
|
|
4357
|
-
|
|
4358
|
-
|
|
4359
|
-
|
|
4360
|
-
|
|
4361
|
-
|
|
4362
|
-
|
|
4363
|
-
|
|
4364
|
-
|
|
4365
|
-
|
|
4366
|
-
|
|
4367
|
-
|
|
4368
|
-
|
|
4369
|
-
|
|
4370
|
-
|
|
4371
|
-
|
|
4372
|
-
|
|
4373
|
-
|
|
4374
|
-
|
|
4375
|
-
|
|
4376
|
-
|
|
4377
|
-
|
|
4378
|
-
|
|
4379
|
-
|
|
4380
|
-
|
|
4381
|
-
|
|
4382
|
-
|
|
4383
|
-
|
|
4384
|
-
|
|
4385
|
-
|
|
4386
|
-
|
|
4387
|
-
|
|
4374
|
+
var Ur = J("h-9 w-9 rounded-xl transition-all duration-200", "hover:bg-muted/80 hover:text-foreground text-muted-foreground"), Wr = ({ isLoadingAI: e, isLoadingFollowups: t, isLoadingFavorite: n, isFavorited: r, isHighlightMode: i, articleUrl: a, fontScale: o, onAskClick: s, onSuggestClick: c, onCopyClick: l, onFavoriteClick: u, onHighlightToggle: d, onZoomIn: f, onZoomOut: p, onZoomReset: m, onClose: h }) => {
|
|
4375
|
+
let g = f || p, _ = Math.round((o ?? 1) * 100);
|
|
4376
|
+
return /* @__PURE__ */ G("div", {
|
|
4377
|
+
className: "flex flex-nowrap items-center gap-1 rounded-2xl border border-muted bg-gradient-to-b from-background to-muted/30 p-1 shadow-sm",
|
|
4378
|
+
children: [
|
|
4379
|
+
/* @__PURE__ */ G(Hr, {
|
|
4380
|
+
onClick: s,
|
|
4381
|
+
disabled: e,
|
|
4382
|
+
variant: "ghost",
|
|
4383
|
+
size: "sm",
|
|
4384
|
+
className: J("flex items-center gap-2 px-3 h-9 rounded-xl transition-all duration-200", "hover:bg-muted/80 hover:text-foreground text-muted-foreground"),
|
|
4385
|
+
children: [/* @__PURE__ */ W(E, { className: "size-4" }), /* @__PURE__ */ W("span", {
|
|
4386
|
+
className: "font-medium",
|
|
4387
|
+
children: e ? "..." : "Ask"
|
|
4388
|
+
})]
|
|
4389
|
+
}),
|
|
4390
|
+
/* @__PURE__ */ G(Hr, {
|
|
4391
|
+
onClick: c,
|
|
4392
|
+
disabled: t,
|
|
4393
|
+
variant: "ghost",
|
|
4394
|
+
size: "sm",
|
|
4395
|
+
className: J("flex items-center gap-2 px-3 h-9 rounded-xl transition-all duration-200", "hover:bg-muted/80 hover:text-foreground text-muted-foreground"),
|
|
4396
|
+
children: [/* @__PURE__ */ W(pe, { className: "size-4" }), /* @__PURE__ */ W("span", {
|
|
4397
|
+
className: "font-medium",
|
|
4398
|
+
children: "Suggest"
|
|
4399
|
+
})]
|
|
4400
|
+
}),
|
|
4401
|
+
/* @__PURE__ */ W(Hr, {
|
|
4402
|
+
onClick: l,
|
|
4403
|
+
variant: "ghost",
|
|
4404
|
+
size: "icon",
|
|
4405
|
+
className: Ur,
|
|
4406
|
+
title: "Copy article",
|
|
4407
|
+
children: /* @__PURE__ */ W(F, { className: "size-4" })
|
|
4408
|
+
}),
|
|
4409
|
+
/* @__PURE__ */ W(Hr, {
|
|
4410
|
+
onClick: d,
|
|
4411
|
+
variant: "ghost",
|
|
4412
|
+
size: "icon",
|
|
4413
|
+
className: J("h-9 w-9 rounded-xl transition-all duration-200", i ? "text-yellow-500 bg-yellow-50 dark:bg-yellow-950/30 hover:bg-yellow-100 dark:hover:bg-yellow-950/50" : "hover:bg-muted/80 hover:text-foreground text-muted-foreground"),
|
|
4414
|
+
title: i ? "Disable highlighting" : "Enable highlighting",
|
|
4415
|
+
children: /* @__PURE__ */ W(le, { className: "size-4" })
|
|
4416
|
+
}),
|
|
4417
|
+
/* @__PURE__ */ W(Hr, {
|
|
4418
|
+
onClick: u,
|
|
4419
|
+
disabled: n,
|
|
4420
|
+
variant: "ghost",
|
|
4421
|
+
size: "icon",
|
|
4422
|
+
className: J("h-9 w-9 rounded-xl transition-all duration-200", r ? "text-yellow-500 hover:text-yellow-600 hover:bg-yellow-50 dark:hover:bg-yellow-950/30" : "hover:bg-muted/80 hover:text-foreground text-muted-foreground"),
|
|
4423
|
+
title: r ? "Remove from favorites" : "Add to favorites",
|
|
4424
|
+
children: /* @__PURE__ */ W(Ee, { className: J("size-4", r && "fill-yellow-400") })
|
|
4425
|
+
}),
|
|
4426
|
+
a && /* @__PURE__ */ W(Hr, {
|
|
4427
|
+
asChild: !0,
|
|
4428
|
+
variant: "ghost",
|
|
4429
|
+
size: "icon",
|
|
4430
|
+
className: Ur,
|
|
4431
|
+
title: "Open in new tab",
|
|
4432
|
+
children: /* @__PURE__ */ W("a", {
|
|
4433
|
+
href: a,
|
|
4434
|
+
target: "_blank",
|
|
4435
|
+
rel: "noopener noreferrer",
|
|
4436
|
+
children: /* @__PURE__ */ W(V, { className: "size-4" })
|
|
4437
|
+
})
|
|
4438
|
+
}),
|
|
4439
|
+
g && /* @__PURE__ */ G("div", {
|
|
4440
|
+
className: "ml-auto flex items-center gap-0.5 rounded-xl border border-muted/60 bg-muted/20 px-1",
|
|
4441
|
+
children: [
|
|
4442
|
+
/* @__PURE__ */ W(Hr, {
|
|
4443
|
+
onClick: p,
|
|
4444
|
+
variant: "ghost",
|
|
4445
|
+
size: "icon",
|
|
4446
|
+
className: "h-8 w-8 rounded-lg text-muted-foreground transition-all duration-200 hover:bg-muted/80 hover:text-foreground",
|
|
4447
|
+
title: "Zoom out",
|
|
4448
|
+
children: /* @__PURE__ */ W(Le, { className: "size-4" })
|
|
4449
|
+
}),
|
|
4450
|
+
/* @__PURE__ */ G("button", {
|
|
4451
|
+
type: "button",
|
|
4452
|
+
onClick: m,
|
|
4453
|
+
className: "min-w-[3rem] rounded-md px-1 text-center text-xs font-medium tabular-nums text-muted-foreground transition-colors hover:text-foreground",
|
|
4454
|
+
title: "Reset zoom",
|
|
4455
|
+
children: [_, "%"]
|
|
4456
|
+
}),
|
|
4457
|
+
/* @__PURE__ */ W(Hr, {
|
|
4458
|
+
onClick: f,
|
|
4459
|
+
variant: "ghost",
|
|
4460
|
+
size: "icon",
|
|
4461
|
+
className: "h-8 w-8 rounded-lg text-muted-foreground transition-all duration-200 hover:bg-muted/80 hover:text-foreground",
|
|
4462
|
+
title: "Zoom in",
|
|
4463
|
+
children: /* @__PURE__ */ W(Ie, { className: "size-4" })
|
|
4464
|
+
})
|
|
4465
|
+
]
|
|
4466
|
+
}),
|
|
4467
|
+
/* @__PURE__ */ W(Hr, {
|
|
4468
|
+
onClick: h,
|
|
4469
|
+
variant: "ghost",
|
|
4470
|
+
size: "icon",
|
|
4471
|
+
className: J(Ur, !g && "ml-auto"),
|
|
4472
|
+
title: "Close",
|
|
4473
|
+
children: /* @__PURE__ */ W(Pe, { className: "size-4" })
|
|
4388
4474
|
})
|
|
4389
|
-
|
|
4390
|
-
|
|
4391
|
-
|
|
4392
|
-
variant: "ghost",
|
|
4393
|
-
size: "icon",
|
|
4394
|
-
className: J(zr, "ml-auto"),
|
|
4395
|
-
title: "Close",
|
|
4396
|
-
children: /* @__PURE__ */ W(Pe, { className: "size-4" })
|
|
4397
|
-
})
|
|
4398
|
-
]
|
|
4399
|
-
}), Vr = ({ value: e, onChange: t, onSubmit: n }) => /* @__PURE__ */ W("div", {
|
|
4475
|
+
]
|
|
4476
|
+
});
|
|
4477
|
+
}, Gr = ({ value: e, onChange: t, onSubmit: n }) => /* @__PURE__ */ W("div", {
|
|
4400
4478
|
className: "relative",
|
|
4401
4479
|
children: /* @__PURE__ */ W("input", {
|
|
4402
4480
|
value: e,
|
|
@@ -4406,7 +4484,7 @@ var zr = J("h-9 w-9 rounded-xl transition-all duration-200", "hover:bg-muted/80
|
|
|
4406
4484
|
placeholder: "Ask AI any question...",
|
|
4407
4485
|
className: "w-full px-3 py-2 text-sm rounded-md border border-input bg-background text-foreground focus:outline-none focus:ring-2 focus:ring-ring"
|
|
4408
4486
|
})
|
|
4409
|
-
}),
|
|
4487
|
+
}), Kr = ({ questions: e, isLoading: n, error: i, onQuestionClick: a }) => {
|
|
4410
4488
|
let o = r.useMemo(() => {
|
|
4411
4489
|
let t = [];
|
|
4412
4490
|
return e.forEach((e) => {
|
|
@@ -4443,7 +4521,7 @@ var zr = J("h-9 w-9 rounded-xl transition-all duration-200", "hover:bg-muted/80
|
|
|
4443
4521
|
children: i
|
|
4444
4522
|
})
|
|
4445
4523
|
] });
|
|
4446
|
-
},
|
|
4524
|
+
}, qr = ({ response: e, isLoading: t, error: n }) => /* @__PURE__ */ G(U, { children: [
|
|
4447
4525
|
t && /* @__PURE__ */ W("div", {
|
|
4448
4526
|
className: "flex justify-center",
|
|
4449
4527
|
children: /* @__PURE__ */ W("div", { className: "animate-spin rounded-full h-8 w-8 border-b-2 border-blue-500" })
|
|
@@ -4457,18 +4535,30 @@ var zr = J("h-9 w-9 rounded-xl transition-all duration-200", "hover:bg-muted/80
|
|
|
4457
4535
|
className: "bg-red-500 text-white p-2 rounded-md text-sm",
|
|
4458
4536
|
children: n
|
|
4459
4537
|
})
|
|
4460
|
-
] }),
|
|
4461
|
-
let [
|
|
4538
|
+
] }), Jr = ({ html: e, isHighlightMode: t = !1, fontScale: n = 1 }) => {
|
|
4539
|
+
let [r, i] = p("");
|
|
4462
4540
|
return u(() => {
|
|
4463
|
-
|
|
4541
|
+
i(xt.sanitize(e || "", {
|
|
4464
4542
|
ADD_TAGS: ["figure", "figcaption"],
|
|
4465
4543
|
ADD_ATTR: ["loading"]
|
|
4466
4544
|
}));
|
|
4467
4545
|
}, [e]), /* @__PURE__ */ W("div", {
|
|
4468
|
-
className:
|
|
4469
|
-
|
|
4546
|
+
className: [
|
|
4547
|
+
"prose prose-neutral dark:prose-invert max-w-none",
|
|
4548
|
+
"prose-p:leading-[1.9] prose-li:leading-[1.9] prose-p:my-5 prose-li:my-1.5",
|
|
4549
|
+
"prose-headings:font-semibold prose-headings:tracking-tight prose-headings:leading-snug",
|
|
4550
|
+
"prose-h1:mt-8 prose-h2:mt-8 prose-h3:mt-6",
|
|
4551
|
+
"prose-blockquote:leading-[1.8] prose-blockquote:border-l-2",
|
|
4552
|
+
"prose-img:rounded-lg prose-img:my-6",
|
|
4553
|
+
t ? "select-text" : ""
|
|
4554
|
+
].join(" "),
|
|
4555
|
+
style: {
|
|
4556
|
+
fontSize: `${n}em`,
|
|
4557
|
+
fontFamily: "ui-serif, Georgia, Cambria, \"Times New Roman\", Times, serif"
|
|
4558
|
+
},
|
|
4559
|
+
dangerouslySetInnerHTML: { __html: r }
|
|
4470
4560
|
});
|
|
4471
|
-
},
|
|
4561
|
+
}, Yr = ({ article: e, isHighlightMode: t, fontScale: n = 1 }) => /* @__PURE__ */ W("div", {
|
|
4472
4562
|
className: "border-t border-border pt-6",
|
|
4473
4563
|
children: /* @__PURE__ */ G("div", { children: [
|
|
4474
4564
|
/* @__PURE__ */ W("div", { className: "flex items-start justify-between mb-2" }),
|
|
@@ -4489,23 +4579,24 @@ var zr = J("h-9 w-9 rounded-xl transition-all duration-200", "hover:bg-muted/80
|
|
|
4489
4579
|
}),
|
|
4490
4580
|
/* @__PURE__ */ W("div", {
|
|
4491
4581
|
id: "article-content",
|
|
4492
|
-
children: /* @__PURE__ */ W(
|
|
4582
|
+
children: /* @__PURE__ */ W(Jr, {
|
|
4493
4583
|
html: e.html || "",
|
|
4494
|
-
isHighlightMode: t
|
|
4584
|
+
isHighlightMode: t,
|
|
4585
|
+
fontScale: n
|
|
4495
4586
|
})
|
|
4496
4587
|
})
|
|
4497
4588
|
] })
|
|
4498
|
-
}),
|
|
4499
|
-
function
|
|
4589
|
+
}), Xr = /(?:https?:\/\/)?(?:www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b(?:[-a-zA-Z0-9()@:%_\+.~#?&\/=]*)/g, Zr = /[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}/g;
|
|
4590
|
+
function Qr(e) {
|
|
4500
4591
|
return e.includes("](") || e.includes(")[") ? !1 : /\.(com|org|net|io|dev|co|uk|de|fr|it|es|jp|cn|in|br|au|ca|us|gov|edu|mil|int|xyz|info|app|tech|online|site|website|store|shop|blog|news|tv|me|cc|ws|name|mobi|asia|tel|travel|jobs|pro|museum|coop|aero|arpa|biz|cat|jobs|post|tel|xxx|ac|ad|ae|af|ag|ai|al|am|ao|aq|ar|as|at|aw|ax|az|ba|bb|bd|be|bf|bg|bh|bi|bj|bm|bn|bo|br|bs|bt|bv|bw|by|bz|ca|cc|cd|cf|cg|ch|ci|ck|cl|cm|cn|co|cr|cu|cv|cw|cx|cy|cz|de|dj|dk|dm|do|dz|ec|ee|eg|eh|er|es|et|eu|fi|fj|fk|fm|fo|fr|ga|gb|gd|ge|gf|gg|gh|gi|gl|gm|gn|gp|gq|gr|gs|gt|gu|gw|gy|hk|hm|hn|hr|ht|hu|id|ie|il|im|in|io|iq|ir|is|it|je|jm|jo|jp|ke|kg|kh|ki|km|kn|kp|kr|kw|ky|kz|la|lb|lc|li|lk|lr|ls|lt|lu|lv|ly|ma|mc|md|me|mg|mh|mk|ml|mm|mn|mo|mp|mq|mr|ms|mt|mu|mv|mw|mx|my|mz|na|nc|ne|nf|ng|ni|nl|no|np|nr|nu|nz|om|pa|pe|pf|pg|ph|pk|pl|pm|pn|pr|ps|pt|pw|py|qa|re|ro|rs|ru|rw|sa|sb|sc|sd|se|sg|sh|si|sj|sk|sl|sm|sn|so|sr|ss|st|su|sv|sx|sy|sz|tc|td|tf|tg|th|tj|tk|tl|tm|tn|to|tr|tt|tv|tw|tz|ua|ug|uk|um|us|uy|uz|va|vc|ve|vg|vi|vn|vu|wf|ws|ye|yt|za|zm|zw)(?:\/|$)/i.test(e);
|
|
4501
4592
|
}
|
|
4502
|
-
function
|
|
4593
|
+
function $r(e) {
|
|
4503
4594
|
return /^https?:\/\//i.test(e) ? e : `https://${e}`;
|
|
4504
4595
|
}
|
|
4505
|
-
function
|
|
4596
|
+
function ei(e) {
|
|
4506
4597
|
if (!e || typeof e != "string") return e;
|
|
4507
4598
|
let t = e, n = [], r;
|
|
4508
|
-
for (
|
|
4599
|
+
for (Zr.lastIndex = 0; (r = Zr.exec(t)) !== null;) {
|
|
4509
4600
|
let e = r[0], i = r.index, a = t.substring(0, i), o = t.substring(i + e.length);
|
|
4510
4601
|
!a.endsWith("](") && !o.startsWith(")") && n.push({
|
|
4511
4602
|
email: e,
|
|
@@ -4517,9 +4608,9 @@ function Xr(e) {
|
|
|
4517
4608
|
t = t.substring(0, i) + `[${r}](mailto:${r})` + t.substring(i + r.length);
|
|
4518
4609
|
}
|
|
4519
4610
|
let i = [], a;
|
|
4520
|
-
for (
|
|
4611
|
+
for (Xr.lastIndex = 0; (a = Xr.exec(t)) !== null;) {
|
|
4521
4612
|
let e = a[0], n = a.index;
|
|
4522
|
-
if (
|
|
4613
|
+
if (Zr.test(e)) continue;
|
|
4523
4614
|
let r = t.substring(0, n), o = t.substring(n + e.length);
|
|
4524
4615
|
if (r.endsWith("](") || o.startsWith(")") || (r.match(/```/g) || []).length % 2 != 0) continue;
|
|
4525
4616
|
let s = r.lastIndexOf("`");
|
|
@@ -4527,23 +4618,23 @@ function Xr(e) {
|
|
|
4527
4618
|
let e = t.substring(s + 1).indexOf("`");
|
|
4528
4619
|
if (e !== -1 && e > n - s - 1) continue;
|
|
4529
4620
|
}
|
|
4530
|
-
|
|
4621
|
+
Qr(e) && i.push({
|
|
4531
4622
|
url: e,
|
|
4532
4623
|
index: n
|
|
4533
4624
|
});
|
|
4534
4625
|
}
|
|
4535
4626
|
for (let e = i.length - 1; e >= 0; e--) {
|
|
4536
|
-
let { url: n, index: r } = i[e], a =
|
|
4627
|
+
let { url: n, index: r } = i[e], a = $r(n);
|
|
4537
4628
|
t = t.substring(0, r) + `[${n}](${a})` + t.substring(r + n.length);
|
|
4538
4629
|
}
|
|
4539
4630
|
return t;
|
|
4540
4631
|
}
|
|
4541
4632
|
//#endregion
|
|
4542
4633
|
//#region src/components/ArticleReader/unified-markdown.tsx
|
|
4543
|
-
function
|
|
4634
|
+
function ti(e) {
|
|
4544
4635
|
return !e || e.startsWith("http://") || e.startsWith("https://") || e.includes("://") ? !1 : e.startsWith("/") || e.startsWith("#");
|
|
4545
4636
|
}
|
|
4546
|
-
function
|
|
4637
|
+
function ni(e, t) {
|
|
4547
4638
|
if (t.startsWith("#")) {
|
|
4548
4639
|
e.preventDefault();
|
|
4549
4640
|
let n = t.substring(1), r = document.getElementById(n);
|
|
@@ -4553,7 +4644,7 @@ function Qr(e, t) {
|
|
|
4553
4644
|
});
|
|
4554
4645
|
}
|
|
4555
4646
|
}
|
|
4556
|
-
function
|
|
4647
|
+
function ri({ code: e }) {
|
|
4557
4648
|
let [t, n] = p(!1);
|
|
4558
4649
|
return /* @__PURE__ */ W("button", {
|
|
4559
4650
|
onClick: c(async () => {
|
|
@@ -4568,7 +4659,7 @@ function $r({ code: e }) {
|
|
|
4568
4659
|
children: t ? /* @__PURE__ */ W(k, { className: "h-4 w-4 text-green-600 dark:text-green-400" }) : /* @__PURE__ */ W(B, { className: "h-4 w-4" })
|
|
4569
4660
|
});
|
|
4570
4661
|
}
|
|
4571
|
-
function
|
|
4662
|
+
function ii({ children: e }) {
|
|
4572
4663
|
let t = f(null), [n, r] = p("");
|
|
4573
4664
|
return u(() => {
|
|
4574
4665
|
if (t.current) {
|
|
@@ -4584,18 +4675,18 @@ function ei({ children: e }) {
|
|
|
4584
4675
|
ref: t,
|
|
4585
4676
|
className: J("p-4 rounded-xl overflow-x-auto", "bg-zinc-100 dark:bg-zinc-900", "border border-zinc-200 dark:border-zinc-800", "text-[13px] font-mono leading-relaxed", "text-zinc-800 dark:text-zinc-200", "[&_code]:bg-transparent [&_code]:text-inherit [&_code]:p-0"),
|
|
4586
4677
|
children: e
|
|
4587
|
-
}), n && /* @__PURE__ */ W(
|
|
4678
|
+
}), n && /* @__PURE__ */ W(ri, { code: n })]
|
|
4588
4679
|
});
|
|
4589
4680
|
}
|
|
4590
|
-
var
|
|
4681
|
+
var ai = r.memo(({ content: e, className: t, isStreaming: n = !1 }) => {
|
|
4591
4682
|
if (!e) return /* @__PURE__ */ W("div", {
|
|
4592
4683
|
className: J("text-muted-foreground text-sm", t),
|
|
4593
4684
|
children: "No content"
|
|
4594
4685
|
});
|
|
4595
|
-
let r =
|
|
4686
|
+
let r = ei(e);
|
|
4596
4687
|
return /* @__PURE__ */ W("div", {
|
|
4597
4688
|
className: J("kortix-markdown", t),
|
|
4598
|
-
children: /* @__PURE__ */ W(
|
|
4689
|
+
children: /* @__PURE__ */ W(Ct, {
|
|
4599
4690
|
isAnimating: n,
|
|
4600
4691
|
components: {
|
|
4601
4692
|
h1: ({ children: e }) => /* @__PURE__ */ W("h1", {
|
|
@@ -4639,13 +4730,13 @@ var ti = r.memo(({ content: e, className: t, isStreaming: n = !1 }) => {
|
|
|
4639
4730
|
children: e
|
|
4640
4731
|
}),
|
|
4641
4732
|
a: ({ href: e, children: t }) => {
|
|
4642
|
-
let n =
|
|
4733
|
+
let n = ti(e), r = e?.startsWith("#"), i = J("font-medium text-foreground", "underline decoration-foreground/30 underline-offset-[3px] decoration-[1px]", "hover:decoration-foreground/60 transition-colors duration-150");
|
|
4643
4734
|
return r ? /* @__PURE__ */ W("a", {
|
|
4644
4735
|
href: e,
|
|
4645
|
-
onClick: (t) =>
|
|
4736
|
+
onClick: (t) => ni(t, e),
|
|
4646
4737
|
className: i,
|
|
4647
4738
|
children: t
|
|
4648
|
-
}) : n ? /* @__PURE__ */ W(
|
|
4739
|
+
}) : n ? /* @__PURE__ */ W(St, {
|
|
4649
4740
|
href: e || "#",
|
|
4650
4741
|
className: i,
|
|
4651
4742
|
children: t
|
|
@@ -4664,7 +4755,7 @@ var ti = r.memo(({ content: e, className: t, isStreaming: n = !1 }) => {
|
|
|
4664
4755
|
className: "px-2 py-1 rounded-md text-[13px] font-mono bg-card dark:bg-[#161618] border border-neutral-200 dark:border-neutral-700/50 text-foreground",
|
|
4665
4756
|
children: e
|
|
4666
4757
|
}),
|
|
4667
|
-
pre: ({ children: e }) => /* @__PURE__ */ W(
|
|
4758
|
+
pre: ({ children: e }) => /* @__PURE__ */ W(ii, { children: e }),
|
|
4668
4759
|
blockquote: ({ children: e }) => /* @__PURE__ */ W("blockquote", {
|
|
4669
4760
|
className: J("my-5 pl-4 py-1 text-sm", "border-l-2 border-border", "text-muted-foreground", "[&>p]:my-2"),
|
|
4670
4761
|
children: e
|
|
@@ -4745,11 +4836,24 @@ var ti = r.memo(({ content: e, className: t, isStreaming: n = !1 }) => {
|
|
|
4745
4836
|
})
|
|
4746
4837
|
});
|
|
4747
4838
|
});
|
|
4748
|
-
|
|
4839
|
+
ai.displayName = "UnifiedMarkdown";
|
|
4749
4840
|
//#endregion
|
|
4750
4841
|
//#region src/components/ArticleReader/ArticleExtractPanel.tsx
|
|
4751
|
-
var
|
|
4752
|
-
let { isOpen: n, url: r, searchText: i, panelWidth: a, setPanelWidth: o, closePanel: s } =
|
|
4842
|
+
var oi = (e) => {
|
|
4843
|
+
let { isOpen: n, url: r, searchText: i, panelWidth: a, setPanelWidth: o, closePanel: s } = Ot(), { isAuthenticated: c } = Dn(), { chatModelProvider: l } = Cn(), d = e.isOpen === void 0 ? n : e.isOpen, m = e.onClose || s, h = e.url || r, g = e.searchText === void 0 ? i : e.searchText, [_, v] = p(null), [y, b] = p([]), [x, S] = p(!1), [C, w] = p(t.defaultSummarizePrompt), [T, E] = p(!1), [D, O] = p(!1), [k, A] = p(!1), [j, M] = p(""), [N, P] = p(""), [F, I] = p([]), [L, R] = p(""), [z, B] = p(!1), [ee, te] = p(!1), [V, ne] = p(!1), [re, ie] = p(!1), [ae, oe] = p(a), [se, ce] = p(!1), [le, ue] = p(!1), [de, H] = p(1), fe = f(null), pe = .8, me = 1.8, he = .1;
|
|
4844
|
+
u(() => {
|
|
4845
|
+
let e = parseFloat(localStorage.getItem("articleFontScale") || "");
|
|
4846
|
+
Number.isNaN(e) || H(Math.min(me, Math.max(pe, e)));
|
|
4847
|
+
}, []);
|
|
4848
|
+
let ge = (e) => {
|
|
4849
|
+
let t = Math.min(me, Math.max(pe, Math.round(e * 100) / 100));
|
|
4850
|
+
H(t);
|
|
4851
|
+
try {
|
|
4852
|
+
localStorage.setItem("articleFontScale", String(t));
|
|
4853
|
+
} catch (e) {
|
|
4854
|
+
console.error("Error storing article font scale:", e);
|
|
4855
|
+
}
|
|
4856
|
+
}, _e = () => ge(de + he), ve = () => ge(de - he), ye = () => ge(1);
|
|
4753
4857
|
u(() => {
|
|
4754
4858
|
let e = () => {
|
|
4755
4859
|
ie(window.innerWidth >= 1024);
|
|
@@ -4767,9 +4871,9 @@ var ni = (e) => {
|
|
|
4767
4871
|
document.removeEventListener("mousemove", e), document.removeEventListener("mouseup", t), document.body.style.cursor = "", document.body.style.userSelect = "";
|
|
4768
4872
|
};
|
|
4769
4873
|
}, [se, o]), u(() => {
|
|
4770
|
-
d && h ? (ue(!1),
|
|
4874
|
+
d && h ? (ue(!1), be()) : d || ue(!1);
|
|
4771
4875
|
}, [d, h]);
|
|
4772
|
-
let
|
|
4876
|
+
let be = async () => {
|
|
4773
4877
|
console.log("[ArticleExtractPanel] Extracting URL:", h);
|
|
4774
4878
|
try {
|
|
4775
4879
|
let e = new URL(h);
|
|
@@ -4787,35 +4891,35 @@ var ni = (e) => {
|
|
|
4787
4891
|
}
|
|
4788
4892
|
E(!0);
|
|
4789
4893
|
try {
|
|
4790
|
-
let { data: e } = await
|
|
4894
|
+
let { data: e } = await qe({ query: { url: h } }), t = e?.article, n = t?.html?.replace(/<[^>]*>/g, "").trim() || "";
|
|
4791
4895
|
t?.error || n.length < 20 ? (document.dispatchEvent(new CustomEvent("onInvokeChromeAPI", { detail: {
|
|
4792
4896
|
type: "extractURL",
|
|
4793
4897
|
url: h
|
|
4794
4898
|
} })), await Promise.race([new Promise((e) => {
|
|
4795
4899
|
let t = async (n) => {
|
|
4796
4900
|
window.removeEventListener("onExtractionResult", t);
|
|
4797
|
-
let { data: r } = await
|
|
4901
|
+
let { data: r } = await qe({ query: { url: h } }), i = r?.article;
|
|
4798
4902
|
i && (v(i), i.followUpQuestions?.length > 0 && I(i.followUpQuestions)), e();
|
|
4799
4903
|
};
|
|
4800
4904
|
window.addEventListener("onExtractionResult", t);
|
|
4801
|
-
}), new Promise((e) => setTimeout(e, 1e4))])) : (v(t), t?.followUpQuestions && t.followUpQuestions.length > 0 && I(t.followUpQuestions)), c &&
|
|
4905
|
+
}), new Promise((e) => setTimeout(e, 1e4))])) : (v(t), t?.followUpQuestions && t.followUpQuestions.length > 0 && I(t.followUpQuestions)), c && xe();
|
|
4802
4906
|
} catch (e) {
|
|
4803
4907
|
console.error("[ArticleExtractPanel] Error extracting URL:", e), K.error("Failed to load article");
|
|
4804
4908
|
} finally {
|
|
4805
4909
|
E(!1), ue(!0);
|
|
4806
4910
|
}
|
|
4807
|
-
},
|
|
4911
|
+
}, xe = async () => {
|
|
4808
4912
|
try {
|
|
4809
|
-
let { data: e } = await
|
|
4913
|
+
let { data: e } = await et(), t = e?.favorites?.some((e) => e.url === h);
|
|
4810
4914
|
B(!!t);
|
|
4811
4915
|
} catch (e) {
|
|
4812
4916
|
console.error("Error checking favorite status:", e);
|
|
4813
4917
|
}
|
|
4814
|
-
},
|
|
4918
|
+
}, Se = async () => {
|
|
4815
4919
|
if (_) {
|
|
4816
4920
|
te(!0);
|
|
4817
4921
|
try {
|
|
4818
|
-
z ? (await
|
|
4922
|
+
z ? (await nt({ query: { url: h } }), B(!1), K.info("Removed from favorites")) : (await Re({ body: {
|
|
4819
4923
|
url: _.url || h,
|
|
4820
4924
|
title: _.title,
|
|
4821
4925
|
cite: _.cite,
|
|
@@ -4832,26 +4936,38 @@ var ni = (e) => {
|
|
|
4832
4936
|
te(!1);
|
|
4833
4937
|
}
|
|
4834
4938
|
}
|
|
4835
|
-
},
|
|
4939
|
+
}, Ce = () => {
|
|
4940
|
+
if (l?.key && l?.providerId) return l;
|
|
4941
|
+
try {
|
|
4942
|
+
let e = localStorage.getItem("chatModelKey") || "", t = localStorage.getItem("chatModelProviderId") || "";
|
|
4943
|
+
if (e && t) return {
|
|
4944
|
+
key: e,
|
|
4945
|
+
providerId: t
|
|
4946
|
+
};
|
|
4947
|
+
} catch (e) {
|
|
4948
|
+
console.error("Error reading persisted chat model:", e);
|
|
4949
|
+
}
|
|
4950
|
+
return l;
|
|
4951
|
+
}, we = async (e) => {
|
|
4836
4952
|
if (!_) return;
|
|
4837
|
-
let n = _.html?.replace(/<[^>]*>?/g, "").slice(0, t.maxArticleLength),
|
|
4838
|
-
|
|
4953
|
+
let n = Ce(), r = _.html?.replace(/<[^>]*>?/g, "").slice(0, t.maxArticleLength), i = e === "question", a = i ? O : A, o = i ? P : R;
|
|
4954
|
+
a(!0), o("");
|
|
4839
4955
|
try {
|
|
4840
|
-
if (
|
|
4956
|
+
if (i) {
|
|
4841
4957
|
let e = [g, C].filter(Boolean).join("\n");
|
|
4842
|
-
if (!
|
|
4843
|
-
let { data: t, error:
|
|
4844
|
-
article:
|
|
4958
|
+
if (!r || r.length === 0) throw Error("Article content is empty");
|
|
4959
|
+
let { data: t, error: i } = await He({ body: {
|
|
4960
|
+
article: r,
|
|
4845
4961
|
question: e,
|
|
4846
4962
|
chatHistory: y.slice(-5),
|
|
4847
|
-
chatModel:
|
|
4963
|
+
chatModel: n
|
|
4848
4964
|
} });
|
|
4849
|
-
if (
|
|
4850
|
-
let e =
|
|
4965
|
+
if (i) {
|
|
4966
|
+
let e = i.details || i.error || i.message || "Article QA failed";
|
|
4851
4967
|
throw Error(e);
|
|
4852
4968
|
}
|
|
4853
|
-
let
|
|
4854
|
-
M(
|
|
4969
|
+
let a = t?.content || "";
|
|
4970
|
+
M(a), b((e) => [
|
|
4855
4971
|
...e,
|
|
4856
4972
|
{
|
|
4857
4973
|
role: "user",
|
|
@@ -4860,51 +4976,51 @@ var ni = (e) => {
|
|
|
4860
4976
|
},
|
|
4861
4977
|
{
|
|
4862
4978
|
role: "assistant",
|
|
4863
|
-
content:
|
|
4979
|
+
content: a,
|
|
4864
4980
|
time: (/* @__PURE__ */ new Date()).toISOString()
|
|
4865
4981
|
}
|
|
4866
4982
|
]);
|
|
4867
4983
|
try {
|
|
4868
|
-
await
|
|
4984
|
+
await ot({ body: {
|
|
4869
4985
|
url: h,
|
|
4870
4986
|
question: C,
|
|
4871
|
-
answer:
|
|
4987
|
+
answer: a
|
|
4872
4988
|
} });
|
|
4873
4989
|
} catch (e) {
|
|
4874
4990
|
console.error("Error storing Q&A in cache:", e);
|
|
4875
4991
|
}
|
|
4876
4992
|
} else {
|
|
4877
4993
|
let e = parseInt(localStorage.getItem("maxFollowupQuestions") || "4");
|
|
4878
|
-
if (!
|
|
4879
|
-
let { data: t, error:
|
|
4880
|
-
article:
|
|
4994
|
+
if (!r || r.length === 0) throw Error("Article content is empty");
|
|
4995
|
+
let { data: t, error: i } = await Ve({ body: {
|
|
4996
|
+
article: r,
|
|
4881
4997
|
chatHistory: y.slice(-5),
|
|
4882
4998
|
maxQuestions: e,
|
|
4883
|
-
chatModel:
|
|
4999
|
+
chatModel: n
|
|
4884
5000
|
} });
|
|
4885
|
-
if (
|
|
4886
|
-
let e =
|
|
5001
|
+
if (i) {
|
|
5002
|
+
let e = i.details || i.error || i.message || "Article followups failed";
|
|
4887
5003
|
throw Error(e);
|
|
4888
5004
|
}
|
|
4889
|
-
let
|
|
4890
|
-
I(
|
|
5005
|
+
let a = t?.extract || [];
|
|
5006
|
+
I(a);
|
|
4891
5007
|
try {
|
|
4892
|
-
await
|
|
5008
|
+
await ot({ body: {
|
|
4893
5009
|
url: h,
|
|
4894
|
-
followUpQuestions:
|
|
5010
|
+
followUpQuestions: a
|
|
4895
5011
|
} });
|
|
4896
5012
|
} catch (e) {
|
|
4897
5013
|
console.error("Error storing follow-up questions in cache:", e);
|
|
4898
5014
|
}
|
|
4899
5015
|
}
|
|
4900
5016
|
} catch (e) {
|
|
4901
|
-
console.error("Error calling language API:", e),
|
|
5017
|
+
console.error("Error calling language API:", e), o(e instanceof Error || typeof e == "object" && e && "message" in e ? e.message : "Failed to get AI response");
|
|
4902
5018
|
} finally {
|
|
4903
|
-
|
|
5019
|
+
a(!1);
|
|
4904
5020
|
}
|
|
4905
|
-
},
|
|
4906
|
-
w(e),
|
|
4907
|
-
},
|
|
5021
|
+
}, Te = (e) => {
|
|
5022
|
+
w(e), we("question");
|
|
5023
|
+
}, Ee = async () => {
|
|
4908
5024
|
if (!_) return;
|
|
4909
5025
|
let e = `${j}\n\n\n${_.cite || ""}\n\n\n${_.html}`;
|
|
4910
5026
|
try {
|
|
@@ -4912,43 +5028,49 @@ var ni = (e) => {
|
|
|
4912
5028
|
} catch (e) {
|
|
4913
5029
|
console.error("Failed to copy to clipboard:", e);
|
|
4914
5030
|
}
|
|
4915
|
-
},
|
|
5031
|
+
}, De = () => /* @__PURE__ */ G("div", {
|
|
4916
5032
|
className: "flex h-full flex-col bg-background shadow-xl",
|
|
4917
|
-
children: /* @__PURE__ */ W("div", {
|
|
5033
|
+
children: [/* @__PURE__ */ W("div", {
|
|
5034
|
+
className: "shrink-0 border-b border-border bg-background/95 px-4 py-3 backdrop-blur supports-[backdrop-filter]:bg-background/80",
|
|
5035
|
+
children: /* @__PURE__ */ W(Wr, {
|
|
5036
|
+
isLoadingAI: D,
|
|
5037
|
+
isLoadingFollowups: k,
|
|
5038
|
+
isLoadingFavorite: ee,
|
|
5039
|
+
isFavorited: z,
|
|
5040
|
+
isHighlightMode: V,
|
|
5041
|
+
articleUrl: _?.url || h,
|
|
5042
|
+
fontScale: de,
|
|
5043
|
+
onAskClick: () => we("question"),
|
|
5044
|
+
onSuggestClick: () => we("suggest-followups"),
|
|
5045
|
+
onCopyClick: Ee,
|
|
5046
|
+
onFavoriteClick: Se,
|
|
5047
|
+
onHighlightToggle: () => ne(!V),
|
|
5048
|
+
onZoomIn: _e,
|
|
5049
|
+
onZoomOut: ve,
|
|
5050
|
+
onZoomReset: ye,
|
|
5051
|
+
onClose: m
|
|
5052
|
+
})
|
|
5053
|
+
}), /* @__PURE__ */ W("div", {
|
|
4918
5054
|
className: "flex-1 overflow-y-auto",
|
|
4919
5055
|
children: /* @__PURE__ */ G("div", {
|
|
4920
5056
|
className: "p-4 space-y-6",
|
|
4921
5057
|
children: [/* @__PURE__ */ G("div", {
|
|
4922
5058
|
className: "space-y-4",
|
|
4923
5059
|
children: [
|
|
4924
|
-
/* @__PURE__ */ W(Br, {
|
|
4925
|
-
isLoadingAI: D,
|
|
4926
|
-
isLoadingFollowups: k,
|
|
4927
|
-
isLoadingFavorite: ee,
|
|
4928
|
-
isFavorited: z,
|
|
4929
|
-
isHighlightMode: V,
|
|
4930
|
-
articleUrl: _?.url || h,
|
|
4931
|
-
onAskClick: () => me("question"),
|
|
4932
|
-
onSuggestClick: () => me("suggest-followups"),
|
|
4933
|
-
onCopyClick: ge,
|
|
4934
|
-
onFavoriteClick: pe,
|
|
4935
|
-
onHighlightToggle: () => ne(!V),
|
|
4936
|
-
onClose: m
|
|
4937
|
-
}),
|
|
4938
5060
|
x && /* @__PURE__ */ W("div", {
|
|
4939
5061
|
className: "bg-blue-500 text-white text-sm font-medium px-3 py-2 rounded-md shadow-lg",
|
|
4940
5062
|
children: "Copied!"
|
|
4941
5063
|
}),
|
|
4942
|
-
/* @__PURE__ */ W(
|
|
5064
|
+
/* @__PURE__ */ W(Gr, {
|
|
4943
5065
|
value: C,
|
|
4944
5066
|
onChange: w,
|
|
4945
|
-
onSubmit: () =>
|
|
5067
|
+
onSubmit: () => we("question")
|
|
4946
5068
|
}),
|
|
4947
|
-
/* @__PURE__ */ W(
|
|
5069
|
+
/* @__PURE__ */ W(Kr, {
|
|
4948
5070
|
questions: F,
|
|
4949
5071
|
isLoading: k,
|
|
4950
5072
|
error: L,
|
|
4951
|
-
onQuestionClick:
|
|
5073
|
+
onQuestionClick: Te
|
|
4952
5074
|
}),
|
|
4953
5075
|
y.length > 0 && /* @__PURE__ */ W("div", {
|
|
4954
5076
|
className: "space-y-4",
|
|
@@ -4975,7 +5097,7 @@ var ni = (e) => {
|
|
|
4975
5097
|
})
|
|
4976
5098
|
}, t))
|
|
4977
5099
|
}),
|
|
4978
|
-
(D || j && y.length === 0) && /* @__PURE__ */ W(
|
|
5100
|
+
(D || j && y.length === 0) && /* @__PURE__ */ W(qr, {
|
|
4979
5101
|
response: j,
|
|
4980
5102
|
isLoading: D,
|
|
4981
5103
|
error: N
|
|
@@ -4985,37 +5107,38 @@ var ni = (e) => {
|
|
|
4985
5107
|
children: N
|
|
4986
5108
|
})
|
|
4987
5109
|
]
|
|
4988
|
-
}), _ && /* @__PURE__ */ W(
|
|
5110
|
+
}), _ && /* @__PURE__ */ W(Yr, {
|
|
4989
5111
|
article: _,
|
|
4990
|
-
isHighlightMode: V
|
|
5112
|
+
isHighlightMode: V,
|
|
5113
|
+
fontScale: de
|
|
4991
5114
|
})]
|
|
4992
5115
|
})
|
|
4993
|
-
})
|
|
5116
|
+
})]
|
|
4994
5117
|
});
|
|
4995
5118
|
return !d || !le ? null : re ? /* @__PURE__ */ G("div", {
|
|
4996
5119
|
className: "fixed top-0 right-0 h-screen z-40 transition-all duration-300",
|
|
4997
5120
|
style: { width: `${ae}px` },
|
|
4998
5121
|
children: [/* @__PURE__ */ W("div", {
|
|
4999
|
-
ref:
|
|
5122
|
+
ref: fe,
|
|
5000
5123
|
onMouseDown: () => ce(!0),
|
|
5001
5124
|
className: "absolute left-0 top-0 bottom-0 w-1 cursor-ew-resize hover:bg-primary bg-transparent transition-colors z-50",
|
|
5002
5125
|
style: { touchAction: "none" },
|
|
5003
5126
|
children: /* @__PURE__ */ W("div", { className: "absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2 w-1 h-12 rounded-full bg-muted-foreground opacity-50 hover:opacity-100 transition-opacity" })
|
|
5004
|
-
}),
|
|
5005
|
-
}) : /* @__PURE__ */ W(
|
|
5127
|
+
}), De()]
|
|
5128
|
+
}) : /* @__PURE__ */ W(Mr, {
|
|
5006
5129
|
open: d,
|
|
5007
5130
|
onOpenChange: (e) => !e && m(),
|
|
5008
|
-
children: /* @__PURE__ */ G(
|
|
5131
|
+
children: /* @__PURE__ */ G(Ir, {
|
|
5009
5132
|
className: "pointer-events-auto fixed inset-0 !top-0 !left-0 !translate-x-0 !translate-y-0 h-full w-full max-w-none p-0 m-0 rounded-none border-0 overflow-hidden 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]:slide-out-to-right data-[state=open]:slide-in-from-right",
|
|
5010
5133
|
hideCloseButton: !0,
|
|
5011
|
-
children: [/* @__PURE__ */ W(
|
|
5134
|
+
children: [/* @__PURE__ */ W(zr, { children: /* @__PURE__ */ W(Lr, { children: "Article Details" }) }), /* @__PURE__ */ W("div", {
|
|
5012
5135
|
className: "h-full overflow-y-auto",
|
|
5013
|
-
children:
|
|
5136
|
+
children: De()
|
|
5014
5137
|
})]
|
|
5015
5138
|
})
|
|
5016
5139
|
});
|
|
5017
|
-
},
|
|
5018
|
-
let { sections: e, chatTurns: n, loading: r, messageAppeared: a, newChat: o, chatId: s } =
|
|
5140
|
+
}, si = () => {
|
|
5141
|
+
let { sections: e, chatTurns: n, loading: r, messageAppeared: a, newChat: o, chatId: s } = Cn(), { isOpen: c, panelWidth: l } = Ot(), { isAuthenticated: d } = Dn(), [m, h] = p(!1), g = f(null), _ = f(null), v = f(!1);
|
|
5019
5142
|
return u(() => {
|
|
5020
5143
|
let e = () => {
|
|
5021
5144
|
h(window.innerWidth >= 1024);
|
|
@@ -5036,7 +5159,7 @@ var ni = (e) => {
|
|
|
5036
5159
|
children: [
|
|
5037
5160
|
e.map((t, n) => {
|
|
5038
5161
|
let r = n === e.length - 1;
|
|
5039
|
-
return /* @__PURE__ */ G(i, { children: [/* @__PURE__ */ W(
|
|
5162
|
+
return /* @__PURE__ */ G(i, { children: [/* @__PURE__ */ W(lr, {
|
|
5040
5163
|
section: t,
|
|
5041
5164
|
sectionIndex: n,
|
|
5042
5165
|
dividerRef: r ? g : void 0,
|
|
@@ -5053,7 +5176,7 @@ var ni = (e) => {
|
|
|
5053
5176
|
alignItems: "center",
|
|
5054
5177
|
justifyContent: "center"
|
|
5055
5178
|
},
|
|
5056
|
-
children: /* @__PURE__ */ W(
|
|
5179
|
+
children: /* @__PURE__ */ W(yt, {
|
|
5057
5180
|
autoRandomize: !0,
|
|
5058
5181
|
onSphereClick: () => console.log("Sphere clicked"),
|
|
5059
5182
|
className: "my-custom-class"
|
|
@@ -5067,13 +5190,13 @@ var ni = (e) => {
|
|
|
5067
5190
|
]
|
|
5068
5191
|
}), /* @__PURE__ */ W("div", {
|
|
5069
5192
|
className: "sticky bottom-[60px] md:bottom-0 z-40 bg-gradient-to-t from-background via-background to-transparent pt-4 pb-2",
|
|
5070
|
-
children: /* @__PURE__ */ W(
|
|
5193
|
+
children: /* @__PURE__ */ W(jr, {})
|
|
5071
5194
|
})]
|
|
5072
|
-
}), /* @__PURE__ */ W(
|
|
5195
|
+
}), /* @__PURE__ */ W(oi, {})] });
|
|
5073
5196
|
};
|
|
5074
5197
|
//#endregion
|
|
5075
5198
|
//#region src/ui/gradient-blur.tsx
|
|
5076
|
-
function
|
|
5199
|
+
function ci({ radius: e = 60, opacityDecay: t = .025, backgroundColor: n = "transparent", color: r, colorGenerator: i }) {
|
|
5077
5200
|
let a = f(null), o = f({
|
|
5078
5201
|
x: 0,
|
|
5079
5202
|
y: 0
|
|
@@ -5133,28 +5256,36 @@ function ii({ radius: e = 60, opacityDecay: t = .025, backgroundColor: n = "tran
|
|
|
5133
5256
|
}
|
|
5134
5257
|
//#endregion
|
|
5135
5258
|
//#region src/components/ChatHistoryDropdown/useHistoryState.ts
|
|
5136
|
-
var
|
|
5137
|
-
function
|
|
5259
|
+
var li = "qwksearch_pinned_chats";
|
|
5260
|
+
function ui(e) {
|
|
5261
|
+
let t = e.messages?.[e.messages.length - 1], n = t && "createdAt" in t ? t.createdAt : void 0;
|
|
5262
|
+
if (n) {
|
|
5263
|
+
let e = new Date(n).getTime();
|
|
5264
|
+
if (!Number.isNaN(e)) return new Date(e).toISOString();
|
|
5265
|
+
}
|
|
5266
|
+
return e.createdAt;
|
|
5267
|
+
}
|
|
5268
|
+
function di() {
|
|
5138
5269
|
if (typeof window > "u") return [];
|
|
5139
5270
|
try {
|
|
5140
|
-
let e = localStorage.getItem(
|
|
5271
|
+
let e = localStorage.getItem(li);
|
|
5141
5272
|
return e ? JSON.parse(e) : [];
|
|
5142
5273
|
} catch {
|
|
5143
5274
|
return [];
|
|
5144
5275
|
}
|
|
5145
5276
|
}
|
|
5146
|
-
function
|
|
5147
|
-
typeof window > "u" || localStorage.setItem(
|
|
5277
|
+
function fi(e) {
|
|
5278
|
+
typeof window > "u" || localStorage.setItem(li, JSON.stringify(e));
|
|
5148
5279
|
}
|
|
5149
|
-
function
|
|
5150
|
-
let [e, t] = p([]), [n, r] = p(!0), [i, a] = p(!1), [o, s] = p(null), [l, f] = p(!1), [m, h] = p(!1), [g, _] = p(!1), [v, y] = p([]), [b, x] = p(""), [S, C] = p([]), [w, T] = p(!1), { isAuthenticated: E, isLoading: D } =
|
|
5280
|
+
function pi() {
|
|
5281
|
+
let [e, t] = p([]), [n, r] = p(!0), [i, a] = p(!1), [o, s] = p(null), [l, f] = p(!1), [m, h] = p(!1), [g, _] = p(!1), [v, y] = p([]), [b, x] = p(""), [S, C] = p([]), [w, T] = p(!1), { isAuthenticated: E, isLoading: D } = Dn(), { incognito: O, setIncognito: k } = Cn();
|
|
5151
5282
|
u(() => {
|
|
5152
|
-
y(
|
|
5283
|
+
y(di());
|
|
5153
5284
|
}, []);
|
|
5154
5285
|
let A = c((e, t) => {
|
|
5155
5286
|
e.preventDefault(), e.stopPropagation(), y((e) => {
|
|
5156
5287
|
let n = e.includes(t) ? e.filter((e) => e !== t) : [...e, t];
|
|
5157
|
-
return
|
|
5288
|
+
return fi(n), n;
|
|
5158
5289
|
});
|
|
5159
5290
|
}, []), j = d(() => [...e].sort((e, t) => {
|
|
5160
5291
|
let n = v.includes(e.id), r = v.includes(t.id);
|
|
@@ -5168,11 +5299,12 @@ function ci() {
|
|
|
5168
5299
|
r(!0);
|
|
5169
5300
|
try {
|
|
5170
5301
|
if (E) {
|
|
5171
|
-
let { data: e, error: n } = await
|
|
5302
|
+
let { data: e, error: n } = await $e();
|
|
5172
5303
|
if (n && n.status === 401) {
|
|
5173
|
-
let e =
|
|
5304
|
+
let e = on().map((e) => ({
|
|
5174
5305
|
...e,
|
|
5175
|
-
messageCount: e.messages?.filter((e) => e.role === "user").length ?? 0
|
|
5306
|
+
messageCount: e.messages?.filter((e) => e.role === "user").length ?? 0,
|
|
5307
|
+
lastMessageAt: ui(e)
|
|
5176
5308
|
}));
|
|
5177
5309
|
t(e);
|
|
5178
5310
|
return;
|
|
@@ -5180,7 +5312,7 @@ function ci() {
|
|
|
5180
5312
|
if (n) throw Error(`Failed to fetch chats: ${n.message}`);
|
|
5181
5313
|
t(Array.isArray(e?.chats) ? e.chats : []);
|
|
5182
5314
|
} else {
|
|
5183
|
-
let e =
|
|
5315
|
+
let e = on().map((e) => ({
|
|
5184
5316
|
...e,
|
|
5185
5317
|
messageCount: e.messages?.filter((e) => e.role === "user").length ?? 0
|
|
5186
5318
|
}));
|
|
@@ -5203,9 +5335,9 @@ function ci() {
|
|
|
5203
5335
|
f(!0);
|
|
5204
5336
|
try {
|
|
5205
5337
|
if (E) {
|
|
5206
|
-
let { error: e } = await
|
|
5338
|
+
let { error: e } = await Ke({ path: { id: o } });
|
|
5207
5339
|
if (e) throw Error(`Failed to delete chat: ${e.message}`);
|
|
5208
|
-
} else
|
|
5340
|
+
} else ln(o);
|
|
5209
5341
|
t((e) => e.filter((e) => e.id !== o)), K.success("Chat deleted");
|
|
5210
5342
|
} catch (e) {
|
|
5211
5343
|
K.error(e.message || "Failed to delete chat");
|
|
@@ -5219,9 +5351,9 @@ function ci() {
|
|
|
5219
5351
|
_(!0);
|
|
5220
5352
|
try {
|
|
5221
5353
|
if (E) {
|
|
5222
|
-
let { error: e } = await
|
|
5354
|
+
let { error: e } = await Ge();
|
|
5223
5355
|
if (e) throw Error(`Failed to clear history: ${e.message}`);
|
|
5224
|
-
} else
|
|
5356
|
+
} else un();
|
|
5225
5357
|
t([]), K.success("All history cleared");
|
|
5226
5358
|
} catch (e) {
|
|
5227
5359
|
K.error(e.message || "Failed to clear history");
|
|
@@ -5238,17 +5370,18 @@ function ci() {
|
|
|
5238
5370
|
T(!0);
|
|
5239
5371
|
try {
|
|
5240
5372
|
if (E) {
|
|
5241
|
-
let { data: t, error: n } = await
|
|
5373
|
+
let { data: t, error: n } = await it({ query: { q: e } });
|
|
5242
5374
|
if (n) throw Error(`Failed to search chats: ${n.message}`);
|
|
5243
5375
|
C(Array.isArray(t?.chats) ? t.chats : []);
|
|
5244
5376
|
} else {
|
|
5245
|
-
let t =
|
|
5377
|
+
let t = on().filter((t) => {
|
|
5246
5378
|
let n = t.title.toLowerCase().includes(e.toLowerCase()), r = t.messages?.some((t) => "content" in t && t.content?.toLowerCase().includes(e.toLowerCase()));
|
|
5247
5379
|
return n || r;
|
|
5248
5380
|
});
|
|
5249
5381
|
C(t.map((e) => ({
|
|
5250
5382
|
...e,
|
|
5251
|
-
messageCount: e.messages?.filter((e) => e.role === "user").length ?? 0
|
|
5383
|
+
messageCount: e.messages?.filter((e) => e.role === "user").length ?? 0,
|
|
5384
|
+
lastMessageAt: ui(e)
|
|
5252
5385
|
})));
|
|
5253
5386
|
}
|
|
5254
5387
|
} catch (e) {
|
|
@@ -5293,7 +5426,7 @@ function ci() {
|
|
|
5293
5426
|
}
|
|
5294
5427
|
//#endregion
|
|
5295
5428
|
//#region src/components/ChatHistoryDropdown/HistoryHeader.tsx
|
|
5296
|
-
function
|
|
5429
|
+
function mi({ incognito: e, onToggleIncognito: t, showClearAll: n, onClearAll: r, searchQuery: i, onSearchChange: a }) {
|
|
5297
5430
|
return /* @__PURE__ */ G("div", {
|
|
5298
5431
|
className: "mb-2 pb-2 border-b border-border space-y-2",
|
|
5299
5432
|
children: [/* @__PURE__ */ G("div", {
|
|
@@ -5340,22 +5473,22 @@ function li({ incognito: e, onToggleIncognito: t, showClearAll: n, onClearAll: r
|
|
|
5340
5473
|
}
|
|
5341
5474
|
//#endregion
|
|
5342
5475
|
//#region src/components/ChatHistoryDropdown/HistoryChatItem.tsx
|
|
5343
|
-
function
|
|
5476
|
+
function hi({ chat: e, isPinned: t, onTogglePin: n, onDelete: r }) {
|
|
5344
5477
|
let i = e.messageCount ?? 0;
|
|
5345
5478
|
return /* @__PURE__ */ G("div", {
|
|
5346
5479
|
className: "group flex items-center gap-1 px-2 py-1 rounded-lg hover:bg-secondary transition-colors duration-200",
|
|
5347
5480
|
children: [
|
|
5348
|
-
/* @__PURE__ */ G(
|
|
5481
|
+
/* @__PURE__ */ G(St, {
|
|
5349
5482
|
href: `/c/${e.id}`,
|
|
5350
5483
|
className: "flex-1 min-w-0 flex items-center gap-1.5",
|
|
5351
5484
|
children: [/* @__PURE__ */ G("span", {
|
|
5352
5485
|
className: "flex items-center gap-1 shrink-0",
|
|
5353
|
-
children: [i > 0 && /* @__PURE__ */ G(
|
|
5486
|
+
children: [i > 0 && /* @__PURE__ */ G(sr, {
|
|
5354
5487
|
className: "px-1.5 py-0 text-[10px] font-medium bg-zinc-200 text-zinc-700 hover:bg-zinc-200 dark:bg-zinc-700 dark:text-zinc-300 dark:hover:bg-zinc-700 border-0 rounded-md",
|
|
5355
5488
|
children: [i, "Q"]
|
|
5356
|
-
}), /* @__PURE__ */ W(
|
|
5489
|
+
}), /* @__PURE__ */ W(sr, {
|
|
5357
5490
|
className: "px-1.5 py-0 text-[10px] font-medium bg-zinc-100 text-zinc-500 hover:bg-zinc-100 dark:bg-zinc-800 dark:text-zinc-400 dark:hover:bg-zinc-800 border-0 rounded-md",
|
|
5358
|
-
children:
|
|
5491
|
+
children: Tt(/* @__PURE__ */ new Date(), e.createdAt)
|
|
5359
5492
|
})]
|
|
5360
5493
|
}), /* @__PURE__ */ G("p", {
|
|
5361
5494
|
className: "text-xs text-popover-foreground truncate",
|
|
@@ -5382,20 +5515,20 @@ function ui({ chat: e, isPinned: t, onTogglePin: n, onDelete: r }) {
|
|
|
5382
5515
|
}
|
|
5383
5516
|
//#endregion
|
|
5384
5517
|
//#region src/components/ChatHistoryDropdown/HistoryDialogs.tsx
|
|
5385
|
-
function
|
|
5386
|
-
return /* @__PURE__ */ W(
|
|
5518
|
+
function gi({ open: e, onOpenChange: t, title: n, description: r, confirmLabel: i, loadingLabel: a, loading: o, onConfirm: s }) {
|
|
5519
|
+
return /* @__PURE__ */ W(Mr, {
|
|
5387
5520
|
open: e,
|
|
5388
5521
|
onOpenChange: (e) => {
|
|
5389
5522
|
!e && !o && t(!1);
|
|
5390
5523
|
},
|
|
5391
|
-
children: /* @__PURE__ */ G(
|
|
5524
|
+
children: /* @__PURE__ */ G(Ir, {
|
|
5392
5525
|
className: "w-full max-w-md transform rounded-2xl bg-light-secondary dark:bg-dark-secondary border border-light-200 dark:border-dark-200 p-6 text-left align-middle shadow-xl",
|
|
5393
5526
|
children: [
|
|
5394
|
-
/* @__PURE__ */ W(
|
|
5527
|
+
/* @__PURE__ */ W(Lr, {
|
|
5395
5528
|
className: "text-lg font-medium leading-6 dark:text-white",
|
|
5396
5529
|
children: n
|
|
5397
5530
|
}),
|
|
5398
|
-
/* @__PURE__ */ W(
|
|
5531
|
+
/* @__PURE__ */ W(Rr, {
|
|
5399
5532
|
className: "text-sm dark:text-white/70 text-black/70 mt-2",
|
|
5400
5533
|
children: r
|
|
5401
5534
|
}),
|
|
@@ -5418,8 +5551,8 @@ function di({ open: e, onOpenChange: t, title: n, description: r, confirmLabel:
|
|
|
5418
5551
|
})
|
|
5419
5552
|
});
|
|
5420
5553
|
}
|
|
5421
|
-
function
|
|
5422
|
-
return /* @__PURE__ */ G(U, { children: [/* @__PURE__ */ W(
|
|
5554
|
+
function _i({ deleteDialogOpen: e, setDeleteDialogOpen: t, chatToDelete: n, setChatToDelete: r, deleting: i, onConfirmDelete: a, clearAllDialogOpen: o, setClearAllDialogOpen: s, clearingAll: c, onConfirmClearAll: l }) {
|
|
5555
|
+
return /* @__PURE__ */ G(U, { children: [/* @__PURE__ */ W(gi, {
|
|
5423
5556
|
open: e,
|
|
5424
5557
|
onOpenChange: (e) => {
|
|
5425
5558
|
t(e), e || r(null);
|
|
@@ -5430,7 +5563,7 @@ function fi({ deleteDialogOpen: e, setDeleteDialogOpen: t, chatToDelete: n, setC
|
|
|
5430
5563
|
loadingLabel: "Deleting...",
|
|
5431
5564
|
loading: i,
|
|
5432
5565
|
onConfirm: a
|
|
5433
|
-
}), /* @__PURE__ */ W(
|
|
5566
|
+
}), /* @__PURE__ */ W(gi, {
|
|
5434
5567
|
open: o,
|
|
5435
5568
|
onOpenChange: s,
|
|
5436
5569
|
title: "Clear All History",
|
|
@@ -5443,13 +5576,13 @@ function fi({ deleteDialogOpen: e, setDeleteDialogOpen: t, chatToDelete: n, setC
|
|
|
5443
5576
|
}
|
|
5444
5577
|
//#endregion
|
|
5445
5578
|
//#region src/components/ChatHistoryDropdown/HistoryDropdown.tsx
|
|
5446
|
-
var
|
|
5579
|
+
var vi = {
|
|
5447
5580
|
Today: /* @__PURE__ */ W(Oe, { size: 12 }),
|
|
5448
5581
|
Yesterday: /* @__PURE__ */ W(L, { size: 12 }),
|
|
5449
5582
|
"This Week": /* @__PURE__ */ W(O, { size: 12 }),
|
|
5450
5583
|
Older: /* @__PURE__ */ W(S, { size: 12 })
|
|
5451
5584
|
};
|
|
5452
|
-
function
|
|
5585
|
+
function yi(e) {
|
|
5453
5586
|
let t = /* @__PURE__ */ new Date(), n = new Date(t.getFullYear(), t.getMonth(), t.getDate()), r = /* @__PURE__ */ new Date(n.getTime() - 864e5), i = /* @__PURE__ */ new Date(n.getTime() - 6 * 864e5), a = {
|
|
5454
5587
|
Today: [],
|
|
5455
5588
|
Yesterday: [],
|
|
@@ -5470,19 +5603,19 @@ function mi(e) {
|
|
|
5470
5603
|
chats: a[e]
|
|
5471
5604
|
}));
|
|
5472
5605
|
}
|
|
5473
|
-
var
|
|
5474
|
-
let t =
|
|
5475
|
-
return /* @__PURE__ */ G(U, { children: [/* @__PURE__ */ G(
|
|
5606
|
+
var bi = ({ showLabel: e = !1 }) => {
|
|
5607
|
+
let t = pi();
|
|
5608
|
+
return /* @__PURE__ */ G(U, { children: [/* @__PURE__ */ G(Mr, { children: [/* @__PURE__ */ G(Nr, {
|
|
5476
5609
|
className: e ? "inline-flex items-center gap-1.5 px-3 py-1 rounded-full text-xs text-muted-foreground bg-secondary hover:bg-secondary/80 hover:text-foreground transition-colors duration-150" : "p-2 text-muted-foreground rounded-2xl bg-background/60 backdrop-blur-md hover:bg-secondary/80 transition duration-200 hover:text-foreground border border-border/30",
|
|
5477
5610
|
children: [/* @__PURE__ */ W(ue, { size: e ? 14 : 18 }), e && /* @__PURE__ */ W("span", { children: "History" })]
|
|
5478
|
-
}), /* @__PURE__ */ G(
|
|
5611
|
+
}), /* @__PURE__ */ G(Ir, {
|
|
5479
5612
|
className: "max-w-[420px] p-3",
|
|
5480
5613
|
children: [
|
|
5481
|
-
/* @__PURE__ */ W(
|
|
5614
|
+
/* @__PURE__ */ W(Lr, {
|
|
5482
5615
|
className: "sr-only",
|
|
5483
5616
|
children: "Chat History"
|
|
5484
5617
|
}),
|
|
5485
|
-
/* @__PURE__ */ W(
|
|
5618
|
+
/* @__PURE__ */ W(mi, {
|
|
5486
5619
|
incognito: t.incognito,
|
|
5487
5620
|
onToggleIncognito: t.toggleIncognito,
|
|
5488
5621
|
showClearAll: t.chats.length > 0 && !t.loading,
|
|
@@ -5520,15 +5653,15 @@ var hi = ({ showLabel: e = !1 }) => {
|
|
|
5520
5653
|
})
|
|
5521
5654
|
}) : /* @__PURE__ */ W("div", {
|
|
5522
5655
|
className: "space-y-1 max-h-[500px] overflow-y-auto",
|
|
5523
|
-
children: t.searchQuery.trim() ? t.displayChats.map((e) => /* @__PURE__ */ W(
|
|
5656
|
+
children: t.searchQuery.trim() ? t.displayChats.map((e) => /* @__PURE__ */ W(hi, {
|
|
5524
5657
|
chat: e,
|
|
5525
5658
|
isPinned: t.pinnedIds.includes(e.id),
|
|
5526
5659
|
onTogglePin: t.togglePin,
|
|
5527
5660
|
onDelete: t.handleDeleteClick
|
|
5528
|
-
}, e.id)) :
|
|
5661
|
+
}, e.id)) : yi(t.displayChats).map(({ label: e, chats: n }) => /* @__PURE__ */ G("div", { children: [/* @__PURE__ */ G("div", {
|
|
5529
5662
|
className: "flex items-center gap-1.5 px-3 py-1.5 text-xs font-semibold text-muted-foreground/70 uppercase tracking-wider",
|
|
5530
|
-
children: [
|
|
5531
|
-
}), n.map((e) => /* @__PURE__ */ W(
|
|
5663
|
+
children: [vi[e], e]
|
|
5664
|
+
}), n.map((e) => /* @__PURE__ */ W(hi, {
|
|
5532
5665
|
chat: e,
|
|
5533
5666
|
isPinned: t.pinnedIds.includes(e.id),
|
|
5534
5667
|
onTogglePin: t.togglePin,
|
|
@@ -5537,14 +5670,14 @@ var hi = ({ showLabel: e = !1 }) => {
|
|
|
5537
5670
|
}),
|
|
5538
5671
|
t.chats.length > 0 && /* @__PURE__ */ W("div", {
|
|
5539
5672
|
className: "mt-2 pt-2 border-t border-border",
|
|
5540
|
-
children: /* @__PURE__ */ W(
|
|
5673
|
+
children: /* @__PURE__ */ W(St, {
|
|
5541
5674
|
href: "/library",
|
|
5542
5675
|
className: "block text-center text-xs text-primary hover:underline",
|
|
5543
5676
|
children: "View all chats"
|
|
5544
5677
|
})
|
|
5545
5678
|
})
|
|
5546
5679
|
]
|
|
5547
|
-
})] }), /* @__PURE__ */ W(
|
|
5680
|
+
})] }), /* @__PURE__ */ W(_i, {
|
|
5548
5681
|
deleteDialogOpen: t.deleteDialogOpen,
|
|
5549
5682
|
setDeleteDialogOpen: t.setDeleteDialogOpen,
|
|
5550
5683
|
chatToDelete: t.chatToDelete,
|
|
@@ -5558,22 +5691,53 @@ var hi = ({ showLabel: e = !1 }) => {
|
|
|
5558
5691
|
})] });
|
|
5559
5692
|
};
|
|
5560
5693
|
//#endregion
|
|
5694
|
+
//#region src/lib/relative-time.ts
|
|
5695
|
+
function xi(e) {
|
|
5696
|
+
let t = new Date(e).getTime();
|
|
5697
|
+
if (Number.isNaN(t)) return "";
|
|
5698
|
+
let n = Math.round((Date.now() - t) / 1e3);
|
|
5699
|
+
if (n < 5) return "just now";
|
|
5700
|
+
if (n < 60) return `${n} sec ago`;
|
|
5701
|
+
let r = Math.round(n / 60);
|
|
5702
|
+
if (r < 60) return `${r} min ago`;
|
|
5703
|
+
let i = Math.round(r / 60);
|
|
5704
|
+
if (i < 24) return `${i} hr ago`;
|
|
5705
|
+
let a = Math.round(i / 24);
|
|
5706
|
+
if (a < 7) return `${a} day${a === 1 ? "" : "s"} ago`;
|
|
5707
|
+
let o = Math.round(a / 7);
|
|
5708
|
+
if (o < 5) return `${o} week${o === 1 ? "" : "s"} ago`;
|
|
5709
|
+
let s = Math.round(a / 30);
|
|
5710
|
+
if (s < 12) return `${s} month${s === 1 ? "" : "s"} ago`;
|
|
5711
|
+
let c = Math.round(a / 365);
|
|
5712
|
+
return `${c} year${c === 1 ? "" : "s"} ago`;
|
|
5713
|
+
}
|
|
5714
|
+
//#endregion
|
|
5561
5715
|
//#region src/components/ChatConversation/RecentHistoryChips.tsx
|
|
5562
|
-
|
|
5563
|
-
|
|
5564
|
-
|
|
5716
|
+
var Si = (e) => new Date(e.lastMessageAt || e.createdAt).getTime();
|
|
5717
|
+
function Ci() {
|
|
5718
|
+
let { chats: e, loading: t } = pi(), n = [...e].sort((e, t) => Si(t) - Si(e)).slice(0, 5);
|
|
5719
|
+
if (t || n.length === 0) return null;
|
|
5720
|
+
let r = xi(n[0].lastMessageAt || n[0].createdAt);
|
|
5721
|
+
return /* @__PURE__ */ G("div", {
|
|
5565
5722
|
className: "flex flex-row items-center justify-center gap-2 flex-wrap",
|
|
5566
|
-
children: [
|
|
5567
|
-
|
|
5568
|
-
|
|
5569
|
-
|
|
5570
|
-
|
|
5571
|
-
|
|
5723
|
+
children: [
|
|
5724
|
+
/* @__PURE__ */ W(bi, { showLabel: !0 }),
|
|
5725
|
+
n.map((e) => /* @__PURE__ */ W(St, {
|
|
5726
|
+
href: `/c/${e.id}`,
|
|
5727
|
+
className: "px-3 py-1 rounded-full text-xs text-muted-foreground bg-secondary hover:bg-secondary/80 hover:text-foreground transition-colors duration-150 truncate max-w-[160px]",
|
|
5728
|
+
title: e.title,
|
|
5729
|
+
children: e.title
|
|
5730
|
+
}, e.id)),
|
|
5731
|
+
r && /* @__PURE__ */ W("span", {
|
|
5732
|
+
className: "text-xs text-muted-foreground/70 whitespace-nowrap",
|
|
5733
|
+
children: r
|
|
5734
|
+
})
|
|
5735
|
+
]
|
|
5572
5736
|
});
|
|
5573
5737
|
}
|
|
5574
5738
|
//#endregion
|
|
5575
5739
|
//#region src/components/Footer.tsx
|
|
5576
|
-
function
|
|
5740
|
+
function wi({ listFooterLinks: e = [], optionShowIcons: t = !0, optionBackgroundColor: n = "bg-black/40" }) {
|
|
5577
5741
|
let [r, i] = p(!1), a = f(null);
|
|
5578
5742
|
u(() => {
|
|
5579
5743
|
if (!r) return;
|
|
@@ -5600,7 +5764,7 @@ function _i({ listFooterLinks: e = [], optionShowIcons: t = !0, optionBackground
|
|
|
5600
5764
|
...o,
|
|
5601
5765
|
className: "relative group inline-flex items-center gap-1 hover:text-white hover:drop-shadow-[0_0_8px_rgba(255,255,255,0.8)] transition-all duration-300 whitespace-nowrap",
|
|
5602
5766
|
children: s
|
|
5603
|
-
}, e) : /* @__PURE__ */ W(
|
|
5767
|
+
}, e) : /* @__PURE__ */ W(St, {
|
|
5604
5768
|
href: e,
|
|
5605
5769
|
className: "relative group inline-flex items-center gap-1 hover:text-white hover:drop-shadow-[0_0_8px_rgba(255,255,255,0.8)] transition-all duration-300 whitespace-nowrap",
|
|
5606
5770
|
children: s
|
|
@@ -5630,19 +5794,19 @@ function _i({ listFooterLinks: e = [], optionShowIcons: t = !0, optionBackground
|
|
|
5630
5794
|
}
|
|
5631
5795
|
//#endregion
|
|
5632
5796
|
//#region src/components/ChatConversation/background-art.ts
|
|
5633
|
-
function
|
|
5797
|
+
function Ti() {
|
|
5634
5798
|
let e = /* @__PURE__ */ "hyZbH3n.mp4,iOeZcCk.mp4,dUZlxYE.mp4,GpWeP6E.gif,LuKUsLE.png,w7X11Dd.png,MHmVtCr.png,HmnUAee.png,vKP22VU.png,l1lsV39.png,Ku8F2qc.png,KUEXtwm.png,vvKFPmY.png,5p8eaEf.png,VAKuJcG.png,sTMPtQW.png,m0gHbZZ.png,cKu7dWQ.png,ogfefYD.png,ey5vAae.png,twuLrvk.png,ELILiYt.png,9el5qpP.png,Up6xTkk.png,W1XKBo0.png,1Y6xvW0.png,JXOytMz.png,DNiI6pp.png,XDv5s6p.jpeg,eRwiRJ9.jpeg,DRAfJoc.jpeg,ASVRQ1G.jpeg,35svwUT.jpeg,81xLiVI.jpeg,6kod2Em.jpeg,eU0C8zt.jpeg,Bv0PBY8.jpeg,DQNbjIZ.jpeg,2uACPqZ.jpeg,XEKltMF.jpeg,WHgLfBm.jpeg,QFYM0Fw.jpeg,K12HCao.jpeg,oN8rtsE.jpeg,9fGnrns.jpeg,2ONJJeW.jpeg,DO23Va7.jpeg,QaKeoXk.jpeg,QU5oCBR.jpeg,MhlYZmh.jpeg,ylL1ToB.jpeg,AWWsCv8.jpeg,Tk9Tzzj.jpeg".split(",");
|
|
5635
5799
|
return "https://i.imgur.com/" + e[Math.floor(Math.random() * e.length)];
|
|
5636
5800
|
}
|
|
5637
5801
|
//#endregion
|
|
5638
5802
|
//#region src/components/ChatConversation/ChatHomepage.tsx
|
|
5639
|
-
function
|
|
5640
|
-
let { sendMessage: e } =
|
|
5803
|
+
function Ei() {
|
|
5804
|
+
let { sendMessage: e } = Cn(), [n, r] = p(null), [i, a] = p(null), [o, s] = p(!1), [c, l] = p({ os: "" });
|
|
5641
5805
|
u(() => {
|
|
5642
5806
|
if (localStorage.getItem("showBackgroundArt") === "false") return;
|
|
5643
|
-
r(
|
|
5807
|
+
r(Ti());
|
|
5644
5808
|
let e = setInterval(() => {
|
|
5645
|
-
let e =
|
|
5809
|
+
let e = Ti();
|
|
5646
5810
|
a(e), s(!0), setTimeout(() => {
|
|
5647
5811
|
r(e), s(!1), a(null);
|
|
5648
5812
|
}, 1e3);
|
|
@@ -5674,7 +5838,7 @@ function yi() {
|
|
|
5674
5838
|
children: [
|
|
5675
5839
|
n && f(n, o ? "opacity-0" : "opacity-30"),
|
|
5676
5840
|
i && f(i, o ? "opacity-30" : "opacity-0"),
|
|
5677
|
-
/* @__PURE__ */ W(
|
|
5841
|
+
/* @__PURE__ */ W(ci, {})
|
|
5678
5842
|
]
|
|
5679
5843
|
}),
|
|
5680
5844
|
/* @__PURE__ */ W("div", {
|
|
@@ -5690,7 +5854,7 @@ function yi() {
|
|
|
5690
5854
|
alignItems: "center",
|
|
5691
5855
|
justifyContent: "center"
|
|
5692
5856
|
},
|
|
5693
|
-
children: /* @__PURE__ */ W(
|
|
5857
|
+
children: /* @__PURE__ */ W(yt, {
|
|
5694
5858
|
autoRandomize: !0,
|
|
5695
5859
|
onSphereClick: () => console.log("Sphere clicked"),
|
|
5696
5860
|
className: "my-custom-class"
|
|
@@ -5712,18 +5876,18 @@ function yi() {
|
|
|
5712
5876
|
}),
|
|
5713
5877
|
/* @__PURE__ */ G("div", {
|
|
5714
5878
|
className: "w-full max-w-2xl mt-8 space-y-2",
|
|
5715
|
-
children: [/* @__PURE__ */ W(
|
|
5879
|
+
children: [/* @__PURE__ */ W(Ci, {}), /* @__PURE__ */ W(jr, {})]
|
|
5716
5880
|
})
|
|
5717
5881
|
]
|
|
5718
5882
|
})
|
|
5719
5883
|
}),
|
|
5720
|
-
/* @__PURE__ */ W(
|
|
5884
|
+
/* @__PURE__ */ W(wi, { listFooterLinks: t.footerLinks })
|
|
5721
5885
|
]
|
|
5722
5886
|
});
|
|
5723
5887
|
}
|
|
5724
5888
|
//#endregion
|
|
5725
5889
|
//#region src/ui/Loader.tsx
|
|
5726
|
-
var
|
|
5890
|
+
var Di = () => /* @__PURE__ */ G("svg", {
|
|
5727
5891
|
"aria-hidden": "true",
|
|
5728
5892
|
className: "w-8 h-8 text-border fill-secondary animate-spin",
|
|
5729
5893
|
viewBox: "0 0 100 101",
|
|
@@ -5739,7 +5903,7 @@ var bi = () => /* @__PURE__ */ G("svg", {
|
|
|
5739
5903
|
});
|
|
5740
5904
|
//#endregion
|
|
5741
5905
|
//#region src/components/ConfigError.tsx
|
|
5742
|
-
function
|
|
5906
|
+
function Oi() {
|
|
5743
5907
|
return /* @__PURE__ */ W("div", {
|
|
5744
5908
|
className: "flex min-h-screen flex-col items-center justify-center p-8",
|
|
5745
5909
|
children: /* @__PURE__ */ G("div", {
|
|
@@ -5857,8 +6021,8 @@ function xi() {
|
|
|
5857
6021
|
}
|
|
5858
6022
|
//#endregion
|
|
5859
6023
|
//#region src/components/ChatConversation/ChatWindow.tsx
|
|
5860
|
-
var
|
|
5861
|
-
let e = h(), { hasError: t, isReady: n, notFound: r, messages: i } =
|
|
6024
|
+
var ki = () => {
|
|
6025
|
+
let e = h(), { hasError: t, isReady: n, notFound: r, messages: i } = Cn(), { isAuthenticated: a } = Dn();
|
|
5862
6026
|
return u(() => {
|
|
5863
6027
|
n && r && !a && e.replace("/");
|
|
5864
6028
|
}, [
|
|
@@ -5866,9 +6030,9 @@ var Si = () => {
|
|
|
5866
6030
|
r,
|
|
5867
6031
|
a,
|
|
5868
6032
|
e
|
|
5869
|
-
]), t ? /* @__PURE__ */ W(
|
|
6033
|
+
]), t ? /* @__PURE__ */ W(Oi, {}) : n && r && !a ? /* @__PURE__ */ W("div", {
|
|
5870
6034
|
className: "flex flex-row items-center justify-center min-h-screen",
|
|
5871
|
-
children: /* @__PURE__ */ W(
|
|
6035
|
+
children: /* @__PURE__ */ W(Di, {})
|
|
5872
6036
|
}) : n ? r ? /* @__PURE__ */ G("div", {
|
|
5873
6037
|
className: "flex min-h-screen flex-col items-center justify-center gap-3 px-4 text-center",
|
|
5874
6038
|
children: [/* @__PURE__ */ W("p", {
|
|
@@ -5880,14 +6044,14 @@ var Si = () => {
|
|
|
5880
6044
|
className: "rounded-md border border-black/15 px-3 py-1.5 text-sm hover:bg-black/5 dark:border-white/20 dark:hover:bg-white/10",
|
|
5881
6045
|
children: "Go Home"
|
|
5882
6046
|
})]
|
|
5883
|
-
}) : /* @__PURE__ */ W("div", { children: i.length > 0 ? /* @__PURE__ */ W(U, { children: /* @__PURE__ */ W(
|
|
6047
|
+
}) : /* @__PURE__ */ W("div", { children: i.length > 0 ? /* @__PURE__ */ W(U, { children: /* @__PURE__ */ W(si, {}) }) : /* @__PURE__ */ W(Ei, {}) }) : /* @__PURE__ */ W("div", {
|
|
5884
6048
|
className: "flex flex-row items-center justify-center min-h-screen",
|
|
5885
|
-
children: /* @__PURE__ */ W(
|
|
6049
|
+
children: /* @__PURE__ */ W(Di, {})
|
|
5886
6050
|
});
|
|
5887
6051
|
};
|
|
5888
6052
|
//#endregion
|
|
5889
6053
|
//#region src/hooks/voice/useKokoroTTS.ts
|
|
5890
|
-
function
|
|
6054
|
+
function Ai(e, t) {
|
|
5891
6055
|
let [n, r] = p("idle"), [i, a] = p(!1), [o, s] = p([]), [l, d] = p("af_heart"), [m, h] = p(null), g = f(null), _ = f(null);
|
|
5892
6056
|
u(() => {
|
|
5893
6057
|
t?.autoPreload && !i && y();
|
|
@@ -5901,8 +6065,8 @@ function Ci(e, t) {
|
|
|
5901
6065
|
g.current &&= (g.current.pause(), g.current.src.startsWith("blob:") && URL.revokeObjectURL(g.current.src), null), _.current?.abort(), _.current = null;
|
|
5902
6066
|
}, []), y = c(async () => {
|
|
5903
6067
|
try {
|
|
5904
|
-
r("loading"), h(null), await
|
|
5905
|
-
let e = await
|
|
6068
|
+
r("loading"), h(null), await Zt();
|
|
6069
|
+
let e = await $t();
|
|
5906
6070
|
s(e), e.length && !e.includes(l) && d(e[0]), a(!0), r("idle");
|
|
5907
6071
|
} catch (e) {
|
|
5908
6072
|
let t = e instanceof Error ? e.message : "Failed to load model";
|
|
@@ -5926,7 +6090,7 @@ function Ci(e, t) {
|
|
|
5926
6090
|
v(), r("generating"), h(null);
|
|
5927
6091
|
let t = new AbortController();
|
|
5928
6092
|
_.current = t;
|
|
5929
|
-
let n = (await (await
|
|
6093
|
+
let n = (await (await Qt()).generate(e.slice(0, 5e3), { voice: l })).toWav(), i = new Blob([n], { type: "audio/wav" }), a = URL.createObjectURL(i), o = new Audio(a);
|
|
5930
6094
|
g.current = o, o.onended = () => {
|
|
5931
6095
|
r("idle"), URL.revokeObjectURL(a), g.current = null;
|
|
5932
6096
|
}, o.onerror = () => {
|
|
@@ -5951,12 +6115,12 @@ function Ci(e, t) {
|
|
|
5951
6115
|
changeVoice: c((e) => {
|
|
5952
6116
|
d(e), localStorage.setItem("kokoroVoice", e);
|
|
5953
6117
|
}, []),
|
|
5954
|
-
backend:
|
|
6118
|
+
backend: en()
|
|
5955
6119
|
};
|
|
5956
6120
|
}
|
|
5957
6121
|
//#endregion
|
|
5958
6122
|
//#region src/components/VoiceSettings/KokoroVoiceSelector.tsx
|
|
5959
|
-
var
|
|
6123
|
+
var ji = {
|
|
5960
6124
|
af_heart: "American Female - Heart",
|
|
5961
6125
|
af_bella: "American Female - Bella",
|
|
5962
6126
|
af_nicole: "American Female - Nicole",
|
|
@@ -5968,8 +6132,8 @@ var wi = {
|
|
|
5968
6132
|
bm_george: "British Male - George",
|
|
5969
6133
|
bm_thomas: "British Male - Thomas"
|
|
5970
6134
|
};
|
|
5971
|
-
function
|
|
5972
|
-
let { status: t, modelReady: n, voices: r, selectedVoice: i, error: a, warmupModel: o, changeVoice: s, backend: c } =
|
|
6135
|
+
function Mi({ preloadOnMount: e = !1 }) {
|
|
6136
|
+
let { status: t, modelReady: n, voices: r, selectedVoice: i, error: a, warmupModel: o, changeVoice: s, backend: c } = Ai("", { autoPreload: e }), [l, u] = p(!1), d = t === "loading", f = t === "error";
|
|
5973
6137
|
return /* @__PURE__ */ G("div", {
|
|
5974
6138
|
className: "flex flex-col gap-3",
|
|
5975
6139
|
children: [/* @__PURE__ */ G("div", {
|
|
@@ -6018,7 +6182,7 @@ function Ti({ preloadOnMount: e = !1 }) {
|
|
|
6018
6182
|
className: "w-full text-left px-3 py-2 rounded-md bg-white/5 dark:bg-black/5 hover:bg-white/10 dark:hover:bg-black/10 transition text-sm font-medium",
|
|
6019
6183
|
children: /* @__PURE__ */ G("div", {
|
|
6020
6184
|
className: "flex items-center gap-2",
|
|
6021
|
-
children: [/* @__PURE__ */ W(Ne, { size: 16 }),
|
|
6185
|
+
children: [/* @__PURE__ */ W(Ne, { size: 16 }), ji[i] || i]
|
|
6022
6186
|
})
|
|
6023
6187
|
}), l && /* @__PURE__ */ W("div", {
|
|
6024
6188
|
className: "grid grid-cols-2 gap-2 p-2 bg-white/5 dark:bg-black/5 rounded-md max-h-64 overflow-y-auto",
|
|
@@ -6027,7 +6191,7 @@ function Ti({ preloadOnMount: e = !1 }) {
|
|
|
6027
6191
|
s(e), u(!1);
|
|
6028
6192
|
},
|
|
6029
6193
|
className: J("p-2 text-left text-sm rounded transition duration-200", i === e ? "bg-blue-500/20 text-blue-600 dark:text-blue-400 font-medium" : "bg-white/5 dark:bg-black/5 text-foreground hover:bg-white/10 dark:hover:bg-black/10"),
|
|
6030
|
-
children:
|
|
6194
|
+
children: ji[e] || e
|
|
6031
6195
|
}, e))
|
|
6032
6196
|
})]
|
|
6033
6197
|
})]
|
|
@@ -6035,8 +6199,8 @@ function Ti({ preloadOnMount: e = !1 }) {
|
|
|
6035
6199
|
}
|
|
6036
6200
|
//#endregion
|
|
6037
6201
|
//#region src/components/VoiceSettings/VoiceSettingsPanel.tsx
|
|
6038
|
-
function
|
|
6039
|
-
let [e, t] = p(!1), [n, r] = p(() => localStorage.getItem("useTTSKokoro") !== "false"), [i, a] = p(() => localStorage.getItem("ttsSpeaker") || "angus"), { start: o, speechStatus: s } =
|
|
6202
|
+
function Ni() {
|
|
6203
|
+
let [e, t] = p(!1), [n, r] = p(() => localStorage.getItem("useTTSKokoro") !== "false"), [i, a] = p(() => localStorage.getItem("ttsSpeaker") || "angus"), { start: o, speechStatus: s } = tn("This is a preview of the selected voice.", { enableInterrupt: !1 }), c = (e) => {
|
|
6040
6204
|
r(e), localStorage.setItem("useTTSKokoro", String(e));
|
|
6041
6205
|
}, l = (e) => {
|
|
6042
6206
|
a(e), localStorage.setItem("ttsSpeaker", e);
|
|
@@ -6086,7 +6250,7 @@ function Ei() {
|
|
|
6086
6250
|
children: "Runs locally in your browser. No server requests, lower latency, and multiple voice options."
|
|
6087
6251
|
})] })
|
|
6088
6252
|
]
|
|
6089
|
-
}), n && /* @__PURE__ */ W(
|
|
6253
|
+
}), n && /* @__PURE__ */ W(Mi, { preloadOnMount: !1 })]
|
|
6090
6254
|
}),
|
|
6091
6255
|
/* @__PURE__ */ G("div", {
|
|
6092
6256
|
className: "space-y-2",
|
|
@@ -6156,4 +6320,4 @@ function Ei() {
|
|
|
6156
6320
|
});
|
|
6157
6321
|
}
|
|
6158
6322
|
//#endregion
|
|
6159
|
-
export {
|
|
6323
|
+
export { qr as ArticleAIResponse, Wr as ArticleActionButtons, Yr as ArticleContent, Kr as ArticleFollowupQuestions, Br as ArticlePanelHeader, Gr as ArticlePromptInput, On as ChatProvider, ki as ChatWindow, kt as ExtractPanelProvider, _i as HistoryDialogs, bi as HistoryDropdown, Mi as KokoroVoiceSelector, Jr as LexicalArticleViewer, En as SessionProvider, ai as UnifiedMarkdown, Ni as VoiceSettingsPanel, J as cn, e as configureResearchAgentUI, wt as formatMessageTime, Tt as formatTimeDifference, t as researchAgentUIConfig, Cn as useChat, xn as useChatState, Ot as useExtractPanel, pi as useHistoryState, Ai as useKokoroTTS, Dn as useSession, tn as useTextToSpeech };
|