@burtson-labs/bandit-engine 2.1.5 → 2.1.8

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.
Files changed (83) hide show
  1. package/CHANGELOG.md +29 -0
  2. package/dist/AdvancedTab-HZTDXFST.mjs +229 -0
  3. package/dist/AdvancedTab-HZTDXFST.mjs.map +1 -0
  4. package/dist/CrewSection-YM26YD2N.mjs +12 -0
  5. package/dist/InstructionsTab-MKOGBQ5L.mjs +195 -0
  6. package/dist/InstructionsTab-MKOGBQ5L.mjs.map +1 -0
  7. package/dist/PersonalizationTab-2XHFTYYW.mjs +179 -0
  8. package/dist/PersonalizationTab-2XHFTYYW.mjs.map +1 -0
  9. package/dist/{ProjectsPane-BSVOVNK7.mjs → ProjectsPane-KE5DGFN4.mjs} +11 -8
  10. package/dist/ProjectsPane-KE5DGFN4.mjs.map +1 -0
  11. package/dist/{SchedulesTab-TCUOAKLH.mjs → SchedulesTab-AM5QP36K.mjs} +8 -6
  12. package/dist/SchedulesTab-AM5QP36K.mjs.map +1 -0
  13. package/dist/{aiProviderStore-ANPQVHGD.mjs → aiProviderStore-GH4JZTMW.mjs} +3 -2
  14. package/dist/chat-D66YM4MB.mjs +26 -0
  15. package/dist/{chunk-SK7FSLCY.mjs → chunk-2FI2IICG.mjs} +7 -564
  16. package/dist/chunk-2FI2IICG.mjs.map +1 -0
  17. package/dist/{chunk-4257FVLK.mjs → chunk-2HFSBPOE.mjs} +6 -1
  18. package/dist/chunk-2HFSBPOE.mjs.map +1 -0
  19. package/dist/chunk-2THUYNVU.mjs +1203 -0
  20. package/dist/chunk-2THUYNVU.mjs.map +1 -0
  21. package/dist/{chunk-KWOUXBSF.mjs → chunk-5LXCZJLJ.mjs} +5 -213
  22. package/dist/chunk-5LXCZJLJ.mjs.map +1 -0
  23. package/dist/{chunk-ZG66NJC3.mjs → chunk-5URP2E5V.mjs} +3 -6
  24. package/dist/chunk-5URP2E5V.mjs.map +1 -0
  25. package/dist/chunk-5WCKKD3S.mjs +1742 -0
  26. package/dist/chunk-5WCKKD3S.mjs.map +1 -0
  27. package/dist/{chunk-GX4FVZNA.mjs → chunk-DHXSFFLX.mjs} +4 -26
  28. package/dist/chunk-DHXSFFLX.mjs.map +1 -0
  29. package/dist/chunk-EKPPIS3X.mjs +336 -0
  30. package/dist/chunk-EKPPIS3X.mjs.map +1 -0
  31. package/dist/chunk-FBLITVVY.mjs +5845 -0
  32. package/dist/chunk-FBLITVVY.mjs.map +1 -0
  33. package/dist/chunk-H2XUGGKV.mjs +168 -0
  34. package/dist/chunk-H2XUGGKV.mjs.map +1 -0
  35. package/dist/chunk-K4AO466X.mjs +570 -0
  36. package/dist/chunk-K4AO466X.mjs.map +1 -0
  37. package/dist/chunk-KPT7NNNK.mjs +214 -0
  38. package/dist/chunk-KPT7NNNK.mjs.map +1 -0
  39. package/dist/{chunk-IXD2TDA5.mjs → chunk-LAH6UL3Q.mjs} +11 -1727
  40. package/dist/chunk-LAH6UL3Q.mjs.map +1 -0
  41. package/dist/chunk-LC64VSDS.mjs +541 -0
  42. package/dist/chunk-LC64VSDS.mjs.map +1 -0
  43. package/dist/{chunk-DH5A2HT2.mjs → chunk-LY3O7UWA.mjs} +45 -1
  44. package/dist/chunk-LY3O7UWA.mjs.map +1 -0
  45. package/dist/chunk-WBKTQJNX.mjs +21 -0
  46. package/dist/chunk-WBKTQJNX.mjs.map +1 -0
  47. package/dist/{chunk-XGIQNHUO.mjs → chunk-WZGDQ4EA.mjs} +5776 -11713
  48. package/dist/chunk-WZGDQ4EA.mjs.map +1 -0
  49. package/dist/chunk-Y272M3D5.mjs +28 -0
  50. package/dist/chunk-Y272M3D5.mjs.map +1 -0
  51. package/dist/image-compare-NW5VCP4Q.mjs +74 -0
  52. package/dist/image-compare-NW5VCP4Q.mjs.map +1 -0
  53. package/dist/image-edit-acknowledgement-RZPQYKYJ.mjs +54 -0
  54. package/dist/image-edit-acknowledgement-RZPQYKYJ.mjs.map +1 -0
  55. package/dist/index.d.mts +135 -7
  56. package/dist/index.d.ts +135 -7
  57. package/dist/index.js +10491 -8632
  58. package/dist/index.js.map +1 -1
  59. package/dist/index.mjs +1393 -2368
  60. package/dist/index.mjs.map +1 -1
  61. package/dist/{modelStore-YNANSWCN.mjs → modelStore-KO45QAO2.mjs} +3 -2
  62. package/dist/modelStore-KO45QAO2.mjs.map +1 -0
  63. package/dist/{public-Tq2Pmw9m.d.mts → public-_W_Zew3C.d.mts} +14 -0
  64. package/dist/{public-Tq2Pmw9m.d.ts → public-_W_Zew3C.d.ts} +14 -0
  65. package/dist/public-types.d.mts +1 -1
  66. package/dist/public-types.d.ts +1 -1
  67. package/dist/{schedule-confirm-card-7CMATYSP.mjs → schedule-confirm-card-D4K76HEA.mjs} +5 -5
  68. package/package.json +1 -1
  69. package/dist/ProjectsPane-BSVOVNK7.mjs.map +0 -1
  70. package/dist/SchedulesTab-TCUOAKLH.mjs.map +0 -1
  71. package/dist/chat-Y7KPN54G.mjs +0 -18
  72. package/dist/chunk-4257FVLK.mjs.map +0 -1
  73. package/dist/chunk-DH5A2HT2.mjs.map +0 -1
  74. package/dist/chunk-GX4FVZNA.mjs.map +0 -1
  75. package/dist/chunk-IXD2TDA5.mjs.map +0 -1
  76. package/dist/chunk-KWOUXBSF.mjs.map +0 -1
  77. package/dist/chunk-SK7FSLCY.mjs.map +0 -1
  78. package/dist/chunk-XGIQNHUO.mjs.map +0 -1
  79. package/dist/chunk-ZG66NJC3.mjs.map +0 -1
  80. /package/dist/{aiProviderStore-ANPQVHGD.mjs.map → CrewSection-YM26YD2N.mjs.map} +0 -0
  81. /package/dist/{chat-Y7KPN54G.mjs.map → aiProviderStore-GH4JZTMW.mjs.map} +0 -0
  82. /package/dist/{modelStore-YNANSWCN.mjs.map → chat-D66YM4MB.mjs.map} +0 -0
  83. /package/dist/{schedule-confirm-card-7CMATYSP.mjs.map → schedule-confirm-card-D4K76HEA.mjs.map} +0 -0
