hermium 0.2.0 → 0.3.1
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/bin/hermium.mjs +103 -58
- package/dist/api.mjs +35 -0
- package/dist/public/assets/css/styles-o9LLzp-x.css +1 -0
- package/dist/public/assets/js/{ChatInputBlock-Bw7AL70H.js → ChatInputBlock-BgJMx5nW.js} +1 -1
- package/dist/public/assets/js/{MarkdownMessage-8d7Y6VL-.js → MarkdownMessage-Dd6VsKhk.js} +1 -1
- package/dist/public/assets/js/{base-ui-BvQbAt_1.js → base-ui-Ls-HE_Zl.js} +1 -1
- package/dist/public/assets/js/{chat._sessionId-BG6lVraH.js → chat._sessionId-Yif-J0_7.js} +1 -1
- package/dist/public/assets/js/{chat.index-D2zdMPTT.js → chat.index-QgwoSqOs.js} +1 -1
- package/dist/public/assets/js/{index-C0AK45FU.js → index-BDLsrzTe.js} +26 -26
- package/dist/public/assets/js/{index-Cx5En4FK.js → index-DRH0t4ti.js} +1 -1
- package/dist/public/assets/js/{memory-CeSRdTkW.js → memory-CHpNNtU2.js} +1 -1
- package/dist/public/assets/js/{router-8uDKazL-.js → router-B8BATVn7.js} +1 -1
- package/dist/public/assets/js/{settings-Bc3Y5zXO.js → settings-CRV3Pp8x.js} +1 -1
- package/dist/public/assets/js/{skills-DZv7sA_5.js → skills-C8G72gXr.js} +1 -1
- package/dist/public/assets/js/{usage-DXQsT9_b.js → usage-Bev8hqwh.js} +1 -1
- package/dist/server/__23tanstack-start-plugin-adapters-Cwee5PKy.mjs +6 -0
- package/dist/server/_chunks/ssr-renderer.mjs +22 -0
- package/dist/server/_libs/bail.mjs +8 -0
- package/dist/server/_libs/base-ui__react.mjs +9858 -0
- package/dist/server/_libs/base-ui__utils.mjs +1106 -0
- package/dist/server/_libs/ccount.mjs +16 -0
- package/dist/server/_libs/character-entities.mjs +2130 -0
- package/dist/server/_libs/class-variance-authority.mjs +44 -0
- package/dist/server/_libs/clsx.mjs +16 -0
- package/dist/server/_libs/comma-separated-tokens.mjs +10 -0
- package/dist/server/_libs/cookie-es.mjs +1 -0
- package/dist/server/_libs/croner.mjs +1 -0
- package/dist/server/_libs/crossws.mjs +1 -0
- package/dist/server/_libs/decode-named-character-reference+[...].mjs +8 -0
- package/dist/server/_libs/devlop.mjs +8 -0
- package/dist/server/_libs/escape-string-regexp.mjs +9 -0
- package/dist/server/_libs/estree-util-is-identifier-name.mjs +11 -0
- package/dist/server/_libs/extend.mjs +97 -0
- package/dist/server/_libs/floating-ui__core.mjs +663 -0
- package/dist/server/_libs/floating-ui__dom.mjs +624 -0
- package/dist/server/_libs/floating-ui__react-dom.mjs +279 -0
- package/dist/server/_libs/floating-ui__utils.mjs +322 -0
- package/dist/server/_libs/h3.mjs +408 -0
- package/dist/server/_libs/hast-util-is-element.mjs +75 -0
- package/dist/server/_libs/hast-util-to-jsx-runtime.mjs +388 -0
- package/dist/server/_libs/hast-util-to-text.mjs +305 -0
- package/dist/server/_libs/hast-util-whitespace.mjs +10 -0
- package/dist/server/_libs/highlight.js.mjs +14756 -0
- package/dist/server/_libs/hookable.mjs +1 -0
- package/dist/server/_libs/html-url-attributes.mjs +26 -0
- package/dist/server/_libs/inline-style-parser.mjs +142 -0
- package/dist/server/_libs/is-plain-obj.mjs +10 -0
- package/dist/server/_libs/isbot.mjs +21 -0
- package/dist/server/_libs/longest-streak.mjs +25 -0
- package/dist/server/_libs/lowlight.mjs +262 -0
- package/dist/server/_libs/markdown-table.mjs +142 -0
- package/dist/server/_libs/mdast-util-find-and-replace.mjs +109 -0
- package/dist/server/_libs/mdast-util-from-markdown.mjs +717 -0
- package/dist/server/_libs/mdast-util-gfm-autolink-literal+[...].mjs +156 -0
- package/dist/server/_libs/mdast-util-gfm-footnote.mjs +117 -0
- package/dist/server/_libs/mdast-util-gfm-strikethrough.mjs +54 -0
- package/dist/server/_libs/mdast-util-gfm-table.mjs +157 -0
- package/dist/server/_libs/mdast-util-gfm-task-list-item.mjs +77 -0
- package/dist/server/_libs/mdast-util-gfm.mjs +29 -0
- package/dist/server/_libs/mdast-util-phrasing.mjs +30 -0
- package/dist/server/_libs/mdast-util-to-hast.mjs +710 -0
- package/dist/server/_libs/mdast-util-to-markdown.mjs +798 -0
- package/dist/server/_libs/mdast-util-to-string.mjs +38 -0
- package/dist/server/_libs/micromark-core-commonmark.mjs +2259 -0
- package/dist/server/_libs/micromark-extension-gfm-autolink-literal+[...].mjs +344 -0
- package/dist/server/_libs/micromark-extension-gfm-footnote+[...].mjs +279 -0
- package/dist/server/_libs/micromark-extension-gfm-strikethrough+[...].mjs +98 -0
- package/dist/server/_libs/micromark-extension-gfm-table.mjs +491 -0
- package/dist/server/_libs/micromark-extension-gfm-tagfilter+[...].mjs +1 -0
- package/dist/server/_libs/micromark-extension-gfm-task-list-item+[...].mjs +77 -0
- package/dist/server/_libs/micromark-extension-gfm.mjs +18 -0
- package/dist/server/_libs/micromark-factory-destination.mjs +94 -0
- package/dist/server/_libs/micromark-factory-label.mjs +63 -0
- package/dist/server/_libs/micromark-factory-space.mjs +24 -0
- package/dist/server/_libs/micromark-factory-title.mjs +65 -0
- package/dist/server/_libs/micromark-factory-whitespace.mjs +22 -0
- package/dist/server/_libs/micromark-util-character.mjs +44 -0
- package/dist/server/_libs/micromark-util-chunked.mjs +36 -0
- package/dist/server/_libs/micromark-util-classify-character+[...].mjs +12 -0
- package/dist/server/_libs/micromark-util-combine-extensions+[...].mjs +41 -0
- package/dist/server/_libs/micromark-util-decode-numeric-character-reference+[...].mjs +19 -0
- package/dist/server/_libs/micromark-util-decode-string.mjs +21 -0
- package/dist/server/_libs/micromark-util-encode.mjs +1 -0
- package/dist/server/_libs/micromark-util-html-tag-name.mjs +69 -0
- package/dist/server/_libs/micromark-util-normalize-identifier+[...].mjs +6 -0
- package/dist/server/_libs/micromark-util-resolve-all.mjs +15 -0
- package/dist/server/_libs/micromark-util-sanitize-uri.mjs +41 -0
- package/dist/server/_libs/micromark-util-subtokenize.mjs +346 -0
- package/dist/server/_libs/micromark.mjs +906 -0
- package/dist/server/_libs/ocache.mjs +1 -0
- package/dist/server/_libs/ohash.mjs +1 -0
- package/dist/server/_libs/property-information.mjs +1209 -0
- package/dist/server/_libs/react-dom.mjs +10779 -0
- package/dist/server/_libs/react-markdown.mjs +147 -0
- package/dist/server/_libs/react.mjs +513 -0
- package/dist/server/_libs/rehype-highlight.mjs +94 -0
- package/dist/server/_libs/remark-gfm.mjs +20 -0
- package/dist/server/_libs/remark-parse.mjs +19 -0
- package/dist/server/_libs/remark-rehype.mjs +21 -0
- package/dist/server/_libs/reselect.mjs +1 -0
- package/dist/server/_libs/rou3.mjs +8 -0
- package/dist/server/_libs/seroval-plugins.mjs +1 -0
- package/dist/server/_libs/seroval.mjs +1 -0
- package/dist/server/_libs/space-separated-tokens.mjs +6 -0
- package/dist/server/_libs/srvx.mjs +781 -0
- package/dist/server/_libs/style-to-js.mjs +72 -0
- package/dist/server/_libs/style-to-object.mjs +38 -0
- package/dist/server/_libs/tabler__icons-react.mjs +140 -0
- package/dist/server/_libs/tailwind-merge.mjs +3255 -0
- package/dist/server/_libs/tanstack__history.mjs +29 -0
- package/dist/server/_libs/tanstack__react-router.mjs +1120 -0
- package/dist/server/_libs/tanstack__react-store.mjs +2 -0
- package/dist/server/_libs/tanstack__router-core.mjs +3594 -0
- package/dist/server/_libs/tanstack__store.mjs +1 -0
- package/dist/server/_libs/trim-lines.mjs +41 -0
- package/dist/server/_libs/trough.mjs +85 -0
- package/dist/server/_libs/ufo.mjs +54 -0
- package/dist/server/_libs/unctx.mjs +1 -0
- package/dist/server/_libs/ungap__structured-clone.mjs +224 -0
- package/dist/server/_libs/unified.mjs +661 -0
- package/dist/server/_libs/unist-util-find-after.mjs +41 -0
- package/dist/server/_libs/unist-util-is.mjs +100 -0
- package/dist/server/_libs/unist-util-position.mjs +27 -0
- package/dist/server/_libs/unist-util-stringify-position.mjs +27 -0
- package/dist/server/_libs/unist-util-visit-parents.mjs +83 -0
- package/dist/server/_libs/unist-util-visit.mjs +24 -0
- package/dist/server/_libs/unstorage.mjs +1 -0
- package/dist/server/_libs/use-sync-external-store.mjs +139 -0
- package/dist/server/_libs/vfile-message.mjs +138 -0
- package/dist/server/_libs/vfile.mjs +467 -0
- package/dist/server/_libs/zustand.mjs +43 -0
- package/dist/server/_libs/zwitch.mjs +1 -0
- package/dist/server/_ssr/ChatInputBlock-Bu2-iop_.mjs +220 -0
- package/dist/server/_ssr/MarkdownMessage-CNS7OSKN.mjs +68 -0
- package/dist/server/_ssr/chat._sessionId-P02iSfut.mjs +477 -0
- package/dist/server/_ssr/chat.index-BYB_48NC.mjs +64 -0
- package/dist/server/_ssr/index-C1mT_2d8.mjs +4890 -0
- package/dist/server/_ssr/index-DFV9_oCk.mjs +43 -0
- package/dist/server/_ssr/memory-CW_fSOG9.mjs +257 -0
- package/dist/server/_ssr/router-CUAfx91O.mjs +2035 -0
- package/dist/server/_ssr/settings-DoXurzvn.mjs +10 -0
- package/dist/server/_ssr/skills-Cs7A5ZwO.mjs +422 -0
- package/dist/server/_ssr/theme-BK4-7E2h.mjs +42 -0
- package/dist/server/_ssr/usage-Bs2-LXGz.mjs +298 -0
- package/dist/server/_tanstack-start-manifest_v-C7Upe2TI.mjs +4 -0
- package/dist/server/index.mjs +506 -0
- package/dist/server/public/assets/css/index-Dfs9RUU9.css +1 -0
- package/dist/server/public/assets/css/styles-o9LLzp-x.css +1 -0
- package/dist/server/public/assets/js/ChatInputBlock-BgJMx5nW.js +1 -0
- package/dist/server/public/assets/js/MarkdownMessage-Dd6VsKhk.js +1 -0
- package/dist/server/public/assets/js/base-ui-Ls-HE_Zl.js +1 -0
- package/dist/server/public/assets/js/chat._sessionId-Yif-J0_7.js +1 -0
- package/dist/server/public/assets/js/chat.index-QgwoSqOs.js +1 -0
- package/dist/server/public/assets/js/index-BDLsrzTe.js +60 -0
- package/dist/server/public/assets/js/index-DRH0t4ti.js +1 -0
- package/dist/server/public/assets/js/memory-CHpNNtU2.js +3 -0
- package/dist/server/public/assets/js/router-B8BATVn7.js +1 -0
- package/dist/server/public/assets/js/settings-CRV3Pp8x.js +1 -0
- package/dist/server/public/assets/js/skills-C8G72gXr.js +1 -0
- package/dist/server/public/assets/js/theme-CPkdkpaj.js +1 -0
- package/dist/server/public/assets/js/usage-Bev8hqwh.js +1 -0
- package/dist/server/public/assets/woff2/geist-cyrillic-ext-wght-normal-DjL33-gN.woff2 +0 -0
- package/dist/server/public/assets/woff2/geist-cyrillic-wght-normal-BEAKL7Jp.woff2 +0 -0
- package/dist/server/public/assets/woff2/geist-latin-ext-wght-normal-DC-KSUi6.woff2 +0 -0
- package/dist/server/public/assets/woff2/geist-latin-wght-normal-BgDaEnEv.woff2 +0 -0
- package/dist/server/public/assets/woff2/geist-vietnamese-wght-normal-6IgcOCM7.woff2 +0 -0
- package/dist/server/public/favicon.ico +0 -0
- package/dist/server/public/logo.png +0 -0
- package/dist/server/public/manifest.json +25 -0
- package/dist/server/public/robots.txt +3 -0
- package/package.json +4 -3
- package/dist/public/assets/css/styles-B8p6jk5Z.css +0 -1
|
@@ -0,0 +1,2035 @@
|
|
|
1
|
+
import { b as createRouter, a as createRootRoute, c as createFileRoute, l as lazyRouteComponent, H as HeadContent, S as Scripts, d as useNavigate, u as useLocation, L as Link } from "../_libs/tanstack__react-router.mjs";
|
|
2
|
+
import { r as reactExports, j as jsxRuntimeExports } from "../_libs/react.mjs";
|
|
3
|
+
import { c as clsx } from "../_libs/clsx.mjs";
|
|
4
|
+
import { t as twMerge } from "../_libs/tailwind-merge.mjs";
|
|
5
|
+
import { c as cva } from "../_libs/class-variance-authority.mjs";
|
|
6
|
+
import { c as create } from "../_libs/zustand.mjs";
|
|
7
|
+
import { h as IconCirclePlus, b as IconBrain, B as IconWand, c as IconChartBar, v as IconSearch, C as IconX, w as IconSettings, y as IconSun, n as IconMoon, l as IconLayoutSidebar, g as IconChevronUp, e as IconChevronDown, r as IconPin, j as IconDots, p as IconPencil, s as IconPinnedOff, i as IconCopy, z as IconTrash } from "../_libs/tabler__icons-react.mjs";
|
|
8
|
+
import { r as TooltipProvider$1, B as Button$1, v as useRender, u as mergeProps, g as DialogRoot, e as DialogPopup, c as DialogClose, h as DialogTitle, d as DialogDescription, s as TooltipRoot, p as TooltipPortal, q as TooltipPositioner, o as TooltipPopup, T as TooltipArrow, a as CollapsibleRoot, b as CollapsibleTrigger$1, C as CollapsiblePanel, l as MenuRoot, m as MenuTrigger, j as MenuPortal, k as MenuPositioner, i as MenuPopup, M as MenuItem, f as DialogPortal, D as DialogBackdrop, t as TooltipTrigger$1 } from "../_libs/base-ui__react.mjs";
|
|
9
|
+
import "../_libs/tanstack__router-core.mjs";
|
|
10
|
+
import "../_libs/tanstack__history.mjs";
|
|
11
|
+
import "node:stream/web";
|
|
12
|
+
import "node:stream";
|
|
13
|
+
import "../_libs/react-dom.mjs";
|
|
14
|
+
import "util";
|
|
15
|
+
import "crypto";
|
|
16
|
+
import "async_hooks";
|
|
17
|
+
import "stream";
|
|
18
|
+
import "../_libs/isbot.mjs";
|
|
19
|
+
import "../_libs/base-ui__utils.mjs";
|
|
20
|
+
import "../_libs/use-sync-external-store.mjs";
|
|
21
|
+
import "../_libs/floating-ui__utils.mjs";
|
|
22
|
+
import "../_libs/floating-ui__react-dom.mjs";
|
|
23
|
+
import "../_libs/floating-ui__dom.mjs";
|
|
24
|
+
import "../_libs/floating-ui__core.mjs";
|
|
25
|
+
function cn(...inputs) {
|
|
26
|
+
return twMerge(clsx(inputs));
|
|
27
|
+
}
|
|
28
|
+
function TooltipProvider({
|
|
29
|
+
delay = 0,
|
|
30
|
+
...props
|
|
31
|
+
}) {
|
|
32
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
33
|
+
TooltipProvider$1,
|
|
34
|
+
{
|
|
35
|
+
"data-slot": "tooltip-provider",
|
|
36
|
+
delay,
|
|
37
|
+
...props
|
|
38
|
+
}
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
function Tooltip({ ...props }) {
|
|
42
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(TooltipRoot, { "data-slot": "tooltip", ...props });
|
|
43
|
+
}
|
|
44
|
+
function TooltipTrigger({ ...props }) {
|
|
45
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(TooltipTrigger$1, { "data-slot": "tooltip-trigger", ...props });
|
|
46
|
+
}
|
|
47
|
+
function TooltipContent({
|
|
48
|
+
className,
|
|
49
|
+
side = "top",
|
|
50
|
+
sideOffset = 4,
|
|
51
|
+
align = "center",
|
|
52
|
+
alignOffset = 0,
|
|
53
|
+
children,
|
|
54
|
+
...props
|
|
55
|
+
}) {
|
|
56
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(TooltipPortal, { children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
57
|
+
TooltipPositioner,
|
|
58
|
+
{
|
|
59
|
+
align,
|
|
60
|
+
alignOffset,
|
|
61
|
+
side,
|
|
62
|
+
sideOffset,
|
|
63
|
+
className: "isolate z-50",
|
|
64
|
+
children: /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
65
|
+
TooltipPopup,
|
|
66
|
+
{
|
|
67
|
+
"data-slot": "tooltip-content",
|
|
68
|
+
className: cn(
|
|
69
|
+
"z-50 inline-flex w-fit max-w-xs origin-(--transform-origin) items-center gap-1.5 rounded-md bg-foreground px-3 py-1.5 text-xs text-background has-data-[slot=kbd]:pr-1.5 data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-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 **:data-[slot=kbd]:relative **:data-[slot=kbd]:isolate **:data-[slot=kbd]:z-50 **:data-[slot=kbd]:rounded-sm data-[state=delayed-open]:animate-in data-[state=delayed-open]:fade-in-0 data-[state=delayed-open]:zoom-in-95 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",
|
|
70
|
+
className
|
|
71
|
+
),
|
|
72
|
+
...props,
|
|
73
|
+
children: [
|
|
74
|
+
children,
|
|
75
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(TooltipArrow, { className: "z-50 size-2.5 translate-y-[calc(-50%-2px)] rotate-45 rounded-[2px] bg-foreground fill-foreground data-[side=bottom]:top-1 data-[side=inline-end]:top-1/2! data-[side=inline-end]:-left-1 data-[side=inline-end]:-translate-y-1/2 data-[side=inline-start]:top-1/2! data-[side=inline-start]:-right-1 data-[side=inline-start]:-translate-y-1/2 data-[side=left]:top-1/2! data-[side=left]:-right-1 data-[side=left]:-translate-y-1/2 data-[side=right]:top-1/2! data-[side=right]:-left-1 data-[side=right]:-translate-y-1/2 data-[side=top]:-bottom-2.5" })
|
|
76
|
+
]
|
|
77
|
+
}
|
|
78
|
+
)
|
|
79
|
+
}
|
|
80
|
+
) });
|
|
81
|
+
}
|
|
82
|
+
const MOBILE_BREAKPOINT = 768;
|
|
83
|
+
function useIsMobile() {
|
|
84
|
+
const [isMobile, setIsMobile] = reactExports.useState(void 0);
|
|
85
|
+
reactExports.useEffect(() => {
|
|
86
|
+
const mql = window.matchMedia(`(max-width: ${MOBILE_BREAKPOINT - 1}px)`);
|
|
87
|
+
const onChange = () => {
|
|
88
|
+
setIsMobile(window.innerWidth < MOBILE_BREAKPOINT);
|
|
89
|
+
};
|
|
90
|
+
mql.addEventListener("change", onChange);
|
|
91
|
+
setIsMobile(window.innerWidth < MOBILE_BREAKPOINT);
|
|
92
|
+
return () => mql.removeEventListener("change", onChange);
|
|
93
|
+
}, []);
|
|
94
|
+
return !!isMobile;
|
|
95
|
+
}
|
|
96
|
+
const buttonVariants = cva(
|
|
97
|
+
"group/button inline-flex shrink-0 items-center justify-center rounded-lg border border-transparent bg-clip-padding text-sm font-medium whitespace-nowrap transition-all outline-none select-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 active:not-aria-[haspopup]:translate-y-px disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
|
98
|
+
{
|
|
99
|
+
variants: {
|
|
100
|
+
variant: {
|
|
101
|
+
default: "bg-primary text-primary-foreground [a]:hover:bg-primary/80",
|
|
102
|
+
outline: "border-border bg-background hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:border-input dark:bg-input/30 dark:hover:bg-input/50",
|
|
103
|
+
secondary: "bg-secondary text-secondary-foreground hover:bg-secondary/80 aria-expanded:bg-secondary aria-expanded:text-secondary-foreground",
|
|
104
|
+
ghost: "hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:hover:bg-muted/50",
|
|
105
|
+
destructive: "bg-destructive/10 text-destructive hover:bg-destructive/20 focus-visible:border-destructive/40 focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:hover:bg-destructive/30 dark:focus-visible:ring-destructive/40",
|
|
106
|
+
link: "text-primary underline-offset-4 hover:underline"
|
|
107
|
+
},
|
|
108
|
+
size: {
|
|
109
|
+
default: "h-8 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",
|
|
110
|
+
xs: "h-6 gap-1 rounded-[min(var(--radius-md),10px)] px-2 text-xs in-data-[slot=button-group]:rounded-lg has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3",
|
|
111
|
+
sm: "h-7 gap-1 rounded-[min(var(--radius-md),12px)] px-2.5 text-[0.8rem] in-data-[slot=button-group]:rounded-lg has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3.5",
|
|
112
|
+
lg: "h-9 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",
|
|
113
|
+
icon: "size-8",
|
|
114
|
+
"icon-xs": "size-6 rounded-[min(var(--radius-md),10px)] in-data-[slot=button-group]:rounded-lg [&_svg:not([class*='size-'])]:size-3",
|
|
115
|
+
"icon-sm": "size-7 rounded-[min(var(--radius-md),12px)] in-data-[slot=button-group]:rounded-lg",
|
|
116
|
+
"icon-lg": "size-9"
|
|
117
|
+
}
|
|
118
|
+
},
|
|
119
|
+
defaultVariants: {
|
|
120
|
+
variant: "default",
|
|
121
|
+
size: "default"
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
);
|
|
125
|
+
function Button({
|
|
126
|
+
className,
|
|
127
|
+
variant = "default",
|
|
128
|
+
size = "default",
|
|
129
|
+
...props
|
|
130
|
+
}) {
|
|
131
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
132
|
+
Button$1,
|
|
133
|
+
{
|
|
134
|
+
"data-slot": "button",
|
|
135
|
+
className: cn(buttonVariants({ variant, size, className })),
|
|
136
|
+
...props
|
|
137
|
+
}
|
|
138
|
+
);
|
|
139
|
+
}
|
|
140
|
+
function Sheet({ ...props }) {
|
|
141
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(DialogRoot, { "data-slot": "sheet", ...props });
|
|
142
|
+
}
|
|
143
|
+
function SheetPortal({ ...props }) {
|
|
144
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(DialogPortal, { "data-slot": "sheet-portal", ...props });
|
|
145
|
+
}
|
|
146
|
+
function SheetOverlay({ className, ...props }) {
|
|
147
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
148
|
+
DialogBackdrop,
|
|
149
|
+
{
|
|
150
|
+
"data-slot": "sheet-overlay",
|
|
151
|
+
className: cn(
|
|
152
|
+
"fixed inset-0 z-50 bg-black/10 transition-opacity duration-150 data-ending-style:opacity-0 data-starting-style:opacity-0 supports-backdrop-filter:backdrop-blur-xs",
|
|
153
|
+
className
|
|
154
|
+
),
|
|
155
|
+
...props
|
|
156
|
+
}
|
|
157
|
+
);
|
|
158
|
+
}
|
|
159
|
+
function SheetContent({
|
|
160
|
+
className,
|
|
161
|
+
children,
|
|
162
|
+
side = "right",
|
|
163
|
+
showCloseButton = true,
|
|
164
|
+
...props
|
|
165
|
+
}) {
|
|
166
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsxs(SheetPortal, { children: [
|
|
167
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(SheetOverlay, {}),
|
|
168
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
169
|
+
DialogPopup,
|
|
170
|
+
{
|
|
171
|
+
"data-slot": "sheet-content",
|
|
172
|
+
"data-side": side,
|
|
173
|
+
className: cn(
|
|
174
|
+
"fixed z-50 flex flex-col gap-4 bg-popover bg-clip-padding text-sm text-popover-foreground shadow-lg transition duration-200 ease-in-out data-ending-style:opacity-0 data-starting-style:opacity-0 data-[side=bottom]:inset-x-0 data-[side=bottom]:bottom-0 data-[side=bottom]:h-auto data-[side=bottom]:border-t data-[side=bottom]:data-ending-style:translate-y-[2.5rem] data-[side=bottom]:data-starting-style:translate-y-[2.5rem] data-[side=left]:inset-y-0 data-[side=left]:left-0 data-[side=left]:h-full data-[side=left]:w-3/4 data-[side=left]:border-r data-[side=left]:data-ending-style:translate-x-[-2.5rem] data-[side=left]:data-starting-style:translate-x-[-2.5rem] data-[side=right]:inset-y-0 data-[side=right]:right-0 data-[side=right]:h-full data-[side=right]:w-3/4 data-[side=right]:border-l data-[side=right]:data-ending-style:translate-x-[2.5rem] data-[side=right]:data-starting-style:translate-x-[2.5rem] data-[side=top]:inset-x-0 data-[side=top]:top-0 data-[side=top]:h-auto data-[side=top]:border-b data-[side=top]:data-ending-style:translate-y-[-2.5rem] data-[side=top]:data-starting-style:translate-y-[-2.5rem] data-[side=left]:sm:max-w-sm data-[side=right]:sm:max-w-sm",
|
|
175
|
+
className
|
|
176
|
+
),
|
|
177
|
+
...props,
|
|
178
|
+
children: [
|
|
179
|
+
children,
|
|
180
|
+
showCloseButton && /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
181
|
+
DialogClose,
|
|
182
|
+
{
|
|
183
|
+
"data-slot": "sheet-close",
|
|
184
|
+
render: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
185
|
+
Button,
|
|
186
|
+
{
|
|
187
|
+
variant: "ghost",
|
|
188
|
+
className: "absolute top-3 right-3",
|
|
189
|
+
size: "icon-sm"
|
|
190
|
+
}
|
|
191
|
+
),
|
|
192
|
+
children: [
|
|
193
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
194
|
+
IconX,
|
|
195
|
+
{}
|
|
196
|
+
),
|
|
197
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "sr-only", children: "Close" })
|
|
198
|
+
]
|
|
199
|
+
}
|
|
200
|
+
)
|
|
201
|
+
]
|
|
202
|
+
}
|
|
203
|
+
)
|
|
204
|
+
] });
|
|
205
|
+
}
|
|
206
|
+
function SheetHeader({ className, ...props }) {
|
|
207
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
208
|
+
"div",
|
|
209
|
+
{
|
|
210
|
+
"data-slot": "sheet-header",
|
|
211
|
+
className: cn("flex flex-col gap-0.5 p-4", className),
|
|
212
|
+
...props
|
|
213
|
+
}
|
|
214
|
+
);
|
|
215
|
+
}
|
|
216
|
+
function SheetTitle({ className, ...props }) {
|
|
217
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
218
|
+
DialogTitle,
|
|
219
|
+
{
|
|
220
|
+
"data-slot": "sheet-title",
|
|
221
|
+
className: cn(
|
|
222
|
+
"font-heading text-base font-medium text-foreground",
|
|
223
|
+
className
|
|
224
|
+
),
|
|
225
|
+
...props
|
|
226
|
+
}
|
|
227
|
+
);
|
|
228
|
+
}
|
|
229
|
+
function SheetDescription({
|
|
230
|
+
className,
|
|
231
|
+
...props
|
|
232
|
+
}) {
|
|
233
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
234
|
+
DialogDescription,
|
|
235
|
+
{
|
|
236
|
+
"data-slot": "sheet-description",
|
|
237
|
+
className: cn("text-sm text-muted-foreground", className),
|
|
238
|
+
...props
|
|
239
|
+
}
|
|
240
|
+
);
|
|
241
|
+
}
|
|
242
|
+
const SIDEBAR_COOKIE_NAME = "sidebar_state";
|
|
243
|
+
const SIDEBAR_COOKIE_MAX_AGE = 60 * 60 * 24 * 7;
|
|
244
|
+
const SIDEBAR_WIDTH = "16rem";
|
|
245
|
+
const SIDEBAR_WIDTH_MOBILE = "18rem";
|
|
246
|
+
const SIDEBAR_WIDTH_ICON = "3rem";
|
|
247
|
+
const SIDEBAR_KEYBOARD_SHORTCUT = "b";
|
|
248
|
+
const SidebarContext = reactExports.createContext(null);
|
|
249
|
+
function useSidebar() {
|
|
250
|
+
const context = reactExports.useContext(SidebarContext);
|
|
251
|
+
if (!context) {
|
|
252
|
+
throw new Error("useSidebar must be used within a SidebarProvider.");
|
|
253
|
+
}
|
|
254
|
+
return context;
|
|
255
|
+
}
|
|
256
|
+
function SidebarProvider({
|
|
257
|
+
defaultOpen = true,
|
|
258
|
+
open: openProp,
|
|
259
|
+
onOpenChange: setOpenProp,
|
|
260
|
+
className,
|
|
261
|
+
style,
|
|
262
|
+
children,
|
|
263
|
+
...props
|
|
264
|
+
}) {
|
|
265
|
+
const isMobile = useIsMobile();
|
|
266
|
+
const [openMobile, setOpenMobile] = reactExports.useState(false);
|
|
267
|
+
const [_open, _setOpen] = reactExports.useState(defaultOpen);
|
|
268
|
+
const open = openProp ?? _open;
|
|
269
|
+
const setOpen = reactExports.useCallback(
|
|
270
|
+
(value) => {
|
|
271
|
+
const openState = typeof value === "function" ? value(open) : value;
|
|
272
|
+
if (setOpenProp) {
|
|
273
|
+
setOpenProp(openState);
|
|
274
|
+
} else {
|
|
275
|
+
_setOpen(openState);
|
|
276
|
+
}
|
|
277
|
+
document.cookie = `${SIDEBAR_COOKIE_NAME}=${openState}; path=/; max-age=${SIDEBAR_COOKIE_MAX_AGE}`;
|
|
278
|
+
},
|
|
279
|
+
[setOpenProp, open]
|
|
280
|
+
);
|
|
281
|
+
const toggleSidebar = reactExports.useCallback(() => {
|
|
282
|
+
return isMobile ? setOpenMobile((open2) => !open2) : setOpen((open2) => !open2);
|
|
283
|
+
}, [isMobile, setOpen, setOpenMobile]);
|
|
284
|
+
reactExports.useEffect(() => {
|
|
285
|
+
const handleKeyDown = (event) => {
|
|
286
|
+
if (event.key === SIDEBAR_KEYBOARD_SHORTCUT && (event.metaKey || event.ctrlKey)) {
|
|
287
|
+
event.preventDefault();
|
|
288
|
+
toggleSidebar();
|
|
289
|
+
}
|
|
290
|
+
};
|
|
291
|
+
window.addEventListener("keydown", handleKeyDown);
|
|
292
|
+
return () => window.removeEventListener("keydown", handleKeyDown);
|
|
293
|
+
}, [toggleSidebar]);
|
|
294
|
+
const state = open ? "expanded" : "collapsed";
|
|
295
|
+
const contextValue = reactExports.useMemo(
|
|
296
|
+
() => ({
|
|
297
|
+
state,
|
|
298
|
+
open,
|
|
299
|
+
setOpen,
|
|
300
|
+
isMobile,
|
|
301
|
+
openMobile,
|
|
302
|
+
setOpenMobile,
|
|
303
|
+
toggleSidebar
|
|
304
|
+
}),
|
|
305
|
+
[state, open, setOpen, isMobile, openMobile, setOpenMobile, toggleSidebar]
|
|
306
|
+
);
|
|
307
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(SidebarContext.Provider, { value: contextValue, children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
308
|
+
"div",
|
|
309
|
+
{
|
|
310
|
+
"data-slot": "sidebar-wrapper",
|
|
311
|
+
style: {
|
|
312
|
+
"--sidebar-width": SIDEBAR_WIDTH,
|
|
313
|
+
"--sidebar-width-icon": SIDEBAR_WIDTH_ICON,
|
|
314
|
+
...style
|
|
315
|
+
},
|
|
316
|
+
className: cn(
|
|
317
|
+
"group/sidebar-wrapper flex min-h-svh w-full has-data-[variant=inset]:bg-sidebar",
|
|
318
|
+
className
|
|
319
|
+
),
|
|
320
|
+
...props,
|
|
321
|
+
children
|
|
322
|
+
}
|
|
323
|
+
) });
|
|
324
|
+
}
|
|
325
|
+
function Sidebar({
|
|
326
|
+
side = "left",
|
|
327
|
+
variant = "sidebar",
|
|
328
|
+
collapsible = "offcanvas",
|
|
329
|
+
className,
|
|
330
|
+
children,
|
|
331
|
+
dir,
|
|
332
|
+
...props
|
|
333
|
+
}) {
|
|
334
|
+
const { isMobile, state, openMobile, setOpenMobile } = useSidebar();
|
|
335
|
+
if (collapsible === "none") {
|
|
336
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
337
|
+
"div",
|
|
338
|
+
{
|
|
339
|
+
"data-slot": "sidebar",
|
|
340
|
+
className: cn(
|
|
341
|
+
"flex h-full w-(--sidebar-width) flex-col bg-sidebar text-sidebar-foreground",
|
|
342
|
+
className
|
|
343
|
+
),
|
|
344
|
+
...props,
|
|
345
|
+
children
|
|
346
|
+
}
|
|
347
|
+
);
|
|
348
|
+
}
|
|
349
|
+
if (isMobile) {
|
|
350
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(Sheet, { open: openMobile, onOpenChange: setOpenMobile, ...props, children: /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
351
|
+
SheetContent,
|
|
352
|
+
{
|
|
353
|
+
dir,
|
|
354
|
+
"data-sidebar": "sidebar",
|
|
355
|
+
"data-slot": "sidebar",
|
|
356
|
+
"data-mobile": "true",
|
|
357
|
+
className: "w-(--sidebar-width) bg-sidebar p-0 text-sidebar-foreground [&>button]:hidden",
|
|
358
|
+
style: {
|
|
359
|
+
"--sidebar-width": SIDEBAR_WIDTH_MOBILE
|
|
360
|
+
},
|
|
361
|
+
side,
|
|
362
|
+
children: [
|
|
363
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs(SheetHeader, { className: "sr-only", children: [
|
|
364
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(SheetTitle, { children: "Sidebar" }),
|
|
365
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(SheetDescription, { children: "Displays the mobile sidebar." })
|
|
366
|
+
] }),
|
|
367
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex h-full w-full flex-col", children })
|
|
368
|
+
]
|
|
369
|
+
}
|
|
370
|
+
) });
|
|
371
|
+
}
|
|
372
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
373
|
+
"div",
|
|
374
|
+
{
|
|
375
|
+
className: "group peer hidden text-sidebar-foreground md:block",
|
|
376
|
+
"data-state": state,
|
|
377
|
+
"data-collapsible": state === "collapsed" ? collapsible : "",
|
|
378
|
+
"data-variant": variant,
|
|
379
|
+
"data-side": side,
|
|
380
|
+
"data-slot": "sidebar",
|
|
381
|
+
children: [
|
|
382
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
383
|
+
"div",
|
|
384
|
+
{
|
|
385
|
+
"data-slot": "sidebar-gap",
|
|
386
|
+
className: cn(
|
|
387
|
+
"relative w-(--sidebar-width) bg-transparent transition-[width] duration-200 ease-linear",
|
|
388
|
+
"group-data-[collapsible=offcanvas]:w-0",
|
|
389
|
+
"group-data-[side=right]:rotate-180",
|
|
390
|
+
variant === "floating" || variant === "inset" ? "group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4)))]" : "group-data-[collapsible=icon]:w-(--sidebar-width-icon)"
|
|
391
|
+
)
|
|
392
|
+
}
|
|
393
|
+
),
|
|
394
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
395
|
+
"div",
|
|
396
|
+
{
|
|
397
|
+
"data-slot": "sidebar-container",
|
|
398
|
+
"data-side": side,
|
|
399
|
+
className: cn(
|
|
400
|
+
"fixed inset-y-0 z-10 hidden h-svh w-(--sidebar-width) transition-[left,right,width] duration-200 ease-linear data-[side=left]:left-0 data-[side=left]:group-data-[collapsible=offcanvas]:left-[calc(var(--sidebar-width)*-1)] data-[side=right]:right-0 data-[side=right]:group-data-[collapsible=offcanvas]:right-[calc(var(--sidebar-width)*-1)] md:flex",
|
|
401
|
+
// Adjust the padding for floating and inset variants.
|
|
402
|
+
variant === "floating" || variant === "inset" ? "p-2 group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4))+2px)]" : "group-data-[collapsible=icon]:w-(--sidebar-width-icon) group-data-[side=left]:border-r group-data-[side=right]:border-l",
|
|
403
|
+
className
|
|
404
|
+
),
|
|
405
|
+
...props,
|
|
406
|
+
children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
407
|
+
"div",
|
|
408
|
+
{
|
|
409
|
+
"data-sidebar": "sidebar",
|
|
410
|
+
"data-slot": "sidebar-inner",
|
|
411
|
+
className: "flex size-full flex-col bg-sidebar group-data-[variant=floating]:rounded-lg group-data-[variant=floating]:shadow-sm group-data-[variant=floating]:ring-1 group-data-[variant=floating]:ring-sidebar-border",
|
|
412
|
+
children
|
|
413
|
+
}
|
|
414
|
+
)
|
|
415
|
+
}
|
|
416
|
+
)
|
|
417
|
+
]
|
|
418
|
+
}
|
|
419
|
+
);
|
|
420
|
+
}
|
|
421
|
+
function SidebarTrigger({
|
|
422
|
+
className,
|
|
423
|
+
onClick,
|
|
424
|
+
...props
|
|
425
|
+
}) {
|
|
426
|
+
const { toggleSidebar } = useSidebar();
|
|
427
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
428
|
+
Button,
|
|
429
|
+
{
|
|
430
|
+
"data-sidebar": "trigger",
|
|
431
|
+
"data-slot": "sidebar-trigger",
|
|
432
|
+
variant: "ghost",
|
|
433
|
+
size: "icon-sm",
|
|
434
|
+
className: cn(className),
|
|
435
|
+
onClick: (event) => {
|
|
436
|
+
onClick?.(event);
|
|
437
|
+
toggleSidebar();
|
|
438
|
+
},
|
|
439
|
+
...props,
|
|
440
|
+
children: [
|
|
441
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(IconLayoutSidebar, {}),
|
|
442
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "sr-only", children: "Toggle Sidebar" })
|
|
443
|
+
]
|
|
444
|
+
}
|
|
445
|
+
);
|
|
446
|
+
}
|
|
447
|
+
function SidebarInset({ className, ...props }) {
|
|
448
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
449
|
+
"main",
|
|
450
|
+
{
|
|
451
|
+
"data-slot": "sidebar-inset",
|
|
452
|
+
className: cn(
|
|
453
|
+
"relative flex w-full flex-1 flex-col bg-background md:peer-data-[variant=inset]:m-2 md:peer-data-[variant=inset]:ml-0 md:peer-data-[variant=inset]:rounded-xl md:peer-data-[variant=inset]:shadow-sm md:peer-data-[variant=inset]:peer-data-[state=collapsed]:ml-2",
|
|
454
|
+
className
|
|
455
|
+
),
|
|
456
|
+
...props
|
|
457
|
+
}
|
|
458
|
+
);
|
|
459
|
+
}
|
|
460
|
+
function SidebarHeader({ className, ...props }) {
|
|
461
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
462
|
+
"div",
|
|
463
|
+
{
|
|
464
|
+
"data-slot": "sidebar-header",
|
|
465
|
+
"data-sidebar": "header",
|
|
466
|
+
className: cn("flex flex-col gap-2 p-2", className),
|
|
467
|
+
...props
|
|
468
|
+
}
|
|
469
|
+
);
|
|
470
|
+
}
|
|
471
|
+
function SidebarContent({ className, ...props }) {
|
|
472
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
473
|
+
"div",
|
|
474
|
+
{
|
|
475
|
+
"data-slot": "sidebar-content",
|
|
476
|
+
"data-sidebar": "content",
|
|
477
|
+
className: cn(
|
|
478
|
+
"no-scrollbar flex min-h-0 flex-1 flex-col gap-0 overflow-auto group-data-[collapsible=icon]:overflow-hidden",
|
|
479
|
+
className
|
|
480
|
+
),
|
|
481
|
+
...props
|
|
482
|
+
}
|
|
483
|
+
);
|
|
484
|
+
}
|
|
485
|
+
function SidebarGroup({ className, ...props }) {
|
|
486
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
487
|
+
"div",
|
|
488
|
+
{
|
|
489
|
+
"data-slot": "sidebar-group",
|
|
490
|
+
"data-sidebar": "group",
|
|
491
|
+
className: cn("relative flex w-full min-w-0 flex-col p-2", className),
|
|
492
|
+
...props
|
|
493
|
+
}
|
|
494
|
+
);
|
|
495
|
+
}
|
|
496
|
+
function SidebarGroupLabel({
|
|
497
|
+
className,
|
|
498
|
+
render,
|
|
499
|
+
...props
|
|
500
|
+
}) {
|
|
501
|
+
return useRender({
|
|
502
|
+
defaultTagName: "div",
|
|
503
|
+
props: mergeProps(
|
|
504
|
+
{
|
|
505
|
+
className: cn(
|
|
506
|
+
"flex h-8 shrink-0 items-center rounded-md px-2 text-xs font-medium text-sidebar-foreground/70 ring-sidebar-ring outline-hidden transition-[margin,opacity] duration-200 ease-linear group-data-[collapsible=icon]:-mt-8 group-data-[collapsible=icon]:opacity-0 focus-visible:ring-2 [&>svg]:size-4 [&>svg]:shrink-0",
|
|
507
|
+
className
|
|
508
|
+
)
|
|
509
|
+
},
|
|
510
|
+
props
|
|
511
|
+
),
|
|
512
|
+
render,
|
|
513
|
+
state: {
|
|
514
|
+
slot: "sidebar-group-label",
|
|
515
|
+
sidebar: "group-label"
|
|
516
|
+
}
|
|
517
|
+
});
|
|
518
|
+
}
|
|
519
|
+
function SidebarMenu({ className, ...props }) {
|
|
520
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
521
|
+
"ul",
|
|
522
|
+
{
|
|
523
|
+
"data-slot": "sidebar-menu",
|
|
524
|
+
"data-sidebar": "menu",
|
|
525
|
+
className: cn("flex w-full min-w-0 flex-col gap-0", className),
|
|
526
|
+
...props
|
|
527
|
+
}
|
|
528
|
+
);
|
|
529
|
+
}
|
|
530
|
+
function SidebarMenuItem({ className, ...props }) {
|
|
531
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
532
|
+
"li",
|
|
533
|
+
{
|
|
534
|
+
"data-slot": "sidebar-menu-item",
|
|
535
|
+
"data-sidebar": "menu-item",
|
|
536
|
+
className: cn("group/menu-item relative", className),
|
|
537
|
+
...props
|
|
538
|
+
}
|
|
539
|
+
);
|
|
540
|
+
}
|
|
541
|
+
const sidebarMenuButtonVariants = cva(
|
|
542
|
+
"peer/menu-button group/menu-button flex w-full items-center gap-2 overflow-hidden rounded-md p-2 text-left text-sm ring-sidebar-ring outline-hidden transition-[width,height,padding] group-has-data-[sidebar=menu-action]/menu-item:pr-8 group-data-[collapsible=icon]:size-8! group-data-[collapsible=icon]:p-2! hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-open:hover:bg-sidebar-accent data-open:hover:text-sidebar-accent-foreground data-active:bg-sidebar-accent data-active:font-medium data-active:text-sidebar-accent-foreground [&_svg]:size-4 [&_svg]:shrink-0 [&>span:last-child]:truncate",
|
|
543
|
+
{
|
|
544
|
+
variants: {
|
|
545
|
+
variant: {
|
|
546
|
+
default: "hover:bg-sidebar-accent hover:text-sidebar-accent-foreground",
|
|
547
|
+
outline: "bg-background shadow-[0_0_0_1px_var(--sidebar-border)] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground hover:shadow-[0_0_0_1px_var(--sidebar-accent)]"
|
|
548
|
+
},
|
|
549
|
+
size: {
|
|
550
|
+
default: "h-8 text-sm",
|
|
551
|
+
sm: "h-7 text-xs",
|
|
552
|
+
lg: "h-12 text-sm group-data-[collapsible=icon]:p-0!"
|
|
553
|
+
}
|
|
554
|
+
},
|
|
555
|
+
defaultVariants: {
|
|
556
|
+
variant: "default",
|
|
557
|
+
size: "default"
|
|
558
|
+
}
|
|
559
|
+
}
|
|
560
|
+
);
|
|
561
|
+
function SidebarMenuButton({
|
|
562
|
+
render,
|
|
563
|
+
isActive = false,
|
|
564
|
+
variant = "default",
|
|
565
|
+
size = "default",
|
|
566
|
+
tooltip,
|
|
567
|
+
className,
|
|
568
|
+
...props
|
|
569
|
+
}) {
|
|
570
|
+
const { isMobile, state } = useSidebar();
|
|
571
|
+
const comp = useRender({
|
|
572
|
+
defaultTagName: "button",
|
|
573
|
+
props: mergeProps(
|
|
574
|
+
{
|
|
575
|
+
className: cn(sidebarMenuButtonVariants({ variant, size }), className)
|
|
576
|
+
},
|
|
577
|
+
props
|
|
578
|
+
),
|
|
579
|
+
render: !tooltip ? render : /* @__PURE__ */ jsxRuntimeExports.jsx(TooltipTrigger, { render }),
|
|
580
|
+
state: {
|
|
581
|
+
slot: "sidebar-menu-button",
|
|
582
|
+
sidebar: "menu-button",
|
|
583
|
+
size,
|
|
584
|
+
active: isActive
|
|
585
|
+
}
|
|
586
|
+
});
|
|
587
|
+
if (!tooltip) {
|
|
588
|
+
return comp;
|
|
589
|
+
}
|
|
590
|
+
if (typeof tooltip === "string") {
|
|
591
|
+
tooltip = {
|
|
592
|
+
children: tooltip
|
|
593
|
+
};
|
|
594
|
+
}
|
|
595
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsxs(Tooltip, { children: [
|
|
596
|
+
comp,
|
|
597
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
598
|
+
TooltipContent,
|
|
599
|
+
{
|
|
600
|
+
side: "right",
|
|
601
|
+
align: "center",
|
|
602
|
+
hidden: state !== "collapsed" || isMobile,
|
|
603
|
+
...tooltip
|
|
604
|
+
}
|
|
605
|
+
)
|
|
606
|
+
] });
|
|
607
|
+
}
|
|
608
|
+
function SidebarMenuSub({ className, ...props }) {
|
|
609
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
610
|
+
"ul",
|
|
611
|
+
{
|
|
612
|
+
"data-slot": "sidebar-menu-sub",
|
|
613
|
+
"data-sidebar": "menu-sub",
|
|
614
|
+
className: cn(
|
|
615
|
+
"mx-3.5 flex min-w-0 translate-x-px flex-col gap-1 border-l border-sidebar-border px-2.5 py-0.5 group-data-[collapsible=icon]:hidden",
|
|
616
|
+
className
|
|
617
|
+
),
|
|
618
|
+
...props
|
|
619
|
+
}
|
|
620
|
+
);
|
|
621
|
+
}
|
|
622
|
+
function SidebarMenuSubButton({
|
|
623
|
+
render,
|
|
624
|
+
size = "md",
|
|
625
|
+
isActive = false,
|
|
626
|
+
className,
|
|
627
|
+
...props
|
|
628
|
+
}) {
|
|
629
|
+
return useRender({
|
|
630
|
+
defaultTagName: "a",
|
|
631
|
+
props: mergeProps(
|
|
632
|
+
{
|
|
633
|
+
className: cn(
|
|
634
|
+
"flex h-7 min-w-0 -translate-x-px items-center gap-2 overflow-hidden rounded-md px-2 text-sidebar-foreground ring-sidebar-ring outline-hidden group-data-[collapsible=icon]:hidden hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-[size=md]:text-sm data-[size=sm]:text-xs data-active:bg-sidebar-accent data-active:text-sidebar-accent-foreground [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0 [&>svg]:text-sidebar-accent-foreground",
|
|
635
|
+
className
|
|
636
|
+
)
|
|
637
|
+
},
|
|
638
|
+
props
|
|
639
|
+
),
|
|
640
|
+
render,
|
|
641
|
+
state: {
|
|
642
|
+
slot: "sidebar-menu-sub-button",
|
|
643
|
+
sidebar: "menu-sub-button",
|
|
644
|
+
size,
|
|
645
|
+
active: isActive
|
|
646
|
+
}
|
|
647
|
+
});
|
|
648
|
+
}
|
|
649
|
+
function Collapsible({ ...props }) {
|
|
650
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(CollapsibleRoot, { "data-slot": "collapsible", ...props });
|
|
651
|
+
}
|
|
652
|
+
function CollapsibleTrigger({ ...props }) {
|
|
653
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(CollapsibleTrigger$1, { "data-slot": "collapsible-trigger", ...props });
|
|
654
|
+
}
|
|
655
|
+
function CollapsibleContent({ ...props }) {
|
|
656
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(CollapsiblePanel, { "data-slot": "collapsible-content", ...props });
|
|
657
|
+
}
|
|
658
|
+
function isRouteActive(pathname, link) {
|
|
659
|
+
if (pathname === link) return true;
|
|
660
|
+
if (link !== "/" && pathname.startsWith(link)) return true;
|
|
661
|
+
return false;
|
|
662
|
+
}
|
|
663
|
+
function DashboardNavigation({ routes }) {
|
|
664
|
+
const { state } = useSidebar();
|
|
665
|
+
const isCollapsed = state === "collapsed";
|
|
666
|
+
const [openCollapsible, setOpenCollapsible] = reactExports.useState(null);
|
|
667
|
+
const location = useLocation();
|
|
668
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(SidebarMenu, { children: routes.map((route) => {
|
|
669
|
+
const isOpen = !isCollapsed && openCollapsible === route.id;
|
|
670
|
+
const hasSubRoutes = !!route.subs?.length;
|
|
671
|
+
const isActive = isRouteActive(location.pathname, route.link) || route.subs?.some((sub) => isRouteActive(location.pathname, sub.link));
|
|
672
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(SidebarMenuItem, { children: hasSubRoutes ? /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
673
|
+
Collapsible,
|
|
674
|
+
{
|
|
675
|
+
open: isOpen,
|
|
676
|
+
onOpenChange: (open) => setOpenCollapsible(open ? route.id : null),
|
|
677
|
+
className: "w-full",
|
|
678
|
+
children: [
|
|
679
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
680
|
+
CollapsibleTrigger,
|
|
681
|
+
{
|
|
682
|
+
render: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
683
|
+
SidebarMenuButton,
|
|
684
|
+
{
|
|
685
|
+
className: cn(
|
|
686
|
+
"flex w-full items-center rounded-lg px-2 transition-colors",
|
|
687
|
+
isOpen || isActive ? "bg-sidebar-muted text-foreground" : "text-muted-foreground hover:bg-sidebar-muted hover:text-foreground",
|
|
688
|
+
isCollapsed && "justify-center"
|
|
689
|
+
)
|
|
690
|
+
}
|
|
691
|
+
),
|
|
692
|
+
children: [
|
|
693
|
+
route.icon,
|
|
694
|
+
!isCollapsed && /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "ml-2 flex-1 text-sm font-medium", children: route.title }),
|
|
695
|
+
!isCollapsed && hasSubRoutes && /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "ml-auto", children: isOpen ? /* @__PURE__ */ jsxRuntimeExports.jsx(IconChevronUp, { className: "size-4" }) : /* @__PURE__ */ jsxRuntimeExports.jsx(IconChevronDown, { className: "size-4" }) })
|
|
696
|
+
]
|
|
697
|
+
}
|
|
698
|
+
),
|
|
699
|
+
!isCollapsed && /* @__PURE__ */ jsxRuntimeExports.jsx(CollapsibleContent, { children: /* @__PURE__ */ jsxRuntimeExports.jsx(SidebarMenuSub, { className: "my-1 ml-3.5", children: route.subs?.map((subRoute) => {
|
|
700
|
+
const isSubActive = isRouteActive(
|
|
701
|
+
location.pathname,
|
|
702
|
+
subRoute.link
|
|
703
|
+
);
|
|
704
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
705
|
+
SidebarMenuItem,
|
|
706
|
+
{
|
|
707
|
+
className: "h-auto",
|
|
708
|
+
children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
709
|
+
SidebarMenuSubButton,
|
|
710
|
+
{
|
|
711
|
+
render: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
712
|
+
Link,
|
|
713
|
+
{
|
|
714
|
+
to: subRoute.link,
|
|
715
|
+
className: cn(
|
|
716
|
+
"flex items-center rounded-md px-4 py-1.5 text-sm font-medium",
|
|
717
|
+
isSubActive ? "bg-sidebar-muted text-foreground" : "text-muted-foreground hover:bg-sidebar-muted hover:text-foreground"
|
|
718
|
+
)
|
|
719
|
+
}
|
|
720
|
+
),
|
|
721
|
+
children: subRoute.title
|
|
722
|
+
}
|
|
723
|
+
)
|
|
724
|
+
},
|
|
725
|
+
`${route.id}-${subRoute.title}`
|
|
726
|
+
);
|
|
727
|
+
}) }) })
|
|
728
|
+
]
|
|
729
|
+
}
|
|
730
|
+
) : /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
731
|
+
SidebarMenuButton,
|
|
732
|
+
{
|
|
733
|
+
tooltip: route.title,
|
|
734
|
+
render: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
735
|
+
Link,
|
|
736
|
+
{
|
|
737
|
+
to: route.link,
|
|
738
|
+
className: cn(
|
|
739
|
+
"flex items-center rounded-lg px-2 transition-colors",
|
|
740
|
+
isActive ? "bg-sidebar-muted text-foreground" : "text-muted-foreground hover:bg-sidebar-muted hover:text-foreground",
|
|
741
|
+
isCollapsed && "justify-center"
|
|
742
|
+
)
|
|
743
|
+
}
|
|
744
|
+
),
|
|
745
|
+
children: [
|
|
746
|
+
route.icon,
|
|
747
|
+
!isCollapsed && /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "ml-2 text-sm font-medium", children: route.title })
|
|
748
|
+
]
|
|
749
|
+
}
|
|
750
|
+
) }, route.id);
|
|
751
|
+
}) });
|
|
752
|
+
}
|
|
753
|
+
function getBaseUrl$1() {
|
|
754
|
+
if (typeof window === "undefined") return "";
|
|
755
|
+
const stored = localStorage.getItem("hermium_server_url");
|
|
756
|
+
if (stored) return stored;
|
|
757
|
+
return window.location.origin;
|
|
758
|
+
}
|
|
759
|
+
function getApiKey$1() {
|
|
760
|
+
return typeof window !== "undefined" ? localStorage.getItem("hermium_api_key") || "" : "";
|
|
761
|
+
}
|
|
762
|
+
function clearApiKey() {
|
|
763
|
+
localStorage.removeItem("hermium_api_key");
|
|
764
|
+
}
|
|
765
|
+
async function request(path, options = {}) {
|
|
766
|
+
const base = getBaseUrl$1();
|
|
767
|
+
const url = `${base}${path}`;
|
|
768
|
+
const headers = {
|
|
769
|
+
"Content-Type": "application/json",
|
|
770
|
+
...options.headers
|
|
771
|
+
};
|
|
772
|
+
const apiKey = getApiKey$1();
|
|
773
|
+
if (apiKey) {
|
|
774
|
+
headers["Authorization"] = `Bearer ${apiKey}`;
|
|
775
|
+
}
|
|
776
|
+
const res = await fetch(url, { ...options, headers });
|
|
777
|
+
if (res.status === 401 && !path.startsWith("/api/hermes/v1/")) {
|
|
778
|
+
clearApiKey();
|
|
779
|
+
window.location.href = "/login";
|
|
780
|
+
throw new Error("Unauthorized");
|
|
781
|
+
}
|
|
782
|
+
if (!res.ok) {
|
|
783
|
+
const text = await res.text().catch(() => "");
|
|
784
|
+
if (text.trim().startsWith("<!DOCTYPE") || text.trim().startsWith("<html")) {
|
|
785
|
+
throw new Error(
|
|
786
|
+
`API unreachable (HTTP ${res.status}). Is the API server running on :4000?`
|
|
787
|
+
);
|
|
788
|
+
}
|
|
789
|
+
throw new Error(`API Error ${res.status}: ${text || res.statusText}`);
|
|
790
|
+
}
|
|
791
|
+
const json = await res.json();
|
|
792
|
+
const data = json && typeof json === "object" && "data" in json ? json.data : json;
|
|
793
|
+
if (json && typeof json === "object" && "error" in json && json.error) {
|
|
794
|
+
throw new Error(json.error.message);
|
|
795
|
+
}
|
|
796
|
+
return data;
|
|
797
|
+
}
|
|
798
|
+
async function fetchSessions() {
|
|
799
|
+
const res = await request("/api/hermes/sessions");
|
|
800
|
+
return res.sessions;
|
|
801
|
+
}
|
|
802
|
+
async function fetchSession(id) {
|
|
803
|
+
try {
|
|
804
|
+
const res = await request(`/api/hermes/sessions/${id}`);
|
|
805
|
+
return res;
|
|
806
|
+
} catch {
|
|
807
|
+
return null;
|
|
808
|
+
}
|
|
809
|
+
}
|
|
810
|
+
async function createSession(payload) {
|
|
811
|
+
return request("/api/hermes/sessions", {
|
|
812
|
+
method: "POST",
|
|
813
|
+
body: JSON.stringify(payload)
|
|
814
|
+
});
|
|
815
|
+
}
|
|
816
|
+
async function renameSession(id, title) {
|
|
817
|
+
await request(`/api/hermes/sessions/${id}/rename`, {
|
|
818
|
+
method: "POST",
|
|
819
|
+
body: JSON.stringify({ title })
|
|
820
|
+
});
|
|
821
|
+
}
|
|
822
|
+
async function deleteSession(id) {
|
|
823
|
+
await request(`/api/hermes/sessions/${id}`, { method: "DELETE" });
|
|
824
|
+
}
|
|
825
|
+
async function saveMessage(sessionId, message) {
|
|
826
|
+
await request(`/api/hermes/sessions/${sessionId}/messages`, {
|
|
827
|
+
method: "POST",
|
|
828
|
+
body: JSON.stringify(message)
|
|
829
|
+
});
|
|
830
|
+
}
|
|
831
|
+
async function runChat(payload) {
|
|
832
|
+
return request("/api/hermes/chat/run", {
|
|
833
|
+
method: "POST",
|
|
834
|
+
body: JSON.stringify(payload)
|
|
835
|
+
});
|
|
836
|
+
}
|
|
837
|
+
const activeSources = /* @__PURE__ */ new Map();
|
|
838
|
+
function getBaseUrl() {
|
|
839
|
+
return typeof window !== "undefined" ? localStorage.getItem("hermium_server_url") || "http://localhost:4000" : "";
|
|
840
|
+
}
|
|
841
|
+
function getApiKey() {
|
|
842
|
+
return typeof window !== "undefined" ? localStorage.getItem("hermium_api_key") || "" : "";
|
|
843
|
+
}
|
|
844
|
+
function streamChatRun(runId, handlers) {
|
|
845
|
+
const existing = activeSources.get(runId);
|
|
846
|
+
if (existing) {
|
|
847
|
+
existing.close();
|
|
848
|
+
activeSources.delete(runId);
|
|
849
|
+
}
|
|
850
|
+
const token = getApiKey();
|
|
851
|
+
let lastEventId = void 0;
|
|
852
|
+
function buildUrl() {
|
|
853
|
+
let url = `${getBaseUrl()}/api/hermes/chat/stream?run_id=${encodeURIComponent(runId)}`;
|
|
854
|
+
if (token) {
|
|
855
|
+
url += `&token=${encodeURIComponent(token)}`;
|
|
856
|
+
}
|
|
857
|
+
if (lastEventId) {
|
|
858
|
+
url += `&last_event_id=${encodeURIComponent(lastEventId)}`;
|
|
859
|
+
}
|
|
860
|
+
return url;
|
|
861
|
+
}
|
|
862
|
+
let es = null;
|
|
863
|
+
let closed = false;
|
|
864
|
+
let reconnectAttempt = 0;
|
|
865
|
+
const maxReconnectDelay = 3e4;
|
|
866
|
+
function connect() {
|
|
867
|
+
if (closed || typeof window === "undefined") return;
|
|
868
|
+
const url = buildUrl();
|
|
869
|
+
console.log(`[EventSource] Connecting to ${url}`);
|
|
870
|
+
es = new EventSource(url);
|
|
871
|
+
activeSources.set(runId, es);
|
|
872
|
+
const handleEvent = (e) => {
|
|
873
|
+
if (closed) return;
|
|
874
|
+
if (e.lastEventId) {
|
|
875
|
+
lastEventId = e.lastEventId;
|
|
876
|
+
}
|
|
877
|
+
try {
|
|
878
|
+
const parsed = JSON.parse(e.data);
|
|
879
|
+
if (parsed && typeof parsed === "object") {
|
|
880
|
+
console.log(`[EventSource] Event: ${parsed.event || e.type}`);
|
|
881
|
+
handlers.onEvent(parsed);
|
|
882
|
+
}
|
|
883
|
+
} catch {
|
|
884
|
+
}
|
|
885
|
+
};
|
|
886
|
+
const eventTypes = [
|
|
887
|
+
"run.started",
|
|
888
|
+
"run.queued",
|
|
889
|
+
"message.delta",
|
|
890
|
+
"reasoning.delta",
|
|
891
|
+
"thinking.delta",
|
|
892
|
+
"reasoning.available",
|
|
893
|
+
"tool.started",
|
|
894
|
+
"tool.completed",
|
|
895
|
+
"run.completed",
|
|
896
|
+
"run.error",
|
|
897
|
+
"error",
|
|
898
|
+
"abort.started",
|
|
899
|
+
"abort.completed",
|
|
900
|
+
"ping"
|
|
901
|
+
];
|
|
902
|
+
for (const type of eventTypes) {
|
|
903
|
+
es.addEventListener(type, handleEvent);
|
|
904
|
+
}
|
|
905
|
+
es.onmessage = handleEvent;
|
|
906
|
+
es.onerror = () => {
|
|
907
|
+
if (closed) return;
|
|
908
|
+
if (es && es.readyState === EventSource.CLOSED) {
|
|
909
|
+
console.log(`[EventSource] Closed for run ${runId}, manual reconnect scheduled`);
|
|
910
|
+
activeSources.delete(runId);
|
|
911
|
+
reconnectAttempt++;
|
|
912
|
+
const delay = Math.min(1e3 * Math.pow(2, reconnectAttempt - 1), maxReconnectDelay);
|
|
913
|
+
setTimeout(connect, delay);
|
|
914
|
+
} else {
|
|
915
|
+
console.log(`[EventSource] Transient error for run ${runId}, browser auto-reconnecting...`);
|
|
916
|
+
}
|
|
917
|
+
};
|
|
918
|
+
es.onopen = () => {
|
|
919
|
+
console.log(`[EventSource] Connected for run ${runId}`);
|
|
920
|
+
reconnectAttempt = 0;
|
|
921
|
+
};
|
|
922
|
+
}
|
|
923
|
+
connect();
|
|
924
|
+
return () => {
|
|
925
|
+
console.log(`[EventSource] Aborting / closing for run ${runId}`);
|
|
926
|
+
closed = true;
|
|
927
|
+
if (es) {
|
|
928
|
+
es.close();
|
|
929
|
+
}
|
|
930
|
+
activeSources.delete(runId);
|
|
931
|
+
handlers.onClose?.();
|
|
932
|
+
};
|
|
933
|
+
}
|
|
934
|
+
async function uploadFiles(files) {
|
|
935
|
+
const formData = new FormData();
|
|
936
|
+
for (const file of files) {
|
|
937
|
+
formData.append("file", file);
|
|
938
|
+
}
|
|
939
|
+
const res = await fetch("/api/hermes/files/upload", {
|
|
940
|
+
method: "POST",
|
|
941
|
+
body: formData
|
|
942
|
+
});
|
|
943
|
+
if (!res.ok) {
|
|
944
|
+
const body = await res.json().catch(() => ({ error: `HTTP ${res.status}` }));
|
|
945
|
+
throw new Error(body.error || `Upload failed: ${res.status}`);
|
|
946
|
+
}
|
|
947
|
+
const data = await res.json();
|
|
948
|
+
return data.files;
|
|
949
|
+
}
|
|
950
|
+
const ACTIVE_SESSION_KEY = "hermium_active_session_id";
|
|
951
|
+
const PINNED_SESSIONS_KEY = "hermium_pinned_sessions";
|
|
952
|
+
function loadPinnedSessions() {
|
|
953
|
+
try {
|
|
954
|
+
const raw = localStorage.getItem(PINNED_SESSIONS_KEY);
|
|
955
|
+
return raw ? JSON.parse(raw) : [];
|
|
956
|
+
} catch {
|
|
957
|
+
return [];
|
|
958
|
+
}
|
|
959
|
+
}
|
|
960
|
+
function savePinnedSessions(ids) {
|
|
961
|
+
localStorage.setItem(PINNED_SESSIONS_KEY, JSON.stringify(ids));
|
|
962
|
+
}
|
|
963
|
+
function uid() {
|
|
964
|
+
return Date.now().toString(36) + Math.random().toString(36).slice(2, 8);
|
|
965
|
+
}
|
|
966
|
+
const debouncedSaves = /* @__PURE__ */ new Map();
|
|
967
|
+
function debouncedSaveMessage(sessionId, message, delay = 500) {
|
|
968
|
+
const key = `${sessionId}:${message.id}`;
|
|
969
|
+
const existing = debouncedSaves.get(key);
|
|
970
|
+
if (existing) clearTimeout(existing);
|
|
971
|
+
const timeout = setTimeout(() => {
|
|
972
|
+
debouncedSaves.delete(key);
|
|
973
|
+
saveMessage(sessionId, message).catch((err) => {
|
|
974
|
+
console.error("[store] Debounced save failed:", err);
|
|
975
|
+
});
|
|
976
|
+
}, delay);
|
|
977
|
+
debouncedSaves.set(key, timeout);
|
|
978
|
+
}
|
|
979
|
+
function mergeMessages(dbMsgs, storeMsgs) {
|
|
980
|
+
const map = /* @__PURE__ */ new Map();
|
|
981
|
+
for (const m of dbMsgs) {
|
|
982
|
+
map.set(m.id, m);
|
|
983
|
+
}
|
|
984
|
+
for (const m of storeMsgs) {
|
|
985
|
+
const existing = map.get(m.id);
|
|
986
|
+
if (!existing) {
|
|
987
|
+
map.set(m.id, m);
|
|
988
|
+
continue;
|
|
989
|
+
}
|
|
990
|
+
const storeLen = (m.content?.length || 0) + (m.reasoning?.length || 0);
|
|
991
|
+
const dbLen = (existing.content?.length || 0) + (existing.reasoning?.length || 0);
|
|
992
|
+
if (storeLen > dbLen) {
|
|
993
|
+
map.set(m.id, m);
|
|
994
|
+
}
|
|
995
|
+
}
|
|
996
|
+
return Array.from(map.values()).sort((a, b) => (a.timestamp || 0) - (b.timestamp || 0));
|
|
997
|
+
}
|
|
998
|
+
const useChatStore = create((set, get) => ({
|
|
999
|
+
sessions: [],
|
|
1000
|
+
activeSessionId: null,
|
|
1001
|
+
messages: [],
|
|
1002
|
+
isStreaming: false,
|
|
1003
|
+
isLoadingSessions: false,
|
|
1004
|
+
sessionsLoaded: false,
|
|
1005
|
+
pinnedSessionIds: loadPinnedSessions(),
|
|
1006
|
+
activeStream: null,
|
|
1007
|
+
setSessions: (sessions) => set({ sessions }),
|
|
1008
|
+
setActiveSessionId: (id) => set({ activeSessionId: id }),
|
|
1009
|
+
setMessages: (messages) => set({ messages }),
|
|
1010
|
+
appendMessage: (message) => set((s) => ({ messages: [...s.messages, message] })),
|
|
1011
|
+
updateMessage: (id, patch) => set((s) => ({
|
|
1012
|
+
messages: s.messages.map((m) => m.id === id ? { ...m, ...patch } : m)
|
|
1013
|
+
})),
|
|
1014
|
+
setStreaming: (v) => set({ isStreaming: v }),
|
|
1015
|
+
async loadSessions() {
|
|
1016
|
+
set({ isLoadingSessions: true });
|
|
1017
|
+
try {
|
|
1018
|
+
const list = await fetchSessions();
|
|
1019
|
+
const localOnly = get().sessions.filter(
|
|
1020
|
+
(local) => !list.some((api) => api.id === local.id) && local.id === get().activeSessionId
|
|
1021
|
+
);
|
|
1022
|
+
const merged = [...localOnly, ...list];
|
|
1023
|
+
set({ sessions: merged, sessionsLoaded: true });
|
|
1024
|
+
const currentActive = get().activeSessionId;
|
|
1025
|
+
if (!currentActive) {
|
|
1026
|
+
const savedId = localStorage.getItem(ACTIVE_SESSION_KEY);
|
|
1027
|
+
if (savedId && merged.some((s) => s.id === savedId)) {
|
|
1028
|
+
await get().switchSession(savedId);
|
|
1029
|
+
}
|
|
1030
|
+
}
|
|
1031
|
+
} catch (err) {
|
|
1032
|
+
console.error("Failed to load sessions:", err);
|
|
1033
|
+
} finally {
|
|
1034
|
+
set({ isLoadingSessions: false });
|
|
1035
|
+
}
|
|
1036
|
+
},
|
|
1037
|
+
async switchSession(id) {
|
|
1038
|
+
const current = get();
|
|
1039
|
+
console.log(`[store] switchSession: ${id}. currentActive=${current.activeSessionId}, msgs=${current.messages.length}, streaming=${current.isStreaming}`);
|
|
1040
|
+
if (current.activeSessionId === id && current.messages.length > 0) {
|
|
1041
|
+
await get().syncFromDb(id);
|
|
1042
|
+
localStorage.setItem(ACTIVE_SESSION_KEY, id);
|
|
1043
|
+
set((s) => {
|
|
1044
|
+
const session = s.sessions.find((sess) => sess.id === id);
|
|
1045
|
+
if (session) {
|
|
1046
|
+
return {
|
|
1047
|
+
sessions: s.sessions.map(
|
|
1048
|
+
(sess) => sess.id === id ? { ...sess, lastActiveAt: Date.now() } : sess
|
|
1049
|
+
)
|
|
1050
|
+
};
|
|
1051
|
+
}
|
|
1052
|
+
return s;
|
|
1053
|
+
});
|
|
1054
|
+
return;
|
|
1055
|
+
}
|
|
1056
|
+
current.activeStream?.abort();
|
|
1057
|
+
set({ activeSessionId: id, messages: [], isStreaming: false, activeStream: null });
|
|
1058
|
+
localStorage.setItem(ACTIVE_SESSION_KEY, id);
|
|
1059
|
+
try {
|
|
1060
|
+
const data = await fetchSession(id);
|
|
1061
|
+
if (data?.messages) {
|
|
1062
|
+
set({ messages: data.messages });
|
|
1063
|
+
}
|
|
1064
|
+
} catch (err) {
|
|
1065
|
+
console.error("Failed to load session messages:", err);
|
|
1066
|
+
}
|
|
1067
|
+
set((s) => {
|
|
1068
|
+
const session = s.sessions.find((sess) => sess.id === id);
|
|
1069
|
+
if (session) {
|
|
1070
|
+
return {
|
|
1071
|
+
sessions: s.sessions.map(
|
|
1072
|
+
(sess) => sess.id === id ? { ...sess, lastActiveAt: Date.now() } : sess
|
|
1073
|
+
)
|
|
1074
|
+
};
|
|
1075
|
+
}
|
|
1076
|
+
return s;
|
|
1077
|
+
});
|
|
1078
|
+
},
|
|
1079
|
+
async syncFromDb(sessionId) {
|
|
1080
|
+
try {
|
|
1081
|
+
const data = await fetchSession(sessionId);
|
|
1082
|
+
if (!data?.messages) return;
|
|
1083
|
+
const storeMsgs = get().messages;
|
|
1084
|
+
const merged = mergeMessages(data.messages, storeMsgs);
|
|
1085
|
+
const mergedContent = merged.map((m) => m.content + (m.reasoning || "")).join("");
|
|
1086
|
+
const storeContent = storeMsgs.map((m) => m.content + (m.reasoning || "")).join("");
|
|
1087
|
+
if (mergedContent !== storeContent || merged.length !== storeMsgs.length) {
|
|
1088
|
+
console.log(`[store] syncFromDb: updating ${storeMsgs.length} → ${merged.length} messages`);
|
|
1089
|
+
set({ messages: merged });
|
|
1090
|
+
}
|
|
1091
|
+
} catch (err) {
|
|
1092
|
+
console.error("[store] syncFromDb failed:", err);
|
|
1093
|
+
}
|
|
1094
|
+
},
|
|
1095
|
+
async createNewSession() {
|
|
1096
|
+
const id = uid();
|
|
1097
|
+
try {
|
|
1098
|
+
await createSession({ id, title: "", source: "api_server" });
|
|
1099
|
+
} catch (err) {
|
|
1100
|
+
console.error("Failed to create session on server:", err);
|
|
1101
|
+
}
|
|
1102
|
+
set({ activeSessionId: id, messages: [], isStreaming: false, activeStream: null });
|
|
1103
|
+
localStorage.setItem(ACTIVE_SESSION_KEY, id);
|
|
1104
|
+
return id;
|
|
1105
|
+
},
|
|
1106
|
+
async deleteSession(id) {
|
|
1107
|
+
try {
|
|
1108
|
+
await deleteSession(id);
|
|
1109
|
+
} catch (err) {
|
|
1110
|
+
console.error("Failed to delete session:", err);
|
|
1111
|
+
}
|
|
1112
|
+
set((s) => {
|
|
1113
|
+
const nextSessions = s.sessions.filter((sess) => sess.id !== id);
|
|
1114
|
+
const nextPinned = s.pinnedSessionIds.filter((pid) => pid !== id);
|
|
1115
|
+
if (nextPinned.length !== s.pinnedSessionIds.length) {
|
|
1116
|
+
savePinnedSessions(nextPinned);
|
|
1117
|
+
}
|
|
1118
|
+
const nextActiveId = s.activeSessionId === id ? nextSessions[0]?.id ?? null : s.activeSessionId;
|
|
1119
|
+
if (s.activeSessionId === id) {
|
|
1120
|
+
s.activeStream?.abort();
|
|
1121
|
+
}
|
|
1122
|
+
if (nextActiveId !== s.activeSessionId) {
|
|
1123
|
+
setTimeout(() => {
|
|
1124
|
+
if (nextActiveId) get().switchSession(nextActiveId);
|
|
1125
|
+
else set({ activeSessionId: null, messages: [] });
|
|
1126
|
+
}, 0);
|
|
1127
|
+
}
|
|
1128
|
+
return { sessions: nextSessions, pinnedSessionIds: nextPinned, activeStream: s.activeSessionId === id ? null : s.activeStream };
|
|
1129
|
+
});
|
|
1130
|
+
},
|
|
1131
|
+
async saveAndAppendMessage(sessionId, message) {
|
|
1132
|
+
set((s) => {
|
|
1133
|
+
const nextMessages = [...s.messages, message];
|
|
1134
|
+
let nextSessions = s.sessions.map(
|
|
1135
|
+
(sess) => sess.id === sessionId ? { ...sess, messageCount: (sess.messageCount ?? 0) + 1, updatedAt: Date.now() } : sess
|
|
1136
|
+
);
|
|
1137
|
+
if (!nextSessions.some((sess) => sess.id === sessionId)) {
|
|
1138
|
+
nextSessions.unshift({
|
|
1139
|
+
id: sessionId,
|
|
1140
|
+
title: "",
|
|
1141
|
+
source: "api_server",
|
|
1142
|
+
createdAt: Date.now(),
|
|
1143
|
+
updatedAt: Date.now(),
|
|
1144
|
+
messageCount: 1
|
|
1145
|
+
});
|
|
1146
|
+
}
|
|
1147
|
+
return { messages: nextMessages, sessions: nextSessions };
|
|
1148
|
+
});
|
|
1149
|
+
try {
|
|
1150
|
+
await saveMessage(sessionId, message);
|
|
1151
|
+
} catch (err) {
|
|
1152
|
+
console.error("Failed to save message:", err);
|
|
1153
|
+
}
|
|
1154
|
+
},
|
|
1155
|
+
updateSessionTitle(sessionId) {
|
|
1156
|
+
set((s) => {
|
|
1157
|
+
const session = s.sessions.find((sess) => sess.id === sessionId);
|
|
1158
|
+
const hasRealTitle = !!session?.title && session.title !== "New Session";
|
|
1159
|
+
if (!session || hasRealTitle) return s;
|
|
1160
|
+
const firstUser = s.messages.find((m) => m.role === "user");
|
|
1161
|
+
if (!firstUser) return s;
|
|
1162
|
+
const raw = firstUser.content.trim();
|
|
1163
|
+
let title = raw;
|
|
1164
|
+
if (raw.length > 40) {
|
|
1165
|
+
const sentenceMatch = raw.slice(0, 60).match(/^[^.!?]+[.!?]/);
|
|
1166
|
+
if (sentenceMatch) {
|
|
1167
|
+
title = sentenceMatch[0].trim();
|
|
1168
|
+
} else {
|
|
1169
|
+
const slice = raw.slice(0, 40);
|
|
1170
|
+
const lastSpace = slice.lastIndexOf(" ");
|
|
1171
|
+
title = lastSpace > 20 ? slice.slice(0, lastSpace) : slice;
|
|
1172
|
+
}
|
|
1173
|
+
}
|
|
1174
|
+
title = title.replace(/[,:;\-]+$/, "").trim();
|
|
1175
|
+
if (title.length < raw.length) title += "…";
|
|
1176
|
+
title = title.charAt(0).toUpperCase() + title.slice(1);
|
|
1177
|
+
return {
|
|
1178
|
+
sessions: s.sessions.map(
|
|
1179
|
+
(sess) => sess.id === sessionId ? { ...sess, title, updatedAt: Date.now() } : sess
|
|
1180
|
+
)
|
|
1181
|
+
};
|
|
1182
|
+
});
|
|
1183
|
+
},
|
|
1184
|
+
updateSession(id, patch) {
|
|
1185
|
+
set((s) => ({
|
|
1186
|
+
sessions: s.sessions.map(
|
|
1187
|
+
(sx) => sx.id === id ? { ...sx, ...patch } : sx
|
|
1188
|
+
)
|
|
1189
|
+
}));
|
|
1190
|
+
},
|
|
1191
|
+
togglePin(sessionId) {
|
|
1192
|
+
set((s) => {
|
|
1193
|
+
const isPinned = s.pinnedSessionIds.includes(sessionId);
|
|
1194
|
+
const next = isPinned ? s.pinnedSessionIds.filter((id) => id !== sessionId) : [...s.pinnedSessionIds, sessionId];
|
|
1195
|
+
savePinnedSessions(next);
|
|
1196
|
+
return { pinnedSessionIds: next };
|
|
1197
|
+
});
|
|
1198
|
+
},
|
|
1199
|
+
// ── Stream lifecycle ──────────────────────────────────────────────────
|
|
1200
|
+
async sendMessage(text, _model, rawAttachments) {
|
|
1201
|
+
const state = get();
|
|
1202
|
+
console.log(`[store] sendMessage. isStreaming=${state.isStreaming}, sessionId=${state.activeSessionId}`);
|
|
1203
|
+
if (state.isStreaming) return;
|
|
1204
|
+
let sessionId = state.activeSessionId;
|
|
1205
|
+
if (!sessionId) {
|
|
1206
|
+
sessionId = await get().createNewSession();
|
|
1207
|
+
}
|
|
1208
|
+
if (!sessionId) return;
|
|
1209
|
+
let uploadedFiles = [];
|
|
1210
|
+
let attachments;
|
|
1211
|
+
if (rawAttachments && rawAttachments.length > 0) {
|
|
1212
|
+
const files = rawAttachments.map((a) => a.file);
|
|
1213
|
+
uploadedFiles = await uploadFiles(files);
|
|
1214
|
+
attachments = rawAttachments.map((att, i) => {
|
|
1215
|
+
const up = uploadedFiles[i];
|
|
1216
|
+
return {
|
|
1217
|
+
id: att.id,
|
|
1218
|
+
name: att.name,
|
|
1219
|
+
type: att.type,
|
|
1220
|
+
size: att.size,
|
|
1221
|
+
url: `/api/hermes/download?path=${encodeURIComponent(up.path)}&name=${encodeURIComponent(up.name)}`
|
|
1222
|
+
};
|
|
1223
|
+
});
|
|
1224
|
+
}
|
|
1225
|
+
const userMsg = {
|
|
1226
|
+
id: uid(),
|
|
1227
|
+
role: "user",
|
|
1228
|
+
content: text,
|
|
1229
|
+
timestamp: Date.now(),
|
|
1230
|
+
attachments
|
|
1231
|
+
};
|
|
1232
|
+
await get().saveAndAppendMessage(sessionId, userMsg);
|
|
1233
|
+
get().updateSessionTitle(sessionId);
|
|
1234
|
+
set({ isStreaming: true });
|
|
1235
|
+
let input;
|
|
1236
|
+
if (attachments && attachments.length > 0) {
|
|
1237
|
+
const blocks = [];
|
|
1238
|
+
if (text.trim()) {
|
|
1239
|
+
blocks.push({ type: "text", text: text.trim() });
|
|
1240
|
+
}
|
|
1241
|
+
for (let i = 0; i < uploadedFiles.length; i++) {
|
|
1242
|
+
const up = uploadedFiles[i];
|
|
1243
|
+
const att = rawAttachments[i];
|
|
1244
|
+
if (att.type.startsWith("image/")) {
|
|
1245
|
+
blocks.push({ type: "image", name: up.name, path: up.path, media_type: att.type });
|
|
1246
|
+
} else {
|
|
1247
|
+
blocks.push({ type: "file", name: up.name, path: up.path, media_type: att.type });
|
|
1248
|
+
}
|
|
1249
|
+
}
|
|
1250
|
+
input = blocks;
|
|
1251
|
+
} else {
|
|
1252
|
+
input = text.trim();
|
|
1253
|
+
}
|
|
1254
|
+
try {
|
|
1255
|
+
const { run_id } = await runChat({
|
|
1256
|
+
input,
|
|
1257
|
+
session_id: sessionId
|
|
1258
|
+
});
|
|
1259
|
+
console.log(`[store] runChat returned run_id=${run_id}`);
|
|
1260
|
+
const assistantId = uid() + "_ai";
|
|
1261
|
+
get().appendMessage({
|
|
1262
|
+
id: assistantId,
|
|
1263
|
+
role: "assistant",
|
|
1264
|
+
content: "",
|
|
1265
|
+
timestamp: Date.now(),
|
|
1266
|
+
isStreaming: true
|
|
1267
|
+
});
|
|
1268
|
+
const abort = streamChatRun(run_id, {
|
|
1269
|
+
onEvent: (event) => {
|
|
1270
|
+
if (event.event === "ping") return;
|
|
1271
|
+
if (event.event === "message.delta" && event.delta) {
|
|
1272
|
+
const s = get();
|
|
1273
|
+
const msg = s.messages.find((m) => m.id === assistantId);
|
|
1274
|
+
if (msg) {
|
|
1275
|
+
const nextContent = msg.content + event.delta;
|
|
1276
|
+
const updatedMsg = { ...msg, content: nextContent };
|
|
1277
|
+
set({
|
|
1278
|
+
messages: s.messages.map(
|
|
1279
|
+
(m) => m.id === assistantId ? updatedMsg : m
|
|
1280
|
+
)
|
|
1281
|
+
});
|
|
1282
|
+
debouncedSaveMessage(sessionId, updatedMsg, 500);
|
|
1283
|
+
}
|
|
1284
|
+
}
|
|
1285
|
+
if ((event.event === "reasoning.delta" || event.event === "thinking.delta") && event.delta) {
|
|
1286
|
+
const s = get();
|
|
1287
|
+
const msg = s.messages.find((m) => m.id === assistantId);
|
|
1288
|
+
if (msg) {
|
|
1289
|
+
const nextReasoning = (msg.reasoning || "") + event.delta;
|
|
1290
|
+
const updatedMsg = {
|
|
1291
|
+
...msg,
|
|
1292
|
+
reasoning: nextReasoning,
|
|
1293
|
+
reasoningStartedAt: msg.reasoningStartedAt || Date.now()
|
|
1294
|
+
};
|
|
1295
|
+
set({
|
|
1296
|
+
messages: s.messages.map(
|
|
1297
|
+
(m) => m.id === assistantId ? updatedMsg : m
|
|
1298
|
+
)
|
|
1299
|
+
});
|
|
1300
|
+
debouncedSaveMessage(sessionId, updatedMsg, 500);
|
|
1301
|
+
}
|
|
1302
|
+
}
|
|
1303
|
+
if (event.event === "reasoning.available") {
|
|
1304
|
+
const s = get();
|
|
1305
|
+
const msg = s.messages.find((m) => m.id === assistantId);
|
|
1306
|
+
if (msg && msg.reasoning) {
|
|
1307
|
+
const updatedMsg = { ...msg, reasoningEndedAt: Date.now() };
|
|
1308
|
+
set({
|
|
1309
|
+
messages: s.messages.map(
|
|
1310
|
+
(m) => m.id === assistantId ? updatedMsg : m
|
|
1311
|
+
)
|
|
1312
|
+
});
|
|
1313
|
+
debouncedSaveMessage(sessionId, updatedMsg, 500);
|
|
1314
|
+
}
|
|
1315
|
+
}
|
|
1316
|
+
if (event.event === "tool.started") {
|
|
1317
|
+
const toolName = event.tool || event.name || "tool";
|
|
1318
|
+
const preview = event.preview || "";
|
|
1319
|
+
const callId = event.tool_call_id || void 0;
|
|
1320
|
+
const s = get();
|
|
1321
|
+
const msg = s.messages.find((m) => m.id === assistantId);
|
|
1322
|
+
if (msg) {
|
|
1323
|
+
const calls = [
|
|
1324
|
+
...msg.toolCalls || [],
|
|
1325
|
+
{ name: toolName, preview, callId, status: "running" }
|
|
1326
|
+
];
|
|
1327
|
+
const updatedMsg = { ...msg, toolCalls: calls };
|
|
1328
|
+
set({
|
|
1329
|
+
messages: s.messages.map(
|
|
1330
|
+
(m) => m.id === assistantId ? updatedMsg : m
|
|
1331
|
+
)
|
|
1332
|
+
});
|
|
1333
|
+
debouncedSaveMessage(sessionId, updatedMsg, 500);
|
|
1334
|
+
}
|
|
1335
|
+
}
|
|
1336
|
+
if (event.event === "tool.completed") {
|
|
1337
|
+
const toolName = event.tool || event.name;
|
|
1338
|
+
const output = event.output;
|
|
1339
|
+
const callId = event.tool_call_id || void 0;
|
|
1340
|
+
const s = get();
|
|
1341
|
+
const msg = s.messages.find((m) => m.id === assistantId);
|
|
1342
|
+
if (msg && msg.toolCalls) {
|
|
1343
|
+
const calls = msg.toolCalls.map((tc) => {
|
|
1344
|
+
if (callId && tc.callId === callId) {
|
|
1345
|
+
return { ...tc, status: "done", output: output || tc.output };
|
|
1346
|
+
}
|
|
1347
|
+
if (!callId && tc.name === toolName && tc.status === "running") {
|
|
1348
|
+
return { ...tc, status: "done", output: output || tc.output };
|
|
1349
|
+
}
|
|
1350
|
+
return tc;
|
|
1351
|
+
});
|
|
1352
|
+
const updatedMsg = { ...msg, toolCalls: calls };
|
|
1353
|
+
set({
|
|
1354
|
+
messages: s.messages.map(
|
|
1355
|
+
(m) => m.id === assistantId ? updatedMsg : m
|
|
1356
|
+
)
|
|
1357
|
+
});
|
|
1358
|
+
debouncedSaveMessage(sessionId, updatedMsg, 500);
|
|
1359
|
+
}
|
|
1360
|
+
}
|
|
1361
|
+
if (event.event === "run.completed") {
|
|
1362
|
+
const s = get();
|
|
1363
|
+
const finalMsg = s.messages.find((m) => m.id === assistantId);
|
|
1364
|
+
if (finalMsg) {
|
|
1365
|
+
abort();
|
|
1366
|
+
const updatedMsg = {
|
|
1367
|
+
...finalMsg,
|
|
1368
|
+
isStreaming: false,
|
|
1369
|
+
reasoningEndedAt: finalMsg.reasoning ? Date.now() : void 0
|
|
1370
|
+
};
|
|
1371
|
+
set({
|
|
1372
|
+
messages: s.messages.map(
|
|
1373
|
+
(m) => m.id === assistantId ? updatedMsg : m
|
|
1374
|
+
),
|
|
1375
|
+
isStreaming: false,
|
|
1376
|
+
activeStream: null
|
|
1377
|
+
});
|
|
1378
|
+
const key = `${sessionId}:${assistantId}`;
|
|
1379
|
+
const existing = debouncedSaves.get(key);
|
|
1380
|
+
if (existing) clearTimeout(existing);
|
|
1381
|
+
debouncedSaves.delete(key);
|
|
1382
|
+
saveMessage(sessionId, updatedMsg).catch(console.error);
|
|
1383
|
+
}
|
|
1384
|
+
}
|
|
1385
|
+
if (event.event === "run.error") {
|
|
1386
|
+
abort();
|
|
1387
|
+
const s = get();
|
|
1388
|
+
set({
|
|
1389
|
+
messages: s.messages.map(
|
|
1390
|
+
(m) => m.id === assistantId ? {
|
|
1391
|
+
...m,
|
|
1392
|
+
role: "system",
|
|
1393
|
+
content: event.error || "Stream error",
|
|
1394
|
+
systemType: "error",
|
|
1395
|
+
isStreaming: false
|
|
1396
|
+
} : m
|
|
1397
|
+
),
|
|
1398
|
+
isStreaming: false,
|
|
1399
|
+
activeStream: null
|
|
1400
|
+
});
|
|
1401
|
+
}
|
|
1402
|
+
},
|
|
1403
|
+
onError: (err) => {
|
|
1404
|
+
set((s) => ({
|
|
1405
|
+
messages: [
|
|
1406
|
+
...s.messages,
|
|
1407
|
+
{
|
|
1408
|
+
id: uid() + "_err",
|
|
1409
|
+
role: "system",
|
|
1410
|
+
content: err.message,
|
|
1411
|
+
timestamp: Date.now(),
|
|
1412
|
+
systemType: "error"
|
|
1413
|
+
}
|
|
1414
|
+
],
|
|
1415
|
+
isStreaming: false,
|
|
1416
|
+
activeStream: null
|
|
1417
|
+
}));
|
|
1418
|
+
},
|
|
1419
|
+
onClose: () => {
|
|
1420
|
+
console.log(`[store] onClose fired. activeStream=${get().activeStream?.runId || "null"}`);
|
|
1421
|
+
set({ activeStream: null });
|
|
1422
|
+
setTimeout(() => {
|
|
1423
|
+
const s = get();
|
|
1424
|
+
if (s.isStreaming && !s.activeStream) {
|
|
1425
|
+
console.log(`[store] onClose timeout → isStreaming=false`);
|
|
1426
|
+
set({ isStreaming: false });
|
|
1427
|
+
}
|
|
1428
|
+
}, 2e3);
|
|
1429
|
+
}
|
|
1430
|
+
});
|
|
1431
|
+
set({ activeStream: { runId: run_id, abort } });
|
|
1432
|
+
} catch (err) {
|
|
1433
|
+
set((s) => ({
|
|
1434
|
+
messages: [
|
|
1435
|
+
...s.messages,
|
|
1436
|
+
{
|
|
1437
|
+
id: uid() + "_err",
|
|
1438
|
+
role: "system",
|
|
1439
|
+
content: err instanceof Error ? err.message : "Unknown error",
|
|
1440
|
+
timestamp: Date.now(),
|
|
1441
|
+
systemType: "error"
|
|
1442
|
+
}
|
|
1443
|
+
],
|
|
1444
|
+
isStreaming: false,
|
|
1445
|
+
activeStream: null
|
|
1446
|
+
}));
|
|
1447
|
+
}
|
|
1448
|
+
},
|
|
1449
|
+
abortStream() {
|
|
1450
|
+
const { activeStream } = get();
|
|
1451
|
+
console.log(`[store] abortStream. activeStream=${activeStream?.runId || "null"}`);
|
|
1452
|
+
if (activeStream) {
|
|
1453
|
+
activeStream.abort();
|
|
1454
|
+
set({ isStreaming: false, activeStream: null });
|
|
1455
|
+
}
|
|
1456
|
+
}
|
|
1457
|
+
}));
|
|
1458
|
+
function DropdownMenu({ ...props }) {
|
|
1459
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(MenuRoot, { "data-slot": "dropdown-menu", ...props });
|
|
1460
|
+
}
|
|
1461
|
+
function DropdownMenuTrigger({ ...props }) {
|
|
1462
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(MenuTrigger, { "data-slot": "dropdown-menu-trigger", ...props });
|
|
1463
|
+
}
|
|
1464
|
+
function DropdownMenuContent({
|
|
1465
|
+
align = "start",
|
|
1466
|
+
alignOffset = 0,
|
|
1467
|
+
side = "bottom",
|
|
1468
|
+
sideOffset = 4,
|
|
1469
|
+
className,
|
|
1470
|
+
...props
|
|
1471
|
+
}) {
|
|
1472
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(MenuPortal, { children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
1473
|
+
MenuPositioner,
|
|
1474
|
+
{
|
|
1475
|
+
className: "isolate z-50 outline-none",
|
|
1476
|
+
align,
|
|
1477
|
+
alignOffset,
|
|
1478
|
+
side,
|
|
1479
|
+
sideOffset,
|
|
1480
|
+
children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
1481
|
+
MenuPopup,
|
|
1482
|
+
{
|
|
1483
|
+
"data-slot": "dropdown-menu-content",
|
|
1484
|
+
className: cn("z-50 max-h-(--available-height) w-(--anchor-width) min-w-32 origin-(--transform-origin) overflow-x-hidden overflow-y-auto rounded-lg p-1 text-popover-foreground shadow-md ring-1 ring-foreground/10 duration-100 outline-none data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-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 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:overflow-hidden data-closed:fade-out-0 data-closed:zoom-out-95 animate-none! relative bg-popover/70 before:pointer-events-none before:absolute before:inset-0 before:-z-1 before:rounded-[inherit] before:backdrop-blur-2xl before:backdrop-saturate-150 **:data-[slot$=-item]:focus:bg-foreground/10 **:data-[slot$=-item]:data-highlighted:bg-foreground/10 **:data-[slot$=-separator]:bg-foreground/5 **:data-[slot$=-trigger]:focus:bg-foreground/10 **:data-[slot$=-trigger]:aria-expanded:bg-foreground/10! **:data-[variant=destructive]:focus:bg-foreground/10! **:data-[variant=destructive]:text-accent-foreground! **:data-[variant=destructive]:**:text-accent-foreground!", className),
|
|
1485
|
+
...props
|
|
1486
|
+
}
|
|
1487
|
+
)
|
|
1488
|
+
}
|
|
1489
|
+
) });
|
|
1490
|
+
}
|
|
1491
|
+
function DropdownMenuItem({
|
|
1492
|
+
className,
|
|
1493
|
+
inset,
|
|
1494
|
+
variant = "default",
|
|
1495
|
+
...props
|
|
1496
|
+
}) {
|
|
1497
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
1498
|
+
MenuItem,
|
|
1499
|
+
{
|
|
1500
|
+
"data-slot": "dropdown-menu-item",
|
|
1501
|
+
"data-inset": inset,
|
|
1502
|
+
"data-variant": variant,
|
|
1503
|
+
className: cn(
|
|
1504
|
+
"group/dropdown-menu-item relative flex cursor-default items-center gap-1.5 rounded-md px-1.5 py-1 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground data-inset:pl-7 data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 data-[variant=destructive]:focus:text-destructive dark:data-[variant=destructive]:focus:bg-destructive/20 data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 data-[variant=destructive]:*:[svg]:text-destructive",
|
|
1505
|
+
className
|
|
1506
|
+
),
|
|
1507
|
+
...props
|
|
1508
|
+
}
|
|
1509
|
+
);
|
|
1510
|
+
}
|
|
1511
|
+
const dashboardRoutes = [];
|
|
1512
|
+
const Logo = () => /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
1513
|
+
"img",
|
|
1514
|
+
{
|
|
1515
|
+
src: "/logo.png",
|
|
1516
|
+
alt: "Hermium",
|
|
1517
|
+
className: "h-7 w-7 rounded-md object-cover shrink-0"
|
|
1518
|
+
}
|
|
1519
|
+
);
|
|
1520
|
+
function DashboardSidebar() {
|
|
1521
|
+
const { state } = useSidebar();
|
|
1522
|
+
const isCollapsed = state === "collapsed";
|
|
1523
|
+
const navigate = useNavigate();
|
|
1524
|
+
const location = useLocation();
|
|
1525
|
+
const sessions = useChatStore((s) => s.sessions);
|
|
1526
|
+
const activeSessionId = useChatStore((s) => s.activeSessionId);
|
|
1527
|
+
const sessionsLoaded = useChatStore((s) => s.sessionsLoaded);
|
|
1528
|
+
const pinnedIds = useChatStore((s) => s.pinnedSessionIds);
|
|
1529
|
+
const loadSessions = useChatStore((s) => s.loadSessions);
|
|
1530
|
+
const deleteStoreSession = useChatStore((s) => s.deleteSession);
|
|
1531
|
+
const togglePin = useChatStore((s) => s.togglePin);
|
|
1532
|
+
const updateStoreSession = useChatStore((s) => s.updateSession);
|
|
1533
|
+
const handleNewChat = () => {
|
|
1534
|
+
useChatStore.setState({ activeSessionId: null, messages: [], isStreaming: false, activeStream: null });
|
|
1535
|
+
navigate({ to: "/" });
|
|
1536
|
+
};
|
|
1537
|
+
const [searchQuery, setSearchQuery] = reactExports.useState("");
|
|
1538
|
+
const [isSearchOpen, setIsSearchOpen] = reactExports.useState(false);
|
|
1539
|
+
const searchRef = reactExports.useRef(null);
|
|
1540
|
+
const [editingSessionId, setEditingSessionId] = reactExports.useState(null);
|
|
1541
|
+
const [editTitle, setEditTitle] = reactExports.useState("");
|
|
1542
|
+
const renameInputRef = reactExports.useRef(null);
|
|
1543
|
+
const [resolvedTheme, setResolvedTheme] = reactExports.useState("light");
|
|
1544
|
+
reactExports.useEffect(() => {
|
|
1545
|
+
import("./theme-BK4-7E2h.mjs").then(({ getStoredTheme, resolveTheme }) => {
|
|
1546
|
+
setResolvedTheme(resolveTheme(getStoredTheme()));
|
|
1547
|
+
});
|
|
1548
|
+
}, []);
|
|
1549
|
+
const handleToggleTheme = () => {
|
|
1550
|
+
import("./theme-BK4-7E2h.mjs").then(({ toggleTheme }) => {
|
|
1551
|
+
const next = toggleTheme();
|
|
1552
|
+
setResolvedTheme(next === "dark" ? "dark" : "light");
|
|
1553
|
+
});
|
|
1554
|
+
};
|
|
1555
|
+
reactExports.useEffect(() => {
|
|
1556
|
+
if (!sessionsLoaded) {
|
|
1557
|
+
loadSessions();
|
|
1558
|
+
}
|
|
1559
|
+
}, [sessionsLoaded, loadSessions]);
|
|
1560
|
+
const handleDeleteSession = async (sid) => {
|
|
1561
|
+
try {
|
|
1562
|
+
await deleteStoreSession(sid);
|
|
1563
|
+
} catch {
|
|
1564
|
+
}
|
|
1565
|
+
};
|
|
1566
|
+
const handleRename = async (sid) => {
|
|
1567
|
+
const trimmed = editTitle.trim();
|
|
1568
|
+
if (!trimmed) {
|
|
1569
|
+
setEditingSessionId(null);
|
|
1570
|
+
return;
|
|
1571
|
+
}
|
|
1572
|
+
try {
|
|
1573
|
+
await renameSession(sid, trimmed);
|
|
1574
|
+
updateStoreSession(sid, { title: trimmed });
|
|
1575
|
+
} catch {
|
|
1576
|
+
}
|
|
1577
|
+
setEditingSessionId(null);
|
|
1578
|
+
};
|
|
1579
|
+
const handleCopyId = (sid) => {
|
|
1580
|
+
navigator.clipboard.writeText(sid).catch(() => {
|
|
1581
|
+
});
|
|
1582
|
+
};
|
|
1583
|
+
const startRename = (s) => {
|
|
1584
|
+
setEditingSessionId(s.id);
|
|
1585
|
+
setEditTitle(s.title);
|
|
1586
|
+
setTimeout(() => renameInputRef.current?.focus(), 0);
|
|
1587
|
+
};
|
|
1588
|
+
const isOnChatRoute = location.pathname.startsWith("/chat/");
|
|
1589
|
+
const visibleSessions = sessions.filter(
|
|
1590
|
+
(s) => (s.messageCount ?? 0) > 0
|
|
1591
|
+
);
|
|
1592
|
+
const filteredSessions = searchQuery ? visibleSessions.filter(
|
|
1593
|
+
(s) => (s.title || "").toLowerCase().includes(searchQuery.toLowerCase())
|
|
1594
|
+
) : visibleSessions;
|
|
1595
|
+
const pinnedSessions = filteredSessions.filter((s) => pinnedIds.includes(s.id));
|
|
1596
|
+
const unpinnedSessions = filteredSessions.filter((s) => !pinnedIds.includes(s.id));
|
|
1597
|
+
const openSearch = () => {
|
|
1598
|
+
setIsSearchOpen(true);
|
|
1599
|
+
setTimeout(() => searchRef.current?.focus(), 0);
|
|
1600
|
+
};
|
|
1601
|
+
const closeSearch = () => {
|
|
1602
|
+
setIsSearchOpen(false);
|
|
1603
|
+
setSearchQuery("");
|
|
1604
|
+
};
|
|
1605
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsxs(Sidebar, { variant: "inset", collapsible: "offcanvas", children: [
|
|
1606
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs(SidebarHeader, { className: "flex flex-row items-center justify-between px-2 py-3", children: [
|
|
1607
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs(Link, { to: "/", className: "flex items-center gap-2.5", children: [
|
|
1608
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(Logo, {}),
|
|
1609
|
+
!isCollapsed && /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "font-semibold text-sm text-foreground tracking-tight", children: "Hermium" })
|
|
1610
|
+
] }),
|
|
1611
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(SidebarTrigger, {})
|
|
1612
|
+
] }),
|
|
1613
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(SidebarContent, { children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "relative flex flex-col flex-1 min-h-0 gap-1 px-0.5 py-1", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-col gap-1 h-full justify-between", children: [
|
|
1614
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-col gap-1 flex-1 min-h-0", children: [
|
|
1615
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(SidebarMenu, { children: /* @__PURE__ */ jsxRuntimeExports.jsx(SidebarMenuItem, { children: /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
1616
|
+
SidebarMenuButton,
|
|
1617
|
+
{
|
|
1618
|
+
onClick: handleNewChat,
|
|
1619
|
+
className: "flex w-full items-center gap-2 rounded-lg px-2 py-2 text-sm font-medium text-muted-foreground hover:text-foreground hover:bg-sidebar-muted transition-colors",
|
|
1620
|
+
children: [
|
|
1621
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(IconCirclePlus, { className: "size-4" }),
|
|
1622
|
+
!isCollapsed && /* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: "New Chat" })
|
|
1623
|
+
]
|
|
1624
|
+
}
|
|
1625
|
+
) }) }),
|
|
1626
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(SidebarMenu, { children: /* @__PURE__ */ jsxRuntimeExports.jsx(SidebarMenuItem, { children: /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
1627
|
+
SidebarMenuButton,
|
|
1628
|
+
{
|
|
1629
|
+
tooltip: "Memory",
|
|
1630
|
+
render: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
1631
|
+
Link,
|
|
1632
|
+
{
|
|
1633
|
+
to: "/memory",
|
|
1634
|
+
className: cn(
|
|
1635
|
+
"flex w-full items-center gap-2 rounded-lg px-2 py-2 text-sm font-medium transition-colors",
|
|
1636
|
+
location.pathname === "/memory" ? "bg-sidebar-muted text-foreground" : "text-muted-foreground hover:text-foreground hover:bg-sidebar-muted"
|
|
1637
|
+
)
|
|
1638
|
+
}
|
|
1639
|
+
),
|
|
1640
|
+
children: [
|
|
1641
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(IconBrain, { className: "size-4" }),
|
|
1642
|
+
!isCollapsed && /* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: "Memory" })
|
|
1643
|
+
]
|
|
1644
|
+
}
|
|
1645
|
+
) }) }),
|
|
1646
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(SidebarMenu, { children: /* @__PURE__ */ jsxRuntimeExports.jsx(SidebarMenuItem, { children: /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
1647
|
+
SidebarMenuButton,
|
|
1648
|
+
{
|
|
1649
|
+
tooltip: "Skills",
|
|
1650
|
+
render: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
1651
|
+
Link,
|
|
1652
|
+
{
|
|
1653
|
+
to: "/skills",
|
|
1654
|
+
className: cn(
|
|
1655
|
+
"flex w-full items-center gap-2 rounded-lg px-2 py-2 text-sm font-medium transition-colors",
|
|
1656
|
+
location.pathname === "/skills" ? "bg-sidebar-muted text-foreground" : "text-muted-foreground hover:text-foreground hover:bg-sidebar-muted"
|
|
1657
|
+
)
|
|
1658
|
+
}
|
|
1659
|
+
),
|
|
1660
|
+
children: [
|
|
1661
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(IconWand, { className: "size-4" }),
|
|
1662
|
+
!isCollapsed && /* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: "Skills" })
|
|
1663
|
+
]
|
|
1664
|
+
}
|
|
1665
|
+
) }) }),
|
|
1666
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(SidebarMenu, { children: /* @__PURE__ */ jsxRuntimeExports.jsx(SidebarMenuItem, { children: /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
1667
|
+
SidebarMenuButton,
|
|
1668
|
+
{
|
|
1669
|
+
tooltip: "Usage",
|
|
1670
|
+
render: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
1671
|
+
Link,
|
|
1672
|
+
{
|
|
1673
|
+
to: "/usage",
|
|
1674
|
+
className: cn(
|
|
1675
|
+
"flex w-full items-center gap-2 rounded-lg px-2 py-2 text-sm font-medium transition-colors",
|
|
1676
|
+
location.pathname === "/usage" ? "bg-sidebar-muted text-foreground" : "text-muted-foreground hover:text-foreground hover:bg-sidebar-muted"
|
|
1677
|
+
)
|
|
1678
|
+
}
|
|
1679
|
+
),
|
|
1680
|
+
children: [
|
|
1681
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(IconChartBar, { className: "size-4" }),
|
|
1682
|
+
!isCollapsed && /* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: "Usage" })
|
|
1683
|
+
]
|
|
1684
|
+
}
|
|
1685
|
+
) }) }),
|
|
1686
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(DashboardNavigation, { routes: dashboardRoutes }),
|
|
1687
|
+
!isCollapsed && /* @__PURE__ */ jsxRuntimeExports.jsxs(SidebarGroup, { className: "px-0 flex flex-col min-h-0", children: [
|
|
1688
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "group/search flex items-center justify-between px-0.5 pb-0.5 shrink-0", children: isSearchOpen ? /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex w-full items-center gap-1 min-w-0", children: [
|
|
1689
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(IconSearch, { className: "size-3.5 shrink-0 text-muted-foreground" }),
|
|
1690
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
1691
|
+
"input",
|
|
1692
|
+
{
|
|
1693
|
+
ref: searchRef,
|
|
1694
|
+
value: searchQuery,
|
|
1695
|
+
onChange: (e) => setSearchQuery(e.target.value),
|
|
1696
|
+
onKeyDown: (e) => {
|
|
1697
|
+
if (e.key === "Escape") closeSearch();
|
|
1698
|
+
},
|
|
1699
|
+
placeholder: "Search...",
|
|
1700
|
+
className: "flex-1 min-w-0 bg-transparent border-none outline-none text-xs text-foreground placeholder:text-muted-foreground/50"
|
|
1701
|
+
}
|
|
1702
|
+
),
|
|
1703
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
1704
|
+
"button",
|
|
1705
|
+
{
|
|
1706
|
+
onClick: closeSearch,
|
|
1707
|
+
className: "flex shrink-0 items-center justify-center rounded-md p-1 text-muted-foreground hover:text-foreground hover:bg-sidebar-muted transition-colors",
|
|
1708
|
+
"aria-label": "Close search",
|
|
1709
|
+
title: "Close search",
|
|
1710
|
+
children: /* @__PURE__ */ jsxRuntimeExports.jsx(IconX, { className: "size-4" })
|
|
1711
|
+
}
|
|
1712
|
+
)
|
|
1713
|
+
] }) : /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
|
|
1714
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(SidebarGroupLabel, { className: "!text-[11px] !font-normal text-muted-foreground/60", children: "Chats" }),
|
|
1715
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
1716
|
+
"button",
|
|
1717
|
+
{
|
|
1718
|
+
onClick: openSearch,
|
|
1719
|
+
className: "flex shrink-0 items-center justify-center rounded p-0.5 text-muted-foreground opacity-0 hover:text-foreground group-hover/search:opacity-100 transition-opacity",
|
|
1720
|
+
"aria-label": "Search chats",
|
|
1721
|
+
children: /* @__PURE__ */ jsxRuntimeExports.jsx(IconSearch, { className: "size-3.5" })
|
|
1722
|
+
}
|
|
1723
|
+
)
|
|
1724
|
+
] }) }),
|
|
1725
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex-1 overflow-y-auto min-h-0", children: /* @__PURE__ */ jsxRuntimeExports.jsxs(SidebarMenu, { children: [
|
|
1726
|
+
filteredSessions.length === 0 && searchQuery && /* @__PURE__ */ jsxRuntimeExports.jsxs("p", { className: "px-2 py-4 text-xs text-muted-foreground", children: [
|
|
1727
|
+
'No chats match "',
|
|
1728
|
+
searchQuery,
|
|
1729
|
+
'"'
|
|
1730
|
+
] }),
|
|
1731
|
+
filteredSessions.length === 0 && !searchQuery && /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "px-2 py-4 text-xs text-muted-foreground", children: "No conversations yet. Start chatting!" }),
|
|
1732
|
+
pinnedSessions.map((s) => /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
1733
|
+
SessionItem,
|
|
1734
|
+
{
|
|
1735
|
+
session: s,
|
|
1736
|
+
isActive: isOnChatRoute && activeSessionId === s.id,
|
|
1737
|
+
isEditing: editingSessionId === s.id,
|
|
1738
|
+
editTitle,
|
|
1739
|
+
setEditTitle,
|
|
1740
|
+
renameInputRef,
|
|
1741
|
+
onRename: (sid) => handleRename(sid),
|
|
1742
|
+
onCancelRename: () => setEditingSessionId(null),
|
|
1743
|
+
onStartRename: () => startRename(s),
|
|
1744
|
+
onTogglePin: () => togglePin(s.id),
|
|
1745
|
+
onCopyId: () => handleCopyId(s.id),
|
|
1746
|
+
onDelete: () => handleDeleteSession(s.id),
|
|
1747
|
+
isPinned: true
|
|
1748
|
+
},
|
|
1749
|
+
s.id
|
|
1750
|
+
)),
|
|
1751
|
+
unpinnedSessions.slice(0, 20).map((s) => /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
1752
|
+
SessionItem,
|
|
1753
|
+
{
|
|
1754
|
+
session: s,
|
|
1755
|
+
isActive: isOnChatRoute && activeSessionId === s.id,
|
|
1756
|
+
isEditing: editingSessionId === s.id,
|
|
1757
|
+
editTitle,
|
|
1758
|
+
setEditTitle,
|
|
1759
|
+
renameInputRef,
|
|
1760
|
+
onRename: (sid) => handleRename(sid),
|
|
1761
|
+
onCancelRename: () => setEditingSessionId(null),
|
|
1762
|
+
onStartRename: () => startRename(s),
|
|
1763
|
+
onTogglePin: () => togglePin(s.id),
|
|
1764
|
+
onCopyId: () => handleCopyId(s.id),
|
|
1765
|
+
onDelete: () => handleDeleteSession(s.id)
|
|
1766
|
+
},
|
|
1767
|
+
s.id
|
|
1768
|
+
))
|
|
1769
|
+
] }) })
|
|
1770
|
+
] })
|
|
1771
|
+
] }),
|
|
1772
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "shrink-0 space-y-1", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center flex-row gap-1", children: [
|
|
1773
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
1774
|
+
Link,
|
|
1775
|
+
{
|
|
1776
|
+
to: "/settings",
|
|
1777
|
+
className: "flex items-center gap-1.5 rounded-md text-xs font-medium text-muted-foreground hover:bg-sidebar-muted hover:text-foreground transition-colors flex-1 px-2 py-1",
|
|
1778
|
+
"aria-label": "Settings",
|
|
1779
|
+
children: [
|
|
1780
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(IconSettings, { className: "size-3.5 shrink-0" }),
|
|
1781
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: "Settings" })
|
|
1782
|
+
]
|
|
1783
|
+
}
|
|
1784
|
+
),
|
|
1785
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
1786
|
+
"button",
|
|
1787
|
+
{
|
|
1788
|
+
onClick: handleToggleTheme,
|
|
1789
|
+
className: "flex items-center justify-center rounded-md text-muted-foreground hover:bg-sidebar-muted hover:text-foreground transition-colors p-1.5",
|
|
1790
|
+
"aria-label": "Toggle theme",
|
|
1791
|
+
children: [
|
|
1792
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(IconSun, { className: cn("size-3.5", resolvedTheme === "dark" && "hidden") }),
|
|
1793
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(IconMoon, { className: cn("size-3.5", resolvedTheme === "light" && "hidden") })
|
|
1794
|
+
]
|
|
1795
|
+
}
|
|
1796
|
+
)
|
|
1797
|
+
] }) })
|
|
1798
|
+
] }) }) })
|
|
1799
|
+
] });
|
|
1800
|
+
}
|
|
1801
|
+
function SessionItem({
|
|
1802
|
+
session,
|
|
1803
|
+
isActive,
|
|
1804
|
+
isEditing,
|
|
1805
|
+
editTitle,
|
|
1806
|
+
setEditTitle,
|
|
1807
|
+
renameInputRef,
|
|
1808
|
+
onRename,
|
|
1809
|
+
onCancelRename,
|
|
1810
|
+
onStartRename,
|
|
1811
|
+
onTogglePin,
|
|
1812
|
+
onCopyId,
|
|
1813
|
+
onDelete,
|
|
1814
|
+
isPinned = false
|
|
1815
|
+
}) {
|
|
1816
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(SidebarMenuItem, { className: "group/chat", children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "relative", children: isEditing ? /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
1817
|
+
"input",
|
|
1818
|
+
{
|
|
1819
|
+
ref: renameInputRef,
|
|
1820
|
+
value: editTitle,
|
|
1821
|
+
onChange: (e) => setEditTitle(e.target.value),
|
|
1822
|
+
onKeyDown: (e) => {
|
|
1823
|
+
if (e.key === "Enter") onRename(session.id);
|
|
1824
|
+
if (e.key === "Escape") onCancelRename();
|
|
1825
|
+
},
|
|
1826
|
+
onBlur: () => onCancelRename(),
|
|
1827
|
+
className: "w-full px-2 py-1 text-xs font-medium bg-transparent border-b border-sidebar-ring text-foreground outline-none"
|
|
1828
|
+
}
|
|
1829
|
+
) : /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
|
|
1830
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
1831
|
+
SidebarMenuButton,
|
|
1832
|
+
{
|
|
1833
|
+
isActive,
|
|
1834
|
+
className: "px-2 py-0.5 pr-8 text-xs font-medium text-muted-foreground hover:text-foreground data-[active=true]:bg-sidebar-muted data-[active=true]:text-foreground",
|
|
1835
|
+
onDoubleClick: onStartRename,
|
|
1836
|
+
render: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
1837
|
+
Link,
|
|
1838
|
+
{
|
|
1839
|
+
to: "/chat/$sessionId",
|
|
1840
|
+
params: { sessionId: session.id },
|
|
1841
|
+
className: "flex items-center gap-1.5"
|
|
1842
|
+
}
|
|
1843
|
+
),
|
|
1844
|
+
children: [
|
|
1845
|
+
isPinned && /* @__PURE__ */ jsxRuntimeExports.jsx(IconPin, { className: "size-3 shrink-0 text-amber-500" }),
|
|
1846
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "truncate", children: session.title })
|
|
1847
|
+
]
|
|
1848
|
+
}
|
|
1849
|
+
),
|
|
1850
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs(DropdownMenu, { children: [
|
|
1851
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
1852
|
+
DropdownMenuTrigger,
|
|
1853
|
+
{
|
|
1854
|
+
render: /* @__PURE__ */ jsxRuntimeExports.jsx("button", { className: "absolute right-0 top-1/2 -translate-y-1/2 z-10 flex items-center justify-center rounded-md p-1 text-muted-foreground opacity-0 hover:bg-sidebar-muted hover:text-foreground group-hover/chat:opacity-100 transition-opacity" }),
|
|
1855
|
+
children: /* @__PURE__ */ jsxRuntimeExports.jsx(IconDots, { className: "size-4" })
|
|
1856
|
+
}
|
|
1857
|
+
),
|
|
1858
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs(DropdownMenuContent, { align: "end", side: "right", sideOffset: 4, children: [
|
|
1859
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs(DropdownMenuItem, { className: "gap-2", onClick: onStartRename, children: [
|
|
1860
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(IconPencil, { className: "size-3.5" }),
|
|
1861
|
+
"Rename"
|
|
1862
|
+
] }),
|
|
1863
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(DropdownMenuItem, { className: "gap-2", onClick: onTogglePin, children: isPinned ? /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
|
|
1864
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(IconPinnedOff, { className: "size-3.5" }),
|
|
1865
|
+
"Unpin"
|
|
1866
|
+
] }) : /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
|
|
1867
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(IconPin, { className: "size-3.5" }),
|
|
1868
|
+
"Pin"
|
|
1869
|
+
] }) }),
|
|
1870
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs(DropdownMenuItem, { className: "gap-2", onClick: onCopyId, children: [
|
|
1871
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(IconCopy, { className: "size-3.5" }),
|
|
1872
|
+
"Copy ID"
|
|
1873
|
+
] }),
|
|
1874
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
1875
|
+
DropdownMenuItem,
|
|
1876
|
+
{
|
|
1877
|
+
className: "gap-2 text-destructive",
|
|
1878
|
+
onClick: onDelete,
|
|
1879
|
+
children: [
|
|
1880
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(IconTrash, { className: "size-3.5" }),
|
|
1881
|
+
"Delete"
|
|
1882
|
+
]
|
|
1883
|
+
}
|
|
1884
|
+
)
|
|
1885
|
+
] })
|
|
1886
|
+
] })
|
|
1887
|
+
] }) }) });
|
|
1888
|
+
}
|
|
1889
|
+
function LayoutInner({ children }) {
|
|
1890
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "relative flex h-dvh w-full", children: [
|
|
1891
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(DashboardSidebar, {}),
|
|
1892
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(SidebarInset, { className: "flex flex-col min-w-0", children })
|
|
1893
|
+
] });
|
|
1894
|
+
}
|
|
1895
|
+
function DashboardLayout({ children }) {
|
|
1896
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(SidebarProvider, { children: /* @__PURE__ */ jsxRuntimeExports.jsx(LayoutInner, { children }) });
|
|
1897
|
+
}
|
|
1898
|
+
const appCss = "/assets/css/styles-o9LLzp-x.css";
|
|
1899
|
+
const themeScript = `
|
|
1900
|
+
(function() {
|
|
1901
|
+
try {
|
|
1902
|
+
var theme = localStorage.getItem('hermium-theme') || 'system';
|
|
1903
|
+
var resolved = theme === 'system'
|
|
1904
|
+
? (window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light')
|
|
1905
|
+
: theme;
|
|
1906
|
+
if (resolved === 'dark') {
|
|
1907
|
+
document.documentElement.classList.add('dark');
|
|
1908
|
+
} else {
|
|
1909
|
+
document.documentElement.classList.remove('dark');
|
|
1910
|
+
}
|
|
1911
|
+
} catch (e) {}
|
|
1912
|
+
})();
|
|
1913
|
+
`;
|
|
1914
|
+
const Route$7 = createRootRoute({
|
|
1915
|
+
head: () => ({
|
|
1916
|
+
meta: [
|
|
1917
|
+
{ charSet: "utf-8" },
|
|
1918
|
+
{ name: "viewport", content: "width=device-width, initial-scale=1" },
|
|
1919
|
+
{ title: "Hermium" }
|
|
1920
|
+
],
|
|
1921
|
+
links: [{ rel: "stylesheet", href: appCss }],
|
|
1922
|
+
scripts: [{ type: "text/javascript", children: themeScript }]
|
|
1923
|
+
}),
|
|
1924
|
+
notFoundComponent: () => /* @__PURE__ */ jsxRuntimeExports.jsxs("main", { className: "container mx-auto p-4 pt-16", children: [
|
|
1925
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("h1", { children: "404" }),
|
|
1926
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("p", { children: "The requested page could not be found." })
|
|
1927
|
+
] }),
|
|
1928
|
+
shellComponent: RootDocument
|
|
1929
|
+
});
|
|
1930
|
+
function RootDocument({ children }) {
|
|
1931
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsxs("html", { lang: "en", suppressHydrationWarning: true, children: [
|
|
1932
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("head", { children: /* @__PURE__ */ jsxRuntimeExports.jsx(HeadContent, {}) }),
|
|
1933
|
+
/* @__PURE__ */ jsxRuntimeExports.jsxs("body", { children: [
|
|
1934
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(TooltipProvider, { children: /* @__PURE__ */ jsxRuntimeExports.jsx(DashboardLayout, { children }) }),
|
|
1935
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(Scripts, {})
|
|
1936
|
+
] })
|
|
1937
|
+
] });
|
|
1938
|
+
}
|
|
1939
|
+
const $$splitComponentImporter$6 = () => import("./usage-Bs2-LXGz.mjs");
|
|
1940
|
+
const Route$6 = createFileRoute("/usage")({
|
|
1941
|
+
component: lazyRouteComponent($$splitComponentImporter$6, "component")
|
|
1942
|
+
});
|
|
1943
|
+
const $$splitComponentImporter$5 = () => import("./skills-Cs7A5ZwO.mjs");
|
|
1944
|
+
const Route$5 = createFileRoute("/skills")({
|
|
1945
|
+
component: lazyRouteComponent($$splitComponentImporter$5, "component")
|
|
1946
|
+
});
|
|
1947
|
+
const $$splitComponentImporter$4 = () => import("./settings-DoXurzvn.mjs");
|
|
1948
|
+
const Route$4 = createFileRoute("/settings")({
|
|
1949
|
+
component: lazyRouteComponent($$splitComponentImporter$4, "component")
|
|
1950
|
+
});
|
|
1951
|
+
const $$splitComponentImporter$3 = () => import("./memory-CW_fSOG9.mjs");
|
|
1952
|
+
const Route$3 = createFileRoute("/memory")({
|
|
1953
|
+
component: lazyRouteComponent($$splitComponentImporter$3, "component")
|
|
1954
|
+
});
|
|
1955
|
+
const $$splitComponentImporter$2 = () => import("./index-DFV9_oCk.mjs");
|
|
1956
|
+
const Route$2 = createFileRoute("/")({
|
|
1957
|
+
component: lazyRouteComponent($$splitComponentImporter$2, "component")
|
|
1958
|
+
});
|
|
1959
|
+
const $$splitComponentImporter$1 = () => import("./chat.index-BYB_48NC.mjs");
|
|
1960
|
+
const Route$1 = createFileRoute("/chat/")({
|
|
1961
|
+
component: lazyRouteComponent($$splitComponentImporter$1, "component")
|
|
1962
|
+
});
|
|
1963
|
+
const $$splitComponentImporter = () => import("./chat._sessionId-P02iSfut.mjs");
|
|
1964
|
+
const Route = createFileRoute("/chat/$sessionId")({
|
|
1965
|
+
component: lazyRouteComponent($$splitComponentImporter, "component")
|
|
1966
|
+
});
|
|
1967
|
+
const UsageRoute = Route$6.update({
|
|
1968
|
+
id: "/usage",
|
|
1969
|
+
path: "/usage",
|
|
1970
|
+
getParentRoute: () => Route$7
|
|
1971
|
+
});
|
|
1972
|
+
const SkillsRoute = Route$5.update({
|
|
1973
|
+
id: "/skills",
|
|
1974
|
+
path: "/skills",
|
|
1975
|
+
getParentRoute: () => Route$7
|
|
1976
|
+
});
|
|
1977
|
+
const SettingsRoute = Route$4.update({
|
|
1978
|
+
id: "/settings",
|
|
1979
|
+
path: "/settings",
|
|
1980
|
+
getParentRoute: () => Route$7
|
|
1981
|
+
});
|
|
1982
|
+
const MemoryRoute = Route$3.update({
|
|
1983
|
+
id: "/memory",
|
|
1984
|
+
path: "/memory",
|
|
1985
|
+
getParentRoute: () => Route$7
|
|
1986
|
+
});
|
|
1987
|
+
const IndexRoute = Route$2.update({
|
|
1988
|
+
id: "/",
|
|
1989
|
+
path: "/",
|
|
1990
|
+
getParentRoute: () => Route$7
|
|
1991
|
+
});
|
|
1992
|
+
const ChatIndexRoute = Route$1.update({
|
|
1993
|
+
id: "/chat/",
|
|
1994
|
+
path: "/chat/",
|
|
1995
|
+
getParentRoute: () => Route$7
|
|
1996
|
+
});
|
|
1997
|
+
const ChatSessionIdRoute = Route.update({
|
|
1998
|
+
id: "/chat/$sessionId",
|
|
1999
|
+
path: "/chat/$sessionId",
|
|
2000
|
+
getParentRoute: () => Route$7
|
|
2001
|
+
});
|
|
2002
|
+
const rootRouteChildren = {
|
|
2003
|
+
IndexRoute,
|
|
2004
|
+
MemoryRoute,
|
|
2005
|
+
SettingsRoute,
|
|
2006
|
+
SkillsRoute,
|
|
2007
|
+
UsageRoute,
|
|
2008
|
+
ChatSessionIdRoute,
|
|
2009
|
+
ChatIndexRoute
|
|
2010
|
+
};
|
|
2011
|
+
const routeTree = Route$7._addFileChildren(rootRouteChildren)._addFileTypes();
|
|
2012
|
+
function getRouter() {
|
|
2013
|
+
const router2 = createRouter({
|
|
2014
|
+
routeTree,
|
|
2015
|
+
scrollRestoration: true,
|
|
2016
|
+
defaultPreload: "intent",
|
|
2017
|
+
defaultPreloadStaleTime: 0
|
|
2018
|
+
});
|
|
2019
|
+
return router2;
|
|
2020
|
+
}
|
|
2021
|
+
const router = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
2022
|
+
__proto__: null,
|
|
2023
|
+
getRouter
|
|
2024
|
+
}, Symbol.toStringTag, { value: "Module" }));
|
|
2025
|
+
export {
|
|
2026
|
+
Button as B,
|
|
2027
|
+
Route as R,
|
|
2028
|
+
SidebarTrigger as S,
|
|
2029
|
+
createSession as a,
|
|
2030
|
+
router as b,
|
|
2031
|
+
cn as c,
|
|
2032
|
+
useSidebar as d,
|
|
2033
|
+
request as r,
|
|
2034
|
+
useChatStore as u
|
|
2035
|
+
};
|