@polderlabs/bizar 4.4.10 → 4.4.12
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/bizar-dash/dist/assets/{main-Nq8Dq3VR.css → main-BKXEqU1w.css} +1 -1
- package/bizar-dash/dist/assets/main-EK_fzXn_.js +352 -0
- package/bizar-dash/dist/assets/main-EK_fzXn_.js.map +1 -0
- package/bizar-dash/dist/assets/mobile-Dl1q7Cyq.js.map +1 -1
- package/bizar-dash/dist/index.html +2 -2
- package/bizar-dash/src/server/api.mjs +2 -0
- package/bizar-dash/src/server/minimax.mjs +352 -0
- package/bizar-dash/src/server/mods-loader.mjs +169 -1
- package/bizar-dash/src/server/routes/_shared.mjs +15 -0
- package/bizar-dash/src/server/routes/minimax.mjs +140 -0
- package/bizar-dash/src/web/App.tsx +2 -0
- package/bizar-dash/src/web/components/Topbar.tsx +2 -0
- package/bizar-dash/src/web/lib/types.ts +12 -0
- package/bizar-dash/src/web/main.tsx +1 -0
- package/bizar-dash/src/web/styles/minimax-usage.css +371 -0
- package/bizar-dash/src/web/views/MiniMaxUsage.tsx +543 -0
- package/cli/bin.mjs +39 -6
- package/cli/provision.mjs +182 -2
- package/package.json +1 -1
- package/bizar-dash/dist/assets/main-CEazNxxy.js +0 -347
- package/bizar-dash/dist/assets/main-CEazNxxy.js.map +0 -1
|
@@ -1,347 +0,0 @@
|
|
|
1
|
-
var Zt=Object.defineProperty;var ea=(s,t,a)=>t in s?Zt(s,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):s[t]=a;var zs=(s,t,a)=>ea(s,typeof t!="symbol"?t+"":t,a);import{c as Z,r,a as A,j as e,R as de,C as Vs,F as Ue,b as Ae,d as He,M as Ve,B as Ee,S as Be,A as ze,e as Te,f as Xe,H as ns,g as ft,h as Oe,i as ae,u as ke,P as pe,k as z,l as ce,X as $e,m as sa,T as De,n as ks,I as Ns,o as ve,p as je,q as Qe,s as vt,t as ye,v as Ws,w as ta,E as aa,x as Ks,y as na,z as Fe,D as is,G as ia,J as la,K as ra,L as oa,N as Ze,O as yt,Q as Gs,U as ds,V as bt,W as ca,Y as kt,Z as Nt,_ as wt,$ as js,a0 as da,a1 as ma,a2 as ha,a3 as ua,a4 as ws,a5 as pa,a6 as at,a7 as xa,a8 as Je,a9 as nt,aa as ga,ab as ja,ac as fa,ad as Ss,ae as ts,af as Ys,ag as va,ah as ya,ai as ba,aj as ka,ak as Na,al as wa,am as Sa,an as Ca,ao as za,ap as Ta}from"./mobile-Dl1q7Cyq.js";/**
|
|
2
|
-
* @license lucide-react v0.460.0 - ISC
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the ISC license.
|
|
5
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
-
*/const fs=Z("ArchiveRestore",[["rect",{width:"20",height:"5",x:"2",y:"3",rx:"1",key:"1wp1u1"}],["path",{d:"M4 8v11a2 2 0 0 0 2 2h2",key:"tvwodi"}],["path",{d:"M20 8v11a2 2 0 0 1-2 2h-2",key:"1gkqxj"}],["path",{d:"m9 15 3-3 3 3",key:"1pd0qc"}],["path",{d:"M12 12v9",key:"192myk"}]]);/**
|
|
7
|
-
* @license lucide-react v0.460.0 - ISC
|
|
8
|
-
*
|
|
9
|
-
* This source code is licensed under the ISC license.
|
|
10
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
11
|
-
*/const Ma=Z("ArrowDown",[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]]);/**
|
|
12
|
-
* @license lucide-react v0.460.0 - ISC
|
|
13
|
-
*
|
|
14
|
-
* This source code is licensed under the ISC license.
|
|
15
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
16
|
-
*/const St=Z("ArrowLeft",[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]);/**
|
|
17
|
-
* @license lucide-react v0.460.0 - ISC
|
|
18
|
-
*
|
|
19
|
-
* This source code is licensed under the ISC license.
|
|
20
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
21
|
-
*/const Ct=Z("ArrowUp",[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]]);/**
|
|
22
|
-
* @license lucide-react v0.460.0 - ISC
|
|
23
|
-
*
|
|
24
|
-
* This source code is licensed under the ISC license.
|
|
25
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
26
|
-
*/const Aa=Z("Book",[["path",{d:"M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H19a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1H6.5a1 1 0 0 1 0-5H20",key:"k3hazp"}]]);/**
|
|
27
|
-
* @license lucide-react v0.460.0 - ISC
|
|
28
|
-
*
|
|
29
|
-
* This source code is licensed under the ISC license.
|
|
30
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
31
|
-
*/const $a=Z("Brain",[["path",{d:"M12 5a3 3 0 1 0-5.997.125 4 4 0 0 0-2.526 5.77 4 4 0 0 0 .556 6.588A4 4 0 1 0 12 18Z",key:"l5xja"}],["path",{d:"M12 5a3 3 0 1 1 5.997.125 4 4 0 0 1 2.526 5.77 4 4 0 0 1-.556 6.588A4 4 0 1 1 12 18Z",key:"ep3f8r"}],["path",{d:"M15 13a4.5 4.5 0 0 1-3-4 4.5 4.5 0 0 1-3 4",key:"1p4c4q"}],["path",{d:"M17.599 6.5a3 3 0 0 0 .399-1.375",key:"tmeiqw"}],["path",{d:"M6.003 5.125A3 3 0 0 0 6.401 6.5",key:"105sqy"}],["path",{d:"M3.477 10.896a4 4 0 0 1 .585-.396",key:"ql3yin"}],["path",{d:"M19.938 10.5a4 4 0 0 1 .585.396",key:"1qfode"}],["path",{d:"M6 18a4 4 0 0 1-1.967-.516",key:"2e4loj"}],["path",{d:"M19.967 17.484A4 4 0 0 1 18 18",key:"159ez6"}]]);/**
|
|
32
|
-
* @license lucide-react v0.460.0 - ISC
|
|
33
|
-
*
|
|
34
|
-
* This source code is licensed under the ISC license.
|
|
35
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
36
|
-
*/const zt=Z("Calendar",[["path",{d:"M8 2v4",key:"1cmpym"}],["path",{d:"M16 2v4",key:"4m81vk"}],["rect",{width:"18",height:"18",x:"3",y:"4",rx:"2",key:"1hopcy"}],["path",{d:"M3 10h18",key:"8toen8"}]]);/**
|
|
37
|
-
* @license lucide-react v0.460.0 - ISC
|
|
38
|
-
*
|
|
39
|
-
* This source code is licensed under the ISC license.
|
|
40
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
41
|
-
*/const Ps=Z("Check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);/**
|
|
42
|
-
* @license lucide-react v0.460.0 - ISC
|
|
43
|
-
*
|
|
44
|
-
* This source code is licensed under the ISC license.
|
|
45
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
46
|
-
*/const Ia=Z("ChevronLeft",[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]]);/**
|
|
47
|
-
* @license lucide-react v0.460.0 - ISC
|
|
48
|
-
*
|
|
49
|
-
* This source code is licensed under the ISC license.
|
|
50
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
51
|
-
*/const Ra=Z("CircleCheckBig",[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]]);/**
|
|
52
|
-
* @license lucide-react v0.460.0 - ISC
|
|
53
|
-
*
|
|
54
|
-
* This source code is licensed under the ISC license.
|
|
55
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
56
|
-
*/const it=Z("CirclePause",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"10",x2:"10",y1:"15",y2:"9",key:"c1nkhi"}],["line",{x1:"14",x2:"14",y1:"15",y2:"9",key:"h65svq"}]]);/**
|
|
57
|
-
* @license lucide-react v0.460.0 - ISC
|
|
58
|
-
*
|
|
59
|
-
* This source code is licensed under the ISC license.
|
|
60
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
61
|
-
*/const Es=Z("CirclePlay",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polygon",{points:"10 8 16 12 10 16 10 8",key:"1cimsy"}]]);/**
|
|
62
|
-
* @license lucide-react v0.460.0 - ISC
|
|
63
|
-
*
|
|
64
|
-
* This source code is licensed under the ISC license.
|
|
65
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
66
|
-
*/const Tt=Z("CircleX",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]]);/**
|
|
67
|
-
* @license lucide-react v0.460.0 - ISC
|
|
68
|
-
*
|
|
69
|
-
* This source code is licensed under the ISC license.
|
|
70
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
71
|
-
*/const Da=Z("Circle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);/**
|
|
72
|
-
* @license lucide-react v0.460.0 - ISC
|
|
73
|
-
*
|
|
74
|
-
* This source code is licensed under the ISC license.
|
|
75
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
76
|
-
*/const Ts=Z("Cpu",[["rect",{width:"16",height:"16",x:"4",y:"4",rx:"2",key:"14l7u7"}],["rect",{width:"6",height:"6",x:"9",y:"9",rx:"1",key:"5aljv4"}],["path",{d:"M15 2v2",key:"13l42r"}],["path",{d:"M15 20v2",key:"15mkzm"}],["path",{d:"M2 15h2",key:"1gxd5l"}],["path",{d:"M2 9h2",key:"1bbxkp"}],["path",{d:"M20 15h2",key:"19e6y8"}],["path",{d:"M20 9h2",key:"19tzq7"}],["path",{d:"M9 2v2",key:"165o2o"}],["path",{d:"M9 20v2",key:"i2bqo8"}]]);/**
|
|
77
|
-
* @license lucide-react v0.460.0 - ISC
|
|
78
|
-
*
|
|
79
|
-
* This source code is licensed under the ISC license.
|
|
80
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
81
|
-
*/const Js=Z("Database",[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5V19A9 3 0 0 0 21 19V5",key:"1wlel7"}],["path",{d:"M3 12A9 3 0 0 0 21 12",key:"mv7ke4"}]]);/**
|
|
82
|
-
* @license lucide-react v0.460.0 - ISC
|
|
83
|
-
*
|
|
84
|
-
* This source code is licensed under the ISC license.
|
|
85
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
86
|
-
*/const La=Z("Diamond",[["path",{d:"M2.7 10.3a2.41 2.41 0 0 0 0 3.41l7.59 7.59a2.41 2.41 0 0 0 3.41 0l7.59-7.59a2.41 2.41 0 0 0 0-3.41l-7.59-7.59a2.41 2.41 0 0 0-3.41 0Z",key:"1f1r0c"}]]);/**
|
|
87
|
-
* @license lucide-react v0.460.0 - ISC
|
|
88
|
-
*
|
|
89
|
-
* This source code is licensed under the ISC license.
|
|
90
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
91
|
-
*/const Le=Z("Download",[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"7 10 12 15 17 10",key:"2ggqvy"}],["line",{x1:"12",x2:"12",y1:"15",y2:"3",key:"1vk2je"}]]);/**
|
|
92
|
-
* @license lucide-react v0.460.0 - ISC
|
|
93
|
-
*
|
|
94
|
-
* This source code is licensed under the ISC license.
|
|
95
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
96
|
-
*/const Pa=Z("Ellipsis",[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"19",cy:"12",r:"1",key:"1wjl8i"}],["circle",{cx:"5",cy:"12",r:"1",key:"1pcz8c"}]]);/**
|
|
97
|
-
* @license lucide-react v0.460.0 - ISC
|
|
98
|
-
*
|
|
99
|
-
* This source code is licensed under the ISC license.
|
|
100
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
101
|
-
*/const lt=Z("EyeOff",[["path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49",key:"ct8e1f"}],["path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242",key:"151rxh"}],["path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143",key:"13bj9a"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);/**
|
|
102
|
-
* @license lucide-react v0.460.0 - ISC
|
|
103
|
-
*
|
|
104
|
-
* This source code is licensed under the ISC license.
|
|
105
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
106
|
-
*/const ls=Z("Eye",[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);/**
|
|
107
|
-
* @license lucide-react v0.460.0 - ISC
|
|
108
|
-
*
|
|
109
|
-
* This source code is licensed under the ISC license.
|
|
110
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
111
|
-
*/const Xs=Z("FileCode2",[["path",{d:"M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4",key:"1pf5j1"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"m5 12-3 3 3 3",key:"oke12k"}],["path",{d:"m9 18 3-3-3-3",key:"112psh"}]]);/**
|
|
112
|
-
* @license lucide-react v0.460.0 - ISC
|
|
113
|
-
*
|
|
114
|
-
* This source code is licensed under the ISC license.
|
|
115
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
116
|
-
*/const Ea=Z("FileCode",[["path",{d:"M10 12.5 8 15l2 2.5",key:"1tg20x"}],["path",{d:"m14 12.5 2 2.5-2 2.5",key:"yinavb"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7z",key:"1mlx9k"}]]);/**
|
|
117
|
-
* @license lucide-react v0.460.0 - ISC
|
|
118
|
-
*
|
|
119
|
-
* This source code is licensed under the ISC license.
|
|
120
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
121
|
-
*/const Ba=Z("File",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}]]);/**
|
|
122
|
-
* @license lucide-react v0.460.0 - ISC
|
|
123
|
-
*
|
|
124
|
-
* This source code is licensed under the ISC license.
|
|
125
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
126
|
-
*/const Oa=Z("Filter",[["polygon",{points:"22 3 2 3 10 12.46 10 19 14 21 14 12.46 22 3",key:"1yg77f"}]]);/**
|
|
127
|
-
* @license lucide-react v0.460.0 - ISC
|
|
128
|
-
*
|
|
129
|
-
* This source code is licensed under the ISC license.
|
|
130
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
131
|
-
*/const Fa=Z("FlaskConical",[["path",{d:"M10 2v7.527a2 2 0 0 1-.211.896L4.72 20.55a1 1 0 0 0 .9 1.45h12.76a1 1 0 0 0 .9-1.45l-5.069-10.127A2 2 0 0 1 14 9.527V2",key:"pzvekw"}],["path",{d:"M8.5 2h7",key:"csnxdl"}],["path",{d:"M7 16h10",key:"wp8him"}]]);/**
|
|
132
|
-
* @license lucide-react v0.460.0 - ISC
|
|
133
|
-
*
|
|
134
|
-
* This source code is licensed under the ISC license.
|
|
135
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
136
|
-
*/const Ua=Z("FolderOpen",[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2",key:"usdka0"}]]);/**
|
|
137
|
-
* @license lucide-react v0.460.0 - ISC
|
|
138
|
-
*
|
|
139
|
-
* This source code is licensed under the ISC license.
|
|
140
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
141
|
-
*/const Ha=Z("FolderPlus",[["path",{d:"M12 10v6",key:"1bos4e"}],["path",{d:"M9 13h6",key:"1uhe8q"}],["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]]);/**
|
|
142
|
-
* @license lucide-react v0.460.0 - ISC
|
|
143
|
-
*
|
|
144
|
-
* This source code is licensed under the ISC license.
|
|
145
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
146
|
-
*/const qa=Z("FolderSearch",[["path",{d:"M10.7 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v4.1",key:"1bw5m7"}],["path",{d:"m21 21-1.9-1.9",key:"1g2n9r"}],["circle",{cx:"17",cy:"17",r:"3",key:"18b49y"}]]);/**
|
|
147
|
-
* @license lucide-react v0.460.0 - ISC
|
|
148
|
-
*
|
|
149
|
-
* This source code is licensed under the ISC license.
|
|
150
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
151
|
-
*/const _a=Z("GitBranch",[["line",{x1:"6",x2:"6",y1:"3",y2:"15",key:"17qcm7"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["path",{d:"M18 9a9 9 0 0 1-9 9",key:"n2h4wq"}]]);/**
|
|
152
|
-
* @license lucide-react v0.460.0 - ISC
|
|
153
|
-
*
|
|
154
|
-
* This source code is licensed under the ISC license.
|
|
155
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
156
|
-
*/const rs=Z("Globe",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]]);/**
|
|
157
|
-
* @license lucide-react v0.460.0 - ISC
|
|
158
|
-
*
|
|
159
|
-
* This source code is licensed under the ISC license.
|
|
160
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
161
|
-
*/const Va=Z("House",[["path",{d:"M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8",key:"5wwlr5"}],["path",{d:"M3 10a2 2 0 0 1 .709-1.528l7-5.999a2 2 0 0 1 2.582 0l7 5.999A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z",key:"1d0kgt"}]]);/**
|
|
162
|
-
* @license lucide-react v0.460.0 - ISC
|
|
163
|
-
*
|
|
164
|
-
* This source code is licensed under the ISC license.
|
|
165
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
166
|
-
*/const vs=Z("Inbox",[["polyline",{points:"22 12 16 12 14 15 10 15 8 12 2 12",key:"o97t9d"}],["path",{d:"M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z",key:"oot6mr"}]]);/**
|
|
167
|
-
* @license lucide-react v0.460.0 - ISC
|
|
168
|
-
*
|
|
169
|
-
* This source code is licensed under the ISC license.
|
|
170
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
171
|
-
*/const Wa=Z("KeyRound",[["path",{d:"M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z",key:"1s6t7t"}],["circle",{cx:"16.5",cy:"7.5",r:".5",fill:"currentColor",key:"w0ekpg"}]]);/**
|
|
172
|
-
* @license lucide-react v0.460.0 - ISC
|
|
173
|
-
*
|
|
174
|
-
* This source code is licensed under the ISC license.
|
|
175
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
176
|
-
*/const Mt=Z("Layers",[["path",{d:"m12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83Z",key:"8b97xw"}],["path",{d:"m22 17.65-9.17 4.16a2 2 0 0 1-1.66 0L2 17.65",key:"dd6zsq"}],["path",{d:"m22 12.65-9.17 4.16a2 2 0 0 1-1.66 0L2 12.65",key:"ep9fru"}]]);/**
|
|
177
|
-
* @license lucide-react v0.460.0 - ISC
|
|
178
|
-
*
|
|
179
|
-
* This source code is licensed under the ISC license.
|
|
180
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
181
|
-
*/const Ka=Z("LayoutDashboard",[["rect",{width:"7",height:"9",x:"3",y:"3",rx:"1",key:"10lvy0"}],["rect",{width:"7",height:"5",x:"14",y:"3",rx:"1",key:"16une8"}],["rect",{width:"7",height:"9",x:"14",y:"12",rx:"1",key:"1hutg5"}],["rect",{width:"7",height:"5",x:"3",y:"16",rx:"1",key:"ldoo1y"}]]);/**
|
|
182
|
-
* @license lucide-react v0.460.0 - ISC
|
|
183
|
-
*
|
|
184
|
-
* This source code is licensed under the ISC license.
|
|
185
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
186
|
-
*/const Bs=Z("LayoutTemplate",[["rect",{width:"18",height:"7",x:"3",y:"3",rx:"1",key:"f1a2em"}],["rect",{width:"9",height:"7",x:"3",y:"14",rx:"1",key:"jqznyg"}],["rect",{width:"5",height:"7",x:"16",y:"14",rx:"1",key:"q5h2i8"}]]);/**
|
|
187
|
-
* @license lucide-react v0.460.0 - ISC
|
|
188
|
-
*
|
|
189
|
-
* This source code is licensed under the ISC license.
|
|
190
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
191
|
-
*/const At=Z("Link2",[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2",key:"8i5ue5"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2",key:"1b9ql8"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]]);/**
|
|
192
|
-
* @license lucide-react v0.460.0 - ISC
|
|
193
|
-
*
|
|
194
|
-
* This source code is licensed under the ISC license.
|
|
195
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
196
|
-
*/const Ga=Z("LoaderCircle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]);/**
|
|
197
|
-
* @license lucide-react v0.460.0 - ISC
|
|
198
|
-
*
|
|
199
|
-
* This source code is licensed under the ISC license.
|
|
200
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
201
|
-
*/const rt=Z("MapPin",[["path",{d:"M20 10c0 4.993-5.539 10.193-7.399 11.799a1 1 0 0 1-1.202 0C9.539 20.193 4 14.993 4 10a8 8 0 0 1 16 0",key:"1r0f0z"}],["circle",{cx:"12",cy:"10",r:"3",key:"ilqhr7"}]]);/**
|
|
202
|
-
* @license lucide-react v0.460.0 - ISC
|
|
203
|
-
*
|
|
204
|
-
* This source code is licensed under the ISC license.
|
|
205
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
206
|
-
*/const os=Z("Map",[["path",{d:"M14.106 5.553a2 2 0 0 0 1.788 0l3.659-1.83A1 1 0 0 1 21 4.619v12.764a1 1 0 0 1-.553.894l-4.553 2.277a2 2 0 0 1-1.788 0l-4.212-2.106a2 2 0 0 0-1.788 0l-3.659 1.83A1 1 0 0 1 3 19.381V6.618a1 1 0 0 1 .553-.894l4.553-2.277a2 2 0 0 1 1.788 0z",key:"169xi5"}],["path",{d:"M15 5.764v15",key:"1pn4in"}],["path",{d:"M9 3.236v15",key:"1uimfh"}]]);/**
|
|
207
|
-
* @license lucide-react v0.460.0 - ISC
|
|
208
|
-
*
|
|
209
|
-
* This source code is licensed under the ISC license.
|
|
210
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
211
|
-
*/const Ya=Z("Maximize2",[["polyline",{points:"15 3 21 3 21 9",key:"mznyad"}],["polyline",{points:"9 21 3 21 3 15",key:"1avn1i"}],["line",{x1:"21",x2:"14",y1:"3",y2:"10",key:"ota7mn"}],["line",{x1:"3",x2:"10",y1:"21",y2:"14",key:"1atl0r"}]]);/**
|
|
212
|
-
* @license lucide-react v0.460.0 - ISC
|
|
213
|
-
*
|
|
214
|
-
* This source code is licensed under the ISC license.
|
|
215
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
216
|
-
*/const Ja=Z("Minus",[["path",{d:"M5 12h14",key:"1ays0h"}]]);/**
|
|
217
|
-
* @license lucide-react v0.460.0 - ISC
|
|
218
|
-
*
|
|
219
|
-
* This source code is licensed under the ISC license.
|
|
220
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
221
|
-
*/const Xa=Z("OctagonAlert",[["path",{d:"M12 16h.01",key:"1drbdi"}],["path",{d:"M12 8v4",key:"1got3b"}],["path",{d:"M15.312 2a2 2 0 0 1 1.414.586l4.688 4.688A2 2 0 0 1 22 8.688v6.624a2 2 0 0 1-.586 1.414l-4.688 4.688a2 2 0 0 1-1.414.586H8.688a2 2 0 0 1-1.414-.586l-4.688-4.688A2 2 0 0 1 2 15.312V8.688a2 2 0 0 1 .586-1.414l4.688-4.688A2 2 0 0 1 8.688 2z",key:"1fd625"}]]);/**
|
|
222
|
-
* @license lucide-react v0.460.0 - ISC
|
|
223
|
-
*
|
|
224
|
-
* This source code is licensed under the ISC license.
|
|
225
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
226
|
-
*/const $t=Z("Palette",[["circle",{cx:"13.5",cy:"6.5",r:".5",fill:"currentColor",key:"1okk4w"}],["circle",{cx:"17.5",cy:"10.5",r:".5",fill:"currentColor",key:"f64h9f"}],["circle",{cx:"8.5",cy:"7.5",r:".5",fill:"currentColor",key:"fotxhn"}],["circle",{cx:"6.5",cy:"12.5",r:".5",fill:"currentColor",key:"qy21gx"}],["path",{d:"M12 2C6.5 2 2 6.5 2 12s4.5 10 10 10c.926 0 1.648-.746 1.648-1.688 0-.437-.18-.835-.437-1.125-.29-.289-.438-.652-.438-1.125a1.64 1.64 0 0 1 1.668-1.668h1.996c3.051 0 5.555-2.503 5.555-5.554C21.965 6.012 17.461 2 12 2z",key:"12rzf8"}]]);/**
|
|
227
|
-
* @license lucide-react v0.460.0 - ISC
|
|
228
|
-
*
|
|
229
|
-
* This source code is licensed under the ISC license.
|
|
230
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
231
|
-
*/const Qa=Z("PanelLeftClose",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"m16 15-3-3 3-3",key:"14y99z"}]]);/**
|
|
232
|
-
* @license lucide-react v0.460.0 - ISC
|
|
233
|
-
*
|
|
234
|
-
* This source code is licensed under the ISC license.
|
|
235
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
236
|
-
*/const Za=Z("PanelLeftOpen",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"m14 9 3 3-3 3",key:"8010ee"}]]);/**
|
|
237
|
-
* @license lucide-react v0.460.0 - ISC
|
|
238
|
-
*
|
|
239
|
-
* This source code is licensed under the ISC license.
|
|
240
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
241
|
-
*/const en=Z("PanelsTopLeft",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9h18",key:"1pudct"}],["path",{d:"M9 21V9",key:"1oto5p"}]]);/**
|
|
242
|
-
* @license lucide-react v0.460.0 - ISC
|
|
243
|
-
*
|
|
244
|
-
* This source code is licensed under the ISC license.
|
|
245
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
246
|
-
*/const cs=Z("Plug",[["path",{d:"M12 22v-5",key:"1ega77"}],["path",{d:"M9 8V2",key:"14iosj"}],["path",{d:"M15 8V2",key:"18g5xt"}],["path",{d:"M18 8v5a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V8Z",key:"osxo6l"}]]);/**
|
|
247
|
-
* @license lucide-react v0.460.0 - ISC
|
|
248
|
-
*
|
|
249
|
-
* This source code is licensed under the ISC license.
|
|
250
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
251
|
-
*/const sn=Z("PowerOff",[["path",{d:"M18.36 6.64A9 9 0 0 1 20.77 15",key:"dxknvb"}],["path",{d:"M6.16 6.16a9 9 0 1 0 12.68 12.68",key:"1x7qb5"}],["path",{d:"M12 2v4",key:"3427ic"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);/**
|
|
252
|
-
* @license lucide-react v0.460.0 - ISC
|
|
253
|
-
*
|
|
254
|
-
* This source code is licensed under the ISC license.
|
|
255
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
256
|
-
*/const ys=Z("Puzzle",[["path",{d:"M15.39 4.39a1 1 0 0 0 1.68-.474 2.5 2.5 0 1 1 3.014 3.015 1 1 0 0 0-.474 1.68l1.683 1.682a2.414 2.414 0 0 1 0 3.414L19.61 15.39a1 1 0 0 1-1.68-.474 2.5 2.5 0 1 0-3.014 3.015 1 1 0 0 1 .474 1.68l-1.683 1.682a2.414 2.414 0 0 1-3.414 0L8.61 19.61a1 1 0 0 0-1.68.474 2.5 2.5 0 1 1-3.014-3.015 1 1 0 0 0 .474-1.68l-1.683-1.682a2.414 2.414 0 0 1 0-3.414L4.39 8.61a1 1 0 0 1 1.68.474 2.5 2.5 0 1 0 3.014-3.015 1 1 0 0 1-.474-1.68l1.683-1.682a2.414 2.414 0 0 1 3.414 0z",key:"w46dr5"}]]);/**
|
|
257
|
-
* @license lucide-react v0.460.0 - ISC
|
|
258
|
-
*
|
|
259
|
-
* This source code is licensed under the ISC license.
|
|
260
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
261
|
-
*/const tn=Z("Radio",[["path",{d:"M4.9 19.1C1 15.2 1 8.8 4.9 4.9",key:"1vaf9d"}],["path",{d:"M7.8 16.2c-2.3-2.3-2.3-6.1 0-8.5",key:"u1ii0m"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}],["path",{d:"M16.2 7.8c2.3 2.3 2.3 6.1 0 8.5",key:"1j5fej"}],["path",{d:"M19.1 4.9C23 8.8 23 15.1 19.1 19",key:"10b0cb"}]]);/**
|
|
262
|
-
* @license lucide-react v0.460.0 - ISC
|
|
263
|
-
*
|
|
264
|
-
* This source code is licensed under the ISC license.
|
|
265
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
266
|
-
*/const an=Z("Redo2",[["path",{d:"m15 14 5-5-5-5",key:"12vg1m"}],["path",{d:"M20 9H9.5A5.5 5.5 0 0 0 4 14.5A5.5 5.5 0 0 0 9.5 20H13",key:"6uklza"}]]);/**
|
|
267
|
-
* @license lucide-react v0.460.0 - ISC
|
|
268
|
-
*
|
|
269
|
-
* This source code is licensed under the ISC license.
|
|
270
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
271
|
-
*/const It=Z("Settings2",[["path",{d:"M20 7h-9",key:"3s1dr2"}],["path",{d:"M14 17H5",key:"gfn3mx"}],["circle",{cx:"17",cy:"17",r:"3",key:"18b49y"}],["circle",{cx:"7",cy:"7",r:"3",key:"dfmy0x"}]]);/**
|
|
272
|
-
* @license lucide-react v0.460.0 - ISC
|
|
273
|
-
*
|
|
274
|
-
* This source code is licensed under the ISC license.
|
|
275
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
276
|
-
*/const nn=Z("Share2",[["circle",{cx:"18",cy:"5",r:"3",key:"gq8acd"}],["circle",{cx:"6",cy:"12",r:"3",key:"w7nqdw"}],["circle",{cx:"18",cy:"19",r:"3",key:"1xt0gg"}],["line",{x1:"8.59",x2:"15.42",y1:"13.51",y2:"17.49",key:"47mynk"}],["line",{x1:"15.41",x2:"8.59",y1:"6.51",y2:"10.49",key:"1n3mei"}]]);/**
|
|
277
|
-
* @license lucide-react v0.460.0 - ISC
|
|
278
|
-
*
|
|
279
|
-
* This source code is licensed under the ISC license.
|
|
280
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
281
|
-
*/const es=Z("ShieldCheck",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);/**
|
|
282
|
-
* @license lucide-react v0.460.0 - ISC
|
|
283
|
-
*
|
|
284
|
-
* This source code is licensed under the ISC license.
|
|
285
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
286
|
-
*/const ln=Z("Shield",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}]]);/**
|
|
287
|
-
* @license lucide-react v0.460.0 - ISC
|
|
288
|
-
*
|
|
289
|
-
* This source code is licensed under the ISC license.
|
|
290
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
291
|
-
*/const rn=Z("SquarePen",[["path",{d:"M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7",key:"1m0v6g"}],["path",{d:"M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z",key:"ohrbg2"}]]);/**
|
|
292
|
-
* @license lucide-react v0.460.0 - ISC
|
|
293
|
-
*
|
|
294
|
-
* This source code is licensed under the ISC license.
|
|
295
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
296
|
-
*/const Rt=Z("Square",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]]);/**
|
|
297
|
-
* @license lucide-react v0.460.0 - ISC
|
|
298
|
-
*
|
|
299
|
-
* This source code is licensed under the ISC license.
|
|
300
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
301
|
-
*/const Dt=Z("Stethoscope",[["path",{d:"M11 2v2",key:"1539x4"}],["path",{d:"M5 2v2",key:"1yf1q8"}],["path",{d:"M5 3H4a2 2 0 0 0-2 2v4a6 6 0 0 0 12 0V5a2 2 0 0 0-2-2h-1",key:"rb5t3r"}],["path",{d:"M8 15a6 6 0 0 0 12 0v-3",key:"x18d4x"}],["circle",{cx:"20",cy:"10",r:"2",key:"ts1r5v"}]]);/**
|
|
302
|
-
* @license lucide-react v0.460.0 - ISC
|
|
303
|
-
*
|
|
304
|
-
* This source code is licensed under the ISC license.
|
|
305
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
306
|
-
*/const Os=Z("Tag",[["path",{d:"M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z",key:"vktsd0"}],["circle",{cx:"7.5",cy:"7.5",r:".5",fill:"currentColor",key:"kqv944"}]]);/**
|
|
307
|
-
* @license lucide-react v0.460.0 - ISC
|
|
308
|
-
*
|
|
309
|
-
* This source code is licensed under the ISC license.
|
|
310
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
311
|
-
*/const on=Z("Target",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"6",key:"1vlfrh"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}]]);/**
|
|
312
|
-
* @license lucide-react v0.460.0 - ISC
|
|
313
|
-
*
|
|
314
|
-
* This source code is licensed under the ISC license.
|
|
315
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
316
|
-
*/const cn=Z("Undo2",[["path",{d:"M9 14 4 9l5-5",key:"102s5s"}],["path",{d:"M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11",key:"f3b9sd"}]]);/**
|
|
317
|
-
* @license lucide-react v0.460.0 - ISC
|
|
318
|
-
*
|
|
319
|
-
* This source code is licensed under the ISC license.
|
|
320
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
321
|
-
*/const dn=Z("User",[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]]);/**
|
|
322
|
-
* @license lucide-react v0.460.0 - ISC
|
|
323
|
-
*
|
|
324
|
-
* This source code is licensed under the ISC license.
|
|
325
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
326
|
-
*/const mn=Z("Wrench",[["path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z",key:"cbrjhi"}]]);/**
|
|
327
|
-
* @license lucide-react v0.460.0 - ISC
|
|
328
|
-
*
|
|
329
|
-
* This source code is licensed under the ISC license.
|
|
330
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
331
|
-
*/const hn=Z("Zap",[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]]),un=200,pn=5*60*1e3,_e=new Map;function xn(s){const t=_e.get(s);return t?Date.now()-t.ts>pn?(_e.delete(s),null):t.data:null}function Ms(s,t){_e.size>=un&&[..._e.entries()].sort((i,n)=>i[1].ts-n[1].ts).slice(0,50).map(([i])=>i).forEach(i=>_e.delete(i)),_e.set(s,{data:t,ts:Date.now()})}function gn(s){if(!s||s==="/")return[{label:"/",path:"/"}];const t=s.split("/").filter(Boolean),a=[];let i="";for(let n=0;n<t.length;n++)i+="/"+t[n],a.push({label:t[n],path:i});return a}function jn(s){return[...s].sort((t,a)=>t.isDir!==a.isDir?t.isDir?-1:1:t.name.localeCompare(a.name,void 0,{sensitivity:"base"}))}function fn(s){const t=s.trim();return t?t!==s?{ok:!1,reason:"Name cannot have leading or trailing whitespace."}:t==="."?{ok:!1,reason:"Name cannot be '.'."}:t===".."?{ok:!1,reason:"Name cannot be '..'."}:t.startsWith("-")?{ok:!1,reason:"Name cannot start with '-'."}:t.length>255?{ok:!1,reason:"Name cannot be longer than 255 characters."}:/[/\0:*?"<>|]/.test(t)?{ok:!1,reason:'Name cannot contain / \\ : * ? " < > |'}:{ok:!0}:{ok:!1,reason:"Name cannot be empty."}}function Lt({value:s,onChange:t,initialPath:a,projectsDirectory:i,rootLabel:n="Home",height:c=360}){const[d,l]=r.useState(a??i??""),[x,u]=r.useState(new Set),[j,m]=r.useState(-1),[o,p]=r.useState(null),[k,f]=r.useState({}),[S,b]=r.useState(!1),[v,y]=r.useState(null),[$,g]=r.useState(!1),[B,H]=r.useState(""),[R,J]=r.useState(null),[D,L]=r.useState(!1),V=r.useRef(null),K=r.useCallback(async E=>{try{const re=xn(E);if(re)return re;const ie=await A.get("/fs?path="+encodeURIComponent(E));return Ms(E,ie),ie}catch{return null}},[]),w=r.useCallback(async E=>{var re;b(!0),y(null);try{const ie=await A.get("/fs?path="+encodeURIComponent(E));Ms(E,ie),p(ie),m(-1)}catch(ie){const fe=((re=ie.data)==null?void 0:re.message)??ie.message??"Failed to load directory";y(fe)}finally{b(!1)}},[]);r.useEffect(()=>{d?w(d):A.get("/fs").then(E=>{Ms("",E),p(E),l(E.path),E.path!==s&&t(E.path)}).catch(()=>{y("Could not determine home directory."),b(!1)})},[d]),r.useEffect(()=>{s&&s!==d&&l(s)},[s]);const I=o?jn(o.entries):[],_=I.filter(E=>E.isDir),W=I,X=E=>{E.isDir&&(l(E.path),t(E.path))},ne=()=>{o!=null&&o.parent&&(l(o.parent),t(o.parent))},se=E=>{E!==d&&(l(E),t(E))},U=async()=>{const E=await K("");E&&(l(E.path),t(E.path))},O=async()=>{if(!i)return;const E=await K(i);E&&(l(E.path),t(E.path))},Q=()=>{g(!0),H(""),J(null),setTimeout(()=>{var E;return(E=V.current)==null?void 0:E.focus()},0)},F=()=>{g(!1),H(""),J(null)},q=async()=>{var re;const E=fn(B);if(!E.ok){J(E.reason);return}L(!0),J(null);try{const ie=await A.post("/fs/mkdir",{parent:d,name:B.trim()});_e.delete(d),await w(d),t(ie.path),g(!1),H("")}catch(ie){const fe=ie;fe.status===409?J(`A folder named "${B.trim()}" already exists.`):J(((re=fe.data)==null?void 0:re.message)??ie.message??"Failed to create folder.")}finally{L(!1)}},ee=E=>{E.key==="Enter"?(E.preventDefault(),q()):E.key==="Escape"&&(E.preventDefault(),F())},T=E=>{u(re=>{const ie=new Set(re);return ie.has(E)?ie.delete(E):ie.add(E),ie}),k[E]||K(E).then(re=>{re&&f(ie=>({...ie,[E]:re.entries.filter(fe=>fe.isDir)}))})},M=E=>{if(!o)return;const re=W.filter(me=>me.isDir),ie=W.filter(me=>!me.isDir),fe=[...re,...ie];if(E.key==="ArrowDown")E.preventDefault(),m(me=>Math.min(me+1,fe.length-1));else if(E.key==="ArrowUp")E.preventDefault(),m(me=>Math.max(me-1,0));else if(E.key==="Enter"||E.key===" "){E.preventDefault();const me=fe[j];me&&(E.key==="Enter"&&me.isDir?X(me):me.isDir&&t(me.path))}else E.key==="Backspace"&&(E.preventDefault(),ne())},C=gn((o==null?void 0:o.path)??d??"/"),h=o==null?void 0:o.parent,P=h!=null,Y=d.split("/").filter(Boolean).at(-1)??"/";return e.jsxs("div",{className:"file-browser",onKeyDown:M,tabIndex:-1,children:[e.jsx("div",{className:"file-browser-breadcrumb",role:"navigation","aria-label":"Path breadcrumb",children:C.map((E,re)=>e.jsxs("span",{className:"file-browser-breadcrumb-item",children:[re>0&&e.jsx("span",{className:"file-browser-breadcrumb-sep","aria-hidden":!0,children:"/"}),e.jsx("button",{type:"button",className:"file-browser-breadcrumb-btn",onClick:()=>se(E.path),title:E.path,children:re===0?E.path==="/"?"/":n:E.label})]},E.path))}),e.jsxs("div",{className:"file-browser-toolbar",children:[e.jsxs("div",{className:"file-browser-toolbar-left",children:[e.jsx("button",{type:"button",className:"file-browser-tool-btn",onClick:ne,disabled:!P,title:"Go up (Backspace)","aria-label":"Go up one level",children:e.jsx(St,{size:13})}),e.jsx("button",{type:"button",className:"file-browser-tool-btn",onClick:()=>w(d),disabled:S,title:"Refresh","aria-label":"Refresh",children:e.jsx(de,{size:13,className:S?"spin":""})}),e.jsx("button",{type:"button",className:"file-browser-tool-btn",onClick:Q,title:"New folder","aria-label":"Create new folder",children:e.jsx(Ha,{size:13})}),e.jsxs("div",{className:"file-browser-chips",children:[e.jsxs("button",{type:"button",className:"file-browser-chip",onClick:U,children:[e.jsx(Va,{size:11})," ",n]}),i&&e.jsxs("button",{type:"button",className:"file-browser-chip",onClick:O,title:i,children:[e.jsx(Ua,{size:11})," ",i.split("/").filter(Boolean).at(-1)??"Projects"]})]})]}),$?e.jsxs("div",{className:"file-browser-mkdir",children:[e.jsx("input",{ref:V,type:"text",className:"file-browser-mkdir-input",placeholder:"Folder name",value:B,onChange:E=>{H(E.target.value),J(null)},onKeyDown:ee,"aria-label":"New folder name","aria-invalid":R?"true":void 0,"aria-describedby":R?"mkdir-error":void 0,disabled:D,maxLength:255}),R?e.jsx("span",{id:"mkdir-error",className:"file-browser-mkdir-error",role:"alert",children:R}):e.jsx("span",{className:"file-browser-mkdir-hint",children:"Enter to create, Esc to cancel"})]}):e.jsx("span",{className:"file-browser-count-hint",children:S?"…":`${I.length} in ${Y}`})]}),v&&e.jsxs("div",{className:"file-browser-error",children:[e.jsx(Vs,{size:13}),e.jsx("span",{children:v}),e.jsx("button",{type:"button",className:"file-browser-retry",onClick:()=>w(d),children:"Retry"})]}),e.jsxs("div",{className:"file-browser-body",style:{height:c},children:[e.jsx("div",{className:"file-browser-pane file-browser-tree","aria-label":"Folder tree",children:S&&!o?e.jsx(vn,{}):e.jsx(Pt,{path:d,entries:_,expanded:x,childrenMap:k,onToggle:T,onNavigate:X,level:0})}),e.jsxs("div",{className:"file-browser-pane file-browser-flat","aria-label":"Directory contents",children:[e.jsxs("div",{className:"file-browser-flat-header",children:[e.jsx("span",{children:"Name"}),e.jsx("span",{children:"Type"})]}),S&&!o?e.jsx(yn,{}):e.jsxs(e.Fragment,{children:[(o==null?void 0:o.truncated)&&e.jsxs("div",{className:"file-browser-truncated-banner",role:"status",children:["Showing first 500 of ",o.totalEntries," entries. Navigate into a subfolder to see more."]}),W.length===0?e.jsx("div",{className:"file-browser-empty",children:"This folder is empty"}):e.jsx("div",{className:"file-browser-flat-list",children:W.map((E,re)=>{const ie=E.isDir,fe=re===j,me=E.path===s;return e.jsxs("div",{role:"option","aria-selected":me,className:["file-browser-row",ie?"file-browser-row--dir":"file-browser-row--file",fe&&"file-browser-row--selected",me&&ie&&"file-browser-row--active",!ie&&"file-browser-row--disabled"].filter(Boolean).join(" "),onClick:()=>{ie&&(m(re),t(E.path))},onDoubleClick:()=>{ie&&X(E)},title:E.path,children:[e.jsx("span",{className:"file-browser-row-icon",children:ie?e.jsx(Ue,{size:13}):e.jsx(Ba,{size:13})}),e.jsx("span",{className:"file-browser-row-name",children:E.name}),e.jsx("span",{className:"file-browser-row-type",children:ie?"Folder":""})]},E.path)})})]})]})]}),e.jsxs("div",{className:"file-browser-footer-hint",children:["Select a folder, then click Add. Use ",e.jsx("kbd",{children:"↑"})," ",e.jsx("kbd",{children:"↓"})," to navigate, ",e.jsx("kbd",{children:"Enter"})," to confirm."]})]})}function Pt({path:s,entries:t,expanded:a,childrenMap:i,onToggle:n,onNavigate:c,level:d}){return e.jsx("ul",{className:"file-browser-tree-list",role:"group",children:t.map(l=>{const x=a.has(l.path),u=i[l.path]??[];return e.jsxs("li",{className:"file-browser-tree-node",children:[e.jsxs("div",{className:["file-browser-tree-row",x&&"file-browser-tree-row--expanded"].filter(Boolean).join(" "),style:{paddingLeft:`${d*16+8}px`},children:[e.jsx("button",{type:"button",className:"file-browser-tree-toggle",onClick:j=>{j.stopPropagation(),n(l.path)},"aria-label":x?"Collapse":"Expand",children:(u.length>0,x?e.jsx(Ae,{size:11}):e.jsx(He,{size:11}))}),e.jsxs("button",{type:"button",className:"file-browser-tree-name",onClick:()=>c(l),title:l.path,children:[e.jsx(Ue,{size:12}),e.jsx("span",{children:l.name})]})]}),x&&u.length>0&&e.jsx(Pt,{path:l.path,entries:u,expanded:a,childrenMap:i,onToggle:n,onNavigate:c,level:d+1})]},l.path)})})}function vn(){return e.jsx("div",{className:"file-browser-skeleton-wrap",children:[80,60,90,55,70].map((s,t)=>e.jsx("div",{className:"file-browser-skeleton-row",style:{width:s}},t))})}function yn(){return e.jsx("div",{className:"file-browser-skeleton-wrap",children:[60,90,70,50,80,65].map((s,t)=>e.jsx("div",{className:"file-browser-skeleton-row",style:{width:s}},t))})}const Fs=[{id:"overview",label:"Overview",icon:Ka},{id:"chat",label:"Chat",icon:Ve},{id:"agents",label:"Agents",icon:Ee},{id:"artifacts",label:"Glyphs",icon:os},{id:"tasks",label:"Tasks",icon:Be},{id:"activity",label:"Activity",icon:ze},{id:"background",label:"Active",icon:tn},{id:"skills",label:"Skills",icon:Te},{id:"mods",label:"Mods",icon:ys},{id:"schedules",label:"Schedules",icon:Xe},{id:"history",label:"History",icon:ns},{id:"config",label:"Config",icon:It},{id:"settings",label:"Settings",icon:ft}];function bn({activeTab:s,onTabChange:t,wsStatus:a,version:i,activeProject:n,projects:c,onProjectChange:d,onProjectsRefresh:l,onOpenSearch:x,settings:u,rightSlot:j,notificationsSlot:m,showTabs:o=!0,extraTabs:p}){return e.jsxs("header",{className:"topbar",children:[e.jsxs("div",{className:"topbar-row",children:[e.jsxs("div",{className:"brand",children:[e.jsx("span",{className:"brand-logo","aria-hidden":"true",children:"ᛒ"}),e.jsx("span",{className:"brand-title",children:"Bizar"}),e.jsx("span",{className:"brand-version",children:i})]}),e.jsx(kn,{activeProject:n,projects:c,onChange:d,onRefresh:l,settings:u??null}),e.jsxs("button",{type:"button",className:"topbar-search",onClick:x,title:"Search (Ctrl/Cmd+K)","aria-label":"Open search",children:[e.jsx(Oe,{size:14}),e.jsx("span",{className:"muted",children:"Search…"}),e.jsx("kbd",{children:"⌘K"})]}),e.jsx("div",{className:"topbar-spacer"}),e.jsxs("div",{className:"topbar-right",children:[m,j,e.jsxs("div",{className:ae("ws-status",`ws-${a}`),title:`WebSocket: ${a}`,children:[e.jsx("span",{className:"ws-dot"}),e.jsx("span",{className:"ws-label",children:a})]})]})]}),o&&e.jsxs("nav",{className:"tabs-row",role:"tablist",children:[Fs.map(k=>{const f=k.icon,S=k.id===s;return e.jsxs("button",{type:"button",role:"tab","aria-selected":S,className:ae("tab",S&&"tab-active"),onClick:()=>t(k.id),title:k.label,children:[e.jsx(f,{size:14,className:"tab-icon"}),e.jsx("span",{className:"tab-label",children:k.label})]},k.id)}),p&&p.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"tab-separator","aria-hidden":"true"}),p.map(k=>{const f=k.icon,S=k.id===s;return e.jsxs("button",{type:"button",role:"tab","aria-selected":S,className:ae("tab","tab-mod",S&&"tab-active"),onClick:()=>t(k.id),title:`${k.label} (mod)`,children:[e.jsx(f,{size:14,className:"tab-icon"}),e.jsx("span",{className:"tab-label",children:k.label}),e.jsx("span",{className:"tab-badge",children:"mod"})]},k.id)})]})]})]})}function kn({activeProject:s,projects:t,onChange:a,onRefresh:i,settings:n}){const[c,d]=r.useState(!1),l=ke();r.useEffect(()=>{if(!c)return;const u=()=>d(!1);return document.addEventListener("click",u),()=>document.removeEventListener("click",u)},[c]);const x=()=>{l.open({title:"Add project",children:e.jsx(Nn,{settings:n,onAdd:async(u,j)=>{try{await A.post("/projects",{path:u,name:j}),i(),d(!1),l.close()}catch(m){alert(`Add failed: ${m.message}`)}}}),footer:e.jsx("div",{className:"modal-footer-actions",children:e.jsx(z,{variant:"ghost",onClick:()=>l.close(),children:"Cancel"})})})};return e.jsxs("div",{className:"project-selector",onClick:u=>u.stopPropagation(),children:[e.jsxs("button",{type:"button",className:"project-selector-btn",onClick:()=>d(u=>!u),title:"Switch active project","aria-haspopup":"menu","aria-expanded":c,children:[e.jsx(Ue,{size:14}),e.jsx("span",{className:"project-selector-name",children:(s==null?void 0:s.name)||"(no project)"}),e.jsx(Ae,{size:12})]}),c&&e.jsxs("div",{className:"project-selector-menu",children:[e.jsxs("div",{className:"project-selector-menu-head",children:[e.jsxs("span",{className:"muted",children:[t.length," project",t.length===1?"":"s"]}),e.jsxs("div",{className:"project-selector-menu-actions",children:[e.jsx("button",{type:"button",className:"icon-btn",onClick:i,title:"Refresh","aria-label":"Refresh projects",children:e.jsx(de,{size:12})}),e.jsx("button",{type:"button",className:"icon-btn",onClick:x,title:"Add project","aria-label":"Add project",children:e.jsx(pe,{size:12})})]})]}),e.jsxs("ul",{className:"project-selector-list",children:[t.length===0&&e.jsx("li",{className:"muted project-selector-empty",children:"No projects. Add one to start."}),t.map(u=>e.jsx("li",{children:e.jsxs("button",{type:"button",className:ae("project-selector-item",(s==null?void 0:s.id)===u.id&&"active"),onClick:()=>{a(u.id),d(!1)},children:[e.jsx("span",{className:"project-selector-item-name",children:u.name}),e.jsx("span",{className:"project-selector-item-status",children:u.status})]})},u.id))]})]})]})}function Nn({settings:s,onAdd:t}){var m,o;const[a,i]=r.useState(((m=s==null?void 0:s.dashboard)==null?void 0:m.projectsDirectory)??""),[n,c]=r.useState(""),[d,l]=r.useState(!1),[x,u]=r.useState(null),j=async()=>{var p;if(a){l(!0),u(null);try{await A.get("/fs?path="+encodeURIComponent(a)),t(a,n||null)}catch(k){const f=k;f.status===404?u("That folder no longer exists. Pick another."):u(((p=f.data)==null?void 0:p.message)??k.message??"Validation failed.")}finally{l(!1)}}};return e.jsxs("div",{children:[e.jsx("label",{className:"field-label",children:"Folder"}),e.jsx(Lt,{value:a,onChange:p=>{i(p),u(null)},projectsDirectory:(o=s==null?void 0:s.dashboard)==null?void 0:o.projectsDirectory,height:320}),x&&e.jsx("p",{className:"field-help",style:{color:"var(--error)",marginTop:4},children:x}),e.jsxs("div",{style:{marginTop:"var(--space-3)"},children:[e.jsx("label",{className:"field-label",htmlFor:"topbar-add-project-name",children:"Name (optional)"}),e.jsx("input",{id:"topbar-add-project-name",className:"input",type:"text",placeholder:"My App",value:n,onChange:p=>c(p.target.value)})]}),e.jsx("div",{style:{marginTop:"var(--space-3)",display:"flex",justifyContent:"flex-end"},children:e.jsxs(z,{variant:"primary",onClick:j,disabled:!a||d,children:[d?e.jsx("span",{className:"btn-spinner"}):null,d?"Checking…":"Add"]})})]})}function wn({tabs:s,activeTab:t,onTabChange:a}){const i=s.filter(c=>!c.isMod),n=s.filter(c=>c.isMod);return e.jsx("aside",{className:"sidebar","aria-label":"Primary navigation",children:e.jsxs("nav",{className:"sidebar-nav",role:"tablist",children:[i.map(c=>{const d=c.icon,l=c.id===t;return e.jsxs("button",{type:"button",role:"tab","aria-selected":l,className:ae("sidebar-tab",l&&"sidebar-tab-active"),onClick:()=>a(c.id),title:c.label,children:[e.jsx(d,{size:18,"aria-hidden":!0}),e.jsx("span",{className:"sidebar-tab-label",children:c.label})]},c.id)}),n.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"sidebar-section-divider","aria-hidden":"true"}),e.jsx("div",{className:"sidebar-section-label",children:"Mods"}),n.map(c=>{const d=c.icon,l=c.id===t;return e.jsxs("button",{type:"button",role:"tab","aria-selected":l,className:ae("sidebar-tab","sidebar-tab-mod",l&&"sidebar-tab-active"),onClick:()=>a(c.id),title:`${c.label} (mod)`,children:[e.jsx(d,{size:18,"aria-hidden":!0}),e.jsx("span",{className:"sidebar-tab-label",children:c.label})]},c.id)})]})]})})}const As=[{id:"all",label:"All"},{id:"projects",label:"Projects"},{id:"agents",label:"Agents"},{id:"tasks",label:"Tasks"},{id:"mods",label:"Mods"},{id:"schedules",label:"Schedules"},{id:"commands",label:"Commands"},{id:"settings",label:"Settings"}],ot={all:null,projects:"project",agents:"agent",tasks:"task",mods:"mod",schedules:"schedule",commands:"command",settings:"setting"};function Sn({open:s,onClose:t,onSelect:a}){const i=ce(),[n,c]=r.useState(""),[d,l]=r.useState("all"),[x,u]=r.useState([]),[j,m]=r.useState(!1),[o,p]=r.useState(0),k=r.useRef(null),f=r.useRef(null);if(r.useEffect(()=>{let y;return s&&(f.current=document.activeElement instanceof HTMLElement?document.activeElement:null,c(""),u([]),p(0),y=window.setTimeout(()=>{var $;return($=k.current)==null?void 0:$.focus()},30)),()=>{if(y&&window.clearTimeout(y),!s)return;const $=f.current;$&&$.isConnected&&$.focus()}},[s]),r.useEffect(()=>{if(!s)return;if(!n.trim()){u([]),p(0);return}let y=!1;m(!0);const $=setTimeout(()=>{A.get(`/search?q=${encodeURIComponent(n)}&scope=${d}`).then(g=>{y||(u(g.results||[]),p(0))}).catch(g=>{y||i.error(`Search failed: ${g.message}`)}).finally(()=>!y&&m(!1))},150);return()=>{y=!0,clearTimeout($)}},[n,d,s,i]),!s)return null;const S={};for(const y of x){const $=y.type.toLowerCase();S[$]=S[$]||[],S[$].push(y)}const b=[];for(const y of As.map($=>$.id)){const $=ot[y];$&&S[$]&&b.push(...S[$])}const v=y=>{if(y.key==="Escape")t();else if(y.key==="ArrowDown"){if(y.preventDefault(),b.length===0)return;p($=>Math.min($+1,b.length-1))}else if(y.key==="ArrowUp"){if(y.preventDefault(),b.length===0)return;p($=>Math.max($-1,0))}else y.key==="Enter"&&b[o]&&(y.preventDefault(),a(b[o]),t())};return e.jsx("div",{className:"search-modal-backdrop",onClick:t,children:e.jsxs("div",{className:"search-modal",role:"dialog","aria-modal":"true","aria-labelledby":"search-modal-title",onClick:y=>y.stopPropagation(),children:[e.jsxs("div",{className:"search-modal-head",children:[e.jsx(Oe,{size:14}),e.jsx("span",{id:"search-modal-title",className:"sr-only",children:"Search"}),e.jsx("input",{ref:k,className:"search-modal-input",placeholder:"Search tasks, agents, settings, projects…",value:n,onChange:y=>c(y.target.value),onKeyDown:v}),e.jsx("button",{type:"button",className:"icon-btn","aria-label":"Close",onClick:t,children:e.jsx($e,{size:14})})]}),e.jsx("div",{className:"search-modal-scopes",children:As.map(y=>e.jsx("button",{type:"button",className:ae("search-scope",d===y.id&&"search-scope-active"),onClick:()=>l(y.id),children:y.label},y.id))}),e.jsxs("div",{className:"search-modal-body",children:[j&&e.jsx("div",{className:"muted",children:"Searching…"}),!j&&n&&b.length===0&&e.jsx("div",{className:"muted",children:"No results."}),!j&&!n&&e.jsx("div",{className:"muted",children:"Type to search…"}),As.map(y=>{const $=ot[y.id];if(!$)return null;const g=S[$];return!g||g.length===0?null:e.jsxs("div",{className:"search-group",children:[e.jsx("div",{className:"search-group-head",children:y.label}),g.map(B=>{const H=b.indexOf(B);return e.jsxs("button",{type:"button",className:ae("search-result",H===o&&"search-result-active"),onMouseEnter:()=>p(H),onClick:()=>{a(B),t()},children:[e.jsx("span",{className:"search-result-type",children:B.type}),e.jsx("span",{className:"search-result-label",children:Cn(B)})]},`${B.type}-${H}`)})]},y.id)})]}),e.jsx("div",{className:"search-modal-foot",children:e.jsx("span",{className:"muted",children:"↑↓ navigate · ↵ open · esc close"})})]})})}function Cn(s){const t=s.item||{};if(s.type==="project")return`${t.name} — ${t.path}`;if(s.type==="agent")return`${t.name} — ${t.description||t.model||""}`;if(s.type==="task")return`${t.title} — ${t.status||""}`;if(s.type==="mod")return`${t.name} v${t.version} — ${t.description||""}`;if(s.type==="schedule")return`${t.name} (${t.type}: ${t.schedule})`;if(s.type==="command")return`${t.name} — ${t.description||""}`;if(s.type==="setting"){const a=t.value===null||t.value===void 0?"":typeof t.value=="string"?` = ${t.value}`:` = ${JSON.stringify(t.value)}`;return`${t.label}${a} — ${t.desc||""}`.trim()}return JSON.stringify(t).slice(0,80)}const zn={info:Ns,success:ks,warning:De,error:Vs};function Tn({onCountChange:s,wsSubscribe:t}){const a=ce(),[i,n]=r.useState(!1),[c,d]=r.useState([]),[l,x]=r.useState(null),[u,j]=r.useState(!1),m=r.useRef(null),o=r.useRef(0),p=async()=>{var v;try{j(!0);const y=await A.get("/notifications?limit=200");d(y.notifications||[]),x(y.stats||null),o.current=((v=y.stats)==null?void 0:v.unread)||0,s==null||s(o.current)}catch(y){console.warn("[notifications] reload failed:",y.message)}finally{j(!1)}};r.useEffect(()=>{p()},[]),r.useEffect(()=>t?t(y=>{if(y.type==="notification:new"){const $=y.notification;d(g=>[$,...g.filter(B=>B.id!==$.id)]),$.read||(o.current+=1,x(g=>g?{...g,unread:(g.unread||0)+1}:{total:1,unread:1,lastTs:$.ts,counts:{[$.severity||"info"]:1}}),s==null||s(o.current))}else y.type==="notifications:change"&&p()}):void 0,[t]),r.useEffect(()=>{if(!i)return;const v=$=>{m.current&&(m.current.contains($.target)||n(!1))},y=$=>{$.key==="Escape"&&n(!1)};return document.addEventListener("mousedown",v),document.addEventListener("keydown",y),()=>{document.removeEventListener("mousedown",v),document.removeEventListener("keydown",y)}},[i]);const k=async()=>{try{await A.post("/notifications/read-all",{}),d(v=>v.map(y=>({...y,read:!0}))),x(v=>v&&{...v,unread:0}),o.current=0,s==null||s(0),a.success("All notifications marked as read.",1500)}catch(v){a.error(`Failed: ${v.message}`)}},f=async v=>{try{await A.post(`/notifications/${encodeURIComponent(v)}/read`,{}),d(y=>y.map($=>$.id===v?{...$,read:!0}:$)),x(y=>y&&{...y,unread:Math.max(0,(y.unread||1)-1)}),o.current=Math.max(0,o.current-1),s==null||s(o.current)}catch(y){a.error(`Failed: ${y.message}`)}},S=async v=>{try{await A.del(`/notifications/${encodeURIComponent(v)}`),d(y=>{const $=y.find(g=>g.id===v);return $&&!$.read&&(o.current=Math.max(0,o.current-1),x(g=>g&&{...g,unread:Math.max(0,g.unread-1)}),s==null||s(o.current)),y.filter(g=>g.id!==v)})}catch(y){a.error(`Failed: ${y.message}`)}},b=(l==null?void 0:l.unread)||0;return e.jsxs("div",{className:"notifications-root",ref:m,children:[e.jsxs("button",{type:"button",className:ae("topbar-icon-btn notifications-bell",i&&"is-open"),onClick:()=>n(v=>!v),title:"Notifications","aria-label":"Notifications","aria-haspopup":"true","aria-expanded":i,children:[e.jsx(sa,{size:16}),b>0&&e.jsx("span",{className:"notifications-badge",children:b>99?"99+":b})]}),i&&e.jsxs("div",{className:"notifications-panel",role:"dialog","aria-label":"Notifications",children:[e.jsxs("header",{className:"notifications-panel-head",children:[e.jsxs("div",{children:[e.jsx("strong",{children:"Notifications"}),b>0&&e.jsxs("span",{className:"muted text-sm",children:[" · ",b," unread"]})]}),e.jsxs("div",{className:"notifications-panel-head-actions",children:[e.jsxs(z,{size:"sm",variant:"ghost",onClick:k,disabled:b===0,children:[e.jsx(Ps,{size:12})," Mark all read"]}),e.jsx("button",{type:"button",className:"icon-btn",onClick:()=>n(!1),"aria-label":"Close",title:"Close",children:e.jsx($e,{size:14})})]})]}),e.jsx("div",{className:"notifications-list",children:u&&c.length===0?e.jsx("div",{className:"notifications-empty muted",children:"Loading…"}):c.length===0?e.jsx("div",{className:"notifications-empty muted",children:"No notifications yet."}):c.map(v=>{const y=zn[v.severity]||Ns;return e.jsxs("div",{className:ae("notification-item",!v.read&&"is-unread",`severity-${v.severity}`),children:[e.jsx(y,{size:14,className:`notification-icon severity-${v.severity}`}),e.jsxs("div",{className:"notification-body",children:[v.title&&e.jsx("div",{className:"notification-title",children:v.title}),e.jsx("div",{className:"notification-msg",children:v.message}),e.jsxs("div",{className:"notification-meta muted",children:[e.jsx("span",{className:"mono",children:v.source}),e.jsx("span",{children:"·"}),e.jsx("span",{children:ve(v.ts)})]})]}),e.jsxs("div",{className:"notification-actions",children:[!v.read&&e.jsx("button",{type:"button",className:"icon-btn",onClick:()=>f(v.id),title:"Mark as read","aria-label":"Mark as read",children:e.jsx(Ps,{size:12})}),e.jsx("button",{type:"button",className:"icon-btn icon-btn-danger",onClick:()=>S(v.id),title:"Remove","aria-label":"Remove",children:e.jsx($e,{size:12})})]})]},v.id)})}),e.jsx("footer",{className:"notifications-panel-foot",children:e.jsx("span",{className:"muted text-sm",children:l?`${l.total} total · last ${ve(l.lastTs||new Date().toISOString())}`:""})})]})]})}function Mn({data:s,onClose:t}){const a=s==null?void 0:s.enabled;s==null||s.previousEnabled;const i=s==null?void 0:s.mode,n=s==null?void 0:s.defaultTemplate,c=s==null?void 0:s.lastUsedSlug,d=i==="toggle";return e.jsxs("div",{children:[d?e.jsxs("p",{style:{marginBottom:16,lineHeight:1.6},children:["Visual plan mode has been ",e.jsx("strong",{children:a?"enabled":"disabled"}),".",a?" The agent will create a plan and wait for your feedback on complex tasks.":" The agent will work without a visual plan canvas."]}):e.jsxs("div",{style:{marginBottom:16},children:[e.jsxs("p",{style:{marginBottom:8,fontWeight:600},children:["Visual Plan: ",e.jsx("span",{style:{color:a?"var(--color-success)":"var(--color-muted)"},children:a?"ON":"OFF"})]}),e.jsx("p",{style:{lineHeight:1.6,color:"var(--color-muted)",fontSize:13},children:"When enabled, the agent creates a visual plan and waits for your feedback before proceeding with complex tasks."}),n&&e.jsxs("p",{style:{marginTop:8,fontSize:13,color:"var(--color-muted)"},children:["Default template: ",e.jsx("code",{children:n})]}),c&&e.jsxs("p",{style:{fontSize:13,color:"var(--color-muted)"},children:["Last used plan: ",e.jsx("code",{children:c})]}),e.jsxs("p",{style:{marginTop:12,fontSize:13,color:"var(--color-muted)"},children:["Use ",e.jsx("code",{children:"/visual-plan on"})," or ",e.jsx("code",{children:"/visual-plan off"})," to toggle."]})]}),e.jsx("div",{style:{display:"flex",gap:8,justifyContent:"flex-end"},children:e.jsx(z,{variant:"ghost",onClick:t,children:"Close"})})]})}const An=["blank","feature-design","bug-investigation","decision-record","horizontal","vertical"];function $n({data:s,onClose:t}){const a=(s==null?void 0:s.templates)??An,i=(s==null?void 0:s.defaultTemplate)??"blank",[n,c]=r.useState(""),[d,l]=r.useState(i),[x,u]=r.useState(!1),[j,m]=r.useState(null),o=async()=>{if(!n.trim()){m("Slug is required.");return}if(!/^[a-z0-9][a-z0-9-]{0,63}$/.test(n)){m("Invalid slug. Use lowercase letters, numbers, and hyphens. Must start with an alphanumeric character.");return}u(!0),m(null);try{await A.post("/artifacts",{slug:n,template:d}),t()}catch(p){m(p.message),u(!1)}};return e.jsxs("div",{children:[e.jsxs("p",{style:{marginBottom:16,color:"var(--color-muted)",fontSize:13},children:["Create a new visual plan. Plans are stored in ",e.jsx("code",{children:"artifacts/"})," in your worktree."]}),e.jsxs("div",{style:{marginBottom:12},children:[e.jsx("label",{className:"field-label",htmlFor:"plan-slug",children:"Plan slug"}),e.jsx("input",{id:"plan-slug",className:"input",type:"text",placeholder:"e.g. my-feature",value:n,onChange:p=>{c(p.target.value),m(null)},autoFocus:!0})]}),e.jsxs("div",{style:{marginBottom:16},children:[e.jsx("label",{className:"field-label",htmlFor:"plan-template",children:"Template"}),e.jsx("select",{id:"plan-template",className:"select",value:d,onChange:p=>l(p.target.value),children:a.map(p=>e.jsx("option",{value:p,children:p},p))})]}),j&&e.jsx("p",{style:{marginBottom:12,color:"var(--color-danger)",fontSize:13},children:j}),e.jsxs("div",{style:{display:"flex",gap:8,justifyContent:"flex-end"},children:[e.jsx(z,{variant:"ghost",onClick:t,disabled:x,children:"Cancel"}),e.jsx(z,{variant:"primary",onClick:o,disabled:x||!n.trim(),children:x?"Creating…":"Create"})]})]})}function In({data:s,onClose:t}){const a=(s==null?void 0:s.plans)??[],i=(s==null?void 0:s.count)??a.length,n=c=>{window.open(`/artifacts/${c}/`,"_blank")};return e.jsxs("div",{children:[a.length===0?e.jsxs("p",{style:{marginBottom:16,color:"var(--color-muted)"},children:["No plans found in this worktree. Use ",e.jsx("code",{children:"/artifact new <slug>"})," to create one."]}):e.jsxs("div",{style:{marginBottom:16},children:[e.jsxs("p",{style:{marginBottom:12,fontSize:13,color:"var(--color-muted)"},children:[i," plan",i!==1?"s":""," in this worktree:"]}),e.jsx("ul",{style:{listStyle:"none",padding:0,margin:0},children:a.map(c=>e.jsxs("li",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"6px 0",borderBottom:"1px solid var(--color-border)"},children:[e.jsx("code",{style:{fontSize:13},children:c}),e.jsx(z,{variant:"ghost",size:"sm",onClick:()=>n(c),children:"Open"})]},c))})]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(z,{variant:"ghost",onClick:t,children:"Close"})})]})}function Rn({data:s,onClose:t}){const a=(s==null?void 0:s.commands)??[],i=(s==null?void 0:s.templates)??[],n=(s==null?void 0:s.statuses)??[];return e.jsxs("div",{children:[a.length>0?e.jsx("table",{style:{width:"100%",borderCollapse:"collapse",marginBottom:16,fontSize:13},children:e.jsx("tbody",{children:a.map(c=>e.jsxs("tr",{style:{borderBottom:"1px solid var(--color-border)"},children:[e.jsx("td",{style:{padding:"5px 8px 5px 0",whiteSpace:"nowrap"},children:e.jsx("code",{style:{fontSize:12},children:c.cmd})}),e.jsx("td",{style:{padding:"5px 0",color:"var(--color-muted)"},children:c.desc})]},c.cmd))})}):e.jsx("p",{style:{marginBottom:16,color:"var(--color-muted)"},children:"No commands available."}),i.length>0&&e.jsxs("div",{style:{marginBottom:12},children:[e.jsx("p",{style:{fontSize:12,color:"var(--color-muted)",marginBottom:4},children:"Available templates:"}),e.jsx("p",{style:{fontSize:13},children:i.join(", ")})]}),n.length>0&&e.jsxs("div",{style:{marginBottom:12},children:[e.jsx("p",{style:{fontSize:12,color:"var(--color-muted)",marginBottom:4},children:"Available statuses:"}),e.jsx("p",{style:{fontSize:13},children:n.join(", ")})]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(z,{variant:"ghost",onClick:t,children:"Close"})})]})}function Dn({data:s,onClose:t}){const[a,i]=r.useState(!1),[n,c]=r.useState(null),d=async()=>{i(!0),c(null);try{const l=await A.post("/chat/audit",{});c(l)}catch(l){c({ok:!1,findings:[],error:l.message})}finally{i(!1)}};return e.jsx("div",{children:n===null?e.jsxs(e.Fragment,{children:[e.jsx("p",{style:{marginBottom:16,lineHeight:1.6},children:"Run a security audit of your Bizar agent configuration. The audit checks for common misconfigurations, exposed secrets, and insecure defaults."}),e.jsxs("div",{style:{display:"flex",gap:8,justifyContent:"flex-end"},children:[e.jsx(z,{variant:"ghost",onClick:t,children:"Cancel"}),e.jsx(z,{variant:"primary",onClick:d,disabled:a,children:a?"Running…":"Run Audit"})]})]}):e.jsxs(e.Fragment,{children:[n.ok?e.jsxs("div",{children:[e.jsx("p",{style:{marginBottom:12,fontWeight:600,color:"var(--color-success)"},children:"Audit passed — no issues found."}),n.findings.length>0&&e.jsx("ul",{style:{marginBottom:16,paddingLeft:20},children:n.findings.map((l,x)=>e.jsx("li",{style:{marginBottom:4,fontSize:13},children:l},x))})]}):e.jsxs("p",{style:{marginBottom:16,color:"var(--color-danger)"},children:["Audit failed: ",n.error??"unknown error"]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(z,{variant:"ghost",onClick:t,children:"Close"})})]})})}function Ln({dialog:s,onClose:t}){if(!s.data)return e.jsxs("div",{children:[e.jsx("p",{style:{marginBottom:16,lineHeight:1.6},children:`Command: ${s.command}`}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx("button",{type:"button",className:"btn",onClick:t,children:"Close"})})]});const{message:a,detail:i,url:n}=s.data;return e.jsxs("div",{children:[e.jsx("p",{style:{marginBottom:16,lineHeight:1.6},children:a??`Command: ${s.command}`}),i&&e.jsx("p",{style:{marginBottom:16,color:"var(--color-muted)",fontSize:13},children:i}),n&&e.jsx("p",{style:{marginBottom:16},children:e.jsx("a",{href:n,target:"_blank",rel:"noopener noreferrer",children:n})}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx("button",{type:"button",className:"btn",onClick:t,children:"Close"})})]})}function Pn({dialog:s,onClose:t}){switch(s.component){case"visual-artifact":return e.jsx(Mn,{data:s.data,onClose:t});case"artifact-create":return e.jsx($n,{data:s.data,onClose:t});case"artifact-list":return e.jsx(In,{data:s.data,onClose:t});case"help":return e.jsx(Rn,{data:s.data,onClose:t});case"audit":return e.jsx(Dn,{data:s.data,onClose:t});default:return e.jsx(Ln,{dialog:s,onClose:t})}}function te({variant:s="elevated",interactive:t=!1,className:a,children:i,...n}){return e.jsx("div",{className:ae("card",`card-${s}`,t&&"card-interactive",a),...n,children:i})}function le({children:s,className:t}){return e.jsx("h3",{className:ae("card-title",t),children:s})}function oe({children:s,className:t}){return e.jsx("div",{className:ae("card-meta",t),children:s})}function Ie({icon:s,title:t,message:a,action:i,className:n}){return e.jsxs("div",{className:ae("empty-state",n),children:[e.jsx("div",{className:"empty-icon",children:s??e.jsx(vs,{size:32})}),e.jsx("div",{className:"empty-title",children:t}),a&&e.jsx("div",{className:"empty-message",children:a}),i&&e.jsx("div",{className:"empty-action",children:i})]})}function En({snapshot:s,settings:t,setActiveTab:a,refreshSnapshot:i}){var X,ne,se;const n=ce(),c=ke(),d=r.useRef(null),[l,x]=r.useState(s.overview??null),[u,j]=r.useState(!s.overview),[m,o]=r.useState(s.projects||[]),[p,k]=r.useState(((X=s.activeProject)==null?void 0:X.id)||null),[f,S]=r.useState(s.mods||[]),[b,v]=r.useState(!1),[y,$]=r.useState(((ne=s.overview)==null?void 0:ne.recentActivity)??[]),[g,B]=r.useState(!1),[H,R]=r.useState(new Set);r.useEffect(()=>{let U=!1;return(async()=>{try{const O=await A.get("/activity/hidden");U||R(new Set(O.hidden||[]))}catch{}})(),()=>{U=!0}},[]);const J=(U,O)=>{const Q=`${U.kind||""}|${U.ts||""}|${U.slug||U.title||""}|${O}`;let F=0;for(let q=0;q<Q.length;q++)F=(F<<5)-F+Q.charCodeAt(q)|0;return Math.abs(F).toString(16).padStart(8,"0").slice(0,16)},D=async U=>{const O=new Set(H);O.add(U),R(O);try{await A.post("/activity/hide",{keys:[U]})}catch(Q){const F=new Set(H);R(F),n.error(`Hide failed: ${Q.message}`)}},L=async()=>{if(!confirm("Hide every recent activity item from the overview? The full log stays in Settings → Activity Log."))return;const U=y.map((Q,F)=>J(Q,F)),O=new Set(H);U.forEach(Q=>O.add(Q)),R(O);try{await A.post("/activity/hide",{keys:U}),n.success(`Hidden ${U.length} item(s). Restore them in Settings → Activity Log.`)}catch(Q){n.error(`Clear failed: ${Q.message}`)}},V=async()=>{R(new Set);try{await A.del("/activity/hide"),n.success("All hidden activity restored to the overview.")}catch(U){n.error(`Restore failed: ${U.message}`)}};r.useEffect(()=>{var U;s.overview&&(x(s.overview),$(s.overview.recentActivity??[]),j(!1)),o(s.projects||[]),k(((U=s.activeProject)==null?void 0:U.id)||null),S(s.mods||[])},[s.overview,s.projects,s.activeProject,s.mods]),r.useEffect(()=>{let U;try{const O=A.getToken(),Q=O?`/api/activity/stream?token=${encodeURIComponent(O)}`:"/api/activity/stream";U=new EventSource(Q),U.addEventListener("snapshot",F=>{try{const q=JSON.parse(F.data);$(Array.isArray(q.events)?q.events.slice(0,50):[])}catch{}}),U.addEventListener("activity",F=>{try{const q=JSON.parse(F.data);$(ee=>[q,...ee].slice(0,50))}catch{}})}catch{}return()=>{try{U==null||U.close()}catch{}}},[]);const K=async()=>{n.info("Refreshing…",1500),await i();try{const U=await A.get("/projects");o(U.projects||[]),k(U.active||null)}catch{}},w=()=>{c.open({title:"Add project",children:e.jsx(Bn,{settings:t,onAdd:async(U,O)=>{try{const Q=await A.post("/projects",{path:U,name:O});o(F=>[...F.filter(q=>q.id!==Q.id),Q]),n.success("Project added."),c.close()}catch(Q){n.error(`Add failed: ${Q.message}`)}}}),footer:e.jsx("div",{className:"modal-footer-actions",children:e.jsx(z,{variant:"ghost",onClick:()=>c.close(),children:"Cancel"})})})},I=async()=>{var U;try{const O=await A.post("/projects/auto-detect");o(O.projects||[]),k(O.active||null);const Q=(U=O.projects)==null?void 0:U.find(F=>F.id===O.active);n.success(Q?`Active: ${Q.name}`:"Projects refreshed."),await i()}catch(O){n.error(`Auto-detect failed: ${O.message}`)}},_=async U=>{try{await A.post(`/projects/${encodeURIComponent(U)}/activate`),k(U),n.success("Project activated."),await i()}catch(O){n.error(`Activate failed: ${O.message}`)}},W=async U=>{if(confirm(`Remove project "${U}" from the registry?`))try{await A.del(`/projects/${encodeURIComponent(U)}`),o(O=>O.filter(Q=>Q.id!==U)),p===U&&k(null),n.success("Project removed.")}catch(O){n.error(`Remove failed: ${O.message}`)}};return u||!l?e.jsxs("div",{className:"view-loading",children:[e.jsx(je,{size:"lg"}),e.jsx("p",{children:"Loading overview…"})]}):e.jsxs("div",{className:"view view-overview",children:[e.jsxs("div",{className:"overview-hero-noframe",children:[e.jsx("h1",{children:"What do you want to do?"}),e.jsx("p",{className:"overview-hero-subtitle",children:"Describe what you want — Odin will split it into tasks, create a plan, delegate to background agents, and track progress in real time."}),e.jsxs("form",{className:"overview-hero-form-noframe",onSubmit:async U=>{var Q,F;U.preventDefault();const O=(((Q=d.current)==null?void 0:Q.value)||"").trim();if(O){v(!0);try{const q=await A.post("/tasks/submit",{title:O});n.success(`Odin split it into ${((F=q.subtasks)==null?void 0:F.length)||1} task(s)`),d.current&&(d.current.value=""),await i()}catch(q){n.error(`Failed: ${q.message}`)}finally{v(!1)}}},children:[e.jsx("textarea",{ref:d,className:"overview-input-hero",placeholder:"e.g. Implement user authentication with email + password, including registration, login, password reset, and integration tests. Use Bcrypt, JWT tokens, and the existing API style.",disabled:b}),e.jsxs("div",{style:{display:"flex",gap:"var(--space-2)",alignItems:"center",flexWrap:"wrap"},children:[e.jsxs(z,{type:"submit",variant:"primary",size:"lg",disabled:b,children:[b?e.jsx(je,{size:"sm"}):e.jsx(Qe,{size:16}),"Submit to Odin"]}),e.jsxs("span",{className:"muted",style:{fontSize:12},children:[e.jsx(Te,{size:12,style:{display:"inline",verticalAlign:-2,color:"var(--accent)"}})," ","Odin + 12 specialist agents available"]})]})]}),e.jsx("div",{className:"overview-quick-actions-row",children:["Implement feature","Fix bug","Refactor","Investigate","Add tests","Document","Optimize","Deploy"].map(U=>e.jsx("button",{type:"button",className:"overview-quick-chip",onClick:()=>{d.current&&(d.current.value=U,d.current.focus())},children:U},U))})]}),e.jsxs("div",{className:"overview-feed",children:[e.jsxs("div",{className:"overview-feed-head",children:[e.jsx("h2",{children:"Recent activity"}),e.jsxs("div",{className:"overview-feed-head-actions",children:[H.size>0&&e.jsxs(z,{variant:"ghost",size:"sm",onClick:V,title:"Restore hidden items to this overview",children:[e.jsx(ls,{size:12})," Show ",H.size," hidden"]}),y.length>8&&e.jsx(z,{variant:"ghost",size:"sm",onClick:()=>B(U=>!U),children:g?"Show less":"Show all"}),y.length>0&&e.jsxs(z,{variant:"ghost",size:"sm",onClick:L,title:"Hide every item from the overview (full log kept)",children:[e.jsx(lt,{size:12})," Hide all"]})]})]}),H.size>0&&e.jsxs("div",{className:"activity-hidden-banner",role:"status",children:[e.jsxs("span",{children:[e.jsx(lt,{size:12,style:{verticalAlign:-2,marginRight:6}}),H.size," item",H.size===1?"":"s"," hidden from the overview."]}),e.jsxs(z,{variant:"ghost",size:"sm",onClick:V,children:[e.jsx(ls,{size:12})," Show them again"]})]}),y.length===0?e.jsx("div",{className:"muted",style:{padding:"24px 0",fontSize:13},children:"No activity yet. Use the chat above or invoke a Bizar command to start a feed."}):e.jsxs("div",{className:ae("activity-feed-list-wrap",!g&&"activity-feed-list-wrap-collapsed"),children:[e.jsx("div",{className:"activity-feed-list",children:y.slice(0,30).map((U,O)=>{const Q=J(U,O);return H.has(Q)?null:e.jsx(Kn,{item:U,activityKey:Q,onNavigate:a,onHide:D},`${U.ts}-${O}`)})}),!g&&y.length>8&&e.jsx("div",{className:"activity-feed-fade","aria-hidden":"true"})]})]}),e.jsxs(te,{className:"project-picker",children:[e.jsxs(le,{children:[e.jsx(Ue,{size:14})," Projects",e.jsxs(z,{variant:"ghost",size:"sm",style:{marginLeft:"auto"},onClick:w,children:[e.jsx(pe,{size:12})," Add"]}),e.jsxs(z,{variant:"ghost",size:"sm",onClick:I,title:"Use the server's working directory",children:[e.jsx(pe,{size:12})," Auto-detect"]}),((se=t==null?void 0:t.dashboard)==null?void 0:se.projectsDirectory)&&e.jsxs(z,{variant:"ghost",size:"sm",title:`Scan ${t.dashboard.projectsDirectory} for projects`,onClick:async()=>{try{const U=await A.post("/projects/scan");U.error?n.error(U.error):n.success(`Added ${U.added.length}, skipped ${U.skipped}.`),await i();const O=await A.get("/projects");o(O.projects||[]),k(O.active||null)}catch(U){n.error(`Scan failed: ${U.message}`)}},children:[e.jsx(qa,{size:12})," Scan"]}),e.jsx(z,{variant:"ghost",size:"sm",onClick:K,title:"Refresh",children:e.jsx(de,{size:12})})]}),e.jsxs(oe,{children:[m.length," project",m.length===1?"":"s"," ·"," ",l.counts.agents," agents ·"," ",l.counts.sessions," session",l.counts.sessions===1?"":"s"]}),m.length===0?e.jsx(Ie,{icon:e.jsx(Ue,{size:32}),title:"No projects yet",message:"Add a project to start tracking its tasks, plans, and schedules.",action:e.jsxs("div",{className:"empty-state-actions",children:[e.jsxs(z,{variant:"primary",onClick:I,children:[e.jsx(pe,{size:14})," Use current directory"]}),e.jsx(z,{variant:"secondary",onClick:w,children:"Add by path…"})]})}):e.jsx("div",{className:"project-grid",children:m.map(U=>e.jsx(On,{project:U,active:p===U.id,onOpen:()=>_(U.id),onRemove:()=>W(U.id)},U.id))})]}),e.jsxs("div",{className:"overview-cols",children:[e.jsxs(te,{children:[e.jsx(le,{children:"Mods"}),e.jsxs(oe,{children:["Extensions installed under ",e.jsx("code",{children:"~/.config/bizar/mods/"})]}),f.length===0?e.jsx("div",{className:"muted",children:"No mods installed."}):e.jsx("ul",{className:"mod-mini-list",children:f.map(U=>e.jsxs("li",{className:"mod-mini",children:[e.jsx("span",{className:"mod-mini-name",children:U.name}),e.jsxs("span",{className:"mod-mini-meta",children:["v",U.version," · ",U.type]}),e.jsx("span",{className:`mod-mini-pill ${U.enabled?"mod-mini-pill-on":"mod-mini-pill-off"}`,children:U.enabled?"on":"off"})]},U.id))})]}),e.jsxs(te,{children:[e.jsx(le,{children:"Environment"}),e.jsx(oe,{children:"Runtime + paths"}),e.jsxs("dl",{className:"env-table",children:[e.jsx("dt",{children:"Node"}),e.jsx("dd",{className:"mono",children:l.versions.node}),e.jsx("dt",{children:"Platform"}),e.jsx("dd",{className:"mono",children:l.versions.platform}),e.jsx("dt",{children:"Project root"}),e.jsx("dd",{className:"mono ellipsis",title:l.versions.projectRoot,children:l.versions.projectRoot}),e.jsx("dt",{children:"Bizar root"}),e.jsx("dd",{className:"mono ellipsis",title:l.versions.bizarRoot,children:l.versions.bizarRoot}),e.jsx("dt",{children:"Generated"}),e.jsx("dd",{className:"mono tabular-nums",children:vt(l.generatedAt)})]})]})]})]})}function Bn({settings:s,onAdd:t}){var m,o;const[a,i]=r.useState(((m=s==null?void 0:s.dashboard)==null?void 0:m.projectsDirectory)??""),[n,c]=r.useState(""),[d,l]=r.useState(!1),[x,u]=r.useState(null),j=async()=>{var p;if(a){l(!0),u(null);try{await A.get("/fs?path="+encodeURIComponent(a)),t(a,n||null)}catch(k){const f=k;f.status===404?u("That folder no longer exists. Pick another."):u(((p=f.data)==null?void 0:p.message)??k.message??"Validation failed.")}finally{l(!1)}}};return e.jsxs("div",{children:[e.jsx("label",{className:"field-label",children:"Folder"}),e.jsx(Lt,{value:a,onChange:p=>{i(p),u(null)},projectsDirectory:(o=s==null?void 0:s.dashboard)==null?void 0:o.projectsDirectory,height:320}),x&&e.jsx("p",{className:"field-help",style:{color:"var(--error)",marginTop:4},children:x}),e.jsxs("div",{style:{marginTop:"var(--space-3)"},children:[e.jsx("label",{className:"field-label",htmlFor:"add-project-name",children:"Name (optional)"}),e.jsx("input",{id:"add-project-name",className:"input",type:"text",placeholder:"My App",value:n,onChange:p=>c(p.target.value)}),e.jsx("p",{className:"field-help",style:{marginTop:4},children:"Display name for this project. Defaults to the folder name."})]}),e.jsx("div",{style:{marginTop:"var(--space-3)",display:"flex",justifyContent:"flex-end"},children:e.jsxs(z,{variant:"primary",onClick:j,disabled:!a||d,children:[d?e.jsx("span",{className:"btn-spinner"}):null,d?"Checking…":"Add"]})})]})}function On({project:s,active:t,onOpen:a,onRemove:i}){const n={active:"status-on",inactive:"status-neutral",error:"status-error"}[s.status]||"status-neutral";return e.jsxs("div",{className:`project-card ${t?"project-card-active":""}`,children:[e.jsxs("div",{className:"project-card-head",children:[e.jsx("span",{className:`project-card-status ${n}`,children:s.status}),e.jsx("div",{className:"project-card-name",children:s.name}),e.jsx("button",{type:"button",className:"icon-btn","aria-label":"Remove project",title:"Remove",onClick:c=>{c.stopPropagation(),i()},children:e.jsx(ye,{size:12})})]}),e.jsx("div",{className:"project-card-path mono ellipsis",title:s.path,children:s.path}),e.jsx("div",{className:"project-card-meta",children:s.lastAccessed&&e.jsxs("span",{className:"muted",children:["Last opened ",ve(s.lastAccessed)]})}),e.jsx("div",{className:"project-card-actions",children:e.jsx(z,{variant:t?"ghost":"primary",size:"sm",onClick:a,children:t?e.jsxs(e.Fragment,{children:[e.jsx(Ws,{size:12})," Active"]}):e.jsx(e.Fragment,{children:"Open"})})})]})}function Fn(s){return s&&s.charAt(0).toUpperCase()+s.slice(1)}function Un(s){const t=s.trim().toLowerCase().replace(/[:_]/g,"."),[a,i="updated"]=t.split("."),n={settings:"Settings",task:"Task",tasks:"Task",agent:"Agent",agents:"Agent",plan:"Plan",plans:"Plan",bg:"Background job",background:"Background job",session:"Session",mod:"Mod",mods:"Mod",provider:"Provider",providers:"Provider"},c={create:"created",created:"created",add:"added",added:"added",update:"updated",updated:"updated",delegate:"delegated",delegated:"delegated",invoke:"invoked",invoked:"invoked",restart:"restarted",restarted:"restarted",delete:"deleted",deleted:"deleted",remove:"removed",removed:"removed",archive:"archived",archived:"archived",restore:"restored",restored:"restored",complete:"completed",completed:"completed",fail:"failed",failed:"failed",error:"errored",stuck:"marked stuck"},d=n[a]||Fn(a.replace(/-/g," ")),l=c[i]||i.replace(/-/g," ");return`${d} ${l}`.trim()}function us(s,t){for(const a of t){const i=s[a];if(typeof i=="string"&&i.trim())return i.trim()}return""}function Hn(s){const t=us(s,["message","text","prompt","title","name"]);if(t)return t;const a=[],i=us(s,["slug"]),n=us(s,["agent","author"]),c=us(s,["status"]);return i&&a.push(`Plan ${i}`),n&&a.push(n),c&&a.push(c),a.length?a.join(" · "):"No additional details."}function qn(s){return ve(s)}function _n(s){const t=(s.kind||"").toLowerCase(),a=(s.status||"").toLowerCase();return t.includes("error")||a==="error"||a==="failure"?"error":t.includes("warn")||a==="blocked"?"warning":t.includes("done")||t.includes("success")||a==="done"?"success":"info"}function Vn(s){const t=s.toLowerCase();return t==="task"?Be:t==="agent"?Ee:t==="plan"?os:t.includes("bg")||t.includes("background")||t.includes("job")?hn:t==="mod"?ys:t==="skill"?Te:t.includes("error")||t.includes("failure")?Xa:t.includes("warn")?De:ze}function Wn(s){const t=s.toLowerCase();return t==="task"?"tasks":t==="agent"?"agents":t==="plan"?"artifacts":t.includes("bg")||t.includes("background")?"activity":t==="mod"?"mods":t==="skill"?"skills":null}function Kn({item:s,activityKey:t,onNavigate:a,onHide:i}){const n=_n(s),c=Vn(s.kind||""),d=Un(s.kind||"activity"),l=Hn(s),x=Wn(s.kind||""),u=n==="error"?"var(--error)":n==="warning"?"var(--warning)":n==="success"?"var(--success)":"var(--accent)";return e.jsxs("div",{className:ae("activity-feed-row",`activity-feed-row-${n}`),children:[e.jsxs("button",{type:"button",className:"activity-feed-row-main",onClick:()=>{x&&a(x)},title:x?`Open ${x}`:d,children:[e.jsx("div",{className:"activity-feed-icon",style:{color:u},children:e.jsx(c,{size:14})}),e.jsxs("div",{className:"activity-feed-body",children:[e.jsxs("div",{className:"activity-feed-title-row",children:[e.jsx("div",{className:"activity-feed-title",children:d}),e.jsx("div",{className:"activity-feed-time text-xs muted tabular-nums",children:qn(s.ts)})]}),e.jsx("div",{className:"activity-feed-summary text-sm",children:l})]})]}),e.jsx("button",{type:"button",className:"activity-feed-hide-btn",onClick:()=>i(t),title:"Hide this from the overview (kept in Settings → Activity Log)","aria-label":"Hide from overview",children:e.jsx($e,{size:12})})]})}function Gn({session:s,mode:t,anchor:a,renameDraft:i,setRenameDraft:n,onEdit:c,onDeleteRequest:d,onConfirmDelete:l,onConfirmRename:x,onClose:u}){const j=r.useRef(null),m=Math.round(a.rect.bottom+2),o=Math.max(8,Math.round(window.innerWidth-a.rect.right));r.useEffect(()=>{const k=b=>{const v=b.target;!j.current||!v||j.current.contains(v)||u()},f=b=>{b.key==="Escape"&&u()},S=window.setTimeout(()=>{document.addEventListener("mousedown",k),document.addEventListener("keydown",f)},0);return()=>{window.clearTimeout(S),document.removeEventListener("mousedown",k),document.removeEventListener("keydown",f)}},[u]),r.useEffect(()=>{if(t!=="rename")return;const k=window.setTimeout(()=>{var S;const f=(S=j.current)==null?void 0:S.querySelector("input.session-row-menu-input");f==null||f.focus(),f==null||f.select()},0);return()=>window.clearTimeout(k)},[t]);const p=e.jsxs("div",{ref:j,className:"session-row-menu",role:"menu","aria-label":`Options for ${s.title}`,style:{position:"fixed",top:m,right:o},onClick:k=>k.stopPropagation(),children:[t==="main"&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{type:"button",className:"session-row-menu-item",role:"menuitem",onClick:k=>{k.stopPropagation(),c()},children:[e.jsx(rn,{size:13,"aria-hidden":!0}),e.jsx("span",{children:"Rename"}),e.jsx("kbd",{children:"R"})]}),e.jsxs("button",{type:"button",className:"session-row-menu-item session-row-menu-item-danger",role:"menuitem",onClick:k=>{k.stopPropagation(),d()},children:[e.jsx(ye,{size:13,"aria-hidden":!0}),e.jsx("span",{children:"Delete"}),e.jsx("kbd",{children:"⌫"})]})]}),t==="rename"&&e.jsxs("div",{className:"session-row-menu-inline",children:[e.jsx("div",{className:"session-row-menu-inline-label chat-mono",children:"Rename session"}),e.jsx("input",{type:"text",className:"session-row-menu-input",value:i,onChange:k=>n(k.target.value),onKeyDown:k=>{k.key==="Enter"?(k.preventDefault(),x()):k.key==="Escape"&&(k.preventDefault(),u())},onClick:k=>k.stopPropagation(),"aria-label":"New session name"}),e.jsxs("div",{className:"session-row-menu-inline-actions",children:[e.jsx("button",{type:"button",className:"btn btn-ghost",onClick:k=>{k.stopPropagation(),u()},children:"Cancel"}),e.jsx("button",{type:"button",className:"btn btn-primary",onClick:k=>{k.stopPropagation(),x()},children:"Save"})]})]}),t==="confirm-delete"&&e.jsxs("div",{className:"session-row-menu-inline",children:[e.jsx("div",{className:"session-row-menu-inline-label chat-mono",children:"Delete this session?"}),e.jsxs("div",{className:"session-row-menu-inline-message",children:['"',s.title,'" and its sub-agents will be removed.']}),e.jsxs("div",{className:"session-row-menu-inline-actions",children:[e.jsx("button",{type:"button",className:"btn btn-ghost",onClick:k=>{k.stopPropagation(),u()},children:"Cancel"}),e.jsx("button",{type:"button",className:"btn btn-danger",onClick:k=>{k.stopPropagation(),l()},children:"Delete"})]})]})]});return ta.createPortal(p,document.body)}function Us({node:s,depth:t=0,collapsible:a=!1,isLast:i=!0,open:n,onToggle:c}){var p;const[d,l]=r.useState(a),x=n!==void 0,u=x?n:d,j=k=>{x||l(k),c==null||c(k)},m=(((p=s.children)==null?void 0:p.length)??0)>0,o=e.jsxs(e.Fragment,{children:[a&&e.jsx("span",{className:`agent-node-chevron ${u?"open":""}`,"aria-hidden":!0,children:"›"}),e.jsx("span",{className:`agent-node-dot status-${s.status}`,"aria-hidden":!0}),e.jsx("span",{className:"agent-node-name",children:s.name}),s.role&&e.jsx("span",{className:"agent-node-role chat-mono",children:s.role}),e.jsx("span",{className:`agent-node-pill status-${s.status}`,children:s.status})]});return e.jsxs("div",{className:["agent-node",`depth-${t}`,`status-${s.status}`,u?"open":"closed",i?"last":""].filter(Boolean).join(" "),children:[a?e.jsx("button",{type:"button",className:`agent-node-head status-${s.status} collapsible`,onClick:k=>{k.stopPropagation(),j(!u)},"aria-expanded":u,children:o}):e.jsx("div",{className:`agent-node-head status-${s.status}`,children:o}),u&&e.jsxs(e.Fragment,{children:[s.summary&&e.jsx("div",{className:"agent-node-summary",children:s.summary}),m&&e.jsx("div",{className:"agent-node-children",children:s.children.map((k,f)=>e.jsx(Us,{node:k,depth:t+1,collapsible:!1,isLast:f===s.children.length-1},k.id))})]})]})}function Yn(s){return s.tree!==void 0}function Jn(s){const t=s.open??!0;if(Yn(s))return e.jsx("div",{className:`agent-tree variant-${s.variant??"full"}`,children:e.jsx(Us,{node:s.tree.root,depth:0,open:t})});const a=s.children??[];return e.jsx("div",{className:`agent-tree variant-${s.variant} agent-tree-children-only`,children:e.jsx("div",{className:"agent-tree-children-body",children:a.map((i,n)=>e.jsx(r.Fragment,{children:e.jsx(Us,{node:i,depth:0,collapsible:!1,open:t,isLast:n===a.length-1})},i.id))})})}function Xn({children:s,variant:t="rail",open:a=!0}){return a?e.jsx(Jn,{variant:t,open:a,children:s}):null}const Qn=["Today","Yesterday","This week","Earlier"];function ct(s,t){return s.getFullYear()===t.getFullYear()&&s.getMonth()===t.getMonth()&&s.getDate()===t.getDate()}function Zn(s,t){const a=s.getTime()-t.getTime();return Math.floor(a/(1e3*60*60*24))}function ei(s){const t=new Date,a=new Date(t);a.setDate(a.getDate()-1);const i=new Date(t);i.setDate(i.getDate()-7);const n={Today:[],Yesterday:[],"This week":[],Earlier:[]};for(const c of s){const d=new Date(Number(c.mtime)||Date.now());ct(d,t)?n.Today.push(c):ct(d,a)?n.Yesterday.push(c):Zn(t,d)<7?n["This week"].push(c):n.Earlier.push(c)}return n}function si(s){return new Date(Number(s)||Date.now()).toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit",hour12:!1})}function ti({state:s,agent:t}){return s==="streaming"?e.jsx("span",{className:"session-state session-state-streaming",title:`${t||"Odin"} is typing…`}):s==="awaiting"?e.jsx("span",{className:"session-state session-state-awaiting",title:"Awaiting your reply","aria-hidden":!0}):s==="idle"?e.jsx("span",{className:"session-state session-state-idle","aria-hidden":!0}):null}function ai({sessions:s,opencodeSessions:t=[],activeSessionId:a,activeOpencodeSessionId:i,activeProject:n,creating:c,onCreateSession:d,onSelectSession:l,onSelectOpencodeSession:x,onRenameSession:u,onDeleteSession:j,groupBy:m}){var W;const o=r.useMemo(()=>[...s,...t],[s,t]),p=r.useMemo(()=>[...o].sort((X,ne)=>Number(ne.mtime??0)-Number(X.mtime??0)),[o]),k=r.useMemo(()=>m?m(p):ei(p),[m,p]),[f,S]=r.useState({}),b=X=>f[X]===!0,[v,y]=r.useState(null),[$,g]=r.useState("main"),[B,H]=r.useState(""),[R,J]=r.useState(null),D=r.useRef({}),L=(X,ne="main")=>{const se=D.current[X];if(!se)return;const U=ne==="main"?se:se.querySelector(".chat-rail-item-menu-trigger")??se;if(J({id:X,rect:U.getBoundingClientRect()}),y(X),g(ne),ne==="rename"){const O=[...s,...t].find(Q=>Q.id===X);H((O==null?void 0:O.title)??(O==null?void 0:O.id)??"")}},V=()=>{y(null),g("main"),H(""),J(null)},K=X=>{if(X.source==="opencode"){x(X);return}l(X.id)},w=()=>{if(!R)return;const X=R.id,ne=B.trim();if(!ne){V();return}u==null||u(X,ne),V()},I=()=>{R&&(j==null||j(R.id),V())},_=m?Object.entries(k):Qn.filter(X=>{var ne;return(ne=k[X])==null?void 0:ne.length}).map(X=>[X,k[X]]);return e.jsxs("aside",{className:"chat-rail",children:[e.jsx("div",{className:"chat-rail-head",children:e.jsxs("button",{type:"button",className:"chat-new-btn",onClick:d,disabled:c||!n,title:n?"Create new session":"Pick a project first","aria-label":"Create new session",children:[e.jsx(pe,{size:14,"aria-hidden":!0}),e.jsx("span",{children:c?"Creating…":"New session"})]})}),p.length===0?e.jsx("div",{className:"chat-sessions-empty",children:e.jsx(aa,{icon:e.jsx(pe,{size:20,"aria-hidden":!0}),title:n?"No sessions yet":"No project",message:n?"Create your first session to start chatting.":"Pick a project in Overview to scope chat sessions."})}):e.jsx("div",{className:"chat-rail-list",children:_.map(([X,ne])=>e.jsxs("div",{className:"chat-rail-group",children:[e.jsx("div",{className:"chat-rail-group-label",children:X}),ne.map(se=>{var ee,T;const U=se.source==="opencode",O=U?i===se.id:a===se.id,Q=se.tree,F=!!((ee=Q==null?void 0:Q.root)!=null&&ee.children&&Q.root.children.length>0),q=b(se.id);return e.jsxs(r.Fragment,{children:[e.jsxs("div",{ref:M=>{D.current[se.id]=M},role:"button",tabIndex:0,className:`chat-rail-item state-${se.state??"idle"}${O?" active":""}`,onClick:()=>K(se),onKeyDown:M=>{(M.key==="Enter"||M.key===" ")&&(M.preventDefault(),K(se))},"aria-current":O?"true":void 0,children:[e.jsx(ti,{state:se.state??"idle",agent:se.agent}),e.jsxs("div",{className:"chat-rail-item-title",children:[se.pinned&&e.jsx("span",{className:"chat-rail-pin","aria-hidden":!0,children:"★"}),U&&e.jsx(Ks,{size:11,style:{color:"var(--text-muted)",flexShrink:0},"aria-hidden":!0}),e.jsx("span",{className:"chat-ellipsis",children:se.title||se.id})]}),e.jsxs("div",{className:"chat-rail-item-meta",children:[e.jsx("span",{className:"chat-rail-item-meta-time",children:se.time??si(se.mtime)}),(se.unread??0)>0&&e.jsx("span",{className:"chat-rail-badge",children:se.unread})]}),e.jsx("button",{type:"button",className:`chat-rail-item-menu-trigger${v===se.id?" open":""}`,"aria-label":`Session options for ${se.title||se.id}`,"aria-haspopup":"menu","aria-expanded":v===se.id,onClick:M=>{M.stopPropagation(),v===se.id?V():L(se.id,"main")},children:e.jsxs("svg",{viewBox:"0 0 14 14","aria-hidden":!0,children:[e.jsx("circle",{cx:"3",cy:"7",r:"1.2",fill:"currentColor"}),e.jsx("circle",{cx:"7",cy:"7",r:"1.2",fill:"currentColor"}),e.jsx("circle",{cx:"11",cy:"7",r:"1.2",fill:"currentColor"})]})}),O&&F&&e.jsx("button",{type:"button",className:`chat-rail-tree-chevron${q?" open":""}`,"aria-label":q?"Collapse sub-agents":"Expand sub-agents","aria-expanded":q,onClick:M=>{M.stopPropagation(),S(C=>({...C,[se.id]:!C[se.id]}))},children:e.jsx("svg",{viewBox:"0 0 10 10","aria-hidden":!0,children:e.jsx("polyline",{points:"3,1.5 7,5 3,8.5"})})})]}),O&&F&&q&&((T=Q==null?void 0:Q.root)==null?void 0:T.children)&&e.jsx(Xn,{children:Q.root.children,variant:"rail",open:!0})]},U?`oc-${se.id}`:se.id)})]},X))}),v&&R&&e.jsx(Gn,{session:{id:R.id,title:((W=[...s,...t].find(X=>X.id===R.id))==null?void 0:W.title)??R.id},mode:$,anchor:R,renameDraft:B,setRenameDraft:H,onEdit:()=>L(v,"rename"),onDeleteRequest:()=>L(v,"confirm-delete"),onConfirmDelete:I,onConfirmRename:w,onClose:V})]})}function ni(s){const{text:t,sending:a,onSend:i}=s,[n,c]=r.useState(!1),d=()=>{t.trim()&&(c(!0),i(),window.setTimeout(()=>c(!1),320))};return e.jsxs("div",{className:"chat-composer-wrap",children:[e.jsx("div",{className:`chat-composer-pill${n?" takeoff":""}`,children:e.jsx(na,{...s,onSend:d})}),e.jsxs("div",{className:"chat-composer-hint chat-muted",children:[e.jsxs("span",{children:[e.jsx("kbd",{children:"⏎"})," send"]}),e.jsxs("span",{children:[e.jsx("kbd",{children:"⇧⏎"})," newline"]}),e.jsxs("span",{children:[e.jsx("kbd",{children:"/"})," commands"]})]})]})}function $s(s){return s.toLocaleString()}function ii({sessionId:s,messages:t,pinned:a,agent:i,model:n,agents:c,mcps:d,allCommands:l}){const x=(t==null?void 0:t.length)??0,u=(a==null?void 0:a.size)??0,j=0,m=128e3;return e.jsxs("aside",{className:"chat-info",children:[e.jsxs("div",{className:"chat-info-section",children:[e.jsx("h4",{children:"Session"}),e.jsx("div",{children:s||"Live"}),e.jsxs("div",{className:"chat-info-mono",children:[$s(x)," message",x===1?"":"s",u>0&&` · ${u} pinned`]})]}),e.jsxs("div",{className:"chat-info-section",children:[e.jsx("h4",{children:"Agent"}),e.jsx("div",{children:i||"—"})]}),e.jsxs("div",{className:"chat-info-section",children:[e.jsx("h4",{children:"Model"}),e.jsx("div",{className:"chat-mono chat-ellipsis",title:n,children:n||"—"})]}),e.jsxs("div",{className:"chat-info-section",children:[e.jsx("h4",{children:"Tokens"}),e.jsxs("div",{className:"chat-mono",children:[$s(j)," / ",$s(m)]}),e.jsx("div",{className:"chat-info-bar","aria-hidden":!0,children:e.jsx("div",{className:"chat-info-bar-fill",style:{width:`${Math.min(100,j/Math.max(1,m)*100)}%`}})})]}),e.jsxs("div",{className:"chat-info-section",children:[e.jsx("h4",{children:"Cost"}),e.jsxs("div",{className:"chat-mono",children:["$",0 .toFixed(4)]})]}),e.jsxs("div",{className:"chat-info-section",children:[e.jsxs("h4",{children:[e.jsx(Ee,{size:11,style:{marginRight:4,verticalAlign:-1},"aria-hidden":!0})," Attached agents"]}),c!=null&&c.length?e.jsx("div",{className:"chat-info-agents",children:c.map(p=>e.jsx("span",{className:"chat-info-agent",children:p.name},p.name))}):e.jsx("div",{className:"chat-info-mono",children:"None attached"})]}),e.jsxs("div",{className:"chat-info-section",children:[e.jsxs("h4",{children:[e.jsx(Fe,{size:11,style:{marginRight:4,verticalAlign:-1},"aria-hidden":!0})," MCPs"]}),d!=null&&d.length?e.jsx("div",{className:"chat-info-agents",children:d.map(p=>e.jsx("span",{className:"chat-info-agent",children:p.id},p.id))}):e.jsx("div",{className:"chat-info-mono",children:"No MCPs configured"})]}),e.jsxs("div",{className:"chat-info-section",children:[e.jsxs("h4",{children:[e.jsx(is,{size:11,style:{marginRight:4,verticalAlign:-1},"aria-hidden":!0})," Slash commands"]}),e.jsxs("div",{className:"chat-info-mono",children:[(l==null?void 0:l.length)??0," available"]})]}),e.jsxs("div",{className:"chat-info-section",children:[e.jsxs("h4",{children:[e.jsx(Ve,{size:11,style:{marginRight:4,verticalAlign:-1},"aria-hidden":!0})," ","Linked"]}),e.jsx("div",{className:"chat-info-mono",children:"No links yet"})]})]})}function li({streaming:s,newMessageCount:t,onClick:a,streamingLabel:i="Odin is replying"}){return e.jsx("button",{type:"button",className:`jump-to-latest${s?" is-streaming":""}`,onClick:a,"aria-label":"Jump to latest message",title:"Jump to latest (⌘/Ctrl+End)",children:s?e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"jump-dots","aria-hidden":!0,children:[e.jsx("span",{}),e.jsx("span",{}),e.jsx("span",{})]}),e.jsx("span",{children:i}),t>0&&e.jsx("span",{className:"jump-badge jump-badge-live",children:"live"})]}):e.jsxs(e.Fragment,{children:[e.jsx(Ma,{size:14,"aria-hidden":!0}),e.jsx("span",{children:"Jump to latest"}),t>0&&e.jsxs("span",{className:"jump-badge",children:[t," new"]})]})})}function ri({snapshot:s,settings:t,setActiveTab:a,initialTaskId:i,onClearTaskId:n}){const c=ce(),d=ke(),l=ia(s,t,i??""),[x,u]=r.useState(""),[j,m]=r.useState(t.defaultAgent||"odin"),[o,p]=r.useState(t.defaultModel||""),[k,f]=r.useState([]),[S,b]=r.useState(!1),v=r.useRef(null),{allCommands:y,suggestions:$,setQuery:g}=la(s);r.useEffect(()=>{g(x)},[x,g]);const B=()=>{var I;return(I=v.current)==null?void 0:I.click()},H=I=>{const _=I.target.files;if(!_)return;const W=[];for(let X=0;X<_.length;X++)W.push(_[X].name);f(X=>{const ne=W.filter(se=>!X.includes(se));return[...X,...ne]}),v.current&&(v.current.value="")},R=()=>{const I=x.trim();I&&(u(""),g(""),l.onSend(I,j,o,k),l.jumpToLatest())},J=async()=>{if(!S){if(!s.activeProject){c.warning("Pick a project in Overview to scope chat sessions.",4e3);return}b(!0);try{const I=await fetch("/chat/sessions",{method:"POST"}).then(_=>_.json());l.loadChat(I.id),c.success(`Session ${I.id} created.`)}catch(I){c.error(`Create failed: ${I.message}`)}finally{b(!1)}}},D=I=>{d.open({title:"Delete message?",children:e.jsx("p",{style:{margin:0},children:"This action cannot be undone."}),footer:e.jsxs("div",{style:{display:"flex",gap:8,justifyContent:"flex-end"},children:[e.jsx(z,{variant:"secondary",size:"sm",onClick:()=>d.close(),children:"Cancel"}),e.jsx(z,{variant:"danger",size:"sm",onClick:()=>{d.close(),l.deleteMessage(I)},children:"Delete"})]})})},L=r.useMemo(()=>l.sessions.map(I=>l.getSessionDisplay(I)),[l.sessions,l.getSessionDisplay]),V=r.useMemo(()=>l.opencodeSessions.map(I=>l.getSessionDisplay(I)),[l.opencodeSessions,l.getSessionDisplay]),K=r.useMemo(()=>{const I=l.activeSource==="opencode"?l.activeOpencodeSessionId??"":l.sessionId;return I?L.find(_=>_.id===I)??V.find(_=>_.id===I)??null:null},[l.activeSource,l.activeOpencodeSessionId,l.sessionId,L,V]),w=(()=>{var W;const I=`${j||"Odin"} · ${((W=s.activeProject)==null?void 0:W.name)??"no project"}`,_=(K==null?void 0:K.state)??"idle";return _==="streaming"?`Replying · ${I}`:_==="awaiting"?`Your turn · ${I}`:`${I} · idle`})();return e.jsxs("div",{className:"chat-shell",children:[e.jsx(ra,{activeProject:s.activeProject,sessionCount:l.sessions.length,sessionsOpen:!0,infoOpen:!0,onToggleSessions:()=>{},onToggleInfo:()=>{},onOpenOverview:()=>a==null?void 0:a("overview")}),e.jsxs("div",{className:"chat-page",children:[e.jsx(ai,{sessions:L,opencodeSessions:V,activeSessionId:l.sessionId,activeOpencodeSessionId:l.activeOpencodeSessionId,activeProject:s.activeProject,creating:S,onCreateSession:J,onSelectSession:l.selectBizarSession,onSelectOpencodeSession:I=>l.loadOpencodeSession(I.id),onRenameSession:(I,_)=>l.renameSession(I,_),onDeleteSession:I=>l.deleteSession(I)}),e.jsxs("section",{className:"chat-thread-section",children:[e.jsxs("div",{className:"chat-thread-head",children:[e.jsxs("div",{children:[e.jsx("div",{className:"chat-thread-title",children:(K==null?void 0:K.title)??l.sessionId??"New chat"}),e.jsxs("div",{className:`chat-thread-sub chat-muted state-${(K==null?void 0:K.state)??"idle"}`,children:[e.jsx("span",{className:"chat-thread-dot"}),w]})]}),e.jsx("div",{className:"chat-thread-actions",children:e.jsx("button",{className:"btn btn-ghost",title:"Rename",type:"button",children:e.jsx("span",{className:"mono",children:"rename"})})})]}),e.jsx("div",{className:"chat-thread-scroll",ref:l.listRef,onScroll:l.handleScroll,children:e.jsx(oa,{messages:l.activeSource==="opencode"?l.opencodeMessages:l.bizarMessages,loading:l.loading,activeProject:s.activeProject,sessionId:l.activeSource==="opencode"?l.activeOpencodeSessionId??l.sessionId:l.sessionId,pinned:l.pinned,onPickSuggestion:I=>u(I),onCopy:I=>l.copyMessage(I),onDelete:D,onTogglePin:l.togglePin,onRegenerate:l.onRegenerate})}),!l.stickToBottom&&e.jsx(li,{streaming:(K==null?void 0:K.state)==="streaming",newMessageCount:l.newMessageCount,onClick:l.jumpToLatest}),e.jsx(ni,{agent:j,setAgent:m,model:o,setModel:p,text:x,setText:u,sending:l.sending,onSend:R,attachments:k,setAttachments:f,suggestions:$,onPickSuggestion:I=>u(`${I.split(" ")[0]} `),agents:s.agents||[],onAttach:B}),e.jsx("input",{ref:v,type:"file",multiple:!0,style:{display:"none"},onChange:H})]}),e.jsx(ii,{sessionId:l.activeSource==="opencode"?l.activeOpencodeSessionId??l.sessionId:l.sessionId,messages:l.activeSource==="opencode"?l.opencodeMessages:l.bizarMessages,pinned:l.pinned,agent:j,model:o,agents:s.agents||[],mcps:s.mcps||[],allCommands:y})]})]})}function Pe({kind:s="neutral",children:t,className:a,dot:i=!1}){return e.jsxs("span",{className:ae("badge",`badge-${s}`,a),children:[i&&e.jsx("span",{className:"badge-dot"}),t]})}const dt=["bash","read","edit","write","webfetch","websearch","task","glob","grep"],mt=["anthropic/claude-3-5-sonnet","anthropic/claude-3-5-haiku","openai/gpt-4o","openai/gpt-4o-mini","openrouter/minimax/minimax-m3","openrouter/minimax/minimax-m2.7"],xs=[{id:"reasoning",label:"Reasoning",color:"var(--accent)"},{id:"code",label:"Code",color:"var(--info)"},{id:"design",label:"Design",color:"var(--success)"},{id:"planning",label:"Planning",color:"var(--warning)"},{id:"gitops",label:"GitOps",color:"var(--error)"},{id:"analysis",label:"Analysis",color:"var(--text-dim)"}];function oi(s){var t;return((t=xs.find(a=>a.id===s))==null?void 0:t.color)||"var(--text-dim)"}function ci({status:s,isStuck:t}){const a=t?"var(--error)":s==="working"?"var(--info)":s==="error"?"var(--error)":"var(--text-dim)";return e.jsx("span",{className:"agent-status-dot",style:{background:a}})}function di({agent:s}){if(s.isStuck)return e.jsx(Pe,{kind:"error",dot:!0,children:"stuck"});const t=s.status||"idle";return t==="working"?e.jsx(Pe,{kind:"info",dot:!0,children:"working"}):t==="error"?e.jsx(Pe,{kind:"error",dot:!0,children:"error"}):e.jsx(Pe,{kind:"neutral",dot:!0,children:"idle"})}function mi({snapshot:s,refreshSnapshot:t}){const a=ce(),i=ke(),[n,c]=r.useState(s.agents||[]),[d,l]=r.useState(!s.agents),[x,u]=r.useState(""),[j,m]=r.useState("");r.useEffect(()=>{c(s.agents||[]),l(!s.agents)},[s.agents]);const o=async()=>{try{const g=await A.get("/agents");c(g.agents||[])}catch(g){a.error(`Agents load failed: ${g.message}`)}finally{l(!1)}},p=r.useMemo(()=>{let g=[...n];if(x&&(g=g.filter(B=>x==="__none__"?!B.category:(B.category||"")===x)),j){const B=j.toLowerCase();g=g.filter(H=>H.name.toLowerCase().includes(B)||(H.description||"").toLowerCase().includes(B)||(H.tags||[]).some(R=>R.toLowerCase().includes(B)))}return g.sort((B,H)=>B.name.localeCompare(H.name))},[n,x,j]),k=r.useMemo(()=>{const g=new Set;for(const B of n)for(const H of B.tags||[])g.add(H);return Array.from(g).sort()},[n]),f=()=>{let g=null,B=null,H=null,R=null,J=null,D=null,L=null,V=null,K=null;i.open({title:"New agent",width:640,children:e.jsxs("div",{className:"agent-form",children:[e.jsx("label",{className:"field-label",children:"Name (a-z, 0-9, dashes)"}),e.jsx("input",{ref:w=>g=w,className:"input",type:"text",placeholder:"my-agent",autoFocus:!0}),e.jsx("label",{className:"field-label",children:"Description"}),e.jsx("input",{ref:w=>{B=w},className:"input",type:"text",placeholder:"What does this agent do?"}),e.jsxs("div",{className:"task-form-row",children:[e.jsxs("div",{className:"task-form-field",children:[e.jsx("label",{className:"field-label",children:"Model"}),e.jsxs("select",{ref:w=>H=w,className:"select",defaultValue:"",children:[e.jsx("option",{value:"",children:"(provider default)"}),mt.map(w=>e.jsx("option",{value:w,children:w},w))]})]}),e.jsxs("div",{className:"task-form-field",children:[e.jsx("label",{className:"field-label",children:"Mode"}),e.jsxs("select",{ref:w=>R=w,className:"select",defaultValue:"subagent",children:[e.jsx("option",{value:"primary",children:"primary"}),e.jsx("option",{value:"subagent",children:"subagent"}),e.jsx("option",{value:"all",children:"all"})]})]}),e.jsxs("div",{className:"task-form-field",style:{flex:"0 0 80px"},children:[e.jsx("label",{className:"field-label",children:"Color"}),e.jsx("input",{ref:w=>J=w,className:"input",type:"color",defaultValue:"#8b5cf6"})]})]}),e.jsxs("div",{className:"task-form-row",children:[e.jsxs("div",{className:"task-form-field",style:{flex:1},children:[e.jsx("label",{className:"field-label",children:"Category"}),e.jsxs("select",{ref:w=>K=w,className:"select",defaultValue:"",children:[e.jsx("option",{value:"",children:"(none)"}),xs.map(w=>e.jsx("option",{value:w.id,children:w.label},w.id))]})]}),e.jsxs("div",{className:"task-form-field",style:{flex:2},children:[e.jsx("label",{className:"field-label",children:"Tags (comma-separated)"}),e.jsx("input",{ref:w=>V=w,className:"input",type:"text",placeholder:"reasoning, code, planning"})]})]}),e.jsx("label",{className:"field-label",children:"Tools"}),e.jsx("div",{ref:w=>L=w,className:"agent-tools",children:dt.map(w=>e.jsxs("label",{className:"checkbox-row",children:[e.jsx("input",{type:"checkbox",value:w}),e.jsx("span",{children:w})]},w))}),e.jsx("label",{className:"field-label",children:"System prompt"}),e.jsx("textarea",{ref:w=>D=w,className:"textarea",rows:6,placeholder:"You are a..."})]}),footer:e.jsxs("div",{className:"modal-footer-actions",children:[e.jsx(z,{variant:"ghost",onClick:()=>i.close(),children:"Cancel"}),e.jsxs(z,{variant:"primary",onClick:async()=>{const w=((g==null?void 0:g.value)||"").trim();if(!/^[a-z0-9][a-z0-9-]{0,63}$/i.test(w)){a.warning("Invalid name (a-z, 0-9, dashes).");return}const I=[];L&&L.querySelectorAll('input[type="checkbox"]:checked').forEach(W=>{I.push(W.value)});const _=((V==null?void 0:V.value)||"").split(",").map(W=>W.trim()).filter(Boolean);try{const W=await A.post("/agents",{name:w,description:((B==null?void 0:B.value)||"").trim(),model:(H==null?void 0:H.value)||"",mode:(R==null?void 0:R.value)||"subagent",color:(J==null?void 0:J.value)||"",tools:I,tags:_,category:(K==null?void 0:K.value)||"",prompt:(D==null?void 0:D.value)||""});c(X=>[...X,W]),a.success("Agent created."),i.close(),await t()}catch(W){a.error(`Create failed: ${W.message}`)}},children:[e.jsx(Ze,{size:12})," Create"]})]})})},S=async g=>{let B=null,H=null,R=null,J=null,D=null,L=null,V=null,K=null;try{const w=await A.get(`/agents/${encodeURIComponent(g.name)}`);i.open({title:`Edit ${g.name}`,width:640,children:e.jsxs("div",{className:"agent-form",children:[e.jsxs("div",{className:"muted",children:["File: ",e.jsx("code",{children:w.path})]}),e.jsx("label",{className:"field-label",children:"Description"}),e.jsx("input",{ref:I=>{B=I},className:"input",type:"text",defaultValue:w.description}),e.jsxs("div",{className:"task-form-row",children:[e.jsxs("div",{className:"task-form-field",children:[e.jsx("label",{className:"field-label",children:"Model"}),e.jsxs("select",{ref:I=>H=I,className:"select",defaultValue:w.model,children:[e.jsx("option",{value:"",children:"(provider default)"}),mt.map(I=>e.jsx("option",{value:I,children:I},I))]})]}),e.jsxs("div",{className:"task-form-field",children:[e.jsx("label",{className:"field-label",children:"Mode"}),e.jsxs("select",{ref:I=>R=I,className:"select",defaultValue:w.mode||"subagent",children:[e.jsx("option",{value:"primary",children:"primary"}),e.jsx("option",{value:"subagent",children:"subagent"}),e.jsx("option",{value:"all",children:"all"})]})]}),e.jsxs("div",{className:"task-form-field",style:{flex:"0 0 80px"},children:[e.jsx("label",{className:"field-label",children:"Color"}),e.jsx("input",{ref:I=>J=I,className:"input",type:"color",defaultValue:w.color||"#8b5cf6"})]})]}),e.jsxs("div",{className:"task-form-row",children:[e.jsxs("div",{className:"task-form-field",style:{flex:1},children:[e.jsx("label",{className:"field-label",children:"Category"}),e.jsxs("select",{ref:I=>K=I,className:"select",defaultValue:w.category||"",children:[e.jsx("option",{value:"",children:"(none)"}),xs.map(I=>e.jsx("option",{value:I.id,children:I.label},I.id))]})]}),e.jsxs("div",{className:"task-form-field",style:{flex:2},children:[e.jsx("label",{className:"field-label",children:"Tags (comma-separated)"}),e.jsx("input",{ref:I=>V=I,className:"input",type:"text",defaultValue:(w.tags||[]).join(", ")})]})]}),e.jsx("label",{className:"field-label",children:"Tools"}),e.jsx("div",{ref:I=>L=I,className:"agent-tools",children:dt.map(I=>{var _;return e.jsxs("label",{className:"checkbox-row",children:[e.jsx("input",{type:"checkbox",value:I,defaultChecked:(_=w.tools)==null?void 0:_.includes(I)}),e.jsx("span",{children:I})]},I)})}),e.jsx("label",{className:"field-label",children:"System prompt"}),e.jsx("textarea",{ref:I=>D=I,className:"textarea",rows:8,defaultValue:w.prompt||""})]}),footer:e.jsxs("div",{className:"modal-footer-actions",children:[e.jsx(z,{variant:"ghost",onClick:()=>i.close(),children:"Cancel"}),e.jsxs(z,{variant:"primary",onClick:async()=>{const I=[];L&&L.querySelectorAll('input[type="checkbox"]:checked').forEach(W=>{I.push(W.value)});const _=((V==null?void 0:V.value)||"").split(",").map(W=>W.trim()).filter(Boolean);try{const W=await A.put(`/agents/${encodeURIComponent(g.name)}`,{description:((B==null?void 0:B.value)||"").trim(),model:(H==null?void 0:H.value)||"",mode:(R==null?void 0:R.value)||"subagent",color:(J==null?void 0:J.value)||"",tools:I,tags:_,category:(K==null?void 0:K.value)||"",prompt:(D==null?void 0:D.value)||""});c(X=>X.map(ne=>ne.name===g.name?W:ne)),a.success("Agent saved."),i.close(),await t()}catch(W){a.error(`Save failed: ${W.message}`)}},children:[e.jsx(Ze,{size:12})," Save"]})]})})}catch(w){a.error(`Load failed: ${w.message}`)}},b=async g=>{if(confirm(`Delete agent "${g.name}"? This removes ${g.path}.`))try{await A.del(`/agents/${encodeURIComponent(g.name)}`),c(B=>B.filter(H=>H.name!==g.name)),a.success("Agent deleted.")}catch(B){a.error(`Delete failed: ${B.message}`)}},v=async g=>{let B=null;i.open({title:`Invoke ${g.name}`,children:e.jsxs("div",{className:"invoke-form",children:[e.jsxs("p",{className:"muted invoke-form-meta mono",children:[g.model||"—"," · ",g.path]}),e.jsx("p",{className:"invoke-form-desc",children:g.description}),e.jsx("label",{className:"field-label",htmlFor:"invoke-prompt",children:"Prompt"}),e.jsx("textarea",{ref:H=>B=H,id:"invoke-prompt",className:"textarea",rows:5,placeholder:"What should this agent do?",autoFocus:!0})]}),footer:e.jsxs("div",{className:"modal-footer-actions",children:[e.jsx(z,{variant:"ghost",onClick:()=>i.close(),children:"Cancel"}),e.jsxs(z,{variant:"primary",onClick:async()=>{const H=((B==null?void 0:B.value)||"").trim();if(!H){a.warning("Prompt is required.");return}try{await A.post(`/agents/${encodeURIComponent(g.name)}/invoke`,{prompt:H}),a.success(`Invoked ${g.name}.`),i.close()}catch(R){a.error(`Invoke failed: ${R.message}`)}},children:[e.jsx(Gs,{size:14})," Invoke"]})]})})},y=async g=>{try{const B=await A.post(`/agents/${encodeURIComponent(g.name)}/restart`);c(H=>H.map(R=>R.name===g.name?B:R)),a.success(`${g.name} restarted.`)}catch(B){a.error(`Restart failed: ${B.message}`)}},$=async(g,B)=>{try{const H=await A.post(`/agents/${encodeURIComponent(g.name)}/status`,{status:B});c(R=>R.map(J=>J.name===g.name?H:J))}catch(H){a.error(`Status update failed: ${H.message}`)}};return e.jsxs("div",{className:"view view-agents",children:[e.jsxs("header",{className:"view-header",children:[e.jsxs("div",{className:"view-header-text",children:[e.jsxs("h2",{className:"view-title",children:[e.jsx(Ee,{size:18})," Agents (",p.length,")"]}),e.jsxs("p",{className:"view-subtitle",children:["The Norse pantheon — click ",e.jsx("kbd",{children:"Edit"})," to modify or ",e.jsx("kbd",{children:"Invoke"})," to dispatch."]})]}),e.jsxs("div",{className:"view-actions",children:[e.jsx("div",{className:"search-input",children:e.jsx("input",{className:"input",type:"text",placeholder:"Search…",value:j,onChange:g=>m(g.target.value)})}),e.jsxs("select",{className:"select select-sm",value:x,onChange:g=>u(g.target.value),children:[e.jsx("option",{value:"",children:"All categories"}),xs.map(g=>e.jsx("option",{value:g.id,children:g.label},g.id)),e.jsx("option",{value:"__none__",children:"(no category)"})]}),e.jsxs(z,{variant:"secondary",size:"sm",onClick:o,children:[e.jsx(de,{size:14})," Refresh"]}),e.jsxs(z,{variant:"primary",size:"sm",onClick:f,children:[e.jsx(pe,{size:14})," New agent"]})]})]}),k.length>0&&e.jsxs("div",{className:"agent-tags-row",children:[e.jsx(Os,{size:12}),k.map(g=>e.jsx("span",{className:"tag",children:g},g))]}),d?e.jsx("div",{className:"view-loading",children:e.jsx(je,{size:"lg"})}):p.length===0?e.jsx(Ie,{icon:e.jsx(Ee,{size:32}),title:"No agents found",message:"Run bizar in the terminal to install Bizar."}):e.jsx("div",{className:"agent-grid",children:p.map(g=>e.jsx(hi,{agent:g,onInvoke:()=>v(g),onEdit:()=>S(g),onDelete:()=>b(g),onRestart:()=>y(g),onSetStatus:B=>$(g,B)},g.name))})]})}function hi({agent:s,onInvoke:t,onEdit:a,onDelete:i,onRestart:n,onSetStatus:c}){const[d,l]=r.useState(!1),x=oi(s.category),u=(s.status==="working"||!!s.currentTaskId)&&!s.isStuck;return e.jsxs(te,{variant:"elevated",interactive:!0,className:ae("agent-card",u&&"is-working",s.isStuck&&"is-stuck"),children:[e.jsxs("div",{className:"agent-card-head",children:[e.jsxs("div",{className:"agent-card-name",children:[e.jsx(ci,{status:s.status,isStuck:s.isStuck}),s.name]}),e.jsxs("div",{className:"agent-card-badges",children:[s.category&&e.jsx("span",{className:"agent-card-category",style:{background:`color-mix(in srgb, ${x} 18%, transparent)`,color:x},children:s.category}),e.jsx(di,{agent:s})]})]}),e.jsx("p",{className:"agent-card-desc",children:yt(s.description,200)}),e.jsxs("div",{className:"agent-card-meta",children:[e.jsx("span",{className:"mono",title:s.model||"",children:s.model||"—"}),e.jsx("span",{className:"tabular-nums muted",children:ve(s.mtime)})]}),s.tags&&s.tags.length>0&&e.jsx("div",{className:"agent-card-tags",children:s.tags.map(j=>e.jsx("span",{className:"agent-card-tag",children:j},j))}),(u||s.lastTask)&&e.jsxs("div",{className:"agent-card-activity",children:[s.currentTaskId&&e.jsxs("div",{className:"agent-card-row",children:[e.jsx(ze,{size:12}),e.jsx("span",{className:"muted",children:"Working on"}),e.jsx("code",{className:"mono",children:s.currentTaskId})]}),s.lastTask&&!s.currentTaskId&&e.jsxs("div",{className:"agent-card-row",children:[e.jsx(ks,{size:12}),e.jsx("span",{className:"muted",children:"Last"}),e.jsx("code",{className:"mono",children:s.lastTask.id}),e.jsx("span",{className:"muted tabular-nums",children:ve(s.lastTask.finishedAt)})]}),s.tasksTotal!=null&&s.tasksTotal>0&&e.jsxs("div",{className:"agent-card-row",children:[e.jsx(Da,{size:12}),e.jsx("span",{className:"muted",children:"Success rate"}),e.jsxs("span",{className:"tabular-nums",children:[Math.round((s.successRate||0)*100),"%"]}),e.jsxs("span",{className:"muted tabular-nums",children:["(",s.tasksSucceeded,"/",s.tasksTotal,")"]})]})]}),s.lastError&&e.jsxs("div",{className:"agent-card-error",children:[e.jsx(De,{size:12}),e.jsxs("span",{className:"muted",children:["Last error: ",s.lastError.message]})]}),e.jsxs("div",{className:"agent-card-actions",children:[e.jsxs(z,{variant:"primary",size:"sm",onClick:t,children:[e.jsx(Gs,{size:12})," Invoke"]}),e.jsxs(z,{variant:"secondary",size:"sm",onClick:a,children:[e.jsx(ds,{size:12})," Edit"]}),(s.isStuck||s.status==="working"||s.status==="error")&&e.jsxs(z,{variant:"ghost",size:"sm",onClick:n,title:"Reset agent status",children:[e.jsx(bt,{size:12})," Restart"]}),e.jsx(z,{variant:"ghost",size:"sm",onClick:i,children:e.jsx(ye,{size:12})}),e.jsx("button",{type:"button",className:"icon-btn","aria-label":d?"Collapse":"Expand",onClick:()=>l(j=>!j),style:{marginLeft:"auto"},children:d?e.jsx(Ae,{size:12}):e.jsx(He,{size:12})})]}),d&&e.jsxs("div",{className:"agent-card-expanded",children:[e.jsxs("div",{className:"agent-card-status-actions",children:[e.jsx("span",{className:"muted text-sm",children:"Set status:"}),e.jsx(z,{variant:s.status==="idle"?"primary":"ghost",size:"sm",onClick:()=>c("idle"),children:"Idle"}),e.jsx(z,{variant:s.status==="working"?"primary":"ghost",size:"sm",onClick:()=>c("working"),children:"Working"}),e.jsx(z,{variant:s.status==="error"?"primary":"ghost",size:"sm",onClick:()=>c("error"),children:"Error"})]}),e.jsxs("div",{className:"agent-card-meta",children:[e.jsx(Ue,{size:11}),e.jsx("code",{className:"mono agent-card-path",children:s.path})]})]})]})}function ui({id:s,children:t}){return e.jsx("div",{id:s,"data-block-id":s,className:ae("glyph-richtext"),style:Et,children:e.jsx(kt,{remarkPlugins:[Nt],children:t})})}const pi={info:{bg:"var(--info-soft, rgba(96, 165, 250, 0.12))",border:"var(--info)",fg:"var(--info)",icon:Ns,label:"Note"},warn:{bg:"var(--warning-soft, rgba(251, 191, 36, 0.15))",border:"var(--warning)",fg:"var(--warning)",icon:De,label:"Warning"},success:{bg:"var(--success-soft, rgba(52, 211, 153, 0.15))",border:"var(--success)",fg:"var(--success)",icon:ks,label:"Success"},danger:{bg:"var(--error-soft, rgba(248, 113, 113, 0.12))",border:"var(--error)",fg:"var(--error)",icon:Tt,label:"Danger"}};function xi({id:s,tone:t="info",children:a}){const i=pi[t],n=i.icon;return e.jsxs("div",{id:s,"data-block-id":s,className:ae("glyph-callout",`glyph-callout-${t}`),style:{display:"flex",gap:12,padding:"12px 16px",margin:"12px 0",borderLeft:`3px solid ${i.border}`,background:i.bg,borderRadius:8,color:"var(--text)"},role:t==="danger"||t==="warn"?"alert":void 0,children:[e.jsx("div",{style:{flexShrink:0,color:i.fg,paddingTop:2},children:e.jsx(n,{size:18})}),e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsx("div",{style:{fontWeight:600,fontSize:13,color:i.fg,marginBottom:4},children:i.label}),e.jsx("div",{className:"glyph-richtext",style:{...Et,fontSize:14},children:e.jsx(kt,{remarkPlugins:[Nt],children:a})})]})]})}function gi({id:s,items:t}){return e.jsx("ul",{id:s,"data-block-id":s,className:"glyph-checklist",style:{listStyle:"none",padding:0,margin:"12px 0",display:"flex",flexDirection:"column",gap:6},children:t.map(a=>e.jsxs("li",{style:{display:"flex",alignItems:"flex-start",gap:10,padding:"6px 10px",borderRadius:6,background:"var(--bg-elev)",border:"1px solid var(--border)",fontSize:14},children:[e.jsx("span",{"aria-hidden":!0,style:{flexShrink:0,marginTop:1,width:16,height:16,borderRadius:4,border:`1.5px solid ${a.checked?"var(--success)":"var(--border-strong)"}`,background:a.checked?"var(--success)":"transparent",color:"var(--bg)",display:"inline-flex",alignItems:"center",justifyContent:"center"},children:a.checked?e.jsx(Ps,{size:12,strokeWidth:3}):null}),e.jsx("span",{style:{color:a.checked?"var(--text-dim)":"var(--text)",textDecoration:a.checked?"line-through":"none",wordBreak:"break-word"},children:a.label})]},a.id))})}function ji({id:s,columns:t,rows:a}){return e.jsx("div",{id:s,"data-block-id":s,className:"glyph-table-wrap",style:{margin:"12px 0",border:"1px solid var(--border)",borderRadius:8,overflow:"auto",background:"var(--bg-elev)"},children:e.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:13},children:[e.jsx("thead",{children:e.jsx("tr",{children:t.map((i,n)=>e.jsx("th",{style:{textAlign:"left",padding:"8px 12px",borderBottom:"1px solid var(--border-strong)",background:"var(--bg)",color:"var(--text-dim)",fontWeight:600,fontSize:12,textTransform:"uppercase",letterSpacing:.3,whiteSpace:"nowrap"},children:i},n))})}),e.jsx("tbody",{children:a.map((i,n)=>e.jsx("tr",{style:{borderTop:n===0?"none":"1px solid var(--border)"},children:i.map((c,d)=>e.jsx("td",{style:{padding:"8px 12px",color:"var(--text)",verticalAlign:"top",wordBreak:"break-word"},children:c},d))},n))})]})})}function fi({id:s,tabs:t}){var c;const[a,i]=r.useState(((c=t[0])==null?void 0:c.id)??""),n=r.useMemo(()=>t.find(d=>d.id===a)??t[0],[t,a]);return e.jsxs("div",{id:s,"data-block-id":s,className:"glyph-codetabs",style:{margin:"12px 0",border:"1px solid var(--border)",borderRadius:8,overflow:"hidden",background:"var(--bg-elev)"},children:[e.jsx("div",{role:"tablist",style:{display:"flex",gap:2,padding:4,background:"var(--bg)",borderBottom:"1px solid var(--border)",overflowX:"auto"},children:t.map(d=>{const l=d.id===(n==null?void 0:n.id);return e.jsxs("button",{type:"button",role:"tab","aria-selected":l,onClick:()=>i(d.id),style:{padding:"6px 12px",fontSize:12,fontFamily:"var(--font-mono)",borderRadius:6,border:"none",cursor:"pointer",background:l?"var(--bg-elev)":"transparent",color:l?"var(--text-strong)":"var(--text-dim)",boxShadow:l?"0 0 0 1px var(--border)":"none",whiteSpace:"nowrap"},children:[e.jsx("span",{children:d.label}),d.language&&e.jsx("span",{style:{marginLeft:6,color:"var(--text-dim)",fontSize:11},children:d.language})]},d.id)})}),n&&e.jsxs(e.Fragment,{children:[e.jsx("pre",{style:{margin:0,padding:14,overflowX:"auto",fontFamily:"var(--font-mono)",fontSize:12.5,lineHeight:1.55,color:"var(--text)",background:"var(--bg-elev)"},children:e.jsx("code",{children:n.code})}),n.caption&&e.jsx("div",{style:{padding:"8px 14px",borderTop:"1px solid var(--border)",fontSize:12,color:"var(--text-dim)",background:"var(--bg)"},children:n.caption})]})]})}function vi({id:s,title:t,question:a,options:i}){return e.jsxs("div",{id:s,"data-block-id":s,className:"glyph-decision",style:{margin:"16px 0",padding:16,border:"1px solid var(--border)",borderRadius:10,background:"var(--bg-elev)"},children:[t&&e.jsx("h3",{style:{margin:0,marginBottom:4,fontSize:15,fontWeight:600,color:"var(--text-strong)"},children:t}),a&&e.jsx("p",{style:{margin:0,marginBottom:12,fontSize:13,color:"var(--text-dim)"},children:a}),e.jsx("div",{style:{display:"grid",gap:10,gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))"},children:i.map(n=>{const c=!!n.recommended;return e.jsxs("div",{style:{position:"relative",padding:12,borderRadius:8,border:c?"2px solid var(--success)":"1px solid var(--border)",background:c?"var(--success-soft)":"var(--bg)"},children:[c&&e.jsx("span",{style:{position:"absolute",top:-10,right:10,padding:"2px 8px",fontSize:11,fontWeight:600,color:"var(--bg)",background:"var(--success)",borderRadius:999},children:"Recommended"}),e.jsx("div",{style:{fontWeight:600,fontSize:14,color:"var(--text-strong)",marginBottom:4},children:n.label}),e.jsx("div",{style:{fontSize:13,color:"var(--text)"},children:n.detail})]},n.id)})})]})}function yi({id:s,questions:t}){const[a,i]=r.useState({});function n(c,d){i(l=>({...l,[c]:d}))}return e.jsxs("div",{id:s,"data-block-id":s,className:"glyph-openquestions",style:{margin:"16px 0",padding:16,border:"1px solid var(--border)",borderRadius:10,background:"var(--bg-elev)",display:"flex",flexDirection:"column",gap:14},children:[e.jsx("div",{style:{fontSize:13,fontWeight:600,color:"var(--text-strong)"},children:"Open questions"}),t.map(c=>e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[e.jsx("label",{htmlFor:`oq-${c.id}`,style:{fontSize:13,color:"var(--text)",fontWeight:500},children:c.label}),c.kind==="choice"&&e.jsxs("select",{id:`oq-${c.id}`,value:a[c.id]??"",onChange:d=>n(c.id,d.target.value),style:ht,children:[e.jsx("option",{value:"",children:"— select —"}),(c.options??[]).map(d=>e.jsx("option",{value:d,children:d},d))]}),c.kind==="text"&&e.jsx("input",{id:`oq-${c.id}`,type:"text",value:a[c.id]??"",onChange:d=>n(c.id,d.target.value),style:ht}),c.kind==="multi"&&e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:4},children:(c.options??[]).map(d=>{const l=a[c.id]??[],x=l.includes(d);return e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:8,fontSize:13,color:"var(--text)",cursor:"pointer"},children:[e.jsx("input",{type:"checkbox",checked:x,onChange:()=>{const u=x?l.filter(j=>j!==d):[...l,d];n(c.id,u)}}),e.jsx("span",{children:d})]},d)})})]},c.id))]})}const ht={padding:"6px 10px",fontSize:13,borderRadius:6,border:"1px solid var(--border-strong)",background:"var(--bg)",color:"var(--text)",fontFamily:"inherit"},bi={added:{bg:"var(--success-soft)",fg:"var(--success)",label:"A"},modified:{bg:"var(--info-soft, rgba(96, 165, 250, 0.12))",fg:"var(--info)",label:"M"},removed:{bg:"var(--error-soft)",fg:"var(--error)",label:"D"},renamed:{bg:"rgba(139, 92, 246, 0.15)",fg:"var(--accent)",label:"R"}};function ki({id:s,title:t,entries:a}){return e.jsxs("div",{id:s,"data-block-id":s,className:"glyph-filetree",style:{margin:"12px 0",padding:t?14:8,border:"1px solid var(--border)",borderRadius:8,background:"var(--bg-elev)"},children:[t&&e.jsx("div",{style:{fontSize:12,fontWeight:600,color:"var(--text-dim)",textTransform:"uppercase",letterSpacing:.4,marginBottom:8},children:t}),e.jsx("ul",{style:{listStyle:"none",padding:0,margin:0,display:"flex",flexDirection:"column",gap:2},children:a.map(i=>{const n=bi[i.change];return e.jsxs("li",{style:{display:"flex",alignItems:"center",gap:10,padding:"5px 8px",borderRadius:5,fontSize:13},children:[e.jsx("span",{"aria-label":i.change,title:i.change,style:{flexShrink:0,width:22,height:18,borderRadius:4,background:n.bg,color:n.fg,display:"inline-flex",alignItems:"center",justifyContent:"center",fontSize:10,fontWeight:700,fontFamily:"var(--font-mono)"},children:n.label}),e.jsx("span",{style:{fontFamily:"var(--font-mono)",color:"var(--text)",wordBreak:"break-all",flex:1},children:i.path}),i.note&&e.jsx("span",{style:{fontSize:12,color:"var(--text-dim)"},children:i.note})]},i.path)})})]})}function Ni({id:s,filename:t,language:a,mode:i="unified",before:n,after:c}){const d=n.split(`
|
|
332
|
-
`),l=c.split(`
|
|
333
|
-
`),x=e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"6px 12px",background:"var(--bg)",borderBottom:"1px solid var(--border)",fontSize:12,color:"var(--text-dim)",fontFamily:"var(--font-mono)"},children:[e.jsx(Xs,{size:14}),e.jsx("span",{style:{color:"var(--text)"},children:t??"diff"}),a&&e.jsxs("span",{children:["· ",a]}),e.jsx("span",{style:{marginLeft:"auto",textTransform:"uppercase",letterSpacing:.3},children:i})]}),u={margin:0,padding:0,fontFamily:"var(--font-mono)",fontSize:12.5,lineHeight:1.55,color:"var(--text)",background:"var(--bg-elev)"},j=(m,o,p)=>{const k={del:"var(--error-soft)",add:"var(--success-soft)",ctx:"transparent"},f={del:"var(--error)",add:"var(--success)",ctx:"var(--text-dim)"};return e.jsxs("div",{style:{display:"flex",padding:"0 12px",background:k[p]},children:[e.jsx("span",{style:{width:18,color:f[p],userSelect:"none",flexShrink:0},children:m}),e.jsx("span",{style:{whiteSpace:"pre",flex:1,overflowX:"auto"},children:o||" "})]})};return e.jsxs("div",{id:s,"data-block-id":s,className:"glyph-diff",style:{margin:"12px 0",border:"1px solid var(--border)",borderRadius:8,overflow:"hidden",background:"var(--bg-elev)"},children:[x,i==="unified"?e.jsxs("pre",{style:u,children:[d.map((m,o)=>e.jsx("div",{children:j("-",m,"del")},`b${o}`)),l.map((m,o)=>e.jsx("div",{children:j("+",m,"add")},`a${o}`))]}):e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr"},children:[e.jsx("pre",{style:{...u,borderRight:"1px solid var(--border)"},children:d.map((m,o)=>e.jsx("div",{children:j("-",m,"del")},o))}),e.jsx("pre",{style:u,children:l.map((m,o)=>e.jsx("div",{children:j("+",m,"add")},o))})]})]})}const wi={up:{fg:"var(--success)",Icon:Ae,label:"trending up"},down:{fg:"var(--error)",Icon:Ae,label:"trending down"},flat:{fg:"var(--text-dim)",Icon:Ja,label:"flat"}};function Si({id:s,label:t,value:a,trend:i,hint:n}){const c=i?wi[i]:null;return e.jsxs("div",{id:s,"data-block-id":s,className:"glyph-stat",style:{padding:14,border:"1px solid var(--border)",borderRadius:10,background:"var(--bg-elev)",display:"flex",flexDirection:"column",gap:4,minWidth:140},children:[e.jsx("div",{style:{fontSize:12,color:"var(--text-dim)",textTransform:"uppercase",letterSpacing:.4},children:t}),e.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:8},children:[e.jsx("span",{style:{fontSize:24,fontWeight:700,color:"var(--text-strong)"},children:a}),c&&e.jsx("span",{"aria-label":c.label,style:{display:"inline-flex",alignItems:"center",color:c.fg,transform:c.Icon===Ae&&i==="up"?"rotate(180deg)":void 0},children:e.jsx(c.Icon,{size:14})})]}),n&&e.jsx("div",{style:{fontSize:12,color:"var(--text-dim)"},children:n})]})}const Ci={task:{stroke:"var(--info)",fill:"var(--bg-elev)",fg:"var(--text)"},decision:{stroke:"var(--warning)",fill:"var(--bg-elev)",fg:"var(--text)"},note:{stroke:"var(--border-strong)",fill:"var(--bg)",fg:"var(--text-dim)"}},Ne=160,Ce=56,Ke=60,Ge=80;function zi({id:s,steps:t,connections:a=[]}){if(t.length===0)return e.jsx("div",{id:s,"data-block-id":s,className:"glyph-workflow",children:e.jsx(Ti,{id:s})});const i=new Map(t.map(j=>[j.id,j])),n=Mi(t),c=Math.max(...n.map(j=>j.col))+1,d=Math.max(...n.map(j=>j.row))+1,l=c*(Ne+Ke)+Ke,x=d*(Ce+Ge)+Ge;function u(j){if(!i.get(j))return null;const o=n.find(p=>p.id===j);return o?{x:Ke+o.col*(Ne+Ke)+Ne/2,y:Ge+o.row*(Ce+Ge)+Ce/2}:null}return e.jsx("div",{id:s,"data-block-id":s,className:"glyph-workflow",style:{margin:"12px 0",padding:12,border:"1px solid var(--border)",borderRadius:10,background:"var(--bg-elev)",overflow:"auto"},children:e.jsxs("svg",{role:"img","aria-label":"Workflow diagram",width:l,height:x,style:{display:"block",maxWidth:"100%"},children:[e.jsx("defs",{children:e.jsx("marker",{id:`arrow-${s}`,viewBox:"0 0 10 10",refX:"9",refY:"5",markerWidth:"6",markerHeight:"6",orient:"auto-start-reverse",children:e.jsx("path",{d:"M 0 0 L 10 5 L 0 10 z",fill:"var(--text-dim)"})})}),a.map((j,m)=>{const o=u(j.from),p=u(j.to);if(!o||!p)return null;const k=p.x-o.x,f=p.y-o.y,S=k>=0?o.x+Ne/2:o.x-Ne/2,b=k>=0?p.x-Ne/2:p.x+Ne/2,v=f>=0?o.y+Ce/2:o.y-Ce/2,y=f>=0?p.y-Ce/2:p.y+Ce/2,$=(S+b)/2,g=(v+y)/2;return e.jsxs("g",{children:[e.jsx("line",{x1:S,y1:v,x2:b,y2:y,stroke:"var(--text-dim)",strokeWidth:1.5,markerEnd:`url(#arrow-${s})`}),j.label&&e.jsx("text",{x:$,y:g-4,fontSize:10,fill:"var(--text-dim)",textAnchor:"middle",fontFamily:"var(--font-mono)",children:j.label})]},m)}),t.map(j=>{const m=n.find(S=>S.id===j.id);if(!m)return null;const o=Ke+m.col*(Ne+Ke),p=Ge+m.row*(Ce+Ge),k=Ci[j.type];if(j.type==="decision"){const S=o+Ne/2,b=p+Ce/2,v=[[S,p],[o+Ne,b],[S,p+Ce],[o,b]].map(y=>y.join(",")).join(" ");return e.jsxs("g",{children:[e.jsx("polygon",{points:v,fill:k.fill,stroke:k.stroke,strokeWidth:2}),e.jsx("foreignObject",{x:o+8,y:b-14,width:Ne-16,height:28,children:e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",gap:4,fontSize:12,color:k.fg,textAlign:"center",lineHeight:1.2,fontStyle:"italic",height:"100%"},children:[e.jsx(La,{size:11}),j.label]})})]},j.id)}const f=j.type==="note";return e.jsxs("g",{children:[e.jsx("rect",{x:o,y:p,width:Ne,height:Ce,rx:8,fill:k.fill,stroke:k.stroke,strokeWidth:f?1:2,strokeDasharray:f?"4 3":void 0}),e.jsx("foreignObject",{x:o+6,y:p+6,width:Ne-12,height:Ce-12,children:e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",gap:6,fontSize:12,color:k.fg,textAlign:"center",lineHeight:1.25,fontStyle:f?"italic":"normal",height:"100%"},children:[f&&e.jsx(ca,{size:11}),j.label]})})]},j.id)})]})})}function Ti({id:s}){return e.jsx("div",{id:s,style:{padding:20,textAlign:"center",color:"var(--text-dim)",fontSize:13},children:"No workflow steps."})}function Mi(s){return s.length===0?[]:s.map((t,a)=>({id:t.id,col:a,row:0}))}const Et={fontSize:14,lineHeight:1.6,color:"var(--text)"};function Ai({id:s,title:t,x:a,y:i,w:n,h:c,html:d}){return e.jsxs("figure",{id:s,"data-block-id":s,className:"glyph-mockup",style:{width:n,minHeight:c},children:[t&&e.jsx("figcaption",{className:"glyph-mockup-title",children:t}),e.jsxs("div",{className:"glyph-mockup-frame",children:[e.jsxs("div",{className:"glyph-mockup-chrome",children:[e.jsx("span",{}),e.jsx("span",{}),e.jsx("span",{})]}),e.jsx("div",{className:"glyph-mockup-body",dangerouslySetInnerHTML:{__html:d}})]})]})}class $i extends wt.Component{constructor(){super(...arguments);zs(this,"state",{err:null})}static getDerivedStateFromError(a){return{err:a}}componentDidCatch(a,i){try{this.props.onError(this.props.blockId,this.props.blockType,a,i)}catch{}}render(){return this.state.err?e.jsxs("div",{className:"glyph-block-error",role:"alert",style:{border:"1px solid var(--error, #f85149)",background:"rgba(248, 81, 73, 0.06)",borderRadius:8,padding:"12px 14px",margin:"12px 0",color:"var(--text)",fontFamily:"var(--font-mono, ui-monospace, monospace)",fontSize:12,lineHeight:1.55},children:[e.jsxs("strong",{style:{color:"var(--error, #f85149)",fontFamily:"var(--font-sans, system-ui, sans-serif)",display:"block",marginBottom:4},children:[this.props.blockType," block crashed"]}),e.jsxs("div",{style:{color:"var(--text-muted)",marginBottom:6},children:["block id: ",e.jsx("code",{children:this.props.blockId})]}),e.jsx("pre",{style:{margin:0,whiteSpace:"pre-wrap",wordBreak:"break-word",color:"var(--text)"},children:this.state.err.message})]}):this.props.children}}function Ii(s){const t=s.data??{};switch(s.type){case"RichText":return{ok:!0};case"Callout":return{ok:!0};case"Checklist":return Array.isArray(t.items)?{ok:!0}:{ok:!1,error:"Checklist requires data.items to be an array"};case"Table":return Array.isArray(t.columns)?Array.isArray(t.rows)?t.rows.length>0&&!Array.isArray(t.rows[0])?{ok:!1,error:"Table.data.rows[0] must be an array (cell array)"}:{ok:!0}:{ok:!1,error:"Table requires data.rows to be an array"}:{ok:!1,error:"Table requires data.columns to be an array"};case"CodeTabs":return Array.isArray(t.tabs)?{ok:!0}:{ok:!1,error:"CodeTabs requires data.tabs to be an array"};case"Decision":return Array.isArray(t.options)?{ok:!0}:{ok:!1,error:"Decision requires data.options to be an array"};case"OpenQuestions":return Array.isArray(t.questions)?{ok:!0}:{ok:!1,error:"OpenQuestions requires data.questions to be an array"};case"FileTree":if(!Array.isArray(t.entries))return{ok:!1,error:"FileTree requires data.entries to be an array"};for(const a of t.entries)if(a===null||typeof a!="object"||Array.isArray(a))return{ok:!1,error:`FileTree contains a malformed entry: ${JSON.stringify(a)}`};return{ok:!0};case"Diff":return typeof t.before!="string"?{ok:!1,error:"Diff requires data.before to be a string"}:typeof t.after!="string"?{ok:!1,error:"Diff requires data.after to be a string"}:{ok:!0};case"Stat":return t.label===void 0||t.label===null?{ok:!1,error:"Stat requires data.label"}:t.value===void 0||t.value===null?{ok:!1,error:"Stat requires data.value"}:{ok:!0};case"Workflow":return Array.isArray(t.steps)?{ok:!0}:{ok:!1,error:"Workflow requires data.steps to be an array"};case"Mockup":return typeof t.html!="string"?{ok:!1,error:"Mockup requires data.html to be a string"}:{ok:!0};case"Diagram":return typeof t.dataHtml!="string"?{ok:!1,error:"Diagram requires data.dataHtml to be a string"}:{ok:!0};default:return{ok:!1,error:`Unknown block type: ${s.type}`}}}const Ri={overview:"Overview",implementation:"Implementation plan","implementation-plan":"Implementation plan",questions:"Open questions","open-questions":"Open questions","open-questions-for-you":"Open questions",comments:"Comments",handoff:"Handoff"};function Di(s){const t=[];let a={heading:null,blocks:[]};for(const i of s){const n=Ri[i.id]??null;n?((a.blocks.length>0||a.heading!==null)&&t.push(a),a={heading:n,blocks:[i]}):a.blocks.push(i)}return(a.blocks.length>0||a.heading!==null)&&t.push(a),t}function Li({slug:s,onClose:t,onCommentAdded:a}){var F,q,ee,T;const i=ce(),[n,c]=r.useState(null),[d,l]=r.useState([]),[x,u]=r.useState(!0),[j,m]=r.useState(null),[o,p]=r.useState(null),[k,f]=r.useState(!1),[S,b]=r.useState(!1),[v,y]=r.useState(null),[$,g]=r.useState(null),[B,H]=r.useState(""),[R,J]=r.useState(null),[D,L]=r.useState([]),V=wt.useCallback((M,C,h)=>{L(P=>P.some(Y=>Y.blockId===M)?P:[...P,{blockId:M,blockType:C,message:h.message||String(h)}])},[]),K=r.useRef(null),w=r.useMemo(()=>n?Di(n.blocks):[],[n]);r.useEffect(()=>{let M=!1;const C=5e3;return(async()=>{u(!0),m(null);try{const h=new Promise((re,ie)=>setTimeout(()=>ie(new Error("Request timed out after 5s")),C)),[P,Y]=await Promise.race([Promise.all([A.get(`/artifacts/${encodeURIComponent(s)}/render`),A.get(`/artifacts/${encodeURIComponent(s)}`)]),h]);if(M)return;c(P);const E=(Y==null?void 0:Y.comments)??[];l(Array.isArray(E)?E:[])}catch(h){if(!M){const P=h.message;m(P),p(P)}}finally{M||u(!1)}})(),()=>{M=!0}},[s]);function I(M){if(!K.current)return;M.preventDefault();const C=K.current.getBoundingClientRect();y({x:M.clientX,y:M.clientY,worldX:M.clientX-C.left,worldY:M.clientY-C.top})}async function _(){if(!(!$||!B.trim()))try{const M=await A.post(`/artifacts/${encodeURIComponent(s)}/comments`,{x:$.worldX,y:$.worldY,text:B.trim(),author:"drb0rk"});l(C=>[...C,{id:M.id??`cmt_${Date.now()}`,x:$.worldX,y:$.worldY,text:B.trim(),author:"drb0rk",created:new Date().toISOString()}]),g(null),H(""),y(null),a==null||a(),i.success("Comment added")}catch(M){i.error(`Failed to add comment: ${M.message}`)}}async function W(){if(!k){f(!0);try{const M=await A.post(`/artifacts/${encodeURIComponent(s)}/submit`,{answers:[],submitter:"drb0rk"});M!=null&&M.ok?(i.success("Sent to agent — feedback.md written, status=review"),a==null||a()):i.error("Submit failed: server did not return ok=true")}catch(M){i.error(`Submit failed: ${M.message}`)}finally{f(!1)}}}function X(){b(M=>!M)}const ne=M=>{const C=M.id,h=M.data??{},P=Ii(M);return P.ok?e.jsx($i,{blockId:C,blockType:M.type,onError:V,children:se(M,C,h)},C):e.jsxs("div",{id:C,className:"glyph-block-error",role:"alert",style:{border:"1px solid var(--error, #f85149)",background:"rgba(248, 81, 73, 0.06)",borderRadius:8,padding:"12px 14px",margin:"12px 0",color:"var(--text)",fontFamily:"var(--font-mono, ui-monospace, monospace)",fontSize:12,lineHeight:1.55},children:[e.jsxs("strong",{style:{color:"var(--error, #f85149)",fontFamily:"var(--font-sans, system-ui, sans-serif)",display:"block",marginBottom:4},children:[M.type," block invalid"]}),e.jsxs("div",{style:{color:"var(--text-muted)",marginBottom:6},children:["block id: ",e.jsx("code",{children:C})]}),e.jsx("pre",{style:{margin:0,whiteSpace:"pre-wrap",wordBreak:"break-word"},children:P.error})]},C)},se=(M,C,h)=>{switch(M.type){case"RichText":return e.jsx(ui,{id:C,children:M.childrenMarkdown??""},C);case"Callout":return e.jsx(xi,{id:C,tone:h.tone??"info",children:M.childrenMarkdown??""},C);case"Checklist":return e.jsx(gi,{id:C,items:h.items??[]},C);case"Table":return e.jsx(ji,{id:C,columns:h.columns??[],rows:h.rows??[]},C);case"CodeTabs":return e.jsx(fi,{id:C,tabs:h.tabs??[]},C);case"Decision":return e.jsx(vi,{id:C,title:h.title,question:h.question,options:h.options??[]},C);case"OpenQuestions":return e.jsx(yi,{id:C,questions:h.questions??[]},C);case"FileTree":return e.jsx(ki,{id:C,title:h.title,entries:h.entries??[]},C);case"Diff":return e.jsx(Ni,{id:C,filename:h.filename,language:h.language,mode:h.mode??"unified",before:h.before??"",after:h.after??""},C);case"Stat":return e.jsx(Si,{id:C,label:h.label??"",value:h.value,trend:h.trend,hint:h.hint},C);case"Workflow":return e.jsx(zi,{id:C,steps:h.steps??[],connections:h.connections},C);case"Mockup":return e.jsx(Ai,{id:C,title:h.title,x:h.x,y:h.y,w:h.w,h:h.h,html:h.html??""},C);case"Diagram":return e.jsx("div",{id:C,className:"glyph-block-placeholder",children:e.jsxs("em",{children:["[Diagram] ",C]})},C)}};if(x)return e.jsx("div",{className:"glyph-renderer glyph-renderer--loading",children:o?e.jsxs(e.Fragment,{children:[e.jsx("strong",{children:"Failed to load glyph."}),e.jsx("pre",{children:o})]}):e.jsxs(e.Fragment,{children:[e.jsx(Pi,{})," Loading glyph…"]})});if(j||!n)return e.jsxs("div",{className:"glyph-renderer glyph-renderer--error",children:[e.jsx("strong",{children:"Failed to load glyph."}),e.jsx("pre",{children:j??"unknown error"})]});const U=((F=n.frontmatter)==null?void 0:F.title)??s,O=((q=n.frontmatter)==null?void 0:q.status)??"draft",Q=d.length;return e.jsxs("div",{className:`glyph-canvas ${S?"glyph-canvas--fullscreen":""}`,ref:K,onContextMenu:I,children:[e.jsxs("div",{className:"glyph-toolbar-floating",children:[e.jsxs("button",{className:"glyph-btn glyph-btn--primary glyph-btn--send",onClick:W,disabled:k,title:"Send comments + question answers to the agent — writes feedback.md, status=review",children:[e.jsx(Qe,{size:14}),e.jsx("span",{children:"Send to agent"}),e.jsx("span",{className:"glyph-btn-badge",children:Q})]}),e.jsx("span",{className:"glyph-toolbar-divider"}),e.jsx("button",{className:"glyph-icon-btn",title:"Share",onClick:()=>{typeof window<"u"&&navigator.clipboard&&(navigator.clipboard.writeText(window.location.href).catch(()=>{}),i.success("Link copied"))},children:e.jsx(nn,{size:15})}),e.jsx("button",{className:"glyph-icon-btn",title:"Undo",disabled:!0,children:e.jsx(cn,{size:15})}),e.jsx("button",{className:"glyph-icon-btn",title:"Redo",disabled:!0,children:e.jsx(an,{size:15})}),e.jsx("button",{className:"glyph-icon-btn",title:S?"Exit fullscreen":"Fullscreen",onClick:X,children:e.jsx(Ya,{size:15})}),e.jsx("button",{className:"glyph-icon-btn",title:"More",children:e.jsx(Pa,{size:15})}),e.jsx("span",{className:"glyph-toolbar-divider"}),e.jsxs("button",{className:"glyph-icon-btn",title:"Comment count","aria-label":"Comment count",children:[e.jsx(Ve,{size:15}),e.jsx("span",{className:"glyph-icon-btn-count",children:Q})]}),t&&e.jsx("button",{className:"glyph-icon-btn glyph-icon-btn--close",title:"Close",onClick:t,"aria-label":"Close",children:e.jsx($e,{size:15})})]}),e.jsxs("div",{className:"glyph-canvas-content",children:[e.jsxs("header",{className:"glyph-canvas-title",children:[e.jsx("h1",{className:"glyph-title",children:U}),e.jsxs("div",{className:"glyph-meta",children:[e.jsx("span",{className:`glyph-status glyph-status--${O}`,children:O}),e.jsx("span",{className:"glyph-slug",children:s})]})]}),(D.length>0||((ee=n.errors)==null?void 0:ee.length)>0)&&e.jsxs("div",{className:"glyph-render-errors",role:"alert",style:{border:"1px solid var(--error, #f85149)",background:"rgba(248, 81, 73, 0.08)",borderRadius:8,padding:"12px 16px",margin:"0 0 16px 0",color:"var(--text)"},children:[e.jsx("strong",{style:{color:"var(--error, #f85149)",display:"block",marginBottom:8},children:D.length>0?`${D.length} block${D.length===1?"":"s"} failed to render`:"Compiler warnings"}),e.jsxs("ul",{style:{margin:0,paddingLeft:20,fontFamily:"var(--font-mono, ui-monospace, monospace)",fontSize:12,lineHeight:1.6},children:[D.map((M,C)=>e.jsxs("li",{children:[e.jsx("strong",{children:M.blockType})," (",e.jsx("code",{children:M.blockId}),"): ",M.message]},`be-${C}`)),(T=n.errors)==null?void 0:T.map((M,C)=>e.jsxs("li",{children:[M.line?`line ${M.line}: `:"",M.message]},`ce-${C}`))]})]}),e.jsx("div",{className:"glyph-sections",children:w.map((M,C)=>e.jsxs("section",{className:`glyph-section ${M.heading?"glyph-section--headed":"glyph-section--plain"}`,children:[M.heading&&e.jsx("h2",{className:"glyph-section-heading",children:M.heading}),e.jsx("div",{className:"glyph-section-blocks",children:M.blocks.map(ne)})]},`sec-${C}-${M.heading??"ungrouped"}`))})]}),d.map(M=>e.jsxs("button",{className:`glyph-pin ${R===M.id?"glyph-pin--active":""}`,style:{left:M.x,top:M.y},onClick:C=>{C.stopPropagation(),J(R===M.id?null:M.id)},title:M.text,children:[e.jsx(rt,{size:14}),R===M.id&&e.jsxs("div",{className:"glyph-pin-thread",children:[e.jsx("div",{className:"glyph-pin-text",children:M.text}),e.jsxs("div",{className:"glyph-pin-meta",children:[M.author??"anonymous"," · ",M.created?new Date(M.created).toLocaleString():""]})]})]},M.id)),v&&e.jsx("div",{className:"glyph-ctx-menu",style:{left:v.x,top:v.y},onClick:M=>M.stopPropagation(),children:e.jsxs("button",{className:"glyph-ctx-item",onClick:()=>{g({worldX:v.worldX,worldY:v.worldY}),y(null)},children:[e.jsx(rt,{size:14})," Add comment here"]})}),$&&e.jsx("div",{className:"glyph-modal-overlay",onClick:()=>g(null),children:e.jsxs("div",{className:"glyph-modal",onClick:M=>M.stopPropagation(),children:[e.jsxs("h3",{children:["Add comment at (",Math.round($.worldX),", ",Math.round($.worldY),")"]}),e.jsx("textarea",{autoFocus:!0,value:B,onChange:M=>H(M.target.value),placeholder:"What should the agent know about this area?",rows:4,className:"glyph-modal-textarea"}),e.jsxs("div",{className:"glyph-modal-actions",children:[e.jsx("button",{className:"glyph-btn glyph-btn--ghost",onClick:()=>g(null),children:"Cancel"}),e.jsx("button",{className:"glyph-btn glyph-btn--primary",onClick:_,disabled:!B.trim(),children:"Add comment"})]})]})})]})}function Pi(){return e.jsx("span",{className:"glyph-spinner","aria-label":"loading",children:"…"})}function Ei(s){switch(s){case"approved":case"done":return"success";case"in-progress":case"doing":return"info";case"rejected":return"error";case"archived":return"warning";case"draft":default:return"neutral"}}function Bi({snapshot:s,refreshSnapshot:t}){const a=ce(),[i,n]=r.useState(s.artifacts||[]),[c,d]=r.useState(!s.artifacts),[l,x]=r.useState(null),[u,j]=r.useState(""),[m,o]=r.useState(!1);r.useEffect(()=>{s.artifacts&&(n(s.artifacts),d(!1))},[s.artifacts]);const p=async()=>{try{const b=await A.get("/artifacts");n(b.artifacts||[]),d(!1)}catch(b){a.error(`Artifacts load failed: ${b.message}`),d(!1)}},k=r.useMemo(()=>{let b=i;if(u){const v=u.toLowerCase();b=b.filter(y=>(y.slug||"").toLowerCase().includes(v)||(y.title||"").toLowerCase().includes(v))}return m||(b=b.filter(v=>v.status!=="archived")),b},[i,u,m]),f=async(b,v)=>{try{const y=await A.post("/artifacts",{slug:b,title:v});a.success(`Artifact "${y.slug}" created.`),x(y.slug),await p()}catch(y){a.error(`Create failed: ${y.message}`)}},S=async b=>{if(confirm(`Delete artifact "${b}"? This removes the directory permanently.`))try{await A.del(`/artifacts/${encodeURIComponent(b)}`),a.success("Artifact deleted."),l===b&&x(null),await p()}catch(v){a.error(`Delete failed: ${v.message}`)}};return l?e.jsxs("div",{className:"artifact-glyph-overlay",children:[e.jsx("div",{className:"artifact-glyph-toolbar",children:e.jsxs(z,{variant:"ghost",onClick:()=>{x(null),p()},children:[e.jsx(St,{size:14})," Back to artifacts"]})}),e.jsx(Li,{slug:l,onClose:()=>{x(null),p()},onCommentAdded:()=>p()})]}):e.jsxs("div",{className:"view view-artifacts",children:[e.jsxs("header",{className:"view-header",children:[e.jsxs("div",{className:"view-header-text",children:[e.jsxs("h2",{className:"view-title",children:[e.jsx(os,{size:18})," Glyphs (",i.length,")"]}),e.jsx("p",{className:"view-subtitle",children:"Visual artifacts with elements, connections, and threaded comments."})]}),e.jsxs("div",{className:"view-actions",children:[e.jsxs("div",{className:"search-input",children:[e.jsx(Oe,{size:14}),e.jsx("input",{className:"input",type:"text",placeholder:"Search…",value:u,onChange:b=>j(b.target.value)})]}),e.jsxs(z,{variant:"ghost",size:"sm",onClick:()=>o(b=>!b),title:m?"Hide archived":"Show archived",children:[m?e.jsx(fs,{size:14}):e.jsx(js,{size:14}),m?"Hide archived":"Show archived"]}),e.jsxs(z,{variant:"secondary",size:"sm",onClick:p,children:[e.jsx(de,{size:14})," Refresh"]})]})]}),e.jsx(Oi,{onCreate:f}),c?e.jsx("div",{className:"view-loading",children:e.jsx(je,{size:"lg"})}):k.length===0?e.jsx(Ie,{icon:e.jsx(os,{size:32}),title:m?"No artifacts":"No artifacts yet",message:m?"No artifacts match your filter (try Show archived off).":"Create one above to get started."}):e.jsx("div",{className:"artifacts-grid",children:k.map(b=>e.jsx(Fi,{artifact:b,onOpen:()=>x(b.slug),onDelete:()=>S(b.slug)},b.slug))})]})}function Oi({onCreate:s}){const[t,a]=r.useState(""),[i,n]=r.useState("");return e.jsxs(te,{className:"new-artifact",children:[e.jsxs(le,{children:[e.jsx(pe,{size:14})," New artifact"]}),e.jsx(oe,{children:"Slug must be lowercase, may contain hyphens, 1–64 chars."}),e.jsxs("form",{className:"new-artifact-form",onSubmit:c=>{c.preventDefault(),t.trim()&&(s(t.trim(),i.trim()||void 0),a(""),n(""))},children:[e.jsx("input",{className:"input",type:"text",placeholder:"slug (e.g. dashboard-v3.1)",pattern:"[a-z0-9][a-z0-9-]{0,63}",required:!0,value:t,onChange:c=>a(c.target.value)}),e.jsx("input",{className:"input",type:"text",placeholder:"Title (optional)",value:i,onChange:c=>n(c.target.value)}),e.jsx(z,{variant:"primary",type:"submit",children:"Create"})]})]})}function Fi({artifact:s,onOpen:t,onDelete:a}){const i=Ei(s.status||"draft");return e.jsxs(te,{variant:"elevated",interactive:!0,className:"artifact-card",onClick:t,children:[e.jsxs("div",{className:"artifact-card-head",children:[e.jsx("div",{className:"artifact-card-title",children:s.title||s.slug}),e.jsx(Pe,{kind:i,children:s.status||"draft"})]}),e.jsxs("div",{className:"artifact-card-slug mono",children:[s.slug," · ",s.source]}),e.jsxs("div",{className:"artifact-card-meta",children:[s.elementCount!=null&&e.jsxs("span",{children:[s.elementCount," elements"]}),s.commentCount!=null&&e.jsxs("span",{children:[" · ",s.commentCount," comments"]}),e.jsxs("span",{children:[" · edited ",ve(s.mtime)]})]}),e.jsxs("div",{className:"artifact-card-actions",children:[e.jsxs(z,{variant:"primary",size:"sm",onClick:n=>{n.stopPropagation(),t()},children:["Open",e.jsx(He,{size:12})]}),e.jsxs(z,{variant:"ghost",size:"sm",onClick:n=>{n.stopPropagation(),a()},children:[e.jsx(ye,{size:12})," Delete"]})]})]})}function Ui({children:s,className:t,onRemove:a}){return e.jsxs("span",{className:ae("tag",t),children:[s,a&&e.jsx("button",{type:"button",className:"tag-remove","aria-label":`Remove ${typeof s=="string"?s:"tag"}`,onClick:a,children:"×"})]})}const Hi={pending:"info",running:"accent",done:"success",failed:"error",killed:"neutral",timed_out:"warning"},qi={pending:"Pending",running:"Running",done:"Done",failed:"Failed",killed:"Killed",timed_out:"Timed out"};function Bt({status:s,dot:t}){const a=Hi[s]||"neutral",i=qi[s]||s;return e.jsx(Pe,{kind:a,dot:t,children:i})}function _i({instanceId:s,instanceName:t,onConfirm:a,onClose:i}){return e.jsxs("div",{children:[e.jsxs("p",{style:{marginBottom:16,lineHeight:1.6},children:["Instance ",e.jsx("code",{children:s}),t?e.jsxs(e.Fragment,{children:[" (",t,")"]}):null," will be terminated. This cannot be undone."]}),e.jsxs("div",{style:{display:"flex",gap:8,justifyContent:"flex-end"},children:[e.jsx(z,{variant:"ghost",onClick:i,children:"Cancel"}),e.jsx(z,{variant:"danger",onClick:async()=>{await a(),i()},children:"Kill"})]})]})}function Ot(s,t,a,i,n){s.open({title:"Kill instance?",width:400,children:e.jsx(_i,{instanceId:a,instanceName:i,onConfirm:async()=>{try{const d=await(await fetch(`/api/background/${encodeURIComponent(a)}`,{method:"DELETE"})).json();d.ok?(t.success(`Instance ${a} killed.`),n==null||n()):t.error(`Kill failed: ${d.error||"unknown error"}`)}catch(c){t.error(`Kill failed: ${c.message}`)}},onClose:()=>s.close()})})}function Vi(s){return A.urlWithToken(`/artifacts/${encodeURIComponent(s)}/content`)}function Ft(s,t){const a=Vi(t);window.open(a,"_blank","noopener,noreferrer")}function Wi({task:s,agents:t,onPromote:a,onDelete:i,onEdit:n,onRefresh:c}){var j;const d=ce(),l=async()=>{try{await A.post(`/tasks/${encodeURIComponent(s.id)}/promote`),d.success("Promoted to queued.",1500),a(s.id)}catch(m){d.error(`Promote failed: ${m.message}`)}},x=async()=>{if(confirm("Delete this task?"))try{await A.del(`/tasks/${encodeURIComponent(s.id)}`),d.success("Deleted.",1500),i(s.id)}catch(m){d.error(`Delete failed: ${m.message}`)}},u={high:"var(--warning)",normal:"var(--info)",low:"var(--muted)"};return e.jsxs("div",{className:"backlog-item","data-task-id":s.id,children:[e.jsxs("div",{className:"backlog-item-head",children:[e.jsx("span",{className:"priority-dot",style:{background:u[s.priority]||"var(--info)"}}),e.jsx("span",{className:"backlog-item-title",children:s.title}),s.assignee&&e.jsxs("span",{className:"backlog-item-badge",children:["@",s.assignee]}),((j=s.tags)==null?void 0:j.length)>0&&e.jsx("span",{className:"backlog-item-badge",children:s.tags.join(", ")})]}),s.description&&e.jsx("div",{className:"backlog-item-desc",children:s.description.slice(0,120)}),e.jsxs("div",{className:"backlog-item-footer",children:[e.jsx("span",{className:"muted text-sm tabular-nums",children:ve(s.createdAt)}),e.jsxs("div",{className:"backlog-item-actions",children:[e.jsx("button",{type:"button",className:"icon-btn",title:"Promote to queued",onClick:l,children:e.jsx(Ct,{size:13})}),e.jsx("button",{type:"button",className:"icon-btn",title:"Edit",onClick:()=>n(s),children:e.jsx(Te,{size:13})}),e.jsx("button",{type:"button",className:"icon-btn icon-btn-danger",title:"Delete",onClick:x,children:e.jsx(ye,{size:13})})]})]})]})}function Ki({agents:s,onRefresh:t}){const a=ce(),[i,n]=r.useState([]),[c,d]=r.useState(!1),l=async()=>{try{d(!0);const o=await A.get("/tasks/backlog");n(Array.isArray(o.tasks)?o.tasks:[])}catch(o){a.error(`Backlog load failed: ${o.message}`)}finally{d(!1)}};r.useEffect(()=>{l()},[]);const x=async o=>{n(p=>p.filter(k=>k.id!==o)),await t()},u=async o=>{n(p=>p.filter(k=>k.id!==o)),await t()},j=o=>{},m=async()=>{var o;if(i.length!==0)try{const k=((o=(await A.post("/tasks/promote-batch",{ids:i.map(f=>f.id)})).affected)==null?void 0:o.filter(f=>f.ok).length)??0;a.success(`Promoted ${k} task(s).`,2e3),n([]),await t()}catch(p){a.error(`Promote all failed: ${p.message}`)}};return e.jsxs("div",{className:"backlog-panel",children:[e.jsxs("div",{className:"backlog-panel-header",children:[e.jsxs("span",{className:"backlog-panel-title",children:[e.jsx(vs,{size:15}),"Backlog (",i.length,")"]}),e.jsxs("div",{className:"backlog-panel-header-actions",children:[i.length>0&&e.jsxs(z,{variant:"ghost",size:"sm",onClick:m,title:"Promote all to queued",children:[e.jsx(Ct,{size:12})," Promote all"]}),e.jsx(z,{variant:"ghost",size:"sm",onClick:l,title:"Refresh backlog","aria-label":"Refresh backlog",children:e.jsx(de,{size:12,className:c?"animate-spin":""})})]})]}),c?e.jsx("div",{className:"backlog-empty",children:"Loading…"}):i.length===0?e.jsxs("div",{className:"backlog-empty",children:[e.jsx(vs,{size:28}),e.jsx("span",{children:"Backlog is empty."})]}):e.jsx("div",{className:"backlog-list",children:i.map(o=>e.jsx(Wi,{task:o,agents:s,onPromote:x,onDelete:u,onEdit:j,onRefresh:t},o.id))})]})}const as=[{id:"queued",label:"Queued",kind:"info"},{id:"doing",label:"Doing",kind:"accent"},{id:"blocked",label:"Blocked",kind:"warning"},{id:"done",label:"Done",kind:"success"}];function ut(s,t){const a=s.status==="archived"||s.archived===!0;return t==="done"?s.status==="done"||a:!a&&s.status===t}const Qs=["low","normal","high"],Gi=[{id:"updated",label:"Last updated"},{id:"created",label:"Created"},{id:"priority",label:"Priority"},{id:"due",label:"Due date"}];function Yi({snapshot:s,refreshSnapshot:t,setActiveTab:a}){const i=ce(),n=ke(),[c,d]=r.useState(s.tasks||[]),[l,x]=r.useState(!s.tasks),[u,j]=r.useState(""),[m,o]=r.useState(""),[p,k]=r.useState(""),[f,S]=r.useState(""),[b,v]=r.useState("updated"),[y,$]=r.useState(!1),[g,B]=r.useState(new Set),[H,R]=r.useState(0),J=async(T={})=>{try{const M=T.archived?"?archived=only":"",C=await A.get(`/tasks${M}`);d(Array.isArray(C)?C:[])}catch(M){i.error(`Tasks load failed: ${M.message}`)}finally{x(!1)}};r.useEffect(()=>{s.tasks&&(d(s.tasks),x(!1))},[s.tasks]),r.useEffect(()=>{const T=setInterval(()=>R(M=>M+1),1e3);return()=>clearInterval(T)},[]);const D=r.useMemo(()=>{const T=new Set;for(const M of c)for(const C of M.tags||[])T.add(C);return Array.from(T).sort()},[c]),L=r.useMemo(()=>{let T=c;if(m&&(T=T.filter(M=>(M.assignee||"")===m)),p&&(T=T.filter(M=>(M.priority||"normal")===p)),f&&(T=T.filter(M=>(M.tags||[]).includes(f))),u.trim()){const M=u.toLowerCase();T=T.filter(C=>{const h=(C.title||"").toLowerCase(),P=(C.description||"").toLowerCase(),Y=(C.tags||[]).join(" ").toLowerCase();return h.includes(M)||P.includes(M)||Y.includes(M)})}return T},[c,u,m,p,f]),V=r.useMemo(()=>{const T=[...L],M={high:0,normal:1,low:2};switch(b){case"priority":T.sort((C,h)=>(M[C.priority]??1)-(M[h.priority]??1));break;case"created":T.sort((C,h)=>new Date(h.createdAt).getTime()-new Date(C.createdAt).getTime());break;case"due":T.sort((C,h)=>{const P=C.dueDate?new Date(C.dueDate).getTime():1/0,Y=h.dueDate?new Date(h.dueDate).getTime():1/0;return P-Y});break;case"updated":default:T.sort((C,h)=>new Date(h.updatedAt).getTime()-new Date(C.updatedAt).getTime());break}return T},[L,b]),K=async(T,M)=>{const C=c.find(P=>P.id===T);if(!C)return;const h=C.status;d(P=>P.map(Y=>Y.id===T?{...Y,status:M}:Y));try{await A.patch(`/tasks/${encodeURIComponent(T)}/status`,{status:M}),i.success(`Moved to ${M}.`,1500)}catch(P){d(Y=>Y.map(E=>E.id===T?{...E,status:h}:E)),i.error(`Move failed: ${P.message}`)}},w=async T=>{if(confirm("Delete this task?"))try{await A.del(`/tasks/${encodeURIComponent(T)}`),d(M=>M.filter(C=>C.id!==T)),i.success("Task deleted.",1500)}catch(M){i.error(`Delete failed: ${M.message}`)}},I=async T=>{try{const M=await A.post(`/tasks/${encodeURIComponent(T)}/archive`);d(C=>C.filter(h=>h.id!==T)),i.success("Task archived.",1500)}catch(M){i.error(`Archive failed: ${M.message}`)}},_=async T=>{try{const M=await A.post(`/tasks/${encodeURIComponent(T)}/unarchive`);d(C=>C.map(h=>h.id===T?M:h)),i.success("Task restored.",1500)}catch(M){i.error(`Restore failed: ${M.message}`)}},W=async(T,M={})=>{if(g.size===0)return;const C=Array.from(g);try{const h=await A.post("/tasks/bulk",{ids:C,action:T,params:M}),P=h.affected.filter(E=>E.ok).length,Y=h.affected.length-P;T==="archive"||T==="delete"?d(E=>E.filter(re=>!C.includes(re.id))):await J(),i.success(`Bulk ${T}: ${P} ok${Y?`, ${Y} failed`:""}.`,2500),B(new Set)}catch(h){i.error(`Bulk failed: ${h.message}`)}},X=async T=>{try{const C=await A.put(`/tasks/${encodeURIComponent(T.id)}`,{assignee:"me"});d(h=>h.map(P=>P.id===T.id?C:P)),i.success("Assigned to me.",1200)}catch(M){i.error(`Assign failed: ${M.message}`)}},ne=async(T,M,C,h)=>{try{const P=await A.post(`/tasks/${encodeURIComponent(T.id)}/work`,{agent:M,status:C,complete:h});d(Y=>Y.map(E=>E.id===T.id?P:E)),i.success(`Marked ${C} by ${M}.`,1500)}catch(P){i.error(`Mark failed: ${P.message}`)}},se=T=>{B(M=>{const C=new Set(M);return C.has(T)?C.delete(T):C.add(T),C})},U=T=>{B(M=>{const C=new Set(M);return T.length>0&&T.every(P=>C.has(P))?(T.forEach(P=>C.delete(P)),C):(T.forEach(P=>C.add(P)),C)})},O=T=>{a("chat"),window.dispatchEvent(new CustomEvent("bizar:setChatTask",{detail:{taskId:T}}))},Q=T=>{Ft(n,T)},[F,q]=r.useState(!1),ee=(s.tasks||[]).filter(T=>T.status==="backlog").length;return e.jsxs("div",{className:"view view-tasks",children:[e.jsx("header",{className:"view-header",children:e.jsxs("div",{className:"view-header-text",children:[e.jsxs("h2",{className:"view-title",children:[e.jsx(Be,{size:18})," Tasks (",V.length,")"]}),e.jsx("p",{className:"view-subtitle",children:"Personal kanban. Click a card for details (subtasks, deps, timer, comments, activity)."})]})}),e.jsxs("div",{className:"tasks-toolbar",children:[e.jsx("div",{className:"tasks-toolbar-group",children:e.jsxs("div",{className:"search-input",style:{width:200},children:[e.jsx(Oe,{size:12}),e.jsx("input",{className:"input",type:"text",placeholder:"Search…",value:u,onChange:T=>j(T.target.value)}),u&&e.jsx("button",{type:"button",className:"icon-btn","aria-label":"Clear search",onClick:()=>j(""),children:e.jsx($e,{size:12})})]})}),e.jsx("div",{className:"tasks-toolbar-divider"}),e.jsxs("div",{className:"tasks-toolbar-group",children:[e.jsx("span",{className:"tasks-toolbar-label",children:"Filter"}),e.jsxs("select",{className:"select select-sm",value:m,onChange:T=>o(T.target.value),title:"Assignee",children:[e.jsx("option",{value:"",children:"All assignees"}),e.jsx("option",{value:"me",children:"Me"}),(s.agents||[]).map(T=>e.jsxs("option",{value:T.name,children:["@",T.name]},T.name))]}),e.jsxs("select",{className:"select select-sm",value:p,onChange:T=>k(T.target.value),title:"Priority",children:[e.jsx("option",{value:"",children:"All priorities"}),Qs.map(T=>e.jsx("option",{value:T,children:T},T))]}),D.length>0&&e.jsxs("select",{className:"select select-sm",value:f,onChange:T=>S(T.target.value),title:"Tag",children:[e.jsx("option",{value:"",children:"All tags"}),D.map(T=>e.jsxs("option",{value:T,children:["#",T]},T))]})]}),e.jsx("div",{className:"tasks-toolbar-divider"}),e.jsxs("div",{className:"tasks-toolbar-group",children:[e.jsx("span",{className:"tasks-toolbar-label",children:"Sort"}),e.jsx("select",{className:"select select-sm",value:b,onChange:T=>v(T.target.value),title:"Sort by",children:Gi.map(T=>e.jsx("option",{value:T.id,children:T.label},T.id))})]}),e.jsx("div",{className:"tasks-toolbar-spacer"}),e.jsxs("div",{className:"tasks-toolbar-group",children:[e.jsxs(z,{variant:y?"primary":"ghost",size:"sm",onClick:()=>{$(T=>!T),J({archived:!y})},title:y?"Showing archived":"Show archived",children:[y?e.jsx(fs,{size:14}):e.jsx(js,{size:14}),y?"Active":"Archived"]}),e.jsx(z,{variant:"ghost",size:"sm",onClick:()=>J(),title:"Refresh","aria-label":"Refresh tasks",children:e.jsx(de,{size:14})}),e.jsxs(z,{variant:"accent",size:"sm",onClick:()=>Zi(n,i,d,J,t),children:[e.jsx(Qe,{size:14})," Odin"]}),e.jsxs(z,{variant:"primary",size:"sm",onClick:()=>qs(n,i,null,"queued",d,J,t,s.agents),children:[e.jsx(pe,{size:14})," Add"]}),ee>0&&e.jsxs(z,{variant:F?"accent":"ghost",size:"sm",onClick:()=>q(T=>!T),title:F?"Hide backlog":"Show backlog",children:[e.jsx(vs,{size:14}),"Backlog",e.jsx("span",{className:"badge",children:ee})]})]})]}),F&&ee>0&&e.jsx(Ki,{agents:s.agents||[],onRefresh:t}),g.size>0&&e.jsxs("div",{className:"task-bulk-bar",children:[e.jsxs("span",{className:"text-sm",children:[e.jsx(Be,{size:14})," ",g.size," selected"]}),e.jsxs("div",{className:"task-bulk-bar-actions",children:[e.jsx(z,{size:"sm",variant:"ghost",onClick:()=>W("move",{status:"queued"}),children:"Queued"}),e.jsx(z,{size:"sm",variant:"ghost",onClick:()=>W("move",{status:"doing"}),children:"Doing"}),e.jsx(z,{size:"sm",variant:"ghost",onClick:()=>W("move",{status:"done"}),children:"Done"}),e.jsx(z,{size:"sm",variant:"ghost",onClick:()=>W("priority",{priority:"high"}),children:"High"}),e.jsxs(z,{size:"sm",variant:"ghost",onClick:()=>W("archive"),children:[e.jsx(js,{size:12})," Archive"]}),e.jsxs(z,{size:"sm",variant:"danger",onClick:()=>W("delete"),children:[e.jsx(ye,{size:12})," Delete"]}),e.jsx(z,{size:"sm",variant:"ghost",onClick:()=>B(new Set),children:"Clear"})]})]}),l?e.jsx("div",{className:"view-loading",children:e.jsx(je,{size:"lg"})}):e.jsx("div",{className:"kanban",children:as.map(T=>e.jsx(Ji,{column:T,tasks:V.filter(M=>ut(M,T.id)),selected:g,onToggleSelect:se,onToggleSelectAll:U,allTaskIdsInCol:V.filter(M=>ut(M,T.id)).map(M=>M.id),onMove:K,onDelete:w,onArchive:I,onUnarchive:_,onEdit:M=>Qi(n,i,M,d,J,t,s.agents,H),onAdd:()=>qs(n,i,null,T.id,d,J,t,s.agents),onAssignMe:X,onMarkWorkedBy:ne,onOpenChat:O,onOpenArtifact:Q,isArchivedView:y},T.id))})]})}function Ji({column:s,tasks:t,selected:a,onToggleSelect:i,onToggleSelectAll:n,allTaskIdsInCol:c,onMove:d,onDelete:l,onArchive:x,onUnarchive:u,onEdit:j,onAdd:m,onAssignMe:o,onMarkWorkedBy:p,onOpenChat:k,onOpenArtifact:f,isArchivedView:S}){const[b,v]=r.useState(!1),y=t.length>0&&c.every($=>a.has($));return e.jsxs("div",{className:ae("kanban-column",b&&"kanban-column-drop"),"data-column":s.id,onDragOver:$=>{$.preventDefault(),v(!0)},onDragLeave:()=>v(!1),onDrop:$=>{$.preventDefault(),v(!1);const g=$.dataTransfer.getData("text/task-id");g&&d(g,s.id)},children:[e.jsxs("div",{className:"kanban-col-header",children:[e.jsx("button",{type:"button",className:"icon-btn",onClick:()=>n(c),title:y?"Deselect all":"Select all","aria-label":y?"Deselect all":"Select all",children:y?e.jsx(Be,{size:12}):e.jsx(Rt,{size:12})}),e.jsx(le,{children:e.jsx(Pe,{kind:s.kind,dot:!0,children:s.label})}),e.jsx("span",{className:"kanban-col-count tabular-nums",children:t.length})]}),e.jsx("div",{className:"kanban-col-body",children:t.length===0?e.jsx("div",{className:"kanban-empty",children:"No tasks"}):t.map($=>e.jsx(Xi,{task:$,focused:a.has($.id),onFocus:()=>i($.id),onMove:g=>{const H=as.findIndex(R=>R.id===$.status)+g;H>=0&&H<as.length&&d($.id,as[H].id)},onEdit:()=>j($),onDelete:()=>l($.id),onArchive:()=>x($.id),onUnarchive:()=>u($.id),onAssignMe:()=>o($),onMarkWorkedBy:(g,B,H)=>p($,g,B,H),onOpenChat:k,onOpenArtifact:f,isArchivedView:S},$.id))}),!S&&e.jsx("footer",{className:"kanban-col-footer",children:e.jsxs(z,{variant:"ghost",size:"sm",onClick:m,className:"w-full",children:[e.jsx(pe,{size:12})," Add task"]})})]})}function Xi({task:s,focused:t,onFocus:a,onMove:i,onEdit:n,onDelete:c,onArchive:d,onUnarchive:l,onAssignMe:x,onMarkWorkedBy:u,onOpenChat:j,onOpenArtifact:m,isArchivedView:o}){var g,B,H;const p=ce(),k=ke(),f=s._timerStart,S=(s.workedBy||s.status==="doing")&&!o,b=s.metadata||{},v=!!(b.sessionId||b.bgInstanceId),$=(b.artifactIds||(b.artifactId?[b.artifactId]:[]))[0];return e.jsxs("div",{className:ae("task-card",`priority-${s.priority}`,t&&"task-card-focused",f?"task-card-timer is-working":null,S&&!f?"is-working":null),"data-task-id":s.id,"data-task-parent":s.parent||"",draggable:!o,onDragStart:R=>{R.dataTransfer.setData("text/task-id",s.id),R.dataTransfer.effectAllowed="move"},onClick:a,children:[e.jsxs("div",{className:"task-card-head",children:[e.jsx("button",{type:"button",className:ae("task-card-checkbox",t&&"task-card-checkbox-on"),"aria-label":t?"Deselect task":"Select task",title:t?"Deselect":"Select",onClick:R=>{R.stopPropagation(),a()},children:t?e.jsx(Be,{size:13}):e.jsx(Rt,{size:13})}),e.jsx("span",{className:"priority-dot",style:{background:ha[s.priority]||"var(--info)"}}),e.jsx("div",{className:"task-card-title",children:s.title}),f&&e.jsxs("span",{className:"task-card-timer-pill",children:[e.jsx(Xe,{size:10})," running"]}),s.workedBy&&s.status==="doing"&&!f&&e.jsxs("span",{className:"task-card-timer-pill",title:`@${s.workedBy}`,children:[e.jsx(Ee,{size:10})," @",s.workedBy]}),s.recurring&&e.jsx("span",{className:"task-card-timer-pill",title:"Recurring",children:e.jsx(bt,{size:10})})]}),s.description&&e.jsx("div",{className:"task-card-desc",children:s.description.slice(0,160)}),e.jsxs("div",{className:"task-card-badges",children:[s.assignee&&!s.workedBy&&e.jsxs("span",{className:"task-card-badge",children:[e.jsx(Os,{size:10})," @",s.assignee]}),s.timeSpent?e.jsxs("span",{className:"task-card-badge",children:[e.jsx(Xe,{size:10})," ",Hs(s.timeSpent)]}):null,(g=s.dependencies)!=null&&g.length?e.jsxs("span",{className:"task-card-badge",children:[e.jsx(At,{size:10})," ",s.dependencies.length]}):null,s.recurring?e.jsxs("span",{className:"task-card-badge",children:[e.jsx(zt,{size:10})," ",s.recurring.cron||s.recurring.freq||"recurring"]}):null,(B=s.comments)!=null&&B.length?e.jsxs("span",{className:"task-card-badge",children:[e.jsx(Ve,{size:10})," ",s.comments.length]}):null,(H=s.attachments)!=null&&H.length?e.jsxs("span",{className:"task-card-badge",children:[e.jsx(ua,{size:10})," ",s.attachments.length]}):null,b.bgInstanceId?e.jsxs("span",{className:"task-card-badge",children:[e.jsx(ze,{size:10})," ",e.jsx(Bt,{status:b.status||"pending"})]}):null]}),s.tags&&s.tags.length>0&&e.jsx("div",{className:"task-card-tags",children:s.tags.map(R=>e.jsx(Ui,{children:R},R))}),e.jsxs("div",{className:"task-card-footer",children:[e.jsx("span",{className:"task-card-time tabular-nums muted",children:ve(s.updatedAt||s.createdAt)}),e.jsxs("div",{className:"task-card-actions",onClick:R=>R.stopPropagation(),children:[!o&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:"icon-btn","aria-label":"Move left",title:"Move left",onClick:()=>i(-1),children:e.jsx(Ia,{size:14})}),e.jsx("button",{type:"button",className:"icon-btn","aria-label":"Edit",title:"Open detail",onClick:n,children:e.jsx(Te,{size:14})}),e.jsx("button",{type:"button",className:"icon-btn","aria-label":"Assign me",title:"Assign to me",onClick:x,children:e.jsx(Os,{size:14})}),v&&e.jsx("button",{type:"button",className:"icon-btn","aria-label":"Open chat",title:"Open in chat",onClick:()=>j(s.id),children:e.jsx(Ve,{size:14})}),$&&e.jsx("button",{type:"button",className:"icon-btn","aria-label":"Open artifact",title:"Open artifact",onClick:()=>m($),children:e.jsx(ws,{size:14})}),o?e.jsx("button",{type:"button",className:"icon-btn","aria-label":"Restore",title:"Restore",onClick:l,children:e.jsx(fs,{size:14})}):e.jsx("button",{type:"button",className:"icon-btn","aria-label":"Archive",title:"Archive",onClick:d,children:e.jsx(js,{size:14})}),b.bgInstanceId&&e.jsx("button",{type:"button",className:"icon-btn icon-btn-danger","aria-label":"Kill background instance",title:"Kill background instance",onClick:()=>{Ot(k,p,b.bgInstanceId,s.title,()=>{const R=new CustomEvent("bizar:taskKilled",{detail:{taskId:s.id,bgInstanceId:b.bgInstanceId}});window.dispatchEvent(R)})},children:e.jsx(ze,{size:14})}),e.jsx("button",{type:"button",className:"icon-btn icon-btn-danger","aria-label":"Delete",title:"Delete",onClick:c,children:e.jsx(ye,{size:14})}),e.jsx("button",{type:"button",className:"icon-btn","aria-label":"Move right",title:"Move right",onClick:()=>i(1),children:e.jsx(He,{size:14})})]}),o&&e.jsxs(e.Fragment,{children:[e.jsx("button",{type:"button",className:"icon-btn","aria-label":"Restore",title:"Restore",onClick:l,children:e.jsx(fs,{size:14})}),e.jsx("button",{type:"button",className:"icon-btn icon-btn-danger","aria-label":"Delete",title:"Delete",onClick:c,children:e.jsx(ye,{size:14})})]})]})]})]})}function Hs(s){if(!s)return"0m";const t=Math.floor(s/3600),a=Math.floor(s%3600/60);return t>0?`${t}h ${a}m`:`${a}m`}function qs(s,t,a,i,n,c,d,l=[]){var v,y,$;let x=null,u=null,j=null,m=null,o=null,p=null,k=null,f=null,S=null;const b=async()=>{var _;const g=(x==null?void 0:x.value.trim())||"";if(!g){t.warning("Title is required."),x==null||x.focus();return}const B=(u==null?void 0:u.value.trim())||"",H=((_=m==null?void 0:m.querySelector('input[name="task-priority"]:checked'))==null?void 0:_.value)||"normal",R=(j==null?void 0:j.value.trim())||"",J=R?R.split(",").map(W=>W.trim()).filter(Boolean):[],D=(o==null?void 0:o.value)||i,L=((p==null?void 0:p.value)||"").trim()||null,V=(k==null?void 0:k.value)||"",K=(f==null?void 0:f.value.trim())||"",w=V==="custom"&&K?{freq:"custom",cron:K}:V&&V!=="none"?{freq:V}:null,I=(S==null?void 0:S.value)||null;try{if(a){const W=await A.put(`/tasks/${encodeURIComponent(a.id)}`,{title:g,description:B,tags:J,priority:H,status:D,assignee:L,recurring:w,dueDate:I});s.close(),typeof window<"u"&&window.dispatchEvent(new MouseEvent("mousedown")),n(X=>X.map(ne=>ne.id===a.id?W:ne)),t.success("Task updated.",1500)}else{const W=await A.post("/tasks",{title:g,description:B,status:D,tags:J,priority:H,assignee:L,recurring:w,dueDate:I});s.close(),typeof window<"u"&&window.dispatchEvent(new MouseEvent("mousedown")),n(X=>[W,...X]),t.success("Task created.",1500)}await d()}catch(W){t.error(`Save failed: ${W.message}`)}};s.open({title:a?"Edit task":"New task",width:560,children:e.jsxs("div",{className:"task-form",children:[e.jsx("label",{className:"field-label",htmlFor:"task-title",children:"Title *"}),e.jsx("input",{ref:g=>{x=g},id:"task-title",className:"input",type:"text",maxLength:200,placeholder:"What needs to be done?",defaultValue:(a==null?void 0:a.title)||"",autoFocus:!0}),e.jsx("label",{className:"field-label",htmlFor:"task-desc",children:"Description (markdown)"}),e.jsx("textarea",{ref:g=>{u=g},id:"task-desc",className:"textarea",rows:3,placeholder:"Markdown supported…",defaultValue:(a==null?void 0:a.description)||""}),e.jsxs("div",{className:"task-form-row",children:[e.jsxs("div",{className:"task-form-field",children:[e.jsx("label",{className:"field-label",htmlFor:"task-status",children:"Status"}),e.jsx("select",{ref:g=>{o=g},id:"task-status",className:"select",defaultValue:(a==null?void 0:a.status)||i,children:as.map(g=>e.jsx("option",{value:g.id,children:g.label},g.id))})]}),e.jsxs("div",{className:"task-form-field",children:[e.jsx("label",{className:"field-label",children:"Priority"}),e.jsx("div",{className:"radio-row",ref:g=>{m=g},children:Qs.map(g=>e.jsxs("label",{className:"radio-label",children:[e.jsx("input",{type:"radio",name:"task-priority",value:g,defaultChecked:((a==null?void 0:a.priority)||"normal")===g}),e.jsx("span",{className:"capitalize",children:g})]},g))})]})]}),e.jsxs("div",{className:"task-form-row",children:[e.jsxs("div",{className:"task-form-field",children:[e.jsx("label",{className:"field-label",htmlFor:"task-assignee",children:"Assignee"}),e.jsx("input",{ref:g=>{p=g},id:"task-assignee",className:"input",type:"text",placeholder:"odin, thor, me, …",list:"task-assignee-suggestions",defaultValue:(a==null?void 0:a.assignee)||""}),e.jsx("datalist",{id:"task-assignee-suggestions",children:l.map(g=>e.jsxs("option",{value:g.name,children:["@",g.name]},g.name))})]}),e.jsxs("div",{className:"task-form-field",children:[e.jsx("label",{className:"field-label",htmlFor:"task-due",children:"Due date"}),e.jsx("input",{ref:g=>{S=g},id:"task-due",className:"input",type:"date",defaultValue:((v=a==null?void 0:a.dueDate)==null?void 0:v.slice(0,10))||""})]})]}),e.jsx("label",{className:"field-label",htmlFor:"task-tags",children:"Tags"}),e.jsx("input",{ref:g=>{j=g},id:"task-tags",className:"input",type:"text",placeholder:"comma-separated, e.g. bug, frontend",defaultValue:((a==null?void 0:a.tags)||[]).join(", ")}),e.jsxs("div",{className:"task-form-row",children:[e.jsxs("div",{className:"task-form-field",children:[e.jsx("label",{className:"field-label",htmlFor:"task-recur",children:"Recurring"}),e.jsxs("select",{ref:g=>{k=g},id:"task-recur",className:"select",defaultValue:((y=a==null?void 0:a.recurring)==null?void 0:y.freq)||"none",children:[e.jsx("option",{value:"none",children:"None"}),e.jsx("option",{value:"daily",children:"Daily"}),e.jsx("option",{value:"weekly",children:"Weekly"}),e.jsx("option",{value:"monthly",children:"Monthly"}),e.jsx("option",{value:"custom",children:"Custom (cron)"})]})]}),e.jsxs("div",{className:"task-form-field",children:[e.jsx("label",{className:"field-label",htmlFor:"task-cron",children:"Cron expression"}),e.jsx("input",{ref:g=>{f=g},id:"task-cron",className:"input",type:"text",placeholder:"0 9 * * *",defaultValue:(($=a==null?void 0:a.recurring)==null?void 0:$.cron)||""})]})]})]}),footer:e.jsxs("div",{className:"modal-footer-actions",children:[e.jsx(z,{variant:"ghost",onClick:()=>s.close(),children:"Cancel"}),e.jsx(z,{variant:"primary",onClick:b,children:a?"Save":"Create"})]})})}function Qi(s,t,a,i,n,c,d=[],l=0){let x=null,u=null,j=null;const m=async()=>{const b=((x==null?void 0:x.value)||"").trim();if(b)try{const v=await A.post(`/tasks/${encodeURIComponent(a.id)}/comments`,{text:b});i(y=>y.map($=>$.id===a.id?v:$)),x&&(x.value=""),t.success("Comment added.",1200)}catch(v){t.error(`Comment failed: ${v.message}`)}},o=async()=>{try{const b=await A.post(`/tasks/${encodeURIComponent(a.id)}/timer/start`);i(v=>v.map(y=>y.id===a.id?b:y)),t.success("Timer started.",1200)}catch(b){t.error(`Start failed: ${b.message}`)}},p=async()=>{try{const b=await A.post(`/tasks/${encodeURIComponent(a.id)}/timer/stop`);i(v=>v.map(y=>y.id===a.id?b:y)),t.success("Timer stopped.",1200)}catch(b){t.error(`Stop failed: ${b.message}`)}},k=async()=>{const b=((u==null?void 0:u.value)||"").trim();if(!b)return;const v=[...a.dependencies||[],b];try{const y=await A.put(`/tasks/${encodeURIComponent(a.id)}`,{dependencies:v});i($=>$.map(g=>g.id===a.id?y:g)),u&&(u.value=""),t.success("Dependency added.",1200)}catch(y){t.error(`Failed: ${y.message}`)}},f=async(b,v)=>{const y=(j==null?void 0:j.value)||"";if(!y){t.warning("Pick an agent first.");return}try{const $=await A.post(`/tasks/${encodeURIComponent(a.id)}/work`,{agent:y,status:b,complete:v});i(g=>g.map(B=>B.id===a.id?$:B)),t.success(`${b} by @${y}.`,1200)}catch($){t.error(`Failed: ${$.message}`)}},S=a._timerStart?Math.floor((Date.now()-a._timerStart)/1e3)+(a.timeSpent||0):a.timeSpent||0;s.open({title:`Task — ${a.title}`,width:640,children:e.jsxs("div",{className:"task-detail",children:[e.jsxs("div",{className:"task-detail-meta",children:[e.jsxs("span",{children:[e.jsx("strong",{children:"Status:"})," ",a.status]}),e.jsxs("span",{children:[e.jsx("strong",{children:"Priority:"})," ",a.priority]}),a.assignee&&e.jsxs("span",{children:[e.jsx("strong",{children:"Assignee:"})," @",a.assignee]}),a.workedBy&&e.jsxs("span",{children:[e.jsx("strong",{children:"Working:"})," ",e.jsxs("span",{className:"is-working",style:{display:"inline-block",padding:"0 6px"},children:["@",a.workedBy]})]}),a.dueDate&&e.jsxs("span",{children:[e.jsx("strong",{children:"Due:"})," ",a.dueDate.slice(0,10)]}),e.jsxs("span",{children:[e.jsx("strong",{children:"Time:"})," ",Hs(S)]})]}),a.description&&e.jsxs(te,{children:[e.jsx(le,{children:"Description"}),e.jsx("div",{className:"task-detail-desc",children:a.description})]}),e.jsxs(te,{children:[e.jsxs(le,{children:[e.jsx(Ee,{size:14})," Mark as worked on by"]}),e.jsxs("div",{className:"task-detail-row",children:[e.jsxs("select",{ref:b=>{j=b},className:"select",defaultValue:a.workedBy||"",children:[e.jsx("option",{value:"",children:"(pick an agent)"}),d.map(b=>e.jsxs("option",{value:b.name,children:["@",b.name]},b.name))]}),e.jsxs(z,{variant:"primary",size:"sm",onClick:()=>f("doing",!1),children:[e.jsx(Es,{size:12})," Start working"]}),e.jsxs(z,{variant:"success",size:"sm",onClick:()=>f("done",!0),children:[e.jsx(Be,{size:12})," Complete"]}),e.jsxs(z,{variant:"ghost",size:"sm",onClick:()=>f("idle",!1),children:[e.jsx(it,{size:12})," Stop"]})]})]}),e.jsxs(te,{children:[e.jsxs(le,{children:[e.jsx(Xe,{size:14})," Time tracking"]}),e.jsxs("div",{className:"task-detail-row",children:[a._timerStart?e.jsxs(z,{variant:"secondary",size:"sm",onClick:p,className:"is-working",children:[e.jsx(it,{size:12})," Stop"]}):e.jsxs(z,{variant:"secondary",size:"sm",onClick:o,children:[e.jsx(Es,{size:12})," Start"]}),e.jsxs("span",{className:ae("muted",a._timerStart?"is-working":null),children:[Hs(S),a._timerStart&&" (running)"]})]})]}),e.jsxs(te,{children:[e.jsxs(le,{children:[e.jsx(At,{size:14})," Dependencies"]}),e.jsxs("div",{className:"task-detail-row",children:[e.jsx("input",{ref:b=>{u=b},className:"input",type:"text",placeholder:"task id (e.g. tsk_abc12345)"}),e.jsx(z,{variant:"secondary",size:"sm",onClick:k,children:"Add"})]}),e.jsxs("ul",{children:[(a.dependencies||[]).map(b=>e.jsx("li",{children:e.jsx("code",{children:b})},b)),(a.dependencies||[]).length===0&&e.jsx("li",{className:"muted",children:"No dependencies."})]})]}),a.recurring&&e.jsxs(te,{children:[e.jsxs(le,{children:[e.jsx(zt,{size:14})," Recurring"]}),e.jsxs("div",{className:"muted",children:["Frequency: ",e.jsx("code",{children:a.recurring.freq||"custom"})," ",a.recurring.cron&&e.jsx("code",{children:a.recurring.cron})]}),a.recurring.lastGenerated&&e.jsxs("div",{className:"muted text-sm",children:["Last spawned: ",ve(a.recurring.lastGenerated)]})]}),e.jsxs(te,{children:[e.jsxs(le,{children:[e.jsx(Ve,{size:14})," Comments"]}),e.jsx("textarea",{ref:b=>{x=b},className:"textarea",rows:3,placeholder:"Add a comment…"}),e.jsx(z,{variant:"primary",size:"sm",onClick:m,children:"Post"}),e.jsxs("ul",{className:"task-comments",children:[(a.comments||[]).map(b=>e.jsxs("li",{children:[e.jsx("div",{className:"muted tabular-nums",children:ve(b.createdAt)}),e.jsx("div",{children:b.text})]},b.id)),(a.comments||[]).length===0&&e.jsx("li",{className:"muted",children:"No comments."})]})]}),e.jsxs(te,{children:[e.jsxs(le,{children:[e.jsx(ze,{size:14})," Activity"]}),e.jsxs("ul",{className:"task-activity",children:[(a.activity||[]).slice().reverse().slice(0,20).map(b=>e.jsxs("li",{children:[e.jsx("span",{className:"muted tabular-nums",children:ve(b.ts)})," ",e.jsx("span",{className:"tag",children:b.type}),b.data&&typeof b.data=="object"?e.jsxs("code",{className:"muted",children:[" ",JSON.stringify(b.data)]}):null]},b.id)),(a.activity||[]).length===0&&e.jsx("li",{className:"muted",children:"No activity yet."})]})]})]}),footer:e.jsxs("div",{className:"modal-footer-actions",children:[e.jsx(z,{variant:"ghost",onClick:()=>s.close(),children:"Close"}),e.jsxs(z,{variant:"primary",onClick:()=>{s.close(),qs(s,t,a,a.status,i,n,c,d)},children:[e.jsx(Te,{size:12})," Edit basics"]})]})})}function Zi(s,t,a,i,n){let c=null,d=null,l=null,x=null;const u=async m=>{m&&typeof m.preventDefault=="function"&&m.preventDefault(),m&&typeof m.stopPropagation=="function"&&m.stopPropagation();const o=(d==null?void 0:d.value)||"";let p=((c==null?void 0:c.value)||"").trim();if(!p&&o.trim()&&(p=ma(o),c&&(c.value=p)),!p){t.warning("Add a description so Odin knows what to do.");return}const k=(l==null?void 0:l.value)||"normal",f=((x==null?void 0:x.value)||"").split(",").map(S=>S.trim()).filter(Boolean);try{const S=await A.post("/tasks/submit",{title:p,description:o,priority:k,tags:f}),b=(S.subtasks||[]).length;t.success(b>1?`Odin split it into ${b} subtasks.`:"Task submitted to Odin."),s.close(),typeof window<"u"&&window.dispatchEvent(new MouseEvent("mousedown")),a&&a(v=>[S.main,...S.subtasks||[],...v]),i&&await i(),n&&await n()}catch(S){t.error(`Submit failed: ${S.message}`)}},j=m=>{m.key==="Enter"&&!m.shiftKey&&(m.preventDefault(),u(m))};s.open({title:"Submit Task to Odin",width:560,children:e.jsxs("div",{className:"submit-task-form",children:[e.jsxs("label",{htmlFor:"submit-task-title",children:["Title ",e.jsx("span",{className:"field-hint",children:"(optional — auto-generated from description)"}),e.jsx("input",{id:"submit-task-title",ref:m=>{c=m},className:"input",type:"text",placeholder:"Leave blank to derive from description",autoFocus:!0,onKeyDown:j}),e.jsx("span",{className:"field-hint",children:"Odin will analyze this and split it into subtasks assigned to the best agent."})]}),e.jsxs("label",{htmlFor:"submit-task-desc",children:["Description",e.jsxs("span",{style:{display:"flex",gap:6,alignItems:"flex-start"},children:[e.jsx("textarea",{id:"submit-task-desc",ref:m=>{d=m},className:"textarea",rows:5,placeholder:"Provide more detail (markdown ok)…",style:{flex:1}}),e.jsx("button",{type:"button",className:"btn btn-ghost btn-icon",style:{marginTop:0,flexShrink:0},title:"Enhance prompt with AI",onClick:async()=>{var o;if(!((o=d==null?void 0:d.value)!=null&&o.trim()))return;const m=await da(d.value);m!==d.value&&(d.value=m)},children:e.jsx(Te,{size:14})})]})]}),e.jsxs("div",{className:"task-form-row",children:[e.jsxs("label",{htmlFor:"submit-task-priority",className:"task-form-field",children:["Priority",e.jsx("select",{id:"submit-task-priority",ref:m=>{l=m},className:"select",defaultValue:"normal",children:Qs.map(m=>e.jsx("option",{value:m,children:m},m))})]}),e.jsxs("label",{htmlFor:"submit-task-tags",className:"task-form-field",style:{flex:2},children:["Tags ",e.jsx("span",{className:"field-hint",children:"(comma-separated)"}),e.jsx("input",{id:"submit-task-tags",ref:m=>{x=m},className:"input",type:"text",placeholder:"backend, auth"})]})]})]}),footer:e.jsxs("div",{className:"modal-footer-actions",children:[e.jsx(z,{variant:"ghost",onClick:()=>s.close(),children:"Cancel"}),e.jsxs(z,{variant:"primary",type:"button",onClick:m=>u(m),children:[e.jsx(Qe,{size:14})," Submit to Odin"]})]})})}const pt={"1m":60*1e3,"5m":5*60*1e3,"30m":30*60*1e3,"1h":60*60*1e3},we=56,Re=32,Ye=22,el=4,sl=.9,Is={working:"var(--success)",running:"var(--success)",doing:"var(--info)",queued:"var(--info)",done:"var(--success)",success:"var(--success)",blocked:"var(--warning)",error:"var(--error)",failed:"var(--error)",stuck:"var(--warning)",killed:"var(--error)",idle:"var(--text-dim)",pending:"var(--info)",timed_out:"var(--warning)"};function Rs(s){return s&&Is[s]||Is.idle}function ps(s,t=24){return s?s.length<=t?s:s.slice(0,t-1)+"…":""}function bs(s){if(s==null)return 0;if(typeof s=="number")return s;const t=new Date(s).getTime();return Number.isNaN(t)?0:t}function Ds(s){const t=s._timerStart;return typeof t=="number"&&t>0?t:bs(s.createdAt)||Date.now()}function tl(s,t){return(s.status==="done"||s.status==="archived"||s.status==="failed"||s.status==="killed")&&(bs(s.completedAt)||bs(s.updatedAt))||t}function al(s){return typeof s.startedAt=="number"&&s.startedAt>0?s.startedAt:Date.now()}function nl(s,t){return(s.status==="done"||s.status==="success"||s.status==="killed"||s.status==="failed"||s.status==="error"||s.status==="timed_out")&&(s.completedAt||s.lastEventAt)||t}function il(s){return s<=6e4?1e4:s<=3e5?3e4:s<=18e5?3e5:6e5}function ll(s,t){const a=new Date(s);return t<=3e5?a.toLocaleTimeString("en-GB",{hour12:!1}):a.toLocaleTimeString("en-GB",{hour12:!1,hour:"2-digit",minute:"2-digit"})}function rl({snapshot:s,refreshSnapshot:t}){const a=ce(),i=r.useRef(null),[n,c]=r.useState("live"),[d,l]=r.useState("5m"),[x,u]=r.useState(()=>typeof window>"u"?!0:window.innerWidth>900),[j,m]=r.useState([]),[o,p]=r.useState([]),[k,f]=r.useState(!0),[S,b]=r.useState(0),[v,y]=r.useState(Date.now()),[$,g]=r.useState(()=>Date.now()-pt["5m"]*.1),[B,H]=r.useState({width:800,height:400}),[R,J]=r.useState(null),[D,L]=r.useState(""),[V,K]=r.useState([]),[w,I]=r.useState(""),[_,W]=r.useState("normal"),[X,ne]=r.useState(""),[se,U]=r.useState(""),[O,Q]=r.useState(!1),[F,q]=r.useState(!1),[ee,T]=r.useState([]),M=ke(),C=s.agents||[],h=s.tasks||[],P=pt[d],Y=$,E=$+P,re=r.useCallback(async()=>{try{const[N,G]=await Promise.all([A.get("/background").catch(()=>({instances:[]})),A.get("/activity?limit=200").catch(()=>({events:[]}))]);m(N.instances||[]),p(G.events||[])}catch(N){console.warn("activity reload failed:",N)}finally{f(!1)}},[]);r.useEffect(()=>{re();const N=setInterval(re,3e3);return()=>clearInterval(N)},[re]),r.useEffect(()=>{b(N=>N+1)},[h.length,C.length]),r.useEffect(()=>{if(n==="pause")return;y(Date.now());const N=setInterval(()=>y(Date.now()),1e3);return()=>clearInterval(N)},[n,S]),r.useEffect(()=>{if(n==="pause")return;(v-$)/P>sl&&g(v-P*.1)},[v,$,P,n]),r.useEffect(()=>{g(Date.now()-P*.1)},[d]),r.useEffect(()=>{n==="live"&&g(Date.now()-P*.1)},[n]),r.useLayoutEffect(()=>{const N=i.current;if(!N)return;const G=new ResizeObserver(ue=>{for(const xe of ue){const{width:he,height:ge}=xe.contentRect;H({width:Math.max(200,Math.floor(he)),height:Math.max(120,Math.floor(ge))})}});return G.observe(N),()=>G.disconnect()},[]);const ie=r.useMemo(()=>{const N=[];let G=0;for(const he of j){const ge=al(he),Se=nl(he,v);Se<Y||ge>E||N.push({kind:"bg",id:`bg:${he.instanceId}`,index:G++,label:`BG ${ps(he.promptPreview,20)||he.instanceId.slice(0,10)}`,sub:he.status||"pending",start:ge,end:Se,data:he})}const ue=[...h].sort((he,ge)=>Ds(he)-Ds(ge)),xe=[];for(const he of ue){const ge=Ds(he),Se=tl(he,v);if(Se<Y||ge>E)continue;let We=-1;for(let qe=0;qe<xe.length;qe++)if(xe[qe]<=ge){xe[qe]=Se,We=qe;break}We===-1&&(xe.push(Se),We=xe.length-1),N.push({kind:"task",id:`task:${he.id}`,index:G+We,label:ps(he.title,32),sub:he.status,start:ge,end:Se,data:he})}return N},[j,h,v,Y,E]),fe=r.useMemo(()=>{const N=new Map;for(const G of ie)N.set(G.id,G);return N},[ie]),me=r.useCallback(N=>P<=0?0:(N-Y)/P*B.width,[Y,P,B.width]),ms=r.useMemo(()=>{const N=il(P),G=[],ue=Math.floor(Y/N)*N;for(let xe=ue;xe<=E+N;xe+=N){if(xe<Y-N)continue;if(xe>E)break;const he=me(xe);he<-40||he>B.width+40||G.push({t:xe,x:he,label:ll(xe,P)})}return G},[Y,E,P,B.width,me]),_t=r.useMemo(()=>{const N=[];for(const G of ie){if(G.kind==="events")continue;const ue=Math.max(G.start,Y),xe=Math.min(G.end,E);if(xe<Y||ue>E)continue;const he=me(ue),ge=me(xe),Se=Math.max(el,ge-he),We=Re+Ye+G.index*we+8,qe=we-16;let Me="doing";if(G.kind==="bg"){const be=G.data.status||"pending";be==="done"||be==="success"?Me="done":be==="failed"||be==="killed"||be==="error"?Me="failed":be==="queued"||be==="pending"?Me="queued":be==="blocked"||be==="stuck"?Me="blocked":Me="doing"}else{const be=G.data.status;be==="done"||be==="archived"?Me="done":be==="failed"||be==="killed"?Me="failed":be==="queued"?Me="queued":be==="blocked"?Me="blocked":Me="doing"}const Qt=(R==null?void 0:R.id)===G.id;N.push({id:G.id,laneIndex:G.index,x:he,y:We,w:Se,h:qe,label:G.label,statusClass:Me,selected:Qt,data:G.data,kind:G.kind,start:G.start,end:G.end})}return N},[ie,me,R,Y,E]),Vt=r.useMemo(()=>{const N=[];for(const G of o){const ue=bs(G.ts);if(ue<Y-5e3||ue>E+5e3)continue;const xe=me(ue);let he=Re+12;if(G.taskId){const ge=fe.get(`task:${G.taskId}`);ge&&(he=Re+Ye+ge.index*we+we/2)}else if(G.nodeId){const ge=String(G.nodeId),Se=fe.get(ge.startsWith("task:")||ge.startsWith("bg:")?ge:`task:${ge}`);Se&&(he=Re+Ye+Se.index*we+we/2)}N.push({id:`${G.ts}-${G.kind}-${G.author??""}-${G.taskId??""}`,x:xe,y:he,kind:G.kind||"event",ts:ue,text:String(G.text||G.kind||""),author:G.author})}return N},[o,Y,E,me,fe]),Wt=r.useMemo(()=>ie.map(N=>({id:N.id,y:Re+Ye+N.index*we,h:we})),[ie]),hs=r.useMemo(()=>{const N=me(v);return Math.max(0,Math.min(B.width,N))},[me,v,B.width]),Kt=r.useCallback(N=>{const ue={id:N.id,kind:N.kind,label:N.label,status:N.statusClass,data:N.data};J(ue)},[]);r.useEffect(()=>{if(!R){K([]),U(""),T([]);return}L(""),I(""),ne(""),T([]),(async()=>{try{const N=await A.get(`/activity?nodeId=${encodeURIComponent(R.id)}&limit=50`);K(N.events||[])}catch{K([])}if(R.kind==="bg"){const N=R.data;try{const G=await A.get(`/background/${encodeURIComponent(N.instanceId)}/output?lines=80`);U(G.output||"")}catch{U("")}if(N.taskId)try{const G=await A.get(`/tasks/${encodeURIComponent(N.taskId)}/artifacts`);T((G.artifacts||[]).map(ue=>ue.id))}catch{T([])}}})()},[R]);const st=async()=>{if(!(!R||!D.trim())){q(!0);try{await A.post("/comments",{nodeId:R.id,text:D,author:"user"}),L("");const N=await A.get(`/activity?nodeId=${encodeURIComponent(R.id)}&limit=50`);K(N.events||[]),a.success("Comment added.")}catch(N){a.error(`Comment failed: ${N.message}`)}finally{q(!1)}}},Gt=async()=>{if(!(!R||!w.trim())){Q(!0);try{await A.post(`/nodes/${encodeURIComponent(R.id)}/tasks`,{title:w,description:`Created from timeline selection ${R.id}.`,priority:_}),I(""),a.success("Task created."),await t()}catch(N){a.error(`Task create failed: ${N.message}`)}finally{Q(!1)}}},tt=async()=>{if(!R||R.kind!=="bg"||!X.trim())return;const N=R.data;try{const G=await A.post(`/background/${encodeURIComponent(N.instanceId)}/message`,{message:X});G.ok?(a.success("Message sent."),ne("")):a.warning(G.error||"Send failed")}catch(G){a.error(`Send failed: ${G.message}`)}},Yt=async()=>{if(!R||R.kind!=="bg"||!confirm("Kill this bg instance session?"))return;const N=R.data;try{const G=await A.del(`/background/${encodeURIComponent(N.instanceId)}`);G.ok?a.success("Session killed."):a.warning(G.error||"Kill failed"),await re()}catch(G){a.error(`Kill failed: ${G.message}`)}},Jt=async()=>{if(!R||R.kind!=="bg")return;const N=R.data;try{const G=await A.get(`/background/${encodeURIComponent(N.instanceId)}/output?lines=80`);U(G.output||"")}catch{}};r.useEffect(()=>{const N=G=>{G.key==="Escape"&&J(null)};return window.addEventListener("keydown",N),()=>window.removeEventListener("keydown",N)},[]);const Xt=()=>{b(N=>N+1),re()},Cs=Re+Ye+ie.length*we;return e.jsxs("div",{className:"view view-activity",children:[e.jsxs("header",{className:"view-header",children:[e.jsxs("div",{className:"view-header-text",children:[e.jsxs("h2",{className:"view-title",children:[e.jsx(ze,{size:18})," Activity"]}),e.jsx("p",{className:"view-subtitle",children:"Live timeline of agents, tasks, and background sessions. Active tasks pulse; the red line marks “now”."})]}),e.jsx("div",{className:"view-actions",children:e.jsxs("div",{className:"tl-mode-toggle",children:[e.jsxs(z,{variant:n==="live"?"primary":"secondary",size:"sm",onClick:()=>c(n==="live"?"pause":"live"),title:n==="live"?"Pause timeline":"Resume timeline",children:[n==="live"?e.jsx(pa,{size:14}):e.jsx(Gs,{size:14}),n==="live"?"Live":"Paused"]}),e.jsx("div",{className:"tl-zoom-group",children:["1m","5m","30m","1h"].map(N=>e.jsx("button",{type:"button",className:ae("tl-zoom-btn",d===N&&"tl-zoom-btn-active"),onClick:()=>l(N),title:`Zoom to ${N}`,children:N},N))}),e.jsxs(z,{variant:"secondary",size:"sm",onClick:Xt,title:"Refresh",children:[e.jsx(de,{size:14})," Refresh"]})]})})]}),k&&e.jsx("div",{className:"view-loading",children:e.jsx(je,{size:"lg"})}),!k&&C.length===0&&h.length===0&&j.length===0&&o.length===0?e.jsx(Ie,{icon:e.jsx(ze,{size:32}),title:"No activity yet",message:"Once agents, tasks, or background instances exist, they'll show up here on the timeline."}):e.jsx("div",{className:ae("tl-view",R&&"tl-view-detail-open"),children:e.jsxs("div",{className:ae("tl-body",!x&&"tl-body-stream-collapsed"),children:[e.jsxs("aside",{className:ae("tl-stream",!x&&"tl-stream-collapsed"),children:[e.jsxs("div",{className:"tl-stream-head",children:[e.jsxs("h3",{children:[e.jsx(ns,{size:13})," Live events"]}),e.jsx("button",{type:"button",className:"icon-btn",onClick:()=>u(!1),title:"Hide event stream","aria-label":"Hide event stream",children:e.jsx(Qa,{size:14})})]}),e.jsx("div",{className:"tl-stream-list",children:o.length===0?e.jsx("div",{className:"tl-stream-empty",children:e.jsx("p",{children:"No events yet."})}):[...o].reverse().map((N,G)=>{const ue=N.author?Ee:N.kind==="task"?Be:N.kind==="bg"?Ts:ze;return e.jsxs("div",{className:"tl-stream-event",children:[e.jsx("span",{className:"tl-stream-event-time",children:new Date(N.ts).toLocaleTimeString("en-GB",{hour12:!1})}),e.jsx("span",{className:"tl-stream-event-icon",style:{color:Rs(N.kind)},children:e.jsx(ue,{size:12})}),e.jsx("span",{className:"tl-stream-event-text",children:N.author||N.text||N.kind})]},`${N.ts}-${G}`)})})]}),e.jsxs("div",{className:"tl-canvas-wrap",ref:i,children:[e.jsxs("div",{className:"tl-canvas-toolbar",children:[e.jsxs("div",{className:"tl-canvas-toolbar-left",children:[!x&&e.jsxs(z,{variant:"ghost",size:"sm",onClick:()=>u(!0),title:"Show event stream",children:[e.jsx(Za,{size:14})," Events"]}),e.jsx("span",{className:"tl-canvas-mode",children:n==="live"?"● Live":"⏸ Paused"}),e.jsxs("span",{className:"tl-canvas-range",children:[new Date(Y).toLocaleTimeString("en-GB",{hour12:!1})," →"," ",new Date(E).toLocaleTimeString("en-GB",{hour12:!1})]})]}),e.jsxs("div",{className:"tl-canvas-legend",children:[e.jsxs("span",{className:"tl-legend-item",children:[e.jsx("span",{className:"tl-legend-dot",style:{background:"var(--success)"}})," active"]}),e.jsxs("span",{className:"tl-legend-item",children:[e.jsx("span",{className:"tl-legend-dot tl-legend-dot-dashed",style:{borderColor:"var(--info)"}})," queued"]}),e.jsxs("span",{className:"tl-legend-item",children:[e.jsx("span",{className:"tl-legend-dot",style:{background:"var(--warning)"}})," blocked"]}),e.jsxs("span",{className:"tl-legend-item",children:[e.jsx("span",{className:"tl-legend-dot",style:{background:"var(--error)"}})," error"]}),e.jsx("span",{className:"tl-legend-sep"}),e.jsxs("span",{className:"tl-legend-item",children:[e.jsx(Mt,{size:11})," agent"]}),e.jsxs("span",{className:"tl-legend-item",children:[e.jsx(on,{size:11})," task"]}),e.jsxs("span",{className:"tl-legend-item",children:[e.jsx(Ts,{size:11})," bg"]})]})]}),e.jsx("div",{className:"tl-canvas-scroll",children:e.jsxs("svg",{className:"tl-canvas",width:B.width,height:Math.max(B.height,Cs),role:"application","aria-label":"Activity timeline",children:[e.jsx("defs",{children:e.jsx("pattern",{id:"tl-canvas-grid",width:B.width,height:we,patternUnits:"userSpaceOnUse",children:e.jsx("path",{d:`M 0 0 L 0 ${we}`,fill:"none",stroke:"var(--border)",strokeWidth:.5,opacity:.35})})}),e.jsx("rect",{width:"100%",height:"100%",fill:"url(#tl-canvas-grid)"}),Wt.map(N=>e.jsx("rect",{className:"tl-lane-bg",x:0,y:N.y,width:B.width,height:N.h,fill:N.id.charCodeAt(N.id.length-1)%2===0?"var(--bg-elev-2)":"var(--bg-elev)",opacity:.4},`bg-${N.id}`)),e.jsx("g",{className:"tl-time-axis",children:ms.map(N=>e.jsxs("g",{children:[e.jsx("line",{x1:N.x,y1:0,x2:N.x,y2:Cs,stroke:"var(--border)",strokeWidth:.5,strokeDasharray:"2,4",opacity:.5}),e.jsx("text",{x:N.x+4,y:Re-8,fontSize:10,fontFamily:"var(--font-mono)",fill:"var(--text-dim)",children:N.label})]},`tick-${N.t}`))}),ie.map(N=>{const G=Re+Ye+N.index*we+we/2;return e.jsxs("g",{className:"tl-lane-label-group",children:[e.jsx("text",{x:6,y:G-2,className:"tl-lane-label",textAnchor:"start",children:ps(N.label,28)}),e.jsx("text",{x:6,y:G+10,className:"tl-lane-label-sub",textAnchor:"start",children:N.sub})]},`label-${N.id}`)}),_t.map(N=>{const G=Rs(N.statusClass),ue=N.id===(R==null?void 0:R.id);return e.jsxs("g",{className:ae("tl-task-bar",`tl-task-bar-${N.statusClass}`,ue&&"tl-task-bar-selected"),onClick:()=>Kt(N),children:[e.jsx("rect",{x:N.x,y:N.y,width:N.w,height:N.h,rx:6,fill:G,fillOpacity:N.statusClass==="done"?.35:N.statusClass==="queued"?.18:.85,stroke:G,strokeWidth:ue?2.5:1.5,strokeOpacity:N.statusClass==="done"?.5:1,strokeDasharray:N.statusClass==="queued"?"4 4":void 0,style:{cursor:"pointer"}}),N.w>36&&e.jsx("text",{x:N.x+8,y:N.y+N.h/2+4,fontSize:11,fontFamily:"var(--font-sans)",fontWeight:500,fill:"var(--text-strong)",style:{pointerEvents:"none"},opacity:N.statusClass==="done"?.7:1,children:ps(N.label,Math.max(4,Math.floor(N.w/7)))})]},`bar-${N.id}`)}),Vt.map(N=>{const G=Rs(N.kind);return e.jsxs("g",{className:"tl-event-marker-group",children:[e.jsx("line",{x1:N.x,y1:N.y-6,x2:N.x,y2:N.y+6,stroke:G,strokeWidth:1.2,opacity:.7}),e.jsx("circle",{cx:N.x,cy:N.y,r:4,fill:G,opacity:.9,children:e.jsx("title",{children:`${N.kind}${N.author?` · ${N.author}`:""} · ${new Date(N.ts).toLocaleTimeString("en-GB",{hour12:!1})}`})})]},`ev-${N.id}`)}),e.jsx("line",{className:"tl-now-line",x1:hs,y1:0,x2:hs,y2:Cs,stroke:"var(--error)",strokeWidth:1.5,opacity:.9}),e.jsxs("g",{className:"tl-now-marker",children:[e.jsx("circle",{cx:hs,cy:Re-4,r:4,fill:"var(--error)"}),e.jsx("text",{x:hs+6,y:Re-4,fontSize:10,fontWeight:700,fill:"var(--error)",fontFamily:"var(--font-mono)",children:"now"})]})]})})]}),R&&e.jsx("aside",{className:"tl-detail tl-detail-enter",children:e.jsxs(te,{children:[e.jsxs(le,{children:[R.kind==="agent"&&e.jsx(Ee,{size:14}),R.kind==="task"&&e.jsx(Be,{size:14}),R.kind==="bg"&&e.jsx(Ts,{size:14}),R.label,e.jsx("button",{type:"button",className:"icon-btn",onClick:()=>J(null),title:"Close","aria-label":"Close activity detail",style:{marginLeft:"auto"},children:e.jsx($e,{size:14})})]}),e.jsxs("div",{className:"tl-detail-meta",children:[e.jsxs("div",{children:[e.jsx("span",{className:"muted",children:"type"})," ",R.kind]}),e.jsxs("div",{children:[e.jsx("span",{className:"muted",children:"status"})," ",e.jsx("code",{children:R.status})]}),R.kind==="agent"&&(()=>{const N=R.data;return e.jsxs(e.Fragment,{children:[N.role&&e.jsxs("div",{children:[e.jsx("span",{className:"muted",children:"role"})," ",N.role]}),N.model&&e.jsxs("div",{children:[e.jsx("span",{className:"muted",children:"model"})," ",N.model]})]})})(),R.kind==="task"&&(()=>{const N=R.data;return e.jsxs(e.Fragment,{children:[N.assignee&&e.jsxs("div",{children:[e.jsx("span",{className:"muted",children:"assignee"})," @",N.assignee]}),N.priority&&e.jsxs("div",{children:[e.jsx("span",{className:"muted",children:"priority"})," ",N.priority]}),N.createdAt&&e.jsxs("div",{children:[e.jsx("span",{className:"muted",children:"created"})," ",new Date(N.createdAt).toLocaleString()]})]})})(),R.kind==="bg"&&(()=>{const N=R.data;return e.jsxs(e.Fragment,{children:[N.startedAt&&e.jsxs("div",{children:[e.jsx("span",{className:"muted",children:"started"})," ",new Date(N.startedAt).toLocaleString()]}),N.tmuxSession&&e.jsxs("div",{children:[e.jsx("span",{className:"muted",children:"tmux"})," ",e.jsx("code",{children:N.tmuxSession})," ",N.tmuxActive?e.jsx("span",{className:"tag tag-success",children:"active"}):e.jsx("span",{className:"tag",children:"inactive"})]})]})})()]}),R.kind==="task"&&R.data.description&&e.jsx("div",{className:"tl-detail-desc",children:R.data.description}),R.kind==="bg"&&R.data.promptPreview&&e.jsx("div",{className:"tl-detail-desc",children:R.data.promptPreview}),R.kind==="bg"&&e.jsxs("div",{className:"tl-detail-bg",children:[e.jsx("pre",{className:"tl-bg-output",children:se||"(no output — start the session via tmux attach)"}),e.jsxs("div",{className:"tl-bg-output-actions",children:[e.jsxs(z,{variant:"ghost",size:"sm",onClick:Jt,children:[e.jsx(de,{size:12})," Refresh output"]}),ee.length>0&&e.jsxs(z,{variant:"secondary",size:"sm",onClick:()=>Ft(M,ee[0]),children:[e.jsx(ws,{size:12})," Open artifact"]}),e.jsxs(z,{variant:"danger",size:"sm",onClick:Yt,children:[e.jsx(ye,{size:12})," Kill session"]})]}),e.jsxs("div",{className:"tl-form-row",children:[e.jsx("input",{className:"input",placeholder:"Send a message to this bg session…",value:X,onChange:N=>ne(N.target.value),onKeyDown:N=>{N.key==="Enter"&&tt()}}),e.jsxs(z,{variant:"primary",size:"sm",disabled:!X.trim(),onClick:tt,children:[e.jsx(Qe,{size:12})," Send"]})]})]}),R.kind!=="bg"&&e.jsxs("div",{className:"tl-detail-create",children:[e.jsx("div",{className:"field-label",children:"Create follow-up task"}),e.jsx("input",{className:"input",placeholder:"Task title",value:w,onChange:N=>I(N.target.value)}),e.jsxs("div",{className:"tl-form-row",children:[e.jsxs("select",{className:"select",value:_,onChange:N=>W(N.target.value),children:[e.jsx("option",{value:"low",children:"Low"}),e.jsx("option",{value:"normal",children:"Normal"}),e.jsx("option",{value:"high",children:"High"})]}),e.jsxs(z,{variant:"primary",size:"sm",disabled:!w.trim()||O,onClick:Gt,children:[e.jsx(pe,{size:12})," Add task"]})]})]}),e.jsxs("div",{className:"tl-detail-comments",children:[e.jsxs("div",{className:"field-label",children:[e.jsx(Ve,{size:12})," Comments & activity"]}),e.jsxs("ul",{className:"comment-list",children:[V.length===0&&e.jsx("li",{className:"muted",children:"No comments yet."}),V.map((N,G)=>e.jsxs("li",{className:"comment-item",children:[e.jsxs("div",{className:"comment-head",children:[e.jsx("strong",{children:N.author||"system"}),e.jsxs("span",{className:"muted",children:[N.kind," · ",new Date(N.ts).toLocaleString()]})]}),N.text&&e.jsx("div",{className:"comment-text",children:N.text}),N.taskId&&e.jsxs("div",{className:"muted",children:["→ task ",e.jsx("code",{children:String(N.taskId)})]})]},`c-${G}`))]}),e.jsxs("div",{className:"comment-input-row",children:[e.jsx("input",{className:"input",placeholder:"Add a comment…",value:D,onChange:N=>L(N.target.value),onKeyDown:N=>{N.key==="Enter"&&!N.shiftKey&&st()}}),e.jsxs(z,{variant:"secondary",size:"sm",disabled:!D.trim()||F,onClick:st,children:[e.jsx(Qe,{size:12})," Post"]})]})]})]})},R.id)]})})]})}const ol=[{id:"opencode",label:"OpenCode config",icon:Xs,desc:"Edit opencode.json directly"},{id:"providers",label:"Providers",icon:Fe,desc:"AI providers + API keys"},{id:"mcps",label:"MCPs",icon:cs,desc:"Model Context Protocol servers"},{id:"diagnostics",label:"Diagnostics",icon:Dt,desc:"Service health + counts"},{id:"memory",label:"Memory & LightRAG",icon:Js,desc:"Configure Bizar Memory Service and the LightRAG embedding server."},{id:"export",label:"Export / Import",icon:Le,desc:"Download diagnostics bundle"}];function cl({snapshot:s,refreshSnapshot:t}){const a=ce();ke();const i=s.config,[n,c]=r.useState("opencode"),[d,l]=r.useState((i==null?void 0:i.raw)||(i!=null&&i.data?JSON.stringify(i.data,null,2):"")),[x,u]=r.useState({raw:(i==null?void 0:i.raw)||"",data:(i==null?void 0:i.data)??null,error:null}),[j,m]=r.useState(!1),[o,p]=r.useState(!1),[k,f]=r.useState((i==null?void 0:i.path)||""),S=r.useRef(null),[b,v]=r.useState(null),[y,$]=r.useState(null),[g,B]=r.useState([]),[H,R]=r.useState(s.providers||[]),[J,D]=r.useState(s.mcps||[]),L=r.useMemo(()=>at(d),[d]);r.useEffect(()=>{s.providers&&R(s.providers),s.mcps&&D(s.mcps)},[s.providers,s.mcps]);const V=async()=>{try{const O=await A.post("/config/reload"),Q=O.raw||(O.data?JSON.stringify(O.data,null,2):"");l(Q),u({raw:Q,data:O.data??null,error:null}),m(!1),f(O.path||""),a.info("Config reloaded.",1500)}catch(O){a.error(`Reload failed: ${O.message}`)}},K=async()=>{try{const O=await A.get("/config/providers");R(O.providers||[])}catch(O){a.error(`Providers load failed: ${O.message}`)}},w=async()=>{try{const O=await A.get("/config/mcps");D(O.mcps||[])}catch(O){a.error(`MCPs load failed: ${O.message}`)}};r.useEffect(()=>{n==="providers"&&H.length===0&&K(),n==="mcps"&&J.length===0&&w(),n==="diagnostics"&&!b&&X(),n==="memory"&&ne()},[n]);const I=O=>{u(Q=>{const F={raw:O,data:Q.data,error:null};try{F.data=JSON.parse(O),F.error=null}catch(q){F.data=null,F.error=q.message}return F}),_(O)},_=r.useMemo(()=>xa(O=>{m(at(O)!==L)},100),[L]),W=async()=>{if(!(!x.data||x.error||o)){p(!0);try{const O=await A.put("/config",x.data),Q=O.raw||JSON.stringify(O.data,null,2);l(Q),u({raw:Q,data:O.data??null,error:null}),m(!1),a.success("Config saved."),await t(),await K(),await w()}catch(O){a.error(`Save failed: ${O.message}`)}finally{p(!1)}}},X=async()=>{try{const O=await A.get("/diagnostics");v(O)}catch(O){a.error(`Diagnostics load failed: ${O.message}`)}},ne=async()=>{try{const O=await A.get("/memory/lightrag/status");$(O)}catch(O){a.error(`LightRAG status failed: ${O.message}`)}},se=async()=>{try{const O=await A.get("/memory/lightrag/log");B(O.lines||[])}catch{B([])}},U=()=>{const O={generatedAt:new Date().toISOString(),diagnostics:b,config:x.data,opencodeJsonPath:k,providers:H,mcps:J},Q=new Blob([JSON.stringify(O,null,2)],{type:"application/json"}),F=URL.createObjectURL(Q),q=document.createElement("a");q.href=F,q.download=`bizar-diagnostics-${new Date().toISOString().replace(/[:.]/g,"-")}.json`,q.click(),URL.revokeObjectURL(F),a.success("Bundle downloaded.")};return e.jsxs("div",{className:"view view-config",children:[e.jsx("header",{className:"view-header",children:e.jsxs("div",{className:"view-header-text",children:[e.jsxs("h2",{className:"view-title",children:[e.jsx(It,{size:18})," Config"]}),e.jsx("p",{className:"view-subtitle",children:"Manage OpenCode config, providers, MCPs, and diagnostics."})]})}),e.jsxs("div",{className:"config-layout",children:[e.jsx("nav",{className:"config-nav",role:"navigation","aria-label":"Config sections",children:ol.map(O=>{const Q=O.icon;return e.jsxs("button",{type:"button",className:ae("config-nav-item",n===O.id&&"config-nav-item-active"),onClick:()=>c(O.id),"aria-current":n===O.id?"page":void 0,children:[e.jsx(Q,{size:14}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",minWidth:0,flex:1},children:[e.jsx("span",{children:O.label}),e.jsx("span",{style:{fontSize:10,color:"var(--text-dim)",fontWeight:400},children:O.desc})]})]},O.id)})}),e.jsxs("div",{className:"config-content",children:[n==="opencode"&&e.jsx(ml,{parsed:x,dirty:j,saving:o,path:k,onReload:V,onSave:W,onChange:I,textareaRef:S}),n==="providers"&&e.jsx(fl,{providers:H,onChange:R,onReload:K}),n==="mcps"&&e.jsx(kl,{mcps:J,onChange:D,onReload:w}),n==="diagnostics"&&e.jsx(jl,{diagnostics:b,loading:!b,onReload:X}),n==="memory"&&e.jsx(Cl,{status:y,onReload:ne,logLines:g,onReloadLog:se}),n==="export"&&e.jsx(Nl,{onDownload:U})]})]})]})}const dl=[{id:"model",label:"Model"},{id:"plugins",label:"Plugins"},{id:"tools",label:"Tools"},{id:"permissions",label:"Permissions"},{id:"hooks",label:"Hooks"},{id:"advanced",label:"Advanced"}];function ml({parsed:s,dirty:t,saving:a,path:i,onReload:n,onSave:c,onChange:d,textareaRef:l}){const[x,u]=r.useState("model"),j=s.data,m=o=>{if(!j)return;const p={...j,...o};d(JSON.stringify(p,null,2))};return e.jsxs(te,{children:[e.jsxs(le,{children:[e.jsx(Xs,{size:14})," OpenCode config"]}),e.jsx(oe,{children:e.jsx("code",{className:"mono ellipsis",style:{fontSize:11},children:i||"~/.config/opencode/opencode.json"})}),e.jsxs("div",{className:"view-actions",style:{marginBottom:12},children:[e.jsxs(z,{variant:"secondary",size:"sm",onClick:n,children:[e.jsx(de,{size:14})," Reload"]}),e.jsxs(z,{variant:"primary",size:"sm",disabled:!s.data||!!s.error||!t,onClick:c,children:[a?e.jsx("span",{className:"btn-spinner"}):e.jsx(Ze,{size:14}),"Save"]})]}),e.jsx("div",{className:"config-section-tabs",style:{display:"flex",gap:4,marginBottom:16,flexWrap:"wrap"},children:dl.map(o=>e.jsx("button",{type:"button",className:ae("tab-btn",x===o.id&&"active"),onClick:()=>u(o.id),children:o.label},o.id))}),x==="model"&&e.jsx(hl,{cfg:j,apply:m}),x==="plugins"&&e.jsx(ul,{cfg:j,apply:m}),x==="tools"&&e.jsx(pl,{cfg:j,apply:m}),x==="permissions"&&e.jsx(xl,{cfg:j,apply:m}),x==="hooks"&&e.jsx(gl,{cfg:j,apply:m}),x==="advanced"&&e.jsxs("div",{children:[e.jsx("div",{className:"config-grid-label",style:{marginBottom:8},children:s.error?e.jsx("span",{className:"text-error",children:s.error}):e.jsx("span",{className:"muted",children:"Raw JSON — edit with care"})}),e.jsx("textarea",{ref:l,className:ae("textarea config-textarea",s.error&&"invalid"),spellCheck:!1,value:s.raw,onChange:o=>d(o.target.value),style:{minHeight:300}})]})]})}function hl({cfg:s,apply:t}){const a=(s==null?void 0:s.model)||{};return e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:12},children:[e.jsx("p",{className:"muted text-sm",children:"Configure the default model used by OpenCode agents."}),e.jsxs("div",{className:"field-row",children:[e.jsx("label",{className:"field-label",children:"Provider"}),e.jsx("input",{className:"input",value:String(a.provider||""),onChange:i=>t({model:{...a,provider:i.target.value}}),placeholder:"e.g. openai, anthropic, google"})]}),e.jsxs("div",{className:"field-row",children:[e.jsx("label",{className:"field-label",children:"Model ID"}),e.jsx("input",{className:"input",value:String(a.model||""),onChange:i=>t({model:{...a,model:i.target.value}}),placeholder:"e.g. gpt-4o, claude-sonnet-4-20250514"})]}),!!a.apiKey&&e.jsxs("div",{className:"field-row",children:[e.jsx("label",{className:"field-label",children:"API Key"}),e.jsx("input",{className:"input",type:"password",value:String(a.apiKey||""),onChange:i=>t({model:{...a,apiKey:i.target.value}}),placeholder:"sk-..."})]}),!!a.baseURL&&e.jsxs("div",{className:"field-row",children:[e.jsx("label",{className:"field-label",children:"Base URL"}),e.jsx("input",{className:"input",value:String(a.baseURL||""),onChange:i=>t({model:{...a,baseURL:i.target.value}}),placeholder:"https://api.openai.com/v1"})]})]})}function ul({cfg:s,apply:t}){const a=Array.isArray(s==null?void 0:s.plugins)?s.plugins:[],[i,n]=r.useState(null),[c,d]=r.useState({}),l=()=>{const j=[...a,{name:"",enabled:!0}];t({plugins:j})},x=j=>{const m=a.filter((o,p)=>p!==j);t({plugins:m})},u=(j,m)=>{const o=a.map((p,k)=>k===j?{...p,...m}:p);t({plugins:o}),n(null)};return e.jsxs("div",{children:[e.jsx("p",{className:"muted text-sm",style:{marginBottom:12},children:"Manage enabled plugins."}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[a.length===0&&e.jsx("p",{className:"muted text-sm",children:"No plugins configured."}),a.map((j,m)=>e.jsx("div",{className:"config-list-row",children:i===m?e.jsxs("div",{style:{display:"flex",gap:8,flex:1,alignItems:"center"},children:[e.jsx("input",{className:"input",value:String(c.name||""),onChange:o=>d({...c,name:o.target.value}),placeholder:"plugin-name"}),e.jsxs("label",{style:{display:"flex",gap:4,fontSize:12},children:[e.jsx("input",{type:"checkbox",checked:!!c.enabled,onChange:o=>d({...c,enabled:o.target.checked})}),"enabled"]}),e.jsx(z,{variant:"primary",size:"sm",onClick:()=>u(m,c),children:"Apply"}),e.jsx(z,{variant:"ghost",size:"sm",onClick:()=>n(null),children:e.jsx($e,{size:12})})]}):e.jsxs(e.Fragment,{children:[e.jsx("span",{style:{fontFamily:"var(--font-mono)",fontSize:13},children:j.name||"unnamed"}),e.jsx("span",{className:ae("tag",j.enabled!==!1?"tag-success":"tag-neutral"),children:j.enabled!==!1?"enabled":"disabled"}),e.jsxs("div",{style:{marginLeft:"auto",display:"flex",gap:4},children:[e.jsx("button",{type:"button",className:"icon-btn",onClick:()=>{n(m),d(j)},title:"Edit",children:e.jsx(ds,{size:12})}),e.jsx("button",{type:"button",className:"icon-btn text-error",onClick:()=>x(m),title:"Remove",children:e.jsx(ye,{size:12})})]})]})},m))]}),e.jsxs(z,{variant:"secondary",size:"sm",onClick:l,style:{marginTop:8},children:[e.jsx(pe,{size:12})," Add plugin"]})]})}function pl({cfg:s,apply:t}){const a=(s==null?void 0:s.tools)||{},i=d=>{t({tools:{...a,[d]:!a[d]}})},n=d=>{!d||a[d]!==void 0||t({tools:{...a,[d]:!0}})},c=d=>{const l={...a};delete l[d],t({tools:l})};return e.jsxs("div",{children:[e.jsx("p",{className:"muted text-sm",style:{marginBottom:12},children:"Enable or disable built-in tools."}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[Object.keys(a).length===0&&e.jsx("p",{className:"muted text-sm",children:"No tools configured."}),Object.entries(a).map(([d,l])=>e.jsxs("div",{className:"config-list-row",children:[e.jsx("span",{style:{fontFamily:"var(--font-mono)",fontSize:13},children:d}),e.jsxs("label",{style:{display:"flex",gap:4,alignItems:"center",fontSize:12},children:[e.jsx("input",{type:"checkbox",checked:!!l,onChange:()=>i(d)}),"enabled"]}),e.jsx("button",{type:"button",className:"icon-btn text-error",style:{marginLeft:"auto"},onClick:()=>c(d),title:"Remove",children:e.jsx(ye,{size:12})})]},d))]}),e.jsxs("div",{style:{display:"flex",gap:8,marginTop:8},children:[e.jsx("input",{className:"input",placeholder:"tool-name",onKeyDown:d=>{d.key==="Enter"&&n(d.target.value.trim())}}),e.jsxs(z,{variant:"secondary",size:"sm",onClick:d=>{var l,x;return n(((x=(l=d.currentTarget.closest("div"))==null?void 0:l.querySelector("input"))==null?void 0:x.value.trim())||"")},children:[e.jsx(pe,{size:12})," Add"]})]})]})}function xl({cfg:s,apply:t}){const a=(s==null?void 0:s.permissions)||{},[i,n]=r.useState("allow"),c=Array.isArray(a.allow)?a.allow:[],d=Array.isArray(a.deny)?a.deny:[],l=(j,m)=>o=>{o&&t({permissions:{...a,[m]:[...j,o]}})},x=(j,m,o)=>{t({permissions:{...a,[j]:m.filter((p,k)=>k!==o)}})},u=i==="allow"?c:d;return e.jsxs("div",{children:[e.jsx("p",{className:"muted text-sm",style:{marginBottom:12},children:"Allow or deny tool/scope rules."}),e.jsxs("div",{style:{display:"flex",gap:4,marginBottom:12},children:[e.jsxs("button",{type:"button",className:ae("tab-btn",i==="allow"&&"active"),onClick:()=>n("allow"),children:["Allow (",c.length,")"]}),e.jsxs("button",{type:"button",className:ae("tab-btn",i==="deny"&&"active"),onClick:()=>n("deny"),children:["Deny (",d.length,")"]})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[u.length===0&&e.jsxs("p",{className:"muted text-sm",children:["No ",i," rules."]}),u.map((j,m)=>e.jsxs("div",{className:"config-list-row",children:[e.jsx("span",{style:{fontFamily:"var(--font-mono)",fontSize:13},children:j}),e.jsx("button",{type:"button",className:"icon-btn text-error",style:{marginLeft:"auto"},onClick:()=>x(i,u,m),children:e.jsx(ye,{size:12})})]},m))]}),e.jsxs("div",{style:{display:"flex",gap:8,marginTop:8},children:[e.jsx("input",{className:"input",placeholder:`${i} rule (e.g. tool:read, scope:filesystem)`,onKeyDown:j=>{if(j.key==="Enter"){const m=j.target.value.trim();m&&(l(u,i)(m),j.target.value="")}}}),e.jsxs(z,{variant:"secondary",size:"sm",onClick:j=>{var p;const m=(p=j.currentTarget.closest("div"))==null?void 0:p.querySelector("input"),o=m==null?void 0:m.value.trim();o&&(l(u,i)(o),m.value="")},children:[e.jsx(pe,{size:12})," Add"]})]})]})}function gl({cfg:s,apply:t}){const a=(s==null?void 0:s.hooks)||{},i=(n,c)=>{t({hooks:{...a,[n]:c}})};return e.jsxs("div",{children:[e.jsx("p",{className:"muted text-sm",style:{marginBottom:12},children:"Configure pre/post tool hooks."}),Object.keys(a).length===0&&e.jsx("p",{className:"muted text-sm",children:"No hooks configured."}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:12},children:["preTool","postTool","preAgent","postAgent"].map(n=>{const c=a[n];return e.jsxs("div",{className:"field-row",style:{alignItems:"flex-start"},children:[e.jsx("label",{className:"field-label",style:{minWidth:100},children:n}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:6,flex:1},children:e.jsx("input",{className:"input",value:typeof c=="object"&&c!==null&&"command"in c?String(c.command||""):"",onChange:d=>i(n,{command:d.target.value}),placeholder:`${n} command (e.g. node /path/to/hook.js)`})})]},n)})})]})}function jl({diagnostics:s,loading:t,onReload:a}){return e.jsxs(te,{children:[e.jsxs(le,{children:[e.jsx(Dt,{size:14})," Diagnostics"]}),e.jsxs(oe,{children:["System health, file counts, recent errors."," ",e.jsx("button",{type:"button",className:"link-btn",onClick:a,children:"Refresh"})]}),t&&e.jsx("p",{className:"muted",children:"Loading diagnostics…"}),s&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"diagnostics-grid",children:[e.jsxs("div",{className:"diagnostic-tile",children:[e.jsx("div",{className:"diagnostic-tile-label",children:"Version"}),e.jsx("div",{className:"diagnostic-tile-value mono",children:s.version})]}),e.jsxs("div",{className:"diagnostic-tile",children:[e.jsx("div",{className:"diagnostic-tile-label",children:"Uptime"}),e.jsxs("div",{className:"diagnostic-tile-value mono",children:[s.uptime,"s"]})]}),e.jsxs("div",{className:"diagnostic-tile",children:[e.jsx("div",{className:"diagnostic-tile-label",children:"Node"}),e.jsx("div",{className:"diagnostic-tile-value mono",children:s.nodeVersion})]}),e.jsxs("div",{className:"diagnostic-tile",children:[e.jsx("div",{className:"diagnostic-tile-label",children:"Platform"}),e.jsx("div",{className:"diagnostic-tile-value mono",children:s.platform})]}),e.jsxs("div",{className:"diagnostic-tile",children:[e.jsx("div",{className:"diagnostic-tile-label",children:"Memory (heap)"}),e.jsxs("div",{className:"diagnostic-tile-value mono",children:[Math.round(s.memory.heapUsed/1024/1024),"MB"]})]}),e.jsxs("div",{className:"diagnostic-tile",children:[e.jsx("div",{className:"diagnostic-tile-label",children:"Memory (RSS)"}),e.jsxs("div",{className:"diagnostic-tile-value mono",children:[Math.round(s.memory.rss/1024/1024),"MB"]})]}),e.jsxs("div",{className:"diagnostic-tile",children:[e.jsx("div",{className:"diagnostic-tile-label",children:"Service"}),e.jsx("div",{className:"diagnostic-tile-value",children:s.service.running?e.jsxs("span",{className:"tag tag-success",children:["running (pid ",s.service.pid,")"]}):e.jsx("span",{className:"tag tag-neutral",children:"stopped"})})]}),e.jsxs("div",{className:"diagnostic-tile",children:[e.jsx("div",{className:"diagnostic-tile-label",children:"Active project"}),e.jsx("div",{className:"diagnostic-tile-value mono",children:s.counts.activeProject||"—"})]})]}),e.jsxs("div",{className:"diagnostic-counts",children:[e.jsxs("span",{children:["agents: ",e.jsx("strong",{children:s.counts.agents})]}),e.jsxs("span",{children:["projects: ",e.jsx("strong",{children:s.counts.projects})]}),e.jsxs("span",{children:["mods: ",e.jsx("strong",{children:s.counts.mods})]}),e.jsxs("span",{children:["schedules: ",e.jsx("strong",{children:s.counts.schedules})]}),e.jsxs("span",{children:["tasks: ",e.jsx("strong",{children:s.counts.tasks})]}),e.jsxs("span",{children:["providers: ",e.jsx("strong",{children:s.counts.providers})]}),e.jsxs("span",{children:["mcps: ",e.jsx("strong",{children:s.counts.mcps})]})]}),e.jsxs("div",{className:"diagnostic-errors",children:[e.jsxs("div",{className:"muted",children:["Last ",s.errors.length," errors from service.log"]}),s.errors.length===0?e.jsx("p",{className:"muted",children:"No errors recorded."}):e.jsx("ul",{children:s.errors.map((i,n)=>e.jsxs("li",{className:"mono",children:[i.ts&&e.jsxs("span",{className:"muted",children:["[",i.ts,"] "]}),i.line]},n))})]})]})]})}function fl({providers:s,onChange:t,onReload:a}){const i=ce(),n=ke(),c=l=>{let x=null,u=null,j=null,m=null,o=null,p=null;const k=!!l,f=(l==null?void 0:l.id)||"",S=(l==null?void 0:l.name)||"",b=(l==null?void 0:l.baseURL)||"",v=(l==null?void 0:l.apiKey)||"",y=((l==null?void 0:l.models)||[]).join(", "),$=(l==null?void 0:l.enabled)!==!1;n.open({title:k?`Edit provider "${l.id}"`:"Add provider",children:e.jsxs("div",{children:[e.jsxs("div",{className:"modal-form-row",children:[e.jsx("label",{children:"ID (a-z, 0-9, dashes)"}),e.jsx("input",{ref:g=>x=g,className:"input",type:"text",defaultValue:f,placeholder:"anthropic",disabled:k})]}),e.jsxs("div",{className:"modal-form-row",children:[e.jsx("label",{children:"Display name"}),e.jsx("input",{ref:g=>u=g,className:"input",type:"text",defaultValue:S,placeholder:"Anthropic"})]}),e.jsxs("div",{className:"modal-form-row",children:[e.jsx("label",{children:"Base URL"}),e.jsx("input",{ref:g=>j=g,className:"input",type:"text",defaultValue:b,placeholder:"https://api.anthropic.com"})]}),e.jsxs("div",{className:"modal-form-row",children:[e.jsxs("label",{children:["API key",k&&" (leave masked value unchanged to keep)"]}),e.jsx("input",{ref:g=>m=g,className:"input",type:"password",defaultValue:v,placeholder:"sk-...",autoComplete:"off"})]}),e.jsxs("div",{className:"modal-form-row",children:[e.jsx("label",{children:"Models (comma-separated)"}),e.jsx("textarea",{ref:g=>o=g,className:"textarea",defaultValue:y,placeholder:"claude-sonnet-4-5, claude-opus-4-1",rows:3})]}),e.jsx("div",{className:"modal-form-row",children:e.jsxs("label",{className:"checkbox-row",children:[e.jsx("input",{ref:g=>p=g,type:"checkbox",defaultChecked:$}),"Enabled"]})})]}),footer:e.jsxs("div",{className:"modal-footer-actions",children:[e.jsx(z,{variant:"ghost",onClick:()=>n.close(),children:"Cancel"}),e.jsxs(z,{variant:"primary",onClick:async()=>{const g=((x==null?void 0:x.value)||"").trim(),B=((u==null?void 0:u.value)||"").trim(),H=((j==null?void 0:j.value)||"").trim(),R=(m==null?void 0:m.value)||"",D=((o==null?void 0:o.value)||"").split(/[,\n]/).map(V=>V.trim()).filter(Boolean),L=!!(p!=null&&p.checked);if(!g){i.warning("ID is required.");return}if(!/^[a-z0-9][a-z0-9_-]{0,63}$/i.test(g)){i.warning("ID must be a-z, 0-9, dashes.");return}try{const V={id:g,name:B||g,baseURL:H,apiKey:R,models:D,enabled:L};if(k){const K=await A.put(`/config/providers/${encodeURIComponent(g)}`,V);t(s.map(w=>w.id===g?K:w)),i.success(`Provider "${g}" updated.`)}else{const K=await A.post("/config/providers",V);t([...s,K]),i.success(`Provider "${g}" added.`)}n.close()}catch(V){i.error(`Save failed: ${V.message}`)}},children:[k?"Update":"Add"," provider"]})]})})},d=async l=>{if(confirm(`Remove provider "${l}"?`))try{await A.del(`/config/providers/${encodeURIComponent(l)}`),t(s.filter(x=>x.id!==l)),i.success("Provider removed.")}catch(x){i.error(`Remove failed: ${x.message}`)}};return e.jsxs(te,{children:[e.jsxs(le,{children:[e.jsx(Fe,{size:14})," Providers (",s.length,")"]}),e.jsxs(oe,{children:["AI providers configured under ",e.jsx("code",{children:"opencode.json#provider"}),". Each provider has a base URL, API key, and a list of model IDs."]}),e.jsx(zl,{onAdd:(l,x,u,j)=>{c({id:l,name:x,baseURL:u,apiKey:j})}}),e.jsxs("div",{className:"view-actions",style:{marginBottom:12},children:[e.jsxs(z,{variant:"primary",size:"sm",onClick:()=>c(),children:[e.jsx(pe,{size:14})," Add provider"]}),e.jsxs(z,{variant:"ghost",size:"sm",onClick:a,children:[e.jsx(de,{size:14})," Refresh"]})]}),s.length===0?e.jsx(vl,{onAdd:()=>c()}):e.jsx("div",{className:"provider-list",children:s.map(l=>e.jsxs(te,{className:"provider-row",children:[e.jsxs("div",{className:"provider-row-head",children:[e.jsxs("div",{style:{minWidth:0,flex:1},children:[e.jsx("div",{className:"provider-name",children:l.name||l.id}),e.jsx("div",{className:"provider-id",children:l.id})]}),e.jsxs("div",{className:"provider-actions",children:[e.jsxs("label",{className:"toggle-row",title:"Enabled",children:[e.jsx("input",{type:"checkbox",checked:l.enabled!==!1,onChange:async x=>{try{const u=await A.put(`/config/providers/${encodeURIComponent(l.id)}`,{enabled:x.target.checked});t(s.map(j=>j.id===l.id?u:j))}catch(u){i.error(`Toggle failed: ${u.message}`)}}}),l.enabled!==!1?"on":"off"]}),e.jsx("button",{type:"button",className:"icon-btn","aria-label":"Edit",title:"Edit",onClick:()=>c(l),children:e.jsx(ds,{size:12})}),e.jsx("button",{type:"button",className:"icon-btn icon-btn-danger","aria-label":"Remove",title:"Remove",onClick:()=>d(l.id),children:e.jsx(ye,{size:12})})]})]}),e.jsxs("div",{className:"provider-meta",children:[e.jsxs("div",{children:[e.jsx("span",{className:"muted",children:"Base URL:"})," ",e.jsx("code",{children:l.baseURL||"—"})]}),e.jsxs("div",{children:[e.jsx("span",{className:"muted",children:"API key:"})," ",e.jsx("code",{children:l.apiKey||"—"})]}),e.jsxs("div",{children:[e.jsx("span",{className:"muted",children:"Models:"})," ",(l.models||[]).join(", ")||"—"]})]})]},l.id))})]})}function vl({onAdd:s}){return e.jsxs("div",{style:{padding:"32px 16px",textAlign:"center",color:"var(--text-dim)",border:"1px dashed var(--border)",borderRadius:"var(--radius-md)",display:"flex",flexDirection:"column",gap:8,alignItems:"center"},children:[e.jsx(Fe,{size:28}),e.jsx("div",{children:"No providers configured."}),e.jsx("div",{style:{fontSize:12},children:"Add a provider to connect an AI model."}),e.jsxs(z,{variant:"primary",size:"sm",onClick:s,children:[e.jsx(pe,{size:14})," Add your first provider"]})]})}function yl(s){const t={};for(const a of s.split(/\r?\n/)){const i=a.trim();if(!i||i.startsWith("#"))continue;const n=i.indexOf("=");if(n<=0)continue;const c=i.slice(0,n).trim(),d=i.slice(n+1).trim();c&&(t[c]=d)}return t}function bl(s){const t={};for(const a of s.split(/\r?\n/)){const i=a.trim();if(!i||i.startsWith("#"))continue;const n=i.indexOf(":");if(n<=0)continue;const c=i.slice(0,n).trim(),d=i.slice(n+1).trim();c&&(t[c]=d)}return t}function kl({mcps:s,onChange:t,onReload:a}){const i=ce(),n=ke(),c=l=>{let x=null,u=null,j=null,m=null,o=null,p=null,k=null,f=null,S=null;const b=!!l;l==null||l.type;const v=(l==null?void 0:l.type)==="remote"?"remote":"local",y=(l==null?void 0:l.command)||"",$=((l==null?void 0:l.args)||[]).join(" "),g=l!=null&&l.env?Object.entries(l.env).map(([D,L])=>`${D}=${L}`).join(`
|
|
334
|
-
`):"",B=(l==null?void 0:l.url)||"",H=l!=null&&l.headers?Object.entries(l.headers).map(([D,L])=>`${D}: ${L}`).join(`
|
|
335
|
-
`):"",R=!!(l!=null&&l.oauth),J=(l==null?void 0:l.enabled)!==!1;n.open({title:b?`Edit MCP "${l.id}"`:"Add MCP",children:e.jsxs("div",{children:[e.jsxs("div",{className:"modal-form-row",children:[e.jsx("label",{children:"ID (a-z, 0-9, dashes)"}),e.jsx("input",{ref:D=>x=D,className:"input",type:"text",defaultValue:(l==null?void 0:l.id)||"",placeholder:"supabase",disabled:b})]}),e.jsxs("div",{className:"modal-form-row",children:[e.jsx("label",{children:"Type"}),e.jsxs("div",{style:{display:"flex",gap:12},children:[e.jsxs("label",{className:"radio-label",children:[e.jsx("input",{ref:D=>D,type:"radio",name:"mcp-type",value:"local",defaultChecked:v==="local"}),"Local (stdio)"]}),e.jsxs("label",{className:"radio-label",children:[e.jsx("input",{ref:D=>u=D,type:"radio",name:"mcp-type",value:"remote",defaultChecked:v==="remote"}),"Remote (HTTP)"]})]})]}),e.jsxs("div",{"data-mcp-section":"local",children:[e.jsxs("div",{className:"modal-form-row",children:[e.jsx("label",{children:"Command (binary to invoke)"}),e.jsx("input",{ref:D=>j=D,className:"input",type:"text",defaultValue:y,placeholder:"uvx --from semble[mcp] semble"})]}),e.jsxs("div",{className:"modal-form-row",children:[e.jsx("label",{children:"Extra args (space-separated)"}),e.jsx("input",{ref:D=>m=D,className:"input",type:"text",defaultValue:$,placeholder:"--port 8080"}),e.jsx("div",{className:"field-help",children:"These are appended after the command."})]}),e.jsxs("div",{className:"modal-form-row",children:[e.jsx("label",{children:"Environment variables"}),e.jsx("textarea",{ref:D=>o=D,className:"textarea",defaultValue:g,placeholder:`API_KEY=xxx
|
|
336
|
-
DEBUG=true`,rows:3}),e.jsx("div",{className:"field-help",children:"One KEY=VALUE per line."})]})]}),e.jsxs("div",{"data-mcp-section":"remote",children:[e.jsxs("div",{className:"modal-form-row",children:[e.jsx("label",{children:"URL"}),e.jsx("input",{ref:D=>p=D,className:"input",type:"text",defaultValue:B,placeholder:"https://mcp.example.com/mcp"})]}),e.jsxs("div",{className:"modal-form-row",children:[e.jsx("label",{children:"Headers"}),e.jsx("textarea",{ref:D=>k=D,className:"textarea",defaultValue:H,placeholder:`Authorization: Bearer xxx
|
|
337
|
-
Content-Type: application/json`,rows:3}),e.jsx("div",{className:"field-help",children:'One "Key: Value" per line.'})]}),e.jsx("div",{className:"modal-form-row",children:e.jsxs("label",{className:"checkbox-row",children:[e.jsx("input",{ref:D=>f=D,type:"checkbox",defaultChecked:R}),"Use OAuth (browser-based auth flow)"]})})]}),e.jsx("div",{className:"modal-form-row",children:e.jsxs("label",{className:"checkbox-row",children:[e.jsx("input",{ref:D=>S=D,type:"checkbox",defaultChecked:J}),"Enabled"]})})]}),footer:e.jsxs("div",{className:"modal-footer-actions",children:[e.jsx(z,{variant:"ghost",onClick:()=>n.close(),children:"Cancel"}),e.jsxs(z,{variant:"primary",onClick:async()=>{const D=((x==null?void 0:x.value)||"").trim(),L=!!(u!=null&&u.checked),V=((j==null?void 0:j.value)||"").trim(),K=((m==null?void 0:m.value)||"").trim(),w=K?K.split(/\s+/):[],I=yl((o==null?void 0:o.value)||""),_=((p==null?void 0:p.value)||"").trim(),W=bl((k==null?void 0:k.value)||""),X=!!(f!=null&&f.checked),ne=!!(S!=null&&S.checked);if(!D){i.warning("ID is required.");return}if(!/^[a-z0-9][a-z0-9_-]{0,63}$/i.test(D)){i.warning("ID must be a-z, 0-9, dashes.");return}try{const se={id:D,type:L?"remote":"local",command:V,args:w,env:I,url:_,headers:W,oauth:X,enabled:ne};if(b){const U=await A.put(`/config/mcps/${encodeURIComponent(D)}`,se);t(s.map(O=>O.id===D?U:O)),i.success(`MCP "${D}" updated.`)}else{const U=await A.post("/config/mcps",se);t([...s,U]),i.success(`MCP "${D}" added.`)}n.close()}catch(se){i.error(`Save failed: ${se.message}`)}},children:[b?"Update":"Add"," MCP"]})]})})},d=async l=>{if(confirm(`Remove MCP "${l}"?`))try{await A.del(`/config/mcps/${encodeURIComponent(l)}`),t(s.filter(x=>x.id!==l)),i.success("MCP removed.")}catch(x){i.error(`Remove failed: ${x.message}`)}};return e.jsxs(te,{children:[e.jsxs(le,{children:[e.jsx(cs,{size:14})," MCPs (",s.length,")"]}),e.jsxs(oe,{children:["Model Context Protocol servers under ",e.jsx("code",{children:"opencode.json#mcp"}),". Local MCPs run as stdio subprocesses; remote MCPs are HTTP endpoints."]}),e.jsxs("div",{className:"view-actions",style:{marginBottom:12},children:[e.jsxs(z,{variant:"primary",size:"sm",onClick:()=>c(),children:[e.jsx(pe,{size:14})," Add MCP"]}),e.jsxs(z,{variant:"ghost",size:"sm",onClick:a,children:[e.jsx(de,{size:14})," Refresh"]})]}),s.length===0?e.jsxs("div",{style:{padding:"32px 16px",textAlign:"center",color:"var(--text-dim)",border:"1px dashed var(--border)",borderRadius:"var(--radius-md)",display:"flex",flexDirection:"column",gap:8,alignItems:"center"},children:[e.jsx(cs,{size:28}),e.jsx("div",{children:"No MCPs configured."}),e.jsxs(z,{variant:"primary",size:"sm",onClick:()=>c(),children:[e.jsx(pe,{size:14})," Add your first MCP"]})]}):e.jsx("div",{className:"mcp-list",children:s.map(l=>e.jsxs(te,{className:"mcp-row",children:[e.jsxs("div",{className:"mcp-row-head",children:[e.jsxs("div",{style:{minWidth:0,flex:1},children:[e.jsx("div",{className:"mcp-name",children:l.id}),e.jsxs("div",{className:"mcp-id",children:[l.type==="remote"?"remote":"local"," ",l.enabled!==!1?"· enabled":"· disabled"]})]}),e.jsxs("div",{className:"mcp-actions",children:[e.jsxs("label",{className:"toggle-row",title:"Enabled",children:[e.jsx("input",{type:"checkbox",checked:l.enabled!==!1,onChange:async x=>{try{const u=await A.put(`/config/mcps/${encodeURIComponent(l.id)}`,{enabled:x.target.checked});t(s.map(j=>j.id===l.id?u:j))}catch(u){i.error(`Toggle failed: ${u.message}`)}}}),l.enabled!==!1?"on":"off"]}),e.jsx("button",{type:"button",className:"icon-btn","aria-label":"Edit",title:"Edit",onClick:()=>c(l),children:e.jsx(ds,{size:12})}),e.jsx("button",{type:"button",className:"icon-btn icon-btn-danger","aria-label":"Remove",title:"Remove",onClick:()=>d(l.id),children:e.jsx(ye,{size:12})})]})]}),e.jsx("div",{className:"mcp-meta",children:l.type==="remote"?e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx("span",{className:"muted",children:"URL:"})," ",e.jsx("code",{children:l.url||"—"})]}),Object.keys(l.headers||{}).length>0&&e.jsxs("div",{children:[e.jsx("span",{className:"muted",children:"Headers:"})," ",e.jsxs("code",{children:[Object.keys(l.headers||{}).length," header(s)"]})]}),l.oauth&&e.jsxs("div",{children:[e.jsx("span",{className:"muted",children:"Auth:"})," ",e.jsx("code",{children:"OAuth"})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx("span",{className:"muted",children:"Command:"})," ",e.jsx("code",{children:l.command||"—"})]}),l.args&&l.args.length>0&&e.jsxs("div",{children:[e.jsx("span",{className:"muted",children:"Args:"})," ",e.jsx("code",{children:l.args.join(" ")})]}),l.env&&Object.keys(l.env).length>0&&e.jsxs("div",{children:[e.jsx("span",{className:"muted",children:"Env:"})," ",e.jsxs("code",{children:[Object.keys(l.env).length," var(s)"]})]})]})})]},l.id))})]})}function Nl({onDownload:s}){return e.jsxs(te,{children:[e.jsxs(le,{children:[e.jsx(Le,{size:14})," Export / Import"]}),e.jsx(oe,{children:"Download a JSON bundle of diagnostics, configuration, providers, and MCPs for support requests or backup. Server-side imports are not yet implemented."}),e.jsx("div",{className:"view-actions",style:{marginTop:12},children:e.jsxs(z,{variant:"primary",onClick:s,children:[e.jsx(Le,{size:14})," Download diagnostics bundle"]})}),e.jsxs("div",{style:{marginTop:16,fontSize:12,color:"var(--text-dim)"},children:[e.jsx(Js,{size:12,style:{display:"inline",verticalAlign:-2}})," Bundles include: opencode.json snapshot, providers list (with masked API keys), MCP list, recent service log errors, and active project metadata."]})]})}const wl=["ollama","openai","lollms","azure_openai","bedrock","gemini"],Sl=["ollama","openai","azure_openai","bedrock","jina","gemini","voyageai"];function Cl({status:s,onReload:t,logLines:a,onReloadLog:i}){const n=ce(),[c,d]=r.useState(!1),[l,x]=r.useState(!1),[u,j]=r.useState(!1),[m,o]=r.useState(!1),[p,k]=r.useState(!1),[f,S]=r.useState({enabled:!0,host:"127.0.0.1",port:9621,workingDir:"",llmBinding:"ollama",embeddingBinding:"ollama",llmBindingHost:"",embeddingBindingHost:"",llmModel:"minimax/MiniMax-M3",embeddingModel:"text-embedding-3-small",apiKeySource:"env",apiKey:""}),[b,v]=r.useState(!1);r.useEffect(()=>{s&&(S(D=>({...D,enabled:!0,host:s.host,port:s.port,llmBinding:s.llmBinding,embeddingBinding:s.embeddingBinding,llmBindingHost:s.llmBindingHost||"",embeddingBindingHost:s.embeddingBindingHost||"",llmModel:s.llmModel,embeddingModel:s.embeddingModel,apiKeySource:"env",apiKey:""})),v(!1))},[s==null?void 0:s.running]);const y=(D,L)=>{S(V=>({...V,[D]:L})),v(!0)},$=async()=>{if(!c){d(!0);try{const D={enabled:f.enabled,host:f.host,port:f.port===""?9621:Number(f.port),workingDir:f.workingDir,llmBinding:f.llmBinding,embeddingBinding:f.embeddingBinding,llmBindingHost:f.llmBindingHost||null,embeddingBindingHost:f.embeddingBindingHost||null,llmModel:f.llmModel,embeddingModel:f.embeddingModel,apiKeySource:f.apiKeySource};f.apiKeySource==="file"&&f.apiKey!==""&&(D.apiKey=f.apiKey),f.apiKeySource==="env"&&(D.apiKey="<empty>"),await A.post("/memory/config",{patch:!0,lightrag:D}),n.success("LightRAG config saved."),v(!1),t()}catch(D){n.error(`Save failed: ${D.message}`)}finally{d(!1)}}},g=async()=>{if(!l){x(!0);try{const D=await A.post("/memory/lightrag/start");D.ok?n.success(`LightRAG started (pid ${D.pid}).`):n.error(`Start failed: ${D.error}`),t()}catch(D){n.error(`Start failed: ${D.message}`)}finally{x(!1)}}},B=async()=>{if(!u){j(!0);try{await A.post("/memory/lightrag/stop"),n.success("LightRAG stopped."),t()}catch(D){n.error(`Stop failed: ${D.message}`)}finally{j(!1)}}},H=async()=>{await B(),await g()},R=async()=>{p||(o(!0),await i(),o(!1)),k(D=>!D)},J=(s==null?void 0:s.running)??!1;return e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:16},children:[e.jsxs(te,{children:[e.jsxs(le,{children:[e.jsx(Js,{size:14})," LightRAG Server"]}),e.jsxs(oe,{children:["In-process embedding server for semantic memory search."," ",e.jsx("button",{type:"button",className:"link-btn",onClick:t,children:"Refresh"})]}),e.jsxs("div",{style:{display:"flex",gap:8,marginTop:8,flexWrap:"wrap",alignItems:"center"},children:[J?e.jsxs("span",{className:"tag tag-success",children:["running ",s!=null&&s.pid?`(pid ${s.pid})`:""]}):e.jsx("span",{className:"tag tag-neutral",children:"stopped"}),s&&e.jsxs("span",{className:"mono text-sm muted",children:[s.host,":",s.port," · ",s.llmBinding," · ",s.embeddingModel]}),(s==null?void 0:s.lastError)&&e.jsxs("span",{className:"text-error text-sm",children:["⚠ ",s.lastError]})]}),e.jsxs("div",{style:{display:"flex",gap:8,marginTop:12,flexWrap:"wrap"},children:[J?e.jsxs(e.Fragment,{children:[e.jsxs(z,{variant:"secondary",size:"sm",onClick:H,disabled:u||l,children:[e.jsx(de,{size:12})," Restart"]}),e.jsxs(z,{variant:"ghost",size:"sm",onClick:B,disabled:u,children:[u?e.jsx(je,{size:"sm"}):null,u?"Stopping…":"Stop"]})]}):e.jsxs(z,{variant:"primary",size:"sm",onClick:g,disabled:l,children:[l?e.jsx(je,{size:"sm"}):e.jsx(de,{size:12}),l?"Starting…":"Start"]}),e.jsxs(z,{variant:"ghost",size:"sm",onClick:R,children:[p?"Hide":"Show"," log"]})]}),p&&e.jsxs("div",{style:{marginTop:12},children:[e.jsxs("div",{className:"field-help",style:{marginBottom:6},children:["Last ",a.length," line(s)",e.jsx("button",{type:"button",className:"link-btn",style:{marginLeft:8},onClick:i,children:"Refresh"})]}),m?e.jsx("p",{className:"muted text-sm",children:"Loading…"}):a.length===0?e.jsx("p",{className:"muted text-sm",children:"No log output yet."}):e.jsx("pre",{className:"log-pre",children:a.join(`
|
|
338
|
-
`)})]})]}),e.jsxs(te,{children:[e.jsxs(le,{children:[e.jsx(es,{size:14})," Bindings"]}),e.jsx(oe,{children:"Choose the LLM and embedding provider bindings."}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:12,marginTop:12},children:[e.jsxs("div",{className:"field-row",children:[e.jsx("label",{className:"field-label",children:"LLM Binding"}),e.jsx("select",{className:"input",value:f.llmBinding,onChange:D=>y("llmBinding",D.target.value),children:wl.map(D=>e.jsx("option",{value:D,children:D},D))})]}),e.jsxs("div",{className:"field-row",children:[e.jsx("label",{className:"field-label",children:"Embedding Binding"}),e.jsx("select",{className:"input",value:f.embeddingBinding,onChange:D=>y("embeddingBinding",D.target.value),children:Sl.map(D=>e.jsx("option",{value:D,children:D},D))})]}),f.llmBinding!=="ollama"&&e.jsxs("div",{className:"field-row",children:[e.jsx("label",{className:"field-label",children:"LLM Binding Host"}),e.jsx("input",{className:"input",type:"text",value:f.llmBindingHost,onChange:D=>y("llmBindingHost",D.target.value),placeholder:"https://api.minimax.chat/v1"})]}),f.embeddingBinding!=="ollama"&&e.jsxs("div",{className:"field-row",children:[e.jsx("label",{className:"field-label",children:"Embedding Binding Host"}),e.jsx("input",{className:"input",type:"text",value:f.embeddingBindingHost,onChange:D=>y("embeddingBindingHost",D.target.value),placeholder:"https://api.minimax.chat/v1"})]})]})]}),e.jsxs(te,{children:[e.jsxs(le,{children:[e.jsx(Fe,{size:14})," Models"]}),e.jsx(oe,{children:"Model IDs for the LLM and embedding engine."}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:12,marginTop:12},children:[e.jsxs("div",{className:"field-row",children:[e.jsx("label",{className:"field-label",children:"LLM Model"}),e.jsx("input",{className:"input",type:"text",value:f.llmModel,onChange:D=>y("llmModel",D.target.value),placeholder:"minimax/MiniMax-M3"})]}),e.jsxs("div",{className:"field-row",children:[e.jsx("label",{className:"field-label",children:"Embedding Model"}),e.jsx("input",{className:"input",type:"text",value:f.embeddingModel,onChange:D=>y("embeddingModel",D.target.value),placeholder:"text-embedding-3-small"})]})]})]}),e.jsxs(te,{children:[e.jsxs(le,{children:[e.jsx(cs,{size:14})," Connection"]}),e.jsx(oe,{children:"Host, port, and working directory for the LightRAG server."}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:12,marginTop:12},children:[e.jsxs("div",{className:"field-row",children:[e.jsx("label",{className:"field-label",children:"Host"}),e.jsx("input",{className:"input",type:"text",value:f.host,onChange:D=>y("host",D.target.value),placeholder:"127.0.0.1"})]}),e.jsxs("div",{className:"field-row",children:[e.jsx("label",{className:"field-label",children:"Port"}),e.jsx("input",{className:"input",type:"number",min:1,max:65535,value:f.port,onChange:D=>y("port",D.target.value===""?"":Number(D.target.value)),placeholder:"9621"})]}),e.jsxs("div",{className:"field-row",children:[e.jsx("label",{className:"field-label",children:"Working Dir"}),e.jsx("input",{className:"input",type:"text",value:f.workingDir,onChange:D=>y("workingDir",D.target.value),placeholder:".bizar/lightrag (default)"})]})]})]}),e.jsxs(te,{children:[e.jsxs(le,{children:[e.jsx(es,{size:14})," Credentials"]}),e.jsx(oe,{children:"API key source — set in your shell env, or stored in .bizar/memory.json."}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:12,marginTop:12},children:[e.jsxs("div",{className:"field-row",children:[e.jsx("label",{className:"field-label",children:"Source"}),e.jsxs("select",{className:"input",value:f.apiKeySource,onChange:D=>y("apiKeySource",D.target.value),children:[e.jsx("option",{value:"env",children:"Environment variable (recommended)"}),e.jsx("option",{value:"file",children:"Stored in .bizar/memory.json"})]})]}),f.apiKeySource==="env"?e.jsxs("p",{className:"muted text-sm",style:{padding:"8px 0"},children:["Set ",e.jsx("code",{children:"OPENAI_API_KEY"})," (or provider-specific env var) in your shell before running reindex or queries."]}):e.jsxs("div",{className:"field-row",children:[e.jsx("label",{className:"field-label",children:"API Key"}),e.jsx("input",{className:"input",type:"password",value:f.apiKey,onChange:D=>y("apiKey",D.target.value),placeholder:s!=null&&s.running?"(unchanged — leave blank)":"sk-…",autoComplete:"off"})]})]})]}),e.jsx("div",{className:"view-actions",children:e.jsxs(z,{variant:"primary",disabled:!b||c,onClick:$,children:[c?e.jsx(je,{size:"sm"}):e.jsx(Ze,{size:14}),c?"Saving…":"Save config"]})})]})}function zl({onAdd:s}){const t=ce(),[a,i]=r.useState(null),[n,c]=r.useState(!1),[d,l]=r.useState(!1),x=async o=>{c(!0);try{const p=await A.get(`/providers/auto-detect${o?"":"?probe=0"}`);i(p.providers||[]);const k=(p.providers||[]).filter(f=>f.status==="configured");k.length>0?t.success(`Detected ${k.length} configured provider${k.length===1?"":"s"}.`):t.info("No configured providers detected in env or config.")}catch(p){t.error(`Auto-detect failed: ${p.message}`)}finally{c(!1)}},u=o=>o==="configured"?e.jsx(es,{size:12,style:{color:"var(--success)"}}):o==="unknown"?e.jsx(De,{size:12,style:{color:"var(--warning)"}}):e.jsx($e,{size:12,style:{color:"var(--text-dim)"}}),j=(a||[]).filter(o=>o.status==="configured"),m=(a||[]).filter(o=>o.status!=="configured");return e.jsxs(te,{className:"autodetect-banner",children:[e.jsxs("div",{className:"autodetect-head",onClick:()=>l(o=>!o),children:[e.jsx(es,{size:14}),e.jsx("span",{className:"autodetect-title",children:"Auto-detect providers"}),e.jsx("span",{className:"muted",style:{fontSize:11},children:a?`${j.length} configured · ${m.length} other`:"scan env vars + opencode.json for known keys"}),e.jsx("span",{className:"autodetect-spacer"}),e.jsxs(z,{variant:"ghost",size:"sm",onClick:o=>{o.stopPropagation(),x(!0)},disabled:n,title:"Probe each provider's /models endpoint",children:[n?e.jsx(je,{size:"sm"}):e.jsx(de,{size:12})," Detect"]}),d?e.jsx(Ae,{size:14}):e.jsx(He,{size:14})]}),d&&e.jsx("div",{className:"autodetect-body",children:a?e.jsxs("table",{className:"autodetect-table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Status"}),e.jsx("th",{children:"Provider"}),e.jsx("th",{children:"Source"}),e.jsx("th",{children:"Probe"}),e.jsx("th",{})]})}),e.jsx("tbody",{children:a.map(o=>{var p,k,f;return e.jsxs("tr",{children:[e.jsxs("td",{children:[u(o.status)," ",e.jsx("span",{className:"autodetect-status",children:o.status})]}),e.jsxs("td",{children:[e.jsx("strong",{children:o.name})," ",e.jsx("span",{className:"muted mono",children:o.id})]}),e.jsx("td",{className:"muted",children:o.keySource||"—"}),e.jsx("td",{className:"muted",children:((p=o.probed)==null?void 0:p.modelCount)!=null?`${o.probed.modelCount} models`:(k=o.probed)!=null&&k.reason?o.probed.reason:(f=o.probed)!=null&&f.ok?"ok":"—"}),e.jsx("td",{children:o.status==="configured"&&e.jsxs(z,{variant:"ghost",size:"sm",onClick:()=>s(o.id,o.name,o.baseURL||""),title:"Add this provider to opencode.json",children:[e.jsx(pe,{size:10})," Add"]})})]},o.id)})})]}):e.jsxs("div",{className:"muted",style:{padding:12,fontSize:12},children:["Click ",e.jsx("strong",{children:"Detect"})," to scan env vars and opencode.json for known provider keys. Probes each provider's ",e.jsx("code",{children:"/models"})," endpoint with a 1.5s timeout."]})})]})}const Tl=[{id:"dark",label:"Dark",Icon:ga},{id:"light",label:"Light",Icon:ja},{id:"system",label:"System",Icon:fa}],Ml=[{name:"Purple",accent:"#8b5cf6"},{name:"Blue",accent:"#3b82f6"},{name:"Green",accent:"#10b981"},{name:"Orange",accent:"#f97316"},{name:"Red",accent:"#ef4444"},{name:"Pink",accent:"#ec4899"},{name:"Cyan",accent:"#06b6d4"},{name:"Mono",accent:"#6b7280"}],Al=["Inter","system-ui","Segoe UI","Roboto","JetBrains Mono","SF Mono","Cascadia Code"];function $l(s){if(s<=0)return"expired";const t=Math.floor(s/1e3),a=Math.floor(t/60),i=t%60;return`${a}:${String(i).padStart(2,"0")}`}function Il(){const s=ce(),[t,a]=r.useState(null),[i,n]=r.useState(!1),[c,d]=r.useState(null),[l,x]=r.useState(Date.now()),u=r.useCallback(async()=>{n(!0),d(null);try{const o=await A.post("/pair/start");a(o)}catch(o){d((o==null?void 0:o.message)||"Failed to start pairing"),s.error("Pairing failed.")}finally{n(!1)}},[s]);r.useEffect(()=>{if(!t)return;const o=setInterval(()=>x(Date.now()),1e3);return()=>clearInterval(o)},[t]);const j=t?t.expiresAt-l:0,m=t!=null&&j<=0;return e.jsxs(te,{id:"settings-updates","data-section":"updates",children:[e.jsxs(le,{children:[e.jsx(va,{size:14})," Companion App"]}),e.jsxs(oe,{children:["Scan the QR with ",e.jsx("a",{href:"https://github.com/DrB0rk/BizarHarness",target:"_blank",rel:"noopener noreferrer",children:"Bizar Companion"})," to pair. Tokens expire after 5 minutes."]}),e.jsxs("div",{style:{display:"flex",gap:16,alignItems:"flex-start",flexWrap:"wrap"},children:[e.jsx("div",{style:{flex:"0 0 auto"},children:t&&!m?e.jsx("div",{style:{background:"#fff",padding:12,borderRadius:12},children:e.jsx(ya,{value:t.qrPayload,size:192,level:"M",includeMargin:!1})}):e.jsx("div",{style:{width:216,height:216,borderRadius:12,background:"var(--surface-2, #161b22)",display:"flex",alignItems:"center",justifyContent:"center",color:"var(--text-muted, #8b949e)",fontSize:12,textAlign:"center",padding:16,border:"1px dashed var(--border, #30363d)"},children:t&&m?"QR expired":"No QR generated yet"})}),e.jsxs("div",{style:{flex:"1 1 240px",minWidth:220},children:[!t&&e.jsxs(z,{variant:"primary",onClick:u,disabled:i,children:[e.jsx(ba,{size:14})," ",i?"Generating…":"Generate QR Code"]}),t&&!m&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{marginBottom:10},children:[e.jsx("strong",{children:"Expires in"})," ",e.jsx("span",{className:"mono",children:$l(j)})]}),e.jsxs("div",{style:{marginBottom:6},children:[e.jsx("strong",{children:"URL:"})," ",e.jsx("span",{className:"mono",style:{wordBreak:"break-all"},children:t.publicUrl})]}),e.jsxs("div",{style:{marginBottom:12},children:[e.jsx("strong",{children:"Token:"})," ",e.jsxs("span",{className:"mono",style:{wordBreak:"break-all",fontSize:12},children:[t.token.slice(0,16),"…",t.token.slice(-6)]})]}),e.jsxs(z,{variant:"secondary",onClick:u,disabled:i,children:[e.jsx(de,{size:14})," Regenerate"]})]}),t&&m&&e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{marginBottom:12,color:"var(--error, #f85149)"},children:"Token expired — generate a fresh QR to pair again."}),e.jsxs(z,{variant:"primary",onClick:()=>{a(null),u()},children:[e.jsx(de,{size:14})," Generate new QR"]})]}),c&&e.jsx("div",{style:{marginTop:10,color:"var(--error, #f85149)",fontSize:12},children:c})]})]})]})}const Rl=[{id:"topnav",label:"Top nav"},{id:"sidebar",label:"Sidebar"},{id:"both",label:"Both"}];function Dl(){const s=ce(),[t,a]=r.useState({current:{},latest:null,checking:!1,updating:!1,hasUpdates:!1,requiresRestart:!1,perPackage:{}});r.useEffect(()=>{const x=new Ys;return x.on(u=>{(u.type==="update:progress"||u.type==="update:log"||u.type==="update:complete")&&a(j=>{if(u.type==="update:complete")return{...j,updating:!1,requiresRestart:!!u.requiresRestart};if(u.type==="update:log"){const o=u,p=j.perPackage[o.pkg]||{logs:[]};return{...j,perPackage:{...j.perPackage,[o.pkg]:{...p,logs:[...(p.logs||[]).slice(-50),o.line]}}}}const m=u;return{...j,perPackage:{...j.perPackage,[m.pkg]:{...j.perPackage[m.pkg],status:m.status,error:m.error,newVersion:m.newVersion}}}})}),()=>x.close()},[]),r.useEffect(()=>{A.get("/updates/status").then(x=>a(u=>({...u,current:x.current}))).catch(x=>a(u=>({...u,error:x.message})))},[]);const i=async()=>{a(x=>({...x,checking:!0,error:void 0}));try{const x=await A.get("/updates/check");a(u=>({...u,checking:!1,current:x.current,latest:x.latest,hasUpdates:x.hasUpdates}))}catch(x){a(u=>({...u,checking:!1,error:x.message}))}},n=async()=>{if(confirm("Update Bizar packages? The dashboard will restart automatically.")){a(x=>({...x,updating:!0,requiresRestart:!1,perPackage:{},error:void 0}));try{await A.post("/updates/apply",{packages:["bizar","bizar-dash","bizar-plugin"]})}catch(x){a(u=>({...u,updating:!1,error:x.message}))}}},c=async()=>{if(confirm("Restart the dashboard? You will be disconnected briefly."))try{await A.post("/restart"),s.info("Restarting…",3e3),setTimeout(()=>window.location.reload(),3e3)}catch{s.error("Restart failed")}},d=[{id:"bizar",name:"Bizar CLI"},{id:"bizar-dash",name:"Dashboard"},{id:"bizar-plugin",name:"Opencode Plugin"}],l=t.checking||t.updating;return e.jsxs(te,{id:"settings-updates","data-section":"updates",children:[e.jsxs(le,{children:[e.jsx(Le,{size:14})," Updates"]}),e.jsx(oe,{children:"Check installed Bizar packages and apply dashboard updates."}),e.jsxs("div",{className:"updates-current",children:[e.jsx("h4",{children:"Installed versions"}),e.jsx("ul",{children:d.map(x=>e.jsxs("li",{children:[e.jsx("span",{children:x.name}),e.jsx("code",{className:"mono",children:t.current[x.id]||"—"})]},x.id))})]}),t.latest&&e.jsxs("div",{className:"updates-latest",children:[e.jsx("h4",{children:"Latest available"}),e.jsx("ul",{children:d.map(x=>{var o;const u=t.current[x.id],j=(o=t.latest)==null?void 0:o[x.id],m=u&&j&&u!==j;return e.jsxs("li",{className:m?"updates-outdated":"updates-current-version",children:[e.jsx("span",{children:x.name}),e.jsxs("code",{className:"mono",children:[j||"—",m&&e.jsx("span",{className:"updates-badge",children:"update available"})]})]},x.id)})})]}),t.updating&&e.jsx("div",{className:"updates-progress-rows",children:d.map(x=>{const u=t.perPackage[x.id]||{status:"idle",logs:[]};return e.jsxs("div",{className:"updates-pkg-row",children:[e.jsxs("div",{className:"updates-pkg-row-header",children:[e.jsx("span",{className:"updates-pkg-name",children:x.name}),e.jsxs("div",{className:"updates-pkg-status",children:[u.status==="starting"&&e.jsx("span",{className:"btn-spinner"}),u.status==="installing"&&e.jsx("span",{className:"btn-spinner"}),u.status==="done"&&e.jsx(Ra,{size:14,className:"icon-success"}),u.status==="error"&&e.jsx(Vs,{size:14,className:"icon-error"}),e.jsx("span",{children:u.status}),u.newVersion&&e.jsxs("code",{className:"mono",style:{fontSize:11},children:["→ ",u.newVersion]})]})]}),u.logs.length>0&&e.jsxs("details",{className:"updates-pkg-logs",children:[e.jsxs("summary",{children:["npm output (",u.logs.length," lines)"]}),e.jsx("pre",{children:u.logs.join(`
|
|
339
|
-
`)})]}),u.status==="error"&&u.error&&e.jsxs("div",{className:"updates-pkg-error",children:[e.jsx(De,{size:12})," ",u.error]})]},x.id)})}),e.jsxs("div",{className:"updates-actions",children:[e.jsxs(z,{onClick:i,disabled:l,children:[t.checking?e.jsx("span",{className:"btn-spinner"}):e.jsx(de,{size:14}),"Check for updates"]}),e.jsxs(z,{variant:"primary",onClick:n,disabled:!t.hasUpdates||t.updating,children:[t.updating?e.jsx("span",{className:"btn-spinner"}):e.jsx(Le,{size:14}),t.updating?"Updating…":t.hasUpdates?"Update now":"Up to date"]}),t.requiresRestart&&e.jsxs(z,{variant:"danger",onClick:c,children:[e.jsx(de,{size:14})," Restart Dashboard"]})]}),t.error&&e.jsxs("div",{className:"updates-error",children:[e.jsx(De,{size:14}),e.jsx("span",{children:t.error})]})]})}function Ll({settings:s,refreshSnapshot:t}){var Q,F,q,ee,T,M,C;const a=ce(),[i,n]=r.useState(s),[c,d]=r.useState(!1),[l,x]=r.useState(!1),[u,j]=r.useState(null),[m,o]=r.useState({port:4321,https:!0,hostname:""}),[p,k]=r.useState({});r.useEffect(()=>{n(s),d(!1),s.theme&&Je(s.theme)},[s]),r.useEffect(()=>{u&&o({port:u.settings.port,https:u.settings.https!==!1,hostname:u.settings.hostname||""})},[u]),r.useEffect(()=>{A.get("/tailscale/status").then(j).catch(()=>{})},[]),r.useEffect(()=>{A.get("/settings/plugin-options").then(k).catch(()=>{})},[]);const f=h=>{n(P=>{const Y={...P,theme:{...P.theme,...h}};return Je(Y.theme),Y}),d(!0)},S=h=>{n(P=>({...P,ui:{...P.ui,...h}})),d(!0)},b=(h,P)=>{n(Y=>({...Y,[h]:P})),d(!0)},v=h=>{n(P=>({...P,notifications:{...P.notifications,...h}})),d(!0)},y=h=>{n(P=>({...P,agents:{...P.agents,...h}})),d(!0)},$=[{id:"theme",label:"Theme"},{id:"layout",label:"Layout"},{id:"general",label:"General"},{id:"service",label:"Service"},{id:"tailscale",label:"Tailscale"},{id:"notifications",label:"Notifications"},{id:"auth",label:"Auth"},{id:"agents",label:"Agents"},{id:"dashboard",label:"Dashboard"},{id:"background",label:"Background"},{id:"system-llm",label:"System LLM"},{id:"updates",label:"Updates"},{id:"activity-log",label:"Activity"},{id:"about",label:"About"}],[g,B]=r.useState(()=>{if(typeof window>"u")return null;const h=window.location.hash.replace(/^#settings-/,"");return $.some(P=>P.id===h)?h:null}),H=h=>{B(h);try{const P=h?`#settings-${h}`:window.location.pathname;if(history.replaceState(null,"",P),h){const Y=document.getElementById(`settings-${h}`);Y&&Y.scrollIntoView({behavior:"smooth",block:"start"})}else window.scrollTo({top:0,behavior:"smooth"})}catch{}},R=h=>{n(P=>({...P,dashboard:{...P.dashboard,...h}})),d(!0)},J=async()=>{x(!0);try{const h=await A.put("/settings",i);n(h.data),d(!1),ts(h.data.theme),Je(h.data.theme),a.success("Settings saved."),await t()}catch(h){a.error(`Save failed: ${h.message}`)}finally{x(!1)}},D=async()=>{try{const h=await A.get("/settings");n(h.data),d(!1),ts(h.data.theme),Je(h.data.theme),a.info("Settings reloaded.",1500)}catch(h){a.error(`Reload failed: ${h.message}`)}},L=async()=>{if(confirm("Reset all settings to defaults?"))try{const h=await A.post("/settings/reset");n(h.data),d(!1),ts(h.data.theme),Je(h.data.theme),a.success("Settings reset."),await t()}catch(h){a.error(`Reset failed: ${h.message}`)}},V=async()=>{try{u!=null&&u.settings.enabled?(await A.post("/tailscale/disable"),a.success("Tailscale serve disabled.")):(await A.post("/tailscale/enable",{port:m.port||4321,https:m.https,hostname:m.hostname||""}),a.success("Tailscale serve enabled."));const h=await A.get("/tailscale/status");j(h)}catch(h){a.error(`Tailscale failed: ${h.message}`)}},K=i.about||{version:"3.0.4",homepage:"https://github.com/DrB0rk/BizarHarness",license:"MIT"},[w,I]=r.useState(A.getToken()),[_,W]=r.useState(null),[X,ne]=r.useState("");r.useEffect(()=>{let h=!1;return(async()=>{try{const P=await A.probeAuthStatus();h||W(P)}catch{h||W({required:!0,loopback:!1,peer:""})}})(),()=>{h=!0}},[]);const se=async()=>{try{const h=await A.get("/auth/reveal");ne(h.token),I(h.token),A.setToken(h.token);try{await navigator.clipboard.writeText(h.token),a.success("Token copied to clipboard.")}catch{a.success("Token revealed — copy from the field below.")}}catch(h){a.error(`Reveal failed: ${h.message}`)}},U=async()=>{if(confirm("Regenerate the auth token? Anything still using the old token will start getting 401 errors immediately."))try{const h=await A.post("/auth/regenerate");ne(h.token),I(h.token),A.setToken(h.token);try{await navigator.clipboard.writeText(h.token),a.success("New token generated and copied to clipboard.")}catch{a.success("New token generated — copy from the field below. Old token is now invalid.")}}catch(h){a.error(`Regenerate failed: ${h.message}`)}},O=()=>{A.setToken(w.trim()),a.success("Token saved. The dashboard will use it on the next request.")};return e.jsxs("div",{className:"view view-settings",children:[e.jsxs("header",{className:"view-header",children:[e.jsxs("div",{className:"view-header-text",children:[e.jsxs("h2",{className:"view-title",children:[e.jsx(ft,{size:18})," Settings"]}),e.jsxs("p",{className:"view-subtitle",children:["Personal preferences. Changes are saved to"," ",e.jsx("code",{children:"~/.config/bizar/settings.json"}),"."]})]}),e.jsxs("div",{className:"view-actions",children:[e.jsxs(z,{variant:"ghost",size:"sm",onClick:L,children:[e.jsx(nt,{size:14})," Reset"]}),e.jsxs(z,{variant:"secondary",size:"sm",onClick:D,children:[e.jsx(de,{size:14})," Reload"]}),e.jsxs(z,{variant:"primary",size:"sm",disabled:!c||l,onClick:J,children:[l?e.jsx("span",{className:"btn-spinner"}):e.jsx(Ze,{size:14}),l?"Saving…":"Save"]})]})]}),e.jsxs("nav",{className:"settings-subnav","aria-label":"Settings sections",children:[e.jsx("button",{type:"button",className:ae("settings-subnav-button","settings-subnav-button-all",g===null&&"settings-subnav-button-active"),onClick:()=>H(null),title:"Show all settings sections",children:"All"}),$.map(h=>e.jsx("button",{type:"button",className:ae("settings-subnav-button",g===h.id&&"settings-subnav-button-active"),onClick:()=>H(h.id),children:h.label},h.id))]}),e.jsxs("div",{className:ae("settings-grid",g&&"settings-grid-filtered"),"data-active-section":g||void 0,children:[g&&e.jsxs("div",{className:"settings-filter-banner",children:[e.jsxs("span",{children:["Showing only ",e.jsx("strong",{children:(Q=$.find(h=>h.id===g))==null?void 0:Q.label}),"."]}),e.jsx("button",{type:"button",className:"settings-filter-clear",onClick:()=>H(null),children:"Show all sections"})]}),e.jsx("div",{"data-section":"theme",style:{display:g===null||g==="theme"?"block":"none"},children:e.jsxs(te,{id:"settings-theme","data-section":"theme",children:[e.jsxs(le,{children:[e.jsx($t,{size:14})," Theme"]}),e.jsx(oe,{children:"Mode, accent, and colors. Live preview as you tweak."}),e.jsxs("div",{className:"field","data-setting-id":"theme.presets",children:[e.jsx("label",{className:"field-label",children:"Accent presets"}),e.jsx("div",{className:"theme-presets",children:Ml.map(h=>e.jsxs("button",{type:"button",className:ae("theme-preset",i.theme.accent===h.accent&&"theme-preset-active"),onClick:()=>f({accent:h.accent}),title:h.name,children:[e.jsx("span",{className:"theme-preset-swatch",style:{background:h.accent}}),e.jsx("span",{className:"theme-preset-name",children:h.name})]},h.name))})]}),e.jsxs("div",{className:"field","data-setting-id":"theme.mode",children:[e.jsx("label",{className:"field-label",children:"Mode"}),e.jsx("div",{className:"theme-row",children:Tl.map(({id:h,label:P,Icon:Y})=>{const E=i.theme.mode===h;return e.jsxs("button",{type:"button",className:ae("theme-card",E&&"theme-card-active"),onClick:()=>f({mode:h}),children:[e.jsx(Y,{size:16}),e.jsx("span",{className:"theme-card-label",children:P}),e.jsx("span",{className:ae("theme-card-swatch",`theme-card-swatch-${h}`)})]},h)})})]}),e.jsxs("div",{className:"theme-colors",children:[e.jsxs("div",{className:"field","data-setting-id":"theme.accent",children:[e.jsx("label",{className:"field-label",children:"Accent"}),e.jsxs("div",{className:"color-row",children:[e.jsx("input",{type:"color",className:"input color-input",value:i.theme.accent,onChange:h=>f({accent:h.target.value}),"aria-label":"Accent color"}),e.jsx("input",{type:"text",className:"input",value:i.theme.accent,onChange:h=>f({accent:h.target.value})})]})]}),e.jsxs("div",{className:"field","data-setting-id":"theme.success",children:[e.jsx("label",{className:"field-label",children:"Success"}),e.jsxs("div",{className:"color-row",children:[e.jsx("input",{type:"color",className:"input color-input",value:i.theme.success,onChange:h=>f({success:h.target.value}),"aria-label":"Success color"}),e.jsx("input",{type:"text",className:"input",value:i.theme.success,onChange:h=>f({success:h.target.value})})]})]}),e.jsxs("div",{className:"field","data-setting-id":"theme.warning",children:[e.jsx("label",{className:"field-label",children:"Warning"}),e.jsxs("div",{className:"color-row",children:[e.jsx("input",{type:"color",className:"input color-input",value:i.theme.warning,onChange:h=>f({warning:h.target.value}),"aria-label":"Warning color"}),e.jsx("input",{type:"text",className:"input",value:i.theme.warning,onChange:h=>f({warning:h.target.value})})]})]}),e.jsxs("div",{className:"field","data-setting-id":"theme.error",children:[e.jsx("label",{className:"field-label",children:"Error"}),e.jsxs("div",{className:"color-row",children:[e.jsx("input",{type:"color",className:"input color-input",value:i.theme.error,onChange:h=>f({error:h.target.value}),"aria-label":"Error color"}),e.jsx("input",{type:"text",className:"input",value:i.theme.error,onChange:h=>f({error:h.target.value})})]})]}),e.jsxs("div",{className:"field","data-setting-id":"theme.info",children:[e.jsx("label",{className:"field-label",children:"Info"}),e.jsxs("div",{className:"color-row",children:[e.jsx("input",{type:"color",className:"input color-input",value:i.theme.info,onChange:h=>f({info:h.target.value}),"aria-label":"Info color"}),e.jsx("input",{type:"text",className:"input",value:i.theme.info,onChange:h=>f({info:h.target.value})})]})]})]}),e.jsxs("div",{className:"field","data-setting-id":"theme.fontFamily",children:[e.jsx("label",{className:"field-label",children:"Font family"}),e.jsx("select",{className:"select",value:i.theme.fontFamily,onChange:h=>f({fontFamily:h.target.value}),children:Al.map(h=>e.jsx("option",{value:h,children:h},h))})]}),e.jsxs("div",{className:"field","data-setting-id":"theme.fontSize",children:[e.jsxs("label",{className:"field-label",children:["Font size: ",i.theme.fontSize,"px"]}),e.jsx("input",{type:"range",min:12,max:20,value:i.theme.fontSize,onChange:h=>f({fontSize:Number(h.target.value)})})]}),e.jsxs("label",{className:"checkbox-row","data-setting-id":"theme.compactMode",children:[e.jsx("input",{type:"checkbox",checked:i.theme.compactMode,onChange:h=>f({compactMode:h.target.checked})}),e.jsx("span",{children:"Compact mode (denser UI)"})]}),e.jsxs("label",{className:"checkbox-row","data-setting-id":"theme.animations",children:[e.jsx("input",{type:"checkbox",checked:i.theme.animations,onChange:h=>f({animations:h.target.checked})}),e.jsx("span",{children:"Enable animations"})]})]})}),e.jsx("div",{"data-section":"updates",style:{display:g===null||g==="updates"?"block":"none"},children:e.jsx(Dl,{})}),e.jsx("div",{"data-section":"layout",style:{display:g===null||g==="layout"?"block":"none"},children:e.jsxs(te,{id:"settings-layout","data-section":"layout",children:[e.jsxs(le,{children:[e.jsx(en,{size:14})," UI layout"]}),e.jsx(oe,{children:"Choose how the dashboard's navigation is presented."}),e.jsx("div",{className:"layout-row","data-setting-id":"ui.layout",children:Rl.map(h=>e.jsx("button",{type:"button",className:ae("layout-card",i.ui.layout===h.id&&"layout-card-active"),onClick:()=>S({layout:h.id}),children:e.jsx("span",{className:"layout-card-label",children:h.label})},h.id))}),e.jsxs("label",{className:"checkbox-row","data-setting-id":"ui.showHeader",children:[e.jsx("input",{type:"checkbox",checked:i.ui.showHeader,onChange:h=>S({showHeader:h.target.checked})}),e.jsx("span",{children:"Show header"})]}),e.jsxs("label",{className:"checkbox-row","data-setting-id":"ui.showStatusBar",children:[e.jsx("input",{type:"checkbox",checked:i.ui.showStatusBar,onChange:h=>S({showStatusBar:h.target.checked})}),e.jsx("span",{children:"Show status bar"})]}),e.jsxs("div",{className:"field","data-setting-id":"ui.defaultTab",children:[e.jsx("label",{className:"field-label",children:"Default tab"}),e.jsxs("select",{className:"select",value:i.ui.defaultTab,onChange:h=>S({defaultTab:h.target.value}),children:[e.jsx("option",{value:"overview",children:"Overview"}),e.jsx("option",{value:"chat",children:"Chat"}),e.jsx("option",{value:"agents",children:"Agents"}),e.jsx("option",{value:"artifacts",children:"Plans"}),e.jsx("option",{value:"projects",children:"Projects"}),e.jsx("option",{value:"tasks",children:"Tasks"}),e.jsx("option",{value:"config",children:"Config"}),e.jsx("option",{value:"settings",children:"Settings"}),e.jsx("option",{value:"mods",children:"Mods"}),e.jsx("option",{value:"schedules",children:"Schedules"})]})]})]})}),e.jsx("div",{"data-section":"general",style:{display:g===null||g==="general"?"block":"none"},children:e.jsxs(te,{id:"settings-general","data-section":"general",children:[e.jsx(le,{children:"General"}),e.jsx(oe,{children:"Default agent + model override."}),e.jsxs("div",{className:"field","data-setting-id":"defaultAgent",children:[e.jsx("label",{className:"field-label",htmlFor:"set-default-agent",children:"Default agent"}),e.jsx("input",{id:"set-default-agent",className:"input",type:"text",placeholder:"e.g. odin",value:i.defaultAgent||"",onChange:h=>b("defaultAgent",h.target.value)})]}),e.jsxs("div",{className:"field","data-setting-id":"defaultModel",children:[e.jsx("label",{className:"field-label",htmlFor:"set-default-model",children:"Model override"}),e.jsx("input",{id:"set-default-model",className:"input",type:"text",placeholder:"(leave empty for provider default)",value:i.defaultModel||"",onChange:h=>b("defaultModel",h.target.value)})]})]})}),e.jsx("div",{"data-section":"service",style:{display:g===null||g==="service"?"block":"none"},children:e.jsxs(te,{id:"settings-service","data-section":"service",children:[e.jsxs(le,{children:[e.jsx(Fe,{size:14})," Service"]}),e.jsx(oe,{children:"Background daemon that runs schedules."}),e.jsx("div",{"data-setting-id":"service.enabled",children:u?e.jsxs("div",{className:"service-card",children:[e.jsxs("p",{children:["Status: ",e.jsx("strong",{children:u!=null&&u.settings.enabled?"enabled":"disabled"})," ","· Tailscale installed: ",e.jsx("strong",{children:u.installed?"yes":"no"})," ","· authenticated: ",e.jsx("strong",{children:u.authenticated?"yes":"no"})]}),e.jsxs("p",{className:"muted",children:["Use ",e.jsx("code",{children:"bizar service start"})," / ",e.jsx("code",{children:"bizar service stop"})," in your terminal to control the daemon."]})]}):e.jsx("p",{className:"muted",children:"Loading service status…"})})]})}),e.jsx("div",{"data-section":"tailscale",style:{display:g===null||g==="tailscale"?"block":"none"},children:e.jsxs(te,{id:"settings-tailscale","data-section":"tailscale",children:[e.jsxs(le,{children:[e.jsx(cs,{size:14})," Tailscale serve"]}),e.jsx(oe,{children:"Expose the dashboard over your Tailscale network."}),u?e.jsxs(e.Fragment,{children:[e.jsxs("p",{children:["Installed: ",e.jsx("strong",{children:u.installed?"yes":"no"})," ",u.version&&e.jsxs("span",{className:"muted",children:["(",u.version,")"]})]}),e.jsxs("p",{children:["Authenticated: ",e.jsx("strong",{children:u.authenticated?"yes":"no"})]}),e.jsxs("p",{children:["Serve enabled: ",e.jsx("strong",{children:u.settings.enabled?"yes":"no"})]}),e.jsxs("div",{className:"task-form-row",children:[e.jsxs("div",{className:"task-form-field",children:[e.jsx("label",{className:"field-label",children:"Port"}),e.jsx("input",{type:"number",className:"input",value:m.port,onChange:h=>o(P=>({...P,port:Number(h.target.value)||4321}))})]}),e.jsxs("div",{className:"task-form-field",children:[e.jsx("label",{className:"field-label",children:"Use HTTPS"}),e.jsx("input",{type:"checkbox",checked:m.https,onChange:h=>o(P=>({...P,https:h.target.checked}))})]})]}),e.jsx(z,{variant:"primary",onClick:V,children:u.settings.enabled?"Disable serve":"Enable serve"})]}):e.jsx("p",{className:"muted",children:"Loading Tailscale status…"})]})}),e.jsx("div",{"data-section":"notifications",style:{display:g===null||g==="notifications"?"block":"none"},children:e.jsxs(te,{id:"settings-notifications","data-section":"notifications",children:[e.jsx(le,{children:"Notifications"}),e.jsx(oe,{children:"Toast triggers inside the dashboard."}),e.jsxs("label",{className:"checkbox-row","data-setting-id":"notifications.onAgentComplete",children:[e.jsx("input",{type:"checkbox",checked:!!i.notifications.onAgentComplete,onChange:h=>v({onAgentComplete:h.target.checked})}),e.jsx("span",{children:"Notify when an agent invocation completes"})]}),e.jsxs("label",{className:"checkbox-row","data-setting-id":"notifications.onPlanApproval",children:[e.jsx("input",{type:"checkbox",checked:!!i.notifications.onPlanApproval,onChange:h=>v({onPlanApproval:h.target.checked})}),e.jsx("span",{children:"Notify when a plan needs approval"})]})]})}),e.jsx("div",{"data-section":"auth",style:{display:g===null||g==="auth"?"block":"none"},children:e.jsxs(te,{id:"settings-auth","data-section":"auth",children:[e.jsxs(le,{children:[e.jsx(ln,{size:14})," Authentication"]}),e.jsx(oe,{children:"Localhost and Tailscale browser access are auto-trusted via loopback. A bearer token is still available for non-loopback clients and forced-auth mode."}),e.jsxs("div",{className:"field","data-setting-id":"auth.status",children:[e.jsx("label",{className:"field-label",children:"Server status"}),e.jsxs("p",{style:{margin:"4px 0"},children:["Auth required:"," ",e.jsx("strong",{children:_?_.required?"yes":"no":"probing…"})]}),e.jsxs("p",{style:{margin:"4px 0"},children:["Connection:"," ",e.jsx("strong",{children:_?_.loopback?"loopback (auto-trusted)":"remote":"probing…"})]}),e.jsxs("p",{style:{margin:"4px 0"},children:["Peer address:"," ",_!=null&&_.peer?e.jsx("code",{children:_.peer}):e.jsx("span",{className:"muted",children:"probing…"})]}),e.jsxs("p",{className:"muted",style:{fontSize:12,margin:"4px 0"},children:["Localhost and Tailscale browser access are auto-trusted because the dashboard sees a loopback peer. Paste a token only for non-loopback API clients/scripts, or if you force auth for every connection with"," ",e.jsx("code",{children:"BIZAR_DASHBOARD_REQUIRE_AUTH=1"}),"."]}),e.jsxs("p",{className:"muted",style:{fontSize:12,margin:"4px 0"},children:["Dashboard tokens are generated on first boot and saved to"," ",e.jsx("code",{children:"~/.config/bizar/dashboard-secret"})," (mode 0600)."]})]}),e.jsxs("div",{className:"field","data-setting-id":"auth.token",children:[e.jsx("label",{className:"field-label",children:"Token (this browser)"}),e.jsx("input",{type:"password",className:"input mono",value:w,onChange:h=>I(h.target.value),placeholder:"Paste token from server stderr or another browser",spellCheck:!1,autoComplete:"off"}),e.jsxs("div",{className:"task-form-row",style:{marginTop:8},children:[e.jsxs(z,{variant:"secondary",size:"sm",onClick:O,children:[e.jsx(Wa,{size:14})," Save token"]}),e.jsxs(z,{variant:"ghost",size:"sm",onClick:se,children:[e.jsx(Ss,{size:14})," Reveal & copy server token"]}),e.jsxs(z,{variant:"ghost",size:"sm",onClick:U,children:[e.jsx(nt,{size:14})," Regenerate"]})]}),X?e.jsxs("p",{className:"muted",style:{fontSize:12,marginTop:8},children:["Last revealed token (one-time): ",e.jsx("code",{className:"mono",children:X})]}):null,e.jsx("p",{className:"muted",style:{fontSize:12,marginTop:8},children:"Regenerating invalidates the current token immediately. Anything still using the old token will see 401 until it's updated."})]})]})}),e.jsx("div",{"data-section":"agents",style:{display:g===null||g==="agents"?"block":"none"},children:e.jsxs(te,{id:"settings-agents","data-section":"agents",children:[e.jsxs(le,{children:[e.jsx(Fe,{size:14})," Agent Behavior"]}),e.jsx(oe,{children:"Limits and timeouts for background agent dispatch."}),e.jsxs("div",{className:"form-row",children:[e.jsxs("label",{htmlFor:"agents-maxParallel",children:["Max parallel agents",e.jsx("span",{className:"meta-badge",children:"default: 6"})]}),e.jsx("input",{id:"agents-maxParallel",type:"number",min:1,max:20,value:((F=i.agents)==null?void 0:F.maxParallel)??6,onChange:h=>y({maxParallel:Math.max(1,Math.min(20,parseInt(h.target.value,10)||6))})})]}),e.jsxs("div",{className:"form-row",children:[e.jsxs("label",{htmlFor:"agents-stuckThresholdMs",children:["Stuck threshold (ms)",e.jsx("span",{className:"meta-badge",children:"default: 600000 (10 min)"})]}),e.jsx("input",{id:"agents-stuckThresholdMs",type:"number",min:6e4,max:36e5,step:6e4,value:((q=i.agents)==null?void 0:q.stuckThresholdMs)??6e5,onChange:h=>y({stuckThresholdMs:Math.max(6e4,Math.min(36e5,parseInt(h.target.value,10)||6e5))})})]}),e.jsxs("label",{className:"checkbox-row","data-setting-id":"agents.autoRestart",children:[e.jsx("input",{type:"checkbox",checked:!!((ee=i.agents)!=null&&ee.autoRestart),onChange:h=>y({autoRestart:h.target.checked})}),e.jsx("span",{children:"Auto-restart stuck agents"})]})]})}),e.jsx("div",{"data-section":"dashboard",style:{display:g===null||g==="dashboard"?"block":"none"},children:e.jsxs(te,{id:"settings-dashboard","data-section":"dashboard",children:[e.jsxs(le,{children:[e.jsx(rs,{size:14})," Dashboard"]}),e.jsxs(oe,{children:["Controls how ",e.jsx("code",{children:"bizar"})," starts up."]}),e.jsxs("label",{className:"checkbox-row","data-setting-id":"dashboard.autoLaunchWeb",children:[e.jsx("input",{type:"checkbox",checked:i.dashboard.autoLaunchWeb!==!1,onChange:h=>R({autoLaunchWeb:h.target.checked})}),e.jsx("span",{children:"Auto-launch web UI alongside TUI"})]}),e.jsxs("div",{className:"field","data-setting-id":"dashboard.projectsDirectory",style:{marginTop:"var(--space-4)"},children:[e.jsx("label",{className:"field-label",htmlFor:"set-projects-directory",children:"Projects directory"}),e.jsx("input",{id:"set-projects-directory",className:"input",type:"text",placeholder:"/home/user/projects",value:i.dashboard.projectsDirectory??"",onChange:h=>R({projectsDirectory:h.target.value})}),e.jsx("p",{className:"field-help",children:"New projects created via the dashboard will land here, and existing project directories inside this folder are auto-recognized on startup."}),i.dashboard.projectsDirectory&&e.jsxs(e.Fragment,{children:[!/^\/|^[A-Za-z]:/.test(i.dashboard.projectsDirectory)&&e.jsx("p",{style:{color:"var(--warning)",fontSize:11,marginTop:4},children:"Path should be absolute (start with / on Linux/Mac, or a drive letter on Windows)."}),i.dashboard.projectsDirectory.includes("..")&&e.jsx("p",{style:{color:"var(--error)",fontSize:11,marginTop:4},children:"Path traversal not allowed — this will be rejected server-side."})]})]}),e.jsxs("div",{className:"field","data-setting-id":"dashboard.allowedRoots",style:{marginTop:"var(--space-4)"},children:[e.jsxs("label",{className:"field-label",htmlFor:"set-allowed-roots",children:["Additional allowed roots ",e.jsx("span",{className:"muted",children:"(advanced)"})]}),e.jsx("textarea",{id:"set-allowed-roots",className:"textarea",rows:4,placeholder:`/workspace
|
|
340
|
-
/srv/projects`,value:(i.dashboard.allowedRoots??[]).join(`
|
|
341
|
-
`),onChange:h=>{const P=h.target.value.split(`
|
|
342
|
-
`).map(Y=>Y.trim()).filter(Boolean);R({allowedRoots:P})}}),e.jsx("p",{className:"field-help",children:"Optional. Add filesystem roots beyond your home directory that the file browser and project scanner can access. Each path must be inside your home directory. One per line."}),(()=>{const h=(i.dashboard.allowedRoots??[]).join(`
|
|
343
|
-
`).split(`
|
|
344
|
-
`),P=[];return h.forEach((Y,E)=>{Y.trim()&&(/^\/|^[A-Za-z]:/.test(Y)||P.push({key:`noabs-${E}`,msg:e.jsxs("p",{style:{color:"var(--warning)",fontSize:11,marginTop:2},children:["Line ",E+1,': "',Y,'" — should be absolute (start with / or a drive letter).']})}),Y.includes("..")&&P.push({key:`dots-${E}`,msg:e.jsxs("p",{style:{color:"var(--error)",fontSize:11,marginTop:2},children:["Line ",E+1,': "',Y,`" — contains '..' (server will reject this).`]})}))}),P.map(Y=>Y.msg)})()]})]})}),e.jsx("div",{"data-section":"background",style:{display:g===null||g==="background"?"block":"none"},children:e.jsxs(te,{id:"settings-background","data-section":"background",children:[e.jsxs(le,{children:[e.jsx(Fe,{size:14})," Background Agents"]}),e.jsx(oe,{children:"Tune plugin options. Changes take effect on next plugin restart."}),e.jsxs("div",{className:"form-row",children:[e.jsxs("label",{htmlFor:"bg-maxConcurrent",children:["Max concurrent instances",e.jsx("span",{className:"meta-badge",children:"default: 8"})]}),e.jsx("input",{id:"bg-maxConcurrent",type:"number",min:1,max:32,value:p.maxConcurrentInstances??8,onChange:h=>k(P=>({...P,maxConcurrentInstances:Math.max(1,Math.min(32,parseInt(h.target.value,10)||8))}))}),e.jsxs("small",{className:"muted",children:["Plugin option: ",e.jsx("code",{children:"maxConcurrentInstances"})]})]}),e.jsxs("div",{className:"form-row",children:[e.jsxs("label",{htmlFor:"bg-toolCallCap",children:["Tool-call cap",e.jsx("span",{className:"meta-badge",children:"default: 500"})]}),e.jsx("input",{id:"bg-toolCallCap",type:"number",min:1,max:5e3,value:p.backgroundToolCallCap??500,onChange:h=>k(P=>({...P,backgroundToolCallCap:Math.max(1,Math.min(5e3,parseInt(h.target.value,10)||500))}))}),e.jsxs("small",{className:"muted",children:["Plugin option: ",e.jsx("code",{children:"backgroundToolCallCap"})]})]}),e.jsxs("div",{className:"form-row",children:[e.jsxs("label",{htmlFor:"bg-stallTimeout",children:["Stall timeout (ms)",e.jsx("span",{className:"meta-badge",children:"default: 180000"})]}),e.jsx("input",{id:"bg-stallTimeout",type:"number",min:1e4,max:6e5,step:1e3,value:p.backgroundStallTimeoutMs??18e4,onChange:h=>k(P=>({...P,backgroundStallTimeoutMs:Math.max(1e4,Math.min(6e5,parseInt(h.target.value,10)||18e4))}))}),e.jsxs("small",{className:"muted",children:["Plugin option: ",e.jsx("code",{children:"backgroundStallTimeoutMs"})]})]}),e.jsxs("div",{className:"form-row",children:[e.jsxs("label",{htmlFor:"bg-thinkingLoopTimeout",children:["Thinking-loop timeout (ms)",e.jsx("span",{className:"meta-badge",children:"default: 300000"})]}),e.jsx("input",{id:"bg-thinkingLoopTimeout",type:"number",min:3e4,max:9e5,step:1e3,value:p.backgroundThinkingLoopTimeoutMs??3e5,onChange:h=>k(P=>({...P,backgroundThinkingLoopTimeoutMs:Math.max(3e4,Math.min(9e5,parseInt(h.target.value,10)||3e5))}))}),e.jsxs("small",{className:"muted",children:["Plugin option: ",e.jsx("code",{children:"backgroundThinkingLoopTimeoutMs"})]})]}),e.jsxs("div",{className:"form-row",children:[e.jsxs("label",{htmlFor:"bg-maxInterventions",children:["Max interventions",e.jsx("span",{className:"meta-badge",children:"default: 1"})]}),e.jsx("input",{id:"bg-maxInterventions",type:"number",min:1,max:3,value:p.backgroundMaxInterventions??1,onChange:h=>k(P=>({...P,backgroundMaxInterventions:Math.max(1,Math.min(3,parseInt(h.target.value,10)||1))}))}),e.jsxs("small",{className:"muted",children:["Plugin option: ",e.jsx("code",{children:"backgroundMaxInterventions"})]})]}),e.jsxs("div",{className:"form-row",children:[e.jsxs(z,{variant:"secondary",size:"sm",onClick:async()=>{try{await A.put("/settings/plugin-options",p),a.success("Saved — restart opencode for changes to take effect.")}catch(h){a.error(`Save failed: ${h.message}`)}},children:[e.jsx(Ze,{size:14})," Save plugin options"]}),e.jsx(z,{variant:"secondary",size:"sm",onClick:async()=>{try{const P=await(await fetch("/api/background/cleanup",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({maxAgeDays:7})})).json();a.success(`Cleaned up ${P.deleted} old instances.`)}catch(h){a.error(`Cleanup failed: ${h.message}`)}},children:"Cleanup old instances (>7 days)"})]}),e.jsx("div",{className:"form-row",children:e.jsxs("small",{children:["Plugin options are read at startup. Save changes and run ",e.jsx("code",{children:"bizar update"})," to apply."]})})]})})]}),e.jsx("div",{"data-section":"system-llm",style:{display:g===null||g==="system-llm"?"block":"none"},children:e.jsxs(te,{id:"settings-system-llm","data-section":"system-llm",children:[e.jsxs(le,{children:[e.jsx(Te,{size:14})," System LLM API"]}),e.jsx(oe,{children:"Configures the LLM used for automatic title generation, prompt enhancement, summarization, and other system-level calls."}),e.jsxs("label",{className:"checkbox-row","data-setting-id":"systemLlm.enabled",children:[e.jsx("input",{type:"checkbox",checked:!!((T=i.systemLlm)!=null&&T.enabled),onChange:h=>{const P=i.systemLlm||{enabled:!0,provider:"opencode",model:"opencode/deepseek-v4-flash-free"};b("systemLlm",{...P,enabled:h.target.checked})}}),e.jsx("span",{children:"Enable system LLM calls"})]}),e.jsxs("div",{className:"field","data-setting-id":"systemLlm.provider",style:{marginTop:"var(--space-3)"},children:[e.jsx("label",{className:"field-label",htmlFor:"set-system-llm-provider",children:"Provider"}),e.jsxs("select",{id:"set-system-llm-provider",className:"select",value:((M=i.systemLlm)==null?void 0:M.provider)||"opencode",onChange:h=>{const P=i.systemLlm||{enabled:!0,provider:"opencode",model:"opencode/deepseek-v4-flash-free"};b("systemLlm",{...P,provider:h.target.value})},children:[e.jsx("option",{value:"opencode",children:"Opencode"}),e.jsx("option",{value:"openrouter",children:"OpenRouter"}),e.jsx("option",{value:"minimax",children:"MiniMax"})]})]}),e.jsxs("div",{className:"field","data-setting-id":"systemLlm.model",children:[e.jsx("label",{className:"field-label",htmlFor:"set-system-llm-model",children:"Model"}),e.jsx("input",{id:"set-system-llm-model",className:"input mono",type:"text",placeholder:"opencode/deepseek-v4-flash-free",value:((C=i.systemLlm)==null?void 0:C.model)||"opencode/deepseek-v4-flash-free",onChange:h=>{const P=i.systemLlm||{enabled:!0,provider:"opencode",model:"opencode/deepseek-v4-flash-free"};b("systemLlm",{...P,model:h.target.value})}}),e.jsxs("p",{className:"field-help",children:["The API key is read from ",e.jsx("code",{children:"auth.json"})," for the selected provider. Leave the default model for best results."]})]}),e.jsxs("div",{style:{marginTop:"var(--space-4)"},children:[e.jsx("h4",{style:{margin:"0 0 var(--space-2)"},children:"Features using this API"}),e.jsxs("ul",{className:"settings-feature-list",style:{margin:0,paddingLeft:"var(--space-4)",lineHeight:1.8},children:[e.jsx("li",{children:"Auto-title generation for new chat sessions"}),e.jsx("li",{children:"Auto-title generation for new tasks"}),e.jsx("li",{children:'"Enhance prompt" button in the task input'}),e.jsx("li",{children:'"Enhance prompt" button in the chat composer'}),e.jsx("li",{className:"muted",style:{fontSize:12},children:"Future: summarization, name generation, and more"})]})]})]})}),e.jsx(Il,{}),e.jsx("div",{style:{display:g===null||g==="activity-log"?"block":"none"},children:e.jsx("div",{"data-section":"activity-log",style:{display:g===null||g==="activity-log"?"block":"none"},children:e.jsx("section",{id:"settings-activity-log","data-section":"activity-log",className:"settings-section-wrap",children:e.jsx(Pl,{})})})}),e.jsx("div",{style:{display:g===null||g==="about"?"block":"none"},children:e.jsx("div",{"data-section":"about",style:{display:g===null||g==="about"?"block":"none"},children:e.jsxs(te,{id:"settings-about","data-section":"about",children:[e.jsxs(le,{children:[e.jsx(Ns,{size:14})," About"]}),e.jsx(oe,{children:"Build metadata."}),e.jsxs("dl",{className:"about-table",children:[e.jsx("dt",{children:"Version"}),e.jsx("dd",{className:"mono",children:K.version}),e.jsx("dt",{children:"Homepage"}),e.jsx("dd",{children:e.jsx("a",{href:K.homepage,target:"_blank",rel:"noopener noreferrer",children:K.homepage})}),e.jsx("dt",{children:"License"}),e.jsx("dd",{children:K.license})]})]})})})]})}function Pl(){const s=ce(),[t,a]=r.useState([]),[i,n]=r.useState(new Set),[c,d]=r.useState(!0),[l,x]=r.useState(""),[u,j]=r.useState(!0),m=r.useCallback(async()=>{d(!0);try{const[S,b]=await Promise.all([A.get("/activity"),A.get("/activity/hidden")]);a(Array.isArray(S.items)?S.items:[]),n(new Set(b.hidden||[]))}catch(S){s.error(`Load failed: ${S.message}`)}finally{d(!1)}},[s]);r.useEffect(()=>{m()},[m]);const o=(S,b)=>{const v=`${S.kind||""}|${S.ts||""}|${S.slug||""}|${b}`;let y=0;for(let $=0;$<v.length;$++)y=(y<<5)-y+v.charCodeAt($)|0;return Math.abs(y).toString(16).padStart(8,"0").slice(0,16)},p=async()=>{try{await A.del("/activity/hide"),n(new Set),s.success("All hidden activity restored.")}catch(S){s.error(`Restore failed: ${S.message}`)}},k=async S=>{try{await A.del(`/activity/hide/${encodeURIComponent(S)}`);const b=new Set(i);b.delete(S),n(b)}catch(b){s.error(`Restore failed: ${b.message}`)}},f=t.filter((S,b)=>{const v=o(S,b);if(!u&&i.has(v))return!1;if(!l)return!0;const y=l.toLowerCase();return[S.kind,S.slug,S.message].some($=>typeof $=="string"&&$.toLowerCase().includes(y))});return e.jsxs(te,{id:"settings-diagnostics","data-section":"diagnostics",children:[e.jsxs(le,{children:[e.jsx(ze,{size:14})," Activity log",e.jsxs("span",{className:"muted",style:{fontWeight:400,marginLeft:8,fontSize:12},children:[t.length," total · ",i.size," hidden"]}),e.jsx(z,{variant:"ghost",size:"sm",style:{marginLeft:"auto"},onClick:m,title:"Reload",children:e.jsx(de,{size:12})})]}),e.jsxs(oe,{children:["Full history from ",e.jsx("code",{children:"~/.bizar/activity.log"}),". Hiding an item in the Overview only hides it there — the entry stays here."]}),e.jsxs("div",{className:"activity-log-toolbar",children:[e.jsxs("div",{className:"activity-log-search",children:[e.jsx(Oe,{size:12}),e.jsx("input",{type:"text",className:"input",placeholder:"Filter by kind, slug, or message…",value:l,onChange:S=>x(S.target.value)})]}),e.jsxs("label",{className:"activity-log-toggle",children:[e.jsx("input",{type:"checkbox",checked:u,onChange:S=>j(S.target.checked)}),"Show hidden"]}),e.jsxs(z,{variant:"ghost",size:"sm",disabled:i.size===0,onClick:p,title:"Restore all hidden items to the Overview",children:[e.jsx(ls,{size:12})," Restore all"]})]}),c?e.jsx("div",{className:"muted",style:{padding:"12px 0",fontSize:12},children:"Loading…"}):f.length===0?e.jsx("div",{className:"muted",style:{padding:"12px 0",fontSize:12},children:t.length===0?"No activity yet.":"No items match the current filter."}):e.jsxs("div",{className:"activity-log-table-wrap",children:[e.jsxs("table",{className:"activity-log-table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Kind"}),e.jsx("th",{children:"Detail"}),e.jsx("th",{children:"Time"}),e.jsx("th",{})]})}),e.jsx("tbody",{children:f.slice(0,200).map((S,b)=>{const v=o(S,b),y=i.has(v);return e.jsxs("tr",{className:ae(y&&"activity-log-row-hidden"),children:[e.jsx("td",{className:"activity-log-kind",children:S.kind||"activity"}),e.jsx("td",{className:"activity-log-detail",children:S.message||S.slug||"—"}),e.jsx("td",{className:"activity-log-time mono",children:S.ts?new Date(S.ts).toLocaleString():"—"}),e.jsx("td",{children:y?e.jsx(z,{variant:"ghost",size:"sm",onClick:()=>k(v),title:"Restore to Overview",children:e.jsx(ls,{size:12})}):e.jsx("span",{className:"activity-log-state-tag",children:"shown"})})]},`${S.ts}-${b}`)})})]}),f.length>200&&e.jsxs("div",{className:"muted",style:{fontSize:11,padding:"8px 0"},children:["Showing first 200 of ",f.length,"."]})]})]})}function El({snapshot:s,refreshSnapshot:t}){const a=ce(),i=ke(),[n,c]=r.useState(Array.isArray(s.mods)?s.mods:[]),[d,l]=r.useState(!0),[x,u]=r.useState(null),[j,m]=r.useState([]),[o,p]=r.useState(null),[k,f]=r.useState(!1),[S,b]=r.useState(null),[v,y]=r.useState(!1),[$,g]=r.useState({}),B=async()=>{var w,I,_;y(!0);try{const W=await A.get("/mods/registry");b({source:((w=W.registry)==null?void 0:w.source)||"",version:(I=W.registry)==null?void 0:I.version,updatedAt:(_=W.registry)==null?void 0:_.updatedAt,mods:W.mods||[]})}catch(W){b({source:"",mods:[],error:W.message})}finally{y(!1)}},H=async w=>{g(I=>({...I,[w]:!0}));try{const I=await A.post("/mods",{id:w});c(_=>[..._.filter(W=>W.id!==I.id),I]),a.success(`Mod "${I.id}" installed from registry.`),await t()}catch(I){a.error(`Install failed: ${I.message}`)}finally{g(I=>({...I,[w]:!1}))}},R=async(w,I=!1)=>{g(_=>({..._,[w]:!0}));try{const _=await A.post(`/mods/${encodeURIComponent(w)}/upgrade`,{backup:I});c(X=>[...X.filter(ne=>ne.id!==_.mod.id),_.mod]);const W=_.backupPath?` (backup at ${_.backupPath})`:"";a.success(`Mod "${w}" upgraded v${_.from} → v${_.to}${W}.`),await t()}catch(_){a.error(`Upgrade failed: ${_.message}`)}finally{g(_=>({..._,[w]:!1}))}},J=async()=>{try{const w=await A.get("/mods");c(w.mods||[]);try{const I=await A.get("/mods/views");m(I.views||[])}catch{m([])}}catch(w){a.error(`Mods load failed: ${w.message}`)}finally{l(!1)}};r.useEffect(()=>{J()},[]),r.useEffect(()=>{Array.isArray(s.mods)&&s.mods!==n&&c(s.mods)},[s.mods]);const D=()=>{let w=null;i.open({title:"Install mod",children:e.jsxs("div",{children:[e.jsxs("p",{className:"muted",children:["Provide the absolute path to a mod folder (one that contains a ",e.jsx("code",{children:"mod.json"}),"). The folder will be copied to"," ",e.jsx("code",{children:"~/.config/bizar/mods/<id>/"}),"."]}),e.jsx("label",{className:"field-label",children:"Path"}),e.jsx("input",{ref:I=>w=I,className:"input",type:"text",placeholder:"/path/to/my-mod",autoFocus:!0})]}),footer:e.jsxs("div",{className:"modal-footer-actions",children:[e.jsx(z,{variant:"ghost",onClick:()=>i.close(),children:"Cancel"}),e.jsx(z,{variant:"primary",onClick:async()=>{const I=((w==null?void 0:w.value)||"").trim();if(!I){a.warning("Path is required.");return}try{const _=await A.post("/mods",{path:I});c(W=>[...W,_]),a.success(`Mod "${_.id}" installed.`),i.close(),await t()}catch(_){a.error(`Install failed: ${_.message}`)}},children:"Install"})]})})},L=async w=>{if(confirm(`Uninstall mod "${w}"? This removes the folder from ~/.config/bizar/mods/.`))try{await A.del(`/mods/${encodeURIComponent(w)}`),c(I=>I.filter(_=>_.id!==w)),x===w&&u(null),a.success("Mod uninstalled.")}catch(I){a.error(`Uninstall failed: ${I.message}`)}},V=async w=>{try{const I=await A.put(`/mods/${encodeURIComponent(w.id)}`,{enabled:!w.enabled});c(_=>_.map(W=>W.id===w.id?I:W)),a.success(`Mod ${I.enabled?"enabled":"disabled"}.`)}catch(I){a.error(`Toggle failed: ${I.message}`)}},K=n.find(w=>w.id===x)||null;return d?e.jsx("div",{className:"view-loading",children:e.jsx(je,{size:"lg"})}):e.jsxs("div",{className:"view view-mods",children:[e.jsxs("header",{className:"view-header",children:[e.jsxs("div",{className:"view-header-text",children:[e.jsxs("h2",{className:"view-title",children:[e.jsx(ys,{size:18})," Mods (",n.length,")"]}),e.jsxs("p",{className:"view-subtitle",children:["Extensions installed in ",e.jsx("code",{children:"~/.config/bizar/mods/"}),". Mods can add agents, commands, routes, and views."]})]}),e.jsxs("div",{className:"view-actions",children:[e.jsxs(z,{variant:"secondary",size:"sm",onClick:J,children:[e.jsx(de,{size:14})," Refresh"]}),e.jsxs(z,{variant:"primary",size:"sm",onClick:D,children:[e.jsx(pe,{size:14})," Install mod"]})]})]}),n.length===0?e.jsx(Ie,{icon:e.jsx(ys,{size:32}),title:"No mods installed",message:"Mods are folders with a mod.json. Install one to extend Bizar with custom agents, commands, and views."}):e.jsxs("div",{className:"mods-layout",children:[e.jsx("div",{className:"mods-list",children:n.map(w=>e.jsxs("div",{className:ae("mod-list-item",x===w.id&&"mod-list-item-active"),onClick:()=>u(w.id),children:[e.jsxs("div",{className:"mod-list-item-head",children:[e.jsxs("div",{children:[e.jsx("div",{className:"mod-list-item-name",children:w.name}),e.jsxs("div",{className:"mod-list-item-meta",children:["v",w.version," · ",w.type," · ",w.author]})]}),e.jsxs("div",{className:"mod-list-item-actions",onClick:I=>I.stopPropagation(),children:[e.jsx("button",{type:"button",className:"icon-btn","aria-label":"Toggle enabled",title:w.enabled?"Disable":"Enable",onClick:()=>V(w),children:e.jsx(Ws,{size:12})}),e.jsx("button",{type:"button",className:"icon-btn icon-btn-danger","aria-label":"Uninstall",title:"Uninstall",onClick:()=>L(w.id),children:e.jsx(ye,{size:12})})]})]}),e.jsx("div",{className:"mod-list-item-desc ellipsis-2",title:w.description,children:w.description}),e.jsx("div",{className:"mod-list-item-status",children:e.jsx("span",{className:`mod-mini-pill ${w.enabled?"mod-mini-pill-on":"mod-mini-pill-off"}`,children:w.enabled?"enabled":"disabled"})})]},w.id))}),K&&e.jsx(Bl,{mod:K})]}),e.jsxs(te,{className:"mods-registry-card",children:[e.jsxs("div",{className:"mods-registry-head",onClick:()=>{!S&&!v&&B(),f(w=>!w)},children:[e.jsx(rs,{size:14}),e.jsx("span",{className:"mods-registry-title",children:"Mod registry"}),e.jsx("span",{className:"muted",style:{fontSize:11},children:S!=null&&S.mods?`${S.mods.length} available`:"click to browse"}),e.jsx("span",{className:"mods-registry-spacer"}),k?e.jsx(Ae,{size:14}):e.jsx(He,{size:14})]}),k&&e.jsx("div",{className:"mods-registry-body",children:v?e.jsx("div",{className:"muted",style:{padding:12,fontSize:12},children:"Loading registry…"}):S!=null&&S.error?e.jsxs("div",{className:"mods-registry-error",children:[e.jsx(es,{size:12})," Could not load registry: ",S.error]}):!S||S.mods.length===0?e.jsx("div",{className:"muted",style:{padding:12,fontSize:12},children:"No mods listed in the registry yet."}):e.jsxs(e.Fragment,{children:[S.source&&e.jsxs("div",{className:"muted",style:{fontSize:11,marginBottom:8},children:["Source: ",e.jsx("code",{children:S.source})]}),e.jsx("div",{className:"mods-registry-grid",children:S.mods.map(w=>{const I=n.some(W=>W.id===w.id),_=!!$[w.id];return e.jsxs("div",{className:"mod-registry-card",children:[e.jsxs("div",{className:"mod-registry-card-head",children:[e.jsx("div",{className:"mod-registry-card-name",children:w.name}),w.latest&&e.jsxs("span",{className:ae("mod-registry-version",w.upgradeAvailable&&"mod-registry-version-upgrade"),children:["v",w.latest,w.upgradeAvailable?" ↑":""]})]}),w.description&&e.jsx("div",{className:"mod-registry-card-desc",children:w.description}),e.jsxs("div",{className:"mod-registry-card-meta",children:[w.author&&e.jsxs("span",{className:"muted",children:["by ",w.author]}),w.homepage&&e.jsx("a",{href:w.homepage,target:"_blank",rel:"noopener noreferrer",className:"mod-registry-link",children:"homepage"})]}),(w.permissions||[]).length>0&&e.jsxs("div",{className:"mod-registry-perms",children:[e.jsx(es,{size:10}),(w.permissions||[]).slice(0,4).map(W=>e.jsx("span",{className:"mod-registry-perm",children:W},W)),(w.permissions||[]).length>4&&e.jsxs("span",{className:"mod-registry-perm-more",children:["+",w.permissions.length-4]})]}),e.jsxs("div",{className:"mod-registry-card-actions",children:[!I&&e.jsx(z,{variant:"primary",size:"sm",disabled:_,onClick:()=>H(w.id),title:"Install from registry",children:_?e.jsx(je,{size:"sm"}):e.jsxs(e.Fragment,{children:[e.jsx(Le,{size:12})," Install"]})}),I&&w.upgradeAvailable&&e.jsx(z,{variant:"primary",size:"sm",disabled:_,onClick:()=>R(w.id),title:`Upgrade from v${w.installedVersion||"?"} to v${w.upgradeAvailable}`,children:_?e.jsx(je,{size:"sm"}):e.jsxs(e.Fragment,{children:[e.jsx(Le,{size:12})," Upgrade to v",w.upgradeAvailable]})}),I&&!w.upgradeAvailable&&e.jsxs(z,{variant:"ghost",size:"sm",disabled:!0,title:`Installed v${w.installedVersion||"?"}`,children:["Installed v",w.installedVersion||"?"]})]})]},w.id)})})]})})]}),j.length>0&&e.jsxs(te,{className:"mod-views-hint",children:[e.jsxs(le,{children:[e.jsx(rs,{size:14})," Mod views"]}),e.jsxs(oe,{children:[j.length," mod-supplied view",j.length===1?"":"s"," are now available in the sidebar navigation. Look for the ",e.jsx("strong",{children:"Mods"})," section at the bottom of the sidebar."]})]}),o&&e.jsxs("div",{className:"mod-iframe-panel",children:[e.jsxs("div",{className:"mod-iframe-header",children:[e.jsxs("span",{children:["Mod view — ",e.jsx("a",{href:o,target:"_blank",rel:"noreferrer",children:o})]}),e.jsx("button",{type:"button",className:"icon-btn","aria-label":"Close iframe",onClick:()=>p(null),children:e.jsx($e,{size:14})})]}),e.jsx("iframe",{src:o,className:"mod-iframe",title:"Mod view",sandbox:"allow-scripts allow-same-origin allow-forms allow-popups"})]})]})}function Bl({mod:s}){const t=ce(),[a,i]=r.useState(null),[n,c]=r.useState(!1),[d,l]=r.useState(!1),[x,u]=r.useState(null),j=async()=>{c(!0);try{const o=await A.get(`/mods/${s.id}/instructions`);i(o),l(!0)}catch(o){t.error(`Failed to load instructions: ${o.message}`)}finally{c(!1)}},m=async()=>{try{const o=await A.post(`/mods/${s.id}/instructions/reinstall`,{});t.success(`Reinstalled: ${o.counts.agents} agents, ${o.counts.commands} commands, ${o.counts.skills} skills, ${o.counts.instructions} instructions.`),await j()}catch(o){t.error(`Reinstall failed: ${o.message}`)}};return e.jsxs(te,{className:"mod-details",children:[e.jsxs(le,{children:[e.jsx(ws,{size:14})," Mod details — ",s.name]}),e.jsx(oe,{children:e.jsx("code",{children:s.path})}),e.jsxs("dl",{className:"env-table",children:[e.jsx("dt",{children:"ID"}),e.jsx("dd",{className:"mono",children:s.id}),e.jsx("dt",{children:"Version"}),e.jsx("dd",{className:"mono",children:s.version}),e.jsx("dt",{children:"Type"}),e.jsx("dd",{className:"mono",children:s.type}),e.jsx("dt",{children:"Author"}),e.jsx("dd",{className:"mono",children:s.author||"—"}),e.jsx("dt",{children:"Bizar"}),e.jsx("dd",{className:"mono",children:s.bizar||"*"}),e.jsx("dt",{children:"Enabled"}),e.jsx("dd",{children:s.enabled?"yes":"no"}),e.jsx("dt",{children:"Permissions"}),e.jsxs("dd",{children:[(s.permissions||[]).map(o=>e.jsx("span",{className:"tag",children:o},o)),(s.permissions||[]).length===0&&e.jsx("span",{className:"muted",children:"(none)"})]})]}),e.jsxs("div",{className:"mod-files",children:[e.jsx("div",{className:"muted",children:"Files"}),e.jsx("ul",{children:(s.files||[]).map(o=>e.jsxs("li",{children:[e.jsx("span",{className:"mod-file-cat",children:o.category}),e.jsx("span",{className:"mono",children:o.path})]},o.path))})]}),e.jsxs("div",{className:"mod-instructions",children:[e.jsxs("div",{className:"mod-instructions-head",onClick:()=>{!a&&!n&&j(),l(o=>!o)},children:[e.jsx(Ea,{size:14}),e.jsx("span",{children:"Installed instructions"}),e.jsx("span",{className:"muted",style:{fontSize:11},children:a?`${a.total} files`:"click to view"}),e.jsx("span",{className:"mod-instructions-spacer"}),d?e.jsx(Ae,{size:14}):e.jsx(He,{size:14})]}),d&&a&&e.jsxs("div",{className:"mod-instructions-body",children:[a.agents.length>0&&e.jsxs("div",{className:"mod-instructions-section",children:[e.jsxs("div",{className:"mod-instructions-section-title",children:[e.jsx(dn,{size:11})," Agents (",a.agents.length,")"]}),a.agents.map(o=>e.jsxs("div",{className:"mod-instructions-file",children:[e.jsxs("div",{className:"mod-instructions-file-head",onClick:()=>u(p=>p===o.filename?null:o.filename),children:[e.jsx("span",{className:"mono",children:o.filename}),e.jsxs("span",{className:"muted",style:{fontSize:10},children:["installed at ",o.fullPath]})]}),x===o.filename&&e.jsx("pre",{className:"mod-instructions-content",children:o.content||e.jsx("em",{className:"muted",children:"(file missing on disk)"})})]},o.filename))]}),a.commands.length>0&&e.jsxs("div",{className:"mod-instructions-section",children:[e.jsxs("div",{className:"mod-instructions-section-title",children:[e.jsx(is,{size:11})," Commands (",a.commands.length,")"]}),a.commands.map(o=>e.jsxs("div",{className:"mod-instructions-file",children:[e.jsxs("div",{className:"mod-instructions-file-head",onClick:()=>u(p=>p===o.filename?null:o.filename),children:[e.jsx("span",{className:"mono",children:o.filename}),e.jsxs("span",{className:"muted",style:{fontSize:10},children:["installed at ",o.fullPath]})]}),x===o.filename&&e.jsx("pre",{className:"mod-instructions-content",children:o.content||e.jsx("em",{className:"muted",children:"(file missing on disk)"})})]},o.filename))]}),a.skills.length>0&&e.jsxs("div",{className:"mod-instructions-section",children:[e.jsxs("div",{className:"mod-instructions-section-title",children:[e.jsx(ka,{size:11})," Skills (",a.skills.length,")"]}),a.skills.map(o=>e.jsxs("div",{className:"mod-instructions-file",children:[e.jsxs("div",{className:"mod-instructions-file-head",onClick:()=>u(p=>p===o.name?null:o.name),children:[e.jsx("span",{className:"mono",children:o.name}),e.jsxs("span",{className:"muted",style:{fontSize:10},children:["installed at ",o.fullPath]})]}),x===o.name&&e.jsx("pre",{className:"mod-instructions-content",children:o.content||e.jsx("em",{className:"muted",children:"(file missing on disk)"})})]},o.name))]}),a.total===0&&e.jsxs("div",{className:"muted",style:{padding:8,fontSize:12},children:["This mod did not install any instruction files. Mods install instructions by shipping a top-level ",e.jsx("code",{children:"INSTRUCTIONS.md"}),", an ",e.jsx("code",{children:"agents/"})," directory, a ",e.jsx("code",{children:"commands/"})," directory, or a ",e.jsx("code",{children:"skills/"})," directory."]}),e.jsx("div",{className:"mod-instructions-actions",children:e.jsxs(z,{variant:"ghost",size:"sm",onClick:m,children:[e.jsx(de,{size:11})," Reinstall from mod folder"]})})]})]})]})}function Ol({viewId:s,reloadKey:t,setActiveTab:a}){const i=ce(),[n,c]=r.useState(null),[d,l]=r.useState(!0),[x,u]=r.useState(0);if(r.useEffect(()=>{let j=!1;return(async()=>{try{const m=await A.get("/mods/views");if(j)return;const o=(m.views||[]).find(p=>p.id===s);c(o||null)}catch(m){i.error(`Failed to load mod view: ${m.message}`)}finally{j||l(!1)}})(),()=>{j=!0}},[s,i]),d)return e.jsx(Ie,{title:"Loading mod view…"});if(!n)return e.jsx(Ie,{title:"Mod view not found",message:`No view with id "${s}" is currently installed.`,action:e.jsx(z,{onClick:()=>a("mods"),variant:"primary",size:"sm",children:"Open Mods"})});if(n.kind==="iframe"){const j=`/api/mods/${n.modId}/web/index.html?t=${x+(t||0)}`;return e.jsxs("div",{className:"mod-view-iframe-pane",children:[e.jsxs("div",{className:"mod-view-iframe-header",children:[e.jsxs("span",{className:"mod-view-iframe-label",children:[e.jsx(rs,{size:14}),n.label,e.jsxs("span",{className:"muted",style:{fontSize:11,fontWeight:400},children:["by ",n.modId]})]}),e.jsxs("div",{className:"mod-view-iframe-actions",children:[e.jsxs(z,{variant:"ghost",size:"sm",onClick:()=>u(m=>m+1),title:"Reload this view",children:[e.jsx(de,{size:11})," Reload"]}),e.jsx("a",{href:j,target:"_blank",rel:"noopener noreferrer",className:"icon-btn",title:"Open in new tab",children:e.jsx(Ks,{size:12})})]})]}),e.jsx("iframe",{src:j,className:"mod-view-iframe",title:n.label},x+(t||0))]})}if(n.component){const j=n.component,m=n.modId,o=r.lazy(()=>Na(()=>import(`/api/mods/${encodeURIComponent(m)}/views/${encodeURIComponent(j)}`),[]).then(p=>({default:p.default??(()=>null)})));return e.jsxs("div",{className:"mod-view-tab-pane",children:[e.jsx("div",{className:"mod-view-iframe-header",children:e.jsxs("span",{className:"mod-view-iframe-label",children:[e.jsx(Bs,{size:14}),n.label,e.jsxs("span",{className:"muted",style:{fontSize:11,fontWeight:400},children:["by ",n.modId]})]})}),e.jsx("div",{className:"mod-view-tab-body",children:e.jsx(Fl,{modId:n.modId,component:n.component,children:e.jsx(r.Suspense,{fallback:e.jsxs("div",{style:{padding:24},children:[e.jsx(je,{size:"md"})," ",e.jsx("span",{className:"muted",children:"Loading mod view…"})]}),children:e.jsx(o,{})})})})]})}return e.jsxs(te,{children:[e.jsxs(le,{children:[e.jsx(Bs,{size:14})," ",n.label]}),e.jsxs(oe,{children:["by ",n.modId]}),n.description&&e.jsx("p",{className:"muted",style:{marginTop:8},children:n.description}),e.jsxs("p",{className:"muted",style:{fontSize:12,marginTop:12},children:["This mod declared a tab view but did not provide a component path in views/registry.json. Add a ",e.jsx("code",{children:"component"})," field (e.g. ",e.jsx("code",{children:'"MyView.js"'}),") and ship the file under ",e.jsx("code",{children:"views/"}),"."]}),e.jsx("div",{style:{marginTop:12},children:e.jsx(z,{variant:"secondary",size:"sm",onClick:()=>a("mods"),children:"Open Mods page"})})]})}class Fl extends r.Component{constructor(){super(...arguments);zs(this,"state",{error:null})}static getDerivedStateFromError(a){return{error:a}}componentDidCatch(){}render(){return this.state.error?e.jsxs("div",{className:"mod-view-error",children:[e.jsx(De,{size:16}),e.jsx("strong",{children:"Failed to render mod view"}),e.jsxs("div",{className:"muted",style:{fontSize:12,marginTop:6},children:[this.props.modId," → ",this.props.component,": ",this.state.error.message]})]}):this.props.children}}const Ul=["interval","cron","once"],Hl=["command","agent","webhook"],_s=[{value:"UTC",label:"UTC"},{value:"America/New_York",label:"America/New_York (ET)"},{value:"America/Los_Angeles",label:"America/Los_Angeles (PT)"},{value:"America/Chicago",label:"America/Chicago (CT)"},{value:"Europe/London",label:"Europe/London (UK)"},{value:"Europe/Berlin",label:"Europe/Berlin (CET)"},{value:"Asia/Tokyo",label:"Asia/Tokyo (JST)"}],ql=Array.from({length:12},(s,t)=>t*5),Zs=Array.from({length:24},(s,t)=>({value:t,label:t===0?"12 AM":t<12?`${t} AM`:t===12?"12 PM":`${t-12} PM`})),et=[{value:"*",label:"Every day"},{value:"0",label:"Sunday"},{value:"1",label:"Monday"},{value:"2",label:"Tuesday"},{value:"3",label:"Wednesday"},{value:"4",label:"Thursday"},{value:"5",label:"Friday"},{value:"6",label:"Saturday"}],Ut=[{value:"s",label:"seconds"},{value:"m",label:"minutes"},{value:"h",label:"hours"},{value:"d",label:"days"}];function Ht(s){if(typeof s!="string")return null;const t=s.trim().split(/\s+/);if(t.length!==5)return null;const[a,i,,,n]=t,c=parseInt(a,10),d=parseInt(i,10);if(!Number.isFinite(c)||!Number.isFinite(d)||a!==String(c)||i!==String(d))return null;const l=n==="*"?"*":parseInt(n,10);return l===null||n!=="*"&&!Number.isFinite(l)?null:{minute:c,hour:d,dow:n==="*"?"*":String(l)}}function _l(s){if(typeof s!="string")return null;const t=/^(\d+)\s*([smhd])$/i.exec(s.trim());return t?{n:parseInt(t[1],10),unit:t[2].toLowerCase()}:null}function Vl(s){var c,d;if(!s)return{name:"",type:"cron",cronMinute:0,cronHour:13,cronDow:"0",showAdvanced:!1,rawCron:"0 13 * * 0",intervalN:30,intervalUnit:"m",onceAt:"",timezone:"UTC",customTimezone:"",actionType:"agent",actionTarget:"",actionPrompt:"",skipIfBudgetLow:!1,maxConcurrent:6,enabled:!0,humanLabel:""};const t=s.type==="cron"?Ht(s.schedule):null,a=s.type==="interval"?_l(s.schedule):null,i=s.timezone||"UTC",n=_s.some(l=>l.value===i);return{name:s.name||"",type:s.type,cronMinute:(t==null?void 0:t.minute)??0,cronHour:(t==null?void 0:t.hour)??9,cronDow:(t==null?void 0:t.dow)??"*",showAdvanced:!t,rawCron:s.schedule,intervalN:(a==null?void 0:a.n)??30,intervalUnit:(a==null?void 0:a.unit)??"m",onceAt:s.type==="once"?Wl(s.schedule):"",timezone:n?i:"Other…",customTimezone:n?"":i,actionType:s.action.type,actionTarget:s.action.target||"",actionPrompt:s.action.prompt||"",skipIfBudgetLow:!!((c=s.budgetCheck)!=null&&c.skipIfBudgetLow),maxConcurrent:Number.isFinite((d=s.budgetCheck)==null?void 0:d.maxConcurrent)?s.budgetCheck.maxConcurrent:6,enabled:s.enabled!==!1,humanLabel:""}}function Wl(s){if(!s)return"";try{const t=new Date(s);if(Number.isNaN(t.getTime()))return"";const a=i=>String(i).padStart(2,"0");return`${t.getFullYear()}-${a(t.getMonth()+1)}-${a(t.getDate())}T${a(t.getHours())}:${a(t.getMinutes())}`}catch{return""}}function Kl(s){var a,i,n;if(s.type==="cron"){if(s.showAdvanced)return{schedule:s.rawCron.trim(),humanLabel:s.humanLabel||s.rawCron.trim()};const c=`${s.cronMinute} ${s.cronHour} * * ${s.cronDow}`,d=((a=et.find(j=>j.value===s.cronDow))==null?void 0:a.label)||"",l=((i=Zs.find(j=>j.value===s.cronHour))==null?void 0:i.label)||`${s.cronHour}`,x=String(s.cronMinute).padStart(2,"0"),u=d==="Every day"?`Every day at ${l.replace(" ","")} (min ${x})`:`Every ${d} at ${l.replace(" ","")} (min ${x})`;return{schedule:c,humanLabel:s.humanLabel||u}}if(s.type==="interval"){const c=((n=Ut.find(l=>l.value===s.intervalUnit))==null?void 0:n.label)||s.intervalUnit;return{schedule:`${s.intervalN}${s.intervalUnit}`,humanLabel:s.humanLabel||`Every ${s.intervalN} ${c}`}}return s.onceAt?{schedule:new Date(s.onceAt).toISOString(),humanLabel:s.humanLabel||new Date(s.onceAt).toLocaleString()}:{schedule:"",humanLabel:s.humanLabel||""}}function Gl({snapshot:s,refreshSnapshot:t}){var o;const a=ce(),i=ke(),[n,c]=r.useState(s.schedules||[]),[d,l]=r.useState(!s.schedules),x=async()=>{try{const p=await A.get("/projects/active/schedules");c(p.schedules||[])}catch(p){a.error(`Schedules load failed: ${p.message}`)}finally{l(!1)}};r.useEffect(()=>{var p;if((p=s.schedules)!=null&&p.length||s.schedules){c(s.schedules||[]),l(!1);return}x()},[s.schedules]);const u=p=>{i.open({title:p?`Edit schedule: ${p.name}`:"New schedule",width:640,children:e.jsx(Yl,{initial:p,onClose:i.close,onSubmitted:async k=>{c(f=>{const S=f.findIndex(v=>v.id===k.id);if(S===-1)return[...f,k];const b=f.slice();return b[S]=k,b}),a.success(p?"Schedule updated.":"Schedule created."),i.close(),await t()},onError:k=>a.error(k)})})},j=async p=>{var k;try{const f=await A.post(`/schedules/${encodeURIComponent(p.id)}/run`);a.success(f.ok?"Schedule ran.":`Run failed: ${((k=f.runResult)==null?void 0:k.error)||"unknown"}`),await x()}catch(f){a.error(`Run failed: ${f.message}`)}},m=async p=>{if(confirm(`Delete schedule "${p.name}"?`))try{await A.del(`/schedules/${encodeURIComponent(p.id)}`),c(k=>k.filter(f=>f.id!==p.id)),a.success("Schedule deleted.")}catch(k){a.error(`Delete failed: ${k.message}`)}};return d?e.jsx("div",{className:"view-loading",children:e.jsx(je,{size:"lg"})}):e.jsxs("div",{className:"view view-schedules",children:[e.jsxs("header",{className:"view-header",children:[e.jsxs("div",{className:"view-header-text",children:[e.jsxs("h2",{className:"view-title",children:[e.jsx(Xe,{size:18})," Schedules (",n.length,")"]}),e.jsxs("p",{className:"view-subtitle",children:["Recurring tasks for the active project: ",e.jsx("strong",{children:((o=s.activeProject)==null?void 0:o.name)||"(none)"}),". Service daemon runs them at the right time."]})]}),e.jsxs("div",{className:"view-actions",children:[e.jsxs(z,{variant:"secondary",size:"sm",onClick:x,children:[e.jsx(de,{size:14})," Refresh"]}),e.jsxs(z,{variant:"primary",size:"sm",onClick:()=>u(),children:[e.jsx(pe,{size:14})," New schedule"]})]})]}),n.length===0?e.jsx(Ie,{icon:e.jsx(Xe,{size:32}),title:"No schedules",message:s.activeProject?"Add a schedule to run commands, webhooks, or agent tasks on a cron / interval / one-shot basis.":"Activate a project first to scope schedules."}):e.jsx("div",{className:"schedule-grid",children:n.map(p=>{var k;return e.jsxs(te,{className:"schedule-card",children:[e.jsxs("div",{className:"schedule-card-head",children:[e.jsxs("div",{children:[e.jsx(le,{children:p.name}),e.jsxs(oe,{children:[e.jsx("code",{children:p.type})," ·"," ",e.jsx("span",{title:p.schedule,children:Jl(p)||p.schedule}),p.timezone&&p.timezone!=="UTC"?e.jsxs(e.Fragment,{children:[" · ",e.jsx("code",{children:p.timezone})]}):null," · ",e.jsx("span",{className:p.enabled?"status-on":"status-neutral",children:p.enabled?"enabled":"disabled"})]})]}),e.jsxs("div",{className:"schedule-card-actions",children:[e.jsxs(z,{variant:"secondary",size:"sm",onClick:()=>u(p),children:[e.jsx(ds,{size:12})," Edit"]}),e.jsxs(z,{variant:"secondary",size:"sm",onClick:()=>j(p),children:[e.jsx(Es,{size:12})," Run now"]}),e.jsx("button",{type:"button",className:"icon-btn icon-btn-danger","aria-label":"Delete",title:"Delete",onClick:()=>m(p),children:e.jsx(ye,{size:12})})]})]}),e.jsxs("div",{className:"schedule-card-action",children:[e.jsx("span",{className:"muted",children:"action:"})," ",e.jsxs("code",{children:[p.action.type," ",p.action.target]}),p.action.type==="agent"&&p.action.prompt&&e.jsxs("div",{className:"schedule-card-prompt",children:[e.jsx("span",{className:"muted",children:"prompt:"})," ",p.action.prompt]})]}),((k=p.budgetCheck)==null?void 0:k.skipIfBudgetLow)&&e.jsxs("div",{className:"schedule-card-budget",children:[e.jsx("span",{className:"muted",children:"budget gate:"})," ","skip if concurrent ≥ ",p.budgetCheck.maxConcurrent??6]}),e.jsxs("div",{className:"schedule-card-times",children:[e.jsxs("div",{children:[e.jsx("span",{className:"muted",children:"last"})," ",p.lastRun?ve(p.lastRun):"—",p.lastResult&&e.jsx("span",{className:`tag ${xt(p.lastResult)}`,children:p.lastResult}),p.lastError&&e.jsxs("span",{className:"muted schedule-card-error",title:p.lastError,children:[" ","— ",gt(p.lastError,80)]})]}),e.jsxs("div",{children:[e.jsx("span",{className:"muted",children:"next"})," ",p.nextRun?e.jsx("span",{title:new Date(p.nextRun).toISOString(),children:Xl(p.nextRun,p.timezone)}):"—",p.nextRun&&e.jsxs("span",{className:"muted",children:[" · ",ve(p.nextRun)]})]})]}),p.history&&p.history.length>0&&e.jsxs("details",{className:"schedule-card-history",children:[e.jsxs("summary",{children:[e.jsx(ns,{size:12})," ",p.history.length," run",p.history.length===1?"":"s"]}),e.jsx("ul",{children:p.history.slice(-10).reverse().map((f,S)=>e.jsxs("li",{children:[e.jsx("span",{className:"tabular-nums muted",children:ve(f.ts)})," ",e.jsx("span",{className:`tag ${xt(f.result)}`,children:f.result}),f.error&&e.jsxs("span",{className:"muted",children:[" — ",gt(f.error,80)]})]},S))})]})]},p.id)})})]})}function Yl({initial:s,onClose:t,onSubmitted:a,onError:i}){const[n,c]=r.useState(()=>Vl(s)),[d,l]=r.useState(!1),x=r.useMemo(()=>_s.some(m=>m.value===n.timezone)?n.timezone:"Other…",[n.timezone]),u=(m,o)=>{c(p=>({...p,[m]:o}))},j=async m=>{m.preventDefault();const o=n.name.trim();if(!o){i("Name is required.");return}const p=Kl(n);if(!p.schedule){i("Schedule value is required.");return}if(!n.actionTarget.trim()){i("Action target is required.");return}const k=n.timezone==="Other…"?n.customTimezone.trim():n.timezone,f={type:n.actionType,target:n.actionTarget.trim()};n.actionType==="agent"&&n.actionPrompt.trim()&&(f.prompt=n.actionPrompt.trim());const S={name:o,type:n.type,schedule:p.schedule,timezone:k||"UTC",action:f,budgetCheck:{maxConcurrent:n.maxConcurrent,skipIfBudgetLow:n.skipIfBudgetLow},enabled:n.enabled};l(!0);try{const b=s?await A.put(`/schedules/${encodeURIComponent(s.id)}`,S):await A.post("/schedules",S);await a(b)}catch(b){i(`${s?"Update":"Create"} failed: ${b.message}`)}finally{l(!1)}};return e.jsxs("form",{className:"schedule-form",onSubmit:j,children:[e.jsx("label",{className:"field-label",children:"Name"}),e.jsx("input",{className:"input",type:"text",placeholder:"Weekly code review",value:n.name,onChange:m=>u("name",m.target.value),autoFocus:!0}),e.jsx("div",{className:"task-form-row",children:e.jsxs("div",{className:"task-form-field",children:[e.jsx("label",{className:"field-label",children:"Type"}),e.jsx("select",{className:"select",value:n.type,onChange:m=>u("type",m.target.value),children:Ul.map(m=>e.jsx("option",{value:m,children:m},m))})]})}),n.type==="cron"&&e.jsxs("div",{className:"schedule-cron-group",children:[!n.showAdvanced&&e.jsx(e.Fragment,{children:e.jsxs("div",{className:"task-form-row",children:[e.jsxs("div",{className:"task-form-field",children:[e.jsx("label",{className:"field-label",children:"Day of week"}),e.jsx("select",{className:"select",value:n.cronDow,onChange:m=>u("cronDow",m.target.value),children:et.map(m=>e.jsx("option",{value:m.value,children:m.label},m.value))})]}),e.jsxs("div",{className:"task-form-field",children:[e.jsx("label",{className:"field-label",children:"Hour"}),e.jsx("select",{className:"select",value:String(n.cronHour),onChange:m=>u("cronHour",parseInt(m.target.value,10)),children:Zs.map(m=>e.jsx("option",{value:String(m.value),children:m.label},m.value))})]}),e.jsxs("div",{className:"task-form-field",children:[e.jsx("label",{className:"field-label",children:"Minute"}),e.jsx("select",{className:"select",value:String(n.cronMinute),onChange:m=>u("cronMinute",parseInt(m.target.value,10)),children:ql.map(m=>e.jsx("option",{value:String(m),children:String(m).padStart(2,"0")},m))})]})]})}),n.showAdvanced&&e.jsxs("div",{className:"task-form-field",children:[e.jsx("label",{className:"field-label",children:"Cron expression"}),e.jsx("input",{className:"input",type:"text",value:n.rawCron,onChange:m=>u("rawCron",m.target.value),placeholder:"0 13 * * 0"})]}),e.jsxs("button",{type:"button",className:"link-btn",onClick:()=>u("showAdvanced",!n.showAdvanced),children:[e.jsx(Ae,{size:12,style:{transform:n.showAdvanced?"rotate(180deg)":"none",transition:"transform 0.15s"}}),n.showAdvanced?"Hide advanced":"Advanced (raw cron)"]})]}),n.type==="interval"&&e.jsxs("div",{className:"task-form-row",children:[e.jsxs("div",{className:"task-form-field",style:{flex:1},children:[e.jsx("label",{className:"field-label",children:"Every"}),e.jsx("input",{className:"input",type:"number",min:1,value:n.intervalN,onChange:m=>u("intervalN",parseInt(m.target.value,10)||1)})]}),e.jsxs("div",{className:"task-form-field",style:{flex:1},children:[e.jsx("label",{className:"field-label",children:"Unit"}),e.jsx("select",{className:"select",value:n.intervalUnit,onChange:m=>u("intervalUnit",m.target.value),children:Ut.map(m=>e.jsx("option",{value:m.value,children:m.label},m.value))})]})]}),n.type==="once"&&e.jsxs("div",{className:"task-form-field",children:[e.jsx("label",{className:"field-label",children:"Run at"}),e.jsx("input",{className:"input",type:"datetime-local",value:n.onceAt,onChange:m=>u("onceAt",m.target.value)})]}),e.jsxs("div",{className:"task-form-row",children:[e.jsxs("div",{className:"task-form-field",style:{flex:1},children:[e.jsx("label",{className:"field-label",children:"Timezone"}),e.jsxs("select",{className:"select",value:x,onChange:m=>u("timezone",m.target.value),children:[_s.map(m=>e.jsx("option",{value:m.value,children:m.label},m.value)),e.jsx("option",{value:"Other…",children:"Other…"})]})]}),n.timezone==="Other…"&&e.jsxs("div",{className:"task-form-field",style:{flex:1},children:[e.jsx("label",{className:"field-label",children:"IANA name"}),e.jsx("input",{className:"input",type:"text",placeholder:"Europe/Paris",value:n.customTimezone,onChange:m=>u("customTimezone",m.target.value)})]})]}),e.jsxs("div",{className:"task-form-row",children:[e.jsxs("div",{className:"task-form-field",children:[e.jsx("label",{className:"field-label",children:"Action"}),e.jsx("select",{className:"select",value:n.actionType,onChange:m=>u("actionType",m.target.value),children:Hl.map(m=>e.jsx("option",{value:m,children:m},m))})]}),e.jsxs("div",{className:"task-form-field",style:{flex:2},children:[e.jsx("label",{className:"field-label",children:"Target"}),e.jsx("input",{className:"input",type:"text",placeholder:n.actionType==="webhook"?"https://...":n.actionType==="agent"?"agent name or task ref":"echo hi",value:n.actionTarget,onChange:m=>u("actionTarget",m.target.value)})]})]}),n.actionType==="agent"&&e.jsxs("div",{className:"task-form-field",children:[e.jsx("label",{className:"field-label",children:"Prompt (what to send the agent)"}),e.jsx("textarea",{className:"input",rows:3,placeholder:"Review open PRs for stale code review comments and nudge reviewers.",value:n.actionPrompt,onChange:m=>u("actionPrompt",m.target.value)})]}),e.jsxs("fieldset",{className:"schedule-budget-card",children:[e.jsx("legend",{children:"Budget pre-flight"}),e.jsxs("label",{className:"checkbox-row",children:[e.jsx("input",{type:"checkbox",checked:n.skipIfBudgetLow,onChange:m=>u("skipIfBudgetLow",m.target.checked)}),e.jsx("span",{children:"Skip this run when too many background tasks are already running."})]}),e.jsxs("div",{className:"task-form-field",children:[e.jsx("label",{className:"field-label",children:"Max concurrent bg tasks"}),e.jsx("input",{className:"input",type:"number",min:1,max:64,value:n.maxConcurrent,onChange:m=>u("maxConcurrent",parseInt(m.target.value,10)||6),disabled:!n.skipIfBudgetLow})]})]}),e.jsxs("label",{className:"checkbox-row",children:[e.jsx("input",{type:"checkbox",checked:n.enabled,onChange:m=>u("enabled",m.target.checked)}),e.jsx("span",{children:"Enabled"})]}),e.jsxs("div",{className:"modal-footer-actions",children:[e.jsx(z,{variant:"ghost",type:"button",onClick:t,disabled:d,children:"Cancel"}),e.jsx(z,{variant:"primary",type:"submit",disabled:d,children:s?"Save":"Create"})]})]})}function Jl(s){var c,d;if(s.type!=="cron")return s.schedule;const t=Ht(s.schedule);if(!t)return s.schedule;const a=((c=et.find(l=>l.value===t.dow))==null?void 0:c.label)||"",i=((d=Zs.find(l=>l.value===t.hour))==null?void 0:d.label)||`${t.hour}`,n=String(t.minute).padStart(2,"0");return a==="Every day"?`Every day at ${i} :${n}`:`Every ${a} at ${i} :${n}`}function Xl(s,t){try{return new Date(s).toLocaleString(void 0,{timeZone:t||void 0,weekday:"long",hour:"numeric",minute:"2-digit",month:"short",day:"numeric"})}catch{return new Date(s).toLocaleString()}}function xt(s){return s==="success"?"tag-success":s==="skipped"?"tag-warning":"tag-error"}function gt(s,t){return s.length<=t?s:s.slice(0,t-1)+"…"}const gs={all:Te,languages:wa,frameworks:Mt,tools:mn,testing:Fa,design:$t,reasoning:$a,planning:os,gitops:_a,docs:Aa};function Ql({snapshot:s,refreshSnapshot:t}){const a=ce(),i=ke(),[n,c]=r.useState([]),[d,l]=r.useState([]),[x,u]=r.useState(!0),[j,m]=r.useState("all"),[o,p]=r.useState(""),[k,f]=r.useState(null),[S,b]=r.useState(!1),[v,y]=r.useState(null),[$,g]=r.useState(new Set(["all","languages","frameworks"])),B=async()=>{u(!0);try{const L=await A.get("/skills");c(L.skills||[]),l(L.categories||[])}catch(L){a.error(`Skills load failed: ${L.message}`)}finally{u(!1)}};r.useEffect(()=>{B()},[]),r.useEffect(()=>{if(!o.trim()){f(null);return}b(!0);const L=setTimeout(async()=>{try{const V=await A.get(`/skills/search?q=${encodeURIComponent(o.trim())}`);f(V.results||[])}catch(V){a.error(`Search failed: ${V.message}`)}finally{b(!1)}},280);return()=>clearTimeout(L)},[o,a]);const H=r.useMemo(()=>{let L=n;return j!=="all"&&(L=L.filter(V=>(V.category||"tools")===j)),L},[n,j]),R=async L=>{if(confirm(`Install skill "${L.name}"?
|
|
345
|
-
|
|
346
|
-
${L.installCmd||`skills add ${L.id}`}`)){y(L.id);try{await A.post("/skills/install",{name:L.name,source:L.id}),a.success(`Installed ${L.name}.`),f(V=>(V==null?void 0:V.filter(K=>K.id!==L.id))||V),await B()}catch(V){a.error(`Install failed: ${V.message}`)}finally{y(null)}}},J=async L=>{try{L.enabled!==!1?(await A.post(`/skills/${encodeURIComponent(L.id)}/disable`),a.success(`Disabled ${L.name}.`)):(await A.post(`/skills/${encodeURIComponent(L.id)}/enable`),a.success(`Enabled ${L.name}.`)),await B()}catch(V){a.error(`Toggle failed: ${V.message}`)}},D=L=>{let V;V=e.jsxs("div",{className:"skill-detail",children:[e.jsx("p",{className:"muted text-sm mono skill-detail-source",children:L.source}),e.jsx("p",{className:"skill-detail-desc",children:L.description||"No description."}),e.jsxs("div",{className:"skill-detail-meta",children:[e.jsxs("span",{children:[e.jsx("strong",{children:"Category:"})," ",L.category]}),e.jsxs("span",{children:[e.jsx("strong",{children:"Version:"})," ",e.jsx("code",{children:L.version})]}),L.path&&e.jsxs("span",{children:[e.jsx("strong",{children:"Path:"})," ",e.jsx("code",{children:L.path})]})]}),L.tags&&L.tags.length>0&&e.jsx("div",{className:"skill-detail-tags",children:L.tags.map(K=>e.jsx("span",{className:"tag",children:K},K))}),L.installCmd&&e.jsxs("div",{children:[e.jsx("label",{className:"field-label",children:"Install command"}),e.jsx("pre",{className:"skill-detail-cmd mono",children:L.installCmd})]})]}),i.open({title:L.name,width:560,children:V,footer:e.jsxs("div",{className:"modal-footer-actions",children:[e.jsx(z,{variant:"ghost",onClick:()=>i.close(),children:"Close"}),!L.installed&&e.jsxs(z,{variant:"primary",onClick:()=>{i.close(),R(L)},loading:v===L.id,children:[e.jsx(Le,{size:12})," Install"]})]})})};return e.jsxs("div",{className:"view view-skills",children:[e.jsxs("header",{className:"view-header",children:[e.jsxs("div",{className:"view-header-text",children:[e.jsxs("h2",{className:"view-title",children:[e.jsx(Te,{size:18})," Skills"]}),e.jsxs("p",{className:"view-subtitle",children:["Installed skills + browse the registry. Powered by the ",e.jsx("code",{children:"skills"})," CLI."]})]}),e.jsxs("div",{className:"view-actions",children:[e.jsxs("div",{className:"search-input",children:[e.jsx(Oe,{size:14}),e.jsx("input",{className:"input",type:"text",placeholder:"Browse new skills…",value:o,onChange:L=>p(L.target.value)}),o&&e.jsx("button",{type:"button",className:"icon-btn","aria-label":"Clear search",onClick:()=>p(""),title:"Clear",children:e.jsx(Tt,{size:12})})]}),e.jsxs(z,{variant:"secondary",size:"sm",onClick:B,children:[e.jsx(de,{size:14})," Refresh"]})]})]}),o.trim()&&e.jsxs("section",{className:"skills-section",children:[e.jsxs("h3",{className:"skills-section-title",children:[e.jsx(Oe,{size:14})," Search results",S&&e.jsx(je,{size:"sm"})]}),S?e.jsx("div",{className:"skills-grid",children:[0,1,2].map(L=>e.jsx("div",{className:"skill-card skill-card-skeleton"},L))}):k&&k.length===0?e.jsx(Ie,{icon:e.jsx(Oe,{size:28}),title:"No matches",message:`No skills match "${o}".`}):e.jsx("div",{className:"skills-grid",children:(k||[]).map(L=>e.jsx(jt,{skill:L,onShow:()=>D(L),onInstall:()=>R(L),installing:v===L.id,installed:!!n.find(V=>V.id===L.id)},`search-${L.id}`))})]}),!o.trim()&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"skills-categories",children:d.map(L=>{const V=gs[L.id]||Te,K=n.filter(w=>(w.category||"tools")===L.id).length;return e.jsxs("button",{type:"button",className:ae("skill-category",j===L.id&&"skill-category-active"),onClick:()=>m(L.id),children:[e.jsx(V,{size:14}),e.jsx("span",{children:L.label}),K>0&&e.jsx("span",{className:"skill-category-count",children:K})]},L.id)})}),e.jsxs("section",{className:"skills-section",children:[e.jsxs("h3",{className:"skills-section-title",children:[e.jsx(ks,{size:14})," Installed"]}),x?e.jsx("div",{className:"view-loading",children:e.jsx(je,{size:"lg"})}):e.jsx("div",{className:"skills-categories-list",children:d.map(L=>{const V=H.filter(w=>(w.category||"tools")===L.id);if(V.length===0)return null;const K=$.has(L.id);return e.jsxs("details",{className:"skills-category",open:K,onToggle:w=>{const I=w.currentTarget;g(_=>{const W=new Set(_);return I.open?W.add(L.id):W.delete(L.id),W})},children:[e.jsxs("summary",{className:"skills-category-summary",children:[e.jsxs("span",{className:"skills-category-name",children:[gs[L.id]&&(()=>{const w=gs[L.id];return e.jsx(w,{size:14})})(),L.label]}),e.jsx("span",{className:"skill-category-count",children:V.length})]}),e.jsx("div",{className:"skills-grid",children:V.map(w=>e.jsx(jt,{skill:w,onShow:()=>D(w),onToggle:()=>J(w)},w.id))})]},L.id)})})]})]})]})}function jt({skill:s,onShow:t,onInstall:a,onToggle:i,installing:n,installed:c}){const d=gs[s.category]||Te,l=s.enabled!==!1;return e.jsxs(te,{variant:"elevated",interactive:!0,className:ae("skill-card",!l&&"skill-card-disabled"),children:[e.jsxs("div",{className:"skill-card-head",children:[e.jsx("div",{className:"skill-card-icon",style:{background:"color-mix(in srgb, var(--accent) 12%, transparent)"},children:e.jsx(d,{size:18})}),e.jsxs("div",{className:"skill-card-title-area",children:[e.jsx("div",{className:"skill-card-title",children:s.name}),e.jsx("div",{className:"skill-card-source mono",children:s.source})]}),c?e.jsx(Pe,{kind:l?"success":"neutral",children:l?"on":"off"}):e.jsx(Pe,{kind:"accent",children:"new"})]}),e.jsx("p",{className:"skill-card-desc",children:s.description||"No description."}),e.jsxs("div",{className:"skill-card-meta",children:[e.jsxs("span",{className:"mono text-sm",children:["v",s.version]}),s.category&&e.jsx("span",{className:"text-sm muted",children:s.category}),s.tags&&s.tags.length>0&&s.tags.slice(0,3).map(x=>e.jsx("span",{className:"skill-card-tag",children:x},x))]}),e.jsxs("div",{className:"skill-card-actions",children:[e.jsxs(z,{variant:"ghost",size:"sm",onClick:t,children:[e.jsx(Ks,{size:12})," Details"]}),c&&i&&e.jsxs(z,{variant:l?"ghost":"secondary",size:"sm",onClick:i,title:l?"Disable":"Enable",children:[l?e.jsx(sn,{size:12}):e.jsx(Ws,{size:12}),l?"Disable":"Enable"]}),!c&&a&&e.jsxs(z,{variant:"primary",size:"sm",onClick:a,loading:n,children:[e.jsx(Le,{size:12})," Install"]})]})]})}const ss=[{id:"1h",label:"Last hour",ms:60*60*1e3},{id:"1d",label:"Last day",ms:24*60*60*1e3},{id:"7d",label:"Last 7 days",ms:7*24*60*60*1e3},{id:"30d",label:"Last 30 days",ms:30*24*60*60*1e3},{id:"all",label:"All time",ms:0}];function Zl({snapshot:s}){var S,b;const t=ce(),[a,i]=r.useState(null),[n,c]=r.useState(!0),[d,l]=r.useState("1d"),[x,u]=r.useState(new Set),[j,m]=r.useState(0),o=async v=>{try{const y=v?`?since=${encodeURIComponent(v)}&limit=1000`:"?limit=1000",$=await A.get(`/history${y}`);i($),u(new Set($.projects.filter(g=>$.events.some(B=>B.projectId===g.id)).map(g=>g.id)))}catch(y){t.error(`History load failed: ${y.message}`)}finally{c(!1)}};r.useEffect(()=>{c(!0);const v=ss.find(y=>y.id===d)||ss[1];if(v.ms>0){const y=new Date(Date.now()-v.ms).toISOString();o(y)}else o()},[d]),r.useEffect(()=>{const v=setInterval(()=>m(y=>y+1),3e4);return()=>clearInterval(v)},[]);const p=new Map;for(const v of(a==null?void 0:a.events)||[]){const y=v.projectId||"global";p.has(y)||p.set(y,[]),p.get(y).push(v)}const k=v=>{u(y=>{const $=new Set(y);return $.has(v)?$.delete(v):$.add(v),$})},f=()=>{if(!a)return;const v=new Blob([JSON.stringify(a,null,2)],{type:"application/json"}),y=URL.createObjectURL(v),$=document.createElement("a");$.href=y,$.download=`bizar-history-${new Date().toISOString().replace(/[:.]/g,"-")}.json`,$.click(),URL.revokeObjectURL(y),t.success("History exported.")};return e.jsxs("div",{className:"view view-history","data-tick":j,children:[e.jsxs("header",{className:"view-header",children:[e.jsxs("div",{className:"view-header-text",children:[e.jsxs("h2",{className:"view-title",children:[e.jsx(ns,{size:18})," History"]}),e.jsxs("p",{className:"view-subtitle",children:["Cross-project history of events, tasks, and plans.",((S=a==null?void 0:a.stats)==null?void 0:S.lastTs)&&e.jsxs(e.Fragment,{children:[" · last event ",ve(a.stats.lastTs)]})]})]}),e.jsxs("div",{className:"view-actions",children:[e.jsxs("div",{className:"tasks-toolbar-group",children:[e.jsx(Oa,{size:14,style:{color:"var(--text-dim)"}}),e.jsx("select",{className:"select select-sm",value:d,onChange:v=>l(v.target.value),title:"Time range",children:ss.map(v=>e.jsx("option",{value:v.id,children:v.label},v.id))})]}),e.jsxs(z,{variant:"ghost",size:"sm",onClick:()=>{c(!0);const v=ss.find(y=>y.id===d)||ss[1];v.ms>0?o(new Date(Date.now()-v.ms).toISOString()):o()},children:[e.jsx(de,{size:14})," Refresh"]}),e.jsxs(z,{variant:"secondary",size:"sm",onClick:f,children:[e.jsx(Le,{size:14})," Export"]})]})]}),n&&e.jsxs("div",{className:"view-loading",children:[e.jsx(je,{size:"lg"}),e.jsx("p",{children:"Loading history…"})]}),!n&&a&&e.jsxs("div",{className:"history-list",children:[a.projects.length===0&&e.jsxs(te,{children:[e.jsxs(le,{children:[e.jsx(Ue,{size:14})," No projects"]}),e.jsx(oe,{children:"Register a project in Overview to start tracking history."})]}),a.projects.map(v=>{const y=p.get(v.id)||[],$=x.has(v.id);return e.jsxs(te,{className:"history-project",children:[e.jsxs("div",{className:"history-project-head",children:[e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:4,minWidth:0,flex:1},children:[e.jsxs("div",{className:"history-project-name",children:[e.jsx(Ue,{size:16})," ",v.name]}),e.jsx("div",{className:"history-project-meta",children:v.path})]}),e.jsxs("div",{className:"history-project-stats",children:[e.jsxs("span",{className:"history-project-stat",children:[e.jsx("span",{className:"history-project-stat-num",children:v.tasks.done}),e.jsxs("span",{className:"muted",children:["/ ",v.tasks.total," done"]})]}),v.tasks.doing>0&&e.jsxs("span",{className:"history-project-stat",children:[e.jsx("span",{className:"history-project-stat-num",children:v.tasks.doing}),e.jsx("span",{className:"muted",children:"doing"})]}),v.tasks.blocked>0&&e.jsxs("span",{className:"history-project-stat",children:[e.jsx("span",{className:"history-project-stat-num",children:v.tasks.blocked}),e.jsx("span",{className:"muted",children:"blocked"})]}),e.jsxs("span",{className:"history-project-stat",children:[e.jsx(ws,{size:11})," ",e.jsx("span",{className:"history-project-stat-num",children:v.plans}),e.jsxs("span",{className:"muted",children:[" plan",v.plans===1?"":"s"]})]}),v.lastAccessed&&e.jsx("span",{className:"history-project-stat",children:e.jsxs("span",{className:"muted",children:["last opened ",ve(v.lastAccessed)]})})]}),e.jsx("button",{type:"button",className:"icon-btn",onClick:()=>k(v.id),"aria-label":$?"Collapse":"Expand",children:$?e.jsx(Ae,{size:14}):e.jsx(He,{size:14})})]}),$&&e.jsx("div",{className:"history-timeline-mini",children:y.length===0?e.jsx("div",{className:"muted",style:{padding:"12px 8px",fontSize:12},children:"No events in this time range."}):y.slice(-100).reverse().map((g,B)=>e.jsxs("div",{className:"history-timeline-row",children:[e.jsx("span",{className:"history-timeline-ts",children:new Date(g.ts).toLocaleTimeString()}),e.jsx("span",{className:"history-timeline-kind",children:g.kind||"event"}),e.jsxs("span",{className:"history-timeline-msg",title:String(g.text||g.title||""),children:[g.author?`@${g.author} `:"",String(g.text??g.title??g.name??"")]})]},B))})]},v.id)}),p.has("global")&&e.jsxs(te,{className:"history-project",children:[e.jsx("div",{className:"history-project-head",children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:4,minWidth:0,flex:1},children:[e.jsxs("div",{className:"history-project-name",children:[e.jsx(ns,{size:16})," Global events"]}),e.jsx("div",{className:"history-project-meta",children:"Activity not tied to a specific project"})]})}),e.jsx("div",{className:"history-timeline-mini",children:(p.get("global")||[]).slice(-100).reverse().map((v,y)=>e.jsxs("div",{className:"history-timeline-row",children:[e.jsx("span",{className:"history-timeline-ts",children:new Date(v.ts).toLocaleTimeString()}),e.jsx("span",{className:"history-timeline-kind",children:v.kind||"event"}),e.jsxs("span",{className:"history-timeline-msg",title:String(v.text||v.title||""),children:[v.author?`@${v.author} `:"",String(v.text??v.title??v.name??"")]})]},y))})]}),((b=a.stats)==null?void 0:b.counts)&&Object.keys(a.stats.counts).length>0&&e.jsxs(te,{children:[e.jsx(le,{children:"Event counts by kind"}),e.jsxs(oe,{children:[a.stats.lines," total lines in log"]}),e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:8,marginTop:8},children:Object.entries(a.stats.counts).sort((v,y)=>y[1]-v[1]).slice(0,30).map(([v,y])=>e.jsxs("span",{className:ae("tag","tag-neutral"),style:{fontFamily:"var(--font-mono)"},children:[v,": ",y]},v))})]})]})]})}function er({instance:s}){const t=ce(),[a,i]=r.useState(!1),n=s.tmuxSession,c=n?`tmux attach -t ${n}`:null,d=async()=>{if(c)try{await navigator.clipboard.writeText(c),t.success("Attach command copied")}catch{t.error("Could not copy to clipboard")}},l=async()=>{if(!(!s.instanceId||!n)){i(!0);try{const x=await A.post(`/background/${encodeURIComponent(s.instanceId)}/open-terminal`,{emulator:"system"});if(x.ok)t.success("Opening terminal…");else if(t.error(x.error||"Failed to open terminal"),c)try{await navigator.clipboard.writeText(c),t.success("Command copied to clipboard")}catch{}}catch(x){if(t.error(`Failed: ${x.message}`),c)try{await navigator.clipboard.writeText(c),t.success("Command copied to clipboard")}catch{}}finally{i(!1)}}};return n?e.jsxs(te,{variant:"outlined",className:"bg-tmux-card",children:[e.jsxs("div",{className:"bg-tmux-card-header",children:[e.jsx(is,{size:14}),e.jsx("span",{children:"tmux session"}),s.tmuxActive!==!1?e.jsx("span",{className:"badge badge-success",children:"live"}):e.jsx("span",{className:"badge badge-warning",children:"inactive"})]}),e.jsx("code",{className:"mono bg-tmux-session-name",children:n}),e.jsx("p",{className:"muted bg-tmux-hint",children:"Attach to the agent's tmux session from a terminal on the host running the dashboard."}),e.jsxs("div",{className:"bg-tmux-card-actions",children:[e.jsxs(z,{variant:"ghost",size:"sm",onClick:d,title:"Copy attach command",children:[e.jsx(Ss,{size:14})," Copy"]}),e.jsxs(z,{variant:"primary",size:"sm",onClick:l,loading:a,title:"Open in system terminal",children:[e.jsx(is,{size:14})," Open terminal"]})]})]}):e.jsxs(te,{variant:"outlined",className:"bg-tmux-card bg-tmux-card-warn",children:[e.jsxs("div",{className:"bg-tmux-card-header",children:[e.jsx(De,{size:14}),e.jsx("span",{children:"No tmux session"})]}),e.jsx("p",{className:"bg-tmux-hint muted",children:"This instance does not have a tmux session attached. Sessions are created automatically when a background agent starts."})]})}const sr=5e3,tr=2e3,ar=120;function nr(s){return s.status==="pending"||s.status==="running"}function ir(s){if(!Number.isFinite(s)||s<0)return"—";const t=Math.floor(s/1e3),a=Math.floor(t/3600),i=Math.floor(t%3600/60),n=t%60;return a>0?`${a}h ${i}m ${n}s`:i>0?`${i}m ${n}s`:`${n}s`}function lr(s){const t=ce(),a=ke(),[i,n]=r.useState([]),[c,d]=r.useState(!0),[l,x]=r.useState(null),[,u]=r.useState(0),j=r.useCallback(async()=>{try{const f=await A.get("/background");n(Array.isArray(f==null?void 0:f.instances)?f.instances:[]),x(null)}catch(f){x((f==null?void 0:f.message)||"Failed to load background agents.")}finally{d(!1)}},[]);r.useEffect(()=>{j();const f=setInterval(j,sr);return()=>clearInterval(f)},[j]),r.useEffect(()=>{const f=setInterval(()=>u(S=>(S+1)%1e6),1e3);return()=>clearInterval(f)},[]),r.useEffect(()=>{const f=new Ys,S=f.on(b=>{const v=b.type;(v==="background:change"||v==="background:cleanup")&&j()});return()=>{S(),f.close()}},[j]);const m=i.filter(nr),o=f=>{or(a,f)},p=async f=>{try{const S=await A.get(`/background/${encodeURIComponent(f.instanceId)}/tmux`);dr(a,S)}catch(S){t.error(`Tmux info failed: ${S.message}`)}},k=f=>{Ot(a,t,f.instanceId,f.agent||f.prompt,()=>{n(S=>S.filter(b=>b.instanceId!==f.instanceId))})};return c?e.jsx("div",{className:"bg-active-view",children:e.jsxs("div",{className:"bg-active-loading",children:[e.jsx(je,{size:"md"}),e.jsx("span",{children:"Loading background agents…"})]})}):l?e.jsx("div",{className:"bg-active-view",children:e.jsx(Ie,{icon:e.jsx(ze,{size:32}),title:"Couldn't load background agents",message:l,action:e.jsxs(z,{variant:"primary",onClick:j,children:[e.jsx(de,{size:14})," Retry"]})})}):e.jsxs("div",{className:"bg-active-view",children:[e.jsxs("div",{className:"bg-active-header",children:[e.jsxs("div",{className:"bg-active-header-text",children:[e.jsx("h2",{className:"bg-active-title",children:"Active Background Agents"}),e.jsxs("p",{className:"bg-active-subtitle muted",children:[m.length," active · ",i.length," total in store"]})]}),e.jsxs(z,{variant:"ghost",size:"sm",onClick:j,title:"Refresh now",children:[e.jsx(de,{size:14})," Refresh"]})]}),m.length===0?e.jsx(Ie,{icon:e.jsx(ze,{size:32}),title:"No active background agents",message:"Spawn one from the Agents tab or via the bizar_spawn_background tool."}):e.jsx("div",{className:"bg-active-list",children:m.map(f=>e.jsx(rr,{inst:f,onViewOutput:()=>o(f),onOpenTmux:()=>p(f),onKill:()=>k(f)},f.instanceId))})]})}function rr({inst:s,onViewOutput:t,onOpenTmux:a,onKill:i}){const n=typeof s.startedAt=="number"?s.startedAt:0,c=n?vt(n):"—",d=n?Date.now()-n:0,l=yt(s.prompt,ar);return e.jsxs(te,{className:"bg-active-card",variant:"elevated",children:[e.jsxs("div",{className:"bg-active-card-top",children:[e.jsxs("div",{className:"bg-active-card-id",children:[e.jsx("code",{className:"mono",children:s.instanceId}),e.jsx(Bt,{status:s.status||"pending",dot:!0})]}),e.jsxs("div",{className:"bg-active-card-agent",children:[e.jsx("span",{className:"bg-active-card-agent-label",children:"Agent"}),e.jsx("span",{className:"bg-active-card-agent-name",children:s.agent||"unknown"})]})]}),l&&e.jsx("div",{className:"bg-active-prompt",children:l}),s.currentStep&&e.jsxs("div",{className:"bg-active-step",children:[e.jsx("span",{className:"bg-active-step-label",children:"Step:"}),e.jsx("span",{className:"bg-active-step-value",children:s.currentStep})]}),typeof s.progress=="number"&&e.jsxs("div",{className:"progress-bar","aria-label":"Progress",children:[e.jsx("div",{className:"progress-fill",style:{width:`${Math.max(0,Math.min(100,s.progress))}%`}}),e.jsxs("span",{className:"progress-label",children:[Math.round(s.progress),"%"]})]}),e.jsxs("div",{className:"bg-active-meta",children:[e.jsxs("span",{title:c,children:[e.jsx("strong",{children:"Started:"})," ",c]}),e.jsxs("span",{children:[e.jsx("strong",{children:"Duration:"})," ",ir(d)]}),e.jsxs("span",{children:[e.jsx("strong",{children:"Tool calls:"})," ",s.toolCallCount??0]}),s.tmuxSession&&e.jsxs("span",{className:ae(s.tmuxActive&&"bg-active-meta-tmux-live"),children:[e.jsx("strong",{children:"tmux:"})," ",e.jsx("code",{className:"mono",children:s.tmuxSession}),s.tmuxActive?" · live":""]})]}),e.jsxs("div",{className:"bg-active-actions",children:[e.jsxs(z,{variant:"secondary",size:"sm",onClick:t,children:[e.jsx(ls,{size:14})," View output"]}),e.jsxs(z,{variant:"ghost",size:"sm",onClick:a,children:[e.jsx(is,{size:14})," Open in tmux"]}),e.jsxs(z,{variant:"danger",size:"sm",onClick:i,children:[e.jsx(ye,{size:14})," Kill"]})]}),e.jsx(er,{instance:s})]})}function or(s,t){s.open({title:`Output — ${t.agent||t.instanceId}`,width:720,children:e.jsx(cr,{instanceId:t.instanceId})})}function cr({instanceId:s}){const t=ce(),[a,i]=r.useState(""),[n,c]=r.useState(!0),[d,l]=r.useState(null),[x,u]=r.useState(!0),j=r.useRef(null),m=r.useRef(!0),o=r.useCallback(async()=>{try{const f=await A.get(`/background/${encodeURIComponent(s)}/output?lines=200`);i((f==null?void 0:f.output)??""),u((f==null?void 0:f.available)!==!1),l(null)}catch(f){l((f==null?void 0:f.message)||"Failed to load output.")}finally{c(!1)}},[s]);r.useEffect(()=>{o();const f=setInterval(o,tr);return()=>clearInterval(f)},[o]),r.useEffect(()=>{var f;m.current&&((f=j.current)==null||f.scrollIntoView({behavior:"auto",block:"end"}))},[a]);const p=f=>{const S=f.currentTarget,b=S.scrollHeight-S.scrollTop-S.clientHeight<24;m.current=b},k=async()=>{try{await navigator.clipboard.writeText(a),t.success("Output copied.")}catch{}};return e.jsxs("div",{className:"bg-output-modal",children:[e.jsxs("div",{className:"bg-output-toolbar",children:[e.jsx("span",{className:"muted",children:x?`${a.length} chars · auto-refresh 2s`:"Output unavailable"}),e.jsxs("div",{className:"bg-output-toolbar-actions",children:[e.jsxs(z,{variant:"ghost",size:"sm",onClick:o,title:"Refresh now",children:[e.jsx(de,{size:14})," Refresh"]}),e.jsxs(z,{variant:"ghost",size:"sm",onClick:k,disabled:!a,children:[e.jsx(Ss,{size:14})," Copy"]})]})]}),n&&!a?e.jsxs("div",{className:"bg-output-loading",children:[e.jsx(Ga,{size:16,className:"spin"})," Loading…"]}):d?e.jsx("div",{className:"bg-output-error",children:d}):a?e.jsxs("div",{className:"bg-output-scroll",onScroll:p,children:[e.jsx("pre",{className:"bg-output-pre mono",children:e.jsx("code",{children:a})}),e.jsx("div",{ref:j})]}):e.jsx("div",{className:"bg-output-empty muted",children:"No output captured yet."})]})}function dr(s,t){const a=t.attachCommand||t.session||"";s.open({title:"Attach to tmux",width:520,children:e.jsx(mr,{info:t,cmd:a})})}function mr({info:s,cmd:t}){const[a,i]=r.useState(!1),n=async()=>{try{await navigator.clipboard.writeText(t),i(!0),window.setTimeout(()=>i(!1),1500)}catch{}};return e.jsx("div",{className:"bg-tmux-modal",children:t?e.jsxs(e.Fragment,{children:[e.jsxs("p",{className:"bg-tmux-meta",children:[s.exists?e.jsx("span",{className:"badge badge-success",children:"session live"}):e.jsxs("span",{className:"badge badge-warning",children:["session not running",s.reason?` — ${s.reason}`:""]}),s.session&&e.jsxs("span",{className:"bg-tmux-session muted",children:["· session ",e.jsx("code",{className:"mono",children:s.session})]})]}),e.jsx("label",{className:"field-label",children:"Attach command"}),e.jsxs("div",{className:"bg-tmux-command-row",children:[e.jsx("code",{className:"bg-tmux-command mono",children:t}),e.jsxs(z,{variant:"secondary",size:"sm",onClick:n,children:[e.jsx(Ss,{size:14})," ",a?"Copied":"Copy"]})]}),e.jsx("p",{className:"muted bg-tmux-hint",children:"Paste this into a terminal on the host running the dashboard. The dashboard itself does not open terminals."})]}):e.jsx("p",{className:"muted",children:"No tmux session attached to this instance."})})}const Ls={overview:En,chat:ri,agents:mi,artifacts:Bi,tasks:Yi,activity:rl,background:lr,config:cl,settings:Ll,mods:El,schedules:Gl,skills:Ql,history:Zl},hr="v3.21.0";function ur(s,t,a,i){if(Ls[s]){const d=Ls[s];return e.jsx(d,{...t})}const n=a.find(d=>d.id===s);if(n)return e.jsx(Ol,{viewId:n.id,reloadKey:i,activeTab:t.activeTab,setActiveTab:t.setActiveTab});const c=Ls.overview;return e.jsx(c,{...t})}function pr(){return e.jsx(Sa,{children:e.jsx(Ca,{children:e.jsx(xr,{})})})}function xr(){var U,O,Q;const s=ce(),t=ke(),{isModalOpen:a}=t,i=r.useRef(!1),[n,c]=r.useState("overview"),[d,l]=r.useState(null),[x,u]=r.useState(null),[j,m]=r.useState("connecting"),[o,p]=r.useState(null),[k,f]=r.useState(!1),[S,b]=r.useState([]),[v,y]=r.useState(!1),[$,g]=r.useState([]),[B,H]=r.useState(0),R=r.useRef(null),[J,D]=r.useState(null);r.useEffect(()=>{let F=!1;return(async()=>{try{const q=await A.get("/mods/views");if(F)return;g(q.views||[])}catch{F||g([])}})(),()=>{F=!0}},[B,d==null?void 0:d.mods]),r.useEffect(()=>{if(!J)return;const F=J.on(q=>{((q==null?void 0:q.type)==="mod:change"||(q==null?void 0:q.type)==="mod:enabled"||(q==null?void 0:q.type)==="mod:installed")&&H(ee=>ee+1)});return()=>F()},[J]),r.useEffect(()=>{x!=null&&x.theme&&(ts(x.theme),Je(x.theme))},[x==null?void 0:x.theme]),r.useEffect(()=>{i.current=a},[a]),r.useEffect(()=>{var ee;if(((ee=x==null?void 0:x.theme)==null?void 0:ee.mode)!=="system")return;const F=window.matchMedia("(prefers-color-scheme: light)"),q=()=>ts(x.theme.mode);return F.addEventListener("change",q),()=>F.removeEventListener("change",q)},[(U=x==null?void 0:x.theme)==null?void 0:U.mode]),r.useEffect(()=>{let F=!1;const q=()=>Promise.all([A.get("/snapshot").catch(()=>null),A.get("/settings").catch(()=>null),A.get("/agents/stuck").catch(()=>null)]),ee=(T,M,C)=>{T&&l(T),M!=null&&M.data&&u(M.data),C!=null&&C.stuck&&b(C.stuck)};return(async()=>{try{const T=await A.probeAuthStatus(),[M,C,h]=await q();if(F||(ee(M,C,h),M||C))return;if(!T.loopback){p("Dashboard server unreachable.");return}if(await new Promise(re=>setTimeout(re,1e3)),F)return;const[P,Y,E]=await q();if(F)return;ee(P,Y,E),!P&&!Y&&p("Dashboard server unreachable.")}catch(T){if(F)return;const M=(T==null?void 0:T.message)??"unknown error";p(M),s.error(`Failed to load: ${M}`)}})(),()=>{F=!0}},[s]),r.useEffect(()=>{let F=!1;return A.get("/settings").then(q=>{var T,M;if(F)return;const ee=(M=(T=q==null?void 0:q.data)==null?void 0:T.ui)==null?void 0:M.defaultTab;ee&&c(ee)}).catch(()=>{}),()=>{F=!0}},[]),r.useEffect(()=>{let F=!1;const q=async()=>{try{const T=await A.get("/agents/stuck");F||b(M=>{const C=T.stuck||[];return M.length===0&&C.length>0&&s.warning(`${C.length} agent${C.length===1?"":"s"} stuck`,5e3),C})}catch{}},ee=setInterval(q,3e4);return q(),()=>{F=!0,clearInterval(ee)}},[]),r.useEffect(()=>{const F=new Ys;R.current=F,D(F);const q=F.onStatus(T=>m(T)),ee=F.on(T=>{var M;if(T.type==="snapshot"&&"data"in T&&T.data)l(C=>({...C??{},...T.data}));else if(T.type==="change"){const C=T,h=((M=C.path)==null?void 0:M.split("/").pop())||C.path||"";s.info(`File changed: ${h}`,2500),A.get("/snapshot").then(P=>l(Y=>({...Y??{},...P}))).catch(()=>{})}else if(T.type==="tasks:change"){const C=T;l(h=>{if(!h)return h;const P=(h.tasks||[]).map(E=>E.id===C.task.id?C.task:E),Y=P.some(E=>E.id===C.task.id);return{...h,tasks:Y?P:[C.task,...P]}})}else if(T.type==="tasks:delete"){const C=T;l(h=>h&&{...h,tasks:(h.tasks||[]).filter(P=>P.id!==C.id)})}else if(T.type==="settings:change"){const C=T;C.settings&&u(C.settings)}else if(T.type==="project:change")A.get("/snapshot").then(C=>l(h=>({...h??{},...C}))).catch(()=>{});else if(T.type==="agents:change"||T.type==="schedules:change")A.get("/snapshot").then(C=>l(h=>({...h??{},...C}))).catch(()=>{});else if(T.type==="agent:status"||T.type==="agent:restarted"){const C=T;l(h=>{if(!h)return h;const P=(h.agents||[]).map(Y=>Y.name===C.agent.name?C.agent:Y);return{...h,agents:P}})}else if(T.type==="artifact:change")A.get("/artifacts").then(C=>{l(h=>h&&{...h,artifacts:C.artifacts||[]})}).catch(()=>{});else if(T.type==="agent:stuck")b(T.agents||[]);else if(T.type==="dialog:show"){const C=T;C.dialog&&t.open({title:C.dialog.title,width:520,children:e.jsx(Pn,{dialog:C.dialog,onClose:()=>t.close()})})}});return()=>{q(),ee(),F.close(),D(null)}},[s]);const L=r.useCallback(F=>J?J.on(F):()=>{},[J]),V=r.useRef(0);r.useEffect(()=>{const F=()=>{V.current=Date.now()+1500};return document.addEventListener("mousedown",F,!0),document.addEventListener("click",F,!0),document.addEventListener("focusin",F,!0),document.addEventListener("keydown",F,!0),()=>{document.removeEventListener("mousedown",F,!0),document.removeEventListener("click",F,!0),document.removeEventListener("focusin",F,!0),document.removeEventListener("keydown",F,!0)}},[]),r.useEffect(()=>{const F={};Fs.forEach((ee,T)=>{F[String(T+1)]=ee.id});const q=ee=>{var re,ie,fe,me;if((ee.metaKey||ee.ctrlKey)&&ee.key.toLowerCase()==="k"){ee.preventDefault(),f(!0);return}if(ee.key==="/"&&!ee.metaKey&&!ee.ctrlKey){const ms=(ie=(re=ee.target)==null?void 0:re.tagName)==null?void 0:ie.toLowerCase();if(ms!=="input"&&ms!=="textarea"&&!((fe=ee.target)!=null&&fe.isContentEditable)){ee.preventDefault(),f(!0);return}}const T=document.activeElement;if(!T||T===document.body||T===document.documentElement)return;const C=ee.target,h=(me=C==null?void 0:C.tagName)==null?void 0:me.toLowerCase(),P=h==="input"||h==="textarea"||h==="select"||h==="button"||h==="option"||h==="label"||!!(C!=null&&C.isContentEditable);let Y=!1;if(C&&typeof C.closest=="function"&&(Y=!!C.closest('form, [role="dialog"], [contenteditable], [data-no-key]')),ee.repeat||i.current||P||Y||ee.metaKey||ee.ctrlKey||ee.altKey||ee.shiftKey||Date.now()<V.current)return;const E=F[ee.key];E&&(ee.preventDefault(),c(E))};return document.addEventListener("keydown",q),()=>document.removeEventListener("keydown",q)},[]);const K=r.useMemo(()=>async()=>{try{const F=await A.get("/snapshot");l(q=>({...q??{},...F}))}catch(F){s.error(`Refresh failed: ${F.message}`)}},[s]),w=r.useMemo(()=>{const F=$.map(q=>({id:q.id,label:q.label,icon:q.kind==="iframe"?rs:Bs,isMod:!0,modId:q.modId}));return[...Fs,...F]},[$]),I=r.useMemo(()=>d&&x?ur(n,{snapshot:d,settings:x,activeTab:n,setActiveTab:c,refreshSnapshot:K},$,B):null,[n,d,x,$,B,K]),_=async()=>{try{const F=await A.get("/projects");l(q=>{var ee;return q&&{...q,projects:F.projects||[],activeProject:((ee=F.projects)==null?void 0:ee.find(T=>T.id===F.active))||null}})}catch(F){s.error(`Projects refresh failed: ${F.message}`)}},W=async F=>{try{await A.post(`/projects/${encodeURIComponent(F)}/activate`),l(q=>q&&{...q,activeProject:q.projects.find(ee=>ee.id===F)||null})}catch(q){s.error(`Activate failed: ${q.message}`)}},X=F=>{const q=F.type;if(q==="agent")c("agents");else if(q==="task")c("tasks");else if(q==="mod")c("mods");else if(q==="schedule")c("schedules");else if(q==="project"){const ee=F.item.id;W(ee)}else if(q==="command")s.info(`/${F.item.name} — run from the TUI`,2500);else if(q==="setting"){const ee=F.item.id||F.item.path||"";c("settings");const T=M=>{if(M<=0)return;const C=ee?document.querySelector(`[data-setting-id="${CSS.escape(ee)}"]`):null;C?(C.scrollIntoView({behavior:"smooth",block:"center"}),C.classList.remove("setting-flash"),C.offsetWidth,C.classList.add("setting-flash"),window.setTimeout(()=>C.classList.remove("setting-flash"),1500)):window.setTimeout(()=>T(M-1),80)};window.setTimeout(()=>T(15),60)}},ne=((O=x==null?void 0:x.ui)==null?void 0:O.layout)||"topnav",se=((Q=x==null?void 0:x.ui)==null?void 0:Q.showHeader)!==!1;return e.jsxs("div",{className:"app","data-layout":ne,"data-active-tab":n,children:[se&&e.jsx(bn,{activeTab:n,onTabChange:c,wsStatus:j,version:hr,activeProject:(d==null?void 0:d.activeProject)||null,projects:(d==null?void 0:d.projects)||[],onProjectChange:W,onProjectsRefresh:_,onOpenSearch:()=>f(!0),settings:x,notificationsSlot:e.jsx(Tn,{wsSubscribe:L}),showTabs:ne==="topnav",extraTabs:w}),S.length>0&&!v&&e.jsxs("div",{className:"stuck-banner",role:"alert",children:[e.jsx(De,{size:16}),e.jsxs("span",{children:[e.jsx("strong",{children:S.length})," agent",S.length===1?"":"s"," stuck:"," ",e.jsx("span",{className:"mono",children:S.map(F=>F.name).join(", ")})]}),e.jsx(z,{variant:"secondary",size:"sm",onClick:()=>{c("agents"),y(!0)},children:"Review"}),e.jsx("button",{type:"button",className:"icon-btn","aria-label":"Dismiss",onClick:()=>y(!0),children:e.jsx($e,{size:14})})]}),e.jsxs("div",{className:"layout-body",children:[ne!=="topnav"&&e.jsx(wn,{tabs:w,activeTab:n,onTabChange:c}),e.jsxs("main",{className:"content",children:[o&&e.jsxs("div",{className:"boot-error",children:[e.jsx("h2",{children:"Dashboard unavailable"}),e.jsx("p",{children:o}),e.jsxs("p",{className:"boot-error-hint",children:["Make sure the Bizar dashboard server is running. Try"," ",e.jsx("code",{children:"bizar-dash start"})," in your terminal."]})]}),!o&&(!d||!x)&&e.jsxs("div",{className:"loading",children:[e.jsx(je,{size:"lg"}),e.jsx("p",{children:"Loading Bizar…"})]}),I]})]}),e.jsx(Sn,{open:k,onClose:()=>f(!1),onSelect:X})]})}function gr(){const[s,t]=r.useState(()=>typeof window>"u"?!1:window.matchMedia("(max-width: 767px)").matches);return r.useEffect(()=>{const a=window.matchMedia("(max-width: 767px)"),i=n=>t(n.matches);return a.addEventListener("change",i),()=>a.removeEventListener("change",i)},[]),s?e.jsx(Ta,{}):e.jsx(pr,{})}const qt=document.getElementById("root");if(!qt)throw new Error("Root element #root not found");za(qt).render(e.jsx(r.StrictMode,{children:e.jsx(gr,{})}));
|
|
347
|
-
//# sourceMappingURL=main-CEazNxxy.js.map
|