@polderlabs/bizar 7.0.2 → 7.0.4
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/EnvVarsSection-BfhAz3ax.js.map +1 -1
- package/bizar-dash/dist/assets/Toast-ATSAmbdi.js.map +1 -1
- package/bizar-dash/dist/assets/main-CJAtrosO.css +1 -0
- package/bizar-dash/dist/assets/main-DKKj9dsq.js +430 -0
- package/bizar-dash/dist/assets/main-DKKj9dsq.js.map +1 -0
- package/bizar-dash/dist/assets/mobile-layout-GZ3bE8L6.js.map +1 -1
- package/bizar-dash/dist/assets/useSlashCommands-BOwD7lNb.js.map +1 -1
- package/bizar-dash/dist/index.html +2 -2
- package/bizar-dash/node_modules/.vite/vitest/da39a3ee5e6b4b0d3255bfef95601890afd80709/results.json +1 -0
- package/bizar-dash/src/web/components/SettingsNav.tsx +9 -4
- package/bizar-dash/src/web/components/Topbar.tsx +45 -0
- package/bizar-dash/src/web/styles/main.css +87 -89
- package/bizar-dash/src/web/styles/memory.css +30 -35
- package/bizar-dash/src/web/styles/settings.css +6 -26
- package/bizar-dash/src/web/ui/data/data.css +6 -1
- package/bizar-dash/src/web/ui/index.ts +1 -0
- package/bizar-dash/src/web/views/Memory.tsx +94 -62
- package/bizar-dash/src/web/views/Overview.tsx +2 -23
- package/bizar-dash/tests/settings-layout.test.tsx +2 -2
- package/bizar-dash/tests/settings-nav.test.tsx +6 -6
- package/cli/provision-claude.mjs +108 -5
- package/package.json +1 -1
- package/packages/sdk/.harness/agents.json +17 -0
- package/packages/sdk/.harness/topology.json +4 -0
- package/bizar-dash/dist/assets/main-306CZfn6.js +0 -430
- package/bizar-dash/dist/assets/main-306CZfn6.js.map +0 -1
- package/bizar-dash/dist/assets/main-G3bNDpY3.css +0 -1
|
@@ -0,0 +1,430 @@
|
|
|
1
|
+
var tu=Object.defineProperty;var su=(t,s,n)=>s in t?tu(t,s,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[s]=n;var Ps=(t,s,n)=>su(t,typeof s!="symbol"?s+"":s,n);import{c as ie,r as f,j as e,a as Fo,X as Ie,b as H,R as xe,F as lt,C as Ut,M as mn,B as pt,S as Qt,A as He,d as vt,e as Jt,H as Zs,f as wi,g as Re,h as te,P as We,i as Ve,l as At,k as Ue,m as St,n as rt,o as Rt,T as Fe,p as ua,q as fn,s as bs,t as Oo,u as ws,v as nu,w as au,x as ye,y as iu,z as ki,D as Bo,E as fs,G as Ys,I as Ho,_ as ru,J as ou,W as es,K as lu,L as cu,N as du,O as uu}from"./mobile-layout-GZ3bE8L6.js";import{C as Ni,a as ct,u as pe,T as qe,b as Ze,I as Si,c as hu}from"./Toast-ATSAmbdi.js";import{B as xt,S as mu,a as U,C as Fn,b as Ht,c as fe,d as se,e as de,E as Is,f as ue,G as gt,g as si,h as ks,Z as Ci,D as ts,i as ls,P as ni,K as zi,j as Qs,A as fu,U as pu,k as xu,l as gu,T as yu,m as vu,H as ju,n as bu,L as je,F as dr,o as wu,p as ku}from"./EnvVarsSection-BfhAz3ax.js";import{C as Vt,a as Nu,u as Su,b as Cu,c as zu,d as Mu,M as Vo,r as Uo,V as qo,B as Mi}from"./useSlashCommands-BOwD7lNb.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 Wo=ie("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 ha=ie("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 Go=ie("ArrowLeftRight",[["path",{d:"M8 3 4 7l4 4",key:"9rb6wj"}],["path",{d:"M4 7h16",key:"6tx8e3"}],["path",{d:"m16 21 4-4-4-4",key:"siv7j2"}],["path",{d:"M20 17H4",key:"h6l3hr"}]]);/**
|
|
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 $i=ie("ArrowLeft",[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]);/**
|
|
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 Yo=ie("ArrowRight",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]]);/**
|
|
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 pn=ie("ArrowUp",[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]]);/**
|
|
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 Xo=ie("Bell",[["path",{d:"M6 8a6 6 0 0 1 12 0c0 7 3 9 3 9H3s3-2 3-9",key:"1qo2s2"}],["path",{d:"M10.3 21a1.94 1.94 0 0 0 3.4 0",key:"qgo35s"}]]);/**
|
|
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 $u=ie("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"}]]);/**
|
|
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 Ea=ie("Camera",[["path",{d:"M14.5 4h-5L7 7H4a2 2 0 0 0-2 2v9a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V9a2 2 0 0 0-2-2h-3l-2.5-3z",key:"1tc9qg"}],["circle",{cx:"12",cy:"13",r:"3",key:"1vg3eu"}]]);/**
|
|
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 Ko=ie("ChartNoAxesColumn",[["line",{x1:"18",x2:"18",y1:"20",y2:"10",key:"1xfpm4"}],["line",{x1:"12",x2:"12",y1:"20",y2:"4",key:"be30l9"}],["line",{x1:"6",x2:"6",y1:"20",y2:"14",key:"1r4le6"}]]);/**
|
|
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 Eu=ie("ChevronsUpDown",[["path",{d:"m7 15 5 5 5-5",key:"1hf1tw"}],["path",{d:"m7 9 5-5 5 5",key:"sgt6xg"}]]);/**
|
|
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 _u=ie("CircleDollarSign",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M16 8h-6a2 2 0 1 0 0 4h4a2 2 0 1 1 0 4H8",key:"1h4pet"}],["path",{d:"M12 18V6",key:"zqpxq5"}]]);/**
|
|
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 Tu=ie("CircleDot",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}]]);/**
|
|
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 Au=ie("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"}]]);/**
|
|
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 Yn=ie("CirclePlay",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polygon",{points:"10 8 16 12 10 16 10 8",key:"1cimsy"}]]);/**
|
|
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 Ot=ie("ClipboardCheck",[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2",key:"116196"}],["path",{d:"m9 14 2 2 4-4",key:"df797q"}]]);/**
|
|
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 Zo=ie("Clipboard",[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2",key:"116196"}]]);/**
|
|
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 Ru=ie("Cloud",[["path",{d:"M17.5 19H9a7 7 0 1 1 6.71-9h1.79a4.5 4.5 0 1 1 0 9Z",key:"p7xjir"}]]);/**
|
|
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 Ei=ie("Coins",[["circle",{cx:"8",cy:"8",r:"6",key:"3yglwk"}],["path",{d:"M18.09 10.37A6 6 0 1 1 10.34 18",key:"t5s6rm"}],["path",{d:"M7 6h1v4",key:"1obek4"}],["path",{d:"m16.71 13.88.7.71-2.82 2.82",key:"1rbuyh"}]]);/**
|
|
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 Iu=ie("Crown",[["path",{d:"M11.562 3.266a.5.5 0 0 1 .876 0L15.39 8.87a1 1 0 0 0 1.516.294L21.183 5.5a.5.5 0 0 1 .798.519l-2.834 10.246a1 1 0 0 1-.956.734H5.81a1 1 0 0 1-.957-.734L2.02 6.02a.5.5 0 0 1 .798-.519l4.276 3.664a1 1 0 0 0 1.516-.294z",key:"1vdc57"}],["path",{d:"M5 21h14",key:"11awu3"}]]);/**
|
|
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 Xn=ie("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"}]]);/**
|
|
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 Lu=ie("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"}]]);/**
|
|
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 Pu=ie("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"}]]);/**
|
|
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 Du=ie("FileCheck2",[["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:"m3 15 2 2 4-4",key:"1lhrkk"}]]);/**
|
|
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 Fu=ie("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"}]]);/**
|
|
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 Ou=ie("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"}]]);/**
|
|
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 Bu=ie("FilePlus",[["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"}],["path",{d:"M9 15h6",key:"cctwl0"}],["path",{d:"M12 18v-6",key:"17g6i2"}]]);/**
|
|
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 Hu=ie("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"}]]);/**
|
|
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 Vu=ie("Filter",[["polygon",{points:"22 3 2 3 10 12.46 10 19 14 21 14 12.46 22 3",key:"1yg77f"}]]);/**
|
|
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 Uu=ie("FolderGit2",[["path",{d:"M9 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 2v5",key:"1w6njk"}],["circle",{cx:"13",cy:"12",r:"2",key:"1j92g6"}],["path",{d:"M18 19c-2.8 0-5-2.2-5-5v8",key:"pkpw2h"}],["circle",{cx:"20",cy:"19",r:"2",key:"1obnsp"}]]);/**
|
|
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 qu=ie("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"}]]);/**
|
|
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 Wu=ie("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"}]]);/**
|
|
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 Gu=ie("Gauge",[["path",{d:"m12 14 4-4",key:"9kzdfg"}],["path",{d:"M3.34 19a10 10 0 1 1 17.32 0",key:"19p75a"}]]);/**
|
|
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 Qo=ie("GitCommitHorizontal",[["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}],["line",{x1:"3",x2:"9",y1:"12",y2:"12",key:"1dyftd"}],["line",{x1:"15",x2:"21",y1:"12",y2:"12",key:"oup4p8"}]]);/**
|
|
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 Yu=ie("GitMerge",[["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}],["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M6 21V9a9 9 0 0 0 9 9",key:"7kw0sc"}]]);/**
|
|
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 Xu=ie("GitPullRequest",[["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}],["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M13 6h3a2 2 0 0 1 2 2v7",key:"1yeb86"}],["line",{x1:"6",x2:"6",y1:"9",y2:"21",key:"rroup"}]]);/**
|
|
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 Ku=ie("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"}]]);/**
|
|
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 Kn=ie("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"}]]);/**
|
|
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 Zu=ie("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"}]]);/**
|
|
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 Jo=ie("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"}]]);/**
|
|
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 Qu=ie("LayoutGrid",[["rect",{width:"7",height:"7",x:"3",y:"3",rx:"1",key:"1g98yp"}],["rect",{width:"7",height:"7",x:"14",y:"3",rx:"1",key:"6d4xhi"}],["rect",{width:"7",height:"7",x:"14",y:"14",rx:"1",key:"nxv5o0"}],["rect",{width:"7",height:"7",x:"3",y:"14",rx:"1",key:"1bb6yr"}]]);/**
|
|
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 Js=ie("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"}]]);/**
|
|
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 Ju=ie("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"}]]);/**
|
|
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 eh=ie("Mail",[["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}],["path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7",key:"1ocrg3"}]]);/**
|
|
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 ur=ie("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"}]]);/**
|
|
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 Zn=ie("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"}]]);/**
|
|
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 th=ie("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"}]]);/**
|
|
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 _i=ie("Mic",[["path",{d:"M12 2a3 3 0 0 0-3 3v7a3 3 0 0 0 6 0V5a3 3 0 0 0-3-3Z",key:"131961"}],["path",{d:"M19 10v2a7 7 0 0 1-14 0v-2",key:"1vc78b"}],["line",{x1:"12",x2:"12",y1:"19",y2:"22",key:"x3vr5v"}]]);/**
|
|
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 el=ie("Minus",[["path",{d:"M5 12h14",key:"1ays0h"}]]);/**
|
|
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 sh=ie("Monitor",[["rect",{width:"20",height:"14",x:"2",y:"3",rx:"2",key:"48i651"}],["line",{x1:"8",x2:"16",y1:"21",y2:"21",key:"1svkeh"}],["line",{x1:"12",x2:"12",y1:"17",y2:"21",key:"vw1qmm"}]]);/**
|
|
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 tl=ie("Moon",[["path",{d:"M12 3a6 6 0 0 0 9 9 9 9 0 1 1-9-9Z",key:"a7tn18"}]]);/**
|
|
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 sl=ie("Network",[["rect",{x:"16",y:"16",width:"6",height:"6",rx:"1",key:"4q2zg0"}],["rect",{x:"2",y:"16",width:"6",height:"6",rx:"1",key:"8cvhb9"}],["rect",{x:"9",y:"2",width:"6",height:"6",rx:"1",key:"1egb70"}],["path",{d:"M5 16v-3a1 1 0 0 1 1-1h12a1 1 0 0 1 1 1v3",key:"1jsf9p"}],["path",{d:"M12 12V8",key:"2874zd"}]]);/**
|
|
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 ys=ie("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"}]]);/**
|
|
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 Ti=ie("Package",[["path",{d:"M11 21.73a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73z",key:"1a0edw"}],["path",{d:"M12 22V12",key:"d0xqtd"}],["path",{d:"m3.3 7 7.703 4.734a2 2 0 0 0 1.994 0L20.7 7",key:"yx3hmr"}],["path",{d:"m7.5 4.27 9 5.15",key:"1c824w"}]]);/**
|
|
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 nl=ie("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"}]]);/**
|
|
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 nh=ie("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"}]]);/**
|
|
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 ah=ie("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"}]]);/**
|
|
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 ih=ie("Pen",[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}]]);/**
|
|
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 rh=ie("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"}]]);/**
|
|
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 Ns=ie("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"}]]);/**
|
|
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 oh=ie("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"}]]);/**
|
|
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 lh=ie("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"}]]);/**
|
|
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 ch=ie("Scan",[["path",{d:"M3 7V5a2 2 0 0 1 2-2h2",key:"aa7l1z"}],["path",{d:"M17 3h2a2 2 0 0 1 2 2v2",key:"4qcy5o"}],["path",{d:"M21 17v2a2 2 0 0 1-2 2h-2",key:"6vwrx8"}],["path",{d:"M7 21H5a2 2 0 0 1-2-2v-2",key:"ioqczr"}]]);/**
|
|
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 Ss=ie("Server",[["rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2",key:"ngkwjq"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2",key:"iecqi9"}],["line",{x1:"6",x2:"6.01",y1:"6",y2:"6",key:"16zg32"}],["line",{x1:"6",x2:"6.01",y1:"18",y2:"18",key:"nzw8ys"}]]);/**
|
|
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 dh=ie("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"}]]);/**
|
|
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 en=ie("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"}]]);/**
|
|
332
|
+
* @license lucide-react v0.460.0 - ISC
|
|
333
|
+
*
|
|
334
|
+
* This source code is licensed under the ISC license.
|
|
335
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
336
|
+
*/const ss=ie("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"}]]);/**
|
|
337
|
+
* @license lucide-react v0.460.0 - ISC
|
|
338
|
+
*
|
|
339
|
+
* This source code is licensed under the ISC license.
|
|
340
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
341
|
+
*/const uh=ie("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"}]]);/**
|
|
342
|
+
* @license lucide-react v0.460.0 - ISC
|
|
343
|
+
*
|
|
344
|
+
* This source code is licensed under the ISC license.
|
|
345
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
346
|
+
*/const al=ie("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"}]]);/**
|
|
347
|
+
* @license lucide-react v0.460.0 - ISC
|
|
348
|
+
*
|
|
349
|
+
* This source code is licensed under the ISC license.
|
|
350
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
351
|
+
*/const il=ie("Sun",[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]]);/**
|
|
352
|
+
* @license lucide-react v0.460.0 - ISC
|
|
353
|
+
*
|
|
354
|
+
* This source code is licensed under the ISC license.
|
|
355
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
356
|
+
*/const hh=ie("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"}]]);/**
|
|
357
|
+
* @license lucide-react v0.460.0 - ISC
|
|
358
|
+
*
|
|
359
|
+
* This source code is licensed under the ISC license.
|
|
360
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
361
|
+
*/const Ai=ie("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"}]]);/**
|
|
362
|
+
* @license lucide-react v0.460.0 - ISC
|
|
363
|
+
*
|
|
364
|
+
* This source code is licensed under the ISC license.
|
|
365
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
366
|
+
*/const Cs=ie("Terminal",[["polyline",{points:"4 17 10 11 4 5",key:"akl6gq"}],["line",{x1:"12",x2:"20",y1:"19",y2:"19",key:"q2wloq"}]]);/**
|
|
367
|
+
* @license lucide-react v0.460.0 - ISC
|
|
368
|
+
*
|
|
369
|
+
* This source code is licensed under the ISC license.
|
|
370
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
371
|
+
*/const mh=ie("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"}]]);/**
|
|
372
|
+
* @license lucide-react v0.460.0 - ISC
|
|
373
|
+
*
|
|
374
|
+
* This source code is licensed under the ISC license.
|
|
375
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
376
|
+
*/const fh=ie("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"}]]);/**
|
|
377
|
+
* @license lucide-react v0.460.0 - ISC
|
|
378
|
+
*
|
|
379
|
+
* This source code is licensed under the ISC license.
|
|
380
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
381
|
+
*/const tn=ie("Users",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["path",{d:"M16 3.13a4 4 0 0 1 0 7.75",key:"1da9ce"}]]);/**
|
|
382
|
+
* @license lucide-react v0.460.0 - ISC
|
|
383
|
+
*
|
|
384
|
+
* This source code is licensed under the ISC license.
|
|
385
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
386
|
+
*/const ph=ie("Wifi",[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M2 8.82a15 15 0 0 1 20 0",key:"dnpr2z"}],["path",{d:"M5 12.859a10 10 0 0 1 14 0",key:"1x1e6c"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}]]);/**
|
|
387
|
+
* @license lucide-react v0.460.0 - ISC
|
|
388
|
+
*
|
|
389
|
+
* This source code is licensed under the ISC license.
|
|
390
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
391
|
+
*/const xh=ie("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"}]]),rl=f.createContext(null),gh=["button:not([disabled])","[href]","input:not([disabled])","select:not([disabled])","textarea:not([disabled])",'[tabindex]:not([tabindex="-1"])'].join(", ");function Qe(){const t=f.useContext(rl);return t||{open:()=>"",close:()=>{},isModalOpen:!1}}function yh({children:t}){const[s,n]=f.useState([]),a=f.useCallback(r=>{n(o=>{if(!r)return o.slice(0,-1);const l=o.findIndex(c=>c.id===r);return l===-1||l!==o.length-1?o:o.slice(0,-1)})},[]),i=f.useCallback(r=>{const o=`m${Math.random().toString(36).slice(2,9)}`;return n(l=>[...l,{...r,id:o}]),o},[]);return f.useEffect(()=>{if(s.length===0)return;const r=o=>{o.key==="Escape"&&(o.stopPropagation(),a())};return document.addEventListener("keydown",r),()=>document.removeEventListener("keydown",r)},[s.length,a]),e.jsxs(rl.Provider,{value:{open:i,close:a,isModalOpen:s.length>0},children:[t,typeof document<"u"&&Fo.createPortal(e.jsx("div",{className:"modal-stack","aria-hidden":s.length===0,children:s.map((r,o)=>e.jsx(vh,{modal:r,onClose:()=>{var l;(l=r.onClose)==null||l.call(r),a(r.id)},depth:o},r.id))}),document.body)]})}function vh({modal:t,onClose:s,depth:n}){const a=f.useRef(null),i=f.useRef(null),r=f.useId(),o=()=>{const l=a.current;return l?Array.from(l.querySelectorAll(gh)).filter(c=>!c.hasAttribute("disabled")&&c.tabIndex!==-1):[]};return f.useEffect(()=>{var h;i.current=document.activeElement instanceof HTMLElement?document.activeElement:null,(h=o()[0]??a.current)==null||h.focus();const c=m=>{var j,v,g;if(m.key!=="Tab")return;const d=o();if(d.length===0){m.preventDefault(),(j=a.current)==null||j.focus();return}const u=d[0],p=d[d.length-1],x=document.activeElement instanceof HTMLElement?document.activeElement:null;if(m.shiftKey){(!x||x===u||!((v=a.current)!=null&&v.contains(x)))&&(m.preventDefault(),p.focus());return}(!x||x===p||!((g=a.current)!=null&&g.contains(x)))&&(m.preventDefault(),u.focus())};return document.addEventListener("keydown",c),()=>{document.removeEventListener("keydown",c);const m=i.current;m&&m.isConnected&&m.focus()}},[]),e.jsx("div",{className:"modal-backdrop",onClick:l=>{l.stopPropagation(),l.target===l.currentTarget&&s()},style:n>0?{background:"rgba(0,0,0,0.4)"}:void 0,children:e.jsxs("div",{ref:a,className:"modal",role:"dialog","aria-modal":"true","aria-labelledby":t.title?r:void 0,tabIndex:-1,onClick:l=>l.stopPropagation(),style:t.width?{maxWidth:t.width}:void 0,children:[t.title&&e.jsxs("header",{className:"modal-header",children:[e.jsx("h2",{id:r,className:"modal-title",children:t.title}),e.jsx("button",{type:"button",className:"icon-btn","aria-label":"Close",onClick:s,children:e.jsx(Ie,{size:16})})]}),e.jsx("div",{className:"modal-body",children:t.children}),t.footer&&e.jsx("footer",{className:"modal-footer",children:t.footer})]})})}const jh=200,bh=5*60*1e3,Yt=new Map;function wh(t){const s=Yt.get(t);return s?Date.now()-s.ts>bh?(Yt.delete(t),null):s.data:null}function _a(t,s){Yt.size>=jh&&[...Yt.entries()].sort((a,i)=>a[1].ts-i[1].ts).slice(0,50).map(([a])=>a).forEach(a=>Yt.delete(a)),Yt.set(t,{data:s,ts:Date.now()})}function kh(t){if(!t||t==="/")return[{label:"/",path:"/"}];const s=t.split("/").filter(Boolean),n=[];let a="";for(let i=0;i<s.length;i++)a+="/"+s[i],n.push({label:s[i],path:a});return n}function Nh(t){return[...t].sort((s,n)=>s.isDir!==n.isDir?s.isDir?-1:1:s.name.localeCompare(n.name,void 0,{sensitivity:"base"}))}function Sh(t){const s=t.trim();return s?s!==t?{ok:!1,reason:"Name cannot have leading or trailing whitespace."}:s==="."?{ok:!1,reason:"Name cannot be '.'."}:s===".."?{ok:!1,reason:"Name cannot be '..'."}:s.startsWith("-")?{ok:!1,reason:"Name cannot start with '-'."}:s.length>255?{ok:!1,reason:"Name cannot be longer than 255 characters."}:/[/\0:*?"<>|]/.test(s)?{ok:!1,reason:'Name cannot contain / \\ : * ? " < > |'}:{ok:!0}:{ok:!1,reason:"Name cannot be empty."}}function Ch({value:t,onChange:s,initialPath:n,projectsDirectory:a,rootLabel:i="Home",height:r=360}){const[o,l]=f.useState(n??a??""),[c,h]=f.useState(new Set),[m,d]=f.useState(-1),[u,p]=f.useState(null),[x,j]=f.useState({}),[v,g]=f.useState(!1),[b,y]=f.useState(null),[w,S]=f.useState(!1),[$,M]=f.useState(""),[z,A]=f.useState(null),[k,C]=f.useState(!1),_=f.useRef(null),P=f.useCallback(async O=>{try{const K=wh(O);if(K)return K;const Z=await H.get("/fs?path="+encodeURIComponent(O));return _a(O,Z),Z}catch{return null}},[]),N=f.useCallback(async O=>{var K;g(!0),y(null);try{const Z=await H.get("/fs?path="+encodeURIComponent(O));_a(O,Z),p(Z),d(-1)}catch(Z){const Q=((K=Z.data)==null?void 0:K.message)??Z.message??"Failed to load directory";y(Q)}finally{g(!1)}},[]);f.useEffect(()=>{o?N(o):H.get("/fs").then(O=>{_a("",O),p(O),l(O.path),O.path!==t&&s(O.path)}).catch(()=>{y("Could not determine home directory."),g(!1)})},[o]),f.useEffect(()=>{t&&t!==o&&l(t)},[t]);const T=u?Nh(u.entries):[],L=T.filter(O=>O.isDir),R=T,F=O=>{O.isDir&&(l(O.path),s(O.path))},E=()=>{u!=null&&u.parent&&(l(u.parent),s(u.parent))},D=O=>{O!==o&&(l(O),s(O))},G=async()=>{const O=await P("");O&&(l(O.path),s(O.path))},I=async()=>{if(!a)return;const O=await P(a);O&&(l(O.path),s(O.path))},W=()=>{S(!0),M(""),A(null),setTimeout(()=>{var O;return(O=_.current)==null?void 0:O.focus()},0)},V=()=>{S(!1),M(""),A(null)},X=async()=>{var K;const O=Sh($);if(!O.ok){A(O.reason);return}C(!0),A(null);try{const Z=await H.post("/fs/mkdir",{parent:o,name:$.trim()});Yt.delete(o),await N(o),s(Z.path),S(!1),M("")}catch(Z){const Q=Z;Q.status===409?A(`A folder named "${$.trim()}" already exists.`):A(((K=Q.data)==null?void 0:K.message)??Z.message??"Failed to create folder.")}finally{C(!1)}},J=O=>{O.key==="Enter"?(O.preventDefault(),X()):O.key==="Escape"&&(O.preventDefault(),V())},le=O=>{h(K=>{const Z=new Set(K);return Z.has(O)?Z.delete(O):Z.add(O),Z}),x[O]||P(O).then(K=>{K&&j(Z=>({...Z,[O]:K.entries.filter(Q=>Q.isDir)}))})},B=O=>{if(!u)return;const K=R.filter(oe=>oe.isDir),Z=R.filter(oe=>!oe.isDir),Q=[...K,...Z];if(O.key==="ArrowDown")O.preventDefault(),d(oe=>Math.min(oe+1,Q.length-1));else if(O.key==="ArrowUp")O.preventDefault(),d(oe=>Math.max(oe-1,0));else if(O.key==="Enter"||O.key===" "){O.preventDefault();const oe=Q[m];oe&&(O.key==="Enter"&&oe.isDir?F(oe):oe.isDir&&s(oe.path))}else O.key==="Backspace"&&(O.preventDefault(),E())},Y=kh((u==null?void 0:u.path)??o??"/"),ee=u==null?void 0:u.parent,ae=ee!=null,ne=o.split("/").filter(Boolean).at(-1)??"/";return e.jsxs("div",{className:"file-browser",onKeyDown:B,tabIndex:-1,children:[e.jsx("div",{className:"file-browser-breadcrumb",role:"navigation","aria-label":"Path breadcrumb",children:Y.map((O,K)=>e.jsxs("span",{className:"file-browser-breadcrumb-item",children:[K>0&&e.jsx("span",{className:"file-browser-breadcrumb-sep","aria-hidden":!0,children:"/"}),e.jsx("button",{type:"button",className:"file-browser-breadcrumb-btn",onClick:()=>D(O.path),title:O.path,children:K===0?O.path==="/"?"/":i:O.label})]},O.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:E,disabled:!ae,title:"Go up (Backspace)","aria-label":"Go up one level",children:e.jsx($i,{size:13})}),e.jsx("button",{type:"button",className:"file-browser-tool-btn",onClick:()=>N(o),disabled:v,title:"Refresh","aria-label":"Refresh",children:e.jsx(xe,{size:13,className:v?"spin":""})}),e.jsx("button",{type:"button",className:"file-browser-tool-btn",onClick:W,title:"New folder","aria-label":"Create new folder",children:e.jsx(Wu,{size:13})}),e.jsxs("div",{className:"file-browser-chips",children:[e.jsxs("button",{type:"button",className:"file-browser-chip",onClick:G,children:[e.jsx(Ku,{size:11})," ",i]}),a&&e.jsxs("button",{type:"button",className:"file-browser-chip",onClick:I,title:a,children:[e.jsx(qu,{size:11})," ",a.split("/").filter(Boolean).at(-1)??"Projects"]})]})]}),w?e.jsxs("div",{className:"file-browser-mkdir",children:[e.jsx("input",{ref:_,type:"text",className:"file-browser-mkdir-input",placeholder:"Folder name",value:$,onChange:O=>{M(O.target.value),A(null)},onKeyDown:J,"aria-label":"New folder name","aria-invalid":z?"true":void 0,"aria-describedby":z?"mkdir-error":void 0,disabled:k,maxLength:255}),z?e.jsx("span",{id:"mkdir-error",className:"file-browser-mkdir-error",role:"alert",children:z}):e.jsx("span",{className:"file-browser-mkdir-hint",children:"Enter to create, Esc to cancel"})]}):e.jsx("span",{className:"file-browser-count-hint",children:v?"…":`${T.length} in ${ne}`})]}),b&&e.jsxs("div",{className:"file-browser-error",children:[e.jsx(Ni,{size:13}),e.jsx("span",{children:b}),e.jsx("button",{type:"button",className:"file-browser-retry",onClick:()=>N(o),children:"Retry"})]}),e.jsxs("div",{className:"file-browser-body",style:{height:r},children:[e.jsx("div",{className:"file-browser-pane file-browser-tree","aria-label":"Folder tree",children:v&&!u?e.jsx(zh,{}):e.jsx(ol,{path:o,entries:L,expanded:c,childrenMap:x,onToggle:le,onNavigate:F,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"})]}),v&&!u?e.jsx(Mh,{}):e.jsxs(e.Fragment,{children:[(u==null?void 0:u.truncated)&&e.jsxs("div",{className:"file-browser-truncated-banner",role:"status",children:["Showing first 500 of ",u.totalEntries," entries. Navigate into a subfolder to see more."]}),R.length===0?e.jsx("div",{className:"file-browser-empty",children:"This folder is empty"}):e.jsx("div",{className:"file-browser-flat-list",children:R.map((O,K)=>{const Z=O.isDir,Q=K===m,oe=O.path===t;return e.jsxs("div",{role:"option","aria-selected":oe,className:["file-browser-row",Z?"file-browser-row--dir":"file-browser-row--file",Q&&"file-browser-row--selected",oe&&Z&&"file-browser-row--active",!Z&&"file-browser-row--disabled"].filter(Boolean).join(" "),onClick:()=>{Z&&(d(K),s(O.path))},onDoubleClick:()=>{Z&&F(O)},title:O.path,children:[e.jsx("span",{className:"file-browser-row-icon",children:Z?e.jsx(lt,{size:13}):e.jsx(Hu,{size:13})}),e.jsx("span",{className:"file-browser-row-name",children:O.name}),e.jsx("span",{className:"file-browser-row-type",children:Z?"Folder":""})]},O.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 ol({path:t,entries:s,expanded:n,childrenMap:a,onToggle:i,onNavigate:r,level:o}){return e.jsx("ul",{className:"file-browser-tree-list",role:"group",children:s.map(l=>{const c=n.has(l.path),h=a[l.path]??[];return e.jsxs("li",{className:"file-browser-tree-node",children:[e.jsxs("div",{className:["file-browser-tree-row",c&&"file-browser-tree-row--expanded"].filter(Boolean).join(" "),style:{paddingLeft:`${o*16+8}px`},children:[e.jsx("button",{type:"button",className:"file-browser-tree-toggle",onClick:m=>{m.stopPropagation(),i(l.path)},"aria-label":c?"Collapse":"Expand",children:(h.length>0,c?e.jsx(ct,{size:11}):e.jsx(Ut,{size:11}))}),e.jsxs("button",{type:"button",className:"file-browser-tree-name",onClick:()=>r(l),title:l.path,children:[e.jsx(lt,{size:12}),e.jsx("span",{children:l.name})]})]}),c&&h.length>0&&e.jsx(ol,{path:l.path,entries:h,expanded:n,childrenMap:a,onToggle:i,onNavigate:r,level:o+1})]},l.path)})})}function zh(){return e.jsx("div",{className:"file-browser-skeleton-wrap",children:[80,60,90,55,70].map((t,s)=>e.jsx("div",{className:"file-browser-skeleton-row",style:{width:t}},s))})}function Mh(){return e.jsx("div",{className:"file-browser-skeleton-wrap",children:[60,90,70,50,80,65].map((t,s)=>e.jsx("div",{className:"file-browser-skeleton-row",style:{width:t}},s))})}const ai=[{id:"overview",label:"Overview",icon:Jo},{id:"chat",label:"Chat",icon:mn},{id:"agents",label:"Agents",icon:pt},{id:"artifacts",label:"Glyphs",icon:Zn},{id:"tasks",label:"Tasks",icon:Qt},{id:"activity",label:"Activity",icon:He},{id:"background",label:"Active",icon:oh},{id:"skills",label:"Skills",icon:vt},{id:"memory",label:"Memory",icon:xt},{id:"mods",label:"Mods",icon:Ns},{id:"schedules",label:"Schedules",icon:Jt},{id:"history",label:"History",icon:Zs},{id:"minimax",label:"Usage",icon:Ei},{id:"eval",label:"Eval",icon:Ot},{id:"doctor",label:"Doctor",icon:al},{id:"harness",label:"Harness",icon:ss},{id:"goal-planner",label:"Goals",icon:Ai},{id:"settings",label:"Settings",icon:wi}];function $h({activeTab:t,onTabChange:s,wsStatus:n,version:a,activeProject:i,projects:r,onProjectChange:o,onProjectsRefresh:l,onOpenSearch:c,settings:h,rightSlot:m,notificationsSlot:d,showTabs:u=!0,extraTabs:p,clineStatus:x=null}){const[j,v]=f.useState(()=>{var y,w;if(typeof document>"u")return!0;const g=(y=window.localStorage)==null?void 0:y.getItem("bizar.theme");if(g==="light")return!1;if(g==="dark")return!0;const b=document.documentElement.getAttribute("data-theme");return b==="light"?!1:b==="dark"?!0:((w=window.matchMedia)==null?void 0:w.call(window,"(prefers-color-scheme: light)").matches)===!1});return f.useEffect(()=>{var g,b;if(!(typeof document>"u"))if(j){document.documentElement.removeAttribute("data-theme");try{(g=window.localStorage)==null||g.setItem("bizar.theme","dark")}catch{}}else{document.documentElement.setAttribute("data-theme","light");try{(b=window.localStorage)==null||b.setItem("bizar.theme","light")}catch{}}},[j]),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:a})]}),e.jsx(Eh,{activeProject:i,projects:r,onChange:o,onRefresh:l,settings:h??null}),e.jsxs("button",{type:"button",className:"topbar-search",onClick:c,title:"Search (Ctrl/Cmd+K)","aria-label":"Open search",children:[e.jsx(Re,{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:[d,m,e.jsx("button",{type:"button",className:"icon-btn topbar-theme-toggle",onClick:()=>v(g=>!g),"aria-label":j?"Switch to light theme":"Switch to dark theme",title:j?"Switch to light theme":"Switch to dark theme","data-testid":"topbar-theme-toggle",children:j?e.jsx(il,{size:14}):e.jsx(tl,{size:14})}),x&&e.jsxs("div",{className:te("cline-status",`cline-${x.state}`),title:x.detail||`Cline ${x.label}`,"aria-label":`Cline runtime: ${x.label}`,children:[e.jsx("span",{className:"cline-dot"}),e.jsxs("span",{className:"cline-label",children:["Cline · ",x.label]})]}),e.jsxs("div",{className:te("ws-status",`ws-${n}`),title:`WebSocket: ${n}`,children:[e.jsx("span",{className:"ws-dot"}),e.jsx("span",{className:"ws-label",children:n})]})]})]}),u&&e.jsxs("nav",{className:"tabs-row",role:"tablist","aria-label":"Primary tabs",children:[ai.map(g=>{const b=g.icon,y=g.id===t;return e.jsxs("button",{type:"button",role:"tab","aria-selected":y,className:te("tab",y&&"tab-active"),onClick:()=>s(g.id),title:g.label,children:[e.jsx(b,{size:14,className:"tab-icon"}),e.jsx("span",{className:"tab-label",children:g.label}),g.id==="settings"&&y&&e.jsx("span",{className:"settings-mode-indicator",title:"Settings mode active",children:e.jsx(mu,{size:12})})]},g.id)}),p&&p.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"tab-separator","aria-hidden":"true"}),p.map(g=>{const b=g.icon,y=g.id===t;return e.jsxs("button",{type:"button",role:"tab","aria-selected":y,className:te("tab","tab-mod",y&&"tab-active"),onClick:()=>s(g.id),title:`${g.label} (mod)`,children:[e.jsx(b,{size:14,className:"tab-icon"}),e.jsx("span",{className:"tab-label",children:g.label}),e.jsx("span",{className:"tab-badge",children:"mod"})]},g.id)})]})]})]})}function Eh({activeProject:t,projects:s,onChange:n,onRefresh:a,settings:i}){const[r,o]=f.useState(!1),l=Qe();f.useEffect(()=>{if(!r)return;const h=()=>o(!1);return document.addEventListener("click",h),()=>document.removeEventListener("click",h)},[r]);const c=()=>{l.open({title:"Add project",children:e.jsx(_h,{settings:i,onAdd:async(h,m)=>{try{await H.post("/projects",{path:h,name:m}),a(),o(!1),l.close()}catch(d){alert(`Add failed: ${d.message}`)}}}),footer:e.jsx("div",{className:"modal-footer-actions",children:e.jsx(U,{variant:"ghost",onClick:()=>l.close(),children:"Cancel"})})})};return e.jsxs("div",{className:"project-selector",onClick:h=>h.stopPropagation(),children:[e.jsxs("button",{type:"button",className:"project-selector-btn",onClick:()=>o(h=>!h),title:"Switch active project","aria-haspopup":"menu","aria-expanded":r,children:[e.jsx(lt,{size:14}),e.jsx("span",{className:"project-selector-name",children:(t==null?void 0:t.name)||"(no project)"}),e.jsx(ct,{size:12})]}),r&&e.jsxs("div",{className:"project-selector-menu",children:[e.jsxs("div",{className:"project-selector-menu-head",children:[e.jsxs("span",{className:"muted",children:[s.length," project",s.length===1?"":"s"]}),e.jsxs("div",{className:"project-selector-menu-actions",children:[e.jsx("button",{type:"button",className:"icon-btn",onClick:a,title:"Refresh","aria-label":"Refresh projects",children:e.jsx(xe,{size:12})}),e.jsx("button",{type:"button",className:"icon-btn",onClick:c,title:"Add project","aria-label":"Add project",children:e.jsx(We,{size:12})})]})]}),e.jsxs("ul",{className:"project-selector-list",children:[s.length===0&&e.jsx("li",{className:"muted project-selector-empty",children:"No projects. Add one to start."}),s.map(h=>e.jsx("li",{children:e.jsxs("button",{type:"button",className:te("project-selector-item",(t==null?void 0:t.id)===h.id&&"active"),onClick:()=>{n(h.id),o(!1)},children:[e.jsx("span",{className:"project-selector-item-name",children:h.name}),e.jsx("span",{className:"project-selector-item-status",children:h.status})]})},h.id))]})]})]})}function _h({settings:t,onAdd:s}){var d,u;const[n,a]=f.useState(((d=t==null?void 0:t.dashboard)==null?void 0:d.projectsDirectory)??""),[i,r]=f.useState(""),[o,l]=f.useState(!1),[c,h]=f.useState(null),m=async()=>{var p;if(n){l(!0),h(null);try{await H.get("/fs?path="+encodeURIComponent(n)),s(n,i||null)}catch(x){const j=x;j.status===404?h("That folder no longer exists. Pick another."):h(((p=j.data)==null?void 0:p.message)??x.message??"Validation failed.")}finally{l(!1)}}};return e.jsxs("div",{children:[e.jsx("label",{className:"field-label",children:"Folder"}),e.jsx(Ch,{value:n,onChange:p=>{a(p),h(null)},projectsDirectory:(u=t==null?void 0:t.dashboard)==null?void 0:u.projectsDirectory,height:320}),c&&e.jsx("p",{className:"field-help",style:{color:"var(--error)",marginTop:4},children:c}),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:i,onChange:p=>r(p.target.value)})]}),e.jsx("div",{style:{marginTop:"var(--space-3)",display:"flex",justifyContent:"flex-end"},children:e.jsxs(U,{variant:"primary",onClick:m,disabled:!n||o,children:[o?e.jsx("span",{className:"btn-spinner"}):null,o?"Checking…":"Add"]})})]})}const Th=[{label:"General",sections:[{id:"theme",label:"Theme",icon:nl},{id:"layout",label:"Layout",icon:Qu}]},{label:"Core",sections:[{id:"env-vars",label:"Env Vars",icon:Cs},{id:"network",label:"Network",icon:ph},{id:"notifications",label:"Notifications",icon:Xo},{id:"auth",label:"Auth",icon:ss},{id:"system-llm",label:"System LLM",icon:Fn}]},{label:"Agents",sections:[{id:"agents",label:"Agents",icon:tn}]},{label:"Experience",sections:[{id:"updates",label:"Updates",icon:xe},{id:"headroom",label:"Headroom",icon:Gu}]},{label:"Data",sections:[{id:"activity-log",label:"Activity",icon:He},{id:"workspaces",label:"Workspaces",icon:Uu}]}];function Ah({activeSection:t,onSectionChange:s,onExitSettings:n}){return e.jsxs("nav",{className:"sidebar-nav","aria-label":"Settings sections",children:[e.jsxs("button",{type:"button",className:"sidebar-tab",onClick:n,"aria-label":"Exit settings",children:[e.jsx($i,{size:14,"aria-hidden":!0}),e.jsx("span",{className:"sidebar-tab-label",children:"Back"})]}),e.jsx("div",{className:"sidebar-section-divider","aria-hidden":"true"}),Th.map(a=>e.jsxs("div",{className:"settings-nav-group",children:[e.jsx("div",{className:"sidebar-section-label",children:a.label}),a.sections.map(i=>{const r=i.icon,o=t===i.id;return e.jsxs("button",{type:"button",className:te("sidebar-tab",o&&"sidebar-tab-active"),onClick:()=>s(o?null:i.id),"aria-current":o?"page":void 0,children:[r&&e.jsx(r,{size:14,"aria-hidden":!0}),e.jsx("span",{className:"sidebar-tab-label",children:i.label}),o&&e.jsx(Ut,{size:12,"aria-hidden":!0})]},i.id)})]},a.label))]})}function Rh({tabs:t,activeTab:s,onTabChange:n,settingsMode:a,settingsActiveSection:i,onSettingsSectionChange:r,onExitSettings:o}){if(a)return e.jsx("aside",{className:"sidebar sidebar-settings-mode","aria-label":"Settings navigation",children:e.jsx(Ah,{activeSection:i??null,onSectionChange:r??(()=>{}),onExitSettings:o??(()=>{})})});const l=t.filter(h=>!h.isMod),c=t.filter(h=>h.isMod);return e.jsx("aside",{className:"sidebar","aria-label":"Primary navigation",children:e.jsxs("nav",{className:"sidebar-nav",role:"tablist",children:[l.map(h=>{const m=h.icon,d=h.id===s;return e.jsxs("button",{type:"button",role:"tab","aria-selected":d,className:te("sidebar-tab",d&&"sidebar-tab-active"),onClick:()=>n(h.id),title:h.label,children:[e.jsx(m,{size:18,"aria-hidden":!0}),e.jsx("span",{className:"sidebar-tab-label",children:h.label})]},h.id)}),c.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"}),c.map(h=>{const m=h.icon,d=h.id===s;return e.jsxs("button",{type:"button",role:"tab","aria-selected":d,className:te("sidebar-tab","sidebar-tab-mod",d&&"sidebar-tab-active"),onClick:()=>n(h.id),title:`${h.label} (mod)`,children:[e.jsx(m,{size:18,"aria-hidden":!0}),e.jsx("span",{className:"sidebar-tab-label",children:h.label})]},h.id)})]})]})})}const Ta=[{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"}],hr={all:null,projects:"project",agents:"agent",tasks:"task",mods:"mod",schedules:"schedule",commands:"command",settings:"setting"};function Ih({open:t,onClose:s,onSelect:n}){const a=pe(),[i,r]=f.useState(""),[o,l]=f.useState("all"),[c,h]=f.useState([]),[m,d]=f.useState(!1),[u,p]=f.useState(0),x=f.useRef(null),j=f.useRef(null);if(f.useEffect(()=>{let y;return t&&(j.current=document.activeElement instanceof HTMLElement?document.activeElement:null,r(""),h([]),p(0),y=window.setTimeout(()=>{var w;return(w=x.current)==null?void 0:w.focus()},30)),()=>{if(y&&window.clearTimeout(y),!t)return;const w=j.current;w&&w.isConnected&&w.focus()}},[t]),f.useEffect(()=>{if(!t)return;if(!i.trim()){h([]),p(0);return}let y=!1;d(!0);const w=setTimeout(()=>{H.get(`/search?q=${encodeURIComponent(i)}&scope=${o}`).then(S=>{y||(h(S.results||[]),p(0))}).catch(S=>{y||a.error(`Search failed: ${S.message}`)}).finally(()=>!y&&d(!1))},150);return()=>{y=!0,clearTimeout(w)}},[i,o,t,a]),!t)return null;const v={};for(const y of c){const w=y.type.toLowerCase();v[w]=v[w]||[],v[w].push(y)}const g=[];for(const y of Ta.map(w=>w.id)){const w=hr[y];w&&v[w]&&g.push(...v[w])}const b=y=>{if(y.key==="Escape")s();else if(y.key==="ArrowDown"){if(y.preventDefault(),g.length===0)return;p(w=>Math.min(w+1,g.length-1))}else if(y.key==="ArrowUp"){if(y.preventDefault(),g.length===0)return;p(w=>Math.max(w-1,0))}else y.key==="Enter"&&g[u]&&(y.preventDefault(),n(g[u]),s())};return e.jsx("div",{className:"search-modal-backdrop",onClick:s,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",role:"search",children:[e.jsx(Re,{size:14,"aria-hidden":!0}),e.jsx("span",{id:"search-modal-title",className:"sr-only",children:"Search"}),e.jsx("input",{ref:x,className:"search-modal-input",placeholder:"Search tasks, agents, settings, projects…",value:i,onChange:y=>r(y.target.value),onKeyDown:b,"aria-label":"Search"}),e.jsx("button",{type:"button",className:"icon-btn","aria-label":"Close",onClick:s,children:e.jsx(Ie,{size:14})})]}),e.jsx("div",{className:"search-modal-scopes",role:"tablist","aria-label":"Search scope",children:Ta.map(y=>e.jsx("button",{type:"button",role:"tab","aria-selected":o===y.id,className:te("search-scope",o===y.id&&"search-scope-active"),onClick:()=>l(y.id),children:y.label},y.id))}),e.jsxs("div",{className:"search-modal-body",children:[m&&e.jsx("div",{className:"muted",children:"Searching…"}),!m&&i&&g.length===0&&e.jsx("div",{className:"muted",children:"No results."}),!m&&!i&&e.jsx("div",{className:"muted",children:"Type to search…"}),Ta.map(y=>{const w=hr[y.id];if(!w)return null;const S=v[w];return!S||S.length===0?null:e.jsxs("div",{className:"search-group",children:[e.jsx("div",{className:"search-group-head",children:y.label}),S.map($=>{const M=g.indexOf($);return e.jsxs("button",{type:"button",className:te("search-result",M===u&&"search-result-active"),onMouseEnter:()=>p(M),onClick:()=>{n($),s()},children:[e.jsx("span",{className:"search-result-type",children:$.type}),e.jsx("span",{className:"search-result-label",children:Lh($)})]},`${$.type}-${M}`)})]},y.id)})]}),e.jsx("div",{className:"search-modal-foot",children:e.jsx("span",{className:"muted",children:"↑↓ navigate · ↵ open · esc close"})})]})})}function Lh(t){const s=t.item||{};if(t.type==="project")return`${s.name} — ${s.path}`;if(t.type==="agent")return`${s.name} — ${s.description||s.model||""}`;if(t.type==="task")return`${s.title} — ${s.status||""}`;if(t.type==="mod")return`${s.name} v${s.version} — ${s.description||""}`;if(t.type==="schedule")return`${s.name} (${s.type}: ${s.schedule})`;if(t.type==="command")return`${s.name} — ${s.description||""}`;if(t.type==="setting"){const n=s.value===null||s.value===void 0?"":typeof s.value=="string"?` = ${s.value}`:` = ${JSON.stringify(s.value)}`;return`${s.label}${n} — ${s.desc||""}`.trim()}return JSON.stringify(s).slice(0,80)}const Ph={info:Si,success:Ze,warning:qe,error:Ni};function Dh({onCountChange:t,wsSubscribe:s}){const n=pe(),[a,i]=f.useState(!1),[r,o]=f.useState([]),[l,c]=f.useState(null),[h,m]=f.useState(!1),d=f.useRef(null),u=f.useRef(0),p=async()=>{var b;try{m(!0);const y=await H.get("/notifications?limit=200");o(y.notifications||[]),c(y.stats||null),u.current=((b=y.stats)==null?void 0:b.unread)||0,t==null||t(u.current)}catch(y){At.warn("[notifications] reload failed:",y.message)}finally{m(!1)}};f.useEffect(()=>{p()},[]),f.useEffect(()=>s?s(y=>{if(y.type==="notification:new"){const w=y.notification;o(S=>[w,...S.filter($=>$.id!==w.id)]),w.read||(u.current+=1,c(S=>S?{...S,unread:(S.unread||0)+1}:{total:1,unread:1,lastTs:w.ts,counts:{[w.severity||"info"]:1}}),t==null||t(u.current))}else y.type==="notifications:change"&&p()}):void 0,[s]),f.useEffect(()=>{if(!a)return;const b=w=>{d.current&&(d.current.contains(w.target)||i(!1))},y=w=>{w.key==="Escape"&&i(!1)};return document.addEventListener("mousedown",b),document.addEventListener("keydown",y),()=>{document.removeEventListener("mousedown",b),document.removeEventListener("keydown",y)}},[a]);const x=async()=>{try{await H.post("/notifications/read-all",{}),o(b=>b.map(y=>({...y,read:!0}))),c(b=>b&&{...b,unread:0}),u.current=0,t==null||t(0),n.success("All notifications marked as read.",1500)}catch(b){n.error(`Failed: ${b.message}`)}},j=async b=>{try{await H.post(`/notifications/${encodeURIComponent(b)}/read`,{}),o(y=>y.map(w=>w.id===b?{...w,read:!0}:w)),c(y=>y&&{...y,unread:Math.max(0,(y.unread||1)-1)}),u.current=Math.max(0,u.current-1),t==null||t(u.current)}catch(y){n.error(`Failed: ${y.message}`)}},v=async b=>{try{await H.del(`/notifications/${encodeURIComponent(b)}`),o(y=>{const w=y.find(S=>S.id===b);return w&&!w.read&&(u.current=Math.max(0,u.current-1),c(S=>S&&{...S,unread:Math.max(0,S.unread-1)}),t==null||t(u.current)),y.filter(S=>S.id!==b)})}catch(y){n.error(`Failed: ${y.message}`)}},g=(l==null?void 0:l.unread)||0;return e.jsxs("div",{className:"notifications-root",ref:d,children:[e.jsxs("button",{type:"button",className:te("topbar-icon-btn notifications-bell",a&&"is-open"),onClick:()=>i(b=>!b),title:"Notifications","aria-label":"Notifications","aria-haspopup":"true","aria-expanded":a,children:[e.jsx(Xo,{size:16}),g>0&&e.jsx("span",{className:"notifications-badge",children:g>99?"99+":g})]}),a&&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"}),g>0&&e.jsxs("span",{className:"muted text-sm",children:[" · ",g," unread"]})]}),e.jsxs("div",{className:"notifications-panel-head-actions",children:[e.jsxs(U,{size:"sm",variant:"ghost",onClick:x,disabled:g===0,children:[e.jsx(Ht,{size:12})," Mark all read"]}),e.jsx("button",{type:"button",className:"icon-btn",onClick:()=>i(!1),"aria-label":"Close",title:"Close",children:e.jsx(Ie,{size:14})})]})]}),e.jsx("div",{className:"notifications-list",children:h&&r.length===0?e.jsx("div",{className:"notifications-empty muted",children:"Loading…"}):r.length===0?e.jsx("div",{className:"notifications-empty muted",children:"No notifications yet."}):r.map(b=>{const y=Ph[b.severity]||Si;return e.jsxs("div",{className:te("notification-item",!b.read&&"is-unread",`severity-${b.severity}`),children:[e.jsx(y,{size:14,className:`notification-icon severity-${b.severity}`}),e.jsxs("div",{className:"notification-body",children:[b.title&&e.jsx("div",{className:"notification-title",children:b.title}),e.jsx("div",{className:"notification-msg",children:b.message}),e.jsxs("div",{className:"notification-meta muted",children:[e.jsx("span",{className:"mono",children:b.source}),e.jsx("span",{children:"·"}),e.jsx("span",{children:Ve(b.ts)})]})]}),e.jsxs("div",{className:"notification-actions",children:[!b.read&&e.jsx("button",{type:"button",className:"icon-btn",onClick:()=>j(b.id),title:"Mark as read","aria-label":"Mark as read",children:e.jsx(Ht,{size:12})}),e.jsx("button",{type:"button",className:"icon-btn icon-btn-danger",onClick:()=>v(b.id),title:"Remove","aria-label":"Remove",children:e.jsx(Ie,{size:12})})]})]},b.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 Fh({data:t,onClose:s}){const n=t==null?void 0:t.enabled;t==null||t.previousEnabled;const a=t==null?void 0:t.mode,i=t==null?void 0:t.defaultTemplate,r=t==null?void 0:t.lastUsedSlug,o=a==="toggle";return e.jsxs("div",{children:[o?e.jsxs("p",{style:{marginBottom:16,lineHeight:1.6},children:["Visual plan mode has been ",e.jsx("strong",{children:n?"enabled":"disabled"}),".",n?" 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:n?"var(--color-success)":"var(--color-muted)"},children:n?"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."}),i&&e.jsxs("p",{style:{marginTop:8,fontSize:13,color:"var(--color-muted)"},children:["Default template: ",e.jsx("code",{children:i})]}),r&&e.jsxs("p",{style:{fontSize:13,color:"var(--color-muted)"},children:["Last used plan: ",e.jsx("code",{children:r})]}),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(U,{variant:"ghost",onClick:s,children:"Close"})})]})}const Oh=["blank","feature-design","bug-investigation","decision-record","horizontal","vertical"];function Bh({data:t,onClose:s}){const n=(t==null?void 0:t.templates)??Oh,a=(t==null?void 0:t.defaultTemplate)??"blank",[i,r]=f.useState(""),[o,l]=f.useState(a),[c,h]=f.useState(!1),[m,d]=f.useState(null),u=async()=>{if(!i.trim()){d("Slug is required.");return}if(!/^[a-z0-9][a-z0-9-]{0,63}$/.test(i)){d("Invalid slug. Use lowercase letters, numbers, and hyphens. Must start with an alphanumeric character.");return}h(!0),d(null);try{await H.post("/artifacts",{slug:i,template:o}),s()}catch(p){d(p.message),h(!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:i,onChange:p=>{r(p.target.value),d(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:o,onChange:p=>l(p.target.value),children:n.map(p=>e.jsx("option",{value:p,children:p},p))})]}),m&&e.jsx("p",{style:{marginBottom:12,color:"var(--color-danger)",fontSize:13},children:m}),e.jsxs("div",{style:{display:"flex",gap:8,justifyContent:"flex-end"},children:[e.jsx(U,{variant:"ghost",onClick:s,disabled:c,children:"Cancel"}),e.jsx(U,{variant:"primary",onClick:u,disabled:c||!i.trim(),children:c?"Creating…":"Create"})]})]})}function Hh({data:t,onClose:s}){const n=(t==null?void 0:t.plans)??[],a=(t==null?void 0:t.count)??n.length,i=r=>{window.open(`/artifacts/${r}/`,"_blank")};return e.jsxs("div",{children:[n.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:[a," plan",a!==1?"s":""," in this worktree:"]}),e.jsx("ul",{style:{listStyle:"none",padding:0,margin:0},children:n.map(r=>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:r}),e.jsx(U,{variant:"ghost",size:"sm",onClick:()=>i(r),children:"Open"})]},r))})]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(U,{variant:"ghost",onClick:s,children:"Close"})})]})}function Vh({data:t,onClose:s}){const n=(t==null?void 0:t.commands)??[],a=(t==null?void 0:t.templates)??[],i=(t==null?void 0:t.statuses)??[];return e.jsxs("div",{children:[n.length>0?e.jsx("table",{style:{width:"100%",borderCollapse:"collapse",marginBottom:16,fontSize:13},children:e.jsx("tbody",{children:n.map(r=>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:r.cmd})}),e.jsx("td",{style:{padding:"5px 0",color:"var(--color-muted)"},children:r.desc})]},r.cmd))})}):e.jsx("p",{style:{marginBottom:16,color:"var(--color-muted)"},children:"No commands available."}),a.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:a.join(", ")})]}),i.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:i.join(", ")})]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(U,{variant:"ghost",onClick:s,children:"Close"})})]})}function Uh({data:t,onClose:s}){const[n,a]=f.useState(!1),[i,r]=f.useState(null),o=async()=>{a(!0),r(null);try{const l=await H.post("/chat/audit",{});r(l)}catch(l){r({ok:!1,findings:[],error:l.message})}finally{a(!1)}};return e.jsx("div",{children:i===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(U,{variant:"ghost",onClick:s,children:"Cancel"}),e.jsx(U,{variant:"primary",onClick:o,disabled:n,children:n?"Running…":"Run Audit"})]})]}):e.jsxs(e.Fragment,{children:[i.ok?e.jsxs("div",{children:[e.jsx("p",{style:{marginBottom:12,fontWeight:600,color:"var(--color-success)"},children:"Audit passed — no issues found."}),i.findings.length>0&&e.jsx("ul",{style:{marginBottom:16,paddingLeft:20},children:i.findings.map((l,c)=>e.jsx("li",{style:{marginBottom:4,fontSize:13},children:l},c))})]}):e.jsxs("p",{style:{marginBottom:16,color:"var(--color-danger)"},children:["Audit failed: ",i.error??"unknown error"]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(U,{variant:"ghost",onClick:s,children:"Close"})})]})})}function qh({dialog:t,onClose:s}){if(!t.data)return e.jsxs("div",{children:[e.jsx("p",{style:{marginBottom:16,lineHeight:1.6},children:`Command: ${t.command}`}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx("button",{type:"button",className:"btn",onClick:s,children:"Close"})})]});const{message:n,detail:a,url:i}=t.data;return e.jsxs("div",{children:[e.jsx("p",{style:{marginBottom:16,lineHeight:1.6},children:n??`Command: ${t.command}`}),a&&e.jsx("p",{style:{marginBottom:16,color:"var(--color-muted)",fontSize:13},children:a}),i&&e.jsx("p",{style:{marginBottom:16},children:e.jsx("a",{href:i,target:"_blank",rel:"noopener noreferrer",children:i})}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx("button",{type:"button",className:"btn",onClick:s,children:"Close"})})]})}function Wh({dialog:t,onClose:s}){switch(t.component){case"visual-artifact":return e.jsx(Fh,{data:t.data,onClose:s});case"artifact-create":return e.jsx(Bh,{data:t.data,onClose:s});case"artifact-list":return e.jsx(Hh,{data:t.data,onClose:s});case"help":return e.jsx(Vh,{data:t.data,onClose:s});case"audit":return e.jsx(Uh,{data:t.data,onClose:s});default:return e.jsx(qh,{dialog:t,onClose:s})}}f.createContext(null);function _e({as:t="div",p:s,px:n,py:a,m:i,mx:r,my:o,bg:l,border:c,rounded:h,shadow:m,display:d,position:u,className:p,children:x,...j}){return f.createElement(t,{...j,className:fe("box",s!==void 0&&`box-p-${s}`,n!==void 0&&`box-px-${n}`,a!==void 0&&`box-py-${a}`,i!==void 0&&`box-m-${i}`,r!==void 0&&`box-mx-${r}`,o!==void 0&&`box-my-${o}`,l&&`box-bg-${l}`,c&&`box-border-${c}`,h&&`box-rounded-${h}`,m&&`box-shadow-${m}`,d&&`box-d-${d}`,u&&`box-pos-${u}`,p)},x)}function Be({direction:t="column",gap:s=3,align:n,justify:a,wrap:i,as:r="div",className:o,children:l,...c}){return f.createElement(r,{...c,className:fe("stack",t==="row"&&"stack-row",`gap-${s}`,n&&`align-${n}`,a&&`justify-${a}`,i===!0&&"wrap",o)},l)}function Le({direction:t="row",gap:s=3,align:n,justify:a,wrap:i=!0,as:r="div",className:o,children:l,...c}){return f.createElement(r,{...c,className:fe("inline",t==="column"&&"inline-col",`gap-${s}`,n&&`align-${n}`,a&&`justify-${a}`,i?"wrap":"nowrap",o)},l)}function Qn({cols:t=1,gap:s=3,autoFit:n=!1,className:a,children:i,style:r,...o}){return e.jsx("div",{...o,className:fe("grid",!n&&`cols-${t}`,n&&"grid-autofit",`gap-${s}`,a),style:r,children:i})}const nt=f.forwardRef(function({variant:s="secondary",size:n="md",loading:a=!1,fullWidth:i=!1,icon:r,iconRight:o,disabled:l,className:c,children:h,type:m="button",...d},u){return e.jsxs("button",{ref:u,type:m,disabled:l||a,"aria-busy":a||void 0,className:fe("btn",`btn-${s}`,`btn-size-${n}`,a&&"btn-loading",i&&"btn-full",c),...d,children:[a&&e.jsx("span",{className:"btn-spinner","aria-hidden":!0}),r,h,o]})}),ps=f.forwardRef(function({variant:s="secondary",size:n="md",icon:a,disabled:i,className:r,type:o="button",...l},c){return e.jsx("button",{ref:c,type:o,disabled:i,className:fe("icon-btn",`icon-btn-${s}`,`icon-btn-size-${n}`,r),...l,children:a})});f.forwardRef(function({checked:s,onChange:n,label:a,disabled:i,size:r="md",name:o,autoFocus:l,className:c,...h},m){return e.jsxs("label",{...h,className:fe("toggle",r==="sm"&&"toggle-sm",s&&"toggle-checked",c),children:[e.jsx("input",{ref:m,type:"checkbox",role:"switch",name:o,checked:s,disabled:i,autoFocus:l,onChange:d=>n(d.target.checked),className:"toggle-input"}),e.jsx("span",{className:"toggle-track","aria-hidden":!0,children:e.jsx("span",{className:"toggle-thumb"})}),a!==void 0&&e.jsx("span",{className:"toggle-label",children:a})]})});f.forwardRef(function({inputSize:s="md",error:n,leftIcon:a,rightIcon:i,disabled:r,className:o,...l},c){return e.jsxs("span",{className:fe("field",`field-size-${s}`,a&&"field-has-left",i&&"field-has-right",o),children:[a&&e.jsx("span",{className:"field-icon-left",children:a}),e.jsx("input",{ref:c,type:"text",disabled:r,"aria-invalid":n?!0:void 0,className:fe("field-input",n&&"field-error"),...l}),i&&e.jsx("span",{className:"field-icon-right",children:i})]})});const Gh=f.forwardRef(function({inputSize:s="md",error:n,hint:a,disabled:i,className:r,rows:o=4,...l},c){return e.jsxs("span",{className:fe("field","field-textarea",`field-size-${s}`,r),children:[e.jsx("textarea",{ref:c,rows:o,disabled:i,"aria-invalid":n?!0:void 0,className:fe("field-input","field-input-textarea",n&&"field-error"),...l}),a&&e.jsx("span",{className:"field-hint",children:a})]})});f.forwardRef(function({inputSize:s="md",error:n,value:a,onChange:i,min:r,max:o,step:l,disabled:c,className:h,...m},d){return e.jsx("span",{className:fe("field",`field-size-${s}`,h),children:e.jsx("input",{ref:d,type:"number",disabled:c,value:a,min:r,max:o,step:l,"aria-invalid":n?!0:void 0,className:fe("field-input",n&&"field-error"),onChange:u=>{const p=u.target.value;if(p===""){i("");return}const x=Number(p);i(Number.isFinite(x)?x:p)},...m})})});const Yh=f.forwardRef(function({inputSize:s="md",options:n,placeholder:a,error:i,value:r,defaultValue:o,disabled:l,name:c,required:h,onChange:m,className:d,...u},p){return e.jsxs("span",{...u,className:fe("select",`select-size-${s}`,d),children:[e.jsxs("select",{ref:p,disabled:l,name:c,required:h,value:r,defaultValue:o??(a!==void 0?"":void 0),onChange:m,"aria-invalid":i?!0:void 0,className:fe("select-native",i&&"select-error"),children:[a!==void 0&&e.jsx("option",{value:"",disabled:!0,children:a}),n.map(x=>e.jsx("option",{value:x.value,disabled:x.disabled,children:x.label},x.value))]}),e.jsx(ct,{className:"select-caret",size:14,"aria-hidden":!0})]})});f.forwardRef(function({checked:s,onChange:n,label:a,indeterminate:i=!1,disabled:r,name:o,autoFocus:l,required:c,className:h,...m},d){const u=f.useRef(null);f.useEffect(()=>{u.current&&(u.current.indeterminate=i)},[i]);const p=x=>{u.current=x,typeof d=="function"?d(x):d&&(d.current=x)};return e.jsxs("label",{...m,className:fe("checkbox",s&&"checkbox-checked",i&&"checkbox-indeterminate",h),children:[e.jsx("input",{ref:p,type:"checkbox",name:o,checked:s,disabled:r,required:c,autoFocus:l,onChange:x=>n(x.target.checked),className:"checkbox-input"}),e.jsx("span",{className:"checkbox-box","aria-hidden":!0,children:i?e.jsx(el,{strokeWidth:3}):s?e.jsx(Ht,{strokeWidth:3}):null}),a!==void 0&&e.jsx("span",{className:"checkbox-label",children:a})]})});f.forwardRef(function({name:s,value:n,onChange:a,options:i,orientation:r="vertical",legend:o,disabled:l,required:c,className:h,...m},d){return e.jsxs("div",{ref:d,role:"radiogroup",...m,className:fe("radio-group",r==="horizontal"&&"radio-group-horizontal",h),children:[o!==void 0&&e.jsx("p",{className:"radio-option-label",style:{marginBottom:4},children:o}),i.map(u=>{const p=u.value===n;return e.jsxs("label",{className:fe("radio-option",p&&"radio-option-checked"),children:[e.jsx("input",{type:"radio",name:s,value:u.value,checked:p,disabled:l||u.disabled,required:c,onChange:()=>a(u.value),className:"radio-option-input"}),e.jsx("span",{className:"radio-option-box","aria-hidden":!0,children:e.jsx("span",{className:"radio-option-dot"})}),e.jsxs("span",{className:"radio-option-content",children:[e.jsx("span",{className:"radio-option-label",children:u.label}),u.description!==void 0&&e.jsx("span",{className:"radio-option-desc",children:u.description})]})]},u.value)})]})});f.forwardRef(function({value:s,onChange:n,min:a=0,max:i=100,step:r=1,label:o,showValue:l=!1,disabled:c,className:h,...m},d){return e.jsxs("div",{className:fe("slider",h),children:[(o!==void 0||l)&&e.jsxs("div",{className:"slider-header",children:[o!==void 0&&e.jsx("span",{className:"slider-label",children:o}),l&&e.jsx("span",{className:"slider-value",children:String(s)})]}),e.jsx("input",{ref:d,type:"range",min:a,max:i,step:r,value:s,disabled:c,onChange:u=>n(Number(u.target.value)),className:"slider-input",...m})]})});const Xh=f.forwardRef(function({inputSize:s="md",value:n,onChange:a,onClear:i,placeholder:r="Search…",disabled:o,className:l,...c},h){const m=f.useCallback(()=>{a(""),i==null||i()},[a,i]),d=f.useCallback(u=>{a(u.target.value)},[a]);return e.jsxs("span",{className:fe("field",l),children:[e.jsx(Re,{size:14,className:"field-icon-left","aria-hidden":!0}),e.jsx("input",{ref:h,type:"search",value:n,onChange:d,placeholder:r,disabled:o,className:"field-input field-has-left",...c}),n!==""&&!o&&e.jsx("button",{type:"button",onClick:m,className:"field-clear","aria-label":"Clear search",tabIndex:-1,children:e.jsx(Ie,{size:12,"aria-hidden":!0})})]})});function Ds({label:t,value:s,unit:n,delta:a,icon:i,href:r,loading:o=!1,className:l,...c}){const h=r?"a":"div",m=r?{href:r,...c}:c;return e.jsxs(h,{...m,className:fe("bd-stat-tile",r&&"bd-stat-tile--clickable",l),children:[i&&e.jsx("div",{className:"bd-stat-tile__icon",children:i}),e.jsxs("div",{className:"bd-stat-tile__body",children:[e.jsx("div",{className:"bd-stat-tile__label",children:t}),e.jsx("div",{className:"bd-stat-tile__value-row",children:o?e.jsx("div",{className:"bd-stat-tile__skeleton","aria-hidden":"true"}):e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"bd-stat-tile__value",children:s}),n&&e.jsx("span",{className:"bd-stat-tile__unit",children:n})]})}),a&&!o&&e.jsxs("div",{className:fe("bd-stat-tile__delta",a.direction==="up"&&"bd-stat-tile__delta--up",a.direction==="down"&&"bd-stat-tile__delta--down"),"aria-label":`${a.direction==="up"?"up":"down"} ${a.value}`,children:[a.direction==="up"?e.jsx(pn,{size:12,"aria-hidden":"true"}):e.jsx(ha,{size:12,"aria-hidden":"true"}),e.jsx("span",{children:a.value})]})]})]})}function Kh(t,s,n,a){if(t.length===0)return{line:"",area:"",min:0,max:0};const i=Math.min(...t),r=Math.max(...t),o=r-i||1,l=n-a*2,c=s,h=t.length>1?c/(t.length-1):0,m=t.map((j,v)=>{const g=v*h,b=a+l-(j-i)/o*l;return[g,b]}),d=m.map(([j,v],g)=>`${g===0?"M":"L"}${j.toFixed(2)},${v.toFixed(2)}`).join(" "),u=m[m.length-1],p=m[0],x=`${d} L${u[0].toFixed(2)},${(n-a).toFixed(2)} L${p[0].toFixed(2)},${(n-a).toFixed(2)} Z`;return{line:d,area:x,min:i,max:r}}function mr({data:t,width:s=80,height:n=24,stroke:a="var(--chart-1)",fill:i="var(--accent-subtle)",ariaLabel:r,className:o}){const{line:c,area:h}=Kh(t,s,n,2);return e.jsx("svg",{role:"img","aria-label":r??`Sparkline of ${t.length} values`,className:o,width:s,height:n,viewBox:`0 0 ${s} ${n}`,preserveAspectRatio:"none",children:t.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("path",{className:"bd-sparkline__fill",d:h,fill:i}),e.jsx("path",{className:"bd-sparkline__line",d:c,stroke:a})]})})}function Zh({data:t,maxValue:s,showLabels:n=!0,className:a}){const i=s??Math.max(1,...t.map(r=>r.value));return e.jsx("div",{className:fe("bd-bar-chart",a),role:"list",children:t.map((r,o)=>{const l=Math.max(0,Math.min(100,r.value/i*100));return e.jsxs("div",{role:"listitem",className:"bd-bar-chart__row",children:[n&&e.jsxs("div",{className:"bd-bar-chart__header",children:[e.jsx("span",{className:"bd-bar-chart__label",children:r.label}),e.jsx("span",{className:"bd-bar-chart__value",children:r.value})]}),e.jsx("div",{className:"bd-bar-chart__track","aria-hidden":!n,children:e.jsx("div",{className:"bd-bar-chart__bar",style:{width:`${l}%`,background:r.color??"var(--chart-1)"}})})]},`${r.label}-${o}`)})})}function Qh(t){return t==null?"":typeof t=="string"||typeof t=="number"?t:String(t)}function Jh(t,s){return typeof t=="number"&&typeof s=="number"?t-s:String(t).localeCompare(String(s))}function em({columns:t,data:s,rowKey:n,onRowClick:a,sort:i,onSortChange:r,empty:o,loading:l=!1,compact:c=!1,className:h}){const[m,d]=f.useState(null),u=i??m,p=f.useMemo(()=>{if(!u)return s;const v=t.find(y=>y.key===u.key);if(!v)return s;const g=v.accessor??Qh,b=[...s];return b.sort((y,w)=>{const S=Jh(g(y),g(w));return u.direction==="asc"?S:-S}),b},[s,t,u]),x=v=>{const g=!u||u.key!==v?{key:v,direction:"asc"}:u.direction==="asc"?{key:v,direction:"desc"}:null;i===void 0&&d(g),r==null||r(g)},j=()=>{if(l){const v=t.length;return e.jsx(e.Fragment,{children:Array.from({length:3}).map((g,b)=>e.jsx("tr",{className:"bd-data-table__skeleton-row",children:Array.from({length:v}).map((y,w)=>e.jsx("td",{children:e.jsx("div",{className:"bd-data-table__skeleton"})},`skel-${b}-${w}`))},`skel-${b}`))})}return p.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:t.length,className:"bd-data-table__empty",children:o??"No data"})}):p.map(v=>e.jsx("tr",{className:fe(a&&"bd-data-table__row--clickable"),onClick:a?()=>a(v):void 0,children:t.map(g=>e.jsx("td",{className:fe("bd-data-table__td",g.align==="right"&&"bd-data-table__td--right",g.align==="center"&&"bd-data-table__td--center"),children:g.render?g.render(v):String(g.accessor?g.accessor(v):"")},g.key))},n(v)))};return e.jsx("div",{className:fe("bd-data-table",c&&"bd-data-table--compact",h),children:e.jsx("div",{className:"bd-data-table__scroll",children:e.jsxs("table",{className:"bd-data-table__table",children:[e.jsx("thead",{className:"bd-data-table__thead",children:e.jsx("tr",{className:"bd-data-table__tr",children:t.map(v=>{const g=(u==null?void 0:u.key)===v.key,b=v.width!==void 0?{width:v.width}:void 0;return e.jsxs("th",{style:b,className:fe("bd-data-table__th",v.align==="right"&&"bd-data-table__th--right",v.align==="center"&&"bd-data-table__th--center",v.sortable&&"bd-data-table__th--sortable",g&&"bd-data-table__th--sorted"),onClick:v.sortable?()=>x(v.key):void 0,"aria-sort":g?u.direction==="asc"?"ascending":"descending":void 0,children:[v.header,v.sortable&&e.jsx("span",{className:"bd-data-table__sort-icon",children:g?u.direction==="asc"?e.jsx(pn,{size:12,"aria-hidden":"true"}):e.jsx(ha,{size:12,"aria-hidden":"true"}):e.jsx(Eu,{size:12,"aria-hidden":"true"})})]},v.key)})})}),e.jsx("tbody",{className:"bd-data-table__tbody",children:j()})]})})})}function tm({text:t}){const[s,n]=f.useState(!1),a=f.useRef(null);f.useEffect(()=>()=>{a.current&&clearTimeout(a.current)},[]);const i=f.useCallback(()=>{typeof navigator>"u"||!navigator.clipboard||navigator.clipboard.writeText(t).then(()=>{n(!0),a.current&&clearTimeout(a.current),a.current=setTimeout(()=>n(!1),1500)}).catch(()=>{})},[t]);return e.jsx("button",{type:"button",className:fe("bd-kv-list__copy",s&&"bd-kv-list__copy--done"),"aria-label":s?"Copied":"Copy to clipboard",onClick:i,children:s?e.jsx(Ht,{size:12}):e.jsx(Vt,{size:12})})}function ll({items:t,orientation:s="horizontal",className:n}){return e.jsx("dl",{className:fe("bd-kv-list",s==="horizontal"?"bd-kv-list--horizontal":"bd-kv-list--vertical",n),children:t.map(a=>e.jsxs("div",{className:"bd-kv-list__row",children:[e.jsx("dt",{className:"bd-kv-list__label",children:a.label}),e.jsxs("dd",{className:fe("bd-kv-list__value",a.mono&&"bd-kv-list__value--mono"),children:[e.jsx("span",{children:a.value}),a.copyable&&e.jsx(tm,{text:String(a.value)})]})]},a.key))})}function On({title:t,description:s,icon:n,action:a,inline:i=!1,className:r}){return e.jsxs("div",{className:fe("bd-state",i&&"bd-state--inline",r),children:[n!==null&&e.jsx("div",{className:"bd-state__icon","aria-hidden":"true",children:n??e.jsx(Ru,{size:32})}),e.jsx("div",{className:"bd-state__title",children:t}),s&&e.jsx("div",{className:"bd-state__description",children:s}),a&&e.jsx("button",{type:"button",className:"bd-state__action bd-state__action--ghost",onClick:a.onClick,children:a.label})]})}function Ri({label:t,rows:s=3,inline:n=!1,className:a}){return s>0?e.jsxs("div",{className:fe("bd-state",n&&"bd-state--inline",a),role:"status","aria-live":"polite","aria-label":t??"Loading",children:[e.jsx("div",{className:"bd-skeleton-row","aria-hidden":"true",children:Array.from({length:s}).map((i,r)=>e.jsx("div",{className:"bd-skeleton-row__bar"},r))}),t&&e.jsx("div",{className:"bd-state__label",children:t})]}):e.jsxs("div",{className:fe("bd-state",n&&"bd-state--inline",a),role:"status","aria-live":"polite","aria-label":t??"Loading",children:[e.jsx("div",{className:fe("bd-spinner",n&&"bd-spinner--inline"),"aria-hidden":"true"}),t&&e.jsx("div",{className:"bd-state__label",children:t})]})}function wt({title:t,description:s,actions:n,children:a,padding:i=4,variant:r="outlined",className:o}){const l=t!==void 0||s!==void 0||n!==void 0;return e.jsxs("section",{className:fe("bizar-panel",r==="filled"&&"bizar-panel--filled",o),children:[l&&e.jsxs("div",{className:"bizar-panel__header",children:[(t||s)&&e.jsxs("div",{className:"bizar-panel__header-text",children:[t&&e.jsx("h3",{className:"bizar-panel__title",children:t}),s&&e.jsx("p",{className:"bizar-panel__description",children:s})]}),n&&e.jsx("div",{className:"bizar-panel__actions",children:n})]}),e.jsx("div",{className:fe("bizar-panel__body",`bizar-panel__padding--${i}`),children:a})]})}function sm({title:t,subtitle:s,actions:n,eyebrow:a,className:i}){return e.jsxs("header",{className:fe("bizar-view-header",i),children:[e.jsxs("div",{className:"bizar-view-header__text",children:[a&&e.jsx("div",{className:"bizar-view-header__eyebrow",children:a}),t&&e.jsx("h1",{className:"bizar-view-header__title",children:t}),s&&e.jsx("p",{className:"bizar-view-header__subtitle",children:s})]}),n&&e.jsx("div",{className:"bizar-view-header__actions",children:n})]})}f.createContext(null);function ht({variant:t="neutral",size:s="md",children:n,className:a}){return e.jsx("span",{className:fe("bizar-badge",`bizar-badge--${t}`,`bizar-badge--${s}`,a),children:n})}function sn({variant:t="neutral",size:s="md",pulse:n=!1,className:a,label:i}){return e.jsx("span",{className:fe("bizar-status-dot",`bizar-status-dot--${t}`,`bizar-status-dot--${s}`,n&&"bizar-status-dot--pulse",a),role:i?"status":"presentation","aria-label":i})}function nm({setActiveTab:t,refreshKey:s=0}){var h;const[n,a]=f.useState(null),[i,r]=f.useState(!0),o=async()=>{r(!0);try{const[m,d,u]=await Promise.all([H.get("/memory/status").catch(()=>null),H.get("/memory/health").catch(()=>null),H.get("/memory/lightrag/stats").catch(()=>null)]);a({initialized:!!(m!=null&&m.initialized),mode:m==null?void 0:m.mode,projectId:m==null?void 0:m.projectId,vaultRoot:m==null?void 0:m.vaultRoot,branch:m==null?void 0:m.branch,gitClean:m==null?void 0:m.gitClean,noteCount:(m==null?void 0:m.noteCount)||0,healthScore:d==null?void 0:d.score,healthStatus:d==null?void 0:d.status,lightrag:u?{running:u.running,indexedApprox:u.indexedApprox}:void 0})}catch{a({initialized:!1})}finally{r(!1)}};f.useEffect(()=>{o()},[s]);const l=()=>t("memory"),c=(n==null?void 0:n.healthStatus)==="healthy"?"var(--success)":(n==null?void 0:n.healthStatus)==="degraded"?"var(--warning)":(n==null?void 0:n.healthStatus)==="unhealthy"?"var(--error)":"var(--text-dim)";return e.jsxs(se,{className:"memory-overview-card",children:[e.jsxs(de,{children:[e.jsx(xt,{size:14})," Memory",e.jsxs(U,{variant:"ghost",size:"sm",style:{marginLeft:"auto"},onClick:l,children:["Open Memory ",e.jsx(Is,{size:12})]}),e.jsx(U,{variant:"ghost",size:"sm",onClick:o,"aria-label":"Refresh",title:"Refresh",children:e.jsx(xe,{size:12})})]}),e.jsx(ue,{children:"LightRAG + Obsidian vault + git sync — opens the dedicated Memory tab."}),n!=null&&n.initialized?e.jsxs("div",{className:"memory-status-card-grid",children:[e.jsxs("div",{className:"memory-status-card-cell",children:[e.jsxs("div",{className:"memory-status-card-label",children:[e.jsx(He,{size:11})," Health"]}),e.jsx("div",{className:"memory-status-card-value",style:{color:c},children:n.healthScore!==void 0?`${n.healthScore}/100`:"—"}),e.jsx("div",{className:"memory-status-card-sub muted",children:n.healthStatus||"—"})]}),e.jsxs("div",{className:"memory-status-card-cell",children:[e.jsxs("div",{className:"memory-status-card-label",children:[e.jsx(xt,{size:11})," LightRAG"]}),e.jsx("div",{className:"memory-status-card-value",children:(h=n.lightrag)!=null&&h.running?"running":"stopped"}),e.jsx("div",{className:"memory-status-card-sub muted",children:n.lightrag?`${n.lightrag.indexedApprox} chunks`:"—"})]}),e.jsxs("div",{className:"memory-status-card-cell",children:[e.jsxs("div",{className:"memory-status-card-label",children:[e.jsx(Ue,{size:11})," Vault"]}),e.jsxs("div",{className:"memory-status-card-value",children:[n.noteCount," notes"]}),e.jsx("div",{className:"memory-status-card-sub muted ellipsis",title:n.vaultRoot||"",children:n.vaultRoot?n.vaultRoot.split("/").slice(-2).join("/"):"—"})]}),e.jsxs("div",{className:"memory-status-card-cell",children:[e.jsxs("div",{className:"memory-status-card-label",children:[e.jsx(gt,{size:11})," Git"]}),e.jsx("div",{className:"memory-status-card-value",children:n.gitClean===null?n.mode==="local-only"?"local-only":"—":n.gitClean?"clean":"dirty"}),e.jsx("div",{className:"memory-status-card-sub muted",children:n.branch?`branch ${n.branch}`:St(n.branch||"")||"—"})]})]}):e.jsxs("div",{className:"muted",children:["Memory not initialised. Click ",e.jsx("strong",{children:"Open Memory"})," to set it up."]}),i&&!n&&e.jsx("div",{className:"muted text-sm",children:"Loading…"})]})}function am({snapshot:t,settings:s,setActiveTab:n,refreshSnapshot:a}){var D,G;const i=pe();Qe();const r=f.useRef(null),[o,l]=f.useState(t.overview??null),[c,h]=f.useState(!t.overview),[m,d]=f.useState(t.projects||[]),[u,p]=f.useState(((D=t.activeProject)==null?void 0:D.id)||null),[x,j]=f.useState(t.mods||[]),[v,g]=f.useState(!1),[b,y]=f.useState(((G=t.overview)==null?void 0:G.recentActivity)??[]),[w,S]=f.useState(new Set);f.useEffect(()=>{let I=!1;return(async()=>{try{const W=await H.get("/activity/hidden");I||S(new Set(W.hidden||[]))}catch{}})(),()=>{I=!0}},[]);const $=(I,W)=>{const V=`${I.kind||""}|${I.ts||""}|${I.slug||I.title||""}|${W}`;let X=0;for(let J=0;J<V.length;J++)X=(X<<5)-X+V.charCodeAt(J)|0;return Math.abs(X).toString(16).padStart(8,"0").slice(0,16)},M=async I=>{const W=w,V=new Set(W);V.add(I),S(V);try{await H.post("/activity/hide",{keys:[I]})}catch(X){S(W),i.error(`Hide failed: ${X.message}`)}},z=async()=>{if(!window.confirm("Hide every recent activity item from the overview? The full log stays in Settings → Activity Log."))return;const I=b.map((V,X)=>$(V,X)),W=new Set(w);I.forEach(V=>W.add(V)),S(W);try{await H.post("/activity/hide",{keys:I}),i.success(`Hidden ${I.length} item(s).`)}catch(V){i.error(`Clear failed: ${V.message}`)}},A=async()=>{S(new Set);try{await H.del("/activity/hide"),i.success("All hidden activity restored.")}catch(I){i.error(`Restore failed: ${I.message}`)}};f.useEffect(()=>{var I;t.overview&&(l(t.overview),y(t.overview.recentActivity??[]),h(!1)),d(t.projects||[]),p(((I=t.activeProject)==null?void 0:I.id)||null),j(t.mods||[])},[t.overview,t.projects,t.activeProject,t.mods]),f.useEffect(()=>{let I=null;try{const W=H.getToken(),V=W?`/api/activity/stream?token=${encodeURIComponent(W)}`:"/api/activity/stream";I=new EventSource(V),I.addEventListener("snapshot",X=>{try{const J=JSON.parse(X.data);y(Array.isArray(J.events)?J.events.slice(0,50):[])}catch{}}),I.addEventListener("activity",X=>{try{const J=JSON.parse(X.data);y(le=>[J,...le].slice(0,50))}catch{}})}catch{}return()=>{try{I==null||I.close()}catch{}}},[]);const k=async()=>{i.info("Refreshing…",1500),await a();try{const I=await H.get("/projects");d(I.projects||[]),p(I.active||null)}catch{}},C=async()=>{var I;try{const W=await H.post("/projects/auto-detect");d(W.projects||[]),p(W.active||null);const V=(I=W.projects)==null?void 0:I.find(X=>X.id===W.active);i.success(V?`Active: ${V.name}`:"Projects refreshed."),await a()}catch(W){i.error(`Auto-detect failed: ${W.message}`)}},_=async I=>{try{await H.post(`/projects/${encodeURIComponent(I)}/activate`),p(I),i.success("Project activated."),await a()}catch(W){i.error(`Activate failed: ${W.message}`)}},P=f.useMemo(()=>{const I={};(t.tasks||[]).forEach(V=>{I[V.status]=(I[V.status]||0)+1});const W={queued:"var(--chart-3)",doing:"var(--info)",done:"var(--chart-1)",blocked:"var(--warning)",archived:"var(--text-tertiary)"};return Object.entries(I).map(([V,X])=>({label:V,value:X,color:W[V]??"var(--chart-2)"}))},[t.tasks]),N=f.useMemo(()=>{const W=new Array(30).fill(0),V=Date.now();(t.tasks||[]).forEach(J=>{const le=Date.parse(J.createdAt||"");if(Number.isNaN(le))return;const B=Math.floor((V-le)/(24*3600*1e3));B>=0&&B<30&&(W[29-B]+=1)});const X=W[W.length-1]||1;for(let J=0;J<29;J++)W[J]===0&&(W[J]=Math.max(1,Math.round(X*(.6+J/30*.4))));return W},[t.tasks]),T=f.useMemo(()=>{const W=new Array(30).fill(0),V=Date.now();(t.tasks||[]).forEach(J=>{if(!J.assignee)return;const le=Date.parse(J.updatedAt||J.createdAt||"");if(Number.isNaN(le))return;const B=Math.floor((V-le)/(24*3600*1e3));B>=0&&B<30&&(W[29-B]+=1)});const X=W[W.length-1]||1;for(let J=0;J<29;J++)W[J]===0&&(W[J]=Math.max(1,Math.round(X*(.6+J/30*.4))));return W},[t.tasks]),L=f.useMemo(()=>(t.tasks||[]).filter(I=>!!I.assignee&&(I.status==="doing"||I.status==="queued")).length,[t.tasks]),R=(t.tasks||[]).length,F=f.useMemo(()=>t.activeProject?t.activeProject:u?m.find(I=>I.id===u)??null:m[0]??null,[t.activeProject,u,m]),E=f.useMemo(()=>b.slice(0,30).map((I,W)=>({it:I,idx:W,key:$(I,W)})).filter(({key:I})=>!w.has(I)),[b,w]);return c||!o?e.jsx(_e,{as:"div",className:"view view-overview",bg:"0",p:7,children:e.jsx(Be,{direction:"row",align:"center",justify:"center",children:e.jsx(Ri,{label:"Loading overview…"})})}):e.jsx(_e,{as:"div",className:"view view-overview",bg:"0",p:7,children:e.jsxs(Be,{gap:6,children:[e.jsxs(Le,{justify:"between",align:"center",gap:3,wrap:!0,children:[e.jsxs(Be,{gap:1,children:[e.jsx("h1",{className:"overview-title",style:{fontSize:"var(--text-2xl)",fontWeight:"var(--weight-semibold)",margin:0},children:"Overview"}),e.jsx("span",{className:"overview-subtitle muted",style:{fontSize:"var(--text-sm)",color:"var(--text-secondary)"},children:F?`Active: ${F.name}`:"No active project — pick one below."})]}),e.jsxs(Le,{gap:2,align:"center",wrap:!0,children:[m.length>0&&e.jsxs("span",{className:"select select-size-sm overview-project-select","aria-label":"Switch active project",children:[e.jsx("select",{className:"select-native",value:u??"",onChange:async I=>{const W=I.target.value;!W||W===u||await _(W)},"aria-label":"Switch active project","data-testid":"overview-project-select",children:m.map(I=>e.jsx("option",{value:I.id,children:I.name},I.id))}),e.jsx("svg",{className:"select-caret",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2","aria-hidden":!0,children:e.jsx("polyline",{points:"6 9 12 15 18 9"})})]}),e.jsx(nt,{variant:"secondary",size:"sm",onClick:k,icon:e.jsx(xe,{size:12}),"data-testid":"overview-refresh",children:"Refresh"})]})]}),e.jsxs(Qn,{cols:5,autoFit:!0,gap:3,style:{minHeight:"unset"},"data-testid":"overview-stat-row",children:[e.jsx(Ds,{label:"Agents",value:o.counts.agents,icon:e.jsx(pt,{size:18}),href:"#","data-testid":"overview-stat-agents"}),e.jsx(Ds,{label:"Tasks",value:R,icon:e.jsx(Qt,{size:18}),"data-testid":"overview-stat-tasks"}),e.jsx(Ds,{label:"Projects",value:m.length,icon:e.jsx(lt,{size:18}),"data-testid":"overview-stat-projects"}),e.jsx(Ds,{label:"Mods",value:x.length,icon:e.jsx(Ns,{size:18}),"data-testid":"overview-stat-mods"}),e.jsx(Ds,{label:"Background",value:L,icon:e.jsx(Yn,{size:18}),"data-testid":"overview-stat-background"})]}),e.jsxs(Qn,{cols:3,autoFit:!0,gap:3,children:[e.jsx(wt,{title:"Tasks · last 30 days",description:"Bucketed from snapshot.tasks createdAt",padding:3,"data-testid":"overview-panel-tasks-spark",children:e.jsx(_e,{p:3,children:e.jsxs(Be,{direction:"row",justify:"between",align:"end",gap:3,children:[e.jsx(mr,{data:N,width:220,height:56,ariaLabel:"Tasks created per day, last 30"}),e.jsx(_e,{as:"div",className:"overview-spark-meta",style:{fontFamily:"var(--font-mono)",fontVariantNumeric:"tabular-nums",fontSize:"var(--text-2xl)",fontWeight:"var(--weight-semibold)",color:"var(--text-primary)"},children:R})]})})}),e.jsx(wt,{title:"Agent activity · 30d",description:"Distinct assignees touching tasks per day",padding:3,"data-testid":"overview-panel-agents-spark",children:e.jsx(_e,{p:3,children:e.jsxs(Be,{direction:"row",justify:"between",align:"end",gap:3,children:[e.jsx(mr,{data:T,width:220,height:56,stroke:"var(--chart-2)",fill:"var(--info-subtle)",ariaLabel:"Agent touches per day, last 30"}),e.jsx(_e,{as:"div",style:{fontFamily:"var(--font-mono)",fontVariantNumeric:"tabular-nums",fontSize:"var(--text-2xl)",fontWeight:"var(--weight-semibold)",color:"var(--text-primary)"},children:o.counts.agents})]})})}),e.jsx(wt,{title:"Tasks by status",description:"Live snapshot of the kanban buckets",padding:3,"data-testid":"overview-panel-tasks-by-status",children:e.jsx(_e,{as:"div",p:3,children:e.jsx(Zh,{data:P})})}),e.jsx(wt,{title:"Memory",description:"Vault, LightRAG, git sync",padding:3,"data-testid":"overview-panel-memory",children:e.jsx(_e,{as:"div",p:3,children:e.jsx(nm,{setActiveTab:n})})}),e.jsx(wt,{title:"Active project",description:F?`${F.path}`:"No active project selected",padding:3,"data-testid":"overview-panel-active-project",children:F?e.jsx(_e,{p:3,children:e.jsxs(Be,{gap:3,children:[e.jsx(ll,{items:[{key:"pname",label:"Name",value:F.name,mono:!0},{key:"ppath",label:"Path",value:mm(F.path,48),mono:!0,copyable:!0},{key:"pstatus",label:"Status",value:e.jsxs(ht,{variant:F.status==="active"?"success":F.status==="error"?"danger":"neutral",children:[e.jsx(sn,{variant:F.status==="active"?"success":F.status==="error"?"danger":"neutral",size:"sm",pulse:F.status==="active"}),F.status]})},{key:"pseen",label:"Last opened",value:F.lastAccessed&&Ve(F.lastAccessed)||"—"}]}),e.jsxs(Le,{gap:2,wrap:!0,children:[e.jsx(nt,{variant:"primary",size:"sm",onClick:()=>n("tasks"),icon:e.jsx(Qt,{size:12}),children:"Open tasks"}),e.jsx(nt,{variant:"secondary",size:"sm",onClick:C,icon:e.jsx(lt,{size:12}),children:"Auto-detect"})]})]})}):e.jsx(_e,{as:"div",p:3,children:e.jsx(On,{title:"No active project",description:"Add one or auto-detect from the current directory.",inline:!0,icon:e.jsx(lt,{size:20})})})}),e.jsx(wt,{title:"Recent mods",description:"Last few installed extensions",padding:3,"data-testid":"overview-panel-recent-mods",children:x.length===0?e.jsx(_e,{as:"div",p:3,children:e.jsx(On,{title:"No mods installed",description:"Install from the Mods tab.",inline:!0,icon:e.jsx(Ns,{size:20})})}):e.jsx(_e,{p:2,children:e.jsx(Be,{gap:0,children:x.slice(0,6).map(I=>e.jsx(_e,{py:2,px:3,style:{borderTop:"1px solid var(--border-subtle)"},children:e.jsxs(Le,{justify:"between",align:"center",gap:3,children:[e.jsxs(Be,{gap:0,style:{minWidth:0},children:[e.jsx("span",{style:{fontWeight:"var(--weight-medium)",fontSize:"var(--text-base)"},children:I.name}),e.jsxs("span",{className:"muted",style:{fontFamily:"var(--font-mono)",fontSize:"var(--text-xs)",color:"var(--text-tertiary)"},children:["v",I.version," · ",I.type]})]}),e.jsxs(ht,{variant:I.enabled?"success":"neutral",size:"sm",children:[e.jsx(sn,{variant:I.enabled?"success":"neutral",size:"sm"}),I.enabled?"on":"off"]})]})},I.id))})})})]}),e.jsxs(wt,{title:"Recent activity",description:`${E.length} item${E.length===1?"":"s"} · live via SSE`,actions:e.jsxs(Le,{gap:2,align:"center",children:[w.size>0&&e.jsxs(nt,{variant:"ghost",size:"sm",onClick:A,icon:e.jsx(ks,{size:12}),"aria-label":`Restore ${w.size} hidden items`,children:["Restore (",w.size,")"]}),b.length>0&&e.jsx(nt,{variant:"ghost",size:"sm",onClick:z,icon:e.jsx(si,{size:12}),"data-testid":"overview-hide-all","aria-label":"Hide all activity from overview",children:"Hide all"})]}),padding:0,"data-testid":"overview-panel-activity",children:[w.size>0&&e.jsxs(_e,{as:"div",p:3,style:{background:"var(--surface-2)",borderTop:"1px solid var(--border-subtle)",borderBottom:"1px solid var(--border-subtle)",display:"flex",alignItems:"center",justifyContent:"space-between",gap:"var(--space-3)"},role:"status",children:[e.jsxs(Le,{gap:2,align:"center",children:[e.jsx(si,{size:12}),e.jsxs("span",{style:{fontSize:"var(--text-sm)"},children:[w.size," item",w.size===1?"":"s"," ","hidden from the overview."]})]}),e.jsxs(nt,{variant:"ghost",size:"sm",onClick:A,children:[e.jsx(ks,{size:12})," Show them again"]})]}),E.length===0?e.jsx(_e,{as:"div",p:5,children:e.jsx(On,{title:"No activity yet",description:"Use the prompt below or invoke a Bizar command to start a feed.",inline:!0,icon:e.jsx(He,{size:20})})}):e.jsx(Be,{as:"ul",gap:0,role:"list","aria-live":"polite","aria-relevant":"additions","data-testid":"overview-activity-list",children:E.map(({it:I,key:W})=>e.jsx(im,{item:I,activityKey:W,onNavigate:n,onHide:M},W))})]}),e.jsx(wt,{title:"What do you want to do?",description:"Describe what you want — Odin will split it into tasks, delegate to background agents, and track progress in real time.",padding:4,actions:e.jsxs(ht,{variant:"accent",size:"sm",children:[e.jsx(vt,{size:12}),e.jsx("span",{style:{marginLeft:4},children:"Odin + 12 specialists"})]}),"data-testid":"overview-panel-prompts",children:e.jsx("form",{onSubmit:async I=>{var V,X;I.preventDefault();const W=(((V=r.current)==null?void 0:V.value)||"").trim();if(W){g(!0);try{const J=await H.post("/tasks/submit",{title:W});i.success(`Odin split it into ${((X=J.subtasks)==null?void 0:X.length)||1} task(s)`),r.current&&(r.current.value=""),await a()}catch(J){i.error(`Failed: ${J.message}`)}finally{g(!1)}}},children:e.jsxs(Be,{gap:3,children:[e.jsx(Gh,{ref:r,disabled:v,"aria-label":"Describe what you want Odin to do",rows:4,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.","data-testid":"overview-prompt-input"}),e.jsxs(Le,{justify:"between",align:"center",gap:3,wrap:!0,children:[e.jsx(Le,{gap:2,wrap:!0,children:["Implement feature","Fix bug","Refactor","Investigate","Add tests","Document","Optimize","Deploy"].map(I=>e.jsx("button",{type:"button",className:"overview-quick-chip",onClick:()=>{r.current&&(r.current.value=I,r.current.focus())},children:I},I))}),e.jsx(nt,{type:"submit",variant:"primary",size:"md",disabled:v,loading:v,icon:v?void 0:e.jsx(Rt,{size:12}),"data-testid":"overview-submit",children:v?"Submitting…":"Submit to Odin"})]})]})})})]})})}function im({item:t,activityKey:s,onNavigate:n,onHide:a}){const i=cm(t),r=dm(t.kind||""),o=om(t.kind||"activity"),l=lm(t),c=um(t.kind||"");return e.jsxs("li",{className:`overview-activity-row overview-activity-row-${i}`,style:{borderTop:"1px solid var(--border-subtle)",display:"flex",alignItems:"center",gap:"var(--space-3)",paddingInline:"var(--space-4)",paddingBlock:"var(--space-3)"},children:[e.jsxs("button",{type:"button",onClick:()=>{c&&n(c)},className:"overview-activity-row__main",title:c?`Open ${c}`:o,style:{flex:1,display:"flex",alignItems:"center",gap:"var(--space-3)",textAlign:"left",background:"transparent",color:"inherit",padding:0},children:[e.jsx("span",{style:{color:i==="error"?"var(--danger)":i==="warning"?"var(--warning)":i==="success"?"var(--success)":"var(--accent)",display:"inline-flex",alignItems:"center",justifyContent:"center",width:22,height:22,flexShrink:0},children:e.jsx(r,{size:14})}),e.jsxs(Be,{gap:0,style:{minWidth:0,flex:1},children:[e.jsxs(Le,{justify:"between",align:"center",gap:3,wrap:!0,children:[e.jsx("span",{style:{fontSize:"var(--text-sm)",fontWeight:"var(--weight-medium)"},children:o}),e.jsx("span",{style:{fontFamily:"var(--font-mono)",fontVariantNumeric:"tabular-nums",fontSize:"var(--text-xs)",color:"var(--text-tertiary)"},children:hm(t.ts)})]}),e.jsx("span",{className:"muted",style:{fontSize:"var(--text-sm)",color:"var(--text-secondary)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",display:"block"},title:l,children:l})]})]}),e.jsx(ps,{variant:"ghost",size:"sm",onClick:()=>a(s),"aria-label":"Hide from overview",title:"Hide from overview (kept in Settings → Activity Log)",icon:e.jsx(Ie,{size:12})})]})}function rm(t){return t&&t.charAt(0).toUpperCase()+t.slice(1)}function om(t){const s=t.trim().toLowerCase().replace(/[:_]/g,"."),[n,a="updated"]=s.split("."),i={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"},r={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"},o=i[n]||rm(n.replace(/-/g," ")),l=r[a]||a.replace(/-/g," ");return`${o} ${l}`.trim()}function kn(t,s){for(const n of s){const a=t[n];if(typeof a=="string"&&a.trim())return a.trim()}return""}function lm(t){const s=kn(t,["message","text","prompt","title","name"]);if(s)return s;const n=[],a=kn(t,["slug"]),i=kn(t,["agent","author"]),r=kn(t,["status"]);return a&&n.push(`Plan ${a}`),i&&n.push(i),r&&n.push(r),n.length?n.join(" · "):"No additional details."}function cm(t){const s=(t.kind||"").toLowerCase(),n=(t.status||"").toLowerCase();return s.includes("error")||n==="error"||n==="failure"?"error":s.includes("warn")||n==="blocked"?"warning":s.includes("done")||s.includes("success")||n==="done"?"success":"info"}function dm(t){const s=t.toLowerCase();return s==="task"?Qt:s==="agent"?pt:s==="plan"?Zn:s.includes("bg")||s.includes("background")||s.includes("job")?Ci:s==="mod"?Ns:s==="skill"?vt:s.includes("error")||s.includes("failure")?ys:s.includes("warn")?qe:He}function um(t){const s=t.toLowerCase();return s==="task"?"tasks":s==="agent"?"agents":s==="plan"?"artifacts":s.includes("bg")||s.includes("background")?"activity":s==="mod"?"mods":s==="skill"?"skills":null}function hm(t){return Ve(t)}function mm(t,s){if(!t||t.length<=s)return t;const n=Math.floor((s-1)/2);return`${t.slice(0,n)}…${t.slice(-n)}`}const fm=rt.memo(am);function pm({icon:t,title:s,message:n,action:a}){return e.jsxs("div",{className:"chat-empty-state",children:[t&&e.jsx("div",{className:"chat-empty-state-icon",children:t}),e.jsx("h2",{className:"chat-empty-state-title",children:s}),e.jsx("p",{className:"chat-empty-state-message",children:n}),a&&e.jsx("div",{className:"chat-empty-state-action",children:a})]})}function xm({session:t,mode:s,anchor:n,renameDraft:a,setRenameDraft:i,onEdit:r,onDeleteRequest:o,onConfirmDelete:l,onConfirmRename:c,onClose:h}){const m=f.useRef(null),d=Math.round(n.rect.bottom+2),u=Math.max(8,Math.round(window.innerWidth-n.rect.right));f.useEffect(()=>{const x=g=>{const b=g.target;!m.current||!b||m.current.contains(b)||h()},j=g=>{g.key==="Escape"&&h()},v=window.setTimeout(()=>{document.addEventListener("mousedown",x),document.addEventListener("keydown",j)},0);return()=>{window.clearTimeout(v),document.removeEventListener("mousedown",x),document.removeEventListener("keydown",j)}},[h]),f.useEffect(()=>{if(s!=="rename")return;const x=window.setTimeout(()=>{var v;const j=(v=m.current)==null?void 0:v.querySelector("input.session-row-menu-input");j==null||j.focus(),j==null||j.select()},0);return()=>window.clearTimeout(x)},[s]);const p=e.jsxs("div",{ref:m,className:"session-row-menu",role:"menu","aria-label":`Options for ${t.title}`,style:{position:"fixed",top:d,right:u},onClick:x=>x.stopPropagation(),children:[s==="main"&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{type:"button",className:"session-row-menu-item",role:"menuitem",onClick:x=>{x.stopPropagation(),r()},children:[e.jsx(uh,{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:x=>{x.stopPropagation(),o()},children:[e.jsx(Fe,{size:13,"aria-hidden":!0}),e.jsx("span",{children:"Delete"}),e.jsx("kbd",{children:"⌫"})]})]}),s==="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:a,onChange:x=>i(x.target.value),onKeyDown:x=>{x.key==="Enter"?(x.preventDefault(),c()):x.key==="Escape"&&(x.preventDefault(),h())},onClick:x=>x.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:x=>{x.stopPropagation(),h()},children:"Cancel"}),e.jsx("button",{type:"button",className:"btn btn-primary",onClick:x=>{x.stopPropagation(),c()},children:"Save"})]})]}),s==="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:['"',t.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:x=>{x.stopPropagation(),h()},children:"Cancel"}),e.jsx("button",{type:"button",className:"btn btn-danger",onClick:x=>{x.stopPropagation(),l()},children:"Delete"})]})]})]});return Fo.createPortal(p,document.body)}function ii({node:t,depth:s=0,collapsible:n=!1,isLast:a=!0,open:i,onToggle:r}){var p;const[o,l]=f.useState(n),c=i!==void 0,h=c?i:o,m=x=>{c||l(x),r==null||r(x)},d=(((p=t.children)==null?void 0:p.length)??0)>0,u=e.jsxs(e.Fragment,{children:[n&&e.jsx("span",{className:`agent-node-chevron ${h?"open":""}`,"aria-hidden":!0,children:"›"}),e.jsx("span",{className:`agent-node-dot status-${t.status}`,"aria-hidden":!0}),e.jsx("span",{className:"agent-node-name",children:t.name}),t.role&&e.jsx("span",{className:"agent-node-role chat-mono",children:t.role}),e.jsx("span",{className:`agent-node-pill status-${t.status}`,children:t.status})]});return e.jsxs("div",{className:["agent-node",`depth-${s}`,`status-${t.status}`,h?"open":"closed",a?"last":""].filter(Boolean).join(" "),children:[n?e.jsx("button",{type:"button",className:`agent-node-head status-${t.status} collapsible`,onClick:x=>{x.stopPropagation(),m(!h)},"aria-expanded":h,children:u}):e.jsx("div",{className:`agent-node-head status-${t.status}`,children:u}),h&&e.jsxs(e.Fragment,{children:[t.summary&&e.jsx("div",{className:"agent-node-summary",children:t.summary}),d&&e.jsx("div",{className:"agent-node-children",children:t.children.map((x,j)=>e.jsx(ii,{node:x,depth:s+1,collapsible:!1,isLast:j===t.children.length-1},x.id))})]})]})}function gm(t){return t.tree!==void 0}function ym(t){const s=t.open??!0;if(gm(t))return e.jsx("div",{className:`agent-tree variant-${t.variant??"full"}`,children:e.jsx(ii,{node:t.tree.root,depth:0,open:s})});const n=t.children??[];return e.jsx("div",{className:`agent-tree variant-${t.variant} agent-tree-children-only`,children:e.jsx("div",{className:"agent-tree-children-body",children:n.map((a,i)=>e.jsx(f.Fragment,{children:e.jsx(ii,{node:a,depth:0,collapsible:!1,open:s,isLast:i===n.length-1})},a.id))})})}function vm({children:t,variant:s="rail",open:n=!0}){return n?e.jsx(ym,{variant:s,open:n,children:t}):null}const jm=["Today","Yesterday","This week","Earlier"];function fr(t,s){return t.getFullYear()===s.getFullYear()&&t.getMonth()===s.getMonth()&&t.getDate()===s.getDate()}function bm(t,s){const n=t.getTime()-s.getTime();return Math.floor(n/(1e3*60*60*24))}function wm(t){const s=new Date,n=new Date(s);n.setDate(n.getDate()-1);const a=new Date(s);a.setDate(a.getDate()-7);const i={Today:[],Yesterday:[],"This week":[],Earlier:[]};for(const r of t){const o=new Date(Number(r.mtime)||Date.now());fr(o,s)?i.Today.push(r):fr(o,n)?i.Yesterday.push(r):bm(s,o)<7?i["This week"].push(r):i.Earlier.push(r)}return i}function km(t){return new Date(Number(t)||Date.now()).toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit",hour12:!1})}function Nm({state:t,agent:s}){return t==="streaming"?e.jsx("span",{className:"session-state session-state-streaming",title:`${s||"Odin"} is typing…`}):t==="awaiting"?e.jsx("span",{className:"session-state session-state-awaiting",title:"Awaiting your reply","aria-hidden":!0}):t==="idle"?e.jsx("span",{className:"session-state session-state-idle","aria-hidden":!0}):null}function Sm({sessions:t,clineSessions:s=[],activeSessionId:n,activeClineSessionId:a,activeProject:i,creating:r,onCreateSession:o,onSelectSession:l,onSelectClineSession:c,onRenameSession:h,onDeleteSession:m,groupBy:d}){var R;const u=f.useMemo(()=>[...t,...s],[t,s]),p=f.useMemo(()=>[...u].sort((F,E)=>Number(E.mtime??0)-Number(F.mtime??0)),[u]),x=f.useMemo(()=>d?d(p):wm(p),[d,p]),[j,v]=f.useState({}),g=F=>j[F]===!0,[b,y]=f.useState(null),[w,S]=f.useState("main"),[$,M]=f.useState(""),[z,A]=f.useState(null),k=f.useRef({}),C=(F,E="main")=>{const D=k.current[F];if(!D)return;const G=E==="main"?D:D.querySelector(".chat-rail-item-menu-trigger")??D;if(A({id:F,rect:G.getBoundingClientRect()}),y(F),S(E),E==="rename"){const I=[...t,...s].find(W=>W.id===F);M((I==null?void 0:I.title)??(I==null?void 0:I.id)??"")}},_=()=>{y(null),S("main"),M(""),A(null)},P=F=>{if(F.source==="cline"){c(F);return}l(F.id)},N=()=>{if(!z)return;const F=z.id,E=$.trim();if(!E){_();return}h==null||h(F,E),_()},T=()=>{z&&(m==null||m(z.id),_())},L=d?Object.entries(x):jm.filter(F=>{var E;return(E=x[F])==null?void 0:E.length}).map(F=>[F,x[F]]);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:o,disabled:r||!i,title:i?"Create new session":"Pick a project first","aria-label":"Create new session",children:[e.jsx(We,{size:14,"aria-hidden":!0}),e.jsx("span",{children:r?"Creating…":"New session"})]})}),p.length===0?e.jsx("div",{className:"chat-sessions-empty",children:e.jsx(pm,{icon:e.jsx(We,{size:20,"aria-hidden":!0}),title:i?"No sessions yet":"No project",message:i?"Create your first session to start chatting.":"Pick a project in Overview to scope chat sessions."})}):e.jsx("div",{className:"chat-rail-list",children:L.map(([F,E])=>e.jsxs("div",{className:"chat-rail-group",children:[e.jsx("div",{className:"chat-rail-group-label",children:F}),E.map(D=>{var J,le;const G=D.source==="cline",I=G?a===D.id:n===D.id,W=D.tree,V=!!((J=W==null?void 0:W.root)!=null&&J.children&&W.root.children.length>0),X=g(D.id);return e.jsxs(f.Fragment,{children:[e.jsxs("div",{ref:B=>{k.current[D.id]=B},role:"button",tabIndex:0,className:`chat-rail-item state-${D.state??"idle"}${I?" active":""}`,onClick:()=>P(D),onKeyDown:B=>{(B.key==="Enter"||B.key===" ")&&(B.preventDefault(),P(D))},"aria-current":I?"true":void 0,children:[e.jsx(Nm,{state:D.state??"idle",agent:D.agent}),e.jsxs("div",{className:"chat-rail-item-title",children:[D.pinned&&e.jsx("span",{className:"chat-rail-pin","aria-hidden":!0,children:"★"}),G&&e.jsx(Is,{size:11,style:{color:"var(--text-muted)",flexShrink:0},"aria-hidden":!0}),e.jsx("span",{className:"chat-ellipsis",children:D.title||D.id})]}),e.jsxs("div",{className:"chat-rail-item-meta",children:[e.jsx("span",{className:"chat-rail-item-meta-time",children:D.time??km(D.mtime)}),(D.unread??0)>0&&e.jsx("span",{className:"chat-rail-badge",children:D.unread})]}),e.jsx("button",{type:"button",className:`chat-rail-item-menu-trigger${b===D.id?" open":""}`,"aria-label":`Session options for ${D.title||D.id}`,"aria-haspopup":"menu","aria-expanded":b===D.id,onClick:B=>{B.stopPropagation(),b===D.id?_():C(D.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"})]})}),I&&V&&e.jsx("button",{type:"button",className:`chat-rail-tree-chevron${X?" open":""}`,"aria-label":X?"Collapse sub-agents":"Expand sub-agents","aria-expanded":X,onClick:B=>{B.stopPropagation(),v(Y=>({...Y,[D.id]:!Y[D.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"})})})]}),I&&V&&X&&((le=W==null?void 0:W.root)==null?void 0:le.children)&&e.jsx(vm,{children:W.root.children,variant:"rail",open:!0})]},G?`oc-${D.id}`:D.id)})]},F))}),b&&z&&e.jsx(xm,{session:{id:z.id,title:((R=[...t,...s].find(F=>F.id===z.id))==null?void 0:R.title)??z.id},mode:w,anchor:z,renameDraft:$,setRenameDraft:M,onEdit:()=>C(b,"rename"),onDeleteRequest:()=>C(b,"confirm-delete"),onConfirmDelete:T,onConfirmRename:N,onClose:_})]})}function Cm(t){const{text:s,sending:n,onSend:a,activeSource:i}=t,[r,o]=f.useState(!1),l=()=>{!s.trim()||n||(o(!0),a(),window.setTimeout(()=>o(!1),320))};return e.jsxs("div",{className:`chat-composer-wrap chat-composer-source-${i??"none"}`,children:[e.jsx("div",{className:`chat-composer-pill${r?" takeoff":""}`,children:e.jsx(Nu,{...t,onSend:l})}),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"]}),i==="cline"&&e.jsx("span",{className:"chat-composer-source-hint",children:"→ cline"}),i==="bizar"&&e.jsx("span",{className:"chat-composer-source-hint",children:"→ bizar chat"}),n&&e.jsx("span",{className:"chat-composer-source-hint",children:"sending…"})]})]})}function Aa(t){return t.toLocaleString()}function zm(t){return!t||!t.includes("/")?"":t.split("/")[0]}function Mm(t){if(!t)return 0;const s=t.toLowerCase();return s.includes("opus")?15:s.includes("sonnet")?3:s.includes("haiku")?.8:s.includes("gpt-4o")?5:s.includes("gpt-4")?10:s.includes("deepseek")?.27:s.includes("minimax")?.3:s.includes("llama-3.3-70b")?.59:1}function $m({sessionId:t,messages:s,pinned:n,agent:a,model:i,agents:r,mcps:o,allCommands:l,activeSource:c="bizar",onRename:h,onDelete:m,onExport:d,busy:u,error:p,onRetry:x}){const[j,v]=f.useState(null);f.useEffect(()=>{let C=!1;return(async()=>{try{const _=await fetch("/api/usage?range=24h",{headers:{Accept:"application/json"}});if(!_.ok)return;const P=await _.json();C||v(P)}catch{}})(),()=>{C=!0}},[t]);const g=(s==null?void 0:s.length)??0,b=(n==null?void 0:n.size)??0,y=s.reduce((C,_)=>C+(_.content||_.message||"").length,0),w=Math.round(y/4),S=Mm(i),$=w/1e6*S,M=(j==null?void 0:j.totalTokens)??w,z=(j==null?void 0:j.costUsd)??$,A=128e3,k=zm(i);return e.jsxs("aside",{className:"chat-info",children:[p&&e.jsxs("div",{className:"chat-info-section chat-info-error",role:"alert","aria-live":"polite",children:[e.jsxs("h4",{children:[e.jsx(qe,{size:11,style:{marginRight:4,verticalAlign:-1},"aria-hidden":!0})," ","Couldn't load session"]}),e.jsx("p",{className:"chat-info-value chat-ellipsis",title:p.message,children:p.message}),e.jsxs("div",{className:"chat-info-mono",children:["code · ",p.code]}),p.suggestion?e.jsx("p",{className:"chat-info-suggestion",children:p.suggestion}):null,p.canRetry!==!1&&x?e.jsxs("button",{type:"button",className:"btn btn-ghost btn-sm chat-info-retry",onClick:x,title:"Retry loading the session",children:[e.jsx(ua,{size:12,"aria-hidden":!0})," Retry"]}):null]}),e.jsxs("div",{className:"chat-info-section",children:[e.jsxs("div",{className:"chat-info-section-head",children:[e.jsxs("h4",{children:[e.jsx(mn,{size:11,style:{marginRight:4,verticalAlign:-1},"aria-hidden":!0})," ","Session"]}),e.jsx("span",{className:`chat-source-badge chat-source-${c??"none"}`,style:{marginLeft:"auto"},children:c==="cline"?"cline":"bizar chat"})]}),e.jsx("div",{className:"chat-info-mono chat-ellipsis",title:t,children:t||"Live"}),e.jsxs("div",{className:"chat-info-mono",children:[Aa(g)," message",g===1?"":"s",b>0&&` · ${b} pinned`]})]}),e.jsxs("div",{className:"chat-info-section",children:[e.jsxs("h4",{children:[e.jsx(pt,{size:11,style:{marginRight:4,verticalAlign:-1},"aria-hidden":!0})," ","Agent"]}),e.jsx("div",{className:"chat-info-value",children:a||"—"})]}),e.jsxs("div",{className:"chat-info-section",children:[e.jsxs("h4",{children:[e.jsx(Ss,{size:11,style:{marginRight:4,verticalAlign:-1},"aria-hidden":!0})," ","Model"]}),e.jsx("div",{className:"chat-mono chat-ellipsis",title:i,children:i||"—"}),k&&e.jsxs("div",{className:"chat-info-mono",children:["provider · ",k]})]}),e.jsxs("div",{className:"chat-info-section",children:[e.jsx("h4",{children:"Tokens"}),e.jsxs("div",{className:"chat-mono",children:[Aa(M)," / ",Aa(A)]}),e.jsx("div",{className:"chat-info-bar","aria-hidden":!0,children:e.jsx("div",{className:"chat-info-bar-fill",style:{width:`${Math.min(100,M/Math.max(1,A)*100)}%`}})})]}),e.jsxs("div",{className:"chat-info-section",children:[e.jsxs("h4",{children:[e.jsx(_u,{size:11,style:{marginRight:4,verticalAlign:-1},"aria-hidden":!0})," ","Cost"]}),e.jsxs("div",{className:"chat-mono",children:["$",z.toFixed(4)]}),!j&&e.jsx("div",{className:"chat-info-mono",children:"approx · live from MiniMax"})]}),e.jsxs("div",{className:"chat-info-section",children:[e.jsxs("h4",{children:[e.jsx(pt,{size:11,style:{marginRight:4,verticalAlign:-1},"aria-hidden":!0})," ","Attached agents"]}),r!=null&&r.length?e.jsx("div",{className:"chat-info-agents",children:r.map(C=>e.jsx("span",{className:"chat-info-agent",children:C.name},C.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(Ss,{size:11,style:{marginRight:4,verticalAlign:-1},"aria-hidden":!0})," ","MCPs"]}),o!=null&&o.length?e.jsx("div",{className:"chat-info-agents",children:o.map(C=>e.jsx("span",{className:"chat-info-agent",children:C.id},C.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(Cs,{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"]})]}),(h||m||d)&&e.jsxs("div",{className:"chat-info-section",children:[e.jsx("h4",{children:"Actions"}),e.jsxs("div",{className:"chat-info-actions",children:[h&&e.jsxs("button",{type:"button",className:"btn btn-ghost btn-sm",onClick:h,disabled:u==null?void 0:u.rename,title:"Rename session",children:[e.jsx(fn,{size:12,"aria-hidden":!0})," Rename"]}),d&&e.jsxs("button",{type:"button",className:"btn btn-ghost btn-sm",onClick:d,title:"Export transcript",children:[e.jsx(ts,{size:12,"aria-hidden":!0})," Export"]}),m&&e.jsxs("button",{type:"button",className:"btn btn-ghost btn-sm btn-danger",onClick:m,disabled:u==null?void 0:u.delete,title:"Delete session",children:[e.jsx(Fe,{size:12,"aria-hidden":!0})," Delete"]})]})]})]})}function Em({streaming:t,newMessageCount:s,onClick:n,streamingLabel:a="Odin is replying"}){return e.jsx("button",{type:"button",className:`jump-to-latest${t?" is-streaming":""}`,onClick:n,"aria-label":"Jump to latest message",title:"Jump to latest (⌘/Ctrl+End)",children:t?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:a}),s>0&&e.jsx("span",{className:"jump-badge jump-badge-live",children:"live"})]}):e.jsxs(e.Fragment,{children:[e.jsx(ha,{size:14,"aria-hidden":!0}),e.jsx("span",{children:"Jump to latest"}),s>0&&e.jsxs("span",{className:"jump-badge",children:[s," new"]})]})})}function _m({snapshot:t,settings:s,setActiveTab:n,initialTaskId:a,onClearTaskId:i}){const r=pe(),o=Qe(),l=Su(t,s,a??"");f.useEffect(()=>{l.setToast({error:R=>r.error(R),success:R=>r.success(R),info:R=>r.info(R),warning:R=>r.warning(R)})},[l,r]);const[c,h]=f.useState(""),[m,d]=f.useState(s.defaultAgent||"odin"),[u,p]=f.useState(s.defaultModel||""),[x,j]=f.useState([]),v=f.useRef(null),{allCommands:g,suggestions:b,setQuery:y}=Cu(t);f.useEffect(()=>{y(c)},[c,y]);const w=()=>{var R;return(R=v.current)==null?void 0:R.click()},S=R=>{const F=R.target.files;if(!F)return;const E=[];for(let D=0;D<F.length;D++)E.push(F[D].name);j(D=>{const G=E.filter(I=>!D.includes(I));return[...D,...G]}),v.current&&(v.current.value="")},$=async()=>{const R=c.trim();if(!R)return;h(""),y(""),(await l.onSend(R,m,u,x)).ok&&l.jumpToLatest()},M=async()=>{l.busy.create||await l.onCreateSession()},z=R=>{o.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(U,{variant:"secondary",size:"sm",onClick:()=>o.close(),children:"Cancel"}),e.jsx(U,{variant:"danger",size:"sm",onClick:()=>{o.close(),l.deleteMessage(R)},children:"Delete"})]})})},A=(R,F)=>{let E="";o.open({title:"Rename session",children:e.jsx("input",{id:"rename-session-input",autoFocus:!0,defaultValue:F,"aria-label":"Session title",onChange:D=>{E=D.target.value},onKeyDown:D=>{D.key==="Enter"&&(D.preventDefault(),o.close(),l.renameSession(R,E).then(G=>{G&&r.success("Renamed.")}))},style:{width:"100%",padding:"8px 10px",background:"var(--bg)",border:"1px solid var(--border)",borderRadius:"var(--radius-sm)",color:"var(--text)",font:"13px/1.4 var(--font-sans)",marginTop:6}}),footer:e.jsxs("div",{style:{display:"flex",gap:8,justifyContent:"flex-end"},children:[e.jsx(U,{variant:"secondary",size:"sm",onClick:()=>o.close(),children:"Cancel"}),e.jsx(U,{variant:"primary",size:"sm",onClick:()=>{o.close(),l.renameSession(R,E)},children:"Save"})]})})},k=(R,F)=>{o.open({title:"Delete session?",children:e.jsxs("p",{style:{margin:0},children:["Delete ",e.jsx("strong",{children:F}),"? Messages on the cline serve will be removed. This cannot be undone."]}),footer:e.jsxs("div",{style:{display:"flex",gap:8,justifyContent:"flex-end"},children:[e.jsx(U,{variant:"secondary",size:"sm",onClick:()=>o.close(),children:"Cancel"}),e.jsx(U,{variant:"danger",size:"sm",onClick:async()=>{o.close(),await l.deleteSession(R)},children:"Delete"})]})})},C=()=>{const R=l.activeSource==="cline"?l.activeClineSessionId:l.sessionId;if(!R)return;const E=(l.activeSource==="cline"?l.clineMessages:l.bizarMessages).map(W=>{const V=W.ts??"",X=(W.role||"unknown").toUpperCase(),J=W.content||W.message||"";return`[${V}] ${X}: ${J}`}).join(`
|
|
392
|
+
|
|
393
|
+
`),D=new Blob([E],{type:"text/plain;charset=utf-8"}),G=URL.createObjectURL(D),I=document.createElement("a");I.href=G,I.download=`${R}.txt`,document.body.appendChild(I),I.click(),document.body.removeChild(I),URL.revokeObjectURL(G)},_=f.useMemo(()=>l.sessions.map(R=>l.getSessionDisplay(R)),[l.sessions,l.getSessionDisplay]),P=f.useMemo(()=>l.clineSessions.map(R=>l.getSessionDisplay(R)),[l.clineSessions,l.getSessionDisplay]),N=f.useMemo(()=>{const R=l.activeSource==="cline"?l.activeClineSessionId??"":l.sessionId;return R?_.find(F=>F.id===R)??P.find(F=>F.id===R)??null:null},[l.activeSource,l.activeClineSessionId,l.sessionId,_,P]),T=(()=>{var E;const R=`${m||"Odin"} · ${((E=t.activeProject)==null?void 0:E.name)??"no project"}`,F=(N==null?void 0:N.state)??"idle";return F==="streaming"?`Replying · ${R}`:F==="awaiting"?`Your turn · ${R}`:`${R} · idle`})(),L=l.activeSource==="cline"?"cline":"bizar chat";return e.jsxs("div",{className:"chat-shell",children:[e.jsx(zu,{activeProject:t.activeProject,sessionCount:l.sessions.length,sessionsOpen:!0,infoOpen:!0,onToggleSessions:()=>{},onToggleInfo:()=>{},onOpenOverview:()=>n==null?void 0:n("overview")}),e.jsxs("div",{className:"chat-page",children:[e.jsx(Sm,{sessions:_,clineSessions:P,activeSessionId:l.sessionId,activeClineSessionId:l.activeClineSessionId,activeProject:t.activeProject,creating:l.busy.create,onCreateSession:M,onSelectSession:l.selectBizarSession,onSelectClineSession:R=>l.loadClineSession(R.id),onRenameSession:A,onDeleteSession:R=>{const F=l.sessions.find(E=>E.id===R)??l.clineSessions.find(E=>E.id===R);k(R,(F==null?void 0:F.title)??"")}}),e.jsxs("section",{className:"chat-thread-section",children:[e.jsxs("div",{className:"chat-thread-head",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"chat-thread-title-row",children:[e.jsx("div",{className:"chat-thread-title",children:(N==null?void 0:N.title)??l.sessionId??"New chat"}),e.jsx("span",{className:`chat-source-badge chat-source-${l.activeSource??"none"}`,title:l.activeSource==="cline"?"Messages go to the cline serve child":"Messages go to the local chat store",children:L})]}),e.jsxs("div",{className:`chat-thread-sub chat-muted state-${(N==null?void 0:N.state)??"idle"}`,children:[e.jsx("span",{className:"chat-thread-dot"}),T]}),l.clineError&&e.jsxs("div",{className:"chat-thread-error",role:"alert",children:[e.jsx("p",{className:"chat-error-message",children:l.clineError}),l.clineSuggestion&&e.jsx("p",{className:"chat-error-suggestion",children:l.clineSuggestion}),l.activeClineSessionId&&e.jsx("button",{className:"btn btn-sm",type:"button",onClick:()=>l.loadClineSession(l.activeClineSessionId),children:"Retry"})]})]}),e.jsxs("div",{className:"chat-thread-actions",children:[N&&e.jsxs("button",{className:"btn btn-ghost",title:"Rename session",type:"button",disabled:l.busy.rename,onClick:()=>A(N.id,N.title??""),children:[e.jsx(fn,{size:12,"aria-hidden":!0})," ",e.jsx("span",{className:"mono",children:"rename"})]}),N&&e.jsxs("button",{className:"btn btn-ghost btn-danger",title:"Delete session",type:"button",disabled:l.busy.delete,onClick:()=>k(N.id,N.title??N.id),children:[e.jsx(Fe,{size:12,"aria-hidden":!0})," ",e.jsx("span",{className:"mono",children:"delete"})]}),e.jsx("button",{className:"btn btn-ghost",title:"Export transcript",type:"button",onClick:C,children:e.jsx("span",{className:"mono",children:"export"})})]})]}),e.jsx("div",{className:"chat-thread-scroll",ref:l.listRef,onScroll:l.handleScroll,role:"log","aria-live":"polite","aria-relevant":"additions","aria-label":"Chat message thread",children:e.jsx(Mu,{messages:l.activeSource==="cline"?l.clineMessages:l.bizarMessages,loading:l.loading,activeProject:t.activeProject,sessionId:l.activeSource==="cline"?l.activeClineSessionId??l.sessionId:l.sessionId,pinned:l.pinned,activeSource:l.activeSource,onPickSuggestion:R=>h(R),onCopy:R=>l.copyMessage(R),onDelete:z,onTogglePin:l.togglePin,onRegenerate:l.onRegenerate})}),!l.stickToBottom&&e.jsx(Em,{streaming:(N==null?void 0:N.state)==="streaming",newMessageCount:l.newMessageCount,onClick:l.jumpToLatest}),e.jsx(Cm,{agent:m,setAgent:d,model:u,setModel:p,text:c,setText:h,sending:l.sending,activeSource:l.activeSource,onSend:$,attachments:x,setAttachments:j,suggestions:b,onPickSuggestion:R=>h(`${R.split(" ")[0]} `),agents:t.agents||[],onAttach:w}),e.jsx("input",{ref:v,type:"file",multiple:!0,style:{display:"none"},onChange:S,"aria-label":"Attach files to message",tabIndex:-1})]}),e.jsx($m,{sessionId:l.activeSource==="cline"?l.activeClineSessionId??l.sessionId:l.sessionId,messages:l.activeSource==="cline"?l.clineMessages:l.bizarMessages,pinned:l.pinned,agent:m,model:u,agents:t.agents||[],mcps:t.mcps||[],allCommands:g,activeSource:l.activeSource,onRename:()=>{N&&A(N.id,N.title??"")},onDelete:()=>{N&&k(N.id,N.title??N.id)},onExport:C,busy:l.busy})]})]})}const pr=["bash","read","edit","write","webfetch","websearch","task","glob","grep"],xr=["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"],gr="#8b5cf6",Bn=[{id:"reasoning",label:"Reasoning",variant:"accent"},{id:"code",label:"Code",variant:"info"},{id:"design",label:"Design",variant:"success"},{id:"planning",label:"Planning",variant:"warning"},{id:"gitops",label:"GitOps",variant:"danger"},{id:"analysis",label:"Analysis",variant:"neutral"}];function yr(t){if(!t)return{label:"—",variant:"neutral"};const s=Bn.find(n=>n.id===t);return s?{label:s.label,variant:s.variant}:{label:t,variant:"neutral"}}function Ra(t){if(t.isStuck)return"stuck";const s=t.status||"idle";return s==="working"?"working":s==="error"?"error":"idle"}function Nn(t){return t==="stuck"?"stuck":t}function vr(t){return t==="working"?"info":t==="error"||t==="stuck"?"danger":"neutral"}function Fs(t){return t.lastSeenAt??t.lastSeen}function Tm(t,s=4){if(!t||t.length===0)return"—";const n=t.slice(0,s).join(", ");return t.length>s?`${n} +${t.length-s}`:n}function Am({snapshot:t,refreshSnapshot:s}){const n=pe(),a=Qe(),[i,r]=f.useState(t.agents||[]),[o,l]=f.useState(!t.agents),[c,h]=f.useState(""),[m,d]=f.useState(""),[u,p]=f.useState(null);f.useEffect(()=>{r(t.agents||[]),l(!t.agents)},[t.agents]),f.useEffect(()=>{u&&!i.some(k=>k.name===u)&&p(null)},[i,u]);const x=async()=>{try{const k=await H.get("/agents");r(k.agents||[])}catch(k){n.error(`Agents load failed: ${k.message}`)}finally{l(!1)}},j=f.useMemo(()=>{let k=[...i];if(c&&(k=k.filter(C=>c==="__none__"?!C.category:(C.category||"")===c)),m){const C=m.toLowerCase();k=k.filter(_=>_.name.toLowerCase().includes(C)||(_.description||"").toLowerCase().includes(C)||(_.tags||[]).some(P=>P.toLowerCase().includes(C)))}return k.sort((C,_)=>C.name.localeCompare(_.name))},[i,c,m]),v=j.some(k=>typeof Fs(k)=="number"),g=f.useMemo(()=>j.find(k=>k.name===u)||null,[j,u]),b=()=>{let k=null,C=null,_=null,P=null,N=null,T=null,L=null,R=null,F=null;a.open({title:"New agent",width:640,children:e.jsxs("div",{className:"agent-form",children:[e.jsx("label",{className:"field-label",htmlFor:"agent-new-name",children:"Name (a-z, 0-9, dashes)"}),e.jsx("input",{id:"agent-new-name",ref:E=>k=E,className:"input",type:"text",placeholder:"my-agent",autoFocus:!0}),e.jsx("label",{className:"field-label",htmlFor:"agent-new-desc",children:"Description"}),e.jsx("input",{id:"agent-new-desc",ref:E=>{C=E},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",htmlFor:"agent-new-model",children:"Model"}),e.jsxs("select",{id:"agent-new-model",ref:E=>_=E,className:"select",defaultValue:"",children:[e.jsx("option",{value:"",children:"(provider default)"}),xr.map(E=>e.jsx("option",{value:E,children:E},E))]})]}),e.jsxs("div",{className:"task-form-field",children:[e.jsx("label",{className:"field-label",htmlFor:"agent-new-mode",children:"Mode"}),e.jsxs("select",{id:"agent-new-mode",ref:E=>P=E,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",htmlFor:"agent-new-color",children:"Color"}),e.jsx("input",{id:"agent-new-color",ref:E=>N=E,className:"input",type:"color",defaultValue:gr})]})]}),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",htmlFor:"agent-new-category",children:"Category"}),e.jsxs("select",{id:"agent-new-category",ref:E=>F=E,className:"select",defaultValue:"",children:[e.jsx("option",{value:"",children:"(none)"}),Bn.map(E=>e.jsx("option",{value:E.id,children:E.label},E.id))]})]}),e.jsxs("div",{className:"task-form-field",style:{flex:2},children:[e.jsx("label",{className:"field-label",htmlFor:"agent-new-tags",children:"Tags (comma-separated)"}),e.jsx("input",{id:"agent-new-tags",ref:E=>R=E,className:"input",type:"text",placeholder:"reasoning, code, planning"})]})]}),e.jsxs("fieldset",{children:[e.jsx("legend",{className:"field-label",style:{padding:0},children:"Tools"}),e.jsx("div",{ref:E=>L=E,className:"agent-tools",children:pr.map(E=>e.jsxs("label",{className:"checkbox-row",children:[e.jsx("input",{type:"checkbox",value:E,"aria-label":E}),e.jsx("span",{children:E})]},E))})]}),e.jsx("label",{className:"field-label",htmlFor:"agent-new-prompt",children:"System prompt"}),e.jsx("textarea",{id:"agent-new-prompt",ref:E=>T=E,className:"textarea",rows:6,placeholder:"You are a..."})]}),footer:e.jsxs("div",{className:"modal-footer-actions",children:[e.jsx(U,{variant:"ghost",onClick:()=>a.close(),children:"Cancel"}),e.jsxs(U,{variant:"primary",onClick:async()=>{const E=((k==null?void 0:k.value)||"").trim();if(!/^[a-z0-9][a-z0-9-]{0,63}$/i.test(E)){n.warning("Invalid name (a-z, 0-9, dashes).");return}const D=[];L&&L.querySelectorAll('input[type="checkbox"]:checked').forEach(I=>{D.push(I.value)});const G=((R==null?void 0:R.value)||"").split(",").map(I=>I.trim()).filter(Boolean);try{const I=await H.post("/agents",{name:E,description:((C==null?void 0:C.value)||"").trim(),model:(_==null?void 0:_.value)||"",mode:(P==null?void 0:P.value)||"subagent",color:(N==null?void 0:N.value)||"",tools:D,tags:G,category:(F==null?void 0:F.value)||"",prompt:(T==null?void 0:T.value)||""});r(W=>[...W,I]),p(I.name),n.success("Agent created."),a.close(),await s()}catch(I){n.error(`Create failed: ${I.message}`)}},children:[e.jsx(bs,{size:12})," Create"]})]})})},y=async k=>{let C=null,_=null,P=null,N=null,T=null,L=null,R=null,F=null;try{const E=await H.get(`/agents/${encodeURIComponent(k.name)}`);a.open({title:`Edit ${k.name}`,width:640,children:e.jsxs("div",{className:"agent-form",children:[e.jsxs("div",{className:"muted",children:["File: ",e.jsx("code",{children:E.path})]}),e.jsx("label",{className:"field-label",htmlFor:"agent-edit-desc",children:"Description"}),e.jsx("input",{id:"agent-edit-desc",ref:D=>{C=D},className:"input",type:"text",defaultValue:E.description}),e.jsxs("div",{className:"task-form-row",children:[e.jsxs("div",{className:"task-form-field",children:[e.jsx("label",{className:"field-label",htmlFor:"agent-edit-model",children:"Model"}),e.jsxs("select",{id:"agent-edit-model",ref:D=>_=D,className:"select",defaultValue:E.model,children:[e.jsx("option",{value:"",children:"(provider default)"}),xr.map(D=>e.jsx("option",{value:D,children:D},D))]})]}),e.jsxs("div",{className:"task-form-field",children:[e.jsx("label",{className:"field-label",htmlFor:"agent-edit-mode",children:"Mode"}),e.jsxs("select",{id:"agent-edit-mode",ref:D=>P=D,className:"select",defaultValue:E.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",htmlFor:"agent-edit-color",children:"Color"}),e.jsx("input",{id:"agent-edit-color",ref:D=>N=D,className:"input",type:"color",defaultValue:E.color||gr})]})]}),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",htmlFor:"agent-edit-category",children:"Category"}),e.jsxs("select",{id:"agent-edit-category",ref:D=>F=D,className:"select",defaultValue:E.category||"",children:[e.jsx("option",{value:"",children:"(none)"}),Bn.map(D=>e.jsx("option",{value:D.id,children:D.label},D.id))]})]}),e.jsxs("div",{className:"task-form-field",style:{flex:2},children:[e.jsx("label",{className:"field-label",htmlFor:"agent-edit-tags",children:"Tags (comma-separated)"}),e.jsx("input",{id:"agent-edit-tags",ref:D=>R=D,className:"input",type:"text",defaultValue:(E.tags||[]).join(", ")})]})]}),e.jsxs("fieldset",{children:[e.jsx("legend",{className:"field-label",style:{padding:0},children:"Tools"}),e.jsx("div",{ref:D=>L=D,className:"agent-tools",children:pr.map(D=>{var G;return e.jsxs("label",{className:"checkbox-row",children:[e.jsx("input",{type:"checkbox",value:D,"aria-label":D,defaultChecked:(G=E.tools)==null?void 0:G.includes(D)}),e.jsx("span",{children:D})]},D)})})]}),e.jsx("label",{className:"field-label",htmlFor:"agent-edit-prompt",children:"System prompt"}),e.jsx("textarea",{id:"agent-edit-prompt",ref:D=>T=D,className:"textarea",rows:8,defaultValue:E.prompt||""})]}),footer:e.jsxs("div",{className:"modal-footer-actions",children:[e.jsx(U,{variant:"ghost",onClick:()=>a.close(),children:"Cancel"}),e.jsxs(U,{variant:"primary",onClick:async()=>{const D=[];L&&L.querySelectorAll('input[type="checkbox"]:checked').forEach(I=>{D.push(I.value)});const G=((R==null?void 0:R.value)||"").split(",").map(I=>I.trim()).filter(Boolean);try{const I=await H.put(`/agents/${encodeURIComponent(k.name)}`,{description:((C==null?void 0:C.value)||"").trim(),model:(_==null?void 0:_.value)||"",mode:(P==null?void 0:P.value)||"subagent",color:(N==null?void 0:N.value)||"",tools:D,tags:G,category:(F==null?void 0:F.value)||"",prompt:(T==null?void 0:T.value)||""});r(W=>W.map(V=>V.name===k.name?I:V)),n.success("Agent saved."),a.close(),await s()}catch(I){n.error(`Save failed: ${I.message}`)}},children:[e.jsx(bs,{size:12})," Save"]})]})})}catch(E){n.error(`Load failed: ${E.message}`)}},w=async k=>{if(confirm(`Delete agent "${k.name}"? This removes ${k.path}.`))try{await H.del(`/agents/${encodeURIComponent(k.name)}`),r(C=>C.filter(_=>_.name!==k.name)),n.success("Agent deleted.")}catch(C){n.error(`Delete failed: ${C.message}`)}},S=k=>{let C=null;a.open({title:`Invoke ${k.name}`,children:e.jsxs("div",{className:"invoke-form",children:[e.jsxs("p",{className:"muted invoke-form-meta mono",children:[k.model||"—"," · ",k.path]}),e.jsx("p",{className:"invoke-form-desc",children:k.description}),e.jsx("label",{className:"field-label",htmlFor:"invoke-prompt",children:"Prompt"}),e.jsx("textarea",{ref:_=>C=_,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(U,{variant:"ghost",onClick:()=>a.close(),children:"Cancel"}),e.jsxs(U,{variant:"primary",onClick:async()=>{const _=((C==null?void 0:C.value)||"").trim();if(!_){n.warning("Prompt is required.");return}try{await H.post(`/agents/${encodeURIComponent(k.name)}/invoke`,{prompt:_}),n.success(`Invoked ${k.name}.`),a.close()}catch(P){n.error(`Invoke failed: ${P.message}`)}},children:[e.jsx(ws,{size:14})," Invoke"]})]})})},$=async k=>{try{const C=await H.post(`/agents/${encodeURIComponent(k.name)}/restart`);r(_=>_.map(P=>P.name===k.name?C:P)),n.success(`${k.name} restarted.`)}catch(C){n.error(`Restart failed: ${C.message}`)}},M=[{key:"name",header:"Name",sortable:!0,accessor:k=>k.name,render:k=>e.jsxs("span",{className:"agents-name-cell",children:[e.jsx("span",{className:fe("agents-name-cell__swatch",!k.color&&"agents-name-cell__swatch--empty"),style:k.color?{background:k.color}:void 0,"aria-hidden":"true"}),k.name]})},{key:"status",header:"Status",sortable:!0,accessor:k=>Ra(k),render:k=>{const C=Ra(k);return e.jsxs("span",{className:"agents-status-cell",children:[e.jsx(sn,{variant:vr(C),size:"sm",pulse:C==="stuck",label:Nn(C)}),e.jsx("span",{className:fe("agents-status-cell__label",C==="stuck"&&"agents-status-cell__label--stuck"),children:Nn(C)})]})}},{key:"category",header:"Category",sortable:!0,accessor:k=>k.category||"",render:k=>{const C=yr(k.category);return k.category?e.jsx("span",{className:"agents-category-cell",children:e.jsx(ht,{variant:C.variant,size:"sm",children:C.label})}):e.jsx("span",{className:"muted",children:"—"})}},{key:"tags",header:"Tags",accessor:k=>(k.tags||[]).join(","),render:k=>e.jsx("span",{className:"agents-tags-cell",title:(k.tags||[]).join(", "),children:Tm(k.tags)})}];v&&M.push({key:"lastSeen",header:"Last seen",sortable:!0,accessor:k=>Fs(k)||0,render:k=>{const C=Fs(k);return e.jsx("span",{className:"muted tabular-nums",children:C?Ve(C):"—"})}});function z(){var T;if(!g)return e.jsxs("div",{className:"agents-detail__placeholder",children:[e.jsx("span",{className:"agents-detail__placeholder-icon","aria-hidden":"true",children:e.jsx(pt,{size:28})}),e.jsx("span",{className:"agents-detail__placeholder-title",children:"No agent selected"}),e.jsx("span",{children:"Pick a row from the table to see its metadata, actions, and prompt."})]});const k=g,C=Ra(k),_=yr(k.category),P=k.isStuck||k.status==="working"||k.status==="error",N=[{key:"status",label:"Status",value:e.jsxs("span",{className:"agents-status-cell",children:[e.jsx(sn,{variant:vr(C),size:"sm",pulse:C==="stuck",label:Nn(C)}),e.jsx("span",{className:"agents-status-cell__label",children:Nn(C)})]})},{key:"category",label:"Category",value:k.category?e.jsx(ht,{variant:_.variant,size:"sm",children:_.label}):e.jsx("span",{className:"muted",children:"—"})},{key:"tags",label:"Tags",value:k.tags&&k.tags.length>0?e.jsx(Le,{gap:1,className:"agents-detail__tags",children:k.tags.map(L=>e.jsx(ht,{variant:"neutral",size:"sm",children:L},L))}):e.jsx("span",{className:"muted",children:"—"})},{key:"tools",label:"Tools",value:k.tools&&k.tools.length>0?e.jsx(Le,{gap:1,className:"agents-detail__tools",children:k.tools.map(L=>e.jsx(ht,{variant:"info",size:"sm",children:L},L))}):e.jsx("span",{className:"muted",children:"—"})},{key:"model",label:"Model",mono:!0,copyable:!0,value:k.model||"—"},{key:"mode",label:"Mode",value:k.mode||"subagent"},{key:"color",label:"Color",value:k.color?e.jsxs(Le,{gap:2,align:"center",children:[e.jsx("span",{className:"agents-detail__name-swatch",style:{background:k.color},"aria-hidden":"true"}),e.jsx("code",{className:"mono",children:k.color})]}):e.jsx("span",{className:"muted",children:"—"})},{key:"description",label:"Description",value:k.description?e.jsx("div",{className:"agents-detail__description",children:Oo(k.description,600)}):e.jsx("span",{className:"muted",children:"—"})}];return typeof Fs(k)=="number"&&N.push({key:"lastSeen",label:"Last seen",mono:!0,value:Ve(Fs(k))}),(T=k.lastError)!=null&&T.message&&N.push({key:"lastError",label:"Last error",value:e.jsx("div",{className:"agents-detail__error",children:k.lastError.message})}),e.jsxs(Be,{gap:4,className:"agents-detail__meta",children:[e.jsx(ll,{items:N,orientation:"horizontal"}),e.jsxs(_e,{className:"agents-detail__prompt",children:[e.jsx("span",{className:"agents-detail__prompt-label",children:"System prompt"}),k.prompt?e.jsx("pre",{className:"agents-detail__prompt-body",children:k.prompt}):e.jsx("span",{className:"agents-detail__prompt-empty",children:"No prompt configured."})]}),e.jsxs(Le,{gap:2,wrap:!0,className:"agents-detail__actions",children:[e.jsx(nt,{variant:"secondary",size:"sm",icon:e.jsx(fn,{size:12}),onClick:()=>y(k),"aria-label":`Edit ${k.name}`,"data-testid":`agents-detail-edit-${k.name}`,children:"Edit"}),e.jsx(nt,{variant:"secondary",size:"sm",icon:e.jsx(ws,{size:12}),onClick:()=>S(k),"aria-label":`Invoke ${k.name}`,"data-testid":`agents-detail-invoke-${k.name}`,children:"Invoke"}),P&&e.jsx(nt,{variant:"ghost",size:"sm",icon:e.jsx(ua,{size:12}),onClick:()=>$(k),"aria-label":`Restart ${k.name}`,"data-testid":`agents-detail-restart-${k.name}`,children:"Restart"}),e.jsx(nt,{variant:"danger",size:"sm",icon:e.jsx(Fe,{size:12}),onClick:()=>w(k),"aria-label":`Delete ${k.name}`,"data-testid":`agents-detail-delete-${k.name}`,children:"Delete"})]}),k.isStuck&&e.jsxs(Le,{gap:2,align:"center",className:"agents-detail__error",children:[e.jsx(Ni,{size:12}),e.jsx("span",{children:"Agent is stuck — restart to reset state."})]})]})}const A=[{value:"",label:"All categories"},...Bn.map(k=>({value:k.id,label:k.label})),{value:"__none__",label:"(no category)"}];return e.jsxs("div",{className:"agents-redesign","data-testid":"agents-view",children:[e.jsxs("header",{className:"agents-redesign__header",children:[e.jsxs("div",{className:"agents-redesign__header-text",children:[e.jsxs("h2",{className:"agents-redesign__title",children:[e.jsx(pt,{size:18,"aria-hidden":"true"}),e.jsx("span",{children:"Agents"}),e.jsxs("span",{className:"agents-redesign__title-count","data-testid":"agents-count",children:["(",j.length,")"]})]}),e.jsxs("p",{className:"agents-redesign__subtitle",children:["The Norse pantheon — pick a row to inspect, ",e.jsx("kbd",{children:"Edit"})," to modify, ",e.jsx("kbd",{children:"Invoke"})," to dispatch."]})]}),e.jsxs("div",{className:"agents-redesign__controls",children:[e.jsxs("span",{className:"agents-redesign__control",style:{minWidth:180},children:[e.jsx("label",{htmlFor:"agents-search",className:"vh",children:"Search agents"}),e.jsx("input",{id:"agents-search",className:"input",type:"search",placeholder:"Search name, description, tag…",value:m,onChange:k=>d(k.target.value),"aria-label":"Search agents","data-testid":"agents-search"})]}),e.jsxs("span",{className:"agents-redesign__control",style:{minWidth:180},children:[e.jsx("label",{htmlFor:"agents-category-filter",className:"vh",children:"Filter by category"}),e.jsx("select",{id:"agents-category-filter",className:"select",value:c,onChange:k=>h(k.target.value),"data-testid":"agents-category-filter",children:A.map(k=>e.jsx("option",{value:k.value,children:k.label},k.value||"__all__"))})]}),e.jsx(nt,{variant:"ghost",size:"sm",icon:e.jsx(xe,{size:12}),onClick:x,"aria-label":"Refresh","data-testid":"agents-refresh",children:"Refresh"}),e.jsx(nt,{variant:"primary",size:"sm",icon:e.jsx(We,{size:12}),onClick:b,"aria-label":"New agent","data-testid":"agents-new",children:"New agent"})]})]}),e.jsxs("div",{className:"agents-redesign__body",children:[e.jsx(_e,{className:"agents-roster",children:o?e.jsx(Ri,{label:"Loading agents…",rows:3}):j.length===0?e.jsx(On,{icon:e.jsx(pt,{size:32}),title:"No agents found",description:i.length===0?"Run bizar in the terminal to install Bizar.":"No agents match the current filters — try clearing the search or category.",action:i.length===0?void 0:{label:"Clear filters",onClick:()=>{d(""),h("")}}}):e.jsx("div",{className:"agents-roster__table","data-testid":"agents-table",children:e.jsx(em,{columns:M,data:j,rowKey:k=>k.name,compact:!0,onRowClick:k=>p(k.name)})})}),e.jsx(wt,{title:g?e.jsxs("span",{className:"agents-detail__name",children:[e.jsx("span",{className:fe("agents-detail__name-swatch",!g.color&&"agents-detail__name-swatch--empty"),style:g.color?{background:g.color}:void 0,"aria-hidden":"true"}),e.jsx("span",{children:g.name})]}):"Agent detail",description:g?g.path:"Select an agent from the roster to see its metadata.",padding:4,variant:"outlined",className:"agents-detail",children:z()})]})]})}function Rm({id:t,children:s}){return e.jsx("div",{id:t,"data-block-id":t,className:te("glyph-richtext"),style:cl,children:e.jsx(Vo,{remarkPlugins:[Uo],children:s})})}const Im={info:{bg:"var(--info-soft, rgba(96, 165, 250, 0.12))",border:"var(--info)",fg:"var(--info)",icon:Si,label:"Note"},warn:{bg:"var(--warning-soft, rgba(251, 191, 36, 0.15))",border:"var(--warning)",fg:"var(--warning)",icon:qe,label:"Warning"},success:{bg:"var(--success-soft, rgba(52, 211, 153, 0.15))",border:"var(--success)",fg:"var(--success)",icon:Ze,label:"Success"},danger:{bg:"var(--error-soft, rgba(248, 113, 113, 0.12))",border:"var(--error)",fg:"var(--error)",icon:ls,label:"Danger"}};function Lm({id:t,tone:s="info",children:n}){const a=Im[s],i=a.icon;return e.jsxs("div",{id:t,"data-block-id":t,className:te("glyph-callout",`glyph-callout-${s}`),style:{display:"flex",gap:12,padding:"12px 16px",margin:"12px 0",borderLeft:`3px solid ${a.border}`,background:a.bg,borderRadius:8,color:"var(--text)"},role:s==="danger"||s==="warn"?"alert":void 0,children:[e.jsx("div",{style:{flexShrink:0,color:a.fg,paddingTop:2},children:e.jsx(i,{size:18})}),e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsx("div",{style:{fontWeight:600,fontSize:13,color:a.fg,marginBottom:4},children:a.label}),e.jsx("div",{className:"glyph-richtext",style:{...cl,fontSize:14},children:e.jsx(Vo,{remarkPlugins:[Uo],children:n})})]})]})}function Pm({id:t,items:s}){return e.jsx("ul",{id:t,"data-block-id":t,className:"glyph-checklist",style:{listStyle:"none",padding:0,margin:"12px 0",display:"flex",flexDirection:"column",gap:6},children:s.map(n=>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 ${n.checked?"var(--success)":"var(--border-strong)"}`,background:n.checked?"var(--success)":"transparent",color:"var(--bg)",display:"inline-flex",alignItems:"center",justifyContent:"center"},children:n.checked?e.jsx(Ht,{size:12,strokeWidth:3}):null}),e.jsx("span",{style:{color:n.checked?"var(--text-dim)":"var(--text)",textDecoration:n.checked?"line-through":"none",wordBreak:"break-word"},children:n.label})]},n.id))})}function Dm({id:t,columns:s,rows:n}){return e.jsx("div",{id:t,"data-block-id":t,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:s.map((a,i)=>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:a},i))})}),e.jsx("tbody",{children:n.map((a,i)=>e.jsx("tr",{style:{borderTop:i===0?"none":"1px solid var(--border)"},children:a.map((r,o)=>e.jsx("td",{style:{padding:"8px 12px",color:"var(--text)",verticalAlign:"top",wordBreak:"break-word"},children:r},o))},i))})]})})}function Fm({id:t,tabs:s}){var r;const[n,a]=f.useState(((r=s[0])==null?void 0:r.id)??""),i=f.useMemo(()=>s.find(o=>o.id===n)??s[0],[s,n]);return e.jsxs("div",{id:t,"data-block-id":t,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:s.map(o=>{const l=o.id===(i==null?void 0:i.id);return e.jsxs("button",{type:"button",role:"tab","aria-selected":l,onClick:()=>a(o.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:o.label}),o.language&&e.jsx("span",{style:{marginLeft:6,color:"var(--text-dim)",fontSize:11},children:o.language})]},o.id)})}),i&&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:i.code})}),i.caption&&e.jsx("div",{style:{padding:"8px 14px",borderTop:"1px solid var(--border)",fontSize:12,color:"var(--text-dim)",background:"var(--bg)"},children:i.caption})]})]})}function Om({id:t,title:s,question:n,options:a}){return e.jsxs("div",{id:t,"data-block-id":t,className:"glyph-decision",style:{margin:"16px 0",padding:16,border:"1px solid var(--border)",borderRadius:10,background:"var(--bg-elev)"},children:[s&&e.jsx("h3",{style:{margin:0,marginBottom:4,fontSize:15,fontWeight:600,color:"var(--text-strong)"},children:s}),n&&e.jsx("p",{style:{margin:0,marginBottom:12,fontSize:13,color:"var(--text-dim)"},children:n}),e.jsx("div",{style:{display:"grid",gap:10,gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))"},children:a.map(i=>{const r=!!i.recommended;return e.jsxs("div",{style:{position:"relative",padding:12,borderRadius:8,border:r?"2px solid var(--success)":"1px solid var(--border)",background:r?"var(--success-soft)":"var(--bg)"},children:[r&&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:i.label}),e.jsx("div",{style:{fontSize:13,color:"var(--text)"},children:i.detail})]},i.id)})})]})}function Bm({id:t,questions:s}){const[n,a]=f.useState({});function i(r,o){a(l=>({...l,[r]:o}))}return e.jsxs("div",{id:t,"data-block-id":t,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"}),s.map(r=>e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[e.jsx("label",{htmlFor:`oq-${r.id}`,style:{fontSize:13,color:"var(--text)",fontWeight:500},children:r.label}),r.kind==="choice"&&e.jsxs("select",{id:`oq-${r.id}`,value:n[r.id]??"",onChange:o=>i(r.id,o.target.value),style:jr,children:[e.jsx("option",{value:"",children:"— select —"}),(r.options??[]).map(o=>e.jsx("option",{value:o,children:o},o))]}),r.kind==="text"&&e.jsx("input",{id:`oq-${r.id}`,type:"text",value:n[r.id]??"",onChange:o=>i(r.id,o.target.value),style:jr}),r.kind==="multi"&&e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:4},children:(r.options??[]).map(o=>{const l=n[r.id]??[],c=l.includes(o);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:c,onChange:()=>{const h=c?l.filter(m=>m!==o):[...l,o];i(r.id,h)}}),e.jsx("span",{children:o})]},o)})})]},r.id))]})}const jr={padding:"6px 10px",fontSize:13,borderRadius:6,border:"1px solid var(--border-strong)",background:"var(--bg)",color:"var(--text)",fontFamily:"inherit"},Hm={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 Vm({id:t,title:s,entries:n}){return e.jsxs("div",{id:t,"data-block-id":t,className:"glyph-filetree",style:{margin:"12px 0",padding:s?14:8,border:"1px solid var(--border)",borderRadius:8,background:"var(--bg-elev)"},children:[s&&e.jsx("div",{style:{fontSize:12,fontWeight:600,color:"var(--text-dim)",textTransform:"uppercase",letterSpacing:.4,marginBottom:8},children:s}),e.jsx("ul",{style:{listStyle:"none",padding:0,margin:0,display:"flex",flexDirection:"column",gap:2},children:n.map(a=>{const i=Hm[a.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":a.change,title:a.change,style:{flexShrink:0,width:22,height:18,borderRadius:4,background:i.bg,color:i.fg,display:"inline-flex",alignItems:"center",justifyContent:"center",fontSize:10,fontWeight:700,fontFamily:"var(--font-mono)"},children:i.label}),e.jsx("span",{style:{fontFamily:"var(--font-mono)",color:"var(--text)",wordBreak:"break-all",flex:1},children:a.path}),a.note&&e.jsx("span",{style:{fontSize:12,color:"var(--text-dim)"},children:a.note})]},a.path)})})]})}function Um({id:t,filename:s,language:n,mode:a="unified",before:i,after:r}){const o=i.split(`
|
|
394
|
+
`),l=r.split(`
|
|
395
|
+
`),c=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(Fu,{size:14}),e.jsx("span",{style:{color:"var(--text)"},children:s??"diff"}),n&&e.jsxs("span",{children:["· ",n]}),e.jsx("span",{style:{marginLeft:"auto",textTransform:"uppercase",letterSpacing:.3},children:a})]}),h={margin:0,padding:0,fontFamily:"var(--font-mono)",fontSize:12.5,lineHeight:1.55,color:"var(--text)",background:"var(--bg-elev)"},m=(d,u,p)=>{const x={del:"var(--error-soft)",add:"var(--success-soft)",ctx:"transparent"},j={del:"var(--error)",add:"var(--success)",ctx:"var(--text-dim)"};return e.jsxs("div",{style:{display:"flex",padding:"0 12px",background:x[p]},children:[e.jsx("span",{style:{width:18,color:j[p],userSelect:"none",flexShrink:0},children:d}),e.jsx("span",{style:{whiteSpace:"pre",flex:1,overflowX:"auto"},children:u||" "})]})};return e.jsxs("div",{id:t,"data-block-id":t,className:"glyph-diff",style:{margin:"12px 0",border:"1px solid var(--border)",borderRadius:8,overflow:"hidden",background:"var(--bg-elev)"},children:[c,a==="unified"?e.jsxs("pre",{style:h,children:[o.map((d,u)=>e.jsx("div",{children:m("-",d,"del")},`b${u}`)),l.map((d,u)=>e.jsx("div",{children:m("+",d,"add")},`a${u}`))]}):e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr"},children:[e.jsx("pre",{style:{...h,borderRight:"1px solid var(--border)"},children:o.map((d,u)=>e.jsx("div",{children:m("-",d,"del")},u))}),e.jsx("pre",{style:h,children:l.map((d,u)=>e.jsx("div",{children:m("+",d,"add")},u))})]})]})}const qm={up:{fg:"var(--success)",Icon:ct,label:"trending up"},down:{fg:"var(--error)",Icon:ct,label:"trending down"},flat:{fg:"var(--text-dim)",Icon:el,label:"flat"}};function Wm({id:t,label:s,value:n,trend:a,hint:i}){const r=a?qm[a]:null;return e.jsxs("div",{id:t,"data-block-id":t,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:s}),e.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:8},children:[e.jsx("span",{style:{fontSize:24,fontWeight:700,color:"var(--text-strong)"},children:n}),r&&e.jsx("span",{"aria-label":r.label,style:{display:"inline-flex",alignItems:"center",color:r.fg,transform:r.Icon===ct&&a==="up"?"rotate(180deg)":void 0},children:e.jsx(r.Icon,{size:14})})]}),i&&e.jsx("div",{style:{fontSize:12,color:"var(--text-dim)"},children:i})]})}const Gm={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)"}},tt=160,ot=56,cs=60,ds=80;function Ym({id:t,steps:s,connections:n=[]}){if(s.length===0)return e.jsx("div",{id:t,"data-block-id":t,className:"glyph-workflow",children:e.jsx(Xm,{id:t})});const a=new Map(s.map(m=>[m.id,m])),i=Km(s),r=Math.max(...i.map(m=>m.col))+1,o=Math.max(...i.map(m=>m.row))+1,l=r*(tt+cs)+cs,c=o*(ot+ds)+ds;function h(m){if(!a.get(m))return null;const u=i.find(p=>p.id===m);return u?{x:cs+u.col*(tt+cs)+tt/2,y:ds+u.row*(ot+ds)+ot/2}:null}return e.jsx("div",{id:t,"data-block-id":t,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:c,style:{display:"block",maxWidth:"100%"},children:[e.jsx("defs",{children:e.jsx("marker",{id:`arrow-${t}`,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)"})})}),n.map((m,d)=>{const u=h(m.from),p=h(m.to);if(!u||!p)return null;const x=p.x-u.x,j=p.y-u.y,v=x>=0?u.x+tt/2:u.x-tt/2,g=x>=0?p.x-tt/2:p.x+tt/2,b=j>=0?u.y+ot/2:u.y-ot/2,y=j>=0?p.y-ot/2:p.y+ot/2,w=(v+g)/2,S=(b+y)/2;return e.jsxs("g",{children:[e.jsx("line",{x1:v,y1:b,x2:g,y2:y,stroke:"var(--text-dim)",strokeWidth:1.5,markerEnd:`url(#arrow-${t})`}),m.label&&e.jsx("text",{x:w,y:S-4,fontSize:10,fill:"var(--text-dim)",textAnchor:"middle",fontFamily:"var(--font-mono)",children:m.label})]},d)}),s.map(m=>{const d=i.find(v=>v.id===m.id);if(!d)return null;const u=cs+d.col*(tt+cs),p=ds+d.row*(ot+ds),x=Gm[m.type];if(m.type==="decision"){const v=u+tt/2,g=p+ot/2,b=[[v,p],[u+tt,g],[v,p+ot],[u,g]].map(y=>y.join(",")).join(" ");return e.jsxs("g",{children:[e.jsx("polygon",{points:b,fill:x.fill,stroke:x.stroke,strokeWidth:2}),e.jsx("foreignObject",{x:u+8,y:g-14,width:tt-16,height:28,children:e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",gap:4,fontSize:12,color:x.fg,textAlign:"center",lineHeight:1.2,fontStyle:"italic",height:"100%"},children:[e.jsx(Lu,{size:11}),m.label]})})]},m.id)}const j=m.type==="note";return e.jsxs("g",{children:[e.jsx("rect",{x:u,y:p,width:tt,height:ot,rx:8,fill:x.fill,stroke:x.stroke,strokeWidth:j?1:2,strokeDasharray:j?"4 3":void 0}),e.jsx("foreignObject",{x:u+6,y:p+6,width:tt-12,height:ot-12,children:e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",gap:6,fontSize:12,color:x.fg,textAlign:"center",lineHeight:1.25,fontStyle:j?"italic":"normal",height:"100%"},children:[j&&e.jsx(nu,{size:11}),m.label]})})]},m.id)})]})})}function Xm({id:t}){return e.jsx("div",{id:t,style:{padding:20,textAlign:"center",color:"var(--text-dim)",fontSize:13},children:"No workflow steps."})}function Km(t){return t.length===0?[]:t.map((s,n)=>({id:s.id,col:n,row:0}))}const cl={fontSize:14,lineHeight:1.6,color:"var(--text)"};function Zm({id:t,title:s,x:n,y:a,w:i,h:r,html:o}){return e.jsxs("figure",{id:t,"data-block-id":t,className:"glyph-mockup",style:{width:i,minHeight:r},children:[s&&e.jsx("figcaption",{className:"glyph-mockup-title",children:s}),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:o}})]})]})}class Qm extends rt.Component{constructor(){super(...arguments);Ps(this,"state",{err:null})}static getDerivedStateFromError(n){return{err:n}}componentDidCatch(n,a){try{this.props.onError(this.props.blockId,this.props.blockType,n,a)}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 Jm(t){const s=t.data??{};switch(t.type){case"RichText":return{ok:!0};case"Callout":return{ok:!0};case"Checklist":return Array.isArray(s.items)?{ok:!0}:{ok:!1,error:"Checklist requires data.items to be an array"};case"Table":return Array.isArray(s.columns)?Array.isArray(s.rows)?s.rows.length>0&&!Array.isArray(s.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(s.tabs)?{ok:!0}:{ok:!1,error:"CodeTabs requires data.tabs to be an array"};case"Decision":return Array.isArray(s.options)?{ok:!0}:{ok:!1,error:"Decision requires data.options to be an array"};case"OpenQuestions":return Array.isArray(s.questions)?{ok:!0}:{ok:!1,error:"OpenQuestions requires data.questions to be an array"};case"FileTree":if(!Array.isArray(s.entries))return{ok:!1,error:"FileTree requires data.entries to be an array"};for(const n of s.entries)if(n===null||typeof n!="object"||Array.isArray(n))return{ok:!1,error:`FileTree contains a malformed entry: ${JSON.stringify(n)}`};return{ok:!0};case"Diff":return typeof s.before!="string"?{ok:!1,error:"Diff requires data.before to be a string"}:typeof s.after!="string"?{ok:!1,error:"Diff requires data.after to be a string"}:{ok:!0};case"Stat":return s.label===void 0||s.label===null?{ok:!1,error:"Stat requires data.label"}:s.value===void 0||s.value===null?{ok:!1,error:"Stat requires data.value"}:{ok:!0};case"Workflow":return Array.isArray(s.steps)?{ok:!0}:{ok:!1,error:"Workflow requires data.steps to be an array"};case"Mockup":return typeof s.html!="string"?{ok:!1,error:"Mockup requires data.html to be a string"}:{ok:!0};case"Diagram":return typeof s.dataHtml!="string"?{ok:!1,error:"Diagram requires data.dataHtml to be a string"}:{ok:!0};default:return{ok:!1,error:`Unknown block type: ${t.type}`}}}const ef={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 tf(t){const s=[];let n={heading:null,blocks:[]};for(const a of t){const i=ef[a.id]??null;i?((n.blocks.length>0||n.heading!==null)&&s.push(n),n={heading:i,blocks:[a]}):n.blocks.push(a)}return(n.blocks.length>0||n.heading!==null)&&s.push(n),s}function sf({slug:t,onClose:s,onCommentAdded:n}){var V,X,J,le;const a=pe(),[i,r]=f.useState(null),[o,l]=f.useState([]),[c,h]=f.useState(!0),[m,d]=f.useState(null),[u,p]=f.useState(null),[x,j]=f.useState(!1),[v,g]=f.useState(!1),[b,y]=f.useState(null),[w,S]=f.useState(null),[$,M]=f.useState(""),[z,A]=f.useState(null),[k,C]=f.useState([]),_=rt.useCallback((B,Y,ee)=>{C(ae=>ae.some(ne=>ne.blockId===B)?ae:[...ae,{blockId:B,blockType:Y,message:ee.message||String(ee)}])},[]),P=f.useRef(null),N=f.useMemo(()=>i?tf(i.blocks):[],[i]);f.useEffect(()=>{let B=!1;const Y=5e3;return(async()=>{h(!0),d(null);try{const ee=new Promise((K,Z)=>setTimeout(()=>Z(new Error("Request timed out after 5s")),Y)),[ae,ne]=await Promise.race([Promise.all([H.get(`/artifacts/${encodeURIComponent(t)}/render`),H.get(`/artifacts/${encodeURIComponent(t)}`)]),ee]);if(B)return;r(ae);const O=(ne==null?void 0:ne.comments)??[];l(Array.isArray(O)?O:[])}catch(ee){if(!B){const ae=ee.message;d(ae),p(ae)}}finally{B||h(!1)}})(),()=>{B=!0}},[t]);function T(B){if(!P.current)return;B.preventDefault();const Y=P.current.getBoundingClientRect();y({x:B.clientX,y:B.clientY,worldX:B.clientX-Y.left,worldY:B.clientY-Y.top})}async function L(){if(!(!w||!$.trim()))try{const B=await H.post(`/artifacts/${encodeURIComponent(t)}/comments`,{x:w.worldX,y:w.worldY,text:$.trim(),author:"drb0rk"});l(Y=>[...Y,{id:B.id??`cmt_${Date.now()}`,x:w.worldX,y:w.worldY,text:$.trim(),author:"drb0rk",created:new Date().toISOString()}]),S(null),M(""),y(null),n==null||n(),a.success("Comment added")}catch(B){a.error(`Failed to add comment: ${B.message}`)}}async function R(){if(!x){j(!0);try{const B=await H.post(`/artifacts/${encodeURIComponent(t)}/submit`,{answers:[],submitter:"drb0rk"});B!=null&&B.ok?(a.success("Sent to agent — feedback.md written, status=review"),n==null||n()):a.error("Submit failed: server did not return ok=true")}catch(B){a.error(`Submit failed: ${B.message}`)}finally{j(!1)}}}function F(){g(B=>!B)}const E=B=>{const Y=B.id,ee=B.data??{},ae=Jm(B);return ae.ok?e.jsx(Qm,{blockId:Y,blockType:B.type,onError:_,children:D(B,Y,ee)},Y):e.jsxs("div",{id:Y,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:[B.type," block invalid"]}),e.jsxs("div",{style:{color:"var(--text-muted)",marginBottom:6},children:["block id: ",e.jsx("code",{children:Y})]}),e.jsx("pre",{style:{margin:0,whiteSpace:"pre-wrap",wordBreak:"break-word"},children:ae.error})]},Y)},D=(B,Y,ee)=>{switch(B.type){case"RichText":return e.jsx(Rm,{id:Y,children:B.childrenMarkdown??""},Y);case"Callout":return e.jsx(Lm,{id:Y,tone:ee.tone??"info",children:B.childrenMarkdown??""},Y);case"Checklist":return e.jsx(Pm,{id:Y,items:ee.items??[]},Y);case"Table":return e.jsx(Dm,{id:Y,columns:ee.columns??[],rows:ee.rows??[]},Y);case"CodeTabs":return e.jsx(Fm,{id:Y,tabs:ee.tabs??[]},Y);case"Decision":return e.jsx(Om,{id:Y,title:ee.title,question:ee.question,options:ee.options??[]},Y);case"OpenQuestions":return e.jsx(Bm,{id:Y,questions:ee.questions??[]},Y);case"FileTree":return e.jsx(Vm,{id:Y,title:ee.title,entries:ee.entries??[]},Y);case"Diff":return e.jsx(Um,{id:Y,filename:ee.filename,language:ee.language,mode:ee.mode??"unified",before:ee.before??"",after:ee.after??""},Y);case"Stat":return e.jsx(Wm,{id:Y,label:ee.label??"",value:ee.value,trend:ee.trend,hint:ee.hint},Y);case"Workflow":return e.jsx(Ym,{id:Y,steps:ee.steps??[],connections:ee.connections},Y);case"Mockup":return e.jsx(Zm,{id:Y,title:ee.title,x:ee.x,y:ee.y,w:ee.w,h:ee.h,html:ee.html??""},Y);case"Diagram":return e.jsx("div",{id:Y,className:"glyph-block-placeholder",children:e.jsxs("em",{children:["[Diagram] ",Y]})},Y)}};if(c)return e.jsx("div",{className:"glyph-renderer glyph-renderer--loading",children:u?e.jsxs(e.Fragment,{children:[e.jsx("strong",{children:"Failed to load glyph."}),e.jsx("pre",{children:u})]}):e.jsxs(e.Fragment,{children:[e.jsx(nf,{})," Loading glyph…"]})});if(m||!i)return e.jsxs("div",{className:"glyph-renderer glyph-renderer--error",children:[e.jsx("strong",{children:"Failed to load glyph."}),e.jsx("pre",{children:m??"unknown error"})]});const G=((V=i.frontmatter)==null?void 0:V.title)??t,I=((X=i.frontmatter)==null?void 0:X.status)??"draft",W=o.length;return e.jsxs("div",{className:`glyph-canvas ${v?"glyph-canvas--fullscreen":""}`,ref:P,onContextMenu:T,children:[e.jsxs("div",{className:"glyph-toolbar-floating",children:[e.jsxs("button",{className:"glyph-btn glyph-btn--primary glyph-btn--send",onClick:R,disabled:x,title:"Send comments + question answers to the agent — writes feedback.md, status=review",children:[e.jsx(Rt,{size:14}),e.jsx("span",{children:"Send to agent"}),e.jsx("span",{className:"glyph-btn-badge",children:W})]}),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(()=>{}),a.success("Link copied"))},children:e.jsx(dh,{size:15})}),e.jsx("button",{className:"glyph-icon-btn",title:"Undo",disabled:!0,children:e.jsx(mh,{size:15})}),e.jsx("button",{className:"glyph-icon-btn",title:"Redo",disabled:!0,children:e.jsx(lh,{size:15})}),e.jsx("button",{className:"glyph-icon-btn",title:v?"Exit fullscreen":"Fullscreen",onClick:F,children:e.jsx(th,{size:15})}),e.jsx("button",{className:"glyph-icon-btn",title:"More",children:e.jsx(Pu,{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(mn,{size:15}),e.jsx("span",{className:"glyph-icon-btn-count",children:W})]}),s&&e.jsx("button",{className:"glyph-icon-btn glyph-icon-btn--close",title:"Close",onClick:s,"aria-label":"Close",children:e.jsx(Ie,{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:G}),e.jsxs("div",{className:"glyph-meta",children:[e.jsx("span",{className:`glyph-status glyph-status--${I}`,children:I}),e.jsx("span",{className:"glyph-slug",children:t})]})]}),(k.length>0||((J=i.errors)==null?void 0:J.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:k.length>0?`${k.length} block${k.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:[k.map((B,Y)=>e.jsxs("li",{children:[e.jsx("strong",{children:B.blockType})," (",e.jsx("code",{children:B.blockId}),"): ",B.message]},`be-${Y}`)),(le=i.errors)==null?void 0:le.map((B,Y)=>e.jsxs("li",{children:[B.line?`line ${B.line}: `:"",B.message]},`ce-${Y}`))]})]}),e.jsx("div",{className:"glyph-sections",children:N.map((B,Y)=>e.jsxs("section",{className:`glyph-section ${B.heading?"glyph-section--headed":"glyph-section--plain"}`,children:[B.heading&&e.jsx("h2",{className:"glyph-section-heading",children:B.heading}),e.jsx("div",{className:"glyph-section-blocks",children:B.blocks.map(E)})]},`sec-${Y}-${B.heading??"ungrouped"}`))})]}),o.map(B=>e.jsxs("button",{className:`glyph-pin ${z===B.id?"glyph-pin--active":""}`,style:{left:B.x,top:B.y},onClick:Y=>{Y.stopPropagation(),A(z===B.id?null:B.id)},title:B.text,children:[e.jsx(ur,{size:14}),z===B.id&&e.jsxs("div",{className:"glyph-pin-thread",children:[e.jsx("div",{className:"glyph-pin-text",children:B.text}),e.jsxs("div",{className:"glyph-pin-meta",children:[B.author??"anonymous"," · ",B.created?new Date(B.created).toLocaleString():""]})]})]},B.id)),b&&e.jsx("div",{className:"glyph-ctx-menu",style:{left:b.x,top:b.y},onClick:B=>B.stopPropagation(),children:e.jsxs("button",{className:"glyph-ctx-item",onClick:()=>{S({worldX:b.worldX,worldY:b.worldY}),y(null)},children:[e.jsx(ur,{size:14})," Add comment here"]})}),w&&e.jsx("div",{className:"glyph-modal-overlay",onClick:()=>S(null),children:e.jsxs("div",{className:"glyph-modal",onClick:B=>B.stopPropagation(),children:[e.jsxs("h3",{children:["Add comment at (",Math.round(w.worldX),", ",Math.round(w.worldY),")"]}),e.jsx("textarea",{autoFocus:!0,value:$,onChange:B=>M(B.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:()=>S(null),children:"Cancel"}),e.jsx("button",{className:"glyph-btn glyph-btn--primary",onClick:L,disabled:!$.trim(),children:"Add comment"})]})]})})]})}function nf(){return e.jsx("span",{className:"glyph-spinner","aria-label":"loading",children:"…"})}function Te({icon:t,title:s,message:n,action:a,className:i}){return e.jsxs("div",{className:te("empty-state",i),children:[e.jsx("div",{className:"empty-icon",children:t??e.jsx(Kn,{size:32})}),e.jsx("div",{className:"empty-title",children:s}),n&&e.jsx("div",{className:"empty-message",children:n}),a&&e.jsx("div",{className:"empty-action",children:a})]})}function af(t){return t==="ok"?"success":t==="warn"?"warning":t==="fail"?"error":t}function ma({kind:t="neutral",children:s,className:n,dot:a=!1}){const i=af(t);return e.jsxs("span",{className:te("badge",`badge-${i}`,n),title:`status: ${t}`,children:[a&&e.jsx("span",{className:"badge-dot"}),s]})}function rf(t){switch(t){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 of({snapshot:t,refreshSnapshot:s}){const n=pe(),[a,i]=f.useState(t.artifacts||[]),[r,o]=f.useState(!t.artifacts),[l,c]=f.useState(null),[h,m]=f.useState(""),[d,u]=f.useState(!1);f.useEffect(()=>{t.artifacts&&(i(t.artifacts),o(!1))},[t.artifacts]);const p=async()=>{try{const g=await H.get("/artifacts");i(g.artifacts||[]),o(!1)}catch(g){n.error(`Artifacts load failed: ${g.message}`),o(!1)}},x=f.useMemo(()=>{let g=a;if(h){const b=h.toLowerCase();g=g.filter(y=>(y.slug||"").toLowerCase().includes(b)||(y.title||"").toLowerCase().includes(b))}return d||(g=g.filter(b=>b.status!=="archived")),g},[a,h,d]),j=async(g,b)=>{try{const y=await H.post("/artifacts",{slug:g,title:b});n.success(`Artifact "${y.slug}" created.`),c(y.slug),await p()}catch(y){n.error(`Create failed: ${y.message}`)}},v=async g=>{if(confirm(`Delete artifact "${g}"? This removes the directory permanently.`))try{await H.del(`/artifacts/${encodeURIComponent(g)}`),n.success("Artifact deleted."),l===g&&c(null),await p()}catch(b){n.error(`Delete failed: ${b.message}`)}};return l?e.jsxs("div",{className:"artifact-glyph-overlay",children:[e.jsx("div",{className:"artifact-glyph-toolbar",children:e.jsxs(U,{variant:"ghost",onClick:()=>{c(null),p()},children:[e.jsx($i,{size:14})," Back to artifacts"]})}),e.jsx(sf,{slug:l,onClose:()=>{c(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(Zn,{size:18})," Glyphs (",a.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(Re,{size:14,"aria-hidden":!0}),e.jsx("label",{htmlFor:"artifacts-search",className:"sr-only",children:"Search artifacts"}),e.jsx("input",{id:"artifacts-search",className:"input",type:"text",placeholder:"Search…",value:h,onChange:g=>m(g.target.value),"aria-label":"Search artifacts"})]}),e.jsxs(U,{variant:"ghost",size:"sm",onClick:()=>u(g=>!g),title:d?"Hide archived":"Show archived",children:[d?e.jsx(Wo,{size:14}):e.jsx(au,{size:14}),d?"Hide archived":"Show archived"]}),e.jsxs(U,{variant:"secondary",size:"sm",onClick:p,children:[e.jsx(xe,{size:14})," Refresh"]})]})]}),e.jsx(lf,{onCreate:j}),r?e.jsx("div",{className:"view-loading",children:e.jsx(ye,{size:"lg"})}):x.length===0?e.jsx(Te,{icon:e.jsx(Zn,{size:32}),title:d?"No artifacts":"No artifacts yet",message:d?"No artifacts match your filter (try Show archived off).":"Create one above to get started."}):e.jsx("div",{className:"artifacts-grid",children:x.map(g=>e.jsx(cf,{artifact:g,onOpen:()=>c(g.slug),onDelete:()=>v(g.slug)},g.slug))})]})}function lf({onCreate:t}){const[s,n]=f.useState(""),[a,i]=f.useState("");return e.jsxs(se,{className:"new-artifact",children:[e.jsxs(de,{children:[e.jsx(We,{size:14})," New artifact"]}),e.jsx(ue,{children:"Slug must be lowercase, may contain hyphens, 1–64 chars."}),e.jsxs("form",{className:"new-artifact-form",onSubmit:r=>{r.preventDefault(),s.trim()&&(t(s.trim(),a.trim()||void 0),n(""),i(""))},children:[e.jsx("label",{htmlFor:"new-artifact-slug",className:"sr-only",children:"Artifact slug"}),e.jsx("input",{id:"new-artifact-slug",className:"input",type:"text",placeholder:"slug (e.g. dashboard-v3.1)",pattern:"[a-z0-9][a-z0-9-]{0,63}",required:!0,value:s,onChange:r=>n(r.target.value),"aria-label":"Artifact slug"}),e.jsx("label",{htmlFor:"new-artifact-title",className:"sr-only",children:"Artifact title"}),e.jsx("input",{id:"new-artifact-title",className:"input",type:"text",placeholder:"Title (optional)",value:a,onChange:r=>i(r.target.value)}),e.jsx(U,{variant:"primary",type:"submit",children:"Create"})]})]})}function cf({artifact:t,onOpen:s,onDelete:n}){const a=rf(t.status||"draft");return e.jsxs(se,{variant:"elevated",interactive:!0,className:"artifact-card",onClick:s,children:[e.jsxs("div",{className:"artifact-card-head",children:[e.jsx("div",{className:"artifact-card-title",children:t.title||t.slug}),e.jsx(ma,{kind:a,children:t.status||"draft"})]}),e.jsxs("div",{className:"artifact-card-slug mono",children:[t.slug," · ",t.source]}),e.jsxs("div",{className:"artifact-card-meta",children:[t.elementCount!=null&&e.jsxs("span",{children:[t.elementCount," elements"]}),t.commentCount!=null&&e.jsxs("span",{children:[" · ",t.commentCount," comments"]}),e.jsxs("span",{children:[" · edited ",Ve(t.mtime)]})]}),e.jsxs("div",{className:"artifact-card-actions",children:[e.jsxs(U,{variant:"primary",size:"sm",onClick:i=>{i.stopPropagation(),s()},children:["Open",e.jsx(Ut,{size:12})]}),e.jsxs(U,{variant:"ghost",size:"sm",onClick:i=>{i.stopPropagation(),n()},children:[e.jsx(Fe,{size:12})," Delete"]})]})]})}function df({task:t,agents:s,onPromote:n,onDelete:a,onEdit:i,onRefresh:r}){var m;const o=pe(),l=async()=>{try{await H.post(`/tasks/${encodeURIComponent(t.id)}/promote`),o.success("Promoted to queued.",1500),n(t.id)}catch(d){o.error(`Promote failed: ${d.message}`)}},c=async()=>{if(confirm("Delete this task?"))try{await H.del(`/tasks/${encodeURIComponent(t.id)}`),o.success("Deleted.",1500),a(t.id)}catch(d){o.error(`Delete failed: ${d.message}`)}},h={high:"var(--warning)",normal:"var(--info)",low:"var(--muted)"};return e.jsxs("div",{className:"backlog-item","data-task-id":t.id,children:[e.jsxs("div",{className:"backlog-item-head",children:[e.jsx("span",{className:"priority-dot",style:{background:h[t.priority]||"var(--info)"}}),e.jsx("span",{className:"backlog-item-title",children:t.title}),t.assignee&&e.jsxs("span",{className:"backlog-item-badge",children:["@",t.assignee]}),((m=t.tags)==null?void 0:m.length)>0&&e.jsx("span",{className:"backlog-item-badge",children:t.tags.join(", ")})]}),t.description&&e.jsx("div",{className:"backlog-item-desc",children:t.description.slice(0,120)}),e.jsxs("div",{className:"backlog-item-footer",children:[e.jsx("span",{className:"muted text-sm tabular-nums",children:Ve(t.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(pn,{size:13})}),e.jsx("button",{type:"button",className:"icon-btn",title:"Edit",onClick:()=>i(t),children:e.jsx(vt,{size:13})}),e.jsx("button",{type:"button",className:"icon-btn icon-btn-danger",title:"Delete",onClick:c,children:e.jsx(Fe,{size:13})})]})]})]})}function uf({agents:t,onRefresh:s}){const n=pe(),[a,i]=f.useState([]),[r,o]=f.useState(!1),l=async()=>{try{o(!0);const u=await H.get("/tasks/backlog");i(Array.isArray(u.tasks)?u.tasks:[])}catch(u){n.error(`Backlog load failed: ${u.message}`)}finally{o(!1)}};f.useEffect(()=>{l()},[]);const c=async u=>{i(p=>p.filter(x=>x.id!==u)),await s()},h=async u=>{i(p=>p.filter(x=>x.id!==u)),await s()},m=u=>{},d=async()=>{var u;if(a.length!==0)try{const x=((u=(await H.post("/tasks/promote-batch",{ids:a.map(j=>j.id)})).affected)==null?void 0:u.filter(j=>j.ok).length)??0;n.success(`Promoted ${x} task(s).`,2e3),i([]),await s()}catch(p){n.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(Kn,{size:15}),"Backlog (",a.length,")"]}),e.jsxs("div",{className:"backlog-panel-header-actions",children:[a.length>0&&e.jsxs(U,{variant:"ghost",size:"sm",onClick:d,title:"Promote all to queued",children:[e.jsx(pn,{size:12})," Promote all"]}),e.jsx(U,{variant:"ghost",size:"sm",onClick:l,title:"Refresh backlog","aria-label":"Refresh backlog",children:e.jsx(xe,{size:12,className:r?"animate-spin":""})})]})]}),r?e.jsx("div",{className:"backlog-empty",children:"Loading…"}):a.length===0?e.jsxs("div",{className:"backlog-empty",children:[e.jsx(Kn,{size:28}),e.jsx("span",{children:"Backlog is empty."})]}):e.jsx("div",{className:"backlog-list",children:a.map(u=>e.jsx(df,{task:u,agents:t,onPromote:c,onDelete:h,onEdit:m,onRefresh:s},u.id))})]})}const hf=[{id:"queued",label:"Todo",kind:"info",dotVariant:"info"},{id:"doing",label:"In progress",kind:"accent",dotVariant:"info"},{id:"done",label:"Done",kind:"success",dotVariant:"success"},{id:"blocked",label:"Failed",kind:"error",dotVariant:"danger"}],fa=["low","normal","high"],mf=[{value:"",label:"All"},...fa.map(t=>({value:t,label:t}))],ff={info:"info",accent:"accent",success:"success",warning:"warning",error:"danger"},pf={high:"danger",normal:"info",low:"neutral"};function xf({snapshot:t,refreshSnapshot:s}){const n=pe(),a=Qe(),[i,r]=f.useState(t.tasks||[]),[o,l]=f.useState(!t.tasks),[c,h]=f.useState(""),[m,d]=f.useState(""),[u,p]=f.useState(!1),[x,j]=f.useState(0),[v,g]=f.useState(""),b=async()=>{try{const k=await H.get("/tasks");r(Array.isArray(k)?k:[])}catch(k){n.error(`Tasks load failed: ${k.message}`)}finally{l(!1)}};f.useEffect(()=>{t.tasks&&(r(t.tasks),l(!1))},[t.tasks]),f.useEffect(()=>{const k=setInterval(()=>j(C=>C+1),3e4);return()=>clearInterval(k)},[]);const y=f.useMemo(()=>{let k=i.filter(C=>C.status!=="backlog");if(m&&(k=k.filter(C=>(C.priority||"normal")===m)),c.trim()){const C=c.toLowerCase();k=k.filter(_=>(_.title||"").toLowerCase().includes(C)||(_.description||"").toLowerCase().includes(C))}return k},[i,c,m]),w=f.useMemo(()=>{const k={high:0,normal:1,low:2};return[...y].sort((C,_)=>{const P=k[C.priority]??1,N=k[_.priority]??1;return P!==N?P-N:new Date(_.createdAt).getTime()-new Date(C.createdAt).getTime()})},[y]),S=i.filter(k=>k.status==="backlog").length,$=async k=>{if(confirm("Delete this task?"))try{await H.del(`/tasks/${encodeURIComponent(k)}`),r(C=>C.filter(_=>_.id!==k)),n.success("Task deleted.",1200)}catch(C){n.error(`Delete failed: ${C.message}`)}},M=async k=>{try{const C=await H.post(`/tasks/${encodeURIComponent(k)}/start`);C&&C.task&&r(_=>_.map(P=>P.id===k?C.task:P)),n.success("Retry dispatched.",1200)}catch(C){n.error(`Retry failed: ${C.message}`)}},z=async k=>{const C=i.find(_=>_.id===k);if(C)try{const _=await H.post("/tasks/submit",{title:C.title,description:C.description,priority:C.priority,tags:C.tags}),P=(_.subtasks||[]).length;n.success(P>1?`Odin split it into ${P} subtasks.`:"Sent to Odin.",1500),_.subtasks&&_.subtasks.length>0&&r(N=>[_.main,..._.subtasks,...N.filter(T=>T.id!==C.id)]),await s()}catch(_){n.error(`Submit failed: ${_.message}`)}},A=k=>{br(a,n,k,r,b,s)};return e.jsxs("div",{className:"view view-tasks tasks-wave3",children:[e.jsx("div",{className:"sr-only",role:"status","aria-live":"polite",children:v}),e.jsx("header",{className:"tasks-wave3__header",children:e.jsxs("div",{children:[e.jsxs("h2",{className:"tasks-wave3__title-row",children:[e.jsx(Qt,{size:18,"aria-hidden":!0})," Tasks (",w.length,")"]}),e.jsx("p",{className:"tasks-wave3__subtitle",children:"Add a task — title and description is all you need. Odin picks the agent and priority."})]})}),e.jsxs("div",{className:"tasks-wave3__toolbar",role:"toolbar","aria-label":"Task filters",children:[e.jsx("div",{className:"tasks-wave3__toolbar-group",children:e.jsx(Xh,{inputSize:"sm",value:c,onChange:k=>h(String(k)),placeholder:"Search…","aria-label":"Search tasks"})}),e.jsxs("div",{className:"tasks-wave3__toolbar-group",children:[e.jsx("span",{className:"tasks-wave3__toolbar-label",id:"tasks-priority-filter-label",children:"Priority"}),e.jsx(Yh,{inputSize:"sm","aria-labelledby":"tasks-priority-filter-label",options:mf,value:m,onChange:k=>d(k.target.value)})]}),e.jsx("div",{className:"tasks-wave3__toolbar-spacer"}),e.jsxs("div",{className:"tasks-wave3__toolbar-group",children:[e.jsx(U,{variant:"ghost",size:"sm",onClick:b,title:"Refresh","aria-label":"Refresh tasks",children:e.jsx(xe,{size:14,"aria-hidden":!0})}),S>0&&e.jsxs(U,{variant:u?"accent":"ghost",size:"sm",onClick:()=>p(k=>!k),title:u?"Hide backlog":"Show backlog",children:[e.jsx(Kn,{size:14,"aria-hidden":!0}),"Backlog",e.jsx("span",{className:"tasks-wave3__column-count","aria-label":`${S} items`,children:S})]}),e.jsxs(U,{variant:"primary",size:"sm",onClick:()=>yf(a,n,r,b,s),children:[e.jsx(We,{size:14,"aria-hidden":!0})," New task"]})]})]}),u&&S>0&&e.jsx(uf,{agents:t.agents||[],onRefresh:s}),o?e.jsx(Ri,{label:"Loading tasks…"}):e.jsx(Qn,{cols:5,gap:3,className:"tasks-wave3__kanban",children:hf.map(k=>{const C=w.filter(_=>_.status===k.id);return e.jsx(wt,{padding:3,className:"tasks-wave3__column",title:e.jsxs("span",{className:"tasks-wave3__column-title",children:[e.jsx(sn,{variant:k.dotVariant,size:"sm",label:k.label}),k.label]}),actions:e.jsx("span",{className:"tasks-wave3__column-count","aria-label":`${C.length} tasks`,children:C.length}),children:e.jsx(Be,{gap:2,className:"tasks-wave3__column-body",children:C.length===0?e.jsx("div",{className:"tasks-wave3__column-empty",children:"No tasks"}):C.map(_=>e.jsx(gf,{task:_,column:k,onTaskClick:A,onEdit:()=>br(a,n,_,r,b,s),onDelete:()=>$(_.id),onRetry:()=>M(_.id),onSubmitToOdin:()=>z(_.id),tick:x},_.id))})},k.id)})})]})}function gf({task:t,column:s,onTaskClick:n,onEdit:a,onDelete:i,onRetry:r,onSubmitToOdin:o,tick:l}){const c=t.workedBy||t.assignee||null,h=fa.includes(t.priority)?t.priority:"normal";return e.jsxs("div",{className:fe("tasks-wave3__row"),"data-task-id":t.id,"data-tick":l,role:"button",tabIndex:0,onClick:()=>n(t),onKeyDown:m=>{(m.key==="Enter"||m.key===" ")&&(m.preventDefault(),n(t))},children:[e.jsxs("div",{className:"tasks-wave3__row-title-row",children:[e.jsx("div",{className:"tasks-wave3__row-title",title:t.title,children:t.title}),e.jsx(ht,{variant:ff[s.kind],size:"sm","aria-label":`Status ${s.label}`,children:s.label})]}),e.jsxs(Le,{gap:1,align:"center",className:"tasks-wave3__row-badges",children:[e.jsx(ht,{variant:pf[h],size:"sm",children:h}),c&&e.jsxs(ht,{variant:"neutral",size:"sm",children:[e.jsx(pt,{size:10,"aria-hidden":!0})," @",c]}),(t.tags||[]).slice(0,2).map(m=>e.jsxs(ht,{variant:"neutral",size:"sm",children:["#",m]},m))]}),e.jsxs("div",{className:"tasks-wave3__row-footer",children:[e.jsx("span",{className:"tasks-wave3__row-time",children:Ve(t.createdAt)}),e.jsxs(Le,{gap:1,align:"center",className:"tasks-wave3__row-actions",onClick:m=>m.stopPropagation(),children:[e.jsx(ps,{variant:"ghost",size:"sm",icon:e.jsx(ih,{size:12,"aria-hidden":!0}),"aria-label":"Edit task",title:"Edit",onClick:a}),e.jsx(ps,{variant:"ghost",size:"sm",icon:e.jsx(Rt,{size:12,"aria-hidden":!0}),"aria-label":"Submit to Odin",title:"Re-delegate to Odin",onClick:o}),e.jsx(ps,{variant:"ghost",size:"sm",icon:e.jsx(ua,{size:12,"aria-hidden":!0}),"aria-label":"Retry task",title:"Retry",onClick:r}),e.jsx(ps,{variant:"danger",size:"sm",icon:e.jsx(Fe,{size:12,"aria-hidden":!0}),"aria-label":"Delete task",title:"Delete",onClick:i})]})]})]})}function yf(t,s,n,a,i){let r=null,o=null,l=null,c=null;const h=async d=>{d&&typeof d.preventDefault=="function"&&d.preventDefault();const u=((r==null?void 0:r.value)||"").trim(),p=((o==null?void 0:o.value)||"").trim();if(!u){s.warning("Title is required."),r==null||r.focus();return}const x=(c==null?void 0:c.value)||"normal",j=((l==null?void 0:l.value)||"").split(",").map(v=>v.trim()).filter(Boolean);try{const v=await H.post("/tasks",{title:u,description:p,priority:x,tags:j});t.close(),typeof window<"u"&&window.dispatchEvent(new MouseEvent("mousedown")),n(g=>[v,...g]),s.success("Task created.",1200),await i()}catch(v){s.error(`Create failed: ${v.message}`)}},m=d=>{d.key==="Enter"&&!d.shiftKey&&(d.preventDefault(),h(d))};t.open({title:"New task",width:520,children:e.jsxs("div",{className:"task-form",children:[e.jsx("label",{className:"field-label",htmlFor:"task-title",children:"Title *"}),e.jsx("input",{ref:d=>{r=d},id:"task-title",className:"input",type:"text",maxLength:200,placeholder:"What needs to be done?",autoFocus:!0,onKeyDown:m}),e.jsx("label",{className:"field-label",htmlFor:"task-desc",children:"Description"}),e.jsxs("div",{style:{display:"flex",gap:6,alignItems:"flex-start"},children:[e.jsx("textarea",{ref:d=>{o=d},id:"task-desc",className:"textarea",rows:4,placeholder:"Add any context Odin might need (markdown ok)…",style:{flex:1}}),e.jsx("button",{type:"button",className:"btn btn-ghost btn-icon",title:"Enhance with AI",onClick:async()=>{var u;if(!((u=o==null?void 0:o.value)!=null&&u.trim()))return;const d=await iu(o.value);d!==o.value&&(o.value=d)},children:"✨"})]}),e.jsxs("div",{className:"task-form-row",children:[e.jsxs("label",{htmlFor:"task-priority",className:"task-form-field",children:["Priority hint",e.jsx("select",{ref:d=>{c=d},id:"task-priority",className:"select",defaultValue:"normal",children:fa.map(d=>e.jsx("option",{value:d,children:d},d))})]}),e.jsxs("label",{htmlFor:"task-tags",className:"task-form-field",style:{flex:2},children:["Tags ",e.jsx("span",{className:"field-hint",children:"(comma-separated)"}),e.jsx("input",{ref:d=>{l=d},id:"task-tags",className:"input",type:"text",placeholder:"bug, frontend, urgent"})]})]}),e.jsx("p",{className:"muted text-sm",style:{marginTop:8},children:"The agent and final priority are decided by Odin after you submit."})]}),footer:e.jsxs("div",{className:"modal-footer-actions",children:[e.jsx(U,{variant:"ghost",onClick:()=>t.close(),children:"Cancel"}),e.jsxs(U,{variant:"primary",type:"button",onClick:d=>h(d),children:[e.jsx(We,{size:14})," Create task"]})]})})}function br(t,s,n,a,i,r){let o=null,l=null,c=null,h=null;const m=async()=>{const d=((o==null?void 0:o.value)||"").trim(),u=((l==null?void 0:l.value)||"").trim();if(!d){s.warning("Title is required."),o==null||o.focus();return}const p=(h==null?void 0:h.value)||"normal",x=((c==null?void 0:c.value)||"").split(",").map(j=>j.trim()).filter(Boolean);try{const j=await H.put(`/tasks/${encodeURIComponent(n.id)}`,{title:d,description:u,priority:p,tags:x});t.close(),typeof window<"u"&&window.dispatchEvent(new MouseEvent("mousedown")),a(v=>v.map(g=>g.id===n.id?j:g)),s.success("Task updated.",1200),await r()}catch(j){s.error(`Save failed: ${j.message}`)}};t.open({title:"Edit task",width:520,children:e.jsxs("div",{className:"task-form",children:[e.jsx("label",{className:"field-label",htmlFor:"edit-task-title",children:"Title *"}),e.jsx("input",{ref:d=>{o=d},id:"edit-task-title",className:"input",type:"text",maxLength:200,defaultValue:n.title,autoFocus:!0}),e.jsx("label",{className:"field-label",htmlFor:"edit-task-desc",children:"Description"}),e.jsx("textarea",{ref:d=>{l=d},id:"edit-task-desc",className:"textarea",rows:4,defaultValue:n.description||""}),e.jsxs("div",{className:"task-form-row",children:[e.jsxs("label",{htmlFor:"edit-task-priority",className:"task-form-field",children:["Priority hint",e.jsx("select",{ref:d=>{h=d},id:"edit-task-priority",className:"select",defaultValue:n.priority||"normal",children:fa.map(d=>e.jsx("option",{value:d,children:d},d))})]}),e.jsxs("label",{htmlFor:"edit-task-tags",className:"task-form-field",style:{flex:2},children:["Tags",e.jsx("input",{ref:d=>{c=d},id:"edit-task-tags",className:"input",type:"text",defaultValue:(n.tags||[]).join(", "),placeholder:"comma-separated"})]})]}),e.jsxs(se,{children:[e.jsxs(de,{children:[e.jsx(hh,{size:12})," Status"]}),e.jsxs(ue,{children:["Current: ",e.jsx("strong",{children:n.status}),n.workedBy&&e.jsxs(e.Fragment,{children:[" · Worked by @",n.workedBy]}),n.assignee&&!n.workedBy&&e.jsxs(e.Fragment,{children:[" · Assigned @",n.assignee]})]})]})]}),footer:e.jsxs("div",{className:"modal-footer-actions",children:[e.jsx(U,{variant:"ghost",onClick:()=>t.close(),children:"Cancel"}),e.jsxs(U,{variant:"primary",onClick:m,children:[e.jsx(Wo,{size:14})," Save"]})]})})}const vf=rt.memo(xf);function jf(t){return H.urlWithToken(`/artifacts/${encodeURIComponent(t)}/content`)}function bf(t,s){const n=jf(s);window.open(n,"_blank","noopener,noreferrer")}const wr={"1m":60*1e3,"5m":5*60*1e3,"30m":30*60*1e3,"1h":60*60*1e3},st=56,bt=32,us=22,wf=4,kf=.9,Ia={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 La(t){return t&&Ia[t]||Ia.idle}function Sn(t,s=24){return t?t.length<=s?t:t.slice(0,s-1)+"…":""}function Jn(t){if(t==null)return 0;if(typeof t=="number")return t;const s=new Date(t).getTime();return Number.isNaN(s)?0:s}function Pa(t){const s=t._timerStart;return typeof s=="number"&&s>0?s:Jn(t.createdAt)||Date.now()}function Nf(t,s){return(t.status==="done"||t.status==="archived"||t.status==="failed"||t.status==="killed")&&(Jn(t.completedAt)||Jn(t.updatedAt))||s}function Sf(t){return typeof t.startedAt=="number"&&t.startedAt>0?t.startedAt:Date.now()}function Cf(t,s){return(t.status==="done"||t.status==="success"||t.status==="killed"||t.status==="failed"||t.status==="error"||t.status==="timed_out")&&(t.completedAt||t.lastEventAt)||s}function zf(t){return t<=6e4?1e4:t<=3e5?3e4:t<=18e5?3e5:6e5}function Mf(t,s){const n=new Date(t);return s<=3e5?n.toLocaleTimeString("en-GB",{hour12:!1}):n.toLocaleTimeString("en-GB",{hour12:!1,hour:"2-digit",minute:"2-digit"})}function $f({snapshot:t,refreshSnapshot:s}){const n=pe(),a=f.useRef(null),[i,r]=f.useState("live"),[o,l]=f.useState("5m"),[c,h]=f.useState(()=>typeof window>"u"?!0:window.innerWidth>900),[m,d]=f.useState([]),[u,p]=f.useState([]),[x,j]=f.useState(!0),[v,g]=f.useState(0),[b,y]=f.useState(Date.now()),[w,S]=f.useState(()=>Date.now()-wr["5m"]*.1),[$,M]=f.useState({width:800,height:400}),[z,A]=f.useState(null),[k,C]=f.useState(""),[_,P]=f.useState([]),[N,T]=f.useState(""),[L,R]=f.useState("normal"),[F,E]=f.useState(""),[D,G]=f.useState(""),[I,W]=f.useState(!1),[V,X]=f.useState(!1),[J,le]=f.useState([]),B=Qe(),Y=t.agents||[],ee=t.tasks||[],ae=wr[o],ne=w,O=w+ae,K=f.useCallback(async()=>{try{const[q,re]=await Promise.all([H.get("/background").catch(()=>({instances:[]})),H.get("/activity?limit=200").catch(()=>({events:[]}))]);d(q.instances||[]),p(re.events||[])}catch(q){At.warn("activity reload failed:",q)}finally{j(!1)}},[]);f.useEffect(()=>{K();const q=setInterval(K,3e3);return()=>clearInterval(q)},[K]),f.useEffect(()=>{g(q=>q+1)},[ee.length,Y.length]),f.useEffect(()=>{if(i==="pause")return;y(Date.now());const q=setInterval(()=>y(Date.now()),1e3);return()=>clearInterval(q)},[i,v]),f.useEffect(()=>{if(i==="pause")return;(b-w)/ae>kf&&S(b-ae*.1)},[b,w,ae,i]),f.useEffect(()=>{S(Date.now()-ae*.1)},[o]),f.useEffect(()=>{i==="live"&&S(Date.now()-ae*.1)},[i]),f.useLayoutEffect(()=>{const q=a.current;if(!q)return;const re=new ResizeObserver(Se=>{for(const Ce of Se){const{width:ve,height:ze}=Ce.contentRect;M({width:Math.max(200,Math.floor(ve)),height:Math.max(120,Math.floor(ze))})}});return re.observe(q),()=>re.disconnect()},[]);const Z=f.useMemo(()=>{const q=[];let re=0;for(const ve of m){const ze=Sf(ve),Xe=Cf(ve,b);Xe<ne||ze>O||q.push({kind:"bg",id:`bg:${ve.instanceId}`,index:re++,label:`BG ${Sn(ve.promptPreview,20)||ve.instanceId.slice(0,10)}`,sub:ve.status||"pending",start:ze,end:Xe,data:ve})}const Se=[...ee].sort((ve,ze)=>Pa(ve)-Pa(ze)),Ce=[];for(const ve of Se){const ze=Pa(ve),Xe=Nf(ve,b);if(Xe<ne||ze>O)continue;let Lt=-1;for(let $t=0;$t<Ce.length;$t++)if(Ce[$t]<=ze){Ce[$t]=Xe,Lt=$t;break}Lt===-1&&(Ce.push(Xe),Lt=Ce.length-1),q.push({kind:"task",id:`task:${ve.id}`,index:re+Lt,label:Sn(ve.title,32),sub:ve.status,start:ze,end:Xe,data:ve})}return q},[m,ee,b,ne,O]),Q=f.useMemo(()=>{const q=new Map;for(const re of Z)q.set(re.id,re);return q},[Z]),oe=f.useCallback(q=>ae<=0?0:(q-ne)/ae*$.width,[ne,ae,$.width]),ce=f.useMemo(()=>{const q=zf(ae),re=[],Se=Math.floor(ne/q)*q;for(let Ce=Se;Ce<=O+q;Ce+=q){if(Ce<ne-q)continue;if(Ce>O)break;const ve=oe(Ce);ve<-40||ve>$.width+40||re.push({t:Ce,x:ve,label:Mf(Ce,ae)})}return re},[ne,O,ae,$.width,oe]),me=f.useMemo(()=>{const q=[];for(const re of Z){if(re.kind==="events")continue;const Se=Math.max(re.start,ne),Ce=Math.min(re.end,O);if(Ce<ne||Se>O)continue;const ve=oe(Se),ze=oe(Ce),Xe=Math.max(wf,ze-ve),Lt=bt+us+re.index*st+8,$t=st-16;let et="doing";if(re.kind==="bg"){const Ae=re.data.status||"pending";Ae==="done"||Ae==="success"?et="done":Ae==="failed"||Ae==="killed"||Ae==="error"?et="failed":Ae==="queued"||Ae==="pending"?et="queued":Ae==="blocked"||Ae==="stuck"?et="blocked":et="doing"}else{const Ae=re.data.status;Ae==="done"||Ae==="archived"?et="done":Ae==="failed"||Ae==="killed"?et="failed":Ae==="queued"?et="queued":Ae==="blocked"?et="blocked":et="doing"}const Ma=(z==null?void 0:z.id)===re.id;q.push({id:re.id,laneIndex:re.index,x:ve,y:Lt,w:Xe,h:$t,label:re.label,statusClass:et,selected:Ma,data:re.data,kind:re.kind,start:re.start,end:re.end})}return q},[Z,oe,z,ne,O]),be=f.useMemo(()=>{const q=[];for(const re of u){const Se=Jn(re.ts);if(Se<ne-5e3||Se>O+5e3)continue;const Ce=oe(Se);let ve=bt+12;if(re.taskId){const ze=Q.get(`task:${re.taskId}`);ze&&(ve=bt+us+ze.index*st+st/2)}else if(re.nodeId){const ze=String(re.nodeId),Xe=Q.get(ze.startsWith("task:")||ze.startsWith("bg:")?ze:`task:${ze}`);Xe&&(ve=bt+us+Xe.index*st+st/2)}q.push({id:`${re.ts}-${re.kind}-${re.author??""}-${re.taskId??""}`,x:Ce,y:ve,kind:re.kind||"event",ts:Se,text:String(re.text||re.kind||""),author:re.author})}return q},[u,ne,O,oe,Q]),Ne=f.useMemo(()=>Z.map(q=>({id:q.id,y:bt+us+q.index*st,h:st})),[Z]),Me=f.useMemo(()=>{const q=oe(b);return Math.max(0,Math.min($.width,q))},[oe,b,$.width]),Ge=f.useCallback(q=>{const Se={id:q.id,kind:q.kind,label:q.label,status:q.statusClass,data:q.data};A(Se)},[]);f.useEffect(()=>{if(!z){P([]),G(""),le([]);return}C(""),T(""),E(""),le([]),(async()=>{try{const q=await H.get(`/activity?nodeId=${encodeURIComponent(z.id)}&limit=50`);P(q.events||[])}catch{P([])}if(z.kind==="bg"){const q=z.data;try{const re=await H.get(`/background/${encodeURIComponent(q.instanceId)}/output?lines=80`);G(re.output||"")}catch{G("")}if(q.taskId)try{const re=await H.get(`/tasks/${encodeURIComponent(q.taskId)}/artifacts`);le((re.artifacts||[]).map(Se=>Se.id))}catch{le([])}}})()},[z]);const Je=async()=>{if(!(!z||!k.trim())){X(!0);try{await H.post("/comments",{nodeId:z.id,text:k,author:"user"}),C("");const q=await H.get(`/activity?nodeId=${encodeURIComponent(z.id)}&limit=50`);P(q.events||[]),n.success("Comment added.")}catch(q){n.error(`Comment failed: ${q.message}`)}finally{X(!1)}}},De=async()=>{if(!(!z||!N.trim())){W(!0);try{await H.post(`/nodes/${encodeURIComponent(z.id)}/tasks`,{title:N,description:`Created from timeline selection ${z.id}.`,priority:L}),T(""),n.success("Task created."),await s()}catch(q){n.error(`Task create failed: ${q.message}`)}finally{W(!1)}}},Oe=async()=>{if(!z||z.kind!=="bg"||!F.trim())return;const q=z.data;try{const re=await H.post(`/background/${encodeURIComponent(q.instanceId)}/message`,{message:F});re.ok?(n.success("Message sent."),E("")):n.warning(re.error||"Send failed")}catch(re){n.error(`Send failed: ${re.message}`)}},Ye=async()=>{if(!z||z.kind!=="bg"||!confirm("Kill this bg instance session?"))return;const q=z.data;try{const re=await H.del(`/background/${encodeURIComponent(q.instanceId)}`);re.ok?n.success("Session killed."):n.warning(re.error||"Kill failed"),await K()}catch(re){n.error(`Kill failed: ${re.message}`)}},Mt=async()=>{if(!z||z.kind!=="bg")return;const q=z.data;try{const re=await H.get(`/background/${encodeURIComponent(q.instanceId)}/output?lines=80`);G(re.output||"")}catch{}};f.useEffect(()=>{const q=re=>{re.key==="Escape"&&A(null)};return window.addEventListener("keydown",q),()=>window.removeEventListener("keydown",q)},[]);const Ls=()=>{g(q=>q+1),K()},qt=bt+us+Z.length*st;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(He,{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(U,{variant:i==="live"?"primary":"secondary",size:"sm",onClick:()=>r(i==="live"?"pause":"live"),title:i==="live"?"Pause timeline":"Resume timeline",children:[i==="live"?e.jsx(ki,{size:14}):e.jsx(ws,{size:14}),i==="live"?"Live":"Paused"]}),e.jsx("div",{className:"tl-zoom-group",children:["1m","5m","30m","1h"].map(q=>e.jsx("button",{type:"button",className:te("tl-zoom-btn",o===q&&"tl-zoom-btn-active"),onClick:()=>l(q),title:`Zoom to ${q}`,children:q},q))}),e.jsxs(U,{variant:"secondary",size:"sm",onClick:Ls,title:"Refresh",children:[e.jsx(xe,{size:14})," Refresh"]})]})})]}),x&&e.jsx("div",{className:"view-loading",children:e.jsx(ye,{size:"lg"})}),!x&&Y.length===0&&ee.length===0&&m.length===0&&u.length===0?e.jsx(Te,{icon:e.jsx(He,{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:te("tl-view",z&&"tl-view-detail-open"),children:e.jsxs("div",{className:te("tl-body",!c&&"tl-body-stream-collapsed"),children:[e.jsxs("aside",{className:te("tl-stream",!c&&"tl-stream-collapsed"),children:[e.jsxs("div",{className:"tl-stream-head",children:[e.jsxs("h3",{children:[e.jsx(Zs,{size:13})," Live events"]}),e.jsx("button",{type:"button",className:"icon-btn",onClick:()=>h(!1),title:"Hide event stream","aria-label":"Hide event stream",children:e.jsx(nh,{size:14})})]}),e.jsx("div",{className:"tl-stream-list",children:u.length===0?e.jsx("div",{className:"tl-stream-empty",children:e.jsx("p",{children:"No events yet."})}):e.jsx(qo,{items:[...u].reverse(),itemHeight:40,height:400,className:"tl-stream-virtual",renderItem:q=>{const re=q.author?pt:q.kind==="task"?Qt:q.kind==="bg"?Fn:He;return e.jsxs("div",{className:"tl-stream-event",children:[e.jsx("span",{className:"tl-stream-event-time",children:new Date(q.ts).toLocaleTimeString("en-GB",{hour12:!1})}),e.jsx("span",{className:"tl-stream-event-icon",style:{color:La(q.kind)},children:e.jsx(re,{size:12})}),e.jsx("span",{className:"tl-stream-event-text",children:q.author||q.text||q.kind})]})}})})]}),e.jsxs("div",{className:"tl-canvas-wrap",ref:a,children:[e.jsxs("div",{className:"tl-canvas-toolbar",children:[e.jsxs("div",{className:"tl-canvas-toolbar-left",children:[!c&&e.jsxs(U,{variant:"ghost",size:"sm",onClick:()=>h(!0),title:"Show event stream",children:[e.jsx(ah,{size:14})," Events"]}),e.jsx("span",{className:"tl-canvas-mode",children:i==="live"?"● Live":"⏸ Paused"}),e.jsxs("span",{className:"tl-canvas-range",children:[new Date(ne).toLocaleTimeString("en-GB",{hour12:!1})," →"," ",new Date(O).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(Zu,{size:11})," agent"]}),e.jsxs("span",{className:"tl-legend-item",children:[e.jsx(Ai,{size:11})," task"]}),e.jsxs("span",{className:"tl-legend-item",children:[e.jsx(Fn,{size:11})," bg"]})]})]}),e.jsx("div",{className:"tl-canvas-scroll",children:e.jsxs("svg",{className:"tl-canvas",width:$.width,height:Math.max($.height,qt),role:"application","aria-label":"Activity timeline",children:[e.jsx("defs",{children:e.jsx("pattern",{id:"tl-canvas-grid",width:$.width,height:st,patternUnits:"userSpaceOnUse",children:e.jsx("path",{d:`M 0 0 L 0 ${st}`,fill:"none",stroke:"var(--border)",strokeWidth:.5,opacity:.35})})}),e.jsx("rect",{width:"100%",height:"100%",fill:"url(#tl-canvas-grid)"}),Ne.map(q=>e.jsx("rect",{className:"tl-lane-bg",x:0,y:q.y,width:$.width,height:q.h,fill:q.id.charCodeAt(q.id.length-1)%2===0?"var(--bg-elev-2)":"var(--bg-elev)",opacity:.4},`bg-${q.id}`)),e.jsx("g",{className:"tl-time-axis",children:ce.map(q=>e.jsxs("g",{children:[e.jsx("line",{x1:q.x,y1:0,x2:q.x,y2:qt,stroke:"var(--border)",strokeWidth:.5,strokeDasharray:"2,4",opacity:.5}),e.jsx("text",{x:q.x+4,y:bt-8,fontSize:10,fontFamily:"var(--font-mono)",fill:"var(--text-dim)",children:q.label})]},`tick-${q.t}`))}),Z.map(q=>{const re=bt+us+q.index*st+st/2;return e.jsxs("g",{className:"tl-lane-label-group",children:[e.jsx("text",{x:6,y:re-2,className:"tl-lane-label",textAnchor:"start",children:Sn(q.label,28)}),e.jsx("text",{x:6,y:re+10,className:"tl-lane-label-sub",textAnchor:"start",children:q.sub})]},`label-${q.id}`)}),me.map(q=>{const re=La(q.statusClass),Se=q.id===(z==null?void 0:z.id);return e.jsxs("g",{className:te("tl-task-bar",`tl-task-bar-${q.statusClass}`,Se&&"tl-task-bar-selected"),onClick:()=>Ge(q),children:[e.jsx("rect",{x:q.x,y:q.y,width:q.w,height:q.h,rx:6,fill:re,fillOpacity:q.statusClass==="done"?.35:q.statusClass==="queued"?.18:.85,stroke:re,strokeWidth:Se?2.5:1.5,strokeOpacity:q.statusClass==="done"?.5:1,strokeDasharray:q.statusClass==="queued"?"4 4":void 0,style:{cursor:"pointer"}}),q.w>36&&e.jsx("text",{x:q.x+8,y:q.y+q.h/2+4,fontSize:11,fontFamily:"var(--font-sans)",fontWeight:500,fill:"var(--text-strong)",style:{pointerEvents:"none"},opacity:q.statusClass==="done"?.7:1,children:Sn(q.label,Math.max(4,Math.floor(q.w/7)))})]},`bar-${q.id}`)}),be.map(q=>{const re=La(q.kind);return e.jsxs("g",{className:"tl-event-marker-group",children:[e.jsx("line",{x1:q.x,y1:q.y-6,x2:q.x,y2:q.y+6,stroke:re,strokeWidth:1.2,opacity:.7}),e.jsx("circle",{cx:q.x,cy:q.y,r:4,fill:re,opacity:.9,children:e.jsx("title",{children:`${q.kind}${q.author?` · ${q.author}`:""} · ${new Date(q.ts).toLocaleTimeString("en-GB",{hour12:!1})}`})})]},`ev-${q.id}`)}),e.jsx("line",{className:"tl-now-line",x1:Me,y1:0,x2:Me,y2:qt,stroke:"var(--error)",strokeWidth:1.5,opacity:.9}),e.jsxs("g",{className:"tl-now-marker",children:[e.jsx("circle",{cx:Me,cy:bt-4,r:4,fill:"var(--error)"}),e.jsx("text",{x:Me+6,y:bt-4,fontSize:10,fontWeight:700,fill:"var(--error)",fontFamily:"var(--font-mono)",children:"now"})]})]})})]}),z&&e.jsx("aside",{className:"tl-detail tl-detail-enter",children:e.jsxs(se,{children:[e.jsxs(de,{children:[z.kind==="agent"&&e.jsx(pt,{size:14}),z.kind==="task"&&e.jsx(Qt,{size:14}),z.kind==="bg"&&e.jsx(Fn,{size:14}),z.label,e.jsx("button",{type:"button",className:"icon-btn",onClick:()=>A(null),title:"Close","aria-label":"Close activity detail",style:{marginLeft:"auto"},children:e.jsx(Ie,{size:14})})]}),e.jsxs("div",{className:"tl-detail-meta",children:[e.jsxs("div",{children:[e.jsx("span",{className:"muted",children:"type"})," ",z.kind]}),e.jsxs("div",{children:[e.jsx("span",{className:"muted",children:"status"})," ",e.jsx("code",{children:z.status})]}),z.kind==="agent"&&(()=>{const q=z.data;return e.jsxs(e.Fragment,{children:[q.role&&e.jsxs("div",{children:[e.jsx("span",{className:"muted",children:"role"})," ",q.role]}),q.model&&e.jsxs("div",{children:[e.jsx("span",{className:"muted",children:"model"})," ",q.model]})]})})(),z.kind==="task"&&(()=>{const q=z.data;return e.jsxs(e.Fragment,{children:[q.assignee&&e.jsxs("div",{children:[e.jsx("span",{className:"muted",children:"assignee"})," @",q.assignee]}),q.priority&&e.jsxs("div",{children:[e.jsx("span",{className:"muted",children:"priority"})," ",q.priority]}),q.createdAt&&e.jsxs("div",{children:[e.jsx("span",{className:"muted",children:"created"})," ",new Date(q.createdAt).toLocaleString()]})]})})(),z.kind==="bg"&&(()=>{const q=z.data;return e.jsxs(e.Fragment,{children:[q.startedAt&&e.jsxs("div",{children:[e.jsx("span",{className:"muted",children:"started"})," ",new Date(q.startedAt).toLocaleString()]}),q.tmuxSession&&e.jsxs("div",{children:[e.jsx("span",{className:"muted",children:"tmux"})," ",e.jsx("code",{children:q.tmuxSession})," ",q.tmuxActive?e.jsx("span",{className:"tag tag-success",children:"active"}):e.jsx("span",{className:"tag",children:"inactive"})]})]})})()]}),z.kind==="task"&&z.data.description&&e.jsx("div",{className:"tl-detail-desc",children:z.data.description}),z.kind==="bg"&&z.data.promptPreview&&e.jsx("div",{className:"tl-detail-desc",children:z.data.promptPreview}),z.kind==="bg"&&e.jsxs("div",{className:"tl-detail-bg",children:[e.jsx("pre",{className:"tl-bg-output",children:D||"(no output — start the session via tmux attach)"}),e.jsxs("div",{className:"tl-bg-output-actions",children:[e.jsxs(U,{variant:"ghost",size:"sm",onClick:Mt,children:[e.jsx(xe,{size:12})," Refresh output"]}),J.length>0&&e.jsxs(U,{variant:"secondary",size:"sm",onClick:()=>bf(B,J[0]),children:[e.jsx(Ue,{size:12})," Open artifact"]}),e.jsxs(U,{variant:"danger",size:"sm",onClick:Ye,children:[e.jsx(Fe,{size:12})," Kill session"]})]}),e.jsxs("div",{className:"tl-form-row",children:[e.jsx("label",{htmlFor:"bg-message-input",className:"sr-only",children:"Send a message to this bg session"}),e.jsx("input",{id:"bg-message-input",className:"input",placeholder:"Send a message to this bg session…",value:F,onChange:q=>E(q.target.value),onKeyDown:q=>{q.key==="Enter"&&Oe()},"aria-label":"Send a message to this bg session"}),e.jsxs(U,{variant:"primary",size:"sm",disabled:!F.trim(),onClick:Oe,children:[e.jsx(Rt,{size:12})," Send"]})]})]}),z.kind!=="bg"&&e.jsxs("div",{className:"tl-detail-create",children:[e.jsx("label",{className:"field-label",htmlFor:"followup-task-title",children:"Create follow-up task"}),e.jsx("input",{id:"followup-task-title",className:"input",placeholder:"Task title",value:N,onChange:q=>T(q.target.value)}),e.jsxs("div",{className:"tl-form-row",children:[e.jsx("label",{htmlFor:"followup-task-priority",className:"sr-only",children:"Task priority"}),e.jsxs("select",{id:"followup-task-priority",className:"select",value:L,onChange:q=>R(q.target.value),"aria-label":"Task priority",children:[e.jsx("option",{value:"low",children:"Low"}),e.jsx("option",{value:"normal",children:"Normal"}),e.jsx("option",{value:"high",children:"High"})]}),e.jsxs(U,{variant:"primary",size:"sm",disabled:!N.trim()||I,onClick:De,children:[e.jsx(We,{size:12})," Add task"]})]})]}),e.jsxs("div",{className:"tl-detail-comments",children:[e.jsxs("div",{className:"field-label",children:[e.jsx(mn,{size:12})," Comments & activity"]}),e.jsxs("ul",{className:"comment-list",children:[_.length===0&&e.jsx("li",{className:"muted",children:"No comments yet."}),_.map((q,re)=>e.jsxs("li",{className:"comment-item",children:[e.jsxs("div",{className:"comment-head",children:[e.jsx("strong",{children:q.author||"system"}),e.jsxs("span",{className:"muted",children:[q.kind," · ",new Date(q.ts).toLocaleString()]})]}),q.text&&e.jsx("div",{className:"comment-text",children:q.text}),q.taskId&&e.jsxs("div",{className:"muted",children:["→ task ",e.jsx("code",{children:String(q.taskId)})]})]},`c-${re}`))]}),e.jsxs("div",{className:"comment-input-row",children:[e.jsx("label",{htmlFor:"comment-input",className:"sr-only",children:"Add a comment"}),e.jsx("input",{id:"comment-input",className:"input",placeholder:"Add a comment…",value:k,onChange:q=>C(q.target.value),onKeyDown:q=>{q.key==="Enter"&&!q.shiftKey&&Je()},"aria-label":"Add a comment"}),e.jsxs(U,{variant:"secondary",size:"sm",disabled:!k.trim()||V,onClick:Je,children:[e.jsx(Rt,{size:12})," Post"]})]})]})]})},z.id)]})})]})}function Ef(t,s){const n=t.length,a=s.length,i=Array.from({length:a+1},()=>Array(n+1).fill(0));for(let r=0;r<=n;r++)i[0][r]=r;for(let r=0;r<=a;r++)i[r][0]=r;for(let r=1;r<=a;r++)for(let o=1;o<=n;o++){const l=t[o-1]===s[r-1]?0:1;i[r][o]=Math.min(i[r][o-1]+1,i[r-1][o]+1,i[r-1][o-1]+l)}return i[a][n]}function Da(t,s){if(s===t)return 100;if(s.startsWith(t))return 90;const n=s.split(/\s+/);for(const r of n)if(r.startsWith(t))return 80;const a=Math.min(t.length,s.length);return Ef(t,s.substring(0,a))<=2?40:s.includes(t)?30:0}function _f(t,s){const n=t.toLowerCase().trim();return n?s.map(a=>{const i=Da(n,a.label.toLowerCase()),r=a.value?Da(n,String(a.value).toLowerCase()):0,o=a.description?Da(n,a.description.toLowerCase()):0,l=Math.max(i,r,o);if(l===0)return null;const c=i>=r&&i>=o?"label":r>=i&&r>=o?"value":"description",h=c==="label"?a.label:c==="value"?String(a.value):a.description;return{...a,score:l,matchedField:c,matchedTerm:h}}).filter(a=>a!==null).sort((a,i)=>i.score-a.score):[]}const Ii="bizar_settings_recent";function dl(){try{const t=localStorage.getItem(Ii);return t?JSON.parse(t):[]}catch{return[]}}function Tf(t){if(t)try{const s=dl().filter(n=>n!==t);s.unshift(t),localStorage.setItem(Ii,JSON.stringify(s.slice(0,5)))}catch{}}function Af(t,s){if(!s)return t;const n=s.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),a=new RegExp(`(${n})`,"gi");return t.split(a).map((r,o)=>a.test(r)?e.jsx("mark",{children:r},o):e.jsx("span",{children:r},o))}function Rf(t){const s=[];for(const n of t){s.push({key:n.id,label:n.label,section:n.id,description:`${n.fields.length} field${n.fields.length===1?"":"s"}`});for(const a of n.fields)s.push({key:a.key,label:a.label,section:n.id,value:a.value})}return s}function If({sections:t,onJump:s}){const[n,a]=f.useState(""),[i,r]=f.useState([]),[o,l]=f.useState(0),[c,h]=f.useState(null),[m,d]=f.useState(!1),u=f.useRef(null),p=f.useRef(null),x=f.useRef(null),j=f.useRef([]);f.useEffect(()=>{j.current=Rf(t)},[t]);const v=f.useCallback((k,C=!1)=>{if(p.current&&clearTimeout(p.current),!k.trim()){r([]),l(0);return}const _=()=>{const P=_f(k,j.current);r(P),l(0)};C?_():p.current=setTimeout(_,150)},[]);f.useEffect(()=>{v(n)},[n,v]),f.useEffect(()=>()=>{p.current&&clearTimeout(p.current),x.current&&clearTimeout(x.current)},[]);const g=(k,C)=>{const _=document.querySelector(`[data-section="${k}"] [data-setting-id="${C}"]`);_&&(_.scrollIntoView({behavior:"smooth",block:"center"}),_.classList.add("setting-flash"),setTimeout(()=>_.classList.remove("setting-flash"),2e3));const P=document.querySelector(`[data-section="${k}"]`);P&&P.scrollIntoView({behavior:"smooth",block:_?"nearest":"start"})},b=k=>{h(k),x.current&&clearTimeout(x.current),x.current=setTimeout(()=>h(null),1500);const C=document.querySelector(`[data-section="${k}"]`);C&&C.scrollIntoView({behavior:"smooth",block:"start"})},y=k=>{var C;Tf(n),k.key===k.section?(b(k.section),s(k.section)):(b(k.section),s(k.section,k.key),g(k.section,k.key)),a(""),(C=u.current)==null||C.blur()},w=k=>{var C;k.key==="Escape"?(a(""),(C=u.current)==null||C.blur()):k.key==="ArrowDown"?(k.preventDefault(),l(_=>Math.min(_+1,i.length-1))):k.key==="ArrowUp"?(k.preventDefault(),l(_=>Math.max(_-1,0))):k.key==="Enter"&&(k.preventDefault(),i.length===0&&n.trim()&&v(n,!0),i[o]&&y(i[o]))},S=k=>{y(k)},$=dl(),M=k=>{var C;a(k),(C=u.current)==null||C.focus()},z=()=>{try{localStorage.removeItem(Ii)}catch{}d(k=>k)},A=m&&!n.trim()&&$.length>0;return e.jsxs("div",{className:"settings-search",children:[e.jsxs("div",{className:"settings-search-input-wrap",children:[e.jsx(Re,{size:13,className:"settings-search-icon"}),e.jsx("input",{ref:u,className:"settings-search-input",placeholder:"Search settings…",value:n,onChange:k=>a(k.target.value),onKeyDown:w,onFocus:()=>d(!0),onBlur:()=>setTimeout(()=>d(!1),150),"aria-label":"Search settings"}),n&&e.jsx("button",{type:"button",className:"icon-btn settings-search-clear",onClick:()=>a(""),"aria-label":"Clear search",children:e.jsx(Ie,{size:12})})]}),A&&e.jsxs("div",{className:"settings-search-recent",children:[e.jsxs("div",{className:"settings-search-recent-header",children:[e.jsx("span",{className:"settings-search-recent-label",children:"Recent"}),e.jsx("button",{type:"button",className:"settings-search-recent-clear",onClick:z,tabIndex:-1,children:"Clear"})]}),$.map(k=>e.jsxs("button",{type:"button",className:"settings-search-recent-item",onMouseDown:C=>{C.preventDefault(),M(k)},children:[e.jsx(Re,{size:11}),e.jsx("span",{children:k})]},k))]}),n&&i.length>0&&e.jsx("div",{className:"settings-search-results",children:i.map((k,C)=>e.jsxs("button",{type:"button",className:te("settings-search-result",C===o&&"settings-search-result-active"),onClick:()=>S(k),onMouseEnter:()=>l(C),children:[e.jsx("span",{className:te("settings-search-result-type",k.key===k.section&&"settings-search-result-type-section"),children:k.key===k.section?"section":"field"}),e.jsx("span",{className:"settings-search-result-label",children:Af(k.label,n)}),k.key!==k.section&&e.jsx("span",{className:"settings-search-result-key mono muted",children:k.key})]},`${k.section}::${k.key}`))}),n&&i.length===0&&e.jsx("div",{className:"settings-search-empty muted",children:"No matching settings."})]})}const Lf=[{id:"dark",label:"Dark",Icon:tl},{id:"light",label:"Light",Icon:il},{id:"system",label:"System",Icon:sh}],Pf=[{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"}],Df=["Inter","system-ui","Segoe UI","Roboto","JetBrains Mono","SF Mono","Cascadia Code"];function Ff({settings:t,patchTheme:s,patchUi:n}){return e.jsxs(se,{id:"settings-theme","data-section":"theme",children:[e.jsxs(de,{children:[e.jsx(nl,{size:14})," Theme"]}),e.jsx(ue,{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:Pf.map(a=>e.jsxs("button",{type:"button",className:te("theme-preset",t.theme.accent===a.accent&&"theme-preset-active"),onClick:()=>s({accent:a.accent}),title:a.name,children:[e.jsx("span",{className:"theme-preset-swatch",style:{background:a.accent}}),e.jsx("span",{className:"theme-preset-name",children:a.name})]},a.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:Lf.map(({id:a,label:i,Icon:r})=>{const o=t.theme.mode===a;return e.jsxs("button",{type:"button",className:te("theme-card",o&&"theme-card-active"),onClick:()=>s({mode:a}),children:[e.jsx(r,{size:16}),e.jsx("span",{className:"theme-card-label",children:i}),e.jsx("span",{className:te("theme-card-swatch",`theme-card-swatch-${a}`)})]},a)})})]}),e.jsx("div",{className:"theme-colors",children:["accent","success","warning","error","info"].map(a=>e.jsxs("div",{className:"field","data-setting-id":`theme.${a}`,children:[e.jsx("label",{className:"field-label",children:a.charAt(0).toUpperCase()+a.slice(1)}),e.jsxs("div",{className:"color-row",children:[e.jsx("input",{type:"color",className:"input color-input",value:t.theme[a],onChange:i=>s({[a]:i.target.value}),"aria-label":`${a} color`}),e.jsx("input",{type:"text",className:"input",value:t.theme[a],onChange:i=>s({[a]:i.target.value}),"aria-label":`${a} color hex`})]})]},a))}),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:t.theme.fontFamily,onChange:a=>s({fontFamily:a.target.value}),children:Df.map(a=>e.jsx("option",{value:a,children:a},a))})]}),e.jsxs("div",{className:"field","data-setting-id":"theme.fontSize",children:[e.jsxs("label",{className:"field-label",children:["Font size: ",t.theme.fontSize,"px"]}),e.jsx("input",{type:"range",min:12,max:20,value:t.theme.fontSize,onChange:a=>s({fontSize:Number(a.target.value)})})]}),e.jsxs("label",{className:"checkbox-row","data-setting-id":"theme.compactMode",children:[e.jsx("input",{type:"checkbox",checked:t.theme.compactMode,onChange:a=>s({compactMode:a.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:t.theme.animations,onChange:a=>s({animations:a.target.checked})}),e.jsx("span",{children:"Enable animations"})]})]})}function Of({tailscale:t,tailscaleDraft:s,setTailscaleDraft:n,onTailscaleToggle:a}){return e.jsxs(e.Fragment,{children:[e.jsxs(se,{id:"settings-service","data-section":"service",children:[e.jsxs(de,{children:[e.jsx(Ss,{size:14})," Service"]}),e.jsx(ue,{children:"Background daemon that runs schedules."}),e.jsx("div",{"data-setting-id":"service.enabled",children:t?e.jsxs("div",{className:"service-card",children:[e.jsxs("p",{children:["Status: ",e.jsx("strong",{children:t.settings.enabled?"enabled":"disabled"})," ","· Tailscale installed: ",e.jsx("strong",{children:t.installed?"yes":"no"})," ","· authenticated: ",e.jsx("strong",{children:t.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.jsxs(se,{id:"settings-tailscale","data-section":"tailscale",children:[e.jsxs(de,{children:[e.jsx(ni,{size:14})," Tailscale serve"]}),e.jsx(ue,{children:"Expose the dashboard over your Tailscale network."}),t?e.jsxs(e.Fragment,{children:[e.jsxs("p",{children:["Installed: ",e.jsx("strong",{children:t.installed?"yes":"no"})," ",t.version&&e.jsxs("span",{className:"muted",children:["(",t.version,")"]})]}),e.jsxs("p",{children:["Authenticated: ",e.jsx("strong",{children:t.authenticated?"yes":"no"})]}),e.jsxs("p",{children:["Serve enabled: ",e.jsx("strong",{children:t.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:s.port,onChange:i=>n(r=>({...r,port:Number(i.target.value)||4321}))})]}),e.jsxs("div",{className:"task-form-field",children:[e.jsx("label",{className:"field-label",htmlFor:"tailscale-https",children:"Use HTTPS"}),e.jsx("input",{id:"tailscale-https",type:"checkbox",checked:s.https,onChange:i=>n(r=>({...r,https:i.target.checked}))})]})]}),e.jsx(U,{variant:"primary",onClick:a,children:t.settings.enabled?"Disable serve":"Enable serve"})]}):e.jsx("p",{className:"muted",children:"Loading Tailscale status…"})]})]})}function Bf({settings:t,patchNotifications:s}){return e.jsxs(se,{id:"settings-notifications","data-section":"notifications",children:[e.jsx(de,{children:"Notifications"}),e.jsx(ue,{children:"Toast triggers inside the dashboard."}),e.jsxs("label",{className:"checkbox-row","data-setting-id":"notifications.onAgentComplete",children:[e.jsx("input",{type:"checkbox",checked:!!t.notifications.onAgentComplete,onChange:n=>s({onAgentComplete:n.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:!!t.notifications.onPlanApproval,onChange:n=>s({onPlanApproval:n.target.checked})}),e.jsx("span",{children:"Notify when a plan needs approval"})]})]})}function Hf({authStatus:t,setAuthStatus:s}){const n=pe(),[a,i]=f.useState(H.getToken()),[r,o]=f.useState("");f.useEffect(()=>{let m=!1;return(async()=>{try{const d=await H.probeAuthStatus();m||s(d)}catch{m||s({required:!0,loopback:!1,peer:""})}})(),()=>{m=!0}},[]);const l=async()=>{try{const m=await H.get("/auth/reveal");o(m.token),i(m.token),H.setToken(m.token);try{await navigator.clipboard.writeText(m.token),n.success("Token copied to clipboard.")}catch{n.success("Token revealed — copy from the field below.")}}catch(m){n.error(`Reveal failed: ${m.message}`)}},c=async()=>{if(confirm("Regenerate the auth token? Anything still using the old token will start getting 401 errors immediately."))try{const m=await H.post("/auth/regenerate");o(m.token),i(m.token),H.setToken(m.token);try{await navigator.clipboard.writeText(m.token),n.success("New token generated and copied to clipboard.")}catch{n.success("New token generated — copy from the field below. Old token is now invalid.")}}catch(m){n.error(`Regenerate failed: ${m.message}`)}},h=()=>{H.setToken(a.trim()),n.success("Token saved. The dashboard will use it on the next request.")};return e.jsxs(se,{id:"settings-auth","data-section":"auth",children:[e.jsxs(de,{children:[e.jsx(ss,{size:14})," Authentication"]}),e.jsx(ue,{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:t?t.required?"yes":"no":"probing…"})]}),e.jsxs("p",{style:{margin:"4px 0"},children:["Connection:"," ",e.jsx("strong",{children:t?t.loopback?"loopback (auto-trusted)":"remote":"probing…"})]}),e.jsxs("p",{style:{margin:"4px 0"},children:["Peer address:"," ",t!=null&&t.peer?e.jsx("code",{children:t.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.jsx("p",{className:"muted",style:{fontSize:12,margin:"4px 0"},children:"For Tailscale Serve or any reverse-proxy access, paste this token once via the boot screen — it is saved per-origin and works for all subsequent visits."})]}),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:a,onChange:m=>i(m.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(U,{variant:"secondary",size:"sm",onClick:h,children:[e.jsx(zi,{size:14})," Save token"]}),e.jsxs(U,{variant:"ghost",size:"sm",onClick:l,children:[e.jsx(Vt,{size:14})," Reveal & copy server token"]}),e.jsxs(U,{variant:"ghost",size:"sm",onClick:c,children:[e.jsx(Bo,{size:14})," Regenerate"]})]}),r?e.jsxs("p",{className:"muted",style:{fontSize:12,marginTop:8},children:["Last revealed token (one-time): ",e.jsx("code",{className:"mono",children:r})]}):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."})]})]})}function Vf({settings:t,patchAgents:s,patchDashboard:n,autoSave:a}){var h,m,d,u;const i=pe(),[r,o]=f.useState({});f.useEffect(()=>{H.get("/settings/plugin-options").then(o).catch(()=>{})},[]);const l=async()=>{try{await H.put("/settings/plugin-options",r),i.success("Saved — restart cline for changes to take effect.")}catch(p){i.error(`Save failed: ${p.message}`)}},c=async()=>{try{const x=await(await fetch("/api/background/cleanup",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({maxAgeDays:7})})).json();i.success(`Cleaned up ${x.deleted} old instances.`)}catch(p){i.error(`Cleanup failed: ${p.message}`)}};return e.jsxs(e.Fragment,{children:[e.jsxs(se,{id:"settings-agents","data-section":"agents",children:[e.jsxs(de,{children:[e.jsx(Ss,{size:14})," Agent Behavior"]}),e.jsx(ue,{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:((h=t.agents)==null?void 0:h.maxParallel)??6,onChange:p=>s({maxParallel:Math.max(1,Math.min(20,parseInt(p.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:((m=t.agents)==null?void 0:m.stuckThresholdMs)??6e5,onChange:p=>s({stuckThresholdMs:Math.max(6e4,Math.min(36e5,parseInt(p.target.value,10)||6e5))})})]}),e.jsxs("label",{className:"checkbox-row","data-setting-id":"agents.autoRestart",children:[e.jsx("input",{type:"checkbox",checked:!!((d=t.agents)!=null&&d.autoRestart),onChange:p=>s({autoRestart:p.target.checked})}),e.jsx("span",{children:"Auto-restart stuck agents"})]})]}),e.jsxs(se,{id:"settings-dashboard","data-section":"dashboard",children:[e.jsxs(de,{children:[e.jsx(Qs,{size:14})," Dashboard"]}),e.jsxs(ue,{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:t.dashboard.autoLaunchWeb!==!1,onChange:p=>n({autoLaunchWeb:p.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:t.dashboard.projectsDirectory??"",onChange:p=>n({projectsDirectory:p.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."}),t.dashboard.projectsDirectory&&e.jsxs(e.Fragment,{children:[!/^\/|^[A-Za-z]:/.test(t.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)."}),t.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(fu,{initialValue:(t.dashboard.allowedRoots??[]).join(`
|
|
396
|
+
`),delay:1500,saveFn:async p=>{const x=p.split(`
|
|
397
|
+
`).map(j=>j.trim()).filter(Boolean);n({allowedRoots:x}),a==null||a("dashboard",{allowedRoots:x})},render:({value:p,onChange:x,onBlur:j})=>e.jsx("textarea",{id:"set-allowed-roots",className:"textarea",rows:4,placeholder:`/workspace
|
|
398
|
+
/srv/projects`,value:p,onChange:v=>x(v.target.value),onBlur:j})},(u=t.dashboard.allowedRoots)==null?void 0:u.join(`
|
|
399
|
+
`)),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 p=(t.dashboard.allowedRoots??[]).join(`
|
|
400
|
+
`).split(`
|
|
401
|
+
`),x=[];return p.forEach((j,v)=>{j.trim()&&(/^\/|^[A-Za-z]:/.test(j)||x.push({key:`noabs-${v}`,msg:e.jsxs("p",{style:{color:"var(--warning)",fontSize:11,marginTop:2},children:["Line ",v+1,': "',j,'" — should be absolute (start with / or a drive letter).']})}),j.includes("..")&&x.push({key:`dots-${v}`,msg:e.jsxs("p",{style:{color:"var(--error)",fontSize:11,marginTop:2},children:["Line ",v+1,': "',j,`" — contains '..' (server will reject this).`]})}))}),x.map(j=>j.msg)})()]})]}),e.jsxs(se,{id:"settings-background","data-section":"background",children:[e.jsxs(de,{children:[e.jsx(Ss,{size:14})," Background Agents"]}),e.jsx(ue,{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:r.maxConcurrentInstances??8,onChange:p=>o(x=>({...x,maxConcurrentInstances:Math.max(1,Math.min(32,parseInt(p.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:r.backgroundToolCallCap??500,onChange:p=>o(x=>({...x,backgroundToolCallCap:Math.max(1,Math.min(5e3,parseInt(p.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:r.backgroundStallTimeoutMs??18e4,onChange:p=>o(x=>({...x,backgroundStallTimeoutMs:Math.max(1e4,Math.min(6e5,parseInt(p.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:r.backgroundThinkingLoopTimeoutMs??3e5,onChange:p=>o(x=>({...x,backgroundThinkingLoopTimeoutMs:Math.max(3e4,Math.min(9e5,parseInt(p.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:r.backgroundMaxInterventions??1,onChange:p=>o(x=>({...x,backgroundMaxInterventions:Math.max(1,Math.min(3,parseInt(p.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(U,{variant:"secondary",size:"sm",onClick:l,children:[e.jsx(bs,{size:14})," Save plugin options"]}),e.jsx(U,{variant:"secondary",size:"sm",onClick:c,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."]})})]})]})}function Uf({workspaceId:t,onInviteCreated:s}){const n=Qe(),[a,i]=f.useState(""),[r,o]=f.useState("editor"),[l,c]=f.useState([]),[h,m]=f.useState(!1),[d,u]=f.useState(!1),[p,x]=f.useState(null),[j,v]=f.useState(null);f.useEffect(()=>{g()},[t]);async function g(){m(!0);try{const $=await H.get(`/workspaces/${t}/invites`);c($.invites||[])}catch{}finally{m(!1)}}async function b($){if($.preventDefault(),!!a.trim()){u(!0),v(null);try{const M=await H.post(`/workspaces/${t}/invites`,{email:a.trim(),role:r});i(""),await g(),s==null||s(),n.open({title:"Invite Link Created",children:e.jsxs("div",{className:"invite-link-dialog",children:[e.jsxs("p",{children:["Share this link with ",e.jsx("strong",{children:a})," to invite them as ",e.jsx("strong",{children:r}),":"]}),e.jsxs("div",{className:"invite-url-box",children:[e.jsx(Ju,{size:14}),e.jsx("input",{type:"text",readOnly:!0,value:M.url,onClick:z=>z.target.select()}),e.jsx("button",{type:"button",className:"invite-copy-btn",onClick:()=>{navigator.clipboard.writeText(M.url).catch(()=>{}),x(M.token),setTimeout(()=>x(null),2e3)},children:p===M.token?e.jsx(Ht,{size:14}):e.jsx(Vt,{size:14})})]}),e.jsx("p",{className:"invite-url-note",children:"This link expires in 7 days."})]}),footer:e.jsx(U,{variant:"primary",size:"sm",onClick:()=>n.close(),children:"Done"})})}catch(M){v(M.message||"Failed to create invite")}finally{u(!1)}}}async function y($){if(confirm("Revoke this invite?"))try{await H.del(`/workspaces/${t}/invites/${$}`),await g()}catch(M){v(M.message||"Failed to revoke invite")}}function w($,M){navigator.clipboard.writeText($).catch(()=>{}),x(M),setTimeout(()=>x(null),2e3)}const S={admin:"role-admin",editor:"role-editor",viewer:"role-viewer"};return e.jsxs("div",{className:"invite-dialog",children:[e.jsxs("form",{className:"invite-form",onSubmit:b,children:[e.jsxs("div",{className:"invite-form-row",children:[e.jsxs("div",{className:"invite-form-field",children:[e.jsx("label",{htmlFor:"invite-email",children:"Email address"}),e.jsx("input",{id:"invite-email",type:"email",value:a,onChange:$=>i($.target.value),placeholder:"colleague@example.com",required:!0})]}),e.jsxs("div",{className:"invite-form-field invite-form-field-role",children:[e.jsx("label",{htmlFor:"invite-role",children:"Role"}),e.jsxs("select",{id:"invite-role",value:r,onChange:$=>o($.target.value),children:[e.jsx("option",{value:"viewer",children:"Viewer"}),e.jsx("option",{value:"editor",children:"Editor"}),e.jsx("option",{value:"admin",children:"Admin"})]})]}),e.jsxs(U,{type:"submit",variant:"primary",size:"sm",loading:d,disabled:!a.trim(),children:[e.jsx(eh,{size:13}),"Invite"]})]}),j&&e.jsx("p",{className:"invite-error",children:j})]}),e.jsxs("div",{className:"invite-list",children:[e.jsx("h4",{className:"invite-list-title",children:"Pending Invites"}),h&&e.jsx("p",{className:"invite-loading",children:"Loading..."}),!h&&l.length===0&&e.jsx("p",{className:"invite-empty",children:"No pending invites"}),l.map($=>e.jsxs("div",{className:"invite-item",children:[e.jsxs("div",{className:"invite-item-info",children:[e.jsx("span",{className:"invite-item-email",children:$.email}),e.jsx("span",{className:te("invite-item-role",S[$.role]),children:$.role})]}),e.jsxs("div",{className:"invite-item-actions",children:[e.jsx("button",{type:"button",className:"invite-action-btn",title:"Copy invite link",onClick:()=>{const M=`${window.location.origin}/accept-invite?token=${$.token}`;w(M,$.token)},children:p===$.token?e.jsx(Ht,{size:13}):e.jsx(Vt,{size:13})}),e.jsx("button",{type:"button",className:"invite-action-btn invite-action-revoke",title:"Revoke invite",onClick:()=>y($.token),children:e.jsx(Fe,{size:13})})]})]},$.token))]})]})}const qf={admin:Iu,editor:ss,viewer:ks},Wf={admin:"role-admin",editor:"role-editor",viewer:"role-viewer"};function Gf(){const[t,s]=f.useState([]),[n,a]=f.useState(!0),[i,r]=f.useState(!1),[o,l]=f.useState(""),[c,h]=f.useState(null),[m,d]=f.useState(null),u=Qe();f.useEffect(()=>{p()},[]);async function p(){a(!0);try{const g=await H.get("/workspaces");s(g.workspaces||[])}catch{h("Failed to load workspaces")}finally{a(!1)}}async function x(g){if(g.preventDefault(),!!o.trim()){r(!0);try{await H.post("/workspaces",{name:o.trim()}),l(""),await p()}catch(b){h(b.message||"Failed to create workspace")}finally{r(!1)}}}async function j(g,b){if(confirm(`Delete workspace "${b}"?`)&&confirm("This cannot be undone."))try{await H.del(`/workspaces/${g}`),await p()}catch(y){h(y.message||"Failed to delete workspace")}}function v(g){navigator.clipboard.writeText(`${window.location.origin}/accept-invite?workspace=${g}`).catch(()=>{}),d(g),setTimeout(()=>d(null),2e3)}return n?e.jsx("div",{className:"settings-section-loading",children:"Loading workspaces..."}):e.jsxs("div",{className:"settings-section settings-section-workspaces",children:[e.jsx("h3",{className:"settings-section-title",children:"Workspaces"}),e.jsx("p",{className:"settings-section-desc",children:"Workspaces let you share access with team members. Each workspace has its own members, settings, and data."}),c&&e.jsxs("div",{className:"settings-section-error",children:[e.jsx("span",{children:c}),e.jsx("button",{onClick:()=>h(null),children:"×"})]}),e.jsxs("form",{className:"workspace-create-form",onSubmit:x,children:[e.jsx("input",{type:"text",placeholder:"New workspace name",value:o,onChange:g=>l(g.target.value),maxLength:64}),e.jsxs(U,{type:"submit",variant:"primary",size:"sm",loading:i,disabled:!o.trim(),children:[e.jsx(We,{size:13}),"Create"]})]}),e.jsxs("div",{className:"workspace-list",children:[t.length===0&&e.jsx("p",{className:"workspace-list-empty",children:"No workspaces yet. Create one above."}),t.map(({workspace:g,role:b})=>{const y=qf[b]||ks;return e.jsxs("div",{className:"workspace-item",children:[e.jsxs("div",{className:"workspace-item-info",children:[e.jsx("div",{className:"workspace-item-icon",children:e.jsx(tn,{size:16})}),e.jsxs("div",{className:"workspace-item-details",children:[e.jsx("span",{className:"workspace-item-name",children:g.name}),e.jsxs("span",{className:te("workspace-item-role",Wf[b]),children:[e.jsx(y,{size:11}),b]})]})]}),e.jsxs("div",{className:"workspace-item-actions",children:[e.jsx(U,{variant:"ghost",size:"sm",iconOnly:!0,title:"Copy invite link",onClick:()=>v(g.id),children:m===g.id?e.jsx(Ht,{size:13}):e.jsx(Vt,{size:13})}),b==="admin"&&e.jsx(U,{variant:"ghost",size:"sm",iconOnly:!0,title:"Manage members",onClick:()=>{u.open({title:`Manage "${g.name}"`,children:e.jsx(Uf,{workspaceId:g.id,onInviteCreated:()=>p()}),width:520})},children:e.jsx(tn,{size:13})}),b==="admin"&&t.length>1&&e.jsx(U,{variant:"ghost",size:"sm",iconOnly:!0,title:"Delete workspace",onClick:()=>j(g.id,g.name),children:e.jsx(Fe,{size:13})})]})]},g.id)})]})]})}const Yf=[{id:"theme",label:"Theme"},{id:"updates",label:"Updates"},{id:"layout",label:"Layout"},{id:"general",label:"General"},{id:"env-vars",label:"Env Vars"},{id:"network",label:"Network"},{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:"headroom",label:"Headroom"},{id:"activity-log",label:"Activity"},{id:"about",label:"About"},{id:"workspaces",label:"Workspaces"}],Xf=[{id:"theme",label:"Theme",fields:[{key:"theme.presets",label:"Accent presets",section:"theme"},{key:"theme.accent",label:"Accent color",section:"theme"},{key:"theme.success",label:"Success color",section:"theme"},{key:"theme.warning",label:"Warning color",section:"theme"},{key:"theme.error",label:"Error color",section:"theme"},{key:"theme.info",label:"Info color",section:"theme"},{key:"theme.fontFamily",label:"Font family",section:"theme"},{key:"theme.fontSize",label:"Font size",section:"theme"},{key:"theme.compactMode",label:"Compact mode",section:"theme"},{key:"theme.animations",label:"Animations",section:"theme"}]},{id:"updates",label:"Updates",fields:[{key:"updates.channel",label:"Update channel",section:"updates"}]},{id:"layout",label:"Layout",fields:[{key:"ui.layout",label:"UI layout",section:"layout"},{key:"ui.showHeader",label:"Show header",section:"layout"},{key:"ui.showStatusBar",label:"Show status bar",section:"layout"},{key:"ui.defaultTab",label:"Default tab",section:"layout"}]},{id:"general",label:"General",fields:[{key:"defaultAgent",label:"Default agent",section:"general"},{key:"defaultModel",label:"Model override",section:"general"}]},{id:"env-vars",label:"Environment Variables",fields:[{key:"env-vars.count",label:"Env var count",section:"env-vars"}]},{id:"network",label:"Network",fields:[{key:"tailscale.enabled",label:"Tailscale Serve",section:"network"},{key:"tailscale.port",label:"Tailscale port",section:"network"},{key:"tailscale.https",label:"Tailscale HTTPS",section:"network"},{key:"tailscale.hostname",label:"Tailscale hostname",section:"network"}]},{id:"notifications",label:"Notifications",fields:[{key:"notifications.onAgentComplete",label:"Notify on agent complete",section:"notifications"},{key:"notifications.onPlanApproval",label:"Notify on plan approval",section:"notifications"}]},{id:"auth",label:"Auth",fields:[{key:"auth.enabled",label:"Auth enabled",section:"auth"},{key:"auth.loopback",label:"Loopback mode",section:"auth"},{key:"auth.token",label:"Auth token",section:"auth"}]},{id:"agents",label:"Agents",fields:[{key:"agents.maxParallel",label:"Max parallel agents",section:"agents"},{key:"agents.stuckThresholdMs",label:"Stuck threshold",section:"agents"},{key:"agents.autoRestart",label:"Auto restart",section:"agents"},{key:"workflow.artifactsEnabled",label:"Artifacts enabled",section:"agents"},{key:"workflow.agentsDecideAutonomously",label:"Autonomous decisions",section:"agents"}]},{id:"dashboard",label:"Dashboard",fields:[{key:"dashboard.autoLaunchWeb",label:"Auto-launch web",section:"dashboard"},{key:"dashboard.projectsDirectory",label:"Projects directory",section:"dashboard"},{key:"dashboard.allowedRoots",label:"Allowed roots",section:"dashboard"}]},{id:"background",label:"Background",fields:[{key:"service.enabled",label:"Background service",section:"background"},{key:"service.autostart",label:"Auto-start service",section:"background"}]},{id:"system-llm",label:"System LLM",fields:[{key:"systemLlm.enabled",label:"System LLM enabled",section:"system-llm"}]},{id:"headroom",label:"Headroom",fields:[{key:"headroom.enabled",label:"Headroom enabled",section:"headroom"},{key:"headroom.port",label:"Headroom port",section:"headroom"},{key:"headroom.budget",label:"Headroom budget",section:"headroom"},{key:"headroom.backend",label:"Headroom backend",section:"headroom"}]},{id:"activity-log",label:"Activity",fields:[{key:"activity.log",label:"Activity log",section:"activity-log"}]},{id:"about",label:"About",fields:[{key:"about.version",label:"Version",section:"about"},{key:"about.homepage",label:"Homepage",section:"about"},{key:"about.license",label:"License",section:"about"}]}];function Kf({settings:t,refreshSnapshot:s,settingsMode:n,settingsActiveSection:a,setSettingsActiveSection:i,setActiveTab:r}){const o=pe(),[l,c]=f.useState(t),[h,m]=f.useState(!1),[d,u]=f.useState(!1),[p,x]=f.useState(null),[j,v]=f.useState({port:4321,https:!0,hostname:""}),[g,b]=f.useState(null),y=()=>{r("overview")};f.useEffect(()=>{c(t),m(!1),t.theme&&fs(t.theme)},[t]),f.useEffect(()=>{p&&v({port:p.settings.port,https:p.settings.https!==!1,hostname:p.settings.hostname||""})},[p]),f.useEffect(()=>{H.get("/tailscale/status").then(x).catch(()=>{})},[]);const w=f.useRef(null),S=f.useCallback(async(V,X)=>{c(J=>({...J,[V]:X})),w.current&&clearTimeout(w.current),w.current=setTimeout(async()=>{try{await H.put("/settings",{...l,[V]:X})}catch(J){At.error("autoSave failed",J)}},300)},[l]);f.useEffect(()=>()=>{w.current&&clearTimeout(w.current)},[]);const $=V=>{c(X=>{const J={...X,theme:{...X.theme,...V}};return fs(J.theme),J}),m(!0)},M=V=>{c(X=>({...X,ui:{...X.ui,...V}})),m(!0)},z=(V,X)=>{c(J=>({...J,[V]:X})),m(!0)},A=V=>{c(X=>({...X,notifications:{...X.notifications,...V}})),m(!0)},k=V=>{c(X=>({...X,agents:{...X.agents,...V}})),m(!0)},C=V=>{c(X=>({...X,dashboard:{...X.dashboard,...V}})),m(!0)},[_,P]=f.useState(()=>{if(typeof window>"u")return null;const V=window.location.hash.replace(/^#settings-/,"");return Yf.some(X=>X.id===V)?V:null}),N=n?a??null:_,T=V=>{if(n)i==null||i(V);else{P(V);try{if(history.replaceState(null,"",V?`#settings-${V}`:window.location.pathname),V){const X=document.getElementById(`settings-${V}`);X&&X.scrollIntoView({behavior:"smooth",block:"start"})}else window.scrollTo({top:0,behavior:"smooth"})}catch{}}if(V){const X=document.getElementById(`settings-${V}`);X&&X.scrollIntoView({behavior:"smooth",block:"start"})}else window.scrollTo({top:0,behavior:"smooth"})},L=async()=>{try{p!=null&&p.settings.enabled?(await H.post("/tailscale/disable"),o.success("Tailscale serve disabled.")):(await H.post("/tailscale/enable",{port:j.port||4321,https:j.https,hostname:j.hostname||""}),o.success("Tailscale serve enabled.")),x(await H.get("/tailscale/status"))}catch(V){o.error(`Tailscale failed: ${V.message}`)}},R=async()=>{u(!0);try{const V=await H.put("/settings",l);c(V.data),m(!1),Ys(V.data.theme),fs(V.data.theme),o.success("Settings saved."),await s()}catch(V){o.error(`Save failed: ${V.message}`)}finally{u(!1)}},F=async()=>{try{const V=await H.get("/settings");c(V.data),m(!1),Ys(V.data.theme),fs(V.data.theme),o.info("Settings reloaded.",1500)}catch(V){o.error(`Reload failed: ${V.message}`)}},E=async()=>{if(confirm("Reset all settings to defaults?"))try{const V=await H.post("/settings/reset");c(V.data),m(!1),Ys(V.data.theme),fs(V.data.theme),o.success("Settings reset."),await s()}catch(V){o.error(`Reset failed: ${V.message}`)}},D={settings:l,patchTheme:$,patchUi:M,patchTop:z,patchNotifications:A,patchAgents:k,patchDashboard:C},G=l.about||{version:"3.0.4",homepage:"https://github.com/DrB0rk/BizarHarness",license:"MIT"},I=N===null,W=V=>N===V;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(wi,{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(U,{variant:"ghost",size:"sm",onClick:E,children:[e.jsx(Bo,{size:14})," Reset"]}),e.jsxs(U,{variant:"secondary",size:"sm",onClick:F,children:[e.jsx(xe,{size:14})," Reload"]}),e.jsxs(U,{variant:"primary",size:"sm",disabled:!h||d,onClick:R,children:[d?e.jsx("span",{className:"btn-spinner"}):e.jsx(bs,{size:14}),d?"Saving…":"Save"]})]})]}),n&&e.jsxs("div",{className:"settings-mode-banner",children:[e.jsx("span",{children:"You're in settings mode. All sections are visible in the sidebar."}),e.jsx(U,{variant:"secondary",size:"sm",onClick:y,children:"← Back to main view"})]}),e.jsx(If,{sections:Xf,onJump:T}),e.jsxs("div",{className:te("settings-grid",N&&"settings-grid-filtered"),"data-active-section":N||void 0,children:[(I||W("theme"))&&e.jsx("div",{id:"settings-theme",children:e.jsx(Ff,{...D})}),(I||W("updates"))&&e.jsx("div",{id:"settings-updates",children:e.jsx(pu,{})}),(I||W("layout"))&&e.jsx("div",{id:"settings-general",children:e.jsx(xu,{...D,autoSave:S})}),(I||W("env-vars"))&&e.jsx("div",{id:"settings-env-vars",children:e.jsx(gu,{})}),(I||W("network")||W("service")||W("tailscale"))&&e.jsx("div",{id:"settings-network",children:e.jsx(Of,{tailscale:p,tailscaleDraft:j,setTailscaleDraft:v,onTailscaleToggle:L})}),(I||W("network")||W("tailscale"))&&e.jsx(yu,{initialStatus:p}),(I||W("notifications"))&&e.jsx("div",{id:"settings-notifications",children:e.jsx(Bf,{...D})}),(I||W("auth"))&&e.jsx("div",{id:"settings-auth",children:e.jsx(Hf,{settings:l,authStatus:g,setAuthStatus:b})}),(I||W("agents")||W("dashboard")||W("background"))&&e.jsx("div",{id:"settings-agents",children:e.jsx(Vf,{...D,autoSave:S})}),(I||W("system-llm"))&&e.jsx("div",{id:"settings-system-llm",children:e.jsx(vu,{...D})}),(I||W("headroom"))&&e.jsx("div",{id:"settings-headroom",children:e.jsx(ju,{settings:l,setSettings:c,setDirty:m})}),(I||W("activity-log")||W("about"))&&e.jsx("div",{id:"settings-activity-log",children:e.jsx(bu,{about:G})}),(I||W("workspaces"))&&e.jsx("div",{id:"settings-workspaces",children:e.jsx(Gf,{})})]})]})}const kr=rt.memo(Kf);function Zf({snapshot:t,refreshSnapshot:s}){const n=pe(),a=Qe(),[i,r]=f.useState(Array.isArray(t.mods)?t.mods:[]),[o,l]=f.useState(!0),[c,h]=f.useState(null),[m,d]=f.useState([]),[u,p]=f.useState(null),[x,j]=f.useState(!1),[v,g]=f.useState(null),[b,y]=f.useState(!1),[w,S]=f.useState({}),$=async()=>{var N,T,L;y(!0);try{const R=await H.get("/mods/registry");g({source:((N=R.registry)==null?void 0:N.source)||"",version:(T=R.registry)==null?void 0:T.version,updatedAt:(L=R.registry)==null?void 0:L.updatedAt,mods:R.mods||[]})}catch(R){g({source:"",mods:[],error:R.message})}finally{y(!1)}},M=async N=>{S(T=>({...T,[N]:!0}));try{const T=await H.post("/mods",{id:N});r(L=>[...L.filter(R=>R.id!==T.id),T]),n.success(`Mod "${T.id}" installed from registry.`),await s()}catch(T){n.error(`Install failed: ${T.message}`)}finally{S(T=>({...T,[N]:!1}))}},z=async(N,T=!1)=>{S(L=>({...L,[N]:!0}));try{const L=await H.post(`/mods/${encodeURIComponent(N)}/upgrade`,{backup:T});r(F=>[...F.filter(E=>E.id!==L.mod.id),L.mod]);const R=L.backupPath?` (backup at ${L.backupPath})`:"";n.success(`Mod "${N}" upgraded v${L.from} → v${L.to}${R}.`),await s()}catch(L){n.error(`Upgrade failed: ${L.message}`)}finally{S(L=>({...L,[N]:!1}))}},A=async()=>{try{const N=await H.get("/mods");r(N.mods||[]);try{const T=await H.get("/mods/views");d(T.views||[])}catch{d([])}}catch(N){n.error(`Mods load failed: ${N.message}`)}finally{l(!1)}};f.useEffect(()=>{A()},[]),f.useEffect(()=>{Array.isArray(t.mods)&&t.mods!==i&&r(t.mods)},[t.mods]);const k=()=>{let N=null;a.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",htmlFor:"install-mod-path",children:"Path"}),e.jsx("input",{id:"install-mod-path",ref:T=>N=T,className:"input",type:"text",placeholder:"/path/to/my-mod",autoFocus:!0})]}),footer:e.jsxs("div",{className:"modal-footer-actions",children:[e.jsx(U,{variant:"ghost",onClick:()=>a.close(),children:"Cancel"}),e.jsx(U,{variant:"primary",onClick:async()=>{const T=((N==null?void 0:N.value)||"").trim();if(!T){n.warning("Path is required.");return}try{const L=await H.post("/mods",{path:T});r(R=>[...R,L]),n.success(`Mod "${L.id}" installed.`),a.close(),await s()}catch(L){n.error(`Install failed: ${L.message}`)}},children:"Install"})]})})},C=async N=>{if(confirm(`Uninstall mod "${N}"? This removes the folder from ~/.config/bizar/mods/.`))try{await H.del(`/mods/${encodeURIComponent(N)}`),r(T=>T.filter(L=>L.id!==N)),c===N&&h(null),n.success("Mod uninstalled.")}catch(T){n.error(`Uninstall failed: ${T.message}`)}},_=async N=>{try{const T=await H.put(`/mods/${encodeURIComponent(N.id)}`,{enabled:!N.enabled});r(L=>L.map(R=>R.id===N.id?T:R)),n.success(`Mod ${T.enabled?"enabled":"disabled"}.`)}catch(T){n.error(`Toggle failed: ${T.message}`)}},P=i.find(N=>N.id===c)||null;return o?e.jsx("div",{className:"view-loading",children:e.jsx(ye,{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(Ns,{size:18})," Mods (",i.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(U,{variant:"secondary",size:"sm",onClick:A,children:[e.jsx(xe,{size:14})," Refresh"]}),e.jsxs(U,{variant:"primary",size:"sm",onClick:k,children:[e.jsx(We,{size:14})," Install mod"]})]})]}),i.length===0?e.jsx(Te,{icon:e.jsx(Ns,{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:i.map(N=>e.jsxs("div",{className:te("mod-list-item",c===N.id&&"mod-list-item-active"),onClick:()=>h(N.id),children:[e.jsxs("div",{className:"mod-list-item-head",children:[e.jsxs("div",{children:[e.jsx("div",{className:"mod-list-item-name",children:N.name}),e.jsxs("div",{className:"mod-list-item-meta",children:["v",N.version," · ",N.type," · ",N.author]})]}),e.jsxs("div",{className:"mod-list-item-actions",onClick:T=>T.stopPropagation(),children:[e.jsx("button",{type:"button",className:"icon-btn","aria-label":"Toggle enabled",title:N.enabled?"Disable":"Enable",onClick:()=>_(N),children:e.jsx(Ho,{size:12})}),e.jsx("button",{type:"button",className:"icon-btn icon-btn-danger","aria-label":"Uninstall",title:"Uninstall",onClick:()=>C(N.id),children:e.jsx(Fe,{size:12})})]})]}),e.jsx("div",{className:"mod-list-item-desc ellipsis-2",title:N.description,children:N.description}),e.jsx("div",{className:"mod-list-item-status",children:e.jsx("span",{className:`mod-mini-pill ${N.enabled?"mod-mini-pill-on":"mod-mini-pill-off"}`,children:N.enabled?"enabled":"disabled"})})]},N.id))}),P&&e.jsx(Qf,{mod:P})]}),e.jsxs(se,{className:"mods-registry-card",children:[e.jsxs("button",{type:"button",className:"mods-registry-head","aria-expanded":x,"aria-controls":"mods-registry-body",onClick:()=>{!v&&!b&&$(),j(N=>!N)},children:[e.jsx(Qs,{size:14,"aria-hidden":!0}),e.jsx("span",{className:"mods-registry-title",children:"Mod registry"}),e.jsx("span",{className:"muted",style:{fontSize:11},children:v!=null&&v.mods?`${v.mods.length} available`:"click to browse"}),e.jsx("span",{className:"mods-registry-spacer"}),x?e.jsx(ct,{size:14,"aria-hidden":!0}):e.jsx(Ut,{size:14,"aria-hidden":!0})]}),x&&e.jsx("div",{id:"mods-registry-body",className:"mods-registry-body",children:b?e.jsx("div",{className:"muted",style:{padding:12,fontSize:12},children:"Loading registry…"}):v!=null&&v.error?e.jsxs("div",{className:"mods-registry-error",children:[e.jsx(en,{size:12})," Could not load registry: ",v.error]}):!v||v.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:[v.source&&e.jsxs("div",{className:"muted",style:{fontSize:11,marginBottom:8},children:["Source: ",e.jsx("code",{children:v.source})]}),e.jsx("div",{className:"mods-registry-grid",children:v.mods.map(N=>{const T=i.some(R=>R.id===N.id),L=!!w[N.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:N.name}),N.latest&&e.jsxs("span",{className:te("mod-registry-version",N.upgradeAvailable&&"mod-registry-version-upgrade"),children:["v",N.latest,N.upgradeAvailable?" ↑":""]})]}),N.description&&e.jsx("div",{className:"mod-registry-card-desc",children:N.description}),e.jsxs("div",{className:"mod-registry-card-meta",children:[N.author&&e.jsxs("span",{className:"muted",children:["by ",N.author]}),N.homepage&&e.jsx("a",{href:N.homepage,target:"_blank",rel:"noopener noreferrer",className:"mod-registry-link",children:"homepage"})]}),(N.permissions||[]).length>0&&e.jsxs("div",{className:"mod-registry-perms",children:[e.jsx(en,{size:10}),(N.permissions||[]).slice(0,4).map(R=>e.jsx("span",{className:"mod-registry-perm",children:R},R)),(N.permissions||[]).length>4&&e.jsxs("span",{className:"mod-registry-perm-more",children:["+",N.permissions.length-4]})]}),e.jsxs("div",{className:"mod-registry-card-actions",children:[!T&&e.jsx(U,{variant:"primary",size:"sm",disabled:L,onClick:()=>M(N.id),title:"Install from registry",children:L?e.jsx(ye,{size:"sm"}):e.jsxs(e.Fragment,{children:[e.jsx(ts,{size:12})," Install"]})}),T&&N.upgradeAvailable&&e.jsx(U,{variant:"primary",size:"sm",disabled:L,onClick:()=>z(N.id),title:`Upgrade from v${N.installedVersion||"?"} to v${N.upgradeAvailable}`,children:L?e.jsx(ye,{size:"sm"}):e.jsxs(e.Fragment,{children:[e.jsx(ts,{size:12})," Upgrade to v",N.upgradeAvailable]})}),T&&!N.upgradeAvailable&&e.jsxs(U,{variant:"ghost",size:"sm",disabled:!0,title:`Installed v${N.installedVersion||"?"}`,children:["Installed v",N.installedVersion||"?"]})]})]},N.id)})})]})})]}),m.length>0&&e.jsxs(se,{className:"mod-views-hint",children:[e.jsxs(de,{children:[e.jsx(Qs,{size:14})," Mod views"]}),e.jsxs(ue,{children:[m.length," mod-supplied view",m.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."]})]}),u&&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:u,target:"_blank",rel:"noreferrer",children:u})]}),e.jsx("button",{type:"button",className:"icon-btn","aria-label":"Close iframe",onClick:()=>p(null),children:e.jsx(Ie,{size:14})})]}),e.jsx("iframe",{src:u,className:"mod-iframe",title:"Mod view",sandbox:"allow-scripts allow-same-origin allow-forms allow-popups"})]})]})}function Qf({mod:t}){const s=pe(),[n,a]=f.useState(null),[i,r]=f.useState(!1),[o,l]=f.useState(!1),[c,h]=f.useState(null),m=async()=>{r(!0);try{const u=await H.get(`/mods/${t.id}/instructions`);a(u),l(!0)}catch(u){s.error(`Failed to load instructions: ${u.message}`)}finally{r(!1)}},d=async()=>{try{const u=await H.post(`/mods/${t.id}/instructions/reinstall`,{});s.success(`Reinstalled: ${u.counts.agents} agents, ${u.counts.commands} commands, ${u.counts.skills} skills, ${u.counts.instructions} instructions.`),await m()}catch(u){s.error(`Reinstall failed: ${u.message}`)}};return e.jsxs(se,{className:"mod-details",children:[e.jsxs(de,{children:[e.jsx(Ue,{size:14})," Mod details — ",t.name]}),e.jsx(ue,{children:e.jsx("code",{children:t.path})}),e.jsxs("dl",{className:"env-table",children:[e.jsx("dt",{children:"ID"}),e.jsx("dd",{className:"mono",children:t.id}),e.jsx("dt",{children:"Version"}),e.jsx("dd",{className:"mono",children:t.version}),e.jsx("dt",{children:"Type"}),e.jsx("dd",{className:"mono",children:t.type}),e.jsx("dt",{children:"Author"}),e.jsx("dd",{className:"mono",children:t.author||"—"}),e.jsx("dt",{children:"Bizar"}),e.jsx("dd",{className:"mono",children:t.bizar||"*"}),e.jsx("dt",{children:"Enabled"}),e.jsx("dd",{children:t.enabled?"yes":"no"}),e.jsx("dt",{children:"Permissions"}),e.jsxs("dd",{children:[(t.permissions||[]).map(u=>e.jsx("span",{className:"tag",children:u},u)),(t.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:(t.files||[]).map(u=>e.jsxs("li",{children:[e.jsx("span",{className:"mod-file-cat",children:u.category}),e.jsx("span",{className:"mono",children:u.path})]},u.path))})]}),e.jsxs("div",{className:"mod-instructions",children:[e.jsxs("button",{type:"button",className:"mod-instructions-head","aria-expanded":o,"aria-controls":`mod-instructions-body-${t.id}`,onClick:()=>{!n&&!i&&m(),l(u=>!u)},children:[e.jsx(Ou,{size:14,"aria-hidden":!0}),e.jsx("span",{children:"Installed instructions"}),e.jsx("span",{className:"muted",style:{fontSize:11},children:n?`${n.total} files`:"click to view"}),e.jsx("span",{className:"mod-instructions-spacer"}),o?e.jsx(ct,{size:14,"aria-hidden":!0}):e.jsx(Ut,{size:14,"aria-hidden":!0})]}),o&&n&&e.jsxs("div",{id:`mod-instructions-body-${t.id}`,className:"mod-instructions-body",children:[n.agents.length>0&&e.jsxs("div",{className:"mod-instructions-section",children:[e.jsxs("div",{className:"mod-instructions-section-title",children:[e.jsx(fh,{size:11})," Agents (",n.agents.length,")"]}),n.agents.map(u=>e.jsxs("div",{className:"mod-instructions-file",children:[e.jsxs("div",{className:"mod-instructions-file-head",onClick:()=>h(p=>p===u.filename?null:u.filename),children:[e.jsx("span",{className:"mono",children:u.filename}),e.jsxs("span",{className:"muted",style:{fontSize:10},children:["installed at ",u.fullPath]})]}),c===u.filename&&e.jsx("pre",{className:"mod-instructions-content",children:u.content||e.jsx("em",{className:"muted",children:"(file missing on disk)"})})]},u.filename))]}),n.commands.length>0&&e.jsxs("div",{className:"mod-instructions-section",children:[e.jsxs("div",{className:"mod-instructions-section-title",children:[e.jsx(Cs,{size:11})," Commands (",n.commands.length,")"]}),n.commands.map(u=>e.jsxs("div",{className:"mod-instructions-file",children:[e.jsxs("div",{className:"mod-instructions-file-head",onClick:()=>h(p=>p===u.filename?null:u.filename),children:[e.jsx("span",{className:"mono",children:u.filename}),e.jsxs("span",{className:"muted",style:{fontSize:10},children:["installed at ",u.fullPath]})]}),c===u.filename&&e.jsx("pre",{className:"mod-instructions-content",children:u.content||e.jsx("em",{className:"muted",children:"(file missing on disk)"})})]},u.filename))]}),n.skills.length>0&&e.jsxs("div",{className:"mod-instructions-section",children:[e.jsxs("div",{className:"mod-instructions-section-title",children:[e.jsx(Mi,{size:11})," Skills (",n.skills.length,")"]}),n.skills.map(u=>e.jsxs("div",{className:"mod-instructions-file",children:[e.jsxs("div",{className:"mod-instructions-file-head",onClick:()=>h(p=>p===u.name?null:u.name),children:[e.jsx("span",{className:"mono",children:u.name}),e.jsxs("span",{className:"muted",style:{fontSize:10},children:["installed at ",u.fullPath]})]}),c===u.name&&e.jsx("pre",{className:"mod-instructions-content",children:u.content||e.jsx("em",{className:"muted",children:"(file missing on disk)"})})]},u.name))]}),n.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(U,{variant:"ghost",size:"sm",onClick:d,children:[e.jsx(xe,{size:11})," Reinstall from mod folder"]})})]})]})]})}function Jf({viewId:t,reloadKey:s,setActiveTab:n}){const a=pe(),[i,r]=f.useState(null),[o,l]=f.useState(!0),[c,h]=f.useState(0);if(f.useEffect(()=>{let m=!1;return(async()=>{try{const d=await H.get("/mods/views");if(m)return;const u=(d.views||[]).find(p=>p.id===t);r(u||null)}catch(d){a.error(`Failed to load mod view: ${d.message}`)}finally{m||l(!1)}})(),()=>{m=!0}},[t,a]),o)return e.jsx(Te,{title:"Loading mod view…"});if(!i)return e.jsx(Te,{title:"Mod view not found",message:`No view with id "${t}" is currently installed.`,action:e.jsx(U,{onClick:()=>n("mods"),variant:"primary",size:"sm",children:"Open Mods"})});if(i.kind==="iframe"){const m=`/api/mods/${i.modId}/web/index.html?t=${c+(s||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(Qs,{size:14}),i.label,e.jsxs("span",{className:"muted",style:{fontSize:11,fontWeight:400},children:["by ",i.modId]})]}),e.jsxs("div",{className:"mod-view-iframe-actions",children:[e.jsxs(U,{variant:"ghost",size:"sm",onClick:()=>h(d=>d+1),title:"Reload this view",children:[e.jsx(xe,{size:11})," Reload"]}),e.jsx("a",{href:m,target:"_blank",rel:"noopener noreferrer",className:"icon-btn",title:"Open in new tab",children:e.jsx(Is,{size:12})})]})]}),e.jsx("iframe",{src:m,className:"mod-view-iframe",title:i.label},c+(s||0))]})}if(i.component){const m=i.component,d=i.modId,u=f.lazy(()=>ru(()=>import(`/api/mods/${encodeURIComponent(d)}/views/${encodeURIComponent(m)}`),[]).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(Js,{size:14}),i.label,e.jsxs("span",{className:"muted",style:{fontSize:11,fontWeight:400},children:["by ",i.modId]})]})}),e.jsx("div",{className:"mod-view-tab-body",children:e.jsx(ep,{modId:i.modId,component:i.component,children:e.jsx(f.Suspense,{fallback:e.jsxs("div",{style:{padding:24},children:[e.jsx(ye,{size:"md"})," ",e.jsx("span",{className:"muted",children:"Loading mod view…"})]}),children:e.jsx(u,{})})})})]})}return e.jsxs(se,{children:[e.jsxs(de,{children:[e.jsx(Js,{size:14})," ",i.label]}),e.jsxs(ue,{children:["by ",i.modId]}),i.description&&e.jsx("p",{className:"muted",style:{marginTop:8},children:i.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(U,{variant:"secondary",size:"sm",onClick:()=>n("mods"),children:"Open Mods page"})})]})}class ep extends f.Component{constructor(){super(...arguments);Ps(this,"state",{error:null})}static getDerivedStateFromError(n){return{error:n}}componentDidCatch(){}render(){return this.state.error?e.jsxs("div",{className:"mod-view-error",children:[e.jsx(qe,{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}}function tp(t){if(t.type==="cron"&&t.schedule)return`cron: ${t.schedule}`;if(t.type==="interval"){const n=(t.intervalMs||0)/1e3;return n>=3600?`every ${n/3600}h`:n>=60?`every ${n/60}m`:`every ${n}s`}return t.type}function sp({template:t,onUse:s}){return e.jsxs(se,{className:"schedule-template-card",children:[e.jsxs("div",{className:"schedule-template-header",children:[e.jsx(de,{children:t.name}),t.tags&&t.tags.length>0&&e.jsx("div",{className:"schedule-template-tags",children:t.tags.map(n=>e.jsx("span",{className:"tag",children:n},n))})]}),e.jsx(ue,{children:t.description}),e.jsxs("div",{className:"schedule-template-summary",children:[e.jsx("code",{children:tp(t)})," · ",e.jsx("code",{children:t.action.type})]}),e.jsx(U,{variant:"secondary",size:"sm",onClick:()=>s(t),"aria-label":`Use template: ${t.name}`,children:"Use this template"})]})}const np=["interval","cron","once"],ap=["command","agent","webhook"],ri=[{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)"}],ip=Array.from({length:12},(t,s)=>s*5),Li=Array.from({length:24},(t,s)=>({value:s,label:s===0?"12 AM":s<12?`${s} AM`:s===12?"12 PM":`${s-12} PM`})),Pi=[{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"}],ul=[{value:"s",label:"seconds"},{value:"m",label:"minutes"},{value:"h",label:"hours"},{value:"d",label:"days"}];function hl(t){if(typeof t!="string")return null;const s=t.trim().split(/\s+/);if(s.length!==5)return null;const[n,a,,,i]=s,r=parseInt(n,10),o=parseInt(a,10);if(!Number.isFinite(r)||!Number.isFinite(o)||n!==String(r)||a!==String(o))return null;const l=i==="*"?"*":parseInt(i,10);return l===null||i!=="*"&&!Number.isFinite(l)?null:{minute:r,hour:o,dow:i==="*"?"*":String(l)}}function rp(t){if(typeof t!="string")return null;const s=/^(\d+)\s*([smhd])$/i.exec(t.trim());return s?{n:parseInt(s[1],10),unit:s[2].toLowerCase()}:null}function op(t){var r,o;if(!t)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 s=t.type==="cron"?hl(t.schedule):null,n=t.type==="interval"?rp(t.schedule):null,a=t.timezone||"UTC",i=ri.some(l=>l.value===a);return{name:t.name||"",type:t.type,cronMinute:(s==null?void 0:s.minute)??0,cronHour:(s==null?void 0:s.hour)??9,cronDow:(s==null?void 0:s.dow)??"*",showAdvanced:!s,rawCron:t.schedule,intervalN:(n==null?void 0:n.n)??30,intervalUnit:(n==null?void 0:n.unit)??"m",onceAt:t.type==="once"?lp(t.schedule):"",timezone:i?a:"Other…",customTimezone:i?"":a,actionType:t.action.type,actionTarget:t.action.target||"",actionPrompt:t.action.prompt||"",skipIfBudgetLow:!!((r=t.budgetCheck)!=null&&r.skipIfBudgetLow),maxConcurrent:Number.isFinite((o=t.budgetCheck)==null?void 0:o.maxConcurrent)?t.budgetCheck.maxConcurrent:6,enabled:t.enabled!==!1,humanLabel:""}}function lp(t){if(!t)return"";try{const s=new Date(t);if(Number.isNaN(s.getTime()))return"";const n=a=>String(a).padStart(2,"0");return`${s.getFullYear()}-${n(s.getMonth()+1)}-${n(s.getDate())}T${n(s.getHours())}:${n(s.getMinutes())}`}catch{return""}}function cp(t){var n,a,i;if(t.type==="cron"){if(t.showAdvanced)return{schedule:t.rawCron.trim(),humanLabel:t.humanLabel||t.rawCron.trim()};const r=`${t.cronMinute} ${t.cronHour} * * ${t.cronDow}`,o=((n=Pi.find(m=>m.value===t.cronDow))==null?void 0:n.label)||"",l=((a=Li.find(m=>m.value===t.cronHour))==null?void 0:a.label)||`${t.cronHour}`,c=String(t.cronMinute).padStart(2,"0"),h=o==="Every day"?`Every day at ${l.replace(" ","")} (min ${c})`:`Every ${o} at ${l.replace(" ","")} (min ${c})`;return{schedule:r,humanLabel:t.humanLabel||h}}if(t.type==="interval"){const r=((i=ul.find(l=>l.value===t.intervalUnit))==null?void 0:i.label)||t.intervalUnit;return{schedule:`${t.intervalN}${t.intervalUnit}`,humanLabel:t.humanLabel||`Every ${t.intervalN} ${r}`}}return t.onceAt?{schedule:new Date(t.onceAt).toISOString(),humanLabel:t.humanLabel||new Date(t.onceAt).toLocaleString()}:{schedule:"",humanLabel:t.humanLabel||""}}function dp({snapshot:t,refreshSnapshot:s}){var w;const n=pe(),a=Qe(),[i,r]=f.useState(t.schedules||[]),[o,l]=f.useState(!t.schedules),[c,h]=f.useState("schedules"),[m,d]=f.useState([]),[u,p]=f.useState(!1),x=async()=>{try{const S=await H.get("/projects/active/schedules");r(S.schedules||[])}catch(S){n.error(`Schedules load failed: ${S.message}`)}finally{l(!1)}},j=async()=>{p(!0);try{const S=await H.get("/schedules/templates");d(S.templates||[])}catch(S){n.error(`Templates load failed: ${S.message}`)}finally{p(!1)}};f.useEffect(()=>{var S;if((S=t.schedules)!=null&&S.length||t.schedules){r(t.schedules||[]),l(!1);return}x()},[t.schedules]),f.useEffect(()=>{c==="templates"&&m.length===0&&j()},[c]);const v=S=>{a.open({title:S?`Edit schedule: ${S.name}`:"New schedule",width:640,children:e.jsx(up,{initial:S,onClose:a.close,onSubmitted:async $=>{r(M=>{const z=M.findIndex(k=>k.id===$.id);if(z===-1)return[...M,$];const A=M.slice();return A[z]=$,A}),n.success(S?"Schedule updated.":"Schedule created."),a.close(),await s()},onError:$=>n.error($)})})},g=async S=>{var $;try{const M=await H.post(`/schedules/${encodeURIComponent(S.id)}/run`);n.success(M.ok?"Schedule ran.":`Run failed: ${(($=M.runResult)==null?void 0:$.error)||"unknown"}`),await x()}catch(M){n.error(`Run failed: ${M.message}`)}},b=async S=>{if(confirm(`Delete schedule "${S.name}"?`))try{await H.del(`/schedules/${encodeURIComponent(S.id)}`),r($=>$.filter(M=>M.id!==S.id)),n.success("Schedule deleted.")}catch($){n.error(`Delete failed: ${$.message}`)}},y=async S=>{try{const $=await H.post("/schedules/from-template",{templateId:S.id});r(M=>[...M,$]),h("schedules"),n.success(`Schedule "${$.name}" created from template.`),await s()}catch($){n.error(`Failed to create schedule: ${$.message}`)}};return o?e.jsx("div",{className:"view-loading",children:e.jsx(ye,{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("div",{className:"view-title-row",children:[e.jsxs("h2",{className:"view-title",children:[e.jsx(Jt,{size:18})," Schedules"]}),e.jsxs("div",{className:"view-section-tabs",children:[e.jsxs("button",{type:"button",className:`tab-btn ${c==="schedules"?"tab-btn-active":""}`,onClick:()=>h("schedules"),children:["Schedules (",i.length,")"]}),e.jsxs("button",{type:"button",className:`tab-btn ${c==="templates"?"tab-btn-active":""}`,onClick:()=>h("templates"),children:[e.jsx(Js,{size:14})," Templates"]})]})]}),e.jsx("p",{className:"view-subtitle",children:c==="schedules"?e.jsxs(e.Fragment,{children:["Recurring tasks for ",e.jsx("strong",{children:((w=t.activeProject)==null?void 0:w.name)||"(none)"}),". Service daemon runs them at the right time."]}):"Example schedules you can use as a starting point."})]}),e.jsxs("div",{className:"view-actions",children:[c==="schedules"&&e.jsxs(e.Fragment,{children:[e.jsxs(U,{variant:"secondary",size:"sm",onClick:x,"aria-label":"Refresh schedules",children:[e.jsx(xe,{size:14})," Refresh"]}),e.jsxs(U,{variant:"primary",size:"sm",onClick:()=>v(),children:[e.jsx(We,{size:14})," New schedule"]})]}),c==="templates"&&e.jsxs(U,{variant:"secondary",size:"sm",onClick:j,disabled:u,children:[e.jsx(xe,{size:14})," Refresh"]})]})]}),c==="templates"?u?e.jsx("div",{className:"view-loading",children:e.jsx(ye,{size:"lg"})}):m.length===0?e.jsx(Te,{icon:e.jsx(Js,{size:32}),title:"No templates",message:"No schedule templates found. Templates are loaded from templates/schedules/."}):e.jsx("div",{className:"schedule-template-grid",children:m.map(S=>e.jsx(sp,{template:S,onUse:y},S.id))}):i.length===0?e.jsx(Te,{icon:e.jsx(Jt,{size:32}),title:"No schedules",message:t.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:i.map(S=>{var $;return e.jsxs(se,{className:"schedule-card",children:[e.jsxs("div",{className:"schedule-card-head",children:[e.jsxs("div",{children:[e.jsx(de,{children:S.name}),e.jsxs(ue,{children:[e.jsx("code",{children:S.type})," ·"," ",e.jsx("span",{title:S.schedule,children:hp(S)||S.schedule}),S.timezone&&S.timezone!=="UTC"?e.jsxs(e.Fragment,{children:[" · ",e.jsx("code",{children:S.timezone})]}):null," · ",e.jsx("span",{className:S.enabled?"status-on":"status-neutral",children:S.enabled?"enabled":"disabled"})]})]}),e.jsxs("div",{className:"schedule-card-actions",children:[e.jsxs(U,{variant:"secondary",size:"sm",onClick:()=>v(S),children:[e.jsx(fn,{size:12})," Edit"]}),e.jsxs(U,{variant:"secondary",size:"sm",onClick:()=>g(S),children:[e.jsx(Yn,{size:12})," Run now"]}),e.jsx("button",{type:"button",className:"icon-btn icon-btn-danger","aria-label":"Delete",title:"Delete",onClick:()=>b(S),children:e.jsx(Fe,{size:12})})]})]}),e.jsxs("div",{className:"schedule-card-action",children:[e.jsx("span",{className:"muted",children:"action:"})," ",e.jsxs("code",{children:[S.action.type," ",S.action.target]}),S.action.type==="agent"&&S.action.prompt&&e.jsxs("div",{className:"schedule-card-prompt",children:[e.jsx("span",{className:"muted",children:"prompt:"})," ",S.action.prompt]})]}),(($=S.budgetCheck)==null?void 0:$.skipIfBudgetLow)&&e.jsxs("div",{className:"schedule-card-budget",children:[e.jsx("span",{className:"muted",children:"budget gate:"})," ","skip if concurrent ≥ ",S.budgetCheck.maxConcurrent??6]}),e.jsxs("div",{className:"schedule-card-times",children:[e.jsxs("div",{children:[e.jsx("span",{className:"muted",children:"last"})," ",S.lastRun?Ve(S.lastRun):"—",S.lastResult&&e.jsx("span",{className:`tag ${Nr(S.lastResult)}`,children:S.lastResult}),S.lastError&&e.jsxs("span",{className:"muted schedule-card-error",title:S.lastError,children:[" ","— ",Sr(S.lastError,80)]})]}),e.jsxs("div",{children:[e.jsx("span",{className:"muted",children:"next"})," ",S.nextRun?e.jsx("span",{title:new Date(S.nextRun).toISOString(),children:mp(S.nextRun,S.timezone)}):"—",S.nextRun&&e.jsxs("span",{className:"muted",children:[" · ",Ve(S.nextRun)]})]})]}),S.history&&S.history.length>0&&e.jsxs("details",{className:"schedule-card-history",children:[e.jsxs("summary",{children:[e.jsx(Zs,{size:12})," ",S.history.length," run",S.history.length===1?"":"s"]}),e.jsx("ul",{children:S.history.slice(-10).reverse().map((M,z)=>e.jsxs("li",{children:[e.jsx("span",{className:"tabular-nums muted",children:Ve(M.ts)})," ",e.jsx("span",{className:`tag ${Nr(M.result)}`,children:M.result}),M.error&&e.jsxs("span",{className:"muted",children:[" — ",Sr(M.error,80)]})]},z))})]})]},S.id)})})]})}function up({initial:t,onClose:s,onSubmitted:n,onError:a}){const[i,r]=f.useState(()=>op(t)),[o,l]=f.useState(!1),c=f.useMemo(()=>ri.some(d=>d.value===i.timezone)?i.timezone:"Other…",[i.timezone]),h=(d,u)=>{r(p=>({...p,[d]:u}))},m=async d=>{d.preventDefault();const u=i.name.trim();if(!u){a("Name is required.");return}const p=cp(i);if(!p.schedule){a("Schedule value is required.");return}if(!i.actionTarget.trim()){a("Action target is required.");return}const x=i.timezone==="Other…"?i.customTimezone.trim():i.timezone,j={type:i.actionType,target:i.actionTarget.trim()};i.actionType==="agent"&&i.actionPrompt.trim()&&(j.prompt=i.actionPrompt.trim());const v={name:u,type:i.type,schedule:p.schedule,timezone:x||"UTC",action:j,budgetCheck:{maxConcurrent:i.maxConcurrent,skipIfBudgetLow:i.skipIfBudgetLow},enabled:i.enabled};l(!0);try{const g=t?await H.put(`/schedules/${encodeURIComponent(t.id)}`,v):await H.post("/schedules",v);await n(g)}catch(g){a(`${t?"Update":"Create"} failed: ${g.message}`)}finally{l(!1)}};return e.jsxs("form",{className:"schedule-form",onSubmit:m,children:[e.jsx("label",{className:"field-label",htmlFor:"schedule-name",children:"Name"}),e.jsx("input",{id:"schedule-name",className:"input",type:"text",placeholder:"Weekly code review",value:i.name,onChange:d=>h("name",d.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",htmlFor:"schedule-type",children:"Type"}),e.jsx("select",{id:"schedule-type",className:"select",value:i.type,onChange:d=>h("type",d.target.value),children:np.map(d=>e.jsx("option",{value:d,children:d},d))})]})}),i.type==="cron"&&e.jsxs("div",{className:"schedule-cron-group",children:[!i.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",htmlFor:"schedule-dow",children:"Day of week"}),e.jsx("select",{id:"schedule-dow",className:"select",value:i.cronDow,onChange:d=>h("cronDow",d.target.value),children:Pi.map(d=>e.jsx("option",{value:d.value,children:d.label},d.value))})]}),e.jsxs("div",{className:"task-form-field",children:[e.jsx("label",{className:"field-label",htmlFor:"schedule-hour",children:"Hour"}),e.jsx("select",{id:"schedule-hour",className:"select",value:String(i.cronHour),onChange:d=>h("cronHour",parseInt(d.target.value,10)),children:Li.map(d=>e.jsx("option",{value:String(d.value),children:d.label},d.value))})]}),e.jsxs("div",{className:"task-form-field",children:[e.jsx("label",{className:"field-label",htmlFor:"schedule-minute",children:"Minute"}),e.jsx("select",{id:"schedule-minute",className:"select",value:String(i.cronMinute),onChange:d=>h("cronMinute",parseInt(d.target.value,10)),children:ip.map(d=>e.jsx("option",{value:String(d),children:String(d).padStart(2,"0")},d))})]})]})}),i.showAdvanced&&e.jsxs("div",{className:"task-form-field",children:[e.jsx("label",{className:"field-label",htmlFor:"schedule-cron-expr",children:"Cron expression"}),e.jsx("input",{id:"schedule-cron-expr",className:"input",type:"text",value:i.rawCron,onChange:d=>h("rawCron",d.target.value),placeholder:"0 13 * * 0"})]}),e.jsxs("button",{type:"button",className:"link-btn",onClick:()=>h("showAdvanced",!i.showAdvanced),"aria-expanded":i.showAdvanced,children:[e.jsx(ct,{size:12,style:{transform:i.showAdvanced?"rotate(180deg)":"none",transition:"transform 0.15s"}}),i.showAdvanced?"Hide advanced":"Advanced (raw cron)"]})]}),i.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",htmlFor:"schedule-interval-n",children:"Every"}),e.jsx("input",{id:"schedule-interval-n",className:"input",type:"number",min:1,value:i.intervalN,onChange:d=>h("intervalN",parseInt(d.target.value,10)||1)})]}),e.jsxs("div",{className:"task-form-field",style:{flex:1},children:[e.jsx("label",{className:"field-label",htmlFor:"schedule-interval-unit",children:"Unit"}),e.jsx("select",{id:"schedule-interval-unit",className:"select",value:i.intervalUnit,onChange:d=>h("intervalUnit",d.target.value),children:ul.map(d=>e.jsx("option",{value:d.value,children:d.label},d.value))})]})]}),i.type==="once"&&e.jsxs("div",{className:"task-form-field",children:[e.jsx("label",{className:"field-label",htmlFor:"schedule-once-at",children:"Run at"}),e.jsx("input",{id:"schedule-once-at",className:"input",type:"datetime-local",value:i.onceAt,onChange:d=>h("onceAt",d.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",htmlFor:"schedule-timezone",children:"Timezone"}),e.jsxs("select",{id:"schedule-timezone",className:"select",value:c,onChange:d=>h("timezone",d.target.value),children:[ri.map(d=>e.jsx("option",{value:d.value,children:d.label},d.value)),e.jsx("option",{value:"Other…",children:"Other…"})]})]}),i.timezone==="Other…"&&e.jsxs("div",{className:"task-form-field",style:{flex:1},children:[e.jsx("label",{className:"field-label",htmlFor:"schedule-custom-tz",children:"IANA name"}),e.jsx("input",{id:"schedule-custom-tz",className:"input",type:"text",placeholder:"Europe/Paris",value:i.customTimezone,onChange:d=>h("customTimezone",d.target.value)})]})]}),e.jsxs("div",{className:"task-form-row",children:[e.jsxs("div",{className:"task-form-field",children:[e.jsx("label",{className:"field-label",htmlFor:"schedule-action-type",children:"Action"}),e.jsx("select",{id:"schedule-action-type",className:"select",value:i.actionType,onChange:d=>h("actionType",d.target.value),children:ap.map(d=>e.jsx("option",{value:d,children:d},d))})]}),e.jsxs("div",{className:"task-form-field",style:{flex:2},children:[e.jsx("label",{className:"field-label",htmlFor:"schedule-action-target",children:"Target"}),e.jsx("input",{id:"schedule-action-target",className:"input",type:"text",placeholder:i.actionType==="webhook"?"https://...":i.actionType==="agent"?"agent name or task ref":"echo hi",value:i.actionTarget,onChange:d=>h("actionTarget",d.target.value)})]})]}),i.actionType==="agent"&&e.jsxs("div",{className:"task-form-field",children:[e.jsx("label",{className:"field-label",htmlFor:"schedule-action-prompt",children:"Prompt (what to send the agent)"}),e.jsx("textarea",{id:"schedule-action-prompt",className:"input",rows:3,placeholder:"Review open PRs for stale code review comments and nudge reviewers.",value:i.actionPrompt,onChange:d=>h("actionPrompt",d.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",{id:"schedule-skip-budget",type:"checkbox",checked:i.skipIfBudgetLow,onChange:d=>h("skipIfBudgetLow",d.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",htmlFor:"schedule-max-concurrent",children:"Max concurrent bg tasks"}),e.jsx("input",{id:"schedule-max-concurrent",className:"input",type:"number",min:1,max:64,value:i.maxConcurrent,onChange:d=>h("maxConcurrent",parseInt(d.target.value,10)||6),disabled:!i.skipIfBudgetLow})]})]}),e.jsxs("label",{className:"checkbox-row",children:[e.jsx("input",{id:"schedule-enabled",type:"checkbox",checked:i.enabled,onChange:d=>h("enabled",d.target.checked)}),e.jsx("span",{children:"Enabled"})]}),e.jsxs("div",{className:"modal-footer-actions",children:[e.jsx(U,{variant:"ghost",type:"button",onClick:s,disabled:o,children:"Cancel"}),e.jsx(U,{variant:"primary",type:"submit",disabled:o,children:t?"Save":"Create"})]})]})}function hp(t){var r,o;if(t.type!=="cron")return t.schedule;const s=hl(t.schedule);if(!s)return t.schedule;const n=((r=Pi.find(l=>l.value===s.dow))==null?void 0:r.label)||"",a=((o=Li.find(l=>l.value===s.hour))==null?void 0:o.label)||`${s.hour}`,i=String(s.minute).padStart(2,"0");return n==="Every day"?`Every day at ${a} :${i}`:`Every ${n} at ${a} :${i}`}function mp(t,s){try{return new Date(t).toLocaleString(void 0,{timeZone:s||void 0,weekday:"long",hour:"numeric",minute:"2-digit",month:"short",day:"numeric"})}catch{return new Date(t).toLocaleString()}}function Nr(t){return t==="success"?"tag-success":t==="skipped"?"tag-warning":"tag-error"}function Sr(t,s){return t.length<=s?t:t.slice(0,s-1)+"…"}const fp=[{id:"all",label:"All",icon:vt},{id:"shipped",label:"Shipped",icon:Ti},{id:"user",label:"User",icon:tn},{id:"project",label:"Project",icon:lt}],Hn={shipped:"Shipped",user:"User",project:"Project"},pp={shipped:Ti,user:tn,project:lt};function xp({snapshot:t,refreshSnapshot:s}){const n=pe(),a=Qe(),[i,r]=f.useState([]),[o,l]=f.useState({shipped:0,user:0,project:0,all:0}),[c,h]=f.useState(!0),[m,d]=f.useState("all"),[u,p]=f.useState(""),[x,j]=f.useState(null),[v,g]=f.useState(!1),b=async()=>{var $,M,z;h(!0);try{const A=await H.get("/skills");r(A.skills||[]),l({shipped:(($=A.counts)==null?void 0:$.shipped)??0,user:((M=A.counts)==null?void 0:M.user)??0,project:((z=A.counts)==null?void 0:z.project)??0,all:(A.skills||[]).length})}catch(A){n.error(`Skills load failed: ${A.message}`)}finally{h(!1)}};f.useEffect(()=>{b()},[]),f.useEffect(()=>{if(!u.trim()){j(null);return}g(!0);const $=setTimeout(async()=>{try{const M=await H.get(`/skills/search?q=${encodeURIComponent(u.trim())}`);j(M.results||[])}catch(M){n.error(`Search failed: ${M.message}`)}finally{g(!1)}},280);return()=>clearTimeout($)},[u]);const y=f.useMemo(()=>x!==null?x:m==="all"?i:i.filter($=>$.source===m),[i,m,x]),w=async()=>{try{await H.post("/skills/refresh",{}),n.success("Skills refreshed."),await b()}catch($){n.error(`Refresh failed: ${$.message}`)}},S=async $=>{try{const M=await H.get(`/skills/${encodeURIComponent($.source)}/${encodeURIComponent($.name)}`);a.open({title:M.name,width:640,children:e.jsxs("div",{className:"skill-detail",children:[e.jsxs("div",{className:"skill-detail-meta",children:[e.jsx("span",{className:"skill-source-badge","data-source":M.source,children:Hn[M.source]||M.source}),e.jsx("code",{className:"mono text-sm muted",children:M.path})]}),M.description&&e.jsx("p",{className:"skill-detail-desc",children:M.description}),M.body&&e.jsx("div",{className:"skill-detail-body",children:e.jsx("pre",{className:"skill-body-pre",children:M.body})})]}),footer:e.jsx(U,{variant:"ghost",onClick:()=>a.close(),children:"Close"})})}catch{a.open({title:$.name,width:560,children:e.jsxs("div",{className:"skill-detail",children:[e.jsxs("div",{className:"skill-detail-meta",children:[e.jsx("span",{className:"skill-source-badge","data-source":$.source,children:Hn[$.source]||$.source}),e.jsx("code",{className:"mono text-sm muted",children:$.path})]}),$.description&&e.jsx("p",{className:"skill-detail-desc",children:$.description})]}),footer:e.jsx(U,{variant:"ghost",onClick:()=>a.close(),children:"Close"})})}};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(vt,{size:18})," Skills"]}),e.jsx("p",{className:"view-subtitle",children:"Browse all available skills — shipped, user, and project-local."})]}),e.jsxs("div",{className:"view-actions",children:[e.jsxs("div",{className:"search-input",children:[e.jsx(Re,{size:14,"aria-hidden":!0}),e.jsx("label",{htmlFor:"skills-search",className:"sr-only",children:"Search skills"}),e.jsx("input",{id:"skills-search",className:"input",type:"text",placeholder:"Search skills…",value:u,onChange:$=>p($.target.value),"aria-label":"Search skills"}),u&&e.jsx("button",{type:"button",className:"icon-btn","aria-label":"Clear search",onClick:()=>p(""),children:e.jsx(ls,{size:12})})]}),e.jsxs(U,{variant:"secondary",size:"sm",onClick:w,children:[e.jsx(xe,{size:14})," Refresh"]})]})]}),!u.trim()&&e.jsx("div",{className:"skills-tabs",children:fp.map($=>{const M=$.icon,z=$.id==="all"?o.all:o[$.id]??0;return e.jsxs("button",{type:"button",className:te("skills-tab",m===$.id&&"skills-tab-active"),onClick:()=>d($.id),children:[e.jsx(M,{size:14}),e.jsx("span",{children:$.label}),e.jsx("span",{className:"skills-tab-count",children:z})]},$.id)})}),u.trim()&&e.jsxs("section",{className:"skills-section",children:[e.jsxs("h3",{className:"skills-section-title",children:[e.jsx(Re,{size:14})," Search results",v&&e.jsx(ye,{size:"sm"})]}),v?e.jsx("div",{className:"skills-grid",children:[0,1,2].map($=>e.jsx("div",{className:"skill-card skill-card-skeleton"},$))}):x&&x.length===0?e.jsx(Te,{icon:e.jsx(Re,{size:28}),title:"No matches",message:`No skills match "${u}".`}):e.jsx("div",{className:"skills-grid",children:(x||[]).map(($,M)=>e.jsx(Cr,{skill:$,onShow:()=>S($),searchQ:u},`search-${M}`))})]}),!u.trim()&&e.jsx("section",{className:"skills-section",children:c?e.jsx("div",{className:"view-loading",children:e.jsx(ye,{size:"lg"})}):y.length===0?e.jsx(Te,{icon:e.jsx(Mi,{size:28}),title:"No skills here",message:m==="all"?"No skills found. Install skills with the skills CLI or add SKILL.md files to a skills directory.":`No skills in the ${Hn[m]} tab.`}):e.jsx("div",{className:"skills-grid",children:y.map(($,M)=>e.jsx(Cr,{skill:$,onShow:()=>S($)},`${$.source}-${$.name}-${M}`))})}),!u.trim()&&e.jsx("footer",{className:"view-footer",children:e.jsxs("span",{className:"text-sm muted",children:["Skills are discovered from"," ",e.jsx("code",{children:"~/.cline/skills/"}),","," ",e.jsx("code",{children:"~/.agents/skills/"}),","," ",e.jsx("code",{children:"bizar-dash/skills/"}),", and project-local directories."]})})]})}function Cr({skill:t,onShow:s,searchQ:n=""}){const a=pp[t.source]||Ti,i=t.description?t.description.length>200?t.description.slice(0,200)+"…":t.description:"No description.";return e.jsxs(se,{variant:"elevated",interactive:!0,className:"skill-card",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(a,{size:18})}),e.jsxs("div",{className:"skill-card-title-area",children:[e.jsx("div",{className:"skill-card-title",children:gp(t.name,n)}),e.jsx("span",{className:"skill-source-badge","data-source":t.source,children:Hn[t.source]||t.source})]})]}),e.jsx("p",{className:"skill-card-desc",children:i}),e.jsx("div",{className:"skill-card-actions",children:e.jsxs(U,{variant:"ghost",size:"sm",onClick:s,children:[e.jsx(Is,{size:12})," View"]})})]})}function gp(t,s){if(!s.trim())return t;const n=t.toLowerCase().indexOf(s.toLowerCase());return n<0?t:e.jsxs(e.Fragment,{children:[t.slice(0,n),e.jsx("mark",{className:"skill-highlight",children:t.slice(n,n+s.length)}),t.slice(n+s.length)]})}const yp=rt.memo(xp);function vp({refreshKey:t,onRefresh:s,setActiveSubPanel:n}){const a=pe(),[i,r]=f.useState(null),[o,l]=f.useState(""),[c,h]=f.useState(!0),m=async v=>{h(!0);try{const[g,b,y,w]=await Promise.all([H.get("/memory/health",v).catch(()=>null),H.get("/memory/status",v).catch(()=>null),H.get("/memory/lightrag/stats",v).catch(()=>null),H.get("/memory/storage",v).catch(()=>null)]);l((b==null?void 0:b.vaultRoot)||""),r({health:g||{score:0,status:"unconfigured",checks:[],message:"memory not initialised"},vault:{exists:!!(b!=null&&b.initialized),vaultRoot:(b==null?void 0:b.vaultRoot)||"",mode:(b==null?void 0:b.mode)||"local-only",noteCount:(b==null?void 0:b.noteCount)||0,totalSize:(w==null?void 0:w.total)||0,folderCount:0,folders:[],lastModified:null,gitClean:(b==null?void 0:b.gitClean)??null,gitBranch:(b==null?void 0:b.branch)||null},lightrag:y||{running:!1,pid:null,host:"127.0.0.1",port:9621,indexedApprox:0,queryCountLast24h:0,lastReindexAt:null},storage:w||{total:0,breakdown:[]}})}catch(g){a.error(`Memory overview failed: ${g.message}`)}finally{h(!1)}};if(f.useEffect(()=>{const v=new AbortController;return m(v.signal),()=>v.abort()},[t]),c&&!i)return e.jsxs("div",{className:"view-loading",children:[e.jsx(ye,{size:"lg"}),e.jsx("p",{children:"Loading memory overview…"})]});if(!i)return e.jsx("div",{className:"muted",children:"No memory data available."});const{health:d,vault:u,lightrag:p,storage:x}=i,j=d.score>=80?"var(--success)":d.score>=50?"var(--warning)":"var(--error)";return e.jsxs("div",{className:"memory-overview",children:[e.jsxs(se,{variant:"elevated",className:"memory-health-hero",children:[e.jsxs("div",{className:"memory-health-score",style:{borderColor:j},children:[e.jsx("span",{className:"memory-health-score-value",style:{color:j},children:d.score}),e.jsx("span",{className:"memory-health-score-label",children:"/ 100"})]}),e.jsxs("div",{className:"memory-health-meta",children:[e.jsxs("h3",{className:"memory-health-title",children:[e.jsx(He,{size:16}),"Memory health ·"," ",e.jsx("span",{style:{color:j},children:d.status})]}),e.jsx("p",{className:"memory-health-message",children:d.message}),e.jsxs("p",{className:"memory-health-vault mono muted","data-testid":"memory-overview-vault-path",children:[e.jsx("span",{className:"memory-health-vault-label",children:"Vault:"})," ",o||e.jsx("em",{children:"not initialised"})]}),e.jsxs(U,{variant:"ghost",size:"sm",onClick:s,children:[e.jsx(xe,{size:12})," Refresh"]})]})]}),e.jsxs("div",{className:"memory-source-pills",children:[e.jsxs("button",{type:"button",className:"memory-source-pill",onClick:()=>n("lightrag"),children:[e.jsx(xt,{size:14}),e.jsx("span",{children:"LightRAG"}),e.jsx("span",{className:te("memory-source-pill-status",p.running?"on":"off"),children:p.running?"running":"stopped"})]}),e.jsxs("button",{type:"button",className:"memory-source-pill",onClick:()=>n("obsidian"),children:[e.jsx(Ue,{size:14}),e.jsx("span",{children:"Obsidian Vault"}),e.jsxs("span",{className:te("memory-source-pill-status",u.exists?"on":"off"),children:[u.noteCount," notes"]})]}),e.jsxs("button",{type:"button",className:"memory-source-pill",onClick:()=>n("git"),children:[e.jsx(gt,{size:14}),e.jsx("span",{children:"Git Sync"}),e.jsx("span",{className:te("memory-source-pill-status",u.gitClean===null?"na":u.gitClean?"on":"warn"),children:u.gitClean===null?"—":u.gitClean?"clean":"dirty"})]}),e.jsxs("button",{type:"button",className:"memory-source-pill",onClick:()=>n("semantic"),children:[e.jsx(Re,{size:14}),e.jsx("span",{children:"Semantic Search"}),e.jsx("span",{className:"memory-source-pill-status na",children:"cross-source"})]})]}),e.jsxs("div",{className:"memory-stat-grid",children:[e.jsx(hs,{icon:e.jsx(xt,{size:16}),label:"LightRAG",value:p.running?`running · ${p.queryCountLast24h} q/24h`:"stopped",sub:p.running?`${p.indexedApprox} indexed chunks`:"start from the LightRAG panel",onClick:()=>n("lightrag")}),e.jsx(hs,{icon:e.jsx(Ue,{size:16}),label:"Obsidian",value:`${u.noteCount} notes`,sub:u.folderCount>0?`${u.folderCount} folders`:"no folders yet",onClick:()=>n("obsidian")}),e.jsx(hs,{icon:e.jsx(gt,{size:16}),label:"Git",value:u.gitBranch?`branch ${u.gitBranch}`:"local-only",sub:u.gitClean===null?"not configured":u.gitClean?"clean working tree":"dirty — commit or pull",onClick:()=>n("git")}),e.jsx(hs,{icon:e.jsx(Xn,{size:16}),label:"Storage",value:jp(x.total),sub:x.breakdown.length>0?`${x.breakdown.length} dirs tracked`:"no memory data on disk"}),e.jsx(hs,{icon:e.jsx(vt,{size:16}),label:"Last reindex",value:p.lastReindexAt?St(p.lastReindexAt):"never",sub:"lightrag ingest",onClick:()=>n("lightrag")}),e.jsx(hs,{icon:e.jsx(en,{size:16}),label:"Health",value:`${d.score}/100`,sub:d.status,onClick:()=>n("config")})]}),d.checks.length>0&&e.jsxs(se,{children:[e.jsx(de,{children:"Health checks"}),e.jsx(ue,{children:"Composite score across all memory subsystems"}),e.jsx("ul",{className:"memory-check-list",children:d.checks.map(v=>e.jsxs("li",{className:"memory-check-row",children:[e.jsx("span",{className:"memory-check-icon",children:v.pass?e.jsx(Ze,{size:14,style:{color:"var(--success)"}}):v.name.includes("secrets")||v.name.includes("schema")?e.jsx(qe,{size:14,style:{color:"var(--warning)"}}):e.jsx(ls,{size:14,style:{color:"var(--error)"}})}),e.jsx("span",{className:"memory-check-name",children:v.name}),e.jsx("span",{className:"memory-check-detail muted",children:v.detail})]},v.name))})]})]})}function hs({icon:t,label:s,value:n,sub:a,onClick:i}){const r=i?"button":"div";return e.jsxs(r,{type:i?"button":void 0,onClick:i,className:te("memory-stat-card",i&&"memory-stat-card-clickable"),children:[e.jsx("div",{className:"memory-stat-icon",children:t}),e.jsxs("div",{className:"memory-stat-body",children:[e.jsx("div",{className:"memory-stat-label",children:s}),e.jsx("div",{className:"memory-stat-value",children:n}),e.jsx("div",{className:"memory-stat-sub muted",children:a})]})]})}function jp(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:t<1024*1024*1024?`${(t/(1024*1024)).toFixed(1)} MB`:`${(t/(1024*1024*1024)).toFixed(2)} GB`}function bp({refreshKey:t}){const s=pe(),[n,a]=f.useState(null),[i,r]=f.useState(null),[o,l]=f.useState([]),[c,h]=f.useState(!0),[m,d]=f.useState(null),[u,p]=f.useState(""),[x,j]=f.useState(null),v=async()=>{h(!0);try{const[z,A,k]=await Promise.all([H.get("/memory/lightrag/stats").catch(()=>null),H.get("/memory/config").then(C=>(C==null?void 0:C.lightrag)||null).catch(()=>null),H.get("/memory/lightrag/log").catch(()=>({lines:[]}))]);a(z),r(A),l((k==null?void 0:k.lines)||[])}catch(z){s.error(`LightRAG status failed: ${z.message}`)}finally{h(!1)}};f.useEffect(()=>{v()},[t]);const g=async(z,A,k)=>{d(z);try{await A(),s.success(k),await v()}catch(C){s.error(`${z} failed: ${C.message}`)}finally{d(null)}},b=()=>g("start",()=>H.post("/memory/lightrag/start",{}),"LightRAG starting…"),y=()=>g("stop",()=>H.post("/memory/lightrag/stop",{}),"LightRAG stopping…"),w=async()=>{d("restart");try{await H.post("/memory/lightrag/stop",{}).catch(()=>{}),await new Promise(z=>setTimeout(z,600)),await H.post("/memory/lightrag/start",{}),s.success("LightRAG restarted."),await v()}catch(z){s.error(`Restart failed: ${z.message}`)}finally{d(null)}},S=()=>g("reindex",()=>H.post("/memory/lightrag/reindex",{}),"Reindex complete."),$=()=>g("rebuild",()=>H.post("/memory/lightrag/rebuild-graph",{}),"Graph rebuilt."),M=async()=>{var z,A,k;if(u.trim()){d("query");try{const C=await H.get(`/memory/query?q=${encodeURIComponent(u)}&topK=8`),_=(z=C==null?void 0:C.semantic)!=null&&z.response?typeof C.semantic.response=="string"?C.semantic.response:JSON.stringify(C.semantic.response):((A=C==null?void 0:C.semantic)==null?void 0:A.error)||"No response";j({ok:!!((k=C==null?void 0:C.semantic)!=null&&k.ok),text:_})}catch(C){j({ok:!1,text:C.message})}finally{d(null)}}};return c&&!n?e.jsxs("div",{className:"view-loading",children:[e.jsx(ye,{size:"lg"}),e.jsx("p",{children:"Loading LightRAG status…"})]}):n?e.jsxs("div",{className:"memory-panel-content",children:[e.jsxs(se,{variant:"elevated",children:[e.jsxs(de,{children:[e.jsx(xt,{size:14}),"LightRAG",e.jsx("span",{className:te("memory-source-pill-status",n.running?"on":"off"),children:n.running?"running":"stopped"})]}),e.jsx(ue,{children:n.running?e.jsxs(e.Fragment,{children:["PID ",e.jsx("code",{children:n.pid})," · ",n.host,":",n.port]}):e.jsx(e.Fragment,{children:"Server is not running. Start it from the controls below."})}),e.jsxs("div",{className:"memory-action-row",children:[e.jsxs(U,{variant:"primary",size:"sm",onClick:b,disabled:!!m||n.running,children:[m==="start"?e.jsx(je,{size:12,className:"memory-spin"}):e.jsx(ws,{size:12}),"Start"]}),e.jsxs(U,{variant:"secondary",size:"sm",onClick:y,disabled:!!m||!n.running,children:[m==="stop"?e.jsx(je,{size:12,className:"memory-spin"}):e.jsx(rh,{size:12}),"Stop"]}),e.jsxs(U,{variant:"secondary",size:"sm",onClick:w,disabled:!!m,children:[m==="restart"?e.jsx(je,{size:12,className:"memory-spin"}):e.jsx(Ho,{size:12}),"Restart"]}),e.jsxs(U,{variant:"ghost",size:"sm",onClick:S,disabled:!!m,children:[m==="reindex"?e.jsx(je,{size:12,className:"memory-spin"}):e.jsx(xe,{size:12}),"Reindex all"]}),e.jsxs(U,{variant:"ghost",size:"sm",onClick:$,disabled:!!m,title:"Wipe working dir + reindex from scratch",children:[m==="rebuild"?e.jsx(je,{size:12,className:"memory-spin"}):e.jsx(ua,{size:12}),"Rebuild graph"]})]})]}),e.jsxs("div",{className:"memory-stat-grid",children:[e.jsx(Os,{icon:e.jsx(Xn,{size:14}),label:"Indexed chunks (approx)",value:String(n.indexedApprox)}),e.jsx(Os,{icon:e.jsx(wp,{n:n.noteCount}),label:"Notes in vault",value:String(n.noteCount)}),e.jsx(Os,{icon:e.jsx(Ci,{size:14}),label:"Queries last 24h",value:String(n.queryCountLast24h)}),e.jsx(Os,{icon:e.jsx(vt,{size:14}),label:"Avg response",value:n.avgResponseMs!==null?`${n.avgResponseMs} ms`:"—"}),e.jsx(Os,{icon:n.lastReindexOk?e.jsx(Ze,{size:14}):n.lastReindexOk===!1?e.jsx(ls,{size:14}):e.jsx(xe,{size:14}),label:"Last reindex",value:n.lastReindexAt?St(n.lastReindexAt):"never",sub:n.lastReindexInserted!==null?`${n.lastReindexInserted} inserted${n.lastReindexFailed?`, ${n.lastReindexFailed} failed`:""}`:void 0})]}),e.jsxs(se,{children:[e.jsxs(de,{children:[e.jsx(Re,{size:14})," Quick search"]}),e.jsx(ue,{children:"Send a natural-language query to the LightRAG index."}),e.jsxs("div",{className:"memory-search-row",children:[e.jsx("label",{htmlFor:"lightrag-query",className:"sr-only",children:"Search LightRAG"}),e.jsx("input",{id:"lightrag-query",type:"text",className:"input",placeholder:"e.g. how does the memory service write notes?",value:u,onChange:z=>p(z.target.value),onKeyDown:z=>{z.key==="Enter"&&M()},disabled:m==="query","aria-label":"Search LightRAG"}),e.jsxs(U,{variant:"primary",onClick:M,disabled:m==="query"||!u.trim(),children:[m==="query"?e.jsx(je,{size:12,className:"memory-spin"}):e.jsx(Re,{size:12}),"Query"]})]}),x&&e.jsx("div",{className:te("memory-query-result",x.ok?"ok":"err"),children:e.jsx("pre",{className:"mono text-sm",children:x.text})})]}),i&&e.jsxs(se,{children:[e.jsx(de,{children:"Configuration"}),e.jsxs(ue,{children:["Effective values from ",e.jsx("code",{children:".bizar/memory.json"})," + env defaults."]}),e.jsxs("dl",{className:"memory-config-row",children:[e.jsx("dt",{children:"LLM binding"}),e.jsxs("dd",{children:[e.jsx("code",{children:i.llmBinding})," · ",e.jsx("code",{children:i.llmModel})]}),e.jsx("dt",{children:"Embedding"}),e.jsxs("dd",{children:[e.jsx("code",{children:i.embeddingBinding})," · ",e.jsx("code",{children:i.embeddingModel})]}),e.jsx("dt",{children:"Host"}),e.jsx("dd",{children:e.jsxs("code",{children:[i.host,":",i.port]})}),e.jsx("dt",{children:"Working dir"}),e.jsx("dd",{className:"mono ellipsis",title:i.workingDir,children:i.workingDir})]})]}),o.length>0&&e.jsxs(se,{children:[e.jsxs(de,{children:[e.jsx(xe,{size:14})," Server log (tail)"]}),e.jsxs(ue,{children:["Last ",o.length," lines from ",e.jsx("code",{children:"lightrag.log"})]}),e.jsx("pre",{className:"memory-log-tail mono text-xs",children:o.join(`
|
|
402
|
+
`)})]})]}):e.jsx("div",{className:"muted",children:"No LightRAG data available."})}function Os({icon:t,label:s,value:n,sub:a}){return e.jsxs("div",{className:"memory-stat-card",children:[e.jsx("div",{className:"memory-stat-icon",children:t}),e.jsxs("div",{className:"memory-stat-body",children:[e.jsx("div",{className:"memory-stat-label",children:s}),e.jsx("div",{className:"memory-stat-value",children:n}),a&&e.jsx("div",{className:"memory-stat-sub muted",children:a})]})]})}function wp({n:t}){return e.jsxs("span",{style:{position:"relative",display:"inline-block"},children:[e.jsx(Re,{size:14}),e.jsx("span",{className:"memory-mini-badge",children:t})]})}function kp({refreshKey:t}){const s=pe(),n=Qe(),[a,i]=f.useState([]),[r,o]=f.useState(null),[l,c]=f.useState(!0),[h,m]=f.useState(""),[d,u]=f.useState(null),[p,x]=f.useState(!1),[j,v]=f.useState(null),[g,b]=f.useState([]),y=async()=>{var k;c(!0);try{const[C,_]=await Promise.all([H.get("/memory/notes").catch(()=>({notes:[]})),H.get("/memory/obsidian/tree").catch(()=>({tree:null}))]);i(C.notes||[]),o(_.tree),j&&!((k=C.notes)!=null&&k.find(P=>P.relPath===j))&&(v(null),b([]))}catch(C){s.error(`Vault load failed: ${C.message}`)}finally{c(!1)}};f.useEffect(()=>{y()},[t]),f.useEffect(()=>{if(!h.trim()){u(null);return}x(!0);const k=setTimeout(async()=>{try{const C=await H.get(`/memory/search?q=${encodeURIComponent(h)}&limit=50`),_=new Set((C.results||[]).map(P=>P.relPath));u(a.filter(P=>_.has(P.relPath)))}catch(C){s.error(`Search failed: ${C.message}`)}finally{x(!1)}},240);return()=>clearTimeout(k)},[h,a,s]);const w=async k=>{v(k);try{const C=await H.get(`/memory/obsidian/backlinks?note=${encodeURIComponent(k)}`);b(C.backlinks||[])}catch{b([])}},S=()=>{n.open({title:"New note",width:720,children:e.jsx(zr,{mode:"create",onSave:async(k,C,_)=>{try{await H.post("/memory/notes",{path:k,frontmatter:C,body:_}),s.success(`Created ${k}.`),n.close(),await y(),w(k)}catch(P){s.error(`Create failed: ${P.message}`)}},onCancel:()=>n.close()})})},$=async k=>{try{const C=await H.get(`/memory/notes/${k.split("/").map(encodeURIComponent).join("/")}`);n.open({title:`Edit ${k}`,width:720,children:e.jsx(zr,{mode:"edit",initial:{relPath:C.relPath,frontmatter:C.frontmatter,body:C.body},onSave:async(_,P,N)=>{try{await H.put(`/memory/notes/${_.split("/").map(encodeURIComponent).join("/")}`,{frontmatter:P,body:N}),s.success(`Saved ${_}.`),n.close(),await y(),w(_)}catch(T){s.error(`Save failed: ${T.message}`)}},onCancel:()=>n.close()})})}catch(C){s.error(`Load failed: ${C.message}`)}},M=async k=>{if(confirm(`Delete ${k}? This cannot be undone.`))try{await H.del(`/memory/notes/${k.split("/").map(encodeURIComponent).join("/")}`),s.success(`Deleted ${k}.`),j===k&&v(null),await y()}catch(C){s.error(`Delete failed: ${C.message}`)}},z=f.useMemo(()=>[...a].sort((k,C)=>C.mtime-k.mtime),[a]),A=d??z;return l&&!a.length?e.jsxs("div",{className:"view-loading",children:[e.jsx(ye,{size:"lg"}),e.jsx("p",{children:"Loading vault…"})]}):e.jsxs("div",{className:"memory-panel-content memory-obsidian-grid",children:[e.jsxs(se,{variant:"outlined",className:"memory-tree-card",children:[e.jsxs(de,{children:[e.jsx(lt,{size:14})," Folders"]}),e.jsx(ue,{children:r?`${pl(r)} folder(s)`:"no vault"}),e.jsx("div",{className:"memory-tree-body",children:r?e.jsx(fl,{node:r,depth:0,onSelect:w,selected:j}):null})]}),e.jsxs("div",{className:"memory-obsidian-list-col",children:[e.jsxs("div",{className:"memory-list-toolbar",children:[e.jsxs("div",{className:"search-input",children:[e.jsx(Re,{size:14,"aria-hidden":!0}),e.jsx("label",{htmlFor:"obsidian-search",className:"sr-only",children:"Search notes"}),e.jsx("input",{id:"obsidian-search",type:"text",className:"input",placeholder:"Search notes…",value:h,onChange:k=>m(k.target.value),"aria-label":"Search notes"}),h&&e.jsx("button",{type:"button",className:"icon-btn",onClick:()=>m(""),"aria-label":"Clear search",children:e.jsx(Ie,{size:12})})]}),e.jsxs(U,{variant:"primary",size:"sm",onClick:S,children:[e.jsx(Bu,{size:12})," New note"]}),e.jsx(U,{variant:"ghost",size:"sm",onClick:y,title:"Refresh",children:e.jsx(xe,{size:12})})]}),p&&e.jsx("div",{className:"muted text-sm",children:"Searching…"}),A.length===0?e.jsx(Te,{icon:e.jsx(Ue,{size:28}),title:"No notes",message:a.length===0?'No notes in this vault yet. Click "New note" to create one.':`No notes match "${h}".`}):e.jsx("ul",{className:"memory-note-list",children:A.map(k=>e.jsxs("li",{className:te("memory-note-card",j===k.relPath&&"memory-note-card-active"),children:[e.jsxs("button",{type:"button",className:"memory-note-card-main",onClick:()=>w(k.relPath),children:[e.jsxs("div",{className:"memory-note-card-title",children:[e.jsx(Ue,{size:12}),e.jsx("span",{children:ml(k)})]}),e.jsxs("div",{className:"memory-note-card-meta",children:[e.jsx("code",{className:"muted",children:k.relPath}),e.jsxs("span",{className:"muted",children:["· ",Ve(k.mtime)]}),!k.schemaValid&&e.jsx("span",{className:"memory-pill-warn",children:"schema"})]})]}),e.jsxs("div",{className:"memory-note-card-actions",children:[e.jsx("button",{type:"button",className:"icon-btn",onClick:()=>$(k.relPath),"aria-label":`Edit ${k.relPath}`,title:"Edit",children:e.jsx(fn,{size:12})}),e.jsx("button",{type:"button",className:"icon-btn",onClick:()=>M(k.relPath),"aria-label":`Delete ${k.relPath}`,title:"Delete",children:e.jsx(Fe,{size:12})})]})]},k.relPath))})]}),e.jsx("div",{className:"memory-obsidian-detail-col",children:j?e.jsx(Np,{relPath:j,onClose:()=>v(null)}):e.jsx(Te,{icon:e.jsx(Ue,{size:28}),title:"Pick a note",message:"Select a note from the list to view its content, frontmatter, and backlinks."})})]})}function ml(t){var n;const s=(n=t.frontmatter)==null?void 0:n.title;return typeof s=="string"&&s.trim()?s:t.relPath.replace(/\.md$/i,"")}function fl({node:t,depth:s,onSelect:n,selected:a}){const[i,r]=f.useState(s<2);return t.type==="note"?e.jsxs("button",{type:"button",className:te("memory-tree-node memory-tree-node-note",a===t.path&&"memory-tree-node-active"),style:{paddingLeft:6+s*12},onClick:()=>n(t.path),children:[e.jsx(Ue,{size:11}),e.jsx("span",{children:t.name})]}):e.jsxs("div",{className:"memory-tree-folder",children:[e.jsxs("button",{type:"button",className:"memory-tree-node memory-tree-node-folder",style:{paddingLeft:6+s*12},onClick:()=>r(o=>!o),children:[i?e.jsx(ct,{size:11}):e.jsx(Ut,{size:11}),e.jsx(lt,{size:11}),e.jsx("span",{children:t.name||"vault"}),t.children&&t.children.length>0&&e.jsx("span",{className:"muted text-xs",children:t.children.length})]}),i&&t.children&&e.jsx("div",{className:"memory-tree-children",children:t.children.map((o,l)=>e.jsx(fl,{node:o,depth:s+1,onSelect:n,selected:a},`${o.path}-${l}`))})]})}function pl(t){return t.type==="note"?0:1+(t.children||[]).reduce((s,n)=>s+pl(n),0)}function Np({relPath:t,onClose:s}){var m,d;const[n,a]=f.useState(null),[i,r]=f.useState([]),[o,l]=f.useState(!0);if(f.useEffect(()=>{let u=!1;return l(!0),(async()=>{try{const[p,x]=await Promise.all([H.get(`/memory/notes/${t.split("/").map(encodeURIComponent).join("/")}`),H.get(`/memory/obsidian/backlinks?note=${encodeURIComponent(t)}`)]);if(u)return;a(p),r(x.backlinks||[])}catch{u||a(null)}finally{u||l(!1)}})(),()=>{u=!0}},[t]),o)return e.jsx("div",{className:"view-loading",children:e.jsx(ye,{size:"sm"})});if(!n)return e.jsx("div",{className:"muted",children:"Note not found."});const c=Array.isArray((m=n.frontmatter)==null?void 0:m.tags)?n.frontmatter.tags:[],h=Array.isArray((d=n.frontmatter)==null?void 0:d.links)?n.frontmatter.links:[];return e.jsxs("div",{className:"memory-note-detail",children:[e.jsxs("div",{className:"memory-note-detail-head",children:[e.jsx("h3",{children:ml(n)}),e.jsx("button",{type:"button",className:"icon-btn",onClick:s,"aria-label":"Close",children:e.jsx(Ie,{size:12})})]}),e.jsxs("div",{className:"memory-note-detail-meta",children:[e.jsx("code",{children:t}),e.jsxs("span",{className:"muted",children:["· modified ",St(n.mtime)]})]}),c.length>0&&e.jsx("div",{className:"memory-tag-row",children:c.map((u,p)=>e.jsx("span",{className:"memory-tag",children:String(u)},p))}),e.jsx("pre",{className:"memory-note-body mono text-sm",children:n.body}),i.length>0&&e.jsxs("div",{className:"memory-backlinks",children:[e.jsx("h4",{children:"Backlinks"}),e.jsx("ul",{children:i.map(u=>e.jsxs("li",{children:[e.jsx("code",{children:u.fromRelPath}),e.jsx("p",{className:"muted text-sm",children:u.snippet})]},u.fromRelPath))})]}),h.length>0&&e.jsxs("div",{className:"memory-backlinks",children:[e.jsx("h4",{children:"Forward links"}),e.jsx("ul",{children:h.map((u,p)=>e.jsx("li",{children:e.jsx("code",{children:String(u)})},p))})]})]})}function zr({mode:t,initial:s,onSave:n,onCancel:a}){const[i,r]=f.useState((s==null?void 0:s.relPath)||"untitled.md"),[o,l]=f.useState(s!=null&&s.frontmatter?Sp(s.frontmatter):`title: ""
|
|
403
|
+
tags: []
|
|
404
|
+
`),[c,h]=f.useState((s==null?void 0:s.body)||""),[m,d]=f.useState(!1),u=pe(),p=async()=>{if(!i.endsWith(".md")){u.error("Path must end in .md");return}let x;try{x=Cp(o)||{}}catch(j){u.error(`Frontmatter parse failed: ${j.message}`);return}d(!0);try{await n(i,x,c)}finally{d(!1)}};return e.jsxs("div",{className:"memory-editor-modal",children:[e.jsx("label",{className:"field-label",htmlFor:"obsidian-note-path",children:"Path"}),e.jsx("input",{id:"obsidian-note-path",type:"text",className:"input mono",value:i,onChange:x=>r(x.target.value),disabled:t==="edit",placeholder:"notes/example.md"}),e.jsx("label",{className:"field-label",htmlFor:"obsidian-note-frontmatter",style:{marginTop:12},children:"Frontmatter (YAML)"}),e.jsx("textarea",{id:"obsidian-note-frontmatter",className:"memory-editor-textarea mono text-sm",rows:6,value:o,onChange:x=>l(x.target.value),"aria-label":"Frontmatter YAML"}),e.jsx("label",{className:"field-label",htmlFor:"obsidian-note-body",style:{marginTop:12},children:"Body (Markdown)"}),e.jsx("textarea",{id:"obsidian-note-body",className:"memory-editor-textarea mono text-sm",rows:14,value:c,onChange:x=>h(x.target.value),"aria-label":"Body markdown"}),e.jsxs("div",{className:"modal-footer-actions",style:{marginTop:12},children:[e.jsx(U,{variant:"ghost",onClick:a,disabled:m,children:"Cancel"}),e.jsxs(U,{variant:"primary",onClick:p,disabled:m,children:[m&&e.jsx(je,{size:12,className:"memory-spin"}),t==="create"?"Create":"Save"]})]})]})}function Sp(t){const s=[];for(const[n,a]of Object.entries(t))if(a!=null)if(Array.isArray(a)){if(a.length===0){s.push(`${n}: []`);continue}s.push(`${n}:`);for(const i of a)s.push(` - ${Fa(i)}`)}else if(typeof a=="object"){s.push(`${n}:`);for(const[i,r]of Object.entries(a))s.push(` ${i}: ${Fa(r)}`)}else s.push(`${n}: ${Fa(a)}`);return s.join(`
|
|
405
|
+
`)}function Fa(t){return typeof t=="string"?/[:#\n"']/.test(t)||t===""?JSON.stringify(t):t:typeof t=="number"||typeof t=="boolean"?String(t):JSON.stringify(t)}function Cp(t){const s={},n=t.split(/\r?\n/);let a=0;for(;a<n.length;){const i=n[a];if(!i.trim()||i.trim().startsWith("#")){a++;continue}const r=i.match(/^([A-Za-z_][\w-]*):\s*(.*)$/);if(!r){a++;continue}const[,o,l]=r;if(l===""){const c={},h=[];let m=!1,d=!1;for(;a+1<n.length;){const u=n[a+1];if(!u.startsWith(" "))break;if(u.startsWith(" - "))m=!0,h.push(Oa(u.slice(4))),a++;else{d=!0;const p=u.match(/^ ([A-Za-z_][\w-]*):\s*(.*)$/);p&&(c[p[1]]=Oa(p[2])),a++}}s[o]=m&&!d?h:d?c:{}}else s[o]=Oa(l);a++}return s}function Oa(t){const s=t.trim();return s===""?"":s==="true"?!0:s==="false"?!1:s==="null"||s==="~"?null:/^-?\d+$/.test(s)?parseInt(s,10):/^-?\d+\.\d+$/.test(s)?parseFloat(s):s.startsWith('"')&&s.endsWith('"')||s.startsWith("'")&&s.endsWith("'")?s.slice(1,-1):s}function zp({refreshKey:t}){var y,w,S,$;const s=pe(),[n,a]=f.useState(null),[i,r]=f.useState(null),[o,l]=f.useState(!0),[c,h]=f.useState(null),[m,d]=f.useState(null),u=async()=>{var M;l(!0);try{const[z,A,k]=await Promise.all([H.get("/memory/git/status").catch(()=>null),H.get("/memory/git/diff").catch(()=>null),H.get("/memory/config/global").catch(()=>null)]);a(z),r(A),d(((M=k==null?void 0:k.config)==null?void 0:M.git)||null)}catch(z){s.error(`Git status failed: ${z.message}`)}finally{l(!1)}};f.useEffect(()=>{u()},[t]);const p=async(M,z,A)=>{h(M);try{await z(),s.success(A),await u()}catch(k){s.error(`${M} failed: ${k.message}`)}finally{h(null)}},x=()=>p("pull",()=>H.post("/memory/git/pull",{}),"Pull complete."),j=()=>p("push",()=>H.post("/memory/git/push",{}),"Push complete."),v=()=>{const M=prompt("Commit message:",`[memory-sync] ${new Date().toISOString().slice(0,10)} vault sync`);M&&p("commit",()=>H.post("/memory/git/commit",{message:M}),"Committed.")},g=()=>p("fetch",()=>H.post("/memory/git/sync",{push:!1}),"Fetch complete.");if(o&&!n)return e.jsxs("div",{className:"view-loading",children:[e.jsx(ye,{size:"lg"}),e.jsx("p",{children:"Loading git status…"})]});if(!n)return e.jsx("div",{className:"muted",children:"No git data available."});const b=n.mode==="local-only";return e.jsxs("div",{className:"memory-panel-content",children:[e.jsxs(se,{variant:"elevated",children:[e.jsxs(de,{children:[e.jsx(gt,{size:14})," Git sync",b?e.jsx("span",{className:"memory-source-pill-status na",children:"local-only"}):e.jsx("span",{className:te("memory-source-pill-status",n.clean?"on":"warn"),children:n.clean?"clean":"dirty"})]}),e.jsx(ue,{children:b?"Memory is in local-only mode. Configure a shared repo in Settings → Memory to enable git sync.":e.jsxs(e.Fragment,{children:["Branch ",e.jsx("code",{children:n.branch||"—"}),n.ahead?e.jsxs(e.Fragment,{children:[" · ahead ",n.ahead]}):null,n.behind?e.jsxs(e.Fragment,{children:[" · behind ",n.behind]}):null]})}),!b&&e.jsxs("div",{className:"memory-git-status-row",children:[e.jsx(Bs,{ok:n.clean??!1,label:"Working tree"}),e.jsx(Bs,{ok:(n.ahead??0)===0,label:`Ahead: ${n.ahead??0}`}),e.jsx(Bs,{ok:(n.behind??0)===0,label:`Behind: ${n.behind??0}`}),e.jsx(Bs,{ok:(((y=n.modified)==null?void 0:y.length)??0)===0,label:`Modified: ${((w=n.modified)==null?void 0:w.length)??0}`}),e.jsx(Bs,{ok:(((S=n.untracked)==null?void 0:S.length)??0)===0,label:`Untracked: ${(($=n.untracked)==null?void 0:$.length)??0}`})]}),e.jsxs("div",{className:"memory-action-row",children:[e.jsxs(U,{variant:"secondary",size:"sm",onClick:x,disabled:!!c||b,children:[c==="pull"?e.jsx(je,{size:12,className:"memory-spin"}):e.jsx(ha,{size:12}),"Pull"]}),e.jsxs(U,{variant:"secondary",size:"sm",onClick:j,disabled:!!c||b,children:[c==="push"?e.jsx(je,{size:12,className:"memory-spin"}):e.jsx(pn,{size:12}),"Push"]}),e.jsxs(U,{variant:"secondary",size:"sm",onClick:v,disabled:!!c||b,children:[c==="commit"?e.jsx(je,{size:12,className:"memory-spin"}):e.jsx(Qo,{size:12}),"Commit"]}),e.jsxs(U,{variant:"ghost",size:"sm",onClick:g,disabled:!!c||b,children:[c==="fetch"?e.jsx(je,{size:12,className:"memory-spin"}):e.jsx(Xu,{size:12}),"Fetch + sync"]}),e.jsxs(U,{variant:"ghost",size:"sm",onClick:u,disabled:!!c,children:[e.jsx(xe,{size:12})," Refresh"]})]})]}),m&&e.jsxs(se,{children:[e.jsxs(de,{children:[e.jsx(ou,{size:14})," Repository"]}),e.jsxs(ue,{children:["Snapshot of ",e.jsx("code",{children:"~/.config/bizar/memory-config.json"})," → git block."]}),e.jsxs("dl",{className:"memory-config-row",children:[e.jsx("dt",{children:"Path"}),e.jsx("dd",{className:"mono ellipsis",title:m.repoPath,children:m.repoPath||"—"}),e.jsx("dt",{children:"Remote"}),e.jsx("dd",{className:"mono ellipsis",title:m.remoteUrl,children:m.remoteUrl||"—"}),e.jsx("dt",{children:"Branch"}),e.jsx("dd",{children:e.jsx("code",{children:m.branch||"main"})}),e.jsx("dt",{children:"Auto-sync"}),e.jsx("dd",{children:m.autoSync?"enabled":"disabled"})]})]}),e.jsxs(se,{children:[e.jsxs(de,{children:[e.jsx(Yu,{size:14})," Working-tree diff"]}),e.jsx(ue,{children:i!=null&&i.hasDiff?`${i.files.length} file(s) changed`:"no working-tree changes"}),i&&i.files.length>0&&e.jsx("ul",{className:"memory-diff-files",children:i.files.map(M=>e.jsx("li",{children:e.jsx("code",{children:M})},M))}),i&&i.lines.length>1&&e.jsx("pre",{className:"memory-log-tail mono text-xs",children:i.lines.slice(0,400).join(`
|
|
406
|
+
`)})]})]})}function Bs({ok:t,label:s}){return e.jsxs("span",{className:te("memory-git-status-pill",t?"ok":"warn"),children:[t?e.jsx(Ze,{size:11}):e.jsx(je,{size:11,className:"memory-spin"}),s]})}function Mp({refreshKey:t}){const s=pe(),[n,a]=f.useState(""),[i,r]=f.useState({lightrag:!0,obsidian:!0}),[o,l]=f.useState(null),[c,h]=f.useState(!1),[m,d]=f.useState(""),u=async x=>{if(x.trim()){h(!0),d(x);try{const j=[...i.lightrag?["lightrag"]:[],...i.obsidian?["obsidian"]:[]],v=await H.post("/memory/semantic-search",{query:x,limit:20,sources:j});l(v.results||[])}catch(j){s.error(`Search failed: ${j.message}`),l([])}finally{h(!1)}}};f.useEffect(()=>{m&&u(m)},[i]),f.useEffect(()=>{m&&u(m)},[t]);const p=f.useMemo(()=>{const x=(o||[]).filter(v=>v.source==="obsidian"),j=(o||[]).filter(v=>v.source==="lightrag");return{obs:x,lr:j}},[o]);return e.jsxs("div",{className:"memory-panel-content",children:[e.jsxs(se,{variant:"elevated",children:[e.jsxs(de,{children:[e.jsx(Re,{size:14})," Semantic search"]}),e.jsx(ue,{children:"Query both LightRAG (graph-based) and the Obsidian vault in one shot."}),e.jsxs("div",{className:"memory-search-row",children:[e.jsx("label",{htmlFor:"semantic-search-input",className:"sr-only",children:"Semantic search"}),e.jsx("input",{id:"semantic-search-input",type:"text",className:"input",placeholder:"e.g. how are notes indexed?",value:n,onChange:x=>a(x.target.value),onKeyDown:x=>{x.key==="Enter"&&u(n)},disabled:c,"aria-label":"Semantic search query"}),e.jsxs(U,{variant:"primary",onClick:()=>u(n),disabled:c||!n.trim(),children:[c?e.jsx(je,{size:12,className:"memory-spin"}):e.jsx(Re,{size:12}),"Search"]})]}),e.jsxs("div",{className:"memory-source-toggle-row",children:[e.jsx(Mr,{active:i.obsidian,onToggle:()=>r(x=>({...x,obsidian:!x.obsidian})),label:"Obsidian",icon:e.jsx(Ue,{size:11})}),e.jsx(Mr,{active:i.lightrag,onToggle:()=>r(x=>({...x,lightrag:!x.lightrag})),label:"LightRAG",icon:e.jsx(xt,{size:11})}),n&&e.jsx("button",{type:"button",className:"icon-btn",onClick:()=>{a(""),l(null),d("")},"aria-label":"Clear",children:e.jsx(Ie,{size:12})})]})]}),c&&e.jsx("div",{className:"view-loading",children:e.jsx(ye,{size:"md"})}),!c&&o&&o.length===0&&e.jsx(Te,{icon:e.jsx(Re,{size:28}),title:"No matches",message:`Nothing in scope matched "${m}".`}),p.obs.length>0&&e.jsxs(se,{children:[e.jsxs(de,{children:[e.jsx(Ue,{size:14})," Obsidian (",p.obs.length,")"]}),e.jsx("ul",{className:"memory-search-result-list",children:p.obs.map((x,j)=>e.jsxs("li",{className:"memory-search-result",children:[e.jsxs("div",{className:"memory-search-result-head",children:[e.jsx("code",{children:x.relPath}),e.jsxs("span",{className:"muted text-xs",children:["score ",x.score.toFixed(1)]})]}),e.jsx("p",{className:"muted text-sm",children:x.snippet})]},`obs-${j}`))})]}),p.lr.length>0&&e.jsxs(se,{children:[e.jsxs(de,{children:[e.jsx(xt,{size:14})," LightRAG (",p.lr.length,")"]}),e.jsx("div",{className:"memory-search-result-list",children:p.lr.map((x,j)=>e.jsxs("div",{className:"memory-search-result",children:[e.jsxs("div",{className:"memory-search-result-head",children:[e.jsxs("span",{className:"memory-source-pill",children:[e.jsx(xt,{size:11})," LightRAG"]}),x.error&&e.jsxs("span",{className:"muted text-xs",children:["error: ",x.error]})]}),e.jsx("p",{className:"text-sm",children:x.snippet})]},`lr-${j}`))})]})]})}function Mr({active:t,onToggle:s,label:n,icon:a}){return e.jsxs("button",{type:"button",className:te("memory-toggle-chip",t&&"memory-toggle-chip-active"),onClick:s,"aria-pressed":t,children:[a,e.jsx("span",{children:n})]})}function $p({refreshKey:t}){const s=pe(),[n,a]=f.useState(null),[i,r]=f.useState(!0),[o,l]=f.useState(!1),[c,h]=f.useState(""),[m,d]=f.useState(null),[u,p]=f.useState(""),[x,j]=f.useState(!1),[v,g]=f.useState(!1),[b,y]=f.useState(null),[w,S]=f.useState(null),[$,M]=f.useState(null),[z,A]=f.useState(!1),k=async()=>{var E,D;r(!0);try{const[G,I]=await Promise.all([H.get("/memory/config/global").catch(()=>null),H.get("/memory/status").catch(()=>null)]);G?(a(G.config),h(((D=(E=G.config)==null?void 0:E.git)==null?void 0:D.remoteUrl)||"")):a({}),I&&(d(I),p(W=>W||I.vaultRoot||"")),await C()}catch(G){s.error(`Config load failed: ${G.message}`)}finally{r(!1)}},C=async()=>{try{const E=await H.get("/memory/git/status");E.ok&&y({clean:E.clean,branch:E.branch,modified:E.modified,untracked:E.untracked})}catch{}};f.useEffect(()=>{k()},[t]);const _=async()=>{const E=u.trim();if(!E){s.error("Vault path cannot be empty.");return}g(!0);try{const D=await H.get("/memory/status").catch(()=>null);(D==null?void 0:D.initialized)?(await H.post("/memory/config/vault",{vaultRoot:E}),s.success(`Vault path updated to ${E}.`)):(await H.post("/memory/init",{vaultRoot:E}),s.success(`Vault initialised at ${E}.`)),p(E),await k()}catch(D){s.error(`Vault path save failed: ${D.message}`)}finally{g(!1)}},P=async()=>{j(!0);try{await H.post("/memory/init",{}),s.success("Vault initialised."),await k()}catch(E){s.error(`Init failed: ${E.message}`)}finally{j(!1)}},N=async()=>{if(n){l(!0);try{await H.put("/memory/config/global",{git:{remoteUrl:c}}),s.success("Config saved.")}catch(E){s.error(`Save failed: ${E.message}`)}finally{l(!1)}}},T=async E=>{S(E);try{if(E==="pull"){const D=await H.post("/memory/git/pull",{});D.ok?s.success("Pull successful."):s.error(`Pull failed: ${D.output||"unknown error"}`)}else if(E==="push")(await H.post("/memory/git/push",{})).ok?s.success("Push successful."):s.error("Push failed.");else if(E==="commit"){const D=await H.post("/memory/git/commit",{});D.ok?s.success(`Committed: ${D.message}`):s.error("Commit failed.")}await C()}catch(D){s.error(`${E} failed: ${D.message}`)}finally{S(null)}},L=async()=>{A(!0);try{const E=await H.post("/memory/test-git",{});M(E.checks)}catch(E){s.error(`Test failed: ${E.message}`)}finally{A(!1)}};if(i&&!n)return e.jsxs("div",{className:"view-loading",children:[e.jsx(ye,{size:"md"}),e.jsx("p",{children:"Loading config…"})]});if(!n)return e.jsx("div",{className:"muted",children:"No config available."});const R=!!(m!=null&&m.initialized),F=(m==null?void 0:m.vaultRoot)??"";return e.jsxs("div",{className:"memory-panel-content",children:[e.jsxs(se,{children:[e.jsxs(de,{children:[e.jsx(dr,{size:14})," Vault location"]}),e.jsxs(ue,{children:["The on-disk folder where notes and memory metadata live. Default:"," ",e.jsx("code",{children:"~/.bizar_memory"}),"."]}),e.jsxs("div",{className:"memory-config-form",children:[e.jsxs(Cn,{label:"Current path",inline:!0,children:[e.jsx("span",{className:"memory-vault-path mono","data-testid":"memory-current-vault-path",children:F||e.jsx("span",{className:"muted",children:"not initialised"})}),R?e.jsxs("span",{className:"memory-pill memory-pill-ok",style:{marginLeft:8},title:"Vault folder exists on disk",children:[e.jsx(Ze,{size:10})," initialised"]}):e.jsxs("span",{className:"memory-pill memory-pill-warn",style:{marginLeft:8},title:"Vault folder does not exist yet",children:[e.jsx(ls,{size:10})," not initialised"]})]}),e.jsxs(Cn,{label:"Set path",children:[e.jsx("input",{type:"text",className:"input mono",value:u,onChange:E=>p(E.target.value),placeholder:"~/.bizar_memory","aria-label":"Vault path","data-testid":"memory-vault-path-input"}),e.jsx("span",{className:"field-hint",children:R?"Save to update the working path.":"Save and initialise will create this folder if it does not exist."})]})]}),e.jsxs("div",{className:"memory-action-row",style:{marginTop:12},children:[e.jsxs(U,{variant:"primary",onClick:_,disabled:v||x||!u.trim(),"data-testid":"memory-save-vault-path",children:[v?e.jsx(je,{size:12,className:"memory-spin"}):e.jsx(bs,{size:12}),R?"Save path":"Save and initialise"]}),!R&&e.jsxs(U,{variant:"secondary",onClick:P,disabled:x||v,"data-testid":"memory-init-vault",children:[x?e.jsx(je,{size:12,className:"memory-spin"}):e.jsx(dr,{size:12}),"Initialise default"]})]})]}),e.jsxs(se,{children:[e.jsxs(de,{children:[e.jsx(gt,{size:14})," Git sync"]}),e.jsx(ue,{children:"Configure the git remote and sync your memory vault."}),e.jsxs("div",{className:"memory-config-form",children:[e.jsx(Cn,{label:"Remote URL",children:e.jsx("input",{type:"text",className:"input mono",value:c,onChange:E=>h(E.target.value),placeholder:"git@github.com:org/repo.git"})}),b&&e.jsxs(Cn,{label:"Status",inline:!0,children:[e.jsx("span",{className:te("memory-pill",b.clean?"memory-pill-ok":"memory-pill-warn"),children:b.clean?"clean":"dirty"}),b.branch&&e.jsxs("span",{className:"muted",style:{marginLeft:8},children:[e.jsx(gt,{size:12,style:{display:"inline"}})," ",b.branch]}),!b.clean&&b.modified!==void 0&&e.jsxs("span",{className:"muted",style:{marginLeft:8},children:[b.modified," modified, ",b.untracked," untracked"]})]})]}),e.jsxs("div",{className:"memory-action-row",style:{marginTop:12},children:[e.jsxs(U,{variant:"secondary",onClick:()=>T("pull"),disabled:w!==null,children:[w==="pull"?e.jsx(je,{size:12,className:"memory-spin"}):e.jsx(ts,{size:12}),"Pull"]}),e.jsxs(U,{variant:"secondary",onClick:()=>T("commit"),disabled:w!==null,children:[w==="commit"?e.jsx(je,{size:12,className:"memory-spin"}):e.jsx(Qo,{size:12}),"Commit"]}),e.jsxs(U,{variant:"secondary",onClick:()=>T("push"),disabled:w!==null,children:[w==="push"?e.jsx(je,{size:12,className:"memory-spin"}):e.jsx(wu,{size:12}),"Push"]})]})]}),e.jsxs(se,{children:[e.jsxs(de,{children:[e.jsx(ni,{size:14})," Connection tests"]}),e.jsx(ue,{children:"Verify the configured git remote is reachable."}),e.jsxs("div",{className:"memory-action-row",children:[e.jsxs(U,{variant:"secondary",onClick:L,disabled:z,children:[z?e.jsx(je,{size:12,className:"memory-spin"}):e.jsx(ni,{size:12}),"Test git connection"]}),e.jsxs(U,{variant:"primary",onClick:N,disabled:o,children:[o?e.jsx(je,{size:12,className:"memory-spin"}):e.jsx(bs,{size:12}),"Save config"]})]}),$&&$.length>0&&e.jsx("ul",{className:"memory-check-list",style:{marginTop:12},children:$.map((E,D)=>e.jsxs("li",{className:"memory-check-row",children:[e.jsx("span",{className:"memory-check-icon",children:e.jsx("span",{className:te("memory-pill",E.pass?"memory-pill-ok":"memory-pill-warn"),children:E.pass?"OK":"FAIL"})}),e.jsx("span",{className:"memory-check-name",children:E.name}),e.jsx("span",{className:"memory-check-detail muted",children:E.detail})]},D))})]})]})}function Cn({label:t,children:s,inline:n}){return n?e.jsxs("div",{className:"memory-config-row-inline",children:[e.jsx("div",{className:"memory-config-row-label",id:`cfg-${t.replace(/\s+/g,"-").toLowerCase()}`,children:t}),e.jsx("div",{className:"memory-config-row-control",role:"group","aria-labelledby":`cfg-${t.replace(/\s+/g,"-").toLowerCase()}`,children:s})]}):e.jsxs("label",{className:"memory-config-row-stack",children:[e.jsx("span",{children:t}),s]})}const _t=800,$r=60,Ba={default:"#8b5cf6",note:"#8b5cf6",entity:"#34d399",concept:"#fbbf24",root:"#f87171"};function Ep(t,s){return Ba[t]||Ba[s]||Ba.default}function _p(t){return 6+Math.min(t.size*2,10)}function Tp(t,s){var r,o;if(t.length===0)return[];const n=new Map;for(const l of t)n.set(l.id,new Set);for(const l of s)(r=n.get(l.source))==null||r.add(l.target),(o=n.get(l.target))==null||o.add(l.source);const a=t.map((l,c)=>{const h=c/t.length*Math.PI*2,m=_t*.28;return{...l,x:_t/2+m*Math.cos(h)+(Math.random()-.5)*40,y:_t/2+m*Math.sin(h)+(Math.random()-.5)*40,vx:0,vy:0}}),i=new Map;for(const l of a)i.set(l.id,l);for(let l=0;l<$r;l++){const c=1-l/$r;for(let d=0;d<a.length;d++)for(let u=d+1;u<a.length;u++){const p=a[d],x=a[u],j=x.x-p.x,v=x.y-p.y,g=Math.sqrt(j*j+v*v)||1,b=400*c/(g*g),y=j/g*b,w=v/g*b;p.vx-=y,p.vy-=w,x.vx+=y,x.vy+=w}for(const d of s){const u=i.get(d.source),p=i.get(d.target);if(!u||!p)continue;const x=p.x-u.x,j=p.y-u.y,v=Math.sqrt(x*x+j*j)||1,b=(v-80)*.08*c,y=x/v*b,w=j/v*b;u.vx+=y,u.vy+=w,p.vx-=y,p.vy-=w}const h=_t/2,m=_t/2;for(const d of a)d.vx+=(h-d.x)*.01*c,d.vy+=(m-d.y)*.01*c;for(const d of a)d.vx*=.85,d.vy*=.85,d.x+=d.vx,d.y+=d.vy,d.x=Math.max(20,Math.min(_t-20,d.x)),d.y=Math.max(20,Math.min(_t-20,d.y))}return a}function Ap({data:t,onNodeClick:s,className:n}){const a=f.useRef(null),[i,r]=f.useState({x:0,y:0,scale:1}),o=f.useRef(!1),l=f.useRef({x:0,y:0,tx:0,ty:0}),c=f.useRef(null),[h,m]=f.useState(null),[d,u]=f.useState(null),p=f.useMemo(()=>Tp(t.nodes,t.edges),[t.nodes,t.edges]),x=f.useMemo(()=>{const z=new Map;for(const A of p)z.set(A.id,A);return z},[p]),j=f.useCallback(z=>{z.target.closest(".memory-graph-node")||(o.current=!0,l.current={x:z.clientX,y:z.clientY,tx:i.x,ty:i.y})},[i]),v=f.useCallback(z=>{if(!o.current)return;const A=z.clientX-l.current.x,k=z.clientY-l.current.y;r(C=>({...C,x:l.current.tx+A,y:l.current.ty+k}))},[]),g=f.useCallback(()=>{o.current=!1},[]),b=f.useCallback(z=>{z.preventDefault();const A=z.deltaY<0?1.1:.9,k=a.current;if(!k)return;const C=k.getBoundingClientRect(),_=z.clientX-C.left,P=z.clientY-C.top;r(N=>{const T=Math.max(.2,Math.min(4,N.scale*A)),L=T/N.scale;return{x:_-(_-N.x)*L,y:P-(P-N.y)*L,scale:T}})},[]),y=f.useCallback(z=>{const A=Array.from(z.touches);if(A.length===2){const[k,C]=A;c.current=Math.hypot(C.clientX-k.clientX,C.clientY-k.clientY)}else A.length===1&&(o.current=!0,l.current={x:A[0].clientX,y:A[0].clientY,tx:i.x,ty:i.y})},[i]),w=f.useCallback(z=>{const A=Array.from(z.touches);if(A.length===2&&c.current!==null){const[k,C]=A,_=Math.hypot(C.clientX-k.clientX,C.clientY-k.clientY),P=_/c.current;c.current=_,r(N=>({...N,scale:Math.max(.2,Math.min(4,N.scale*P))}))}else if(A.length===1&&o.current){const k=A[0].clientX-l.current.x,C=A[0].clientY-l.current.y;r(_=>({..._,x:l.current.tx+k,y:l.current.ty+C}))}},[]),S=f.useCallback(()=>{o.current=!1,c.current=null},[]),$=f.useCallback(z=>{m(z.id===h?null:z.id),s==null||s(z)},[h,s]),M=Math.max(.5,1/Math.log2(i.scale+1));return e.jsx("svg",{ref:a,className:te("memory-graph-canvas",n),viewBox:`0 0 ${_t} ${_t}`,style:{width:"100%",height:"100%",minHeight:400,cursor:o.current?"grabbing":"grab"},onMouseDown:j,onMouseMove:v,onMouseUp:g,onMouseLeave:g,onWheel:b,onTouchStart:y,onTouchMove:w,onTouchEnd:S,children:e.jsxs("g",{transform:`translate(${i.x},${i.y}) scale(${i.scale})`,children:[t.edges.map((z,A)=>{const k=x.get(z.source),C=x.get(z.target);if(!k||!C)return null;const _=d===z.source||d===z.target||h===z.source||h===z.target;return e.jsx("line",{x1:k.x,y1:k.y,x2:C.x,y2:C.y,stroke:_?"#8b5cf6":"#2d3648",strokeWidth:_?M*2:M,strokeOpacity:_?.9:.5},`e-${A}`)}),p.map(z=>{const A=_p(z),k=Ep(z.group,z.type),C=h===z.id,_=d===z.id;return e.jsxs("g",{className:"memory-graph-node",transform:`translate(${z.x},${z.y})`,onClick:()=>$(z),onMouseEnter:()=>u(z.id),onMouseLeave:()=>u(null),style:{cursor:"pointer"},children:[e.jsx("circle",{r:A+6,fill:"transparent"}),(C||_)&&e.jsx("circle",{r:A+4,fill:k,fillOpacity:.2}),e.jsx("circle",{r:A,fill:k,fillOpacity:C?1:.75,stroke:C?"#fff":k,strokeWidth:C?2:1}),i.scale>.5&&e.jsx("text",{y:A+12,textAnchor:"middle",fontSize:Math.max(8,Math.min(11,10/Math.sqrt(i.scale))),fill:"var(--text-dim, #b4bcd0)",style:{pointerEvents:"none",userSelect:"none"},children:z.label.length>20?z.label.slice(0,18)+"…":z.label})]},z.id)})]})})}const Rp=[{color:"#8b5cf6",label:"Note / Default"},{color:"#34d399",label:"Entity (LightRAG)"},{color:"#fbbf24",label:"Concept (LightRAG)"},{color:"#f87171",label:"Root / Ungrouped"}];function Ip({className:t}){return e.jsx("div",{className:te("memory-graph-legend",t),children:Rp.map(s=>e.jsxs("span",{className:"memory-graph-legend-item",children:[e.jsx("span",{className:"memory-graph-legend-dot",style:{background:s.color}}),s.label]},s.label))})}function Lp({refreshKey:t}){const s=pe(),[n,a]=f.useState({nodes:[],edges:[]}),[i,r]=f.useState(!0),[o,l]=f.useState(null),[c,h]=f.useState(""),[m,d]=f.useState(2),[u,p]=f.useState(""),[x,j]=f.useState(null),[v,g]=f.useState(null),b=f.useCallback(async()=>{var S,$;r(!0),l(null);try{const M=new URLSearchParams({limit:"200"});u&&M.set("root",u),M.set("depth",String(m));const z=await H.get(`/memory/graph?${M}`);a({nodes:z.nodes||[],edges:z.edges||[]}),j({totalNodes:z.totalNodes??((S=z.nodes)==null?void 0:S.length)??0,totalEdges:z.totalEdges??(($=z.edges)==null?void 0:$.length)??0})}catch(M){l(M.message),s.error(`Graph load failed: ${M.message}`)}finally{r(!1)}},[u,m,s]);f.useEffect(()=>{b()},[b,t]);const y=f.useCallback(S=>{g($=>($==null?void 0:$.id)===S.id?null:S)},[]),w=c.trim()?{nodes:n.nodes.filter(S=>S.label.toLowerCase().includes(c.toLowerCase())),edges:n.edges.filter(S=>n.nodes.some($=>$.id===S.source&&$.label.toLowerCase().includes(c.toLowerCase()))||n.nodes.some($=>$.id===S.target&&$.label.toLowerCase().includes(c.toLowerCase())))}:n;return e.jsxs("div",{className:"memory-panel-content",children:[e.jsxs(se,{children:[e.jsxs(de,{children:[e.jsx(sl,{size:14})," Memory Graph"]}),e.jsx(ue,{children:"Interactive knowledge graph — LightRAG entities + Obsidian wikilinks. Drag to pan, scroll to zoom."}),e.jsxs("div",{className:"memory-graph-controls",children:[e.jsxs("div",{className:"memory-graph-search-row",children:[e.jsx("label",{htmlFor:"graph-filter",className:"sr-only",children:"Filter nodes"}),e.jsx("input",{id:"graph-filter",type:"text",className:"input",placeholder:"Filter nodes…",value:c,onChange:S=>h(S.target.value),style:{maxWidth:240}}),e.jsx("input",{type:"text",className:"input",placeholder:"Root note id (optional)",value:u,onChange:S=>p(S.target.value),style:{maxWidth:240},title:"Start from a specific note"}),e.jsx("label",{htmlFor:"graph-depth",className:"sr-only",children:"Depth"}),e.jsxs("span",{className:"muted text-sm",style:{whiteSpace:"nowrap"},children:["Depth",e.jsx("input",{id:"graph-depth",type:"range",min:1,max:3,value:m,onChange:S=>d(parseInt(S.target.value,10)),style:{marginLeft:8,verticalAlign:"middle"}}),m]}),e.jsx("button",{type:"button",className:"icon-btn",onClick:b,title:"Refresh graph",disabled:i,children:e.jsx(xe,{size:14,className:i?"memory-spin":""})})]}),e.jsx(Ip,{})]})]}),e.jsx(se,{children:i&&!n.nodes.length?e.jsxs("div",{className:"view-loading",children:[e.jsx(ye,{size:"lg"}),e.jsx("p",{children:"Loading graph…"})]}):o&&!n.nodes.length?e.jsxs("div",{className:"muted text-sm",children:["Failed to load graph: ",o]}):n.nodes.length===0?e.jsx("div",{className:"muted text-sm",children:"No graph data available. Index some notes first with LightRAG or add wikilinks to your vault."}):e.jsxs("div",{style:{position:"relative"},children:[e.jsx(Ap,{data:w,onNodeClick:y,className:"memory-graph-canvas-svg"}),c&&e.jsxs("div",{className:"text-xs muted",style:{marginTop:4},children:["Showing ",w.nodes.length," of ",n.nodes.length," nodes"]})]})}),v&&e.jsxs(se,{children:[e.jsx(de,{children:v.label}),e.jsx(ue,{children:e.jsx("code",{children:v.id})}),e.jsxs("dl",{className:"memory-config-row",children:[e.jsx("dt",{children:"Type"}),e.jsx("dd",{children:e.jsx("code",{children:v.type})}),e.jsx("dt",{children:"Group"}),e.jsx("dd",{children:e.jsx("code",{children:v.group})}),e.jsx("dt",{children:"Size"}),e.jsx("dd",{children:v.size})]})]}),x&&e.jsx(se,{children:e.jsxs("div",{className:"memory-graph-stats",children:[e.jsxs("span",{children:[x.totalNodes," node",x.totalNodes!==1?"s":""]}),e.jsx("span",{className:"muted",children:"·"}),e.jsxs("span",{children:[x.totalEdges," edge",x.totalEdges!==1?"s":""]}),c&&e.jsxs("span",{className:"muted",children:["· ",w.nodes.length," shown"]})]})})]})}function Pp({onTextExtracted:t}){const s=pe(),[n,a]=f.useState(null),[i,r]=f.useState(!1),[o,l]=f.useState(!1),c=f.useCallback(async()=>{l(!0);try{const d=await navigator.mediaDevices.getDisplayMedia({video:{mediaSource:"screen"}}),u=document.createElement("video");u.srcObject=d,await u.play();const p=document.createElement("canvas");p.width=u.videoWidth,p.height=u.videoHeight;const x=p.getContext("2d");if(!x){s.error("Failed to get canvas context");return}x.drawImage(u,0,0),d.getTracks().forEach(j=>j.stop()),u.remove(),p.toBlob(async j=>{if(!j){s.error("Failed to capture screenshot");return}const v=URL.createObjectURL(j);a(v),await h(j)},"image/png")}catch(d){d.name!=="NotAllowedError"&&s.error(`Capture failed: ${d.message}`)}finally{l(!1)}},[s]),h=f.useCallback(async d=>{r(!0);try{const u=new FileReader,p=await new Promise((j,v)=>{u.onload=()=>{const g=u.result,b=g.includes(",")?g.split(",")[1]:g;j(b)},u.onerror=()=>v(new Error("FileReader failed")),u.readAsDataURL(d)}),x=await H.post("/ocr/process",{image:p,lang:"eng"});x.ok&&(s.success("Text extracted from screenshot"),t==null||t(x.text,x.notePath))}catch(u){s.error(`OCR failed: ${u.message}`)}finally{r(!1)}},[s,t]),m=f.useCallback(()=>{a(null)},[]);return e.jsxs(se,{variant:"outlined",className:"screenshot-capture-card",children:[e.jsxs(de,{children:[e.jsx(Ea,{size:14})," Screenshot Capture"]}),e.jsx("div",{className:"screenshot-capture-body",children:n?e.jsxs("div",{className:"screenshot-capture-preview",children:[e.jsx("img",{src:n,alt:"Captured screenshot",className:"screenshot-capture-img"}),e.jsxs("div",{className:"screenshot-capture-actions",children:[i&&e.jsxs("span",{className:"text-sm muted",children:[e.jsx(je,{size:12,className:"spinner"})," Extracting text…"]}),e.jsx(U,{variant:"ghost",size:"sm",onClick:m,disabled:i,children:"Dismiss"})]})]}):e.jsxs("div",{className:"screenshot-capture-empty",children:[e.jsx(Ea,{size:32,className:"muted"}),e.jsx("p",{className:"muted text-sm",children:"Capture your screen to extract text via OCR."}),e.jsxs(U,{variant:"primary",size:"sm",onClick:c,disabled:o,children:[o?e.jsx(je,{size:12,className:"spinner"}):e.jsx(Ea,{size:12}),o?"Selecting…":"Capture Screen"]})]})})]})}function Dp(){const[t,s]=f.useState(null),[n,a]=f.useState(null),i=(r,o)=>{s(r),a(o)};return e.jsxs("div",{className:"screenshot-ocr-panel",children:[e.jsx(Pp,{onTextExtracted:i}),t!==null&&e.jsxs(se,{variant:"outlined",className:"screenshot-ocr-result-card",children:[e.jsxs(de,{children:[e.jsx(Ue,{size:14})," Extracted Text"]}),n&&e.jsxs(ue,{children:["Saved to: ",n]}),e.jsx("div",{className:"screenshot-ocr-text",children:t?e.jsx("pre",{className:"screenshot-ocr-pre mono text-sm",children:t}):e.jsx("p",{className:"muted text-sm",children:"No text was found in the captured image."})})]})]})}function Fp({refreshKey:t}){return e.jsx("div",{className:"memory-panel-content",children:e.jsx(se,{variant:"outlined",className:"memory-panel-card",children:e.jsx("div",{className:"memory-panel-body",children:e.jsx(Dp,{})})})})}function Op({refreshKey:t}){const s=pe(),[n,a]=f.useState(""),[i,r]=f.useState(""),[o,l]=f.useState(""),[c,h]=f.useState(!1),m=async()=>{if(!o.trim()){s.error("Content is required");return}h(!0);try{const d=await H.post("/clipboard/save",{url:n.trim()||void 0,title:i.trim()||void 0,content:o,savedAt:new Date().toISOString()});d.ok&&(s.success(`Saved to ${d.notePath}`),a(""),r(""),l(""))}catch(d){s.error(`Save failed: ${d.message}`)}finally{h(!1)}};return e.jsx("div",{className:"memory-panel-content",children:e.jsx(se,{variant:"outlined",className:"memory-panel-card",children:e.jsx("div",{className:"memory-panel-body",children:e.jsxs("div",{className:"vault-clipboard-panel",children:[e.jsxs("div",{className:"vault-clipboard-header",children:[e.jsx(Zo,{size:16}),e.jsx("span",{children:"Paste Content"})]}),e.jsx("label",{className:"field-label",htmlFor:"clip-url",children:"URL (optional)"}),e.jsx("input",{id:"clip-url",type:"text",className:"input",placeholder:"https://example.com",value:n,onChange:d=>a(d.target.value)}),e.jsx("label",{className:"field-label",htmlFor:"clip-title",style:{marginTop:10},children:"Title (optional)"}),e.jsx("input",{id:"clip-title",type:"text",className:"input",placeholder:"Page title",value:i,onChange:d=>r(d.target.value)}),e.jsx("label",{className:"field-label",htmlFor:"clip-content",style:{marginTop:10},children:"Content *"}),e.jsx("textarea",{id:"clip-content",className:"input vault-clipboard-textarea mono text-sm",rows:12,placeholder:"Paste or type content to save to your vault…",value:o,onChange:d=>l(d.target.value)}),e.jsx("div",{className:"vault-clipboard-actions",style:{marginTop:12},children:e.jsxs(U,{variant:"primary",size:"sm",onClick:m,disabled:c||!o.trim(),children:[c&&e.jsx(je,{size:12,className:"spinner"}),"Save to Vault"]})})]})})})})}function Bp({vaultPath:t,onSaved:s}){const[n,a]=f.useState(!1),[i,r]=f.useState(!1),o=f.useRef(null),l=f.useRef([]),c=async()=>{try{const d=await navigator.mediaDevices.getUserMedia({audio:!0}),u=MediaRecorder.isTypeSupported("audio/webm;codecs=opus")?"audio/webm;codecs=opus":"audio/webm",p=new MediaRecorder(d,{mimeType:u});p.ondataavailable=x=>{x.data&&x.data.size>0&&l.current.push(x.data)},p.onstop=async()=>{const x=new Blob(l.current,{type:"audio/webm"});l.current=[],d.getTracks().forEach(j=>j.stop()),await m(x)},p.start(1e3),o.current=p,a(!0)}catch(d){At.error("[VoiceRecorder] failed to start recording:",d)}},h=()=>{const d=o.current;d&&(d.stop(),a(!1),r(!0))},m=async d=>{try{const u=new FormData;u.append("audio",d,"voice-note.webm"),u.append("vaultPath",t||"");const p=await fetch("/api/voice/upload",{method:"POST",body:u});if(!p.ok){At.error("[VoiceRecorder] upload failed:",p.status,await p.text()),r(!1);return}const{notePath:x,transcription:j}=await p.json();s==null||s(x,j)}catch(u){At.error("[VoiceRecorder] upload error:",u)}finally{r(!1)}};return e.jsxs("div",{className:"voice-recorder",children:[!n&&!i&&e.jsxs(U,{variant:"accent",size:"sm",onClick:c,"aria-label":"Start recording",children:[e.jsx(_i,{size:14})," Record"]}),n&&e.jsxs(U,{variant:"danger",size:"sm",onClick:h,"aria-label":"Stop recording",children:[e.jsx(ku,{size:14})," Stop"]}),i&&e.jsxs(U,{variant:"secondary",size:"sm",disabled:!0,children:[e.jsx(je,{size:14,className:"spinning"})," Transcribing…"]})]})}function Hp({note:t,onDelete:s}){const[n,a]=f.useState(!1),[i]=f.useState(()=>{if(!t.audioPath)return null;const l=new Audio(`/api/voice/${t.id}/audio`);return l.onended=()=>a(!1),l}),r=()=>{i&&(n?(i.pause(),i.currentTime=0,a(!1)):(i.play(),a(!0)))},o=new Date(t.createdAtMs).toLocaleDateString("en-US",{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"});return e.jsxs("div",{className:"voice-note-card",children:[e.jsxs("div",{className:"voice-note-card-head",children:[e.jsxs("div",{className:"voice-note-card-meta",children:[e.jsx("span",{className:"voice-note-date",children:o}),t.durationSec&&e.jsxs("span",{className:"voice-note-duration",children:[Math.round(t.durationSec),"s"]})]}),e.jsxs("div",{className:"voice-note-card-actions",children:[i&&e.jsx("button",{type:"button",className:"icon-btn",onClick:r,"aria-label":n?"Pause":"Play",title:n?"Pause":"Play",children:n?e.jsx(ki,{size:13}):e.jsx(ws,{size:13})}),e.jsx("button",{type:"button",className:"icon-btn",onClick:()=>s(t.id),"aria-label":"Delete note",title:"Delete note",children:e.jsx(Fe,{size:13})})]})]}),t.transcript&&e.jsx("p",{className:"voice-note-transcript",children:t.transcript}),!t.transcript&&e.jsx("p",{className:"voice-note-no-transcript muted text-sm",children:"No transcription available"})]})}function Vp({vaultPath:t,refreshKey:s=0}){const[n,a]=f.useState([]),[i,r]=f.useState(""),[o,l]=f.useState(!0),c=async()=>{l(!0);try{const d=t?`?vaultPath=${encodeURIComponent(t)}`:"",p=await(await fetch(`/api/voice/list${d}`)).json();a(p.notes||[])}catch(d){At.error("[VoiceNotesPanel] failed to load notes:",d)}finally{l(!1)}};f.useEffect(()=>{c();const d=x=>{try{const j=JSON.parse(x.data);j.type==="voice:updated"&&j.noteId&&a(v=>v.map(g=>{var b;return g.id===j.noteId?{...g,transcript:((b=j.patch)==null?void 0:b.transcript)??g.transcript}:g}))}catch{}},u=`${location.protocol==="https:"?"wss":"ws"}://${location.host}/ws`;let p=null;try{p=new WebSocket(u),p.addEventListener("message",d)}catch{}return()=>{p==null||p.removeEventListener("message",d),p==null||p.close()}},[t,s]);const h=async d=>{try{const u=await fetch(`/api/voice/${d}`,{method:"DELETE"});(u.ok||u.status===204)&&a(p=>p.filter(x=>x.id!==d))}catch(u){At.error("[VoiceNotesPanel] delete failed:",u)}},m=n.filter(d=>{var u;return!i||(((u=d.transcript)==null?void 0:u.toLowerCase().includes(i.toLowerCase()))??!1)});return e.jsxs(se,{children:[e.jsxs(de,{children:[e.jsx(_i,{size:14})," Voice Notes"]}),e.jsx(ue,{children:"Record and transcribe audio notes into your vault"}),e.jsx("div",{className:"memory-search-row",children:e.jsx("input",{type:"text",className:"input search-input",value:i,onChange:d=>r(d.target.value),placeholder:"Search transcripts…","aria-label":"Search voice notes"})}),e.jsx("div",{className:"voice-recorder-row",children:e.jsx(Bp,{vaultPath:t,onSaved:c})}),o?e.jsx("p",{className:"muted text-sm",children:"Loading notes…"}):m.length===0?e.jsx("p",{className:"muted text-sm",children:i?"No notes match your search.":"No voice notes yet. Hit Record to add one."}):e.jsx("div",{className:"voice-note-list",children:m.map(d=>e.jsx(Hp,{note:d,onDelete:h},d.id))})]})}const Up=[{id:"overview",label:"Overview",icon:Jo},{id:"lightrag",label:"LightRAG",icon:xt},{id:"obsidian",label:"Obsidian Vault",icon:Ue},{id:"git",label:"Git Sync",icon:gt},{id:"semantic",label:"Semantic Search",icon:Re},{id:"config",label:"Config",icon:wi},{id:"graph",label:"Memory Graph",icon:sl},{id:"webclip",label:"Web Clip",icon:Zo},{id:"screenshot",label:"Screenshot OCR",icon:ch},{id:"voice",label:"Voice Notes",icon:_i}];function qp(t){const s=pe(),[n,a]=f.useState("overview"),[i,r]=f.useState(0),o=f.useCallback(()=>{r(h=>h+1)},[]),l=f.useCallback(async()=>{o(),s.info("Refreshing memory…",1200)},[o,s]),c=()=>{switch(n){case"overview":return e.jsx(vp,{refreshKey:i,onRefresh:o,setActiveSubPanel:h=>a(h)});case"lightrag":return e.jsx(bp,{refreshKey:i});case"obsidian":return e.jsx(kp,{refreshKey:i});case"git":return e.jsx(zp,{refreshKey:i});case"semantic":return e.jsx(Mp,{refreshKey:i});case"config":return e.jsx($p,{refreshKey:i});case"graph":return e.jsx(Lp,{refreshKey:i});case"webclip":return e.jsx(Op,{refreshKey:i});case"screenshot":return e.jsx(Fp,{refreshKey:i});case"voice":return e.jsx(Vp,{refreshKey:i});default:return null}};return e.jsx(_e,{as:"div",className:"view view-memory",bg:"0",p:7,children:e.jsxs(Be,{gap:5,children:[e.jsx(sm,{title:e.jsxs(Le,{gap:2,align:"center",children:[e.jsx(xt,{size:18}),e.jsx("span",{children:"Memory"})]}),subtitle:"LightRAG, Obsidian vault, git sync, semantic search, web clips, and screenshot OCR — all in one place.",actions:e.jsx(ps,{variant:"ghost",size:"md",onClick:l,"aria-label":"Refresh memory",title:"Refresh",icon:e.jsx(xe,{size:14})})}),e.jsxs(Qn,{cols:2,gap:4,style:{gridTemplateColumns:"240px 1fr",alignItems:"start",minHeight:0},"data-testid":"memory-grid",children:[e.jsx("nav",{"aria-label":"Memory sources","data-testid":"memory-source-rail",children:e.jsx(Be,{direction:"column",gap:1,children:Up.map(h=>{const m=h.icon,d=n===h.id;return e.jsxs("button",{type:"button",role:"tab","aria-selected":d,className:fe("memory-source-button",d&&"memory-source-button-active"),onClick:()=>a(h.id),children:[e.jsx(m,{size:16,"aria-hidden":!0}),e.jsx("span",{children:h.label})]},h.id)})})}),e.jsx(_e,{as:"div","data-testid":"memory-main-panel",children:c()},n)]})]})})}const Wp=rt.memo(qp),Hs=[{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 Gp(t,s,n,a){const i=n.has(t.id);return e.jsxs(se,{className:"history-project",style:{marginBottom:4},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(lt,{size:16})," ",t.name]}),e.jsx("div",{className:"history-project-meta",children:t.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:t.tasks.done}),e.jsxs("span",{className:"muted",children:["/ ",t.tasks.total," done"]})]}),t.tasks.doing>0&&e.jsxs("span",{className:"history-project-stat",children:[e.jsx("span",{className:"history-project-stat-num",children:t.tasks.doing}),e.jsx("span",{className:"muted",children:"doing"})]}),t.tasks.blocked>0&&e.jsxs("span",{className:"history-project-stat",children:[e.jsx("span",{className:"history-project-stat-num",children:t.tasks.blocked}),e.jsx("span",{className:"muted",children:"blocked"})]}),e.jsxs("span",{className:"history-project-stat",children:[e.jsx(Ue,{size:11})," ",e.jsx("span",{className:"history-project-stat-num",children:t.plans}),e.jsxs("span",{className:"muted",children:[" plan",t.plans===1?"":"s"]})]}),t.lastAccessed&&e.jsx("span",{className:"history-project-stat",children:e.jsxs("span",{className:"muted",children:["last opened ",Ve(t.lastAccessed)]})})]}),e.jsx("button",{type:"button",className:"icon-btn",onClick:()=>a(t.id),"aria-label":i?"Collapse":"Expand",children:i?e.jsx(ct,{size:14}):e.jsx(Ut,{size:14})})]}),i&&e.jsx("div",{className:"history-timeline-mini",children:s.length===0?e.jsx("div",{className:"muted",style:{padding:"12px 8px",fontSize:12},children:"No events in this time range."}):s.slice(-100).reverse().map((r,o)=>e.jsxs("div",{className:"history-timeline-row",children:[e.jsx("span",{className:"history-timeline-ts",children:new Date(r.ts).toLocaleTimeString()}),e.jsx("span",{className:"history-timeline-kind",children:r.kind||"event"}),e.jsxs("span",{className:"history-timeline-msg",title:String(r.text||r.title||""),children:[r.author?`@${r.author} `:"",String(r.text??r.title??r.name??"")]})]},o))})]},t.id)}function Yp({snapshot:t}){var v,g;const s=pe(),[n,a]=f.useState(null),[i,r]=f.useState(!0),[o,l]=f.useState("1d"),[c,h]=f.useState(new Set),[m,d]=f.useState(0),u=async b=>{try{const y=b?`?since=${encodeURIComponent(b)}&limit=1000`:"?limit=1000",w=await H.get(`/history${y}`);a(w),h(new Set(w.projects.filter(S=>w.events.some($=>$.projectId===S.id)).map(S=>S.id)))}catch(y){s.error(`History load failed: ${y.message}`)}finally{r(!1)}};f.useEffect(()=>{r(!0);const b=Hs.find(y=>y.id===o)||Hs[1];if(b.ms>0){const y=new Date(Date.now()-b.ms).toISOString();u(y)}else u()},[o]),f.useEffect(()=>{const b=setInterval(()=>d(y=>y+1),3e4);return()=>clearInterval(b)},[]);const p=new Map;for(const b of(n==null?void 0:n.events)||[]){const y=b.projectId||"global";p.has(y)||p.set(y,[]),p.get(y).push(b)}const x=b=>{h(y=>{const w=new Set(y);return w.has(b)?w.delete(b):w.add(b),w})},j=()=>{if(!n)return;const b=new Blob([JSON.stringify(n,null,2)],{type:"application/json"}),y=URL.createObjectURL(b),w=document.createElement("a");w.href=y,w.download=`bizar-history-${new Date().toISOString().replace(/[:.]/g,"-")}.json`,w.click(),URL.revokeObjectURL(y),s.success("History exported.")};return e.jsxs("div",{className:"view view-history","data-tick":m,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(Zs,{size:18})," History"]}),e.jsxs("p",{className:"view-subtitle",children:["Cross-project history of events, tasks, and plans.",((v=n==null?void 0:n.stats)==null?void 0:v.lastTs)&&e.jsxs(e.Fragment,{children:[" · last event ",Ve(n.stats.lastTs)]})]})]}),e.jsxs("div",{className:"view-actions",children:[e.jsxs("div",{className:"tasks-toolbar-group",children:[e.jsx(Vu,{size:14,style:{color:"var(--text-dim)"},"aria-hidden":!0}),e.jsx("label",{htmlFor:"history-range",className:"sr-only",children:"Time range"}),e.jsx("select",{id:"history-range",className:"select select-sm",value:o,onChange:b=>l(b.target.value),title:"Time range","aria-label":"Time range",children:Hs.map(b=>e.jsx("option",{value:b.id,children:b.label},b.id))})]}),e.jsxs(U,{variant:"ghost",size:"sm",onClick:()=>{r(!0);const b=Hs.find(y=>y.id===o)||Hs[1];b.ms>0?u(new Date(Date.now()-b.ms).toISOString()):u()},children:[e.jsx(xe,{size:14})," Refresh"]}),e.jsxs(U,{variant:"secondary",size:"sm",onClick:j,children:[e.jsx(ts,{size:14})," Export"]})]})]}),i&&e.jsxs("div",{className:"view-loading",children:[e.jsx(ye,{size:"lg"}),e.jsx("p",{children:"Loading history…"})]}),!i&&n&&e.jsxs("div",{className:"history-list",children:[n.projects.length===0&&e.jsxs(se,{children:[e.jsxs(de,{children:[e.jsx(lt,{size:14})," No projects"]}),e.jsx(ue,{children:"Register a project in Overview to start tracking history."})]}),n.projects.length>0&&e.jsx(qo,{items:n.projects,itemHeight:70,height:Math.min(n.projects.length*70,500),className:"history-virtual-list",renderItem:b=>Gp(b,p.get(b.id)||[],c,x)}),p.has("global")&&e.jsxs(se,{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(Zs,{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((b,y)=>e.jsxs("div",{className:"history-timeline-row",children:[e.jsx("span",{className:"history-timeline-ts",children:new Date(b.ts).toLocaleTimeString()}),e.jsx("span",{className:"history-timeline-kind",children:b.kind||"event"}),e.jsxs("span",{className:"history-timeline-msg",title:String(b.text||b.title||""),children:[b.author?`@${b.author} `:"",String(b.text??b.title??b.name??"")]})]},y))})]}),((g=n.stats)==null?void 0:g.counts)&&Object.keys(n.stats.counts).length>0&&e.jsxs(se,{children:[e.jsx(de,{children:"Event counts by kind"}),e.jsxs(ue,{children:[n.stats.lines," total lines in log"]}),e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:8,marginTop:8},children:Object.entries(n.stats.counts).sort((b,y)=>y[1]-b[1]).slice(0,30).map(([b,y])=>e.jsxs("span",{className:te("tag","tag-neutral"),style:{fontFamily:"var(--font-mono)"},children:[b,": ",y]},b))})]})]})]})}const Ee={top:16,right:20,bottom:40,left:52};function Xp({series:t,height:s=280,onHover:n,className:a}){const i=f.useRef(null),[r,o]=f.useState(null),{labels:l,requests:c,tokens:h}=t,m=l.length;if(m===0)return e.jsx("div",{className:te("usage-chart-empty",a),style:{height:s},children:e.jsx("span",{children:"No data for this range"})});const d=600-Ee.left-Ee.right,u=s-Ee.top-Ee.bottom,p=Math.max(...c,1),x=Math.max(...h,1),j=Math.max(4,Math.min(24,Math.floor(d/m)-4)),v=(d-j*m)/(m+1);function g(_){return Ee.left+v+_*(j+v)}function b(_){return _/p*u*.75}function y(_){return Ee.top+u-_/x*u*.75}const w=h.map((_,P)=>`${g(P)+j/2},${y(_)}`).join(" "),S=[0,.25,.5,.75,1].map(_=>({y:Ee.top+u-_*u*.75,label:_===0?"0":`${Math.round(p*_).toLocaleString()}`})),$=[0,.25,.5,.75,1].map(_=>({y:Ee.top+u-_*u*.75,label:_===0?"0":`${Math.round(x*_/1e3)}k`})),M=Math.max(1,Math.floor(m/7)),z=l.map((_,P)=>({i:P,l:_,x:g(P)+j/2})).filter((_,P)=>P%M===0),A=f.useCallback(_=>{if(!i.current)return;const P=i.current.getBoundingClientRect(),N=(_.clientX-P.left)*(600/P.width),T=(_.clientY-P.top)*(s/P.height),L=N-Ee.left,R=Math.round((L-v/2)/(j+v)),F=Math.max(0,Math.min(m-1,R));o({index:F,x:_.clientX-P.left,y:_.clientY-P.top}),n==null||n(F,N,T)},[m,j,v,n,s]),k=f.useCallback(()=>{o(null),n==null||n(null,0,0)},[n]),C=r;return e.jsxs("div",{ref:i,className:te("usage-chart",a),style:{position:"relative"},children:[e.jsxs("svg",{viewBox:`0 0 600 ${s}`,width:"100%",height:s,style:{display:"block",overflow:"visible"},onMouseMove:A,onMouseLeave:k,children:[S.map((_,P)=>e.jsx("line",{x1:Ee.left,y1:_.y,x2:600-Ee.right,y2:_.y,stroke:"var(--border)",strokeWidth:1,strokeDasharray:"4,3",opacity:.5},`grid-${P}`)),S.map((_,P)=>e.jsx("text",{x:Ee.left-6,y:_.y+4,textAnchor:"end",fontSize:10,fill:"var(--text-muted)",fontFamily:"var(--font-mono, ui-monospace, monospace)",children:_.label},`ly-${P}`)),$.map((_,P)=>e.jsx("text",{x:600-Ee.right+6,y:_.y+4,textAnchor:"start",fontSize:10,fill:"var(--text-muted)",fontFamily:"var(--font-mono, ui-monospace, monospace)",children:_.label},`ry-${P}`)),c.map((_,P)=>{const N=b(_),T=g(P),L=Ee.top+u-N;return e.jsx("rect",{x:T,y:L,width:j,height:N,rx:2,fill:((C==null?void 0:C.index)===P,"var(--accent)"),opacity:(C==null?void 0:C.index)===P?1:.75,style:{transition:"opacity 120ms ease"}},`bar-${P}`)}),e.jsx("polyline",{points:w,fill:"none",stroke:"var(--warning, #d29922)",strokeWidth:2,strokeLinejoin:"round",strokeLinecap:"round",opacity:.9}),h.map((_,P)=>e.jsx("circle",{cx:g(P)+j/2,cy:y(_),r:(C==null?void 0:C.index)===P?5:3,fill:"var(--warning, #d29922)",opacity:(C==null?void 0:C.index)===P?1:.7,style:{transition:"r 120ms ease"}},`dot-${P}`)),z.map(({i:_,l:P,x:N})=>e.jsx("text",{x:N,y:Ee.top+u+18,textAnchor:"middle",fontSize:10,fill:"var(--text-muted)",fontFamily:"var(--font-mono, ui-monospace, monospace)",children:P},`xl-${_}`)),e.jsx("line",{x1:Ee.left,y1:Ee.top+u,x2:600-Ee.right,y2:Ee.top+u,stroke:"var(--border)",strokeWidth:1})]}),C!==null&&e.jsxs("div",{className:"usage-chart-tooltip",style:{left:Math.min(C.x+12,460),top:C.y-60},children:[e.jsx("div",{className:"usage-tooltip-date",children:l[C.index]}),e.jsxs("div",{className:"usage-tooltip-row",children:[e.jsx("span",{className:"usage-tooltip-dot",style:{background:"var(--accent)"}}),e.jsx("span",{children:"Requests:"}),e.jsx("strong",{children:c[C.index].toLocaleString()})]}),e.jsxs("div",{className:"usage-tooltip-row",children:[e.jsx("span",{className:"usage-tooltip-dot",style:{background:"var(--warning, #d29922)"}}),e.jsx("span",{children:"Tokens:"}),e.jsx("strong",{children:h[C.index].toLocaleString()})]})]})]})}function Wt({label:t,col:s,sortKey:n,sortDir:a,onSort:i}){const r=n===s;return e.jsxs("th",{className:te("usage-sort-header",r&&"is-active"),onClick:()=>i(s),"aria-sort":r?a==="asc"?"ascending":"descending":"none",children:[e.jsx("span",{children:t}),e.jsx("span",{className:"usage-sort-icon",children:r?a==="asc"?" ↑":" ↓":" ↕"})]})}function Kp({rows:t,sortKey:s,sortDir:n,onSort:a}){return e.jsx("div",{className:"usage-table-wrap",children:e.jsxs("table",{className:"usage-table",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx(Wt,{label:"Model",col:"modelId",sortKey:s,sortDir:n,onSort:a}),e.jsx(Wt,{label:"Requests",col:"requests",sortKey:s,sortDir:n,onSort:a}),e.jsx(Wt,{label:"Prompt Tok",col:"promptTokens",sortKey:s,sortDir:n,onSort:a}),e.jsx(Wt,{label:"Compl Tok",col:"completionTokens",sortKey:s,sortDir:n,onSort:a}),e.jsx(Wt,{label:"Total Tok",col:"totalTokens",sortKey:s,sortDir:n,onSort:a}),e.jsx(Wt,{label:"Avg Latency",col:"avgLatencyMs",sortKey:s,sortDir:n,onSort:a}),e.jsx(Wt,{label:"Errors",col:"errors",sortKey:s,sortDir:n,onSort:a})]})}),e.jsx("tbody",{children:t.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:7,className:"usage-table-empty",children:"No data for this range"})}):t.map(i=>e.jsxs("tr",{children:[e.jsx("td",{className:"usage-table-model",children:e.jsx("code",{children:i.modelId})}),e.jsx("td",{className:"mono",children:i.requests.toLocaleString()}),e.jsx("td",{className:"mono",children:i.promptTokens.toLocaleString()}),e.jsx("td",{className:"mono",children:i.completionTokens.toLocaleString()}),e.jsx("td",{className:"mono",children:i.totalTokens.toLocaleString()}),e.jsxs("td",{className:"mono",children:[i.avgLatencyMs,"ms"]}),e.jsx("td",{className:te("mono",i.errors>0&&"is-err"),children:i.errors>0?i.errors:"—"})]},`${i.providerId}::${i.modelId}`))})]})})}function Zp({activeTab:t,setActiveTab:s}){const[n,a]=f.useState("quota"),i=pe();return e.jsxs("div",{className:"view-container view-minimax-usage",children:[e.jsxs("div",{className:"minimax-sub-tabs",children:[e.jsxs("button",{className:te("minimax-sub-tab",n==="quota"&&"is-active"),onClick:()=>a("quota"),children:[e.jsx(Ei,{size:13})," Token Plan"]}),e.jsxs("button",{className:te("minimax-sub-tab",n==="analytics"&&"is-active"),onClick:()=>a("analytics"),children:[e.jsx(Ko,{size:13})," Usage Analytics"]})]}),n==="quota"?e.jsx(Qp,{activeTab:t,setActiveTab:s}):e.jsx(Jp,{toast:i})]})}function Qp({activeTab:t,setActiveTab:s}){var W;const n=pe(),[a,i]=f.useState(null),[r,o]=f.useState(null),[l,c]=f.useState(null),[h,m]=f.useState(!0),[d,u]=f.useState(!1),[p,x]=f.useState(null),[j,v]=f.useState(null),[g,b]=f.useState(!1),[y,w]=f.useState(0),[S,$]=f.useState(!1),[M,z]=f.useState(null),[A,k]=f.useState(""),[C,_]=f.useState(!1),[P,N]=f.useState(!1),T=f.useCallback(async()=>{m(!0),x(null);try{const[V,X,J]=await Promise.all([H.get("/minimax/status"),H.get("/minimax/remains"),H.get("/minimax/onboarding")]);i(V),o(X),c(J),V.configured&&w(4)}catch(V){x(V.message||"Failed to load MiniMax data")}finally{m(!1)}},[]);f.useEffect(()=>{T()},[T]);const L=f.useCallback(async()=>{try{await H.post("/minimax/onboarding",{dismissedAt:Date.now()}),c(V=>V&&{...V,dismissedAt:Date.now()})}catch{}},[]),R=f.useCallback(async()=>{if(!A.trim()){n.error("Paste a Subscription Key first.");return}$(!0),z(null);try{const V=await H.post("/minimax/test",{prompt:"Reply with a single word: pong",model:"MiniMax-M3",maxTokens:16});if(z(V),V.ok){w(3),n.success("Key works. Saving…");try{await H.post("/minimax/onboarding/save-key",{key:A.trim(),groupId:"default"}),E(),n.success("Subscription Key saved.")}catch(X){n.error(`Save failed: ${X.message}`)}T()}else n.error(`Verification failed: ${V.message??V.error??"unknown"}`)}catch(V){n.error(`Test request failed: ${V.message}`)}finally{$(!1)}},[A,n,T]),F=f.useCallback(async()=>{if(!A.trim()){n.error("Paste a Subscription Key first.");return}N(!0);try{const V=await H.post("/minimax/onboarding/save-key",{key:A.trim(),groupId:"default"});if(!V.ok){n.error(`Save failed: ${V.message??V.error??"unknown"}`);return}k(""),E(),n.success("Subscription Key saved. Loading quota…"),T()}catch(V){n.error(`Save failed: ${V.message}`)}finally{N(!1)}},[A,n,T]),E=f.useCallback(async()=>{try{await H.del("/minimax/cache")}catch{}},[]),D=f.useCallback(async()=>{u(!0),x(null);try{await H.post("/minimax/remains/refresh"),await T(),n.success("Refreshed")}catch(V){n.error(`Refresh failed: ${V.message}`)}finally{u(!1)}},[T,n]),G=f.useCallback(async()=>{var V;b(!0),v(null);try{const X=await H.post("/minimax/test",{prompt:"Reply with a single word: pong",model:"MiniMax-M3",maxTokens:16});v(X),X.ok?n.success(`Test ok — used ${((V=X.usage)==null?void 0:V.total_tokens)??"?"} tokens`):n.error(`Test failed: ${X.message??X.error??"unknown"}`)}catch(X){n.error(`Test request failed: ${X.message}`)}finally{b(!1)}},[n]);return h&&!a?e.jsxs("div",{className:"view-container",children:[e.jsx(ye,{})," Loading MiniMax data…"]}):a?!a.configured&&(l==null?void 0:l.dismissedAt)==null&&y<4?e.jsx(sx,{step:y,setStep:w,keyDraft:A,setKeyDraft:k,showKey:C,setShowKey:_,verifying:S,verifyResult:M,onVerify:R,onSkip:async()=>{await L(),n.success("Skipped.")},onManualKeySave:F,savingKey:P,status:a}):e.jsxs(e.Fragment,{children:[e.jsxs("header",{className:"view-header",children:[e.jsxs("div",{className:"view-header-titles",children:[e.jsxs("h1",{className:"view-title",children:[e.jsx(Ei,{size:20,style:{verticalAlign:"text-bottom",marginRight:6}}),"MiniMax Token Plan"]}),e.jsxs("p",{className:"view-subtitle",children:["Remaining 5-hour + weekly quota per model. Fetches live from"," ",e.jsx("code",{children:"www.minimax.io/v1/token_plan/remains"}),"."]})]}),e.jsxs("div",{className:"view-header-actions",children:[e.jsxs(U,{variant:"secondary",size:"sm",onClick:()=>s("settings"),title:"Configure your Subscription Key",children:[e.jsx(zi,{size:14})," ",a.configured?`Key ${a.apiKeyHint}`:"Add key"]}),e.jsxs(U,{variant:"secondary",size:"sm",onClick:D,disabled:d,children:[d?e.jsx(je,{size:14,className:"spin"}):e.jsx(xe,{size:14})," Refresh"]})]})]}),r&&!r.ok&&e.jsxs("div",{className:"banner banner-err",children:[e.jsx(qe,{size:16}),e.jsxs("span",{children:[e.jsx("strong",{children:"Couldn't load quota"}),": ",r.message??r.error??"unknown error"]})]}),(r==null?void 0:r.ok)&&r.models&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"minimax-stats-row",children:[e.jsx(zn,{label:"Models tracked",value:String(r.models.length),hint:"Distinct model quotas returned by the API"}),e.jsx(zn,{label:"Last fetched",value:r.fetchedAt?tx(r.fetchedAt):"—",hint:"Refreshed on demand + every 60s"}),e.jsx(zn,{label:"Group",value:r.groupId??"—",hint:"Usually 'default' for an individual team"}),e.jsx(zn,{label:"API key",value:r.apiKeyHint??"—",hint:"Masked; the real key never leaves auth.json"})]}),e.jsx("div",{className:"minimax-models-grid",children:r.models.map(V=>e.jsx(ex,{model:V},V.model_name))})]}),a.configured&&e.jsxs(se,{id:"minimax-test",children:[e.jsxs(de,{children:[e.jsx(Rt,{size:14})," Test the API key"]}),e.jsxs(ue,{children:["One-shot chat completion to ",e.jsxs("code",{children:[a.chatBaseUrl,"/chat/completions"]}),"."]}),e.jsxs("div",{className:"minimax-test-actions",children:[e.jsxs(U,{onClick:G,disabled:g,variant:"primary",size:"sm",children:[g?e.jsx(je,{size:14,className:"spin"}):e.jsx(Rt,{size:14})," Send test prompt"]}),e.jsx("code",{className:"minimax-test-prompt",children:'"Reply with a single word: pong"'})]}),j&&e.jsxs("div",{className:te("minimax-test-result",j.ok?"ok":"err"),children:[j.ok?e.jsx(Ze,{size:14}):e.jsx(qe,{size:14}),e.jsx("div",{className:"minimax-test-body",children:j.ok?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"minimax-test-line",children:[e.jsx("strong",{children:"model:"})," ",e.jsx("code",{children:j.model})," ·"," ",e.jsx("strong",{children:"finish:"})," ",j.finishReason??"—"]}),j.content&&e.jsx("div",{className:"minimax-test-content",children:e.jsx("code",{children:j.content})}),j.usage&&e.jsxs("div",{className:"minimax-test-usage",children:[e.jsx("strong",{children:"usage:"})," total ",e.jsx("code",{children:j.usage.total_tokens??"?"})," · prompt"," ",e.jsx("code",{children:j.usage.prompt_tokens??"?"})," · completion"," ",e.jsx("code",{children:j.usage.completion_tokens??"?"}),((W=j.usage.prompt_tokens_details)==null?void 0:W.cached_tokens)!=null&&e.jsxs(e.Fragment,{children:[" · cached ",e.jsx("code",{children:j.usage.prompt_tokens_details.cached_tokens})]})]})]}):e.jsx("pre",{children:j.message??j.error??"unknown error"})})]})]})]}):e.jsx("div",{className:"view-container",children:e.jsxs("div",{className:"error-card",children:[e.jsx(qe,{size:20}),e.jsxs("div",{children:[e.jsx("strong",{children:"Couldn't load MiniMax status"}),e.jsx("pre",{children:p??"unknown error"})]})]})})}function Jp({toast:t}){const[s,n]=f.useState("24h"),[a,i]=f.useState(""),[r,o]=f.useState(""),[l,c]=f.useState(!0),[h,m]=f.useState(null),[d,u]=f.useState([]),[p,x]=f.useState("requests"),[j,v]=f.useState("desc"),[g,b]=f.useState(!1),y=f.useCallback(async(C,_,P)=>{c(!0);try{const N=new URLSearchParams({range:C});C==="custom"&&_&&P&&(N.set("from",String(_)),N.set("to",String(P)));const[T,L]=await Promise.all([H.get(`/usage?${N.toString()}`),H.get("/usage/recent?limit=20")]);m(T),u(L.records)}catch(N){t.error(`Failed to load usage data: ${N.message}`)}finally{c(!1)}},[t]);f.useEffect(()=>{if(s==="custom"){const C=a?new Date(a).getTime():Date.now()-6048e5,_=r?new Date(r).getTime():Date.now();y("custom",C,_)}else y(s)},[s,y]);const w=f.useCallback(C=>{p===C?v(_=>_==="asc"?"desc":"asc"):(x(C),v("desc"))},[p]),S=f.useMemo(()=>h!=null&&h.perModel?[...h.perModel].sort((C,_)=>{const P=C[p]??0,N=_[p]??0,T=typeof P=="number"&&typeof N=="number"?P-N:String(P).localeCompare(String(N));return j==="asc"?T:-T}):[],[h==null?void 0:h.perModel,p,j]),$=f.useMemo(()=>h!=null&&h.daily?{labels:h.daily.map(C=>C.date.slice(5)),requests:h.daily.map(C=>C.requests),tokens:h.daily.map(C=>C.totalTokens)}:{labels:[],requests:[],tokens:[]},[h==null?void 0:h.daily]),M=f.useCallback(async()=>{b(!0),await y(s==="custom"?"custom":s,s==="custom"&&a?new Date(a).getTime():void 0,s==="custom"&&r?new Date(r).getTime():void 0),b(!1)},[y,s,a,r]);if(l&&!h)return e.jsxs("div",{className:"view-container",children:[e.jsx(ye,{})," Loading usage data…"]});const z=h==null?void 0:h.totals,A=(h==null?void 0:h.errors)??[],k=(h==null?void 0:h.perKey)??[];return e.jsxs(e.Fragment,{children:[e.jsxs("header",{className:"view-header",children:[e.jsxs("div",{className:"view-header-titles",children:[e.jsxs("h1",{className:"view-title",children:[e.jsx(Ko,{size:20,style:{verticalAlign:"text-bottom",marginRight:6}}),"Usage Analytics"]}),e.jsxs("p",{className:"view-subtitle",children:["Aggregated from ",e.jsx("code",{children:"~/.local/share/bizar/usage.jsonl"})," — every chatCompletion and fetchRemains call."]})]}),e.jsx("div",{className:"view-header-actions",children:e.jsxs(U,{variant:"secondary",size:"sm",onClick:M,disabled:g,children:[g?e.jsx(je,{size:14,className:"spin"}):e.jsx(xe,{size:14})," Refresh"]})})]}),e.jsxs("div",{className:"usage-time-range",children:[["24h","7d","30d","custom"].map(C=>e.jsx("button",{className:te("usage-range-chip",s===C&&"is-active"),onClick:()=>n(C),children:C==="custom"?"Custom":C.toUpperCase()},C)),s==="custom"&&e.jsxs("div",{className:"usage-custom-dates",children:[e.jsx("label",{htmlFor:"usage-from-date",className:"sr-only",children:"From date"}),e.jsx("input",{id:"usage-from-date",type:"date",className:"usage-date-input",value:a,onChange:C=>i(C.target.value),"aria-label":"From date"}),e.jsx("span",{style:{color:"var(--text-muted)",fontSize:12},"aria-hidden":!0,children:"to"}),e.jsx("label",{htmlFor:"usage-to-date",className:"sr-only",children:"To date"}),e.jsx("input",{id:"usage-to-date",type:"date",className:"usage-date-input",value:r,onChange:C=>o(C.target.value),"aria-label":"To date"})]})]}),e.jsxs("div",{className:"usage-kpi-row",children:[e.jsx(Vs,{label:"Total Requests",value:(z==null?void 0:z.requests.toLocaleString())??"—",sub:z?`${z.errors} errors`:void 0,tone:z&&z.errors>z.requests*.1?"warn":void 0}),e.jsx(Vs,{label:"Total Tokens",value:z?z.totalTokens>=1e3?`${Math.round(z.totalTokens/1e3)}k`:String(z.totalTokens):"—",sub:z?`${z.promptTokens.toLocaleString()} prompt · ${z.completionTokens.toLocaleString()} completion`:void 0}),e.jsx(Vs,{label:"Errors",value:String((z==null?void 0:z.errors)??"—"),sub:A.length>0?`${A[0].code}: ${A[0].count}`:void 0,tone:z&&z.errors>0?"err":void 0}),e.jsx(Vs,{label:"Avg Latency",value:(z==null?void 0:z.avgLatencyMs)!=null?`${z.avgLatencyMs}ms`:"—",sub:(z==null?void 0:z.p95LatencyMs)!=null?`p95 ${z.p95LatencyMs}ms`:void 0}),e.jsx(Vs,{label:"Est. Cost",value:(z==null?void 0:z.costEstimate)!=null&&z.costEstimate>0?`$${z.costEstimate.toFixed(4)}`:"—",sub:"approximate USD",tone:void 0})]}),e.jsxs(se,{className:"usage-chart-card",children:[e.jsx("div",{className:"usage-chart-wrap",children:e.jsx(Xp,{series:$,height:280})}),e.jsxs("div",{className:"usage-legend",children:[e.jsxs("div",{className:"usage-legend-item",children:[e.jsx("div",{className:"usage-legend-bar",style:{background:"var(--accent)"}}),e.jsx("span",{children:"Requests (bar)"})]}),e.jsxs("div",{className:"usage-legend-item",children:[e.jsx("div",{className:"usage-legend-line",style:{background:"var(--warning, #d29922)"}}),e.jsx("span",{children:"Tokens (line)"})]})]})]}),e.jsxs(se,{children:[e.jsx(de,{children:"Per-model breakdown"}),e.jsx(Kp,{rows:S,sortKey:p,sortDir:j,onSort:w})]}),k.length>0&&e.jsxs(se,{children:[e.jsx(de,{children:"API Keys"}),e.jsx("div",{className:"usage-key-row",children:k.map(C=>e.jsxs("span",{className:te("usage-key-badge",C.isBackup?"is-backup":"is-active"),children:[e.jsx("span",{className:"usage-key-dot"}),C.keyEnvVar,C.isBackup?" (backup)":" (active)"," · ",C.requests," req"]},C.keyEnvVar))})]}),d.length>0&&e.jsxs(se,{children:[e.jsx(de,{children:"Recent activity"}),e.jsx("div",{className:"usage-recent-list",children:d.map((C,_)=>e.jsxs("div",{className:te("usage-recent-item",C.error&&"is-err"),children:[e.jsx("span",{className:"usage-recent-time",children:new Date(C.ts).toLocaleTimeString()}),e.jsx("span",{className:"usage-recent-model",children:e.jsx("code",{children:C.modelId})}),e.jsxs("span",{className:"usage-recent-tokens",children:[C.totalTokens.toLocaleString()," tok"]}),e.jsxs("span",{className:"usage-recent-latency",children:[C.latencyMs,"ms"]}),e.jsx("span",{className:"usage-recent-endpoint",children:C.endpoint})]},`${C.requestId}-${_}`))})]})]})}function Vs({label:t,value:s,sub:n,tone:a}){return e.jsxs("div",{className:"usage-kpi-card",children:[e.jsx("div",{className:"usage-kpi-label",children:t}),e.jsx("div",{className:te("usage-kpi-value",a&&`is-${a}`),children:s}),n&&e.jsx("div",{className:"usage-kpi-sub",children:n})]})}function zn({label:t,value:s,hint:n}){return e.jsxs("div",{className:"stat",children:[e.jsx("div",{className:"stat-label",children:t}),e.jsx("div",{className:"stat-value",children:s}),n&&e.jsx("div",{className:"stat-hint",children:n})]})}function ex({model:t}){const s=Mn(t.current_interval_remaining_percent??0,0,100),n=Mn(t.current_weekly_remaining_percent??0,0,100),a=Mn(100-s,0,100),i=Mn(100-n,0,100);return e.jsxs(se,{id:`minimax-model-${t.model_name}`,className:"minimax-model-card",children:[e.jsxs("div",{className:"minimax-model-head",children:[e.jsx("div",{className:"minimax-model-name",children:t.model_name}),e.jsxs("div",{className:te("minimax-model-status",s<25||n<25?"is-warn":"is-ok"),children:[t.current_interval_status===1?"active":"idle"," ·"," ",t.current_weekly_status===1?"week active":"week idle"]})]}),e.jsxs("div",{className:"minimax-quota-rows",children:[e.jsx(Er,{icon:e.jsx(He,{size:12}),label:"5-hour rolling",remainingPct:s,consumedPct:a,used:t.current_interval_usage_count??0,total:t.current_interval_total_count??0,resetIn:t.intervalResetInHuman,resetISO:t.endTimeISO}),e.jsx(Er,{icon:e.jsx($u,{size:12}),label:"Weekly",remainingPct:n,consumedPct:i,used:t.current_weekly_usage_count??0,total:t.current_weekly_total_count??0,resetIn:t.weeklyResetInHuman,resetISO:t.weeklyEndTimeISO})]})]})}function Er({icon:t,label:s,remainingPct:n,consumedPct:a,used:i,total:r,resetIn:o,resetISO:l}){const c=n>=75?"good":n>=25?"warn":"low";return e.jsxs("div",{className:`minimax-quota-row is-${c}`,children:[e.jsxs("div",{className:"minimax-quota-head",children:[e.jsxs("span",{className:"minimax-quota-label",children:[t," ",s]}),e.jsxs("span",{className:"minimax-quota-remaining",children:[n,"% remaining"]}),e.jsxs("span",{className:"minimax-quota-consumed",children:["· ",a,"% used"]})]}),e.jsx("div",{className:"minimax-bar",children:e.jsx("div",{className:"minimax-bar-fill",style:{width:`${a}%`},"aria-label":`${a}% consumed`})}),e.jsxs("div",{className:"minimax-quota-meta",children:[e.jsxs("span",{children:[e.jsx("strong",{children:i})," / ",r||"—"," requests"]}),e.jsx("span",{title:l,children:o?`resets in ${o}`:"—"})]})]})}function Mn(t,s,n){return Math.max(s,Math.min(n,t))}function tx(t){const s=Date.now()-t;return s<5e3?"just now":s<6e4?`${Math.floor(s/1e3)}s ago`:s<36e5?`${Math.floor(s/6e4)}m ago`:`${Math.floor(s/36e5)}h ago`}function sx({step:t,setStep:s,keyDraft:n,setKeyDraft:a,showKey:i,setShowKey:r,verifying:o,verifyResult:l,onVerify:c,onSkip:h,onManualKeySave:m,savingKey:d,status:u}){return e.jsxs("div",{className:"view-container view-minimax-onboarding",children:[e.jsxs("header",{className:"view-header",children:[e.jsxs("div",{className:"view-header-titles",children:[e.jsxs("h1",{className:"view-title",children:[e.jsx(vt,{size:20,style:{verticalAlign:"text-bottom",marginRight:6}}),"Set up MiniMax Token Plan tracking"]}),e.jsx("p",{className:"view-subtitle",children:"We'll read your Subscription Key and show your remaining quota."})]}),e.jsx("div",{className:"view-header-actions",children:e.jsxs(U,{variant:"ghost",size:"sm",onClick:h,children:[e.jsx(Ie,{size:14})," Skip for now"]})})]}),e.jsx("div",{className:"minimax-wizard-stepper",children:["Welcome","Get a key","Paste & test","Done"].map((p,x)=>e.jsxs("div",{className:te("minimax-wizard-step",x===t&&"is-current",x<t&&"is-done",x>t&&"is-todo"),children:[e.jsx("div",{className:"minimax-wizard-step-bullet",children:x<t?e.jsx(Ze,{size:14}):x+1}),e.jsx("div",{className:"minimax-wizard-step-label",children:p})]},p))}),e.jsxs(se,{id:"minimax-wizard-card",children:[t===0&&e.jsxs("div",{className:"minimax-wizard-body",children:[e.jsx("h3",{className:"minimax-wizard-title",children:"Welcome"}),e.jsxs("p",{className:"minimax-wizard-prose",children:["BizarHarness shows you how much of your MiniMax Token Plan quota you have left — both the ",e.jsx("strong",{children:"5-hour rolling"})," and ",e.jsx("strong",{children:"weekly"})," windows."]}),e.jsxs("ul",{className:"minimax-wizard-list",children:[e.jsxs("li",{children:["Stored in ",e.jsx("code",{children:"~/.local/share/cline/auth.json"}),"."]}),e.jsx("li",{children:"Read fresh on every dashboard load."}),e.jsx("li",{children:"Never logged in full."})]}),e.jsx("div",{className:"minimax-wizard-actions",children:e.jsxs(U,{onClick:()=>s(1),variant:"primary",size:"md",children:["Get started ",e.jsx("span",{style:{marginLeft:6},children:"→"})]})})]}),t===1&&e.jsxs("div",{className:"minimax-wizard-body",children:[e.jsx("h3",{className:"minimax-wizard-title",children:"Get your Subscription Key"}),e.jsx("p",{className:"minimax-wizard-prose",children:"Go to the MiniMax console and copy your Subscription Key."}),e.jsxs("ol",{className:"minimax-wizard-list",children:[e.jsxs("li",{children:["Open ",e.jsxs("a",{href:"https://platform.minimax.io/user-center/payment/token-plan",target:"_blank",rel:"noreferrer",className:"minimax-wizard-link",children:[e.jsx(Is,{size:12})," platform.minimax.io"]})]}),e.jsxs("li",{children:["Click ",e.jsx("strong",{children:"Copy Subscription Key"}),"."]}),e.jsx("li",{children:"Come back here and paste it."})]}),e.jsxs("div",{className:"minimax-wizard-actions",children:[e.jsx(U,{variant:"secondary",size:"md",onClick:()=>s(0),children:"← Back"}),e.jsxs(U,{variant:"primary",size:"md",onClick:()=>s(2),children:["I have my key ",e.jsx("span",{style:{marginLeft:6},children:"→"})]})]})]}),t===2&&e.jsxs("div",{className:"minimax-wizard-body",children:[e.jsx("h3",{className:"minimax-wizard-title",children:"Paste & test"}),e.jsx("p",{className:"minimax-wizard-prose",children:"Paste your key below. We'll test it against the real API before saving."}),e.jsx("div",{className:"minimax-key-row",children:e.jsxs("div",{className:"minimax-key-input-wrap",children:[e.jsx(zi,{size:12,className:"minimax-key-icon","aria-hidden":!0}),e.jsx("label",{htmlFor:"minimax-key-input",className:"sr-only",children:"Subscription Key"}),e.jsx("input",{id:"minimax-key-input",type:i?"text":"password",value:n,onChange:p=>a(p.target.value),placeholder:"sk-cp-...",spellCheck:!1,autoComplete:"off",className:"minimax-key-input",autoFocus:!0,"aria-label":"Subscription Key"}),e.jsx("button",{type:"button",onClick:()=>r(p=>!p),className:"minimax-key-toggle","aria-label":i?"Hide key":"Show key",children:i?e.jsx(si,{size:13}):e.jsx(ks,{size:13})})]})}),l&&!l.ok&&e.jsxs("div",{className:"minimax-wizard-error",children:[e.jsx(qe,{size:14}),e.jsxs("span",{children:[e.jsx("strong",{children:"Verification failed:"})," ",l.message??l.error]})]}),e.jsxs("div",{className:"minimax-wizard-actions",children:[e.jsx(U,{variant:"secondary",size:"md",onClick:()=>s(1),children:"← Back"}),e.jsxs(U,{variant:"primary",size:"md",onClick:c,disabled:o||!n.trim(),children:[o?e.jsx(je,{size:14,className:"spin"}):e.jsx(en,{size:14}),o?"Testing…":"Test & save key"]})]}),e.jsxs("p",{className:"minimax-wizard-prose minimax-wizard-prose--muted",children:["Don't want to test first? ",e.jsx("a",{href:"#",onClick:p=>{p.preventDefault(),m()},className:"minimax-wizard-link",children:"Save without testing"})]})]}),t===3&&e.jsxs("div",{className:"minimax-wizard-body",children:[e.jsxs("h3",{className:"minimax-wizard-title",children:[e.jsx(Ze,{size:18,style:{verticalAlign:"text-bottom",marginRight:6}}),"All set"]}),e.jsx("p",{className:"minimax-wizard-prose",children:"The key works and is saved. Reloading so you can see your live quota."}),e.jsx("div",{className:"minimax-wizard-actions",children:e.jsx(U,{variant:"primary",size:"md",onClick:()=>window.location.reload(),children:"View your quota →"})})]}),e.jsxs("div",{className:"minimax-wizard-footer",children:[e.jsx(en,{size:11}),e.jsxs("span",{children:["Key written to ",e.jsx("code",{children:"~/.local/share/cline/auth.json"})," with mode 0600."]})]})]})]})}const nx=rt.memo(Zp),ax={pending:"info",running:"accent",done:"success",failed:"error",killed:"neutral",timed_out:"warning"},ix={pending:"Pending",running:"Running",done:"Done",failed:"Failed",killed:"Killed",timed_out:"Timed out"};function rx({status:t,dot:s}){const n=ax[t]||"neutral",a=ix[t]||t;return e.jsx(ma,{kind:n,dot:s,children:a})}function ox({instanceId:t,instanceName:s,onConfirm:n,onClose:a}){return e.jsxs("div",{children:[e.jsxs("p",{style:{marginBottom:16,lineHeight:1.6},children:["Instance ",e.jsx("code",{children:t}),s?e.jsxs(e.Fragment,{children:[" (",s,")"]}):null," will be terminated. This cannot be undone."]}),e.jsxs("div",{style:{display:"flex",gap:8,justifyContent:"flex-end"},children:[e.jsx(U,{variant:"ghost",onClick:a,children:"Cancel"}),e.jsx(U,{variant:"danger",onClick:async()=>{await n(),a()},children:"Kill"})]})]})}function lx(t,s,n,a,i){t.open({title:"Kill instance?",width:400,children:e.jsx(ox,{instanceId:n,instanceName:a,onConfirm:async()=>{try{const o=await(await fetch(`/api/background/${encodeURIComponent(n)}`,{method:"DELETE"})).json();o.ok?(s.success(`Instance ${n} killed.`),i==null||i()):s.error(`Kill failed: ${o.error||"unknown error"}`)}catch(r){s.error(`Kill failed: ${r.message}`)}},onClose:()=>t.close()})})}function cx({instance:t}){const s=pe(),[n,a]=f.useState(!1),i=t.tmuxSession,r=i?`tmux attach -t ${i}`:null,o=async()=>{if(r)try{await navigator.clipboard.writeText(r),s.success("Attach command copied")}catch{s.error("Could not copy to clipboard")}},l=async()=>{if(!(!t.instanceId||!i)){a(!0);try{const c=await H.post(`/background/${encodeURIComponent(t.instanceId)}/open-terminal`,{emulator:"system"});if(c.ok)s.success("Opening terminal…");else if(s.error(c.error||"Failed to open terminal"),r)try{await navigator.clipboard.writeText(r),s.success("Command copied to clipboard")}catch{}}catch(c){if(s.error(`Failed: ${c.message}`),r)try{await navigator.clipboard.writeText(r),s.success("Command copied to clipboard")}catch{}}finally{a(!1)}}};return i?e.jsxs(se,{variant:"outlined",className:"bg-tmux-card",children:[e.jsxs("div",{className:"bg-tmux-card-header",children:[e.jsx(Cs,{size:14}),e.jsx("span",{children:"tmux session"}),t.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:i}),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(U,{variant:"ghost",size:"sm",onClick:o,title:"Copy attach command",children:[e.jsx(Vt,{size:14})," Copy"]}),e.jsxs(U,{variant:"primary",size:"sm",onClick:l,loading:n,title:"Open in system terminal",children:[e.jsx(Cs,{size:14})," Open terminal"]})]})]}):e.jsxs(se,{variant:"outlined",className:"bg-tmux-card bg-tmux-card-warn",children:[e.jsxs("div",{className:"bg-tmux-card-header",children:[e.jsx(qe,{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 dx=[{name:"mimir",description:"Deep research & codebase exploration"},{name:"frigg",description:"Read-only codebase Q&A"},{name:"thor",description:"Moderate-complexity implementation"},{name:"tyr",description:"Complex feature implementation"},{name:"heimdall",description:"Quick edits & simple tasks"},{name:"odin",description:"Primary router agent"}],ux=[{label:"1 min",value:6e4},{label:"5 min",value:3e5},{label:"15 min",value:9e5},{label:"30 min",value:18e5},{label:"1 hr",value:36e5},{label:"4 hr",value:144e5}];function hx({open:t,onClose:s,onCreated:n,agents:a=dx}){var $;const i=pe(),[r,o]=f.useState((($=a[0])==null?void 0:$.name)||"mimir"),[l,c]=f.useState(""),[h,m]=f.useState(""),[d,u]=f.useState(3e5),[p,x]=f.useState(!1),[j,v]=f.useState(""),[g,b]=f.useState(!1),[y,w]=f.useState(null);if(!t)return null;const S=async M=>{if(M.preventDefault(),w(null),!l.trim()){w("Prompt is required.");return}b(!0);try{const z=j.split(",").map(C=>C.trim()).filter(C=>C.length>0),A={agent:r,prompt:l,...h.trim()?{model:h.trim()}:{},timeoutMs:d,persistent:p,maxRestarts:3,...z.length>0?{tags:z}:{}},k=await H.post("/background",A);if(k!=null&&k.error)throw new Error(k.message||k.error);i.success(`Spawned ${r} (${k.instanceId.slice(0,14)}…)`),n==null||n(k.instanceId),c(""),m(""),x(!1),v(""),s()}catch(z){w((z==null?void 0:z.message)||"Failed to spawn.")}finally{b(!1)}};return e.jsx("div",{className:"modal-backdrop",role:"dialog","aria-modal":"true",children:e.jsxs("div",{className:"modal-card spawn-modal",children:[e.jsxs("div",{className:"spawn-modal-header",children:[e.jsxs("h3",{children:[e.jsx(We,{size:18})," Spawn background agent"]}),e.jsx(U,{variant:"ghost",size:"sm",onClick:s,title:"Close",children:e.jsx(Ie,{size:14})})]}),e.jsxs("form",{onSubmit:S,className:"spawn-modal-body",children:[e.jsxs("label",{className:"field",children:[e.jsx("span",{className:"field-label",children:"Agent"}),e.jsx("select",{className:"field-input",value:r,onChange:M=>o(M.target.value),required:!0,children:a.map(M=>e.jsxs("option",{value:M.name,children:[M.name,M.description?` — ${M.description}`:""]},M.name))})]}),e.jsxs("label",{className:"field",children:[e.jsx("span",{className:"field-label",children:"Initial prompt"}),e.jsx("textarea",{className:"field-input spawn-modal-textarea",rows:5,value:l,onChange:M=>c(M.target.value),placeholder:"What do you want this agent to do?",required:!0})]}),e.jsxs("label",{className:"field",children:[e.jsx("span",{className:"field-label",children:"Model (optional)"}),e.jsx("input",{type:"text",className:"field-input",value:h,onChange:M=>m(M.target.value),placeholder:"providerID/modelID (leave blank for agent default)"})]}),e.jsxs("div",{className:"field",children:[e.jsx("span",{className:"field-label",children:"Timeout"}),e.jsx("div",{className:"spawn-modal-timeouts",children:ux.map(M=>e.jsx("button",{type:"button",className:"spawn-modal-timeout-pill"+(M.value===d?" spawn-modal-timeout-pill-active":""),onClick:()=>u(M.value),children:M.label},M.value))}),e.jsx("input",{type:"range",min:6e4,max:144e5,step:6e4,value:d,onChange:M=>u(Number(M.target.value)),className:"spawn-modal-slider"}),e.jsxs("span",{className:"muted",children:[(d/6e4).toFixed(0)," min"]})]}),e.jsxs("label",{className:"field-checkbox",children:[e.jsx("input",{type:"checkbox",checked:p,onChange:M=>x(M.target.checked)}),e.jsx("span",{children:"Persistent — auto-restart on terminal failure (max 3 attempts)"})]}),e.jsxs("label",{className:"field",children:[e.jsx("span",{className:"field-label",children:"Tags (optional, comma-separated)"}),e.jsx("input",{type:"text",className:"field-input",value:j,onChange:M=>v(M.target.value),placeholder:"e.g. refactor, urgent"})]}),y&&e.jsx("div",{className:"spawn-modal-error",children:y}),e.jsxs("div",{className:"spawn-modal-actions",children:[e.jsx(U,{variant:"ghost",size:"sm",type:"button",onClick:s,children:"Cancel"}),e.jsx(U,{variant:"primary",size:"sm",type:"submit",disabled:g,children:g?"Spawning…":"Spawn agent"})]})]})]})})}const mx=5e3,_r=3e3,fx=120,px=32e3;function xx(t){return t.status==="pending"||t.status==="running"||t.status==="paused"}function oi(t){return t.status==="paused"}function gx(t){if(!Number.isFinite(t)||t<0)return"—";const s=Math.floor(t/1e3),n=Math.floor(s/3600),a=Math.floor(s%3600/60),i=s%60;return n>0?`${n}h ${a}m ${i}s`:a>0?`${a}m ${i}s`:`${i}s`}function yx(t){const s=pe(),n=Qe(),[a,i]=f.useState([]),[r,o]=f.useState(!0),[l,c]=f.useState(null),[,h]=f.useState(0),[m,d]=f.useState(!1),u=f.useCallback(async()=>{try{const w=await H.get("/background");i(Array.isArray(w==null?void 0:w.instances)?w.instances:[]),c(null)}catch(w){c((w==null?void 0:w.message)||"Failed to load background agents.")}finally{o(!1)}},[]);f.useEffect(()=>{u();const w=setInterval(u,mx);return()=>clearInterval(w)},[u]),f.useEffect(()=>{const w=setInterval(()=>h(S=>(S+1)%1e6),1e3);return()=>clearInterval(w)},[]),f.useEffect(()=>{const w=new es,S=w.on($=>{const M=$.type;(M==="background:change"||M==="background:cleanup"||M==="bg:progress"||M==="bg:tool-call")&&u()});return()=>{S(),w.close()}},[u]);const p=a.filter(xx),x=w=>{jx(n,w)},j=async w=>{try{const S=await H.get(`/background/${encodeURIComponent(w.instanceId)}/tmux`);kx(n,S)}catch(S){s.error(`Tmux info failed: ${S.message}`)}},v=w=>{lx(n,s,w.instanceId,w.agent||w.prompt,()=>{i(S=>S.filter($=>$.instanceId!==w.instanceId))})},g=async w=>{try{const S=await H.post(`/background/${encodeURIComponent(w.instanceId)}/pause`,{});S!=null&&S.ok?s.info(`Paused ${w.instanceId.slice(0,14)}…`):s.error((S==null?void 0:S.error)||"Pause failed.")}catch(S){s.error(`Pause failed: ${S.message}`)}},b=async w=>{try{const S=await H.post(`/background/${encodeURIComponent(w.instanceId)}/resume`,{});S!=null&&S.ok?s.info(`Resumed ${w.instanceId.slice(0,14)}…`):s.error((S==null?void 0:S.error)||"Resume failed.")}catch(S){s.error(`Resume failed: ${S.message}`)}},y=w=>{Nx(n,s,w,u)};return r?e.jsx("div",{className:"bg-active-view",children:e.jsxs("div",{className:"bg-active-loading",children:[e.jsx(ye,{size:"md"}),e.jsx("span",{children:"Loading background agents…"})]})}):l?e.jsx("div",{className:"bg-active-view",children:e.jsx(Te,{icon:e.jsx(He,{size:32}),title:"Couldn't load background agents",message:l,action:e.jsxs(U,{variant:"primary",onClick:u,children:[e.jsx(xe,{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:[p.length," active · ",a.length," total in store"]})]}),e.jsxs("div",{className:"bg-active-header-actions",children:[e.jsxs(U,{variant:"primary",size:"sm",onClick:()=>d(!0),children:[e.jsx(We,{size:14})," Spawn"]}),e.jsxs(U,{variant:"ghost",size:"sm",onClick:u,title:"Refresh now",children:[e.jsx(xe,{size:14})," Refresh"]})]})]}),e.jsx(hx,{open:m,onClose:()=>d(!1),onCreated:()=>{u()}}),p.length===0?e.jsx(Te,{icon:e.jsx(He,{size:32}),title:"No active background agents",message:"Use the Spawn button above or call bizar_spawn_background from an agent.",action:e.jsxs(U,{variant:"primary",onClick:()=>d(!0),children:[e.jsx(We,{size:14})," Spawn your first agent"]})}):e.jsx("div",{className:"bg-active-list",children:p.map(w=>e.jsx(vx,{inst:w,onViewOutput:()=>x(w),onOpenTmux:()=>j(w),onKill:()=>v(w),onPause:oi(w)?void 0:()=>g(w),onResume:oi(w)?()=>b(w):void 0,onSteer:()=>y(w)},w.instanceId))})]})}function vx({inst:t,onViewOutput:s,onOpenTmux:n,onKill:a,onPause:i,onResume:r,onSteer:o}){const l=typeof t.startedAt=="number"?t.startedAt:0,c=l?St(l):"—",h=l?Date.now()-l:0,m=Oo(t.prompt,fx),d=typeof t.progress=="number"?t.progress:null;return e.jsxs(se,{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:t.instanceId}),e.jsx(rx,{status:t.status||"pending",dot:!0}),oi(t)&&e.jsxs("span",{className:"bg-active-card-paused-tag",children:[e.jsx(Au,{size:12})," paused"]})]}),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:t.agent||"unknown"})]})]}),m&&e.jsx("div",{className:"bg-active-prompt",children:m}),t.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:t.currentStep})]}),d!==null&&e.jsxs("div",{className:"progress-bar","aria-label":"Progress",children:[e.jsx("div",{className:"progress-fill",style:{width:`${d<0?100:Math.max(0,Math.min(100,d))}%`}}),e.jsxs("span",{className:"progress-label",children:[d<0?"…":`${Math.round(d)}%`,t.progressMessage?` · ${t.progressMessage}`:""]})]}),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:"})," ",gx(h)]}),e.jsxs("span",{children:[e.jsx("strong",{children:"Tool calls:"})," ",t.toolCallCount??0]}),t.processId&&e.jsxs("span",{children:[e.jsx("strong",{children:"PID:"})," ",e.jsx("code",{className:"mono",children:t.processId})]}),Array.isArray(t.tags)&&t.tags.length>0&&e.jsxs("span",{children:[e.jsx("strong",{children:"Tags:"})," ",t.tags.map((u,p)=>e.jsxs("span",{className:"tag-pill",children:[u,p<t.tags.length-1?" ":""]},u))]}),t.tmuxSession&&e.jsxs("span",{className:te(t.tmuxActive&&"bg-active-meta-tmux-live"),children:[e.jsx("strong",{children:"tmux:"})," ",e.jsx("code",{className:"mono",children:t.tmuxSession}),t.tmuxActive?" · live":""]})]}),e.jsxs("div",{className:"bg-active-actions",children:[e.jsxs(U,{variant:"secondary",size:"sm",onClick:s,children:[e.jsx(ks,{size:14})," View output"]}),i&&e.jsxs(U,{variant:"secondary",size:"sm",onClick:i,title:"Pause subprocess (POSIX)",children:[e.jsx(ki,{size:14})," Pause"]}),r&&e.jsxs(U,{variant:"secondary",size:"sm",onClick:r,title:"Resume subprocess (POSIX)",children:[e.jsx(ws,{size:14})," Resume"]}),e.jsxs(U,{variant:"ghost",size:"sm",onClick:o,title:"Steer with new instructions",children:[e.jsx(Rt,{size:14})," Steer"]}),e.jsxs(U,{variant:"ghost",size:"sm",onClick:n,children:[e.jsx(Cs,{size:14})," Open in tmux"]}),e.jsxs(U,{variant:"danger",size:"sm",onClick:a,children:[e.jsx(Fe,{size:14})," Kill"]})]}),e.jsx(cx,{instance:t})]})}function jx(t,s){t.open({title:`Output — ${s.agent||s.instanceId}`,width:720,children:e.jsx(bx,{instanceId:s.instanceId})})}function bx({instanceId:t}){const s=pe(),n=f.useRef([]),[a,i]=f.useState(""),[r,o]=f.useState(!0),[l,c]=f.useState(null),[h,m]=f.useState(!0),[d,u]=f.useState(!0),[p,x]=f.useState([]),[j,v]=f.useState(!0),g=f.useRef(null),b=f.useRef(!0),y=f.useCallback(()=>{i(n.current.join(`
|
|
407
|
+
`))},[]),w=f.useCallback(async()=>{try{const M=await H.get(`/background/${encodeURIComponent(t)}/output?lines=300`);if(m((M==null?void 0:M.available)!==!1),M!=null&&M.output&&n.current.length===0){const z=M.output.split(/\r?\n/);n.current=z.slice(-300),y()}c(null)}catch(M){c((M==null?void 0:M.message)||"Failed to load output.")}finally{o(!1)}},[t,y]);f.useEffect(()=>{w();const M=setInterval(w,_r);return()=>clearInterval(M)},[w]),f.useEffect(()=>{const M=new es;let z=!1;const A=M.onStatus(C=>{z=C==="connected",u(z)}),k=M.on(C=>{var P;const _=C;if(_.type==="bg:output"&&_.instanceId===t&&typeof _.line=="string"){n.current.push(_.line);let N=0;for(let T=n.current.length-1;T>=0;T--)if(N+=(((P=n.current[T])==null?void 0:P.length)??0)+1,N>px){n.current=n.current.slice(T+1);break}i(n.current.join(`
|
|
408
|
+
`))}});return()=>{A(),k(),M.close()}},[t]),f.useEffect(()=>{let M=!1;const z=async()=>{try{const C=await H.get(`/background/${encodeURIComponent(t)}/tool-calls`);!M&&Array.isArray(C==null?void 0:C.toolCalls)&&x(C.toolCalls)}catch{}};z();const A=new es,k=A.on(C=>{const _=C;_.type==="bg:tool-call"&&_.instanceId===t&&z()});return()=>{M=!0,k(),A.close()}},[t]),f.useEffect(()=>{var M;b.current&&((M=g.current)==null||M.scrollIntoView({behavior:"auto",block:"end"}))},[a]);const S=M=>{const z=M.currentTarget,A=z.scrollHeight-z.scrollTop-z.clientHeight<24;b.current=A},$=async()=>{try{await navigator.clipboard.writeText(a),s.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:d?`streaming · ${a.length} chars`:h?`${a.length} chars · auto-refresh ${_r/1e3}s (WS idle)`:"Output unavailable (no tmux session)"}),e.jsxs("div",{className:"bg-output-toolbar-actions",children:[e.jsx(U,{variant:"ghost",size:"sm",onClick:()=>v(M=>!M),title:"Toggle tool-call history",children:j?"Hide tools":"Show tools"}),e.jsxs(U,{variant:"ghost",size:"sm",onClick:w,title:"Refresh now",children:[e.jsx(xe,{size:14})," Refresh"]}),e.jsxs(U,{variant:"ghost",size:"sm",onClick:$,disabled:!a,children:[e.jsx(Vt,{size:14})," Copy"]})]})]}),r&&!a?e.jsxs("div",{className:"bg-output-loading",children:[e.jsx(je,{size:16,className:"spin"})," Loading…"]}):l?e.jsx("div",{className:"bg-output-error",children:l}):e.jsxs("div",{className:"bg-output-body",children:[e.jsxs("div",{className:"bg-output-scroll",onScroll:S,children:[e.jsx("pre",{className:"bg-output-pre mono",children:e.jsx("code",{children:a||e.jsx("span",{className:"muted",children:"No output captured yet — waiting for the agent to start…"})})}),e.jsx("div",{ref:g})]}),j&&e.jsx(wx,{calls:p})]})]})}function wx({calls:t}){return e.jsxs("aside",{className:"bg-tool-calls","aria-label":"Tool call history",children:[e.jsxs("h4",{className:"bg-tool-calls-title",children:["Tool calls (",t.length,")"]}),t.length===0?e.jsx("p",{className:"muted bg-tool-calls-empty",children:"No tool calls recorded yet."}):e.jsx("ol",{className:"bg-tool-calls-list",children:t.slice().reverse().map(s=>{const n=s.endedAt&&s.startedAt?`${Math.max(0,s.endedAt-s.startedAt)}ms`:"…";return e.jsxs("li",{className:`bg-tool-call bg-tool-call-${s.status}`,children:[e.jsxs("div",{className:"bg-tool-call-head",children:[e.jsx("code",{className:"mono bg-tool-call-name",children:s.name}),e.jsx("span",{className:`badge badge-${s.status==="error"?"danger":s.status==="ok"?"success":"neutral"}`,children:s.status}),e.jsx("span",{className:"bg-tool-call-dur muted",children:n})]}),s.args&&e.jsx("pre",{className:"bg-tool-call-args mono",children:s.args}),s.result&&e.jsx("pre",{className:"bg-tool-call-result mono",children:s.result.slice(0,240)}),s.error&&e.jsx("pre",{className:"bg-tool-call-error mono",children:s.error})]},s.id)})})]})}function kx(t,s){const n=s.attachCommand||s.session||"";t.open({title:"Attach to tmux",width:520,children:e.jsx(Cx,{info:s,cmd:n})})}function Nx(t,s,n,a){t.open({title:`Steer ${n.agent||n.instanceId}`,width:600,children:e.jsx(Sx,{instanceId:n.instanceId,toast:s,onCreated:a,onClose:()=>t.close()})})}function Sx({instanceId:t,toast:s,onCreated:n,onClose:a}){const[i,r]=f.useState(""),[o,l]=f.useState(!1),[c,h]=f.useState(null),m=async()=>{if(!i.trim()){h("Message is required.");return}l(!0);try{const d=await H.post(`/background/${encodeURIComponent(t)}/steer`,{message:i});if(!(d!=null&&d.ok)){h((d==null?void 0:d.error)||"Steer failed.");return}s.success(`Steered → new instance ${(d.newInstanceId??"").slice(0,14)}…`),n(),a()}catch(d){h(d.message)}finally{l(!1)}};return e.jsxs("div",{className:"bg-steer-modal",children:[e.jsxs("p",{className:"muted",children:["Steer kills the current subprocess and spawns a new one with the original prompt + your message appended. The new instance is linked to this one as ",e.jsx("code",{children:"parentInstanceId"}),"."]}),e.jsx("textarea",{className:"field-input bg-steer-textarea",rows:6,value:i,onChange:d=>r(d.target.value),placeholder:"What do you want the agent to do differently?"}),c&&e.jsx("div",{className:"bg-steer-error",children:c}),e.jsxs("div",{className:"bg-steer-actions",children:[e.jsx(U,{variant:"ghost",size:"sm",onClick:a,children:"Cancel"}),e.jsx(U,{variant:"primary",size:"sm",onClick:m,disabled:o||!i.trim(),children:o?"Steering…":"Steer"})]})]})}function Cx({info:t,cmd:s}){const[n,a]=f.useState(!1),i=async()=>{try{await navigator.clipboard.writeText(s),a(!0),window.setTimeout(()=>a(!1),1500)}catch{}};return e.jsx("div",{className:"bg-tmux-modal",children:s?e.jsxs(e.Fragment,{children:[e.jsxs("p",{className:"bg-tmux-meta",children:[t.exists?e.jsx("span",{className:"badge badge-success",children:"session live"}):e.jsxs("span",{className:"badge badge-warning",children:["session not running",t.reason?` — ${t.reason}`:""]}),t.session&&e.jsxs("span",{className:"bg-tmux-session muted",children:["· session ",e.jsx("code",{className:"mono",children:t.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:s}),e.jsxs(U,{variant:"secondary",size:"sm",onClick:i,children:[e.jsx(Vt,{size:14})," ",n?"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 zx={system:{title:"System health",icon:Ss,emptyTitle:"No system checks",emptyMessage:"System checks did not return any rows."},services:{title:"Services",icon:Ci,emptyTitle:"No service probes",emptyMessage:"Service probes did not return any rows."},counts:{title:"Counts",icon:He,emptyTitle:"No counts",emptyMessage:"No counts reported by the dashboard stores."},errors:{title:"Recent errors",icon:ys,emptyTitle:"No recent errors",emptyMessage:"No error lines in the service log within the last hour."},actions:{title:"Actions",icon:xh,emptyTitle:"No actions",emptyMessage:"No actions available."}};function Mx(t){return t==="ok"?Ze:t==="warn"?Tu:ys}function $x(t){return t==="ok"?"ok":t==="warn"?"warn":"fail"}function Ha({category:t,title:s,icon:n,checks:a,info:i,meta:r,children:o,className:l}){const c=zx[t],h=n??c.icon,m=s??c.title,d=a.length>0||i&&i.length>0||o;return e.jsxs(se,{className:te("doctor-panel",`doctor-panel-${t}`,l),children:[e.jsxs(de,{children:[e.jsx(h,{size:14,"aria-hidden":!0}),e.jsx("span",{children:m}),r?e.jsx("span",{className:"card-meta-inline muted",children:r}):null]}),d?e.jsxs("div",{className:"doctor-panel-body",children:[o,a.length>0?e.jsx("ul",{className:"doctor-check-list",role:"list",children:a.map(u=>{const p=Mx(u.status);return e.jsxs("li",{className:te("doctor-check-row",`doctor-check-${u.status}`),children:[e.jsx("span",{className:"doctor-check-icon","aria-hidden":!0,children:e.jsx(p,{size:14,className:te("doctor-check-icon-svg",u.status==="ok"&&"doctor-check-icon-ok",u.status==="warn"&&"doctor-check-icon-warn",u.status==="fail"&&"doctor-check-icon-fail")})}),e.jsx("span",{className:"doctor-check-name mono",children:u.name}),e.jsx("span",{className:"doctor-check-message",children:u.message}),e.jsx(ma,{kind:u.status,dot:!0,children:$x(u.status)})]},u.name)})}):null,i&&i.length>0?e.jsx("dl",{className:"doctor-info-list",children:i.map(u=>e.jsxs(rt.Fragment,{children:[e.jsx("dt",{children:u.label}),e.jsx("dd",{className:"tabular-nums",children:u.value})]},u.label))}):null]}):e.jsx(Te,{icon:e.jsx(h,{size:28,"aria-hidden":!0}),title:c.emptyTitle,message:c.emptyMessage})]})}const Ex=3e4;function _x({setActiveTab:t}){var $;const s=pe(),[n,a]=f.useState(null),[i,r]=f.useState(!0),[o,l]=f.useState(!1),[c,h]=f.useState(null),[m,d]=f.useState(!0),u=f.useRef(!1),p=f.useCallback(async()=>{l(!0);try{const M=await H.get("/doctor");u.current||(a(M),h(Date.now()),r(!1))}catch(M){u.current||(r(!1),s.error(`Doctor refresh failed: ${M.message}`))}finally{u.current||l(!1)}},[s]);f.useEffect(()=>(u.current=!1,p(),()=>{u.current=!0}),[p]),f.useEffect(()=>{if(!m)return;const z=setInterval(async()=>{try{const A=await H.get("/doctor/health");a(k=>k&&((k.health.status!==A.status||k.health.issues.length!==A.issues.length)&&p(),k))}catch{}},Ex);return()=>clearInterval(z)},[m,p]);const x=async M=>{var z;try{const A=await H.post("/doctor/check",{checkName:M});s.info(`${A.name}: ${A.message}`,4e3),await p()}catch(A){const k=A;s.error(`Check failed: ${((z=k.data)==null?void 0:z.message)??A.message}`)}},j=()=>{if(n)try{const M=new Blob([JSON.stringify(n,null,2)],{type:"application/json"}),z=URL.createObjectURL(M),A=document.createElement("a");A.href=z,A.download=`doctor-snapshot-${new Date().toISOString().replace(/[:.]/g,"-")}.json`,document.body.appendChild(A),A.click(),document.body.removeChild(A),URL.revokeObjectURL(z)}catch(M){s.error(`Export failed: ${M.message}`)}},v=()=>{t("settings")},g=n==null?void 0:n.counts,b=f.useMemo(()=>g?[{label:"Tasks",value:g.tasks},{label:"Schedules",value:g.schedules},{label:"Mods",value:g.mods},{label:"Providers",value:g.providers},{label:"MCPs",value:g.mcps},{label:"Agents",value:g.agents},{label:"Projects",value:g.projects},{label:"Workspaces",value:g.workspaces},{label:"Voice notes",value:g.voiceNotes},{label:"Eval runs",value:g.evalRuns},{label:"Backups",value:g.backups}]:[],[g]);if(i)return e.jsxs("div",{className:"view view-doctor view-loading",children:[e.jsx(ye,{size:"lg"}),e.jsx("p",{children:"Running health checks…"})]});if(!n)return e.jsx("div",{className:"view view-doctor",children:e.jsxs(se,{children:[e.jsxs(de,{children:[e.jsx(ys,{size:14})," Doctor unavailable"]}),e.jsx(ue,{children:"Could not reach /api/doctor."}),e.jsx("div",{className:"doctor-fallback-actions",children:e.jsxs(U,{variant:"primary",onClick:p,children:[e.jsx(xe,{size:12})," Retry"]})})]})});const y=n.health.status,w=y==="ok"?Ze:y==="warn"?qe:ys,S=y==="ok"?"Healthy":y==="warn"?"Warning":"Failed";return e.jsxs("div",{className:"view view-doctor","data-overall":y,children:[e.jsxs("div",{className:"doctor-header",children:[e.jsxs("div",{className:"doctor-header-row",children:[e.jsxs("div",{className:"doctor-header-title",children:[e.jsx(al,{size:20,"aria-hidden":!0}),e.jsx("h1",{children:"Doctor"})]}),e.jsx("div",{className:"doctor-header-status",children:e.jsxs("span",{className:te("doctor-overall-pill",`doctor-overall-${y}`),children:[e.jsx(w,{size:14,"aria-hidden":!0}),e.jsx("span",{className:"doctor-overall-label",children:S}),e.jsxs(ma,{kind:y,dot:!0,children:[n.health.issues.length," issue",n.health.issues.length===1?"":"s"]})]})})]}),e.jsxs("div",{className:"doctor-header-meta muted",children:[e.jsx(Jt,{size:12,"aria-hidden":!0}),e.jsxs("span",{"aria-live":"polite","aria-atomic":"true",children:["v",n.bizarVersion," · ",n.platform,"/",n.arch," ·"," ","up ",Math.floor(n.uptime),"s",c?` · refreshed ${St(new Date(c))}`:""]})]})]}),e.jsxs("div",{className:"doctor-grid",children:[e.jsx(Ha,{category:"system",checks:n.checks.system,meta:`${n.platform}/${n.arch}`}),e.jsx(Ha,{category:"services",checks:n.checks.services,meta:($=n.services.cline)!=null&&$.reachable?`cline on ${n.services.cline.port??"?"}`:"cline not connected"}),e.jsx(Ha,{category:"counts",checks:[],info:b,meta:g!=null&&g.activeProject?`active: ${g.activeProject}`:"no active project"}),e.jsxs(se,{className:"doctor-errors-card",children:[e.jsxs(de,{children:[e.jsx(ys,{size:14,"aria-hidden":!0}),e.jsx("span",{children:"Recent errors (last hour)"}),e.jsxs("span",{className:"card-meta-inline muted",children:[n.recentErrors.length," line",n.recentErrors.length===1?"":"s"]})]}),n.recentErrors.length===0?e.jsx("div",{className:"muted doctor-errors-empty",children:"No errors in the last hour. Nice."}):e.jsx("ul",{className:"doctor-errors-list",role:"list",children:n.recentErrors.map((M,z)=>e.jsxs("li",{className:"doctor-error-row",children:[e.jsx("span",{className:"doctor-error-ts mono",children:M.ts?St(new Date(M.ts)):"??:??:??"}),e.jsx("span",{className:"doctor-error-line mono",children:M.line})]},`${M.tsMs??z}-${z}`))})]}),e.jsxs(se,{className:"doctor-actions-card",children:[e.jsxs(de,{children:[e.jsx(Yn,{size:14,"aria-hidden":!0})," Actions"]}),e.jsx(ue,{children:"Run a check, view logs, or export the snapshot."}),e.jsxs("div",{className:"doctor-actions-row",children:[e.jsxs(U,{variant:"primary",onClick:p,disabled:o,"aria-label":"Refresh diagnostics",children:[o?e.jsx(ye,{size:"sm"}):e.jsx(xe,{size:12}),o?"Running…":"Run Health Check Now"]}),e.jsxs(U,{variant:"secondary",onClick:v,children:[e.jsx(Ue,{size:12})," View Full Logs"]}),e.jsxs(U,{variant:"secondary",onClick:j,children:[e.jsx(ts,{size:12})," Export Diagnostics as JSON"]}),e.jsx(U,{variant:"ghost",onClick:()=>d(M=>!M),"aria-label":m?"Pause auto-refresh":"Resume auto-refresh",children:m?"Pause auto-refresh":"Resume auto-refresh"})]}),n.checks.services.some(M=>M.status!=="ok")||n.checks.config.some(M=>M.status!=="ok")?e.jsxs("div",{className:"doctor-actions-rerun",children:[e.jsx("span",{className:"muted",children:"Rerun a single check:"}),e.jsx("div",{className:"doctor-actions-rerun-row",children:[...n.checks.services,...n.checks.config].filter(M=>M.status!=="ok").map(M=>e.jsxs(U,{variant:"ghost",size:"sm",onClick:()=>x(M.name),title:`Run check: ${M.name}`,children:[e.jsx(Yn,{size:10})," ",M.name]},M.name))})]}):null]})]})]})}const Tx=rt.memo(_x);function Ax({snapshot:t,setActiveTab:s,refreshSnapshot:n}){var p;const a=pe(),[i,r]=f.useState(!1),[o,l]=f.useState(null),c=f.useMemo(()=>[{id:"instructions",label:"Instructions",description:"AGENTS.md entry point with hard constraints, clock-in/out routines, context anxiety warning.",icon:e.jsx(Mi,{size:16}),checks:[{id:"inst-file",label:"AGENTS.md exists",severity:"critical",status:"pass"},{id:"inst-summary",label:"System description in first 10 lines",severity:"critical",status:"pass"},{id:"inst-verify",label:"Verification commands listed",severity:"critical",status:"pass"},{id:"inst-hard",label:"Hard constraints (MUST / MUST NOT)",severity:"recommended",status:"pass"},{id:"inst-state",label:"State files enumerated",severity:"recommended",status:"pass"},{id:"inst-clock",label:"Clock-in / Clock-out routines",severity:"recommended",status:"pass"}]},{id:"tools",label:"Tools",description:"Scoped tool permissions, MCP integrations, integration docs.",icon:e.jsx(Xn,{size:16}),checks:[{id:"tools-scope",label:"Tool access scoped (.claude/settings.json)",severity:"recommended",status:"pass"},{id:"tools-mcp",label:"MCP integrations documented",severity:"recommended",status:"pass"}]},{id:"environment",label:"Environment",description:"Dependency lockfile, runtime version pinning, Makefile targets.",icon:e.jsx(He,{size:16}),checks:[{id:"env-lock",label:"Dependency lockfile",severity:"critical",status:"pass"},{id:"env-pin",label:"Runtime version pinned (.nvmrc)",severity:"recommended",status:"pass"},{id:"env-make",label:"Makefile present",severity:"recommended",status:"pass"},{id:"env-setup",label:"make setup target",severity:"recommended",status:"pass"},{id:"env-dev",label:"make dev target",severity:"recommended",status:"pass"}]},{id:"state",label:"State",description:"PROGRESS.md, DECISIONS.md, feature_list.json — cross-session state.",icon:e.jsx(Xn,{size:16}),checks:[{id:"state-progress",label:"PROGRESS.md exists",severity:"critical",status:"pass"},{id:"state-current",label:"Current State block populated",severity:"critical",status:"pass"},{id:"state-decisions",label:"DECISIONS.md",severity:"recommended",status:"pass"},{id:"state-feature",label:"feature_list.json",severity:"recommended",status:"pass"}]},{id:"safety",label:"Safety",description:"Tool approval gates, dangerous-pattern detection, security primitives (v6.0.0).",icon:e.jsx(ss,{size:16}),checks:[{id:"safety-patterns",label:"36+ dangerous patterns registered",severity:"critical",status:"pass"},{id:"safety-gate",label:"Tool approval gate in beforeTool",severity:"critical",status:"pass"},{id:"safety-flush",label:"Pre-compaction memory flush",severity:"recommended",status:"pass"},{id:"safety-curator",label:"Skill curator (closed learning loop)",severity:"recommended",status:"pass"},{id:"safety-graph",label:"Knowledge graph query tools",severity:"recommended",status:"pass"}]},{id:"feedback",label:"Feedback",description:"Verification pipelines, make check / test / e2e, clean-check.",icon:e.jsx(Ze,{size:16}),checks:[{id:"fb-check",label:"make check target",severity:"recommended",status:"pass"},{id:"fb-test",label:"make test target",severity:"recommended",status:"pass"},{id:"fb-e2e",label:"make e2e target",severity:"recommended",status:"pass"},{id:"fb-cleancheck",label:"make clean-check (5 dimensions)",severity:"recommended",status:"pass"},{id:"fb-arch",label:"make check-arch (.harness/arch-rules.json)",severity:"recommended",status:"pass"},{id:"fb-vcr",label:"make vcr (VCR ratio)",severity:"recommended",status:"pass"},{id:"fb-trace",label:"make session-start/end (traces)",severity:"recommended",status:"pass"}]}],[]),h=f.useMemo(()=>{const x=c.flatMap(S=>S.checks).length,j=c.flatMap(S=>S.checks).filter(S=>S.status==="pass").length,v=c.flatMap(S=>S.checks).filter(S=>S.severity==="critical"),g=v.filter(S=>S.status==="pass").length,b=c.flatMap(S=>S.checks).filter(S=>S.severity==="recommended"),y=b.filter(S=>S.status==="pass").length,w=x===0?1:j/x;return{total:x,passing:j,critical:v.length,criticalPass:g,recommended:b.length,recommendedPass:y,ratio:w}},[c]),m=async()=>{r(!0);try{await n(),a.show("Snapshot refreshed","success")}finally{r(!1)}},d=()=>{a.show("Audit script runs via `make check-arch` from a shell","info")},u=((p=t.cline)==null?void 0:p.state)==="active";return e.jsxs("div",{className:"harness-page",children:[e.jsxs("header",{className:"harness-header",children:[e.jsxs("div",{className:"harness-header-left",children:[e.jsx("div",{className:"harness-icon-wrap",children:e.jsx(ss,{size:22})}),e.jsxs("div",{children:[e.jsx("h1",{className:"harness-title",children:"Harness Engineering"}),e.jsx("p",{className:"harness-subtitle",children:"v6.0.0 — 5 subsystems × 12 checks. All passing."})]})]}),e.jsxs("div",{className:"harness-header-actions",children:[e.jsxs("button",{type:"button",className:"btn btn-secondary",onClick:d,children:[e.jsx(Du,{size:14}),"Run audit"]}),e.jsxs("button",{type:"button",className:"btn btn-primary",onClick:m,children:[e.jsx(xe,{size:14,className:i?"spin":""}),"Refresh"]})]})]}),e.jsxs("section",{className:"harness-audit",children:[e.jsxs("div",{className:"harness-card",children:[e.jsx("span",{className:"harness-card-label",children:"Audit score"}),e.jsxs("span",{className:te("harness-card-value",h.ratio>=.99?"pass":h.ratio>=.85?"warn":"fail"),children:[h.passing,"/",h.total]}),e.jsxs("span",{className:"harness-card-sub",children:[(h.ratio*100).toFixed(1),"% passing"]})]}),e.jsxs("div",{className:"harness-card",children:[e.jsx("span",{className:"harness-card-label",children:"Critical"}),e.jsxs("span",{className:te("harness-card-value",h.criticalPass===h.critical?"pass":"fail"),children:[h.criticalPass,"/",h.critical]}),e.jsx("span",{className:"harness-card-sub",children:"all must-have"})]}),e.jsxs("div",{className:"harness-card",children:[e.jsx("span",{className:"harness-card-label",children:"Recommended"}),e.jsxs("span",{className:te("harness-card-value",h.recommendedPass===h.recommended?"pass":"warn"),children:[h.recommendedPass,"/",h.recommended]}),e.jsx("span",{className:"harness-card-sub",children:"best practice"})]}),e.jsxs("div",{className:"harness-card",children:[e.jsx("span",{className:"harness-card-label",children:"Cline runtime"}),e.jsx("span",{className:te("harness-card-value",u?"pass":"warn"),children:u?"in-process":"subprocess"}),e.jsx("span",{className:"harness-card-sub",children:"ClineCore in-process v6.0.0"})]})]}),e.jsx("section",{className:"harness-subsystems",children:c.map(x=>{const j=x.checks.filter(b=>b.status==="pass").length,v=x.checks.length,g=j===v;return e.jsxs(se,{className:te("harness-subsystem-card",g?"harness-pass":"harness-warn"),children:[e.jsxs("div",{className:"harness-subsystem-head",children:[e.jsx("div",{className:"harness-subsystem-icon",children:x.icon}),e.jsxs("div",{className:"harness-subsystem-title",children:[e.jsx("h3",{children:x.label}),e.jsx("span",{className:"muted",children:x.description})]}),e.jsx("div",{className:"harness-subsystem-score",children:e.jsxs("span",{className:te("harness-card-value-sm",g?"pass":"warn"),children:[j,"/",v]})})]}),e.jsx("ul",{className:"harness-checklist",children:x.checks.map(b=>e.jsxs("li",{className:te("harness-check",b.status),children:[b.status==="pass"?e.jsx(Ze,{size:13,className:"pass"}):e.jsx(ls,{size:13,className:"fail"}),e.jsx("span",{className:"harness-check-label",children:b.label}),e.jsx("span",{className:te("harness-check-severity",b.severity),children:b.severity})]},b.id))})]},x.id)})}),e.jsxs("section",{className:"harness-quick-actions",children:[e.jsxs(se,{children:[e.jsx(de,{children:"Harness commands"}),e.jsx(ue,{children:"Run from a shell to verify / repair the harness."}),e.jsxs("div",{className:"harness-command-grid",children:[e.jsx("code",{children:"make check"}),e.jsx("span",{children:"Full verification pipeline (typecheck + tests)"}),e.jsx("code",{children:"make e2e"}),e.jsx("span",{children:"Real plugin load + 22 tool/hook checks"}),e.jsx("code",{children:"make vcr"}),e.jsx("span",{children:"VCR ratio (passing / activated features)"}),e.jsx("code",{children:"make verify-feature ID=F-001"}),e.jsx("span",{children:"Verify a specific feature by ID"}),e.jsx("code",{children:"make check-arch"}),e.jsx("span",{children:"Run architectural constraints"}),e.jsx("code",{children:"make clean-check"}),e.jsx("span",{children:"5-dimension clean-state check"}),e.jsx("code",{children:"make session-start"}),e.jsx("span",{children:"Record session start to .harness/traces/"}),e.jsx("code",{children:"make session-end"}),e.jsx("span",{children:"Record session end to .harness/traces/"})]})]}),e.jsxs(se,{children:[e.jsx(de,{children:"Documentation"}),e.jsx(ue,{children:"Entry point + topic docs."}),e.jsxs("ul",{className:"harness-docs-list",children:[e.jsxs("li",{children:[e.jsx("button",{type:"button",className:"link",onClick:()=>s("doctor"),children:"Doctor"})," ",e.jsx("span",{className:"muted",children:"— runtime health + service status"})]}),e.jsxs("li",{children:[e.jsx("a",{className:"link",href:"/api/doctor/health",target:"_blank",rel:"noreferrer",children:"/api/doctor/health"})," ",e.jsx("span",{className:"muted",children:"— health endpoint"})]}),e.jsxs("li",{children:[e.jsx("code",{children:"AGENTS.md"})," ",e.jsx("span",{className:"muted",children:"— entry point with hard constraints"})]}),e.jsxs("li",{children:[e.jsx("code",{children:"PROGRESS.md"})," ",e.jsx("span",{className:"muted",children:"— current state, in progress, next steps"})]}),e.jsxs("li",{children:[e.jsx("code",{children:"DECISIONS.md"})," ",e.jsx("span",{className:"muted",children:"— architectural decision log (ADRs)"})]}),e.jsxs("li",{children:[e.jsx("code",{children:"feature_list.json"})," ",e.jsx("span",{className:"muted",children:"— machine-readable feature state"})]}),e.jsxs("li",{children:[e.jsx("code",{children:"docs/architecture.md"})," ",e.jsx("span",{className:"muted",children:"— layer model + module map"})]}),e.jsxs("li",{children:[e.jsx("code",{children:"docs/quality-document.md"})," ",e.jsx("span",{className:"muted",children:"— per-module A/B/C/D scores"})]}),e.jsxs("li",{children:[e.jsx("code",{children:".harness/arch-rules.json"})," ",e.jsx("span",{className:"muted",children:"— architectural rule registry"})]})]})]})]})]})}function Rx(t){return e.jsx(Ax,{...t})}function Ix(t){return t.total<=0?"fail":t.failed===0?"pass":t.passed/t.total>.8?"warn":"fail"}function xl({run:t,onClick:s,selected:n,ariaLabel:a}){const i=Ix(t),r=t.total>0?(t.passed/t.total*100).toFixed(1):"0.0",o=!!s;return e.jsxs(se,{onClick:s,interactive:o,"aria-label":a??`Eval run ${t.id}`,"aria-pressed":o?n:void 0,className:te("eval-run-card",n&&"eval-run-card-selected",`eval-run-${i}`),children:[e.jsxs("div",{className:"eval-run-head",children:[e.jsx(de,{className:"eval-run-title",children:t.id}),e.jsxs("span",{className:te("eval-status",`is-${i}`),children:[t.passed,"/",t.total," (",r,"%)"]})]}),e.jsxs(ue,{className:"eval-run-meta",children:[St(t.startedAt)," · ",t.suitePath]})]})}const Va=8;function Lx({onAdded:t,onCancel:s}){const n=pe(),[a,i]=f.useState(""),[r,o]=f.useState(""),[l,c]=f.useState(""),[h,m]=f.useState("thor"),[d,u]=f.useState(!1),p=async x=>{if(x.preventDefault(),!a||!r||!l){n.error("name, suitePath, and cron are required");return}u(!0);try{const j=await H.post("/eval/schedules",{name:a,suitePath:r,cron:l,agent:h});t(j),n.success("Schedule created")}catch(j){n.error(`Failed to create schedule: ${j.message}`)}finally{u(!1)}};return e.jsxs("form",{className:"eval-schedule-form",onSubmit:p,children:[e.jsxs("div",{className:"form-row",children:[e.jsx("label",{htmlFor:"sched-name",children:"Name"}),e.jsx("input",{id:"sched-name",type:"text",value:a,onChange:x=>i(x.target.value),placeholder:"Daily fixture check",required:!0})]}),e.jsxs("div",{className:"form-row",children:[e.jsx("label",{htmlFor:"sched-suite",children:"Suite path"}),e.jsx("input",{id:"sched-suite",type:"text",value:r,onChange:x=>o(x.target.value),placeholder:"./fixtures",required:!0})]}),e.jsxs("div",{className:"form-row",children:[e.jsx("label",{htmlFor:"sched-cron",children:"Cron"}),e.jsx("input",{id:"sched-cron",type:"text",value:l,onChange:x=>c(x.target.value),placeholder:"0 8 * * *",required:!0})]}),e.jsxs("div",{className:"form-row",children:[e.jsx("label",{htmlFor:"sched-agent",children:"Agent"}),e.jsx("input",{id:"sched-agent",type:"text",value:h,onChange:x=>m(x.target.value),placeholder:"thor"})]}),e.jsxs("div",{className:"form-actions",children:[e.jsx(U,{type:"submit",variant:"primary",size:"sm",disabled:d,children:d?"Creating…":"Create schedule"}),e.jsx(U,{type:"button",variant:"ghost",size:"sm",onClick:s,children:"Cancel"})]})]})}function Px({setActiveTab:t}){const s=pe(),[n,a]=f.useState([]),[i,r]=f.useState(!0),[o,l]=f.useState("runs"),[c,h]=f.useState([]),[m,d]=f.useState(!1),[u,p]=f.useState(!1),x=f.useRef(!1),j=f.useCallback(async()=>{r(!0);try{const S=await H.get(`/eval/runs?limit=${Va}`);x.current||a(S.runs||[])}catch(S){x.current||s.error(`Failed to load eval runs: ${S.message}`)}finally{x.current||r(!1)}},[s]),v=f.useCallback(async()=>{d(!0);try{const S=await H.get("/eval/schedules");x.current||h(S.schedules||[])}catch(S){x.current||s.error(`Failed to load eval schedules: ${S.message}`)}finally{x.current||d(!1)}},[s]);f.useEffect(()=>(x.current=!1,j(),o==="schedules"&&v(),()=>{x.current=!0}),[j,v,o]);const g=async S=>{try{await H.del(`/eval/schedules/${S}`),h($=>$.filter(M=>M.id!==S)),s.success("Schedule deleted")}catch($){s.error(`Failed to delete schedule: ${$.message}`)}},b=n.slice(0,Va),y=n.reduce((S,$)=>(S.total+=$.total,S.passed+=$.passed,S.failed+=$.failed,$.failed===0&&(S.fullPass+=1),S),{total:0,passed:0,failed:0,fullPass:0}),w=y.total>0?(y.passed/y.total*100).toFixed(1):"—";return e.jsxs("div",{className:"view view-eval","data-testid":"eval-overview",children:[e.jsxs("div",{className:"view-header",children:[e.jsxs("div",{className:"view-header-text",children:[e.jsxs("h1",{className:"view-title",children:[e.jsx(Ot,{size:20,"aria-hidden":!0})," Eval"]}),e.jsx("p",{className:"view-subtitle muted",children:"Track golden-fixture runs, catch regressions, and compare run history."})]}),e.jsxs("div",{className:"view-actions",children:[e.jsxs(U,{variant:"secondary",size:"sm",onClick:j,disabled:i,children:[i?e.jsx(ye,{size:"sm"}):e.jsx(xe,{size:12}),i?"Refreshing…":"Refresh"]}),e.jsxs(U,{variant:"primary",size:"sm",onClick:()=>t("evalReport"),title:"Open the full eval report",children:[e.jsx(Is,{size:12})," Open Eval Report"]})]})]}),e.jsxs("div",{className:"eval-summary-grid",children:[e.jsxs(se,{className:"eval-summary-card",children:[e.jsx(de,{children:"Recent runs"}),e.jsx("div",{className:"eval-summary-value",children:n.length}),e.jsxs(ue,{className:"muted",children:["Latest ",Va," runs across all suites."]})]}),e.jsxs(se,{className:"eval-summary-card",children:[e.jsx(de,{children:"Fixtures run"}),e.jsx("div",{className:"eval-summary-value",children:y.total}),e.jsx(ue,{className:"muted",children:e.jsxs("span",{className:te("eval-rate",y.failed===0?"is-pass":"is-fail"),children:[w,"% pass rate"]})})]}),e.jsxs(se,{className:"eval-summary-card",children:[e.jsx(de,{children:"Clean runs"}),e.jsx("div",{className:"eval-summary-value",children:y.fullPass}),e.jsx(ue,{className:"muted",children:"Runs where every fixture passed."})]}),e.jsxs(se,{className:"eval-summary-card eval-summary-cta",children:[e.jsx(de,{children:"Compare runs"}),e.jsx(ue,{children:"Open the detailed report to diff two runs side-by-side and spot regressions fixture by fixture."}),e.jsxs(U,{variant:"primary",size:"sm",onClick:()=>t("evalReport"),className:"eval-summary-cta-btn",children:["Open report ",e.jsx(Yo,{size:12})]})]})]}),e.jsxs("div",{className:"eval-recent-section",children:[e.jsxs("div",{className:"eval-sub-tabs",children:[e.jsxs("button",{type:"button",className:te("eval-sub-tab",o==="runs"?"is-active":""),onClick:()=>l("runs"),children:[e.jsx(Ot,{size:12,"aria-hidden":!0})," Runs"]}),e.jsxs("button",{type:"button",className:te("eval-sub-tab",o==="schedules"?"is-active":""),onClick:()=>{l("schedules"),c.length===0&&v()},children:[e.jsx(Jt,{size:12,"aria-hidden":!0})," Schedules"]})]}),o==="runs"?e.jsxs(e.Fragment,{children:[e.jsx("h2",{className:"eval-section-title",children:"Recent runs"}),i&&b.length===0?e.jsxs("div",{className:"eval-runs-loading",children:[e.jsx(ye,{size:"sm"}),e.jsx("span",{className:"muted",children:"Loading runs…"})]}):b.length===0?e.jsx(Te,{icon:e.jsx(Ot,{size:28}),title:"No eval runs yet",message:e.jsxs(e.Fragment,{children:["Run a suite via the CLI:"," ",e.jsx("code",{className:"mono",children:"bizar eval run ./path/to/fixtures"}),". Results will appear here."]})}):e.jsx("div",{className:"eval-runs-list",children:b.map(S=>e.jsx(xl,{run:S},S.id))})]}):e.jsxs(e.Fragment,{children:[e.jsx("h2",{className:"eval-section-title",children:"Schedules"}),m?e.jsxs("div",{className:"eval-runs-loading",children:[e.jsx(ye,{size:"sm"}),e.jsx("span",{className:"muted",children:"Loading schedules…"})]}):c.length===0?e.jsx(Te,{icon:e.jsx(Jt,{size:28}),title:"No eval schedules",message:"Schedules let you run eval suites automatically on a cron. Add one below."}):e.jsx("div",{className:"eval-schedules-list",children:c.map(S=>e.jsx(se,{className:"eval-schedule-card",children:e.jsxs("div",{className:"eval-schedule-row",children:[e.jsxs("div",{className:"eval-schedule-info",children:[e.jsx(de,{children:S.name}),e.jsxs(ue,{className:"muted",children:[S.cron," · ",S.suitePath," · agent:",S.agent||"thor"]})]}),e.jsx(U,{variant:"ghost",size:"sm",onClick:()=>g(S.id),title:"Delete schedule",children:e.jsx(Fe,{size:12,"aria-hidden":!0})})]})},S.id))}),e.jsxs("div",{className:"eval-schedule-add",children:[e.jsx(Lx,{onAdded:S=>{h($=>[...$,S]),p(!1)},onCancel:()=>p(!1)}),!u&&e.jsxs(U,{variant:"secondary",size:"sm",onClick:()=>p(!0),children:[e.jsx(We,{size:12,"aria-hidden":!0})," Add schedule"]})]})]})]})]})}const Dx=rt.memo(Px);function gl(t,s){const n=new Map(t.results.map(l=>[l.fixtureId,l])),a=new Map(s.results.map(l=>[l.fixtureId,l])),i=new Set([...n.keys(),...a.keys()]),r=[];for(const l of i){const c=n.get(l),h=a.get(l),m=c?c.ok:null,d=h?h.ok:null;let u;c&&h?m===d?u="same":m===!1&&d===!0?u="improved":u="regressed":h&&!c?u="added":u="removed",r.push({fixtureId:l,before:m,after:d,change:u})}const o={regressed:0,improved:1,added:2,removed:3,same:4};return r.sort((l,c)=>{const h=o[l.change]-o[c.change];return h!==0?h:l.fixtureId.localeCompare(c.fixtureId)}),r}function Fx({runA:t,runB:s,title:n="Regression Analysis"}){const a=gl(t,s),i=a.filter(c=>c.change==="improved").length,r=a.filter(c=>c.change==="regressed").length,o=a.filter(c=>c.change==="same").length,l=a.filter(c=>c.change!=="same");return e.jsxs("div",{className:"eval-diff","data-testid":"eval-diff",children:[e.jsx("h3",{className:"eval-diff-title",children:n}),e.jsxs("div",{className:"eval-diff-subtitle muted",children:["Comparing ",e.jsx("code",{className:"mono",children:t.id})," →"," ",e.jsx("code",{className:"mono",children:s.id})]}),e.jsxs("div",{className:"eval-diff-stats","aria-label":"Diff summary",children:[e.jsxs("span",{className:"eval-diff-stat improved",children:[e.jsx("span",{className:"eval-diff-stat-icon","aria-hidden":!0,children:"+"}),i," improved"]}),e.jsxs("span",{className:"eval-diff-stat regressed",children:[e.jsx("span",{className:"eval-diff-stat-icon","aria-hidden":!0,children:"−"}),r," regressed"]}),e.jsxs("span",{className:"eval-diff-stat unchanged muted",children:[o," unchanged"]})]}),l.length===0?e.jsx("p",{className:"eval-diff-empty muted",children:"No fixture-level changes between these runs."}):e.jsx("ul",{className:"eval-diff-list",role:"list",children:l.map(c=>e.jsxs("li",{"data-fixture-id":c.fixtureId,className:te("eval-diff-row",`is-${c.change}`),children:[e.jsx("span",{className:"eval-diff-fixture mono",children:c.fixtureId}),e.jsx("span",{className:"eval-diff-arrow","aria-hidden":!0,children:"→"}),e.jsxs("span",{className:"eval-diff-states",children:[e.jsx("span",{className:te("eval-diff-state",c.before?"is-pass":"is-fail"),children:c.before===null?"—":c.before?"pass":"fail"}),e.jsx("span",{className:"eval-diff-arrow-small","aria-hidden":!0,children:"→"}),e.jsx("span",{className:te("eval-diff-state",c.after?"is-pass":"is-fail"),children:c.after===null?"—":c.after?"pass":"fail"})]})]},c.fixtureId))})]})}function Ox({runId:t,variant:s="secondary",size:n="sm"}){const a=()=>{const i=H.getToken();window.open(`/api/eval/runs/${encodeURIComponent(t)}/export.csv?_t=${encodeURIComponent(i)}`,"_blank")};return e.jsxs(U,{variant:s,size:n,onClick:a,title:"Export results as CSV",children:[e.jsx(ts,{size:14,"aria-hidden":!0}),"Export CSV"]})}function Bx({run:t,onClearCompare:s,compareRun:n,onClearSelection:a,runsForDiff:i}){const r=t.total>0?(t.passed/t.total*100).toFixed(1):"0.0",o=[...t.results].sort((l,c)=>l.ok!==c.ok?l.ok?1:-1:l.fixtureId.localeCompare(c.fixtureId));return e.jsxs("div",{className:"eval-run-detail","data-testid":"eval-run-detail",children:[e.jsxs(se,{className:"eval-run-detail-header",children:[e.jsxs("div",{className:"eval-run-detail-header-row",children:[e.jsxs(de,{children:[e.jsx(Ot,{size:14,"aria-hidden":!0})," ",t.id]}),e.jsxs("div",{className:"eval-run-detail-actions",children:[e.jsx(Ox,{runId:t.id}),e.jsxs(U,{variant:"ghost",size:"sm",onClick:a,title:"Close detail",children:[e.jsx(Ie,{size:12})," Close"]})]})]}),e.jsxs(ue,{children:[St(t.startedAt),t.finishedAt?` → ${St(t.finishedAt)}`:""," · ",t.suitePath]}),e.jsxs("div",{className:"eval-run-detail-summary",children:[e.jsxs("span",{className:te("eval-status",t.failed===0?"is-pass":"is-fail"),children:[t.passed,"/",t.total," (",r,"%)"]}),e.jsxs("span",{className:"muted",children:[t.failed," failed · ",t.passed," passed"]})]})]}),n?e.jsx(se,{className:"eval-diff-card",children:(()=>{const l=i.find(d=>d.id===n);if(!l)return e.jsxs("div",{className:"eval-diff-missing muted",children:["Baseline run ",e.jsx("code",{children:n})," not loaded. Pick another from the list."]});const c=gl(l,t),h=c.filter(d=>d.change==="improved").length,m=c.filter(d=>d.change==="regressed").length;return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"eval-diff-card-head",children:[e.jsxs("span",{className:"eval-diff-card-title",children:[e.jsx(Go,{size:14,"aria-hidden":!0})," Comparing ",l.id," → ",t.id]}),e.jsxs(U,{variant:"ghost",size:"sm",onClick:s,children:[e.jsx(Ie,{size:12})," Clear baseline"]})]}),e.jsxs("div",{className:"eval-diff-stats","aria-label":"Diff summary",children:[e.jsxs("span",{className:"eval-diff-stat improved",children:["+",h," improved"]}),e.jsxs("span",{className:"eval-diff-stat regressed",children:["−",m," regressed"]})]}),e.jsx(Fx,{runA:l,runB:t})]})})()}):e.jsx(se,{className:"eval-baseline-hint",children:e.jsx(ue,{children:"Tip: click another run in the list to use it as a baseline for diffing."})}),e.jsxs(se,{className:"eval-fixtures-card",children:[e.jsxs(de,{children:["Fixtures (",t.results.length,")"]}),o.length===0?e.jsx(ue,{className:"muted",children:"No fixture results in this run."}):e.jsx("ul",{className:"eval-fixtures-list",role:"list",children:o.map(l=>e.jsxs("li",{className:te("eval-fixture-row",l.ok?"is-pass":"is-fail"),children:[e.jsx("span",{className:te("eval-fixture-pill",l.ok?"is-pass":"is-fail"),"aria-label":l.ok?"pass":"fail",children:l.ok?"✓":"✗"}),e.jsx("span",{className:"eval-fixture-id mono",children:l.fixtureId}),!l.ok&&l.checks?e.jsx("span",{className:"eval-fixture-fails muted",children:l.checks.filter(c=>!c.ok).map(c=>c.message).filter(Boolean).join(" · ")}):null,l.latencyMs!=null?e.jsxs("span",{className:"eval-fixture-latency muted",children:[Math.round(l.latencyMs),"ms"]}):null]},l.fixtureId))})]})]})}function Hx({setActiveTab:t}){const s=pe(),[n,a]=f.useState([]),[i,r]=f.useState(!0),[o,l]=f.useState(null),[c,h]=f.useState(null),[m,d]=f.useState(null),[u,p]=f.useState(!1),[x,j]=f.useState(null),v=f.useRef(!1),g=f.useCallback(async()=>{r(!0);try{const M=await H.get("/eval/runs");v.current||a(M.runs||[])}catch(M){v.current||s.error(`Failed to load eval runs: ${M.message}`)}finally{v.current||r(!1)}},[s]),b=f.useCallback(async M=>{p(!0);try{const z=await H.get(`/eval/runs/${encodeURIComponent(M)}`);v.current||d(z)}catch(z){v.current||(s.error(`Failed to load run ${M}: ${z.message}`),d(null))}finally{v.current||p(!1)}},[s]),y=f.useCallback(async M=>{try{const z=await H.get(`/eval/runs/${encodeURIComponent(M)}`);v.current||j(z)}catch(z){v.current||(s.error(`Failed to load run ${M}: ${z.message}`),j(null))}},[s]);f.useEffect(()=>(v.current=!1,g(),()=>{v.current=!0}),[g]);const w=async M=>{M!==o&&(l(M),h(null),j(null),await b(M))},S=async M=>{M!==o&&(h(M),await y(M))},$=[];return x&&$.push(x),m&&$.push(m),e.jsxs("div",{className:"view view-eval-report","data-testid":"eval-report",children:[e.jsxs("div",{className:"view-header",children:[e.jsxs("div",{className:"view-header-text",children:[e.jsxs("h1",{className:"view-title",children:[e.jsx(Ot,{size:20,"aria-hidden":!0})," Eval Reports"]}),e.jsx("p",{className:"view-subtitle muted",children:"Browse eval runs, inspect per-fixture results, and diff two runs to spot regressions."})]}),e.jsx("div",{className:"view-actions",children:e.jsxs(U,{variant:"secondary",size:"sm",onClick:g,disabled:i,children:[i?e.jsx(ye,{size:"sm"}):e.jsx(xe,{size:12}),i?"Refreshing…":"Refresh"]})})]}),e.jsxs("div",{className:"eval-grid",children:[e.jsx("div",{className:"eval-runs-list",children:i&&n.length===0?e.jsxs("div",{className:"eval-runs-loading",children:[e.jsx(ye,{size:"sm"}),e.jsx("span",{className:"muted",children:"Loading runs…"})]}):n.length===0?e.jsx(Te,{icon:e.jsx(Ot,{size:28}),title:"No eval runs yet",message:e.jsxs(e.Fragment,{children:["Run a suite via the CLI:"," ",e.jsx("code",{className:"mono",children:"bizar eval run ./path/to/fixtures"}),"."]})}):n.map(M=>e.jsxs("div",{className:"eval-run-card-wrap",children:[e.jsx(xl,{run:M,selected:M.id===o,onClick:()=>w(M.id)}),o&&M.id!==o?e.jsxs("button",{type:"button",className:"eval-baseline-btn",onClick:()=>S(M.id),title:"Use this run as a baseline for diffing",children:[e.jsx(Go,{size:10,"aria-hidden":!0}),"Use as baseline"]}):null]},M.id))}),e.jsx("div",{className:"eval-detail",children:u&&!m?e.jsxs("div",{className:"eval-detail-loading",children:[e.jsx(ye,{size:"sm"}),e.jsx("span",{className:"muted",children:"Loading run details…"})]}):m?e.jsx(Bx,{run:m,compareRun:c,runsForDiff:$,onClearCompare:()=>{h(null),j(null)},onClearSelection:()=>{l(null),d(null),h(null),j(null)}}):e.jsx(se,{className:"eval-detail-empty",children:e.jsx(Te,{icon:e.jsx(Ot,{size:28}),title:"Select a run",message:"Pick an eval run from the list to view fixture-by-fixture results, latency, and per-check failure details."})})})]})]})}const Vx=rt.memo(Hx),$n=4e3;function Ux({onPlan:t,compact:s=!1}){const n=pe(),[a,i]=f.useState(""),[r,o]=f.useState(!1),l=async()=>{const c=a.trim();if(!c){n.error("Enter a goal first.");return}if(c.length>$n){n.error(`Goal must be ${$n} chars or fewer.`);return}o(!0);try{const h=await H.post("/goal-planner/plan",{goal:c});t&&t(h),n.success(`Plan generated: ${h.steps.length} steps.`)}catch(h){const m=(h==null?void 0:h.message)||"Planner failed";n.error(`Planner failed: ${m}`)}finally{o(!1)}};return e.jsxs("div",{className:`goal-input${s?" goal-input-compact":""}`,children:[e.jsxs("label",{className:"goal-input-label",htmlFor:"goal-input-textarea",children:[e.jsx(vt,{size:14,"aria-hidden":!0}),"Plain-English goal"]}),e.jsx("textarea",{id:"goal-input-textarea",className:"goal-input-textarea",value:a,onChange:c=>i(c.target.value),placeholder:"e.g. Research the latest advancements in quantum computing, then design and build a small demo, test it, and document the result.",disabled:r,maxLength:$n,rows:s?3:5,"data-testid":"goal-input-textarea"}),e.jsxs("div",{className:"goal-input-footer",children:[e.jsxs("span",{className:"goal-input-counter","data-testid":"goal-input-counter",children:[a.length," / ",$n]}),e.jsxs(U,{variant:"primary",size:"md",onClick:l,loading:r,disabled:r||!a.trim(),"data-testid":"goal-input-submit",children:[e.jsx(Rt,{size:14,"aria-hidden":!0}),r?"Planning…":"Generate plan"]})]})]})}function Pe({children:t,className:s,variant:n,onRemove:a,...i}){return e.jsxs("span",{className:te("tag",n?`tag-${n}`:void 0,s),...i,children:[t,a&&e.jsx("button",{type:"button",className:"tag-remove","aria-label":`Remove ${typeof t=="string"?t:"tag"}`,onClick:a,children:"×"})]})}function qx(t){if(!Number.isFinite(t)||t<0)return"—";const s=Math.floor(t/1e3),n=Math.floor(s/3600),a=Math.floor(s%3600/60),i=s%60;return n>0?`${n}h ${a}m`:a>0?`${a}m ${i}s`:`${i}s`}function Wx({plan:t}){return t?e.jsxs(se,{className:"plan-visualization","data-testid":"plan-visualization",children:[e.jsxs("div",{className:"plan-viz-header",children:[e.jsxs(de,{children:[e.jsx(gt,{size:14,"aria-hidden":!0})," Execution plan"]}),e.jsxs("div",{className:"plan-viz-badges",children:[e.jsxs(Pe,{variant:"info",children:[t.steps.length," steps"]}),e.jsxs(Pe,{variant:"accent",children:["Cost ",t.totalCost]}),e.jsxs(Pe,{variant:"success",children:[e.jsx(Jt,{size:10,"aria-hidden":!0})," ",qx(t.totalDurationMs)]})]})]}),e.jsxs(ue,{className:"plan-viz-goal",children:["Goal: ",t.goal]}),e.jsx("ol",{className:"plan-viz-tree",role:"tree",children:t.steps.map(s=>e.jsx(Gx,{step:s},s.id))})]}):e.jsxs(se,{className:"plan-visualization",children:[e.jsx(de,{children:"Execution plan"}),e.jsx(ue,{children:"Submit a goal to generate a plan."})]})}function Gx({step:t}){const[s,n]=f.useState(!1);return e.jsxs("li",{className:"plan-viz-row",role:"treeitem","aria-expanded":s,children:[e.jsxs("button",{type:"button",className:"plan-viz-row-head",onClick:()=>n(a=>!a),"data-testid":`plan-step-${t.id}`,children:[e.jsx("span",{className:"plan-viz-chevron",children:s?e.jsx(ct,{size:14,"aria-hidden":!0}):e.jsx(Ut,{size:14,"aria-hidden":!0})}),e.jsx("span",{className:te("plan-viz-action",`is-${t.action}`),children:t.action}),e.jsx("span",{className:"plan-viz-title",children:t.title}),e.jsxs("span",{className:"plan-viz-agent",children:["@",t.agent]}),e.jsx("span",{className:"plan-viz-cost",children:t.estimatedCost})]}),s&&e.jsxs("div",{className:"plan-viz-row-body","data-testid":`plan-step-${t.id}-body`,children:[e.jsx("p",{children:t.description}),t.deps.length>0&&e.jsxs("div",{className:"plan-viz-deps",children:[e.jsx("strong",{children:"Deps:"}),e.jsx("ul",{children:t.deps.map(a=>e.jsx("li",{children:e.jsx("code",{children:a})},a))})]}),e.jsxs("div",{className:"plan-viz-effects",children:[e.jsx("strong",{children:"Effects:"}),e.jsx("ul",{children:t.effects.map(a=>e.jsx("li",{children:e.jsx("code",{children:a})},a))})]})]})]})}function $e(t){if(typeof t=="string"||typeof t=="number")return""+t;let s="";if(Array.isArray(t))for(let n=0,a;n<t.length;n++)(a=$e(t[n]))!==""&&(s+=(s&&" ")+a);else for(let n in t)t[n]&&(s+=(s&&" ")+n);return s}var Yx={value:()=>{}};function pa(){for(var t=0,s=arguments.length,n={},a;t<s;++t){if(!(a=arguments[t]+"")||a in n||/[\s.]/.test(a))throw new Error("illegal type: "+a);n[a]=[]}return new Vn(n)}function Vn(t){this._=t}function Xx(t,s){return t.trim().split(/^|\s+/).map(function(n){var a="",i=n.indexOf(".");if(i>=0&&(a=n.slice(i+1),n=n.slice(0,i)),n&&!s.hasOwnProperty(n))throw new Error("unknown type: "+n);return{type:n,name:a}})}Vn.prototype=pa.prototype={constructor:Vn,on:function(t,s){var n=this._,a=Xx(t+"",n),i,r=-1,o=a.length;if(arguments.length<2){for(;++r<o;)if((i=(t=a[r]).type)&&(i=Kx(n[i],t.name)))return i;return}if(s!=null&&typeof s!="function")throw new Error("invalid callback: "+s);for(;++r<o;)if(i=(t=a[r]).type)n[i]=Tr(n[i],t.name,s);else if(s==null)for(i in n)n[i]=Tr(n[i],t.name,null);return this},copy:function(){var t={},s=this._;for(var n in s)t[n]=s[n].slice();return new Vn(t)},call:function(t,s){if((i=arguments.length-2)>0)for(var n=new Array(i),a=0,i,r;a<i;++a)n[a]=arguments[a+2];if(!this._.hasOwnProperty(t))throw new Error("unknown type: "+t);for(r=this._[t],a=0,i=r.length;a<i;++a)r[a].value.apply(s,n)},apply:function(t,s,n){if(!this._.hasOwnProperty(t))throw new Error("unknown type: "+t);for(var a=this._[t],i=0,r=a.length;i<r;++i)a[i].value.apply(s,n)}};function Kx(t,s){for(var n=0,a=t.length,i;n<a;++n)if((i=t[n]).name===s)return i.value}function Tr(t,s,n){for(var a=0,i=t.length;a<i;++a)if(t[a].name===s){t[a]=Yx,t=t.slice(0,a).concat(t.slice(a+1));break}return n!=null&&t.push({name:s,value:n}),t}var li="http://www.w3.org/1999/xhtml";const Ar={svg:"http://www.w3.org/2000/svg",xhtml:li,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function xa(t){var s=t+="",n=s.indexOf(":");return n>=0&&(s=t.slice(0,n))!=="xmlns"&&(t=t.slice(n+1)),Ar.hasOwnProperty(s)?{space:Ar[s],local:t}:t}function Zx(t){return function(){var s=this.ownerDocument,n=this.namespaceURI;return n===li&&s.documentElement.namespaceURI===li?s.createElement(t):s.createElementNS(n,t)}}function Qx(t){return function(){return this.ownerDocument.createElementNS(t.space,t.local)}}function yl(t){var s=xa(t);return(s.local?Qx:Zx)(s)}function Jx(){}function Di(t){return t==null?Jx:function(){return this.querySelector(t)}}function eg(t){typeof t!="function"&&(t=Di(t));for(var s=this._groups,n=s.length,a=new Array(n),i=0;i<n;++i)for(var r=s[i],o=r.length,l=a[i]=new Array(o),c,h,m=0;m<o;++m)(c=r[m])&&(h=t.call(c,c.__data__,m,r))&&("__data__"in c&&(h.__data__=c.__data__),l[m]=h);return new it(a,this._parents)}function tg(t){return t==null?[]:Array.isArray(t)?t:Array.from(t)}function sg(){return[]}function vl(t){return t==null?sg:function(){return this.querySelectorAll(t)}}function ng(t){return function(){return tg(t.apply(this,arguments))}}function ag(t){typeof t=="function"?t=ng(t):t=vl(t);for(var s=this._groups,n=s.length,a=[],i=[],r=0;r<n;++r)for(var o=s[r],l=o.length,c,h=0;h<l;++h)(c=o[h])&&(a.push(t.call(c,c.__data__,h,o)),i.push(c));return new it(a,i)}function jl(t){return function(){return this.matches(t)}}function bl(t){return function(s){return s.matches(t)}}var ig=Array.prototype.find;function rg(t){return function(){return ig.call(this.children,t)}}function og(){return this.firstElementChild}function lg(t){return this.select(t==null?og:rg(typeof t=="function"?t:bl(t)))}var cg=Array.prototype.filter;function dg(){return Array.from(this.children)}function ug(t){return function(){return cg.call(this.children,t)}}function hg(t){return this.selectAll(t==null?dg:ug(typeof t=="function"?t:bl(t)))}function mg(t){typeof t!="function"&&(t=jl(t));for(var s=this._groups,n=s.length,a=new Array(n),i=0;i<n;++i)for(var r=s[i],o=r.length,l=a[i]=[],c,h=0;h<o;++h)(c=r[h])&&t.call(c,c.__data__,h,r)&&l.push(c);return new it(a,this._parents)}function wl(t){return new Array(t.length)}function fg(){return new it(this._enter||this._groups.map(wl),this._parents)}function ea(t,s){this.ownerDocument=t.ownerDocument,this.namespaceURI=t.namespaceURI,this._next=null,this._parent=t,this.__data__=s}ea.prototype={constructor:ea,appendChild:function(t){return this._parent.insertBefore(t,this._next)},insertBefore:function(t,s){return this._parent.insertBefore(t,s)},querySelector:function(t){return this._parent.querySelector(t)},querySelectorAll:function(t){return this._parent.querySelectorAll(t)}};function pg(t){return function(){return t}}function xg(t,s,n,a,i,r){for(var o=0,l,c=s.length,h=r.length;o<h;++o)(l=s[o])?(l.__data__=r[o],a[o]=l):n[o]=new ea(t,r[o]);for(;o<c;++o)(l=s[o])&&(i[o]=l)}function gg(t,s,n,a,i,r,o){var l,c,h=new Map,m=s.length,d=r.length,u=new Array(m),p;for(l=0;l<m;++l)(c=s[l])&&(u[l]=p=o.call(c,c.__data__,l,s)+"",h.has(p)?i[l]=c:h.set(p,c));for(l=0;l<d;++l)p=o.call(t,r[l],l,r)+"",(c=h.get(p))?(a[l]=c,c.__data__=r[l],h.delete(p)):n[l]=new ea(t,r[l]);for(l=0;l<m;++l)(c=s[l])&&h.get(u[l])===c&&(i[l]=c)}function yg(t){return t.__data__}function vg(t,s){if(!arguments.length)return Array.from(this,yg);var n=s?gg:xg,a=this._parents,i=this._groups;typeof t!="function"&&(t=pg(t));for(var r=i.length,o=new Array(r),l=new Array(r),c=new Array(r),h=0;h<r;++h){var m=a[h],d=i[h],u=d.length,p=jg(t.call(m,m&&m.__data__,h,a)),x=p.length,j=l[h]=new Array(x),v=o[h]=new Array(x),g=c[h]=new Array(u);n(m,d,j,v,g,p,s);for(var b=0,y=0,w,S;b<x;++b)if(w=j[b]){for(b>=y&&(y=b+1);!(S=v[y])&&++y<x;);w._next=S||null}}return o=new it(o,a),o._enter=l,o._exit=c,o}function jg(t){return typeof t=="object"&&"length"in t?t:Array.from(t)}function bg(){return new it(this._exit||this._groups.map(wl),this._parents)}function wg(t,s,n){var a=this.enter(),i=this,r=this.exit();return typeof t=="function"?(a=t(a),a&&(a=a.selection())):a=a.append(t+""),s!=null&&(i=s(i),i&&(i=i.selection())),n==null?r.remove():n(r),a&&i?a.merge(i).order():i}function kg(t){for(var s=t.selection?t.selection():t,n=this._groups,a=s._groups,i=n.length,r=a.length,o=Math.min(i,r),l=new Array(i),c=0;c<o;++c)for(var h=n[c],m=a[c],d=h.length,u=l[c]=new Array(d),p,x=0;x<d;++x)(p=h[x]||m[x])&&(u[x]=p);for(;c<i;++c)l[c]=n[c];return new it(l,this._parents)}function Ng(){for(var t=this._groups,s=-1,n=t.length;++s<n;)for(var a=t[s],i=a.length-1,r=a[i],o;--i>=0;)(o=a[i])&&(r&&o.compareDocumentPosition(r)^4&&r.parentNode.insertBefore(o,r),r=o);return this}function Sg(t){t||(t=Cg);function s(d,u){return d&&u?t(d.__data__,u.__data__):!d-!u}for(var n=this._groups,a=n.length,i=new Array(a),r=0;r<a;++r){for(var o=n[r],l=o.length,c=i[r]=new Array(l),h,m=0;m<l;++m)(h=o[m])&&(c[m]=h);c.sort(s)}return new it(i,this._parents).order()}function Cg(t,s){return t<s?-1:t>s?1:t>=s?0:NaN}function zg(){var t=arguments[0];return arguments[0]=this,t.apply(null,arguments),this}function Mg(){return Array.from(this)}function $g(){for(var t=this._groups,s=0,n=t.length;s<n;++s)for(var a=t[s],i=0,r=a.length;i<r;++i){var o=a[i];if(o)return o}return null}function Eg(){let t=0;for(const s of this)++t;return t}function _g(){return!this.node()}function Tg(t){for(var s=this._groups,n=0,a=s.length;n<a;++n)for(var i=s[n],r=0,o=i.length,l;r<o;++r)(l=i[r])&&t.call(l,l.__data__,r,i);return this}function Ag(t){return function(){this.removeAttribute(t)}}function Rg(t){return function(){this.removeAttributeNS(t.space,t.local)}}function Ig(t,s){return function(){this.setAttribute(t,s)}}function Lg(t,s){return function(){this.setAttributeNS(t.space,t.local,s)}}function Pg(t,s){return function(){var n=s.apply(this,arguments);n==null?this.removeAttribute(t):this.setAttribute(t,n)}}function Dg(t,s){return function(){var n=s.apply(this,arguments);n==null?this.removeAttributeNS(t.space,t.local):this.setAttributeNS(t.space,t.local,n)}}function Fg(t,s){var n=xa(t);if(arguments.length<2){var a=this.node();return n.local?a.getAttributeNS(n.space,n.local):a.getAttribute(n)}return this.each((s==null?n.local?Rg:Ag:typeof s=="function"?n.local?Dg:Pg:n.local?Lg:Ig)(n,s))}function kl(t){return t.ownerDocument&&t.ownerDocument.defaultView||t.document&&t||t.defaultView}function Og(t){return function(){this.style.removeProperty(t)}}function Bg(t,s,n){return function(){this.style.setProperty(t,s,n)}}function Hg(t,s,n){return function(){var a=s.apply(this,arguments);a==null?this.style.removeProperty(t):this.style.setProperty(t,a,n)}}function Vg(t,s,n){return arguments.length>1?this.each((s==null?Og:typeof s=="function"?Hg:Bg)(t,s,n??"")):zs(this.node(),t)}function zs(t,s){return t.style.getPropertyValue(s)||kl(t).getComputedStyle(t,null).getPropertyValue(s)}function Ug(t){return function(){delete this[t]}}function qg(t,s){return function(){this[t]=s}}function Wg(t,s){return function(){var n=s.apply(this,arguments);n==null?delete this[t]:this[t]=n}}function Gg(t,s){return arguments.length>1?this.each((s==null?Ug:typeof s=="function"?Wg:qg)(t,s)):this.node()[t]}function Nl(t){return t.trim().split(/^|\s+/)}function Fi(t){return t.classList||new Sl(t)}function Sl(t){this._node=t,this._names=Nl(t.getAttribute("class")||"")}Sl.prototype={add:function(t){var s=this._names.indexOf(t);s<0&&(this._names.push(t),this._node.setAttribute("class",this._names.join(" ")))},remove:function(t){var s=this._names.indexOf(t);s>=0&&(this._names.splice(s,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(t){return this._names.indexOf(t)>=0}};function Cl(t,s){for(var n=Fi(t),a=-1,i=s.length;++a<i;)n.add(s[a])}function zl(t,s){for(var n=Fi(t),a=-1,i=s.length;++a<i;)n.remove(s[a])}function Yg(t){return function(){Cl(this,t)}}function Xg(t){return function(){zl(this,t)}}function Kg(t,s){return function(){(s.apply(this,arguments)?Cl:zl)(this,t)}}function Zg(t,s){var n=Nl(t+"");if(arguments.length<2){for(var a=Fi(this.node()),i=-1,r=n.length;++i<r;)if(!a.contains(n[i]))return!1;return!0}return this.each((typeof s=="function"?Kg:s?Yg:Xg)(n,s))}function Qg(){this.textContent=""}function Jg(t){return function(){this.textContent=t}}function ey(t){return function(){var s=t.apply(this,arguments);this.textContent=s??""}}function ty(t){return arguments.length?this.each(t==null?Qg:(typeof t=="function"?ey:Jg)(t)):this.node().textContent}function sy(){this.innerHTML=""}function ny(t){return function(){this.innerHTML=t}}function ay(t){return function(){var s=t.apply(this,arguments);this.innerHTML=s??""}}function iy(t){return arguments.length?this.each(t==null?sy:(typeof t=="function"?ay:ny)(t)):this.node().innerHTML}function ry(){this.nextSibling&&this.parentNode.appendChild(this)}function oy(){return this.each(ry)}function ly(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function cy(){return this.each(ly)}function dy(t){var s=typeof t=="function"?t:yl(t);return this.select(function(){return this.appendChild(s.apply(this,arguments))})}function uy(){return null}function hy(t,s){var n=typeof t=="function"?t:yl(t),a=s==null?uy:typeof s=="function"?s:Di(s);return this.select(function(){return this.insertBefore(n.apply(this,arguments),a.apply(this,arguments)||null)})}function my(){var t=this.parentNode;t&&t.removeChild(this)}function fy(){return this.each(my)}function py(){var t=this.cloneNode(!1),s=this.parentNode;return s?s.insertBefore(t,this.nextSibling):t}function xy(){var t=this.cloneNode(!0),s=this.parentNode;return s?s.insertBefore(t,this.nextSibling):t}function gy(t){return this.select(t?xy:py)}function yy(t){return arguments.length?this.property("__data__",t):this.node().__data__}function vy(t){return function(s){t.call(this,s,this.__data__)}}function jy(t){return t.trim().split(/^|\s+/).map(function(s){var n="",a=s.indexOf(".");return a>=0&&(n=s.slice(a+1),s=s.slice(0,a)),{type:s,name:n}})}function by(t){return function(){var s=this.__on;if(s){for(var n=0,a=-1,i=s.length,r;n<i;++n)r=s[n],(!t.type||r.type===t.type)&&r.name===t.name?this.removeEventListener(r.type,r.listener,r.options):s[++a]=r;++a?s.length=a:delete this.__on}}}function wy(t,s,n){return function(){var a=this.__on,i,r=vy(s);if(a){for(var o=0,l=a.length;o<l;++o)if((i=a[o]).type===t.type&&i.name===t.name){this.removeEventListener(i.type,i.listener,i.options),this.addEventListener(i.type,i.listener=r,i.options=n),i.value=s;return}}this.addEventListener(t.type,r,n),i={type:t.type,name:t.name,value:s,listener:r,options:n},a?a.push(i):this.__on=[i]}}function ky(t,s,n){var a=jy(t+""),i,r=a.length,o;if(arguments.length<2){var l=this.node().__on;if(l){for(var c=0,h=l.length,m;c<h;++c)for(i=0,m=l[c];i<r;++i)if((o=a[i]).type===m.type&&o.name===m.name)return m.value}return}for(l=s?wy:by,i=0;i<r;++i)this.each(l(a[i],s,n));return this}function Ml(t,s,n){var a=kl(t),i=a.CustomEvent;typeof i=="function"?i=new i(s,n):(i=a.document.createEvent("Event"),n?(i.initEvent(s,n.bubbles,n.cancelable),i.detail=n.detail):i.initEvent(s,!1,!1)),t.dispatchEvent(i)}function Ny(t,s){return function(){return Ml(this,t,s)}}function Sy(t,s){return function(){return Ml(this,t,s.apply(this,arguments))}}function Cy(t,s){return this.each((typeof s=="function"?Sy:Ny)(t,s))}function*zy(){for(var t=this._groups,s=0,n=t.length;s<n;++s)for(var a=t[s],i=0,r=a.length,o;i<r;++i)(o=a[i])&&(yield o)}var $l=[null];function it(t,s){this._groups=t,this._parents=s}function xn(){return new it([[document.documentElement]],$l)}function My(){return this}it.prototype=xn.prototype={constructor:it,select:eg,selectAll:ag,selectChild:lg,selectChildren:hg,filter:mg,data:vg,enter:fg,exit:bg,join:wg,merge:kg,selection:My,order:Ng,sort:Sg,call:zg,nodes:Mg,node:$g,size:Eg,empty:_g,each:Tg,attr:Fg,style:Vg,property:Gg,classed:Zg,text:ty,html:iy,raise:oy,lower:cy,append:dy,insert:hy,remove:fy,clone:gy,datum:yy,on:ky,dispatch:Cy,[Symbol.iterator]:zy};function at(t){return typeof t=="string"?new it([[document.querySelector(t)]],[document.documentElement]):new it([[t]],$l)}function $y(t){let s;for(;s=t.sourceEvent;)t=s;return t}function dt(t,s){if(t=$y(t),s===void 0&&(s=t.currentTarget),s){var n=s.ownerSVGElement||s;if(n.createSVGPoint){var a=n.createSVGPoint();return a.x=t.clientX,a.y=t.clientY,a=a.matrixTransform(s.getScreenCTM().inverse()),[a.x,a.y]}if(s.getBoundingClientRect){var i=s.getBoundingClientRect();return[t.clientX-i.left-s.clientLeft,t.clientY-i.top-s.clientTop]}}return[t.pageX,t.pageY]}const Ey={passive:!1},nn={capture:!0,passive:!1};function Ua(t){t.stopImmediatePropagation()}function vs(t){t.preventDefault(),t.stopImmediatePropagation()}function El(t){var s=t.document.documentElement,n=at(t).on("dragstart.drag",vs,nn);"onselectstart"in s?n.on("selectstart.drag",vs,nn):(s.__noselect=s.style.MozUserSelect,s.style.MozUserSelect="none")}function _l(t,s){var n=t.document.documentElement,a=at(t).on("dragstart.drag",null);s&&(a.on("click.drag",vs,nn),setTimeout(function(){a.on("click.drag",null)},0)),"onselectstart"in n?a.on("selectstart.drag",null):(n.style.MozUserSelect=n.__noselect,delete n.__noselect)}const En=t=>()=>t;function ci(t,{sourceEvent:s,subject:n,target:a,identifier:i,active:r,x:o,y:l,dx:c,dy:h,dispatch:m}){Object.defineProperties(this,{type:{value:t,enumerable:!0,configurable:!0},sourceEvent:{value:s,enumerable:!0,configurable:!0},subject:{value:n,enumerable:!0,configurable:!0},target:{value:a,enumerable:!0,configurable:!0},identifier:{value:i,enumerable:!0,configurable:!0},active:{value:r,enumerable:!0,configurable:!0},x:{value:o,enumerable:!0,configurable:!0},y:{value:l,enumerable:!0,configurable:!0},dx:{value:c,enumerable:!0,configurable:!0},dy:{value:h,enumerable:!0,configurable:!0},_:{value:m}})}ci.prototype.on=function(){var t=this._.on.apply(this._,arguments);return t===this._?this:t};function _y(t){return!t.ctrlKey&&!t.button}function Ty(){return this.parentNode}function Ay(t,s){return s??{x:t.x,y:t.y}}function Ry(){return navigator.maxTouchPoints||"ontouchstart"in this}function Tl(){var t=_y,s=Ty,n=Ay,a=Ry,i={},r=pa("start","drag","end"),o=0,l,c,h,m,d=0;function u(w){w.on("mousedown.drag",p).filter(a).on("touchstart.drag",v).on("touchmove.drag",g,Ey).on("touchend.drag touchcancel.drag",b).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function p(w,S){if(!(m||!t.call(this,w,S))){var $=y(this,s.call(this,w,S),w,S,"mouse");$&&(at(w.view).on("mousemove.drag",x,nn).on("mouseup.drag",j,nn),El(w.view),Ua(w),h=!1,l=w.clientX,c=w.clientY,$("start",w))}}function x(w){if(vs(w),!h){var S=w.clientX-l,$=w.clientY-c;h=S*S+$*$>d}i.mouse("drag",w)}function j(w){at(w.view).on("mousemove.drag mouseup.drag",null),_l(w.view,h),vs(w),i.mouse("end",w)}function v(w,S){if(t.call(this,w,S)){var $=w.changedTouches,M=s.call(this,w,S),z=$.length,A,k;for(A=0;A<z;++A)(k=y(this,M,w,S,$[A].identifier,$[A]))&&(Ua(w),k("start",w,$[A]))}}function g(w){var S=w.changedTouches,$=S.length,M,z;for(M=0;M<$;++M)(z=i[S[M].identifier])&&(vs(w),z("drag",w,S[M]))}function b(w){var S=w.changedTouches,$=S.length,M,z;for(m&&clearTimeout(m),m=setTimeout(function(){m=null},500),M=0;M<$;++M)(z=i[S[M].identifier])&&(Ua(w),z("end",w,S[M]))}function y(w,S,$,M,z,A){var k=r.copy(),C=dt(A||$,S),_,P,N;if((N=n.call(w,new ci("beforestart",{sourceEvent:$,target:u,identifier:z,active:o,x:C[0],y:C[1],dx:0,dy:0,dispatch:k}),M))!=null)return _=N.x-C[0]||0,P=N.y-C[1]||0,function T(L,R,F){var E=C,D;switch(L){case"start":i[z]=T,D=o++;break;case"end":delete i[z],--o;case"drag":C=dt(F||R,S),D=o;break}k.call(L,w,new ci(L,{sourceEvent:R,subject:N,target:u,identifier:z,active:D,x:C[0]+_,y:C[1]+P,dx:C[0]-E[0],dy:C[1]-E[1],dispatch:k}),M)}}return u.filter=function(w){return arguments.length?(t=typeof w=="function"?w:En(!!w),u):t},u.container=function(w){return arguments.length?(s=typeof w=="function"?w:En(w),u):s},u.subject=function(w){return arguments.length?(n=typeof w=="function"?w:En(w),u):n},u.touchable=function(w){return arguments.length?(a=typeof w=="function"?w:En(!!w),u):a},u.on=function(){var w=r.on.apply(r,arguments);return w===r?u:w},u.clickDistance=function(w){return arguments.length?(d=(w=+w)*w,u):Math.sqrt(d)},u}function Oi(t,s,n){t.prototype=s.prototype=n,n.constructor=t}function Al(t,s){var n=Object.create(t.prototype);for(var a in s)n[a]=s[a];return n}function gn(){}var an=.7,ta=1/an,js="\\s*([+-]?\\d+)\\s*",rn="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",Nt="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",Iy=/^#([0-9a-f]{3,8})$/,Ly=new RegExp(`^rgb\\(${js},${js},${js}\\)$`),Py=new RegExp(`^rgb\\(${Nt},${Nt},${Nt}\\)$`),Dy=new RegExp(`^rgba\\(${js},${js},${js},${rn}\\)$`),Fy=new RegExp(`^rgba\\(${Nt},${Nt},${Nt},${rn}\\)$`),Oy=new RegExp(`^hsl\\(${rn},${Nt},${Nt}\\)$`),By=new RegExp(`^hsla\\(${rn},${Nt},${Nt},${rn}\\)$`),Rr={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};Oi(gn,ns,{copy(t){return Object.assign(new this.constructor,this,t)},displayable(){return this.rgb().displayable()},hex:Ir,formatHex:Ir,formatHex8:Hy,formatHsl:Vy,formatRgb:Lr,toString:Lr});function Ir(){return this.rgb().formatHex()}function Hy(){return this.rgb().formatHex8()}function Vy(){return Rl(this).formatHsl()}function Lr(){return this.rgb().formatRgb()}function ns(t){var s,n;return t=(t+"").trim().toLowerCase(),(s=Iy.exec(t))?(n=s[1].length,s=parseInt(s[1],16),n===6?Pr(s):n===3?new Ke(s>>8&15|s>>4&240,s>>4&15|s&240,(s&15)<<4|s&15,1):n===8?_n(s>>24&255,s>>16&255,s>>8&255,(s&255)/255):n===4?_n(s>>12&15|s>>8&240,s>>8&15|s>>4&240,s>>4&15|s&240,((s&15)<<4|s&15)/255):null):(s=Ly.exec(t))?new Ke(s[1],s[2],s[3],1):(s=Py.exec(t))?new Ke(s[1]*255/100,s[2]*255/100,s[3]*255/100,1):(s=Dy.exec(t))?_n(s[1],s[2],s[3],s[4]):(s=Fy.exec(t))?_n(s[1]*255/100,s[2]*255/100,s[3]*255/100,s[4]):(s=Oy.exec(t))?Or(s[1],s[2]/100,s[3]/100,1):(s=By.exec(t))?Or(s[1],s[2]/100,s[3]/100,s[4]):Rr.hasOwnProperty(t)?Pr(Rr[t]):t==="transparent"?new Ke(NaN,NaN,NaN,0):null}function Pr(t){return new Ke(t>>16&255,t>>8&255,t&255,1)}function _n(t,s,n,a){return a<=0&&(t=s=n=NaN),new Ke(t,s,n,a)}function Uy(t){return t instanceof gn||(t=ns(t)),t?(t=t.rgb(),new Ke(t.r,t.g,t.b,t.opacity)):new Ke}function di(t,s,n,a){return arguments.length===1?Uy(t):new Ke(t,s,n,a??1)}function Ke(t,s,n,a){this.r=+t,this.g=+s,this.b=+n,this.opacity=+a}Oi(Ke,di,Al(gn,{brighter(t){return t=t==null?ta:Math.pow(ta,t),new Ke(this.r*t,this.g*t,this.b*t,this.opacity)},darker(t){return t=t==null?an:Math.pow(an,t),new Ke(this.r*t,this.g*t,this.b*t,this.opacity)},rgb(){return this},clamp(){return new Ke(Kt(this.r),Kt(this.g),Kt(this.b),sa(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:Dr,formatHex:Dr,formatHex8:qy,formatRgb:Fr,toString:Fr}));function Dr(){return`#${Xt(this.r)}${Xt(this.g)}${Xt(this.b)}`}function qy(){return`#${Xt(this.r)}${Xt(this.g)}${Xt(this.b)}${Xt((isNaN(this.opacity)?1:this.opacity)*255)}`}function Fr(){const t=sa(this.opacity);return`${t===1?"rgb(":"rgba("}${Kt(this.r)}, ${Kt(this.g)}, ${Kt(this.b)}${t===1?")":`, ${t})`}`}function sa(t){return isNaN(t)?1:Math.max(0,Math.min(1,t))}function Kt(t){return Math.max(0,Math.min(255,Math.round(t)||0))}function Xt(t){return t=Kt(t),(t<16?"0":"")+t.toString(16)}function Or(t,s,n,a){return a<=0?t=s=n=NaN:n<=0||n>=1?t=s=NaN:s<=0&&(t=NaN),new ut(t,s,n,a)}function Rl(t){if(t instanceof ut)return new ut(t.h,t.s,t.l,t.opacity);if(t instanceof gn||(t=ns(t)),!t)return new ut;if(t instanceof ut)return t;t=t.rgb();var s=t.r/255,n=t.g/255,a=t.b/255,i=Math.min(s,n,a),r=Math.max(s,n,a),o=NaN,l=r-i,c=(r+i)/2;return l?(s===r?o=(n-a)/l+(n<a)*6:n===r?o=(a-s)/l+2:o=(s-n)/l+4,l/=c<.5?r+i:2-r-i,o*=60):l=c>0&&c<1?0:o,new ut(o,l,c,t.opacity)}function Wy(t,s,n,a){return arguments.length===1?Rl(t):new ut(t,s,n,a??1)}function ut(t,s,n,a){this.h=+t,this.s=+s,this.l=+n,this.opacity=+a}Oi(ut,Wy,Al(gn,{brighter(t){return t=t==null?ta:Math.pow(ta,t),new ut(this.h,this.s,this.l*t,this.opacity)},darker(t){return t=t==null?an:Math.pow(an,t),new ut(this.h,this.s,this.l*t,this.opacity)},rgb(){var t=this.h%360+(this.h<0)*360,s=isNaN(t)||isNaN(this.s)?0:this.s,n=this.l,a=n+(n<.5?n:1-n)*s,i=2*n-a;return new Ke(qa(t>=240?t-240:t+120,i,a),qa(t,i,a),qa(t<120?t+240:t-120,i,a),this.opacity)},clamp(){return new ut(Br(this.h),Tn(this.s),Tn(this.l),sa(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const t=sa(this.opacity);return`${t===1?"hsl(":"hsla("}${Br(this.h)}, ${Tn(this.s)*100}%, ${Tn(this.l)*100}%${t===1?")":`, ${t})`}`}}));function Br(t){return t=(t||0)%360,t<0?t+360:t}function Tn(t){return Math.max(0,Math.min(1,t||0))}function qa(t,s,n){return(t<60?s+(n-s)*t/60:t<180?n:t<240?s+(n-s)*(240-t)/60:s)*255}const Bi=t=>()=>t;function Gy(t,s){return function(n){return t+n*s}}function Yy(t,s,n){return t=Math.pow(t,n),s=Math.pow(s,n)-t,n=1/n,function(a){return Math.pow(t+a*s,n)}}function Xy(t){return(t=+t)==1?Il:function(s,n){return n-s?Yy(s,n,t):Bi(isNaN(s)?n:s)}}function Il(t,s){var n=s-t;return n?Gy(t,n):Bi(isNaN(t)?s:t)}const na=function t(s){var n=Xy(s);function a(i,r){var o=n((i=di(i)).r,(r=di(r)).r),l=n(i.g,r.g),c=n(i.b,r.b),h=Il(i.opacity,r.opacity);return function(m){return i.r=o(m),i.g=l(m),i.b=c(m),i.opacity=h(m),i+""}}return a.gamma=t,a}(1);function Ky(t,s){s||(s=[]);var n=t?Math.min(s.length,t.length):0,a=s.slice(),i;return function(r){for(i=0;i<n;++i)a[i]=t[i]*(1-r)+s[i]*r;return a}}function Zy(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)}function Qy(t,s){var n=s?s.length:0,a=t?Math.min(n,t.length):0,i=new Array(a),r=new Array(n),o;for(o=0;o<a;++o)i[o]=Xs(t[o],s[o]);for(;o<n;++o)r[o]=s[o];return function(l){for(o=0;o<a;++o)r[o]=i[o](l);return r}}function Jy(t,s){var n=new Date;return t=+t,s=+s,function(a){return n.setTime(t*(1-a)+s*a),n}}function kt(t,s){return t=+t,s=+s,function(n){return t*(1-n)+s*n}}function ev(t,s){var n={},a={},i;(t===null||typeof t!="object")&&(t={}),(s===null||typeof s!="object")&&(s={});for(i in s)i in t?n[i]=Xs(t[i],s[i]):a[i]=s[i];return function(r){for(i in n)a[i]=n[i](r);return a}}var ui=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,Wa=new RegExp(ui.source,"g");function tv(t){return function(){return t}}function sv(t){return function(s){return t(s)+""}}function Ll(t,s){var n=ui.lastIndex=Wa.lastIndex=0,a,i,r,o=-1,l=[],c=[];for(t=t+"",s=s+"";(a=ui.exec(t))&&(i=Wa.exec(s));)(r=i.index)>n&&(r=s.slice(n,r),l[o]?l[o]+=r:l[++o]=r),(a=a[0])===(i=i[0])?l[o]?l[o]+=i:l[++o]=i:(l[++o]=null,c.push({i:o,x:kt(a,i)})),n=Wa.lastIndex;return n<s.length&&(r=s.slice(n),l[o]?l[o]+=r:l[++o]=r),l.length<2?c[0]?sv(c[0].x):tv(s):(s=c.length,function(h){for(var m=0,d;m<s;++m)l[(d=c[m]).i]=d.x(h);return l.join("")})}function Xs(t,s){var n=typeof s,a;return s==null||n==="boolean"?Bi(s):(n==="number"?kt:n==="string"?(a=ns(s))?(s=a,na):Ll:s instanceof ns?na:s instanceof Date?Jy:Zy(s)?Ky:Array.isArray(s)?Qy:typeof s.valueOf!="function"&&typeof s.toString!="function"||isNaN(s)?ev:kt)(t,s)}var Hr=180/Math.PI,hi={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function Pl(t,s,n,a,i,r){var o,l,c;return(o=Math.sqrt(t*t+s*s))&&(t/=o,s/=o),(c=t*n+s*a)&&(n-=t*c,a-=s*c),(l=Math.sqrt(n*n+a*a))&&(n/=l,a/=l,c/=l),t*a<s*n&&(t=-t,s=-s,c=-c,o=-o),{translateX:i,translateY:r,rotate:Math.atan2(s,t)*Hr,skewX:Math.atan(c)*Hr,scaleX:o,scaleY:l}}var An;function nv(t){const s=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(t+"");return s.isIdentity?hi:Pl(s.a,s.b,s.c,s.d,s.e,s.f)}function av(t){return t==null||(An||(An=document.createElementNS("http://www.w3.org/2000/svg","g")),An.setAttribute("transform",t),!(t=An.transform.baseVal.consolidate()))?hi:(t=t.matrix,Pl(t.a,t.b,t.c,t.d,t.e,t.f))}function Dl(t,s,n,a){function i(h){return h.length?h.pop()+" ":""}function r(h,m,d,u,p,x){if(h!==d||m!==u){var j=p.push("translate(",null,s,null,n);x.push({i:j-4,x:kt(h,d)},{i:j-2,x:kt(m,u)})}else(d||u)&&p.push("translate("+d+s+u+n)}function o(h,m,d,u){h!==m?(h-m>180?m+=360:m-h>180&&(h+=360),u.push({i:d.push(i(d)+"rotate(",null,a)-2,x:kt(h,m)})):m&&d.push(i(d)+"rotate("+m+a)}function l(h,m,d,u){h!==m?u.push({i:d.push(i(d)+"skewX(",null,a)-2,x:kt(h,m)}):m&&d.push(i(d)+"skewX("+m+a)}function c(h,m,d,u,p,x){if(h!==d||m!==u){var j=p.push(i(p)+"scale(",null,",",null,")");x.push({i:j-4,x:kt(h,d)},{i:j-2,x:kt(m,u)})}else(d!==1||u!==1)&&p.push(i(p)+"scale("+d+","+u+")")}return function(h,m){var d=[],u=[];return h=t(h),m=t(m),r(h.translateX,h.translateY,m.translateX,m.translateY,d,u),o(h.rotate,m.rotate,d,u),l(h.skewX,m.skewX,d,u),c(h.scaleX,h.scaleY,m.scaleX,m.scaleY,d,u),h=m=null,function(p){for(var x=-1,j=u.length,v;++x<j;)d[(v=u[x]).i]=v.x(p);return d.join("")}}}var iv=Dl(nv,"px, ","px)","deg)"),rv=Dl(av,", ",")",")"),ov=1e-12;function Vr(t){return((t=Math.exp(t))+1/t)/2}function lv(t){return((t=Math.exp(t))-1/t)/2}function cv(t){return((t=Math.exp(2*t))-1)/(t+1)}const Un=function t(s,n,a){function i(r,o){var l=r[0],c=r[1],h=r[2],m=o[0],d=o[1],u=o[2],p=m-l,x=d-c,j=p*p+x*x,v,g;if(j<ov)g=Math.log(u/h)/s,v=function(M){return[l+M*p,c+M*x,h*Math.exp(s*M*g)]};else{var b=Math.sqrt(j),y=(u*u-h*h+a*j)/(2*h*n*b),w=(u*u-h*h-a*j)/(2*u*n*b),S=Math.log(Math.sqrt(y*y+1)-y),$=Math.log(Math.sqrt(w*w+1)-w);g=($-S)/s,v=function(M){var z=M*g,A=Vr(S),k=h/(n*b)*(A*cv(s*z+S)-lv(S));return[l+k*p,c+k*x,h*A/Vr(s*z+S)]}}return v.duration=g*1e3*s/Math.SQRT2,v}return i.rho=function(r){var o=Math.max(.001,+r),l=o*o,c=l*l;return t(o,l,c)},i}(Math.SQRT2,2,4);var Ms=0,Ws=0,Us=0,Fl=1e3,aa,Gs,ia=0,as=0,ga=0,on=typeof performance=="object"&&performance.now?performance:Date,Ol=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(t){setTimeout(t,17)};function Hi(){return as||(Ol(dv),as=on.now()+ga)}function dv(){as=0}function ra(){this._call=this._time=this._next=null}ra.prototype=Bl.prototype={constructor:ra,restart:function(t,s,n){if(typeof t!="function")throw new TypeError("callback is not a function");n=(n==null?Hi():+n)+(s==null?0:+s),!this._next&&Gs!==this&&(Gs?Gs._next=this:aa=this,Gs=this),this._call=t,this._time=n,mi()},stop:function(){this._call&&(this._call=null,this._time=1/0,mi())}};function Bl(t,s,n){var a=new ra;return a.restart(t,s,n),a}function uv(){Hi(),++Ms;for(var t=aa,s;t;)(s=as-t._time)>=0&&t._call.call(void 0,s),t=t._next;--Ms}function Ur(){as=(ia=on.now())+ga,Ms=Ws=0;try{uv()}finally{Ms=0,mv(),as=0}}function hv(){var t=on.now(),s=t-ia;s>Fl&&(ga-=s,ia=t)}function mv(){for(var t,s=aa,n,a=1/0;s;)s._call?(a>s._time&&(a=s._time),t=s,s=s._next):(n=s._next,s._next=null,s=t?t._next=n:aa=n);Gs=t,mi(a)}function mi(t){if(!Ms){Ws&&(Ws=clearTimeout(Ws));var s=t-as;s>24?(t<1/0&&(Ws=setTimeout(Ur,t-on.now()-ga)),Us&&(Us=clearInterval(Us))):(Us||(ia=on.now(),Us=setInterval(hv,Fl)),Ms=1,Ol(Ur))}}function qr(t,s,n){var a=new ra;return s=s==null?0:+s,a.restart(i=>{a.stop(),t(i+s)},s,n),a}var fv=pa("start","end","cancel","interrupt"),pv=[],Hl=0,Wr=1,fi=2,qn=3,Gr=4,pi=5,Wn=6;function ya(t,s,n,a,i,r){var o=t.__transition;if(!o)t.__transition={};else if(n in o)return;xv(t,n,{name:s,index:a,group:i,on:fv,tween:pv,time:r.time,delay:r.delay,duration:r.duration,ease:r.ease,timer:null,state:Hl})}function Vi(t,s){var n=jt(t,s);if(n.state>Hl)throw new Error("too late; already scheduled");return n}function Ct(t,s){var n=jt(t,s);if(n.state>qn)throw new Error("too late; already running");return n}function jt(t,s){var n=t.__transition;if(!n||!(n=n[s]))throw new Error("transition not found");return n}function xv(t,s,n){var a=t.__transition,i;a[s]=n,n.timer=Bl(r,0,n.time);function r(h){n.state=Wr,n.timer.restart(o,n.delay,n.time),n.delay<=h&&o(h-n.delay)}function o(h){var m,d,u,p;if(n.state!==Wr)return c();for(m in a)if(p=a[m],p.name===n.name){if(p.state===qn)return qr(o);p.state===Gr?(p.state=Wn,p.timer.stop(),p.on.call("interrupt",t,t.__data__,p.index,p.group),delete a[m]):+m<s&&(p.state=Wn,p.timer.stop(),p.on.call("cancel",t,t.__data__,p.index,p.group),delete a[m])}if(qr(function(){n.state===qn&&(n.state=Gr,n.timer.restart(l,n.delay,n.time),l(h))}),n.state=fi,n.on.call("start",t,t.__data__,n.index,n.group),n.state===fi){for(n.state=qn,i=new Array(u=n.tween.length),m=0,d=-1;m<u;++m)(p=n.tween[m].value.call(t,t.__data__,n.index,n.group))&&(i[++d]=p);i.length=d+1}}function l(h){for(var m=h<n.duration?n.ease.call(null,h/n.duration):(n.timer.restart(c),n.state=pi,1),d=-1,u=i.length;++d<u;)i[d].call(t,m);n.state===pi&&(n.on.call("end",t,t.__data__,n.index,n.group),c())}function c(){n.state=Wn,n.timer.stop(),delete a[s];for(var h in a)return;delete t.__transition}}function Gn(t,s){var n=t.__transition,a,i,r=!0,o;if(n){s=s==null?null:s+"";for(o in n){if((a=n[o]).name!==s){r=!1;continue}i=a.state>fi&&a.state<pi,a.state=Wn,a.timer.stop(),a.on.call(i?"interrupt":"cancel",t,t.__data__,a.index,a.group),delete n[o]}r&&delete t.__transition}}function gv(t){return this.each(function(){Gn(this,t)})}function yv(t,s){var n,a;return function(){var i=Ct(this,t),r=i.tween;if(r!==n){a=n=r;for(var o=0,l=a.length;o<l;++o)if(a[o].name===s){a=a.slice(),a.splice(o,1);break}}i.tween=a}}function vv(t,s,n){var a,i;if(typeof n!="function")throw new Error;return function(){var r=Ct(this,t),o=r.tween;if(o!==a){i=(a=o).slice();for(var l={name:s,value:n},c=0,h=i.length;c<h;++c)if(i[c].name===s){i[c]=l;break}c===h&&i.push(l)}r.tween=i}}function jv(t,s){var n=this._id;if(t+="",arguments.length<2){for(var a=jt(this.node(),n).tween,i=0,r=a.length,o;i<r;++i)if((o=a[i]).name===t)return o.value;return null}return this.each((s==null?yv:vv)(n,t,s))}function Ui(t,s,n){var a=t._id;return t.each(function(){var i=Ct(this,a);(i.value||(i.value={}))[s]=n.apply(this,arguments)}),function(i){return jt(i,a).value[s]}}function Vl(t,s){var n;return(typeof s=="number"?kt:s instanceof ns?na:(n=ns(s))?(s=n,na):Ll)(t,s)}function bv(t){return function(){this.removeAttribute(t)}}function wv(t){return function(){this.removeAttributeNS(t.space,t.local)}}function kv(t,s,n){var a,i=n+"",r;return function(){var o=this.getAttribute(t);return o===i?null:o===a?r:r=s(a=o,n)}}function Nv(t,s,n){var a,i=n+"",r;return function(){var o=this.getAttributeNS(t.space,t.local);return o===i?null:o===a?r:r=s(a=o,n)}}function Sv(t,s,n){var a,i,r;return function(){var o,l=n(this),c;return l==null?void this.removeAttribute(t):(o=this.getAttribute(t),c=l+"",o===c?null:o===a&&c===i?r:(i=c,r=s(a=o,l)))}}function Cv(t,s,n){var a,i,r;return function(){var o,l=n(this),c;return l==null?void this.removeAttributeNS(t.space,t.local):(o=this.getAttributeNS(t.space,t.local),c=l+"",o===c?null:o===a&&c===i?r:(i=c,r=s(a=o,l)))}}function zv(t,s){var n=xa(t),a=n==="transform"?rv:Vl;return this.attrTween(t,typeof s=="function"?(n.local?Cv:Sv)(n,a,Ui(this,"attr."+t,s)):s==null?(n.local?wv:bv)(n):(n.local?Nv:kv)(n,a,s))}function Mv(t,s){return function(n){this.setAttribute(t,s.call(this,n))}}function $v(t,s){return function(n){this.setAttributeNS(t.space,t.local,s.call(this,n))}}function Ev(t,s){var n,a;function i(){var r=s.apply(this,arguments);return r!==a&&(n=(a=r)&&$v(t,r)),n}return i._value=s,i}function _v(t,s){var n,a;function i(){var r=s.apply(this,arguments);return r!==a&&(n=(a=r)&&Mv(t,r)),n}return i._value=s,i}function Tv(t,s){var n="attr."+t;if(arguments.length<2)return(n=this.tween(n))&&n._value;if(s==null)return this.tween(n,null);if(typeof s!="function")throw new Error;var a=xa(t);return this.tween(n,(a.local?Ev:_v)(a,s))}function Av(t,s){return function(){Vi(this,t).delay=+s.apply(this,arguments)}}function Rv(t,s){return s=+s,function(){Vi(this,t).delay=s}}function Iv(t){var s=this._id;return arguments.length?this.each((typeof t=="function"?Av:Rv)(s,t)):jt(this.node(),s).delay}function Lv(t,s){return function(){Ct(this,t).duration=+s.apply(this,arguments)}}function Pv(t,s){return s=+s,function(){Ct(this,t).duration=s}}function Dv(t){var s=this._id;return arguments.length?this.each((typeof t=="function"?Lv:Pv)(s,t)):jt(this.node(),s).duration}function Fv(t,s){if(typeof s!="function")throw new Error;return function(){Ct(this,t).ease=s}}function Ov(t){var s=this._id;return arguments.length?this.each(Fv(s,t)):jt(this.node(),s).ease}function Bv(t,s){return function(){var n=s.apply(this,arguments);if(typeof n!="function")throw new Error;Ct(this,t).ease=n}}function Hv(t){if(typeof t!="function")throw new Error;return this.each(Bv(this._id,t))}function Vv(t){typeof t!="function"&&(t=jl(t));for(var s=this._groups,n=s.length,a=new Array(n),i=0;i<n;++i)for(var r=s[i],o=r.length,l=a[i]=[],c,h=0;h<o;++h)(c=r[h])&&t.call(c,c.__data__,h,r)&&l.push(c);return new It(a,this._parents,this._name,this._id)}function Uv(t){if(t._id!==this._id)throw new Error;for(var s=this._groups,n=t._groups,a=s.length,i=n.length,r=Math.min(a,i),o=new Array(a),l=0;l<r;++l)for(var c=s[l],h=n[l],m=c.length,d=o[l]=new Array(m),u,p=0;p<m;++p)(u=c[p]||h[p])&&(d[p]=u);for(;l<a;++l)o[l]=s[l];return new It(o,this._parents,this._name,this._id)}function qv(t){return(t+"").trim().split(/^|\s+/).every(function(s){var n=s.indexOf(".");return n>=0&&(s=s.slice(0,n)),!s||s==="start"})}function Wv(t,s,n){var a,i,r=qv(s)?Vi:Ct;return function(){var o=r(this,t),l=o.on;l!==a&&(i=(a=l).copy()).on(s,n),o.on=i}}function Gv(t,s){var n=this._id;return arguments.length<2?jt(this.node(),n).on.on(t):this.each(Wv(n,t,s))}function Yv(t){return function(){var s=this.parentNode;for(var n in this.__transition)if(+n!==t)return;s&&s.removeChild(this)}}function Xv(){return this.on("end.remove",Yv(this._id))}function Kv(t){var s=this._name,n=this._id;typeof t!="function"&&(t=Di(t));for(var a=this._groups,i=a.length,r=new Array(i),o=0;o<i;++o)for(var l=a[o],c=l.length,h=r[o]=new Array(c),m,d,u=0;u<c;++u)(m=l[u])&&(d=t.call(m,m.__data__,u,l))&&("__data__"in m&&(d.__data__=m.__data__),h[u]=d,ya(h[u],s,n,u,h,jt(m,n)));return new It(r,this._parents,s,n)}function Zv(t){var s=this._name,n=this._id;typeof t!="function"&&(t=vl(t));for(var a=this._groups,i=a.length,r=[],o=[],l=0;l<i;++l)for(var c=a[l],h=c.length,m,d=0;d<h;++d)if(m=c[d]){for(var u=t.call(m,m.__data__,d,c),p,x=jt(m,n),j=0,v=u.length;j<v;++j)(p=u[j])&&ya(p,s,n,j,u,x);r.push(u),o.push(m)}return new It(r,o,s,n)}var Qv=xn.prototype.constructor;function Jv(){return new Qv(this._groups,this._parents)}function ej(t,s){var n,a,i;return function(){var r=zs(this,t),o=(this.style.removeProperty(t),zs(this,t));return r===o?null:r===n&&o===a?i:i=s(n=r,a=o)}}function Ul(t){return function(){this.style.removeProperty(t)}}function tj(t,s,n){var a,i=n+"",r;return function(){var o=zs(this,t);return o===i?null:o===a?r:r=s(a=o,n)}}function sj(t,s,n){var a,i,r;return function(){var o=zs(this,t),l=n(this),c=l+"";return l==null&&(c=l=(this.style.removeProperty(t),zs(this,t))),o===c?null:o===a&&c===i?r:(i=c,r=s(a=o,l))}}function nj(t,s){var n,a,i,r="style."+s,o="end."+r,l;return function(){var c=Ct(this,t),h=c.on,m=c.value[r]==null?l||(l=Ul(s)):void 0;(h!==n||i!==m)&&(a=(n=h).copy()).on(o,i=m),c.on=a}}function aj(t,s,n){var a=(t+="")=="transform"?iv:Vl;return s==null?this.styleTween(t,ej(t,a)).on("end.style."+t,Ul(t)):typeof s=="function"?this.styleTween(t,sj(t,a,Ui(this,"style."+t,s))).each(nj(this._id,t)):this.styleTween(t,tj(t,a,s),n).on("end.style."+t,null)}function ij(t,s,n){return function(a){this.style.setProperty(t,s.call(this,a),n)}}function rj(t,s,n){var a,i;function r(){var o=s.apply(this,arguments);return o!==i&&(a=(i=o)&&ij(t,o,n)),a}return r._value=s,r}function oj(t,s,n){var a="style."+(t+="");if(arguments.length<2)return(a=this.tween(a))&&a._value;if(s==null)return this.tween(a,null);if(typeof s!="function")throw new Error;return this.tween(a,rj(t,s,n??""))}function lj(t){return function(){this.textContent=t}}function cj(t){return function(){var s=t(this);this.textContent=s??""}}function dj(t){return this.tween("text",typeof t=="function"?cj(Ui(this,"text",t)):lj(t==null?"":t+""))}function uj(t){return function(s){this.textContent=t.call(this,s)}}function hj(t){var s,n;function a(){var i=t.apply(this,arguments);return i!==n&&(s=(n=i)&&uj(i)),s}return a._value=t,a}function mj(t){var s="text";if(arguments.length<1)return(s=this.tween(s))&&s._value;if(t==null)return this.tween(s,null);if(typeof t!="function")throw new Error;return this.tween(s,hj(t))}function fj(){for(var t=this._name,s=this._id,n=ql(),a=this._groups,i=a.length,r=0;r<i;++r)for(var o=a[r],l=o.length,c,h=0;h<l;++h)if(c=o[h]){var m=jt(c,s);ya(c,t,n,h,o,{time:m.time+m.delay+m.duration,delay:0,duration:m.duration,ease:m.ease})}return new It(a,this._parents,t,n)}function pj(){var t,s,n=this,a=n._id,i=n.size();return new Promise(function(r,o){var l={value:o},c={value:function(){--i===0&&r()}};n.each(function(){var h=Ct(this,a),m=h.on;m!==t&&(s=(t=m).copy(),s._.cancel.push(l),s._.interrupt.push(l),s._.end.push(c)),h.on=s}),i===0&&r()})}var xj=0;function It(t,s,n,a){this._groups=t,this._parents=s,this._name=n,this._id=a}function ql(){return++xj}var Et=xn.prototype;It.prototype={constructor:It,select:Kv,selectAll:Zv,selectChild:Et.selectChild,selectChildren:Et.selectChildren,filter:Vv,merge:Uv,selection:Jv,transition:fj,call:Et.call,nodes:Et.nodes,node:Et.node,size:Et.size,empty:Et.empty,each:Et.each,on:Gv,attr:zv,attrTween:Tv,style:aj,styleTween:oj,text:dj,textTween:mj,remove:Xv,tween:jv,delay:Iv,duration:Dv,ease:Ov,easeVarying:Hv,end:pj,[Symbol.iterator]:Et[Symbol.iterator]};function gj(t){return((t*=2)<=1?t*t*t:(t-=2)*t*t+2)/2}var yj={time:null,delay:0,duration:250,ease:gj};function vj(t,s){for(var n;!(n=t.__transition)||!(n=n[s]);)if(!(t=t.parentNode))throw new Error(`transition ${s} not found`);return n}function jj(t){var s,n;t instanceof It?(s=t._id,t=t._name):(s=ql(),(n=yj).time=Hi(),t=t==null?null:t+"");for(var a=this._groups,i=a.length,r=0;r<i;++r)for(var o=a[r],l=o.length,c,h=0;h<l;++h)(c=o[h])&&ya(c,t,s,h,o,n||vj(c,s));return new It(a,this._parents,t,s)}xn.prototype.interrupt=gv;xn.prototype.transition=jj;const Rn=t=>()=>t;function bj(t,{sourceEvent:s,target:n,transform:a,dispatch:i}){Object.defineProperties(this,{type:{value:t,enumerable:!0,configurable:!0},sourceEvent:{value:s,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},transform:{value:a,enumerable:!0,configurable:!0},_:{value:i}})}function Tt(t,s,n){this.k=t,this.x=s,this.y=n}Tt.prototype={constructor:Tt,scale:function(t){return t===1?this:new Tt(this.k*t,this.x,this.y)},translate:function(t,s){return t===0&s===0?this:new Tt(this.k,this.x+this.k*t,this.y+this.k*s)},apply:function(t){return[t[0]*this.k+this.x,t[1]*this.k+this.y]},applyX:function(t){return t*this.k+this.x},applyY:function(t){return t*this.k+this.y},invert:function(t){return[(t[0]-this.x)/this.k,(t[1]-this.y)/this.k]},invertX:function(t){return(t-this.x)/this.k},invertY:function(t){return(t-this.y)/this.k},rescaleX:function(t){return t.copy().domain(t.range().map(this.invertX,this).map(t.invert,t))},rescaleY:function(t){return t.copy().domain(t.range().map(this.invertY,this).map(t.invert,t))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var va=new Tt(1,0,0);Wl.prototype=Tt.prototype;function Wl(t){for(;!t.__zoom;)if(!(t=t.parentNode))return va;return t.__zoom}function Ga(t){t.stopImmediatePropagation()}function qs(t){t.preventDefault(),t.stopImmediatePropagation()}function wj(t){return(!t.ctrlKey||t.type==="wheel")&&!t.button}function kj(){var t=this;return t instanceof SVGElement?(t=t.ownerSVGElement||t,t.hasAttribute("viewBox")?(t=t.viewBox.baseVal,[[t.x,t.y],[t.x+t.width,t.y+t.height]]):[[0,0],[t.width.baseVal.value,t.height.baseVal.value]]):[[0,0],[t.clientWidth,t.clientHeight]]}function Yr(){return this.__zoom||va}function Nj(t){return-t.deltaY*(t.deltaMode===1?.05:t.deltaMode?1:.002)*(t.ctrlKey?10:1)}function Sj(){return navigator.maxTouchPoints||"ontouchstart"in this}function Cj(t,s,n){var a=t.invertX(s[0][0])-n[0][0],i=t.invertX(s[1][0])-n[1][0],r=t.invertY(s[0][1])-n[0][1],o=t.invertY(s[1][1])-n[1][1];return t.translate(i>a?(a+i)/2:Math.min(0,a)||Math.max(0,i),o>r?(r+o)/2:Math.min(0,r)||Math.max(0,o))}function Gl(){var t=wj,s=kj,n=Cj,a=Nj,i=Sj,r=[0,1/0],o=[[-1/0,-1/0],[1/0,1/0]],l=250,c=Un,h=pa("start","zoom","end"),m,d,u,p=500,x=150,j=0,v=10;function g(N){N.property("__zoom",Yr).on("wheel.zoom",z,{passive:!1}).on("mousedown.zoom",A).on("dblclick.zoom",k).filter(i).on("touchstart.zoom",C).on("touchmove.zoom",_).on("touchend.zoom touchcancel.zoom",P).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}g.transform=function(N,T,L,R){var F=N.selection?N.selection():N;F.property("__zoom",Yr),N!==F?S(N,T,L,R):F.interrupt().each(function(){$(this,arguments).event(R).start().zoom(null,typeof T=="function"?T.apply(this,arguments):T).end()})},g.scaleBy=function(N,T,L,R){g.scaleTo(N,function(){var F=this.__zoom.k,E=typeof T=="function"?T.apply(this,arguments):T;return F*E},L,R)},g.scaleTo=function(N,T,L,R){g.transform(N,function(){var F=s.apply(this,arguments),E=this.__zoom,D=L==null?w(F):typeof L=="function"?L.apply(this,arguments):L,G=E.invert(D),I=typeof T=="function"?T.apply(this,arguments):T;return n(y(b(E,I),D,G),F,o)},L,R)},g.translateBy=function(N,T,L,R){g.transform(N,function(){return n(this.__zoom.translate(typeof T=="function"?T.apply(this,arguments):T,typeof L=="function"?L.apply(this,arguments):L),s.apply(this,arguments),o)},null,R)},g.translateTo=function(N,T,L,R,F){g.transform(N,function(){var E=s.apply(this,arguments),D=this.__zoom,G=R==null?w(E):typeof R=="function"?R.apply(this,arguments):R;return n(va.translate(G[0],G[1]).scale(D.k).translate(typeof T=="function"?-T.apply(this,arguments):-T,typeof L=="function"?-L.apply(this,arguments):-L),E,o)},R,F)};function b(N,T){return T=Math.max(r[0],Math.min(r[1],T)),T===N.k?N:new Tt(T,N.x,N.y)}function y(N,T,L){var R=T[0]-L[0]*N.k,F=T[1]-L[1]*N.k;return R===N.x&&F===N.y?N:new Tt(N.k,R,F)}function w(N){return[(+N[0][0]+ +N[1][0])/2,(+N[0][1]+ +N[1][1])/2]}function S(N,T,L,R){N.on("start.zoom",function(){$(this,arguments).event(R).start()}).on("interrupt.zoom end.zoom",function(){$(this,arguments).event(R).end()}).tween("zoom",function(){var F=this,E=arguments,D=$(F,E).event(R),G=s.apply(F,E),I=L==null?w(G):typeof L=="function"?L.apply(F,E):L,W=Math.max(G[1][0]-G[0][0],G[1][1]-G[0][1]),V=F.__zoom,X=typeof T=="function"?T.apply(F,E):T,J=c(V.invert(I).concat(W/V.k),X.invert(I).concat(W/X.k));return function(le){if(le===1)le=X;else{var B=J(le),Y=W/B[2];le=new Tt(Y,I[0]-B[0]*Y,I[1]-B[1]*Y)}D.zoom(null,le)}})}function $(N,T,L){return!L&&N.__zooming||new M(N,T)}function M(N,T){this.that=N,this.args=T,this.active=0,this.sourceEvent=null,this.extent=s.apply(N,T),this.taps=0}M.prototype={event:function(N){return N&&(this.sourceEvent=N),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(N,T){return this.mouse&&N!=="mouse"&&(this.mouse[1]=T.invert(this.mouse[0])),this.touch0&&N!=="touch"&&(this.touch0[1]=T.invert(this.touch0[0])),this.touch1&&N!=="touch"&&(this.touch1[1]=T.invert(this.touch1[0])),this.that.__zoom=T,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(N){var T=at(this.that).datum();h.call(N,this.that,new bj(N,{sourceEvent:this.sourceEvent,target:g,transform:this.that.__zoom,dispatch:h}),T)}};function z(N,...T){if(!t.apply(this,arguments))return;var L=$(this,T).event(N),R=this.__zoom,F=Math.max(r[0],Math.min(r[1],R.k*Math.pow(2,a.apply(this,arguments)))),E=dt(N);if(L.wheel)(L.mouse[0][0]!==E[0]||L.mouse[0][1]!==E[1])&&(L.mouse[1]=R.invert(L.mouse[0]=E)),clearTimeout(L.wheel);else{if(R.k===F)return;L.mouse=[E,R.invert(E)],Gn(this),L.start()}qs(N),L.wheel=setTimeout(D,x),L.zoom("mouse",n(y(b(R,F),L.mouse[0],L.mouse[1]),L.extent,o));function D(){L.wheel=null,L.end()}}function A(N,...T){if(u||!t.apply(this,arguments))return;var L=N.currentTarget,R=$(this,T,!0).event(N),F=at(N.view).on("mousemove.zoom",I,!0).on("mouseup.zoom",W,!0),E=dt(N,L),D=N.clientX,G=N.clientY;El(N.view),Ga(N),R.mouse=[E,this.__zoom.invert(E)],Gn(this),R.start();function I(V){if(qs(V),!R.moved){var X=V.clientX-D,J=V.clientY-G;R.moved=X*X+J*J>j}R.event(V).zoom("mouse",n(y(R.that.__zoom,R.mouse[0]=dt(V,L),R.mouse[1]),R.extent,o))}function W(V){F.on("mousemove.zoom mouseup.zoom",null),_l(V.view,R.moved),qs(V),R.event(V).end()}}function k(N,...T){if(t.apply(this,arguments)){var L=this.__zoom,R=dt(N.changedTouches?N.changedTouches[0]:N,this),F=L.invert(R),E=L.k*(N.shiftKey?.5:2),D=n(y(b(L,E),R,F),s.apply(this,T),o);qs(N),l>0?at(this).transition().duration(l).call(S,D,R,N):at(this).call(g.transform,D,R,N)}}function C(N,...T){if(t.apply(this,arguments)){var L=N.touches,R=L.length,F=$(this,T,N.changedTouches.length===R).event(N),E,D,G,I;for(Ga(N),D=0;D<R;++D)G=L[D],I=dt(G,this),I=[I,this.__zoom.invert(I),G.identifier],F.touch0?!F.touch1&&F.touch0[2]!==I[2]&&(F.touch1=I,F.taps=0):(F.touch0=I,E=!0,F.taps=1+!!m);m&&(m=clearTimeout(m)),E&&(F.taps<2&&(d=I[0],m=setTimeout(function(){m=null},p)),Gn(this),F.start())}}function _(N,...T){if(this.__zooming){var L=$(this,T).event(N),R=N.changedTouches,F=R.length,E,D,G,I;for(qs(N),E=0;E<F;++E)D=R[E],G=dt(D,this),L.touch0&&L.touch0[2]===D.identifier?L.touch0[0]=G:L.touch1&&L.touch1[2]===D.identifier&&(L.touch1[0]=G);if(D=L.that.__zoom,L.touch1){var W=L.touch0[0],V=L.touch0[1],X=L.touch1[0],J=L.touch1[1],le=(le=X[0]-W[0])*le+(le=X[1]-W[1])*le,B=(B=J[0]-V[0])*B+(B=J[1]-V[1])*B;D=b(D,Math.sqrt(le/B)),G=[(W[0]+X[0])/2,(W[1]+X[1])/2],I=[(V[0]+J[0])/2,(V[1]+J[1])/2]}else if(L.touch0)G=L.touch0[0],I=L.touch0[1];else return;L.zoom("touch",n(y(D,G,I),L.extent,o))}}function P(N,...T){if(this.__zooming){var L=$(this,T).event(N),R=N.changedTouches,F=R.length,E,D;for(Ga(N),u&&clearTimeout(u),u=setTimeout(function(){u=null},p),E=0;E<F;++E)D=R[E],L.touch0&&L.touch0[2]===D.identifier?delete L.touch0:L.touch1&&L.touch1[2]===D.identifier&&delete L.touch1;if(L.touch1&&!L.touch0&&(L.touch0=L.touch1,delete L.touch1),L.touch0)L.touch0[1]=this.__zoom.invert(L.touch0[0]);else if(L.end(),L.taps===2&&(D=dt(D,this),Math.hypot(d[0]-D[0],d[1]-D[1])<v)){var G=at(this).on("dblclick.zoom");G&&G.apply(this,arguments)}}}return g.wheelDelta=function(N){return arguments.length?(a=typeof N=="function"?N:Rn(+N),g):a},g.filter=function(N){return arguments.length?(t=typeof N=="function"?N:Rn(!!N),g):t},g.touchable=function(N){return arguments.length?(i=typeof N=="function"?N:Rn(!!N),g):i},g.extent=function(N){return arguments.length?(s=typeof N=="function"?N:Rn([[+N[0][0],+N[0][1]],[+N[1][0],+N[1][1]]]),g):s},g.scaleExtent=function(N){return arguments.length?(r[0]=+N[0],r[1]=+N[1],g):[r[0],r[1]]},g.translateExtent=function(N){return arguments.length?(o[0][0]=+N[0][0],o[1][0]=+N[1][0],o[0][1]=+N[0][1],o[1][1]=+N[1][1],g):[[o[0][0],o[0][1]],[o[1][0],o[1][1]]]},g.constrain=function(N){return arguments.length?(n=N,g):n},g.duration=function(N){return arguments.length?(l=+N,g):l},g.interpolate=function(N){return arguments.length?(c=N,g):c},g.on=function(){var N=h.on.apply(h,arguments);return N===h?g:N},g.clickDistance=function(N){return arguments.length?(j=(N=+N)*N,g):Math.sqrt(j)},g.tapDistance=function(N){return arguments.length?(v=+N,g):v},g}const yt={error001:(t="react")=>`Seems like you have not used ${t==="svelte"?"SvelteFlowProvider":"ReactFlowProvider"} as an ancestor. Help: https://${t}flow.dev/error#001`,error002:()=>"It looks like you've created a new nodeTypes or edgeTypes object. If this wasn't on purpose please define the nodeTypes/edgeTypes outside of the component or memoize them.",error003:t=>`Node type "${t}" not found. Using fallback type "default".`,error004:()=>"The parent container needs a width and a height to render the graph.",error005:()=>"Only child nodes can use a parent extent.",error006:()=>"Can't create edge. An edge needs a source and a target.",error007:t=>`The old edge with id=${t} does not exist.`,error009:t=>`Marker type "${t}" doesn't exist.`,error008:(t,{id:s,sourceHandle:n,targetHandle:a})=>`Couldn't create edge for ${t} handle id: "${t==="source"?n:a}", edge id: ${s}.`,error010:()=>"Handle: No node id found. Make sure to only use a Handle inside a custom Node.",error011:t=>`Edge type "${t}" not found. Using fallback type "default".`,error012:t=>`Node with id "${t}" does not exist, it may have been removed. This can happen when a node is deleted before the "onNodeClick" handler is called.`,error013:(t="react")=>`It seems that you haven't loaded the styles. Please import '@xyflow/${t}/dist/style.css' or base.css to make sure everything is working properly.`,error014:()=>"useNodeConnections: No node ID found. Call useNodeConnections inside a custom Node or provide a node ID.",error015:()=>"It seems that you are trying to drag a node that is not initialized. Please use onNodesChange as explained in the docs.",error016:t=>`Edge with id "${t}" does not exist, it may have been removed. This can happen when an edge is deleted before the "onEdgeClick" handler is called.`},ln=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],Yl=["Enter"," ","Escape"],Xl={"node.a11yDescription.default":"Press enter or space to select a node. Press delete to remove it and escape to cancel.","node.a11yDescription.keyboardDisabled":"Press enter or space to select a node. You can then use the arrow keys to move the node around. Press delete to remove it and escape to cancel.","node.a11yDescription.ariaLiveMessage":({direction:t,x:s,y:n})=>`Moved selected node ${t}. New position, x: ${s}, y: ${n}`,"edge.a11yDescription.default":"Press enter or space to select an edge. You can then press delete to remove it or escape to cancel.","controls.ariaLabel":"Control Panel","controls.zoomIn.ariaLabel":"Zoom In","controls.zoomOut.ariaLabel":"Zoom Out","controls.fitView.ariaLabel":"Fit View","controls.interactive.ariaLabel":"Toggle Interactivity","minimap.ariaLabel":"Mini Map","handle.ariaLabel":"Handle"};var $s;(function(t){t.Strict="strict",t.Loose="loose"})($s||($s={}));var Zt;(function(t){t.Free="free",t.Vertical="vertical",t.Horizontal="horizontal"})(Zt||(Zt={}));var cn;(function(t){t.Partial="partial",t.Full="full"})(cn||(cn={}));const Kl={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null};var Ft;(function(t){t.Bezier="default",t.Straight="straight",t.Step="step",t.SmoothStep="smoothstep",t.SimpleBezier="simplebezier"})(Ft||(Ft={}));var oa;(function(t){t.Arrow="arrow",t.ArrowClosed="arrowclosed"})(oa||(oa={}));var he;(function(t){t.Left="left",t.Top="top",t.Right="right",t.Bottom="bottom"})(he||(he={}));const Xr={[he.Left]:he.Right,[he.Right]:he.Left,[he.Top]:he.Bottom,[he.Bottom]:he.Top};function Zl(t){return t===null?null:t?"valid":"invalid"}const Ql=t=>!!t&&typeof t=="object"&&"id"in t&&"source"in t&&"target"in t,zj=t=>!!t&&typeof t=="object"&&"id"in t&&"position"in t&&!("source"in t)&&!("target"in t),qi=t=>!!t&&typeof t=="object"&&"id"in t&&"internals"in t&&!("source"in t)&&!("target"in t),yn=(t,s=[0,0])=>{const{width:n,height:a}=zt(t),i=t.origin??s,r=n*i[0],o=a*i[1];return{x:t.position.x-r,y:t.position.y-o}},Mj=(t,s={nodeOrigin:[0,0]})=>{if(t.length===0)return{x:0,y:0,width:0,height:0};const n=t.reduce((a,i)=>{const r=typeof i=="string";let o=!s.nodeLookup&&!r?i:void 0;s.nodeLookup&&(o=r?s.nodeLookup.get(i):qi(i)?i:s.nodeLookup.get(i.id));const l=o?la(o,s.nodeOrigin):{x:0,y:0,x2:0,y2:0};return ja(a,l)},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return ba(n)},vn=(t,s={})=>{let n={x:1/0,y:1/0,x2:-1/0,y2:-1/0},a=!1;return t.forEach(i=>{(s.filter===void 0||s.filter(i))&&(n=ja(n,la(i)),a=!0)}),a?ba(n):{x:0,y:0,width:0,height:0}},Wi=(t,s,[n,a,i]=[0,0,1],r=!1,o=!1)=>{const l=(s.x-n)/i,c=(s.y-a)/i,h=s.width/i,m=s.height/i,d=[];for(const u of t.values()){const{measured:p,selectable:x=!0,hidden:j=!1}=u;if(o&&!x||j)continue;const v=p.width??u.width??u.initialWidth??0,g=p.height??u.height??u.initialHeight??0,{x:b,y}=u.internals.positionAbsolute,w=sc(l,c,h,m,b,y,v,g),S=v*g,$=r&&w>0;(!u.internals.handleBounds||$||w>=S||u.dragging)&&d.push(u)}return d},$j=(t,s)=>{const n=new Set;return t.forEach(a=>{n.add(a.id)}),s.filter(a=>n.has(a.source)||n.has(a.target))};function Ej(t,s){const n=new Map,a=s!=null&&s.nodes?new Set(s.nodes.map(i=>i.id)):null;return t.forEach(i=>{let r;if(s!=null&&s.includeHiddenNodes){const{width:o,height:l}=zt(i);r=o>0&&l>0}else r=!!(i.measured.width&&i.measured.height&&!i.hidden);r&&(!a||a.has(i.id))&&n.set(i.id,i)}),n}async function _j({nodes:t,width:s,height:n,panZoom:a,minZoom:i,maxZoom:r},o){if(t.size===0)return!0;const l=Ej(t,o),c=vn(l),h=Yi(c,s,n,(o==null?void 0:o.minZoom)??i,(o==null?void 0:o.maxZoom)??r,(o==null?void 0:o.padding)??.1);return await a.setViewport(h,{duration:o==null?void 0:o.duration,ease:o==null?void 0:o.ease,interpolate:o==null?void 0:o.interpolate}),!0}function Jl({nodeId:t,nextPosition:s,nodeLookup:n,nodeOrigin:a=[0,0],nodeExtent:i,onError:r}){const o=n.get(t),l=o.parentId?n.get(o.parentId):void 0,{x:c,y:h}=l?l.internals.positionAbsolute:{x:0,y:0},m=o.origin??a;let d=o.extent||i;if(o.extent==="parent"&&!o.expandParent)if(!l)r==null||r("005",yt.error005());else{const p=l.measured.width,x=l.measured.height;p&&x&&(d=[[c,h],[c+p,h+x]])}else l&&rs(o.extent)&&(d=[[o.extent[0][0]+c,o.extent[0][1]+h],[o.extent[1][0]+c,o.extent[1][1]+h]]);const u=rs(d)?is(s,d,o.measured):s;return(o.measured.width===void 0||o.measured.height===void 0)&&(r==null||r("015",yt.error015())),{position:{x:u.x-c+(o.measured.width??0)*m[0],y:u.y-h+(o.measured.height??0)*m[1]},positionAbsolute:u}}async function Tj({nodesToRemove:t=[],edgesToRemove:s=[],nodes:n,edges:a,onBeforeDelete:i}){const r=new Set(t.map(u=>u.id)),o=[];for(const u of n){if(u.deletable===!1)continue;const p=r.has(u.id),x=!p&&u.parentId&&o.find(j=>j.id===u.parentId);(p||x)&&o.push(u)}const l=new Set(s.map(u=>u.id)),c=a.filter(u=>u.deletable!==!1),m=$j(o,c);for(const u of c)l.has(u.id)&&!m.find(x=>x.id===u.id)&&m.push(u);if(!i)return{edges:m,nodes:o};const d=await i({nodes:o,edges:m});return typeof d=="boolean"?d?{edges:m,nodes:o}:{edges:[],nodes:[]}:d}const Es=(t,s=0,n=1)=>Math.min(Math.max(t,s),n),is=(t={x:0,y:0},s,n)=>({x:Es(t.x,s[0][0],s[1][0]-((n==null?void 0:n.width)??0)),y:Es(t.y,s[0][1],s[1][1]-((n==null?void 0:n.height)??0))});function ec(t,s,n){const{width:a,height:i}=zt(n),{x:r,y:o}=n.internals.positionAbsolute;return is(t,[[r,o],[r+a,o+i]],s)}const Kr=(t,s,n)=>t<s?Es(Math.abs(t-s),1,s)/s:t>n?-Es(Math.abs(t-n),1,s)/s:0,Gi=(t,s,n=15,a=40)=>{const i=Kr(t.x,a,s.width-a)*n,r=Kr(t.y,a,s.height-a)*n;return[i,r]},ja=(t,s)=>({x:Math.min(t.x,s.x),y:Math.min(t.y,s.y),x2:Math.max(t.x2,s.x2),y2:Math.max(t.y2,s.y2)}),xi=({x:t,y:s,width:n,height:a})=>({x:t,y:s,x2:t+n,y2:s+a}),ba=({x:t,y:s,x2:n,y2:a})=>({x:t,y:s,width:n-t,height:a-s}),dn=(t,s=[0,0])=>{var i,r;const{x:n,y:a}=qi(t)?t.internals.positionAbsolute:yn(t,s);return{x:n,y:a,width:((i=t.measured)==null?void 0:i.width)??t.width??t.initialWidth??0,height:((r=t.measured)==null?void 0:r.height)??t.height??t.initialHeight??0}},la=(t,s=[0,0])=>{var i,r;const{x:n,y:a}=qi(t)?t.internals.positionAbsolute:yn(t,s);return{x:n,y:a,x2:n+(((i=t.measured)==null?void 0:i.width)??t.width??t.initialWidth??0),y2:a+(((r=t.measured)==null?void 0:r.height)??t.height??t.initialHeight??0)}},tc=(t,s)=>ba(ja(xi(t),xi(s))),sc=(t,s,n,a,i,r,o,l)=>{const c=Math.max(0,Math.min(t+n,i+o)-Math.max(t,i)),h=Math.max(0,Math.min(s+a,r+l)-Math.max(s,r));return Math.ceil(c*h)},ca=(t,s)=>sc(t.x,t.y,t.width,t.height,s.x,s.y,s.width,s.height),Zr=t=>mt(t.width)&&mt(t.height)&&mt(t.x)&&mt(t.y),mt=t=>!isNaN(t)&&isFinite(t),nc=(t,s)=>(n,a)=>{},jn=(t,s=[1,1])=>({x:s[0]*Math.round(t.x/s[0]),y:s[1]*Math.round(t.y/s[1])}),bn=({x:t,y:s},[n,a,i],r=!1,o=[1,1])=>{const l={x:(t-n)/i,y:(s-a)/i};return r?jn(l,o):l},_s=({x:t,y:s},[n,a,i])=>({x:t*i+n,y:s*i+a});function ms(t,s){if(typeof t=="number")return Math.floor((s-s/(1+t))*.5);if(typeof t=="string"&&t.endsWith("px")){const n=parseFloat(t);if(!Number.isNaN(n))return Math.floor(n)}if(typeof t=="string"&&t.endsWith("%")){const n=parseFloat(t);if(!Number.isNaN(n))return Math.floor(s*n*.01)}return console.error(`The padding value "${t}" is invalid. Please provide a number or a string with a valid unit (px or %).`),0}function Aj(t,s,n){if(typeof t=="string"||typeof t=="number"){const a=ms(t,n),i=ms(t,s);return{top:a,right:i,bottom:a,left:i,x:i*2,y:a*2}}if(typeof t=="object"){const a=ms(t.top??t.y??0,n),i=ms(t.bottom??t.y??0,n),r=ms(t.left??t.x??0,s),o=ms(t.right??t.x??0,s);return{top:a,right:o,bottom:i,left:r,x:r+o,y:a+i}}return{top:0,right:0,bottom:0,left:0,x:0,y:0}}function Rj(t,s,n,a,i,r){const{x:o,y:l}=_s(t,[s,n,a]),{x:c,y:h}=_s({x:t.x+t.width,y:t.y+t.height},[s,n,a]),m=i-c,d=r-h;return{left:Math.floor(o),top:Math.floor(l),right:Math.floor(m),bottom:Math.floor(d)}}const Yi=(t,s,n,a,i,r)=>{const o=Aj(r,s,n),l=(s-o.x)/t.width,c=(n-o.y)/t.height,h=Math.min(l,c),m=Es(h,a,i),d=t.x+t.width/2,u=t.y+t.height/2,p=s/2-d*m,x=n/2-u*m,j=Rj(t,p,x,m,s,n),v={left:Math.min(j.left-o.left,0),top:Math.min(j.top-o.top,0),right:Math.min(j.right-o.right,0),bottom:Math.min(j.bottom-o.bottom,0)};return{x:p-v.left+v.right,y:x-v.top+v.bottom,zoom:m}},un=()=>{var t;return typeof navigator<"u"&&((t=navigator==null?void 0:navigator.userAgent)==null?void 0:t.indexOf("Mac"))>=0};function rs(t){return t!=null&&t!=="parent"}function zt(t){var s,n;return{width:((s=t.measured)==null?void 0:s.width)??t.width??t.initialWidth??0,height:((n=t.measured)==null?void 0:n.height)??t.height??t.initialHeight??0}}function ac(t){var s,n;return(((s=t.measured)==null?void 0:s.width)??t.width??t.initialWidth)!==void 0&&(((n=t.measured)==null?void 0:n.height)??t.height??t.initialHeight)!==void 0}function ic(t,s={width:0,height:0},n,a,i){const r={...t},o=a.get(n);if(o){const l=o.origin||i;r.x+=o.internals.positionAbsolute.x-(s.width??0)*l[0],r.y+=o.internals.positionAbsolute.y-(s.height??0)*l[1]}return r}function Qr(t,s){if(t.size!==s.size)return!1;for(const n of t)if(!s.has(n))return!1;return!0}function Ij(){let t,s;return{promise:new Promise((a,i)=>{t=a,s=i}),resolve:t,reject:s}}function Lj(t){return{...Xl,...t||{}}}function Ks(t,{snapGrid:s=[0,0],snapToGrid:n=!1,transform:a,containerBounds:i}){const{x:r,y:o}=ft(t),l=bn({x:r-((i==null?void 0:i.left)??0),y:o-((i==null?void 0:i.top)??0)},a),{x:c,y:h}=n?jn(l,s):l;return{xSnapped:c,ySnapped:h,...l}}const Xi=t=>({width:t.offsetWidth,height:t.offsetHeight}),rc=t=>{var s;return((s=t==null?void 0:t.getRootNode)==null?void 0:s.call(t))||(window==null?void 0:window.document)},Pj=["INPUT","SELECT","TEXTAREA"];function oc(t){var a,i;const s=((i=(a=t.composedPath)==null?void 0:a.call(t))==null?void 0:i[0])||t.target;return(s==null?void 0:s.nodeType)!==1?!1:Pj.includes(s.nodeName)||s.hasAttribute("contenteditable")||!!s.closest(".nokey")}const lc=t=>"clientX"in t,ft=(t,s)=>{var r,o;const n=lc(t),a=n?t.clientX:(r=t.touches)==null?void 0:r[0].clientX,i=n?t.clientY:(o=t.touches)==null?void 0:o[0].clientY;return{x:a-((s==null?void 0:s.left)??0),y:i-((s==null?void 0:s.top)??0)}},Jr=(t,s,n,a,i)=>{const r=s.querySelectorAll(`.${t}`);return!r||!r.length?null:Array.from(r).map(o=>{const l=o.getBoundingClientRect();return{id:o.getAttribute("data-handleid"),type:t,nodeId:i,position:o.getAttribute("data-handlepos"),x:(l.left-n.left)/a,y:(l.top-n.top)/a,...Xi(o)}})};function cc({sourceX:t,sourceY:s,targetX:n,targetY:a,sourceControlX:i,sourceControlY:r,targetControlX:o,targetControlY:l}){const c=t*.125+i*.375+o*.375+n*.125,h=s*.125+r*.375+l*.375+a*.125,m=Math.abs(c-t),d=Math.abs(h-s);return[c,h,m,d]}function In(t,s){return t>=0?.5*t:s*25*Math.sqrt(-t)}function eo({pos:t,x1:s,y1:n,x2:a,y2:i,c:r}){switch(t){case he.Left:return[s-In(s-a,r),n];case he.Right:return[s+In(a-s,r),n];case he.Top:return[s,n-In(n-i,r)];case he.Bottom:return[s,n+In(i-n,r)]}}function dc({sourceX:t,sourceY:s,sourcePosition:n=he.Bottom,targetX:a,targetY:i,targetPosition:r=he.Top,curvature:o=.25}){const[l,c]=eo({pos:n,x1:t,y1:s,x2:a,y2:i,c:o}),[h,m]=eo({pos:r,x1:a,y1:i,x2:t,y2:s,c:o}),[d,u,p,x]=cc({sourceX:t,sourceY:s,targetX:a,targetY:i,sourceControlX:l,sourceControlY:c,targetControlX:h,targetControlY:m});return[`M${t},${s} C${l},${c} ${h},${m} ${a},${i}`,d,u,p,x]}function uc({sourceX:t,sourceY:s,targetX:n,targetY:a}){const i=Math.abs(n-t)/2,r=n<t?n+i:n-i,o=Math.abs(a-s)/2,l=a<s?a+o:a-o;return[r,l,i,o]}function Dj({sourceNode:t,targetNode:s,selected:n=!1,zIndex:a=0,elevateOnSelect:i=!1,zIndexMode:r="basic"}){if(r==="manual")return a;const o=i&&n?a+1e3:a,l=Math.max(t.parentId||i&&t.selected?t.internals.z:0,s.parentId||i&&s.selected?s.internals.z:0);return o+l}function Fj({sourceNode:t,targetNode:s,width:n,height:a,transform:i}){const r=ja(la(t),la(s));r.x===r.x2&&(r.x2+=1),r.y===r.y2&&(r.y2+=1);const o={x:-i[0]/i[2],y:-i[1]/i[2],width:n/i[2],height:a/i[2]};return ca(o,ba(r))>0}const Oj=({source:t,sourceHandle:s,target:n,targetHandle:a})=>`xy-edge__${t}${s||""}-${n}${a||""}`,Bj=(t,s)=>s.some(n=>n.source===t.source&&n.target===t.target&&(n.sourceHandle===t.sourceHandle||!n.sourceHandle&&!t.sourceHandle)&&(n.targetHandle===t.targetHandle||!n.targetHandle&&!t.targetHandle)),Hj=(t,s,n={})=>{var r;if(!t.source||!t.target)return(r=n.onError)==null||r.call(n,"006",yt.error006()),s;const a=n.getEdgeId||Oj;let i;return Ql(t)?i={...t}:i={...t,id:a(t)},Bj(i,s)?s:(i.sourceHandle===null&&delete i.sourceHandle,i.targetHandle===null&&delete i.targetHandle,s.concat(i))};function hc({sourceX:t,sourceY:s,targetX:n,targetY:a}){const[i,r,o,l]=uc({sourceX:t,sourceY:s,targetX:n,targetY:a});return[`M ${t},${s}L ${n},${a}`,i,r,o,l]}const to={[he.Left]:{x:-1,y:0},[he.Right]:{x:1,y:0},[he.Top]:{x:0,y:-1},[he.Bottom]:{x:0,y:1}},Vj=({source:t,sourcePosition:s=he.Bottom,target:n})=>s===he.Left||s===he.Right?t.x<n.x?{x:1,y:0}:{x:-1,y:0}:t.y<n.y?{x:0,y:1}:{x:0,y:-1},so=(t,s)=>Math.sqrt(Math.pow(s.x-t.x,2)+Math.pow(s.y-t.y,2));function Uj({source:t,sourcePosition:s=he.Bottom,target:n,targetPosition:a=he.Top,center:i,offset:r,stepPosition:o}){const l=to[s],c=to[a],h={x:t.x+l.x*r,y:t.y+l.y*r},m={x:n.x+c.x*r,y:n.y+c.y*r},d=Vj({source:h,sourcePosition:s,target:m}),u=d.x!==0?"x":"y",p=d[u];let x=[],j,v;const g={x:0,y:0},b={x:0,y:0},[,,y,w]=uc({sourceX:t.x,sourceY:t.y,targetX:n.x,targetY:n.y});if(l[u]*c[u]===-1){u==="x"?(j=i.x??h.x+(m.x-h.x)*o,v=i.y??(h.y+m.y)/2):(j=i.x??(h.x+m.x)/2,v=i.y??h.y+(m.y-h.y)*o);const z=[{x:j,y:h.y},{x:j,y:m.y}],A=[{x:h.x,y:v},{x:m.x,y:v}];l[u]===p?x=u==="x"?z:A:x=u==="x"?A:z}else{const z=[{x:h.x,y:m.y}],A=[{x:m.x,y:h.y}];if(u==="x"?x=l.x===p?A:z:x=l.y===p?z:A,s===a){const N=Math.abs(t[u]-n[u]);if(N<=r){const T=Math.min(r-1,r-N);l[u]===p?g[u]=(h[u]>t[u]?-1:1)*T:b[u]=(m[u]>n[u]?-1:1)*T}}if(s!==a){const N=u==="x"?"y":"x",T=l[u]===c[N],L=h[N]>m[N],R=h[N]<m[N];(l[u]===1&&(!T&&L||T&&R)||l[u]!==1&&(!T&&R||T&&L))&&(x=u==="x"?z:A)}const k={x:h.x+g.x,y:h.y+g.y},C={x:m.x+b.x,y:m.y+b.y},_=Math.max(Math.abs(k.x-x[0].x),Math.abs(C.x-x[0].x)),P=Math.max(Math.abs(k.y-x[0].y),Math.abs(C.y-x[0].y));_>=P?(j=(k.x+C.x)/2,v=x[0].y):(j=x[0].x,v=(k.y+C.y)/2)}const S={x:h.x+g.x,y:h.y+g.y},$={x:m.x+b.x,y:m.y+b.y};return[[t,...S.x!==x[0].x||S.y!==x[0].y?[S]:[],...x,...$.x!==x[x.length-1].x||$.y!==x[x.length-1].y?[$]:[],n],j,v,y,w]}function qj(t,s,n,a){const i=Math.min(so(t,s)/2,so(s,n)/2,a),{x:r,y:o}=s;if(t.x===r&&r===n.x||t.y===o&&o===n.y)return`L${r} ${o}`;if(t.y===o){const h=t.x<n.x?-1:1,m=t.y<n.y?1:-1;return`L ${r+i*h},${o}Q ${r},${o} ${r},${o+i*m}`}const l=t.x<n.x?1:-1,c=t.y<n.y?-1:1;return`L ${r},${o+i*c}Q ${r},${o} ${r+i*l},${o}`}function gi({sourceX:t,sourceY:s,sourcePosition:n=he.Bottom,targetX:a,targetY:i,targetPosition:r=he.Top,borderRadius:o=5,centerX:l,centerY:c,offset:h=20,stepPosition:m=.5}){const[d,u,p,x,j]=Uj({source:{x:t,y:s},sourcePosition:n,target:{x:a,y:i},targetPosition:r,center:{x:l,y:c},offset:h,stepPosition:m});let v=`M${d[0].x} ${d[0].y}`;for(let g=1;g<d.length-1;g++)v+=qj(d[g-1],d[g],d[g+1],o);return v+=`L${d[d.length-1].x} ${d[d.length-1].y}`,[v,u,p,x,j]}function no(t){var s;return t&&!!(t.internals.handleBounds||(s=t.handles)!=null&&s.length)&&!!(t.measured.width||t.width||t.initialWidth)}function Wj(t){var d;const{sourceNode:s,targetNode:n}=t;if(!no(s)||!no(n))return null;const a=s.internals.handleBounds||ao(s.handles),i=n.internals.handleBounds||ao(n.handles),r=io((a==null?void 0:a.source)??[],t.sourceHandle),o=io(t.connectionMode===$s.Strict?(i==null?void 0:i.target)??[]:((i==null?void 0:i.target)??[]).concat((i==null?void 0:i.source)??[]),t.targetHandle);if(!r||!o)return(d=t.onError)==null||d.call(t,"008",yt.error008(r?"target":"source",{id:t.id,sourceHandle:t.sourceHandle,targetHandle:t.targetHandle})),null;const l=(r==null?void 0:r.position)||he.Bottom,c=(o==null?void 0:o.position)||he.Top,h=os(s,r,l),m=os(n,o,c);return{sourceX:h.x,sourceY:h.y,targetX:m.x,targetY:m.y,sourcePosition:l,targetPosition:c}}function ao(t){if(!t)return null;const s=[],n=[];for(const a of t)a.width=a.width??1,a.height=a.height??1,a.type==="source"?s.push(a):a.type==="target"&&n.push(a);return{source:s,target:n}}function os(t,s,n=he.Left,a=!1){const i=((s==null?void 0:s.x)??0)+t.internals.positionAbsolute.x,r=((s==null?void 0:s.y)??0)+t.internals.positionAbsolute.y,{width:o,height:l}=s??zt(t);if(a)return{x:i+o/2,y:r+l/2};switch((s==null?void 0:s.position)??n){case he.Top:return{x:i+o/2,y:r};case he.Right:return{x:i+o,y:r+l/2};case he.Bottom:return{x:i+o/2,y:r+l};case he.Left:return{x:i,y:r+l/2}}}function io(t,s){return t&&(s?t.find(n=>n.id===s):t[0])||null}function yi(t,s){return t?typeof t=="string"?t:`${s?`${s}__`:""}${Object.keys(t).sort().map(a=>`${a}=${t[a]}`).join("&")}`:""}function Gj(t,{id:s,defaultColor:n,defaultMarkerStart:a,defaultMarkerEnd:i}){const r=new Set;return t.reduce((o,l)=>([l.markerStart||a,l.markerEnd||i].forEach(c=>{if(c&&typeof c=="object"){const h=yi(c,s);r.has(h)||(o.push({id:h,color:c.color||n,...c}),r.add(h))}}),o),[]).sort((o,l)=>o.id.localeCompare(l.id))}const mc=1e3,Yj=10,Ki={nodeOrigin:[0,0],nodeExtent:ln,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},Xj={...Ki,checkEquality:!0};function Zi(t,s){const n={...t};for(const a in s)s[a]!==void 0&&(n[a]=s[a]);return n}function Kj(t,s,n){const a=Zi(Ki,n);for(const i of t.values())if(i.parentId)Ji(i,t,s,a);else{const r=yn(i,a.nodeOrigin),o=rs(i.extent)?i.extent:a.nodeExtent,l=is(r,o,zt(i));i.internals.positionAbsolute=l}}function Zj(t,s){if(!t.handles)return t.measured?s==null?void 0:s.internals.handleBounds:void 0;const n=[],a=[];for(const i of t.handles){const r={id:i.id,width:i.width??1,height:i.height??1,nodeId:t.id,x:i.x,y:i.y,position:i.position,type:i.type};i.type==="source"?n.push(r):i.type==="target"&&a.push(r)}return{source:n,target:a}}function Qi(t){return t==="manual"}function vi(t,s,n,a={}){var m,d;const i=Zi(Xj,a),r={i:0},o=new Map(s),l=i!=null&&i.elevateNodesOnSelect&&!Qi(i.zIndexMode)?mc:0;let c=t.length>0,h=!1;s.clear(),n.clear();for(const u of t){let p=o.get(u.id);if(i.checkEquality&&u===(p==null?void 0:p.internals.userNode))s.set(u.id,p);else{const x=yn(u,i.nodeOrigin),j=rs(u.extent)?u.extent:i.nodeExtent,v=is(x,j,zt(u));p={...i.defaults,...u,measured:{width:(m=u.measured)==null?void 0:m.width,height:(d=u.measured)==null?void 0:d.height},internals:{positionAbsolute:v,handleBounds:Zj(u,p),z:fc(u,l,i.zIndexMode),userNode:u}},s.set(u.id,p)}(p.measured===void 0||p.measured.width===void 0||p.measured.height===void 0)&&!p.hidden&&(c=!1),u.parentId&&Ji(p,s,n,a,r),h||(h=u.selected??!1)}return{nodesInitialized:c,hasSelectedNodes:h}}function Qj(t,s){if(!t.parentId)return;const n=s.get(t.parentId);n?n.set(t.id,t):s.set(t.parentId,new Map([[t.id,t]]))}function Ji(t,s,n,a,i){const{elevateNodesOnSelect:r,nodeOrigin:o,nodeExtent:l,zIndexMode:c}=Zi(Ki,a),h=t.parentId,m=s.get(h);if(!m){console.warn(`Parent node ${h} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);return}Qj(t,n),i&&!m.parentId&&m.internals.rootParentIndex===void 0&&c==="auto"&&(m.internals.rootParentIndex=++i.i,m.internals.z=m.internals.z+i.i*Yj),i&&m.internals.rootParentIndex!==void 0&&(i.i=m.internals.rootParentIndex);const d=r&&!Qi(c)?mc:0,{x:u,y:p,z:x}=Jj(t,m,o,l,d,c),{positionAbsolute:j}=t.internals,v=u!==j.x||p!==j.y;(v||x!==t.internals.z)&&s.set(t.id,{...t,internals:{...t.internals,positionAbsolute:v?{x:u,y:p}:j,z:x}})}function fc(t,s,n){const a=mt(t.zIndex)?t.zIndex:0;return Qi(n)?a:a+(t.selected?s:0)}function Jj(t,s,n,a,i,r){const{x:o,y:l}=s.internals.positionAbsolute,c=zt(t),h=yn(t,n),m=rs(t.extent)?is(h,t.extent,c):h;let d=is({x:o+m.x,y:l+m.y},a,c);t.extent==="parent"&&(d=ec(d,c,s));const u=fc(t,i,r),p=s.internals.z??0;return{x:d.x,y:d.y,z:p>=u?p+1:u}}function er(t,s,n,a=[0,0]){var o;const i=[],r=new Map;for(const l of t){const c=s.get(l.parentId);if(!c)continue;const h=((o=r.get(l.parentId))==null?void 0:o.expandedRect)??dn(c),m=tc(h,l.rect);r.set(l.parentId,{expandedRect:m,parent:c})}return r.size>0&&r.forEach(({expandedRect:l,parent:c},h)=>{var y;const m=c.internals.positionAbsolute,d=zt(c),u=c.origin??a,p=l.x<m.x?Math.round(Math.abs(m.x-l.x)):0,x=l.y<m.y?Math.round(Math.abs(m.y-l.y)):0,j=Math.max(d.width,Math.round(l.width)),v=Math.max(d.height,Math.round(l.height)),g=(j-d.width)*u[0],b=(v-d.height)*u[1];(p>0||x>0||g||b)&&(i.push({id:h,type:"position",position:{x:c.position.x-p+g,y:c.position.y-x+b}}),(y=n.get(h))==null||y.forEach(w=>{t.some(S=>S.id===w.id)||i.push({id:w.id,type:"position",position:{x:w.position.x+p,y:w.position.y+x}})})),(d.width<l.width||d.height<l.height||p||x)&&i.push({id:h,type:"dimensions",setAttributes:!0,dimensions:{width:j+(p?u[0]*p-g:0),height:v+(x?u[1]*x-b:0)}})}),i}function eb(t,s,n,a,i,r,o){const l=a==null?void 0:a.querySelector(".xyflow__viewport");let c=!1;if(!l)return{changes:[],updatedInternals:c};const h=[],m=window.getComputedStyle(l),{m22:d}=new window.DOMMatrixReadOnly(m.transform),u=[];for(const p of t.values()){const x=s.get(p.id);if(!x)continue;if(x.hidden){s.set(x.id,{...x,internals:{...x.internals,handleBounds:void 0}}),c=!0;continue}const j=Xi(p.nodeElement),v=x.measured.width!==j.width||x.measured.height!==j.height;if(!!(j.width&&j.height&&(v||!x.internals.handleBounds||p.force))){const b=p.nodeElement.getBoundingClientRect(),y=rs(x.extent)?x.extent:r;let{positionAbsolute:w}=x.internals;if(x.parentId&&x.extent==="parent"){const $=s.get(x.parentId);$&&(w=ec(w,j,$))}else y&&(w=is(w,y,j));const S={...x,measured:j,internals:{...x.internals,positionAbsolute:w,handleBounds:{source:Jr("source",p.nodeElement,b,d,x.id),target:Jr("target",p.nodeElement,b,d,x.id)}}};s.set(x.id,S),x.parentId&&Ji(S,s,n,{nodeOrigin:i,zIndexMode:o}),c=!0,v&&(h.push({id:x.id,type:"dimensions",dimensions:j}),x.expandParent&&x.parentId&&u.push({id:x.id,parentId:x.parentId,rect:dn(S,i)}))}}if(u.length>0){const p=er(u,s,n,i);h.push(...p)}return{changes:h,updatedInternals:c}}async function tb({delta:t,panZoom:s,transform:n,translateExtent:a,width:i,height:r}){if(!s||!t.x&&!t.y)return!1;const o=await s.setViewportConstrained({x:n[0]+t.x,y:n[1]+t.y,zoom:n[2]},[[0,0],[i,r]],a);return!!o&&(o.x!==n[0]||o.y!==n[1]||o.k!==n[2])}function ro(t,s,n,a,i,r){let o=i;const l=a.get(o)||new Map;a.set(o,l.set(n,s)),o=`${i}-${t}`;const c=a.get(o)||new Map;if(a.set(o,c.set(n,s)),r){o=`${i}-${t}-${r}`;const h=a.get(o)||new Map;a.set(o,h.set(n,s))}}function pc(t,s,n){t.clear(),s.clear();for(const a of n){const{source:i,target:r,sourceHandle:o=null,targetHandle:l=null}=a,c={edgeId:a.id,source:i,target:r,sourceHandle:o,targetHandle:l},h=`${i}-${o}--${r}-${l}`,m=`${r}-${l}--${i}-${o}`;ro("source",c,m,t,i,o),ro("target",c,h,t,r,l),s.set(a.id,a)}}function xc(t,s){if(!t.parentId)return!1;const n=s.get(t.parentId);return n?n.selected?!0:xc(n,s):!1}function oo(t,s,n){var i;let a=t;do{if((i=a==null?void 0:a.matches)!=null&&i.call(a,s))return!0;if(a===n)return!1;a=a==null?void 0:a.parentElement}while(a);return!1}function sb(t,s,n,a){const i=new Map;for(const[r,o]of t)if((o.selected||o.id===a)&&(!o.parentId||!xc(o,t))&&(o.draggable||s&&typeof o.draggable>"u")){const l=t.get(r);l&&i.set(r,{id:r,position:l.position||{x:0,y:0},distance:{x:n.x-l.internals.positionAbsolute.x,y:n.y-l.internals.positionAbsolute.y},extent:l.extent,parentId:l.parentId,origin:l.origin,expandParent:l.expandParent,internals:{positionAbsolute:l.internals.positionAbsolute||{x:0,y:0}},measured:{width:l.measured.width??0,height:l.measured.height??0}})}return i}function Ya({nodeId:t,dragItems:s,nodeLookup:n,dragging:a=!0}){var o,l,c;const i=[];for(const[h,m]of s){const d=(o=n.get(h))==null?void 0:o.internals.userNode;d&&i.push({...d,position:m.position,dragging:a})}if(!t)return[i[0],i];const r=(l=n.get(t))==null?void 0:l.internals.userNode;return[r?{...r,position:((c=s.get(t))==null?void 0:c.position)||r.position,dragging:a}:i[0],i]}function nb({dragItems:t,snapGrid:s,x:n,y:a}){const i=t.values().next().value;if(!i)return null;const r={x:n-i.distance.x,y:a-i.distance.y},o=jn(r,s);return{x:o.x-r.x,y:o.y-r.y}}function ab({onNodeMouseDown:t,getStoreItems:s,onDragStart:n,onDrag:a,onDragStop:i}){let r={x:null,y:null},o=0,l=new Map,c=!1,h={x:0,y:0},m=null,d=!1,u=null,p=!1,x=!1,j=null;function v({noDragClassName:b,handleSelector:y,domNode:w,isSelectable:S,nodeId:$,nodeClickDistance:M=0}){u=at(w);function z({x:_,y:P}){const{nodeLookup:N,nodeExtent:T,snapGrid:L,snapToGrid:R,nodeOrigin:F,onNodeDrag:E,onSelectionDrag:D,onError:G,updateNodePositions:I}=s();r={x:_,y:P};let W=!1;const V=l.size>1,X=V&&T?xi(vn(l)):null,J=V&&R?nb({dragItems:l,snapGrid:L,x:_,y:P}):null;for(const[le,B]of l){if(!N.has(le))continue;let Y={x:_-B.distance.x,y:P-B.distance.y};R&&(Y=J?{x:Math.round(Y.x+J.x),y:Math.round(Y.y+J.y)}:jn(Y,L));let ee=null;if(V&&T&&!B.extent&&X){const{positionAbsolute:O}=B.internals,K=O.x-X.x+T[0][0],Z=O.x+B.measured.width-X.x2+T[1][0],Q=O.y-X.y+T[0][1],oe=O.y+B.measured.height-X.y2+T[1][1];ee=[[K,Q],[Z,oe]]}const{position:ae,positionAbsolute:ne}=Jl({nodeId:le,nextPosition:Y,nodeLookup:N,nodeExtent:ee||T,nodeOrigin:F,onError:G});W=W||B.position.x!==ae.x||B.position.y!==ae.y,B.position=ae,B.internals.positionAbsolute=ne}if(x=x||W,!!W&&(I(l,!0),j&&(a||E||!$&&D))){const[le,B]=Ya({nodeId:$,dragItems:l,nodeLookup:N});a==null||a(j,l,le,B),E==null||E(j,le,B),$||D==null||D(j,B)}}async function A(){if(!m)return;const{transform:_,panBy:P,autoPanSpeed:N,autoPanOnNodeDrag:T}=s();if(!T){c=!1,cancelAnimationFrame(o);return}const[L,R]=Gi(h,m,N);(L!==0||R!==0)&&(r.x=(r.x??0)-L/_[2],r.y=(r.y??0)-R/_[2],await P({x:L,y:R})&&z(r)),o=requestAnimationFrame(A)}function k(_){var V;const{nodeLookup:P,multiSelectionActive:N,nodesDraggable:T,transform:L,snapGrid:R,snapToGrid:F,selectNodesOnDrag:E,onNodeDragStart:D,onSelectionDragStart:G,unselectNodesAndEdges:I}=s();d=!0,(!E||!S)&&!N&&$&&((V=P.get($))!=null&&V.selected||I()),S&&E&&$&&(t==null||t($));const W=Ks(_.sourceEvent,{transform:L,snapGrid:R,snapToGrid:F,containerBounds:m});if(r=W,l=sb(P,T,W,$),l.size>0&&(n||D||!$&&G)){const[X,J]=Ya({nodeId:$,dragItems:l,nodeLookup:P});n==null||n(_.sourceEvent,l,X,J),D==null||D(_.sourceEvent,X,J),$||G==null||G(_.sourceEvent,J)}}const C=Tl().clickDistance(M).on("start",_=>{const{domNode:P,nodeDragThreshold:N,transform:T,snapGrid:L,snapToGrid:R}=s();m=(P==null?void 0:P.getBoundingClientRect())||null,p=!1,x=!1,j=_.sourceEvent,N===0&&k(_),r=Ks(_.sourceEvent,{transform:T,snapGrid:L,snapToGrid:R,containerBounds:m}),h=ft(_.sourceEvent,m)}).on("drag",_=>{const{autoPanOnNodeDrag:P,transform:N,snapGrid:T,snapToGrid:L,nodeDragThreshold:R,nodeLookup:F}=s(),E=Ks(_.sourceEvent,{transform:N,snapGrid:T,snapToGrid:L,containerBounds:m});if(j=_.sourceEvent,(_.sourceEvent.type==="touchmove"&&_.sourceEvent.touches.length>1||$&&!F.has($))&&(p=!0),!p){if(!c&&P&&d&&(c=!0,A()),!d){const D=ft(_.sourceEvent,m),G=D.x-h.x,I=D.y-h.y;Math.sqrt(G*G+I*I)>R&&k(_)}(r.x!==E.xSnapped||r.y!==E.ySnapped)&&l&&d&&(h=ft(_.sourceEvent,m),z(E))}}).on("end",_=>{if(!d||p){p&&l.size>0&&s().updateNodePositions(l,!1);return}if(c=!1,d=!1,cancelAnimationFrame(o),l.size>0){const{nodeLookup:P,updateNodePositions:N,onNodeDragStop:T,onSelectionDragStop:L}=s();if(x&&(N(l,!1),x=!1),i||T||!$&&L){const[R,F]=Ya({nodeId:$,dragItems:l,nodeLookup:P,dragging:!1});i==null||i(_.sourceEvent,l,R,F),T==null||T(_.sourceEvent,R,F),$||L==null||L(_.sourceEvent,F)}}}).filter(_=>{const P=_.target;return!_.button&&(!b||!oo(P,`.${b}`,w))&&(!y||oo(P,y,w))});u.call(C)}function g(){u==null||u.on(".drag",null)}return{update:v,destroy:g}}function ib(t,s,n){const a=[],i={x:t.x-n,y:t.y-n,width:n*2,height:n*2};for(const r of s.values())ca(i,dn(r))>0&&a.push(r);return a}const rb=250;function ob(t,s,n,a){var l,c;let i=[],r=1/0;const o=ib(t,n,s+rb);for(const h of o){const m=[...((l=h.internals.handleBounds)==null?void 0:l.source)??[],...((c=h.internals.handleBounds)==null?void 0:c.target)??[]];for(const d of m){if(a.nodeId===d.nodeId&&a.type===d.type&&a.id===d.id)continue;const{x:u,y:p}=os(h,d,d.position,!0),x=Math.sqrt(Math.pow(u-t.x,2)+Math.pow(p-t.y,2));x>s||(x<r?(i=[{...d,x:u,y:p}],r=x):x===r&&i.push({...d,x:u,y:p}))}}if(!i.length)return null;if(i.length>1){const h=a.type==="source"?"target":"source";return i.find(m=>m.type===h)??i[0]}return i[0]}function gc(t,s,n,a,i,r=!1){var h,m,d;const o=a.get(t);if(!o)return null;const l=i==="strict"?(h=o.internals.handleBounds)==null?void 0:h[s]:[...((m=o.internals.handleBounds)==null?void 0:m.source)??[],...((d=o.internals.handleBounds)==null?void 0:d.target)??[]],c=(n?l==null?void 0:l.find(u=>u.id===n):l==null?void 0:l[0])??null;return c&&r?{...c,...os(o,c,c.position,!0)}:c}function yc(t,s){return t||(s!=null&&s.classList.contains("target")?"target":s!=null&&s.classList.contains("source")?"source":null)}function lb(t,s){let n=null;return s?n=!0:t&&!s&&(n=!1),n}const vc=()=>!0;function cb(t,{connectionMode:s,connectionRadius:n,handleId:a,nodeId:i,edgeUpdaterType:r,isTarget:o,domNode:l,nodeLookup:c,lib:h,autoPanOnConnect:m,flowId:d,panBy:u,cancelConnection:p,onConnectStart:x,onConnect:j,onConnectEnd:v,isValidConnection:g=vc,onReconnectEnd:b,updateConnection:y,getTransform:w,getFromHandle:S,autoPanSpeed:$,dragThreshold:M=1,handleDomNode:z}){const A=rc(t.target);let k=0,C;const{x:_,y:P}=ft(t),N=yc(r,z),T=l==null?void 0:l.getBoundingClientRect();let L=!1;if(!T||!N)return;const R=gc(i,N,a,c,s);if(!R)return;let F=ft(t,T),E=!1,D=null,G=!1,I=null;function W(){if(!m||!T)return;const[ae,ne]=Gi(F,T,$);u({x:ae,y:ne}),k=requestAnimationFrame(W)}const V={...R,nodeId:i,type:N,position:R.position},X=c.get(i);let le={inProgress:!0,isValid:null,from:os(X,V,he.Left,!0),fromHandle:V,fromPosition:V.position,fromNode:X,to:F,toHandle:null,toPosition:Xr[V.position],toNode:null,pointer:F};function B(){L=!0,y(le),x==null||x(t,{nodeId:i,handleId:a,handleType:N})}M===0&&B();function Y(ae){if(!L){const{x:oe,y:ce}=ft(ae),me=oe-_,be=ce-P;if(!(me*me+be*be>M*M))return;B()}if(!S()||!V){ee(ae);return}const ne=w();F=ft(ae,T),C=ob(bn(F,ne,!1,[1,1]),n,c,V),E||(W(),E=!0);const O=jc(ae,{handle:C,connectionMode:s,fromNodeId:i,fromHandleId:a,fromType:o?"target":"source",isValidConnection:g,doc:A,lib:h,flowId:d,nodeLookup:c});I=O.handleDomNode,D=O.connection,G=lb(!!C,O.isValid);const K=c.get(i),Z=K?os(K,V,he.Left,!0):le.from,Q={...le,from:Z,isValid:G,to:O.toHandle&&G?_s({x:O.toHandle.x,y:O.toHandle.y},ne):F,toHandle:O.toHandle,toPosition:G&&O.toHandle?O.toHandle.position:Xr[V.position],toNode:O.toHandle?c.get(O.toHandle.nodeId):null,pointer:F};y(Q),le=Q}function ee(ae){if(!("touches"in ae&&ae.touches.length>0)){if(L){(C||I)&&D&&G&&(j==null||j(D));const{inProgress:ne,...O}=le,K={...O,toPosition:le.toHandle?le.toPosition:null};v==null||v(ae,K),r&&(b==null||b(ae,K))}p(),cancelAnimationFrame(k),E=!1,G=!1,D=null,I=null,A.removeEventListener("mousemove",Y),A.removeEventListener("mouseup",ee),A.removeEventListener("touchmove",Y),A.removeEventListener("touchend",ee)}}A.addEventListener("mousemove",Y),A.addEventListener("mouseup",ee),A.addEventListener("touchmove",Y),A.addEventListener("touchend",ee)}function jc(t,{handle:s,connectionMode:n,fromNodeId:a,fromHandleId:i,fromType:r,doc:o,lib:l,flowId:c,isValidConnection:h=vc,nodeLookup:m}){const d=r==="target",u=s?o.querySelector(`.${l}-flow__handle[data-id="${c}-${s==null?void 0:s.nodeId}-${s==null?void 0:s.id}-${s==null?void 0:s.type}"]`):null,{x:p,y:x}=ft(t),j=o.elementFromPoint(p,x),v=j!=null&&j.classList.contains(`${l}-flow__handle`)?j:u,g={handleDomNode:v,isValid:!1,connection:null,toHandle:null};if(v){const b=yc(void 0,v),y=v.getAttribute("data-nodeid"),w=v.getAttribute("data-handleid"),S=v.classList.contains("connectable"),$=v.classList.contains("connectableend");if(!y||!b)return g;const M={source:d?y:a,sourceHandle:d?w:i,target:d?a:y,targetHandle:d?i:w};g.connection=M;const A=S&&$&&(n===$s.Strict?d&&b==="source"||!d&&b==="target":y!==a||w!==i);g.isValid=A&&h(M),g.toHandle=gc(y,b,w,m,n,!0)}return g}const ji={onPointerDown:cb,isValid:jc};function db({domNode:t,panZoom:s,getTransform:n,getViewScale:a}){const i=at(t);function r({translateExtent:l,width:c,height:h,zoomStep:m=1,pannable:d=!0,zoomable:u=!0,inversePan:p=!1}){const x=y=>{if(y.sourceEvent.type!=="wheel"||!s)return;const w=n(),S=y.sourceEvent.ctrlKey&&un()?10:1,$=-y.sourceEvent.deltaY*(y.sourceEvent.deltaMode===1?.05:y.sourceEvent.deltaMode?1:.002)*m,M=w[2]*Math.pow(2,$*S);s.scaleTo(M)};let j=[0,0];const v=y=>{(y.sourceEvent.type==="mousedown"||y.sourceEvent.type==="touchstart")&&(j=[y.sourceEvent.clientX??y.sourceEvent.touches[0].clientX,y.sourceEvent.clientY??y.sourceEvent.touches[0].clientY])},g=y=>{const w=n();if(y.sourceEvent.type!=="mousemove"&&y.sourceEvent.type!=="touchmove"||!s)return;const S=[y.sourceEvent.clientX??y.sourceEvent.touches[0].clientX,y.sourceEvent.clientY??y.sourceEvent.touches[0].clientY],$=[S[0]-j[0],S[1]-j[1]];j=S;const M=a()*Math.max(w[2],Math.log(w[2]))*(p?-1:1),z={x:w[0]-$[0]*M,y:w[1]-$[1]*M},A=[[0,0],[c,h]];s.setViewportConstrained({x:z.x,y:z.y,zoom:w[2]},A,l)},b=Gl().on("start",v).on("zoom",d?g:null).on("zoom.wheel",u?x:null);i.call(b,{})}function o(){i.on("zoom",null)}return{update:r,destroy:o,pointer:dt}}const wa=t=>({x:t.x,y:t.y,zoom:t.k}),Xa=({x:t,y:s,zoom:n})=>va.translate(t,s).scale(n),xs=(t,s)=>t.target.closest(`.${s}`),bc=(t,s)=>s===2&&Array.isArray(t)&&t.includes(2),ub=t=>((t*=2)<=1?t*t*t:(t-=2)*t*t+2)/2,Ka=(t,s=0,n=ub,a=()=>{})=>{const i=typeof s=="number"&&s>0;return i||a(),i?t.transition().duration(s).ease(n).on("end",a):t},wc=t=>{const s=t.ctrlKey&&un()?10:1;return-t.deltaY*(t.deltaMode===1?.05:t.deltaMode?1:.002)*s};function hb({zoomPanValues:t,noWheelClassName:s,d3Selection:n,d3Zoom:a,panOnScrollMode:i,panOnScrollSpeed:r,zoomOnPinch:o,onPanZoomStart:l,onPanZoom:c,onPanZoomEnd:h}){return m=>{if(xs(m,s))return m.ctrlKey&&m.preventDefault(),!1;m.preventDefault(),m.stopImmediatePropagation();const d=n.property("__zoom").k||1;if(m.ctrlKey&&o){const v=dt(m),g=wc(m),b=d*Math.pow(2,g);a.scaleTo(n,b,v,m);return}const u=m.deltaMode===1?20:1;let p=i===Zt.Vertical?0:m.deltaX*u,x=i===Zt.Horizontal?0:m.deltaY*u;!un()&&m.shiftKey&&i!==Zt.Vertical&&(p=m.deltaY*u,x=0),a.translateBy(n,-(p/d)*r,-(x/d)*r,{internal:!0});const j=wa(n.property("__zoom"));clearTimeout(t.panScrollTimeout),t.isPanScrolling?c==null||c(m,j):(t.isPanScrolling=!0,l==null||l(m,j)),t.panScrollTimeout=setTimeout(()=>{h==null||h(m,j),t.isPanScrolling=!1},150)}}function mb({noWheelClassName:t,preventScrolling:s,d3ZoomHandler:n}){return function(a,i){const r=a.type==="wheel",o=!s&&r&&!a.ctrlKey,l=xs(a,t);if(a.ctrlKey&&r&&l&&a.preventDefault(),o||l)return null;a.preventDefault(),n.call(this,a,i)}}function fb({zoomPanValues:t,onDraggingChange:s,onPanZoomStart:n}){return a=>{var r,o,l;if((r=a.sourceEvent)!=null&&r.internal)return;const i=wa(a.transform);t.mouseButton=((o=a.sourceEvent)==null?void 0:o.button)||0,t.isZoomingOrPanning=!0,t.prevViewport=i,((l=a.sourceEvent)==null?void 0:l.type)==="mousedown"&&s(!0),n&&(n==null||n(a.sourceEvent,i))}}function pb({zoomPanValues:t,panOnDrag:s,onPaneContextMenu:n,onTransformChange:a,onPanZoom:i}){return r=>{var o,l;t.usedRightMouseButton=!!(n&&bc(s,t.mouseButton??0)),(o=r.sourceEvent)!=null&&o.sync||a([r.transform.x,r.transform.y,r.transform.k]),i&&!((l=r.sourceEvent)!=null&&l.internal)&&(i==null||i(r.sourceEvent,wa(r.transform)))}}function xb({zoomPanValues:t,panOnDrag:s,panOnScroll:n,onDraggingChange:a,onPanZoomEnd:i,onPaneContextMenu:r}){return o=>{var l;if(!((l=o.sourceEvent)!=null&&l.internal)&&(t.isZoomingOrPanning=!1,r&&bc(s,t.mouseButton??0)&&!t.usedRightMouseButton&&o.sourceEvent&&r(o.sourceEvent),t.usedRightMouseButton=!1,a(!1),i)){const c=wa(o.transform);t.prevViewport=c,clearTimeout(t.timerId),t.timerId=setTimeout(()=>{i==null||i(o.sourceEvent,c)},n?150:0)}}}function gb({zoomActivationKeyPressed:t,zoomOnScroll:s,zoomOnPinch:n,panOnDrag:a,panOnScroll:i,zoomOnDoubleClick:r,userSelectionActive:o,noWheelClassName:l,noPanClassName:c,lib:h,connectionInProgress:m}){return d=>{var v;const u=t||s,p=n&&d.ctrlKey,x=d.type==="wheel";if(d.button===1&&d.type==="mousedown"&&(xs(d,`${h}-flow__node`)||xs(d,`${h}-flow__edge`)))return!0;if(!a&&!u&&!i&&!r&&!n||o||m&&!x||xs(d,l)&&x||xs(d,c)&&(!x||i&&x&&!t)||!n&&d.ctrlKey&&x)return!1;if(!n&&d.type==="touchstart"&&((v=d.touches)==null?void 0:v.length)>1)return d.preventDefault(),!1;if(!u&&!i&&!p&&x||!a&&(d.type==="mousedown"||d.type==="touchstart")||Array.isArray(a)&&!a.includes(d.button)&&d.type==="mousedown")return!1;const j=Array.isArray(a)&&a.includes(d.button)||!d.button||d.button<=1;return(!d.ctrlKey||x)&&j}}function yb({domNode:t,minZoom:s,maxZoom:n,translateExtent:a,viewport:i,onPanZoom:r,onPanZoomStart:o,onPanZoomEnd:l,onDraggingChange:c}){const h={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},m=t.getBoundingClientRect();let d=[[0,0],[m.width,m.height]];const u=typeof ResizeObserver<"u"?new ResizeObserver(P=>{const N=P[0];N&&(d=[[0,0],[N.contentRect.width,N.contentRect.height]])}):null;u==null||u.observe(t);const p=Gl().extent(()=>d).scaleExtent([s,n]).translateExtent(a),x=at(t).call(p);w({x:i.x,y:i.y,zoom:Es(i.zoom,s,n)},[[0,0],[m.width,m.height]],a);const j=x.on("wheel.zoom"),v=x.on("dblclick.zoom");p.wheelDelta(wc);async function g(P,N){return x?new Promise(T=>{p==null||p.interpolate((N==null?void 0:N.interpolate)==="linear"?Xs:Un).transform(Ka(x,N==null?void 0:N.duration,N==null?void 0:N.ease,()=>T(!0)),P)}):!1}function b({noWheelClassName:P,noPanClassName:N,onPaneContextMenu:T,userSelectionActive:L,panOnScroll:R,panOnDrag:F,panOnScrollMode:E,panOnScrollSpeed:D,preventScrolling:G,zoomOnPinch:I,zoomOnScroll:W,zoomOnDoubleClick:V,zoomActivationKeyPressed:X,lib:J,onTransformChange:le,connectionInProgress:B,paneClickDistance:Y,selectionOnDrag:ee}){L&&!h.isZoomingOrPanning&&y();const ae=R&&!X&&!L;p.clickDistance(ee?1/0:!mt(Y)||Y<0?0:Y);const ne=ae?hb({zoomPanValues:h,noWheelClassName:P,d3Selection:x,d3Zoom:p,panOnScrollMode:E,panOnScrollSpeed:D,zoomOnPinch:I,onPanZoomStart:o,onPanZoom:r,onPanZoomEnd:l}):mb({noWheelClassName:P,preventScrolling:G,d3ZoomHandler:j});x.on("wheel.zoom",ne,{passive:!1});const O=fb({zoomPanValues:h,onDraggingChange:c,onPanZoomStart:o});p.on("start",O);const K=pb({zoomPanValues:h,panOnDrag:F,onPaneContextMenu:!!T,onPanZoom:r,onTransformChange:le});p.on("zoom",K);const Z=xb({zoomPanValues:h,panOnDrag:F,panOnScroll:R,onPaneContextMenu:T,onPanZoomEnd:l,onDraggingChange:c});p.on("end",Z);const Q=gb({zoomActivationKeyPressed:X,panOnDrag:F,zoomOnScroll:W,panOnScroll:R,zoomOnDoubleClick:V,zoomOnPinch:I,userSelectionActive:L,noPanClassName:N,noWheelClassName:P,lib:J,connectionInProgress:B});p.filter(Q),V?x.on("dblclick.zoom",v):x.on("dblclick.zoom",null)}function y(){p.on("zoom",null)}async function w(P,N,T){const L=Xa(P),R=p==null?void 0:p.constrain()(L,N,T);return R&&await g(R),R}async function S(P,N){const T=Xa(P);return await g(T,N),T}function $(P){if(x){const N=Xa(P),T=x.property("__zoom");(T.k!==P.zoom||T.x!==P.x||T.y!==P.y)&&(p==null||p.transform(x,N,null,{sync:!0}))}}function M(){const P=x?Wl(x.node()):{x:0,y:0,k:1};return{x:P.x,y:P.y,zoom:P.k}}async function z(P,N){return x?new Promise(T=>{p==null||p.interpolate((N==null?void 0:N.interpolate)==="linear"?Xs:Un).scaleTo(Ka(x,N==null?void 0:N.duration,N==null?void 0:N.ease,()=>T(!0)),P)}):!1}async function A(P,N){return x?new Promise(T=>{p==null||p.interpolate((N==null?void 0:N.interpolate)==="linear"?Xs:Un).scaleBy(Ka(x,N==null?void 0:N.duration,N==null?void 0:N.ease,()=>T(!0)),P)}):!1}function k(P){p==null||p.scaleExtent(P)}function C(P){p==null||p.translateExtent(P)}function _(P){const N=!mt(P)||P<0?0:P;p==null||p.clickDistance(N)}return{update:b,destroy:y,setViewport:S,setViewportConstrained:w,getViewport:M,scaleTo:z,scaleBy:A,setScaleExtent:k,setTranslateExtent:C,syncViewport:$,setClickDistance:_}}var Ts;(function(t){t.Line="line",t.Handle="handle"})(Ts||(Ts={}));function vb({width:t,prevWidth:s,height:n,prevHeight:a,affectsX:i,affectsY:r}){const o=t-s,l=n-a,c=[o>0?1:o<0?-1:0,l>0?1:l<0?-1:0];return o&&i&&(c[0]=c[0]*-1),l&&r&&(c[1]=c[1]*-1),c}function lo(t){const s=t.includes("right")||t.includes("left"),n=t.includes("bottom")||t.includes("top"),a=t.includes("left"),i=t.includes("top");return{isHorizontal:s,isVertical:n,affectsX:a,affectsY:i}}function Pt(t,s){return Math.max(0,s-t)}function Dt(t,s){return Math.max(0,t-s)}function Ln(t,s,n){return Math.max(0,s-t,t-n)}function co(t,s){return t?!s:s}function jb(t,s,n,a,i,r,o,l){let{affectsX:c,affectsY:h}=s;const{isHorizontal:m,isVertical:d}=s,u=m&&d,{xSnapped:p,ySnapped:x}=n,{minWidth:j,maxWidth:v,minHeight:g,maxHeight:b}=a,{x:y,y:w,width:S,height:$,aspectRatio:M}=t;let z=Math.floor(m?p-t.pointerX:0),A=Math.floor(d?x-t.pointerY:0);const k=S+(c?-z:z),C=$+(h?-A:A),_=-r[0]*S,P=-r[1]*$;let N=Ln(k,j,v),T=Ln(C,g,b);if(o){let F=0,E=0;c&&z<0?F=Pt(y+z+_,o[0][0]):!c&&z>0&&(F=Dt(y+k+_,o[1][0])),h&&A<0?E=Pt(w+A+P,o[0][1]):!h&&A>0&&(E=Dt(w+C+P,o[1][1])),N=Math.max(N,F),T=Math.max(T,E)}if(l){let F=0,E=0;c&&z>0?F=Dt(y+z,l[0][0]):!c&&z<0&&(F=Pt(y+k,l[1][0])),h&&A>0?E=Dt(w+A,l[0][1]):!h&&A<0&&(E=Pt(w+C,l[1][1])),N=Math.max(N,F),T=Math.max(T,E)}if(i){if(m){const F=Ln(k/M,g,b)*M;if(N=Math.max(N,F),o){let E=0;!c&&!h||c&&!h&&u?E=Dt(w+P+k/M,o[1][1])*M:E=Pt(w+P+(c?z:-z)/M,o[0][1])*M,N=Math.max(N,E)}if(l){let E=0;!c&&!h||c&&!h&&u?E=Pt(w+k/M,l[1][1])*M:E=Dt(w+(c?z:-z)/M,l[0][1])*M,N=Math.max(N,E)}}if(d){const F=Ln(C*M,j,v)/M;if(T=Math.max(T,F),o){let E=0;!c&&!h||h&&!c&&u?E=Dt(y+C*M+_,o[1][0])/M:E=Pt(y+(h?A:-A)*M+_,o[0][0])/M,T=Math.max(T,E)}if(l){let E=0;!c&&!h||h&&!c&&u?E=Pt(y+C*M,l[1][0])/M:E=Dt(y+(h?A:-A)*M,l[0][0])/M,T=Math.max(T,E)}}}A=A+(A<0?T:-T),z=z+(z<0?N:-N),i&&(u?k>C*M?A=(co(c,h)?-z:z)/M:z=(co(c,h)?-A:A)*M:m?(A=z/M,h=c):(z=A*M,c=h));const L=c?y+z:y,R=h?w+A:w;return{width:S+(c?-z:z),height:$+(h?-A:A),x:r[0]*z*(c?-1:1)+L,y:r[1]*A*(h?-1:1)+R}}const kc={width:0,height:0,x:0,y:0},bb={...kc,pointerX:0,pointerY:0,aspectRatio:1};function wb(t,s,n){const a=s.position.x+t.position.x,i=s.position.y+t.position.y,r=t.measured.width??0,o=t.measured.height??0,l=n[0]*r,c=n[1]*o;return[[a-l,i-c],[a+r-l,i+o-c]]}function kb({domNode:t,nodeId:s,getStoreItems:n,onChange:a,onEnd:i}){const r=at(t);let o={controlDirection:lo("bottom-right"),boundaries:{minWidth:0,minHeight:0,maxWidth:Number.MAX_VALUE,maxHeight:Number.MAX_VALUE},resizeDirection:void 0,keepAspectRatio:!1};function l({controlPosition:h,boundaries:m,keepAspectRatio:d,resizeDirection:u,onResizeStart:p,onResize:x,onResizeEnd:j,shouldResize:v}){let g={...kc},b={...bb};o={boundaries:m,resizeDirection:u,keepAspectRatio:d,controlDirection:lo(h)};let y,w=null,S=[],$,M,z,A=!1;const k=Tl().on("start",C=>{const{nodeLookup:_,transform:P,snapGrid:N,snapToGrid:T,nodeOrigin:L,paneDomNode:R}=n();if(y=_.get(s),!y)return;w=(R==null?void 0:R.getBoundingClientRect())??null;const{xSnapped:F,ySnapped:E}=Ks(C.sourceEvent,{transform:P,snapGrid:N,snapToGrid:T,containerBounds:w});g={width:y.measured.width??0,height:y.measured.height??0,x:y.position.x??0,y:y.position.y??0},b={...g,pointerX:F,pointerY:E,aspectRatio:g.width/g.height},$=void 0,M=rs(y.extent)?y.extent:void 0,y.parentId&&(y.extent==="parent"||y.expandParent)&&($=_.get(y.parentId)),$&&y.extent==="parent"&&(M=[[0,0],[$.measured.width,$.measured.height]]),S=[],z=void 0;for(const[D,G]of _)if(G.parentId===s&&(S.push({id:D,position:{...G.position},extent:G.extent}),G.extent==="parent"||G.expandParent)){const I=wb(G,y,G.origin??L);z?z=[[Math.min(I[0][0],z[0][0]),Math.min(I[0][1],z[0][1])],[Math.max(I[1][0],z[1][0]),Math.max(I[1][1],z[1][1])]]:z=I}p==null||p(C,{...g})}).on("drag",C=>{const{transform:_,snapGrid:P,snapToGrid:N,nodeOrigin:T}=n(),L=Ks(C.sourceEvent,{transform:_,snapGrid:P,snapToGrid:N,containerBounds:w}),R=[];if(!y)return;const{x:F,y:E,width:D,height:G}=g,I={},W=y.origin??T,{width:V,height:X,x:J,y:le}=jb(b,o.controlDirection,L,o.boundaries,o.keepAspectRatio,W,M,z),B=V!==D,Y=X!==G,ee=J!==F&&B,ae=le!==E&&Y;if(!ee&&!ae&&!B&&!Y)return;if((ee||ae||W[0]===1||W[1]===1)&&(I.x=ee?J:g.x,I.y=ae?le:g.y,g.x=I.x,g.y=I.y,S.length>0)){const Z=J-F,Q=le-E;for(const oe of S)oe.position={x:oe.position.x-Z+W[0]*(V-D),y:oe.position.y-Q+W[1]*(X-G)},R.push(oe)}if((B||Y)&&(I.width=B&&(!o.resizeDirection||o.resizeDirection==="horizontal")?V:g.width,I.height=Y&&(!o.resizeDirection||o.resizeDirection==="vertical")?X:g.height,g.width=I.width,g.height=I.height),$&&y.expandParent){const Z=W[0]*(I.width??0);I.x&&I.x<Z&&(g.x=Z,b.x=b.x-(I.x-Z));const Q=W[1]*(I.height??0);I.y&&I.y<Q&&(g.y=Q,b.y=b.y-(I.y-Q))}const ne=vb({width:g.width,prevWidth:D,height:g.height,prevHeight:G,affectsX:o.controlDirection.affectsX,affectsY:o.controlDirection.affectsY}),O={...g,direction:ne};(v==null?void 0:v(C,O))!==!1&&(A=!0,x==null||x(C,O),a(I,R))}).on("end",C=>{A&&(j==null||j(C,{...g}),i==null||i({...g}),A=!1)});r.call(k)}function c(){r.on(".drag",null)}return{update:l,destroy:c}}var Nc={exports:{}},Sc={},Cc={exports:{}},zc={};/**
|
|
409
|
+
* @license React
|
|
410
|
+
* use-sync-external-store-shim.production.js
|
|
411
|
+
*
|
|
412
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
413
|
+
*
|
|
414
|
+
* This source code is licensed under the MIT license found in the
|
|
415
|
+
* LICENSE file in the root directory of this source tree.
|
|
416
|
+
*/var As=f;function Nb(t,s){return t===s&&(t!==0||1/t===1/s)||t!==t&&s!==s}var Sb=typeof Object.is=="function"?Object.is:Nb,Cb=As.useState,zb=As.useEffect,Mb=As.useLayoutEffect,$b=As.useDebugValue;function Eb(t,s){var n=s(),a=Cb({inst:{value:n,getSnapshot:s}}),i=a[0].inst,r=a[1];return Mb(function(){i.value=n,i.getSnapshot=s,Za(i)&&r({inst:i})},[t,n,s]),zb(function(){return Za(i)&&r({inst:i}),t(function(){Za(i)&&r({inst:i})})},[t]),$b(n),n}function Za(t){var s=t.getSnapshot;t=t.value;try{var n=s();return!Sb(t,n)}catch{return!0}}function _b(t,s){return s()}var Tb=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?_b:Eb;zc.useSyncExternalStore=As.useSyncExternalStore!==void 0?As.useSyncExternalStore:Tb;Cc.exports=zc;var Ab=Cc.exports;/**
|
|
417
|
+
* @license React
|
|
418
|
+
* use-sync-external-store-shim/with-selector.production.js
|
|
419
|
+
*
|
|
420
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
421
|
+
*
|
|
422
|
+
* This source code is licensed under the MIT license found in the
|
|
423
|
+
* LICENSE file in the root directory of this source tree.
|
|
424
|
+
*/var ka=f,Rb=Ab;function Ib(t,s){return t===s&&(t!==0||1/t===1/s)||t!==t&&s!==s}var Lb=typeof Object.is=="function"?Object.is:Ib,Pb=Rb.useSyncExternalStore,Db=ka.useRef,Fb=ka.useEffect,Ob=ka.useMemo,Bb=ka.useDebugValue;Sc.useSyncExternalStoreWithSelector=function(t,s,n,a,i){var r=Db(null);if(r.current===null){var o={hasValue:!1,value:null};r.current=o}else o=r.current;r=Ob(function(){function c(p){if(!h){if(h=!0,m=p,p=a(p),i!==void 0&&o.hasValue){var x=o.value;if(i(x,p))return d=x}return d=p}if(x=d,Lb(m,p))return x;var j=a(p);return i!==void 0&&i(x,j)?(m=p,x):(m=p,d=j)}var h=!1,m,d,u=n===void 0?null:n;return[function(){return c(s())},u===null?void 0:function(){return c(u())}]},[s,n,a,i]);var l=Pb(t,r[0],r[1]);return Fb(function(){o.hasValue=!0,o.value=l},[l]),Bb(l),l};Nc.exports=Sc;var Hb=Nc.exports;const Vb=lu(Hb),Ub={},uo=t=>{let s;const n=new Set,a=(m,d)=>{const u=typeof m=="function"?m(s):m;if(!Object.is(u,s)){const p=s;s=d??(typeof u!="object"||u===null)?u:Object.assign({},s,u),n.forEach(x=>x(s,p))}},i=()=>s,c={setState:a,getState:i,getInitialState:()=>h,subscribe:m=>(n.add(m),()=>n.delete(m)),destroy:()=>{(Ub?"production":void 0)!=="production"&&console.warn("[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected."),n.clear()}},h=s=t(a,i,c);return c},qb=t=>t?uo(t):uo,{useDebugValue:Wb}=rt,{useSyncExternalStoreWithSelector:Gb}=Vb,Yb=t=>t;function Mc(t,s=Yb,n){const a=Gb(t.subscribe,t.getState,t.getServerState||t.getInitialState,s,n);return Wb(a),a}const ho=(t,s)=>{const n=qb(t),a=(i,r=s)=>Mc(n,i,r);return Object.assign(a,n),a},Xb=(t,s)=>t?ho(t,s):ho;function ke(t,s){if(Object.is(t,s))return!0;if(typeof t!="object"||t===null||typeof s!="object"||s===null)return!1;if(t instanceof Map&&s instanceof Map){if(t.size!==s.size)return!1;for(const[a,i]of t)if(!Object.is(i,s.get(a)))return!1;return!0}if(t instanceof Set&&s instanceof Set){if(t.size!==s.size)return!1;for(const a of t)if(!s.has(a))return!1;return!0}const n=Object.keys(t);if(n.length!==Object.keys(s).length)return!1;for(const a of n)if(!Object.prototype.hasOwnProperty.call(s,a)||!Object.is(t[a],s[a]))return!1;return!0}const Na=f.createContext(null),Kb=Na.Provider,$c=yt.error001("react");function ge(t,s){const n=f.useContext(Na);if(n===null)throw new Error($c);return Mc(n,t,s)}function we(){const t=f.useContext(Na);if(t===null)throw new Error($c);return f.useMemo(()=>({getState:t.getState,setState:t.setState,subscribe:t.subscribe}),[t])}const mo={display:"none"},Zb={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},Ec="react-flow__node-desc",_c="react-flow__edge-desc",Qb="react-flow__aria-live",Jb=t=>t.ariaLiveMessage,e0=t=>t.ariaLabelConfig;function t0({rfId:t}){const s=ge(Jb);return e.jsx("div",{id:`${Qb}-${t}`,"aria-live":"assertive","aria-atomic":"true",style:Zb,children:s})}function s0({rfId:t,disableKeyboardA11y:s}){const n=ge(e0);return e.jsxs(e.Fragment,{children:[e.jsx("div",{id:`${Ec}-${t}`,style:mo,children:s?n["node.a11yDescription.default"]:n["node.a11yDescription.keyboardDisabled"]}),e.jsx("div",{id:`${_c}-${t}`,style:mo,children:n["edge.a11yDescription.default"]}),!s&&e.jsx(t0,{rfId:t})]})}const Sa=f.forwardRef(({position:t="top-left",children:s,className:n,style:a,...i},r)=>{const o=`${t}`.split("-");return e.jsx("div",{className:$e(["react-flow__panel",n,...o]),style:a,ref:r,...i,children:s})});Sa.displayName="Panel";const fo="https://reactflow.dev?utm_source=attribution";function n0({proOptions:t,position:s="bottom-right"}){return t!=null&&t.hideAttribution?null:e.jsx(Sa,{position:s,className:"react-flow__attribution","data-message":`Please only hide this attribution when you are subscribed to React Flow Pro: ${fo}`,children:e.jsx("a",{href:fo,target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution",children:"React Flow"})})}const a0=t=>{const s=[],n=[];for(const[,a]of t.nodeLookup)a.selected&&s.push(a.internals.userNode);for(const[,a]of t.edgeLookup)a.selected&&n.push(a);return{selectedNodes:s,selectedEdges:n}},Pn=t=>t.id;function i0(t,s){return ke(t.selectedNodes.map(Pn),s.selectedNodes.map(Pn))&&ke(t.selectedEdges.map(Pn),s.selectedEdges.map(Pn))}function r0({onSelectionChange:t}){const s=we(),{selectedNodes:n,selectedEdges:a}=ge(a0,i0);return f.useEffect(()=>{const i={nodes:n,edges:a};t==null||t(i),s.getState().onSelectionChangeHandlers.forEach(r=>r(i))},[n,a,t]),null}const o0=t=>!!t.onSelectionChangeHandlers;function l0({onSelectionChange:t}){const s=ge(o0);return t||s?e.jsx(r0,{onSelectionChange:t}):null}const Tc=[0,0],c0={x:0,y:0,zoom:1},d0=["nodes","edges","defaultNodes","defaultEdges","onConnect","onConnectStart","onConnectEnd","onClickConnectStart","onClickConnectEnd","nodesDraggable","autoPanOnNodeFocus","nodesConnectable","nodesFocusable","edgesFocusable","edgesReconnectable","elevateNodesOnSelect","elevateEdgesOnSelect","minZoom","maxZoom","nodeExtent","onNodesChange","onEdgesChange","elementsSelectable","connectionMode","snapGrid","snapToGrid","translateExtent","connectOnClick","defaultEdgeOptions","fitView","fitViewOptions","onNodesDelete","onEdgesDelete","onDelete","onNodeDrag","onNodeDragStart","onNodeDragStop","onSelectionDrag","onSelectionDragStart","onSelectionDragStop","onMoveStart","onMove","onMoveEnd","noPanClassName","nodeOrigin","autoPanOnConnect","autoPanOnNodeDrag","onError","connectionRadius","isValidConnection","selectNodesOnDrag","nodeDragThreshold","connectionDragThreshold","onBeforeDelete","debug","autoPanSpeed","ariaLabelConfig","zIndexMode"],po=[...d0,"rfId"],u0=t=>({setNodes:t.setNodes,setEdges:t.setEdges,setMinZoom:t.setMinZoom,setMaxZoom:t.setMaxZoom,setTranslateExtent:t.setTranslateExtent,setNodeExtent:t.setNodeExtent,reset:t.reset,setDefaultNodesAndEdges:t.setDefaultNodesAndEdges}),xo={translateExtent:ln,nodeOrigin:Tc,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:"nopan",rfId:"1"};function h0(t){const{setNodes:s,setEdges:n,setMinZoom:a,setMaxZoom:i,setTranslateExtent:r,setNodeExtent:o,reset:l,setDefaultNodesAndEdges:c}=ge(u0,ke),h=we();f.useEffect(()=>(c(t.defaultNodes,t.defaultEdges),()=>{m.current=xo,l()}),[]);const m=f.useRef(xo);return f.useEffect(()=>{for(const d of po){const u=t[d],p=m.current[d];u!==p&&(typeof t[d]>"u"||(d==="nodes"?s(u):d==="edges"?n(u):d==="minZoom"?a(u):d==="maxZoom"?i(u):d==="translateExtent"?r(u):d==="nodeExtent"?o(u):d==="ariaLabelConfig"?h.setState({ariaLabelConfig:Lj(u)}):d==="fitView"?h.setState({fitViewQueued:u}):d==="fitViewOptions"?h.setState({fitViewOptions:u}):h.setState({[d]:u})))}m.current=t},po.map(d=>t[d])),null}function go(){return typeof window>"u"||!window.matchMedia?null:window.matchMedia("(prefers-color-scheme: dark)")}function m0(t){var a;const[s,n]=f.useState(t==="system"?null:t);return f.useEffect(()=>{if(t!=="system"){n(t);return}const i=go(),r=()=>n(i!=null&&i.matches?"dark":"light");return r(),i==null||i.addEventListener("change",r),()=>{i==null||i.removeEventListener("change",r)}},[t]),s!==null?s:(a=go())!=null&&a.matches?"dark":"light"}const yo=typeof document<"u"?document:null;function hn(t=null,s={target:yo,actInsideInputWithModifier:!0}){const[n,a]=f.useState(!1),i=f.useRef(!1),r=f.useRef(new Set([])),[o,l]=f.useMemo(()=>{if(t!==null){const h=(Array.isArray(t)?t:[t]).filter(d=>typeof d=="string").map(d=>d.replace("+",`
|
|
425
|
+
`).replace(`
|
|
426
|
+
|
|
427
|
+
`,`
|
|
428
|
+
+`).split(`
|
|
429
|
+
`)),m=h.reduce((d,u)=>d.concat(...u),[]);return[h,m]}return[[],[]]},[t]);return f.useEffect(()=>{const c=(s==null?void 0:s.target)??yo,h=(s==null?void 0:s.actInsideInputWithModifier)??!0;if(t!==null){const m=p=>{var v,g;if(i.current=p.ctrlKey||p.metaKey||p.shiftKey||p.altKey,(!i.current||i.current&&!h)&&oc(p))return!1;const j=jo(p.code,l);if(r.current.add(p[j]),vo(o,r.current,!1)){const b=((g=(v=p.composedPath)==null?void 0:v.call(p))==null?void 0:g[0])||p.target,y=(b==null?void 0:b.nodeName)==="BUTTON"||(b==null?void 0:b.nodeName)==="A";s.preventDefault!==!1&&(i.current||!y)&&p.preventDefault(),a(!0)}},d=p=>{const x=jo(p.code,l);vo(o,r.current,!0)?(a(!1),r.current.clear()):r.current.delete(p[x]),p.key==="Meta"&&r.current.clear(),i.current=!1},u=()=>{r.current.clear(),a(!1)};return c==null||c.addEventListener("keydown",m),c==null||c.addEventListener("keyup",d),window.addEventListener("blur",u),window.addEventListener("contextmenu",u),()=>{c==null||c.removeEventListener("keydown",m),c==null||c.removeEventListener("keyup",d),window.removeEventListener("blur",u),window.removeEventListener("contextmenu",u)}}},[t,a]),n}function vo(t,s,n){return t.filter(a=>n||a.length===s.size).some(a=>a.every(i=>s.has(i)))}function jo(t,s){return s.includes(t)?"code":"key"}const f0=()=>{const t=we();return f.useMemo(()=>({zoomIn:async s=>{const{panZoom:n}=t.getState();return n?n.scaleBy(1.2,s):!1},zoomOut:async s=>{const{panZoom:n}=t.getState();return n?n.scaleBy(1/1.2,s):!1},zoomTo:async(s,n)=>{const{panZoom:a}=t.getState();return a?a.scaleTo(s,n):!1},getZoom:()=>t.getState().transform[2],setViewport:async(s,n)=>{const{transform:[a,i,r],panZoom:o}=t.getState();return o?(await o.setViewport({x:s.x??a,y:s.y??i,zoom:s.zoom??r},n),!0):!1},getViewport:()=>{const[s,n,a]=t.getState().transform;return{x:s,y:n,zoom:a}},setCenter:async(s,n,a)=>t.getState().setCenter(s,n,a),fitBounds:async(s,n)=>{const{width:a,height:i,minZoom:r,maxZoom:o,panZoom:l}=t.getState(),c=Yi(s,a,i,r,o,(n==null?void 0:n.padding)??.1);return l?(await l.setViewport(c,{duration:n==null?void 0:n.duration,ease:n==null?void 0:n.ease,interpolate:n==null?void 0:n.interpolate}),!0):!1},screenToFlowPosition:(s,n={})=>{const{transform:a,snapGrid:i,snapToGrid:r,domNode:o}=t.getState();if(!o)return s;const{x:l,y:c}=o.getBoundingClientRect(),h={x:s.x-l,y:s.y-c},m=n.snapGrid??i,d=n.snapToGrid??r;return bn(h,a,d,m)},flowToScreenPosition:s=>{const{transform:n,domNode:a}=t.getState();if(!a)return s;const{x:i,y:r}=a.getBoundingClientRect(),o=_s(s,n);return{x:o.x+i,y:o.y+r}}}),[])};function Ac(t,s){const n=[],a=new Map,i=[];for(const r of t)if(r.type==="add"){i.push(r);continue}else if(r.type==="remove"||r.type==="replace")a.set(r.id,[r]);else{const o=a.get(r.id);o?o.push(r):a.set(r.id,[r])}for(const r of s){const o=a.get(r.id);if(!o){n.push(r);continue}if(o[0].type==="remove")continue;if(o[0].type==="replace"){n.push({...o[0].item});continue}const l={...r};for(const c of o)p0(c,l);n.push(l)}return i.length&&i.forEach(r=>{r.index!==void 0?n.splice(r.index,0,{...r.item}):n.push({...r.item})}),n}function p0(t,s){switch(t.type){case"select":{s.selected=t.selected;break}case"position":{typeof t.position<"u"&&(s.position=t.position),typeof t.dragging<"u"&&(s.dragging=t.dragging);break}case"dimensions":{typeof t.dimensions<"u"&&(s.measured={...t.dimensions},t.setAttributes&&((t.setAttributes===!0||t.setAttributes==="width")&&(s.width=t.dimensions.width),(t.setAttributes===!0||t.setAttributes==="height")&&(s.height=t.dimensions.height))),typeof t.resizing=="boolean"&&(s.resizing=t.resizing);break}}}function x0(t,s){return Ac(t,s)}function g0(t,s){return Ac(t,s)}function Gt(t,s){return{id:t,type:"select",selected:s}}function gs(t,s=new Set,n=!1){const a=[];for(const[i,r]of t){const o=s.has(i);!(r.selected===void 0&&!o)&&r.selected!==o&&(n&&(r.selected=o),a.push(Gt(r.id,o)))}return a}function bo({items:t=[],lookup:s}){var i;const n=[],a=new Map(t.map(r=>[r.id,r]));for(const[r,o]of t.entries()){const l=s.get(o.id),c=((i=l==null?void 0:l.internals)==null?void 0:i.userNode)??l;c!==void 0&&c!==o&&n.push({id:o.id,item:o,type:"replace"}),c===void 0&&n.push({item:o,type:"add",index:r})}for(const[r]of s)a.get(r)===void 0&&n.push({id:r,type:"remove"});return n}function wo(t){return{id:t.id,type:"remove"}}const y0=nc();function v0(t,s,n={}){return Hj(t,s,{...n,onError:n.onError??y0})}const ko=t=>zj(t),j0=t=>Ql(t);function Rc(t){return f.forwardRef(t)}const Ic=typeof window<"u"?f.useLayoutEffect:f.useEffect;function No(t){const[s,n]=f.useState(BigInt(0)),[a]=f.useState(()=>b0(()=>n(i=>i+BigInt(1))));return Ic(()=>{const i=a.get();i.length&&(t(i),a.reset())},[s]),a}function b0(t){let s=[];return{get:()=>s,reset:()=>{s=[]},push:n=>{s.push(n),t()}}}const Lc=f.createContext(null);function w0({children:t}){const s=we(),n=f.useCallback(l=>{const{nodes:c=[],setNodes:h,hasDefaultNodes:m,onNodesChange:d,nodeLookup:u,fitViewQueued:p,onNodesChangeMiddlewareMap:x}=s.getState();let j=c;for(const g of l)j=typeof g=="function"?g(j):g;let v=bo({items:j,lookup:u});for(const g of x.values())v=g(v);m&&h(j),v.length>0?d==null||d(v):p&&window.requestAnimationFrame(()=>{const{fitViewQueued:g,nodes:b,setNodes:y}=s.getState();g&&y(b)})},[]),a=No(n),i=f.useCallback(l=>{const{edges:c=[],setEdges:h,hasDefaultEdges:m,onEdgesChange:d,edgeLookup:u}=s.getState();let p=c;for(const x of l)p=typeof x=="function"?x(p):x;m?h(p):d&&d(bo({items:p,lookup:u}))},[]),r=No(i),o=f.useMemo(()=>({nodeQueue:a,edgeQueue:r}),[]);return e.jsx(Lc.Provider,{value:o,children:t})}function k0(){const t=f.useContext(Lc);if(!t)throw new Error("useBatchContext must be used within a BatchProvider");return t}const N0=t=>!!t.panZoom;function tr(){const t=f0(),s=we(),n=k0(),a=ge(N0),i=f.useMemo(()=>{const r=d=>s.getState().nodeLookup.get(d),o=d=>{n.nodeQueue.push(d)},l=d=>{n.edgeQueue.push(d)},c=d=>{var g,b;const{nodeLookup:u,nodeOrigin:p}=s.getState(),x=ko(d)?d:u.get(d.id),j=x.parentId?ic(x.position,x.measured,x.parentId,u,p):x.position,v={...x,position:j,width:((g=x.measured)==null?void 0:g.width)??x.width,height:((b=x.measured)==null?void 0:b.height)??x.height};return dn(v)},h=(d,u,p={replace:!1})=>{o(x=>x.map(j=>{if(j.id===d){const v=typeof u=="function"?u(j):u;return p.replace&&ko(v)?v:{...j,...v}}return j}))},m=(d,u,p={replace:!1})=>{l(x=>x.map(j=>{if(j.id===d){const v=typeof u=="function"?u(j):u;return p.replace&&j0(v)?v:{...j,...v}}return j}))};return{getNodes:()=>s.getState().nodes.map(d=>({...d})),getNode:d=>{var u;return(u=r(d))==null?void 0:u.internals.userNode},getInternalNode:r,getEdges:()=>{const{edges:d=[]}=s.getState();return d.map(u=>({...u}))},getEdge:d=>s.getState().edgeLookup.get(d),setNodes:o,setEdges:l,addNodes:d=>{const u=Array.isArray(d)?d:[d];n.nodeQueue.push(p=>[...p,...u])},addEdges:d=>{const u=Array.isArray(d)?d:[d];n.edgeQueue.push(p=>[...p,...u])},toObject:()=>{const{nodes:d=[],edges:u=[],transform:p}=s.getState(),[x,j,v]=p;return{nodes:d.map(g=>({...g})),edges:u.map(g=>({...g})),viewport:{x,y:j,zoom:v}}},deleteElements:async({nodes:d=[],edges:u=[]})=>{const{nodes:p,edges:x,onNodesDelete:j,onEdgesDelete:v,triggerNodeChanges:g,triggerEdgeChanges:b,onDelete:y,onBeforeDelete:w}=s.getState(),{nodes:S,edges:$}=await Tj({nodesToRemove:d,edgesToRemove:u,nodes:p,edges:x,onBeforeDelete:w}),M=$.length>0,z=S.length>0;if(M){const A=$.map(wo);v==null||v($),b(A)}if(z){const A=S.map(wo);j==null||j(S),g(A)}return(z||M)&&(y==null||y({nodes:S,edges:$})),{deletedNodes:S,deletedEdges:$}},getIntersectingNodes:(d,u=!0,p)=>{const x=Zr(d),j=x?d:c(d),v=p!==void 0;return j?(p||s.getState().nodes).filter(g=>{const b=s.getState().nodeLookup.get(g.id);if(b&&!x&&(g.id===d.id||!b.internals.positionAbsolute))return!1;const y=dn(v?g:b),w=ca(y,j);return u&&w>0||w>=y.width*y.height||w>=j.width*j.height}):[]},isNodeIntersecting:(d,u,p=!0)=>{const j=Zr(d)?d:c(d);if(!j)return!1;const v=ca(j,u);return p&&v>0||v>=u.width*u.height||v>=j.width*j.height},updateNode:h,updateNodeData:(d,u,p={replace:!1})=>{h(d,x=>{const j=typeof u=="function"?u(x):u;return p.replace?{...x,data:j}:{...x,data:{...x.data,...j}}},p)},updateEdge:m,updateEdgeData:(d,u,p={replace:!1})=>{m(d,x=>{const j=typeof u=="function"?u(x):u;return p.replace?{...x,data:j}:{...x,data:{...x.data,...j}}},p)},getNodesBounds:d=>{const{nodeLookup:u,nodeOrigin:p}=s.getState();return Mj(d,{nodeLookup:u,nodeOrigin:p})},getHandleConnections:({type:d,id:u,nodeId:p})=>{var x;return Array.from(((x=s.getState().connectionLookup.get(`${p}-${d}${u?`-${u}`:""}`))==null?void 0:x.values())??[])},getNodeConnections:({type:d,handleId:u,nodeId:p})=>{var x;return Array.from(((x=s.getState().connectionLookup.get(`${p}${d?u?`-${d}-${u}`:`-${d}`:""}`))==null?void 0:x.values())??[])},fitView:async d=>{const u=s.getState().fitViewResolver??Ij();return s.setState({fitViewQueued:!0,fitViewOptions:d,fitViewResolver:u}),n.nodeQueue.push(p=>[...p]),u.promise}}},[]);return f.useMemo(()=>({...i,...t,viewportInitialized:a}),[a])}const So=t=>t.selected,S0=typeof window<"u"?window:void 0;function C0({deleteKeyCode:t,multiSelectionKeyCode:s}){const n=we(),{deleteElements:a}=tr(),i=hn(t,{actInsideInputWithModifier:!1}),r=hn(s,{target:S0});f.useEffect(()=>{if(i){const{edges:o,nodes:l}=n.getState();a({nodes:l.filter(So),edges:o.filter(So)}),n.setState({nodesSelectionActive:!1})}},[i]),f.useEffect(()=>{n.setState({multiSelectionActive:r})},[r])}function z0(t){const s=we();f.useEffect(()=>{const n=()=>{var i,r,o,l;if(!t.current||!(((r=(i=t.current).checkVisibility)==null?void 0:r.call(i))??!0))return!1;const a=Xi(t.current);(a.height===0||a.width===0)&&((l=(o=s.getState()).onError)==null||l.call(o,"004",yt.error004())),s.setState({width:a.width||500,height:a.height||500})};if(t.current){n(),window.addEventListener("resize",n);const a=new ResizeObserver(()=>n());return a.observe(t.current),()=>{window.removeEventListener("resize",n),a&&t.current&&a.unobserve(t.current)}}},[])}const Ca={position:"absolute",width:"100%",height:"100%",top:0,left:0},M0=t=>({userSelectionActive:t.userSelectionActive,lib:t.lib,connectionInProgress:t.connection.inProgress});function $0({onPaneContextMenu:t,zoomOnScroll:s=!0,zoomOnPinch:n=!0,panOnScroll:a=!1,panOnScrollSpeed:i=.5,panOnScrollMode:r=Zt.Free,zoomOnDoubleClick:o=!0,panOnDrag:l=!0,defaultViewport:c,translateExtent:h,minZoom:m,maxZoom:d,zoomActivationKeyCode:u,preventScrolling:p=!0,children:x,noWheelClassName:j,noPanClassName:v,onViewportChange:g,isControlledViewport:b,paneClickDistance:y,selectionOnDrag:w}){const S=we(),$=f.useRef(null),{userSelectionActive:M,lib:z,connectionInProgress:A}=ge(M0,ke),k=hn(u),C=f.useRef();z0($);const _=f.useCallback(P=>{g==null||g({x:P[0],y:P[1],zoom:P[2]}),b||S.setState({transform:P})},[g,b]);return f.useEffect(()=>{if($.current){C.current=yb({domNode:$.current,minZoom:m,maxZoom:d,translateExtent:h,viewport:c,onDraggingChange:L=>S.setState(R=>R.paneDragging===L?R:{paneDragging:L}),onPanZoomStart:(L,R)=>{const{onViewportChangeStart:F,onMoveStart:E}=S.getState();E==null||E(L,R),F==null||F(R)},onPanZoom:(L,R)=>{const{onViewportChange:F,onMove:E}=S.getState();E==null||E(L,R),F==null||F(R)},onPanZoomEnd:(L,R)=>{const{onViewportChangeEnd:F,onMoveEnd:E}=S.getState();E==null||E(L,R),F==null||F(R)}});const{x:P,y:N,zoom:T}=C.current.getViewport();return S.setState({panZoom:C.current,transform:[P,N,T],domNode:$.current.closest(".react-flow")}),()=>{var L;(L=C.current)==null||L.destroy()}}},[]),f.useEffect(()=>{var P;(P=C.current)==null||P.update({onPaneContextMenu:t,zoomOnScroll:s,zoomOnPinch:n,panOnScroll:a,panOnScrollSpeed:i,panOnScrollMode:r,zoomOnDoubleClick:o,panOnDrag:l,zoomActivationKeyPressed:k,preventScrolling:p,noPanClassName:v,userSelectionActive:M,noWheelClassName:j,lib:z,onTransformChange:_,connectionInProgress:A,selectionOnDrag:w,paneClickDistance:y})},[t,s,n,a,i,r,o,l,k,p,v,M,j,z,_,A,w,y]),e.jsx("div",{className:"react-flow__renderer",ref:$,style:Ca,children:x})}const E0=t=>({userSelectionActive:t.userSelectionActive,userSelectionRect:t.userSelectionRect});function _0(){const{userSelectionActive:t,userSelectionRect:s}=ge(E0,ke);return t&&s?e.jsx("div",{className:"react-flow__selection react-flow__container",style:{width:s.width,height:s.height,transform:`translate(${s.x}px, ${s.y}px)`}}):null}const Qa=(t,s)=>n=>{n.target===s.current&&(t==null||t(n))},T0=t=>({userSelectionActive:t.userSelectionActive,elementsSelectable:t.elementsSelectable,dragging:t.paneDragging,panBy:t.panBy,autoPanSpeed:t.autoPanSpeed});function A0({isSelecting:t,selectionKeyPressed:s,selectionMode:n=cn.Full,panOnDrag:a,autoPanOnSelection:i,paneClickDistance:r,selectionOnDrag:o,onSelectionStart:l,onSelectionEnd:c,onPaneClick:h,onPaneContextMenu:m,onPaneScroll:d,onPaneMouseEnter:u,onPaneMouseMove:p,onPaneMouseLeave:x,children:j}){const v=f.useRef(0),g=we(),{userSelectionActive:b,elementsSelectable:y,dragging:w,panBy:S,autoPanSpeed:$}=ge(T0,ke),M=y&&(t||b),z=f.useRef(null),A=f.useRef(),k=f.useRef(new Set),C=f.useRef(new Set),_=f.useRef(!1),P=f.useRef(!1),N=f.useRef({x:0,y:0}),T=f.useRef(!1),L=B=>{if(P.current||_.current||g.getState().connection.inProgress){P.current=!1,_.current=!1;return}h==null||h(B),g.getState().resetSelectedElements(),g.setState({nodesSelectionActive:!1})},R=B=>{if(Array.isArray(a)&&(a!=null&&a.includes(2))){B.preventDefault();return}m==null||m(B)},F=d?B=>d(B):void 0,E=B=>{P.current&&(B.stopPropagation(),P.current=!1)},D=B=>{var oe,ce;const{domNode:Y,transform:ee}=g.getState();if(A.current=Y==null?void 0:Y.getBoundingClientRect(),!A.current)return;const ae=B.target===z.current;if(!ae&&!!B.target.closest(".nokey")||!t||!(o&&ae||s)||B.button!==0||!B.isPrimary)return;(ce=(oe=B.target)==null?void 0:oe.setPointerCapture)==null||ce.call(oe,B.pointerId),P.current=!1;const{x:K,y:Z}=ft(B.nativeEvent,A.current),Q=bn({x:K,y:Z},ee);g.setState({userSelectionRect:{width:0,height:0,startX:Q.x,startY:Q.y,x:K,y:Z}}),ae||(B.stopPropagation(),B.preventDefault())};function G(B,Y){const{userSelectionRect:ee}=g.getState();if(!ee)return;const{transform:ae,nodeLookup:ne,edgeLookup:O,connectionLookup:K,triggerNodeChanges:Z,triggerEdgeChanges:Q,defaultEdgeOptions:oe}=g.getState(),ce={x:ee.startX,y:ee.startY},{x:me,y:be}=_s(ce,ae),Ne={startX:ce.x,startY:ce.y,x:B<me?B:me,y:Y<be?Y:be,width:Math.abs(B-me),height:Math.abs(Y-be)},Me=k.current,Ge=C.current;k.current=new Set(Wi(ne,Ne,ae,n===cn.Partial,!0).map(De=>De.id)),C.current=new Set;const Je=(oe==null?void 0:oe.selectable)??!0;for(const De of k.current){const Oe=K.get(De);if(Oe)for(const{edgeId:Ye}of Oe.values()){const Mt=O.get(Ye);Mt&&(Mt.selectable??Je)&&C.current.add(Ye)}}if(!Qr(Me,k.current)){const De=gs(ne,k.current,!0);Z(De)}if(!Qr(Ge,C.current)){const De=gs(O,C.current);Q(De)}g.setState({userSelectionRect:Ne,userSelectionActive:!0,nodesSelectionActive:!1})}function I(){if(!i||!A.current)return;const[B,Y]=Gi(N.current,A.current,$);S({x:B,y:Y}).then(ee=>{if(!P.current||!ee){v.current=requestAnimationFrame(I);return}const{x:ae,y:ne}=N.current;G(ae,ne),v.current=requestAnimationFrame(I)})}const W=()=>{cancelAnimationFrame(v.current),v.current=0,T.current=!1};f.useEffect(()=>()=>W(),[]);const V=B=>{const{userSelectionRect:Y,transform:ee,resetSelectedElements:ae}=g.getState();if(!A.current||!Y)return;const{x:ne,y:O}=ft(B.nativeEvent,A.current);N.current={x:ne,y:O};const K=_s({x:Y.startX,y:Y.startY},ee);if(!P.current){const Z=s?0:r;if(Math.hypot(ne-K.x,O-K.y)<=Z)return;ae(),l==null||l(B)}P.current=!0,T.current||(I(),T.current=!0),G(ne,O)},X=B=>{var Y,ee;if(!M){B.target===z.current&&g.getState().connection.inProgress&&(_.current=!0);return}B.button===0&&((ee=(Y=B.target)==null?void 0:Y.releasePointerCapture)==null||ee.call(Y,B.pointerId),!b&&B.target===z.current&&g.getState().userSelectionRect&&(L==null||L(B)),g.setState({userSelectionActive:!1,userSelectionRect:null}),P.current&&(c==null||c(B),g.setState({nodesSelectionActive:k.current.size>0})),W())},J=B=>{var Y,ee;(ee=(Y=B.target)==null?void 0:Y.releasePointerCapture)==null||ee.call(Y,B.pointerId),W()},le=a===!0||Array.isArray(a)&&a.includes(0);return e.jsxs("div",{className:$e(["react-flow__pane",{draggable:le,dragging:w,selection:t}]),onClick:M?void 0:Qa(L,z),onContextMenu:Qa(R,z),onWheel:Qa(F,z),onPointerEnter:M?void 0:u,onPointerMove:M?V:p,onPointerUp:X,onPointerCancel:M?J:void 0,onPointerDownCapture:M?D:void 0,onClickCapture:M?E:void 0,onPointerLeave:x,ref:z,style:Ca,children:[j,e.jsx(_0,{})]})}function bi({id:t,store:s,unselect:n=!1,nodeRef:a}){const{addSelectedNodes:i,unselectNodesAndEdges:r,multiSelectionActive:o,nodeLookup:l,onError:c}=s.getState(),h=l.get(t);if(!h){c==null||c("012",yt.error012(t));return}s.setState({nodesSelectionActive:!1}),h.selected?(n||h.selected&&o)&&(r({nodes:[h],edges:[]}),requestAnimationFrame(()=>{var m;return(m=a==null?void 0:a.current)==null?void 0:m.blur()})):i([t])}function Pc({nodeRef:t,disabled:s=!1,noDragClassName:n,handleSelector:a,nodeId:i,isSelectable:r,nodeClickDistance:o}){const l=we(),[c,h]=f.useState(!1),m=f.useRef();return f.useEffect(()=>{if(!s)return m.current=ab({getStoreItems:()=>l.getState(),onNodeMouseDown:d=>{bi({id:d,store:l,nodeRef:t})},onDragStart:()=>{h(!0)},onDragStop:()=>{h(!1)}}),()=>{var d;(d=m.current)==null||d.destroy(),m.current=void 0}},[s,l,t]),f.useEffect(()=>{s||!t.current||!m.current||m.current.update({noDragClassName:n,handleSelector:a,domNode:t.current,isSelectable:r,nodeId:i,nodeClickDistance:o})},[n,a,s,r,t,i,o]),c}const R0=t=>s=>s.selected&&(s.draggable||t&&typeof s.draggable>"u");function Dc(){const t=we();return f.useCallback(n=>{const{nodeExtent:a,snapToGrid:i,snapGrid:r,nodesDraggable:o,onError:l,updateNodePositions:c,nodeLookup:h,nodeOrigin:m}=t.getState(),d=new Map,u=R0(o),p=i?r[0]:5,x=i?r[1]:5,j=n.direction.x*p*n.factor,v=n.direction.y*x*n.factor;for(const[,g]of h){if(!u(g))continue;let b={x:g.internals.positionAbsolute.x+j,y:g.internals.positionAbsolute.y+v};i&&(b=jn(b,r));const{position:y,positionAbsolute:w}=Jl({nodeId:g.id,nextPosition:b,nodeLookup:h,nodeExtent:a,nodeOrigin:m,onError:l});g.position=y,g.internals.positionAbsolute=w,d.set(g.id,g)}c(d)},[])}const sr=f.createContext(null),I0=sr.Provider;sr.Consumer;const Fc=()=>f.useContext(sr),L0=t=>({connectOnClick:t.connectOnClick,noPanClassName:t.noPanClassName,rfId:t.rfId}),Oc=f.createContext(null);function P0({children:t}){const s=ge(L0,ke);return e.jsx(Oc.Provider,{value:s,children:t})}function D0(){const t=f.useContext(Oc);if(!t)throw new Error("useHandleConfig must be used within a HandleConfigProvider");return t}const F0={connectingFrom:!1,connectingTo:!1,clickConnecting:!1,isPossibleEndHandle:!0,connectionInProcess:!1,clickConnectionInProcess:!1,valid:!1},O0=(t,s,n)=>a=>{const{connectionClickStartHandle:i,connectionMode:r,connection:o}=a,{fromHandle:l,toHandle:c,isValid:h}=o;if(!l&&!i)return F0;const m=(c==null?void 0:c.nodeId)===t&&(c==null?void 0:c.id)===s&&(c==null?void 0:c.type)===n;return{connectingFrom:(l==null?void 0:l.nodeId)===t&&(l==null?void 0:l.id)===s&&(l==null?void 0:l.type)===n,connectingTo:m,clickConnecting:(i==null?void 0:i.nodeId)===t&&(i==null?void 0:i.id)===s&&(i==null?void 0:i.type)===n,isPossibleEndHandle:r===$s.Strict?(l==null?void 0:l.type)!==n:t!==(l==null?void 0:l.nodeId)||s!==(l==null?void 0:l.id),connectionInProcess:!!l,clickConnectionInProcess:!!i,valid:m&&h}};function B0({type:t="source",position:s=he.Top,isValidConnection:n,isConnectable:a=!0,isConnectableStart:i=!0,isConnectableEnd:r=!0,id:o,onConnect:l,children:c,className:h,onMouseDown:m,onTouchStart:d,...u},p){var T,L;const x=o||null,j=t==="target",v=we(),g=Fc(),{connectOnClick:b,noPanClassName:y,rfId:w}=D0(),{connectingFrom:S,connectingTo:$,clickConnecting:M,isPossibleEndHandle:z,connectionInProcess:A,clickConnectionInProcess:k,valid:C}=ge(O0(g,x,t),ke);g||(L=(T=v.getState()).onError)==null||L.call(T,"010",yt.error010());const _=R=>{const{defaultEdgeOptions:F,onConnect:E,hasDefaultEdges:D}=v.getState(),G={...F,...R};if(D){const{edges:I,setEdges:W,onError:V}=v.getState();W(v0(G,I,{onError:V}))}E==null||E(G),l==null||l(G)},P=R=>{if(!g)return;const F=lc(R.nativeEvent);if(i&&(F&&R.button===0||!F)){const E=v.getState();ji.onPointerDown(R.nativeEvent,{handleDomNode:R.currentTarget,autoPanOnConnect:E.autoPanOnConnect,connectionMode:E.connectionMode,connectionRadius:E.connectionRadius,domNode:E.domNode,nodeLookup:E.nodeLookup,lib:E.lib,isTarget:j,handleId:x,nodeId:g,flowId:E.rfId,panBy:E.panBy,cancelConnection:E.cancelConnection,onConnectStart:E.onConnectStart,onConnectEnd:(...D)=>{var G,I;return(I=(G=v.getState()).onConnectEnd)==null?void 0:I.call(G,...D)},updateConnection:E.updateConnection,onConnect:_,isValidConnection:n||((...D)=>{var G,I;return((I=(G=v.getState()).isValidConnection)==null?void 0:I.call(G,...D))??!0}),getTransform:()=>v.getState().transform,getFromHandle:()=>v.getState().connection.fromHandle,autoPanSpeed:E.autoPanSpeed,dragThreshold:E.connectionDragThreshold})}F?m==null||m(R):d==null||d(R)},N=R=>{const{onClickConnectStart:F,onClickConnectEnd:E,connectionClickStartHandle:D,connectionMode:G,isValidConnection:I,lib:W,rfId:V,nodeLookup:X,connection:J}=v.getState();if(!g||!D&&!i)return;if(!D){F==null||F(R.nativeEvent,{nodeId:g,handleId:x,handleType:t}),v.setState({connectionClickStartHandle:{nodeId:g,type:t,id:x}});return}const le=rc(R.target),B=n||I,{connection:Y,isValid:ee}=ji.isValid(R.nativeEvent,{handle:{nodeId:g,id:x,type:t},connectionMode:G,fromNodeId:D.nodeId,fromHandleId:D.id||null,fromType:D.type,isValidConnection:B,flowId:V,doc:le,lib:W,nodeLookup:X});ee&&Y&&_(Y);const ae=structuredClone(J);delete ae.inProgress,ae.toPosition=ae.toHandle?ae.toHandle.position:null,E==null||E(R,ae),v.setState({connectionClickStartHandle:null})};return e.jsx("div",{"data-handleid":x,"data-nodeid":g,"data-handlepos":s,"data-id":`${w}-${g}-${x}-${t}`,className:$e(["react-flow__handle",`react-flow__handle-${s}`,"nodrag",y,h,{source:!j,target:j,connectable:a,connectablestart:i,connectableend:r,clickconnecting:M,connectingfrom:S,connectingto:$,valid:C,connectionindicator:a&&(!A||z)&&(A||k?r:i)}]),onMouseDown:P,onTouchStart:P,onClick:b?N:void 0,ref:p,...u,children:c})}const Rs=f.memo(Rc(B0));function H0({data:t,isConnectable:s,sourcePosition:n=he.Bottom}){return e.jsxs(e.Fragment,{children:[t==null?void 0:t.label,e.jsx(Rs,{type:"source",position:n,isConnectable:s})]})}function V0({data:t,isConnectable:s,targetPosition:n=he.Top,sourcePosition:a=he.Bottom}){return e.jsxs(e.Fragment,{children:[e.jsx(Rs,{type:"target",position:n,isConnectable:s}),t==null?void 0:t.label,e.jsx(Rs,{type:"source",position:a,isConnectable:s})]})}function U0(){return null}function q0({data:t,isConnectable:s,targetPosition:n=he.Top}){return e.jsxs(e.Fragment,{children:[e.jsx(Rs,{type:"target",position:n,isConnectable:s}),t==null?void 0:t.label]})}const da={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},Co={input:H0,default:V0,output:q0,group:U0};function W0(t){var s,n,a,i;return t.internals.handleBounds===void 0?{width:t.width??t.initialWidth??((s=t.style)==null?void 0:s.width),height:t.height??t.initialHeight??((n=t.style)==null?void 0:n.height)}:{width:t.width??((a=t.style)==null?void 0:a.width),height:t.height??((i=t.style)==null?void 0:i.height)}}const G0=t=>{const{width:s,height:n,x:a,y:i}=vn(t.nodeLookup,{filter:r=>!!r.selected});return{width:mt(s)?s:null,height:mt(n)?n:null,userSelectionActive:t.userSelectionActive,transformString:`translate(${t.transform[0]}px,${t.transform[1]}px) scale(${t.transform[2]}) translate(${a}px,${i}px)`}};function Y0({onSelectionContextMenu:t,noPanClassName:s,disableKeyboardA11y:n}){const a=we(),{width:i,height:r,transformString:o,userSelectionActive:l}=ge(G0,ke),c=Dc(),h=f.useRef(null);f.useEffect(()=>{var p;n||(p=h.current)==null||p.focus({preventScroll:!0})},[n]);const m=!l&&i!==null&&r!==null;if(Pc({nodeRef:h,disabled:!m}),!m)return null;const d=t?p=>{const x=a.getState().nodes.filter(j=>j.selected);t(p,x)}:void 0,u=p=>{Object.prototype.hasOwnProperty.call(da,p.key)&&(p.preventDefault(),c({direction:da[p.key],factor:p.shiftKey?4:1}))};return e.jsx("div",{className:$e(["react-flow__nodesselection","react-flow__container",s]),style:{transform:o},children:e.jsx("div",{ref:h,className:"react-flow__nodesselection-rect",onContextMenu:d,tabIndex:n?void 0:-1,onKeyDown:n?void 0:u,style:{width:i,height:r}})})}const zo=typeof window<"u"?window:void 0,X0=t=>({nodesSelectionActive:t.nodesSelectionActive,userSelectionActive:t.userSelectionActive});function Bc({children:t,onPaneClick:s,onPaneMouseEnter:n,onPaneMouseMove:a,onPaneMouseLeave:i,onPaneContextMenu:r,onPaneScroll:o,paneClickDistance:l,deleteKeyCode:c,selectionKeyCode:h,selectionOnDrag:m,selectionMode:d,onSelectionStart:u,onSelectionEnd:p,multiSelectionKeyCode:x,panActivationKeyCode:j,zoomActivationKeyCode:v,elementsSelectable:g,zoomOnScroll:b,zoomOnPinch:y,panOnScroll:w,panOnScrollSpeed:S,panOnScrollMode:$,zoomOnDoubleClick:M,panOnDrag:z,autoPanOnSelection:A,defaultViewport:k,translateExtent:C,minZoom:_,maxZoom:P,preventScrolling:N,onSelectionContextMenu:T,noWheelClassName:L,noPanClassName:R,disableKeyboardA11y:F,onViewportChange:E,isControlledViewport:D}){const{nodesSelectionActive:G,userSelectionActive:I}=ge(X0,ke),W=hn(h,{target:zo}),V=hn(j,{target:zo}),X=V||z,J=V||w,le=m&&X!==!0,B=W||I||le;return C0({deleteKeyCode:c,multiSelectionKeyCode:x}),e.jsx($0,{onPaneContextMenu:r,elementsSelectable:g,zoomOnScroll:b,zoomOnPinch:y,panOnScroll:J,panOnScrollSpeed:S,panOnScrollMode:$,zoomOnDoubleClick:M,panOnDrag:!W&&X,defaultViewport:k,translateExtent:C,minZoom:_,maxZoom:P,zoomActivationKeyCode:v,preventScrolling:N,noWheelClassName:L,noPanClassName:R,onViewportChange:E,isControlledViewport:D,paneClickDistance:l,selectionOnDrag:le,children:e.jsxs(A0,{onSelectionStart:u,onSelectionEnd:p,onPaneClick:s,onPaneMouseEnter:n,onPaneMouseMove:a,onPaneMouseLeave:i,onPaneContextMenu:r,onPaneScroll:o,panOnDrag:X,autoPanOnSelection:A,isSelecting:!!B,selectionMode:d,selectionKeyPressed:W,paneClickDistance:l,selectionOnDrag:le,children:[t,G&&e.jsx(Y0,{onSelectionContextMenu:T,noPanClassName:R,disableKeyboardA11y:F})]})})}Bc.displayName="FlowRenderer";const K0=f.memo(Bc),Z0=t=>s=>t?Wi(s.nodeLookup,{x:0,y:0,width:s.width,height:s.height},s.transform,!0).map(n=>n.id):Array.from(s.nodeLookup.keys());function Q0(t){return ge(f.useCallback(Z0(t),[t]),ke)}const J0=t=>t.updateNodeInternals;function e1(){const t=ge(J0),[s]=f.useState(()=>typeof ResizeObserver>"u"?null:new ResizeObserver(n=>{const a=new Map;n.forEach(i=>{const r=i.target.getAttribute("data-id");a.set(r,{id:r,nodeElement:i.target,force:!0})}),t(a)}));return f.useEffect(()=>()=>{s==null||s.disconnect()},[s]),s}function t1({node:t,nodeType:s,hasDimensions:n,resizeObserver:a}){const i=we(),r=f.useRef(null),o=f.useRef(null),l=f.useRef(t.sourcePosition),c=f.useRef(t.targetPosition),h=f.useRef(s),m=n&&!!t.internals.handleBounds;return f.useEffect(()=>{r.current&&!t.hidden&&(!m||o.current!==r.current)&&(o.current&&(a==null||a.unobserve(o.current)),a==null||a.observe(r.current),o.current=r.current)},[m,t.hidden]),f.useEffect(()=>()=>{o.current&&(a==null||a.unobserve(o.current),o.current=null)},[]),f.useEffect(()=>{if(r.current){const d=h.current!==s,u=l.current!==t.sourcePosition,p=c.current!==t.targetPosition;(d||u||p)&&(h.current=s,l.current=t.sourcePosition,c.current=t.targetPosition,i.getState().updateNodeInternals(new Map([[t.id,{id:t.id,nodeElement:r.current,force:!0}]])))}},[t.id,s,t.sourcePosition,t.targetPosition]),r}function s1({id:t,onClick:s,onMouseEnter:n,onMouseMove:a,onMouseLeave:i,onContextMenu:r,onDoubleClick:o,nodesDraggable:l,elementsSelectable:c,nodesConnectable:h,nodesFocusable:m,resizeObserver:d,noDragClassName:u,noPanClassName:p,disableKeyboardA11y:x,rfId:j,nodeTypes:v,nodeClickDistance:g,onError:b}){const{node:y,internals:w,isParent:S}=ge(B=>{const Y=B.nodeLookup.get(t),ee=B.parentLookup.has(t);return{node:Y,internals:Y.internals,isParent:ee}},ke);let $=y.type||"default",M=(v==null?void 0:v[$])||Co[$];M===void 0&&(b==null||b("003",yt.error003($)),$="default",M=(v==null?void 0:v.default)||Co.default);const z=!!(y.draggable||l&&typeof y.draggable>"u"),A=!!(y.selectable||c&&typeof y.selectable>"u"),k=!!(y.connectable||h&&typeof y.connectable>"u"),C=!!(y.focusable||m&&typeof y.focusable>"u"),_=we(),P=ac(y),N=t1({node:y,nodeType:$,hasDimensions:P,resizeObserver:d}),T=Pc({nodeRef:N,disabled:y.hidden||!z,noDragClassName:u,handleSelector:y.dragHandle,nodeId:t,isSelectable:A,nodeClickDistance:g}),L=Dc();if(y.hidden)return null;const R=zt(y),F=W0(y),E=A||z||s||n||a||i,D=n?B=>n(B,{...w.userNode}):void 0,G=a?B=>a(B,{...w.userNode}):void 0,I=i?B=>i(B,{...w.userNode}):void 0,W=r?B=>r(B,{...w.userNode}):void 0,V=o?B=>o(B,{...w.userNode}):void 0,X=B=>{const{selectNodesOnDrag:Y,nodeDragThreshold:ee}=_.getState();A&&(!Y||!z||ee>0)&&bi({id:t,store:_,nodeRef:N}),s&&s(B,{...w.userNode})},J=B=>{if(!(oc(B.nativeEvent)||x)){if(Yl.includes(B.key)&&A){const Y=B.key==="Escape";bi({id:t,store:_,unselect:Y,nodeRef:N})}else if(z&&y.selected&&Object.prototype.hasOwnProperty.call(da,B.key)){B.preventDefault();const{ariaLabelConfig:Y}=_.getState();_.setState({ariaLiveMessage:Y["node.a11yDescription.ariaLiveMessage"]({direction:B.key.replace("Arrow","").toLowerCase(),x:~~w.positionAbsolute.x,y:~~w.positionAbsolute.y})}),L({direction:da[B.key],factor:B.shiftKey?4:1})}}},le=()=>{var K;if(x||!((K=N.current)!=null&&K.matches(":focus-visible")))return;const{transform:B,width:Y,height:ee,autoPanOnNodeFocus:ae,setCenter:ne}=_.getState();if(!ae)return;Wi(new Map([[t,y]]),{x:0,y:0,width:Y,height:ee},B,!0).length>0||ne(y.position.x+R.width/2,y.position.y+R.height/2,{zoom:B[2]})};return e.jsx("div",{className:$e(["react-flow__node",`react-flow__node-${$}`,{[p]:z},y.className,{selected:y.selected,selectable:A,parent:S,draggable:z,dragging:T}]),ref:N,style:{zIndex:w.z,transform:`translate(${w.positionAbsolute.x}px,${w.positionAbsolute.y}px)`,pointerEvents:E?"all":"none",visibility:P?"visible":"hidden",...y.style,...F},"data-id":t,"data-testid":`rf__node-${t}`,onMouseEnter:D,onMouseMove:G,onMouseLeave:I,onContextMenu:W,onClick:X,onDoubleClick:V,onKeyDown:C?J:void 0,tabIndex:C?0:void 0,onFocus:C?le:void 0,role:y.ariaRole??(C?"group":void 0),"aria-roledescription":"node","aria-describedby":x?void 0:`${Ec}-${j}`,"aria-label":y.ariaLabel,...y.domAttributes,children:e.jsx(I0,{value:t,children:e.jsx(M,{id:t,data:y.data,type:$,positionAbsoluteX:w.positionAbsolute.x,positionAbsoluteY:w.positionAbsolute.y,selected:y.selected??!1,selectable:A,draggable:z,deletable:y.deletable??!0,isConnectable:k,sourcePosition:y.sourcePosition,targetPosition:y.targetPosition,dragging:T,dragHandle:y.dragHandle,zIndex:w.z,parentId:y.parentId,...R})})})}var n1=f.memo(s1);const a1=t=>({nodesConnectable:t.nodesConnectable,nodesFocusable:t.nodesFocusable,elementsSelectable:t.elementsSelectable,onError:t.onError});function Hc(t){const{nodesConnectable:s,nodesFocusable:n,elementsSelectable:a,onError:i}=ge(a1,ke),r=Q0(t.onlyRenderVisibleElements),o=e1();return e.jsx("div",{className:"react-flow__nodes",style:Ca,children:r.map(l=>e.jsx(n1,{id:l,nodeTypes:t.nodeTypes,nodeExtent:t.nodeExtent,onClick:t.onNodeClick,onMouseEnter:t.onNodeMouseEnter,onMouseMove:t.onNodeMouseMove,onMouseLeave:t.onNodeMouseLeave,onContextMenu:t.onNodeContextMenu,onDoubleClick:t.onNodeDoubleClick,noDragClassName:t.noDragClassName,noPanClassName:t.noPanClassName,rfId:t.rfId,disableKeyboardA11y:t.disableKeyboardA11y,resizeObserver:o,nodesDraggable:t.nodesDraggable??!0,nodesConnectable:s,nodesFocusable:n,elementsSelectable:a,nodeClickDistance:t.nodeClickDistance,onError:i},l))})}Hc.displayName="NodeRenderer";const i1=f.memo(Hc);function r1(t){return ge(f.useCallback(n=>{if(!t)return n.edges.map(i=>i.id);const a=[];if(n.width&&n.height)for(const i of n.edges){const r=n.nodeLookup.get(i.source),o=n.nodeLookup.get(i.target);r&&o&&Fj({sourceNode:r,targetNode:o,width:n.width,height:n.height,transform:n.transform})&&a.push(i.id)}return a},[t]),ke)}const o1=({color:t="none",strokeWidth:s=1})=>{const n={strokeWidth:s,...t&&{stroke:t}};return e.jsx("polyline",{className:"arrow",style:n,strokeLinecap:"round",fill:"none",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4"})},l1=({color:t="none",strokeWidth:s=1})=>{const n={strokeWidth:s,...t&&{stroke:t,fill:t}};return e.jsx("polyline",{className:"arrowclosed",style:n,strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"})},Mo={[oa.Arrow]:o1,[oa.ArrowClosed]:l1};function c1(t){const s=we();return f.useMemo(()=>{var i,r;return Object.prototype.hasOwnProperty.call(Mo,t)?Mo[t]:((r=(i=s.getState()).onError)==null||r.call(i,"009",yt.error009(t)),null)},[t])}const d1=({id:t,type:s,color:n,width:a=12.5,height:i=12.5,markerUnits:r="strokeWidth",strokeWidth:o,orient:l="auto-start-reverse"})=>{const c=c1(s);return c?e.jsx("marker",{className:"react-flow__arrowhead",id:t,markerWidth:`${a}`,markerHeight:`${i}`,viewBox:"-10 -10 20 20",markerUnits:r,orient:l,refX:"0",refY:"0",children:e.jsx(c,{color:n,strokeWidth:o})}):null},Vc=({defaultColor:t,rfId:s})=>{const n=ge(r=>r.edges),a=ge(r=>r.defaultEdgeOptions),i=f.useMemo(()=>Gj(n,{id:s,defaultColor:t,defaultMarkerStart:a==null?void 0:a.markerStart,defaultMarkerEnd:a==null?void 0:a.markerEnd}),[n,a,s,t]);return i.length?e.jsx("svg",{className:"react-flow__marker","aria-hidden":"true",children:e.jsx("defs",{children:i.map(r=>e.jsx(d1,{id:r.id,type:r.type,color:r.color,width:r.width,height:r.height,markerUnits:r.markerUnits,strokeWidth:r.strokeWidth,orient:r.orient},r.id))})}):null};Vc.displayName="MarkerDefinitions";var u1=f.memo(Vc);function Uc({x:t,y:s,label:n,labelStyle:a,labelShowBg:i=!0,labelBgStyle:r,labelBgPadding:o=[2,4],labelBgBorderRadius:l=2,children:c,className:h,...m}){const[d,u]=f.useState({x:1,y:0,width:0,height:0}),p=$e(["react-flow__edge-textwrapper",h]),x=f.useRef(null);return f.useEffect(()=>{if(x.current){const j=x.current.getBBox();u({x:j.x,y:j.y,width:j.width,height:j.height})}},[n]),n?e.jsxs("g",{transform:`translate(${t-d.width/2} ${s-d.height/2})`,className:p,visibility:d.width?"visible":"hidden",...m,children:[i&&e.jsx("rect",{width:d.width+2*o[0],x:-o[0],y:-o[1],height:d.height+2*o[1],className:"react-flow__edge-textbg",style:r,rx:l,ry:l}),e.jsx("text",{className:"react-flow__edge-text",y:d.height/2,dy:"0.3em",ref:x,style:a,children:n}),c]}):null}Uc.displayName="EdgeText";const h1=f.memo(Uc);function za({path:t,labelX:s,labelY:n,label:a,labelStyle:i,labelShowBg:r,labelBgStyle:o,labelBgPadding:l,labelBgBorderRadius:c,interactionWidth:h=20,...m}){return e.jsxs(e.Fragment,{children:[e.jsx("path",{...m,d:t,fill:"none",className:$e(["react-flow__edge-path",m.className])}),h?e.jsx("path",{d:t,fill:"none",strokeOpacity:0,strokeWidth:h,className:"react-flow__edge-interaction"}):null,a&&mt(s)&&mt(n)?e.jsx(h1,{x:s,y:n,label:a,labelStyle:i,labelShowBg:r,labelBgStyle:o,labelBgPadding:l,labelBgBorderRadius:c}):null]})}function $o({pos:t,x1:s,y1:n,x2:a,y2:i}){return t===he.Left||t===he.Right?[.5*(s+a),n]:[s,.5*(n+i)]}function qc({sourceX:t,sourceY:s,sourcePosition:n=he.Bottom,targetX:a,targetY:i,targetPosition:r=he.Top}){const[o,l]=$o({pos:n,x1:t,y1:s,x2:a,y2:i}),[c,h]=$o({pos:r,x1:a,y1:i,x2:t,y2:s}),[m,d,u,p]=cc({sourceX:t,sourceY:s,targetX:a,targetY:i,sourceControlX:o,sourceControlY:l,targetControlX:c,targetControlY:h});return[`M${t},${s} C${o},${l} ${c},${h} ${a},${i}`,m,d,u,p]}function Wc(t){return f.memo(({id:s,sourceX:n,sourceY:a,targetX:i,targetY:r,sourcePosition:o,targetPosition:l,label:c,labelStyle:h,labelShowBg:m,labelBgStyle:d,labelBgPadding:u,labelBgBorderRadius:p,style:x,markerEnd:j,markerStart:v,interactionWidth:g})=>{const[b,y,w]=qc({sourceX:n,sourceY:a,sourcePosition:o,targetX:i,targetY:r,targetPosition:l}),S=t.isInternal?void 0:s;return e.jsx(za,{id:S,path:b,labelX:y,labelY:w,label:c,labelStyle:h,labelShowBg:m,labelBgStyle:d,labelBgPadding:u,labelBgBorderRadius:p,style:x,markerEnd:j,markerStart:v,interactionWidth:g})})}const m1=Wc({isInternal:!1}),Gc=Wc({isInternal:!0});m1.displayName="SimpleBezierEdge";Gc.displayName="SimpleBezierEdgeInternal";function Yc(t){return f.memo(({id:s,sourceX:n,sourceY:a,targetX:i,targetY:r,label:o,labelStyle:l,labelShowBg:c,labelBgStyle:h,labelBgPadding:m,labelBgBorderRadius:d,style:u,sourcePosition:p=he.Bottom,targetPosition:x=he.Top,markerEnd:j,markerStart:v,pathOptions:g,interactionWidth:b})=>{const[y,w,S]=gi({sourceX:n,sourceY:a,sourcePosition:p,targetX:i,targetY:r,targetPosition:x,borderRadius:g==null?void 0:g.borderRadius,offset:g==null?void 0:g.offset,stepPosition:g==null?void 0:g.stepPosition}),$=t.isInternal?void 0:s;return e.jsx(za,{id:$,path:y,labelX:w,labelY:S,label:o,labelStyle:l,labelShowBg:c,labelBgStyle:h,labelBgPadding:m,labelBgBorderRadius:d,style:u,markerEnd:j,markerStart:v,interactionWidth:b})})}const Xc=Yc({isInternal:!1}),Kc=Yc({isInternal:!0});Xc.displayName="SmoothStepEdge";Kc.displayName="SmoothStepEdgeInternal";function Zc(t){return f.memo(({id:s,...n})=>{var i;const a=t.isInternal?void 0:s;return e.jsx(Xc,{...n,id:a,pathOptions:f.useMemo(()=>{var r;return{borderRadius:0,offset:(r=n.pathOptions)==null?void 0:r.offset}},[(i=n.pathOptions)==null?void 0:i.offset])})})}const f1=Zc({isInternal:!1}),Qc=Zc({isInternal:!0});f1.displayName="StepEdge";Qc.displayName="StepEdgeInternal";function Jc(t){return f.memo(({id:s,sourceX:n,sourceY:a,targetX:i,targetY:r,label:o,labelStyle:l,labelShowBg:c,labelBgStyle:h,labelBgPadding:m,labelBgBorderRadius:d,style:u,markerEnd:p,markerStart:x,interactionWidth:j})=>{const[v,g,b]=hc({sourceX:n,sourceY:a,targetX:i,targetY:r}),y=t.isInternal?void 0:s;return e.jsx(za,{id:y,path:v,labelX:g,labelY:b,label:o,labelStyle:l,labelShowBg:c,labelBgStyle:h,labelBgPadding:m,labelBgBorderRadius:d,style:u,markerEnd:p,markerStart:x,interactionWidth:j})})}const p1=Jc({isInternal:!1}),ed=Jc({isInternal:!0});p1.displayName="StraightEdge";ed.displayName="StraightEdgeInternal";function td(t){return f.memo(({id:s,sourceX:n,sourceY:a,targetX:i,targetY:r,sourcePosition:o=he.Bottom,targetPosition:l=he.Top,label:c,labelStyle:h,labelShowBg:m,labelBgStyle:d,labelBgPadding:u,labelBgBorderRadius:p,style:x,markerEnd:j,markerStart:v,pathOptions:g,interactionWidth:b})=>{const[y,w,S]=dc({sourceX:n,sourceY:a,sourcePosition:o,targetX:i,targetY:r,targetPosition:l,curvature:g==null?void 0:g.curvature}),$=t.isInternal?void 0:s;return e.jsx(za,{id:$,path:y,labelX:w,labelY:S,label:c,labelStyle:h,labelShowBg:m,labelBgStyle:d,labelBgPadding:u,labelBgBorderRadius:p,style:x,markerEnd:j,markerStart:v,interactionWidth:b})})}const x1=td({isInternal:!1}),sd=td({isInternal:!0});x1.displayName="BezierEdge";sd.displayName="BezierEdgeInternal";const Eo={default:sd,straight:ed,step:Qc,smoothstep:Kc,simplebezier:Gc},_o={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null,zIndex:void 0},g1=(t,s,n)=>n===he.Left?t-s:n===he.Right?t+s:t,y1=(t,s,n)=>n===he.Top?t-s:n===he.Bottom?t+s:t,To="react-flow__edgeupdater";function Ao({position:t,centerX:s,centerY:n,radius:a=10,onMouseDown:i,onMouseEnter:r,onMouseOut:o,type:l}){return e.jsx("circle",{onMouseDown:i,onMouseEnter:r,onMouseOut:o,className:$e([To,`${To}-${l}`]),cx:g1(s,a,t),cy:y1(n,a,t),r:a,stroke:"transparent",fill:"transparent"})}function v1({isReconnectable:t,reconnectRadius:s,edge:n,sourceX:a,sourceY:i,targetX:r,targetY:o,sourcePosition:l,targetPosition:c,onReconnect:h,onReconnectStart:m,onReconnectEnd:d,setReconnecting:u,setUpdateHover:p}){const x=we(),j=(w,S)=>{if(w.button!==0)return;const{autoPanOnConnect:$,domNode:M,connectionMode:z,connectionRadius:A,lib:k,onConnectStart:C,cancelConnection:_,nodeLookup:P,rfId:N,panBy:T,updateConnection:L}=x.getState(),R=S.type==="target",F=(G,I)=>{u(!1),d==null||d(G,n,S.type,I)},E=G=>h==null?void 0:h(n,G),D=(G,I)=>{u(!0),m==null||m(w,n,S.type),C==null||C(G,I)};ji.onPointerDown(w.nativeEvent,{autoPanOnConnect:$,connectionMode:z,connectionRadius:A,domNode:M,handleId:S.id,nodeId:S.nodeId,nodeLookup:P,isTarget:R,edgeUpdaterType:S.type,lib:k,flowId:N,cancelConnection:_,panBy:T,isValidConnection:(...G)=>{var I,W;return((W=(I=x.getState()).isValidConnection)==null?void 0:W.call(I,...G))??!0},onConnect:E,onConnectStart:D,onConnectEnd:(...G)=>{var I,W;return(W=(I=x.getState()).onConnectEnd)==null?void 0:W.call(I,...G)},onReconnectEnd:F,updateConnection:L,getTransform:()=>x.getState().transform,getFromHandle:()=>x.getState().connection.fromHandle,dragThreshold:x.getState().connectionDragThreshold,handleDomNode:w.currentTarget})},v=w=>j(w,{nodeId:n.target,id:n.targetHandle??null,type:"target"}),g=w=>j(w,{nodeId:n.source,id:n.sourceHandle??null,type:"source"}),b=()=>p(!0),y=()=>p(!1);return e.jsxs(e.Fragment,{children:[(t===!0||t==="source")&&e.jsx(Ao,{position:l,centerX:a,centerY:i,radius:s,onMouseDown:v,onMouseEnter:b,onMouseOut:y,type:"source"}),(t===!0||t==="target")&&e.jsx(Ao,{position:c,centerX:r,centerY:o,radius:s,onMouseDown:g,onMouseEnter:b,onMouseOut:y,type:"target"})]})}function j1({id:t,edgesFocusable:s,edgesReconnectable:n,elementsSelectable:a,onClick:i,onDoubleClick:r,onContextMenu:o,onMouseEnter:l,onMouseMove:c,onMouseLeave:h,reconnectRadius:m,onReconnect:d,onReconnectStart:u,onReconnectEnd:p,rfId:x,edgeTypes:j,noPanClassName:v,onError:g,disableKeyboardA11y:b}){let y=ge(ne=>ne.edgeLookup.get(t));const w=ge(ne=>ne.defaultEdgeOptions);y=w?{...w,...y}:y;let S=y.type||"default",$=(j==null?void 0:j[S])||Eo[S];$===void 0&&(g==null||g("011",yt.error011(S)),S="default",$=(j==null?void 0:j.default)||Eo.default);const M=!!(y.focusable||s&&typeof y.focusable>"u"),z=typeof d<"u"&&(y.reconnectable||n&&typeof y.reconnectable>"u"),A=!!(y.selectable||a&&typeof y.selectable>"u"),k=f.useRef(null),[C,_]=f.useState(!1),[P,N]=f.useState(!1),T=we(),{zIndex:L=y.zIndex,sourceX:R,sourceY:F,targetX:E,targetY:D,sourcePosition:G,targetPosition:I}=ge(f.useCallback(ne=>{const O=ne.nodeLookup.get(y.source),K=ne.nodeLookup.get(y.target);if(!O||!K)return _o;const Z=Wj({id:t,sourceNode:O,targetNode:K,sourceHandle:y.sourceHandle||null,targetHandle:y.targetHandle||null,connectionMode:ne.connectionMode,onError:g}),Q=Dj({selected:y.selected,zIndex:y.zIndex,sourceNode:O,targetNode:K,elevateOnSelect:ne.elevateEdgesOnSelect,zIndexMode:ne.zIndexMode});return{...Z||_o,zIndex:Q}},[y.source,y.target,y.sourceHandle,y.targetHandle,y.selected,y.zIndex]),ke),W=f.useMemo(()=>y.markerStart?`url('#${yi(y.markerStart,x)}')`:void 0,[y.markerStart,x]),V=f.useMemo(()=>y.markerEnd?`url('#${yi(y.markerEnd,x)}')`:void 0,[y.markerEnd,x]);if(y.hidden||R===null||F===null||E===null||D===null)return null;const X=ne=>{var Q;const{addSelectedEdges:O,unselectNodesAndEdges:K,multiSelectionActive:Z}=T.getState();A&&(T.setState({nodesSelectionActive:!1}),y.selected&&Z?(K({nodes:[],edges:[y]}),(Q=k.current)==null||Q.blur()):O([t])),i&&i(ne,y)},J=r?ne=>{r(ne,{...y})}:void 0,le=o?ne=>{o(ne,{...y})}:void 0,B=l?ne=>{l(ne,{...y})}:void 0,Y=c?ne=>{c(ne,{...y})}:void 0,ee=h?ne=>{h(ne,{...y})}:void 0,ae=ne=>{var O;if(!b&&Yl.includes(ne.key)&&A){const{unselectNodesAndEdges:K,addSelectedEdges:Z}=T.getState();ne.key==="Escape"?((O=k.current)==null||O.blur(),K({edges:[y]})):Z([t])}};return e.jsx("svg",{style:{zIndex:L},children:e.jsxs("g",{className:$e(["react-flow__edge",`react-flow__edge-${S}`,y.className,v,{selected:y.selected,animated:y.animated,inactive:!A&&!i,updating:C,selectable:A}]),onClick:X,onDoubleClick:J,onContextMenu:le,onMouseEnter:B,onMouseMove:Y,onMouseLeave:ee,onKeyDown:M?ae:void 0,tabIndex:M?0:void 0,role:y.ariaRole??(M?"group":"img"),"aria-roledescription":"edge","data-id":t,"data-testid":`rf__edge-${t}`,"aria-label":y.ariaLabel===null?void 0:y.ariaLabel||`Edge from ${y.source} to ${y.target}`,"aria-describedby":M?`${_c}-${x}`:void 0,ref:k,...y.domAttributes,children:[!P&&e.jsx($,{id:t,source:y.source,target:y.target,type:y.type,selected:y.selected,animated:y.animated,selectable:A,deletable:y.deletable??!0,label:y.label,labelStyle:y.labelStyle,labelShowBg:y.labelShowBg,labelBgStyle:y.labelBgStyle,labelBgPadding:y.labelBgPadding,labelBgBorderRadius:y.labelBgBorderRadius,sourceX:R,sourceY:F,targetX:E,targetY:D,sourcePosition:G,targetPosition:I,data:y.data,style:y.style,sourceHandleId:y.sourceHandle,targetHandleId:y.targetHandle,markerStart:W,markerEnd:V,pathOptions:"pathOptions"in y?y.pathOptions:void 0,interactionWidth:y.interactionWidth}),z&&e.jsx(v1,{edge:y,isReconnectable:z,reconnectRadius:m,onReconnect:d,onReconnectStart:u,onReconnectEnd:p,sourceX:R,sourceY:F,targetX:E,targetY:D,sourcePosition:G,targetPosition:I,setUpdateHover:_,setReconnecting:N})]})})}var b1=f.memo(j1);const w1=t=>({edgesFocusable:t.edgesFocusable,edgesReconnectable:t.edgesReconnectable,elementsSelectable:t.elementsSelectable,connectionMode:t.connectionMode,onError:t.onError});function nd({defaultMarkerColor:t,onlyRenderVisibleElements:s,rfId:n,edgeTypes:a,noPanClassName:i,onReconnect:r,onEdgeContextMenu:o,onEdgeMouseEnter:l,onEdgeMouseMove:c,onEdgeMouseLeave:h,onEdgeClick:m,reconnectRadius:d,onEdgeDoubleClick:u,onReconnectStart:p,onReconnectEnd:x,disableKeyboardA11y:j}){const{edgesFocusable:v,edgesReconnectable:g,elementsSelectable:b,onError:y}=ge(w1,ke),w=r1(s);return e.jsxs("div",{className:"react-flow__edges",children:[e.jsx(u1,{defaultColor:t,rfId:n}),w.map(S=>e.jsx(b1,{id:S,edgesFocusable:v,edgesReconnectable:g,elementsSelectable:b,noPanClassName:i,onReconnect:r,onContextMenu:o,onMouseEnter:l,onMouseMove:c,onMouseLeave:h,onClick:m,reconnectRadius:d,onDoubleClick:u,onReconnectStart:p,onReconnectEnd:x,rfId:n,onError:y,edgeTypes:a,disableKeyboardA11y:j},S))]})}nd.displayName="EdgeRenderer";const k1=f.memo(nd),Ro=t=>`translate(${t[0]}px,${t[1]}px) scale(${t[2]})`;function N1({children:t}){const s=we(),n=f.useRef(null),[a]=f.useState(()=>s.getState().transform);return Ic(()=>{let i=null;const r=()=>{const o=s.getState().transform;i&&o[0]===i[0]&&o[1]===i[1]&&o[2]===i[2]||(i=o,n.current&&(n.current.style.transform=Ro(o)))};return r(),s.subscribe(r)},[s]),e.jsx("div",{ref:n,className:"react-flow__viewport xyflow__viewport react-flow__container",style:{transform:Ro(a)},children:t})}function S1(t){const s=tr(),n=f.useRef(!1);f.useEffect(()=>{!n.current&&s.viewportInitialized&&t&&(setTimeout(()=>t(s),1),n.current=!0)},[t,s.viewportInitialized])}const C1=t=>{var s;return(s=t.panZoom)==null?void 0:s.syncViewport};function z1(t){const s=ge(C1),n=we();return f.useEffect(()=>{t&&(s==null||s(t),n.setState({transform:[t.x,t.y,t.zoom]}))},[t,s]),null}function M1(t){return t.connection.inProgress?{...t.connection,to:bn(t.connection.to,t.transform)}:{...t.connection}}function $1(t){return M1}function E1(t){const s=$1();return ge(s,ke)}const _1=t=>({nodesConnectable:t.nodesConnectable,isValid:t.connection.isValid,inProgress:t.connection.inProgress,width:t.width,height:t.height});function T1({containerStyle:t,style:s,type:n,component:a}){const{nodesConnectable:i,width:r,height:o,isValid:l,inProgress:c}=ge(_1,ke);return!(r&&i&&c)?null:e.jsx("svg",{style:t,width:r,height:o,className:"react-flow__connectionline react-flow__container",children:e.jsx("g",{className:$e(["react-flow__connection",Zl(l)]),children:e.jsx(ad,{style:s,type:n,CustomComponent:a,isValid:l})})})}const ad=({style:t,type:s=Ft.Bezier,CustomComponent:n,isValid:a})=>{const{inProgress:i,from:r,fromNode:o,fromHandle:l,fromPosition:c,to:h,toNode:m,toHandle:d,toPosition:u,pointer:p}=E1();if(!i)return;if(n)return e.jsx(n,{connectionLineType:s,connectionLineStyle:t,fromNode:o,fromHandle:l,fromX:r.x,fromY:r.y,toX:h.x,toY:h.y,fromPosition:c,toPosition:u,connectionStatus:Zl(a),toNode:m,toHandle:d,pointer:p});let x="";const j={sourceX:r.x,sourceY:r.y,sourcePosition:c,targetX:h.x,targetY:h.y,targetPosition:u};switch(s){case Ft.Bezier:[x]=dc(j);break;case Ft.SimpleBezier:[x]=qc(j);break;case Ft.Step:[x]=gi({...j,borderRadius:0});break;case Ft.SmoothStep:[x]=gi(j);break;default:[x]=hc(j)}return e.jsx("path",{d:x,fill:"none",className:"react-flow__connection-path",style:t})};ad.displayName="ConnectionLine";const A1={};function Io(t=A1){f.useRef(t),we(),f.useEffect(()=>{},[t])}function R1(){we(),f.useRef(!1),f.useEffect(()=>{},[])}function id({nodeTypes:t,edgeTypes:s,onInit:n,onNodeClick:a,onEdgeClick:i,onNodeDoubleClick:r,onEdgeDoubleClick:o,onNodeMouseEnter:l,onNodeMouseMove:c,onNodeMouseLeave:h,onNodeContextMenu:m,onSelectionContextMenu:d,onSelectionStart:u,onSelectionEnd:p,connectionLineType:x,connectionLineStyle:j,connectionLineComponent:v,connectionLineContainerStyle:g,selectionKeyCode:b,selectionOnDrag:y,selectionMode:w,multiSelectionKeyCode:S,panActivationKeyCode:$,zoomActivationKeyCode:M,deleteKeyCode:z,onlyRenderVisibleElements:A,elementsSelectable:k,defaultViewport:C,translateExtent:_,minZoom:P,maxZoom:N,preventScrolling:T,defaultMarkerColor:L,zoomOnScroll:R,zoomOnPinch:F,panOnScroll:E,panOnScrollSpeed:D,panOnScrollMode:G,zoomOnDoubleClick:I,panOnDrag:W,autoPanOnSelection:V,onPaneClick:X,onPaneMouseEnter:J,onPaneMouseMove:le,onPaneMouseLeave:B,onPaneScroll:Y,onPaneContextMenu:ee,paneClickDistance:ae,nodeClickDistance:ne,onEdgeContextMenu:O,onEdgeMouseEnter:K,onEdgeMouseMove:Z,onEdgeMouseLeave:Q,reconnectRadius:oe,onReconnect:ce,onReconnectStart:me,onReconnectEnd:be,noDragClassName:Ne,noWheelClassName:Me,noPanClassName:Ge,disableKeyboardA11y:Je,nodeExtent:De,rfId:Oe,viewport:Ye,onViewportChange:Mt,nodesDraggable:Ls}){return Io(t),Io(s),R1(),S1(n),z1(Ye),e.jsx(K0,{onPaneClick:X,onPaneMouseEnter:J,onPaneMouseMove:le,onPaneMouseLeave:B,onPaneContextMenu:ee,onPaneScroll:Y,paneClickDistance:ae,deleteKeyCode:z,selectionKeyCode:b,selectionOnDrag:y,selectionMode:w,onSelectionStart:u,onSelectionEnd:p,multiSelectionKeyCode:S,panActivationKeyCode:$,zoomActivationKeyCode:M,elementsSelectable:k,zoomOnScroll:R,zoomOnPinch:F,zoomOnDoubleClick:I,panOnScroll:E,panOnScrollSpeed:D,panOnScrollMode:G,panOnDrag:W,autoPanOnSelection:V,defaultViewport:C,translateExtent:_,minZoom:P,maxZoom:N,onSelectionContextMenu:d,preventScrolling:T,noDragClassName:Ne,noWheelClassName:Me,noPanClassName:Ge,disableKeyboardA11y:Je,onViewportChange:Mt,isControlledViewport:!!Ye,children:e.jsxs(N1,{children:[e.jsx(k1,{edgeTypes:s,onEdgeClick:i,onEdgeDoubleClick:o,onReconnect:ce,onReconnectStart:me,onReconnectEnd:be,onlyRenderVisibleElements:A,onEdgeContextMenu:O,onEdgeMouseEnter:K,onEdgeMouseMove:Z,onEdgeMouseLeave:Q,reconnectRadius:oe,defaultMarkerColor:L,noPanClassName:Ge,disableKeyboardA11y:Je,rfId:Oe}),e.jsx(T1,{style:j,type:x,component:v,containerStyle:g}),e.jsx("div",{className:"react-flow__edgelabel-renderer"}),e.jsx(i1,{nodeTypes:t,onNodeClick:a,onNodeDoubleClick:r,onNodeMouseEnter:l,onNodeMouseMove:c,onNodeMouseLeave:h,onNodeContextMenu:m,nodeClickDistance:ne,onlyRenderVisibleElements:A,noPanClassName:Ge,noDragClassName:Ne,disableKeyboardA11y:Je,nodeExtent:De,rfId:Oe,nodesDraggable:Ls}),e.jsx("div",{className:"react-flow__viewport-portal"})]})})}id.displayName="GraphView";const I1=f.memo(id),L1=nc(),Lo=({nodes:t,edges:s,defaultNodes:n,defaultEdges:a,width:i,height:r,fitView:o,fitViewOptions:l,minZoom:c=.5,maxZoom:h=2,nodeOrigin:m,nodeExtent:d,zIndexMode:u="basic"}={})=>{const p=new Map,x=new Map,j=new Map,v=new Map,g=a??s??[],b=n??t??[],y=m??[0,0],w=d??ln;pc(j,v,g);const{nodesInitialized:S}=vi(b,p,x,{nodeOrigin:y,nodeExtent:w,zIndexMode:u});let $=[0,0,1];if(o&&i&&r){const M=vn(p,{filter:C=>!!((C.width||C.initialWidth)&&(C.height||C.initialHeight))}),{x:z,y:A,zoom:k}=Yi(M,i,r,c,h,(l==null?void 0:l.padding)??.1);$=[z,A,k]}return{rfId:"1",width:i??0,height:r??0,transform:$,nodes:b,nodesInitialized:S,nodeLookup:p,parentLookup:x,edges:g,edgeLookup:v,connectionLookup:j,onNodesChange:null,onEdgesChange:null,hasDefaultNodes:n!==void 0,hasDefaultEdges:a!==void 0,panZoom:null,minZoom:c,maxZoom:h,translateExtent:ln,nodeExtent:w,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:$s.Strict,domNode:null,paneDragging:!1,noPanClassName:"nopan",nodeOrigin:y,nodeDragThreshold:1,connectionDragThreshold:1,snapGrid:[15,15],snapToGrid:!1,nodesDraggable:!0,nodesConnectable:!0,nodesFocusable:!0,edgesFocusable:!0,edgesReconnectable:!0,elementsSelectable:!0,elevateNodesOnSelect:!0,elevateEdgesOnSelect:!0,selectNodesOnDrag:!0,multiSelectionActive:!1,fitViewQueued:o??!1,fitViewOptions:l,fitViewResolver:null,connection:{...Kl},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:L1,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:"react",debug:!1,ariaLabelConfig:Xl,zIndexMode:u,onNodesChangeMiddlewareMap:new Map,onEdgesChangeMiddlewareMap:new Map}},P1=({nodes:t,edges:s,defaultNodes:n,defaultEdges:a,width:i,height:r,fitView:o,fitViewOptions:l,minZoom:c,maxZoom:h,nodeOrigin:m,nodeExtent:d,zIndexMode:u})=>Xb((p,x)=>{async function j(){const{nodeLookup:v,panZoom:g,fitViewOptions:b,fitViewResolver:y,width:w,height:S,minZoom:$,maxZoom:M}=x();g&&(await _j({nodes:v,width:w,height:S,panZoom:g,minZoom:$,maxZoom:M},b),y==null||y.resolve(!0),p({fitViewResolver:null}))}return{...Lo({nodes:t,edges:s,width:i,height:r,fitView:o,fitViewOptions:l,minZoom:c,maxZoom:h,nodeOrigin:m,nodeExtent:d,defaultNodes:n,defaultEdges:a,zIndexMode:u}),setNodes:v=>{const{nodeLookup:g,parentLookup:b,nodeOrigin:y,elevateNodesOnSelect:w,fitViewQueued:S,zIndexMode:$,nodesSelectionActive:M}=x(),{nodesInitialized:z,hasSelectedNodes:A}=vi(v,g,b,{nodeOrigin:y,nodeExtent:d,elevateNodesOnSelect:w,checkEquality:!0,zIndexMode:$}),k=M&&A;S&&z?(j(),p({nodes:v,nodesInitialized:z,fitViewQueued:!1,fitViewOptions:void 0,nodesSelectionActive:k})):p({nodes:v,nodesInitialized:z,nodesSelectionActive:k})},setEdges:v=>{const{connectionLookup:g,edgeLookup:b}=x();pc(g,b,v),p({edges:v})},setDefaultNodesAndEdges:(v,g)=>{if(v){const{setNodes:b}=x();b(v),p({hasDefaultNodes:!0})}if(g){const{setEdges:b}=x();b(g),p({hasDefaultEdges:!0})}},updateNodeInternals:v=>{const{triggerNodeChanges:g,nodeLookup:b,parentLookup:y,domNode:w,nodeOrigin:S,nodeExtent:$,debug:M,fitViewQueued:z,zIndexMode:A}=x(),{changes:k,updatedInternals:C}=eb(v,b,y,w,S,$,A);C&&(Kj(b,y,{nodeOrigin:S,nodeExtent:$,zIndexMode:A}),z?(j(),p({fitViewQueued:!1,fitViewOptions:void 0})):p({}),(k==null?void 0:k.length)>0&&(M&&console.log("React Flow: trigger node changes",k),g==null||g(k)))},updateNodePositions:(v,g=!1)=>{const b=[];let y=[];const{nodeLookup:w,triggerNodeChanges:S,connection:$,updateConnection:M,onNodesChangeMiddlewareMap:z}=x();for(const[A,k]of v){const C=w.get(A),_=!!(C!=null&&C.expandParent&&(C!=null&&C.parentId)&&(k!=null&&k.position)),P={id:A,type:"position",position:_?{x:Math.max(0,k.position.x),y:Math.max(0,k.position.y)}:k.position,dragging:g};if(C&&$.inProgress&&$.fromNode.id===C.id){const N=os(C,$.fromHandle,he.Left,!0);M({...$,from:N})}_&&C.parentId&&b.push({id:A,parentId:C.parentId,rect:{...k.internals.positionAbsolute,width:k.measured.width??0,height:k.measured.height??0}}),y.push(P)}if(b.length>0){const{parentLookup:A,nodeOrigin:k}=x(),C=er(b,w,A,k);y.push(...C)}for(const A of z.values())y=A(y);S(y)},triggerNodeChanges:v=>{const{onNodesChange:g,setNodes:b,nodes:y,hasDefaultNodes:w,debug:S}=x();if(v!=null&&v.length){if(w){const $=x0(v,y);b($)}S&&console.log("React Flow: trigger node changes",v),g==null||g(v)}},triggerEdgeChanges:v=>{const{onEdgesChange:g,setEdges:b,edges:y,hasDefaultEdges:w,debug:S}=x();if(v!=null&&v.length){if(w){const $=g0(v,y);b($)}S&&console.log("React Flow: trigger edge changes",v),g==null||g(v)}},addSelectedNodes:v=>{const{multiSelectionActive:g,edgeLookup:b,nodeLookup:y,triggerNodeChanges:w,triggerEdgeChanges:S}=x();if(g){const $=v.map(M=>Gt(M,!0));w($);return}w(gs(y,new Set([...v]),!0)),S(gs(b))},addSelectedEdges:v=>{const{multiSelectionActive:g,edgeLookup:b,nodeLookup:y,triggerNodeChanges:w,triggerEdgeChanges:S}=x();if(g){const $=v.map(M=>Gt(M,!0));S($);return}S(gs(b,new Set([...v]))),w(gs(y,new Set,!0))},unselectNodesAndEdges:({nodes:v,edges:g}={})=>{const{edges:b,nodes:y,nodeLookup:w,triggerNodeChanges:S,triggerEdgeChanges:$}=x(),M=v||y,z=g||b,A=[];for(const C of M){if(!C.selected)continue;const _=w.get(C.id);_&&(_.selected=!1),A.push(Gt(C.id,!1))}const k=[];for(const C of z)C.selected&&k.push(Gt(C.id,!1));S(A),$(k)},setMinZoom:v=>{const{panZoom:g,maxZoom:b}=x();g==null||g.setScaleExtent([v,b]),p({minZoom:v})},setMaxZoom:v=>{const{panZoom:g,minZoom:b}=x();g==null||g.setScaleExtent([b,v]),p({maxZoom:v})},setTranslateExtent:v=>{var g;(g=x().panZoom)==null||g.setTranslateExtent(v),p({translateExtent:v})},resetSelectedElements:()=>{const{edges:v,nodes:g,triggerNodeChanges:b,triggerEdgeChanges:y,elementsSelectable:w}=x();if(!w)return;const S=g.reduce((M,z)=>z.selected?[...M,Gt(z.id,!1)]:M,[]),$=v.reduce((M,z)=>z.selected?[...M,Gt(z.id,!1)]:M,[]);b(S),y($)},setNodeExtent:v=>{const{nodes:g,nodeLookup:b,parentLookup:y,nodeOrigin:w,elevateNodesOnSelect:S,nodeExtent:$,zIndexMode:M}=x();v[0][0]===$[0][0]&&v[0][1]===$[0][1]&&v[1][0]===$[1][0]&&v[1][1]===$[1][1]||(vi(g,b,y,{nodeOrigin:w,nodeExtent:v,elevateNodesOnSelect:S,checkEquality:!1,zIndexMode:M}),p({nodeExtent:v}))},panBy:v=>{const{transform:g,width:b,height:y,panZoom:w,translateExtent:S}=x();return tb({delta:v,panZoom:w,transform:g,translateExtent:S,width:b,height:y})},setCenter:async(v,g,b)=>{const{width:y,height:w,maxZoom:S,panZoom:$}=x();if(!$)return!1;const M=typeof(b==null?void 0:b.zoom)<"u"?b.zoom:S;return await $.setViewport({x:y/2-v*M,y:w/2-g*M,zoom:M},{duration:b==null?void 0:b.duration,ease:b==null?void 0:b.ease,interpolate:b==null?void 0:b.interpolate}),!0},cancelConnection:()=>{p({connection:{...Kl}})},updateConnection:v=>{p({connection:v})},reset:()=>p({...Lo()})}},Object.is);function D1({initialNodes:t,initialEdges:s,defaultNodes:n,defaultEdges:a,initialWidth:i,initialHeight:r,initialMinZoom:o,initialMaxZoom:l,initialFitViewOptions:c,fitView:h,nodeOrigin:m,nodeExtent:d,zIndexMode:u,children:p}){const[x]=f.useState(()=>P1({nodes:t,edges:s,defaultNodes:n,defaultEdges:a,width:i,height:r,fitView:h,minZoom:o,maxZoom:l,fitViewOptions:c,nodeOrigin:m,nodeExtent:d,zIndexMode:u}));return e.jsx(Kb,{value:x,children:e.jsx(w0,{children:e.jsx(P0,{children:p})})})}function F1({children:t,nodes:s,edges:n,defaultNodes:a,defaultEdges:i,width:r,height:o,fitView:l,fitViewOptions:c,minZoom:h,maxZoom:m,nodeOrigin:d,nodeExtent:u,zIndexMode:p}){return f.useContext(Na)?e.jsx(e.Fragment,{children:t}):e.jsx(D1,{initialNodes:s,initialEdges:n,defaultNodes:a,defaultEdges:i,initialWidth:r,initialHeight:o,fitView:l,initialFitViewOptions:c,initialMinZoom:h,initialMaxZoom:m,nodeOrigin:d,nodeExtent:u,zIndexMode:p,children:t})}const O1={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0};function B1({nodes:t,edges:s,defaultNodes:n,defaultEdges:a,className:i,nodeTypes:r,edgeTypes:o,onNodeClick:l,onEdgeClick:c,onInit:h,onMove:m,onMoveStart:d,onMoveEnd:u,onConnect:p,onConnectStart:x,onConnectEnd:j,onClickConnectStart:v,onClickConnectEnd:g,onNodeMouseEnter:b,onNodeMouseMove:y,onNodeMouseLeave:w,onNodeContextMenu:S,onNodeDoubleClick:$,onNodeDragStart:M,onNodeDrag:z,onNodeDragStop:A,onNodesDelete:k,onEdgesDelete:C,onDelete:_,onSelectionChange:P,onSelectionDragStart:N,onSelectionDrag:T,onSelectionDragStop:L,onSelectionContextMenu:R,onSelectionStart:F,onSelectionEnd:E,onBeforeDelete:D,connectionMode:G,connectionLineType:I=Ft.Bezier,connectionLineStyle:W,connectionLineComponent:V,connectionLineContainerStyle:X,deleteKeyCode:J="Backspace",selectionKeyCode:le="Shift",selectionOnDrag:B=!1,selectionMode:Y=cn.Full,panActivationKeyCode:ee="Space",multiSelectionKeyCode:ae=un()?"Meta":"Control",zoomActivationKeyCode:ne=un()?"Meta":"Control",snapToGrid:O,snapGrid:K,onlyRenderVisibleElements:Z=!1,selectNodesOnDrag:Q,nodesDraggable:oe,autoPanOnNodeFocus:ce,nodesConnectable:me,nodesFocusable:be,nodeOrigin:Ne=Tc,edgesFocusable:Me,edgesReconnectable:Ge,elementsSelectable:Je=!0,defaultViewport:De=c0,minZoom:Oe=.5,maxZoom:Ye=2,translateExtent:Mt=ln,preventScrolling:Ls=!0,nodeExtent:qt,defaultMarkerColor:q="#b1b1b7",zoomOnScroll:re=!0,zoomOnPinch:Se=!0,panOnScroll:Ce=!1,panOnScrollSpeed:ve=.5,panOnScrollMode:ze=Zt.Free,zoomOnDoubleClick:Xe=!0,panOnDrag:Lt=!0,onPaneClick:$t,onPaneMouseEnter:et,onPaneMouseMove:Ma,onPaneMouseLeave:Ae,onPaneScroll:dd,onPaneContextMenu:ud,paneClickDistance:hd=1,nodeClickDistance:md=0,children:fd,onReconnect:pd,onReconnectStart:xd,onReconnectEnd:gd,onEdgeContextMenu:yd,onEdgeDoubleClick:vd,onEdgeMouseEnter:jd,onEdgeMouseMove:bd,onEdgeMouseLeave:wd,reconnectRadius:kd=10,onNodesChange:Nd,onEdgesChange:Sd,noDragClassName:Cd="nodrag",noWheelClassName:zd="nowheel",noPanClassName:nr="nopan",fitView:ar,fitViewOptions:ir,connectOnClick:Md,attributionPosition:$d,proOptions:Ed,defaultEdgeOptions:_d,elevateNodesOnSelect:Td=!0,elevateEdgesOnSelect:Ad=!1,disableKeyboardA11y:rr=!1,autoPanOnConnect:Rd,autoPanOnNodeDrag:Id,autoPanOnSelection:Ld=!0,autoPanSpeed:Pd,connectionRadius:Dd,isValidConnection:Fd,onError:Od,style:Bd,id:or,nodeDragThreshold:Hd,connectionDragThreshold:Vd,viewport:Ud,onViewportChange:qd,width:Wd,height:Gd,colorMode:Yd="light",debug:Xd,onScroll:wn,ariaLabelConfig:Kd,zIndexMode:lr="basic",...Zd},Qd){const $a=or||"1",Jd=m0(Yd),eu=f.useCallback(cr=>{cr.currentTarget.scrollTo({top:0,left:0,behavior:"instant"}),wn==null||wn(cr)},[wn]);return e.jsx("div",{"data-testid":"rf__wrapper",...Zd,onScroll:eu,style:{...Bd,...O1},ref:Qd,className:$e(["react-flow",i,Jd]),id:or,role:"application",children:e.jsxs(F1,{nodes:t,edges:s,width:Wd,height:Gd,fitView:ar,fitViewOptions:ir,minZoom:Oe,maxZoom:Ye,nodeOrigin:Ne,nodeExtent:qt,zIndexMode:lr,children:[e.jsx(h0,{nodes:t,edges:s,defaultNodes:n,defaultEdges:a,onConnect:p,onConnectStart:x,onConnectEnd:j,onClickConnectStart:v,onClickConnectEnd:g,nodesDraggable:oe,autoPanOnNodeFocus:ce,nodesConnectable:me,nodesFocusable:be,edgesFocusable:Me,edgesReconnectable:Ge,elementsSelectable:Je,elevateNodesOnSelect:Td,elevateEdgesOnSelect:Ad,minZoom:Oe,maxZoom:Ye,nodeExtent:qt,onNodesChange:Nd,onEdgesChange:Sd,snapToGrid:O,snapGrid:K,connectionMode:G,translateExtent:Mt,connectOnClick:Md,defaultEdgeOptions:_d,fitView:ar,fitViewOptions:ir,onNodesDelete:k,onEdgesDelete:C,onDelete:_,onNodeDragStart:M,onNodeDrag:z,onNodeDragStop:A,onSelectionDrag:T,onSelectionDragStart:N,onSelectionDragStop:L,onMove:m,onMoveStart:d,onMoveEnd:u,noPanClassName:nr,nodeOrigin:Ne,rfId:$a,autoPanOnConnect:Rd,autoPanOnNodeDrag:Id,autoPanSpeed:Pd,onError:Od,connectionRadius:Dd,isValidConnection:Fd,selectNodesOnDrag:Q,nodeDragThreshold:Hd,connectionDragThreshold:Vd,onBeforeDelete:D,debug:Xd,ariaLabelConfig:Kd,zIndexMode:lr}),e.jsx(I1,{onInit:h,onNodeClick:l,onEdgeClick:c,onNodeMouseEnter:b,onNodeMouseMove:y,onNodeMouseLeave:w,onNodeContextMenu:S,onNodeDoubleClick:$,nodeTypes:r,edgeTypes:o,connectionLineType:I,connectionLineStyle:W,connectionLineComponent:V,connectionLineContainerStyle:X,selectionKeyCode:le,selectionOnDrag:B,selectionMode:Y,deleteKeyCode:J,multiSelectionKeyCode:ae,panActivationKeyCode:ee,zoomActivationKeyCode:ne,onlyRenderVisibleElements:Z,defaultViewport:De,translateExtent:Mt,minZoom:Oe,maxZoom:Ye,preventScrolling:Ls,zoomOnScroll:re,zoomOnPinch:Se,zoomOnDoubleClick:Xe,panOnScroll:Ce,panOnScrollSpeed:ve,panOnScrollMode:ze,panOnDrag:Lt,autoPanOnSelection:Ld,onPaneClick:$t,onPaneMouseEnter:et,onPaneMouseMove:Ma,onPaneMouseLeave:Ae,onPaneScroll:dd,onPaneContextMenu:ud,paneClickDistance:hd,nodeClickDistance:md,onSelectionContextMenu:R,onSelectionStart:F,onSelectionEnd:E,onReconnect:pd,onReconnectStart:xd,onReconnectEnd:gd,onEdgeContextMenu:yd,onEdgeDoubleClick:vd,onEdgeMouseEnter:jd,onEdgeMouseMove:bd,onEdgeMouseLeave:wd,reconnectRadius:kd,defaultMarkerColor:q,noDragClassName:Cd,noWheelClassName:zd,noPanClassName:nr,rfId:$a,disableKeyboardA11y:rr,nodeExtent:qt,viewport:Ud,onViewportChange:qd,nodesDraggable:oe}),e.jsx(l0,{onSelectionChange:P}),fd,e.jsx(n0,{proOptions:Ed,position:$d}),e.jsx(s0,{rfId:$a,disableKeyboardA11y:rr})]})})}var H1=Rc(B1);function V1({dimensions:t,lineWidth:s,variant:n,className:a}){return e.jsx("path",{strokeWidth:s,d:`M${t[0]/2} 0 V${t[1]} M0 ${t[1]/2} H${t[0]}`,className:$e(["react-flow__background-pattern",n,a])})}function U1({radius:t,className:s}){return e.jsx("circle",{cx:t,cy:t,r:t,className:$e(["react-flow__background-pattern","dots",s])})}var Bt;(function(t){t.Lines="lines",t.Dots="dots",t.Cross="cross"})(Bt||(Bt={}));const q1={[Bt.Dots]:1,[Bt.Lines]:1,[Bt.Cross]:6},W1=t=>({transform:t.transform,patternId:`pattern-${t.rfId}`});function rd({id:t,variant:s=Bt.Dots,gap:n=20,size:a,lineWidth:i=1,offset:r=0,color:o,bgColor:l,style:c,className:h,patternClassName:m}){const d=f.useRef(null),{transform:u,patternId:p}=ge(W1,ke),x=a||q1[s],j=s===Bt.Dots,v=s===Bt.Cross,g=Array.isArray(n)?n:[n,n],b=[g[0]*u[2]||1,g[1]*u[2]||1],y=x*u[2],w=Array.isArray(r)?r:[r,r],S=v?[y,y]:b,$=[w[0]*u[2]||1+S[0]/2,w[1]*u[2]||1+S[1]/2],M=`${p}${t||""}`;return e.jsxs("svg",{className:$e(["react-flow__background",h]),style:{...c,...Ca,"--xy-background-color-props":l,"--xy-background-pattern-color-props":o},ref:d,"data-testid":"rf__background",children:[e.jsx("pattern",{id:M,x:u[0]%b[0],y:u[1]%b[1],width:b[0],height:b[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${$[0]},-${$[1]})`,children:j?e.jsx(U1,{radius:y/2,className:m}):e.jsx(V1,{dimensions:S,lineWidth:i,variant:s,className:m})}),e.jsx("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${M})`})]})}rd.displayName="Background";const G1=f.memo(rd);function Y1(){return e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32",children:e.jsx("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"})})}function X1(){return e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5",children:e.jsx("path",{d:"M0 0h32v4.2H0z"})})}function K1(){return e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30",children:e.jsx("path",{d:"M3.692 4.63c0-.53.4-.938.939-.938h5.215V0H4.708C2.13 0 0 2.054 0 4.63v5.216h3.692V4.631zM27.354 0h-5.2v3.692h5.17c.53 0 .984.4.984.939v5.215H32V4.631A4.624 4.624 0 0027.354 0zm.954 24.83c0 .532-.4.94-.939.94h-5.215v3.768h5.215c2.577 0 4.631-2.13 4.631-4.707v-5.139h-3.692v5.139zm-23.677.94c-.531 0-.939-.4-.939-.94v-5.138H0v5.139c0 2.577 2.13 4.707 4.708 4.707h5.138V25.77H4.631z"})})}function Z1(){return e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:e.jsx("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0 8 0 4.571 3.429 4.571 7.619v3.048H3.048A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047zm4.724-13.866H7.467V7.619c0-2.59 2.133-4.724 4.723-4.724 2.591 0 4.724 2.133 4.724 4.724v3.048z"})})}function Q1(){return e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:e.jsx("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0c-4.114 1.828-1.37 2.133.305 2.438 1.676.305 4.42 2.59 4.42 5.181v3.048H3.047A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047z"})})}function Dn({children:t,className:s,...n}){return e.jsx("button",{type:"button",className:$e(["react-flow__controls-button",s]),...n,children:t})}const J1=t=>({isInteractive:t.nodesDraggable||t.nodesConnectable||t.elementsSelectable,minZoomReached:t.transform[2]<=t.minZoom,maxZoomReached:t.transform[2]>=t.maxZoom,ariaLabelConfig:t.ariaLabelConfig});function od({style:t,showZoom:s=!0,showFitView:n=!0,showInteractive:a=!0,fitViewOptions:i,onZoomIn:r,onZoomOut:o,onFitView:l,onInteractiveChange:c,className:h,children:m,position:d="bottom-left",orientation:u="vertical","aria-label":p}){const x=we(),{isInteractive:j,minZoomReached:v,maxZoomReached:g,ariaLabelConfig:b}=ge(J1,ke),{zoomIn:y,zoomOut:w,fitView:S}=tr(),$=()=>{y(),r==null||r()},M=()=>{w(),o==null||o()},z=()=>{S(i),l==null||l()},A=()=>{x.setState({nodesDraggable:!j,nodesConnectable:!j,elementsSelectable:!j}),c==null||c(!j)},k=u==="horizontal"?"horizontal":"vertical";return e.jsxs(Sa,{className:$e(["react-flow__controls",k,h]),position:d,style:t,"data-testid":"rf__controls","aria-label":p??b["controls.ariaLabel"],children:[s&&e.jsxs(e.Fragment,{children:[e.jsx(Dn,{onClick:$,className:"react-flow__controls-zoomin",title:b["controls.zoomIn.ariaLabel"],"aria-label":b["controls.zoomIn.ariaLabel"],disabled:g,children:e.jsx(Y1,{})}),e.jsx(Dn,{onClick:M,className:"react-flow__controls-zoomout",title:b["controls.zoomOut.ariaLabel"],"aria-label":b["controls.zoomOut.ariaLabel"],disabled:v,children:e.jsx(X1,{})})]}),n&&e.jsx(Dn,{className:"react-flow__controls-fitview",onClick:z,title:b["controls.fitView.ariaLabel"],"aria-label":b["controls.fitView.ariaLabel"],children:e.jsx(K1,{})}),a&&e.jsx(Dn,{className:"react-flow__controls-interactive",onClick:A,title:b["controls.interactive.ariaLabel"],"aria-label":b["controls.interactive.ariaLabel"],children:j?e.jsx(Q1,{}):e.jsx(Z1,{})}),m]})}od.displayName="Controls";const ew=f.memo(od);function tw({id:t,x:s,y:n,width:a,height:i,style:r,color:o,strokeColor:l,strokeWidth:c,className:h,borderRadius:m,shapeRendering:d,selected:u,onClick:p}){const{background:x,backgroundColor:j}=r||{},v=o||x||j;return e.jsx("rect",{className:$e(["react-flow__minimap-node",{selected:u},h]),x:s,y:n,rx:m,ry:m,width:a,height:i,style:{fill:v,stroke:l,strokeWidth:c},shapeRendering:d,onClick:p?g=>p(g,t):void 0})}const sw=f.memo(tw),nw=t=>t.nodes.map(s=>s.id),Ja=t=>t instanceof Function?t:()=>t;function aw({nodeStrokeColor:t,nodeColor:s,nodeClassName:n="",nodeBorderRadius:a=5,nodeStrokeWidth:i,nodeComponent:r=sw,onClick:o}){const l=ge(nw,ke),c=Ja(s),h=Ja(t),m=Ja(n),d=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return e.jsx(e.Fragment,{children:l.map(u=>e.jsx(rw,{id:u,nodeColorFunc:c,nodeStrokeColorFunc:h,nodeClassNameFunc:m,nodeBorderRadius:a,nodeStrokeWidth:i,NodeComponent:r,onClick:o,shapeRendering:d},u))})}function iw({id:t,nodeColorFunc:s,nodeStrokeColorFunc:n,nodeClassNameFunc:a,nodeBorderRadius:i,nodeStrokeWidth:r,shapeRendering:o,NodeComponent:l,onClick:c}){const{node:h,x:m,y:d,width:u,height:p}=ge(x=>{const j=x.nodeLookup.get(t);if(!j)return{node:void 0,x:0,y:0,width:0,height:0};const v=j.internals.userNode,{x:g,y:b}=j.internals.positionAbsolute,{width:y,height:w}=zt(v);return{node:v,x:g,y:b,width:y,height:w}},ke);return!h||h.hidden||!ac(h)?null:e.jsx(l,{x:m,y:d,width:u,height:p,style:h.style,selected:!!h.selected,className:a(h),color:s(h),borderRadius:i,strokeColor:n(h),strokeWidth:r,shapeRendering:o,onClick:c,id:h.id})}const rw=f.memo(iw);var ow=f.memo(aw);const lw=200,cw=150,dw=t=>!t.hidden,uw=t=>{const s={x:-t.transform[0]/t.transform[2],y:-t.transform[1]/t.transform[2],width:t.width/t.transform[2],height:t.height/t.transform[2]};return{viewBB:s,boundingRect:t.nodeLookup.size>0?tc(vn(t.nodeLookup,{filter:dw}),s):s,rfId:t.rfId,panZoom:t.panZoom,translateExtent:t.translateExtent,flowWidth:t.width,flowHeight:t.height,ariaLabelConfig:t.ariaLabelConfig}},Po=(t,s)=>t.x===s.x&&t.y===s.y&&t.width===s.width&&t.height===s.height,hw=(t,s)=>Po(t.viewBB,s.viewBB)&&Po(t.boundingRect,s.boundingRect)&&t.rfId===s.rfId&&t.panZoom===s.panZoom&&t.translateExtent===s.translateExtent&&t.flowWidth===s.flowWidth&&t.flowHeight===s.flowHeight&&t.ariaLabelConfig===s.ariaLabelConfig,mw="react-flow__minimap-desc";function ld({style:t,className:s,nodeStrokeColor:n,nodeColor:a,nodeClassName:i="",nodeBorderRadius:r=5,nodeStrokeWidth:o,nodeComponent:l,bgColor:c,maskColor:h,maskStrokeColor:m,maskStrokeWidth:d,position:u="bottom-right",onClick:p,onNodeClick:x,pannable:j=!1,zoomable:v=!1,ariaLabel:g,inversePan:b,zoomStep:y=1,offsetScale:w=5}){const S=we(),$=f.useRef(null),{boundingRect:M,viewBB:z,rfId:A,panZoom:k,translateExtent:C,flowWidth:_,flowHeight:P,ariaLabelConfig:N}=ge(uw,hw),T=(t==null?void 0:t.width)??lw,L=(t==null?void 0:t.height)??cw,R=M.width/T,F=M.height/L,E=Math.max(R,F),D=E*T,G=E*L,I=w*E,W=M.x-(D-M.width)/2-I,V=M.y-(G-M.height)/2-I,X=D+I*2,J=G+I*2,le=`${mw}-${A}`,B=f.useRef(0),Y=f.useRef();B.current=E,f.useEffect(()=>{if($.current&&k)return Y.current=db({domNode:$.current,panZoom:k,getTransform:()=>S.getState().transform,getViewScale:()=>B.current}),()=>{var O;(O=Y.current)==null||O.destroy()}},[k]),f.useEffect(()=>{var O;(O=Y.current)==null||O.update({translateExtent:C,width:_,height:P,inversePan:b,pannable:j,zoomStep:y,zoomable:v})},[j,v,b,y,C,_,P]);const ee=p?O=>{var Q;const[K,Z]=((Q=Y.current)==null?void 0:Q.pointer(O))||[0,0];p(O,{x:K,y:Z})}:void 0,ae=x?f.useCallback((O,K)=>{const Z=S.getState().nodeLookup.get(K).internals.userNode;x(O,Z)},[]):void 0,ne=g??N["minimap.ariaLabel"];return e.jsx(Sa,{position:u,style:{...t,"--xy-minimap-background-color-props":typeof c=="string"?c:void 0,"--xy-minimap-mask-background-color-props":typeof h=="string"?h:void 0,"--xy-minimap-mask-stroke-color-props":typeof m=="string"?m:void 0,"--xy-minimap-mask-stroke-width-props":typeof d=="number"?d*E:void 0,"--xy-minimap-node-background-color-props":typeof a=="string"?a:void 0,"--xy-minimap-node-stroke-color-props":typeof n=="string"?n:void 0,"--xy-minimap-node-stroke-width-props":typeof o=="number"?o:void 0},className:$e(["react-flow__minimap",s]),"data-testid":"rf__minimap",children:e.jsxs("svg",{width:T,height:L,viewBox:`${W} ${V} ${X} ${J}`,className:"react-flow__minimap-svg",role:"img","aria-labelledby":le,ref:$,onClick:ee,children:[ne&&e.jsx("title",{id:le,children:ne}),e.jsx(ow,{onClick:ae,nodeColor:a,nodeStrokeColor:n,nodeBorderRadius:r,nodeClassName:i,nodeStrokeWidth:o,nodeComponent:l}),e.jsx("path",{className:"react-flow__minimap-mask",d:`M${W-I},${V-I}h${X+I*2}v${J+I*2}h${-X-I*2}z
|
|
430
|
+
M${z.x},${z.y}h${z.width}v${z.height}h${-z.width}z`,fillRule:"evenodd",pointerEvents:"none"})]})})}ld.displayName="MiniMap";const fw=f.memo(ld),pw=t=>s=>t?`${Math.max(1/s.transform[2],1)}`:void 0,xw={[Ts.Line]:"right",[Ts.Handle]:"bottom-right"};function gw({nodeId:t,position:s,variant:n=Ts.Handle,className:a,style:i=void 0,children:r,color:o,minWidth:l=10,minHeight:c=10,maxWidth:h=Number.MAX_VALUE,maxHeight:m=Number.MAX_VALUE,keepAspectRatio:d=!1,resizeDirection:u,autoScale:p=!0,shouldResize:x,onResizeStart:j,onResize:v,onResizeEnd:g}){const b=Fc(),y=typeof t=="string"?t:b,w=we(),S=f.useRef(null),$=n===Ts.Handle,M=ge(f.useCallback(pw($&&p),[$,p]),ke),z=f.useRef(null),A=s??xw[n];f.useEffect(()=>{if(!(!S.current||!y))return z.current||(z.current=kb({domNode:S.current,nodeId:y,getStoreItems:()=>{const{nodeLookup:C,transform:_,snapGrid:P,snapToGrid:N,nodeOrigin:T,domNode:L}=w.getState();return{nodeLookup:C,transform:_,snapGrid:P,snapToGrid:N,nodeOrigin:T,paneDomNode:L}},onChange:(C,_)=>{const{triggerNodeChanges:P,nodeLookup:N,parentLookup:T,nodeOrigin:L}=w.getState(),R=[],F={x:C.x,y:C.y},E=N.get(y);if(E&&E.expandParent&&E.parentId){const D=E.origin??L,G=C.width??E.measured.width??0,I=C.height??E.measured.height??0,W={id:E.id,parentId:E.parentId,rect:{width:G,height:I,...ic({x:C.x??E.position.x,y:C.y??E.position.y},{width:G,height:I},E.parentId,N,D)}},V=er([W],N,T,L);R.push(...V),F.x=C.x?Math.max(D[0]*G,C.x):void 0,F.y=C.y?Math.max(D[1]*I,C.y):void 0}if(F.x!==void 0&&F.y!==void 0){const D={id:y,type:"position",position:{...F}};R.push(D)}if(C.width!==void 0&&C.height!==void 0){const G={id:y,type:"dimensions",resizing:!0,setAttributes:u?u==="horizontal"?"width":"height":!0,dimensions:{width:C.width,height:C.height}};R.push(G)}for(const D of _){const G={...D,type:"position"};R.push(G)}P(R)},onEnd:({width:C,height:_})=>{const P={id:y,type:"dimensions",resizing:!1,dimensions:{width:C,height:_}};w.getState().triggerNodeChanges([P])}})),z.current.update({controlPosition:A,boundaries:{minWidth:l,minHeight:c,maxWidth:h,maxHeight:m},keepAspectRatio:d,resizeDirection:u,onResizeStart:j,onResize:v,onResizeEnd:g,shouldResize:x}),()=>{var C;(C=z.current)==null||C.destroy()}},[A,l,c,h,m,d,j,v,g,x]);const k=A.split("-");return e.jsx("div",{className:$e(["react-flow__resize-control","nodrag",...k,n,a]),ref:S,style:{...i,scale:M,...o&&{[$?"backgroundColor":"borderColor"]:o}},children:r})}f.memo(gw);function yw({data:t}){return e.jsxs("div",{className:`dep-node is-${t.action||"research"}`,children:[e.jsx(Rs,{type:"target",position:he.Left,className:"dep-handle"}),e.jsx("div",{className:"dep-node-action",children:t.action}),e.jsx("div",{className:"dep-node-label",children:t.label}),e.jsxs("div",{className:"dep-node-agent",children:["@",t.agent]}),e.jsx(Rs,{type:"source",position:he.Right,className:"dep-handle"})]})}const vw={step:yw};function jw({plan:t}){const s=f.useMemo(()=>{if(!t)return[];t.steps.length;const a=new Map,i=(l,c=new Set)=>{const h=a.get(l);if(h!==void 0)return h;if(c.has(l))return 0;c.add(l);const m=t.steps.find(u=>u.id===l);if(!m||m.deps.length===0)return a.set(l,0),c.delete(l),0;let d=0;for(const u of m.deps){const p=i(u,c);p>d&&(d=p)}return a.set(l,d+1),c.delete(l),d+1};for(const l of t.steps)i(l.id);const r=new Map;for(const l of t.steps){const c=a.get(l.id)??0,h=r.get(c)||[];h.push(l.id),r.set(c,h)}const o=[];for(const[l,c]of r){const h=c.length;c.forEach((m,d)=>{const u=t.steps.find(j=>j.id===m);if(!u)return;const p=60+l*220,x=40+(d-(h-1)/2)*90;o.push({id:u.id,type:"step",position:{x:p,y:x},data:{label:u.title,action:u.action,agent:u.agent}})})}return o},[t]),n=f.useMemo(()=>t?t.steps.flatMap(a=>a.deps.map(i=>({id:`${i}->${a.id}`,source:i,target:a.id,animated:!0}))):[],[t]);return t?t.steps.length===0?e.jsxs(se,{className:"dep-graph","data-testid":"dep-graph",children:[e.jsxs(de,{children:[e.jsx(gt,{size:14,"aria-hidden":!0})," Dependency graph"]}),e.jsx(ue,{children:"Empty plan — nothing to render."})]}):e.jsxs(se,{className:"dep-graph","data-testid":"dep-graph",children:[e.jsxs("div",{className:"dep-graph-header",children:[e.jsxs(de,{children:[e.jsx(gt,{size:14,"aria-hidden":!0})," Dependency graph"]}),e.jsxs(Pe,{variant:"info",children:[t.steps.length," nodes"]}),e.jsxs(Pe,{variant:"accent",children:[n.length," edges"]})]}),e.jsxs(ue,{children:["Plan step DAG · ",t.goal.slice(0,80)]}),e.jsx("div",{className:"dep-graph-canvas","data-testid":"dep-graph-canvas",children:e.jsxs(H1,{nodes:s,edges:n,nodeTypes:vw,fitView:!0,fitViewOptions:{padding:.15},proOptions:{hideAttribution:!0},children:[e.jsx(G1,{gap:16,size:1}),e.jsx(ew,{showInteractive:!1}),e.jsx(fw,{pannable:!0,zoomable:!0})]})})]}):e.jsxs(se,{className:"dep-graph","data-testid":"dep-graph",children:[e.jsxs(de,{children:[e.jsx(gt,{size:14,"aria-hidden":!0})," Dependency graph"]}),e.jsx(ue,{children:"Submit a goal to render the dependency DAG."})]})}const bw=200;function ww(t){return t==="agent:status"?"status":t==="agent:restarted"?"restarted":t==="agent:stuck"?"stuck":t==="agent:message"?"message":"info"}function kw(t,s,n){const a=ww(t),i=`${n}-${Math.random().toString(36).slice(2,7)}`;if(t==="agent:message"){const l=(s==null?void 0:s.message)||s;return{id:i,ts:n,from:String((l==null?void 0:l.from)||"unknown"),to:String((l==null?void 0:l.to)||"unknown"),message:String((l==null?void 0:l.text)||(l==null?void 0:l.message)||JSON.stringify(l).slice(0,160)),kind:a,raw:s}}const r=(s==null?void 0:s.agent)||s,o=String((r==null?void 0:r.name)||"agent");return{id:i,ts:n,from:o,to:a==="stuck"?"orchestrator":"broadcast",message:`${t} ${r!=null&&r.status?`→ ${r.status}`:""}`.trim(),kind:a,raw:s}}function Nw({maxRows:t=bw}){const[s,n]=f.useState([]);return f.useEffect(()=>{const a=new es,i=a.on(r=>{const o=r.type;if(!o||!o.startsWith("agent:"))return;const l=r,c=Number(l.ts)||Date.now();n(h=>{const m=[...h,kw(o,l,c)];return m.length>t?m.slice(m.length-t):m})});return()=>{i(),a.close()}},[t]),e.jsxs(se,{className:"comm-log","data-testid":"communication-log",children:[e.jsxs("div",{className:"comm-log-header",children:[e.jsxs(de,{children:[e.jsx(mn,{size:14,"aria-hidden":!0})," Communication log"]}),e.jsx(Pe,{variant:"neutral","data-testid":"communication-log-count",children:s.length})]}),e.jsxs(ue,{children:["Inter-agent message bus trace · bounded to ",t," rows"]}),e.jsxs("ul",{className:"comm-log-list","data-testid":"communication-log-list",children:[s.length===0&&e.jsx("li",{className:"comm-log-empty","data-testid":"communication-log-empty",children:"No agent messages yet. Stream will appear here live."}),s.slice().reverse().map(a=>e.jsxs("li",{className:`comm-log-row is-${a.kind}`,"data-testid":"communication-log-row","data-kind":a.kind,children:[e.jsxs("div",{className:"comm-log-row-meta",children:[e.jsx("span",{className:"comm-log-from",children:a.from}),e.jsx(Yo,{size:12,"aria-hidden":!0}),e.jsx("span",{className:"comm-log-to",children:a.to}),e.jsx(Pe,{variant:"neutral",className:`comm-log-kind is-${a.kind}`,children:a.kind}),e.jsx("time",{className:"comm-log-time",dateTime:new Date(a.ts).toISOString(),children:new Date(a.ts).toLocaleTimeString()})]}),e.jsx("div",{className:"comm-log-message",children:a.message})]},a.id))]})]})}const ei=500;function Sw(t){return t.startsWith("goal:")?"success":t.startsWith("task:")?"info":t.includes("error")||t.includes("fail")?"error":t.includes("stuck")||t.includes("blocked")||t.includes("warn")?"warning":t==="ping"||t==="pong"||t==="refresh"?"control":"info"}function Cw(t,s){return s&&Object.keys(s).slice(0,3).map(a=>`${a}=${zw(s[a])}`).join(" ")||t}function zw(t){return t==null?"null":typeof t=="string"?t.length>20?`"${t.slice(0,20)}…"`:`"${t}"`:typeof t=="number"||typeof t=="boolean"?String(t):Array.isArray(t)?`[${t.length}]`:typeof t=="object"?`{${Object.keys(t).length}}`:String(t)}function Mw(){const[t,s]=f.useState([]);f.useEffect(()=>{const a=new es,i=a.on(r=>{const o=r,l=o.type;if(!l)return;const c=Number(o.ts)||Date.now(),h={id:`${c}-${Math.random().toString(36).slice(2,7)}`,ts:c,type:l,severity:Sw(l),preview:Cw(l,o)};s(m=>{const d=[...m,h];return d.length>ei?d.slice(d.length-ei):d})});return()=>{i(),a.close()}},[]);const n=f.useMemo(()=>{const a={info:0,success:0,warning:0,error:0,control:0};for(const i of t)a[i.severity]+=1;return a},[t]);return e.jsxs(se,{className:"event-log","data-testid":"event-log",children:[e.jsxs("div",{className:"event-log-header",children:[e.jsxs(de,{children:[e.jsx(He,{size:14,"aria-hidden":!0})," Real-time events"]}),e.jsx(Pe,{variant:"neutral","data-testid":"event-log-count",children:t.length})]}),e.jsxs(ue,{children:["Live WebSocket event ticker · bounded to ",ei," rows"]}),e.jsxs("div",{className:"event-log-summary","data-testid":"event-log-summary",children:[e.jsxs(Pe,{variant:"info",children:["info ",n.info]}),e.jsxs(Pe,{variant:"success",children:["success ",n.success]}),e.jsxs(Pe,{variant:"warning",children:["warning ",n.warning]}),e.jsxs(Pe,{variant:"error",children:["error ",n.error]}),e.jsxs(Pe,{variant:"neutral",children:["control ",n.control]})]}),e.jsxs("ul",{className:"event-log-list","data-testid":"event-log-list",children:[t.length===0&&e.jsx("li",{className:"event-log-empty","data-testid":"event-log-empty",children:"No events yet. Events will stream here as the server emits them."}),t.slice().reverse().map(a=>e.jsxs("li",{className:`event-log-row is-${a.severity}`,"data-testid":"event-log-row","data-severity":a.severity,children:[e.jsx("time",{className:"event-log-time",dateTime:new Date(a.ts).toISOString(),children:new Date(a.ts).toLocaleTimeString()}),e.jsx("code",{className:"event-log-type",children:a.type}),e.jsx("span",{className:"event-log-preview",children:a.preview})]},a.id))]})]})}function $w(t){const s=t.compileCheck?{name:"Compile check",status:"passed",value:!0,threshold:!0,detail:"make check is green."}:{name:"Compile check",status:"failed",value:!1,threshold:!0,detail:"Typecheck error — fix before marking passing."},n=t.testCoverage>=80?{name:"Test coverage",status:"passed",value:t.testCoverage,threshold:80,detail:"Coverage meets the B-grade threshold."}:t.testCoverage>=60?{name:"Test coverage",status:"warning",value:t.testCoverage,threshold:80,detail:"Coverage is below the B-grade threshold."}:{name:"Test coverage",status:"failed",value:t.testCoverage,threshold:80,detail:"Coverage is critical."},a=t.archScore>=90?{name:"Arch compliance",status:"passed",value:t.archScore,threshold:90,detail:"All non-trivial arch-rules satisfied."}:t.archScore>=70?{name:"Arch compliance",status:"warning",value:t.archScore,threshold:90,detail:"Minor arch-rule violations."}:{name:"Arch compliance",status:"failed",value:t.archScore,threshold:90,detail:"Multiple arch-rule violations."},i=t.evidencePresent?{name:"Verification evidence",status:"passed",value:!0,threshold:!0,detail:"Test output + commit hash captured."}:{name:"Verification evidence",status:"failed",value:!1,threshold:!0,detail:"No evidence recorded yet."};return[s,n,a,i]}function Ew({status:t}){return t==="passed"?e.jsx(Ze,{size:14,className:"qg-icon is-pass"}):t==="warning"?e.jsx(qe,{size:14,className:"qg-icon is-warn"}):e.jsx(ls,{size:14,className:"qg-icon is-fail"})}function _w({status:t}){return t==="passed"?e.jsx(Pe,{variant:"success",children:"passed"}):t==="warning"?e.jsx(Pe,{variant:"warning",children:"warning"}):e.jsx(Pe,{variant:"error",children:"failed"})}function Tw({plan:t,metrics:s}){const n=$w(s),a=n.filter(i=>i.status==="passed").length;return e.jsxs(se,{className:"qg-panel","data-testid":"quality-gates",children:[e.jsxs("div",{className:"qg-header",children:[e.jsxs(de,{children:[e.jsx(ss,{size:14,"aria-hidden":!0})," Quality gates"]}),e.jsxs(Pe,{variant:a===n.length?"success":a>0?"warning":"error",children:[a,"/",n.length," passing"]})]}),e.jsxs(ue,{children:["L09 rubric (Correctness / Arch compliance / Test coverage / Verification evidence) —"," ",t?`evaluating against plan with ${t.steps.length} steps.`:"awaiting plan."]}),e.jsx("ul",{className:"qg-list","data-testid":"quality-gates-list",children:n.map(i=>e.jsxs("li",{className:`qg-row is-${i.status}`,"data-testid":"quality-gates-row","data-status":i.status,children:[e.jsxs("div",{className:"qg-row-head",children:[e.jsx(Ew,{status:i.status}),e.jsx("span",{className:"qg-name",children:i.name}),e.jsx(_w,{status:i.status})]}),e.jsxs("div",{className:"qg-row-body",children:[e.jsx("span",{className:"qg-detail",children:i.detail}),typeof i.value=="number"&&e.jsxs("span",{className:"qg-threshold",children:["current: ",i.value,"% · threshold: ",i.threshold,"%"]}),typeof i.value=="boolean"&&e.jsxs("span",{className:"qg-threshold",children:["current: ",String(i.value)," · threshold: ",String(i.threshold)]})]})]},i.name))})]})}const Aw={compileCheck:"compile-check",testCoverage:"unit",archScore:"check-arch",evidencePresent:"e2e"};function Rw(t){const[s,n]=f.useState(null),[a,i]=f.useState(!1),[r,o]=f.useState(0),[l,c]=f.useState(0),[h,m]=f.useState(!1);return f.useEffect(()=>{const d=new es,u=d.on(p=>{switch(p.type){case"task:progress":o(j=>Do(j+5,0,100)),m(!0);break;case"tasks:change":m(!0);break;case"goal:planned":i(!0),o(j=>j<25?25:j),c(j=>j<30?30:j),m(!0);break;case"agents:change":case"agent:status":c(j=>Do(j+2,0,100));break}});return()=>{u(),d.close()}},[]),e.jsxs("div",{className:"goal-planner-page","data-testid":"goal-planner-page",children:[e.jsxs("header",{className:"goal-planner-header",children:[e.jsxs("div",{className:"goal-planner-title-row",children:[e.jsx(Ai,{size:20,"aria-hidden":!0}),e.jsx("h2",{children:"Goal Planner"}),e.jsx("span",{className:"badge badge-info","data-testid":"goal-planner-version",children:"v6.4.0"})]}),e.jsxs("p",{className:"goal-planner-blurb",children:[e.jsx(vt,{size:12,"aria-hidden":!0})," Type a goal in plain English. We decompose it into clauses, map each clause to a Bizar action template, and run A* over the action space to produce an executable plan. The four panels below update in real time as the harness streams events."]})]}),e.jsxs("div",{className:"goal-planner-grid",children:[e.jsx("section",{className:"goal-planner-input-row",children:e.jsx(Ux,{onPlan:n})}),e.jsx("section",{className:"goal-planner-plan-row",children:e.jsx(Wx,{plan:s})}),e.jsx("section",{className:"goal-planner-panel-row",children:e.jsx(jw,{plan:s})}),e.jsx("section",{className:"goal-planner-panel-row",children:e.jsx(Nw,{})}),e.jsx("section",{className:"goal-planner-panel-row",children:e.jsx(Mw,{})}),e.jsx("section",{className:"goal-planner-panel-row",children:e.jsx(Tw,{plan:s,metrics:{compileCheck:a,testCoverage:r,archScore:l,evidencePresent:h}})})]}),e.jsx("footer",{className:"goal-planner-footer",children:e.jsxs(se,{children:[e.jsx(de,{children:"How this works"}),e.jsxs(ue,{children:["Rubric dimensions: ",Object.values(Aw).join(" · "),". The dependency graph uses @xyflow/react; the message bus and event ticker subscribe to the shared WebSocket feed (never a second connection)."]})]})})]})}function Do(t,s,n){return Math.max(s,Math.min(n,t))}function Iw(t){return e.jsx(Rw,{...t})}const ti={overview:fm,chat:_m,agents:Am,artifacts:of,memory:Wp,tasks:vf,activity:$f,background:yx,config:kr,settings:kr,mods:Zf,schedules:dp,skills:yp,history:Yp,minimax:nx,doctor:Tx,harness:Rx,eval:Dx,evalReport:Vx,"goal-planner":Iw},Lw="v6.0.0";function Pw(t,s,n,a){if(ti[t]){const o=ti[t];return e.jsx(o,{...s})}const i=n.find(o=>o.id===t);if(i)return e.jsx(Jf,{viewId:i.id,reloadKey:a,activeTab:s.activeTab,setActiveTab:s.setActiveTab});const r=ti.overview;return e.jsx(r,{...s})}function Dw({onSaved:t}){const[s,n]=f.useState(""),a=f.useRef(null);f.useEffect(()=>{var o;(o=a.current)==null||o.focus()},[]);const i=()=>{const o=s.trim();o&&(H.setToken(o),t())},r=o=>{o.key==="Escape"&&(o.preventDefault(),t()),o.key==="Enter"&&(o.preventDefault(),i())};return e.jsxs("form",{className:"token-entry-form",onSubmit:o=>{o.preventDefault(),i()},children:[e.jsxs("div",{className:"token-entry-row",children:[e.jsx("input",{ref:a,type:"password",className:"input mono",value:s,onChange:o=>n(o.target.value),placeholder:"Paste auth token",spellCheck:!1,autoComplete:"off",onKeyDown:r}),e.jsx(U,{type:"submit",variant:"primary",size:"sm",disabled:!s.trim(),children:"Save & retry"})]}),e.jsxs("p",{className:"token-entry-hint",children:["Where do I find this token? Check the file"," ",e.jsx("code",{children:"~/.config/bizar/dashboard-secret"})," on the machine running the dashboard, or look for it in the server output."]})]})}function Fw(){return e.jsx(hu,{children:e.jsx(yh,{children:e.jsx(Ow,{})})})}function Ow(){var ee,ae,ne;const t=pe(),s=Qe(),{isModalOpen:n}=s,a=f.useRef(!1),[i,r]=f.useState("overview"),[o,l]=f.useState(null),[c,h]=f.useState(null),[m,d]=f.useState("connecting"),[u,p]=f.useState(null),[x,j]=f.useState(!1),[v,g]=f.useState(null),[b,y]=f.useState(!1),[w,S]=f.useState(!1),[$,M]=f.useState([]),[z,A]=f.useState(!1),[k,C]=f.useState([]),[_,P]=f.useState(0),N=f.useRef(null),[T,L]=f.useState(null);f.useEffect(()=>{let O=!1;return(async()=>{try{const K=await H.get("/mods/views");if(O)return;C(K.views||[])}catch{O||C([])}})(),()=>{O=!0}},[_,o==null?void 0:o.mods]),f.useEffect(()=>{if(!T)return;const O=T.on(K=>{((K==null?void 0:K.type)==="mod:change"||(K==null?void 0:K.type)==="mod:enabled"||(K==null?void 0:K.type)==="mod:installed")&&P(Z=>Z+1)});return()=>O()},[T]),f.useEffect(()=>{c!=null&&c.theme&&(Ys(c.theme),fs(c.theme))},[c==null?void 0:c.theme]),f.useEffect(()=>{a.current=n},[n]),f.useEffect(()=>{var Z;if(((Z=c==null?void 0:c.theme)==null?void 0:Z.mode)!=="system")return;const O=window.matchMedia("(prefers-color-scheme: light)"),K=()=>Ys(c.theme.mode);return O.addEventListener("change",K),()=>O.removeEventListener("change",K)},[(ee=c==null?void 0:c.theme)==null?void 0:ee.mode]);const R=f.useCallback(async()=>{let O=!1;const K=()=>Promise.all([H.get("/snapshot").catch(()=>null),H.get("/settings").catch(()=>null),H.get("/agents/stuck").catch(()=>null)]),Z=(Q,oe,ce)=>{Q&&l(Q),oe!=null&&oe.data&&h(oe.data),ce!=null&&ce.stuck&&M(ce.stuck)};try{const Q=await H.probeAuthStatus(),[oe,ce,me]=await K();if(Z(oe,ce,me),oe||ce){p(null);return}if(!Q.loopback){p("Dashboard server unreachable.");return}await new Promise(Ge=>setTimeout(Ge,1e3));const[be,Ne,Me]=await K();Z(be,Ne,Me),!be&&!Ne&&p("Dashboard server unreachable.")}catch(Q){const oe=(Q==null?void 0:Q.message)??"unknown error";if(Q instanceof cu&&Q.status===401){p(oe),y(!0),t.error(`Auth required: ${oe}`);return}p(oe),t.error(`Failed to load: ${oe}`)}},[t]);f.useEffect(()=>{let O=!1;const K=setTimeout(()=>{O||R()},0);return()=>{O=!0,clearTimeout(K)}},[R]),f.useEffect(()=>{let O=!1;return H.get("/settings").then(K=>{var Q,oe;if(O)return;const Z=(oe=(Q=K==null?void 0:K.data)==null?void 0:Q.ui)==null?void 0:oe.defaultTab;Z&&r(Z)}).catch(()=>{}),()=>{O=!0}},[]),f.useEffect(()=>{let O=!1;const K=async()=>{try{const Q=await H.get("/agents/stuck");O||M(oe=>{const ce=Q.stuck||[];return oe.length===0&&ce.length>0&&t.warning(`${ce.length} agent${ce.length===1?"":"s"} stuck`,5e3),ce})}catch{}},Z=setInterval(K,3e4);return K(),()=>{O=!0,clearInterval(Z)}},[]),f.useEffect(()=>{const O=new es;N.current=O,L(O);const K=O.onStatus(Q=>d(Q)),Z=O.on(Q=>{var oe;if(Q.type==="snapshot"&&"data"in Q&&Q.data)l(ce=>({...ce??{},...Q.data}));else if(Q.type==="change"){const ce=Q,me=((oe=ce.path)==null?void 0:oe.split("/").pop())||ce.path||"";t.info(`File changed: ${me}`,2500)}else if(Q.type==="tasks:change"){const ce=Q;l(me=>{if(!me)return me;const be=(me.tasks||[]).map(Me=>Me.id===ce.task.id?ce.task:Me),Ne=be.some(Me=>Me.id===ce.task.id);return{...me,tasks:Ne?be:[ce.task,...be]}})}else if(Q.type==="tasks:delete"){const ce=Q;l(me=>me&&{...me,tasks:(me.tasks||[]).filter(be=>be.id!==ce.id)})}else if(Q.type==="settings:change"){const ce=Q;ce.settings&&h(ce.settings)}else if(Q.type==="project:change")H.get("/snapshot").then(ce=>l(me=>({...me??{},...ce}))).catch(()=>{});else if(Q.type==="agents:change"||Q.type==="schedules:change")H.get("/snapshot").then(ce=>l(me=>({...me??{},...ce}))).catch(()=>{});else if(Q.type==="agent:status"||Q.type==="agent:restarted"){const ce=Q;l(me=>{if(!me)return me;const be=(me.agents||[]).map(Ne=>Ne.name===ce.agent.name?ce.agent:Ne);return{...me,agents:be}})}else if(Q.type==="artifact:change")H.get("/artifacts").then(ce=>{l(me=>me&&{...me,artifacts:ce.artifacts||[]})}).catch(()=>{});else if(Q.type==="agent:stuck")M(Q.agents||[]);else if(Q.type==="dialog:show"){const ce=Q;ce.dialog&&s.open({title:ce.dialog.title,width:520,children:e.jsx(Wh,{dialog:ce.dialog,onClose:()=>s.close()})})}});return()=>{K(),Z(),O.close(),L(null)}},[t]);const F=f.useCallback(O=>T?T.on(O):()=>{},[T]),E=f.useRef(0);f.useEffect(()=>{const O=()=>{E.current=Date.now()+1500};return document.addEventListener("mousedown",O,!0),document.addEventListener("click",O,!0),document.addEventListener("focusin",O,!0),document.addEventListener("keydown",O,!0),()=>{document.removeEventListener("mousedown",O,!0),document.removeEventListener("click",O,!0),document.removeEventListener("focusin",O,!0),document.removeEventListener("keydown",O,!0)}},[]),f.useEffect(()=>{const O={};ai.forEach((Z,Q)=>{O[String(Q+1)]=Z.id});const K=Z=>{var Ge,Je,De,Oe;if((Z.metaKey||Z.ctrlKey)&&Z.key.toLowerCase()==="k"){Z.preventDefault(),S(!0);return}if(Z.key==="/"&&!Z.metaKey&&!Z.ctrlKey){const Ye=(Je=(Ge=Z.target)==null?void 0:Ge.tagName)==null?void 0:Je.toLowerCase();if(Ye!=="input"&&Ye!=="textarea"&&!((De=Z.target)!=null&&De.isContentEditable)){Z.preventDefault(),S(!0);return}}const Q=document.activeElement;if(!Q||Q===document.body||Q===document.documentElement)return;const ce=Z.target,me=(Oe=ce==null?void 0:ce.tagName)==null?void 0:Oe.toLowerCase(),be=me==="input"||me==="textarea"||me==="select"||me==="button"||me==="option"||me==="label"||!!(ce!=null&&ce.isContentEditable);let Ne=!1;if(ce&&typeof ce.closest=="function"&&(Ne=!!ce.closest('form, [role="dialog"], [contenteditable], [data-no-key]')),Z.repeat||a.current||be||Ne||Z.metaKey||Z.ctrlKey||Z.altKey||Z.shiftKey||Date.now()<E.current)return;const Me=O[Z.key];Me&&(Z.preventDefault(),G(Me))};return document.addEventListener("keydown",K),()=>document.removeEventListener("keydown",K)},[]);const D=f.useMemo(()=>async()=>{try{const O=await H.get("/snapshot");l(K=>({...K??{},...O}))}catch(O){t.error(`Refresh failed: ${O.message}`)}},[t]),G=f.useCallback(O=>{r(O),j(O==="settings")},[]),I=f.useMemo(()=>{const O=k.map(K=>({id:K.id,label:K.label,icon:K.kind==="iframe"?Qs:Js,isMod:!0,modId:K.modId}));return[...ai,...O]},[k]),W=f.useMemo(()=>({state:"active",label:"in-process",detail:"ClineCore running in-process (v6.0.0, no subprocess)"}),[]),V=f.useMemo(()=>o&&c?Pw(i,{snapshot:o,settings:c,activeTab:i,setActiveTab:G,refreshSnapshot:D,settingsMode:x,settingsActiveSection:v,setSettingsActiveSection:g},k,_):null,[i,o,c,k,_,D,x,v,g,G]),X=async()=>{try{const O=await H.get("/projects");l(K=>{var Z;return K&&{...K,projects:O.projects||[],activeProject:((Z=O.projects)==null?void 0:Z.find(Q=>Q.id===O.active))||null}})}catch(O){t.error(`Projects refresh failed: ${O.message}`)}},J=async O=>{try{await H.post(`/projects/${encodeURIComponent(O)}/activate`),l(K=>K&&{...K,activeProject:K.projects.find(Z=>Z.id===O)||null})}catch(K){t.error(`Activate failed: ${K.message}`)}},le=O=>{const K=O.type;if(K==="agent")G("agents");else if(K==="task")G("tasks");else if(K==="mod")G("mods");else if(K==="schedule")G("schedules");else if(K==="project"){const Z=O.item.id;J(Z)}else if(K==="command")t.info(`/${O.item.name} — run from the TUI`,2500);else if(K==="setting"){const Z=O.item.id||O.item.path||"";G("settings");const Q=oe=>{if(oe<=0)return;const ce=Z?document.querySelector(`[data-setting-id="${CSS.escape(Z)}"]`):null;ce?(ce.scrollIntoView({behavior:"smooth",block:"center"}),ce.classList.remove("setting-flash"),ce.offsetWidth,ce.classList.add("setting-flash"),window.setTimeout(()=>ce.classList.remove("setting-flash"),1500)):window.setTimeout(()=>Q(oe-1),80)};window.setTimeout(()=>Q(15),60)}},B=((ae=c==null?void 0:c.ui)==null?void 0:ae.layout)||"topnav",Y=((ne=c==null?void 0:c.ui)==null?void 0:ne.showHeader)!==!1;return e.jsxs("div",{className:"app","data-layout":B,"data-active-tab":i,children:[e.jsx("a",{className:"skip-to-main",href:"#main-content",children:"Skip to main content"}),Y&&e.jsx($h,{activeTab:i,onTabChange:G,wsStatus:m,version:Lw,activeProject:(o==null?void 0:o.activeProject)||null,projects:(o==null?void 0:o.projects)||[],onProjectChange:J,onProjectsRefresh:X,onOpenSearch:()=>S(!0),settings:c,notificationsSlot:e.jsx(Dh,{wsSubscribe:F}),showTabs:B==="topnav",extraTabs:I,clineStatus:W}),$.length>0&&!z&&e.jsxs("div",{className:"stuck-banner",role:"alert",children:[e.jsx(qe,{size:16}),e.jsxs("span",{children:[e.jsx("strong",{children:$.length})," agent",$.length===1?"":"s"," stuck:"," ",e.jsx("span",{className:"mono",children:$.map(O=>O.name).join(", ")})]}),e.jsx(U,{variant:"secondary",size:"sm",onClick:()=>{G("agents"),A(!0)},children:"Review"}),e.jsx("button",{type:"button",className:"icon-btn","aria-label":"Dismiss",onClick:()=>A(!0),children:e.jsx(Ie,{size:14})})]}),e.jsxs("div",{className:"layout-body",children:[B!=="topnav"&&e.jsx(Rh,{tabs:I,activeTab:i,onTabChange:G,settingsMode:x,settingsActiveSection:v,onSettingsSectionChange:g,onExitSettings:()=>G("overview")}),e.jsxs("main",{className:"content",id:"main-content",tabIndex:-1,children:[u&&e.jsxs("div",{className:"boot-error",children:[e.jsx("h2",{children:"Dashboard unavailable"}),e.jsx("p",{children:u}),b&&e.jsx(Dw,{onSaved:()=>{y(!1),R()}}),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."]})]}),!u&&(!o||!c)&&e.jsxs("div",{className:"loading",children:[e.jsx(ye,{size:"lg"}),e.jsx("p",{children:"Loading Bizar…"})]}),V&&e.jsx(f.Suspense,{fallback:e.jsxs("div",{className:"loading",children:[e.jsx(ye,{size:"lg"}),e.jsx("p",{children:"Loading…"})]}),children:e.jsx(Bw,{children:V})})]})]}),e.jsx(Ih,{open:w,onClose:()=>S(!1),onSelect:le})]})}class Bw extends f.Component{constructor(){super(...arguments);Ps(this,"state",{err:null});Ps(this,"reset",()=>this.setState({err:null}))}static getDerivedStateFromError(n){return{err:n}}componentDidCatch(n,a){At.error("[ViewErrorBoundary] caught render error:",n,a==null?void 0:a.componentStack)}render(){return this.state.err?e.jsxs("div",{className:"view-error-fallback",role:"alert",children:[e.jsx(qe,{size:20}),e.jsxs("div",{className:"view-error-body",children:[e.jsx("strong",{children:"This view crashed."}),e.jsx("pre",{children:this.state.err.message}),e.jsx(U,{variant:"secondary",size:"sm",onClick:this.reset,children:"Retry"})]})]}):this.props.children}}function Hw(){const[t,s]=f.useState(()=>typeof window>"u"?!1:window.matchMedia("(max-width: 767px)").matches);return f.useEffect(()=>{const n=window.matchMedia("(max-width: 767px)"),a=i=>s(i.matches);return n.addEventListener("change",a),()=>n.removeEventListener("change",a)},[]),t?e.jsx(uu,{}):e.jsx(Fw,{})}const cd=document.getElementById("root");if(!cd)throw new Error("Root element #root not found");du(cd).render(e.jsx(f.StrictMode,{children:e.jsx(Hw,{})}));
|