jfl 0.4.3 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (428) hide show
  1. package/README.md +15 -5
  2. package/dist/commands/context-hub.d.ts.map +1 -1
  3. package/dist/commands/context-hub.js +818 -39
  4. package/dist/commands/context-hub.js.map +1 -1
  5. package/dist/commands/eval.d.ts +1 -1
  6. package/dist/commands/eval.d.ts.map +1 -1
  7. package/dist/commands/eval.js +192 -1
  8. package/dist/commands/eval.js.map +1 -1
  9. package/dist/commands/findings.d.ts +6 -0
  10. package/dist/commands/findings.d.ts.map +1 -0
  11. package/dist/commands/findings.js +203 -0
  12. package/dist/commands/findings.js.map +1 -0
  13. package/dist/commands/hud.d.ts.map +1 -1
  14. package/dist/commands/hud.js +47 -9
  15. package/dist/commands/hud.js.map +1 -1
  16. package/dist/commands/ide.d.ts +27 -0
  17. package/dist/commands/ide.d.ts.map +1 -0
  18. package/dist/commands/ide.js +546 -0
  19. package/dist/commands/ide.js.map +1 -0
  20. package/dist/commands/onboard.d.ts.map +1 -1
  21. package/dist/commands/onboard.js +212 -2
  22. package/dist/commands/onboard.js.map +1 -1
  23. package/dist/commands/openclaw.d.ts +3 -0
  24. package/dist/commands/openclaw.d.ts.map +1 -1
  25. package/dist/commands/openclaw.js +76 -2
  26. package/dist/commands/openclaw.js.map +1 -1
  27. package/dist/commands/peter.d.ts +3 -0
  28. package/dist/commands/peter.d.ts.map +1 -1
  29. package/dist/commands/peter.js +1218 -2
  30. package/dist/commands/peter.js.map +1 -1
  31. package/dist/commands/pi-fleet.d.ts +18 -0
  32. package/dist/commands/pi-fleet.d.ts.map +1 -0
  33. package/dist/commands/pi-fleet.js +382 -0
  34. package/dist/commands/pi-fleet.js.map +1 -0
  35. package/dist/commands/pi.d.ts.map +1 -1
  36. package/dist/commands/pi.js +18 -3
  37. package/dist/commands/pi.js.map +1 -1
  38. package/dist/commands/scope.d.ts.map +1 -1
  39. package/dist/commands/scope.js +90 -1
  40. package/dist/commands/scope.js.map +1 -1
  41. package/dist/commands/services.d.ts.map +1 -1
  42. package/dist/commands/services.js +18 -0
  43. package/dist/commands/services.js.map +1 -1
  44. package/dist/commands/status.d.ts.map +1 -1
  45. package/dist/commands/status.js +22 -4
  46. package/dist/commands/status.js.map +1 -1
  47. package/dist/commands/viz.d.ts.map +1 -1
  48. package/dist/commands/viz.js +417 -0
  49. package/dist/commands/viz.js.map +1 -1
  50. package/dist/dashboard-static/assets/index-B6b867Pv.js +121 -0
  51. package/dist/dashboard-static/assets/index-Y4BrqxV-.css +1 -0
  52. package/dist/dashboard-static/index.html +2 -2
  53. package/dist/index.js +228 -62
  54. package/dist/index.js.map +1 -1
  55. package/dist/lib/agent-config.d.ts +52 -0
  56. package/dist/lib/agent-config.d.ts.map +1 -0
  57. package/dist/lib/agent-config.js +231 -0
  58. package/dist/lib/agent-config.js.map +1 -0
  59. package/dist/lib/agent-generator.d.ts +10 -0
  60. package/dist/lib/agent-generator.d.ts.map +1 -1
  61. package/dist/lib/agent-generator.js +64 -10
  62. package/dist/lib/agent-generator.js.map +1 -1
  63. package/dist/lib/agent-session.d.ts +104 -0
  64. package/dist/lib/agent-session.d.ts.map +1 -0
  65. package/dist/lib/agent-session.js +627 -0
  66. package/dist/lib/agent-session.js.map +1 -0
  67. package/dist/lib/eval-snapshot.d.ts +47 -0
  68. package/dist/lib/eval-snapshot.d.ts.map +1 -0
  69. package/dist/lib/eval-snapshot.js +315 -0
  70. package/dist/lib/eval-snapshot.js.map +1 -0
  71. package/dist/lib/eval-store.d.ts +5 -0
  72. package/dist/lib/eval-store.d.ts.map +1 -1
  73. package/dist/lib/eval-store.js +33 -3
  74. package/dist/lib/eval-store.js.map +1 -1
  75. package/dist/lib/findings-engine.d.ts +51 -0
  76. package/dist/lib/findings-engine.d.ts.map +1 -0
  77. package/dist/lib/findings-engine.js +338 -0
  78. package/dist/lib/findings-engine.js.map +1 -0
  79. package/dist/lib/flow-engine.d.ts +8 -0
  80. package/dist/lib/flow-engine.d.ts.map +1 -1
  81. package/dist/lib/flow-engine.js +84 -2
  82. package/dist/lib/flow-engine.js.map +1 -1
  83. package/dist/lib/hub-client.d.ts +1 -0
  84. package/dist/lib/hub-client.d.ts.map +1 -1
  85. package/dist/lib/hub-client.js +33 -6
  86. package/dist/lib/hub-client.js.map +1 -1
  87. package/dist/lib/ide-panes.d.ts +58 -0
  88. package/dist/lib/ide-panes.d.ts.map +1 -0
  89. package/dist/lib/ide-panes.js +508 -0
  90. package/dist/lib/ide-panes.js.map +1 -0
  91. package/dist/lib/memory-db.js +4 -4
  92. package/dist/lib/memory-db.js.map +1 -1
  93. package/dist/lib/memory-indexer.d.ts.map +1 -1
  94. package/dist/lib/memory-indexer.js +3 -0
  95. package/dist/lib/memory-indexer.js.map +1 -1
  96. package/dist/lib/memory-search.d.ts +148 -4
  97. package/dist/lib/memory-search.d.ts.map +1 -1
  98. package/dist/lib/memory-search.js +496 -58
  99. package/dist/lib/memory-search.js.map +1 -1
  100. package/dist/lib/meta-orchestrator.d.ts +104 -0
  101. package/dist/lib/meta-orchestrator.d.ts.map +1 -0
  102. package/dist/lib/meta-orchestrator.js +373 -0
  103. package/dist/lib/meta-orchestrator.js.map +1 -0
  104. package/dist/lib/peer-agent-generator.d.ts.map +1 -1
  105. package/dist/lib/peer-agent-generator.js +43 -19
  106. package/dist/lib/peer-agent-generator.js.map +1 -1
  107. package/dist/lib/policy-head.d.ts +25 -0
  108. package/dist/lib/policy-head.d.ts.map +1 -0
  109. package/dist/lib/policy-head.js +136 -0
  110. package/dist/lib/policy-head.js.map +1 -0
  111. package/dist/lib/replay-buffer.d.ts +93 -0
  112. package/dist/lib/replay-buffer.d.ts.map +1 -0
  113. package/dist/lib/replay-buffer.js +302 -0
  114. package/dist/lib/replay-buffer.js.map +1 -0
  115. package/dist/lib/sentinel-rl.d.ts +97 -0
  116. package/dist/lib/sentinel-rl.d.ts.map +1 -0
  117. package/dist/lib/sentinel-rl.js +430 -0
  118. package/dist/lib/sentinel-rl.js.map +1 -0
  119. package/dist/lib/session-lock.d.ts +61 -0
  120. package/dist/lib/session-lock.d.ts.map +1 -0
  121. package/dist/lib/session-lock.js +438 -0
  122. package/dist/lib/session-lock.js.map +1 -0
  123. package/dist/lib/stratus-client.d.ts +1 -0
  124. package/dist/lib/stratus-client.d.ts.map +1 -1
  125. package/dist/lib/stratus-client.js +24 -2
  126. package/dist/lib/stratus-client.js.map +1 -1
  127. package/dist/lib/telemetry-agent-v2.d.ts +128 -0
  128. package/dist/lib/telemetry-agent-v2.d.ts.map +1 -0
  129. package/dist/lib/telemetry-agent-v2.js +1042 -0
  130. package/dist/lib/telemetry-agent-v2.js.map +1 -0
  131. package/dist/lib/telemetry-agent.d.ts.map +1 -1
  132. package/dist/lib/telemetry-agent.js +27 -6
  133. package/dist/lib/telemetry-agent.js.map +1 -1
  134. package/dist/lib/telemetry-digest.d.ts.map +1 -1
  135. package/dist/lib/telemetry-digest.js +27 -5
  136. package/dist/lib/telemetry-digest.js.map +1 -1
  137. package/dist/lib/telemetry.d.ts.map +1 -1
  138. package/dist/lib/telemetry.js +29 -4
  139. package/dist/lib/telemetry.js.map +1 -1
  140. package/dist/lib/text-preprocessing.d.ts +83 -0
  141. package/dist/lib/text-preprocessing.d.ts.map +1 -0
  142. package/dist/lib/text-preprocessing.js +261 -0
  143. package/dist/lib/text-preprocessing.js.map +1 -0
  144. package/dist/lib/training-buffer.d.ts +86 -0
  145. package/dist/lib/training-buffer.d.ts.map +1 -0
  146. package/dist/lib/training-buffer.js +139 -0
  147. package/dist/lib/training-buffer.js.map +1 -0
  148. package/dist/lib/tuple-miner.d.ts +30 -0
  149. package/dist/lib/tuple-miner.d.ts.map +1 -0
  150. package/dist/lib/tuple-miner.js +427 -0
  151. package/dist/lib/tuple-miner.js.map +1 -0
  152. package/dist/lib/vm-backend.d.ts +72 -0
  153. package/dist/lib/vm-backend.d.ts.map +1 -0
  154. package/dist/lib/vm-backend.js +175 -0
  155. package/dist/lib/vm-backend.js.map +1 -0
  156. package/dist/lib/workspace/backend.d.ts +53 -0
  157. package/dist/lib/workspace/backend.d.ts.map +1 -0
  158. package/dist/lib/workspace/backend.js +37 -0
  159. package/dist/lib/workspace/backend.js.map +1 -0
  160. package/dist/lib/workspace/cmux-adapter.d.ts +46 -0
  161. package/dist/lib/workspace/cmux-adapter.d.ts.map +1 -0
  162. package/dist/lib/workspace/cmux-adapter.js +261 -0
  163. package/dist/lib/workspace/cmux-adapter.js.map +1 -0
  164. package/dist/lib/workspace/data-pipeline.d.ts +35 -0
  165. package/dist/lib/workspace/data-pipeline.d.ts.map +1 -0
  166. package/dist/lib/workspace/data-pipeline.js +463 -0
  167. package/dist/lib/workspace/data-pipeline.js.map +1 -0
  168. package/dist/lib/workspace/engine.d.ts +64 -0
  169. package/dist/lib/workspace/engine.d.ts.map +1 -0
  170. package/dist/lib/workspace/engine.js +397 -0
  171. package/dist/lib/workspace/engine.js.map +1 -0
  172. package/dist/lib/workspace/notifications.d.ts +14 -0
  173. package/dist/lib/workspace/notifications.d.ts.map +1 -0
  174. package/dist/lib/workspace/notifications.js +41 -0
  175. package/dist/lib/workspace/notifications.js.map +1 -0
  176. package/dist/lib/workspace/surface-registry.d.ts +49 -0
  177. package/dist/lib/workspace/surface-registry.d.ts.map +1 -0
  178. package/dist/lib/workspace/surface-registry.js +217 -0
  179. package/dist/lib/workspace/surface-registry.js.map +1 -0
  180. package/dist/lib/workspace/surface-type.d.ts +153 -0
  181. package/dist/lib/workspace/surface-type.d.ts.map +1 -0
  182. package/dist/lib/workspace/surface-type.js +9 -0
  183. package/dist/lib/workspace/surface-type.js.map +1 -0
  184. package/dist/lib/workspace/surfaces/agent-overview.d.ts +16 -0
  185. package/dist/lib/workspace/surfaces/agent-overview.d.ts.map +1 -0
  186. package/dist/lib/workspace/surfaces/agent-overview.js +116 -0
  187. package/dist/lib/workspace/surfaces/agent-overview.js.map +1 -0
  188. package/dist/lib/workspace/surfaces/agent.d.ts +16 -0
  189. package/dist/lib/workspace/surfaces/agent.d.ts.map +1 -0
  190. package/dist/lib/workspace/surfaces/agent.js +112 -0
  191. package/dist/lib/workspace/surfaces/agent.js.map +1 -0
  192. package/dist/lib/workspace/surfaces/claude.d.ts +15 -0
  193. package/dist/lib/workspace/surfaces/claude.d.ts.map +1 -0
  194. package/dist/lib/workspace/surfaces/claude.js +23 -0
  195. package/dist/lib/workspace/surfaces/claude.js.map +1 -0
  196. package/dist/lib/workspace/surfaces/dashboard.d.ts +21 -0
  197. package/dist/lib/workspace/surfaces/dashboard.d.ts.map +1 -0
  198. package/dist/lib/workspace/surfaces/dashboard.js +32 -0
  199. package/dist/lib/workspace/surfaces/dashboard.js.map +1 -0
  200. package/dist/lib/workspace/surfaces/eval.d.ts +15 -0
  201. package/dist/lib/workspace/surfaces/eval.d.ts.map +1 -0
  202. package/dist/lib/workspace/surfaces/eval.js +42 -0
  203. package/dist/lib/workspace/surfaces/eval.js.map +1 -0
  204. package/dist/lib/workspace/surfaces/event-stream.d.ts +16 -0
  205. package/dist/lib/workspace/surfaces/event-stream.d.ts.map +1 -0
  206. package/dist/lib/workspace/surfaces/event-stream.js +40 -0
  207. package/dist/lib/workspace/surfaces/event-stream.js.map +1 -0
  208. package/dist/lib/workspace/surfaces/flow.d.ts +16 -0
  209. package/dist/lib/workspace/surfaces/flow.d.ts.map +1 -0
  210. package/dist/lib/workspace/surfaces/flow.js +49 -0
  211. package/dist/lib/workspace/surfaces/flow.js.map +1 -0
  212. package/dist/lib/workspace/surfaces/index.d.ts +16 -0
  213. package/dist/lib/workspace/surfaces/index.d.ts.map +1 -0
  214. package/dist/lib/workspace/surfaces/index.js +16 -0
  215. package/dist/lib/workspace/surfaces/index.js.map +1 -0
  216. package/dist/lib/workspace/surfaces/portfolio.d.ts +16 -0
  217. package/dist/lib/workspace/surfaces/portfolio.d.ts.map +1 -0
  218. package/dist/lib/workspace/surfaces/portfolio.js +102 -0
  219. package/dist/lib/workspace/surfaces/portfolio.js.map +1 -0
  220. package/dist/lib/workspace/surfaces/service.d.ts +16 -0
  221. package/dist/lib/workspace/surfaces/service.d.ts.map +1 -0
  222. package/dist/lib/workspace/surfaces/service.js +45 -0
  223. package/dist/lib/workspace/surfaces/service.js.map +1 -0
  224. package/dist/lib/workspace/surfaces/shell.d.ts +15 -0
  225. package/dist/lib/workspace/surfaces/shell.d.ts.map +1 -0
  226. package/dist/lib/workspace/surfaces/shell.js +19 -0
  227. package/dist/lib/workspace/surfaces/shell.js.map +1 -0
  228. package/dist/lib/workspace/surfaces/telemetry.d.ts +16 -0
  229. package/dist/lib/workspace/surfaces/telemetry.d.ts.map +1 -0
  230. package/dist/lib/workspace/surfaces/telemetry.js +48 -0
  231. package/dist/lib/workspace/surfaces/telemetry.js.map +1 -0
  232. package/dist/lib/workspace/surfaces/topology.d.ts +15 -0
  233. package/dist/lib/workspace/surfaces/topology.d.ts.map +1 -0
  234. package/dist/lib/workspace/surfaces/topology.js +19 -0
  235. package/dist/lib/workspace/surfaces/topology.js.map +1 -0
  236. package/dist/lib/workspace/surfaces/training.d.ts +16 -0
  237. package/dist/lib/workspace/surfaces/training.d.ts.map +1 -0
  238. package/dist/lib/workspace/surfaces/training.js +22 -0
  239. package/dist/lib/workspace/surfaces/training.js.map +1 -0
  240. package/dist/lib/workspace/tmux-adapter.d.ts +27 -0
  241. package/dist/lib/workspace/tmux-adapter.d.ts.map +1 -0
  242. package/dist/lib/workspace/tmux-adapter.js +106 -0
  243. package/dist/lib/workspace/tmux-adapter.js.map +1 -0
  244. package/dist/mcp/context-hub-mcp.js +7 -24
  245. package/dist/mcp/context-hub-mcp.js.map +1 -1
  246. package/dist/types/flows.d.ts +2 -0
  247. package/dist/types/flows.d.ts.map +1 -1
  248. package/dist/types/ide.d.ts +49 -0
  249. package/dist/types/ide.d.ts.map +1 -0
  250. package/dist/types/ide.js +5 -0
  251. package/dist/types/ide.js.map +1 -0
  252. package/dist/types/platform-digest.d.ts +228 -0
  253. package/dist/types/platform-digest.d.ts.map +1 -0
  254. package/dist/types/platform-digest.js +5 -0
  255. package/dist/types/platform-digest.js.map +1 -0
  256. package/dist/types/telemetry-digest.d.ts +2 -0
  257. package/dist/types/telemetry-digest.d.ts.map +1 -1
  258. package/dist/utils/ensure-project.d.ts +1 -0
  259. package/dist/utils/ensure-project.d.ts.map +1 -1
  260. package/dist/utils/ensure-project.js +19 -7
  261. package/dist/utils/ensure-project.js.map +1 -1
  262. package/dist/utils/jfl-config.d.ts +1 -0
  263. package/dist/utils/jfl-config.d.ts.map +1 -1
  264. package/dist/utils/jfl-config.js +19 -1
  265. package/dist/utils/jfl-config.js.map +1 -1
  266. package/dist/utils/jfl-paths.d.ts +5 -0
  267. package/dist/utils/jfl-paths.d.ts.map +1 -1
  268. package/dist/utils/jfl-paths.js +25 -3
  269. package/dist/utils/jfl-paths.js.map +1 -1
  270. package/package.json +3 -2
  271. package/packages/pi/AGENTS.md +112 -0
  272. package/packages/pi/extensions/agent-grid.ts +191 -0
  273. package/packages/pi/extensions/agent-names.ts +178 -0
  274. package/packages/pi/extensions/autoresearch.ts +427 -0
  275. package/packages/pi/extensions/bookmarks.ts +85 -0
  276. package/packages/pi/extensions/context.ts +151 -0
  277. package/packages/pi/extensions/crm-tool.ts +61 -0
  278. package/packages/pi/extensions/eval-tool.ts +224 -0
  279. package/packages/pi/extensions/eval.ts +60 -0
  280. package/packages/pi/extensions/footer.ts +239 -0
  281. package/packages/pi/extensions/hud-tool.ts +145 -0
  282. package/packages/pi/extensions/index.ts +392 -0
  283. package/packages/pi/extensions/journal.ts +224 -0
  284. package/packages/pi/extensions/map-bridge.ts +178 -0
  285. package/packages/pi/extensions/memory-tool.ts +68 -0
  286. package/packages/pi/extensions/notifications.ts +73 -0
  287. package/packages/pi/extensions/peter-parker.ts +202 -0
  288. package/packages/pi/extensions/policy-head-tool.ts +276 -0
  289. package/packages/pi/extensions/portfolio-bridge.ts +90 -0
  290. package/packages/pi/extensions/session.ts +90 -0
  291. package/packages/pi/extensions/shortcuts.ts +259 -0
  292. package/packages/pi/extensions/stratus-bridge.ts +115 -0
  293. package/packages/pi/extensions/synopsis-tool.ts +83 -0
  294. package/packages/pi/extensions/tool-renderers.ts +352 -0
  295. package/packages/pi/extensions/training-buffer-tool.ts +368 -0
  296. package/packages/pi/extensions/types.ts +163 -0
  297. package/packages/pi/package-lock.json +346 -0
  298. package/packages/pi/package.json +44 -0
  299. package/packages/pi/skills/agent-browser/SKILL.md +116 -0
  300. package/packages/pi/skills/brand-architect/SKILL.md +240 -0
  301. package/packages/pi/skills/brand-architect/config.yaml +137 -0
  302. package/packages/pi/skills/campaign-hud/config.yaml +112 -0
  303. package/packages/pi/skills/content-creator/SKILL.md +294 -0
  304. package/packages/pi/skills/context/SKILL.md +65 -0
  305. package/packages/pi/skills/debug/MULTI_AGENT.md +360 -0
  306. package/packages/pi/skills/debug/SKILL.md +554 -0
  307. package/packages/pi/skills/end/SKILL.md +1782 -0
  308. package/packages/pi/skills/eval/SKILL.md +75 -0
  309. package/packages/pi/skills/fly-deploy/SKILL.md +676 -0
  310. package/packages/pi/skills/founder-video/SKILL.md +467 -0
  311. package/packages/pi/skills/hud/SKILL.md +160 -0
  312. package/packages/pi/skills/orchestrate/SKILL.md +74 -0
  313. package/packages/pi/skills/pi-agents/SKILL.md +78 -0
  314. package/packages/pi/skills/react-best-practices/AGENTS.md +2249 -0
  315. package/packages/pi/skills/react-best-practices/README.md +123 -0
  316. package/packages/pi/skills/react-best-practices/SKILL.md +125 -0
  317. package/packages/pi/skills/react-best-practices/metadata.json +15 -0
  318. package/packages/pi/skills/react-best-practices/rules/_sections.md +46 -0
  319. package/packages/pi/skills/react-best-practices/rules/_template.md +28 -0
  320. package/packages/pi/skills/react-best-practices/rules/advanced-event-handler-refs.md +55 -0
  321. package/packages/pi/skills/react-best-practices/rules/advanced-use-latest.md +49 -0
  322. package/packages/pi/skills/react-best-practices/rules/async-api-routes.md +38 -0
  323. package/packages/pi/skills/react-best-practices/rules/async-defer-await.md +80 -0
  324. package/packages/pi/skills/react-best-practices/rules/async-dependencies.md +36 -0
  325. package/packages/pi/skills/react-best-practices/rules/async-parallel.md +28 -0
  326. package/packages/pi/skills/react-best-practices/rules/async-suspense-boundaries.md +99 -0
  327. package/packages/pi/skills/react-best-practices/rules/bundle-barrel-imports.md +59 -0
  328. package/packages/pi/skills/react-best-practices/rules/bundle-conditional.md +31 -0
  329. package/packages/pi/skills/react-best-practices/rules/bundle-defer-third-party.md +49 -0
  330. package/packages/pi/skills/react-best-practices/rules/bundle-dynamic-imports.md +35 -0
  331. package/packages/pi/skills/react-best-practices/rules/bundle-preload.md +50 -0
  332. package/packages/pi/skills/react-best-practices/rules/client-event-listeners.md +74 -0
  333. package/packages/pi/skills/react-best-practices/rules/client-swr-dedup.md +56 -0
  334. package/packages/pi/skills/react-best-practices/rules/js-batch-dom-css.md +82 -0
  335. package/packages/pi/skills/react-best-practices/rules/js-cache-function-results.md +80 -0
  336. package/packages/pi/skills/react-best-practices/rules/js-cache-property-access.md +28 -0
  337. package/packages/pi/skills/react-best-practices/rules/js-cache-storage.md +70 -0
  338. package/packages/pi/skills/react-best-practices/rules/js-combine-iterations.md +32 -0
  339. package/packages/pi/skills/react-best-practices/rules/js-early-exit.md +50 -0
  340. package/packages/pi/skills/react-best-practices/rules/js-hoist-regexp.md +45 -0
  341. package/packages/pi/skills/react-best-practices/rules/js-index-maps.md +37 -0
  342. package/packages/pi/skills/react-best-practices/rules/js-length-check-first.md +49 -0
  343. package/packages/pi/skills/react-best-practices/rules/js-min-max-loop.md +82 -0
  344. package/packages/pi/skills/react-best-practices/rules/js-set-map-lookups.md +24 -0
  345. package/packages/pi/skills/react-best-practices/rules/js-tosorted-immutable.md +57 -0
  346. package/packages/pi/skills/react-best-practices/rules/rendering-activity.md +26 -0
  347. package/packages/pi/skills/react-best-practices/rules/rendering-animate-svg-wrapper.md +47 -0
  348. package/packages/pi/skills/react-best-practices/rules/rendering-conditional-render.md +40 -0
  349. package/packages/pi/skills/react-best-practices/rules/rendering-content-visibility.md +38 -0
  350. package/packages/pi/skills/react-best-practices/rules/rendering-hoist-jsx.md +46 -0
  351. package/packages/pi/skills/react-best-practices/rules/rendering-hydration-no-flicker.md +82 -0
  352. package/packages/pi/skills/react-best-practices/rules/rendering-svg-precision.md +28 -0
  353. package/packages/pi/skills/react-best-practices/rules/rerender-defer-reads.md +39 -0
  354. package/packages/pi/skills/react-best-practices/rules/rerender-dependencies.md +45 -0
  355. package/packages/pi/skills/react-best-practices/rules/rerender-derived-state.md +29 -0
  356. package/packages/pi/skills/react-best-practices/rules/rerender-functional-setstate.md +74 -0
  357. package/packages/pi/skills/react-best-practices/rules/rerender-lazy-state-init.md +58 -0
  358. package/packages/pi/skills/react-best-practices/rules/rerender-memo.md +44 -0
  359. package/packages/pi/skills/react-best-practices/rules/rerender-transitions.md +40 -0
  360. package/packages/pi/skills/react-best-practices/rules/server-after-nonblocking.md +73 -0
  361. package/packages/pi/skills/react-best-practices/rules/server-cache-lru.md +41 -0
  362. package/packages/pi/skills/react-best-practices/rules/server-cache-react.md +26 -0
  363. package/packages/pi/skills/react-best-practices/rules/server-parallel-fetching.md +79 -0
  364. package/packages/pi/skills/react-best-practices/rules/server-serialization.md +38 -0
  365. package/packages/pi/skills/remotion-best-practices/SKILL.md +43 -0
  366. package/packages/pi/skills/remotion-best-practices/rules/3d.md +86 -0
  367. package/packages/pi/skills/remotion-best-practices/rules/animations.md +29 -0
  368. package/packages/pi/skills/remotion-best-practices/rules/assets/charts-bar-chart.tsx +173 -0
  369. package/packages/pi/skills/remotion-best-practices/rules/assets/text-animations-typewriter.tsx +100 -0
  370. package/packages/pi/skills/remotion-best-practices/rules/assets/text-animations-word-highlight.tsx +108 -0
  371. package/packages/pi/skills/remotion-best-practices/rules/assets.md +78 -0
  372. package/packages/pi/skills/remotion-best-practices/rules/audio.md +172 -0
  373. package/packages/pi/skills/remotion-best-practices/rules/calculate-metadata.md +104 -0
  374. package/packages/pi/skills/remotion-best-practices/rules/can-decode.md +75 -0
  375. package/packages/pi/skills/remotion-best-practices/rules/charts.md +58 -0
  376. package/packages/pi/skills/remotion-best-practices/rules/compositions.md +146 -0
  377. package/packages/pi/skills/remotion-best-practices/rules/display-captions.md +126 -0
  378. package/packages/pi/skills/remotion-best-practices/rules/extract-frames.md +229 -0
  379. package/packages/pi/skills/remotion-best-practices/rules/fonts.md +152 -0
  380. package/packages/pi/skills/remotion-best-practices/rules/get-audio-duration.md +58 -0
  381. package/packages/pi/skills/remotion-best-practices/rules/get-video-dimensions.md +68 -0
  382. package/packages/pi/skills/remotion-best-practices/rules/get-video-duration.md +58 -0
  383. package/packages/pi/skills/remotion-best-practices/rules/gifs.md +138 -0
  384. package/packages/pi/skills/remotion-best-practices/rules/images.md +130 -0
  385. package/packages/pi/skills/remotion-best-practices/rules/import-srt-captions.md +67 -0
  386. package/packages/pi/skills/remotion-best-practices/rules/lottie.md +68 -0
  387. package/packages/pi/skills/remotion-best-practices/rules/measuring-dom-nodes.md +35 -0
  388. package/packages/pi/skills/remotion-best-practices/rules/measuring-text.md +143 -0
  389. package/packages/pi/skills/remotion-best-practices/rules/sequencing.md +106 -0
  390. package/packages/pi/skills/remotion-best-practices/rules/tailwind.md +11 -0
  391. package/packages/pi/skills/remotion-best-practices/rules/text-animations.md +20 -0
  392. package/packages/pi/skills/remotion-best-practices/rules/timing.md +179 -0
  393. package/packages/pi/skills/remotion-best-practices/rules/transcribe-captions.md +19 -0
  394. package/packages/pi/skills/remotion-best-practices/rules/transitions.md +122 -0
  395. package/packages/pi/skills/remotion-best-practices/rules/trimming.md +53 -0
  396. package/packages/pi/skills/remotion-best-practices/rules/videos.md +171 -0
  397. package/packages/pi/skills/search/SKILL.md +220 -0
  398. package/packages/pi/skills/spec/SKILL.md +377 -0
  399. package/packages/pi/skills/startup/SKILL.md +315 -0
  400. package/packages/pi/skills/web-architect/SKILL.md +309 -0
  401. package/packages/pi/skills/x-algorithm/SKILL.md +305 -0
  402. package/packages/pi/teams/dev-team.yaml +63 -0
  403. package/packages/pi/teams/gtm-team.yaml +79 -0
  404. package/packages/pi/themes/jfl.theme.json +76 -0
  405. package/packages/pi/tsconfig.json +21 -0
  406. package/scripts/collect-tuples.sh +124 -0
  407. package/scripts/destroy-fleet.sh +37 -0
  408. package/scripts/jfl-ide.sh +48 -0
  409. package/scripts/session/session-cleanup.sh +4 -11
  410. package/scripts/session/session-init.sh +6 -0
  411. package/scripts/session/session-sync.sh +25 -0
  412. package/scripts/setup-branch-protection.sh +106 -0
  413. package/scripts/spawn-fleet.sh +144 -0
  414. package/scripts/train-policy-head.py +434 -0
  415. package/scripts/vm-swarm/README.md +301 -0
  416. package/scripts/vm-swarm/collect-tuples.sh +331 -0
  417. package/scripts/vm-swarm/create-base-template.sh +339 -0
  418. package/scripts/vm-swarm/kill-fleet.sh +204 -0
  419. package/scripts/vm-swarm/monitor-fleet.sh +346 -0
  420. package/scripts/vm-swarm/spawn-fleet.sh +304 -0
  421. package/template/.github/workflows/jfl-eval.yml +105 -8
  422. package/template/.github/workflows/jfl-review.yml +4 -0
  423. package/template/scripts/session/session-end.sh +69 -6
  424. package/template/scripts/session/session-init.sh +55 -30
  425. package/template/scripts/session/session-lock.sh +464 -0
  426. package/template/templates/service-agent/workflows/jfl-eval.yml +19 -0
  427. package/dist/dashboard-static/assets/index-B6kRK9Rq.js +0 -116
  428. package/dist/dashboard-static/assets/index-BpdKJPLu.css +0 -1