@@ -0,0 +1,1742 @@
1
+ import {
2
+ PROJECT_COLORS,
3
+ useConversationStore,
4
+ useFeatureVisibility,
5
+ useProjectStore
6
+ } from "./chunk-LAH6UL3Q.mjs";
7
+ import {
8
+ usePreferencesStore
9
+ } from "./chunk-5LXCZJLJ.mjs";
10
+ import {
11
+ indexedDBService_default
12
+ } from "./chunk-KPT7NNNK.mjs";
13
+ import {
14
+ Check,
15
+ Edit,
16
+ Folder,
17
+ GripVertical,
18
+ Home,
19
+ Inbox,
20
+ LogOut,
21
+ MailOpen,
22
+ MessageSquarePlus,
23
+ MoreVertical,
24
+ Plus,
25
+ Search,
26
+ Settings,
27
+ Trash
28
+ } from "./chunk-5URP2E5V.mjs";
29
+ import {
30
+ usePackageSettingsStore
31
+ } from "./chunk-K7SQWDNF.mjs";
32
+ import {
33
+ authenticationService,
34
+ readPersistedToken,
35
+ useAuthenticationStore
36
+ } from "./chunk-S3DWWUBD.mjs";
37
+ import {
38
+ debugLogger
39
+ } from "./chunk-NI7BKLC7.mjs";
40
+
41
+ // src/chat/sidebar/sidebarState.ts
42
+ import { create } from "zustand";
43
+ var SIDEBAR_WIDTH = 300;
44
+ var SIDEBAR_COLLAPSED_KEY = "bandit.sidebar.collapsed";
45
+ var SIDEBAR_DEFAULT_OPEN_MIN_WIDTH = 1024;
46
+ var CHAT_VIEW = { kind: "chat" };
47
+ var readPersistedCollapsed = () => {
48
+ try {
49
+ const raw = localStorage.getItem(SIDEBAR_COLLAPSED_KEY);
50
+ return raw === null ? null : raw === "1";
51
+ } catch {
52
+ return null;
53
+ }
54
+ };
55
+ var writePersistedCollapsed = (collapsed) => {
56
+ try {
57
+ localStorage.setItem(SIDEBAR_COLLAPSED_KEY, collapsed ? "1" : "0");
58
+ } catch {
59
+ }
60
+ };
61
+ var initialSidebarOpen = (viewportWidth = typeof window === "undefined" ? 0 : window.innerWidth) => {
62
+ const persisted = readPersistedCollapsed();
63
+ if (persisted !== null) return !persisted;
64
+ return viewportWidth >= SIDEBAR_DEFAULT_OPEN_MIN_WIDTH;
65
+ };
66
+ function viewFromSearch(search) {
67
+ const params = new URLSearchParams(search);
68
+ const projectId = params.get("project");
69
+ if (projectId) return { kind: "project", projectId };
70
+ if (params.get("view") === "projects") return { kind: "projects" };
71
+ return CHAT_VIEW;
72
+ }
73
+ function searchWithView(search, view) {
74
+ const params = new URLSearchParams(search);
75
+ params.delete("view");
76
+ params.delete("project");
77
+ if (view.kind === "projects") params.set("view", "projects");
78
+ if (view.kind === "project") params.set("project", view.projectId);
79
+ const next = params.toString();
80
+ return next ? `?${next}` : "";
81
+ }
82
+ var sameView = (a, b) => a.kind === b.kind && (a.kind !== "project" || b.kind !== "project" || a.projectId === b.projectId);
83
+ var useSidebarStore = create((set) => ({
84
+ view: CHAT_VIEW,
85
+ searchFocusRequest: 0,
86
+ setView: (view) => set({ view }),
87
+ showChat: () => set({ view: CHAT_VIEW }),
88
+ showProjects: () => set({ view: { kind: "projects" } }),
89
+ openProject: (projectId) => set({ view: { kind: "project", projectId } }),
90
+ requestSearchFocus: () => set((state) => ({ searchFocusRequest: state.searchFocusRequest + 1 }))
91
+ }));
92
+ function syncViewWithUrl() {
93
+ if (typeof window === "undefined") return () => {
94
+ };
95
+ const store = useSidebarStore;
96
+ store.getState().setView(viewFromSearch(window.location.search));
97
+ const onPop = () => store.getState().setView(viewFromSearch(window.location.search));
98
+ window.addEventListener("popstate", onPop);
99
+ const unsubscribe = store.subscribe((state, previous) => {
100
+ if (sameView(state.view, previous.view)) return;
101
+ const current = viewFromSearch(window.location.search);
102
+ if (sameView(current, state.view)) return;
103
+ const search = searchWithView(window.location.search, state.view);
104
+ const url = `${window.location.pathname}${search}${window.location.hash}`;
105
+ window.history.pushState(window.history.state, "", url);
106
+ });
107
+ return () => {
108
+ window.removeEventListener("popstate", onPop);
109
+ unsubscribe();
110
+ };
111
+ }
112
+ var useSidebarLayout = () => usePackageSettingsStore((state) => state.settings?.navigation?.sidebar ?? "classic");
113
+ var useSectionsLayout = () => useSidebarLayout() === "sections";
114
+
115
+ // src/services/branding/brandingService.ts
116
+ var BrandingService = class {
117
+ DB_NAME = "banditConfig";
118
+ DB_VERSION = 1;
119
+ STORE_NAME = "config";
120
+ STORE_CONFIGS = [{ name: "config", keyPath: "id" }];
121
+ async getBranding() {
122
+ try {
123
+ const data = await indexedDBService_default.get(
124
+ this.DB_NAME,
125
+ this.DB_VERSION,
126
+ this.STORE_NAME,
127
+ "main",
128
+ this.STORE_CONFIGS
129
+ );
130
+ if (data?.branding && (data.branding.logoBase64 || data.branding.hasTransparentLogo !== void 0 || data.branding.brandingText)) {
131
+ return {
132
+ logoBase64: data.branding.logoBase64,
133
+ hasTransparentLogo: data.branding.hasTransparentLogo,
134
+ brandingText: data.branding.brandingText
135
+ };
136
+ }
137
+ return null;
138
+ } catch (error) {
139
+ throw error;
140
+ }
141
+ }
142
+ async setBrandingFromConfig(config) {
143
+ try {
144
+ const existing = await indexedDBService_default.get(
145
+ this.DB_NAME,
146
+ this.DB_VERSION,
147
+ this.STORE_NAME,
148
+ "main",
149
+ this.STORE_CONFIGS
150
+ ) || { id: "main" };
151
+ if (existing.branding?.userSaved) {
152
+ debugLogger.debug(
153
+ "\u{1F6E1}\uFE0F BrandingService: User branding detected, blocking CDN config override"
154
+ );
155
+ return;
156
+ }
157
+ const hasUserBranding = existing.branding && (existing.branding.logoBase64 || existing.branding.brandingText || existing.branding.theme || existing.branding.hasTransparentLogo !== void 0);
158
+ if (hasUserBranding) {
159
+ debugLogger.debug(
160
+ "\u{1F6E1}\uFE0F BrandingService: Detected user branding data, blocking CDN config override"
161
+ );
162
+ return;
163
+ }
164
+ debugLogger.debug(
165
+ "\u{1F527} BrandingService: No user branding detected, applying CDN config"
166
+ );
167
+ const branding = config.branding || {};
168
+ const updated = {
169
+ ...existing,
170
+ branding: {
171
+ ...existing.branding,
172
+ ...branding
173
+ }
174
+ };
175
+ await indexedDBService_default.put(
176
+ this.DB_NAME,
177
+ this.DB_VERSION,
178
+ this.STORE_NAME,
179
+ updated,
180
+ this.STORE_CONFIGS
181
+ );
182
+ } catch (error) {
183
+ throw error;
184
+ }
185
+ }
186
+ };
187
+ var brandingService = new BrandingService();
188
+ var brandingService_default = brandingService;
189
+
190
+ // src/utils/installedApp.ts
191
+ var isNativeShell = () => {
192
+ if (typeof window === "undefined") return false;
193
+ const cap = window.Capacitor;
194
+ return typeof cap?.isNativePlatform === "function" && cap.isNativePlatform() === true;
195
+ };
196
+ var isStandalonePwa = () => {
197
+ if (typeof window === "undefined") return false;
198
+ const nav = window.navigator;
199
+ return window.matchMedia?.("(display-mode: standalone)").matches || nav.standalone === true;
200
+ };
201
+
202
+ // src/hooks/useSafeNavigate.ts
203
+ import { useRef } from "react";
204
+ import { useNavigate } from "react-router-dom";
205
+ var useSafeNavigate = () => {
206
+ const warned = useRef(false);
207
+ let navigate = null;
208
+ try {
209
+ navigate = useNavigate();
210
+ } catch (error) {
211
+ if (!warned.current) {
212
+ debugLogger.warn("useSafeNavigate: no Router context; falling back to location", {
213
+ error
214
+ });
215
+ warned.current = true;
216
+ }
217
+ navigate = null;
218
+ }
219
+ return (to) => {
220
+ if (typeof window !== "undefined" && /^[a-z]+:\/\//i.test(to)) {
221
+ window.location.href = to;
222
+ return;
223
+ }
224
+ if (navigate) {
225
+ navigate(to);
226
+ return;
227
+ }
228
+ if (typeof window !== "undefined") {
229
+ window.location.href = to;
230
+ }
231
+ };
232
+ };
233
+
234
+ // src/chat/move-conversation-modal.tsx
235
+ import { useState, useEffect } from "react";
236
+ import {
237
+ Dialog,
238
+ DialogTitle,
239
+ DialogContent,
240
+ DialogActions,
241
+ Button,
242
+ List,
243
+ ListItem,
244
+ ListItemButton,
245
+ ListItemText,
246
+ ListItemIcon,
247
+ Typography,
248
+ Avatar,
249
+ Radio,
250
+ Box,
251
+ Divider
252
+ } from "@mui/material";
253
+ import { useTheme } from "@mui/material/styles";
254
+ import { jsx, jsxs } from "react/jsx-runtime";
255
+ var MoveConversationModal = ({
256
+ open,
257
+ onClose,
258
+ conversations,
259
+ currentProjectId = null
260
+ }) => {
261
+ const theme = useTheme();
262
+ const { projects, _hasHydrated, hydrate } = useProjectStore();
263
+ const { moveConversationToProject } = useConversationStore();
264
+ const [selectedProjectId, setSelectedProjectId] = useState(
265
+ currentProjectId
266
+ );
267
+ useEffect(() => {
268
+ if (open && !_hasHydrated) {
269
+ hydrate();
270
+ }
271
+ }, [open, _hasHydrated, hydrate]);
272
+ useEffect(() => {
273
+ setSelectedProjectId(currentProjectId);
274
+ }, [currentProjectId, open]);
275
+ const handleMove = async () => {
276
+ try {
277
+ await Promise.all(
278
+ conversations.map(
279
+ (conv) => moveConversationToProject(conv.id, selectedProjectId)
280
+ )
281
+ );
282
+ onClose();
283
+ } catch (error) {
284
+ debugLogger.error("Failed to move conversations", {
285
+ error: error instanceof Error ? error.message : String(error)
286
+ });
287
+ }
288
+ };
289
+ const conversationCount = conversations.length;
290
+ const isMultiple = conversationCount > 1;
291
+ return /* @__PURE__ */ jsxs(
292
+ Dialog,
293
+ {
294
+ open,
295
+ onClose,
296
+ maxWidth: "sm",
297
+ fullWidth: true,
298
+ PaperProps: {
299
+ sx: {
300
+ bgcolor: theme.palette.background.paper,
301
+ backgroundImage: "none"
302
+ }
303
+ },
304
+ children: [
305
+ /* @__PURE__ */ jsxs(DialogTitle, { children: [
306
+ "Move ",
307
+ isMultiple ? `${conversationCount} Conversations` : "Conversation"
308
+ ] }),
309
+ /* @__PURE__ */ jsxs(DialogContent, { sx: { px: 3 }, children: [
310
+ /* @__PURE__ */ jsx(Typography, { variant: "body2", color: "text.secondary", sx: { mb: 2 }, children: isMultiple ? `Select a project to move ${conversationCount} conversations to:` : `Select a project to move "${conversations[0]?.name}" to:` }),
311
+ /* @__PURE__ */ jsxs(List, { children: [
312
+ /* @__PURE__ */ jsx(ListItem, { disablePadding: true, children: /* @__PURE__ */ jsxs(
313
+ ListItemButton,
314
+ {
315
+ onClick: () => setSelectedProjectId(null),
316
+ selected: selectedProjectId === null,
317
+ children: [
318
+ /* @__PURE__ */ jsx(ListItemIcon, { children: /* @__PURE__ */ jsx(
319
+ Radio,
320
+ {
321
+ checked: selectedProjectId === null,
322
+ onChange: () => setSelectedProjectId(null),
323
+ size: "small"
324
+ }
325
+ ) }),
326
+ /* @__PURE__ */ jsx(ListItemIcon, { children: /* @__PURE__ */ jsx(
327
+ Avatar,
328
+ {
329
+ sx: {
330
+ bgcolor: theme.palette.grey[400],
331
+ width: 32,
332
+ height: 32
333
+ },
334
+ children: /* @__PURE__ */ jsx(Inbox, {})
335
+ }
336
+ ) }),
337
+ /* @__PURE__ */ jsx(
338
+ ListItemText,
339
+ {
340
+ primary: "No Project",
341
+ secondary: "Keep conversations ungrouped"
342
+ }
343
+ )
344
+ ]
345
+ }
346
+ ) }),
347
+ /* @__PURE__ */ jsx(Divider, { sx: { my: 1 } }),
348
+ projects.map((project) => /* @__PURE__ */ jsx(ListItem, { disablePadding: true, children: /* @__PURE__ */ jsxs(
349
+ ListItemButton,
350
+ {
351
+ onClick: () => setSelectedProjectId(project.id),
352
+ selected: selectedProjectId === project.id,
353
+ children: [
354
+ /* @__PURE__ */ jsx(ListItemIcon, { children: /* @__PURE__ */ jsx(
355
+ Radio,
356
+ {
357
+ checked: selectedProjectId === project.id,
358
+ onChange: () => setSelectedProjectId(project.id),
359
+ size: "small"
360
+ }
361
+ ) }),
362
+ /* @__PURE__ */ jsx(ListItemIcon, { children: /* @__PURE__ */ jsx(
363
+ Avatar,
364
+ {
365
+ sx: {
366
+ bgcolor: project.color,
367
+ width: 32,
368
+ height: 32
369
+ },
370
+ children: /* @__PURE__ */ jsx(Folder, {})
371
+ }
372
+ ) }),
373
+ /* @__PURE__ */ jsx(ListItemText, { primary: project.name, secondary: project.description })
374
+ ]
375
+ }
376
+ ) }, project.id)),
377
+ projects.length === 0 && /* @__PURE__ */ jsx(
378
+ Box,
379
+ {
380
+ sx: {
381
+ textAlign: "center",
382
+ py: 2,
383
+ color: theme.palette.text.secondary
384
+ },
385
+ children: /* @__PURE__ */ jsx(Typography, { variant: "body2", children: "No projects available. Create a project first to organize conversations." })
386
+ }
387
+ )
388
+ ] })
389
+ ] }),
390
+ /* @__PURE__ */ jsxs(DialogActions, { sx: { px: 3, pb: 2 }, children: [
391
+ /* @__PURE__ */ jsx(Button, { onClick: onClose, children: "Cancel" }),
392
+ /* @__PURE__ */ jsxs(
393
+ Button,
394
+ {
395
+ onClick: handleMove,
396
+ variant: "contained",
397
+ disabled: selectedProjectId === currentProjectId,
398
+ children: [
399
+ "Move ",
400
+ isMultiple ? "Conversations" : "Conversation"
401
+ ]
402
+ }
403
+ )
404
+ ] })
405
+ ]
406
+ }
407
+ );
408
+ };
409
+ var move_conversation_modal_default = MoveConversationModal;
410
+
411
+ // src/chat/simple-conversation-item.tsx
412
+ import { useState as useState2, useRef as useRef2, useEffect as useEffect2 } from "react";
413
+ import {
414
+ Box as Box2,
415
+ Typography as Typography2,
416
+ IconButton,
417
+ Menu,
418
+ MenuItem,
419
+ ListItemIcon as ListItemIcon2,
420
+ ListItemText as ListItemText2,
421
+ useMediaQuery,
422
+ TextField,
423
+ Dialog as Dialog2,
424
+ DialogTitle as DialogTitle2,
425
+ DialogContent as DialogContent2,
426
+ DialogActions as DialogActions2,
427
+ Button as Button2
428
+ } from "@mui/material";
429
+ import { useTheme as useTheme2, alpha } from "@mui/material/styles";
430
+ import { Fragment, jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
431
+ var SimpleConversationItem = ({
432
+ conversation,
433
+ isSelected,
434
+ onSelect,
435
+ onDelete,
436
+ onRename,
437
+ onMove,
438
+ projectColor,
439
+ snippet,
440
+ searchQuery,
441
+ onTouchDragStart,
442
+ onTouchDragMove,
443
+ onTouchDragEnd,
444
+ isTouchDragActive,
445
+ dense = false
446
+ }) => {
447
+ const theme = useTheme2();
448
+ const isMobile = useMediaQuery(theme.breakpoints.down("sm"));
449
+ const [anchorEl, setAnchorEl] = useState2(null);
450
+ const [isEditing, setIsEditing] = useState2(false);
451
+ const [editName, setEditName] = useState2(conversation.name);
452
+ const [isDragging, setIsDragging] = useState2(false);
453
+ const [isTouchDragging, setIsTouchDragging] = useState2(false);
454
+ const [showRenameDialog, setShowRenameDialog] = useState2(false);
455
+ const longPressTimeoutRef = useRef2(null);
456
+ const touchStartPointRef = useRef2(null);
457
+ const activeTouchIdRef = useRef2(null);
458
+ const suppressClickRef = useRef2(false);
459
+ const highlightText = (text, query) => {
460
+ if (!query || !query.trim()) {
461
+ return text;
462
+ }
463
+ const regex = new RegExp(`(${query.trim()})`, "gi");
464
+ const parts = text.split(regex);
465
+ return parts.map(
466
+ (part, index) => regex.test(part) ? /* @__PURE__ */ jsx2(
467
+ Box2,
468
+ {
469
+ component: "span",
470
+ sx: {
471
+ bgcolor: alpha(theme.palette.warning.main, 0.3),
472
+ color: theme.palette.text.primary,
473
+ fontWeight: 600,
474
+ borderRadius: 0.5,
475
+ px: 0.25
476
+ },
477
+ children: part
478
+ },
479
+ index
480
+ ) : part
481
+ );
482
+ };
483
+ const handleMenuOpen = (event) => {
484
+ event.stopPropagation();
485
+ event.preventDefault();
486
+ setAnchorEl(event.currentTarget);
487
+ };
488
+ const handleMenuClose = () => {
489
+ setAnchorEl(null);
490
+ };
491
+ const handleEdit = () => {
492
+ setEditName(conversation.name);
493
+ if (isMobile) {
494
+ setShowRenameDialog(true);
495
+ } else {
496
+ setIsEditing(true);
497
+ }
498
+ handleMenuClose();
499
+ };
500
+ const handleMove = () => {
501
+ if (onMove) {
502
+ onMove();
503
+ }
504
+ handleMenuClose();
505
+ };
506
+ const handleDelete = () => {
507
+ onDelete();
508
+ handleMenuClose();
509
+ };
510
+ const commitRename = () => {
511
+ const trimmed = editName.trim();
512
+ if (!trimmed) {
513
+ return;
514
+ }
515
+ if (trimmed !== conversation.name) {
516
+ onRename?.(trimmed);
517
+ }
518
+ setEditName(trimmed);
519
+ };
520
+ const handleSaveEdit = () => {
521
+ commitRename();
522
+ setIsEditing(false);
523
+ };
524
+ const handleCancelEdit = () => {
525
+ setIsEditing(false);
526
+ setEditName(conversation.name);
527
+ };
528
+ const handleDragStart = (e) => {
529
+ setIsDragging(true);
530
+ e.dataTransfer.setData("text/plain", conversation.id);
531
+ e.dataTransfer.effectAllowed = "move";
532
+ };
533
+ const handleDragEnd = () => {
534
+ setIsDragging(false);
535
+ };
536
+ const cancelLongPress = () => {
537
+ if (longPressTimeoutRef.current !== null) {
538
+ window.clearTimeout(longPressTimeoutRef.current);
539
+ longPressTimeoutRef.current = null;
540
+ }
541
+ };
542
+ const handleTouchStart = (e) => {
543
+ if (!isMobile || isEditing) return;
544
+ if (e.touches.length === 0) return;
545
+ const touch = e.touches[0];
546
+ touchStartPointRef.current = { x: touch.clientX, y: touch.clientY };
547
+ activeTouchIdRef.current = touch.identifier;
548
+ suppressClickRef.current = false;
549
+ cancelLongPress();
550
+ const initialTouch = touch;
551
+ longPressTimeoutRef.current = window.setTimeout(() => {
552
+ if (activeTouchIdRef.current !== null) {
553
+ setIsTouchDragging(true);
554
+ onTouchDragStart?.(conversation, initialTouch);
555
+ }
556
+ }, 350);
557
+ };
558
+ const handleTouchMove = (e) => {
559
+ if (!isMobile) return;
560
+ const targetTouch = activeTouchIdRef.current !== null ? Array.from(e.touches).find((t) => t.identifier === activeTouchIdRef.current) : e.touches[0];
561
+ if (!targetTouch) return;
562
+ if (isTouchDragging) {
563
+ if (e.cancelable) {
564
+ e.preventDefault();
565
+ }
566
+ onTouchDragMove?.(targetTouch);
567
+ return;
568
+ }
569
+ const startPoint = touchStartPointRef.current;
570
+ if (startPoint) {
571
+ const deltaX = Math.abs(targetTouch.clientX - startPoint.x);
572
+ const deltaY = Math.abs(targetTouch.clientY - startPoint.y);
573
+ if (deltaX > 8 || deltaY > 8) {
574
+ cancelLongPress();
575
+ }
576
+ }
577
+ };
578
+ const finalizeTouchDrag = (touch) => {
579
+ if (isTouchDragging) {
580
+ onTouchDragEnd?.(touch);
581
+ suppressClickRef.current = true;
582
+ }
583
+ setIsTouchDragging(false);
584
+ activeTouchIdRef.current = null;
585
+ touchStartPointRef.current = null;
586
+ cancelLongPress();
587
+ };
588
+ const handleTouchEnd = (e) => {
589
+ if (!isMobile) return;
590
+ const touch = activeTouchIdRef.current !== null ? Array.from(e.changedTouches).find(
591
+ (t) => t.identifier === activeTouchIdRef.current
592
+ ) : e.changedTouches[0];
593
+ finalizeTouchDrag(touch);
594
+ };
595
+ const handleTouchCancel = () => {
596
+ if (!isMobile) return;
597
+ finalizeTouchDrag();
598
+ };
599
+ useEffect2(() => {
600
+ if (!isTouchDragActive && isTouchDragging) {
601
+ setIsTouchDragging(false);
602
+ }
603
+ }, [isTouchDragActive, isTouchDragging]);
604
+ return /* @__PURE__ */ jsxs2(Fragment, { children: [
605
+ /* @__PURE__ */ jsxs2(
606
+ Box2,
607
+ {
608
+ "data-project-id": conversation.projectId ?? "__ungrouped",
609
+ draggable: !isMobile && !isEditing,
610
+ onDragStart: handleDragStart,
611
+ onDragEnd: handleDragEnd,
612
+ onTouchStart: handleTouchStart,
613
+ onTouchMove: handleTouchMove,
614
+ onTouchEnd: handleTouchEnd,
615
+ onTouchCancel: handleTouchCancel,
616
+ onClick: isEditing || isTouchDragging ? void 0 : (event) => {
617
+ if (suppressClickRef.current) {
618
+ suppressClickRef.current = false;
619
+ event.preventDefault();
620
+ event.stopPropagation();
621
+ return;
622
+ }
623
+ onSelect();
624
+ },
625
+ sx: {
626
+ display: "flex",
627
+ alignItems: "center",
628
+ px: 2,
629
+ py: dense ? 0.5 : 1.5,
630
+ mx: 1,
631
+ borderRadius: 1,
632
+ cursor: isEditing || isTouchDragging ? "default" : "pointer",
633
+ bgcolor: isSelected ? alpha(projectColor || theme.palette.primary.main, 0.15) : "transparent",
634
+ border: isSelected ? `1px solid ${alpha(projectColor || theme.palette.primary.main, 0.3)}` : "1px solid transparent",
635
+ opacity: isDragging || isTouchDragActive ? 0.55 : 1,
636
+ transition: "all 0.2s ease",
637
+ transform: isTouchDragActive ? "scale(0.98)" : "none",
638
+ boxShadow: isTouchDragActive ? `0 12px 24px ${alpha(theme.palette.common.black, 0.25)}` : void 0,
639
+ touchAction: isTouchDragActive ? "none" : void 0,
640
+ userSelect: isTouchDragging || isTouchDragActive ? "none" : void 0,
641
+ WebkitUserSelect: isTouchDragging || isTouchDragActive ? "none" : void 0,
642
+ "&:hover": !isEditing && !isTouchDragging ? {
643
+ bgcolor: alpha(theme.palette.text.primary, 0.04)
644
+ } : {},
645
+ // Better touch handling on mobile
646
+ ...isMobile && {
647
+ minHeight: dense ? 44 : 48,
648
+ // Larger touch target
649
+ userSelect: "none",
650
+ WebkitUserSelect: "none",
651
+ WebkitTouchCallout: "none",
652
+ "&:active": {
653
+ bgcolor: alpha(theme.palette.text.primary, 0.08)
654
+ }
655
+ }
656
+ },
657
+ children: [
658
+ !isMobile && !isEditing && /* @__PURE__ */ jsx2(
659
+ GripVertical,
660
+ {
661
+ size: 16,
662
+ color: theme.palette.text.disabled,
663
+ style: { marginRight: 4, cursor: "grab" }
664
+ }
665
+ ),
666
+ /* @__PURE__ */ jsxs2(Box2, { sx: { flex: 1, minWidth: 0 }, children: [
667
+ isEditing ? /* @__PURE__ */ jsx2(
668
+ TextField,
669
+ {
670
+ value: editName,
671
+ onChange: (e) => setEditName(e.target.value),
672
+ onBlur: handleSaveEdit,
673
+ onKeyDown: (e) => {
674
+ if (e.key === "Enter") {
675
+ handleSaveEdit();
676
+ } else if (e.key === "Escape") {
677
+ handleCancelEdit();
678
+ }
679
+ },
680
+ size: "small",
681
+ variant: "standard",
682
+ autoFocus: true,
683
+ fullWidth: true,
684
+ sx: {
685
+ "& .MuiInput-root": {
686
+ fontSize: "0.875rem"
687
+ }
688
+ }
689
+ }
690
+ ) : /* @__PURE__ */ jsx2(
691
+ Typography2,
692
+ {
693
+ variant: "body2",
694
+ sx: {
695
+ fontWeight: isSelected ? 600 : 400,
696
+ color: isSelected ? projectColor || theme.palette.primary.main : theme.palette.text.primary,
697
+ overflow: "hidden",
698
+ textOverflow: "ellipsis",
699
+ whiteSpace: "nowrap",
700
+ fontSize: "0.875rem"
701
+ },
702
+ children: highlightText(conversation.name, searchQuery)
703
+ }
704
+ ),
705
+ !isEditing && snippet && /* @__PURE__ */ jsx2(
706
+ Typography2,
707
+ {
708
+ variant: "caption",
709
+ sx: {
710
+ display: "-webkit-box",
711
+ WebkitLineClamp: 2,
712
+ WebkitBoxOrient: "vertical",
713
+ overflow: "hidden",
714
+ color: alpha(theme.palette.text.secondary, 0.9),
715
+ mt: 0.25,
716
+ lineHeight: 1.3,
717
+ fontSize: "0.72rem"
718
+ },
719
+ title: snippet,
720
+ children: highlightText(snippet, searchQuery)
721
+ }
722
+ )
723
+ ] }),
724
+ !isEditing && /* @__PURE__ */ jsx2(
725
+ IconButton,
726
+ {
727
+ onClick: handleMenuOpen,
728
+ size: "small",
729
+ sx: {
730
+ opacity: isMobile ? 1 : isSelected ? 1 : 0,
731
+ // Always visible on mobile
732
+ color: theme.palette.text.secondary,
733
+ ml: 1,
734
+ minWidth: 32,
735
+ minHeight: 32,
736
+ transition: "opacity 0.2s ease",
737
+ ".MuiBox-root:hover &": {
738
+ opacity: 1
739
+ },
740
+ // Larger touch target on mobile
741
+ ...isMobile && {
742
+ padding: 1,
743
+ "&:before": {
744
+ content: '""',
745
+ position: "absolute",
746
+ top: -8,
747
+ left: -8,
748
+ right: -8,
749
+ bottom: -8
750
+ }
751
+ }
752
+ },
753
+ children: /* @__PURE__ */ jsx2(MoreVertical, { size: 16 })
754
+ }
755
+ ),
756
+ /* @__PURE__ */ jsxs2(
757
+ Menu,
758
+ {
759
+ anchorEl,
760
+ open: Boolean(anchorEl),
761
+ onClose: handleMenuClose,
762
+ onClick: (e) => e.stopPropagation(),
763
+ transformOrigin: {
764
+ vertical: "top",
765
+ horizontal: "right"
766
+ },
767
+ anchorOrigin: {
768
+ vertical: "top",
769
+ horizontal: "right"
770
+ },
771
+ PaperProps: {
772
+ sx: {
773
+ // Larger menu items on mobile for easier touch
774
+ ...isMobile && {
775
+ "& .MuiMenuItem-root": {
776
+ minHeight: 48,
777
+ fontSize: "1rem"
778
+ }
779
+ }
780
+ }
781
+ },
782
+ children: [
783
+ onRename && /* @__PURE__ */ jsxs2(MenuItem, { onClick: handleEdit, children: [
784
+ /* @__PURE__ */ jsx2(ListItemIcon2, { children: /* @__PURE__ */ jsx2(Edit, { size: 16 }) }),
785
+ /* @__PURE__ */ jsx2(ListItemText2, { children: "Rename" })
786
+ ] }),
787
+ onMove && /* @__PURE__ */ jsxs2(MenuItem, { onClick: handleMove, children: [
788
+ /* @__PURE__ */ jsx2(ListItemIcon2, { children: /* @__PURE__ */ jsx2(MailOpen, { size: 16 }) }),
789
+ /* @__PURE__ */ jsx2(ListItemText2, { children: "Move to Project" })
790
+ ] }),
791
+ /* @__PURE__ */ jsxs2(MenuItem, { onClick: handleDelete, children: [
792
+ /* @__PURE__ */ jsx2(ListItemIcon2, { children: /* @__PURE__ */ jsx2(Trash, { size: 16 }) }),
793
+ /* @__PURE__ */ jsx2(ListItemText2, { children: "Delete" })
794
+ ] })
795
+ ]
796
+ }
797
+ )
798
+ ]
799
+ }
800
+ ),
801
+ isMobile && /* @__PURE__ */ jsxs2(
802
+ Dialog2,
803
+ {
804
+ open: showRenameDialog,
805
+ onClose: () => {
806
+ setShowRenameDialog(false);
807
+ setEditName(conversation.name);
808
+ },
809
+ fullWidth: true,
810
+ PaperProps: {
811
+ sx: {
812
+ borderRadius: 3,
813
+ pb: 1
814
+ }
815
+ },
816
+ children: [
817
+ /* @__PURE__ */ jsx2(DialogTitle2, { sx: { pb: 1 }, children: "Rename Conversation" }),
818
+ /* @__PURE__ */ jsx2(DialogContent2, { children: /* @__PURE__ */ jsx2(
819
+ TextField,
820
+ {
821
+ value: editName,
822
+ onChange: (e) => setEditName(e.target.value),
823
+ autoFocus: true,
824
+ fullWidth: true,
825
+ placeholder: "Enter a new name",
826
+ InputProps: {
827
+ sx: { fontSize: "1rem" }
828
+ }
829
+ }
830
+ ) }),
831
+ /* @__PURE__ */ jsxs2(DialogActions2, { sx: { px: 3, pb: 2 }, children: [
832
+ /* @__PURE__ */ jsx2(
833
+ Button2,
834
+ {
835
+ onClick: () => {
836
+ setShowRenameDialog(false);
837
+ setEditName(conversation.name);
838
+ },
839
+ children: "Cancel"
840
+ }
841
+ ),
842
+ /* @__PURE__ */ jsx2(
843
+ Button2,
844
+ {
845
+ onClick: () => {
846
+ commitRename();
847
+ setShowRenameDialog(false);
848
+ },
849
+ variant: "contained",
850
+ disabled: !editName.trim() || editName.trim() === conversation.name,
851
+ children: "Save"
852
+ }
853
+ )
854
+ ] })
855
+ ]
856
+ }
857
+ )
858
+ ] });
859
+ };
860
+ var simple_conversation_item_default = SimpleConversationItem;
861
+
862
+ // src/chat/sidebar/SidebarUserCard.tsx
863
+ import { Avatar as Avatar2, Box as Box3, IconButton as IconButton2, Tooltip, Typography as Typography3, alpha as alpha2 } from "@mui/material";
864
+ import { useTheme as useTheme3 } from "@mui/material/styles";
865
+
866
+ // src/chat/sidebar/useSidebarUser.ts
867
+ import { useCallback, useEffect as useEffect3, useMemo, useState as useState3 } from "react";
868
+ var BANDIT_AVATAR = "https://cdn.burtson.ai/images/bandit-head.png";
869
+ var optionalString = (value) => {
870
+ if (typeof value !== "string") return void 0;
871
+ const trimmed = value.trim();
872
+ return trimmed.length > 0 ? trimmed : void 0;
873
+ };
874
+ var deriveInitials = (value) => {
875
+ const sanitized = (value || "").trim();
876
+ if (!sanitized) return "B";
877
+ const words = sanitized.split(/\s+/).filter(Boolean);
878
+ if (words.length >= 2) {
879
+ const initials = `${words[0]?.charAt(0) ?? ""}${words[words.length - 1]?.charAt(0) ?? ""}`;
880
+ return (initials.trim() || sanitized.slice(0, 2)).toUpperCase();
881
+ }
882
+ const alphanumeric = sanitized.replace(/[^A-Za-z0-9]/g, "");
883
+ if (alphanumeric.length >= 1) return alphanumeric.slice(0, 2).toUpperCase();
884
+ return sanitized.slice(0, 2).toUpperCase();
885
+ };
886
+ function useSidebarUser() {
887
+ const { user } = useAuthenticationStore();
888
+ const [avatarSrc, setAvatarSrc] = useState3(BANDIT_AVATAR);
889
+ const claim = useCallback(
890
+ (key) => user ? optionalString(user[key]) : void 0,
891
+ [user]
892
+ );
893
+ const displayName = useMemo(() => {
894
+ if (!user) return void 0;
895
+ const candidates = [
896
+ optionalString(user.name),
897
+ optionalString(user.preferred_username),
898
+ user.given_name && user.family_name ? optionalString(`${user.given_name} ${user.family_name}`) : void 0,
899
+ claim("full_name"),
900
+ claim("displayName")
901
+ ];
902
+ return candidates.find(Boolean) ?? optionalString(user.email) ?? user.sub;
903
+ }, [user, claim]);
904
+ const secondaryText = useMemo(() => {
905
+ if (!user) return void 0;
906
+ const email = optionalString(user.email);
907
+ if (email && email !== displayName) return email;
908
+ const sub = optionalString(user.sub);
909
+ return sub && sub !== displayName ? sub : void 0;
910
+ }, [user, displayName]);
911
+ useEffect3(() => {
912
+ const fresh = readPersistedToken();
913
+ const store = useAuthenticationStore.getState();
914
+ if (fresh && fresh !== store.token) store.setToken(fresh);
915
+ }, []);
916
+ useEffect3(() => {
917
+ let active = true;
918
+ let objectUrl = null;
919
+ const resolve = async () => {
920
+ try {
921
+ const avatarId = claim("avatarUrl");
922
+ const fileStorageApiUrl = usePackageSettingsStore.getState().settings?.fileStorageApiUrl;
923
+ const token = useAuthenticationStore.getState().token;
924
+ if (avatarId && fileStorageApiUrl && token) {
925
+ const base = fileStorageApiUrl.replace(/\/$/, "");
926
+ const response = await fetch(
927
+ `${base}/app-asset/download/${encodeURIComponent(avatarId)}`,
928
+ { headers: { Authorization: `Bearer ${token}` } }
929
+ );
930
+ if (response.ok) {
931
+ const blob = await response.blob();
932
+ if (active) {
933
+ objectUrl = URL.createObjectURL(blob);
934
+ setAvatarSrc(objectUrl);
935
+ }
936
+ return;
937
+ }
938
+ }
939
+ } catch {
940
+ }
941
+ try {
942
+ const branding = await brandingService_default.getBranding();
943
+ if (active) setAvatarSrc(branding?.logoBase64 || BANDIT_AVATAR);
944
+ } catch (error) {
945
+ debugLogger.error("Failed to load branding avatar", {
946
+ error: error instanceof Error ? error.message : String(error)
947
+ });
948
+ if (active) setAvatarSrc(BANDIT_AVATAR);
949
+ }
950
+ };
951
+ void resolve();
952
+ return () => {
953
+ active = false;
954
+ if (objectUrl) URL.revokeObjectURL(objectUrl);
955
+ };
956
+ }, [claim]);
957
+ const label = displayName || user?.email || "Bandit";
958
+ return {
959
+ signedIn: Boolean(user),
960
+ displayName,
961
+ secondaryText,
962
+ avatarSrc,
963
+ initials: deriveInitials(label)
964
+ };
965
+ }
966
+
967
+ // src/chat/sidebar/SidebarUserCard.tsx
968
+ import { jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
969
+ function goHome(safeNavigate, preferencesHomeUrl) {
970
+ const homeUrl = preferencesHomeUrl?.trim() || usePackageSettingsStore.getState().settings?.homeUrl?.trim() || "";
971
+ if (homeUrl) {
972
+ window.location.href = homeUrl;
973
+ return;
974
+ }
975
+ if (isNativeShell()) {
976
+ safeNavigate("/chat");
977
+ return;
978
+ }
979
+ if (isStandalonePwa()) {
980
+ try {
981
+ sessionStorage.setItem("banditPwaStayOnHome", "true");
982
+ } catch {
983
+ }
984
+ window.location.href = "/?mode=home";
985
+ return;
986
+ }
987
+ window.location.href = "/";
988
+ }
989
+ var managementPathFor = (pathname) => pathname.startsWith("/playground") ? "/playground/management" : "/management";
990
+ var SidebarUserCard = ({ safeAreaBottom }) => {
991
+ const theme = useTheme3();
992
+ const user = useSidebarUser();
993
+ const safeNavigate = useSafeNavigate();
994
+ const { preferences } = usePreferencesStore();
995
+ const { showLimitedAdminPanel } = useFeatureVisibility();
996
+ const managementPath = managementPathFor(
997
+ typeof window === "undefined" ? "/" : window.location.pathname
998
+ );
999
+ const roundButton = {
1000
+ flexShrink: 0,
1001
+ width: 32,
1002
+ height: 32,
1003
+ border: `1px solid ${alpha2(theme.palette.divider, 0.8)}`,
1004
+ color: theme.palette.text.secondary,
1005
+ "&:hover": {
1006
+ color: theme.palette.text.primary,
1007
+ bgcolor: alpha2(theme.palette.text.primary, 0.06)
1008
+ },
1009
+ "&:focus-visible": {
1010
+ outline: `2px solid ${theme.palette.primary.main}`,
1011
+ outlineOffset: "2px"
1012
+ }
1013
+ };
1014
+ return /* @__PURE__ */ jsxs3(
1015
+ Box3,
1016
+ {
1017
+ sx: {
1018
+ mt: "auto",
1019
+ px: 1.5,
1020
+ py: 1.25,
1021
+ pb: safeAreaBottom ? `calc(${theme.spacing(1.25)} + env(safe-area-inset-bottom, 0px))` : 1.25,
1022
+ borderTop: `1px solid ${alpha2(theme.palette.divider, 0.6)}`,
1023
+ display: "flex",
1024
+ alignItems: "center",
1025
+ gap: 1
1026
+ },
1027
+ children: [
1028
+ /* @__PURE__ */ jsxs3(
1029
+ Box3,
1030
+ {
1031
+ component: user.signedIn ? "button" : "div",
1032
+ type: user.signedIn ? "button" : void 0,
1033
+ onClick: user.signedIn ? () => safeNavigate("/profile") : void 0,
1034
+ "aria-label": user.signedIn ? "Profile and account" : void 0,
1035
+ sx: {
1036
+ flex: 1,
1037
+ minWidth: 0,
1038
+ display: "flex",
1039
+ alignItems: "center",
1040
+ gap: 1.25,
1041
+ p: 0.5,
1042
+ m: -0.5,
1043
+ border: 0,
1044
+ borderRadius: 1,
1045
+ bgcolor: "transparent",
1046
+ color: "inherit",
1047
+ font: "inherit",
1048
+ textAlign: "left",
1049
+ cursor: user.signedIn ? "pointer" : "default",
1050
+ "&:hover": user.signedIn ? { bgcolor: alpha2(theme.palette.text.primary, 0.04) } : void 0,
1051
+ "&:focus-visible": {
1052
+ outline: `2px solid ${theme.palette.primary.main}`,
1053
+ outlineOffset: "-2px"
1054
+ }
1055
+ },
1056
+ children: [
1057
+ /* @__PURE__ */ jsx3(
1058
+ Avatar2,
1059
+ {
1060
+ src: user.avatarSrc,
1061
+ alt: "",
1062
+ sx: {
1063
+ width: 34,
1064
+ height: 34,
1065
+ fontSize: "0.9rem",
1066
+ bgcolor: alpha2(theme.palette.primary.main, 0.12),
1067
+ color: theme.palette.primary.main
1068
+ },
1069
+ children: user.initials
1070
+ }
1071
+ ),
1072
+ /* @__PURE__ */ jsxs3(Box3, { sx: { minWidth: 0, display: "flex", flexDirection: "column" }, children: [
1073
+ /* @__PURE__ */ jsx3(
1074
+ Typography3,
1075
+ {
1076
+ variant: "subtitle2",
1077
+ noWrap: true,
1078
+ sx: { fontWeight: 600, lineHeight: 1.3 },
1079
+ children: user.signedIn ? user.displayName : "Not signed in"
1080
+ }
1081
+ ),
1082
+ /* @__PURE__ */ jsx3(
1083
+ Typography3,
1084
+ {
1085
+ variant: "caption",
1086
+ noWrap: true,
1087
+ sx: { color: theme.palette.text.secondary, lineHeight: 1.3 },
1088
+ children: user.signedIn ? user.secondaryText || "Profile and account" : "Sign in to sync chats"
1089
+ }
1090
+ )
1091
+ ] })
1092
+ ]
1093
+ }
1094
+ ),
1095
+ /* @__PURE__ */ jsx3(Tooltip, { title: "Home", arrow: true, children: /* @__PURE__ */ jsx3(
1096
+ IconButton2,
1097
+ {
1098
+ "aria-label": "Home",
1099
+ onClick: () => goHome(safeNavigate, preferences.homeUrl),
1100
+ sx: roundButton,
1101
+ children: /* @__PURE__ */ jsx3(Home, { size: 16 })
1102
+ }
1103
+ ) }),
1104
+ user.signedIn && showLimitedAdminPanel() && /* @__PURE__ */ jsx3(Tooltip, { title: "Settings", arrow: true, children: /* @__PURE__ */ jsx3(
1105
+ IconButton2,
1106
+ {
1107
+ "aria-label": "Settings",
1108
+ onClick: () => safeNavigate(managementPath),
1109
+ sx: roundButton,
1110
+ children: /* @__PURE__ */ jsx3(Settings, { size: 16 })
1111
+ }
1112
+ ) }),
1113
+ user.signedIn && /* @__PURE__ */ jsx3(Tooltip, { title: "Sign out", arrow: true, children: /* @__PURE__ */ jsx3(
1114
+ IconButton2,
1115
+ {
1116
+ "aria-label": "Sign out",
1117
+ onClick: () => {
1118
+ authenticationService.clearToken();
1119
+ window.location.href = "/login";
1120
+ },
1121
+ sx: {
1122
+ ...roundButton,
1123
+ border: `1px solid ${alpha2(theme.palette.error.main, 0.4)}`,
1124
+ color: theme.palette.error.main,
1125
+ "&:hover": { bgcolor: alpha2(theme.palette.error.main, 0.1) }
1126
+ },
1127
+ children: /* @__PURE__ */ jsx3(LogOut, { size: 16 })
1128
+ }
1129
+ ) })
1130
+ ]
1131
+ }
1132
+ );
1133
+ };
1134
+
1135
+ // src/chat/sidebar/ProjectDialog.tsx
1136
+ import { useEffect as useEffect4, useState as useState4 } from "react";
1137
+ import {
1138
+ Box as Box4,
1139
+ Button as Button3,
1140
+ Dialog as Dialog3,
1141
+ DialogActions as DialogActions3,
1142
+ DialogContent as DialogContent3,
1143
+ DialogTitle as DialogTitle3,
1144
+ TextField as TextField2,
1145
+ alpha as alpha3
1146
+ } from "@mui/material";
1147
+ import { useTheme as useTheme4 } from "@mui/material/styles";
1148
+ import { jsx as jsx4, jsxs as jsxs4 } from "react/jsx-runtime";
1149
+ var ProjectDialog = ({
1150
+ open,
1151
+ onClose,
1152
+ project,
1153
+ onCreated
1154
+ }) => {
1155
+ const theme = useTheme4();
1156
+ const { createProject, renameProject, updateProjectColor, projects } = useProjectStore();
1157
+ const [name, setName] = useState4("");
1158
+ const [color, setColor] = useState4(PROJECT_COLORS[0]);
1159
+ const [saving, setSaving] = useState4(false);
1160
+ const [error, setError] = useState4(null);
1161
+ useEffect4(() => {
1162
+ if (!open) return;
1163
+ setName(project?.name ?? "");
1164
+ setColor(project?.color ?? PROJECT_COLORS[projects.length % PROJECT_COLORS.length]);
1165
+ setError(null);
1166
+ }, [open, project, projects.length]);
1167
+ const trimmed = name.trim();
1168
+ const canSave = trimmed.length > 0 && !saving;
1169
+ const save = async () => {
1170
+ if (!canSave) return;
1171
+ setSaving(true);
1172
+ setError(null);
1173
+ try {
1174
+ if (project) {
1175
+ if (trimmed !== project.name)
1176
+ await renameProject(project.id, trimmed, project.description);
1177
+ if (color !== project.color) await updateProjectColor(project.id, color);
1178
+ } else {
1179
+ const created = await createProject(trimmed, void 0, color);
1180
+ onCreated?.(created);
1181
+ }
1182
+ onClose();
1183
+ } catch (cause) {
1184
+ debugLogger.error("Saving the project failed", {
1185
+ error: cause instanceof Error ? cause.message : String(cause)
1186
+ });
1187
+ setError("The project could not be saved. Try again.");
1188
+ } finally {
1189
+ setSaving(false);
1190
+ }
1191
+ };
1192
+ return /* @__PURE__ */ jsxs4(Dialog3, { open, onClose, maxWidth: "xs", fullWidth: true, children: [
1193
+ /* @__PURE__ */ jsx4(DialogTitle3, { children: project ? "Edit project" : "New project" }),
1194
+ /* @__PURE__ */ jsxs4(DialogContent3, { sx: { display: "flex", flexDirection: "column", gap: 2 }, children: [
1195
+ /* @__PURE__ */ jsx4(
1196
+ TextField2,
1197
+ {
1198
+ autoFocus: true,
1199
+ label: "Name",
1200
+ value: name,
1201
+ onChange: (event) => setName(event.target.value),
1202
+ onKeyDown: (event) => {
1203
+ if (event.key === "Enter") {
1204
+ event.preventDefault();
1205
+ void save();
1206
+ }
1207
+ },
1208
+ error: Boolean(error),
1209
+ helperText: error ?? " ",
1210
+ fullWidth: true,
1211
+ size: "small",
1212
+ inputProps: { maxLength: 80 }
1213
+ }
1214
+ ),
1215
+ /* @__PURE__ */ jsx4(
1216
+ Box4,
1217
+ {
1218
+ role: "radiogroup",
1219
+ "aria-label": "Colour",
1220
+ sx: { display: "flex", gap: 1, flexWrap: "wrap" },
1221
+ children: PROJECT_COLORS.map((swatch) => {
1222
+ const selected = swatch === color;
1223
+ return /* @__PURE__ */ jsx4(
1224
+ Box4,
1225
+ {
1226
+ component: "button",
1227
+ type: "button",
1228
+ role: "radio",
1229
+ "aria-checked": selected,
1230
+ "aria-label": `Colour ${swatch}`,
1231
+ onClick: () => setColor(swatch),
1232
+ sx: {
1233
+ width: 28,
1234
+ height: 28,
1235
+ p: 0,
1236
+ borderRadius: "50%",
1237
+ border: `2px solid ${selected ? theme.palette.text.primary : "transparent"}`,
1238
+ bgcolor: swatch,
1239
+ cursor: "pointer",
1240
+ display: "grid",
1241
+ placeItems: "center",
1242
+ color: theme.palette.getContrastText(swatch),
1243
+ "&:focus-visible": {
1244
+ outline: `2px solid ${theme.palette.primary.main}`,
1245
+ outlineOffset: "2px"
1246
+ },
1247
+ "&:hover": { boxShadow: `0 0 0 3px ${alpha3(swatch, 0.35)}` }
1248
+ },
1249
+ children: selected && /* @__PURE__ */ jsx4(Check, { size: 14, "aria-hidden": true })
1250
+ },
1251
+ swatch
1252
+ );
1253
+ })
1254
+ }
1255
+ )
1256
+ ] }),
1257
+ /* @__PURE__ */ jsxs4(DialogActions3, { children: [
1258
+ /* @__PURE__ */ jsx4(Button3, { onClick: onClose, children: "Cancel" }),
1259
+ /* @__PURE__ */ jsx4(Button3, { variant: "contained", onClick: () => void save(), disabled: !canSave, children: project ? "Save" : "Create" })
1260
+ ] })
1261
+ ] });
1262
+ };
1263
+
1264
+ // src/chat/sidebar/recents.ts
1265
+ var BUCKET_LABELS = {
1266
+ today: "Today",
1267
+ week: "Previous 7 days",
1268
+ older: "Older"
1269
+ };
1270
+ var DAY_MS = 24 * 60 * 60 * 1e3;
1271
+ var asTime = (value) => {
1272
+ if (!value) return 0;
1273
+ const time = value instanceof Date ? value.getTime() : new Date(value).getTime();
1274
+ return Number.isNaN(time) ? 0 : time;
1275
+ };
1276
+ var lastActivity = (conversation) => asTime(conversation.updatedAt) || asTime(conversation.createdAt);
1277
+ var startOfDay = (now) => {
1278
+ const date = new Date(now);
1279
+ date.setHours(0, 0, 0, 0);
1280
+ return date.getTime();
1281
+ };
1282
+ function groupByRecency(conversations, now = Date.now()) {
1283
+ const today = startOfDay(now);
1284
+ const weekAgo = today - 7 * DAY_MS;
1285
+ const sorted = [...conversations].sort((a, b) => lastActivity(b) - lastActivity(a));
1286
+ const buckets = { today: [], week: [], older: [] };
1287
+ for (const conversation of sorted) {
1288
+ const time = lastActivity(conversation);
1289
+ if (time >= today) buckets.today.push(conversation);
1290
+ else if (time >= weekAgo) buckets.week.push(conversation);
1291
+ else buckets.older.push(conversation);
1292
+ }
1293
+ return ["today", "week", "older"].filter((id) => buckets[id].length > 0).map((id) => ({ id, label: BUCKET_LABELS[id], items: buckets[id] }));
1294
+ }
1295
+ var buildSnippet = (text, query, index) => {
1296
+ const start = Math.max(0, index - 40);
1297
+ const end = Math.min(text.length, index + query.length + 60);
1298
+ return text.slice(start, end).replace(/\s+/g, " ").trim();
1299
+ };
1300
+ function searchConversations(conversations, query) {
1301
+ const needle = query.trim().toLowerCase();
1302
+ if (!needle) return [];
1303
+ const matches = [];
1304
+ for (const conversation of conversations) {
1305
+ if (conversation.name.toLowerCase().includes(needle)) {
1306
+ matches.push({ conversation });
1307
+ continue;
1308
+ }
1309
+ for (const entry of conversation.history) {
1310
+ const body = `${entry.question || ""} ${entry.answer || ""}`;
1311
+ const index = body.toLowerCase().indexOf(needle);
1312
+ if (index !== -1) {
1313
+ matches.push({ conversation, snippet: buildSnippet(body, needle, index) });
1314
+ break;
1315
+ }
1316
+ }
1317
+ }
1318
+ return matches;
1319
+ }
1320
+ var listable = (conversations) => conversations.filter((conversation) => !conversation.incognito);
1321
+ function formatRelative(time, now = Date.now()) {
1322
+ if (!time) return "";
1323
+ const diff = Math.max(0, now - time);
1324
+ const minute = 60 * 1e3;
1325
+ const hour = 60 * minute;
1326
+ if (diff < minute) return "just now";
1327
+ if (diff < hour) return `${Math.floor(diff / minute)} min ago`;
1328
+ if (diff < DAY_MS) return `${Math.floor(diff / hour)} h ago`;
1329
+ const days = Math.floor((startOfDay(now) - startOfDay(time)) / DAY_MS);
1330
+ if (days <= 1) return "yesterday";
1331
+ if (days < 7) return `${days} days ago`;
1332
+ const date = new Date(time);
1333
+ const sameYear = date.getFullYear() === new Date(now).getFullYear();
1334
+ return date.toLocaleDateString(void 0, {
1335
+ month: "short",
1336
+ day: "numeric",
1337
+ ...sameYear ? {} : { year: "numeric" }
1338
+ });
1339
+ }
1340
+
1341
+ // src/chat/sidebar/SidebarProjects.tsx
1342
+ import { useMemo as useMemo2 } from "react";
1343
+ import { Box as Box6, IconButton as IconButton3, Tooltip as Tooltip2, Typography as Typography5 } from "@mui/material";
1344
+ import { useTheme as useTheme6 } from "@mui/material/styles";
1345
+
1346
+ // src/chat/sidebar/SectionRow.tsx
1347
+ import { forwardRef } from "react";
1348
+ import { Box as Box5, ButtonBase, Typography as Typography4, alpha as alpha4 } from "@mui/material";
1349
+ import { useTheme as useTheme5 } from "@mui/material/styles";
1350
+ import { jsx as jsx5, jsxs as jsxs5 } from "react/jsx-runtime";
1351
+ var IS_MAC = typeof navigator !== "undefined" && /Mac|iPhone|iPad/.test(navigator.platform ?? "");
1352
+ var shortcutLabel = (combo) => {
1353
+ if (IS_MAC) {
1354
+ return combo.map((key) => key === "mod" ? "\u2318" : key === "shift" ? "\u21E7" : key).join("");
1355
+ }
1356
+ return combo.map((key) => key === "mod" ? "Ctrl" : key === "shift" ? "Shift" : key).join("+");
1357
+ };
1358
+ var SidebarKbd = ({ children }) => {
1359
+ const theme = useTheme5();
1360
+ return /* @__PURE__ */ jsx5(
1361
+ Box5,
1362
+ {
1363
+ component: "kbd",
1364
+ "aria-hidden": true,
1365
+ sx: {
1366
+ ml: "auto",
1367
+ px: 0.6,
1368
+ py: 0.1,
1369
+ borderRadius: 0.75,
1370
+ border: `1px solid ${alpha4(theme.palette.text.primary, 0.14)}`,
1371
+ color: theme.palette.text.secondary,
1372
+ fontFamily: "inherit",
1373
+ fontSize: "0.68rem",
1374
+ lineHeight: 1.4,
1375
+ whiteSpace: "nowrap",
1376
+ opacity: 0.9
1377
+ },
1378
+ children
1379
+ }
1380
+ );
1381
+ };
1382
+ var SidebarCaption = ({
1383
+ children,
1384
+ action,
1385
+ component = "h2"
1386
+ }) => {
1387
+ const theme = useTheme5();
1388
+ return /* @__PURE__ */ jsxs5(
1389
+ Box5,
1390
+ {
1391
+ sx: {
1392
+ display: "flex",
1393
+ alignItems: "center",
1394
+ gap: 1,
1395
+ px: 2,
1396
+ pt: 1.5,
1397
+ pb: 0.5,
1398
+ minHeight: 32
1399
+ },
1400
+ children: [
1401
+ /* @__PURE__ */ jsx5(
1402
+ Typography4,
1403
+ {
1404
+ component,
1405
+ sx: {
1406
+ m: 0,
1407
+ flex: 1,
1408
+ color: theme.palette.text.secondary,
1409
+ fontSize: "0.7rem",
1410
+ fontWeight: 600,
1411
+ letterSpacing: "0.5px",
1412
+ textTransform: "uppercase",
1413
+ lineHeight: 1.4
1414
+ },
1415
+ children
1416
+ }
1417
+ ),
1418
+ action
1419
+ ]
1420
+ }
1421
+ );
1422
+ };
1423
+ var SectionRow = forwardRef(function SectionRow2({
1424
+ icon,
1425
+ label,
1426
+ trailing,
1427
+ active = false,
1428
+ href,
1429
+ external,
1430
+ onClick,
1431
+ size = "regular",
1432
+ swatch,
1433
+ ...rest
1434
+ }, ref) {
1435
+ const theme = useTheme5();
1436
+ const anchorProps = href ? {
1437
+ component: "a",
1438
+ href,
1439
+ ...external ? { rel: "noopener" } : {}
1440
+ } : { component: "button", type: "button" };
1441
+ return /* @__PURE__ */ jsxs5(
1442
+ ButtonBase,
1443
+ {
1444
+ ref,
1445
+ ...anchorProps,
1446
+ onClick,
1447
+ "aria-current": active ? "page" : void 0,
1448
+ "aria-label": rest["aria-label"],
1449
+ "data-section": rest["data-section"],
1450
+ "data-external": external ? "" : void 0,
1451
+ sx: {
1452
+ width: "calc(100% - 16px)",
1453
+ mx: 1,
1454
+ minHeight: size === "touch" ? 44 : 36,
1455
+ px: 1.25,
1456
+ py: 0.5,
1457
+ display: "flex",
1458
+ alignItems: "center",
1459
+ justifyContent: "flex-start",
1460
+ gap: 1.25,
1461
+ borderRadius: 1,
1462
+ textAlign: "left",
1463
+ textDecoration: "none",
1464
+ font: "inherit",
1465
+ fontSize: "0.875rem",
1466
+ fontWeight: active ? 600 : 500,
1467
+ color: active ? theme.palette.text.primary : theme.palette.text.secondary,
1468
+ bgcolor: active ? alpha4(theme.palette.text.primary, 0.08) : "transparent",
1469
+ transition: theme.transitions.create(["background-color", "color"], {
1470
+ duration: theme.transitions.duration.shorter
1471
+ }),
1472
+ "@media (pointer: coarse)": { minHeight: 44 },
1473
+ "&:hover": {
1474
+ color: theme.palette.text.primary,
1475
+ bgcolor: alpha4(theme.palette.text.primary, active ? 0.1 : 0.04)
1476
+ },
1477
+ "&:focus-visible": {
1478
+ outline: `2px solid ${theme.palette.primary.main}`,
1479
+ outlineOffset: "-2px"
1480
+ },
1481
+ "& svg": { flexShrink: 0 }
1482
+ },
1483
+ children: [
1484
+ swatch ? /* @__PURE__ */ jsx5(
1485
+ Box5,
1486
+ {
1487
+ "aria-hidden": true,
1488
+ sx: {
1489
+ width: 10,
1490
+ height: 10,
1491
+ mx: "4px",
1492
+ borderRadius: "50%",
1493
+ bgcolor: swatch,
1494
+ flexShrink: 0
1495
+ }
1496
+ }
1497
+ ) : icon,
1498
+ /* @__PURE__ */ jsx5(
1499
+ Box5,
1500
+ {
1501
+ component: "span",
1502
+ sx: {
1503
+ flex: 1,
1504
+ minWidth: 0,
1505
+ overflow: "hidden",
1506
+ textOverflow: "ellipsis",
1507
+ whiteSpace: "nowrap"
1508
+ },
1509
+ children: label
1510
+ }
1511
+ ),
1512
+ trailing
1513
+ ]
1514
+ }
1515
+ );
1516
+ });
1517
+
1518
+ // src/chat/sidebar/SidebarProjects.tsx
1519
+ import { jsx as jsx6, jsxs as jsxs6 } from "react/jsx-runtime";
1520
+ var SIDEBAR_PROJECT_LIMIT = 6;
1521
+ function summarizeProjects(projects, conversations) {
1522
+ return projects.map((project) => {
1523
+ const chats = conversations.filter((c) => c.projectId === project.id);
1524
+ const newest = chats.reduce((max, c) => Math.max(max, lastActivity(c)), 0);
1525
+ return {
1526
+ project,
1527
+ chatCount: chats.length,
1528
+ activeAt: newest || project.updatedAt.getTime()
1529
+ };
1530
+ }).sort((a, b) => b.activeAt - a.activeAt || a.project.order - b.project.order);
1531
+ }
1532
+ var SidebarProjects = ({
1533
+ activeProjectId,
1534
+ onOpenProject,
1535
+ onAllProjects,
1536
+ onNewProject,
1537
+ size
1538
+ }) => {
1539
+ const theme = useTheme6();
1540
+ const projects = useProjectStore((state) => state.projects);
1541
+ const conversations = useConversationStore((state) => state.conversations);
1542
+ const summaries = useMemo2(
1543
+ () => summarizeProjects(projects, listable(conversations)),
1544
+ [projects, conversations]
1545
+ );
1546
+ const shown = summaries.slice(0, SIDEBAR_PROJECT_LIMIT);
1547
+ return /* @__PURE__ */ jsxs6(Box6, { component: "section", "aria-labelledby": "bandit-sidebar-projects", children: [
1548
+ /* @__PURE__ */ jsx6(
1549
+ SidebarCaption,
1550
+ {
1551
+ action: /* @__PURE__ */ jsx6(Tooltip2, { title: "New project", arrow: true, children: /* @__PURE__ */ jsx6(
1552
+ IconButton3,
1553
+ {
1554
+ size: "small",
1555
+ "aria-label": "New project",
1556
+ onClick: onNewProject,
1557
+ sx: { color: theme.palette.text.secondary, width: 28, height: 28 },
1558
+ children: /* @__PURE__ */ jsx6(Plus, { size: 16 })
1559
+ }
1560
+ ) }),
1561
+ children: /* @__PURE__ */ jsx6("span", { id: "bandit-sidebar-projects", children: "Projects" })
1562
+ }
1563
+ ),
1564
+ shown.length === 0 && /* @__PURE__ */ jsx6(
1565
+ Typography5,
1566
+ {
1567
+ variant: "caption",
1568
+ sx: { display: "block", px: 2.25, pb: 1, color: theme.palette.text.secondary },
1569
+ children: "No projects yet."
1570
+ }
1571
+ ),
1572
+ shown.map(({ project, chatCount }) => /* @__PURE__ */ jsx6(
1573
+ SectionRow,
1574
+ {
1575
+ "data-section": `project:${project.id}`,
1576
+ swatch: project.color || theme.palette.text.disabled,
1577
+ label: project.name,
1578
+ size,
1579
+ active: activeProjectId === project.id,
1580
+ onClick: () => onOpenProject(project.id),
1581
+ trailing: chatCount > 0 ? /* @__PURE__ */ jsx6(
1582
+ Typography5,
1583
+ {
1584
+ component: "span",
1585
+ variant: "caption",
1586
+ "aria-label": `${chatCount} ${chatCount === 1 ? "chat" : "chats"}`,
1587
+ sx: {
1588
+ color: theme.palette.text.disabled,
1589
+ fontVariantNumeric: "tabular-nums"
1590
+ },
1591
+ children: chatCount
1592
+ }
1593
+ ) : null
1594
+ },
1595
+ project.id
1596
+ )),
1597
+ summaries.length > SIDEBAR_PROJECT_LIMIT && /* @__PURE__ */ jsx6(
1598
+ SectionRow,
1599
+ {
1600
+ "data-section": "all-projects",
1601
+ label: `All projects (${summaries.length})`,
1602
+ size,
1603
+ onClick: onAllProjects,
1604
+ icon: /* @__PURE__ */ jsx6(Box6, { "aria-hidden": true, sx: { width: 18 } })
1605
+ }
1606
+ )
1607
+ ] });
1608
+ };
1609
+
1610
+ // src/chat/sidebar/SidebarSections.tsx
1611
+ import { Box as Box7 } from "@mui/material";
1612
+ import { jsx as jsx7, jsxs as jsxs7 } from "react/jsx-runtime";
1613
+ var NEW_CHAT_SHORTCUT = ["mod", "shift", "O"];
1614
+ var SEARCH_SHORTCUT = ["mod", "K"];
1615
+ var TOGGLE_SIDEBAR_SHORTCUT = ["mod", "shift", "S"];
1616
+ var useNoSections = () => [];
1617
+ function useHostSections() {
1618
+ const useSections = usePackageSettingsStore(
1619
+ (state) => state.settings?.navigation?.useSections
1620
+ );
1621
+ return (useSections ?? useNoSections)();
1622
+ }
1623
+ var isPlainLeftClick = (event) => event.button === 0 && !event.metaKey && !event.ctrlKey && !event.shiftKey && !event.altKey;
1624
+ var SidebarSections = ({
1625
+ onNewChat,
1626
+ onSearch,
1627
+ searchOpen,
1628
+ onProjects,
1629
+ projectsActive,
1630
+ showHints = false,
1631
+ size = "regular",
1632
+ onAfterNavigate
1633
+ }) => {
1634
+ const hostSections = useHostSections();
1635
+ const safeNavigate = useSafeNavigate();
1636
+ const iconSize = 18;
1637
+ const follow = (section) => (event) => {
1638
+ if (!isPlainLeftClick(event)) return;
1639
+ section.onSelect?.(event);
1640
+ if (event.defaultPrevented) {
1641
+ onAfterNavigate?.();
1642
+ return;
1643
+ }
1644
+ if (section.external) {
1645
+ onAfterNavigate?.();
1646
+ return;
1647
+ }
1648
+ event.preventDefault();
1649
+ safeNavigate(section.href);
1650
+ onAfterNavigate?.();
1651
+ };
1652
+ return /* @__PURE__ */ jsxs7(
1653
+ Box7,
1654
+ {
1655
+ component: "nav",
1656
+ "aria-label": "Chat navigation",
1657
+ sx: { display: "flex", flexDirection: "column", gap: 0.25, pt: 0.5, pb: 1 },
1658
+ children: [
1659
+ /* @__PURE__ */ jsx7(
1660
+ SectionRow,
1661
+ {
1662
+ "data-section": "new-chat",
1663
+ icon: /* @__PURE__ */ jsx7(MessageSquarePlus, { size: iconSize }),
1664
+ label: "New chat",
1665
+ size,
1666
+ onClick: onNewChat,
1667
+ trailing: showHints ? /* @__PURE__ */ jsx7(SidebarKbd, { children: shortcutLabel(NEW_CHAT_SHORTCUT) }) : null
1668
+ }
1669
+ ),
1670
+ /* @__PURE__ */ jsx7(
1671
+ SectionRow,
1672
+ {
1673
+ "data-section": "search",
1674
+ icon: /* @__PURE__ */ jsx7(Search, { size: iconSize }),
1675
+ label: "Search chats",
1676
+ size,
1677
+ active: searchOpen,
1678
+ onClick: onSearch,
1679
+ "aria-label": searchOpen ? "Close search" : "Search chats",
1680
+ trailing: showHints ? /* @__PURE__ */ jsx7(SidebarKbd, { children: shortcutLabel(SEARCH_SHORTCUT) }) : null
1681
+ }
1682
+ ),
1683
+ /* @__PURE__ */ jsx7(
1684
+ SectionRow,
1685
+ {
1686
+ "data-section": "projects",
1687
+ icon: /* @__PURE__ */ jsx7(Folder, { size: iconSize }),
1688
+ label: "Projects",
1689
+ size,
1690
+ active: projectsActive,
1691
+ onClick: onProjects
1692
+ }
1693
+ ),
1694
+ hostSections.map((section) => /* @__PURE__ */ jsx7(
1695
+ SectionRow,
1696
+ {
1697
+ "data-section": section.id,
1698
+ icon: section.icon,
1699
+ label: section.label,
1700
+ size,
1701
+ href: section.href,
1702
+ external: section.external,
1703
+ active: section.active,
1704
+ onClick: follow(section)
1705
+ },
1706
+ section.id
1707
+ ))
1708
+ ]
1709
+ }
1710
+ );
1711
+ };
1712
+
1713
+ export {
1714
+ brandingService_default,
1715
+ isNativeShell,
1716
+ isStandalonePwa,
1717
+ useSafeNavigate,
1718
+ move_conversation_modal_default,
1719
+ simple_conversation_item_default,
1720
+ managementPathFor,
1721
+ SidebarUserCard,
1722
+ ProjectDialog,
1723
+ lastActivity,
1724
+ groupByRecency,
1725
+ searchConversations,
1726
+ listable,
1727
+ formatRelative,
1728
+ shortcutLabel,
1729
+ SidebarCaption,
1730
+ summarizeProjects,
1731
+ SidebarProjects,
1732
+ TOGGLE_SIDEBAR_SHORTCUT,
1733
+ useHostSections,
1734
+ SidebarSections,
1735
+ SIDEBAR_WIDTH,
1736
+ writePersistedCollapsed,
1737
+ initialSidebarOpen,
1738
+ useSidebarStore,
1739
+ syncViewWithUrl,
1740
+ useSectionsLayout
1741
+ };
1742
+ //# sourceMappingURL=chunk-5WCKKD3S.mjs.map