@@ -0,0 +1,121 @@
1
+ (function(){const r=document.createElement("link").relList;if(r&&r.supports&&r.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))i(s);new MutationObserver(s=>{for(const o of s)if(o.type==="childList")for(const l of o.addedNodes)l.tagName==="LINK"&&l.rel==="modulepreload"&&i(l)}).observe(document,{childList:!0,subtree:!0});function n(s){const o={};return s.integrity&&(o.integrity=s.integrity),s.referrerPolicy&&(o.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?o.credentials="include":s.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function i(s){if(s.ep)return;s.ep=!0;const o=n(s);fetch(s.href,o)}})();var Ke,K,Lt,ke,mt,Gt,jt,Nt,ut,it,lt,He={},We=[],rr=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,Qe=Array.isArray;function ye(e,r){for(var n in r)e[n]=r[n];return e}function pt(e){e&&e.parentNode&&e.parentNode.removeChild(e)}function nr(e,r,n){var i,s,o,l={};for(o in r)o=="key"?i=r[o]:o=="ref"?s=r[o]:l[o]=r[o];if(arguments.length>2&&(l.children=arguments.length>3?Ke.call(arguments,2):n),typeof e=="function"&&e.defaultProps!=null)for(o in e.defaultProps)l[o]===void 0&&(l[o]=e.defaultProps[o]);return Xe(e,l,i,s,null)}function Xe(e,r,n,i,s){var o={type:e,props:r,key:n,ref:i,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:s??++Lt,__i:-1,__u:0};return s==null&&K.vnode!=null&&K.vnode(o),o}function ae(e){return e.children}function Be(e,r){this.props=e,this.context=r}function Ce(e,r){if(r==null)return e.__?Ce(e.__,e.__i+1):null;for(var n;r<e.__k.length;r++)if((n=e.__k[r])!=null&&n.__e!=null)return n.__e;return typeof e.type=="function"?Ce(e):null}function sr(e){if(e.__P&&e.__d){var r=e.__v,n=r.__e,i=[],s=[],o=ye({},r);o.__v=r.__v+1,K.vnode&&K.vnode(o),ht(e.__P,o,r,e.__n,e.__P.namespaceURI,32&r.__u?[n]:null,i,n??Ce(r),!!(32&r.__u),s),o.__v=r.__v,o.__.__k[o.__i]=o,Bt(i,o,s),r.__e=r.__=null,o.__e!=n&&Ot(o)}}function Ot(e){if((e=e.__)!=null&&e.__c!=null)return e.__e=e.__c.base=null,e.__k.some(function(r){if(r!=null&&r.__e!=null)return e.__e=e.__c.base=r.__e}),Ot(e)}function xt(e){(!e.__d&&(e.__d=!0)&&ke.push(e)&&!Ve.__r++||mt!=K.debounceRendering)&&((mt=K.debounceRendering)||Gt)(Ve)}function Ve(){for(var e,r=1;ke.length;)ke.length>r&&ke.sort(jt),e=ke.shift(),r=ke.length,sr(e);Ve.__r=0}function Ut(e,r,n,i,s,o,l,f,h,u,v){var d,y,b,x,E,w,R,_=i&&i.__k||We,F=r.length;for(h=or(n,r,_,h,F),d=0;d<F;d++)(b=n.__k[d])!=null&&(y=b.__i!=-1&&_[b.__i]||He,b.__i=d,w=ht(e,b,y,s,o,l,f,h,u,v),x=b.__e,b.ref&&y.ref!=b.ref&&(y.ref&&ft(y.ref,null,b),v.push(b.ref,b.__c||x,b)),E==null&&x!=null&&(E=x),(R=!!(4&b.__u))||y.__k===b.__k?h=Xt(b,h,e,R):typeof b.type=="function"&&w!==void 0?h=w:x&&(h=x.nextSibling),b.__u&=-7);return n.__e=E,h}function or(e,r,n,i,s){var o,l,f,h,u,v=n.length,d=v,y=0;for(e.__k=new Array(s),o=0;o<s;o++)(l=r[o])!=null&&typeof l!="boolean"&&typeof l!="function"?(typeof l=="string"||typeof l=="number"||typeof l=="bigint"||l.constructor==String?l=e.__k[o]=Xe(null,l,null,null,null):Qe(l)?l=e.__k[o]=Xe(ae,{children:l},null,null,null):l.constructor===void 0&&l.__b>0?l=e.__k[o]=Xe(l.type,l.props,l.key,l.ref?l.ref:null,l.__v):e.__k[o]=l,h=o+y,l.__=e,l.__b=e.__b+1,f=null,(u=l.__i=ir(l,n,h,d))!=-1&&(d--,(f=n[u])&&(f.__u|=2)),f==null||f.__v==null?(u==-1&&(s>v?y--:s<v&&y++),typeof l.type!="function"&&(l.__u|=4)):u!=h&&(u==h-1?y--:u==h+1?y++:(u>h?y--:y++,l.__u|=4))):e.__k[o]=null;if(d)for(o=0;o<v;o++)(f=n[o])!=null&&(2&f.__u)==0&&(f.__e==i&&(i=Ce(f)),zt(f,f));return i}function Xt(e,r,n,i){var s,o;if(typeof e.type=="function"){for(s=e.__k,o=0;s&&o<s.length;o++)s[o]&&(s[o].__=e,r=Xt(s[o],r,n,i));return r}e.__e!=r&&(i&&(r&&e.type&&!r.parentNode&&(r=Ce(e)),n.insertBefore(e.__e,r||null)),r=e.__e);do r=r&&r.nextSibling;while(r!=null&&r.nodeType==8);return r}function ir(e,r,n,i){var s,o,l,f=e.key,h=e.type,u=r[n],v=u!=null&&(2&u.__u)==0;if(u===null&&f==null||v&&f==u.key&&h==u.type)return n;if(i>(v?1:0)){for(s=n-1,o=n+1;s>=0||o<r.length;)if((u=r[l=s>=0?s--:o++])!=null&&(2&u.__u)==0&&f==u.key&&h==u.type)return l}return-1}function vt(e,r,n){r[0]=="-"?e.setProperty(r,n??""):e[r]=n==null?"":typeof n!="number"||rr.test(r)?n:n+"px"}function Pe(e,r,n,i,s){var o,l;e:if(r=="style")if(typeof n=="string")e.style.cssText=n;else{if(typeof i=="string"&&(e.style.cssText=i=""),i)for(r in i)n&&r in n||vt(e.style,r,"");if(n)for(r in n)i&&n[r]==i[r]||vt(e.style,r,n[r])}else if(r[0]=="o"&&r[1]=="n")o=r!=(r=r.replace(Nt,"$1")),l=r.toLowerCase(),r=l in e||r=="onFocusOut"||r=="onFocusIn"?l.slice(2):r.slice(2),e.l||(e.l={}),e.l[r+o]=n,n?i?n.u=i.u:(n.u=ut,e.addEventListener(r,o?lt:it,o)):e.removeEventListener(r,o?lt:it,o);else{if(s=="http://www.w3.org/2000/svg")r=r.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if(r!="width"&&r!="height"&&r!="href"&&r!="list"&&r!="form"&&r!="tabIndex"&&r!="download"&&r!="rowSpan"&&r!="colSpan"&&r!="role"&&r!="popover"&&r in e)try{e[r]=n??"";break e}catch{}typeof n=="function"||(n==null||n===!1&&r[4]!="-"?e.removeAttribute(r):e.setAttribute(r,r=="popover"&&n==1?"":n))}}function bt(e){return function(r){if(this.l){var n=this.l[r.type+e];if(r.t==null)r.t=ut++;else if(r.t<n.u)return;return n(K.event?K.event(r):r)}}}function ht(e,r,n,i,s,o,l,f,h,u){var v,d,y,b,x,E,w,R,_,F,k,p,g,D,c,S=r.type;if(r.constructor!==void 0)return null;128&n.__u&&(h=!!(32&n.__u),o=[f=r.__e=n.__e]),(v=K.__b)&&v(r);e:if(typeof S=="function")try{if(R=r.props,_="prototype"in S&&S.prototype.render,F=(v=S.contextType)&&i[v.__c],k=v?F?F.props.value:v.__:i,n.__c?w=(d=r.__c=n.__c).__=d.__E:(_?r.__c=d=new S(R,k):(r.__c=d=new Be(R,k),d.constructor=S,d.render=ar),F&&F.sub(d),d.state||(d.state={}),d.__n=i,y=d.__d=!0,d.__h=[],d._sb=[]),_&&d.__s==null&&(d.__s=d.state),_&&S.getDerivedStateFromProps!=null&&(d.__s==d.state&&(d.__s=ye({},d.__s)),ye(d.__s,S.getDerivedStateFromProps(R,d.__s))),b=d.props,x=d.state,d.__v=r,y)_&&S.getDerivedStateFromProps==null&&d.componentWillMount!=null&&d.componentWillMount(),_&&d.componentDidMount!=null&&d.__h.push(d.componentDidMount);else{if(_&&S.getDerivedStateFromProps==null&&R!==b&&d.componentWillReceiveProps!=null&&d.componentWillReceiveProps(R,k),r.__v==n.__v||!d.__e&&d.shouldComponentUpdate!=null&&d.shouldComponentUpdate(R,d.__s,k)===!1){r.__v!=n.__v&&(d.props=R,d.state=d.__s,d.__d=!1),r.__e=n.__e,r.__k=n.__k,r.__k.some(function(C){C&&(C.__=r)}),We.push.apply(d.__h,d._sb),d._sb=[],d.__h.length&&l.push(d);break e}d.componentWillUpdate!=null&&d.componentWillUpdate(R,d.__s,k),_&&d.componentDidUpdate!=null&&d.__h.push(function(){d.componentDidUpdate(b,x,E)})}if(d.context=k,d.props=R,d.__P=e,d.__e=!1,p=K.__r,g=0,_)d.state=d.__s,d.__d=!1,p&&p(r),v=d.render(d.props,d.state,d.context),We.push.apply(d.__h,d._sb),d._sb=[];else do d.__d=!1,p&&p(r),v=d.render(d.props,d.state,d.context),d.state=d.__s;while(d.__d&&++g<25);d.state=d.__s,d.getChildContext!=null&&(i=ye(ye({},i),d.getChildContext())),_&&!y&&d.getSnapshotBeforeUpdate!=null&&(E=d.getSnapshotBeforeUpdate(b,x)),D=v!=null&&v.type===ae&&v.key==null?Yt(v.props.children):v,f=Ut(e,Qe(D)?D:[D],r,n,i,s,o,l,f,h,u),d.base=r.__e,r.__u&=-161,d.__h.length&&l.push(d),w&&(d.__E=d.__=null)}catch(C){if(r.__v=null,h||o!=null)if(C.then){for(r.__u|=h?160:128;f&&f.nodeType==8&&f.nextSibling;)f=f.nextSibling;o[o.indexOf(f)]=null,r.__e=f}else{for(c=o.length;c--;)pt(o[c]);at(r)}else r.__e=n.__e,r.__k=n.__k,C.then||at(r);K.__e(C,r,n)}else o==null&&r.__v==n.__v?(r.__k=n.__k,r.__e=n.__e):f=r.__e=lr(n.__e,r,n,i,s,o,l,h,u);return(v=K.diffed)&&v(r),128&r.__u?void 0:f}function at(e){e&&(e.__c&&(e.__c.__e=!0),e.__k&&e.__k.some(at))}function Bt(e,r,n){for(var i=0;i<n.length;i++)ft(n[i],n[++i],n[++i]);K.__c&&K.__c(r,e),e.some(function(s){try{e=s.__h,s.__h=[],e.some(function(o){o.call(s)})}catch(o){K.__e(o,s.__v)}})}function Yt(e){return typeof e!="object"||e==null||e.__b>0?e:Qe(e)?e.map(Yt):ye({},e)}function lr(e,r,n,i,s,o,l,f,h){var u,v,d,y,b,x,E,w=n.props||He,R=r.props,_=r.type;if(_=="svg"?s="http://www.w3.org/2000/svg":_=="math"?s="http://www.w3.org/1998/Math/MathML":s||(s="http://www.w3.org/1999/xhtml"),o!=null){for(u=0;u<o.length;u++)if((b=o[u])&&"setAttribute"in b==!!_&&(_?b.localName==_:b.nodeType==3)){e=b,o[u]=null;break}}if(e==null){if(_==null)return document.createTextNode(R);e=document.createElementNS(s,_,R.is&&R),f&&(K.__m&&K.__m(r,o),f=!1),o=null}if(_==null)w===R||f&&e.data==R||(e.data=R);else{if(o=o&&Ke.call(e.childNodes),!f&&o!=null)for(w={},u=0;u<e.attributes.length;u++)w[(b=e.attributes[u]).name]=b.value;for(u in w)b=w[u],u=="dangerouslySetInnerHTML"?d=b:u=="children"||u in R||u=="value"&&"defaultValue"in R||u=="checked"&&"defaultChecked"in R||Pe(e,u,null,b,s);for(u in R)b=R[u],u=="children"?y=b:u=="dangerouslySetInnerHTML"?v=b:u=="value"?x=b:u=="checked"?E=b:f&&typeof b!="function"||w[u]===b||Pe(e,u,b,w[u],s);if(v)f||d&&(v.__html==d.__html||v.__html==e.innerHTML)||(e.innerHTML=v.__html),r.__k=[];else if(d&&(e.innerHTML=""),Ut(r.type=="template"?e.content:e,Qe(y)?y:[y],r,n,i,_=="foreignObject"?"http://www.w3.org/1999/xhtml":s,o,l,o?o[0]:n.__k&&Ce(n,0),f,h),o!=null)for(u=o.length;u--;)pt(o[u]);f||(u="value",_=="progress"&&x==null?e.removeAttribute("value"):x!=null&&(x!==e[u]||_=="progress"&&!x||_=="option"&&x!=w[u])&&Pe(e,u,x,w[u],s),u="checked",E!=null&&E!=e[u]&&Pe(e,u,E,w[u],s))}return e}function ft(e,r,n){try{if(typeof e=="function"){var i=typeof e.__u=="function";i&&e.__u(),i&&r==null||(e.__u=e(r))}else e.current=r}catch(s){K.__e(s,n)}}function zt(e,r,n){var i,s;if(K.unmount&&K.unmount(e),(i=e.ref)&&(i.current&&i.current!=e.__e||ft(i,null,r)),(i=e.__c)!=null){if(i.componentWillUnmount)try{i.componentWillUnmount()}catch(o){K.__e(o,r)}i.base=i.__P=null}if(i=e.__k)for(s=0;s<i.length;s++)i[s]&&zt(i[s],r,n||typeof e.type!="function");n||pt(e.__e),e.__c=e.__=e.__e=void 0}function ar(e,r,n){return this.constructor(e,n)}function cr(e,r,n){var i,s,o,l;r==document&&(r=document.documentElement),K.__&&K.__(e,r),s=(i=!1)?null:r.__k,o=[],l=[],ht(r,e=r.__k=nr(ae,null,[e]),s||He,He,r.namespaceURI,s?null:r.firstChild?Ke.call(r.childNodes):null,o,s?s.__e:r.firstChild,i,l),Bt(o,e,l)}Ke=We.slice,K={__e:function(e,r,n,i){for(var s,o,l;r=r.__;)if((s=r.__c)&&!s.__)try{if((o=s.constructor)&&o.getDerivedStateFromError!=null&&(s.setState(o.getDerivedStateFromError(e)),l=s.__d),s.componentDidCatch!=null&&(s.componentDidCatch(e,i||{}),l=s.__d),l)return s.__E=s}catch(f){e=f}throw e}},Lt=0,Be.prototype.setState=function(e,r){var n;n=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=ye({},this.state),typeof e=="function"&&(e=e(ye({},n),this.props)),e&&ye(n,e),e!=null&&this.__v&&(r&&this._sb.push(r),xt(this))},Be.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),xt(this))},Be.prototype.render=ae,ke=[],Gt=typeof Promise=="function"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,jt=function(e,r){return e.__v.__b-r.__v.__b},Ve.__r=0,Nt=/(PointerCapture)$|Capture$/i,ut=0,it=bt(!1),lt=bt(!0);var dr=0;function t(e,r,n,i,s,o){r||(r={});var l,f,h=r;if("ref"in h)for(f in h={},r)f=="ref"?l=r[f]:h[f]=r[f];var u={type:e,props:h,key:n,ref:l,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--dr,__i:-1,__u:0,__source:s,__self:o};if(typeof e=="function"&&(l=e.defaultProps))for(f in l)h[f]===void 0&&(h[f]=l[f]);return K.vnode&&K.vnode(u),u}var Re,te,et,yt,$e=0,Ht=[],ne=K,_t=ne.__b,wt=ne.__r,kt=ne.diffed,St=ne.__c,Ct=ne.unmount,Mt=ne.__;function gt(e,r){ne.__h&&ne.__h(te,e,$e||r),$e=0;var n=te.__H||(te.__H={__:[],__h:[]});return e>=n.__.length&&n.__.push({}),n.__[e]}function j(e){return $e=1,ur(Vt,e)}function ur(e,r,n){var i=gt(Re++,2);if(i.t=e,!i.__c&&(i.__=[Vt(void 0,r),function(f){var h=i.__N?i.__N[0]:i.__[0],u=i.t(h,f);h!==u&&(i.__N=[u,i.__[1]],i.__c.setState({}))}],i.__c=te,!te.__f)){var s=function(f,h,u){if(!i.__c.__H)return!0;var v=i.__c.__H.__.filter(function(y){return y.__c});if(v.every(function(y){return!y.__N}))return!o||o.call(this,f,h,u);var d=i.__c.props!==f;return v.some(function(y){if(y.__N){var b=y.__[0];y.__=y.__N,y.__N=void 0,b!==y.__[0]&&(d=!0)}}),o&&o.call(this,f,h,u)||d};te.__f=!0;var o=te.shouldComponentUpdate,l=te.componentWillUpdate;te.componentWillUpdate=function(f,h,u){if(this.__e){var v=o;o=void 0,s(f,h,u),o=v}l&&l.call(this,f,h,u)},te.shouldComponentUpdate=s}return i.__N||i.__}function ve(e,r){var n=gt(Re++,3);!ne.__s&&Wt(n.__H,r)&&(n.__=e,n.u=r,te.__H.__h.push(n))}function fe(e){return $e=5,qe(function(){return{current:e}},[])}function qe(e,r){var n=gt(Re++,7);return Wt(n.__H,r)&&(n.__=e(),n.__H=r,n.__h=e),n.__}function Fe(e,r){return $e=8,qe(function(){return e},r)}function pr(){for(var e;e=Ht.shift();){var r=e.__H;if(e.__P&&r)try{r.__h.some(Ye),r.__h.some(ct),r.__h=[]}catch(n){r.__h=[],ne.__e(n,e.__v)}}}ne.__b=function(e){te=null,_t&&_t(e)},ne.__=function(e,r){e&&r.__k&&r.__k.__m&&(e.__m=r.__k.__m),Mt&&Mt(e,r)},ne.__r=function(e){wt&&wt(e),Re=0;var r=(te=e.__c).__H;r&&(et===te?(r.__h=[],te.__h=[],r.__.some(function(n){n.__N&&(n.__=n.__N),n.u=n.__N=void 0})):(r.__h.some(Ye),r.__h.some(ct),r.__h=[],Re=0)),et=te},ne.diffed=function(e){kt&&kt(e);var r=e.__c;r&&r.__H&&(r.__H.__h.length&&(Ht.push(r)!==1&&yt===ne.requestAnimationFrame||((yt=ne.requestAnimationFrame)||hr)(pr)),r.__H.__.some(function(n){n.u&&(n.__H=n.u),n.u=void 0})),et=te=null},ne.__c=function(e,r){r.some(function(n){try{n.__h.some(Ye),n.__h=n.__h.filter(function(i){return!i.__||ct(i)})}catch(i){r.some(function(s){s.__h&&(s.__h=[])}),r=[],ne.__e(i,n.__v)}}),St&&St(e,r)},ne.unmount=function(e){Ct&&Ct(e);var r,n=e.__c;n&&n.__H&&(n.__H.__.some(function(i){try{Ye(i)}catch(s){r=s}}),n.__H=void 0,r&&ne.__e(r,n.__v))};var Tt=typeof requestAnimationFrame=="function";function hr(e){var r,n=function(){clearTimeout(i),Tt&&cancelAnimationFrame(r),setTimeout(e)},i=setTimeout(n,35);Tt&&(r=requestAnimationFrame(n))}function Ye(e){var r=te,n=e.__c;typeof n=="function"&&(e.__c=void 0,n()),te=r}function ct(e){var r=te;e.__c=e.__(),te=r}function Wt(e,r){return!e||e.length!==r.length||r.some(function(n,i){return n!==e[i]})}function Vt(e,r){return typeof r=="function"?r(e):r}const fr=()=>{const r=new URLSearchParams(window.location.search).get("token");if(r){localStorage.setItem("jfl-token",r);const n=new URL(window.location.href);return n.searchParams.delete("token"),window.history.replaceState({},"",n.toString()),r}return localStorage.getItem("jfl-token")||""};let tt=null;function Ae(){return tt||(tt=fr()),tt}async function W(e,r={}){const n={"Content-Type":"application/json",...Ae()?{Authorization:`Bearer ${Ae()}`}:{},...r.headers||{}},i=await fetch(e,{...r,headers:n});if(i.status===401)throw new Error("Unauthorized");if(!i.ok)throw new Error(`API error: ${i.status}`);return i.json()}function qt(e,r,n){const i=`${e}${e.includes("?")?"&":"?"}token=${Ae()}`,s=new EventSource(i);return s.onmessage=o=>{try{r(JSON.parse(o.data))}catch{}},s.onerror=o=>n==null?void 0:n(o),()=>s.close()}async function gr(e,r,n,i,s,o){var d;const l={"Content-Type":"application/json",...Ae()?{Authorization:`Bearer ${Ae()}`}:{}},f=await fetch("/api/chat",{method:"POST",headers:l,body:JSON.stringify({message:e,history:r})});if(!f.ok){o(`API error: ${f.status}`);return}const h=(d=f.body)==null?void 0:d.getReader();if(!h){o("No response body");return}const u=new TextDecoder;let v="";for(;;){const{done:y,value:b}=await h.read();if(y)break;v+=u.decode(b,{stream:!0});const x=v.split(`
2
+ `);v=x.pop()||"";for(const E of x){if(!E.startsWith("data: "))continue;const w=E.slice(6);if(w==="[DONE]"){s();return}try{const R=JSON.parse(w);R.sources&&n(R.sources),R.delta&&i(R.delta)}catch{}}}s()}const U={status:()=>W("/api/context/status"),events:(e=50,r)=>{let n=`/api/events?limit=${e}`;return r&&(n+=`&pattern=${encodeURIComponent(r)}`),W(n)},leaderboard:()=>W("/api/eval/leaderboard"),trajectory:(e,r="composite")=>W(`/api/eval/trajectory?agent=${encodeURIComponent(e)}&metric=${r}`),journal:()=>W("/api/context",{method:"POST",body:JSON.stringify({})}).then(e=>e.items||[]),search:e=>W(`/api/context/search?q=${encodeURIComponent(e)}`),services:()=>W("/api/services"),projects:()=>W("/api/projects"),flows:()=>W("/api/flows"),flowExecutions:()=>W("/api/flows/executions"),approveFlow:(e,r)=>W(`/api/flows/${encodeURIComponent(e)}/approve`,{method:"POST",body:JSON.stringify({trigger_event_id:r})}),memoryStatus:()=>W("/api/memory/status"),memorySearch:(e,r)=>{const n={query:e};return r&&r!=="all"&&(n.type=r),W("/api/memory/search",{method:"POST",body:JSON.stringify(n)})},publishEvent:(e,r,n="dashboard")=>W("/api/events",{method:"POST",body:JSON.stringify({type:e,source:n,data:r})}),toggleFlow:(e,r)=>W(`/api/flows/${encodeURIComponent(e)}/toggle`,{method:"POST",body:JSON.stringify({enabled:r})}),spawnAction:(e,r,n)=>W("/api/actions/spawn",{method:"POST",body:JSON.stringify({command:e,args:r,event_type:n})}),predictions:()=>W("/api/eval/predictions"),synopsis:(e=24)=>W(`/api/synopsis?hours=${e}`),telemetryDigest:(e=168)=>W(`/api/telemetry/digest?hours=${e}`),telemetryAgentStatus:()=>W("/api/telemetry/agent"),telemetryAgentRun:()=>W("/api/telemetry/agent/run",{method:"POST"}),childSynopsis:async(e,r=24)=>{try{const n=await fetch(`http://localhost:${e}/api/synopsis?hours=${r}`);return n.ok?n.json():null}catch{return null}},topology:()=>W("/api/v1/topology"),autoresearchStatus:()=>W("/api/v1/autoresearch/status"),evalEntries:(e=100)=>W(`/api/eval/entries?limit=${e}`),rlAgents:()=>W("/api/v1/agents"),rlExperiments:e=>W(e?`/api/v1/experiments?agent=${e}`:"/api/v1/experiments"),rlSessions:()=>W("/api/v1/sessions"),productContext:()=>W("/api/v1/product-context"),findings:(e=!1,r=!1)=>{const n=new URLSearchParams;e&&n.set("refresh","true"),r&&n.set("include_dismissed","true");const i=n.toString();return W(`/api/v1/findings${i?`?${i}`:""}`)},dismissFinding:e=>W(`/api/v1/findings/${encodeURIComponent(e)}/dismiss`,{method:"POST"}),spawnFindingAgent:e=>W(`/api/v1/findings/${encodeURIComponent(e)}/spawn`,{method:"POST"}),analyzeFindings:()=>W("/api/v1/findings/analyze",{method:"POST"})};function _e({label:e,value:r,sub:n,trend:i,icon:s}){return t("div",{class:"bg-card rounded-lg border border-border p-4 animate-fade-in",children:[t("div",{class:"flex items-center justify-between mb-2",children:[t("span",{class:"text-xs text-muted-foreground uppercase tracking-wider",children:e}),s&&t("span",{class:"text-muted-foreground",children:s})]}),t("div",{class:"text-2xl font-semibold mono",children:r}),n&&t("div",{class:`text-xs mt-1 ${i==="up"?"text-success":i==="down"?"text-destructive":"text-muted-foreground"}`,children:n})]})}function Je({data:e,width:r=120,height:n=32,color:i="var(--success)",className:s=""}){if(!e.length)return null;const o=Math.min(...e),f=Math.max(...e)-o||1,h=2,u=e.map((v,d)=>{const y=h+d/(e.length-1||1)*(r-h*2),b=n-h-(v-o)/f*(n-h*2);return`${y},${b}`}).join(" ");return t("svg",{width:r,height:n,class:s,viewBox:`0 0 ${r} ${n}`,children:[t("polyline",{points:u,fill:"none",stroke:i,"stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"}),t("circle",{cx:parseFloat(u.split(" ").pop().split(",")[0]),cy:parseFloat(u.split(" ").pop().split(",")[1]),r:"2.5",fill:i})]})}function J(e,r,n=[]){const[i,s]=j(null),[o,l]=j(!0),[f,h]=j(null),u=fe(),v=Fe(()=>{e().then(d=>{s(d),h(null),l(!1)}).catch(d=>{h(d.message),l(!1)})},n);return ve(()=>(v(),u.current=setInterval(v,r),()=>clearInterval(u.current)),[v,r]),{data:i,loading:o,error:f,refetch:v}}function Jt(e,r){const[n,i]=j(!1);return ve(()=>{const s=localStorage.getItem("jfl-token")||"",o=`${e}${e.includes("?")?"&":"?"}token=${s}`,l=new EventSource(o);return l.onopen=()=>i(!0),l.onmessage=f=>{try{r(JSON.parse(f.data))}catch{}},l.onerror=()=>i(!1),()=>l.close()},[e]),{connected:n}}function P(...e){return e.filter(Boolean).join(" ")}function oe(e){const r=Date.now()-new Date(e).getTime(),n=Math.floor(r/1e3);if(n<60)return`${n}s ago`;const i=Math.floor(n/60);if(i<60)return`${i}m ago`;const s=Math.floor(i/60);return s<24?`${s}h ago`:`${Math.floor(s/24)}d ago`}const mr={ok:"bg-success",active:"bg-success",error:"bg-destructive",down:"bg-destructive",warning:"bg-warning",idle:"bg-muted-foreground"};function Kt({status:e,label:r,pulse:n=!0}){return t("span",{class:"inline-flex items-center gap-1.5",children:[t("span",{class:P("inline-block w-2 h-2 rounded-full",mr[e]||"bg-muted-foreground",n&&(e==="ok"||e==="active")&&"animate-pulse-dot")}),r&&t("span",{class:"text-xs text-muted-foreground",children:r})]})}const Q={card:"rgba(24, 24, 28, 0.95)",border:"rgba(60, 60, 60, 0.25)",text:"#f5f5f5",textMuted:"#8b8b8b",textDim:"#5a5a5a",data:"#4a7dfc",rl:"#a855f7",success:"#34d399",alert:"#f87171",orange:"#FF5722"};function Et(e){return e.includes("error")||e.includes("fail")||e.includes("crash")||e.includes("regression")?"alert":e.includes("scored")||e.includes("success")||e.includes("complete")||e.includes("pass")?"success":e.includes("peter")||e.includes("rollout")||e.includes("experiment")||e.includes("rl:")?"rl":"data"}function rt(e){switch(e){case"alert":return Q.alert;case"success":return Q.success;case"rl":return Q.rl;default:return Q.data}}function xr(e){return!(e.type.startsWith("session:")||e.type.startsWith("hook:")||e.type==="heartbeat")}function vr(e){const r=e.source||"unknown";let n="system";const i=e.type.toLowerCase();return i.includes("eval:")||i.includes(":scored")?n=r.includes("eval")?"peter-parker":"eval-engine":i.includes("telemetry:")?n="peter-parker":i.includes("peter:")?i.includes("rollout")?n="stratus":i.includes("task")?n="eval-engine":n="agents":i.includes("stratus:")?n="eval-engine":i.includes("flow:")&&(n="flow-engine"),{source:r,destination:n}}function br(e){const r=e.data||{};if(e.type==="eval:scored"){const n=r.agent||"agent",i=typeof r.composite=="number"?r.composite.toFixed(4):"—",s=typeof r.delta=="number"?r.delta>=0?`+${r.delta.toFixed(4)}`:r.delta.toFixed(4):null;return s?`${n} scored ${i} (${s})`:`${n} scored ${i}`}return e.type.includes("task-completed")?r.description||r.title||"Task completed":e.type.includes("insight")?r.summary||r.insight||"Insight generated":e.type.includes("flow:triggered")?`Flow "${r.flow||r.name||"flow"}" triggered`:e.type.includes("rollout")?r.description||"Rollout initiated":e.type.includes("regression")?r.message||"Regression detected":r.title||r.message||r.description||e.type.split(":").pop()||e.type}function yr({events:e,windowMs:r=6e4,buckets:n=12}){const i=Date.now(),s=r/n,o=Array(n).fill(0);for(const v of e){const d=i-new Date(v.ts).getTime();if(d<r){const y=Math.floor(d/s);y<n&&o[n-1-y]++}}const l=Math.max(...o,1),f=80,h=20,u=f/n-1;return t("svg",{width:f,height:h,class:"shrink-0",children:[o.map((v,d)=>{const y=v/l*(h-4),b=d*(u+1),x=h-y-2;return t("rect",{x:b,y:x,width:u,height:y,fill:Q.orange,opacity:.3+v/l*.7,rx:"1"},d)}),t("rect",{x:(n-1)*(u+1),y:h-o[n-1]/l*(h-4)-2,width:u,height:o[n-1]/l*(h-4),fill:Q.orange,rx:"1",children:t("animate",{attributeName:"opacity",values:"1;0.5;1",dur:"1s",repeatCount:"indefinite"})})]})}function _r({events:e,maxEvents:r=50,useSSE:n=!0,collapsed:i,onToggleCollapse:s,className:o}){const[l,f]=j([]),[h,u]=j(!1),[v,d]=j(!1),y=fe(null),b=fe(!0),x=i??h,E=s??u,R=(e??l).filter(xr);ve(()=>{if(!n||e)return;const p=qt("/api/events/stream",g=>{d(!0);const D=g;f(c=>[D,...c].slice(0,r))},()=>d(!1));return()=>p()},[n,e,r]),ve(()=>{b.current&&y.current&&!x&&(y.current.scrollTop=0)},[R.length,x]);const _=Fe(()=>{y.current&&(b.current=y.current.scrollTop<10)},[]),F=R.length,k=R.filter(p=>Date.now()-new Date(p.ts).getTime()<6e4).length;return t("div",{class:P("rounded-lg overflow-hidden",o),style:{background:Q.card,border:`1px solid ${Q.border}`,backdropFilter:"blur(12px)"},children:[t("button",{onClick:()=>E(!x),class:"w-full flex items-center justify-between px-4 py-2.5 transition-colors",style:{background:"transparent",border:"none",borderBottom:x?"none":`1px solid ${Q.border}`},children:[t("div",{class:"flex items-center gap-3",children:[t("div",{class:"flex items-center gap-2",children:[t("span",{class:"w-2 h-2 rounded-full",style:{backgroundColor:v?Q.success:Q.textDim,boxShadow:v?`0 0 8px ${Q.success}`:"none"}}),t("span",{class:"text-xs font-semibold uppercase tracking-wider",style:{color:Q.text},children:"Flow Log"})]}),t("span",{class:"text-[10px] mono px-2 py-0.5 rounded-full",style:{background:`${Q.orange}15`,color:Q.orange,border:`1px solid ${Q.orange}25`},children:[k,"/min"]})]}),t("div",{class:"flex items-center gap-4",children:[t(yr,{events:R}),t("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:Q.textMuted,"stroke-width":"2",style:{transform:x?"rotate(0deg)":"rotate(180deg)",transition:"transform 0.2s ease"},children:t("path",{d:"M6 9l6 6 6-6"})})]})]}),!x&&t("div",{ref:y,onScroll:_,class:"overflow-y-auto animate-fade-in",style:{maxHeight:"240px"},children:R.length===0?t("div",{class:"px-4 py-6 text-center",children:t("span",{class:"text-xs",style:{color:Q.textMuted},children:v?"Waiting for events...":"Connecting to event stream..."})}):t("div",{class:"divide-y",style:{borderColor:`${Q.border}`},children:R.slice(0,20).map((p,g)=>{const D=Et(p.type),c=rt(D),{source:S,destination:C}=vr(p),T=br(p);return t("div",{class:"px-4 py-2 flex items-start gap-3 transition-colors hover:bg-white/[0.02]",style:{animation:g===0?"fade-in 0.2s ease":void 0,borderColor:Q.border},children:[t("span",{class:"text-[9px] mono shrink-0 w-12 mt-0.5",style:{color:Q.textDim},children:oe(p.ts)}),t("div",{class:"flex items-center gap-1.5 shrink-0 min-w-[140px]",children:[t("span",{class:"text-[9px] mono truncate max-w-[50px]",style:{color:Q.textMuted},children:S.split("-")[0]}),t("svg",{width:"14",height:"8",viewBox:"0 0 14 8",class:"shrink-0",children:t("path",{d:"M0 4h10M8 1l3 3-3 3",fill:"none",stroke:c,"stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round"})}),t("span",{class:"text-[9px] mono truncate max-w-[50px]",style:{color:Q.textMuted},children:C.split("-")[0]})]}),t("span",{class:"text-[8px] mono px-1.5 py-0.5 rounded shrink-0 uppercase tracking-wider",style:{background:`${c}18`,color:c,border:`1px solid ${c}30`},children:D}),t("span",{class:"text-[10px] truncate flex-1",style:{color:Q.text},children:T})]},p.id||`${p.ts}-${g}`)})})}),x&&F>0&&t("div",{class:"px-4 py-1.5 flex items-center justify-between",children:[t("span",{class:"text-[9px] mono",style:{color:Q.textDim},children:[F," events buffered"]}),t("div",{class:"flex gap-1",children:["data","rl","success","alert"].map(p=>{const g=R.filter(D=>Et(D.type)===p).length;return g===0?null:t("span",{class:"text-[8px] mono px-1 rounded",style:{background:`${rt(p)}15`,color:rt(p)},children:g},p)})})]})]})}const ue={border:"rgba(60, 60, 60, 0.25)",text:"#f5f5f5",textMuted:"#8b8b8b",textDim:"#5a5a5a",success:"#34d399",destructive:"#f87171",purple:"#a855f7",orange:"#FF5722"};function Rt(e){switch(e){case"regression":return"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z";case"insight":return"M9.663 17h4.673M12 3v1m6.364 1.636l-.707.707M21 12h-1M4 12H3m3.343-5.657l-.707-.707m2.828 9.9a5 5 0 117.072 0l-.548.547A3.374 3.374 0 0014 18.469V19a2 2 0 11-4 0v-.531c0-.895-.356-1.754-.988-2.386l-.548-.547z";case"milestone":return"M5 3v4M3 5h4M6 17v4m-2-2h4m5-16l2.286 6.857L21 12l-5.714 2.143L13 21l-2.286-6.857L5 12l5.714-2.143L13 3z";case"success":return"M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"}}function Me(e){switch(e){case"regression":return ue.destructive;case"insight":return ue.purple;case"milestone":return ue.orange;case"success":return ue.success}}function wr(e){switch(e){case"regression":return`${ue.destructive}08`;case"insight":return`${ue.purple}08`;case"milestone":return`${ue.orange}08`;case"success":return`${ue.success}08`}}function kr(e){const r=e.data||{},n=e.type.toLowerCase();if(n.includes("regression")||n==="eval:scored"&&r.delta<-.01)return{id:e.id,type:"regression",title:"Regression Detected",description:r.message||r.description||`Score dropped by ${Math.abs(r.delta||0).toFixed(4)}`,ts:e.ts,source:e.source,data:r};if(n.includes("insight")||n.includes("discovery")||n.includes("correlation"))return{id:e.id,type:"insight",title:r.title||"Cross-Service Insight",description:r.summary||r.insight||r.description||"New pattern detected",ts:e.ts,source:e.source,data:r};if(n.includes("milestone")||n.includes("first-positive")||n.includes("breakthrough"))return{id:e.id,type:"milestone",title:r.title||"Agent Milestone",description:r.description||r.message||"Achievement unlocked",ts:e.ts,source:e.source,data:r};if(n==="eval:scored"){const i=r.delta,s=r.composite;if(i>.02)return{id:e.id,type:"success",title:"Significant Improvement",description:`${r.agent||"Agent"} improved by +${i.toFixed(4)} to ${(s==null?void 0:s.toFixed(4))||"—"}`,ts:e.ts,source:e.source,data:r}}if(n.includes("test")&&(n.includes("added")||n.includes("created"))){const i=r.count||r.tests_added||1;return{id:e.id,type:"milestone",title:"Tests Added",description:`${i} new test${i>1?"s":""} added to coverage`,ts:e.ts,source:e.source,data:r}}return null}function Sr({className:e,maxAlerts:r=5}){var v;const[n,i]=j(new Set),[s,o]=j([]),f=((v=J(()=>U.events(100),15e3).data)==null?void 0:v.events)||[];ve(()=>{const d=[],y=new Set;for(const b of f){if(y.has(b.id)||n.has(b.id))continue;y.add(b.id);const x=kr(b);x&&d.push(x)}d.sort((b,x)=>new Date(x.ts).getTime()-new Date(b.ts).getTime()),o(d.slice(0,r))},[f,n,r]);const h=d=>{i(y=>new Set([...y,d]))},u=()=>{i(d=>new Set([...d,...s.map(y=>y.id)]))};return s.length===0?null:t("div",{class:P("rounded-lg overflow-hidden animate-fade-in",e),style:{background:wr(s[0].type),border:`1px solid ${Me(s[0].type)}30`},children:[t("div",{class:"px-4 py-2.5 flex items-center justify-between",style:{borderBottom:`1px solid ${Me(s[0].type)}20`},children:[t("div",{class:"flex items-center gap-2",children:[t("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:Me(s[0].type),"stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",children:t("path",{d:Rt(s[0].type)})}),t("span",{class:"text-xs font-semibold uppercase tracking-wider",style:{color:Me(s[0].type)},children:s.length===1?"Alert":`${s.length} Alerts`})]}),s.length>1&&t("button",{onClick:u,class:"text-[9px] mono px-2 py-0.5 rounded transition-colors",style:{color:ue.textMuted,background:"rgba(255,255,255,0.05)",border:"none"},children:"dismiss all"})]}),t("div",{class:"divide-y",style:{borderColor:`${ue.border}`},children:s.map((d,y)=>{const b=Me(d.type);return t("div",{class:"px-4 py-3 flex items-start gap-3 transition-all",style:{animation:y===0?"fade-in 0.3s ease":void 0,background:y===0?`${b}05`:"transparent",borderColor:`${b}15`},children:[t("div",{class:"shrink-0 w-8 h-8 rounded-lg flex items-center justify-center",style:{background:`${b}15`,border:`1px solid ${b}25`},children:t("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:b,"stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",children:t("path",{d:Rt(d.type)})})}),t("div",{class:"flex-1 min-w-0",children:[t("div",{class:"flex items-center gap-2 mb-0.5",children:[t("span",{class:"text-sm font-medium",style:{color:ue.text},children:d.title}),t("span",{class:"text-[9px] mono",style:{color:ue.textDim},children:oe(d.ts)})]}),t("p",{class:"text-xs leading-relaxed",style:{color:ue.textMuted},children:d.description}),d.source&&t("span",{class:"text-[9px] mono mt-1 inline-block",style:{color:ue.textDim},children:["via ",d.source]})]}),t("button",{onClick:()=>h(d.id),class:"shrink-0 p-1.5 rounded transition-colors hover:bg-white/5",style:{color:ue.textMuted,background:"none",border:"none"},children:t("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2",children:t("path",{d:"M18 6L6 18M6 6l12 12"})})})]},d.id)})})]})}function Qt({name:e}){return t("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"shrink-0",children:{dashboard:t(ae,{children:[t("rect",{x:"3",y:"3",width:"7",height:"7",rx:"1"}),t("rect",{x:"14",y:"3",width:"7",height:"7",rx:"1"}),t("rect",{x:"3",y:"14",width:"7",height:"7",rx:"1"}),t("rect",{x:"14",y:"14",width:"7",height:"7",rx:"1"})]}),events:t("path",{d:"M13 2 3 14h9l-1 8 10-12h-9z"}),loop:t(ae,{children:[t("circle",{cx:"7",cy:"12",r:"2"}),t("circle",{cx:"12",cy:"7",r:"2"}),t("circle",{cx:"17",cy:"10",r:"2"}),t("circle",{cx:"12",cy:"17",r:"2"}),t("path",{d:"M7 12l5-5M12 7l5 3M17 10l-5 7"})]}),topology:t(ae,{children:[t("circle",{cx:"5",cy:"6",r:"2"}),t("circle",{cx:"12",cy:"4",r:"2"}),t("circle",{cx:"19",cy:"8",r:"2"}),t("circle",{cx:"7",cy:"18",r:"2"}),t("circle",{cx:"17",cy:"17",r:"2"}),t("path",{d:"M7 6l5-2M14 4l5 4M5 8l2 10M12 6l5 11M9 18h8"})]}),system:t(ae,{children:[t("path",{d:"M3 3v18h18"}),t("path",{d:"m7 16 4-8 4 4 4-6"})]}),reviews:t(ae,{children:[t("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),t("path",{d:"M14 2v6h6"}),t("path",{d:"m9 15 2 2 4-4"})]}),chat:t("path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"}),synopsis:t(ae,{children:[t("path",{d:"M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H20v20H6.5a2.5 2.5 0 0 1 0-5H20"}),t("path",{d:"M8 7h6"}),t("path",{d:"M8 11h8"})]}),search:t(ae,{children:[t("circle",{cx:"11",cy:"11",r:"8"}),t("path",{d:"m21 21-4.3-4.3"})]}),findings:t(ae,{children:[t("circle",{cx:"12",cy:"12",r:"10"}),t("path",{d:"M12 8v4"}),t("path",{d:"M12 16h.01"})]})}[e]})}const Cr=[{id:"overview",label:"Overview",icon:"dashboard"},{id:"activity",label:"Activity",icon:"events"},{id:"loop",label:"Loop",icon:"loop"},{id:"experiments",label:"Experiments",icon:"system"},{id:"findings",label:"Findings",icon:"findings"},{id:"reviews",label:"Reviews",icon:"reviews"},{id:"chat",label:"Chat",icon:"chat"},{id:"synopsis",label:"Synopsis",icon:"synopsis"},{id:"topology",label:"Topology",icon:"topology"},{id:"system",label:"System",icon:"system"}];function Mr({status:e,currentPage:r,setPage:n}){var v,d;const i=((v=e==null?void 0:e.config)==null?void 0:v.name)||"JFL",s=(e==null?void 0:e.status)||"unknown",o=(e==null?void 0:e.type)||"standalone",l=(e==null?void 0:e.children)||[],h=J(()=>U.leaderboard(),3e4).data||[],u=h.length>0?[...h].sort((y,b)=>(b.composite||0)-(y.composite||0))[0]:null;return t("aside",{class:"w-56 h-screen bg-sidebar flex flex-col fixed left-0 top-0 z-10 border-r border-sidebar-border",children:[t("div",{class:"px-4 pt-5 pb-4",children:[t("div",{class:"flex items-center gap-2.5",children:[t("div",{class:P("w-7 h-7 rounded-lg flex items-center justify-center text-xs font-bold",s==="ok"||s==="running"?"bg-success/15 text-success":"bg-warning/15 text-warning"),children:i.charAt(0).toUpperCase()}),t("div",{class:"min-w-0",children:[t("div",{class:"font-semibold text-sm text-sidebar-foreground truncate",children:i}),t("div",{class:"flex items-center gap-1.5 mt-0.5",children:[t("span",{class:"text-[10px] mono text-muted-foreground uppercase tracking-wider",children:o}),(e==null?void 0:e.port)&&t("span",{class:"text-[10px] mono text-muted-foreground",children:[":",e.port]})]})]})]}),(u==null?void 0:u.trajectory)&&u.trajectory.length>1&&t("div",{class:"mt-3 flex items-center gap-2",children:[t(Je,{data:u.trajectory,width:100,height:20,color:u.delta!=null&&u.delta>0?"var(--success)":"var(--info)"}),t("span",{class:"text-[10px] mono tabular-nums text-muted-foreground",children:(d=u.composite)==null?void 0:d.toFixed(2)})]})]}),t("div",{class:"px-3 pb-3",children:t(Tr,{setPage:n})}),t("nav",{class:"flex-1 overflow-y-auto pb-2",children:[Cr.map(y=>t("button",{onClick:()=>n(y.id),class:P("w-full flex items-center gap-2.5 px-4 py-1.5 text-[13px] transition-colors relative",r===y.id?"text-sidebar-foreground font-medium bg-accent/60 before:absolute before:left-0 before:top-[5px] before:bottom-[5px] before:w-[2px] before:bg-info before:rounded-r":"text-muted-foreground hover:text-sidebar-foreground hover:bg-accent/30"),children:[t(Qt,{name:y.icon}),y.label]},y.id)),h.length>0&&t("div",{class:"mt-5",children:[t("div",{class:"px-4 pb-1 text-[10px] uppercase tracking-widest text-muted-foreground font-medium",children:"Agents"}),h.sort((y,b)=>(b.composite||0)-(y.composite||0)).slice(0,6).map(y=>{const b=y.delta!=null&&y.delta>0;return t("button",{onClick:()=>n("loop"),class:"w-full flex items-center gap-2.5 px-4 py-1 text-[13px] text-muted-foreground hover:text-sidebar-foreground transition-colors",children:[t("span",{class:P("w-[6px] h-[6px] rounded-full shrink-0",b?"bg-success":"bg-muted-foreground/50")}),t("span",{class:"truncate",children:y.agent}),y.composite!=null&&t("span",{class:"ml-auto mono text-[10px] tabular-nums",children:y.composite.toFixed(2)})]},y.agent)})]})]}),l.length>0&&t("div",{class:"border-t border-sidebar-border py-3 px-4",children:[t("div",{class:"text-[10px] uppercase tracking-widest text-muted-foreground font-medium mb-2",children:"Products"}),t("div",{class:"space-y-1.5",children:l.map(y=>t("div",{class:"flex items-center gap-2",children:[t("span",{class:P("w-[6px] h-[6px] rounded-full shrink-0",y.status==="ok"?"bg-success":y.status==="error"?"bg-destructive":"bg-muted-foreground/50")}),t("span",{class:"text-xs text-sidebar-foreground truncate flex-1",children:y.name}),t("span",{class:"text-[10px] mono text-muted-foreground",children:[":",y.port]})]},y.name))})]}),t("div",{class:"px-4 py-3 border-t border-sidebar-border",children:t("div",{class:"text-[10px] text-muted-foreground/60 mono",children:"jfl v0.3.0"})})]})}function Tr({setPage:e}){const[r,n]=j(""),[i,s]=j([]),[o,l]=j(!1),f=async()=>{var h;if(r.trim()){l(!0);try{const u=await U.memorySearch(r.trim());s(((h=u.results)==null?void 0:h.slice(0,5))||[])}catch{s([])}l(!1)}};return t("div",{class:"relative",children:[t("div",{class:"flex items-center gap-1.5 bg-accent/40 rounded-md px-2.5 py-1.5 border border-sidebar-border/50 focus-within:border-info/50 transition-colors",children:[t(Qt,{name:"search"}),t("input",{type:"text",placeholder:"Search...",value:r,onInput:h=>n(h.target.value),onKeyDown:h=>h.key==="Enter"&&f(),class:"bg-transparent text-xs text-sidebar-foreground placeholder:text-muted-foreground/50 outline-none flex-1 min-w-0"}),o&&t("span",{class:"text-[10px] text-muted-foreground animate-pulse-dot",children:"..."})]}),i.length>0&&t("div",{class:"absolute top-full left-0 right-0 mt-1 bg-card border border-border rounded-md shadow-lg z-50 max-h-60 overflow-y-auto",children:i.map((h,u)=>{var v;return t("button",{onClick:()=>{s([]),n(""),e("activity")},class:"w-full text-left px-3 py-2 hover:bg-muted/30 transition-colors border-b border-border/30 last:border-0",children:[t("div",{class:"text-xs font-medium truncate",children:h.title||((v=h.content)==null?void 0:v.slice(0,60))}),t("div",{class:"flex items-center gap-2 mt-0.5",children:[h.type&&t("span",{class:"text-[10px] mono text-info",children:h.type}),h.relevance&&t("span",{class:P("text-[10px] mono",h.relevance==="high"?"text-success":"text-muted-foreground"),children:h.relevance})]})]},u)})})]})}function Er({status:e}){var S,C,T,m;const r=J(()=>U.events(100),1e4),n=J(()=>U.leaderboard(),15e3),i=J(()=>U.journal(),15e3),s=J(()=>U.synopsis(24),3e4),o=J(()=>U.memoryStatus(),3e4),l=J(()=>U.flowExecutions(),15e3),f=(e==null?void 0:e.type)||"standalone",h=e==null?void 0:e.config,u=(e==null?void 0:e.children)||[],v=((S=r.data)==null?void 0:S.events)||[],d=n.data||[],y=i.data||[],b=(e==null?void 0:e.sources)||{},x=Object.values(b).filter(Boolean).length,E=Object.keys(b).length,w=o.data,R=l.data,F=(Array.isArray(R)?R:(R==null?void 0:R.executions)||[]).filter(a=>a.gated),k=d.length>0?[...d].sort((a,$)=>($.composite||0)-(a.composite||0))[0]:null,p=y.filter(a=>a.type!=="file").slice(0,5),g=v.filter(a=>!a.type.startsWith("session:")&&!a.type.startsWith("hook:")).slice(0,10),[D,c]=j(!1);return t("div",{class:"space-y-6",children:[t("div",{class:"flex items-center justify-between",children:[t("div",{children:[t("h1",{class:"text-xl font-semibold",children:(h==null?void 0:h.name)||"Dashboard"}),(h==null?void 0:h.description)&&t("p",{class:"text-sm text-muted-foreground mt-1",children:h.description})]}),t(Rr,{})]}),t(Sr,{maxAlerts:3}),t("div",{class:"grid grid-cols-2 lg:grid-cols-4 gap-4",children:[t(_e,{label:"Sources",value:`${x}/${E}`,sub:"connected",trend:x===E?"up":"down"}),t(_e,{label:"Items",value:(e==null?void 0:e.itemCount)||0,sub:"indexed"}),t(_e,{label:"Agents",value:d.length,sub:k?`best: ${(C=k.composite)==null?void 0:C.toFixed(2)}`:"none",trend:(k==null?void 0:k.delta)!=null&&k.delta>0?"up":void 0}),t(_e,{label:"Memories",value:(w==null?void 0:w.total_memories)||0,sub:(T=w==null?void 0:w.embeddings)!=null&&T.available?"with embeddings":"keyword only"})]}),F.length>0&&t("div",{class:"bg-warning/5 border border-warning/30 rounded-lg p-4",children:[t("h3",{class:"text-xs text-warning uppercase tracking-wider font-medium mb-2",children:["Actions Needed (",F.length,")"]}),t("div",{class:"space-y-1.5",children:F.map((a,$)=>t("div",{class:"flex items-center justify-between",children:[t("div",{class:"flex items-center gap-2",children:[t("span",{class:"w-1.5 h-1.5 rounded-full bg-warning animate-pulse"}),t("span",{class:"text-sm font-medium",children:a.flow}),t("span",{class:"text-[10px] mono text-muted-foreground",children:oe(a.started_at)})]}),t("button",{onClick:()=>U.approveFlow(a.flow,a.trigger_event_id),class:"text-[10px] mono px-2 py-0.5 rounded bg-success/15 text-success hover:bg-success/25 transition-colors",children:"approve"})]},$))})]}),k&&t("div",{class:"bg-card rounded-lg border border-border p-4",children:[t("div",{class:"flex items-center justify-between mb-3",children:[t("h3",{class:"text-xs text-muted-foreground uppercase tracking-wider",children:"Top Agent"}),t("span",{class:"text-[10px] mono text-muted-foreground",children:[d.length," total"]})]}),t("div",{class:"flex items-center gap-4",children:[t("div",{children:[t("div",{class:"text-sm font-medium",children:k.agent}),t("div",{class:"flex items-center gap-2 mt-1",children:[t("span",{class:"text-2xl font-bold tabular-nums",children:(m=k.composite)==null?void 0:m.toFixed(4)}),k.delta!=null&&t("span",{class:P("text-sm mono",k.delta>=0?"text-success":"text-destructive"),children:[k.delta>=0?"+":"",k.delta.toFixed(4)]})]})]}),k.trajectory&&k.trajectory.length>1&&t(Je,{data:k.trajectory,width:160,height:36,color:k.delta!=null&&k.delta>0?"var(--success)":"var(--info)"})]})]}),s.data&&t($r,{data:s.data}),f==="portfolio"&&u.length>0&&t("div",{class:"bg-card rounded-lg border border-border p-4",children:[t("h3",{class:"text-xs text-muted-foreground uppercase tracking-wider mb-3",children:["Products (",u.length,")"]}),t("div",{class:"space-y-2",children:u.map(a=>t("div",{class:"flex items-center gap-3 text-sm",children:[t(Kt,{status:a.status==="ok"?"ok":"error"}),t("span",{class:"font-medium",children:a.name}),t("span",{class:"text-[10px] mono text-muted-foreground",children:[":",a.port]}),a.status==="ok"&&t("a",{href:`http://localhost:${a.port}/dashboard/`,target:"_blank",rel:"noopener",class:"text-[10px] text-info hover:underline ml-auto",children:"Open"})]},a.name))})]}),t("div",{class:"grid grid-cols-1 lg:grid-cols-2 gap-4",children:[t("div",{class:"bg-card rounded-lg border border-border p-4",children:[t("h3",{class:"text-xs text-muted-foreground uppercase tracking-wider mb-3",children:"Recent Journal"}),p.length>0?t("div",{class:"space-y-2",children:p.map((a,$)=>t("div",{class:"flex items-start gap-2 text-sm",children:[t("span",{class:"text-[10px] mono text-muted-foreground whitespace-nowrap mt-0.5 w-12 shrink-0",children:oe(a.timestamp||a.ts)}),t("div",{class:"min-w-0",children:[t("div",{class:"truncate",children:a.title}),a.type&&t("span",{class:"text-[10px] mono text-info",children:a.type})]})]},$))}):t("div",{class:"text-sm text-muted-foreground",children:"No journal entries"})]}),t("div",{class:"bg-card rounded-lg border border-border p-4",children:[t("h3",{class:"text-xs text-muted-foreground uppercase tracking-wider mb-3",children:"Recent Events"}),g.length>0?t("div",{class:"space-y-2",children:g.map(a=>{var X;const $=a.data||{},L=a.type.startsWith("hook:")?`${$.tool_name||"tool"} ${(X=$.file_paths)!=null&&X.length?`on ${$.file_paths[0]}`:""}`:$.title||$.agent||a.source||a.type;return t("div",{class:"flex items-start gap-2 text-sm",children:[t("span",{class:"text-[10px] mono text-muted-foreground whitespace-nowrap mt-0.5 w-12 shrink-0",children:oe(a.ts)}),t("div",{class:"min-w-0",children:t("div",{class:"flex items-center gap-2",children:[t("span",{class:"text-[10px] mono text-info whitespace-nowrap",children:a.type}),t("span",{class:"truncate text-muted-foreground",children:L})]})})]},a.id)})}):t("div",{class:"text-sm text-muted-foreground",children:"No events"})]})]}),t("div",{class:"bg-card rounded-lg border border-border p-4",children:[t("h3",{class:"text-xs text-muted-foreground uppercase tracking-wider mb-3",children:"Context Sources"}),t("div",{class:"grid grid-cols-2 md:grid-cols-4 gap-3",children:Object.entries(b).map(([a,$])=>t("div",{class:"flex items-center gap-2",children:[t("span",{class:P("w-1.5 h-1.5 rounded-full",$?"bg-success":"bg-destructive")}),t("span",{class:"text-sm capitalize",children:a}),t("span",{class:"text-[10px] text-muted-foreground",children:$?"ok":"disconnected"})]},a))})]}),t(_r,{events:v,collapsed:D,onToggleCollapse:c})]})}function Rr(){const[e,r]=j(null),n=[{label:"run eval",event:"eval:run-requested",data:{source:"dashboard"}},{label:"run peter",spawn:!0,command:"jfl",args:["peter","run"]}],i=async s=>{try{s.spawn?await U.spawnAction(s.command,s.args,s.event):await U.publishEvent(s.event,s.data||{}),r(s.label),setTimeout(()=>r(null),2e3)}catch(o){console.error("Action failed:",o)}};return t("div",{class:"flex items-center gap-2",children:n.map(s=>t("button",{onClick:()=>i(s),class:P("text-[10px] mono px-2 py-1 rounded transition-colors",e===s.label?"bg-success/15 text-success":"bg-muted text-muted-foreground hover:text-foreground hover:bg-muted/80"),children:e===s.label?"done":s.label},s.label))})}function $r({data:e}){const r=e.summary;return r.features+r.fixes+r.decisions+r.discoveries>0||e.commits.length>0?t("div",{class:"bg-card rounded-lg border border-border p-4",children:[t("h3",{class:"text-xs text-muted-foreground uppercase tracking-wider mb-3",children:["Work Summary ",t("span",{class:"text-[10px] font-normal",children:["last ",e.hours,"h"]})]}),t("div",{class:"grid grid-cols-2 md:grid-cols-5 gap-4 mb-4",children:[r.features>0&&t("div",{children:[t("div",{class:"text-lg font-semibold mono text-success",children:r.features}),t("div",{class:"text-[10px] text-muted-foreground uppercase",children:"Features"})]}),r.fixes>0&&t("div",{children:[t("div",{class:"text-lg font-semibold mono text-warning",children:r.fixes}),t("div",{class:"text-[10px] text-muted-foreground uppercase",children:"Fixes"})]}),r.decisions>0&&t("div",{children:[t("div",{class:"text-lg font-semibold mono text-info",children:r.decisions}),t("div",{class:"text-[10px] text-muted-foreground uppercase",children:"Decisions"})]}),r.discoveries>0&&t("div",{children:[t("div",{class:"text-lg font-semibold mono text-purple-400",children:r.discoveries}),t("div",{class:"text-[10px] text-muted-foreground uppercase",children:"Discoveries"})]}),e.commits.length>0&&t("div",{children:[t("div",{class:"text-lg font-semibold mono",children:e.commits.length}),t("div",{class:"text-[10px] text-muted-foreground uppercase",children:"Commits"})]})]}),e.commits.length>0&&t("div",{class:"border-t border-border pt-3",children:t("div",{class:"space-y-1",children:e.commits.slice(0,5).map(i=>t("div",{class:"flex items-center gap-2 text-xs",children:[t("span",{class:"mono text-muted-foreground text-[10px]",children:i.hash.slice(0,7)}),t("span",{class:"truncate",children:i.message}),t("span",{class:"text-[10px] text-muted-foreground ml-auto whitespace-nowrap",children:oe(i.date)})]},i.hash))})}),r.incompleteItems.length>0&&t("div",{class:"border-t border-border pt-3 mt-3",children:[t("div",{class:"text-[10px] text-muted-foreground uppercase tracking-wider mb-2",children:"Incomplete"}),t("div",{class:"space-y-1",children:r.incompleteItems.slice(0,5).map((i,s)=>t("div",{class:"text-xs text-warning/80 flex items-center gap-1.5",children:[t("span",{class:"w-1 h-1 rounded-full bg-warning/60 shrink-0"}),i]},s))})]})]}):null}const Ar={critical:{bg:"bg-destructive/10",text:"text-destructive",icon:"🔴"},warning:{bg:"bg-warning/10",text:"text-warning",icon:"⚠️"},info:{bg:"bg-info/10",text:"text-info",icon:"ℹ️"}},Fr={performance_regression:"Performance Regression",test_failure:"Test Failure",error_spike:"Error Spike",coverage_gap:"Coverage Gap",stale_code:"Stale Code",eval_plateau:"Eval Plateau"};function Pr(){var F;const[e,r]=j(!1),[n,i]=j(null),[s,o]=j(null),[l,f]=j(0),h=J(()=>U.findings(!1,e),3e4,[e,l]),u=async()=>{try{await U.analyzeFindings(),f(k=>k+1)}catch(k){console.error("Failed to analyze:",k)}},v=async k=>{i(k.id);try{await U.spawnFindingAgent(k.id),setTimeout(()=>i(null),3e3)}catch(p){console.error("Failed to spawn:",p),i(null)}},d=async k=>{o(k.id);try{await U.dismissFinding(k.id),f(p=>p+1)}catch(p){console.error("Failed to dismiss:",p)}o(null)},y=((F=h.data)==null?void 0:F.findings)||[],b=y.filter(k=>!k.dismissed),x=y.filter(k=>k.dismissed),E={critical:0,warning:1,info:2};b.sort((k,p)=>E[k.severity]-E[p.severity]);const w=b.filter(k=>k.severity==="critical").length,R=b.filter(k=>k.severity==="warning").length,_=b.filter(k=>k.severity==="info").length;return t("div",{class:"space-y-6",children:[t("div",{class:"flex items-center justify-between",children:[t("div",{children:[t("h1",{class:"text-xl font-semibold",children:"Findings"}),t("p",{class:"text-sm text-muted-foreground mt-1",children:"Automatically detected issues — click Fix to spawn an agent"})]}),t("div",{class:"flex items-center gap-2",children:[t("button",{onClick:u,class:"text-[10px] mono px-2 py-1 rounded bg-muted text-muted-foreground hover:text-foreground transition-colors",children:h.loading?"analyzing...":"re-analyze"}),t("button",{onClick:()=>r(!e),class:P("text-[10px] mono px-2 py-1 rounded transition-colors",e?"bg-info/15 text-info":"bg-muted text-muted-foreground hover:text-foreground"),children:e?"hide dismissed":"show dismissed"})]})]}),b.length>0&&t("div",{class:"flex items-center gap-4",children:[w>0&&t("div",{class:"flex items-center gap-1.5",children:[t("span",{class:"w-2 h-2 rounded-full bg-destructive"}),t("span",{class:"text-sm mono",children:[w," critical"]})]}),R>0&&t("div",{class:"flex items-center gap-1.5",children:[t("span",{class:"w-2 h-2 rounded-full bg-warning"}),t("span",{class:"text-sm mono",children:[R," warning"]})]}),_>0&&t("div",{class:"flex items-center gap-1.5",children:[t("span",{class:"w-2 h-2 rounded-full bg-info"}),t("span",{class:"text-sm mono",children:[_," info"]})]})]}),h.loading&&y.length===0?t("div",{class:"text-sm text-muted-foreground animate-pulse-dot",children:"Loading findings..."}):b.length===0&&!e?t("div",{class:"bg-card rounded-lg border border-border p-8 text-center",children:[t("div",{class:"text-success text-2xl mb-2",children:"✓"}),t("div",{class:"text-sm font-medium",children:"No active findings"}),t("div",{class:"text-xs text-muted-foreground mt-1",children:"Everything looks good! Run re-analyze to check again."})]}):t("div",{class:"space-y-4",children:[b.map(k=>t($t,{finding:k,spawning:n===k.id,dismissing:s===k.id,onSpawn:()=>v(k),onDismiss:()=>d(k)},k.id)),e&&x.length>0&&t(ae,{children:[t("div",{class:"text-xs text-muted-foreground uppercase tracking-wider pt-4",children:["Dismissed (",x.length,")"]}),x.map(k=>t($t,{finding:k,spawning:!1,dismissing:!1,onSpawn:()=>{},onDismiss:()=>{},disabled:!0},k.id))]})]})]})}function $t({finding:e,spawning:r,dismissing:n,onSpawn:i,onDismiss:s,disabled:o}){const[l,f]=j(!1),h=Ar[e.severity],u=Fr[e.type];return t("div",{class:P("bg-card rounded-lg border border-border overflow-hidden transition-all",e.dismissed&&"opacity-50"),children:t("div",{class:"p-4",children:[t("div",{class:"flex items-start gap-3",children:[t("span",{class:"text-lg leading-none",children:h.icon}),t("div",{class:"flex-1 min-w-0",children:[t("div",{class:"flex items-center gap-2 flex-wrap",children:[t("span",{class:P("font-medium",h.text),children:e.title}),t("span",{class:"text-[10px] mono px-1.5 py-0.5 rounded bg-muted text-muted-foreground",children:u})]}),t("p",{class:"text-sm text-muted-foreground mt-1",children:e.description}),e.scope_files.length>0&&t("div",{class:"mt-2",children:[t("button",{onClick:()=>f(!l),class:"text-[10px] mono text-info hover:underline",children:[l?"hide":"show"," ",e.scope_files.length," file",e.scope_files.length!==1?"s":""]}),l&&t("div",{class:"mt-2 p-2 bg-muted/30 rounded text-xs mono space-y-0.5 max-h-32 overflow-y-auto",children:e.scope_files.map((v,d)=>t("div",{class:"text-muted-foreground truncate",children:v},d))})]})]}),!o&&t("div",{class:"flex items-center gap-2 shrink-0",children:[e.agent_config&&t("button",{onClick:i,disabled:r,class:P("text-[10px] mono px-3 py-1.5 rounded transition-colors",r?"bg-success/15 text-success":"bg-info/15 text-info hover:bg-info/25"),children:r?"spawned!":"Fix"}),t("button",{onClick:s,disabled:n,class:"text-[10px] mono px-2 py-1.5 rounded bg-muted text-muted-foreground hover:text-foreground transition-colors",children:n?"...":"dismiss"})]})]}),e.agent_config&&t("div",{class:"flex items-center gap-4 mt-3 pt-3 border-t border-border text-[10px] mono text-muted-foreground",children:[t("span",{children:["target: ",e.agent_config.metric," ≥ ",e.agent_config.target]}),t("span",{children:["rounds: ",e.agent_config.rounds]}),t("span",{children:["eval: ",e.agent_config.eval_script]})]})]})})}function Dr(){const e=J(()=>U.rlAgents().then(v=>v.agents),15e3),r=J(()=>U.rlSessions().then(v=>v.sessions),1e4),n=J(()=>U.productContext(),3e4),i=e.data||[],s=r.data||[],o=n.data||{context:null,updatedAt:null},l={};for(const v of s)l[v.agent]||(l[v.agent]=[]),l[v.agent].push(v);const f=s.reduce((v,d)=>v+d.rounds.length,0),h=s.reduce((v,d)=>v+d.rounds.filter(y=>y.kept).length,0),u=i.filter(v=>(l[v.name]||[]).length>0).length;return t("div",{class:"space-y-6",children:[t("div",{children:[t("h1",{class:"text-xl font-semibold",children:"Autoresearch"}),t("p",{class:"text-sm text-muted-foreground mt-1",children:"Scoped agents optimizing your services. Branches grow overnight, you review in the morning."})]}),t("div",{class:"grid grid-cols-2 lg:grid-cols-4 gap-4",children:[t(De,{label:"Agents",value:i.length,sub:`${u} active`}),t(De,{label:"Sessions",value:s.length,sub:"completed"}),t(De,{label:"Rounds",value:f,sub:`${h} kept`,accent:h>0}),t(De,{label:"Hit Rate",value:f>0?`${Math.round(h/f*100)}%`:"—",sub:"improvements",accent:h>0})]}),t("div",{children:[t("h2",{class:"text-sm font-medium text-muted-foreground uppercase tracking-wider mb-3",children:"Agents"}),t("div",{class:"grid grid-cols-1 lg:grid-cols-2 xl:grid-cols-3 gap-4",children:i.map(v=>t(Ir,{agent:v,sessions:l[v.name]||[]},v.name))})]}),o.context&&t(Lr,{context:o.context,updatedAt:o.updatedAt}),s.length>0&&t(Gr,{sessions:s})]})}function De({label:e,value:r,sub:n,accent:i}){return t("div",{class:"card p-4",children:[t("div",{class:"text-xs text-muted-foreground uppercase tracking-wider mb-1",children:e}),t("div",{class:P("text-2xl font-bold tabular-nums",i?"text-green-400":""),children:r}),t("div",{class:"text-xs text-muted-foreground mt-0.5",children:n})]})}function Ir({agent:e,sessions:r}){var u,v,d,y;const n=r.flatMap(b=>b.rounds),i=n.filter(b=>b.kept),s=r[r.length-1],o=s==null?void 0:s.rounds[s.rounds.length-1],l=i.length>0?Math.max(...i.map(b=>Math.abs(b.delta))):0,f=i.length>0,h=(((v=(u=e.context_scope)==null?void 0:u.produces)==null?void 0:v.length)||0)+(((y=(d=e.context_scope)==null?void 0:d.consumes)==null?void 0:y.length)||0);return t("div",{class:P("card p-4 border-l-2",f?"border-l-green-500":"border-l-border"),children:[t("div",{class:"flex items-center justify-between mb-2",children:[t("h3",{class:"text-sm font-semibold",children:e.name}),t("span",{class:P("text-[10px] px-2 py-0.5 rounded font-mono",e.direction==="minimize"?"bg-green-500/10 text-green-400":"bg-purple-500/10 text-purple-400"),children:[e.direction==="minimize"?"↓":"↑"," ",e.metric]})]}),t("div",{class:"text-xs text-muted-foreground mb-3",children:[e.target_repo?`→ ${e.target_repo}`:"self"," · ",h," scope patterns"]}),t("div",{class:"grid grid-cols-3 gap-2 mb-3",children:[t(nt,{label:"rounds",value:n.length}),t(nt,{label:"kept",value:i.length,accent:f}),t(nt,{label:"best Δ",value:l>0?l.toFixed(0):"—",accent:f})]}),n.length>0&&t("div",{class:"flex gap-px h-5 items-end mb-2",children:n.slice(-15).map((b,x)=>t("div",{class:P("flex-1 min-w-1 rounded-sm transition-all",b.kept?"bg-green-500/70 h-full":"bg-red-500/50 h-2/5"),title:`R${b.round}: ${b.delta>0?"+":""}${b.delta.toFixed(1)} ${b.kept?"KEPT":"REVERTED"}`},x))}),o?t("div",{class:"text-[11px] text-muted-foreground border-t border-border pt-2 mt-1 tabular-nums",children:["Last: ",o.metric.toFixed(1)," (",o.delta>0?"+":"",o.delta.toFixed(1),")",t("span",{class:o.kept?"text-green-400":"text-red-400",children:[" ",o.kept?"✓":"✗"]}),o.timestamp&&t("span",{class:"ml-1",children:["· ",oe(o.timestamp)]})]}):t("div",{class:"text-xs text-muted-foreground italic",children:"No experiments yet"})]})}function nt({label:e,value:r,accent:n}){return t("div",{class:"text-center",children:[t("div",{class:P("text-lg font-bold tabular-nums",n?"text-green-400":"text-foreground"),children:r}),t("div",{class:"text-[10px] text-muted-foreground",children:e})]})}function Lr({context:e,updatedAt:r}){const n=e.replace(/^# Product Context\n\n_Synthesized.*?\n\n/,""),i=n.split(/^## /m).filter(Boolean).map(s=>{const o=s.split(`
3
+ `),l=o[0].trim(),f=o.slice(1).join(`
4
+ `).trim();return{title:l,body:f}});return t("div",{class:"card p-4",children:[t("div",{class:"flex items-center justify-between mb-3",children:[t("h2",{class:"text-sm font-medium text-muted-foreground uppercase tracking-wider",children:"Product Context"}),r&&t("span",{class:"text-[11px] text-muted-foreground",children:oe(r)})]}),i.length>0?t("div",{class:"space-y-3",children:i.map((s,o)=>t("div",{children:[t("h3",{class:"text-xs font-semibold text-foreground mb-1",children:s.title}),t("div",{class:"text-xs text-muted-foreground leading-relaxed whitespace-pre-line",children:s.body.split(`
5
+ `).map((l,f)=>{const h=l.replace(/\*\*(.*?)\*\*/g,"$1");return l.startsWith("- ")?t("div",{class:"ml-2",children:["· ",h.replace(/^- /,"")]},f):h?t("div",{children:h},f):null})})]},o))}):t("div",{class:"text-xs text-muted-foreground whitespace-pre-line leading-relaxed",children:n})]})}function Gr({sessions:e}){return t("div",{class:"card p-4",children:[t("h2",{class:"text-sm font-medium text-muted-foreground uppercase tracking-wider mb-3",children:"Recent Sessions"}),t("div",{class:"overflow-x-auto",children:t("table",{class:"w-full text-xs",children:[t("thead",{children:t("tr",{class:"border-b border-border text-muted-foreground",children:[t("th",{class:"text-left py-2 px-2 font-medium",children:"Agent"}),t("th",{class:"text-center py-2 px-2 font-medium",children:"Rounds"}),t("th",{class:"text-center py-2 px-2 font-medium",children:"Kept"}),t("th",{class:"text-right py-2 px-2 font-medium",children:"Best Δ"}),t("th",{class:"text-left py-2 px-2 font-medium",children:"Results"})]})}),t("tbody",{children:e.slice(-10).reverse().map(r=>{const n=r.rounds.filter(s=>s.kept),i=n.length>0?Math.max(...n.map(s=>Math.abs(s.delta))):0;return t("tr",{class:"border-b border-border/50 hover:bg-muted/20",children:[t("td",{class:"py-2 px-2 font-medium",children:r.agent}),t("td",{class:"py-2 px-2 text-center text-muted-foreground tabular-nums",children:r.rounds.length}),t("td",{class:P("py-2 px-2 text-center tabular-nums",n.length>0?"text-green-400":"text-muted-foreground"),children:n.length}),t("td",{class:P("py-2 px-2 text-right tabular-nums",i>0?"text-green-400":"text-muted-foreground"),children:i>0?i.toFixed(1):"—"}),t("td",{class:"py-2 px-2",children:t("div",{class:"flex gap-1",children:r.rounds.map((s,o)=>t("span",{class:P("inline-block w-2 h-2 rounded-full",s.kept?"bg-green-500":"bg-red-500"),title:`R${s.round}: ${s.delta>0?"+":""}${s.delta.toFixed(1)}`},o))})})]},r.id)})})]})})]})}const M={bg:"#191919",info:"#4a7dfc",infoGlow:"#4a7dfcaa",success:"#34d399",successGlow:"#34d39988",warning:"#eab308",warningGlow:"#eab30888",purple:"#a855f7",purpleGlow:"#a855f788",cyan:"#06b6d4",text:"#f5f5f5",textMuted:"#8b8b8b",textDim:"#5a5a5a",grid:"#2a2a2a"};function ze(e){switch(e){case"gtm":return{fill:M.cyan,glow:M.cyan+"88"};case"orchestrator":return{fill:M.purple,glow:M.purpleGlow};case"eval":return{fill:M.warning,glow:M.warningGlow};case"service":return{fill:M.success,glow:M.successGlow};default:return{fill:M.info,glow:M.infoGlow}}}function jr(e,r=18){return e.length<=r?e:e.slice(0,r-1)+"…"}const pe=new Set(["peter-parker","telemetry-agent","eval-engine","stratus"]),Zt=36,er=32;function Te(e){switch(e){case"running":return M.success;case"idle":return M.warning;default:return M.textDim}}function At(){const e=Date.now(),r=[{id:"telemetry-agent",label:"Telemetry Agent",type:"agent",status:"running",eventCount:142,lastAction:"telemetry:insight emitted",lastTs:new Date(e-45e3).toISOString(),reward:[.4,.5,.6,.55,.7,.65,.8]},{id:"peter-parker",label:"Peter Parker",type:"orchestrator",status:"running",eventCount:89,lastAction:"task dispatched to builder",lastTs:new Date(e-12e4).toISOString(),reward:[.3,.4,.5,.55,.6,.7,.75]},{id:"eval-engine",label:"Eval Engine",type:"eval",status:"running",eventCount:234,lastAction:"eval:scored lobsters-prg-0.6.0",lastTs:new Date(e-3e4).toISOString(),reward:[.6,.5,.7,.8,.75,.85,.9]},{id:"stratus",label:"Stratus API",type:"service",status:"running",eventCount:1203,lastAction:"rollout prediction served",lastTs:new Date(e-15e3).toISOString(),reward:[.5,.55,.6,.65,.7,.75,.8]}],n=[{id:"jfl-gtm",label:"JFL",type:"gtm",status:"running",eventCount:456,lastAction:"gtm:deploy",lastTs:new Date(e-6e4).toISOString(),reward:[.5,.6,.7,.65,.75,.8,.85]},{id:"productrank-gtm",label:"ProductRank",type:"gtm",status:"running",eventCount:312,lastAction:"gtm:train",lastTs:new Date(e-9e4).toISOString(),reward:[.4,.5,.55,.6,.7,.75,.8]},{id:"gatcha-gtm",label:"Gatcha",type:"gtm",status:"running",eventCount:198,lastAction:"gtm:eval",lastTs:new Date(e-3e4).toISOString(),reward:[.6,.55,.65,.7,.75,.8,.85]}],i=[{id:"jfl-gtm/context-hub",label:"Context Hub",type:"service",status:"running",eventCount:234,parentGtm:"jfl-gtm",reward:[.5,.6,.55,.7,.65,.75,.8]},{id:"jfl-gtm/memory-server",label:"Memory Server",type:"service",status:"running",eventCount:178,parentGtm:"jfl-gtm",reward:[.4,.5,.55,.6,.65,.7,.75]},{id:"jfl-gtm/journal-sync",label:"Journal Sync",type:"service",status:"running",eventCount:92,parentGtm:"jfl-gtm",reward:[.6,.55,.7,.65,.75,.8,.85]},{id:"jfl-gtm/skill-runner",label:"Skill Runner",type:"agent",status:"running",eventCount:156,parentGtm:"jfl-gtm",reward:[.45,.55,.6,.65,.7,.75,.8]},{id:"productrank-gtm/arena",label:"Arena",type:"eval",status:"running",eventCount:567,parentGtm:"productrank-gtm",reward:[.7,.65,.75,.8,.85,.9,.88]},{id:"productrank-gtm/ranker",label:"Ranker",type:"service",status:"running",eventCount:445,parentGtm:"productrank-gtm",reward:[.55,.6,.65,.7,.75,.8,.85]},{id:"productrank-gtm/scraper",label:"Scraper",type:"agent",status:"running",eventCount:289,parentGtm:"productrank-gtm",reward:[.5,.55,.6,.65,.7,.72,.75]},{id:"gatcha-gtm/game-engine",label:"Game Engine",type:"service",status:"running",eventCount:678,parentGtm:"gatcha-gtm",reward:[.6,.65,.7,.75,.8,.85,.88]},{id:"gatcha-gtm/nft-minter",label:"NFT Minter",type:"service",status:"running",eventCount:123,parentGtm:"gatcha-gtm",reward:[.5,.55,.6,.65,.68,.7,.75]},{id:"gatcha-gtm/matchmaker",label:"Matchmaker",type:"agent",status:"running",eventCount:234,parentGtm:"gatcha-gtm",reward:[.55,.6,.65,.7,.75,.78,.8]}],s=[];for(const l of r){const f=ze(l.type),h=l.type==="orchestrator"?32:l.type==="service"?28:24;s.push({...l,x:0,y:0,targetX:0,targetY:0,radius:h,baseRadius:h,color:f.fill,glowColor:f.glow,pulsePhase:Math.random()*Math.PI*2})}for(const l of n){const f=ze(l.type);s.push({...l,x:0,y:0,targetX:0,targetY:0,radius:Zt,baseRadius:er,color:f.fill,glowColor:f.glow,pulsePhase:Math.random()*Math.PI*2,isGtm:!0,childCount:0,aggregateReward:l.reward})}for(const l of i){const f=ze(l.type),h=l.type==="eval"?24:l.type==="agent"?22:20;s.push({id:l.id,label:l.label,type:l.type,status:l.status,eventCount:l.eventCount,lastAction:`${l.type} activity`,lastTs:new Date(e-Math.random()*3e5).toISOString(),reward:l.reward,x:0,y:0,targetX:0,targetY:0,radius:h,baseRadius:h,color:f.fill,glowColor:f.glow,pulsePhase:Math.random()*Math.PI*2,parentGtm:l.parentGtm})}const o=[{id:"e1",source:"telemetry-agent",target:"peter-parker",eventType:"telemetry:insight",active:!0,lastFired:e-45e3,color:M.info,category:"data",particles:[]},{id:"e2",source:"peter-parker",target:"eval-engine",eventType:"peter:task-completed",active:!0,lastFired:e-12e4,color:M.purple,category:"rl",particles:[]},{id:"e3",source:"eval-engine",target:"telemetry-agent",eventType:"eval:scored",active:!0,lastFired:e-3e4,color:M.warning,category:"success",particles:[]},{id:"e4",source:"peter-parker",target:"stratus",eventType:"peter:rollout-request",active:!0,lastFired:e-15e3,color:M.purple,category:"rl",particles:[]},{id:"e5",source:"stratus",target:"eval-engine",eventType:"stratus:prediction",active:!0,lastFired:e-2e4,color:M.success,category:"success",particles:[]},{id:"e6",source:"jfl-gtm",target:"peter-parker",eventType:"gtm:request",active:!0,lastFired:e-35e3,color:M.info,category:"data",particles:[]},{id:"e7",source:"productrank-gtm",target:"eval-engine",eventType:"gtm:eval",active:!0,lastFired:e-55e3,color:M.warning,category:"success",particles:[]},{id:"e8",source:"gatcha-gtm",target:"stratus",eventType:"gtm:predict",active:!0,lastFired:e-25e3,color:M.success,category:"success",particles:[]},{id:"e9",source:"telemetry-agent",target:"jfl-gtm",eventType:"telemetry:metrics",active:!0,lastFired:e-4e4,color:M.info,category:"data",particles:[]},{id:"e10",source:"telemetry-agent",target:"productrank-gtm",eventType:"telemetry:metrics",active:!0,lastFired:e-5e4,color:M.info,category:"data",particles:[]},{id:"e11",source:"telemetry-agent",target:"gatcha-gtm",eventType:"telemetry:metrics",active:!0,lastFired:e-6e4,color:M.info,category:"data",particles:[]},{id:"e12",source:"jfl-gtm/context-hub",target:"jfl-gtm/memory-server",eventType:"context:sync",active:!0,lastFired:e-1e4,color:M.info,category:"data",particles:[]},{id:"e13",source:"jfl-gtm/memory-server",target:"jfl-gtm/journal-sync",eventType:"memory:write",active:!0,lastFired:e-15e3,color:M.info,category:"data",particles:[]},{id:"e14",source:"jfl-gtm/skill-runner",target:"jfl-gtm/context-hub",eventType:"skill:result",active:!0,lastFired:e-2e4,color:M.purple,category:"rl",particles:[]},{id:"e15",source:"productrank-gtm/arena",target:"productrank-gtm/ranker",eventType:"arena:score",active:!0,lastFired:e-12e3,color:M.warning,category:"success",particles:[]},{id:"e16",source:"productrank-gtm/scraper",target:"productrank-gtm/arena",eventType:"scraper:data",active:!0,lastFired:e-18e3,color:M.info,category:"data",particles:[]},{id:"e17",source:"gatcha-gtm/game-engine",target:"gatcha-gtm/matchmaker",eventType:"game:match",active:!0,lastFired:e-8e3,color:M.success,category:"success",particles:[]},{id:"e18",source:"gatcha-gtm/matchmaker",target:"gatcha-gtm/nft-minter",eventType:"match:reward",active:!0,lastFired:e-22e3,color:M.purple,category:"rl",particles:[]}];for(const l of o){const f=l.active?3+Math.floor(Math.random()*3):1;for(let h=0;h<f;h++)l.particles.push({t:Math.random(),speed:8e-4+Math.random()*.0015,size:2+Math.random()*2.5,alpha:.5+Math.random()*.5,trail:[]})}return{nodes:s,edges:o}}function Nr(e,r){const n=Date.now(),i=new Set;for(const l of e)(l.type==="gtm"||l.id.endsWith("-gtm"))&&i.add(l.id);const s=e.map(l=>{const f=l.type==="gtm"||l.id.endsWith("-gtm");let h;if(!f&&!pe.has(l.id))if(l.id.includes("/"))h=l.id.split("/")[0];else for(const y of i){const b=y.replace(/-gtm$/,"");if(l.id.startsWith(b+"-")||l.id.startsWith(b+"/")){h=y;break}}const u=f?"gtm":l.type;let v;f?v=er:pe.has(l.id)?v=28:l.type==="orchestrator"?v=26:v=22;const d=ze(u);return{id:l.id,label:l.label,type:u,status:l.status,eventCount:l.eventCount||Math.floor(Math.random()*200)+50,lastAction:`${l.type} activity`,lastTs:new Date(n-Math.random()*3e5).toISOString(),reward:Array.from({length:7},()=>.3+Math.random()*.5),x:0,y:0,targetX:0,targetY:0,radius:v,baseRadius:v,color:d.fill,glowColor:d.glow,pulsePhase:Math.random()*Math.PI*2,produces:l.produces,consumes:l.consumes,parentGtm:h,isGtm:f,childCount:0,aggregateReward:Array.from({length:7},()=>.3+Math.random()*.5)}}),o=r.map(l=>{const f=l.category==="success"?M.success:l.category==="rl"?M.purple:M.info,h={id:l.id,source:l.source,target:l.target,eventType:l.eventType,active:!0,lastFired:n-Math.random()*12e4,color:f,category:l.category,particles:[]},u=3+Math.floor(Math.random()*3);for(let v=0;v<u;v++)h.particles.push({t:Math.random(),speed:8e-4+Math.random()*.0015,size:2+Math.random()*2.5,alpha:.5+Math.random()*.5,trail:[]});return h});return{nodes:s,edges:o}}function Ie(e,r,n,i,s){const o=r/2,l=n/2;if(e.length===0)return;const h=Math.min(r/1200,n/800,1),u=s||new Set,v=e.filter(p=>p.isGtm),d=e.filter(p=>pe.has(p.id)),y=e.filter(p=>!p.isGtm&&!pe.has(p.id)),b=new Map;for(const p of v)b.set(p.id,[]);for(const p of y)p.parentGtm&&b.has(p.parentGtm)&&b.get(p.parentGtm).push(p);for(const p of v){const g=b.get(p.id)||[];p.childCount=g.length,g.length>0&&(p.aggregateReward=g[0].reward.map((c,S)=>g.reduce((T,m)=>T+(m.reward[S]||0),0)/g.length));const D=u.has(p.id);p.radius=D?p.baseRadius:Zt}const x=y.filter(p=>!p.parentGtm||!b.has(p.parentGtm)),E=v.filter(p=>u.has(p.id)),w=v.filter(p=>!u.has(p.id)),R=160;if(E.length===1){const p=E[0];p.targetX=o,p.targetY=l,p.x===0&&p.y===0&&(p.x=o+(Math.random()-.5)*40,p.y=l+(Math.random()-.5)*40);const g=b.get(p.id)||[],D=g.length;if(D>0){const S=Math.PI*2/D,C=-Math.PI/2;g.forEach((T,m)=>{const a=C+m*S,$=R*h+(m%2===0?15:-10);T.targetX=o+Math.cos(a)*$,T.targetY=l+Math.sin(a)*$,T.x===0&&T.y===0&&(T.x=T.targetX+(Math.random()-.5)*30,T.y=T.targetY+(Math.random()-.5)*30)})}const c=Math.min(r,n)*.42;w.forEach((S,C)=>{const T=Math.PI*2*C/Math.max(w.length,1)-Math.PI/2;S.targetX=o+Math.cos(T)*c,S.targetY=l+Math.sin(T)*c,S.x===0&&S.y===0&&(S.x=S.targetX+(Math.random()-.5)*40,S.y=S.targetY+(Math.random()-.5)*40);const m=b.get(S.id)||[];for(const a of m)a.targetX=S.targetX,a.targetY=S.targetY,a.x===0&&a.y===0&&(a.x=a.targetX,a.y=a.targetY)})}else{const p=[{x:r*.22,y:n*.32},{x:r*.68,y:n*.38},{x:r*.45,y:n*.72}];v.forEach((g,D)=>{const c=u.has(g.id),S=p[D%p.length];g.targetX=S.x,g.targetY=S.y,g.x===0&&g.y===0&&(g.x=g.targetX+(Math.random()-.5)*40,g.y=g.targetY+(Math.random()-.5)*40);const C=b.get(g.id)||[];if(c&&C.length>0){const T=C.length,m=Math.PI*2/T,a=-Math.PI/2;C.forEach(($,L)=>{const X=a+L*m,O=R*h+(L%2===0?15:-10);$.targetX=g.targetX+Math.cos(X)*O,$.targetY=g.targetY+Math.sin(X)*O,$.x===0&&$.y===0&&($.x=$.targetX+(Math.random()-.5)*30,$.y=$.targetY+(Math.random()-.5)*30)})}else for(const T of C)T.targetX=g.targetX,T.targetY=g.targetY,T.x===0&&T.y===0&&(T.x=T.targetX,T.y=T.targetY)})}if(d.length>0){const p=l-40,g=50*h,D=[{x:o,y:p-g*.5},{x:o+g,y:p+g*.3},{x:o,y:p+g*1.1},{x:o-g,y:p+g*.3}],c={"peter-parker":0,stratus:1,"eval-engine":2,"telemetry-agent":3};d.forEach((S,C)=>{const T=c[S.id]??C%4,m=D[T];S.targetX=m.x,S.targetY=m.y,S.x===0&&S.y===0&&(S.x=m.x+(Math.random()-.5)*20,S.y=m.y+(Math.random()-.5)*20)})}if(x.length>0){const p=Math.min(r,n)*.44,g=Math.PI*2/x.length,D=Math.PI/6;x.forEach((c,S)=>{const C=D+S*g;c.targetX=o+Math.cos(C)*p,c.targetY=l+Math.sin(C)*p,c.x===0&&c.y===0&&(c.x=c.targetX+(Math.random()-.5)*50,c.y=c.targetY+(Math.random()-.5)*50)})}const F=e.filter(p=>p.isGtm||pe.has(p.id)||!p.parentGtm?!0:u.has(p.parentGtm));for(let p=0;p<6;p++)for(let g=0;g<F.length;g++)for(let D=g+1;D<F.length;D++){const c=F[g],S=F[D];if(c.isGtm&&S.parentGtm===c.id&&u.has(c.id)||S.isGtm&&c.parentGtm===S.id&&u.has(S.id))continue;const C=c.targetX-S.targetX,T=c.targetY-S.targetY,m=Math.sqrt(C*C+T*T),a=(c.radius+S.radius)*2.5;if(m<a&&m>0){const $=(a-m)*.2,L=C/m*$,X=T/m*$,O=c.isGtm||pe.has(c.id),se=S.isGtm||pe.has(S.id);O||(c.targetX+=L*(se?1:.5),c.targetY+=X*(se?1:.5)),se||(S.targetX-=L*(O?1:.5),S.targetY-=X*(O?1:.5))}}const k=60;for(const p of e)p.targetX=Math.max(k,Math.min(r-k,p.targetX)),p.targetY=Math.max(k,Math.min(n-k,p.targetY))}function Ee(e,r,n,i,s,o,l,f,h){const u=1-h;return[u*u*u*e+3*u*u*h*n+3*u*h*h*s+h*h*h*l,u*u*u*r+3*u*u*h*i+3*u*h*h*o+h*h*h*f]}function dt(e,r){const n=r.x-e.x,i=r.y-e.y,s=Math.sqrt(n*n+i*i),o=s>0?-i/s:0,l=s>0?n/s:0,f=Math.min(s*.25,70),h=(e.x+r.x)/2,u=(e.y+r.y)/2;return{sx:e.x,sy:e.y,c1x:h+o*f-n*.15,c1y:u+l*f-i*.15,c2x:h+o*f+n*.15,c2y:u+l*f+i*.15,ex:r.x,ey:r.y}}function de(e,r){const n=parseInt(e.slice(1,3),16),i=parseInt(e.slice(3,5),16),s=parseInt(e.slice(5,7),16);return`rgba(${n}, ${i}, ${s}, ${r})`}function st(e,r,n,i,s){return Math.max(0,Math.sqrt((e-n)**2+(r-i)**2)-s)}const Le=`
6
+ attribute vec2 a_position;
7
+ void main() {
8
+ gl_Position = vec4(a_position, 0.0, 1.0);
9
+ }
10
+ `,Or=`
11
+ precision highp float;
12
+ uniform sampler2D u_scene;
13
+ uniform sampler2D u_bloom;
14
+ uniform vec2 u_resolution;
15
+ uniform float u_time;
16
+
17
+ float hash(vec2 p) {
18
+ return fract(sin(dot(p, vec2(127.1, 311.7))) * 43758.5453);
19
+ }
20
+
21
+ void main() {
22
+ vec2 uv = gl_FragCoord.xy / u_resolution;
23
+ vec4 scene = texture2D(u_scene, uv);
24
+ vec4 bloom = texture2D(u_bloom, uv);
25
+ vec3 color = scene.rgb + bloom.rgb * 0.35;
26
+ float vignette = 1.0 - 0.4 * length((uv - 0.5) * 1.5);
27
+ color *= vignette;
28
+ float scan = 0.97 + 0.03 * sin(uv.y * u_resolution.y * 1.5 + u_time * 0.5);
29
+ color *= scan;
30
+ color += (hash(uv + u_time * 0.001) - 0.5) * 0.015;
31
+ color = pow(color, vec3(0.95));
32
+ gl_FragColor = vec4(color, 1.0);
33
+ }
34
+ `,Ur=`
35
+ precision highp float;
36
+ uniform sampler2D u_texture;
37
+ uniform vec2 u_resolution;
38
+ uniform float u_radius;
39
+ void main() {
40
+ vec2 uv = gl_FragCoord.xy / u_resolution;
41
+ float texelSize = 1.0 / u_resolution.x;
42
+ vec3 result = vec3(0.0);
43
+ float weights[5];
44
+ weights[0] = 0.227027;
45
+ weights[1] = 0.1945946;
46
+ weights[2] = 0.1216216;
47
+ weights[3] = 0.054054;
48
+ weights[4] = 0.016216;
49
+ result += texture2D(u_texture, uv).rgb * weights[0];
50
+ for (int i = 1; i < 5; i++) {
51
+ float offset = float(i) * texelSize * u_radius;
52
+ result += texture2D(u_texture, uv + vec2(offset, 0.0)).rgb * weights[i];
53
+ result += texture2D(u_texture, uv - vec2(offset, 0.0)).rgb * weights[i];
54
+ }
55
+ gl_FragColor = vec4(result, 1.0);
56
+ }
57
+ `,Xr=`
58
+ precision highp float;
59
+ uniform sampler2D u_texture;
60
+ uniform vec2 u_resolution;
61
+ uniform float u_radius;
62
+ void main() {
63
+ vec2 uv = gl_FragCoord.xy / u_resolution;
64
+ float texelSize = 1.0 / u_resolution.y;
65
+ vec3 result = vec3(0.0);
66
+ float weights[5];
67
+ weights[0] = 0.227027;
68
+ weights[1] = 0.1945946;
69
+ weights[2] = 0.1216216;
70
+ weights[3] = 0.054054;
71
+ weights[4] = 0.016216;
72
+ result += texture2D(u_texture, uv).rgb * weights[0];
73
+ for (int i = 1; i < 5; i++) {
74
+ float offset = float(i) * texelSize * u_radius;
75
+ result += texture2D(u_texture, uv + vec2(0.0, offset)).rgb * weights[i];
76
+ result += texture2D(u_texture, uv - vec2(0.0, offset)).rgb * weights[i];
77
+ }
78
+ gl_FragColor = vec4(result, 1.0);
79
+ }
80
+ `,Br=`
81
+ precision highp float;
82
+ uniform sampler2D u_texture;
83
+ uniform vec2 u_resolution;
84
+ uniform float u_threshold;
85
+ void main() {
86
+ vec2 uv = gl_FragCoord.xy / u_resolution;
87
+ vec4 color = texture2D(u_texture, uv);
88
+ float brightness = dot(color.rgb, vec3(0.2126, 0.7152, 0.0722));
89
+ float contribution = smoothstep(u_threshold, u_threshold + 0.15, brightness);
90
+ gl_FragColor = vec4(color.rgb * contribution * 1.5, 1.0);
91
+ }
92
+ `;function Ft(e,r,n){const i=e.createShader(n);return i?(e.shaderSource(i,r),e.compileShader(i),e.getShaderParameter(i,e.COMPILE_STATUS)?i:(console.error("Shader compile error:",e.getShaderInfoLog(i)),e.deleteShader(i),null)):null}function Ge(e,r,n){const i=Ft(e,r,e.VERTEX_SHADER),s=Ft(e,n,e.FRAGMENT_SHADER);if(!i||!s)return null;const o=e.createProgram();return o?(e.attachShader(o,i),e.attachShader(o,s),e.linkProgram(o),e.getProgramParameter(o,e.LINK_STATUS)?o:(console.error("Program link error:",e.getProgramInfoLog(o)),null)):null}function je(e,r,n){const i=e.createFramebuffer(),s=e.createTexture();return!i||!s?null:(e.bindTexture(e.TEXTURE_2D,s),e.texImage2D(e.TEXTURE_2D,0,e.RGBA,r,n,0,e.RGBA,e.UNSIGNED_BYTE,null),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),e.bindFramebuffer(e.FRAMEBUFFER,i),e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,s,0),e.bindFramebuffer(e.FRAMEBUFFER,null),{fb:i,tex:s})}function Yr(e,r,n,i){e.fillStyle=M.grid;for(let o=50;o<r;o+=50)for(let l=50;l<n;l+=50){const f=Math.sqrt((o-r/2)**2+(l-n/2)**2),h=Math.sin(i*3e-4+f*.004)*.3+.7;e.globalAlpha=.12*h,e.beginPath(),e.arc(o,l,.8,0,Math.PI*2),e.fill()}e.globalAlpha=1}function zr(e,r,n,i,s,o,l,f,h,u){var k,p;e.clearRect(0,0,r,n);const v=h||{scale:1,offsetX:0,offsetY:0},d=u||new Set,y=new Set,b=new Set,x=o||l;if(x)for(const g of s)(g.source===x||g.target===x)&&(y.add(g.source),y.add(g.target),b.add(g.id));Yr(e,r,n,f),e.save(),e.translate(v.offsetX,v.offsetY),e.scale(v.scale,v.scale);const E=i.filter(g=>g.isGtm||pe.has(g.id)||!g.parentGtm?!0:d.has(g.parentGtm)),w=i.filter(g=>g.isGtm),R=new Map(i.map(g=>[g.id,g]));for(const g of w){if(!d.has(g.id))continue;const c=i.filter(m=>m.parentGtm===g.id);if(c.length===0)continue;let S=0;for(const m of c){const a=m.x-g.x,$=m.y-g.y,L=Math.sqrt(a*a+$*$)+m.radius+20;S=Math.max(S,L)}const C=Math.max(S,80);e.save(),e.globalAlpha=.08,e.strokeStyle=g.color,e.lineWidth=1,e.setLineDash([8,12]),e.beginPath(),e.arc(g.x,g.y,C,0,Math.PI*2),e.stroke(),e.setLineDash([]);const T=e.createRadialGradient(g.x,g.y,0,g.x,g.y,C);T.addColorStop(0,de(g.color,.03)),T.addColorStop(.7,de(g.color,.015)),T.addColorStop(1,de(g.color,0)),e.fillStyle=T,e.beginPath(),e.arc(g.x,g.y,C,0,Math.PI*2),e.fill(),e.restore()}const _=i.filter(g=>pe.has(g.id));if(_.length>1){let g=0,D=0;for(const T of _)g+=T.x,D+=T.y;const c=g/_.length,S=D/_.length;let C=0;for(const T of _){const m=T.x-c,a=T.y-S,$=Math.sqrt(m*m+a*a)+T.radius+15;C=Math.max(C,$)}e.save(),e.globalAlpha=.06,e.strokeStyle=M.purple,e.lineWidth=1,e.setLineDash([4,8]),e.beginPath(),e.arc(c,S,C,0,Math.PI*2),e.stroke(),e.setLineDash([]),e.restore()}const F=new Set;for(const g of s){let D=R.get(g.source),c=R.get(g.target);if(!D||!c)continue;const S=D.parentGtm&&!d.has(D.parentGtm),C=c.parentGtm&&!d.has(c.parentGtm);if(S){const A=R.get(D.parentGtm);A&&(D=A)}if(C){const A=R.get(c.parentGtm);A&&(c=A)}if(D.id===c.id)continue;const T=`${D.id}->${c.id}`,m=S||C;if(m){if(F.has(T))continue;F.add(T)}const a=b.has(g.id)||S&&g.source&&((k=R.get(g.source))==null?void 0:k.parentGtm)===D.id||C&&g.target&&((p=R.get(g.target))==null?void 0:p.parentGtm)===c.id,$=b.size>0&&!a,{sx:L,sy:X,c1x:O,c1y:se,c2x:ie,c2y:ge,ex:me,ey:le}=dt(D,c),xe=Date.now()-g.lastFired,z=xe<5e3,we=z?1-xe/5e3:0,G=g.active?a?.8:.35:.08,B=$?.05:Math.min(1,G+we*.5),N=m?1.8:1;e.save(),e.globalAlpha=B*.4,e.strokeStyle=g.color,e.shadowColor=g.color,e.shadowBlur=a?20:z?14:8,e.lineWidth=(a?5:3)*N,e.beginPath(),e.moveTo(L,X),e.bezierCurveTo(O,se,ie,ge,me,le),e.stroke(),e.restore(),e.save(),e.globalAlpha=B,e.strokeStyle=g.color,e.lineWidth=(a?2.5:1.2)*N,e.beginPath(),e.moveTo(L,X),e.bezierCurveTo(O,se,ie,ge,me,le),e.stroke(),e.restore();const q=.88,[Z,re]=Ee(L,X,O,se,ie,ge,me,le,q),[Y,H]=Ee(L,X,O,se,ie,ge,me,le,q+.04),V=Math.atan2(H-re,Y-Z),I=(a?9:6)*N;if(e.save(),e.globalAlpha=B,e.fillStyle=g.color,e.shadowColor=g.color,e.shadowBlur=6,e.translate(Y,H),e.rotate(V),e.beginPath(),e.moveTo(0,0),e.lineTo(-I*1.2,-I*.5),e.lineTo(-I*1.2,I*.5),e.closePath(),e.fill(),e.restore(),g.active||z)for(const A of g.particles){const ee=$?.05:A.alpha*(a?1:.6);for(let be=A.trail.length-1;be>=0;be--){const Ze=A.trail[be];e.save(),e.globalAlpha=Ze.a*ee*.3,e.fillStyle=g.color,e.shadowColor=g.color,e.shadowBlur=A.size*2,e.beginPath(),e.arc(Ze.x,Ze.y,A.size*(1-be*.1),0,Math.PI*2),e.fill(),e.restore()}const[ce,he]=Ee(L,X,O,se,ie,ge,me,le,A.t);e.save(),e.globalAlpha=ee,e.fillStyle="#ffffff",e.shadowColor=g.color,e.shadowBlur=A.size*6,e.beginPath(),e.arc(ce,he,A.size*.6,0,Math.PI*2),e.fill(),e.restore(),e.save(),e.globalAlpha=ee*.7,e.fillStyle=g.color,e.shadowColor=g.color,e.shadowBlur=A.size*10,e.beginPath(),e.arc(ce,he,A.size*1.2,0,Math.PI*2),e.fill(),e.restore()}}for(const g of E){const D=o===g.id,c=l===g.id,C=y.size>0&&!y.has(g.id)&&!D&&!c?.15:1,T=g.isGtm&&!d.has(g.id),m=Math.sin(f*.002+g.pulsePhase)*.15+.85,a=g.radius*(D?1.15:c?1.1:1);if(g.status==="running"||D||c){const X=a*(c?2.2:D?2:T?1.4:1.6)*m,O=e.createRadialGradient(g.x,g.y,a*.5,g.x,g.y,X);O.addColorStop(0,de(g.color,.15*C)),O.addColorStop(.5,de(g.color,.04*C)),O.addColorStop(1,de(g.color,0)),e.fillStyle=O,e.beginPath(),e.arc(g.x,g.y,X,0,Math.PI*2),e.fill()}if(g.isGtm){const X=a*(T?1.3:1.6),O=(Math.sin(f*.002+g.pulsePhase)*.2+.4)*C;e.save(),e.globalAlpha=O*.25,e.strokeStyle=g.color,e.lineWidth=T?3:2.5,e.beginPath(),e.arc(g.x,g.y,X,0,Math.PI*2),e.stroke(),e.restore(),e.save(),e.globalAlpha=O*.15,e.strokeStyle=g.color,e.lineWidth=1,e.setLineDash([6,4]),e.beginPath(),e.arc(g.x,g.y,a*1.15,0,Math.PI*2),e.stroke(),e.setLineDash([]),e.restore()}else if(g.status==="running"){const X=(Math.sin(f*.003+g.pulsePhase)*.3+.5)*C,O=a*(1.5+Math.sin(f*.001+g.pulsePhase*2)*.3);e.save(),e.globalAlpha=X*.15,e.strokeStyle=g.color,e.lineWidth=1,e.setLineDash([4,6]),e.beginPath(),e.arc(g.x,g.y,O,0,Math.PI*2),e.stroke(),e.setLineDash([]),e.restore()}const $=e.createRadialGradient(g.x-a*.2,g.y-a*.2,0,g.x,g.y,a);$.addColorStop(0,de(g.color,.3*C)),$.addColorStop(.7,de(g.color,.12*C)),$.addColorStop(1,de(g.color,.05*C)),e.save(),e.fillStyle=$,e.shadowColor=g.color,e.shadowBlur=c?25:D?18:T?15:10,e.globalAlpha=C,e.beginPath(),e.arc(g.x,g.y,a,0,Math.PI*2),e.fill(),e.restore(),e.save(),e.globalAlpha=C*(c?.9:D?.7:.4),e.strokeStyle=g.color,e.lineWidth=c?2:1.2,e.beginPath(),e.arc(g.x,g.y,a,0,Math.PI*2),e.stroke(),e.restore();const L=e.createRadialGradient(g.x,g.y,0,g.x,g.y,a*.35);L.addColorStop(0,de("#ffffff",.6*C*m)),L.addColorStop(.5,de(g.color,.4*C*m)),L.addColorStop(1,de(g.color,0)),e.fillStyle=L,e.beginPath(),e.arc(g.x,g.y,a*.35,0,Math.PI*2),e.fill()}e.restore()}function Pt({data:e,color:r,width:n=48,height:i=16}){if(e.length<2)return null;const s=Math.max(...e),o=Math.min(...e),l=s-o||1,f=e.map((u,v)=>{const d=v/(e.length-1)*n,y=i-(u-o)/l*(i-2)-1;return`${d},${y}`}).join(" "),h=i-(e[e.length-1]-o)/l*(i-2)-1;return t("svg",{width:n,height:i,class:"shrink-0",children:[t("polyline",{points:f,fill:"none",stroke:r,"stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round",opacity:"0.7"}),t("circle",{cx:String(n),cy:String(h),r:"2",fill:r,children:t("animate",{attributeName:"opacity",values:"1;0.4;1",dur:"2s",repeatCount:"indefinite"})})]})}function Hr(){var g,D;const e=fe(null),r=fe(null),n=fe(0),i=fe(!0),s=fe({nodes:[],edges:[],hoveredNode:null,selectedNode:null,dragging:null,dragOffset:{x:0,y:0},mouse:{x:0,y:0},time:0,liveEventQueue:[],offscreenCanvas:null,offscreenCtx:null,gl:null,programs:{threshold:null,blurH:null,blurV:null,composite:null},fbos:{scene:null,bright:null,pingpong:[null,null]},quadVBO:null,sceneTexture:null,fboWidth:0,fboHeight:0}),[o,l]=j(null),[f,h]=j(!1),[u,v]=j([]),[,d]=j(0),[y,b]=j([]),[x,E]=j(new Set),[w,R]=j({scale:1,offsetX:0,offsetY:0}),_=fe(!1),F=fe({x:0,y:0,offsetX:0,offsetY:0}),k=Fe(c=>{const S=s.current;if(!c||S.selectedNode===c.id)S.selectedNode=null,l(null);else{S.selectedNode=c.id;const C=S.edges.filter($=>$.source===c.id||$.target===c.id),T=[];for(const $ of C){const L=$.source===c.id,X=L?$.target:$.source,O=S.nodes.find(se=>se.id===X);O&&T.push({id:X,label:O.label,direction:L?"out":"in",eventType:$.eventType})}const m=u.filter($=>{const L=$.type.toLowerCase(),X=c.id.toLowerCase();return L.includes(X.split("-")[0])||C.some(O=>L.startsWith(O.eventType.split(":")[0]))}).slice(0,8).map($=>({type:$.type,ts:$.ts,data:"",source:void 0})),a=m.length>0?m:C.slice(0,5).map($=>({type:$.eventType,ts:new Date($.lastFired).toISOString(),data:`${$.source} -> ${$.target}`,source:$.source}));l({node:c,edges:C,recentEvents:a,connectedServices:T})}},[u]);ve(()=>{const c=e.current,S=r.current;if(!c||!S)return;const C=document.createElement("canvas"),T=C.getContext("2d");if(!T)return;const m=s.current;m.offscreenCanvas=C,m.offscreenCtx=T;const a=c.getContext("webgl",{alpha:!1,antialias:!1,premultipliedAlpha:!1});if(a){m.gl=a,m.programs.threshold=Ge(a,Le,Br),m.programs.blurH=Ge(a,Le,Ur),m.programs.blurV=Ge(a,Le,Xr),m.programs.composite=Ge(a,Le,Or);const G=new Float32Array([-1,-1,1,-1,-1,1,1,1]),B=a.createBuffer();a.bindBuffer(a.ARRAY_BUFFER,B),a.bufferData(a.ARRAY_BUFFER,G,a.STATIC_DRAW),m.quadVBO=B,m.sceneTexture=a.createTexture(),i.current=!0}else i.current=!1;const $=(G,B)=>{if(!a)return;const N=Math.floor(G/2),q=Math.floor(B/2);m.fbos.scene=je(a,G,B),m.fbos.bright=je(a,N,q),m.fbos.pingpong=[je(a,N,q),je(a,N,q)],m.fboWidth=G,m.fboHeight=B},L=()=>{const G=S.getBoundingClientRect(),B=Math.min(window.devicePixelRatio||1,2),N=Math.floor(G.width*B),q=Math.floor(G.height*B);c.width=N,c.height=q,c.style.width=G.width+"px",c.style.height=G.height+"px",C.width=N,C.height=q,a&&(a.viewport(0,0,N,q),$(N,q)),U.topology().then(({nodes:Z,edges:re})=>{if(Z.length>=6){const{nodes:H,edges:V}=Nr(Z,re);m.nodes=H,m.edges=V,h(!0)}else{const{nodes:H,edges:V}=At();m.nodes=H,m.edges=V}const Y=S.getBoundingClientRect();Ie(m.nodes,Y.width,Y.height,m.edges,x),b([...m.nodes]),d(H=>H+1)}).catch(()=>{if(m.nodes.length===0){const{nodes:Z,edges:re}=At();m.nodes=Z,m.edges=re}Ie(m.nodes,G.width,G.height,m.edges,x),b([...m.nodes]),d(Z=>Z+1)})};L(),window.addEventListener("resize",L);const X=(G,B)=>{const{scale:N,offsetX:q,offsetY:Z}=w;return{x:(G-q)/N,y:(B-Z)/N}},O=G=>{const B=c.getBoundingClientRect(),N=G.clientX-B.left,q=G.clientY-B.top;if(m.mouse={x:N,y:q},_.current){const I=N-F.current.x,A=q-F.current.y;R(ee=>({...ee,offsetX:F.current.offsetX+I,offsetY:F.current.offsetY+A}));return}const{x:Z,y:re}=X(N,q);if(m.dragging){const I=m.nodes.find(A=>A.id===m.dragging);I&&(I.x=Z-m.dragOffset.x,I.y=re-m.dragOffset.y,I.targetX=I.x,I.targetY=I.y);return}const Y=m.nodes.filter(I=>I.isGtm||pe.has(I.id)||!I.parentGtm?!0:x.has(I.parentGtm));let H=null,V=1/0;for(const I of Y){const A=st(I.x,I.y,Z,re,I.radius*1.5);A<V&&A<20/w.scale&&(V=A,H=I)}m.hoveredNode=(H==null?void 0:H.id)||null,c.style.cursor=H?"pointer":_.current?"grabbing":"default"},se=G=>{const B=c.getBoundingClientRect(),N=G.clientX-B.left,q=G.clientY-B.top,{x:Z,y:re}=X(N,q),Y=m.nodes.filter(V=>V.isGtm||pe.has(V.id)||!V.parentGtm?!0:x.has(V.parentGtm));let H=null;for(const V of Y)if(st(V.x,V.y,Z,re,V.radius*1.5)<5/w.scale){H=V;break}H?(m.dragging=H.id,m.dragOffset={x:Z-H.x,y:re-H.y}):(_.current=!0,F.current={x:N,y:q,offsetX:w.offsetX,offsetY:w.offsetY},c.style.cursor="grabbing")},ie=G=>{const B=m.dragging,N=_.current,q=c.getBoundingClientRect(),Z=G.clientX-q.left,re=G.clientY-q.top,{x:Y,y:H}=X(Z,re);if(N){const A=Math.sqrt((Z-F.current.x)**2+(re-F.current.y)**2);_.current=!1,c.style.cursor="default",A<5&&(m.selectedNode=null,l(null));return}if(B){const A=m.nodes.find(ee=>ee.id===B);if(m.dragging=null,A&&Math.sqrt((Y-(m.dragOffset.x+A.targetX))**2+(H-(m.dragOffset.y+A.targetY))**2)<5/w.scale)if(A.isGtm){E(he=>{const be=new Set(he);return be.has(A.id)?be.delete(A.id):be.add(A.id),be});const ce=S.getBoundingClientRect();setTimeout(()=>{Ie(m.nodes,ce.width,ce.height,m.edges,x.has(A.id)?new Set([...x].filter(he=>he!==A.id)):new Set([...x,A.id])),d(he=>he+1)},10)}else k(A);return}const V=m.nodes.filter(A=>A.isGtm||pe.has(A.id)||!A.parentGtm?!0:x.has(A.parentGtm));let I=null;for(const A of V)if(st(A.x,A.y,Y,H,A.radius*1.5)<5/w.scale){I=A;break}if(I)if(I.isGtm){E(ee=>{const ce=new Set(ee);return ce.has(I.id)?ce.delete(I.id):ce.add(I.id),ce});const A=S.getBoundingClientRect();setTimeout(()=>{Ie(m.nodes,A.width,A.height,m.edges,x.has(I.id)?new Set([...x].filter(ee=>ee!==I.id)):new Set([...x,I.id])),d(ee=>ee+1)},10)}else k(I);else m.selectedNode=null,l(null)},ge=G=>{G.preventDefault();const B=c.getBoundingClientRect(),N=G.clientX-B.left,q=G.clientY-B.top,Z=G.deltaY<0?1.1:.9,re=Math.max(.3,Math.min(3,w.scale*Z)),Y=(N-w.offsetX)/w.scale,H=(q-w.offsetY)/w.scale;R({scale:re,offsetX:N-Y*re,offsetY:q-H*re})},me=G=>{G.preventDefault(),R({scale:1,offsetX:0,offsetY:0})};c.addEventListener("mousemove",O),c.addEventListener("mousedown",se),c.addEventListener("mouseup",ie),c.addEventListener("wheel",ge,{passive:!1}),c.addEventListener("dblclick",me);function le(G){if(!a||!m.quadVBO)return;a.useProgram(G),a.bindBuffer(a.ARRAY_BUFFER,m.quadVBO);const B=a.getAttribLocation(G,"a_position");a.enableVertexAttribArray(B),a.vertexAttribPointer(B,2,a.FLOAT,!1,0,0),a.drawArrays(a.TRIANGLE_STRIP,0,4)}let xe=performance.now();const z=G=>{const B=G-xe;xe=G,m.time=G;for(const Y of m.nodes)m.dragging!==Y.id&&(Y.x+=(Y.targetX-Y.x)*.06,Y.y+=(Y.targetY-Y.y)*.06);for(const Y of m.edges){if(!Y.active&&Date.now()-Y.lastFired>1e4)continue;const H=m.nodes.find(A=>A.id===Y.source),V=m.nodes.find(A=>A.id===Y.target);if(!H||!V)continue;const I=dt(H,V);for(const A of Y.particles){A.t+=A.speed*(B/16),A.t>1&&(A.t-=1,A.speed=8e-4+Math.random()*.0015,A.trail=[]);const[ee,ce]=Ee(I.sx,I.sy,I.c1x,I.c1y,I.c2x,I.c2y,I.ex,I.ey,A.t);A.trail.unshift({x:ee,y:ce,a:A.alpha}),A.trail.length>8&&A.trail.pop();for(let he=0;he<A.trail.length;he++)A.trail[he].a*=.82}}const N=Math.min(window.devicePixelRatio||1,2),q=S.getBoundingClientRect(),Z=q.width,re=q.height;if(T&&(T.save(),T.scale(N,N),zr(T,Z,re,m.nodes,m.edges,m.hoveredNode,m.selectedNode,G,w,x),T.restore()),a&&i.current&&m.sceneTexture&&m.fbos.scene&&m.fbos.bright&&m.fbos.pingpong[0]&&m.fbos.pingpong[1]){const Y=m.fboWidth,H=m.fboHeight,V=Math.floor(Y/2),I=Math.floor(H/2);a.bindTexture(a.TEXTURE_2D,m.sceneTexture),a.texImage2D(a.TEXTURE_2D,0,a.RGBA,a.RGBA,a.UNSIGNED_BYTE,C),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MIN_FILTER,a.LINEAR),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MAG_FILTER,a.LINEAR),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_WRAP_S,a.CLAMP_TO_EDGE),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_WRAP_T,a.CLAMP_TO_EDGE),m.programs.threshold&&(a.bindFramebuffer(a.FRAMEBUFFER,m.fbos.bright.fb),a.viewport(0,0,V,I),a.useProgram(m.programs.threshold),a.activeTexture(a.TEXTURE0),a.bindTexture(a.TEXTURE_2D,m.sceneTexture),a.uniform1i(a.getUniformLocation(m.programs.threshold,"u_texture"),0),a.uniform2f(a.getUniformLocation(m.programs.threshold,"u_resolution"),V,I),a.uniform1f(a.getUniformLocation(m.programs.threshold,"u_threshold"),.45),le(m.programs.threshold));const A=4;for(let ee=0;ee<A;ee++){const ce=2+ee*1.5;if(m.programs.blurH){const he=ee===0?m.fbos.bright:m.fbos.pingpong[1];a.bindFramebuffer(a.FRAMEBUFFER,m.fbos.pingpong[0].fb),a.viewport(0,0,V,I),a.useProgram(m.programs.blurH),a.activeTexture(a.TEXTURE0),a.bindTexture(a.TEXTURE_2D,he.tex),a.uniform1i(a.getUniformLocation(m.programs.blurH,"u_texture"),0),a.uniform2f(a.getUniformLocation(m.programs.blurH,"u_resolution"),V,I),a.uniform1f(a.getUniformLocation(m.programs.blurH,"u_radius"),ce),le(m.programs.blurH)}m.programs.blurV&&(a.bindFramebuffer(a.FRAMEBUFFER,m.fbos.pingpong[1].fb),a.viewport(0,0,V,I),a.useProgram(m.programs.blurV),a.activeTexture(a.TEXTURE0),a.bindTexture(a.TEXTURE_2D,m.fbos.pingpong[0].tex),a.uniform1i(a.getUniformLocation(m.programs.blurV,"u_texture"),0),a.uniform2f(a.getUniformLocation(m.programs.blurV,"u_resolution"),V,I),a.uniform1f(a.getUniformLocation(m.programs.blurV,"u_radius"),ce),le(m.programs.blurV))}m.programs.composite&&(a.bindFramebuffer(a.FRAMEBUFFER,null),a.viewport(0,0,Y,H),a.useProgram(m.programs.composite),a.activeTexture(a.TEXTURE0),a.bindTexture(a.TEXTURE_2D,m.sceneTexture),a.uniform1i(a.getUniformLocation(m.programs.composite,"u_scene"),0),a.activeTexture(a.TEXTURE1),a.bindTexture(a.TEXTURE_2D,m.fbos.pingpong[1].tex),a.uniform1i(a.getUniformLocation(m.programs.composite,"u_bloom"),1),a.uniform2f(a.getUniformLocation(m.programs.composite,"u_resolution"),Y,H),a.uniform1f(a.getUniformLocation(m.programs.composite,"u_time"),G*.001),le(m.programs.composite))}else if(!i.current){const Y=c.getContext("2d");Y&&C&&(Y.clearRect(0,0,c.width,c.height),Y.drawImage(C,0,0))}n.current=requestAnimationFrame(z)};n.current=requestAnimationFrame(z);let we=null;try{we=qt("/api/events/stream",G=>{h(!0);const B=G;v(N=>[{type:B.type,ts:B.ts},...N].slice(0,20));for(const N of m.edges)(B.type===N.eventType||B.type.startsWith(N.eventType.split(":")[0]+":"))&&(N.lastFired=Date.now(),N.active=!0,N.particles.push({t:0,speed:.003+Math.random()*.002,size:3.5,alpha:1,trail:[]}),setTimeout(()=>{N.particles.length>10&&N.particles.shift()},3e3))})}catch{}return()=>{window.removeEventListener("resize",L),c.removeEventListener("mousemove",O),c.removeEventListener("mousedown",se),c.removeEventListener("mouseup",ie),c.removeEventListener("wheel",ge),c.removeEventListener("dblclick",me),cancelAnimationFrame(n.current),we==null||we()}},[k,w,x]);const p=s.current;return t("div",{class:"flex h-[calc(100vh-3rem)] gap-0",children:[t("div",{ref:r,class:"flex-1 relative overflow-hidden",style:{background:M.bg},children:[t("style",{children:`
93
+ @keyframes topo-breathe {
94
+ 0%, 100% { opacity: 0.25; }
95
+ 50% { opacity: 0.5; }
96
+ }
97
+ @keyframes topo-float-1 {
98
+ 0%, 100% { transform: translate(0, 0) scale(1); }
99
+ 33% { transform: translate(25px, -18px) scale(1.05); }
100
+ 66% { transform: translate(-12px, 14px) scale(0.95); }
101
+ }
102
+ @keyframes topo-float-2 {
103
+ 0%, 100% { transform: translate(0, 0) scale(1); }
104
+ 33% { transform: translate(-30px, 12px) scale(1.08); }
105
+ 66% { transform: translate(18px, -24px) scale(0.92); }
106
+ }
107
+ @keyframes topo-float-3 {
108
+ 0%, 100% { transform: translate(0, 0) scale(1); }
109
+ 33% { transform: translate(14px, 22px) scale(0.96); }
110
+ 66% { transform: translate(-22px, -14px) scale(1.04); }
111
+ }
112
+ .topo-orb-1 { animation: topo-float-1 12s ease-in-out infinite; }
113
+ .topo-orb-2 { animation: topo-float-2 15s ease-in-out infinite; }
114
+ .topo-orb-3 { animation: topo-float-3 18s ease-in-out infinite; }
115
+ @keyframes topo-status-pulse {
116
+ 0%, 100% { box-shadow: 0 0 4px currentColor; opacity: 1; }
117
+ 50% { box-shadow: 0 0 10px currentColor; opacity: 0.7; }
118
+ }
119
+ .topo-status-pulse { animation: topo-status-pulse 2s ease-in-out infinite; }
120
+ `}),t("div",{class:"absolute inset-0 pointer-events-none overflow-hidden",style:{zIndex:0},children:[t("div",{class:"absolute rounded-full topo-orb-1",style:{width:"360px",height:"360px",left:"12%",top:"18%",background:`radial-gradient(circle, ${de(M.info,.06)} 0%, transparent 70%)`,filter:"blur(40px)"}}),t("div",{class:"absolute rounded-full topo-orb-2",style:{width:"400px",height:"400px",right:"10%",bottom:"15%",background:`radial-gradient(circle, ${de(M.purple,.05)} 0%, transparent 70%)`,filter:"blur(50px)"}}),t("div",{class:"absolute rounded-full topo-orb-3",style:{width:"280px",height:"280px",left:"45%",top:"40%",background:`radial-gradient(circle, ${de(M.cyan,.04)} 0%, transparent 70%)`,filter:"blur(35px)"}})]}),t("canvas",{ref:e,class:"absolute inset-0 w-full h-full",style:{zIndex:1,pointerEvents:"none"}}),p.nodes.length>0&&t("div",{class:"absolute inset-0 pointer-events-none",style:{zIndex:5},children:[p.nodes.filter(c=>c.isGtm).map(c=>{const S=p.nodes.filter(m=>m.parentGtm===c.id);let C=c.y;for(const m of S)C=Math.min(C,m.y-m.radius);const T=C-45;return t("div",{class:"absolute",style:{left:`${c.x}px`,top:`${Math.max(20,T)}px`,transform:"translateX(-50%)"},children:t("span",{style:{fontSize:"9px",fontFamily:"'JetBrains Mono', monospace",fontWeight:600,padding:"3px 10px",borderRadius:"12px",color:c.color,background:"rgba(15, 15, 18, 0.7)",border:`1px solid ${c.color}30`,textTransform:"uppercase",letterSpacing:"1.5px"},children:c.label.replace(/-gtm$/i,"").toUpperCase()})},`cluster-${c.id}`)}),p.nodes.filter(c=>pe.has(c.id)).length>1&&(()=>{const c=p.nodes.filter(a=>pe.has(a.id));let S=0,C=1/0;for(const a of c)S+=a.x,C=Math.min(C,a.y-a.radius);const T=S/c.length,m=C-35;return t("div",{class:"absolute",style:{left:`${T}px`,top:`${Math.max(20,m)}px`,transform:"translateX(-50%)"},children:t("span",{style:{fontSize:"8px",fontFamily:"'JetBrains Mono', monospace",fontWeight:500,padding:"2px 8px",borderRadius:"10px",color:M.purple,background:"rgba(15, 15, 18, 0.6)",border:`1px solid ${M.purple}25`,textTransform:"uppercase",letterSpacing:"1px"},children:"SYSTEM"})})})()]}),y.length>0&&t("div",{class:"absolute inset-0 pointer-events-none",style:{zIndex:2,transform:`translate(${w.offsetX}px, ${w.offsetY}px) scale(${w.scale})`,transformOrigin:"0 0"},children:y.filter(c=>c.isGtm||pe.has(c.id)||!c.parentGtm?!0:x.has(c.parentGtm)).map(c=>{const S=p.hoveredNode===c.id,C=p.selectedNode===c.id,T=p.hoveredNode||p.selectedNode,m=new Set;if(T)for(const L of p.edges)(L.source===T||L.target===T)&&(m.add(L.source),m.add(L.target));const a=m.size>0&&!m.has(c.id)&&!S&&!C,$=c.isGtm&&!x.has(c.id);return t("div",{class:"absolute pointer-events-auto",style:{left:`${c.x}px`,top:`${c.y+c.radius+14}px`,transform:`translateX(-50%) scale(${1/w.scale})`,transformOrigin:"center top",transition:"opacity 0.3s ease",opacity:a?.15:S||C?1:.8,cursor:c.isGtm?"pointer":"default"},children:t("div",{style:{background:C?"rgba(18, 18, 22, 0.92)":"rgba(18, 18, 22, 0.75)",backdropFilter:"blur(16px)",WebkitBackdropFilter:"blur(16px)",border:`1px solid ${C?c.color+"55":S?c.color+"33":"rgba(255,255,255,0.06)"}`,borderRadius:"10px",padding:$?"10px 14px":"8px 12px",whiteSpace:"nowrap",boxShadow:C?`0 0 24px ${c.color}22, 0 4px 16px rgba(0,0,0,0.5), inset 0 1px 0 rgba(255,255,255,0.06)`:"0 2px 10px rgba(0,0,0,0.35), inset 0 1px 0 rgba(255,255,255,0.04)",transition:"border-color 0.25s ease, box-shadow 0.3s ease"},children:[t("div",{style:{display:"flex",alignItems:"center",gap:"7px"},children:[t("span",{class:P("topo-status-pulse"),style:{width:"7px",height:"7px",borderRadius:"50%",flexShrink:0,backgroundColor:Te(c.status),color:Te(c.status),display:(c.status==="running","block"),boxShadow:c.status==="running"?void 0:"none",animation:c.status==="running"?void 0:"none"}}),t("span",{style:{fontSize:$?"13px":c.isGtm?"12px":"11px",fontWeight:c.isGtm?700:600,color:M.text},children:jr(c.label,c.isGtm?20:16)}),$&&c.childCount?t("span",{style:{fontSize:"9px",fontFamily:"'JetBrains Mono', monospace",padding:"2px 6px",borderRadius:"6px",backgroundColor:`${c.color}20`,color:c.color},children:[c.childCount," services"]}):t("span",{style:{fontSize:"8px",fontFamily:"'JetBrains Mono', monospace",padding:"1px 5px",borderRadius:"4px",backgroundColor:`${c.color}18`,color:c.color,textTransform:"uppercase",letterSpacing:"0.5px"},children:c.type})]}),t("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginTop:"5px",gap:"8px"},children:[t("span",{style:{fontSize:"9px",fontFamily:"'JetBrains Mono', monospace",color:M.textMuted},children:[c.eventCount," events"]}),t(Pt,{data:$&&c.aggregateReward?c.aggregateReward:c.reward,color:c.color,width:$?60:48,height:14})]}),$&&t("div",{style:{marginTop:"6px",fontSize:"8px",color:M.textDim,textAlign:"center"},children:"click to expand"})]})},c.id)})}),p.edges.length>0&&t("div",{class:"absolute inset-0 pointer-events-none",style:{zIndex:3,transform:`translate(${w.offsetX}px, ${w.offsetY}px) scale(${w.scale})`,transformOrigin:"0 0"},children:p.edges.map(c=>{const S=p.nodes.find(L=>L.id===c.source),C=p.nodes.find(L=>L.id===c.target);if(!S||!C||!(p.hoveredNode===c.source||p.hoveredNode===c.target||p.selectedNode===c.source||p.selectedNode===c.target))return null;const m=dt(S,C),[a,$]=Ee(m.sx,m.sy,m.c1x,m.c1y,m.c2x,m.c2y,m.ex,m.ey,.5);return t("div",{class:"absolute",style:{left:`${a}px`,top:`${$}px`,transform:`translate(-50%, -50%) scale(${1/w.scale})`},children:t("span",{style:{fontSize:"8px",fontFamily:"'JetBrains Mono', monospace",padding:"2px 6px",borderRadius:"5px",color:c.color,background:"rgba(15, 15, 18, 0.88)",border:`1px solid ${c.color}33`,backdropFilter:"blur(6px)",letterSpacing:"0.05em"},children:c.eventType})},c.id)})}),t("div",{class:"absolute top-5 left-5 flex items-center gap-3",style:{zIndex:10},children:[t("h1",{class:"text-base font-semibold tracking-tight",style:{color:M.text},children:"Agent Topology"}),t("span",{class:P("text-[9px] mono px-2 py-0.5 rounded-full tracking-widest uppercase",f?"text-success":"text-muted-foreground"),style:{background:f?"rgba(52, 211, 153, 0.1)":"rgba(90, 90, 90, 0.2)",border:`1px solid ${f?"rgba(52, 211, 153, 0.2)":"rgba(90, 90, 90, 0.15)"}`},children:f?"LIVE":"MOCK"})]}),t("div",{class:"absolute bottom-5 left-5 flex items-center gap-4",style:{zIndex:10},children:[{color:M.cyan,label:"GTM",isGtm:!0},{color:M.info,label:"Agent"},{color:M.purple,label:"Orchestrator"},{color:M.warning,label:"Eval"},{color:M.success,label:"Service"}].map(c=>t("div",{class:"flex items-center gap-1.5",children:[t("span",{style:{width:c.isGtm?"10px":"6px",height:c.isGtm?"10px":"6px",borderRadius:"50%",backgroundColor:c.color,boxShadow:`0 0 6px ${c.color}88`,border:c.isGtm?`1.5px solid ${c.color}`:"none"}}),t("span",{class:"text-[9px] uppercase tracking-wider",style:{color:M.textMuted},children:c.label})]},c.label))}),t("div",{class:"absolute bottom-5 flex items-center gap-4",style:{zIndex:10,right:o?"336px":"20px",transition:"right 0.3s ease"},children:[{color:M.info,label:"Data"},{color:M.success,label:"Success"},{color:M.purple,label:"RL"}].map(c=>t("div",{style:{display:"flex",alignItems:"center",gap:"6px"},children:[t("svg",{width:"20",height:"4",style:{flexShrink:0},children:t("line",{x1:"0",y1:"2",x2:"20",y2:"2",stroke:c.color,"stroke-width":"1.5","stroke-dasharray":"6 4"})}),t("span",{class:"text-[9px]",style:{color:M.textMuted},children:c.label})]},c.label))}),u.length>0&&t("div",{class:"absolute bottom-5 max-w-60",style:{zIndex:10,right:o?"336px":"20px",bottom:"40px",transition:"right 0.3s ease"},children:[t("div",{class:"text-[9px] uppercase tracking-widest font-medium mb-1.5",style:{color:M.textDim},children:"Live Events"}),t("div",{class:"space-y-0.5 max-h-28 overflow-hidden",children:u.slice(0,6).map((c,S)=>t("div",{class:"text-[9px] mono truncate animate-fade-in",style:{opacity:1-S*.14,color:M.textDim},children:[t("span",{style:{color:M.info},children:c.type})," ",t("span",{style:{opacity:.5},children:oe(c.ts)})]},`${c.ts}-${S}`))})]}),t("div",{class:"absolute",style:{right:o?"336px":"20px",bottom:"140px",width:"180px",height:"100px",background:"rgba(12, 12, 15, 0.85)",border:"1px solid rgba(60, 60, 60, 0.3)",borderRadius:"6px",overflow:"hidden",zIndex:10,transition:"right 0.3s ease"},onClick:c=>{const S=c.currentTarget.getBoundingClientRect(),C=c.clientX-S.left,T=c.clientY-S.top,m=s.current;if(m.nodes.length===0)return;let a=1/0,$=-1/0,L=1/0,X=-1/0;m.nodes.forEach(z=>{a=Math.min(a,z.x),$=Math.max($,z.x),L=Math.min(L,z.y),X=Math.max(X,z.y)});const O=50;a-=O,$+=O,L-=O,X+=O;const se=$-a,ie=X-L,ge=a+C/180*se,me=L+T/100*ie,le=e.current;if(!le)return;const{scale:xe}=w;R({scale:xe,offsetX:le.width/2-ge*xe,offsetY:le.height/2-me*xe})},children:t("svg",{width:"180",height:"100",style:{display:"block"},children:(()=>{const c=s.current;if(c.nodes.length===0)return null;let S=1/0,C=-1/0,T=1/0,m=-1/0;c.nodes.forEach(z=>{S=Math.min(S,z.x),C=Math.max(C,z.x),T=Math.min(T,z.y),m=Math.max(m,z.y)});const a=50;S-=a,C+=a,T-=a,m+=a;const $=C-S,L=m-T,X=c.nodes.filter(z=>z.isGtm||!z.parentGtm?!0:x.has(z.parentGtm)),O=z=>(z-S)/$*180,se=z=>(z-T)/L*100,ie=e.current,ge=ie?-w.offsetX/w.scale:0,me=ie?-w.offsetY/w.scale:0,le=ie?ie.width/w.scale:$,xe=ie?ie.height/w.scale:L;return t(ae,{children:[X.map(z=>{const G=z.isGtm&&!x.has(z.id)?5:z.isGtm?4:2;return t("circle",{cx:O(z.x),cy:se(z.y),r:G,fill:z.color,opacity:.8},z.id)}),t("rect",{x:O(ge),y:se(me),width:le/$*180,height:xe/L*100,fill:"none",stroke:M.info,"stroke-width":"1",opacity:.6})]})})()})})]}),o&&t("div",{class:"w-80 overflow-y-auto animate-slide-in",style:{background:"rgba(18, 18, 22, 0.95)",borderLeft:"1px solid rgba(60, 60, 60, 0.2)",backdropFilter:"blur(16px)",WebkitBackdropFilter:"blur(16px)",flexShrink:0},children:[t("div",{class:"p-4",style:{borderBottom:"1px solid rgba(60, 60, 60, 0.2)"},children:[t("div",{class:"flex items-center justify-between mb-3",children:[t("div",{class:"flex items-center gap-2.5",children:[t("span",{class:"w-3 h-3 rounded-full",style:{backgroundColor:o.node.color,boxShadow:`0 0 10px ${o.node.color}66`}}),t("h2",{class:"font-semibold text-sm",style:{color:M.text},children:o.node.label})]}),t("button",{onClick:()=>{s.current.selectedNode=null,l(null)},class:"p-1 rounded transition-colors",style:{color:M.textMuted,background:"none",border:"none",cursor:"pointer"},children:t("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2",children:t("path",{d:"M18 6L6 18M6 6l12 12"})})})]}),t("div",{class:"flex items-center gap-2 flex-wrap",children:[t("span",{class:"text-[9px] mono px-2 py-0.5 rounded-full uppercase tracking-wider",style:{backgroundColor:Te(o.node.status)+"15",color:Te(o.node.status),border:`1px solid ${Te(o.node.status)}22`},children:o.node.status}),t("span",{class:"text-[9px] mono px-2 py-0.5 rounded-full uppercase tracking-wider",style:{backgroundColor:o.node.color+"15",color:o.node.color,border:`1px solid ${o.node.color}22`},children:o.node.type})]}),(((g=o.node.produces)==null?void 0:g.length)||((D=o.node.consumes)==null?void 0:D.length))&&t("div",{class:"mt-3 space-y-2",children:[o.node.produces&&o.node.produces.length>0&&t("div",{children:[t("span",{class:"text-[8px] uppercase tracking-widest",style:{color:M.textDim},children:"produces"}),t("div",{class:"flex flex-wrap gap-1 mt-1",children:o.node.produces.map(c=>t("span",{class:"text-[8px] mono px-1.5 py-0.5 rounded",style:{background:`${M.success}15`,color:M.success,border:`1px solid ${M.success}25`},children:c},c))})]}),o.node.consumes&&o.node.consumes.length>0&&t("div",{children:[t("span",{class:"text-[8px] uppercase tracking-widest",style:{color:M.textDim},children:"consumes"}),t("div",{class:"flex flex-wrap gap-1 mt-1",children:o.node.consumes.map(c=>t("span",{class:"text-[8px] mono px-1.5 py-0.5 rounded",style:{background:`${M.info}15`,color:M.info,border:`1px solid ${M.info}25`},children:c},c))})]})]})]}),t("div",{class:"p-4 space-y-5",children:[t("div",{children:[t("div",{class:"text-[9px] uppercase tracking-widest font-medium mb-2.5",style:{color:M.textDim},children:"Stats"}),t("div",{class:"grid grid-cols-2 gap-2",children:[t("div",{class:"rounded-lg p-3",style:{background:"rgba(40, 40, 44, 0.4)",border:"1px solid rgba(60, 60, 60, 0.15)"},children:[t("div",{class:"text-[9px] uppercase tracking-wider",style:{color:M.textDim},children:"Events"}),t("div",{class:"text-lg font-semibold mono tabular-nums mt-1",style:{color:M.text},children:o.node.eventCount})]}),t("div",{class:"rounded-lg p-3",style:{background:"rgba(40, 40, 44, 0.4)",border:"1px solid rgba(60, 60, 60, 0.15)"},children:[t("div",{class:"text-[9px] uppercase tracking-wider",style:{color:M.textDim},children:"Connections"}),t("div",{class:"text-lg font-semibold mono tabular-nums mt-1",style:{color:M.text},children:o.edges.length})]})]})]}),t("div",{children:[t("div",{class:"text-[9px] uppercase tracking-widest font-medium mb-2",style:{color:M.textDim},children:"Reward Signal"}),t("div",{class:"rounded-lg p-3",style:{background:"rgba(40, 40, 44, 0.4)",border:"1px solid rgba(60, 60, 60, 0.15)"},children:[t(Pt,{data:o.node.reward,color:o.node.color,width:220,height:40}),t("div",{style:{display:"flex",justifyContent:"space-between",marginTop:"6px"},children:[t("span",{class:"text-[9px] mono",style:{color:M.textMuted},children:"7 sessions"}),t("span",{class:"text-[9px] mono",style:{color:o.node.color},children:[(o.node.reward[o.node.reward.length-1]*100).toFixed(0),"%"]})]})]})]}),t("div",{children:[t("div",{class:"text-[9px] uppercase tracking-widest font-medium mb-2",style:{color:M.textDim},children:"Last Action"}),t("div",{class:"text-xs",style:{color:M.text,opacity:.8},children:o.node.lastAction}),t("div",{class:"text-[9px] mono mt-1",style:{color:M.textMuted},children:o.node.lastTs?oe(o.node.lastTs):"--"})]}),t("div",{children:[t("div",{class:"text-[9px] uppercase tracking-widest font-medium mb-2",style:{color:M.textDim},children:["Connected Services (",o.connectedServices.length,")"]}),t("div",{class:"space-y-3",children:[o.connectedServices.filter(c=>c.direction==="in").length>0&&t("div",{children:[t("div",{class:"text-[8px] uppercase tracking-wider mb-1.5 flex items-center gap-1.5",style:{color:M.info},children:[t("svg",{width:"10",height:"6",viewBox:"0 0 10 6",children:t("path",{d:"M10 3H2M4 0.5L1 3l3 2.5",fill:"none",stroke:M.info,"stroke-width":"1.2"})}),"feeds into"]}),t("div",{class:"space-y-1",children:o.connectedServices.filter(c=>c.direction==="in").map(c=>t("div",{class:"flex items-center gap-2 text-xs pl-3",children:[t("span",{style:{color:M.text},children:c.label}),t("span",{class:"mono text-[8px] ml-auto",style:{color:M.textDim},children:c.eventType})]},c.id))})]}),o.connectedServices.filter(c=>c.direction==="out").length>0&&t("div",{children:[t("div",{class:"text-[8px] uppercase tracking-wider mb-1.5 flex items-center gap-1.5",style:{color:M.success},children:[t("svg",{width:"10",height:"6",viewBox:"0 0 10 6",children:t("path",{d:"M0 3h8M6 0.5l3 2.5-3 2.5",fill:"none",stroke:M.success,"stroke-width":"1.2"})}),"feeds out to"]}),t("div",{class:"space-y-1",children:o.connectedServices.filter(c=>c.direction==="out").map(c=>t("div",{class:"flex items-center gap-2 text-xs pl-3",children:[t("span",{style:{color:M.text},children:c.label}),t("span",{class:"mono text-[8px] ml-auto",style:{color:M.textDim},children:c.eventType})]},c.id))})]})]})]}),o.recentEvents.length>0&&t("div",{children:[t("div",{class:"text-[9px] uppercase tracking-widest font-medium mb-2",style:{color:M.textDim},children:"Recent Activity"}),t("div",{class:"space-y-1",children:o.recentEvents.map((c,S)=>t("div",{class:"flex items-center justify-between text-[9px]",children:[t("span",{class:"mono",style:{color:M.info},children:c.type}),t("span",{class:"mono",style:{color:M.textMuted},children:oe(c.ts)})]},S))})]})]}),t("div",{class:"p-4",style:{borderTop:"1px solid rgba(60, 60, 60, 0.15)"},children:t("div",{class:"text-[8px] mono tracking-wider",style:{color:M.textDim,opacity:.5},children:"Canvas 2D + WebGL Bloom / 4-pass Gaussian"})})]})]})}function Wr(e,r){const n=[];for(const s of e){if(s.type==="session:started"||s.type==="session:ended")continue;const o=s.data||{};let l,f;if(s.type==="hook:tool-use"){const h=o.tool_name||"tool",u=o.file_paths||[];l=u.length>0?`${h} → ${u[0]}${u.length>1?` +${u.length-1}`:""}`:h,f=o.hook_event_name||s.source}else s.type==="hook:subagent-start"||s.type==="hook:subagent-stop"?(l=`Agent ${s.type==="hook:subagent-start"?"started":"stopped"}`,f=s.source):(l=o.title||s.type,f=o.summary||s.source);n.push({id:s.id,ts:s.ts,kind:"event",type:s.type,title:l,detail:f,source:s.source,data:s.data})}for(const s of r)s.type!=="file"&&n.push({id:`j-${s.timestamp}-${s.title}`,ts:s.timestamp,kind:"journal",type:s.type,title:s.title,detail:s.content,source:s.source});n.sort((s,o)=>o.ts.localeCompare(s.ts));const i=new Set;return n.filter(s=>{const o=`${s.kind}-${s.title}-${s.ts.slice(0,16)}`;return i.has(o)?!1:(i.add(o),!0)})}function Vr(e){const r={},n=new Date().toISOString().slice(0,10),i=new Date(Date.now()-864e5).toISOString().slice(0,10);for(const s of e){const o=s.ts.slice(0,10),l=o===n?"Today":o===i?"Yesterday":o;r[l]||(r[l]=[]),r[l].push(s)}return r}const qr=[{label:"All",filter:""},{label:"Eval",filter:"eval"},{label:"Agent",filter:"peter"},{label:"Decision",filter:"decision"},{label:"Feature",filter:"feature"},{label:"Fix",filter:"fix"},{label:"Flow",filter:"flow"},{label:"Telemetry",filter:"telemetry"}],Jr={event:"●",journal:"◆"},Kr={"eval:scored":"text-info","peter:pr-created":"text-warning","peter:pr-proposed":"text-warning","telemetry:insight":"text-accent-foreground","flow:triggered":"text-info/70","flow:completed":"text-success",feature:"text-success",fix:"text-destructive",decision:"text-warning",milestone:"text-info",discovery:"text-info/70"};function Qr(){var R;const[e,r]=j([]),[n,i]=j(""),[s,o]=j(""),[l,f]=j(new Set),h=J(()=>U.events(200),1e4),u=J(()=>U.journal(),1e4),v=Jt("/api/events/stream",Fe(_=>{r(F=>[_,...F].slice(0,50))},[])),y=[...e,...((R=h.data)==null?void 0:R.events)||[]].filter((_,F,k)=>k.findIndex(p=>p.id===_.id)===F),x=Wr(y,u.data||[]).filter(_=>{var F;if(n&&!_.type.toLowerCase().includes(n))return!1;if(s){const k=s.toLowerCase();return _.title.toLowerCase().includes(k)||((F=_.detail)==null?void 0:F.toLowerCase().includes(k))||_.type.toLowerCase().includes(k)}return!0}),E=Vr(x),w=_=>{f(F=>{const k=new Set(F);return k.has(_)?k.delete(_):k.add(_),k})};return t("div",{class:"space-y-5",children:[t("div",{class:"flex items-center justify-between",children:[t("h1",{class:"text-xl font-semibold",children:"Activity"}),t("div",{class:"flex items-center gap-3",children:[v.connected&&t("span",{class:"text-xs text-success mono animate-pulse-dot",children:"LIVE"}),t("span",{class:"text-sm text-muted-foreground",children:[x.length," items"]})]})]}),t("div",{class:"relative",children:[t("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",class:"absolute left-3 top-1/2 -translate-y-1/2 text-muted-foreground",children:[t("circle",{cx:"11",cy:"11",r:"8"}),t("path",{d:"m21 21-4.3-4.3"})]}),t("input",{type:"text",placeholder:"Search activity...",value:s,onInput:_=>o(_.target.value),class:"w-full bg-card border border-border rounded-lg pl-10 pr-4 py-2 text-sm text-foreground placeholder:text-muted-foreground focus:outline-none focus:border-info/50 transition-colors"})]}),t("div",{class:"flex flex-wrap gap-1.5",children:qr.map(_=>t("button",{onClick:()=>i(n===_.filter?"":_.filter),class:P("text-[11px] mono font-medium px-2 py-0.5 rounded-md transition-colors",n===_.filter?"bg-foreground/10 text-foreground":"bg-muted/50 text-muted-foreground hover:text-foreground"),children:_.label},_.filter))}),Object.entries(E).map(([_,F])=>t("div",{children:[t("div",{class:"text-[10px] uppercase tracking-widest text-muted-foreground font-medium mb-2 sticky top-0 bg-background py-1",children:_}),t("div",{class:"space-y-0.5",children:F.map(k=>{var C,T,m;const p=l.has(k.id),g=Kr[k.type]||"text-foreground",D=Jr[k.kind]||"○",c=(C=k.data)==null?void 0:C.delta,S=((T=k.data)==null?void 0:T.improved)==="true"||((m=k.data)==null?void 0:m.improved)===!0;return t("button",{onClick:()=>w(k.id),class:"w-full text-left flex items-start gap-3 py-2 px-3 rounded hover:bg-muted/30 transition-colors animate-fade-in",children:[t("span",{class:"text-[10px] text-muted-foreground mono whitespace-nowrap mt-0.5 w-14 shrink-0",children:oe(k.ts)}),t("span",{class:P("text-xs mt-0.5 shrink-0",k.kind==="journal"?"text-success":"text-info"),children:D}),t("div",{class:"flex-1 min-w-0",children:[t("div",{class:"flex items-center gap-2",children:[t("span",{class:P("text-xs mono font-medium whitespace-nowrap",g),children:k.type}),t("span",{class:"text-sm truncate",children:k.title}),c!=null&&t("span",{class:P("text-xs mono ml-auto shrink-0",S?"text-success":"text-destructive"),children:[c>=0?"+":"",Number(c).toFixed(3)]})]}),p&&k.detail&&t("div",{class:"text-xs text-muted-foreground mt-1 whitespace-pre-wrap",children:k.detail}),p&&k.files&&k.files.length>0&&t("div",{class:"flex flex-wrap gap-1 mt-1",children:k.files.map(a=>t("span",{class:"text-[10px] mono bg-muted/50 px-1.5 py-0.5 rounded",children:a},a))})]})]},k.id)})})]},_)),x.length===0&&t("div",{class:"bg-card rounded-lg border border-border p-8 text-center text-sm text-muted-foreground",children:s||n?"No matching activity":"No activity yet"})]})}function Zr(e){if(!e)return;const r=e.match(/autoresearch-r(\d+)/);if(r)return`Round ${r[1]}`;let n=e.replace(/^pp\//,"").replace(/^feature\//,"").replace(/-\d{10,}$/,"").replace(/-/g," ");return n&&(n=n.charAt(0).toUpperCase()+n.slice(1)),n||void 0}function en(e){return e.map(r=>{var n,i,s;return{ts:r.ts,branch:r.branch,prNumber:r.pr_number,delta:(n=r.delta)==null?void 0:n.composite,composite:r.composite,improved:r.improved,agent:r.agent,testsTotal:(i=r.metrics)==null?void 0:i.tests_total,testsPassed:(s=r.metrics)==null?void 0:s.tests_passed,description:Zr(r.branch)||r.notes}})}function tn(){var _,F,k;const e=J(()=>U.events(500),15e3),r=J(()=>U.leaderboard(),15e3),n=J(()=>U.flowExecutions(),15e3),i=J(()=>U.evalEntries(100),15e3),s=((_=e.data)==null?void 0:_.events)||[],o=r.data||[],l=n.data||[],f=((F=i.data)==null?void 0:F.entries)||[],h=en(f),u=s.filter(p=>p.type==="telemetry:insight").length,v=s.filter(p=>p.type.startsWith("peter:")).length,d=h.length,y=h.filter(p=>p.improved===!0).length,b=h.filter(p=>p.improved===!1).length,x=l.length,E=[...o].sort((p,g)=>(g.composite||0)-(p.composite||0))[0],w=(k=E==null?void 0:E.trajectory)==null?void 0:k[0],R=E==null?void 0:E.composite;return t("div",{class:"space-y-6",children:[t("div",{class:"flex items-center justify-between",children:[t("h1",{class:"text-xl font-semibold",children:"Self-Driving Loop"}),t("span",{class:"text-sm text-muted-foreground",children:[h.length," cycles"]})]}),w!=null&&R!=null&&t("div",{class:"bg-card rounded-lg border border-border p-4",children:t("div",{class:"flex items-center gap-4",children:[t("div",{children:[t("div",{class:"text-xs text-muted-foreground uppercase tracking-wider mb-1",children:"Score"}),t("div",{class:"flex items-center gap-2",children:[t("span",{class:"text-2xl font-bold tabular-nums",children:R.toFixed(2)}),(()=>{const p=R-w;return t("span",{class:P("text-sm mono",p>=0?"text-success":"text-destructive"),children:[p>=0?"▲":"▼",p>=0?"+":"",p.toFixed(3)]})})()]})]}),(E==null?void 0:E.trajectory)&&E.trajectory.length>1&&t(Je,{data:E.trajectory,width:200,height:40,color:R>=w?"var(--success)":"var(--destructive)"}),t("div",{class:"ml-auto",children:[t("div",{class:"w-40 h-3 bg-muted rounded-full overflow-hidden",children:t("div",{class:"h-full bg-success rounded-full transition-all",style:{width:`${Math.round(R*100)}%`}})}),t("div",{class:"text-[10px] text-muted-foreground text-right mt-0.5",children:[Math.round(R*100),"%"]})]})]})}),t("div",{class:"bg-card rounded-lg border border-border p-4",children:[t("h3",{class:"text-xs text-muted-foreground uppercase tracking-wider mb-4",children:"Pipeline"}),t("div",{class:"flex items-center justify-between text-center",children:[{label:"DETECT",count:u,color:"text-accent-foreground",detail:"insights"},{label:"PROPOSE",count:v,color:"text-warning",detail:"PRs"},{label:"EVAL",count:d,color:"text-info",detail:"runs"},{label:"MERGE",count:y,color:"text-success",detail:"merged"},{label:"LEARN",count:x,color:"text-info/70",detail:"flows"}].map((p,g)=>t("div",{class:"flex items-center",children:[g>0&&t("svg",{width:"24",height:"16",class:"text-muted-foreground/30 mx-1 shrink-0",children:t("path",{d:"M2 8h16M14 4l4 4-4 4",fill:"none",stroke:"currentColor","stroke-width":"1.5"})}),t("div",{children:[t("div",{class:P("text-2xl font-bold tabular-nums",p.color),children:p.count}),t("div",{class:"text-[10px] mono text-muted-foreground uppercase tracking-wider",children:p.label}),t("div",{class:"text-[10px] text-muted-foreground",children:p.detail})]})]},p.label))}),b>0&&t("div",{class:"flex items-center gap-2 mt-3 text-xs text-destructive",children:t("span",{class:"mono",children:[b," rejected"]})})]}),o.length>0&&t("div",{class:"bg-card rounded-lg border border-border p-4",children:[t("h3",{class:"text-xs text-muted-foreground uppercase tracking-wider mb-3",children:"Agents"}),t("div",{class:"space-y-2",children:o.sort((p,g)=>(g.composite||0)-(p.composite||0)).map(p=>t("div",{class:"flex items-center gap-3",children:[t("span",{class:P("w-2 h-2 rounded-full shrink-0",p.delta!=null&&p.delta>0?"bg-success":"bg-muted-foreground/50")}),t("span",{class:"text-sm font-medium flex-1 truncate",children:p.agent}),t("span",{class:"text-sm mono tabular-nums text-muted-foreground",children:p.composite!=null?p.composite.toFixed(4):"—"}),p.trajectory&&p.trajectory.length>1&&t(Je,{data:p.trajectory,width:80,height:24})]},p.agent))})]}),h.length>0&&t("div",{class:"bg-card rounded-lg border border-border p-4",children:[t("h3",{class:"text-xs text-muted-foreground uppercase tracking-wider mb-3",children:"Recent Cycles"}),t("div",{class:"space-y-1",children:h.slice(0,20).map((p,g)=>t("div",{class:P("flex items-center gap-3 py-2 px-2 text-sm rounded -mx-2",p.improved===!0&&"bg-success/5",p.improved===!1&&"bg-destructive/5"),children:[t("span",{class:"text-[10px] text-muted-foreground mono w-12 shrink-0",children:oe(p.ts)}),t("span",{class:P("w-2 h-2 rounded-full shrink-0",p.improved===!0?"bg-success":p.improved===!1?"bg-destructive":"bg-muted-foreground/50")}),t("span",{class:"truncate flex-1 text-foreground",title:p.branch||p.agent,children:p.description||p.branch||p.agent||"Eval run"}),p.composite!=null&&t("span",{class:"text-xs mono tabular-nums bg-muted px-1.5 py-0.5 rounded",children:p.composite.toFixed(2)}),p.delta!=null&&t("span",{class:P("text-xs mono tabular-nums px-1.5 py-0.5 rounded",p.delta>=0?"bg-success/20 text-success":"bg-destructive/20 text-destructive"),children:[p.delta>=0?"+":"",p.delta.toFixed(3)]}),p.testsTotal!=null&&t("span",{class:"text-[10px] text-muted-foreground mono whitespace-nowrap",children:[p.testsPassed!=null&&p.testsPassed!==p.testsTotal?`${p.testsPassed}/${p.testsTotal}`:`${p.testsTotal}`," tests"]}),p.prNumber&&t("span",{class:"text-[10px] mono text-muted-foreground",children:["#",p.prNumber]}),t("span",{class:P("text-[10px] mono w-14 text-right",p.improved===!0?"text-success":p.improved===!1?"text-destructive":"text-muted-foreground"),children:p.improved===!0?"✓ merged":p.improved===!1?"✗ rejected":"—"})]},`${p.ts}-${g}`))})]}),h.length===0&&t("div",{class:"bg-card rounded-lg border border-border p-8 text-center",children:[t("div",{class:"text-sm text-muted-foreground",children:"No eval cycles yet"}),t("div",{class:"text-xs text-muted-foreground/70 mt-1",children:["Run ",t("span",{class:"mono",children:'jfl peter pr --task "add tests"'})," to start the loop"]})]})]})}function rn(e){return e.gated?"pending":e.error||e.actions_failed&&e.actions_failed>0?"failed":e.completed_at?"completed":"running"}function nn({status:e}){var R;const[r,n]=j(24),i=J(()=>U.projects(),15e3),s=J(()=>U.memoryStatus(),3e4),o=J(()=>U.flows(),15e3),l=J(()=>U.flowExecutions(),15e3),f=J(()=>U.telemetryDigest(r),3e4,[r]);J(()=>U.telemetryAgentStatus(),15e3);const h=(e==null?void 0:e.sources)||{},u=Object.values(h).filter(Boolean).length,v=Object.keys(h).length,d=s.data,y=o.data||[],b=l.data,x=Array.isArray(b)?b:(b==null?void 0:b.executions)||[],E=x.filter(_=>rn(_)==="pending"),w=f.data;return t("div",{class:"space-y-6",children:[t("div",{class:"flex items-center justify-between",children:[t("h1",{class:"text-xl font-semibold",children:"System"}),t("span",{class:P("text-xs mono px-2 py-0.5 rounded",(e==null?void 0:e.status)==="running"||(e==null?void 0:e.status)==="ok"?"bg-success/10 text-success":"bg-destructive/10 text-destructive"),children:(e==null?void 0:e.status)||"unknown"})]}),t("div",{class:"grid grid-cols-2 lg:grid-cols-4 gap-4",children:[t(_e,{label:"Hub",value:(e==null?void 0:e.status)==="running"||(e==null?void 0:e.status)==="ok"?"OK":(e==null?void 0:e.status)||"--",sub:`port :${(e==null?void 0:e.port)||"--"}`,trend:(e==null?void 0:e.status)==="running"||(e==null?void 0:e.status)==="ok"?"up":"down"}),t(_e,{label:"Sources",value:`${u}/${v}`,sub:"connected",trend:u===v?"up":"down"}),t(_e,{label:"Items",value:(e==null?void 0:e.itemCount)||0,sub:"indexed"}),t(_e,{label:"Memories",value:(d==null?void 0:d.total_memories)||0,sub:(R=d==null?void 0:d.embeddings)!=null&&R.available?"with embeddings":"keyword only"})]}),t("div",{class:"bg-card rounded-lg border border-border p-4",children:[t("div",{class:"flex items-center justify-between mb-3",children:[t("h3",{class:"text-xs text-muted-foreground uppercase tracking-wider",children:"Costs"}),t("div",{class:"flex gap-1",children:[24,72,168].map(_=>t("button",{onClick:()=>n(_),class:P("text-[10px] mono px-2 py-0.5 rounded transition-colors",r===_?"bg-foreground/10 text-foreground":"text-muted-foreground hover:text-foreground"),children:_===24?"24h":_===72?"3d":"7d"},_))})]}),w?t(ae,{children:[t("div",{class:"text-2xl font-bold tabular-nums mb-3",children:["$",w.totalCostUsd.toFixed(2)]}),t("div",{class:"space-y-1.5",children:w.costs.sort((_,F)=>F.estimatedCostUsd-_.estimatedCostUsd).map(_=>{const F=w.totalCostUsd>0?_.estimatedCostUsd/w.totalCostUsd*100:0;return t("div",{class:"flex items-center gap-3 text-xs",children:[t("span",{class:"w-32 truncate mono text-muted-foreground",children:_.model}),t("div",{class:"flex-1 h-1.5 bg-muted rounded-full overflow-hidden",children:t("div",{class:"h-full bg-info rounded-full",style:{width:`${F}%`}})}),t("span",{class:"mono text-muted-foreground w-16 text-right",children:["$",_.estimatedCostUsd.toFixed(2)]}),t("span",{class:"text-muted-foreground/60 w-10 text-right",children:[F.toFixed(0),"%"]})]},_.model)})})]}):t("div",{class:"text-sm text-muted-foreground",children:"No cost data"})]}),t("div",{class:"bg-card rounded-lg border border-border p-4",children:[t("div",{class:"flex items-center justify-between mb-3",children:[t("h3",{class:"text-xs text-muted-foreground uppercase tracking-wider",children:["Flows (",y.length," defined, ",y.filter(_=>_.enabled!==!1).length," enabled)"]}),E.length>0&&t("span",{class:"text-[10px] mono text-warning",children:[E.length," pending"]})]}),E.length>0&&t("div",{class:"mb-3 space-y-1.5",children:E.map((_,F)=>t("div",{class:"flex items-center justify-between p-2 rounded border border-warning/30 bg-warning/5",children:[t("div",{class:"flex items-center gap-2",children:[t("span",{class:"w-1.5 h-1.5 rounded-full bg-warning animate-pulse"}),t("span",{class:"text-sm font-medium",children:_.flow}),t("span",{class:"text-[10px] mono text-muted-foreground",children:oe(_.started_at)})]}),t("button",{onClick:()=>U.approveFlow(_.flow,_.trigger_event_id),class:"text-[10px] mono px-2 py-0.5 rounded bg-success/15 text-success hover:bg-success/25 transition-colors",children:"approve"})]},F))}),t("div",{class:"space-y-1",children:y.map(_=>{var g;const F=typeof _.trigger=="string"?_.trigger:((g=_.trigger)==null?void 0:g.pattern)||"",k=_.enabled!==!1,p=x.filter(D=>D.flow===_.name).length;return t("div",{class:P("flex items-center gap-3 py-1.5 text-sm",!k&&"opacity-40"),children:[t("span",{class:P("w-1.5 h-1.5 rounded-full",k?"bg-success":"bg-muted-foreground/50")}),t("span",{class:"font-medium flex-1 truncate",children:_.name}),t("span",{class:"text-[10px] mono text-info",children:F}),p>0&&t("span",{class:"text-[10px] text-muted-foreground",children:[p," runs"]}),t("button",{onClick:()=>U.toggleFlow(_.name,!k),class:P("text-[10px] mono px-1.5 py-0.5 rounded transition-colors",k?"bg-success/10 text-success":"bg-muted text-muted-foreground"),children:k?"on":"off"})]},_.name)})})]}),w&&t("div",{class:"grid grid-cols-2 gap-4",children:[t("div",{class:"bg-card rounded-lg border border-border p-4",children:[t("h3",{class:"text-xs text-muted-foreground uppercase tracking-wider mb-2",children:"Sessions"}),t("div",{class:"grid grid-cols-2 gap-2 text-sm",children:[t("div",{children:[t("span",{class:"text-muted-foreground",children:"Started:"}),t("span",{class:"ml-1 font-medium",children:w.sessions.started})]}),t("div",{children:[t("span",{class:"text-muted-foreground",children:"Ended:"}),t("span",{class:"ml-1 font-medium",children:w.sessions.ended})]}),t("div",{children:[t("span",{class:"text-muted-foreground",children:"Crashed:"}),t("span",{class:P("ml-1 font-medium",w.sessions.crashed>0?"text-destructive":""),children:w.sessions.crashed})]}),t("div",{children:[t("span",{class:"text-muted-foreground",children:"Avg:"}),t("span",{class:"ml-1 font-medium",children:[Math.round(w.sessions.avgDurationS/60),"m"]})]})]})]}),t("div",{class:"bg-card rounded-lg border border-border p-4",children:[t("h3",{class:"text-xs text-muted-foreground uppercase tracking-wider mb-2",children:"Errors"}),w.errors.total>0?t("div",{class:"space-y-1",children:Object.entries(w.errors.byType).map(([_,F])=>t("div",{class:"flex items-center justify-between text-sm",children:[t("span",{class:"text-muted-foreground truncate",children:_}),t("span",{class:"text-destructive mono",children:F})]},_))}):t("div",{class:"text-sm text-success",children:"No errors"})]})]}),t("div",{class:"bg-card rounded-lg border border-border p-4",children:[t("h3",{class:"text-xs text-muted-foreground uppercase tracking-wider mb-3",children:"Context Sources"}),t("div",{class:"grid grid-cols-2 md:grid-cols-4 gap-3",children:Object.entries(h).map(([_,F])=>t("div",{class:"flex items-center gap-2",children:[t("span",{class:P("w-1.5 h-1.5 rounded-full",F?"bg-success":"bg-destructive")}),t("span",{class:"text-sm capitalize",children:_}),t("span",{class:"text-[10px] text-muted-foreground",children:F?"ok":"down"})]},_))})]}),i.data&&i.data.length>0&&t("div",{class:"bg-card rounded-lg border border-border p-4",children:[t("h3",{class:"text-xs text-muted-foreground uppercase tracking-wider mb-3",children:["Tracked Projects (",i.data.length,")"]}),t("div",{class:"space-y-2",children:i.data.map(_=>t("div",{class:"flex items-center gap-3 text-sm",children:[t(Kt,{status:_.status==="OK"?"ok":"error"}),t("span",{class:"font-medium",children:_.name}),t("span",{class:"text-[10px] mono text-muted-foreground",children:[":",_.port]}),_.status==="OK"&&t("a",{href:`http://localhost:${_.port}/dashboard/`,target:"_blank",rel:"noopener",class:"text-[10px] text-info hover:underline ml-auto",children:"Open"})]},_.name))})]})]})}function sn(e){const r=e.data||{},n=[];if(Array.isArray(r.findings))for(const i of r.findings)n.push({file:i.file||"unknown",line:i.line,severity:i.severity||"yellow",category:i.category||"general",message:i.message||"",suggestion:i.suggestion});return{id:e.id,ts:e.ts,pr:r.pr,branch:r.branch||r.ref,agent:r.agent||e.source,findings:n,summary:r.summary,source:e.source}}const tr={red:{bg:"bg-destructive/15",text:"text-destructive",label:"RED"},yellow:{bg:"bg-warning/15",text:"text-warning",label:"YLW"},green:{bg:"bg-success/15",text:"text-success",label:"OK"}},on=[{label:"All",value:""},{label:"Red",value:"red"},{label:"Yellow",value:"yellow"},{label:"Green",value:"green"}];function ln(){var b;const[e,r]=j([]),[n,i]=j(""),[s,o]=j(new Set),l=J(()=>U.events(200,"review:*"),15e3);Jt("/api/events/stream",Fe(x=>{var w;const E=x;(w=E.type)!=null&&w.startsWith("review:")&&r(R=>[E,...R].slice(0,50))},[]));const h=[...e,...((b=l.data)==null?void 0:b.events)||[]].filter((x,E,w)=>w.findIndex(R=>R.id===x.id)===E),u=qe(()=>h.map(sn).sort((x,E)=>E.ts.localeCompare(x.ts)),[h]),v=n?u.filter(x=>x.findings.some(E=>E.severity===n)):u,d=qe(()=>{let x=0,E=0,w=0;for(const R of u)for(const _ of R.findings)_.severity==="red"?x++:_.severity==="yellow"?E++:w++;return{red:x,yellow:E,green:w,total:u.length}},[u]),y=x=>{o(E=>{const w=new Set(E);return w.has(x)?w.delete(x):w.add(x),w})};return t("div",{class:"space-y-5",children:[t("div",{class:"flex items-center justify-between",children:[t("h1",{class:"text-xl font-semibold",children:"Reviews"}),t("div",{class:"flex items-center gap-3",children:[e.length>0&&t("span",{class:"text-xs text-success mono animate-pulse-dot",children:"LIVE"}),t("span",{class:"text-sm text-muted-foreground",children:[v.length," reviews"]})]})]}),t("div",{class:"grid grid-cols-4 gap-3",children:[t(Ne,{label:"Reviews",value:d.total,color:"text-foreground"}),t(Ne,{label:"Red Findings",value:d.red,color:"text-destructive"}),t(Ne,{label:"Yellow Findings",value:d.yellow,color:"text-warning"}),t(Ne,{label:"Green Findings",value:d.green,color:"text-success"})]}),t("div",{class:"flex flex-wrap gap-1.5",children:on.map(x=>t("button",{onClick:()=>i(x.value),class:P("text-[11px] mono font-medium px-2 py-0.5 rounded-md transition-colors",n===x.value?"bg-foreground/10 text-foreground":"bg-muted/50 text-muted-foreground hover:text-foreground"),children:x.label},x.value))}),t("div",{class:"bg-card rounded-lg border border-border",children:l.loading&&v.length===0?t("div",{class:"p-4 text-sm text-muted-foreground animate-pulse-dot",children:"Loading reviews..."}):v.length===0?t("div",{class:"py-8 text-sm text-muted-foreground text-center",children:"No review events yet. Reviews appear when AI eval runs on PRs."}):t("div",{class:"divide-y divide-border/50",children:v.map(x=>t(an,{review:x,expanded:s.has(x.id),onToggle:()=>y(x.id)},x.id))})})]})}function Ne({label:e,value:r,color:n}){return t("div",{class:"bg-card rounded-lg border border-border p-3",children:[t("div",{class:"text-[10px] text-muted-foreground uppercase tracking-wider",children:e}),t("div",{class:P("text-2xl font-semibold mono tabular-nums mt-1",n),children:r})]})}function an({review:e,expanded:r,onToggle:n}){const i=e.findings.filter(l=>l.severity==="red").length,s=e.findings.filter(l=>l.severity==="yellow").length,o=e.findings.filter(l=>l.severity==="green").length;return t("div",{class:"animate-fade-in",children:[t("button",{onClick:n,class:"w-full flex items-center gap-3 px-4 py-3 hover:bg-muted/20 transition-colors text-left",children:[t("div",{class:"flex items-center gap-1.5 shrink-0",children:[i>0&&t(Oe,{severity:"red",count:i}),s>0&&t(Oe,{severity:"yellow",count:s}),o>0&&t(Oe,{severity:"green",count:o}),e.findings.length===0&&t(Oe,{severity:"green",count:0})]}),t("div",{class:"flex-1 min-w-0",children:[t("div",{class:"flex items-center gap-2",children:[e.pr&&t("span",{class:"text-xs mono font-medium text-info",children:["PR #",e.pr]}),e.branch&&t("span",{class:"text-xs mono text-muted-foreground truncate",children:e.branch})]}),e.summary&&t("div",{class:"text-xs text-muted-foreground mt-0.5 truncate",children:e.summary})]}),t("div",{class:"flex items-center gap-2 shrink-0",children:[t("span",{class:"text-[10px] mono text-muted-foreground",children:e.agent}),t("span",{class:"text-[10px] mono text-muted-foreground whitespace-nowrap",children:oe(e.ts)}),t("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2",class:P("text-muted-foreground transition-transform",r&&"rotate-180"),children:t("polyline",{points:"6 9 12 15 18 9"})})]})]}),r&&e.findings.length>0&&t("div",{class:"px-4 pb-3 space-y-1.5",children:e.findings.map((l,f)=>t(cn,{finding:l},f))})]})}function Oe({severity:e,count:r}){const n=tr[e];return t("span",{class:P("text-[10px] mono font-medium px-1.5 py-0.5 rounded",n.bg,n.text),children:r>0?r:n.label})}function cn({finding:e}){const r=tr[e.severity];return t("div",{class:P("rounded-md px-3 py-2 text-xs",r.bg),children:[t("div",{class:"flex items-center gap-2",children:[t("span",{class:P("mono font-medium",r.text),children:r.label}),t("span",{class:"mono text-muted-foreground",children:[e.file,e.line&&`:${e.line}`]}),t("span",{class:"text-muted-foreground/60 mono",children:e.category})]}),t("div",{class:"mt-1 text-foreground",children:e.message}),e.suggestion&&t("div",{class:"mt-1 text-muted-foreground italic",children:e.suggestion})]})}function dn(){const[e,r]=j([]),[n,i]=j(""),[s,o]=j(!1),l=fe(null),f=fe(null);ve(()=>{var u;(u=l.current)==null||u.scrollIntoView({behavior:"smooth"})},[e]),ve(()=>{var u;(u=f.current)==null||u.focus()},[]);const h=async()=>{const u=n.trim();if(!u||s)return;const v={id:`u-${Date.now()}`,role:"user",content:u,ts:new Date().toISOString()},d=`a-${Date.now()}`,y={id:d,role:"assistant",content:"",ts:new Date().toISOString(),streaming:!0};r(x=>[...x,v,y]),i(""),o(!0);const b=e.filter(x=>!x.streaming).slice(-8).map(x=>({role:x.role,content:x.content}));await gr(u,b,x=>{r(E=>E.map(w=>w.id===d?{...w,sources:x}:w))},x=>{r(E=>E.map(w=>w.id===d?{...w,content:w.content+x}:w))},()=>{r(x=>x.map(E=>E.id===d?{...E,streaming:!1}:E)),o(!1)},x=>{r(E=>E.map(w=>w.id===d?{...w,content:`Error: ${x}`,streaming:!1}:w)),o(!1)})};return t("div",{class:"flex flex-col h-[calc(100vh-3rem)]",children:[t("div",{class:"flex items-center justify-between mb-4",children:[t("h1",{class:"text-xl font-semibold",children:"Chat"}),t("div",{class:"flex items-center gap-2",children:[e.length>0&&t("button",{onClick:()=>r([]),class:"text-[10px] mono px-2 py-1 rounded bg-muted text-muted-foreground hover:text-foreground transition-colors",children:"clear"}),t("span",{class:"text-sm text-muted-foreground",children:[e.length," messages"]})]})]}),t("div",{class:"flex-1 overflow-y-auto space-y-4 pb-4",children:[e.length===0&&t("div",{class:"flex flex-col items-center justify-center h-full text-center",children:[t("div",{class:"text-muted-foreground/40 mb-4",children:t("svg",{width:"48",height:"48",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"1.5","stroke-linecap":"round","stroke-linejoin":"round",children:t("path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})})}),t("div",{class:"text-sm text-muted-foreground mb-1",children:"Ask about your project"}),t("div",{class:"text-xs text-muted-foreground/60 max-w-sm",children:"Answers grounded in your journal, knowledge base, and code context."}),t("div",{class:"flex flex-wrap gap-1.5 mt-4 justify-center",children:["What decisions were made recently?","What features were built this week?","What bugs were fixed?","Summarize the current roadmap"].map(u=>t("button",{onClick:()=>{var v;i(u),(v=f.current)==null||v.focus()},class:"text-[11px] mono px-2.5 py-1 rounded-md bg-muted/50 text-muted-foreground hover:text-foreground hover:bg-muted/80 transition-colors",children:u},u))})]}),e.map(u=>t(un,{message:u},u.id)),t("div",{ref:l})]}),t("div",{class:"border-t border-border pt-3",children:t("div",{class:"flex gap-2",children:[t("input",{ref:f,type:"text",placeholder:"Ask about your project...",value:n,onInput:u=>i(u.target.value),onKeyDown:u=>u.key==="Enter"&&h(),disabled:s,class:"flex-1 bg-card border border-border rounded-lg px-4 py-2.5 text-sm text-foreground placeholder:text-muted-foreground/50 focus:outline-none focus:border-info/50 transition-colors disabled:opacity-50"}),t("button",{onClick:h,disabled:s||!n.trim(),class:P("px-4 py-2.5 rounded-lg text-sm font-medium transition-colors",n.trim()&&!s?"bg-info text-white hover:bg-info/90":"bg-muted text-muted-foreground cursor-not-allowed"),children:t("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round",children:[t("path",{d:"M22 2 11 13"}),t("path",{d:"M22 2 15 22l-4-9-9-4z"})]})})]})})]})}function un({message:e}){const r=e.role==="user",[n,i]=j(!1);return t("div",{class:P("flex gap-3 animate-fade-in",r&&"flex-row-reverse"),children:[t("div",{class:P("w-6 h-6 rounded-full flex items-center justify-center shrink-0 mt-0.5",r?"bg-foreground/10":"bg-info/15"),children:t("span",{class:P("text-[10px] font-bold",r?"text-foreground":"text-info"),children:r?"Y":"J"})}),t("div",{class:"max-w-[80%] space-y-2",children:[t("div",{class:P("rounded-lg px-3 py-2",r?"bg-foreground/5 border border-border":"bg-card border border-border"),children:[r?t("div",{class:"text-sm",children:e.content}):t("div",{class:"text-sm space-y-1.5",children:[e.content?e.content.split(`
121
+ `).map((s,o)=>s.trim()?s.startsWith("# ")?t("div",{class:"font-semibold text-sm mt-2 first:mt-0",children:s.slice(2)},o):s.startsWith("## ")?t("div",{class:"font-medium text-sm text-muted-foreground mt-2",children:s.slice(3)},o):s.startsWith("- ")?t("div",{class:"text-sm pl-3",children:[t("span",{class:"text-muted-foreground mr-1.5",children:"•"}),Dt(s.slice(2))]},o):t("div",{class:"text-sm",children:Dt(s)},o):t("div",{class:"h-2"},o)):e.streaming?t("span",{class:"text-muted-foreground animate-pulse-dot",children:"Thinking..."}):null,e.streaming&&e.content&&t("span",{class:"inline-block w-1.5 h-4 bg-info/60 animate-pulse ml-0.5 align-middle"})]}),t("div",{class:"flex items-center gap-2 mt-1.5",children:[t("span",{class:"text-[10px] text-muted-foreground/50 mono",children:oe(e.ts)}),e.sources&&e.sources.length>0&&t("button",{onClick:()=>i(!n),class:"text-[10px] text-info/70 hover:text-info mono transition-colors",children:[e.sources.length," sources ",n?"▾":"▸"]})]})]}),n&&e.sources&&t("div",{class:"bg-card/50 border border-border/50 rounded-lg p-2 space-y-1.5 animate-fade-in",children:e.sources.map((s,o)=>t("div",{class:"flex items-start gap-2 text-[11px]",children:[t("span",{class:P("shrink-0 px-1.5 py-0.5 rounded mono uppercase text-[9px]",s.type==="decision"?"bg-warning/15 text-warning":s.type==="feature"?"bg-success/15 text-success":s.type==="fix"?"bg-destructive/15 text-destructive":"bg-info/15 text-info"),children:s.type||"ctx"}),t("div",{class:"min-w-0",children:[t("div",{class:"font-medium truncate",children:s.title}),s.content&&t("div",{class:"text-muted-foreground line-clamp-2 mt-0.5",children:s.content.slice(0,150)})]})]},o))})]})]})}function Dt(e){const r=[];let n=e,i=0;for(;n.length>0;){const s=n.match(/\*\*(.+?)\*\*/),o=n.match(/`(.+?)`/),l=(s==null?void 0:s.index)??1/0,f=(o==null?void 0:o.index)??1/0;if(l===1/0&&f===1/0){r.push(t("span",{children:n},i++));break}l<=f&&s?(l>0&&r.push(t("span",{children:n.slice(0,l)},i++)),r.push(t("span",{class:"font-medium",children:s[1]},i++)),n=n.slice(l+s[0].length)):o&&(f>0&&r.push(t("span",{children:n.slice(0,f)},i++)),r.push(t("span",{class:"mono text-info text-[10px] bg-info/10 px-1 py-0.5 rounded",children:o[1]},i++)),n=n.slice(f+o[0].length))}return t(ae,{children:r})}function pn({status:e}){var b;const[r,n]=j(24),[i,s]=j([]),[o,l]=j(!1),f=J(()=>U.synopsis(r),3e4,[r]),h=(e==null?void 0:e.children)||[],v=((e==null?void 0:e.type)||"standalone")==="portfolio"&&h.length>0;ve(()=>{if(!v)return;l(!0);const x=h.map(E=>({name:E.name,port:E.port,status:"loading",data:null}));s(x),Promise.all(h.map(async E=>{const w=await U.childSynopsis(E.port,r);return{name:E.name,port:E.port,status:w?"ok":"error",data:w}})).then(E=>{s(E),l(!1)})},[v,r,h.map(x=>x.port).join(",")]);const d=hn(f.data,i);return t("div",{class:"space-y-5",children:[t("div",{class:"flex items-center justify-between",children:[t("h1",{class:"text-xl font-semibold",children:"Synopsis"}),t("div",{class:"flex items-center gap-2",children:[6,12,24,48,168].map(x=>t("button",{onClick:()=>n(x),class:P("text-[11px] mono font-medium px-2 py-0.5 rounded-md transition-colors",r===x?"bg-foreground/10 text-foreground":"bg-muted/50 text-muted-foreground hover:text-foreground"),children:[x,"h"]},x))})]}),v&&t("div",{class:"grid grid-cols-2 lg:grid-cols-4 gap-3",children:[t(Ue,{label:"Features",value:d.features,color:"text-success"}),t(Ue,{label:"Fixes",value:d.fixes,color:"text-warning"}),t(Ue,{label:"Decisions",value:d.decisions,color:"text-info"}),t(Ue,{label:"Commits",value:d.commits,color:"text-foreground"})]}),t("div",{class:"bg-card rounded-lg border border-border p-4",children:[t("div",{class:"flex items-center justify-between mb-3",children:[t("h3",{class:"text-xs text-muted-foreground uppercase tracking-wider",children:((b=e==null?void 0:e.config)==null?void 0:b.name)||"This Project"}),f.loading&&t("span",{class:"text-[10px] text-muted-foreground animate-pulse-dot",children:"loading..."})]}),f.data?t(It,{data:f.data}):t("div",{class:"text-sm text-muted-foreground",children:["No activity in the last ",r,"h"]})]}),v&&t("div",{class:"space-y-4",children:[t("h2",{class:"text-sm font-medium text-muted-foreground uppercase tracking-wider",children:["Products (",h.length,")"]}),i.map(x=>t("div",{class:"bg-card rounded-lg border border-border p-4",children:[t("div",{class:"flex items-center justify-between mb-3",children:[t("div",{class:"flex items-center gap-2",children:[t("span",{class:P("w-[6px] h-[6px] rounded-full shrink-0",x.status==="ok"?"bg-success":x.status==="loading"?"bg-muted-foreground/50 animate-pulse":"bg-destructive")}),t("h3",{class:"text-sm font-medium",children:x.name}),t("span",{class:"text-[10px] mono text-muted-foreground",children:[":",x.port]})]}),x.status==="loading"&&t("span",{class:"text-[10px] text-muted-foreground animate-pulse-dot",children:"loading..."})]}),x.data?t(It,{data:x.data}):x.status==="error"?t("div",{class:"text-xs text-muted-foreground",children:"Unable to fetch synopsis"}):null]},x.name))]}),!v&&f.data&&f.data.commits.length>0&&t("div",{class:"bg-card rounded-lg border border-border p-4",children:[t("h3",{class:"text-xs text-muted-foreground uppercase tracking-wider mb-3",children:"Commits"}),t("div",{class:"space-y-1.5",children:f.data.commits.map(x=>t("div",{class:"flex items-center gap-2 text-xs",children:[t("span",{class:"mono text-muted-foreground text-[10px] w-14 shrink-0",children:x.hash.slice(0,7)}),t("span",{class:"truncate flex-1",children:x.message}),t("span",{class:"text-[10px] mono text-muted-foreground",children:x.author}),t("span",{class:"text-[10px] text-muted-foreground whitespace-nowrap",children:oe(x.date)})]},x.hash))})]})]})}function Ue({label:e,value:r,color:n}){return t("div",{class:"bg-card rounded-lg border border-border p-3",children:[t("div",{class:"text-[10px] text-muted-foreground uppercase tracking-wider",children:e}),t("div",{class:P("text-2xl font-semibold mono tabular-nums mt-1",n),children:r}),t("div",{class:"text-[10px] text-muted-foreground",children:"across all projects"})]})}function It({data:e}){const r=e.summary,n=r.features+r.fixes+r.decisions+r.discoveries>0;return t("div",{class:"space-y-3",children:[n&&t("div",{class:"flex gap-4",children:[r.features>0&&t(Se,{label:"features",value:r.features,color:"text-success"}),r.fixes>0&&t(Se,{label:"fixes",value:r.fixes,color:"text-warning"}),r.decisions>0&&t(Se,{label:"decisions",value:r.decisions,color:"text-info"}),r.discoveries>0&&t(Se,{label:"discoveries",value:r.discoveries,color:"text-purple-400"}),e.commits.length>0&&t(Se,{label:"commits",value:e.commits.length,color:"text-foreground"}),r.filesModified>0&&t(Se,{label:"files",value:r.filesModified,color:"text-muted-foreground"})]}),e.journalEntries.length>0&&t("div",{children:[t("div",{class:"text-[10px] text-muted-foreground uppercase tracking-wider mb-1.5",children:"Journal"}),t("div",{class:"space-y-1",children:e.journalEntries.slice(0,5).map((i,s)=>t("div",{class:"flex items-start gap-2 text-xs",children:[t("span",{class:P("text-[10px] mono px-1 py-0.5 rounded shrink-0",i.type==="feature"?"bg-success/15 text-success":i.type==="fix"?"bg-warning/15 text-warning":i.type==="decision"?"bg-info/15 text-info":"bg-muted text-muted-foreground"),children:i.type}),t("span",{class:"truncate",children:i.title}),t("span",{class:"text-[10px] text-muted-foreground whitespace-nowrap ml-auto",children:oe(i.ts)})]},s))})]}),r.incompleteItems.length>0&&t("div",{children:[t("div",{class:"text-[10px] text-muted-foreground uppercase tracking-wider mb-1.5",children:"Incomplete"}),t("div",{class:"space-y-1",children:r.incompleteItems.map((i,s)=>t("div",{class:"text-xs text-warning/80 flex items-center gap-1.5",children:[t("span",{class:"w-1 h-1 rounded-full bg-warning/60 shrink-0"}),i]},s))})]})]})}function Se({label:e,value:r,color:n}){return t("div",{children:[t("div",{class:P("text-lg font-semibold mono tabular-nums",n),children:r}),t("div",{class:"text-[10px] text-muted-foreground uppercase",children:e})]})}function hn(e,r){let n=0,i=0,s=0,o=0;const l=f=>{f&&(n+=f.summary.features,i+=f.summary.fixes,s+=f.summary.decisions,o+=f.commits.length)};l(e);for(const f of r)l(f.data);return{features:n,fixes:i,decisions:s,commits:o}}const fn={_startTime:Date.now(),_lastPage:"",pageView(e){const r=this._lastPage?Date.now()-this._startTime:0;this._lastPage&&r>1e3&&this._emit("dashboard:page-dwell",{page:this._lastPage,durationMs:r}),this._emit("dashboard:page-view",{page:e}),this._startTime=Date.now(),this._lastPage=e},click(e,r){this._emit("dashboard:click",{target:e,...r})},_emit(e,r){const n=new Date().toISOString(),i=localStorage.getItem("jfl-token")||"";fetch("/api/hooks",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${i}`},body:JSON.stringify({type:e,source:"dashboard",data:r,ts:n})}).catch(()=>{}),fetch("https://jfl-platform.fly.dev/api/v1/telemetry/ingest",{method:"POST",headers:{"Content-Type":"application/json","x-jfl-install-id":"jfl-dashboard"},body:JSON.stringify({events:[{event_id:crypto.randomUUID(),ts:n,category:"dashboard",event:e,install_id:"jfl-dashboard",...r}]})}).catch(()=>{})}},ot={overview:Er,activity:()=>t(Qr,{}),loop:()=>t(tn,{}),experiments:()=>t(Dr,{}),findings:()=>t(Pr,{}),reviews:()=>t(ln,{}),chat:()=>t(dn,{}),synopsis:pn,topology:Hr,system:nn};function gn(){const e=J(()=>U.status(),1e4),r=location.hash.replace("#/","")||"overview",[n,i]=j(r in ot?r:"overview"),s=fe(!0);if(ve(()=>{fn.pageView(n),s.current||(location.hash=`#/${n}`),s.current=!1},[n]),e.loading)return t("div",{class:"flex items-center justify-center h-screen",children:t("div",{class:"text-muted-foreground text-sm animate-pulse-dot",children:"Loading dashboard..."})});if(e.error)return t("div",{class:"flex items-center justify-center h-screen",children:t("div",{class:"text-center",children:[t("div",{class:"text-destructive text-sm font-medium",children:"Connection Error"}),t("div",{class:"text-muted-foreground text-xs mt-1",children:e.error}),t("div",{class:"text-muted-foreground text-xs mt-2 mono",children:"jfl context-hub start"})]})});const o=ot[n]||ot.overview;return t("div",{class:"flex min-h-screen",children:[t(Mr,{status:e.data,currentPage:n,setPage:l=>i(l)}),t("main",{class:"flex-1 ml-56 p-6",children:t(o,{status:e.data})})]})}cr(t(gn,{}),document.getElementById("app"));