@polderlabs/bizar 6.2.4 → 6.3.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.
- package/.claude/CLAUDE.md +15 -0
- package/.claude/agents/_shared/AGENT_BASELINE.md +168 -0
- package/.claude/agents/_shared/CLAUDE_TOOLS.md +412 -0
- package/.claude/agents/_shared/SKILLS.md +109 -0
- package/.claude/agents/agent-browser.md +80 -0
- package/.claude/agents/baldr.md +49 -0
- package/.claude/agents/forseti.md +51 -0
- package/.claude/agents/frigg.md +42 -0
- package/.claude/agents/heimdall.md +33 -0
- package/.claude/agents/hermod.md +53 -0
- package/.claude/agents/mimir.md +49 -0
- package/.claude/agents/odin.md +287 -0
- package/.claude/agents/quick.md +34 -0
- package/.claude/agents/semble-search.md +50 -0
- package/.claude/agents/thor.md +53 -0
- package/.claude/agents/tyr.md +56 -0
- package/.claude/agents/vidarr.md +54 -0
- package/.claude/agents/vor.md +53 -0
- package/.claude/commands/audit.md +25 -0
- package/.claude/commands/bizar.md +22 -0
- package/.claude/commands/explain.md +17 -0
- package/.claude/commands/init.md +29 -0
- package/.claude/commands/learn.md +44 -0
- package/.claude/commands/plan.md +35 -0
- package/.claude/commands/plow-through.md +50 -0
- package/.claude/commands/pr-review.md +49 -0
- package/.claude/commands/setup-provider.md +96 -0
- package/.claude/commands/tailscale-serve.md +100 -0
- package/.claude/commands/team.md +132 -0
- package/.claude/commands/test.md +62 -0
- package/.claude/commands/validate.md +68 -0
- package/.claude/commands/visual-plan.md +24 -0
- package/.claude/hooks/README.md +92 -0
- package/.claude/hooks/posttooluse-editwrite.mjs +91 -0
- package/.claude/hooks/pretooluse-bash.mjs +81 -0
- package/.claude/hooks/pretooluse-editwrite.mjs +139 -0
- package/.claude/hooks/sessionend-recall.mjs +74 -0
- package/.claude/hooks/sessionstart-prime.mjs +80 -0
- package/.claude/hooks/userpromptsubmit-tag.mjs +80 -0
- package/.claude/settings.json +116 -0
- package/.claude/skills/9router/SKILL.md +80 -0
- package/.claude/skills/9router-chat/SKILL.md +73 -0
- package/.claude/skills/9router-embeddings/SKILL.md +69 -0
- package/.claude/skills/9router-image/SKILL.md +86 -0
- package/.claude/skills/9router-stt/SKILL.md +79 -0
- package/.claude/skills/9router-tts/SKILL.md +80 -0
- package/.claude/skills/9router-web-fetch/SKILL.md +99 -0
- package/.claude/skills/9router-web-search/SKILL.md +91 -0
- package/.claude/skills/bizar/README.md +9 -0
- package/.claude/skills/bizar/SKILL.md +450 -0
- package/.claude/skills/cpp-coding-standards/README.md +28 -0
- package/.claude/skills/cpp-coding-standards/SKILL.md +634 -0
- package/.claude/skills/cpp-coding-standards/references/concurrency.md +320 -0
- package/.claude/skills/cpp-coding-standards/references/error-handling.md +229 -0
- package/.claude/skills/cpp-coding-standards/references/memory-safety.md +216 -0
- package/.claude/skills/cpp-coding-standards/references/modern-idioms.md +282 -0
- package/.claude/skills/cpp-coding-standards/references/review-checklist.md +96 -0
- package/.claude/skills/cpp-testing/README.md +28 -0
- package/.claude/skills/cpp-testing/SKILL.md +304 -0
- package/.claude/skills/cpp-testing/references/coverage.md +370 -0
- package/.claude/skills/cpp-testing/references/framework-compare.md +175 -0
- package/.claude/skills/cpp-testing/references/host-test-for-embedded.md +499 -0
- package/.claude/skills/cpp-testing/references/mocking.md +364 -0
- package/.claude/skills/cpp-testing/references/tdd-workflow.md +308 -0
- package/.claude/skills/cubesandbox/SKILL.md +148 -0
- package/.claude/skills/embedded-esp-idf/README.md +41 -0
- package/.claude/skills/embedded-esp-idf/SKILL.md +439 -0
- package/.claude/skills/embedded-esp-idf/references/freertos-patterns.md +214 -0
- package/.claude/skills/embedded-esp-idf/references/host-tests.md +164 -0
- package/.claude/skills/embedded-esp-idf/references/idf-py-commands.md +157 -0
- package/.claude/skills/embedded-esp-idf/references/kconfig.md +159 -0
- package/.claude/skills/embedded-esp-idf/references/logging-discipline.md +118 -0
- package/.claude/skills/embedded-esp-idf/references/memory-and-iram.md +137 -0
- package/.claude/skills/embedded-esp-idf/references/nvs.md +121 -0
- package/.claude/skills/embedded-esp-idf/references/packed-structs.md +192 -0
- package/.claude/skills/embedded-esp-idf/scripts/idf_env.sh +47 -0
- package/.claude/skills/embedded-esp-idf/scripts/size_check.sh +77 -0
- package/.claude/skills/glyph/SKILL.md +163 -0
- package/.claude/skills/harness-engineering/SKILL.md +143 -0
- package/.claude/skills/lightrag/SKILL.md +81 -0
- package/.claude/skills/memory-protocol/SKILL.md +105 -0
- package/.claude/skills/obsidian/SKILL.md +306 -0
- package/.claude/skills/read-the-damn-docs/SKILL.md +113 -0
- package/.claude/skills/self-improvement/SKILL.md +64 -0
- package/README.md +87 -59
- package/bizar-dash/dist/assets/{EnvVarsSection-DXM8gRm_.js → EnvVarsSection-B58aiJiE.js} +1 -1
- package/bizar-dash/dist/assets/{EnvVarsSection-DXM8gRm_.js.map → EnvVarsSection-B58aiJiE.js.map} +1 -1
- package/bizar-dash/dist/assets/{MobileChat-BnKN_Ks_.js → MobileChat-BJrqwVDd.js} +1 -1
- package/bizar-dash/dist/assets/{MobileChat-BnKN_Ks_.js.map → MobileChat-BJrqwVDd.js.map} +1 -1
- package/bizar-dash/dist/assets/{MobileSettings-DjCPxC-Q.js → MobileSettings-CEQNJNLJ.js} +1 -1
- package/bizar-dash/dist/assets/{MobileSettings-DjCPxC-Q.js.map → MobileSettings-CEQNJNLJ.js.map} +1 -1
- package/bizar-dash/dist/assets/{main-DYiZqMrn.js → main-IvfQAOfy.js} +1 -1
- package/bizar-dash/dist/assets/{main-DYiZqMrn.js.map → main-IvfQAOfy.js.map} +1 -1
- package/bizar-dash/dist/assets/{markdown-C6mXtQxD.js → markdown-tOLaD6nm.js} +1 -1
- package/bizar-dash/dist/assets/{markdown-C6mXtQxD.js.map → markdown-tOLaD6nm.js.map} +1 -1
- package/bizar-dash/dist/assets/{mobile-CMHqtLV2.js → mobile-DYCHcUpq.js} +1 -1
- package/bizar-dash/dist/assets/{mobile-CMHqtLV2.js.map → mobile-DYCHcUpq.js.map} +1 -1
- package/bizar-dash/dist/assets/{mobile-layout-3jIhHX_p.js → mobile-layout-CBHjpwsb.js} +2 -2
- package/bizar-dash/dist/assets/{mobile-layout-3jIhHX_p.js.map → mobile-layout-CBHjpwsb.js.map} +1 -1
- package/bizar-dash/dist/assets/{useSlashCommands-DtITw8Xv.js → useSlashCommands-Bd7_FA6U.js} +2 -2
- package/bizar-dash/dist/assets/{useSlashCommands-DtITw8Xv.js.map → useSlashCommands-Bd7_FA6U.js.map} +1 -1
- package/bizar-dash/dist/assets/{vendor-CeHGtduv.js → vendor-C843201K.js} +12 -12
- package/bizar-dash/dist/assets/vendor-C843201K.js.map +1 -0
- package/bizar-dash/dist/index.html +6 -6
- package/bizar-dash/dist/mobile.html +2 -2
- package/bizar-dash/node_modules/.vite/vitest/da39a3ee5e6b4b0d3255bfef95601890afd80709/results.json +1 -1
- package/bizar-dash/src/server/api.mjs +4 -4
- package/bizar-dash/src/server/background-store.mjs +15 -16
- package/bizar-dash/src/server/bg-poller.mjs +25 -35
- package/bizar-dash/src/server/bg-retry.mjs +66 -194
- package/bizar-dash/src/server/claude-bg-spawner.mjs +390 -0
- package/bizar-dash/src/server/claude-info.mjs +412 -0
- package/bizar-dash/src/server/{cline-runner.mjs → claude-runner.mjs} +53 -48
- package/bizar-dash/src/server/claude-sdk.mjs +191 -0
- package/bizar-dash/src/server/providers-store.mjs +22 -49
- package/bizar-dash/src/server/routes/background.mjs +24 -20
- package/bizar-dash/src/server/routes/chat.mjs +223 -326
- package/bizar-dash/src/server/routes/claude-session-detail.mjs +329 -0
- package/bizar-dash/src/server/routes/claude-sessions.mjs +259 -0
- package/bizar-dash/src/server/routes/tasks.mjs +20 -28
- package/bizar-dash/src/server/task-delegator.mjs +76 -77
- package/bizar-dash/src/web/components/chat/useChat.ts +23 -27
- package/bizar-dash/src/web/views/Chat.tsx +8 -8
- package/cli/bin.mjs +31 -18
- package/cli/commands/claude-cmd.mjs +348 -0
- package/cli/commands/install.mjs +12 -11
- package/cli/commands/sandbox.mjs +220 -0
- package/cli/commands/validate.mjs +252 -288
- package/cli/dev-link.test.mjs +11 -11
- package/cli/doctor.mjs +131 -213
- package/cli/install.mjs +33 -37
- package/cli/install.test.mjs +9 -9
- package/cli/provision-claude.mjs +893 -0
- package/cli/provision.mjs +330 -226
- package/cli/provision.test.mjs +102 -0
- package/cli/utils.mjs +72 -58
- package/config/AGENTS.md +28 -28
- package/config/agents/_shared/AGENT_BASELINE.md +104 -684
- package/config/skills/bizar/SKILL.md +197 -0
- package/config/skills/cubesandbox/SKILL.md +148 -0
- package/config/skills/harness-engineering/SKILL.md +142 -0
- package/install.sh +66 -44
- package/package.json +19 -11
- package/packages/sdk/ARCHITECTURE.md +40 -36
- package/packages/sdk/package-lock.json +32 -0
- package/packages/sdk/package.json +15 -5
- package/{plugins/bizar → packages/sdk}/src/dangerous-patterns.ts +6 -28
- package/packages/sdk/src/fingerprint.ts +0 -0
- package/packages/sdk/src/index.ts +38 -73
- package/packages/sdk/src/mcp/bin.ts +51 -0
- package/packages/sdk/src/mcp/server.ts +498 -0
- package/{plugins/bizar/src/memory-vault.ts → packages/sdk/src/memory/index.ts} +18 -21
- package/packages/sdk/tests/sdk.test.mjs +148 -0
- package/packages/sdk/vitest.config.ts +1 -1
- package/scripts/bh-full-e2e.mjs +166 -363
- package/scripts/check-deps.mjs +28 -46
- package/scripts/mirror-claude-md.sh +78 -0
- package/scripts/test-in-container.sh +157 -0
- package/templates/clean-state-checklist.md +3 -3
- package/templates/sprint-contract.md +2 -2
- package/bizar-dash/.bizar/activity.log +0 -3
- package/bizar-dash/.omx/logs/omx-2026-07-07.jsonl +0 -1
- package/bizar-dash/.omx/state/session.json +0 -10
- package/bizar-dash/bizar-design/EXPLANATION.md +0 -307
- package/bizar-dash/bizar-design/INSTRUCTIONS.md +0 -149
- package/bizar-dash/bizar-design/canvas.html +0 -281
- package/bizar-dash/bizar-design/canvas.html.artifact.json +0 -19
- package/bizar-dash/bizar-design/components.css +0 -1665
- package/bizar-dash/bizar-design/components.html +0 -557
- package/bizar-dash/bizar-design/components.html.artifact.json +0 -19
- package/bizar-dash/bizar-design/desktop/agents.html +0 -74
- package/bizar-dash/bizar-design/desktop/agents.html.artifact.json +0 -19
- package/bizar-dash/bizar-design/desktop/memory.html +0 -75
- package/bizar-dash/bizar-design/desktop/memory.html.artifact.json +0 -19
- package/bizar-dash/bizar-design/desktop/metrics.html +0 -63
- package/bizar-dash/bizar-design/desktop/metrics.html.artifact.json +0 -19
- package/bizar-dash/bizar-design/desktop/overview.html +0 -95
- package/bizar-dash/bizar-design/desktop/overview.html.artifact.json +0 -19
- package/bizar-dash/bizar-design/desktop/settings.html +0 -70
- package/bizar-dash/bizar-design/desktop/settings.html.artifact.json +0 -19
- package/bizar-dash/bizar-design/icons.svg +0 -44
- package/bizar-dash/bizar-design/index.html +0 -192
- package/bizar-dash/bizar-design/index.html.artifact.json +0 -19
- package/bizar-dash/bizar-design/mobile/agents.html +0 -29
- package/bizar-dash/bizar-design/mobile/agents.html.artifact.json +0 -19
- package/bizar-dash/bizar-design/mobile/memory.html +0 -28
- package/bizar-dash/bizar-design/mobile/memory.html.artifact.json +0 -19
- package/bizar-dash/bizar-design/mobile/metrics.html +0 -29
- package/bizar-dash/bizar-design/mobile/metrics.html.artifact.json +0 -19
- package/bizar-dash/bizar-design/mobile/overview.html +0 -33
- package/bizar-dash/bizar-design/mobile/overview.html.artifact.json +0 -19
- package/bizar-dash/bizar-design/mobile/settings.html +0 -28
- package/bizar-dash/bizar-design/mobile/settings.html.artifact.json +0 -19
- package/bizar-dash/bizar-design/prototype.js +0 -114
- package/bizar-dash/bizar-design/tokens.css +0 -106
- package/bizar-dash/dist/assets/vendor-CeHGtduv.js.map +0 -1
- package/bizar-dash/node_modules/.package-lock.json +0 -6
- package/bizar-dash/package-lock.json +0 -6
- package/bizar-dash/src/server/cline-sdk.mjs +0 -132
- package/bizar-dash/src/server/routes/cline-session-detail.mjs +0 -559
- package/bizar-dash/src/server/routes/cline-sessions.mjs +0 -291
- package/cli/commands/cline-cmd.mjs +0 -289
- package/cli/commands/validate.test.mjs +0 -344
- package/cli/doctor.test.mjs +0 -350
- package/config/cline.json.template +0 -342
- package/packages/sdk/src/client.ts +0 -188
- package/packages/sdk/src/cline-events.ts +0 -134
- package/packages/sdk/src/cline-types.ts +0 -66
- package/packages/sdk/src/cline.ts +0 -339
- package/packages/sdk/src/errors.ts +0 -129
- package/packages/sdk/src/events.ts +0 -153
- package/packages/sdk/src/types.ts +0 -176
- package/packages/sdk/tests/client.test.ts +0 -217
- package/packages/sdk/tests/errors.test.ts +0 -108
- package/packages/sdk/tests/events.test.ts +0 -139
- package/packages/sdk/tests/fixtures/fetch-mock.ts +0 -152
- package/packages/sdk/tests/fixtures/sse-mock.ts +0 -30
- package/plugins/bizar/ARCHITECTURE.md +0 -142
- package/plugins/bizar/CONSTRAINTS.md +0 -67
- package/plugins/bizar/LICENSE +0 -21
- package/plugins/bizar/README.md +0 -448
- package/plugins/bizar/index.ts +0 -872
- package/plugins/bizar/package.json +0 -39
- package/plugins/bizar/scripts/check-forbidden-imports.sh +0 -33
- package/plugins/bizar/src/background-state.ts +0 -641
- package/plugins/bizar/src/background.ts +0 -1806
- package/plugins/bizar/src/cline-runner.ts +0 -203
- package/plugins/bizar/src/clineruntime.ts +0 -227
- package/plugins/bizar/src/commands-impl.ts +0 -151
- package/plugins/bizar/src/commands.ts +0 -1799
- package/plugins/bizar/src/compaction.d.mts +0 -48
- package/plugins/bizar/src/compaction.mjs +0 -192
- package/plugins/bizar/src/dashboard-client.ts +0 -233
- package/plugins/bizar/src/event-stream.ts +0 -606
- package/plugins/bizar/src/fingerprint.ts +0 -120
- package/plugins/bizar/src/handoff.ts +0 -79
- package/plugins/bizar/src/hooks/memory-flush-on-compact.ts +0 -123
- package/plugins/bizar/src/hooks/memory-inject.ts +0 -247
- package/plugins/bizar/src/hooks/memory-write-on-end.ts +0 -188
- package/plugins/bizar/src/hooks/skill-curator.ts +0 -180
- package/plugins/bizar/src/http-client.ts +0 -467
- package/plugins/bizar/src/key-rotation.ts +0 -218
- package/plugins/bizar/src/logger.ts +0 -144
- package/plugins/bizar/src/loop-engineering.ts +0 -241
- package/plugins/bizar/src/loop.ts +0 -176
- package/plugins/bizar/src/mistake-recovery.ts +0 -98
- package/plugins/bizar/src/odin.ts +0 -227
- package/plugins/bizar/src/options.ts +0 -470
- package/plugins/bizar/src/plan-fs.ts +0 -323
- package/plugins/bizar/src/reasoning-clean.ts +0 -454
- package/plugins/bizar/src/report.ts +0 -178
- package/plugins/bizar/src/research-prompt.ts +0 -35
- package/plugins/bizar/src/serve-info.ts +0 -228
- package/plugins/bizar/src/serve.ts +0 -496
- package/plugins/bizar/src/settings.ts +0 -349
- package/plugins/bizar/src/state.ts +0 -298
- package/plugins/bizar/src/tool-discipline.ts +0 -105
- package/plugins/bizar/src/tools/agent-browser.ts +0 -315
- package/plugins/bizar/src/tools/bg-collect.ts +0 -131
- package/plugins/bizar/src/tools/bg-get-comments.ts +0 -266
- package/plugins/bizar/src/tools/bg-kill.ts +0 -116
- package/plugins/bizar/src/tools/bg-pause.ts +0 -99
- package/plugins/bizar/src/tools/bg-report-progress.ts +0 -115
- package/plugins/bizar/src/tools/bg-resume.ts +0 -94
- package/plugins/bizar/src/tools/bg-send-message.ts +0 -223
- package/plugins/bizar/src/tools/bg-spawn.ts +0 -502
- package/plugins/bizar/src/tools/bg-status.ts +0 -130
- package/plugins/bizar/src/tools/graph-query.ts +0 -278
- package/plugins/bizar/src/tools/loop-engineering.ts +0 -193
- package/plugins/bizar/src/tools/memory-list.ts +0 -43
- package/plugins/bizar/src/tools/memory-read.ts +0 -69
- package/plugins/bizar/src/tools/memory-search.ts +0 -47
- package/plugins/bizar/src/tools/memory-write.ts +0 -54
- package/plugins/bizar/src/tools/open-kb.ts +0 -198
- package/plugins/bizar/src/tools/plan-action.ts +0 -785
- package/plugins/bizar/src/tools/read-glyph-feedback.ts +0 -191
- package/plugins/bizar/src/tools/team-spawn.ts +0 -73
- package/plugins/bizar/src/tools/team-status.ts +0 -76
- package/plugins/bizar/src/tools/wait-for-feedback.ts +0 -415
- package/plugins/bizar/src/trajectory.ts +0 -104
- package/plugins/bizar/tests/README.md +0 -99
- package/plugins/bizar/tests/attach-handler-bug.test.ts +0 -169
- package/plugins/bizar/tests/background-state.test.ts +0 -277
- package/plugins/bizar/tests/background.test.ts +0 -402
- package/plugins/bizar/tests/block.test.ts +0 -195
- package/plugins/bizar/tests/canonical-key-order.test.ts +0 -75
- package/plugins/bizar/tests/clineruntime-config.test.ts +0 -283
- package/plugins/bizar/tests/commands-impl.test.ts +0 -316
- package/plugins/bizar/tests/commands.test.ts +0 -584
- package/plugins/bizar/tests/compaction.test.ts +0 -264
- package/plugins/bizar/tests/config.test.ts +0 -128
- package/plugins/bizar/tests/dashboard-client.test.ts +0 -159
- package/plugins/bizar/tests/dispose.test.ts +0 -336
- package/plugins/bizar/tests/event-stream.test.ts +0 -409
- package/plugins/bizar/tests/event.test.ts +0 -262
- package/plugins/bizar/tests/fingerprint.test.ts +0 -162
- package/plugins/bizar/tests/http-client.test.ts +0 -404
- package/plugins/bizar/tests/init-helpers.test.ts +0 -203
- package/plugins/bizar/tests/integration/slash-command.test.ts +0 -349
- package/plugins/bizar/tests/integration/tool-routing.test.ts +0 -98
- package/plugins/bizar/tests/key-rotation.test.ts +0 -396
- package/plugins/bizar/tests/loop-engineering.test.ts +0 -168
- package/plugins/bizar/tests/loop.test.ts +0 -397
- package/plugins/bizar/tests/memory-write-on-end.test.ts +0 -92
- package/plugins/bizar/tests/mistake-recovery.test.ts +0 -116
- package/plugins/bizar/tests/odin.test.ts +0 -125
- package/plugins/bizar/tests/options.test.ts +0 -329
- package/plugins/bizar/tests/reasoning-clean.test.ts +0 -422
- package/plugins/bizar/tests/safety.test.ts +0 -256
- package/plugins/bizar/tests/serve.test.ts +0 -339
- package/plugins/bizar/tests/settings.test.ts +0 -351
- package/plugins/bizar/tests/stall-think.test.ts +0 -750
- package/plugins/bizar/tests/state.test.ts +0 -276
- package/plugins/bizar/tests/tool-discipline.test.ts +0 -77
- package/plugins/bizar/tests/tools/agent-browser.test.ts +0 -98
- package/plugins/bizar/tests/tools/bg-collect.test.ts +0 -337
- package/plugins/bizar/tests/tools/bg-get-comments.test.ts +0 -485
- package/plugins/bizar/tests/tools/bg-kill.test.ts +0 -235
- package/plugins/bizar/tests/tools/bg-pause.test.ts +0 -61
- package/plugins/bizar/tests/tools/bg-report-progress.test.ts +0 -79
- package/plugins/bizar/tests/tools/bg-resume.test.ts +0 -40
- package/plugins/bizar/tests/tools/bg-send-message.test.ts +0 -116
- package/plugins/bizar/tests/tools/bg-spawn-delegation.test.ts +0 -147
- package/plugins/bizar/tests/tools/bg-spawn-http.test.ts +0 -233
- package/plugins/bizar/tests/tools/bg-spawn.test.ts +0 -311
- package/plugins/bizar/tests/tools/bg-status.test.ts +0 -217
- package/plugins/bizar/tests/tools/cline-runner.test.ts +0 -115
- package/plugins/bizar/tests/tools/plan-action.test.ts +0 -599
- package/plugins/bizar/tests/tools/read-glyph-feedback.test.ts +0 -253
- package/plugins/bizar/tests/tools/wait-for-feedback.test.ts +0 -390
- package/plugins/bizar/tests/update-deadlock.test.ts +0 -151
- package/plugins/bizar/tsconfig.json +0 -29
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var Ua=Object.defineProperty;var _a=(s,t,a)=>t in s?Ua(s,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):s[t]=a;var zs=(s,t,a)=>_a(s,typeof t!="symbol"?t+"":t,a);import{a as T,c as _,f as Ce,l as Ye,b as Ve,S as de,t as la,e as Wa,p as Va,d as xs,g as Ms,_ as qa,W as Qs,A as Ha,M as Ga}from"./mobile-layout-3jIhHX_p.js";import{r,j as e,a as oa,R as Ue,b as Ka}from"./react-vendor-Dn4wqh4Z.js";import{X as ke,A as zt,R as oe,F as Ya,H as Xa,a as Qa,C as ca,b as Be,c as Ja,d as qe,e as Qe,L as da,M as at,B as Xe,f as Js,S as Is,g as Me,h as Za,i as Ge,j as We,P as Zs,k as ns,l as Es,m as Rt,n as Ze,o as ma,p as gs,q as Tt,r as be,s as en,t as Ne,u as ua,v as sn,T as js,W as tn,w as ha,x as Gs,U as Ls,G as an,y as nn,z as fs,D as ze,E as Ie,I as $t,J as Ns,K as Re,N as is,O as et,Q as es,V as vs,Y as yt,Z as rn,_ as we,$ as At,a0 as Mt,a1 as ps,a2 as ln,a3 as nt,a4 as ys,a5 as on,a6 as Os,a7 as rs,a8 as xa,a9 as pa,aa as bs,ab as cn,ac as ks,ad as dn,ae as mn,af as un,ag as ws,ah as hn,ai as xn,aj as pn,ak as gn,al as jn,am as fn,an as Vt,ao as ga,ap as vn,aq as It,ar as yn,as as bn,at as Et,au as Nn,av as kn,aw as wn,ax as Sn,ay as Cn,az as zn,aA as Rn,aB as bt,aC as Lt,aD as ls,aE as ja,aF as Ds,aG as Tn,aH as $n,aI as An,aJ as Ps,aK as Mn,aL as In,aM as Dt,aN as Fs,aO as Nt,aP as Pt,aQ as st,aR as he,aS as En,aT as Ln,aU as fa,aV as Dn,aW as Pn,aX as Fn,aY as qt,aZ as On,a_ as va,a$ as rt,b0 as ya,b1 as Ft,b2 as Bn,b3 as Un,b4 as _n,b5 as ba,b6 as Wn,b7 as Vn,b8 as qn,b9 as Hn,ba as Gn,bb as Kn,bc as Na}from"./icons-Do5N2jmX.js";import{B as A,C as K,a as te,b as ne,A as Yn,U as Xn,G as Qn,E as Jn,T as Zn,S as ei,H as si,c as ti}from"./EnvVarsSection-DXM8gRm_.js";import{u as le,T as ai}from"./Toast-Cpl6-E63.js";import{V as Ot,C as ni,u as ii,a as ri,b as li,c as oi}from"./useSlashCommands-DtITw8Xv.js";import{M as ka,r as wa}from"./markdown-C6mXtQxD.js";import"./vendor-CeHGtduv.js";const Sa=r.createContext(null),ci=["button:not([disabled])","[href]","input:not([disabled])","select:not([disabled])","textarea:not([disabled])",'[tabindex]:not([tabindex="-1"])'].join(", ");function Ee(){const s=r.useContext(Sa);return s||{open:()=>"",close:()=>{},isModalOpen:!1}}function di({children:s}){const[t,a]=r.useState([]),i=r.useCallback(c=>{a(o=>{if(!c)return o.slice(0,-1);const l=o.findIndex(u=>u.id===c);return l===-1||l!==o.length-1?o:o.slice(0,-1)})},[]),n=r.useCallback(c=>{const o=`m${Math.random().toString(36).slice(2,9)}`;return a(l=>[...l,{...c,id:o}]),o},[]);return r.useEffect(()=>{if(t.length===0)return;const c=o=>{o.key==="Escape"&&(o.stopPropagation(),i())};return document.addEventListener("keydown",c),()=>document.removeEventListener("keydown",c)},[t.length,i]),e.jsxs(Sa.Provider,{value:{open:n,close:i,isModalOpen:t.length>0},children:[s,typeof document<"u"&&oa.createPortal(e.jsx("div",{className:"modal-stack","aria-hidden":t.length===0,children:t.map((c,o)=>e.jsx(mi,{modal:c,onClose:()=>{var l;(l=c.onClose)==null||l.call(c),i(c.id)},depth:o},c.id))}),document.body)]})}function mi({modal:s,onClose:t,depth:a}){const i=r.useRef(null),n=r.useRef(null),c=r.useId(),o=()=>{const l=i.current;return l?Array.from(l.querySelectorAll(ci)).filter(u=>!u.hasAttribute("disabled")&&u.tabIndex!==-1):[]};return r.useEffect(()=>{var x;n.current=document.activeElement instanceof HTMLElement?document.activeElement:null,(x=o()[0]??i.current)==null||x.focus();const u=h=>{var N,z,S;if(h.key!=="Tab")return;const d=o();if(d.length===0){h.preventDefault(),(N=i.current)==null||N.focus();return}const m=d[0],p=d[d.length-1],g=document.activeElement instanceof HTMLElement?document.activeElement:null;if(h.shiftKey){(!g||g===m||!((z=i.current)!=null&&z.contains(g)))&&(h.preventDefault(),p.focus());return}(!g||g===p||!((S=i.current)!=null&&S.contains(g)))&&(h.preventDefault(),m.focus())};return document.addEventListener("keydown",u),()=>{document.removeEventListener("keydown",u);const h=n.current;h&&h.isConnected&&h.focus()}},[]),e.jsx("div",{className:"modal-backdrop",onClick:l=>{l.stopPropagation(),l.target===l.currentTarget&&t()},style:a>0?{background:"rgba(0,0,0,0.4)"}:void 0,children:e.jsxs("div",{ref:i,className:"modal",role:"dialog","aria-modal":"true","aria-labelledby":s.title?c:void 0,tabIndex:-1,onClick:l=>l.stopPropagation(),style:s.width?{maxWidth:s.width}:void 0,children:[s.title&&e.jsxs("header",{className:"modal-header",children:[e.jsx("h2",{id:c,className:"modal-title",children:s.title}),e.jsx("button",{type:"button",className:"icon-btn","aria-label":"Close",onClick:t,children:e.jsx(ke,{size:16})})]}),e.jsx("div",{className:"modal-body",children:s.children}),s.footer&&e.jsx("footer",{className:"modal-footer",children:s.footer})]})})}const ui=200,hi=5*60*1e3,as=new Map;function xi(s){const t=as.get(s);return t?Date.now()-t.ts>hi?(as.delete(s),null):t.data:null}function lt(s,t){as.size>=ui&&[...as.entries()].sort((i,n)=>i[1].ts-n[1].ts).slice(0,50).map(([i])=>i).forEach(i=>as.delete(i)),as.set(s,{data:t,ts:Date.now()})}function pi(s){if(!s||s==="/")return[{label:"/",path:"/"}];const t=s.split("/").filter(Boolean),a=[];let i="";for(let n=0;n<t.length;n++)i+="/"+t[n],a.push({label:t[n],path:i});return a}function gi(s){return[...s].sort((t,a)=>t.isDir!==a.isDir?t.isDir?-1:1:t.name.localeCompare(a.name,void 0,{sensitivity:"base"}))}function ji(s){const t=s.trim();return t?t!==s?{ok:!1,reason:"Name cannot have leading or trailing whitespace."}:t==="."?{ok:!1,reason:"Name cannot be '.'."}:t===".."?{ok:!1,reason:"Name cannot be '..'."}:t.startsWith("-")?{ok:!1,reason:"Name cannot start with '-'."}:t.length>255?{ok:!1,reason:"Name cannot be longer than 255 characters."}:/[/\0:*?"<>|]/.test(t)?{ok:!1,reason:'Name cannot contain / \\ : * ? " < > |'}:{ok:!0}:{ok:!1,reason:"Name cannot be empty."}}function Ca({value:s,onChange:t,initialPath:a,projectsDirectory:i,rootLabel:n="Home",height:c=360}){const[o,l]=r.useState(a??i??""),[u,x]=r.useState(new Set),[h,d]=r.useState(-1),[m,p]=r.useState(null),[g,N]=r.useState({}),[z,S]=r.useState(!1),[y,w]=r.useState(null),[R,j]=r.useState(!1),[k,f]=r.useState(""),[v,L]=r.useState(null),[$,b]=r.useState(!1),M=r.useRef(null),P=r.useCallback(async E=>{try{const G=xi(E);if(G)return G;const H=await T.get("/fs?path="+encodeURIComponent(E));return lt(E,H),H}catch{return null}},[]),C=r.useCallback(async E=>{var G;S(!0),w(null);try{const H=await T.get("/fs?path="+encodeURIComponent(E));lt(E,H),p(H),d(-1)}catch(H){const ee=((G=H.data)==null?void 0:G.message)??H.message??"Failed to load directory";w(ee)}finally{S(!1)}},[]);r.useEffect(()=>{o?C(o):T.get("/fs").then(E=>{lt("",E),p(E),l(E.path),E.path!==s&&t(E.path)}).catch(()=>{w("Could not determine home directory."),S(!1)})},[o]),r.useEffect(()=>{s&&s!==o&&l(s)},[s]);const D=m?gi(m.entries):[],X=D.filter(E=>E.isDir),O=D,Q=E=>{E.isDir&&(l(E.path),t(E.path))},U=()=>{m!=null&&m.parent&&(l(m.parent),t(m.parent))},W=E=>{E!==o&&(l(E),t(E))},F=async()=>{const E=await P("");E&&(l(E.path),t(E.path))},V=async()=>{if(!i)return;const E=await P(i);E&&(l(E.path),t(E.path))},Y=()=>{j(!0),f(""),L(null),setTimeout(()=>{var E;return(E=M.current)==null?void 0:E.focus()},0)},B=()=>{j(!1),f(""),L(null)},Z=async()=>{var G;const E=ji(k);if(!E.ok){L(E.reason);return}b(!0),L(null);try{const H=await T.post("/fs/mkdir",{parent:o,name:k.trim()});as.delete(o),await C(o),t(H.path),j(!1),f("")}catch(H){const ee=H;ee.status===409?L(`A folder named "${k.trim()}" already exists.`):L(((G=ee.data)==null?void 0:G.message)??H.message??"Failed to create folder.")}finally{b(!1)}},xe=E=>{E.key==="Enter"?(E.preventDefault(),Z()):E.key==="Escape"&&(E.preventDefault(),B())},Te=E=>{x(G=>{const H=new Set(G);return H.has(E)?H.delete(E):H.add(E),H}),g[E]||P(E).then(G=>{G&&N(H=>({...H,[E]:G.entries.filter(ee=>ee.isDir)}))})},q=E=>{if(!m)return;const G=O.filter(ie=>ie.isDir),H=O.filter(ie=>!ie.isDir),ee=[...G,...H];if(E.key==="ArrowDown")E.preventDefault(),d(ie=>Math.min(ie+1,ee.length-1));else if(E.key==="ArrowUp")E.preventDefault(),d(ie=>Math.max(ie-1,0));else if(E.key==="Enter"||E.key===" "){E.preventDefault();const ie=ee[h];ie&&(E.key==="Enter"&&ie.isDir?Q(ie):ie.isDir&&t(ie.path))}else E.key==="Backspace"&&(E.preventDefault(),U())},se=pi((m==null?void 0:m.path)??o??"/"),re=m==null?void 0:m.parent,me=re!=null,pe=o.split("/").filter(Boolean).at(-1)??"/";return e.jsxs("div",{className:"file-browser",onKeyDown:q,tabIndex:-1,children:[e.jsx("div",{className:"file-browser-breadcrumb",role:"navigation","aria-label":"Path breadcrumb",children:se.map((E,G)=>e.jsxs("span",{className:"file-browser-breadcrumb-item",children:[G>0&&e.jsx("span",{className:"file-browser-breadcrumb-sep","aria-hidden":!0,children:"/"}),e.jsx("button",{type:"button",className:"file-browser-breadcrumb-btn",onClick:()=>W(E.path),title:E.path,children:G===0?E.path==="/"?"/":n:E.label})]},E.path))}),e.jsxs("div",{className:"file-browser-toolbar",children:[e.jsxs("div",{className:"file-browser-toolbar-left",children:[e.jsx("button",{type:"button",className:"file-browser-tool-btn",onClick:U,disabled:!me,title:"Go up (Backspace)","aria-label":"Go up one level",children:e.jsx(zt,{size:13})}),e.jsx("button",{type:"button",className:"file-browser-tool-btn",onClick:()=>C(o),disabled:z,title:"Refresh","aria-label":"Refresh",children:e.jsx(oe,{size:13,className:z?"spin":""})}),e.jsx("button",{type:"button",className:"file-browser-tool-btn",onClick:Y,title:"New folder","aria-label":"Create new folder",children:e.jsx(Ya,{size:13})}),e.jsxs("div",{className:"file-browser-chips",children:[e.jsxs("button",{type:"button",className:"file-browser-chip",onClick:F,children:[e.jsx(Xa,{size:11})," ",n]}),i&&e.jsxs("button",{type:"button",className:"file-browser-chip",onClick:V,title:i,children:[e.jsx(Qa,{size:11})," ",i.split("/").filter(Boolean).at(-1)??"Projects"]})]})]}),R?e.jsxs("div",{className:"file-browser-mkdir",children:[e.jsx("input",{ref:M,type:"text",className:"file-browser-mkdir-input",placeholder:"Folder name",value:k,onChange:E=>{f(E.target.value),L(null)},onKeyDown:xe,"aria-label":"New folder name","aria-invalid":v?"true":void 0,"aria-describedby":v?"mkdir-error":void 0,disabled:$,maxLength:255}),v?e.jsx("span",{id:"mkdir-error",className:"file-browser-mkdir-error",role:"alert",children:v}):e.jsx("span",{className:"file-browser-mkdir-hint",children:"Enter to create, Esc to cancel"})]}):e.jsx("span",{className:"file-browser-count-hint",children:z?"…":`${D.length} in ${pe}`})]}),y&&e.jsxs("div",{className:"file-browser-error",children:[e.jsx(ca,{size:13}),e.jsx("span",{children:y}),e.jsx("button",{type:"button",className:"file-browser-retry",onClick:()=>C(o),children:"Retry"})]}),e.jsxs("div",{className:"file-browser-body",style:{height:c},children:[e.jsx("div",{className:"file-browser-pane file-browser-tree","aria-label":"Folder tree",children:z&&!m?e.jsx(fi,{}):e.jsx(za,{path:o,entries:X,expanded:u,childrenMap:g,onToggle:Te,onNavigate:Q,level:0})}),e.jsxs("div",{className:"file-browser-pane file-browser-flat","aria-label":"Directory contents",children:[e.jsxs("div",{className:"file-browser-flat-header",children:[e.jsx("span",{children:"Name"}),e.jsx("span",{children:"Type"})]}),z&&!m?e.jsx(vi,{}):e.jsxs(e.Fragment,{children:[(m==null?void 0:m.truncated)&&e.jsxs("div",{className:"file-browser-truncated-banner",role:"status",children:["Showing first 500 of ",m.totalEntries," entries. Navigate into a subfolder to see more."]}),O.length===0?e.jsx("div",{className:"file-browser-empty",children:"This folder is empty"}):e.jsx("div",{className:"file-browser-flat-list",children:O.map((E,G)=>{const H=E.isDir,ee=G===h,ie=E.path===s;return e.jsxs("div",{role:"option","aria-selected":ie,className:["file-browser-row",H?"file-browser-row--dir":"file-browser-row--file",ee&&"file-browser-row--selected",ie&&H&&"file-browser-row--active",!H&&"file-browser-row--disabled"].filter(Boolean).join(" "),onClick:()=>{H&&(d(G),t(E.path))},onDoubleClick:()=>{H&&Q(E)},title:E.path,children:[e.jsx("span",{className:"file-browser-row-icon",children:H?e.jsx(Be,{size:13}):e.jsx(Ja,{size:13})}),e.jsx("span",{className:"file-browser-row-name",children:E.name}),e.jsx("span",{className:"file-browser-row-type",children:H?"Folder":""})]},E.path)})})]})]})]}),e.jsxs("div",{className:"file-browser-footer-hint",children:["Select a folder, then click Add. Use ",e.jsx("kbd",{children:"↑"})," ",e.jsx("kbd",{children:"↓"})," to navigate, ",e.jsx("kbd",{children:"Enter"})," to confirm."]})]})}function za({path:s,entries:t,expanded:a,childrenMap:i,onToggle:n,onNavigate:c,level:o}){return e.jsx("ul",{className:"file-browser-tree-list",role:"group",children:t.map(l=>{const u=a.has(l.path),x=i[l.path]??[];return e.jsxs("li",{className:"file-browser-tree-node",children:[e.jsxs("div",{className:["file-browser-tree-row",u&&"file-browser-tree-row--expanded"].filter(Boolean).join(" "),style:{paddingLeft:`${o*16+8}px`},children:[e.jsx("button",{type:"button",className:"file-browser-tree-toggle",onClick:h=>{h.stopPropagation(),n(l.path)},"aria-label":u?"Collapse":"Expand",children:(x.length>0,u?e.jsx(qe,{size:11}):e.jsx(Qe,{size:11}))}),e.jsxs("button",{type:"button",className:"file-browser-tree-name",onClick:()=>c(l),title:l.path,children:[e.jsx(Be,{size:12}),e.jsx("span",{children:l.name})]})]}),u&&x.length>0&&e.jsx(za,{path:l.path,entries:x,expanded:a,childrenMap:i,onToggle:n,onNavigate:c,level:o+1})]},l.path)})})}function fi(){return e.jsx("div",{className:"file-browser-skeleton-wrap",children:[80,60,90,55,70].map((s,t)=>e.jsx("div",{className:"file-browser-skeleton-row",style:{width:s}},t))})}function vi(){return e.jsx("div",{className:"file-browser-skeleton-wrap",children:[60,90,70,50,80,65].map((s,t)=>e.jsx("div",{className:"file-browser-skeleton-row",style:{width:s}},t))})}const kt=[{id:"overview",label:"Overview",icon:da},{id:"chat",label:"Chat",icon:at},{id:"agents",label:"Agents",icon:Xe},{id:"artifacts",label:"Glyphs",icon:Js},{id:"tasks",label:"Tasks",icon:Is},{id:"activity",label:"Activity",icon:Me},{id:"background",label:"Active",icon:Za},{id:"skills",label:"Skills",icon:Ge},{id:"memory",label:"Memory",icon:We},{id:"mods",label:"Mods",icon:Zs},{id:"schedules",label:"Schedules",icon:ns},{id:"history",label:"History",icon:Es},{id:"minimax",label:"Usage",icon:Rt},{id:"eval",label:"Eval",icon:Ze},{id:"doctor",label:"Doctor",icon:ma},{id:"harness",label:"Harness",icon:gs},{id:"settings",label:"Settings",icon:Tt}];function yi({activeTab:s,onTabChange:t,wsStatus:a,version:i,activeProject:n,projects:c,onProjectChange:o,onProjectsRefresh:l,onOpenSearch:u,settings:x,rightSlot:h,notificationsSlot:d,showTabs:m=!0,extraTabs:p,clineStatus:g=null}){return e.jsxs("header",{className:"topbar",children:[e.jsxs("div",{className:"topbar-row",children:[e.jsxs("div",{className:"brand",children:[e.jsx("span",{className:"brand-logo","aria-hidden":"true",children:"ᛒ"}),e.jsx("span",{className:"brand-title",children:"Bizar"}),e.jsx("span",{className:"brand-version",children:i})]}),e.jsx(bi,{activeProject:n,projects:c,onChange:o,onRefresh:l,settings:x??null}),e.jsxs("button",{type:"button",className:"topbar-search",onClick:u,title:"Search (Ctrl/Cmd+K)","aria-label":"Open search",children:[e.jsx(be,{size:14}),e.jsx("span",{className:"muted",children:"Search…"}),e.jsx("kbd",{children:"⌘K"})]}),e.jsx("div",{className:"topbar-spacer"}),e.jsxs("div",{className:"topbar-right",children:[d,h,g&&e.jsxs("div",{className:_("cline-status",`cline-${g.state}`),title:g.detail||`Cline ${g.label}`,"aria-label":`Cline runtime: ${g.label}`,children:[e.jsx("span",{className:"cline-dot"}),e.jsxs("span",{className:"cline-label",children:["Cline · ",g.label]})]}),e.jsxs("div",{className:_("ws-status",`ws-${a}`),title:`WebSocket: ${a}`,children:[e.jsx("span",{className:"ws-dot"}),e.jsx("span",{className:"ws-label",children:a})]})]})]}),m&&e.jsxs("nav",{className:"tabs-row",role:"tablist","aria-label":"Primary tabs",children:[kt.map(N=>{const z=N.icon,S=N.id===s;return e.jsxs("button",{type:"button",role:"tab","aria-selected":S,className:_("tab",S&&"tab-active"),onClick:()=>t(N.id),title:N.label,children:[e.jsx(z,{size:14,className:"tab-icon"}),e.jsx("span",{className:"tab-label",children:N.label}),N.id==="settings"&&S&&e.jsx("span",{className:"settings-mode-indicator",title:"Settings mode active",children:e.jsx(en,{size:12})})]},N.id)}),p&&p.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"tab-separator","aria-hidden":"true"}),p.map(N=>{const z=N.icon,S=N.id===s;return e.jsxs("button",{type:"button",role:"tab","aria-selected":S,className:_("tab","tab-mod",S&&"tab-active"),onClick:()=>t(N.id),title:`${N.label} (mod)`,children:[e.jsx(z,{size:14,className:"tab-icon"}),e.jsx("span",{className:"tab-label",children:N.label}),e.jsx("span",{className:"tab-badge",children:"mod"})]},N.id)})]})]})]})}function bi({activeProject:s,projects:t,onChange:a,onRefresh:i,settings:n}){const[c,o]=r.useState(!1),l=Ee();r.useEffect(()=>{if(!c)return;const x=()=>o(!1);return document.addEventListener("click",x),()=>document.removeEventListener("click",x)},[c]);const u=()=>{l.open({title:"Add project",children:e.jsx(Ni,{settings:n,onAdd:async(x,h)=>{try{await T.post("/projects",{path:x,name:h}),i(),o(!1),l.close()}catch(d){alert(`Add failed: ${d.message}`)}}}),footer:e.jsx("div",{className:"modal-footer-actions",children:e.jsx(A,{variant:"ghost",onClick:()=>l.close(),children:"Cancel"})})})};return e.jsxs("div",{className:"project-selector",onClick:x=>x.stopPropagation(),children:[e.jsxs("button",{type:"button",className:"project-selector-btn",onClick:()=>o(x=>!x),title:"Switch active project","aria-haspopup":"menu","aria-expanded":c,children:[e.jsx(Be,{size:14}),e.jsx("span",{className:"project-selector-name",children:(s==null?void 0:s.name)||"(no project)"}),e.jsx(qe,{size:12})]}),c&&e.jsxs("div",{className:"project-selector-menu",children:[e.jsxs("div",{className:"project-selector-menu-head",children:[e.jsxs("span",{className:"muted",children:[t.length," project",t.length===1?"":"s"]}),e.jsxs("div",{className:"project-selector-menu-actions",children:[e.jsx("button",{type:"button",className:"icon-btn",onClick:i,title:"Refresh","aria-label":"Refresh projects",children:e.jsx(oe,{size:12})}),e.jsx("button",{type:"button",className:"icon-btn",onClick:u,title:"Add project","aria-label":"Add project",children:e.jsx(Ne,{size:12})})]})]}),e.jsxs("ul",{className:"project-selector-list",children:[t.length===0&&e.jsx("li",{className:"muted project-selector-empty",children:"No projects. Add one to start."}),t.map(x=>e.jsx("li",{children:e.jsxs("button",{type:"button",className:_("project-selector-item",(s==null?void 0:s.id)===x.id&&"active"),onClick:()=>{a(x.id),o(!1)},children:[e.jsx("span",{className:"project-selector-item-name",children:x.name}),e.jsx("span",{className:"project-selector-item-status",children:x.status})]})},x.id))]})]})]})}function Ni({settings:s,onAdd:t}){var d,m;const[a,i]=r.useState(((d=s==null?void 0:s.dashboard)==null?void 0:d.projectsDirectory)??""),[n,c]=r.useState(""),[o,l]=r.useState(!1),[u,x]=r.useState(null),h=async()=>{var p;if(a){l(!0),x(null);try{await T.get("/fs?path="+encodeURIComponent(a)),t(a,n||null)}catch(g){const N=g;N.status===404?x("That folder no longer exists. Pick another."):x(((p=N.data)==null?void 0:p.message)??g.message??"Validation failed.")}finally{l(!1)}}};return e.jsxs("div",{children:[e.jsx("label",{className:"field-label",children:"Folder"}),e.jsx(Ca,{value:a,onChange:p=>{i(p),x(null)},projectsDirectory:(m=s==null?void 0:s.dashboard)==null?void 0:m.projectsDirectory,height:320}),u&&e.jsx("p",{className:"field-help",style:{color:"var(--error)",marginTop:4},children:u}),e.jsxs("div",{style:{marginTop:"var(--space-3)"},children:[e.jsx("label",{className:"field-label",htmlFor:"topbar-add-project-name",children:"Name (optional)"}),e.jsx("input",{id:"topbar-add-project-name",className:"input",type:"text",placeholder:"My App",value:n,onChange:p=>c(p.target.value)})]}),e.jsx("div",{style:{marginTop:"var(--space-3)",display:"flex",justifyContent:"flex-end"},children:e.jsxs(A,{variant:"primary",onClick:h,disabled:!a||o,children:[o?e.jsx("span",{className:"btn-spinner"}):null,o?"Checking…":"Add"]})})]})}const ki=[{label:"General",sections:[{id:"theme",label:"Theme",icon:ua},{id:"layout",label:"Layout",icon:sn}]},{label:"Core",sections:[{id:"env-vars",label:"Env Vars",icon:js},{id:"network",label:"Network",icon:tn},{id:"notifications",label:"Notifications",icon:ha},{id:"auth",label:"Auth",icon:gs},{id:"system-llm",label:"System LLM",icon:Gs}]},{label:"Agents",sections:[{id:"agents",label:"Agents",icon:Ls}]},{label:"Experience",sections:[{id:"updates",label:"Updates",icon:oe},{id:"headroom",label:"Headroom",icon:an}]},{label:"Data",sections:[{id:"activity-log",label:"Activity",icon:Me},{id:"workspaces",label:"Workspaces",icon:nn}]}];function wi({activeSection:s,onSectionChange:t,onExitSettings:a}){return e.jsxs("div",{className:"settings-nav-root","aria-label":"Settings sections",children:[e.jsxs("button",{type:"button",className:"sidebar-tab",onClick:a,"aria-label":"Exit settings",children:[e.jsx(zt,{size:14,"aria-hidden":!0}),e.jsx("span",{className:"sidebar-tab-label",children:"Back"})]}),e.jsx("div",{className:"settings-nav-divider","aria-hidden":"true"}),ki.map(i=>e.jsxs("div",{className:"settings-nav-group",children:[e.jsx("div",{className:"settings-nav-group-label",children:i.label}),i.sections.map(n=>{const c=n.icon,o=s===n.id;return e.jsxs("button",{type:"button",className:_("sidebar-tab",o&&"sidebar-tab-active"),onClick:()=>t(o?null:n.id),"aria-current":o?"page":void 0,children:[c&&e.jsx(c,{size:14,"aria-hidden":!0}),e.jsx("span",{className:"sidebar-tab-label",children:n.label}),o&&e.jsx(Qe,{size:12,"aria-hidden":!0})]},n.id)})]},i.label))]})}function Si({tabs:s,activeTab:t,onTabChange:a,settingsMode:i,settingsActiveSection:n,onSettingsSectionChange:c,onExitSettings:o}){if(i)return e.jsx("aside",{className:"sidebar sidebar-settings-mode","aria-label":"Settings navigation",children:e.jsx(wi,{activeSection:n??null,onSectionChange:c??(()=>{}),onExitSettings:o??(()=>{})})});const l=s.filter(x=>!x.isMod),u=s.filter(x=>x.isMod);return e.jsx("aside",{className:"sidebar","aria-label":"Primary navigation",children:e.jsxs("nav",{className:"sidebar-nav",role:"tablist",children:[l.map(x=>{const h=x.icon,d=x.id===t;return e.jsxs("button",{type:"button",role:"tab","aria-selected":d,className:_("sidebar-tab",d&&"sidebar-tab-active"),onClick:()=>a(x.id),title:x.label,children:[e.jsx(h,{size:18,"aria-hidden":!0}),e.jsx("span",{className:"sidebar-tab-label",children:x.label})]},x.id)}),u.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"sidebar-section-divider","aria-hidden":"true"}),e.jsx("div",{className:"sidebar-section-label",children:"Mods"}),u.map(x=>{const h=x.icon,d=x.id===t;return e.jsxs("button",{type:"button",role:"tab","aria-selected":d,className:_("sidebar-tab","sidebar-tab-mod",d&&"sidebar-tab-active"),onClick:()=>a(x.id),title:`${x.label} (mod)`,children:[e.jsx(h,{size:18,"aria-hidden":!0}),e.jsx("span",{className:"sidebar-tab-label",children:x.label})]},x.id)})]})]})})}const ot=[{id:"all",label:"All"},{id:"projects",label:"Projects"},{id:"agents",label:"Agents"},{id:"tasks",label:"Tasks"},{id:"mods",label:"Mods"},{id:"schedules",label:"Schedules"},{id:"commands",label:"Commands"},{id:"settings",label:"Settings"}],Ht={all:null,projects:"project",agents:"agent",tasks:"task",mods:"mod",schedules:"schedule",commands:"command",settings:"setting"};function Ci({open:s,onClose:t,onSelect:a}){const i=le(),[n,c]=r.useState(""),[o,l]=r.useState("all"),[u,x]=r.useState([]),[h,d]=r.useState(!1),[m,p]=r.useState(0),g=r.useRef(null),N=r.useRef(null);if(r.useEffect(()=>{let w;return s&&(N.current=document.activeElement instanceof HTMLElement?document.activeElement:null,c(""),x([]),p(0),w=window.setTimeout(()=>{var R;return(R=g.current)==null?void 0:R.focus()},30)),()=>{if(w&&window.clearTimeout(w),!s)return;const R=N.current;R&&R.isConnected&&R.focus()}},[s]),r.useEffect(()=>{if(!s)return;if(!n.trim()){x([]),p(0);return}let w=!1;d(!0);const R=setTimeout(()=>{T.get(`/search?q=${encodeURIComponent(n)}&scope=${o}`).then(j=>{w||(x(j.results||[]),p(0))}).catch(j=>{w||i.error(`Search failed: ${j.message}`)}).finally(()=>!w&&d(!1))},150);return()=>{w=!0,clearTimeout(R)}},[n,o,s,i]),!s)return null;const z={};for(const w of u){const R=w.type.toLowerCase();z[R]=z[R]||[],z[R].push(w)}const S=[];for(const w of ot.map(R=>R.id)){const R=Ht[w];R&&z[R]&&S.push(...z[R])}const y=w=>{if(w.key==="Escape")t();else if(w.key==="ArrowDown"){if(w.preventDefault(),S.length===0)return;p(R=>Math.min(R+1,S.length-1))}else if(w.key==="ArrowUp"){if(w.preventDefault(),S.length===0)return;p(R=>Math.max(R-1,0))}else w.key==="Enter"&&S[m]&&(w.preventDefault(),a(S[m]),t())};return e.jsx("div",{className:"search-modal-backdrop",onClick:t,children:e.jsxs("div",{className:"search-modal",role:"dialog","aria-modal":"true","aria-labelledby":"search-modal-title",onClick:w=>w.stopPropagation(),children:[e.jsxs("div",{className:"search-modal-head",role:"search",children:[e.jsx(be,{size:14,"aria-hidden":!0}),e.jsx("span",{id:"search-modal-title",className:"sr-only",children:"Search"}),e.jsx("input",{ref:g,className:"search-modal-input",placeholder:"Search tasks, agents, settings, projects…",value:n,onChange:w=>c(w.target.value),onKeyDown:y,"aria-label":"Search"}),e.jsx("button",{type:"button",className:"icon-btn","aria-label":"Close",onClick:t,children:e.jsx(ke,{size:14})})]}),e.jsx("div",{className:"search-modal-scopes",role:"tablist","aria-label":"Search scope",children:ot.map(w=>e.jsx("button",{type:"button",role:"tab","aria-selected":o===w.id,className:_("search-scope",o===w.id&&"search-scope-active"),onClick:()=>l(w.id),children:w.label},w.id))}),e.jsxs("div",{className:"search-modal-body",children:[h&&e.jsx("div",{className:"muted",children:"Searching…"}),!h&&n&&S.length===0&&e.jsx("div",{className:"muted",children:"No results."}),!h&&!n&&e.jsx("div",{className:"muted",children:"Type to search…"}),ot.map(w=>{const R=Ht[w.id];if(!R)return null;const j=z[R];return!j||j.length===0?null:e.jsxs("div",{className:"search-group",children:[e.jsx("div",{className:"search-group-head",children:w.label}),j.map(k=>{const f=S.indexOf(k);return e.jsxs("button",{type:"button",className:_("search-result",f===m&&"search-result-active"),onMouseEnter:()=>p(f),onClick:()=>{a(k),t()},children:[e.jsx("span",{className:"search-result-type",children:k.type}),e.jsx("span",{className:"search-result-label",children:zi(k)})]},`${k.type}-${f}`)})]},w.id)})]}),e.jsx("div",{className:"search-modal-foot",children:e.jsx("span",{className:"muted",children:"↑↓ navigate · ↵ open · esc close"})})]})})}function zi(s){const t=s.item||{};if(s.type==="project")return`${t.name} — ${t.path}`;if(s.type==="agent")return`${t.name} — ${t.description||t.model||""}`;if(s.type==="task")return`${t.title} — ${t.status||""}`;if(s.type==="mod")return`${t.name} v${t.version} — ${t.description||""}`;if(s.type==="schedule")return`${t.name} (${t.type}: ${t.schedule})`;if(s.type==="command")return`${t.name} — ${t.description||""}`;if(s.type==="setting"){const a=t.value===null||t.value===void 0?"":typeof t.value=="string"?` = ${t.value}`:` = ${JSON.stringify(t.value)}`;return`${t.label}${a} — ${t.desc||""}`.trim()}return JSON.stringify(t).slice(0,80)}const Ri={info:$t,success:Ie,warning:ze,error:ca};function Ti({onCountChange:s,wsSubscribe:t}){const a=le(),[i,n]=r.useState(!1),[c,o]=r.useState([]),[l,u]=r.useState(null),[x,h]=r.useState(!1),d=r.useRef(null),m=r.useRef(0),p=async()=>{var y;try{h(!0);const w=await T.get("/notifications?limit=200");o(w.notifications||[]),u(w.stats||null),m.current=((y=w.stats)==null?void 0:y.unread)||0,s==null||s(m.current)}catch(w){Ye.warn("[notifications] reload failed:",w.message)}finally{h(!1)}};r.useEffect(()=>{p()},[]),r.useEffect(()=>t?t(w=>{if(w.type==="notification:new"){const R=w.notification;o(j=>[R,...j.filter(k=>k.id!==R.id)]),R.read||(m.current+=1,u(j=>j?{...j,unread:(j.unread||0)+1}:{total:1,unread:1,lastTs:R.ts,counts:{[R.severity||"info"]:1}}),s==null||s(m.current))}else w.type==="notifications:change"&&p()}):void 0,[t]),r.useEffect(()=>{if(!i)return;const y=R=>{d.current&&(d.current.contains(R.target)||n(!1))},w=R=>{R.key==="Escape"&&n(!1)};return document.addEventListener("mousedown",y),document.addEventListener("keydown",w),()=>{document.removeEventListener("mousedown",y),document.removeEventListener("keydown",w)}},[i]);const g=async()=>{try{await T.post("/notifications/read-all",{}),o(y=>y.map(w=>({...w,read:!0}))),u(y=>y&&{...y,unread:0}),m.current=0,s==null||s(0),a.success("All notifications marked as read.",1500)}catch(y){a.error(`Failed: ${y.message}`)}},N=async y=>{try{await T.post(`/notifications/${encodeURIComponent(y)}/read`,{}),o(w=>w.map(R=>R.id===y?{...R,read:!0}:R)),u(w=>w&&{...w,unread:Math.max(0,(w.unread||1)-1)}),m.current=Math.max(0,m.current-1),s==null||s(m.current)}catch(w){a.error(`Failed: ${w.message}`)}},z=async y=>{try{await T.del(`/notifications/${encodeURIComponent(y)}`),o(w=>{const R=w.find(j=>j.id===y);return R&&!R.read&&(m.current=Math.max(0,m.current-1),u(j=>j&&{...j,unread:Math.max(0,j.unread-1)}),s==null||s(m.current)),w.filter(j=>j.id!==y)})}catch(w){a.error(`Failed: ${w.message}`)}},S=(l==null?void 0:l.unread)||0;return e.jsxs("div",{className:"notifications-root",ref:d,children:[e.jsxs("button",{type:"button",className:_("topbar-icon-btn notifications-bell",i&&"is-open"),onClick:()=>n(y=>!y),title:"Notifications","aria-label":"Notifications","aria-haspopup":"true","aria-expanded":i,children:[e.jsx(ha,{size:16}),S>0&&e.jsx("span",{className:"notifications-badge",children:S>99?"99+":S})]}),i&&e.jsxs("div",{className:"notifications-panel",role:"dialog","aria-label":"Notifications",children:[e.jsxs("header",{className:"notifications-panel-head",children:[e.jsxs("div",{children:[e.jsx("strong",{children:"Notifications"}),S>0&&e.jsxs("span",{className:"muted text-sm",children:[" · ",S," unread"]})]}),e.jsxs("div",{className:"notifications-panel-head-actions",children:[e.jsxs(A,{size:"sm",variant:"ghost",onClick:g,disabled:S===0,children:[e.jsx(fs,{size:12})," Mark all read"]}),e.jsx("button",{type:"button",className:"icon-btn",onClick:()=>n(!1),"aria-label":"Close",title:"Close",children:e.jsx(ke,{size:14})})]})]}),e.jsx("div",{className:"notifications-list",children:x&&c.length===0?e.jsx("div",{className:"notifications-empty muted",children:"Loading…"}):c.length===0?e.jsx("div",{className:"notifications-empty muted",children:"No notifications yet."}):c.map(y=>{const w=Ri[y.severity]||$t;return e.jsxs("div",{className:_("notification-item",!y.read&&"is-unread",`severity-${y.severity}`),children:[e.jsx(w,{size:14,className:`notification-icon severity-${y.severity}`}),e.jsxs("div",{className:"notification-body",children:[y.title&&e.jsx("div",{className:"notification-title",children:y.title}),e.jsx("div",{className:"notification-msg",children:y.message}),e.jsxs("div",{className:"notification-meta muted",children:[e.jsx("span",{className:"mono",children:y.source}),e.jsx("span",{children:"·"}),e.jsx("span",{children:Ce(y.ts)})]})]}),e.jsxs("div",{className:"notification-actions",children:[!y.read&&e.jsx("button",{type:"button",className:"icon-btn",onClick:()=>N(y.id),title:"Mark as read","aria-label":"Mark as read",children:e.jsx(fs,{size:12})}),e.jsx("button",{type:"button",className:"icon-btn icon-btn-danger",onClick:()=>z(y.id),title:"Remove","aria-label":"Remove",children:e.jsx(ke,{size:12})})]})]},y.id)})}),e.jsx("footer",{className:"notifications-panel-foot",children:e.jsx("span",{className:"muted text-sm",children:l?`${l.total} total · last ${Ce(l.lastTs||new Date().toISOString())}`:""})})]})]})}function $i({data:s,onClose:t}){const a=s==null?void 0:s.enabled;s==null||s.previousEnabled;const i=s==null?void 0:s.mode,n=s==null?void 0:s.defaultTemplate,c=s==null?void 0:s.lastUsedSlug,o=i==="toggle";return e.jsxs("div",{children:[o?e.jsxs("p",{style:{marginBottom:16,lineHeight:1.6},children:["Visual plan mode has been ",e.jsx("strong",{children:a?"enabled":"disabled"}),".",a?" The agent will create a plan and wait for your feedback on complex tasks.":" The agent will work without a visual plan canvas."]}):e.jsxs("div",{style:{marginBottom:16},children:[e.jsxs("p",{style:{marginBottom:8,fontWeight:600},children:["Visual Plan: ",e.jsx("span",{style:{color:a?"var(--color-success)":"var(--color-muted)"},children:a?"ON":"OFF"})]}),e.jsx("p",{style:{lineHeight:1.6,color:"var(--color-muted)",fontSize:13},children:"When enabled, the agent creates a visual plan and waits for your feedback before proceeding with complex tasks."}),n&&e.jsxs("p",{style:{marginTop:8,fontSize:13,color:"var(--color-muted)"},children:["Default template: ",e.jsx("code",{children:n})]}),c&&e.jsxs("p",{style:{fontSize:13,color:"var(--color-muted)"},children:["Last used plan: ",e.jsx("code",{children:c})]}),e.jsxs("p",{style:{marginTop:12,fontSize:13,color:"var(--color-muted)"},children:["Use ",e.jsx("code",{children:"/visual-plan on"})," or ",e.jsx("code",{children:"/visual-plan off"})," to toggle."]})]}),e.jsx("div",{style:{display:"flex",gap:8,justifyContent:"flex-end"},children:e.jsx(A,{variant:"ghost",onClick:t,children:"Close"})})]})}const Ai=["blank","feature-design","bug-investigation","decision-record","horizontal","vertical"];function Mi({data:s,onClose:t}){const a=(s==null?void 0:s.templates)??Ai,i=(s==null?void 0:s.defaultTemplate)??"blank",[n,c]=r.useState(""),[o,l]=r.useState(i),[u,x]=r.useState(!1),[h,d]=r.useState(null),m=async()=>{if(!n.trim()){d("Slug is required.");return}if(!/^[a-z0-9][a-z0-9-]{0,63}$/.test(n)){d("Invalid slug. Use lowercase letters, numbers, and hyphens. Must start with an alphanumeric character.");return}x(!0),d(null);try{await T.post("/artifacts",{slug:n,template:o}),t()}catch(p){d(p.message),x(!1)}};return e.jsxs("div",{children:[e.jsxs("p",{style:{marginBottom:16,color:"var(--color-muted)",fontSize:13},children:["Create a new visual plan. Plans are stored in ",e.jsx("code",{children:"artifacts/"})," in your worktree."]}),e.jsxs("div",{style:{marginBottom:12},children:[e.jsx("label",{className:"field-label",htmlFor:"plan-slug",children:"Plan slug"}),e.jsx("input",{id:"plan-slug",className:"input",type:"text",placeholder:"e.g. my-feature",value:n,onChange:p=>{c(p.target.value),d(null)},autoFocus:!0})]}),e.jsxs("div",{style:{marginBottom:16},children:[e.jsx("label",{className:"field-label",htmlFor:"plan-template",children:"Template"}),e.jsx("select",{id:"plan-template",className:"select",value:o,onChange:p=>l(p.target.value),children:a.map(p=>e.jsx("option",{value:p,children:p},p))})]}),h&&e.jsx("p",{style:{marginBottom:12,color:"var(--color-danger)",fontSize:13},children:h}),e.jsxs("div",{style:{display:"flex",gap:8,justifyContent:"flex-end"},children:[e.jsx(A,{variant:"ghost",onClick:t,disabled:u,children:"Cancel"}),e.jsx(A,{variant:"primary",onClick:m,disabled:u||!n.trim(),children:u?"Creating…":"Create"})]})]})}function Ii({data:s,onClose:t}){const a=(s==null?void 0:s.plans)??[],i=(s==null?void 0:s.count)??a.length,n=c=>{window.open(`/artifacts/${c}/`,"_blank")};return e.jsxs("div",{children:[a.length===0?e.jsxs("p",{style:{marginBottom:16,color:"var(--color-muted)"},children:["No plans found in this worktree. Use ",e.jsx("code",{children:"/artifact new <slug>"})," to create one."]}):e.jsxs("div",{style:{marginBottom:16},children:[e.jsxs("p",{style:{marginBottom:12,fontSize:13,color:"var(--color-muted)"},children:[i," plan",i!==1?"s":""," in this worktree:"]}),e.jsx("ul",{style:{listStyle:"none",padding:0,margin:0},children:a.map(c=>e.jsxs("li",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"6px 0",borderBottom:"1px solid var(--color-border)"},children:[e.jsx("code",{style:{fontSize:13},children:c}),e.jsx(A,{variant:"ghost",size:"sm",onClick:()=>n(c),children:"Open"})]},c))})]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(A,{variant:"ghost",onClick:t,children:"Close"})})]})}function Ei({data:s,onClose:t}){const a=(s==null?void 0:s.commands)??[],i=(s==null?void 0:s.templates)??[],n=(s==null?void 0:s.statuses)??[];return e.jsxs("div",{children:[a.length>0?e.jsx("table",{style:{width:"100%",borderCollapse:"collapse",marginBottom:16,fontSize:13},children:e.jsx("tbody",{children:a.map(c=>e.jsxs("tr",{style:{borderBottom:"1px solid var(--color-border)"},children:[e.jsx("td",{style:{padding:"5px 8px 5px 0",whiteSpace:"nowrap"},children:e.jsx("code",{style:{fontSize:12},children:c.cmd})}),e.jsx("td",{style:{padding:"5px 0",color:"var(--color-muted)"},children:c.desc})]},c.cmd))})}):e.jsx("p",{style:{marginBottom:16,color:"var(--color-muted)"},children:"No commands available."}),i.length>0&&e.jsxs("div",{style:{marginBottom:12},children:[e.jsx("p",{style:{fontSize:12,color:"var(--color-muted)",marginBottom:4},children:"Available templates:"}),e.jsx("p",{style:{fontSize:13},children:i.join(", ")})]}),n.length>0&&e.jsxs("div",{style:{marginBottom:12},children:[e.jsx("p",{style:{fontSize:12,color:"var(--color-muted)",marginBottom:4},children:"Available statuses:"}),e.jsx("p",{style:{fontSize:13},children:n.join(", ")})]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(A,{variant:"ghost",onClick:t,children:"Close"})})]})}function Li({data:s,onClose:t}){const[a,i]=r.useState(!1),[n,c]=r.useState(null),o=async()=>{i(!0),c(null);try{const l=await T.post("/chat/audit",{});c(l)}catch(l){c({ok:!1,findings:[],error:l.message})}finally{i(!1)}};return e.jsx("div",{children:n===null?e.jsxs(e.Fragment,{children:[e.jsx("p",{style:{marginBottom:16,lineHeight:1.6},children:"Run a security audit of your Bizar agent configuration. The audit checks for common misconfigurations, exposed secrets, and insecure defaults."}),e.jsxs("div",{style:{display:"flex",gap:8,justifyContent:"flex-end"},children:[e.jsx(A,{variant:"ghost",onClick:t,children:"Cancel"}),e.jsx(A,{variant:"primary",onClick:o,disabled:a,children:a?"Running…":"Run Audit"})]})]}):e.jsxs(e.Fragment,{children:[n.ok?e.jsxs("div",{children:[e.jsx("p",{style:{marginBottom:12,fontWeight:600,color:"var(--color-success)"},children:"Audit passed — no issues found."}),n.findings.length>0&&e.jsx("ul",{style:{marginBottom:16,paddingLeft:20},children:n.findings.map((l,u)=>e.jsx("li",{style:{marginBottom:4,fontSize:13},children:l},u))})]}):e.jsxs("p",{style:{marginBottom:16,color:"var(--color-danger)"},children:["Audit failed: ",n.error??"unknown error"]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(A,{variant:"ghost",onClick:t,children:"Close"})})]})})}function Di({dialog:s,onClose:t}){if(!s.data)return e.jsxs("div",{children:[e.jsx("p",{style:{marginBottom:16,lineHeight:1.6},children:`Command: ${s.command}`}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx("button",{type:"button",className:"btn",onClick:t,children:"Close"})})]});const{message:a,detail:i,url:n}=s.data;return e.jsxs("div",{children:[e.jsx("p",{style:{marginBottom:16,lineHeight:1.6},children:a??`Command: ${s.command}`}),i&&e.jsx("p",{style:{marginBottom:16,color:"var(--color-muted)",fontSize:13},children:i}),n&&e.jsx("p",{style:{marginBottom:16},children:e.jsx("a",{href:n,target:"_blank",rel:"noopener noreferrer",children:n})}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx("button",{type:"button",className:"btn",onClick:t,children:"Close"})})]})}function Pi({dialog:s,onClose:t}){switch(s.component){case"visual-artifact":return e.jsx($i,{data:s.data,onClose:t});case"artifact-create":return e.jsx(Mi,{data:s.data,onClose:t});case"artifact-list":return e.jsx(Ii,{data:s.data,onClose:t});case"help":return e.jsx(Ei,{data:s.data,onClose:t});case"audit":return e.jsx(Li,{data:s.data,onClose:t});default:return e.jsx(Di,{dialog:s,onClose:t})}}function Fi({setActiveTab:s,refreshKey:t=0}){var x;const[a,i]=r.useState(null),[n,c]=r.useState(!0),o=async()=>{c(!0);try{const[h,d,m]=await Promise.all([T.get("/memory/status").catch(()=>null),T.get("/memory/health").catch(()=>null),T.get("/memory/lightrag/stats").catch(()=>null)]);i({initialized:!!(h!=null&&h.initialized),mode:h==null?void 0:h.mode,projectId:h==null?void 0:h.projectId,vaultRoot:h==null?void 0:h.vaultRoot,branch:h==null?void 0:h.branch,gitClean:h==null?void 0:h.gitClean,noteCount:(h==null?void 0:h.noteCount)||0,healthScore:d==null?void 0:d.score,healthStatus:d==null?void 0:d.status,lightrag:m?{running:m.running,indexedApprox:m.indexedApprox}:void 0})}catch{i({initialized:!1})}finally{c(!1)}};r.useEffect(()=>{o()},[t]);const l=()=>s("memory"),u=(a==null?void 0:a.healthStatus)==="healthy"?"var(--success)":(a==null?void 0:a.healthStatus)==="degraded"?"var(--warning)":(a==null?void 0:a.healthStatus)==="unhealthy"?"var(--error)":"var(--text-dim)";return e.jsxs(K,{className:"memory-overview-card",children:[e.jsxs(te,{children:[e.jsx(We,{size:14})," Memory",e.jsxs(A,{variant:"ghost",size:"sm",style:{marginLeft:"auto"},onClick:l,children:["Open Memory ",e.jsx(Ns,{size:12})]}),e.jsx(A,{variant:"ghost",size:"sm",onClick:o,"aria-label":"Refresh",title:"Refresh",children:e.jsx(oe,{size:12})})]}),e.jsx(ne,{children:"LightRAG + Obsidian vault + git sync — opens the dedicated Memory tab."}),a!=null&&a.initialized?e.jsxs("div",{className:"memory-status-card-grid",children:[e.jsxs("div",{className:"memory-status-card-cell",children:[e.jsxs("div",{className:"memory-status-card-label",children:[e.jsx(Me,{size:11})," Health"]}),e.jsx("div",{className:"memory-status-card-value",style:{color:u},children:a.healthScore!==void 0?`${a.healthScore}/100`:"—"}),e.jsx("div",{className:"memory-status-card-sub muted",children:a.healthStatus||"—"})]}),e.jsxs("div",{className:"memory-status-card-cell",children:[e.jsxs("div",{className:"memory-status-card-label",children:[e.jsx(We,{size:11})," LightRAG"]}),e.jsx("div",{className:"memory-status-card-value",children:(x=a.lightrag)!=null&&x.running?"running":"stopped"}),e.jsx("div",{className:"memory-status-card-sub muted",children:a.lightrag?`${a.lightrag.indexedApprox} chunks`:"—"})]}),e.jsxs("div",{className:"memory-status-card-cell",children:[e.jsxs("div",{className:"memory-status-card-label",children:[e.jsx(Re,{size:11})," Vault"]}),e.jsxs("div",{className:"memory-status-card-value",children:[a.noteCount," notes"]}),e.jsx("div",{className:"memory-status-card-sub muted ellipsis",title:a.vaultRoot||"",children:a.vaultRoot?a.vaultRoot.split("/").slice(-2).join("/"):"—"})]}),e.jsxs("div",{className:"memory-status-card-cell",children:[e.jsxs("div",{className:"memory-status-card-label",children:[e.jsx(is,{size:11})," Git"]}),e.jsx("div",{className:"memory-status-card-value",children:a.gitClean===null?a.mode==="local-only"?"local-only":"—":a.gitClean?"clean":"dirty"}),e.jsx("div",{className:"memory-status-card-sub muted",children:a.branch?`branch ${a.branch}`:Ve(a.branch||"")||"—"})]})]}):e.jsxs("div",{className:"muted",children:["Memory not initialised. Click ",e.jsx("strong",{children:"Open Memory"})," to set it up."]}),n&&!a&&e.jsx("div",{className:"muted text-sm",children:"Loading…"})]})}function ge({icon:s,title:t,message:a,action:i,className:n}){return e.jsxs("div",{className:_("empty-state",n),children:[e.jsx("div",{className:"empty-icon",children:s??e.jsx(et,{size:32})}),e.jsx("div",{className:"empty-title",children:t}),a&&e.jsx("div",{className:"empty-message",children:a}),i&&e.jsx("div",{className:"empty-action",children:i})]})}function Oi({snapshot:s,settings:t,setActiveTab:a,refreshSnapshot:i}){var Q,U,W;const n=le(),c=Ee(),o=r.useRef(null),[l,u]=r.useState(s.overview??null),[x,h]=r.useState(!s.overview),[d,m]=r.useState(s.projects||[]),[p,g]=r.useState(((Q=s.activeProject)==null?void 0:Q.id)||null),[N,z]=r.useState(s.mods||[]),[S,y]=r.useState(!1),[w,R]=r.useState(((U=s.overview)==null?void 0:U.recentActivity)??[]),[j,k]=r.useState(!1),[f,v]=r.useState(new Set);r.useEffect(()=>{let F=!1;return(async()=>{try{const V=await T.get("/activity/hidden");F||v(new Set(V.hidden||[]))}catch{}})(),()=>{F=!0}},[]);const L=(F,V)=>{const Y=`${F.kind||""}|${F.ts||""}|${F.slug||F.title||""}|${V}`;let B=0;for(let Z=0;Z<Y.length;Z++)B=(B<<5)-B+Y.charCodeAt(Z)|0;return Math.abs(B).toString(16).padStart(8,"0").slice(0,16)},$=async F=>{const V=new Set(f);V.add(F),v(V);try{await T.post("/activity/hide",{keys:[F]})}catch(Y){const B=new Set(f);v(B),n.error(`Hide failed: ${Y.message}`)}},b=async()=>{if(!confirm("Hide every recent activity item from the overview? The full log stays in Settings → Activity Log."))return;const F=w.map((Y,B)=>L(Y,B)),V=new Set(f);F.forEach(Y=>V.add(Y)),v(V);try{await T.post("/activity/hide",{keys:F}),n.success(`Hidden ${F.length} item(s). Restore them in Settings → Activity Log.`)}catch(Y){n.error(`Clear failed: ${Y.message}`)}},M=async()=>{v(new Set);try{await T.del("/activity/hide"),n.success("All hidden activity restored to the overview.")}catch(F){n.error(`Restore failed: ${F.message}`)}};r.useEffect(()=>{var F;s.overview&&(u(s.overview),R(s.overview.recentActivity??[]),h(!1)),m(s.projects||[]),g(((F=s.activeProject)==null?void 0:F.id)||null),z(s.mods||[])},[s.overview,s.projects,s.activeProject,s.mods]),r.useEffect(()=>{let F;try{const V=T.getToken(),Y=V?`/api/activity/stream?token=${encodeURIComponent(V)}`:"/api/activity/stream";F=new EventSource(Y),F.addEventListener("snapshot",B=>{try{const Z=JSON.parse(B.data);R(Array.isArray(Z.events)?Z.events.slice(0,50):[])}catch{}}),F.addEventListener("activity",B=>{try{const Z=JSON.parse(B.data);R(xe=>[Z,...xe].slice(0,50))}catch{}})}catch{}return()=>{try{F==null||F.close()}catch{}}},[]);const P=async()=>{n.info("Refreshing…",1500),await i();try{const F=await T.get("/projects");m(F.projects||[]),g(F.active||null)}catch{}},C=()=>{c.open({title:"Add project",children:e.jsx(Bi,{settings:t,onAdd:async(F,V)=>{try{const Y=await T.post("/projects",{path:F,name:V});m(B=>[...B.filter(Z=>Z.id!==Y.id),Y]),n.success("Project added."),c.close()}catch(Y){n.error(`Add failed: ${Y.message}`)}}}),footer:e.jsx("div",{className:"modal-footer-actions",children:e.jsx(A,{variant:"ghost",onClick:()=>c.close(),children:"Cancel"})})})},D=async()=>{var F;try{const V=await T.post("/projects/auto-detect");m(V.projects||[]),g(V.active||null);const Y=(F=V.projects)==null?void 0:F.find(B=>B.id===V.active);n.success(Y?`Active: ${Y.name}`:"Projects refreshed."),await i()}catch(V){n.error(`Auto-detect failed: ${V.message}`)}},X=async F=>{try{await T.post(`/projects/${encodeURIComponent(F)}/activate`),g(F),n.success("Project activated."),await i()}catch(V){n.error(`Activate failed: ${V.message}`)}},O=async F=>{if(confirm(`Remove project "${F}" from the registry?`))try{await T.del(`/projects/${encodeURIComponent(F)}`),m(V=>V.filter(Y=>Y.id!==F)),p===F&&g(null),n.success("Project removed.")}catch(V){n.error(`Remove failed: ${V.message}`)}};return x||!l?e.jsxs("div",{className:"view-loading",children:[e.jsx(de,{size:"lg"}),e.jsx("p",{children:"Loading overview…"})]}):e.jsxs("div",{className:"view view-overview",children:[e.jsxs("div",{className:"overview-hero-noframe",children:[e.jsx("h1",{children:"What do you want to do?"}),e.jsx("p",{className:"overview-hero-subtitle",children:"Describe what you want — Odin will split it into tasks, create a plan, delegate to background agents, and track progress in real time."}),e.jsxs("form",{className:"overview-hero-form-noframe",onSubmit:async F=>{var Y,B;F.preventDefault();const V=(((Y=o.current)==null?void 0:Y.value)||"").trim();if(V){y(!0);try{const Z=await T.post("/tasks/submit",{title:V});n.success(`Odin split it into ${((B=Z.subtasks)==null?void 0:B.length)||1} task(s)`),o.current&&(o.current.value=""),await i()}catch(Z){n.error(`Failed: ${Z.message}`)}finally{y(!1)}}},children:[e.jsx("label",{htmlFor:"overview-hero-input",className:"sr-only",children:"Describe what you want Odin to do"}),e.jsx("textarea",{id:"overview-hero-input",ref:o,className:"overview-input-hero",placeholder:"e.g. Implement user authentication with email + password, including registration, login, password reset, and integration tests. Use Bcrypt, JWT tokens, and the existing API style.",disabled:S,"aria-label":"Describe what you want Odin to do"}),e.jsxs("div",{style:{display:"flex",gap:"var(--space-2)",alignItems:"center",flexWrap:"wrap"},children:[e.jsxs(A,{type:"submit",variant:"primary",size:"lg",disabled:S,children:[S?e.jsx(de,{size:"sm"}):e.jsx(es,{size:16}),"Submit to Odin"]}),e.jsxs("span",{className:"muted",style:{fontSize:12},children:[e.jsx(Ge,{size:12,style:{display:"inline",verticalAlign:-2,color:"var(--accent)"}})," ","Odin + 12 specialist agents available"]})]})]}),e.jsx("div",{className:"overview-quick-actions-row",children:["Implement feature","Fix bug","Refactor","Investigate","Add tests","Document","Optimize","Deploy"].map(F=>e.jsx("button",{type:"button",className:"overview-quick-chip",onClick:()=>{o.current&&(o.current.value=F,o.current.focus())},children:F},F))})]}),e.jsxs("div",{className:"overview-feed",children:[e.jsxs("div",{className:"overview-feed-head",children:[e.jsx("h2",{children:"Recent activity"}),e.jsxs("div",{className:"overview-feed-head-actions",children:[f.size>0&&e.jsxs(A,{variant:"ghost",size:"sm",onClick:M,title:"Restore hidden items to this overview",children:[e.jsx(vs,{size:12})," Show ",f.size," hidden"]}),w.length>8&&e.jsx(A,{variant:"ghost",size:"sm",onClick:()=>k(F=>!F),children:j?"Show less":"Show all"}),w.length>0&&e.jsxs(A,{variant:"ghost",size:"sm",onClick:b,title:"Hide every item from the overview (full log kept)",children:[e.jsx(yt,{size:12})," Hide all"]})]})]}),f.size>0&&e.jsxs("div",{className:"activity-hidden-banner",role:"status",children:[e.jsxs("span",{children:[e.jsx(yt,{size:12,style:{verticalAlign:-2,marginRight:6}}),f.size," item",f.size===1?"":"s"," hidden from the overview."]}),e.jsxs(A,{variant:"ghost",size:"sm",onClick:M,children:[e.jsx(vs,{size:12})," Show them again"]})]}),w.length===0?e.jsx("div",{className:"muted",style:{padding:"24px 0",fontSize:13},children:"No activity yet. Use the chat above or invoke a Bizar command to start a feed."}):e.jsxs("div",{className:_("activity-feed-list-wrap",!j&&"activity-feed-list-wrap-collapsed"),"aria-live":"polite","aria-relevant":"additions",children:[e.jsx(Ot,{items:w.slice(0,30).filter((F,V)=>!f.has(L(F,V))),itemHeight:60,height:Math.min(w.filter((F,V)=>!f.has(L(F,V))).length*60,480),className:"activity-feed-list",renderItem:(F,V)=>{const Y=w.slice(0,30).findIndex(B=>B===F);return e.jsx(Yi,{item:F,activityKey:L(F,Y),onNavigate:a,onHide:$})}}),!j&&w.length>8&&e.jsx("div",{className:"activity-feed-fade","aria-hidden":"true"})]})]}),e.jsxs(K,{className:"project-picker",children:[e.jsxs(te,{children:[e.jsx(Be,{size:14})," Projects",e.jsxs(A,{variant:"ghost",size:"sm",style:{marginLeft:"auto"},onClick:C,children:[e.jsx(Ne,{size:12})," Add"]}),e.jsxs(A,{variant:"ghost",size:"sm",onClick:D,title:"Use the server's working directory",children:[e.jsx(Ne,{size:12})," Auto-detect"]}),((W=t==null?void 0:t.dashboard)==null?void 0:W.projectsDirectory)&&e.jsxs(A,{variant:"ghost",size:"sm",title:`Scan ${t.dashboard.projectsDirectory} for projects`,onClick:async()=>{try{const F=await T.post("/projects/scan");F.error?n.error(F.error):n.success(`Added ${F.added.length}, skipped ${F.skipped}.`),await i();const V=await T.get("/projects");m(V.projects||[]),g(V.active||null)}catch(F){n.error(`Scan failed: ${F.message}`)}},children:[e.jsx(rn,{size:12})," Scan"]}),e.jsx(A,{variant:"ghost",size:"sm",onClick:P,title:"Refresh",children:e.jsx(oe,{size:12})})]}),e.jsxs(ne,{children:[d.length," project",d.length===1?"":"s"," ·"," ",l.counts.agents," agents ·"," ",l.counts.sessions," session",l.counts.sessions===1?"":"s"]}),d.length===0?e.jsx(ge,{icon:e.jsx(Be,{size:32}),title:"No projects yet",message:"Add a project to start tracking its tasks, plans, and schedules.",action:e.jsxs("div",{className:"empty-state-actions",children:[e.jsxs(A,{variant:"primary",onClick:D,children:[e.jsx(Ne,{size:14})," Use current directory"]}),e.jsx(A,{variant:"secondary",onClick:C,children:"Add by path…"})]})}):e.jsx("div",{className:"project-grid",children:d.map(F=>e.jsx(Ui,{project:F,active:p===F.id,onOpen:()=>X(F.id),onRemove:()=>O(F.id)},F.id))})]}),e.jsx(Fi,{setActiveTab:a}),e.jsxs("div",{className:"overview-cols",children:[e.jsxs(K,{children:[e.jsx(te,{children:"Mods"}),e.jsxs(ne,{children:["Extensions installed under ",e.jsx("code",{children:"~/.config/bizar/mods/"})]}),N.length===0?e.jsx("div",{className:"muted",children:"No mods installed."}):e.jsx("ul",{className:"mod-mini-list",children:N.map(F=>e.jsxs("li",{className:"mod-mini",children:[e.jsx("span",{className:"mod-mini-name",children:F.name}),e.jsxs("span",{className:"mod-mini-meta",children:["v",F.version," · ",F.type]}),e.jsx("span",{className:`mod-mini-pill ${F.enabled?"mod-mini-pill-on":"mod-mini-pill-off"}`,children:F.enabled?"on":"off"})]},F.id))})]}),e.jsxs(K,{children:[e.jsx(te,{children:"Environment"}),e.jsx(ne,{children:"Runtime + paths"}),e.jsxs("dl",{className:"env-table",children:[e.jsx("dt",{children:"Node"}),e.jsx("dd",{className:"mono",children:l.versions.node}),e.jsx("dt",{children:"Platform"}),e.jsx("dd",{className:"mono",children:l.versions.platform}),e.jsx("dt",{children:"Project root"}),e.jsx("dd",{className:"mono ellipsis",title:l.versions.projectRoot,children:l.versions.projectRoot}),e.jsx("dt",{children:"Bizar root"}),e.jsx("dd",{className:"mono ellipsis",title:l.versions.bizarRoot,children:l.versions.bizarRoot}),e.jsx("dt",{children:"Generated"}),e.jsx("dd",{className:"mono tabular-nums",children:Ve(l.generatedAt)})]})]})]})]})}function Bi({settings:s,onAdd:t}){var d,m;const[a,i]=r.useState(((d=s==null?void 0:s.dashboard)==null?void 0:d.projectsDirectory)??""),[n,c]=r.useState(""),[o,l]=r.useState(!1),[u,x]=r.useState(null),h=async()=>{var p;if(a){l(!0),x(null);try{await T.get("/fs?path="+encodeURIComponent(a)),t(a,n||null)}catch(g){const N=g;N.status===404?x("That folder no longer exists. Pick another."):x(((p=N.data)==null?void 0:p.message)??g.message??"Validation failed.")}finally{l(!1)}}};return e.jsxs("div",{children:[e.jsx("label",{className:"field-label",children:"Folder"}),e.jsx(Ca,{value:a,onChange:p=>{i(p),x(null)},projectsDirectory:(m=s==null?void 0:s.dashboard)==null?void 0:m.projectsDirectory,height:320}),u&&e.jsx("p",{className:"field-help",style:{color:"var(--error)",marginTop:4},children:u}),e.jsxs("div",{style:{marginTop:"var(--space-3)"},children:[e.jsx("label",{className:"field-label",htmlFor:"add-project-name",children:"Name (optional)"}),e.jsx("input",{id:"add-project-name",className:"input",type:"text",placeholder:"My App",value:n,onChange:p=>c(p.target.value)}),e.jsx("p",{className:"field-help",style:{marginTop:4},children:"Display name for this project. Defaults to the folder name."})]}),e.jsx("div",{style:{marginTop:"var(--space-3)",display:"flex",justifyContent:"flex-end"},children:e.jsxs(A,{variant:"primary",onClick:h,disabled:!a||o,children:[o?e.jsx("span",{className:"btn-spinner"}):null,o?"Checking…":"Add"]})})]})}function Ui({project:s,active:t,onOpen:a,onRemove:i}){const n={active:"status-on",inactive:"status-neutral",error:"status-error"}[s.status]||"status-neutral";return e.jsxs("div",{className:`project-card ${t?"project-card-active":""}`,children:[e.jsxs("div",{className:"project-card-head",children:[e.jsx("span",{className:`project-card-status ${n}`,children:s.status}),e.jsx("div",{className:"project-card-name",children:s.name}),e.jsx("button",{type:"button",className:"icon-btn","aria-label":"Remove project",title:"Remove",onClick:c=>{c.stopPropagation(),i()},children:e.jsx(we,{size:12})})]}),e.jsx("div",{className:"project-card-path mono ellipsis",title:s.path,children:s.path}),e.jsx("div",{className:"project-card-meta",children:s.lastAccessed&&e.jsxs("span",{className:"muted",children:["Last opened ",Ce(s.lastAccessed)]})}),e.jsx("div",{className:"project-card-actions",children:e.jsx(A,{variant:t?"ghost":"primary",size:"sm",onClick:a,children:t?e.jsxs(e.Fragment,{children:[e.jsx(At,{size:12})," Active"]}):e.jsx(e.Fragment,{children:"Open"})})})]})}function _i(s){return s&&s.charAt(0).toUpperCase()+s.slice(1)}function Wi(s){const t=s.trim().toLowerCase().replace(/[:_]/g,"."),[a,i="updated"]=t.split("."),n={settings:"Settings",task:"Task",tasks:"Task",agent:"Agent",agents:"Agent",plan:"Plan",plans:"Plan",bg:"Background job",background:"Background job",session:"Session",mod:"Mod",mods:"Mod",provider:"Provider",providers:"Provider"},c={create:"created",created:"created",add:"added",added:"added",update:"updated",updated:"updated",delegate:"delegated",delegated:"delegated",invoke:"invoked",invoked:"invoked",restart:"restarted",restarted:"restarted",delete:"deleted",deleted:"deleted",remove:"removed",removed:"removed",archive:"archived",archived:"archived",restore:"restored",restored:"restored",complete:"completed",completed:"completed",fail:"failed",failed:"failed",error:"errored",stuck:"marked stuck"},o=n[a]||_i(a.replace(/-/g," ")),l=c[i]||i.replace(/-/g," ");return`${o} ${l}`.trim()}function _s(s,t){for(const a of t){const i=s[a];if(typeof i=="string"&&i.trim())return i.trim()}return""}function Vi(s){const t=_s(s,["message","text","prompt","title","name"]);if(t)return t;const a=[],i=_s(s,["slug"]),n=_s(s,["agent","author"]),c=_s(s,["status"]);return i&&a.push(`Plan ${i}`),n&&a.push(n),c&&a.push(c),a.length?a.join(" · "):"No additional details."}function qi(s){return Ce(s)}function Hi(s){const t=(s.kind||"").toLowerCase(),a=(s.status||"").toLowerCase();return t.includes("error")||a==="error"||a==="failure"?"error":t.includes("warn")||a==="blocked"?"warning":t.includes("done")||t.includes("success")||a==="done"?"success":"info"}function Gi(s){const t=s.toLowerCase();return t==="task"?Is:t==="agent"?Xe:t==="plan"?Js:t.includes("bg")||t.includes("background")||t.includes("job")?Mt:t==="mod"?Zs:t==="skill"?Ge:t.includes("error")||t.includes("failure")?ps:t.includes("warn")?ze:Me}function Ki(s){const t=s.toLowerCase();return t==="task"?"tasks":t==="agent"?"agents":t==="plan"?"artifacts":t.includes("bg")||t.includes("background")?"activity":t==="mod"?"mods":t==="skill"?"skills":null}function Yi({item:s,activityKey:t,onNavigate:a,onHide:i}){const n=Hi(s),c=Gi(s.kind||""),o=Wi(s.kind||"activity"),l=Vi(s),u=Ki(s.kind||""),x=n==="error"?"var(--error)":n==="warning"?"var(--warning)":n==="success"?"var(--success)":"var(--accent)";return e.jsxs("div",{className:_("activity-feed-row",`activity-feed-row-${n}`),children:[e.jsxs("button",{type:"button",className:"activity-feed-row-main",onClick:()=>{u&&a(u)},title:u?`Open ${u}`:o,children:[e.jsx("div",{className:"activity-feed-icon",style:{color:x},children:e.jsx(c,{size:14})}),e.jsxs("div",{className:"activity-feed-body",children:[e.jsxs("div",{className:"activity-feed-title-row",children:[e.jsx("div",{className:"activity-feed-title",children:o}),e.jsx("div",{className:"activity-feed-time text-xs muted tabular-nums",children:qi(s.ts)})]}),e.jsx("div",{className:"activity-feed-summary text-sm",children:l})]})]}),e.jsx("button",{type:"button",className:"activity-feed-hide-btn",onClick:()=>i(t),title:"Hide this from the overview (kept in Settings → Activity Log)","aria-label":"Hide from overview",children:e.jsx(ke,{size:12})})]})}const Xi=Ue.memo(Oi);function Qi({icon:s,title:t,message:a,action:i}){return e.jsxs("div",{className:"chat-empty-state",children:[s&&e.jsx("div",{className:"chat-empty-state-icon",children:s}),e.jsx("h2",{className:"chat-empty-state-title",children:t}),e.jsx("p",{className:"chat-empty-state-message",children:a}),i&&e.jsx("div",{className:"chat-empty-state-action",children:i})]})}function Ji({session:s,mode:t,anchor:a,renameDraft:i,setRenameDraft:n,onEdit:c,onDeleteRequest:o,onConfirmDelete:l,onConfirmRename:u,onClose:x}){const h=r.useRef(null),d=Math.round(a.rect.bottom+2),m=Math.max(8,Math.round(window.innerWidth-a.rect.right));r.useEffect(()=>{const g=S=>{const y=S.target;!h.current||!y||h.current.contains(y)||x()},N=S=>{S.key==="Escape"&&x()},z=window.setTimeout(()=>{document.addEventListener("mousedown",g),document.addEventListener("keydown",N)},0);return()=>{window.clearTimeout(z),document.removeEventListener("mousedown",g),document.removeEventListener("keydown",N)}},[x]),r.useEffect(()=>{if(t!=="rename")return;const g=window.setTimeout(()=>{var z;const N=(z=h.current)==null?void 0:z.querySelector("input.session-row-menu-input");N==null||N.focus(),N==null||N.select()},0);return()=>window.clearTimeout(g)},[t]);const p=e.jsxs("div",{ref:h,className:"session-row-menu",role:"menu","aria-label":`Options for ${s.title}`,style:{position:"fixed",top:d,right:m},onClick:g=>g.stopPropagation(),children:[t==="main"&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{type:"button",className:"session-row-menu-item",role:"menuitem",onClick:g=>{g.stopPropagation(),c()},children:[e.jsx(ln,{size:13,"aria-hidden":!0}),e.jsx("span",{children:"Rename"}),e.jsx("kbd",{children:"R"})]}),e.jsxs("button",{type:"button",className:"session-row-menu-item session-row-menu-item-danger",role:"menuitem",onClick:g=>{g.stopPropagation(),o()},children:[e.jsx(we,{size:13,"aria-hidden":!0}),e.jsx("span",{children:"Delete"}),e.jsx("kbd",{children:"⌫"})]})]}),t==="rename"&&e.jsxs("div",{className:"session-row-menu-inline",children:[e.jsx("div",{className:"session-row-menu-inline-label chat-mono",children:"Rename session"}),e.jsx("input",{type:"text",className:"session-row-menu-input",value:i,onChange:g=>n(g.target.value),onKeyDown:g=>{g.key==="Enter"?(g.preventDefault(),u()):g.key==="Escape"&&(g.preventDefault(),x())},onClick:g=>g.stopPropagation(),"aria-label":"New session name"}),e.jsxs("div",{className:"session-row-menu-inline-actions",children:[e.jsx("button",{type:"button",className:"btn btn-ghost",onClick:g=>{g.stopPropagation(),x()},children:"Cancel"}),e.jsx("button",{type:"button",className:"btn btn-primary",onClick:g=>{g.stopPropagation(),u()},children:"Save"})]})]}),t==="confirm-delete"&&e.jsxs("div",{className:"session-row-menu-inline",children:[e.jsx("div",{className:"session-row-menu-inline-label chat-mono",children:"Delete this session?"}),e.jsxs("div",{className:"session-row-menu-inline-message",children:['"',s.title,'" and its sub-agents will be removed.']}),e.jsxs("div",{className:"session-row-menu-inline-actions",children:[e.jsx("button",{type:"button",className:"btn btn-ghost",onClick:g=>{g.stopPropagation(),x()},children:"Cancel"}),e.jsx("button",{type:"button",className:"btn btn-danger",onClick:g=>{g.stopPropagation(),l()},children:"Delete"})]})]})]});return oa.createPortal(p,document.body)}function wt({node:s,depth:t=0,collapsible:a=!1,isLast:i=!0,open:n,onToggle:c}){var p;const[o,l]=r.useState(a),u=n!==void 0,x=u?n:o,h=g=>{u||l(g),c==null||c(g)},d=(((p=s.children)==null?void 0:p.length)??0)>0,m=e.jsxs(e.Fragment,{children:[a&&e.jsx("span",{className:`agent-node-chevron ${x?"open":""}`,"aria-hidden":!0,children:"›"}),e.jsx("span",{className:`agent-node-dot status-${s.status}`,"aria-hidden":!0}),e.jsx("span",{className:"agent-node-name",children:s.name}),s.role&&e.jsx("span",{className:"agent-node-role chat-mono",children:s.role}),e.jsx("span",{className:`agent-node-pill status-${s.status}`,children:s.status})]});return e.jsxs("div",{className:["agent-node",`depth-${t}`,`status-${s.status}`,x?"open":"closed",i?"last":""].filter(Boolean).join(" "),children:[a?e.jsx("button",{type:"button",className:`agent-node-head status-${s.status} collapsible`,onClick:g=>{g.stopPropagation(),h(!x)},"aria-expanded":x,children:m}):e.jsx("div",{className:`agent-node-head status-${s.status}`,children:m}),x&&e.jsxs(e.Fragment,{children:[s.summary&&e.jsx("div",{className:"agent-node-summary",children:s.summary}),d&&e.jsx("div",{className:"agent-node-children",children:s.children.map((g,N)=>e.jsx(wt,{node:g,depth:t+1,collapsible:!1,isLast:N===s.children.length-1},g.id))})]})]})}function Zi(s){return s.tree!==void 0}function er(s){const t=s.open??!0;if(Zi(s))return e.jsx("div",{className:`agent-tree variant-${s.variant??"full"}`,children:e.jsx(wt,{node:s.tree.root,depth:0,open:t})});const a=s.children??[];return e.jsx("div",{className:`agent-tree variant-${s.variant} agent-tree-children-only`,children:e.jsx("div",{className:"agent-tree-children-body",children:a.map((i,n)=>e.jsx(r.Fragment,{children:e.jsx(wt,{node:i,depth:0,collapsible:!1,open:t,isLast:n===a.length-1})},i.id))})})}function sr({children:s,variant:t="rail",open:a=!0}){return a?e.jsx(er,{variant:t,open:a,children:s}):null}const tr=["Today","Yesterday","This week","Earlier"];function Gt(s,t){return s.getFullYear()===t.getFullYear()&&s.getMonth()===t.getMonth()&&s.getDate()===t.getDate()}function ar(s,t){const a=s.getTime()-t.getTime();return Math.floor(a/(1e3*60*60*24))}function nr(s){const t=new Date,a=new Date(t);a.setDate(a.getDate()-1);const i=new Date(t);i.setDate(i.getDate()-7);const n={Today:[],Yesterday:[],"This week":[],Earlier:[]};for(const c of s){const o=new Date(Number(c.mtime)||Date.now());Gt(o,t)?n.Today.push(c):Gt(o,a)?n.Yesterday.push(c):ar(t,o)<7?n["This week"].push(c):n.Earlier.push(c)}return n}function ir(s){return new Date(Number(s)||Date.now()).toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit",hour12:!1})}function rr({state:s,agent:t}){return s==="streaming"?e.jsx("span",{className:"session-state session-state-streaming",title:`${t||"Odin"} is typing…`}):s==="awaiting"?e.jsx("span",{className:"session-state session-state-awaiting",title:"Awaiting your reply","aria-hidden":!0}):s==="idle"?e.jsx("span",{className:"session-state session-state-idle","aria-hidden":!0}):null}function lr({sessions:s,clineSessions:t=[],activeSessionId:a,activeClineSessionId:i,activeProject:n,creating:c,onCreateSession:o,onSelectSession:l,onSelectClineSession:u,onRenameSession:x,onDeleteSession:h,groupBy:d}){var O;const m=r.useMemo(()=>[...s,...t],[s,t]),p=r.useMemo(()=>[...m].sort((Q,U)=>Number(U.mtime??0)-Number(Q.mtime??0)),[m]),g=r.useMemo(()=>d?d(p):nr(p),[d,p]),[N,z]=r.useState({}),S=Q=>N[Q]===!0,[y,w]=r.useState(null),[R,j]=r.useState("main"),[k,f]=r.useState(""),[v,L]=r.useState(null),$=r.useRef({}),b=(Q,U="main")=>{const W=$.current[Q];if(!W)return;const F=U==="main"?W:W.querySelector(".chat-rail-item-menu-trigger")??W;if(L({id:Q,rect:F.getBoundingClientRect()}),w(Q),j(U),U==="rename"){const V=[...s,...t].find(Y=>Y.id===Q);f((V==null?void 0:V.title)??(V==null?void 0:V.id)??"")}},M=()=>{w(null),j("main"),f(""),L(null)},P=Q=>{if(Q.source==="cline"){u(Q);return}l(Q.id)},C=()=>{if(!v)return;const Q=v.id,U=k.trim();if(!U){M();return}x==null||x(Q,U),M()},D=()=>{v&&(h==null||h(v.id),M())},X=d?Object.entries(g):tr.filter(Q=>{var U;return(U=g[Q])==null?void 0:U.length}).map(Q=>[Q,g[Q]]);return e.jsxs("aside",{className:"chat-rail",children:[e.jsx("div",{className:"chat-rail-head",children:e.jsxs("button",{type:"button",className:"chat-new-btn",onClick:o,disabled:c||!n,title:n?"Create new session":"Pick a project first","aria-label":"Create new session",children:[e.jsx(Ne,{size:14,"aria-hidden":!0}),e.jsx("span",{children:c?"Creating…":"New session"})]})}),p.length===0?e.jsx("div",{className:"chat-sessions-empty",children:e.jsx(Qi,{icon:e.jsx(Ne,{size:20,"aria-hidden":!0}),title:n?"No sessions yet":"No project",message:n?"Create your first session to start chatting.":"Pick a project in Overview to scope chat sessions."})}):e.jsx("div",{className:"chat-rail-list",children:X.map(([Q,U])=>e.jsxs("div",{className:"chat-rail-group",children:[e.jsx("div",{className:"chat-rail-group-label",children:Q}),U.map(W=>{var xe,Te;const F=W.source==="cline",V=F?i===W.id:a===W.id,Y=W.tree,B=!!((xe=Y==null?void 0:Y.root)!=null&&xe.children&&Y.root.children.length>0),Z=S(W.id);return e.jsxs(r.Fragment,{children:[e.jsxs("div",{ref:q=>{$.current[W.id]=q},role:"button",tabIndex:0,className:`chat-rail-item state-${W.state??"idle"}${V?" active":""}`,onClick:()=>P(W),onKeyDown:q=>{(q.key==="Enter"||q.key===" ")&&(q.preventDefault(),P(W))},"aria-current":V?"true":void 0,children:[e.jsx(rr,{state:W.state??"idle",agent:W.agent}),e.jsxs("div",{className:"chat-rail-item-title",children:[W.pinned&&e.jsx("span",{className:"chat-rail-pin","aria-hidden":!0,children:"★"}),F&&e.jsx(Ns,{size:11,style:{color:"var(--text-muted)",flexShrink:0},"aria-hidden":!0}),e.jsx("span",{className:"chat-ellipsis",children:W.title||W.id})]}),e.jsxs("div",{className:"chat-rail-item-meta",children:[e.jsx("span",{className:"chat-rail-item-meta-time",children:W.time??ir(W.mtime)}),(W.unread??0)>0&&e.jsx("span",{className:"chat-rail-badge",children:W.unread})]}),e.jsx("button",{type:"button",className:`chat-rail-item-menu-trigger${y===W.id?" open":""}`,"aria-label":`Session options for ${W.title||W.id}`,"aria-haspopup":"menu","aria-expanded":y===W.id,onClick:q=>{q.stopPropagation(),y===W.id?M():b(W.id,"main")},children:e.jsxs("svg",{viewBox:"0 0 14 14","aria-hidden":!0,children:[e.jsx("circle",{cx:"3",cy:"7",r:"1.2",fill:"currentColor"}),e.jsx("circle",{cx:"7",cy:"7",r:"1.2",fill:"currentColor"}),e.jsx("circle",{cx:"11",cy:"7",r:"1.2",fill:"currentColor"})]})}),V&&B&&e.jsx("button",{type:"button",className:`chat-rail-tree-chevron${Z?" open":""}`,"aria-label":Z?"Collapse sub-agents":"Expand sub-agents","aria-expanded":Z,onClick:q=>{q.stopPropagation(),z(se=>({...se,[W.id]:!se[W.id]}))},children:e.jsx("svg",{viewBox:"0 0 10 10","aria-hidden":!0,children:e.jsx("polyline",{points:"3,1.5 7,5 3,8.5"})})})]}),V&&B&&Z&&((Te=Y==null?void 0:Y.root)==null?void 0:Te.children)&&e.jsx(sr,{children:Y.root.children,variant:"rail",open:!0})]},F?`oc-${W.id}`:W.id)})]},Q))}),y&&v&&e.jsx(Ji,{session:{id:v.id,title:((O=[...s,...t].find(Q=>Q.id===v.id))==null?void 0:O.title)??v.id},mode:R,anchor:v,renameDraft:k,setRenameDraft:f,onEdit:()=>b(y,"rename"),onDeleteRequest:()=>b(y,"confirm-delete"),onConfirmDelete:D,onConfirmRename:C,onClose:M})]})}function or(s){const{text:t,sending:a,onSend:i,activeSource:n}=s,[c,o]=r.useState(!1),l=()=>{!t.trim()||a||(o(!0),i(),window.setTimeout(()=>o(!1),320))};return e.jsxs("div",{className:`chat-composer-wrap chat-composer-source-${n??"none"}`,children:[e.jsx("div",{className:`chat-composer-pill${c?" takeoff":""}`,children:e.jsx(ni,{...s,onSend:l})}),e.jsxs("div",{className:"chat-composer-hint chat-muted",children:[e.jsxs("span",{children:[e.jsx("kbd",{children:"⏎"})," send"]}),e.jsxs("span",{children:[e.jsx("kbd",{children:"⇧⏎"})," newline"]}),e.jsxs("span",{children:[e.jsx("kbd",{children:"/"})," commands"]}),n==="cline"&&e.jsx("span",{className:"chat-composer-source-hint",children:"→ cline"}),n==="bizar"&&e.jsx("span",{className:"chat-composer-source-hint",children:"→ bizar chat"}),a&&e.jsx("span",{className:"chat-composer-source-hint",children:"sending…"})]})]})}function ct(s){return s.toLocaleString()}function cr(s){return!s||!s.includes("/")?"":s.split("/")[0]}function dr(s){if(!s)return 0;const t=s.toLowerCase();return t.includes("opus")?15:t.includes("sonnet")?3:t.includes("haiku")?.8:t.includes("gpt-4o")?5:t.includes("gpt-4")?10:t.includes("deepseek")?.27:t.includes("minimax")?.3:t.includes("llama-3.3-70b")?.59:1}function mr({sessionId:s,messages:t,pinned:a,agent:i,model:n,agents:c,mcps:o,allCommands:l,activeSource:u="bizar",onRename:x,onDelete:h,onExport:d,busy:m,error:p,onRetry:g}){const[N,z]=r.useState(null);r.useEffect(()=>{let b=!1;return(async()=>{try{const M=await fetch("/api/usage?range=24h",{headers:{Accept:"application/json"}});if(!M.ok)return;const P=await M.json();b||z(P)}catch{}})(),()=>{b=!0}},[s]);const S=(t==null?void 0:t.length)??0,y=(a==null?void 0:a.size)??0,w=t.reduce((b,M)=>b+(M.content||M.message||"").length,0),R=Math.round(w/4),j=dr(n),k=R/1e6*j,f=(N==null?void 0:N.totalTokens)??R,v=(N==null?void 0:N.costUsd)??k,L=128e3,$=cr(n);return e.jsxs("aside",{className:"chat-info",children:[p&&e.jsxs("div",{className:"chat-info-section chat-info-error",role:"alert","aria-live":"polite",children:[e.jsxs("h4",{children:[e.jsx(ze,{size:11,style:{marginRight:4,verticalAlign:-1},"aria-hidden":!0})," ","Couldn't load session"]}),e.jsx("p",{className:"chat-info-value chat-ellipsis",title:p.message,children:p.message}),e.jsxs("div",{className:"chat-info-mono",children:["code · ",p.code]}),p.suggestion?e.jsx("p",{className:"chat-info-suggestion",children:p.suggestion}):null,p.canRetry!==!1&&g?e.jsxs("button",{type:"button",className:"btn btn-ghost btn-sm chat-info-retry",onClick:g,title:"Retry loading the session",children:[e.jsx(nt,{size:12,"aria-hidden":!0})," Retry"]}):null]}),e.jsxs("div",{className:"chat-info-section",children:[e.jsxs("div",{className:"chat-info-section-head",children:[e.jsxs("h4",{children:[e.jsx(at,{size:11,style:{marginRight:4,verticalAlign:-1},"aria-hidden":!0})," ","Session"]}),e.jsx("span",{className:`chat-source-badge chat-source-${u??"none"}`,style:{marginLeft:"auto"},children:u==="cline"?"cline":"bizar chat"})]}),e.jsx("div",{className:"chat-info-mono chat-ellipsis",title:s,children:s||"Live"}),e.jsxs("div",{className:"chat-info-mono",children:[ct(S)," message",S===1?"":"s",y>0&&` · ${y} pinned`]})]}),e.jsxs("div",{className:"chat-info-section",children:[e.jsxs("h4",{children:[e.jsx(Xe,{size:11,style:{marginRight:4,verticalAlign:-1},"aria-hidden":!0})," ","Agent"]}),e.jsx("div",{className:"chat-info-value",children:i||"—"})]}),e.jsxs("div",{className:"chat-info-section",children:[e.jsxs("h4",{children:[e.jsx(ys,{size:11,style:{marginRight:4,verticalAlign:-1},"aria-hidden":!0})," ","Model"]}),e.jsx("div",{className:"chat-mono chat-ellipsis",title:n,children:n||"—"}),$&&e.jsxs("div",{className:"chat-info-mono",children:["provider · ",$]})]}),e.jsxs("div",{className:"chat-info-section",children:[e.jsx("h4",{children:"Tokens"}),e.jsxs("div",{className:"chat-mono",children:[ct(f)," / ",ct(L)]}),e.jsx("div",{className:"chat-info-bar","aria-hidden":!0,children:e.jsx("div",{className:"chat-info-bar-fill",style:{width:`${Math.min(100,f/Math.max(1,L)*100)}%`}})})]}),e.jsxs("div",{className:"chat-info-section",children:[e.jsxs("h4",{children:[e.jsx(on,{size:11,style:{marginRight:4,verticalAlign:-1},"aria-hidden":!0})," ","Cost"]}),e.jsxs("div",{className:"chat-mono",children:["$",v.toFixed(4)]}),!N&&e.jsx("div",{className:"chat-info-mono",children:"approx · live from MiniMax"})]}),e.jsxs("div",{className:"chat-info-section",children:[e.jsxs("h4",{children:[e.jsx(Xe,{size:11,style:{marginRight:4,verticalAlign:-1},"aria-hidden":!0})," ","Attached agents"]}),c!=null&&c.length?e.jsx("div",{className:"chat-info-agents",children:c.map(b=>e.jsx("span",{className:"chat-info-agent",children:b.name},b.name))}):e.jsx("div",{className:"chat-info-mono",children:"None attached"})]}),e.jsxs("div",{className:"chat-info-section",children:[e.jsxs("h4",{children:[e.jsx(ys,{size:11,style:{marginRight:4,verticalAlign:-1},"aria-hidden":!0})," ","MCPs"]}),o!=null&&o.length?e.jsx("div",{className:"chat-info-agents",children:o.map(b=>e.jsx("span",{className:"chat-info-agent",children:b.id},b.id))}):e.jsx("div",{className:"chat-info-mono",children:"No MCPs configured"})]}),e.jsxs("div",{className:"chat-info-section",children:[e.jsxs("h4",{children:[e.jsx(js,{size:11,style:{marginRight:4,verticalAlign:-1},"aria-hidden":!0})," ","Slash commands"]}),e.jsxs("div",{className:"chat-info-mono",children:[(l==null?void 0:l.length)??0," available"]})]}),(x||h||d)&&e.jsxs("div",{className:"chat-info-section",children:[e.jsx("h4",{children:"Actions"}),e.jsxs("div",{className:"chat-info-actions",children:[x&&e.jsxs("button",{type:"button",className:"btn btn-ghost btn-sm",onClick:x,disabled:m==null?void 0:m.rename,title:"Rename session",children:[e.jsx(Os,{size:12,"aria-hidden":!0})," Rename"]}),d&&e.jsxs("button",{type:"button",className:"btn btn-ghost btn-sm",onClick:d,title:"Export transcript",children:[e.jsx(rs,{size:12,"aria-hidden":!0})," Export"]}),h&&e.jsxs("button",{type:"button",className:"btn btn-ghost btn-sm btn-danger",onClick:h,disabled:m==null?void 0:m.delete,title:"Delete session",children:[e.jsx(we,{size:12,"aria-hidden":!0})," Delete"]})]})]})]})}function ur({streaming:s,newMessageCount:t,onClick:a,streamingLabel:i="Odin is replying"}){return e.jsx("button",{type:"button",className:`jump-to-latest${s?" is-streaming":""}`,onClick:a,"aria-label":"Jump to latest message",title:"Jump to latest (⌘/Ctrl+End)",children:s?e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"jump-dots","aria-hidden":!0,children:[e.jsx("span",{}),e.jsx("span",{}),e.jsx("span",{})]}),e.jsx("span",{children:i}),t>0&&e.jsx("span",{className:"jump-badge jump-badge-live",children:"live"})]}):e.jsxs(e.Fragment,{children:[e.jsx(xa,{size:14,"aria-hidden":!0}),e.jsx("span",{children:"Jump to latest"}),t>0&&e.jsxs("span",{className:"jump-badge",children:[t," new"]})]})})}function hr({snapshot:s,settings:t,setActiveTab:a,initialTaskId:i,onClearTaskId:n}){const c=le(),o=Ee(),l=ii(s,t,i??"");r.useEffect(()=>{l.setToast({error:O=>c.error(O),success:O=>c.success(O),info:O=>c.info(O),warning:O=>c.warning(O)})},[l,c]);const[u,x]=r.useState(""),[h,d]=r.useState(t.defaultAgent||"odin"),[m,p]=r.useState(t.defaultModel||""),[g,N]=r.useState([]),z=r.useRef(null),{allCommands:S,suggestions:y,setQuery:w}=ri(s);r.useEffect(()=>{w(u)},[u,w]);const R=()=>{var O;return(O=z.current)==null?void 0:O.click()},j=O=>{const Q=O.target.files;if(!Q)return;const U=[];for(let W=0;W<Q.length;W++)U.push(Q[W].name);N(W=>{const F=U.filter(V=>!W.includes(V));return[...W,...F]}),z.current&&(z.current.value="")},k=async()=>{const O=u.trim();if(!O)return;x(""),w(""),(await l.onSend(O,h,m,g)).ok&&l.jumpToLatest()},f=async()=>{l.busy.create||await l.onCreateSession()},v=O=>{o.open({title:"Delete message?",children:e.jsx("p",{style:{margin:0},children:"This action cannot be undone."}),footer:e.jsxs("div",{style:{display:"flex",gap:8,justifyContent:"flex-end"},children:[e.jsx(A,{variant:"secondary",size:"sm",onClick:()=>o.close(),children:"Cancel"}),e.jsx(A,{variant:"danger",size:"sm",onClick:()=>{o.close(),l.deleteMessage(O)},children:"Delete"})]})})},L=(O,Q)=>{let U="";o.open({title:"Rename session",children:e.jsx("input",{id:"rename-session-input",autoFocus:!0,defaultValue:Q,"aria-label":"Session title",onChange:W=>{U=W.target.value},onKeyDown:W=>{W.key==="Enter"&&(W.preventDefault(),o.close(),l.renameSession(O,U).then(F=>{F&&c.success("Renamed.")}))},style:{width:"100%",padding:"8px 10px",background:"var(--bg)",border:"1px solid var(--border)",borderRadius:"var(--radius-sm)",color:"var(--text)",font:"13px/1.4 var(--font-sans)",marginTop:6}}),footer:e.jsxs("div",{style:{display:"flex",gap:8,justifyContent:"flex-end"},children:[e.jsx(A,{variant:"secondary",size:"sm",onClick:()=>o.close(),children:"Cancel"}),e.jsx(A,{variant:"primary",size:"sm",onClick:()=>{o.close(),l.renameSession(O,U)},children:"Save"})]})})},$=(O,Q)=>{o.open({title:"Delete session?",children:e.jsxs("p",{style:{margin:0},children:["Delete ",e.jsx("strong",{children:Q}),"? Messages on the cline serve will be removed. This cannot be undone."]}),footer:e.jsxs("div",{style:{display:"flex",gap:8,justifyContent:"flex-end"},children:[e.jsx(A,{variant:"secondary",size:"sm",onClick:()=>o.close(),children:"Cancel"}),e.jsx(A,{variant:"danger",size:"sm",onClick:async()=>{o.close(),await l.deleteSession(O)},children:"Delete"})]})})},b=()=>{const O=l.activeSource==="cline"?l.activeClineSessionId:l.sessionId;if(!O)return;const U=(l.activeSource==="cline"?l.clineMessages:l.bizarMessages).map(Y=>{const B=Y.ts??"",Z=(Y.role||"unknown").toUpperCase(),xe=Y.content||Y.message||"";return`[${B}] ${Z}: ${xe}`}).join(`
|
|
1
|
+
var Ua=Object.defineProperty;var _a=(s,t,a)=>t in s?Ua(s,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):s[t]=a;var zs=(s,t,a)=>_a(s,typeof t!="symbol"?t+"":t,a);import{a as T,c as _,f as Ce,l as Ye,b as Ve,S as de,t as la,e as Wa,p as Va,d as xs,g as Ms,_ as qa,W as Qs,A as Ha,M as Ga}from"./mobile-layout-CBHjpwsb.js";import{r,j as e,a as oa,R as Ue,b as Ka}from"./react-vendor-Dn4wqh4Z.js";import{X as ke,A as zt,R as oe,F as Ya,H as Xa,a as Qa,C as ca,b as Be,c as Ja,d as qe,e as Qe,L as da,M as at,B as Xe,f as Js,S as Is,g as Me,h as Za,i as Ge,j as We,P as Zs,k as ns,l as Es,m as Rt,n as Ze,o as ma,p as gs,q as Tt,r as be,s as en,t as Ne,u as ua,v as sn,T as js,W as tn,w as ha,x as Gs,U as Ls,G as an,y as nn,z as fs,D as ze,E as Ie,I as $t,J as Ns,K as Re,N as is,O as et,Q as es,V as vs,Y as yt,Z as rn,_ as we,$ as At,a0 as Mt,a1 as ps,a2 as ln,a3 as nt,a4 as ys,a5 as on,a6 as Os,a7 as rs,a8 as xa,a9 as pa,aa as bs,ab as cn,ac as ks,ad as dn,ae as mn,af as un,ag as ws,ah as hn,ai as xn,aj as pn,ak as gn,al as jn,am as fn,an as Vt,ao as ga,ap as vn,aq as It,ar as yn,as as bn,at as Et,au as Nn,av as kn,aw as wn,ax as Sn,ay as Cn,az as zn,aA as Rn,aB as bt,aC as Lt,aD as ls,aE as ja,aF as Ds,aG as Tn,aH as $n,aI as An,aJ as Ps,aK as Mn,aL as In,aM as Dt,aN as Fs,aO as Nt,aP as Pt,aQ as st,aR as he,aS as En,aT as Ln,aU as fa,aV as Dn,aW as Pn,aX as Fn,aY as qt,aZ as On,a_ as va,a$ as rt,b0 as ya,b1 as Ft,b2 as Bn,b3 as Un,b4 as _n,b5 as ba,b6 as Wn,b7 as Vn,b8 as qn,b9 as Hn,ba as Gn,bb as Kn,bc as Na}from"./icons-Do5N2jmX.js";import{B as A,C as K,a as te,b as ne,A as Yn,U as Xn,G as Qn,E as Jn,T as Zn,S as ei,H as si,c as ti}from"./EnvVarsSection-B58aiJiE.js";import{u as le,T as ai}from"./Toast-Cpl6-E63.js";import{V as Ot,C as ni,u as ii,a as ri,b as li,c as oi}from"./useSlashCommands-Bd7_FA6U.js";import{M as ka,r as wa}from"./markdown-tOLaD6nm.js";import"./vendor-C843201K.js";const Sa=r.createContext(null),ci=["button:not([disabled])","[href]","input:not([disabled])","select:not([disabled])","textarea:not([disabled])",'[tabindex]:not([tabindex="-1"])'].join(", ");function Ee(){const s=r.useContext(Sa);return s||{open:()=>"",close:()=>{},isModalOpen:!1}}function di({children:s}){const[t,a]=r.useState([]),i=r.useCallback(c=>{a(o=>{if(!c)return o.slice(0,-1);const l=o.findIndex(u=>u.id===c);return l===-1||l!==o.length-1?o:o.slice(0,-1)})},[]),n=r.useCallback(c=>{const o=`m${Math.random().toString(36).slice(2,9)}`;return a(l=>[...l,{...c,id:o}]),o},[]);return r.useEffect(()=>{if(t.length===0)return;const c=o=>{o.key==="Escape"&&(o.stopPropagation(),i())};return document.addEventListener("keydown",c),()=>document.removeEventListener("keydown",c)},[t.length,i]),e.jsxs(Sa.Provider,{value:{open:n,close:i,isModalOpen:t.length>0},children:[s,typeof document<"u"&&oa.createPortal(e.jsx("div",{className:"modal-stack","aria-hidden":t.length===0,children:t.map((c,o)=>e.jsx(mi,{modal:c,onClose:()=>{var l;(l=c.onClose)==null||l.call(c),i(c.id)},depth:o},c.id))}),document.body)]})}function mi({modal:s,onClose:t,depth:a}){const i=r.useRef(null),n=r.useRef(null),c=r.useId(),o=()=>{const l=i.current;return l?Array.from(l.querySelectorAll(ci)).filter(u=>!u.hasAttribute("disabled")&&u.tabIndex!==-1):[]};return r.useEffect(()=>{var x;n.current=document.activeElement instanceof HTMLElement?document.activeElement:null,(x=o()[0]??i.current)==null||x.focus();const u=h=>{var N,z,S;if(h.key!=="Tab")return;const d=o();if(d.length===0){h.preventDefault(),(N=i.current)==null||N.focus();return}const m=d[0],p=d[d.length-1],g=document.activeElement instanceof HTMLElement?document.activeElement:null;if(h.shiftKey){(!g||g===m||!((z=i.current)!=null&&z.contains(g)))&&(h.preventDefault(),p.focus());return}(!g||g===p||!((S=i.current)!=null&&S.contains(g)))&&(h.preventDefault(),m.focus())};return document.addEventListener("keydown",u),()=>{document.removeEventListener("keydown",u);const h=n.current;h&&h.isConnected&&h.focus()}},[]),e.jsx("div",{className:"modal-backdrop",onClick:l=>{l.stopPropagation(),l.target===l.currentTarget&&t()},style:a>0?{background:"rgba(0,0,0,0.4)"}:void 0,children:e.jsxs("div",{ref:i,className:"modal",role:"dialog","aria-modal":"true","aria-labelledby":s.title?c:void 0,tabIndex:-1,onClick:l=>l.stopPropagation(),style:s.width?{maxWidth:s.width}:void 0,children:[s.title&&e.jsxs("header",{className:"modal-header",children:[e.jsx("h2",{id:c,className:"modal-title",children:s.title}),e.jsx("button",{type:"button",className:"icon-btn","aria-label":"Close",onClick:t,children:e.jsx(ke,{size:16})})]}),e.jsx("div",{className:"modal-body",children:s.children}),s.footer&&e.jsx("footer",{className:"modal-footer",children:s.footer})]})})}const ui=200,hi=5*60*1e3,as=new Map;function xi(s){const t=as.get(s);return t?Date.now()-t.ts>hi?(as.delete(s),null):t.data:null}function lt(s,t){as.size>=ui&&[...as.entries()].sort((i,n)=>i[1].ts-n[1].ts).slice(0,50).map(([i])=>i).forEach(i=>as.delete(i)),as.set(s,{data:t,ts:Date.now()})}function pi(s){if(!s||s==="/")return[{label:"/",path:"/"}];const t=s.split("/").filter(Boolean),a=[];let i="";for(let n=0;n<t.length;n++)i+="/"+t[n],a.push({label:t[n],path:i});return a}function gi(s){return[...s].sort((t,a)=>t.isDir!==a.isDir?t.isDir?-1:1:t.name.localeCompare(a.name,void 0,{sensitivity:"base"}))}function ji(s){const t=s.trim();return t?t!==s?{ok:!1,reason:"Name cannot have leading or trailing whitespace."}:t==="."?{ok:!1,reason:"Name cannot be '.'."}:t===".."?{ok:!1,reason:"Name cannot be '..'."}:t.startsWith("-")?{ok:!1,reason:"Name cannot start with '-'."}:t.length>255?{ok:!1,reason:"Name cannot be longer than 255 characters."}:/[/\0:*?"<>|]/.test(t)?{ok:!1,reason:'Name cannot contain / \\ : * ? " < > |'}:{ok:!0}:{ok:!1,reason:"Name cannot be empty."}}function Ca({value:s,onChange:t,initialPath:a,projectsDirectory:i,rootLabel:n="Home",height:c=360}){const[o,l]=r.useState(a??i??""),[u,x]=r.useState(new Set),[h,d]=r.useState(-1),[m,p]=r.useState(null),[g,N]=r.useState({}),[z,S]=r.useState(!1),[y,w]=r.useState(null),[R,j]=r.useState(!1),[k,f]=r.useState(""),[v,L]=r.useState(null),[$,b]=r.useState(!1),M=r.useRef(null),P=r.useCallback(async E=>{try{const G=xi(E);if(G)return G;const H=await T.get("/fs?path="+encodeURIComponent(E));return lt(E,H),H}catch{return null}},[]),C=r.useCallback(async E=>{var G;S(!0),w(null);try{const H=await T.get("/fs?path="+encodeURIComponent(E));lt(E,H),p(H),d(-1)}catch(H){const ee=((G=H.data)==null?void 0:G.message)??H.message??"Failed to load directory";w(ee)}finally{S(!1)}},[]);r.useEffect(()=>{o?C(o):T.get("/fs").then(E=>{lt("",E),p(E),l(E.path),E.path!==s&&t(E.path)}).catch(()=>{w("Could not determine home directory."),S(!1)})},[o]),r.useEffect(()=>{s&&s!==o&&l(s)},[s]);const D=m?gi(m.entries):[],X=D.filter(E=>E.isDir),O=D,Q=E=>{E.isDir&&(l(E.path),t(E.path))},U=()=>{m!=null&&m.parent&&(l(m.parent),t(m.parent))},W=E=>{E!==o&&(l(E),t(E))},F=async()=>{const E=await P("");E&&(l(E.path),t(E.path))},V=async()=>{if(!i)return;const E=await P(i);E&&(l(E.path),t(E.path))},Y=()=>{j(!0),f(""),L(null),setTimeout(()=>{var E;return(E=M.current)==null?void 0:E.focus()},0)},B=()=>{j(!1),f(""),L(null)},Z=async()=>{var G;const E=ji(k);if(!E.ok){L(E.reason);return}b(!0),L(null);try{const H=await T.post("/fs/mkdir",{parent:o,name:k.trim()});as.delete(o),await C(o),t(H.path),j(!1),f("")}catch(H){const ee=H;ee.status===409?L(`A folder named "${k.trim()}" already exists.`):L(((G=ee.data)==null?void 0:G.message)??H.message??"Failed to create folder.")}finally{b(!1)}},xe=E=>{E.key==="Enter"?(E.preventDefault(),Z()):E.key==="Escape"&&(E.preventDefault(),B())},Te=E=>{x(G=>{const H=new Set(G);return H.has(E)?H.delete(E):H.add(E),H}),g[E]||P(E).then(G=>{G&&N(H=>({...H,[E]:G.entries.filter(ee=>ee.isDir)}))})},q=E=>{if(!m)return;const G=O.filter(ie=>ie.isDir),H=O.filter(ie=>!ie.isDir),ee=[...G,...H];if(E.key==="ArrowDown")E.preventDefault(),d(ie=>Math.min(ie+1,ee.length-1));else if(E.key==="ArrowUp")E.preventDefault(),d(ie=>Math.max(ie-1,0));else if(E.key==="Enter"||E.key===" "){E.preventDefault();const ie=ee[h];ie&&(E.key==="Enter"&&ie.isDir?Q(ie):ie.isDir&&t(ie.path))}else E.key==="Backspace"&&(E.preventDefault(),U())},se=pi((m==null?void 0:m.path)??o??"/"),re=m==null?void 0:m.parent,me=re!=null,pe=o.split("/").filter(Boolean).at(-1)??"/";return e.jsxs("div",{className:"file-browser",onKeyDown:q,tabIndex:-1,children:[e.jsx("div",{className:"file-browser-breadcrumb",role:"navigation","aria-label":"Path breadcrumb",children:se.map((E,G)=>e.jsxs("span",{className:"file-browser-breadcrumb-item",children:[G>0&&e.jsx("span",{className:"file-browser-breadcrumb-sep","aria-hidden":!0,children:"/"}),e.jsx("button",{type:"button",className:"file-browser-breadcrumb-btn",onClick:()=>W(E.path),title:E.path,children:G===0?E.path==="/"?"/":n:E.label})]},E.path))}),e.jsxs("div",{className:"file-browser-toolbar",children:[e.jsxs("div",{className:"file-browser-toolbar-left",children:[e.jsx("button",{type:"button",className:"file-browser-tool-btn",onClick:U,disabled:!me,title:"Go up (Backspace)","aria-label":"Go up one level",children:e.jsx(zt,{size:13})}),e.jsx("button",{type:"button",className:"file-browser-tool-btn",onClick:()=>C(o),disabled:z,title:"Refresh","aria-label":"Refresh",children:e.jsx(oe,{size:13,className:z?"spin":""})}),e.jsx("button",{type:"button",className:"file-browser-tool-btn",onClick:Y,title:"New folder","aria-label":"Create new folder",children:e.jsx(Ya,{size:13})}),e.jsxs("div",{className:"file-browser-chips",children:[e.jsxs("button",{type:"button",className:"file-browser-chip",onClick:F,children:[e.jsx(Xa,{size:11})," ",n]}),i&&e.jsxs("button",{type:"button",className:"file-browser-chip",onClick:V,title:i,children:[e.jsx(Qa,{size:11})," ",i.split("/").filter(Boolean).at(-1)??"Projects"]})]})]}),R?e.jsxs("div",{className:"file-browser-mkdir",children:[e.jsx("input",{ref:M,type:"text",className:"file-browser-mkdir-input",placeholder:"Folder name",value:k,onChange:E=>{f(E.target.value),L(null)},onKeyDown:xe,"aria-label":"New folder name","aria-invalid":v?"true":void 0,"aria-describedby":v?"mkdir-error":void 0,disabled:$,maxLength:255}),v?e.jsx("span",{id:"mkdir-error",className:"file-browser-mkdir-error",role:"alert",children:v}):e.jsx("span",{className:"file-browser-mkdir-hint",children:"Enter to create, Esc to cancel"})]}):e.jsx("span",{className:"file-browser-count-hint",children:z?"…":`${D.length} in ${pe}`})]}),y&&e.jsxs("div",{className:"file-browser-error",children:[e.jsx(ca,{size:13}),e.jsx("span",{children:y}),e.jsx("button",{type:"button",className:"file-browser-retry",onClick:()=>C(o),children:"Retry"})]}),e.jsxs("div",{className:"file-browser-body",style:{height:c},children:[e.jsx("div",{className:"file-browser-pane file-browser-tree","aria-label":"Folder tree",children:z&&!m?e.jsx(fi,{}):e.jsx(za,{path:o,entries:X,expanded:u,childrenMap:g,onToggle:Te,onNavigate:Q,level:0})}),e.jsxs("div",{className:"file-browser-pane file-browser-flat","aria-label":"Directory contents",children:[e.jsxs("div",{className:"file-browser-flat-header",children:[e.jsx("span",{children:"Name"}),e.jsx("span",{children:"Type"})]}),z&&!m?e.jsx(vi,{}):e.jsxs(e.Fragment,{children:[(m==null?void 0:m.truncated)&&e.jsxs("div",{className:"file-browser-truncated-banner",role:"status",children:["Showing first 500 of ",m.totalEntries," entries. Navigate into a subfolder to see more."]}),O.length===0?e.jsx("div",{className:"file-browser-empty",children:"This folder is empty"}):e.jsx("div",{className:"file-browser-flat-list",children:O.map((E,G)=>{const H=E.isDir,ee=G===h,ie=E.path===s;return e.jsxs("div",{role:"option","aria-selected":ie,className:["file-browser-row",H?"file-browser-row--dir":"file-browser-row--file",ee&&"file-browser-row--selected",ie&&H&&"file-browser-row--active",!H&&"file-browser-row--disabled"].filter(Boolean).join(" "),onClick:()=>{H&&(d(G),t(E.path))},onDoubleClick:()=>{H&&Q(E)},title:E.path,children:[e.jsx("span",{className:"file-browser-row-icon",children:H?e.jsx(Be,{size:13}):e.jsx(Ja,{size:13})}),e.jsx("span",{className:"file-browser-row-name",children:E.name}),e.jsx("span",{className:"file-browser-row-type",children:H?"Folder":""})]},E.path)})})]})]})]}),e.jsxs("div",{className:"file-browser-footer-hint",children:["Select a folder, then click Add. Use ",e.jsx("kbd",{children:"↑"})," ",e.jsx("kbd",{children:"↓"})," to navigate, ",e.jsx("kbd",{children:"Enter"})," to confirm."]})]})}function za({path:s,entries:t,expanded:a,childrenMap:i,onToggle:n,onNavigate:c,level:o}){return e.jsx("ul",{className:"file-browser-tree-list",role:"group",children:t.map(l=>{const u=a.has(l.path),x=i[l.path]??[];return e.jsxs("li",{className:"file-browser-tree-node",children:[e.jsxs("div",{className:["file-browser-tree-row",u&&"file-browser-tree-row--expanded"].filter(Boolean).join(" "),style:{paddingLeft:`${o*16+8}px`},children:[e.jsx("button",{type:"button",className:"file-browser-tree-toggle",onClick:h=>{h.stopPropagation(),n(l.path)},"aria-label":u?"Collapse":"Expand",children:(x.length>0,u?e.jsx(qe,{size:11}):e.jsx(Qe,{size:11}))}),e.jsxs("button",{type:"button",className:"file-browser-tree-name",onClick:()=>c(l),title:l.path,children:[e.jsx(Be,{size:12}),e.jsx("span",{children:l.name})]})]}),u&&x.length>0&&e.jsx(za,{path:l.path,entries:x,expanded:a,childrenMap:i,onToggle:n,onNavigate:c,level:o+1})]},l.path)})})}function fi(){return e.jsx("div",{className:"file-browser-skeleton-wrap",children:[80,60,90,55,70].map((s,t)=>e.jsx("div",{className:"file-browser-skeleton-row",style:{width:s}},t))})}function vi(){return e.jsx("div",{className:"file-browser-skeleton-wrap",children:[60,90,70,50,80,65].map((s,t)=>e.jsx("div",{className:"file-browser-skeleton-row",style:{width:s}},t))})}const kt=[{id:"overview",label:"Overview",icon:da},{id:"chat",label:"Chat",icon:at},{id:"agents",label:"Agents",icon:Xe},{id:"artifacts",label:"Glyphs",icon:Js},{id:"tasks",label:"Tasks",icon:Is},{id:"activity",label:"Activity",icon:Me},{id:"background",label:"Active",icon:Za},{id:"skills",label:"Skills",icon:Ge},{id:"memory",label:"Memory",icon:We},{id:"mods",label:"Mods",icon:Zs},{id:"schedules",label:"Schedules",icon:ns},{id:"history",label:"History",icon:Es},{id:"minimax",label:"Usage",icon:Rt},{id:"eval",label:"Eval",icon:Ze},{id:"doctor",label:"Doctor",icon:ma},{id:"harness",label:"Harness",icon:gs},{id:"settings",label:"Settings",icon:Tt}];function yi({activeTab:s,onTabChange:t,wsStatus:a,version:i,activeProject:n,projects:c,onProjectChange:o,onProjectsRefresh:l,onOpenSearch:u,settings:x,rightSlot:h,notificationsSlot:d,showTabs:m=!0,extraTabs:p,clineStatus:g=null}){return e.jsxs("header",{className:"topbar",children:[e.jsxs("div",{className:"topbar-row",children:[e.jsxs("div",{className:"brand",children:[e.jsx("span",{className:"brand-logo","aria-hidden":"true",children:"ᛒ"}),e.jsx("span",{className:"brand-title",children:"Bizar"}),e.jsx("span",{className:"brand-version",children:i})]}),e.jsx(bi,{activeProject:n,projects:c,onChange:o,onRefresh:l,settings:x??null}),e.jsxs("button",{type:"button",className:"topbar-search",onClick:u,title:"Search (Ctrl/Cmd+K)","aria-label":"Open search",children:[e.jsx(be,{size:14}),e.jsx("span",{className:"muted",children:"Search…"}),e.jsx("kbd",{children:"⌘K"})]}),e.jsx("div",{className:"topbar-spacer"}),e.jsxs("div",{className:"topbar-right",children:[d,h,g&&e.jsxs("div",{className:_("cline-status",`cline-${g.state}`),title:g.detail||`Cline ${g.label}`,"aria-label":`Cline runtime: ${g.label}`,children:[e.jsx("span",{className:"cline-dot"}),e.jsxs("span",{className:"cline-label",children:["Cline · ",g.label]})]}),e.jsxs("div",{className:_("ws-status",`ws-${a}`),title:`WebSocket: ${a}`,children:[e.jsx("span",{className:"ws-dot"}),e.jsx("span",{className:"ws-label",children:a})]})]})]}),m&&e.jsxs("nav",{className:"tabs-row",role:"tablist","aria-label":"Primary tabs",children:[kt.map(N=>{const z=N.icon,S=N.id===s;return e.jsxs("button",{type:"button",role:"tab","aria-selected":S,className:_("tab",S&&"tab-active"),onClick:()=>t(N.id),title:N.label,children:[e.jsx(z,{size:14,className:"tab-icon"}),e.jsx("span",{className:"tab-label",children:N.label}),N.id==="settings"&&S&&e.jsx("span",{className:"settings-mode-indicator",title:"Settings mode active",children:e.jsx(en,{size:12})})]},N.id)}),p&&p.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"tab-separator","aria-hidden":"true"}),p.map(N=>{const z=N.icon,S=N.id===s;return e.jsxs("button",{type:"button",role:"tab","aria-selected":S,className:_("tab","tab-mod",S&&"tab-active"),onClick:()=>t(N.id),title:`${N.label} (mod)`,children:[e.jsx(z,{size:14,className:"tab-icon"}),e.jsx("span",{className:"tab-label",children:N.label}),e.jsx("span",{className:"tab-badge",children:"mod"})]},N.id)})]})]})]})}function bi({activeProject:s,projects:t,onChange:a,onRefresh:i,settings:n}){const[c,o]=r.useState(!1),l=Ee();r.useEffect(()=>{if(!c)return;const x=()=>o(!1);return document.addEventListener("click",x),()=>document.removeEventListener("click",x)},[c]);const u=()=>{l.open({title:"Add project",children:e.jsx(Ni,{settings:n,onAdd:async(x,h)=>{try{await T.post("/projects",{path:x,name:h}),i(),o(!1),l.close()}catch(d){alert(`Add failed: ${d.message}`)}}}),footer:e.jsx("div",{className:"modal-footer-actions",children:e.jsx(A,{variant:"ghost",onClick:()=>l.close(),children:"Cancel"})})})};return e.jsxs("div",{className:"project-selector",onClick:x=>x.stopPropagation(),children:[e.jsxs("button",{type:"button",className:"project-selector-btn",onClick:()=>o(x=>!x),title:"Switch active project","aria-haspopup":"menu","aria-expanded":c,children:[e.jsx(Be,{size:14}),e.jsx("span",{className:"project-selector-name",children:(s==null?void 0:s.name)||"(no project)"}),e.jsx(qe,{size:12})]}),c&&e.jsxs("div",{className:"project-selector-menu",children:[e.jsxs("div",{className:"project-selector-menu-head",children:[e.jsxs("span",{className:"muted",children:[t.length," project",t.length===1?"":"s"]}),e.jsxs("div",{className:"project-selector-menu-actions",children:[e.jsx("button",{type:"button",className:"icon-btn",onClick:i,title:"Refresh","aria-label":"Refresh projects",children:e.jsx(oe,{size:12})}),e.jsx("button",{type:"button",className:"icon-btn",onClick:u,title:"Add project","aria-label":"Add project",children:e.jsx(Ne,{size:12})})]})]}),e.jsxs("ul",{className:"project-selector-list",children:[t.length===0&&e.jsx("li",{className:"muted project-selector-empty",children:"No projects. Add one to start."}),t.map(x=>e.jsx("li",{children:e.jsxs("button",{type:"button",className:_("project-selector-item",(s==null?void 0:s.id)===x.id&&"active"),onClick:()=>{a(x.id),o(!1)},children:[e.jsx("span",{className:"project-selector-item-name",children:x.name}),e.jsx("span",{className:"project-selector-item-status",children:x.status})]})},x.id))]})]})]})}function Ni({settings:s,onAdd:t}){var d,m;const[a,i]=r.useState(((d=s==null?void 0:s.dashboard)==null?void 0:d.projectsDirectory)??""),[n,c]=r.useState(""),[o,l]=r.useState(!1),[u,x]=r.useState(null),h=async()=>{var p;if(a){l(!0),x(null);try{await T.get("/fs?path="+encodeURIComponent(a)),t(a,n||null)}catch(g){const N=g;N.status===404?x("That folder no longer exists. Pick another."):x(((p=N.data)==null?void 0:p.message)??g.message??"Validation failed.")}finally{l(!1)}}};return e.jsxs("div",{children:[e.jsx("label",{className:"field-label",children:"Folder"}),e.jsx(Ca,{value:a,onChange:p=>{i(p),x(null)},projectsDirectory:(m=s==null?void 0:s.dashboard)==null?void 0:m.projectsDirectory,height:320}),u&&e.jsx("p",{className:"field-help",style:{color:"var(--error)",marginTop:4},children:u}),e.jsxs("div",{style:{marginTop:"var(--space-3)"},children:[e.jsx("label",{className:"field-label",htmlFor:"topbar-add-project-name",children:"Name (optional)"}),e.jsx("input",{id:"topbar-add-project-name",className:"input",type:"text",placeholder:"My App",value:n,onChange:p=>c(p.target.value)})]}),e.jsx("div",{style:{marginTop:"var(--space-3)",display:"flex",justifyContent:"flex-end"},children:e.jsxs(A,{variant:"primary",onClick:h,disabled:!a||o,children:[o?e.jsx("span",{className:"btn-spinner"}):null,o?"Checking…":"Add"]})})]})}const ki=[{label:"General",sections:[{id:"theme",label:"Theme",icon:ua},{id:"layout",label:"Layout",icon:sn}]},{label:"Core",sections:[{id:"env-vars",label:"Env Vars",icon:js},{id:"network",label:"Network",icon:tn},{id:"notifications",label:"Notifications",icon:ha},{id:"auth",label:"Auth",icon:gs},{id:"system-llm",label:"System LLM",icon:Gs}]},{label:"Agents",sections:[{id:"agents",label:"Agents",icon:Ls}]},{label:"Experience",sections:[{id:"updates",label:"Updates",icon:oe},{id:"headroom",label:"Headroom",icon:an}]},{label:"Data",sections:[{id:"activity-log",label:"Activity",icon:Me},{id:"workspaces",label:"Workspaces",icon:nn}]}];function wi({activeSection:s,onSectionChange:t,onExitSettings:a}){return e.jsxs("div",{className:"settings-nav-root","aria-label":"Settings sections",children:[e.jsxs("button",{type:"button",className:"sidebar-tab",onClick:a,"aria-label":"Exit settings",children:[e.jsx(zt,{size:14,"aria-hidden":!0}),e.jsx("span",{className:"sidebar-tab-label",children:"Back"})]}),e.jsx("div",{className:"settings-nav-divider","aria-hidden":"true"}),ki.map(i=>e.jsxs("div",{className:"settings-nav-group",children:[e.jsx("div",{className:"settings-nav-group-label",children:i.label}),i.sections.map(n=>{const c=n.icon,o=s===n.id;return e.jsxs("button",{type:"button",className:_("sidebar-tab",o&&"sidebar-tab-active"),onClick:()=>t(o?null:n.id),"aria-current":o?"page":void 0,children:[c&&e.jsx(c,{size:14,"aria-hidden":!0}),e.jsx("span",{className:"sidebar-tab-label",children:n.label}),o&&e.jsx(Qe,{size:12,"aria-hidden":!0})]},n.id)})]},i.label))]})}function Si({tabs:s,activeTab:t,onTabChange:a,settingsMode:i,settingsActiveSection:n,onSettingsSectionChange:c,onExitSettings:o}){if(i)return e.jsx("aside",{className:"sidebar sidebar-settings-mode","aria-label":"Settings navigation",children:e.jsx(wi,{activeSection:n??null,onSectionChange:c??(()=>{}),onExitSettings:o??(()=>{})})});const l=s.filter(x=>!x.isMod),u=s.filter(x=>x.isMod);return e.jsx("aside",{className:"sidebar","aria-label":"Primary navigation",children:e.jsxs("nav",{className:"sidebar-nav",role:"tablist",children:[l.map(x=>{const h=x.icon,d=x.id===t;return e.jsxs("button",{type:"button",role:"tab","aria-selected":d,className:_("sidebar-tab",d&&"sidebar-tab-active"),onClick:()=>a(x.id),title:x.label,children:[e.jsx(h,{size:18,"aria-hidden":!0}),e.jsx("span",{className:"sidebar-tab-label",children:x.label})]},x.id)}),u.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"sidebar-section-divider","aria-hidden":"true"}),e.jsx("div",{className:"sidebar-section-label",children:"Mods"}),u.map(x=>{const h=x.icon,d=x.id===t;return e.jsxs("button",{type:"button",role:"tab","aria-selected":d,className:_("sidebar-tab","sidebar-tab-mod",d&&"sidebar-tab-active"),onClick:()=>a(x.id),title:`${x.label} (mod)`,children:[e.jsx(h,{size:18,"aria-hidden":!0}),e.jsx("span",{className:"sidebar-tab-label",children:x.label})]},x.id)})]})]})})}const ot=[{id:"all",label:"All"},{id:"projects",label:"Projects"},{id:"agents",label:"Agents"},{id:"tasks",label:"Tasks"},{id:"mods",label:"Mods"},{id:"schedules",label:"Schedules"},{id:"commands",label:"Commands"},{id:"settings",label:"Settings"}],Ht={all:null,projects:"project",agents:"agent",tasks:"task",mods:"mod",schedules:"schedule",commands:"command",settings:"setting"};function Ci({open:s,onClose:t,onSelect:a}){const i=le(),[n,c]=r.useState(""),[o,l]=r.useState("all"),[u,x]=r.useState([]),[h,d]=r.useState(!1),[m,p]=r.useState(0),g=r.useRef(null),N=r.useRef(null);if(r.useEffect(()=>{let w;return s&&(N.current=document.activeElement instanceof HTMLElement?document.activeElement:null,c(""),x([]),p(0),w=window.setTimeout(()=>{var R;return(R=g.current)==null?void 0:R.focus()},30)),()=>{if(w&&window.clearTimeout(w),!s)return;const R=N.current;R&&R.isConnected&&R.focus()}},[s]),r.useEffect(()=>{if(!s)return;if(!n.trim()){x([]),p(0);return}let w=!1;d(!0);const R=setTimeout(()=>{T.get(`/search?q=${encodeURIComponent(n)}&scope=${o}`).then(j=>{w||(x(j.results||[]),p(0))}).catch(j=>{w||i.error(`Search failed: ${j.message}`)}).finally(()=>!w&&d(!1))},150);return()=>{w=!0,clearTimeout(R)}},[n,o,s,i]),!s)return null;const z={};for(const w of u){const R=w.type.toLowerCase();z[R]=z[R]||[],z[R].push(w)}const S=[];for(const w of ot.map(R=>R.id)){const R=Ht[w];R&&z[R]&&S.push(...z[R])}const y=w=>{if(w.key==="Escape")t();else if(w.key==="ArrowDown"){if(w.preventDefault(),S.length===0)return;p(R=>Math.min(R+1,S.length-1))}else if(w.key==="ArrowUp"){if(w.preventDefault(),S.length===0)return;p(R=>Math.max(R-1,0))}else w.key==="Enter"&&S[m]&&(w.preventDefault(),a(S[m]),t())};return e.jsx("div",{className:"search-modal-backdrop",onClick:t,children:e.jsxs("div",{className:"search-modal",role:"dialog","aria-modal":"true","aria-labelledby":"search-modal-title",onClick:w=>w.stopPropagation(),children:[e.jsxs("div",{className:"search-modal-head",role:"search",children:[e.jsx(be,{size:14,"aria-hidden":!0}),e.jsx("span",{id:"search-modal-title",className:"sr-only",children:"Search"}),e.jsx("input",{ref:g,className:"search-modal-input",placeholder:"Search tasks, agents, settings, projects…",value:n,onChange:w=>c(w.target.value),onKeyDown:y,"aria-label":"Search"}),e.jsx("button",{type:"button",className:"icon-btn","aria-label":"Close",onClick:t,children:e.jsx(ke,{size:14})})]}),e.jsx("div",{className:"search-modal-scopes",role:"tablist","aria-label":"Search scope",children:ot.map(w=>e.jsx("button",{type:"button",role:"tab","aria-selected":o===w.id,className:_("search-scope",o===w.id&&"search-scope-active"),onClick:()=>l(w.id),children:w.label},w.id))}),e.jsxs("div",{className:"search-modal-body",children:[h&&e.jsx("div",{className:"muted",children:"Searching…"}),!h&&n&&S.length===0&&e.jsx("div",{className:"muted",children:"No results."}),!h&&!n&&e.jsx("div",{className:"muted",children:"Type to search…"}),ot.map(w=>{const R=Ht[w.id];if(!R)return null;const j=z[R];return!j||j.length===0?null:e.jsxs("div",{className:"search-group",children:[e.jsx("div",{className:"search-group-head",children:w.label}),j.map(k=>{const f=S.indexOf(k);return e.jsxs("button",{type:"button",className:_("search-result",f===m&&"search-result-active"),onMouseEnter:()=>p(f),onClick:()=>{a(k),t()},children:[e.jsx("span",{className:"search-result-type",children:k.type}),e.jsx("span",{className:"search-result-label",children:zi(k)})]},`${k.type}-${f}`)})]},w.id)})]}),e.jsx("div",{className:"search-modal-foot",children:e.jsx("span",{className:"muted",children:"↑↓ navigate · ↵ open · esc close"})})]})})}function zi(s){const t=s.item||{};if(s.type==="project")return`${t.name} — ${t.path}`;if(s.type==="agent")return`${t.name} — ${t.description||t.model||""}`;if(s.type==="task")return`${t.title} — ${t.status||""}`;if(s.type==="mod")return`${t.name} v${t.version} — ${t.description||""}`;if(s.type==="schedule")return`${t.name} (${t.type}: ${t.schedule})`;if(s.type==="command")return`${t.name} — ${t.description||""}`;if(s.type==="setting"){const a=t.value===null||t.value===void 0?"":typeof t.value=="string"?` = ${t.value}`:` = ${JSON.stringify(t.value)}`;return`${t.label}${a} — ${t.desc||""}`.trim()}return JSON.stringify(t).slice(0,80)}const Ri={info:$t,success:Ie,warning:ze,error:ca};function Ti({onCountChange:s,wsSubscribe:t}){const a=le(),[i,n]=r.useState(!1),[c,o]=r.useState([]),[l,u]=r.useState(null),[x,h]=r.useState(!1),d=r.useRef(null),m=r.useRef(0),p=async()=>{var y;try{h(!0);const w=await T.get("/notifications?limit=200");o(w.notifications||[]),u(w.stats||null),m.current=((y=w.stats)==null?void 0:y.unread)||0,s==null||s(m.current)}catch(w){Ye.warn("[notifications] reload failed:",w.message)}finally{h(!1)}};r.useEffect(()=>{p()},[]),r.useEffect(()=>t?t(w=>{if(w.type==="notification:new"){const R=w.notification;o(j=>[R,...j.filter(k=>k.id!==R.id)]),R.read||(m.current+=1,u(j=>j?{...j,unread:(j.unread||0)+1}:{total:1,unread:1,lastTs:R.ts,counts:{[R.severity||"info"]:1}}),s==null||s(m.current))}else w.type==="notifications:change"&&p()}):void 0,[t]),r.useEffect(()=>{if(!i)return;const y=R=>{d.current&&(d.current.contains(R.target)||n(!1))},w=R=>{R.key==="Escape"&&n(!1)};return document.addEventListener("mousedown",y),document.addEventListener("keydown",w),()=>{document.removeEventListener("mousedown",y),document.removeEventListener("keydown",w)}},[i]);const g=async()=>{try{await T.post("/notifications/read-all",{}),o(y=>y.map(w=>({...w,read:!0}))),u(y=>y&&{...y,unread:0}),m.current=0,s==null||s(0),a.success("All notifications marked as read.",1500)}catch(y){a.error(`Failed: ${y.message}`)}},N=async y=>{try{await T.post(`/notifications/${encodeURIComponent(y)}/read`,{}),o(w=>w.map(R=>R.id===y?{...R,read:!0}:R)),u(w=>w&&{...w,unread:Math.max(0,(w.unread||1)-1)}),m.current=Math.max(0,m.current-1),s==null||s(m.current)}catch(w){a.error(`Failed: ${w.message}`)}},z=async y=>{try{await T.del(`/notifications/${encodeURIComponent(y)}`),o(w=>{const R=w.find(j=>j.id===y);return R&&!R.read&&(m.current=Math.max(0,m.current-1),u(j=>j&&{...j,unread:Math.max(0,j.unread-1)}),s==null||s(m.current)),w.filter(j=>j.id!==y)})}catch(w){a.error(`Failed: ${w.message}`)}},S=(l==null?void 0:l.unread)||0;return e.jsxs("div",{className:"notifications-root",ref:d,children:[e.jsxs("button",{type:"button",className:_("topbar-icon-btn notifications-bell",i&&"is-open"),onClick:()=>n(y=>!y),title:"Notifications","aria-label":"Notifications","aria-haspopup":"true","aria-expanded":i,children:[e.jsx(ha,{size:16}),S>0&&e.jsx("span",{className:"notifications-badge",children:S>99?"99+":S})]}),i&&e.jsxs("div",{className:"notifications-panel",role:"dialog","aria-label":"Notifications",children:[e.jsxs("header",{className:"notifications-panel-head",children:[e.jsxs("div",{children:[e.jsx("strong",{children:"Notifications"}),S>0&&e.jsxs("span",{className:"muted text-sm",children:[" · ",S," unread"]})]}),e.jsxs("div",{className:"notifications-panel-head-actions",children:[e.jsxs(A,{size:"sm",variant:"ghost",onClick:g,disabled:S===0,children:[e.jsx(fs,{size:12})," Mark all read"]}),e.jsx("button",{type:"button",className:"icon-btn",onClick:()=>n(!1),"aria-label":"Close",title:"Close",children:e.jsx(ke,{size:14})})]})]}),e.jsx("div",{className:"notifications-list",children:x&&c.length===0?e.jsx("div",{className:"notifications-empty muted",children:"Loading…"}):c.length===0?e.jsx("div",{className:"notifications-empty muted",children:"No notifications yet."}):c.map(y=>{const w=Ri[y.severity]||$t;return e.jsxs("div",{className:_("notification-item",!y.read&&"is-unread",`severity-${y.severity}`),children:[e.jsx(w,{size:14,className:`notification-icon severity-${y.severity}`}),e.jsxs("div",{className:"notification-body",children:[y.title&&e.jsx("div",{className:"notification-title",children:y.title}),e.jsx("div",{className:"notification-msg",children:y.message}),e.jsxs("div",{className:"notification-meta muted",children:[e.jsx("span",{className:"mono",children:y.source}),e.jsx("span",{children:"·"}),e.jsx("span",{children:Ce(y.ts)})]})]}),e.jsxs("div",{className:"notification-actions",children:[!y.read&&e.jsx("button",{type:"button",className:"icon-btn",onClick:()=>N(y.id),title:"Mark as read","aria-label":"Mark as read",children:e.jsx(fs,{size:12})}),e.jsx("button",{type:"button",className:"icon-btn icon-btn-danger",onClick:()=>z(y.id),title:"Remove","aria-label":"Remove",children:e.jsx(ke,{size:12})})]})]},y.id)})}),e.jsx("footer",{className:"notifications-panel-foot",children:e.jsx("span",{className:"muted text-sm",children:l?`${l.total} total · last ${Ce(l.lastTs||new Date().toISOString())}`:""})})]})]})}function $i({data:s,onClose:t}){const a=s==null?void 0:s.enabled;s==null||s.previousEnabled;const i=s==null?void 0:s.mode,n=s==null?void 0:s.defaultTemplate,c=s==null?void 0:s.lastUsedSlug,o=i==="toggle";return e.jsxs("div",{children:[o?e.jsxs("p",{style:{marginBottom:16,lineHeight:1.6},children:["Visual plan mode has been ",e.jsx("strong",{children:a?"enabled":"disabled"}),".",a?" The agent will create a plan and wait for your feedback on complex tasks.":" The agent will work without a visual plan canvas."]}):e.jsxs("div",{style:{marginBottom:16},children:[e.jsxs("p",{style:{marginBottom:8,fontWeight:600},children:["Visual Plan: ",e.jsx("span",{style:{color:a?"var(--color-success)":"var(--color-muted)"},children:a?"ON":"OFF"})]}),e.jsx("p",{style:{lineHeight:1.6,color:"var(--color-muted)",fontSize:13},children:"When enabled, the agent creates a visual plan and waits for your feedback before proceeding with complex tasks."}),n&&e.jsxs("p",{style:{marginTop:8,fontSize:13,color:"var(--color-muted)"},children:["Default template: ",e.jsx("code",{children:n})]}),c&&e.jsxs("p",{style:{fontSize:13,color:"var(--color-muted)"},children:["Last used plan: ",e.jsx("code",{children:c})]}),e.jsxs("p",{style:{marginTop:12,fontSize:13,color:"var(--color-muted)"},children:["Use ",e.jsx("code",{children:"/visual-plan on"})," or ",e.jsx("code",{children:"/visual-plan off"})," to toggle."]})]}),e.jsx("div",{style:{display:"flex",gap:8,justifyContent:"flex-end"},children:e.jsx(A,{variant:"ghost",onClick:t,children:"Close"})})]})}const Ai=["blank","feature-design","bug-investigation","decision-record","horizontal","vertical"];function Mi({data:s,onClose:t}){const a=(s==null?void 0:s.templates)??Ai,i=(s==null?void 0:s.defaultTemplate)??"blank",[n,c]=r.useState(""),[o,l]=r.useState(i),[u,x]=r.useState(!1),[h,d]=r.useState(null),m=async()=>{if(!n.trim()){d("Slug is required.");return}if(!/^[a-z0-9][a-z0-9-]{0,63}$/.test(n)){d("Invalid slug. Use lowercase letters, numbers, and hyphens. Must start with an alphanumeric character.");return}x(!0),d(null);try{await T.post("/artifacts",{slug:n,template:o}),t()}catch(p){d(p.message),x(!1)}};return e.jsxs("div",{children:[e.jsxs("p",{style:{marginBottom:16,color:"var(--color-muted)",fontSize:13},children:["Create a new visual plan. Plans are stored in ",e.jsx("code",{children:"artifacts/"})," in your worktree."]}),e.jsxs("div",{style:{marginBottom:12},children:[e.jsx("label",{className:"field-label",htmlFor:"plan-slug",children:"Plan slug"}),e.jsx("input",{id:"plan-slug",className:"input",type:"text",placeholder:"e.g. my-feature",value:n,onChange:p=>{c(p.target.value),d(null)},autoFocus:!0})]}),e.jsxs("div",{style:{marginBottom:16},children:[e.jsx("label",{className:"field-label",htmlFor:"plan-template",children:"Template"}),e.jsx("select",{id:"plan-template",className:"select",value:o,onChange:p=>l(p.target.value),children:a.map(p=>e.jsx("option",{value:p,children:p},p))})]}),h&&e.jsx("p",{style:{marginBottom:12,color:"var(--color-danger)",fontSize:13},children:h}),e.jsxs("div",{style:{display:"flex",gap:8,justifyContent:"flex-end"},children:[e.jsx(A,{variant:"ghost",onClick:t,disabled:u,children:"Cancel"}),e.jsx(A,{variant:"primary",onClick:m,disabled:u||!n.trim(),children:u?"Creating…":"Create"})]})]})}function Ii({data:s,onClose:t}){const a=(s==null?void 0:s.plans)??[],i=(s==null?void 0:s.count)??a.length,n=c=>{window.open(`/artifacts/${c}/`,"_blank")};return e.jsxs("div",{children:[a.length===0?e.jsxs("p",{style:{marginBottom:16,color:"var(--color-muted)"},children:["No plans found in this worktree. Use ",e.jsx("code",{children:"/artifact new <slug>"})," to create one."]}):e.jsxs("div",{style:{marginBottom:16},children:[e.jsxs("p",{style:{marginBottom:12,fontSize:13,color:"var(--color-muted)"},children:[i," plan",i!==1?"s":""," in this worktree:"]}),e.jsx("ul",{style:{listStyle:"none",padding:0,margin:0},children:a.map(c=>e.jsxs("li",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"6px 0",borderBottom:"1px solid var(--color-border)"},children:[e.jsx("code",{style:{fontSize:13},children:c}),e.jsx(A,{variant:"ghost",size:"sm",onClick:()=>n(c),children:"Open"})]},c))})]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(A,{variant:"ghost",onClick:t,children:"Close"})})]})}function Ei({data:s,onClose:t}){const a=(s==null?void 0:s.commands)??[],i=(s==null?void 0:s.templates)??[],n=(s==null?void 0:s.statuses)??[];return e.jsxs("div",{children:[a.length>0?e.jsx("table",{style:{width:"100%",borderCollapse:"collapse",marginBottom:16,fontSize:13},children:e.jsx("tbody",{children:a.map(c=>e.jsxs("tr",{style:{borderBottom:"1px solid var(--color-border)"},children:[e.jsx("td",{style:{padding:"5px 8px 5px 0",whiteSpace:"nowrap"},children:e.jsx("code",{style:{fontSize:12},children:c.cmd})}),e.jsx("td",{style:{padding:"5px 0",color:"var(--color-muted)"},children:c.desc})]},c.cmd))})}):e.jsx("p",{style:{marginBottom:16,color:"var(--color-muted)"},children:"No commands available."}),i.length>0&&e.jsxs("div",{style:{marginBottom:12},children:[e.jsx("p",{style:{fontSize:12,color:"var(--color-muted)",marginBottom:4},children:"Available templates:"}),e.jsx("p",{style:{fontSize:13},children:i.join(", ")})]}),n.length>0&&e.jsxs("div",{style:{marginBottom:12},children:[e.jsx("p",{style:{fontSize:12,color:"var(--color-muted)",marginBottom:4},children:"Available statuses:"}),e.jsx("p",{style:{fontSize:13},children:n.join(", ")})]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(A,{variant:"ghost",onClick:t,children:"Close"})})]})}function Li({data:s,onClose:t}){const[a,i]=r.useState(!1),[n,c]=r.useState(null),o=async()=>{i(!0),c(null);try{const l=await T.post("/chat/audit",{});c(l)}catch(l){c({ok:!1,findings:[],error:l.message})}finally{i(!1)}};return e.jsx("div",{children:n===null?e.jsxs(e.Fragment,{children:[e.jsx("p",{style:{marginBottom:16,lineHeight:1.6},children:"Run a security audit of your Bizar agent configuration. The audit checks for common misconfigurations, exposed secrets, and insecure defaults."}),e.jsxs("div",{style:{display:"flex",gap:8,justifyContent:"flex-end"},children:[e.jsx(A,{variant:"ghost",onClick:t,children:"Cancel"}),e.jsx(A,{variant:"primary",onClick:o,disabled:a,children:a?"Running…":"Run Audit"})]})]}):e.jsxs(e.Fragment,{children:[n.ok?e.jsxs("div",{children:[e.jsx("p",{style:{marginBottom:12,fontWeight:600,color:"var(--color-success)"},children:"Audit passed — no issues found."}),n.findings.length>0&&e.jsx("ul",{style:{marginBottom:16,paddingLeft:20},children:n.findings.map((l,u)=>e.jsx("li",{style:{marginBottom:4,fontSize:13},children:l},u))})]}):e.jsxs("p",{style:{marginBottom:16,color:"var(--color-danger)"},children:["Audit failed: ",n.error??"unknown error"]}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx(A,{variant:"ghost",onClick:t,children:"Close"})})]})})}function Di({dialog:s,onClose:t}){if(!s.data)return e.jsxs("div",{children:[e.jsx("p",{style:{marginBottom:16,lineHeight:1.6},children:`Command: ${s.command}`}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx("button",{type:"button",className:"btn",onClick:t,children:"Close"})})]});const{message:a,detail:i,url:n}=s.data;return e.jsxs("div",{children:[e.jsx("p",{style:{marginBottom:16,lineHeight:1.6},children:a??`Command: ${s.command}`}),i&&e.jsx("p",{style:{marginBottom:16,color:"var(--color-muted)",fontSize:13},children:i}),n&&e.jsx("p",{style:{marginBottom:16},children:e.jsx("a",{href:n,target:"_blank",rel:"noopener noreferrer",children:n})}),e.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:e.jsx("button",{type:"button",className:"btn",onClick:t,children:"Close"})})]})}function Pi({dialog:s,onClose:t}){switch(s.component){case"visual-artifact":return e.jsx($i,{data:s.data,onClose:t});case"artifact-create":return e.jsx(Mi,{data:s.data,onClose:t});case"artifact-list":return e.jsx(Ii,{data:s.data,onClose:t});case"help":return e.jsx(Ei,{data:s.data,onClose:t});case"audit":return e.jsx(Li,{data:s.data,onClose:t});default:return e.jsx(Di,{dialog:s,onClose:t})}}function Fi({setActiveTab:s,refreshKey:t=0}){var x;const[a,i]=r.useState(null),[n,c]=r.useState(!0),o=async()=>{c(!0);try{const[h,d,m]=await Promise.all([T.get("/memory/status").catch(()=>null),T.get("/memory/health").catch(()=>null),T.get("/memory/lightrag/stats").catch(()=>null)]);i({initialized:!!(h!=null&&h.initialized),mode:h==null?void 0:h.mode,projectId:h==null?void 0:h.projectId,vaultRoot:h==null?void 0:h.vaultRoot,branch:h==null?void 0:h.branch,gitClean:h==null?void 0:h.gitClean,noteCount:(h==null?void 0:h.noteCount)||0,healthScore:d==null?void 0:d.score,healthStatus:d==null?void 0:d.status,lightrag:m?{running:m.running,indexedApprox:m.indexedApprox}:void 0})}catch{i({initialized:!1})}finally{c(!1)}};r.useEffect(()=>{o()},[t]);const l=()=>s("memory"),u=(a==null?void 0:a.healthStatus)==="healthy"?"var(--success)":(a==null?void 0:a.healthStatus)==="degraded"?"var(--warning)":(a==null?void 0:a.healthStatus)==="unhealthy"?"var(--error)":"var(--text-dim)";return e.jsxs(K,{className:"memory-overview-card",children:[e.jsxs(te,{children:[e.jsx(We,{size:14})," Memory",e.jsxs(A,{variant:"ghost",size:"sm",style:{marginLeft:"auto"},onClick:l,children:["Open Memory ",e.jsx(Ns,{size:12})]}),e.jsx(A,{variant:"ghost",size:"sm",onClick:o,"aria-label":"Refresh",title:"Refresh",children:e.jsx(oe,{size:12})})]}),e.jsx(ne,{children:"LightRAG + Obsidian vault + git sync — opens the dedicated Memory tab."}),a!=null&&a.initialized?e.jsxs("div",{className:"memory-status-card-grid",children:[e.jsxs("div",{className:"memory-status-card-cell",children:[e.jsxs("div",{className:"memory-status-card-label",children:[e.jsx(Me,{size:11})," Health"]}),e.jsx("div",{className:"memory-status-card-value",style:{color:u},children:a.healthScore!==void 0?`${a.healthScore}/100`:"—"}),e.jsx("div",{className:"memory-status-card-sub muted",children:a.healthStatus||"—"})]}),e.jsxs("div",{className:"memory-status-card-cell",children:[e.jsxs("div",{className:"memory-status-card-label",children:[e.jsx(We,{size:11})," LightRAG"]}),e.jsx("div",{className:"memory-status-card-value",children:(x=a.lightrag)!=null&&x.running?"running":"stopped"}),e.jsx("div",{className:"memory-status-card-sub muted",children:a.lightrag?`${a.lightrag.indexedApprox} chunks`:"—"})]}),e.jsxs("div",{className:"memory-status-card-cell",children:[e.jsxs("div",{className:"memory-status-card-label",children:[e.jsx(Re,{size:11})," Vault"]}),e.jsxs("div",{className:"memory-status-card-value",children:[a.noteCount," notes"]}),e.jsx("div",{className:"memory-status-card-sub muted ellipsis",title:a.vaultRoot||"",children:a.vaultRoot?a.vaultRoot.split("/").slice(-2).join("/"):"—"})]}),e.jsxs("div",{className:"memory-status-card-cell",children:[e.jsxs("div",{className:"memory-status-card-label",children:[e.jsx(is,{size:11})," Git"]}),e.jsx("div",{className:"memory-status-card-value",children:a.gitClean===null?a.mode==="local-only"?"local-only":"—":a.gitClean?"clean":"dirty"}),e.jsx("div",{className:"memory-status-card-sub muted",children:a.branch?`branch ${a.branch}`:Ve(a.branch||"")||"—"})]})]}):e.jsxs("div",{className:"muted",children:["Memory not initialised. Click ",e.jsx("strong",{children:"Open Memory"})," to set it up."]}),n&&!a&&e.jsx("div",{className:"muted text-sm",children:"Loading…"})]})}function ge({icon:s,title:t,message:a,action:i,className:n}){return e.jsxs("div",{className:_("empty-state",n),children:[e.jsx("div",{className:"empty-icon",children:s??e.jsx(et,{size:32})}),e.jsx("div",{className:"empty-title",children:t}),a&&e.jsx("div",{className:"empty-message",children:a}),i&&e.jsx("div",{className:"empty-action",children:i})]})}function Oi({snapshot:s,settings:t,setActiveTab:a,refreshSnapshot:i}){var Q,U,W;const n=le(),c=Ee(),o=r.useRef(null),[l,u]=r.useState(s.overview??null),[x,h]=r.useState(!s.overview),[d,m]=r.useState(s.projects||[]),[p,g]=r.useState(((Q=s.activeProject)==null?void 0:Q.id)||null),[N,z]=r.useState(s.mods||[]),[S,y]=r.useState(!1),[w,R]=r.useState(((U=s.overview)==null?void 0:U.recentActivity)??[]),[j,k]=r.useState(!1),[f,v]=r.useState(new Set);r.useEffect(()=>{let F=!1;return(async()=>{try{const V=await T.get("/activity/hidden");F||v(new Set(V.hidden||[]))}catch{}})(),()=>{F=!0}},[]);const L=(F,V)=>{const Y=`${F.kind||""}|${F.ts||""}|${F.slug||F.title||""}|${V}`;let B=0;for(let Z=0;Z<Y.length;Z++)B=(B<<5)-B+Y.charCodeAt(Z)|0;return Math.abs(B).toString(16).padStart(8,"0").slice(0,16)},$=async F=>{const V=new Set(f);V.add(F),v(V);try{await T.post("/activity/hide",{keys:[F]})}catch(Y){const B=new Set(f);v(B),n.error(`Hide failed: ${Y.message}`)}},b=async()=>{if(!confirm("Hide every recent activity item from the overview? The full log stays in Settings → Activity Log."))return;const F=w.map((Y,B)=>L(Y,B)),V=new Set(f);F.forEach(Y=>V.add(Y)),v(V);try{await T.post("/activity/hide",{keys:F}),n.success(`Hidden ${F.length} item(s). Restore them in Settings → Activity Log.`)}catch(Y){n.error(`Clear failed: ${Y.message}`)}},M=async()=>{v(new Set);try{await T.del("/activity/hide"),n.success("All hidden activity restored to the overview.")}catch(F){n.error(`Restore failed: ${F.message}`)}};r.useEffect(()=>{var F;s.overview&&(u(s.overview),R(s.overview.recentActivity??[]),h(!1)),m(s.projects||[]),g(((F=s.activeProject)==null?void 0:F.id)||null),z(s.mods||[])},[s.overview,s.projects,s.activeProject,s.mods]),r.useEffect(()=>{let F;try{const V=T.getToken(),Y=V?`/api/activity/stream?token=${encodeURIComponent(V)}`:"/api/activity/stream";F=new EventSource(Y),F.addEventListener("snapshot",B=>{try{const Z=JSON.parse(B.data);R(Array.isArray(Z.events)?Z.events.slice(0,50):[])}catch{}}),F.addEventListener("activity",B=>{try{const Z=JSON.parse(B.data);R(xe=>[Z,...xe].slice(0,50))}catch{}})}catch{}return()=>{try{F==null||F.close()}catch{}}},[]);const P=async()=>{n.info("Refreshing…",1500),await i();try{const F=await T.get("/projects");m(F.projects||[]),g(F.active||null)}catch{}},C=()=>{c.open({title:"Add project",children:e.jsx(Bi,{settings:t,onAdd:async(F,V)=>{try{const Y=await T.post("/projects",{path:F,name:V});m(B=>[...B.filter(Z=>Z.id!==Y.id),Y]),n.success("Project added."),c.close()}catch(Y){n.error(`Add failed: ${Y.message}`)}}}),footer:e.jsx("div",{className:"modal-footer-actions",children:e.jsx(A,{variant:"ghost",onClick:()=>c.close(),children:"Cancel"})})})},D=async()=>{var F;try{const V=await T.post("/projects/auto-detect");m(V.projects||[]),g(V.active||null);const Y=(F=V.projects)==null?void 0:F.find(B=>B.id===V.active);n.success(Y?`Active: ${Y.name}`:"Projects refreshed."),await i()}catch(V){n.error(`Auto-detect failed: ${V.message}`)}},X=async F=>{try{await T.post(`/projects/${encodeURIComponent(F)}/activate`),g(F),n.success("Project activated."),await i()}catch(V){n.error(`Activate failed: ${V.message}`)}},O=async F=>{if(confirm(`Remove project "${F}" from the registry?`))try{await T.del(`/projects/${encodeURIComponent(F)}`),m(V=>V.filter(Y=>Y.id!==F)),p===F&&g(null),n.success("Project removed.")}catch(V){n.error(`Remove failed: ${V.message}`)}};return x||!l?e.jsxs("div",{className:"view-loading",children:[e.jsx(de,{size:"lg"}),e.jsx("p",{children:"Loading overview…"})]}):e.jsxs("div",{className:"view view-overview",children:[e.jsxs("div",{className:"overview-hero-noframe",children:[e.jsx("h1",{children:"What do you want to do?"}),e.jsx("p",{className:"overview-hero-subtitle",children:"Describe what you want — Odin will split it into tasks, create a plan, delegate to background agents, and track progress in real time."}),e.jsxs("form",{className:"overview-hero-form-noframe",onSubmit:async F=>{var Y,B;F.preventDefault();const V=(((Y=o.current)==null?void 0:Y.value)||"").trim();if(V){y(!0);try{const Z=await T.post("/tasks/submit",{title:V});n.success(`Odin split it into ${((B=Z.subtasks)==null?void 0:B.length)||1} task(s)`),o.current&&(o.current.value=""),await i()}catch(Z){n.error(`Failed: ${Z.message}`)}finally{y(!1)}}},children:[e.jsx("label",{htmlFor:"overview-hero-input",className:"sr-only",children:"Describe what you want Odin to do"}),e.jsx("textarea",{id:"overview-hero-input",ref:o,className:"overview-input-hero",placeholder:"e.g. Implement user authentication with email + password, including registration, login, password reset, and integration tests. Use Bcrypt, JWT tokens, and the existing API style.",disabled:S,"aria-label":"Describe what you want Odin to do"}),e.jsxs("div",{style:{display:"flex",gap:"var(--space-2)",alignItems:"center",flexWrap:"wrap"},children:[e.jsxs(A,{type:"submit",variant:"primary",size:"lg",disabled:S,children:[S?e.jsx(de,{size:"sm"}):e.jsx(es,{size:16}),"Submit to Odin"]}),e.jsxs("span",{className:"muted",style:{fontSize:12},children:[e.jsx(Ge,{size:12,style:{display:"inline",verticalAlign:-2,color:"var(--accent)"}})," ","Odin + 12 specialist agents available"]})]})]}),e.jsx("div",{className:"overview-quick-actions-row",children:["Implement feature","Fix bug","Refactor","Investigate","Add tests","Document","Optimize","Deploy"].map(F=>e.jsx("button",{type:"button",className:"overview-quick-chip",onClick:()=>{o.current&&(o.current.value=F,o.current.focus())},children:F},F))})]}),e.jsxs("div",{className:"overview-feed",children:[e.jsxs("div",{className:"overview-feed-head",children:[e.jsx("h2",{children:"Recent activity"}),e.jsxs("div",{className:"overview-feed-head-actions",children:[f.size>0&&e.jsxs(A,{variant:"ghost",size:"sm",onClick:M,title:"Restore hidden items to this overview",children:[e.jsx(vs,{size:12})," Show ",f.size," hidden"]}),w.length>8&&e.jsx(A,{variant:"ghost",size:"sm",onClick:()=>k(F=>!F),children:j?"Show less":"Show all"}),w.length>0&&e.jsxs(A,{variant:"ghost",size:"sm",onClick:b,title:"Hide every item from the overview (full log kept)",children:[e.jsx(yt,{size:12})," Hide all"]})]})]}),f.size>0&&e.jsxs("div",{className:"activity-hidden-banner",role:"status",children:[e.jsxs("span",{children:[e.jsx(yt,{size:12,style:{verticalAlign:-2,marginRight:6}}),f.size," item",f.size===1?"":"s"," hidden from the overview."]}),e.jsxs(A,{variant:"ghost",size:"sm",onClick:M,children:[e.jsx(vs,{size:12})," Show them again"]})]}),w.length===0?e.jsx("div",{className:"muted",style:{padding:"24px 0",fontSize:13},children:"No activity yet. Use the chat above or invoke a Bizar command to start a feed."}):e.jsxs("div",{className:_("activity-feed-list-wrap",!j&&"activity-feed-list-wrap-collapsed"),"aria-live":"polite","aria-relevant":"additions",children:[e.jsx(Ot,{items:w.slice(0,30).filter((F,V)=>!f.has(L(F,V))),itemHeight:60,height:Math.min(w.filter((F,V)=>!f.has(L(F,V))).length*60,480),className:"activity-feed-list",renderItem:(F,V)=>{const Y=w.slice(0,30).findIndex(B=>B===F);return e.jsx(Yi,{item:F,activityKey:L(F,Y),onNavigate:a,onHide:$})}}),!j&&w.length>8&&e.jsx("div",{className:"activity-feed-fade","aria-hidden":"true"})]})]}),e.jsxs(K,{className:"project-picker",children:[e.jsxs(te,{children:[e.jsx(Be,{size:14})," Projects",e.jsxs(A,{variant:"ghost",size:"sm",style:{marginLeft:"auto"},onClick:C,children:[e.jsx(Ne,{size:12})," Add"]}),e.jsxs(A,{variant:"ghost",size:"sm",onClick:D,title:"Use the server's working directory",children:[e.jsx(Ne,{size:12})," Auto-detect"]}),((W=t==null?void 0:t.dashboard)==null?void 0:W.projectsDirectory)&&e.jsxs(A,{variant:"ghost",size:"sm",title:`Scan ${t.dashboard.projectsDirectory} for projects`,onClick:async()=>{try{const F=await T.post("/projects/scan");F.error?n.error(F.error):n.success(`Added ${F.added.length}, skipped ${F.skipped}.`),await i();const V=await T.get("/projects");m(V.projects||[]),g(V.active||null)}catch(F){n.error(`Scan failed: ${F.message}`)}},children:[e.jsx(rn,{size:12})," Scan"]}),e.jsx(A,{variant:"ghost",size:"sm",onClick:P,title:"Refresh",children:e.jsx(oe,{size:12})})]}),e.jsxs(ne,{children:[d.length," project",d.length===1?"":"s"," ·"," ",l.counts.agents," agents ·"," ",l.counts.sessions," session",l.counts.sessions===1?"":"s"]}),d.length===0?e.jsx(ge,{icon:e.jsx(Be,{size:32}),title:"No projects yet",message:"Add a project to start tracking its tasks, plans, and schedules.",action:e.jsxs("div",{className:"empty-state-actions",children:[e.jsxs(A,{variant:"primary",onClick:D,children:[e.jsx(Ne,{size:14})," Use current directory"]}),e.jsx(A,{variant:"secondary",onClick:C,children:"Add by path…"})]})}):e.jsx("div",{className:"project-grid",children:d.map(F=>e.jsx(Ui,{project:F,active:p===F.id,onOpen:()=>X(F.id),onRemove:()=>O(F.id)},F.id))})]}),e.jsx(Fi,{setActiveTab:a}),e.jsxs("div",{className:"overview-cols",children:[e.jsxs(K,{children:[e.jsx(te,{children:"Mods"}),e.jsxs(ne,{children:["Extensions installed under ",e.jsx("code",{children:"~/.config/bizar/mods/"})]}),N.length===0?e.jsx("div",{className:"muted",children:"No mods installed."}):e.jsx("ul",{className:"mod-mini-list",children:N.map(F=>e.jsxs("li",{className:"mod-mini",children:[e.jsx("span",{className:"mod-mini-name",children:F.name}),e.jsxs("span",{className:"mod-mini-meta",children:["v",F.version," · ",F.type]}),e.jsx("span",{className:`mod-mini-pill ${F.enabled?"mod-mini-pill-on":"mod-mini-pill-off"}`,children:F.enabled?"on":"off"})]},F.id))})]}),e.jsxs(K,{children:[e.jsx(te,{children:"Environment"}),e.jsx(ne,{children:"Runtime + paths"}),e.jsxs("dl",{className:"env-table",children:[e.jsx("dt",{children:"Node"}),e.jsx("dd",{className:"mono",children:l.versions.node}),e.jsx("dt",{children:"Platform"}),e.jsx("dd",{className:"mono",children:l.versions.platform}),e.jsx("dt",{children:"Project root"}),e.jsx("dd",{className:"mono ellipsis",title:l.versions.projectRoot,children:l.versions.projectRoot}),e.jsx("dt",{children:"Bizar root"}),e.jsx("dd",{className:"mono ellipsis",title:l.versions.bizarRoot,children:l.versions.bizarRoot}),e.jsx("dt",{children:"Generated"}),e.jsx("dd",{className:"mono tabular-nums",children:Ve(l.generatedAt)})]})]})]})]})}function Bi({settings:s,onAdd:t}){var d,m;const[a,i]=r.useState(((d=s==null?void 0:s.dashboard)==null?void 0:d.projectsDirectory)??""),[n,c]=r.useState(""),[o,l]=r.useState(!1),[u,x]=r.useState(null),h=async()=>{var p;if(a){l(!0),x(null);try{await T.get("/fs?path="+encodeURIComponent(a)),t(a,n||null)}catch(g){const N=g;N.status===404?x("That folder no longer exists. Pick another."):x(((p=N.data)==null?void 0:p.message)??g.message??"Validation failed.")}finally{l(!1)}}};return e.jsxs("div",{children:[e.jsx("label",{className:"field-label",children:"Folder"}),e.jsx(Ca,{value:a,onChange:p=>{i(p),x(null)},projectsDirectory:(m=s==null?void 0:s.dashboard)==null?void 0:m.projectsDirectory,height:320}),u&&e.jsx("p",{className:"field-help",style:{color:"var(--error)",marginTop:4},children:u}),e.jsxs("div",{style:{marginTop:"var(--space-3)"},children:[e.jsx("label",{className:"field-label",htmlFor:"add-project-name",children:"Name (optional)"}),e.jsx("input",{id:"add-project-name",className:"input",type:"text",placeholder:"My App",value:n,onChange:p=>c(p.target.value)}),e.jsx("p",{className:"field-help",style:{marginTop:4},children:"Display name for this project. Defaults to the folder name."})]}),e.jsx("div",{style:{marginTop:"var(--space-3)",display:"flex",justifyContent:"flex-end"},children:e.jsxs(A,{variant:"primary",onClick:h,disabled:!a||o,children:[o?e.jsx("span",{className:"btn-spinner"}):null,o?"Checking…":"Add"]})})]})}function Ui({project:s,active:t,onOpen:a,onRemove:i}){const n={active:"status-on",inactive:"status-neutral",error:"status-error"}[s.status]||"status-neutral";return e.jsxs("div",{className:`project-card ${t?"project-card-active":""}`,children:[e.jsxs("div",{className:"project-card-head",children:[e.jsx("span",{className:`project-card-status ${n}`,children:s.status}),e.jsx("div",{className:"project-card-name",children:s.name}),e.jsx("button",{type:"button",className:"icon-btn","aria-label":"Remove project",title:"Remove",onClick:c=>{c.stopPropagation(),i()},children:e.jsx(we,{size:12})})]}),e.jsx("div",{className:"project-card-path mono ellipsis",title:s.path,children:s.path}),e.jsx("div",{className:"project-card-meta",children:s.lastAccessed&&e.jsxs("span",{className:"muted",children:["Last opened ",Ce(s.lastAccessed)]})}),e.jsx("div",{className:"project-card-actions",children:e.jsx(A,{variant:t?"ghost":"primary",size:"sm",onClick:a,children:t?e.jsxs(e.Fragment,{children:[e.jsx(At,{size:12})," Active"]}):e.jsx(e.Fragment,{children:"Open"})})})]})}function _i(s){return s&&s.charAt(0).toUpperCase()+s.slice(1)}function Wi(s){const t=s.trim().toLowerCase().replace(/[:_]/g,"."),[a,i="updated"]=t.split("."),n={settings:"Settings",task:"Task",tasks:"Task",agent:"Agent",agents:"Agent",plan:"Plan",plans:"Plan",bg:"Background job",background:"Background job",session:"Session",mod:"Mod",mods:"Mod",provider:"Provider",providers:"Provider"},c={create:"created",created:"created",add:"added",added:"added",update:"updated",updated:"updated",delegate:"delegated",delegated:"delegated",invoke:"invoked",invoked:"invoked",restart:"restarted",restarted:"restarted",delete:"deleted",deleted:"deleted",remove:"removed",removed:"removed",archive:"archived",archived:"archived",restore:"restored",restored:"restored",complete:"completed",completed:"completed",fail:"failed",failed:"failed",error:"errored",stuck:"marked stuck"},o=n[a]||_i(a.replace(/-/g," ")),l=c[i]||i.replace(/-/g," ");return`${o} ${l}`.trim()}function _s(s,t){for(const a of t){const i=s[a];if(typeof i=="string"&&i.trim())return i.trim()}return""}function Vi(s){const t=_s(s,["message","text","prompt","title","name"]);if(t)return t;const a=[],i=_s(s,["slug"]),n=_s(s,["agent","author"]),c=_s(s,["status"]);return i&&a.push(`Plan ${i}`),n&&a.push(n),c&&a.push(c),a.length?a.join(" · "):"No additional details."}function qi(s){return Ce(s)}function Hi(s){const t=(s.kind||"").toLowerCase(),a=(s.status||"").toLowerCase();return t.includes("error")||a==="error"||a==="failure"?"error":t.includes("warn")||a==="blocked"?"warning":t.includes("done")||t.includes("success")||a==="done"?"success":"info"}function Gi(s){const t=s.toLowerCase();return t==="task"?Is:t==="agent"?Xe:t==="plan"?Js:t.includes("bg")||t.includes("background")||t.includes("job")?Mt:t==="mod"?Zs:t==="skill"?Ge:t.includes("error")||t.includes("failure")?ps:t.includes("warn")?ze:Me}function Ki(s){const t=s.toLowerCase();return t==="task"?"tasks":t==="agent"?"agents":t==="plan"?"artifacts":t.includes("bg")||t.includes("background")?"activity":t==="mod"?"mods":t==="skill"?"skills":null}function Yi({item:s,activityKey:t,onNavigate:a,onHide:i}){const n=Hi(s),c=Gi(s.kind||""),o=Wi(s.kind||"activity"),l=Vi(s),u=Ki(s.kind||""),x=n==="error"?"var(--error)":n==="warning"?"var(--warning)":n==="success"?"var(--success)":"var(--accent)";return e.jsxs("div",{className:_("activity-feed-row",`activity-feed-row-${n}`),children:[e.jsxs("button",{type:"button",className:"activity-feed-row-main",onClick:()=>{u&&a(u)},title:u?`Open ${u}`:o,children:[e.jsx("div",{className:"activity-feed-icon",style:{color:x},children:e.jsx(c,{size:14})}),e.jsxs("div",{className:"activity-feed-body",children:[e.jsxs("div",{className:"activity-feed-title-row",children:[e.jsx("div",{className:"activity-feed-title",children:o}),e.jsx("div",{className:"activity-feed-time text-xs muted tabular-nums",children:qi(s.ts)})]}),e.jsx("div",{className:"activity-feed-summary text-sm",children:l})]})]}),e.jsx("button",{type:"button",className:"activity-feed-hide-btn",onClick:()=>i(t),title:"Hide this from the overview (kept in Settings → Activity Log)","aria-label":"Hide from overview",children:e.jsx(ke,{size:12})})]})}const Xi=Ue.memo(Oi);function Qi({icon:s,title:t,message:a,action:i}){return e.jsxs("div",{className:"chat-empty-state",children:[s&&e.jsx("div",{className:"chat-empty-state-icon",children:s}),e.jsx("h2",{className:"chat-empty-state-title",children:t}),e.jsx("p",{className:"chat-empty-state-message",children:a}),i&&e.jsx("div",{className:"chat-empty-state-action",children:i})]})}function Ji({session:s,mode:t,anchor:a,renameDraft:i,setRenameDraft:n,onEdit:c,onDeleteRequest:o,onConfirmDelete:l,onConfirmRename:u,onClose:x}){const h=r.useRef(null),d=Math.round(a.rect.bottom+2),m=Math.max(8,Math.round(window.innerWidth-a.rect.right));r.useEffect(()=>{const g=S=>{const y=S.target;!h.current||!y||h.current.contains(y)||x()},N=S=>{S.key==="Escape"&&x()},z=window.setTimeout(()=>{document.addEventListener("mousedown",g),document.addEventListener("keydown",N)},0);return()=>{window.clearTimeout(z),document.removeEventListener("mousedown",g),document.removeEventListener("keydown",N)}},[x]),r.useEffect(()=>{if(t!=="rename")return;const g=window.setTimeout(()=>{var z;const N=(z=h.current)==null?void 0:z.querySelector("input.session-row-menu-input");N==null||N.focus(),N==null||N.select()},0);return()=>window.clearTimeout(g)},[t]);const p=e.jsxs("div",{ref:h,className:"session-row-menu",role:"menu","aria-label":`Options for ${s.title}`,style:{position:"fixed",top:d,right:m},onClick:g=>g.stopPropagation(),children:[t==="main"&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{type:"button",className:"session-row-menu-item",role:"menuitem",onClick:g=>{g.stopPropagation(),c()},children:[e.jsx(ln,{size:13,"aria-hidden":!0}),e.jsx("span",{children:"Rename"}),e.jsx("kbd",{children:"R"})]}),e.jsxs("button",{type:"button",className:"session-row-menu-item session-row-menu-item-danger",role:"menuitem",onClick:g=>{g.stopPropagation(),o()},children:[e.jsx(we,{size:13,"aria-hidden":!0}),e.jsx("span",{children:"Delete"}),e.jsx("kbd",{children:"⌫"})]})]}),t==="rename"&&e.jsxs("div",{className:"session-row-menu-inline",children:[e.jsx("div",{className:"session-row-menu-inline-label chat-mono",children:"Rename session"}),e.jsx("input",{type:"text",className:"session-row-menu-input",value:i,onChange:g=>n(g.target.value),onKeyDown:g=>{g.key==="Enter"?(g.preventDefault(),u()):g.key==="Escape"&&(g.preventDefault(),x())},onClick:g=>g.stopPropagation(),"aria-label":"New session name"}),e.jsxs("div",{className:"session-row-menu-inline-actions",children:[e.jsx("button",{type:"button",className:"btn btn-ghost",onClick:g=>{g.stopPropagation(),x()},children:"Cancel"}),e.jsx("button",{type:"button",className:"btn btn-primary",onClick:g=>{g.stopPropagation(),u()},children:"Save"})]})]}),t==="confirm-delete"&&e.jsxs("div",{className:"session-row-menu-inline",children:[e.jsx("div",{className:"session-row-menu-inline-label chat-mono",children:"Delete this session?"}),e.jsxs("div",{className:"session-row-menu-inline-message",children:['"',s.title,'" and its sub-agents will be removed.']}),e.jsxs("div",{className:"session-row-menu-inline-actions",children:[e.jsx("button",{type:"button",className:"btn btn-ghost",onClick:g=>{g.stopPropagation(),x()},children:"Cancel"}),e.jsx("button",{type:"button",className:"btn btn-danger",onClick:g=>{g.stopPropagation(),l()},children:"Delete"})]})]})]});return oa.createPortal(p,document.body)}function wt({node:s,depth:t=0,collapsible:a=!1,isLast:i=!0,open:n,onToggle:c}){var p;const[o,l]=r.useState(a),u=n!==void 0,x=u?n:o,h=g=>{u||l(g),c==null||c(g)},d=(((p=s.children)==null?void 0:p.length)??0)>0,m=e.jsxs(e.Fragment,{children:[a&&e.jsx("span",{className:`agent-node-chevron ${x?"open":""}`,"aria-hidden":!0,children:"›"}),e.jsx("span",{className:`agent-node-dot status-${s.status}`,"aria-hidden":!0}),e.jsx("span",{className:"agent-node-name",children:s.name}),s.role&&e.jsx("span",{className:"agent-node-role chat-mono",children:s.role}),e.jsx("span",{className:`agent-node-pill status-${s.status}`,children:s.status})]});return e.jsxs("div",{className:["agent-node",`depth-${t}`,`status-${s.status}`,x?"open":"closed",i?"last":""].filter(Boolean).join(" "),children:[a?e.jsx("button",{type:"button",className:`agent-node-head status-${s.status} collapsible`,onClick:g=>{g.stopPropagation(),h(!x)},"aria-expanded":x,children:m}):e.jsx("div",{className:`agent-node-head status-${s.status}`,children:m}),x&&e.jsxs(e.Fragment,{children:[s.summary&&e.jsx("div",{className:"agent-node-summary",children:s.summary}),d&&e.jsx("div",{className:"agent-node-children",children:s.children.map((g,N)=>e.jsx(wt,{node:g,depth:t+1,collapsible:!1,isLast:N===s.children.length-1},g.id))})]})]})}function Zi(s){return s.tree!==void 0}function er(s){const t=s.open??!0;if(Zi(s))return e.jsx("div",{className:`agent-tree variant-${s.variant??"full"}`,children:e.jsx(wt,{node:s.tree.root,depth:0,open:t})});const a=s.children??[];return e.jsx("div",{className:`agent-tree variant-${s.variant} agent-tree-children-only`,children:e.jsx("div",{className:"agent-tree-children-body",children:a.map((i,n)=>e.jsx(r.Fragment,{children:e.jsx(wt,{node:i,depth:0,collapsible:!1,open:t,isLast:n===a.length-1})},i.id))})})}function sr({children:s,variant:t="rail",open:a=!0}){return a?e.jsx(er,{variant:t,open:a,children:s}):null}const tr=["Today","Yesterday","This week","Earlier"];function Gt(s,t){return s.getFullYear()===t.getFullYear()&&s.getMonth()===t.getMonth()&&s.getDate()===t.getDate()}function ar(s,t){const a=s.getTime()-t.getTime();return Math.floor(a/(1e3*60*60*24))}function nr(s){const t=new Date,a=new Date(t);a.setDate(a.getDate()-1);const i=new Date(t);i.setDate(i.getDate()-7);const n={Today:[],Yesterday:[],"This week":[],Earlier:[]};for(const c of s){const o=new Date(Number(c.mtime)||Date.now());Gt(o,t)?n.Today.push(c):Gt(o,a)?n.Yesterday.push(c):ar(t,o)<7?n["This week"].push(c):n.Earlier.push(c)}return n}function ir(s){return new Date(Number(s)||Date.now()).toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit",hour12:!1})}function rr({state:s,agent:t}){return s==="streaming"?e.jsx("span",{className:"session-state session-state-streaming",title:`${t||"Odin"} is typing…`}):s==="awaiting"?e.jsx("span",{className:"session-state session-state-awaiting",title:"Awaiting your reply","aria-hidden":!0}):s==="idle"?e.jsx("span",{className:"session-state session-state-idle","aria-hidden":!0}):null}function lr({sessions:s,clineSessions:t=[],activeSessionId:a,activeClineSessionId:i,activeProject:n,creating:c,onCreateSession:o,onSelectSession:l,onSelectClineSession:u,onRenameSession:x,onDeleteSession:h,groupBy:d}){var O;const m=r.useMemo(()=>[...s,...t],[s,t]),p=r.useMemo(()=>[...m].sort((Q,U)=>Number(U.mtime??0)-Number(Q.mtime??0)),[m]),g=r.useMemo(()=>d?d(p):nr(p),[d,p]),[N,z]=r.useState({}),S=Q=>N[Q]===!0,[y,w]=r.useState(null),[R,j]=r.useState("main"),[k,f]=r.useState(""),[v,L]=r.useState(null),$=r.useRef({}),b=(Q,U="main")=>{const W=$.current[Q];if(!W)return;const F=U==="main"?W:W.querySelector(".chat-rail-item-menu-trigger")??W;if(L({id:Q,rect:F.getBoundingClientRect()}),w(Q),j(U),U==="rename"){const V=[...s,...t].find(Y=>Y.id===Q);f((V==null?void 0:V.title)??(V==null?void 0:V.id)??"")}},M=()=>{w(null),j("main"),f(""),L(null)},P=Q=>{if(Q.source==="cline"){u(Q);return}l(Q.id)},C=()=>{if(!v)return;const Q=v.id,U=k.trim();if(!U){M();return}x==null||x(Q,U),M()},D=()=>{v&&(h==null||h(v.id),M())},X=d?Object.entries(g):tr.filter(Q=>{var U;return(U=g[Q])==null?void 0:U.length}).map(Q=>[Q,g[Q]]);return e.jsxs("aside",{className:"chat-rail",children:[e.jsx("div",{className:"chat-rail-head",children:e.jsxs("button",{type:"button",className:"chat-new-btn",onClick:o,disabled:c||!n,title:n?"Create new session":"Pick a project first","aria-label":"Create new session",children:[e.jsx(Ne,{size:14,"aria-hidden":!0}),e.jsx("span",{children:c?"Creating…":"New session"})]})}),p.length===0?e.jsx("div",{className:"chat-sessions-empty",children:e.jsx(Qi,{icon:e.jsx(Ne,{size:20,"aria-hidden":!0}),title:n?"No sessions yet":"No project",message:n?"Create your first session to start chatting.":"Pick a project in Overview to scope chat sessions."})}):e.jsx("div",{className:"chat-rail-list",children:X.map(([Q,U])=>e.jsxs("div",{className:"chat-rail-group",children:[e.jsx("div",{className:"chat-rail-group-label",children:Q}),U.map(W=>{var xe,Te;const F=W.source==="cline",V=F?i===W.id:a===W.id,Y=W.tree,B=!!((xe=Y==null?void 0:Y.root)!=null&&xe.children&&Y.root.children.length>0),Z=S(W.id);return e.jsxs(r.Fragment,{children:[e.jsxs("div",{ref:q=>{$.current[W.id]=q},role:"button",tabIndex:0,className:`chat-rail-item state-${W.state??"idle"}${V?" active":""}`,onClick:()=>P(W),onKeyDown:q=>{(q.key==="Enter"||q.key===" ")&&(q.preventDefault(),P(W))},"aria-current":V?"true":void 0,children:[e.jsx(rr,{state:W.state??"idle",agent:W.agent}),e.jsxs("div",{className:"chat-rail-item-title",children:[W.pinned&&e.jsx("span",{className:"chat-rail-pin","aria-hidden":!0,children:"★"}),F&&e.jsx(Ns,{size:11,style:{color:"var(--text-muted)",flexShrink:0},"aria-hidden":!0}),e.jsx("span",{className:"chat-ellipsis",children:W.title||W.id})]}),e.jsxs("div",{className:"chat-rail-item-meta",children:[e.jsx("span",{className:"chat-rail-item-meta-time",children:W.time??ir(W.mtime)}),(W.unread??0)>0&&e.jsx("span",{className:"chat-rail-badge",children:W.unread})]}),e.jsx("button",{type:"button",className:`chat-rail-item-menu-trigger${y===W.id?" open":""}`,"aria-label":`Session options for ${W.title||W.id}`,"aria-haspopup":"menu","aria-expanded":y===W.id,onClick:q=>{q.stopPropagation(),y===W.id?M():b(W.id,"main")},children:e.jsxs("svg",{viewBox:"0 0 14 14","aria-hidden":!0,children:[e.jsx("circle",{cx:"3",cy:"7",r:"1.2",fill:"currentColor"}),e.jsx("circle",{cx:"7",cy:"7",r:"1.2",fill:"currentColor"}),e.jsx("circle",{cx:"11",cy:"7",r:"1.2",fill:"currentColor"})]})}),V&&B&&e.jsx("button",{type:"button",className:`chat-rail-tree-chevron${Z?" open":""}`,"aria-label":Z?"Collapse sub-agents":"Expand sub-agents","aria-expanded":Z,onClick:q=>{q.stopPropagation(),z(se=>({...se,[W.id]:!se[W.id]}))},children:e.jsx("svg",{viewBox:"0 0 10 10","aria-hidden":!0,children:e.jsx("polyline",{points:"3,1.5 7,5 3,8.5"})})})]}),V&&B&&Z&&((Te=Y==null?void 0:Y.root)==null?void 0:Te.children)&&e.jsx(sr,{children:Y.root.children,variant:"rail",open:!0})]},F?`oc-${W.id}`:W.id)})]},Q))}),y&&v&&e.jsx(Ji,{session:{id:v.id,title:((O=[...s,...t].find(Q=>Q.id===v.id))==null?void 0:O.title)??v.id},mode:R,anchor:v,renameDraft:k,setRenameDraft:f,onEdit:()=>b(y,"rename"),onDeleteRequest:()=>b(y,"confirm-delete"),onConfirmDelete:D,onConfirmRename:C,onClose:M})]})}function or(s){const{text:t,sending:a,onSend:i,activeSource:n}=s,[c,o]=r.useState(!1),l=()=>{!t.trim()||a||(o(!0),i(),window.setTimeout(()=>o(!1),320))};return e.jsxs("div",{className:`chat-composer-wrap chat-composer-source-${n??"none"}`,children:[e.jsx("div",{className:`chat-composer-pill${c?" takeoff":""}`,children:e.jsx(ni,{...s,onSend:l})}),e.jsxs("div",{className:"chat-composer-hint chat-muted",children:[e.jsxs("span",{children:[e.jsx("kbd",{children:"⏎"})," send"]}),e.jsxs("span",{children:[e.jsx("kbd",{children:"⇧⏎"})," newline"]}),e.jsxs("span",{children:[e.jsx("kbd",{children:"/"})," commands"]}),n==="cline"&&e.jsx("span",{className:"chat-composer-source-hint",children:"→ cline"}),n==="bizar"&&e.jsx("span",{className:"chat-composer-source-hint",children:"→ bizar chat"}),a&&e.jsx("span",{className:"chat-composer-source-hint",children:"sending…"})]})]})}function ct(s){return s.toLocaleString()}function cr(s){return!s||!s.includes("/")?"":s.split("/")[0]}function dr(s){if(!s)return 0;const t=s.toLowerCase();return t.includes("opus")?15:t.includes("sonnet")?3:t.includes("haiku")?.8:t.includes("gpt-4o")?5:t.includes("gpt-4")?10:t.includes("deepseek")?.27:t.includes("minimax")?.3:t.includes("llama-3.3-70b")?.59:1}function mr({sessionId:s,messages:t,pinned:a,agent:i,model:n,agents:c,mcps:o,allCommands:l,activeSource:u="bizar",onRename:x,onDelete:h,onExport:d,busy:m,error:p,onRetry:g}){const[N,z]=r.useState(null);r.useEffect(()=>{let b=!1;return(async()=>{try{const M=await fetch("/api/usage?range=24h",{headers:{Accept:"application/json"}});if(!M.ok)return;const P=await M.json();b||z(P)}catch{}})(),()=>{b=!0}},[s]);const S=(t==null?void 0:t.length)??0,y=(a==null?void 0:a.size)??0,w=t.reduce((b,M)=>b+(M.content||M.message||"").length,0),R=Math.round(w/4),j=dr(n),k=R/1e6*j,f=(N==null?void 0:N.totalTokens)??R,v=(N==null?void 0:N.costUsd)??k,L=128e3,$=cr(n);return e.jsxs("aside",{className:"chat-info",children:[p&&e.jsxs("div",{className:"chat-info-section chat-info-error",role:"alert","aria-live":"polite",children:[e.jsxs("h4",{children:[e.jsx(ze,{size:11,style:{marginRight:4,verticalAlign:-1},"aria-hidden":!0})," ","Couldn't load session"]}),e.jsx("p",{className:"chat-info-value chat-ellipsis",title:p.message,children:p.message}),e.jsxs("div",{className:"chat-info-mono",children:["code · ",p.code]}),p.suggestion?e.jsx("p",{className:"chat-info-suggestion",children:p.suggestion}):null,p.canRetry!==!1&&g?e.jsxs("button",{type:"button",className:"btn btn-ghost btn-sm chat-info-retry",onClick:g,title:"Retry loading the session",children:[e.jsx(nt,{size:12,"aria-hidden":!0})," Retry"]}):null]}),e.jsxs("div",{className:"chat-info-section",children:[e.jsxs("div",{className:"chat-info-section-head",children:[e.jsxs("h4",{children:[e.jsx(at,{size:11,style:{marginRight:4,verticalAlign:-1},"aria-hidden":!0})," ","Session"]}),e.jsx("span",{className:`chat-source-badge chat-source-${u??"none"}`,style:{marginLeft:"auto"},children:u==="cline"?"cline":"bizar chat"})]}),e.jsx("div",{className:"chat-info-mono chat-ellipsis",title:s,children:s||"Live"}),e.jsxs("div",{className:"chat-info-mono",children:[ct(S)," message",S===1?"":"s",y>0&&` · ${y} pinned`]})]}),e.jsxs("div",{className:"chat-info-section",children:[e.jsxs("h4",{children:[e.jsx(Xe,{size:11,style:{marginRight:4,verticalAlign:-1},"aria-hidden":!0})," ","Agent"]}),e.jsx("div",{className:"chat-info-value",children:i||"—"})]}),e.jsxs("div",{className:"chat-info-section",children:[e.jsxs("h4",{children:[e.jsx(ys,{size:11,style:{marginRight:4,verticalAlign:-1},"aria-hidden":!0})," ","Model"]}),e.jsx("div",{className:"chat-mono chat-ellipsis",title:n,children:n||"—"}),$&&e.jsxs("div",{className:"chat-info-mono",children:["provider · ",$]})]}),e.jsxs("div",{className:"chat-info-section",children:[e.jsx("h4",{children:"Tokens"}),e.jsxs("div",{className:"chat-mono",children:[ct(f)," / ",ct(L)]}),e.jsx("div",{className:"chat-info-bar","aria-hidden":!0,children:e.jsx("div",{className:"chat-info-bar-fill",style:{width:`${Math.min(100,f/Math.max(1,L)*100)}%`}})})]}),e.jsxs("div",{className:"chat-info-section",children:[e.jsxs("h4",{children:[e.jsx(on,{size:11,style:{marginRight:4,verticalAlign:-1},"aria-hidden":!0})," ","Cost"]}),e.jsxs("div",{className:"chat-mono",children:["$",v.toFixed(4)]}),!N&&e.jsx("div",{className:"chat-info-mono",children:"approx · live from MiniMax"})]}),e.jsxs("div",{className:"chat-info-section",children:[e.jsxs("h4",{children:[e.jsx(Xe,{size:11,style:{marginRight:4,verticalAlign:-1},"aria-hidden":!0})," ","Attached agents"]}),c!=null&&c.length?e.jsx("div",{className:"chat-info-agents",children:c.map(b=>e.jsx("span",{className:"chat-info-agent",children:b.name},b.name))}):e.jsx("div",{className:"chat-info-mono",children:"None attached"})]}),e.jsxs("div",{className:"chat-info-section",children:[e.jsxs("h4",{children:[e.jsx(ys,{size:11,style:{marginRight:4,verticalAlign:-1},"aria-hidden":!0})," ","MCPs"]}),o!=null&&o.length?e.jsx("div",{className:"chat-info-agents",children:o.map(b=>e.jsx("span",{className:"chat-info-agent",children:b.id},b.id))}):e.jsx("div",{className:"chat-info-mono",children:"No MCPs configured"})]}),e.jsxs("div",{className:"chat-info-section",children:[e.jsxs("h4",{children:[e.jsx(js,{size:11,style:{marginRight:4,verticalAlign:-1},"aria-hidden":!0})," ","Slash commands"]}),e.jsxs("div",{className:"chat-info-mono",children:[(l==null?void 0:l.length)??0," available"]})]}),(x||h||d)&&e.jsxs("div",{className:"chat-info-section",children:[e.jsx("h4",{children:"Actions"}),e.jsxs("div",{className:"chat-info-actions",children:[x&&e.jsxs("button",{type:"button",className:"btn btn-ghost btn-sm",onClick:x,disabled:m==null?void 0:m.rename,title:"Rename session",children:[e.jsx(Os,{size:12,"aria-hidden":!0})," Rename"]}),d&&e.jsxs("button",{type:"button",className:"btn btn-ghost btn-sm",onClick:d,title:"Export transcript",children:[e.jsx(rs,{size:12,"aria-hidden":!0})," Export"]}),h&&e.jsxs("button",{type:"button",className:"btn btn-ghost btn-sm btn-danger",onClick:h,disabled:m==null?void 0:m.delete,title:"Delete session",children:[e.jsx(we,{size:12,"aria-hidden":!0})," Delete"]})]})]})]})}function ur({streaming:s,newMessageCount:t,onClick:a,streamingLabel:i="Odin is replying"}){return e.jsx("button",{type:"button",className:`jump-to-latest${s?" is-streaming":""}`,onClick:a,"aria-label":"Jump to latest message",title:"Jump to latest (⌘/Ctrl+End)",children:s?e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"jump-dots","aria-hidden":!0,children:[e.jsx("span",{}),e.jsx("span",{}),e.jsx("span",{})]}),e.jsx("span",{children:i}),t>0&&e.jsx("span",{className:"jump-badge jump-badge-live",children:"live"})]}):e.jsxs(e.Fragment,{children:[e.jsx(xa,{size:14,"aria-hidden":!0}),e.jsx("span",{children:"Jump to latest"}),t>0&&e.jsxs("span",{className:"jump-badge",children:[t," new"]})]})})}function hr({snapshot:s,settings:t,setActiveTab:a,initialTaskId:i,onClearTaskId:n}){const c=le(),o=Ee(),l=ii(s,t,i??"");r.useEffect(()=>{l.setToast({error:O=>c.error(O),success:O=>c.success(O),info:O=>c.info(O),warning:O=>c.warning(O)})},[l,c]);const[u,x]=r.useState(""),[h,d]=r.useState(t.defaultAgent||"odin"),[m,p]=r.useState(t.defaultModel||""),[g,N]=r.useState([]),z=r.useRef(null),{allCommands:S,suggestions:y,setQuery:w}=ri(s);r.useEffect(()=>{w(u)},[u,w]);const R=()=>{var O;return(O=z.current)==null?void 0:O.click()},j=O=>{const Q=O.target.files;if(!Q)return;const U=[];for(let W=0;W<Q.length;W++)U.push(Q[W].name);N(W=>{const F=U.filter(V=>!W.includes(V));return[...W,...F]}),z.current&&(z.current.value="")},k=async()=>{const O=u.trim();if(!O)return;x(""),w(""),(await l.onSend(O,h,m,g)).ok&&l.jumpToLatest()},f=async()=>{l.busy.create||await l.onCreateSession()},v=O=>{o.open({title:"Delete message?",children:e.jsx("p",{style:{margin:0},children:"This action cannot be undone."}),footer:e.jsxs("div",{style:{display:"flex",gap:8,justifyContent:"flex-end"},children:[e.jsx(A,{variant:"secondary",size:"sm",onClick:()=>o.close(),children:"Cancel"}),e.jsx(A,{variant:"danger",size:"sm",onClick:()=>{o.close(),l.deleteMessage(O)},children:"Delete"})]})})},L=(O,Q)=>{let U="";o.open({title:"Rename session",children:e.jsx("input",{id:"rename-session-input",autoFocus:!0,defaultValue:Q,"aria-label":"Session title",onChange:W=>{U=W.target.value},onKeyDown:W=>{W.key==="Enter"&&(W.preventDefault(),o.close(),l.renameSession(O,U).then(F=>{F&&c.success("Renamed.")}))},style:{width:"100%",padding:"8px 10px",background:"var(--bg)",border:"1px solid var(--border)",borderRadius:"var(--radius-sm)",color:"var(--text)",font:"13px/1.4 var(--font-sans)",marginTop:6}}),footer:e.jsxs("div",{style:{display:"flex",gap:8,justifyContent:"flex-end"},children:[e.jsx(A,{variant:"secondary",size:"sm",onClick:()=>o.close(),children:"Cancel"}),e.jsx(A,{variant:"primary",size:"sm",onClick:()=>{o.close(),l.renameSession(O,U)},children:"Save"})]})})},$=(O,Q)=>{o.open({title:"Delete session?",children:e.jsxs("p",{style:{margin:0},children:["Delete ",e.jsx("strong",{children:Q}),"? Messages on the cline serve will be removed. This cannot be undone."]}),footer:e.jsxs("div",{style:{display:"flex",gap:8,justifyContent:"flex-end"},children:[e.jsx(A,{variant:"secondary",size:"sm",onClick:()=>o.close(),children:"Cancel"}),e.jsx(A,{variant:"danger",size:"sm",onClick:async()=>{o.close(),await l.deleteSession(O)},children:"Delete"})]})})},b=()=>{const O=l.activeSource==="cline"?l.activeClineSessionId:l.sessionId;if(!O)return;const U=(l.activeSource==="cline"?l.clineMessages:l.bizarMessages).map(Y=>{const B=Y.ts??"",Z=(Y.role||"unknown").toUpperCase(),xe=Y.content||Y.message||"";return`[${B}] ${Z}: ${xe}`}).join(`
|
|
2
2
|
|
|
3
3
|
`),W=new Blob([U],{type:"text/plain;charset=utf-8"}),F=URL.createObjectURL(W),V=document.createElement("a");V.href=F,V.download=`${O}.txt`,document.body.appendChild(V),V.click(),document.body.removeChild(V),URL.revokeObjectURL(F)},M=r.useMemo(()=>l.sessions.map(O=>l.getSessionDisplay(O)),[l.sessions,l.getSessionDisplay]),P=r.useMemo(()=>l.clineSessions.map(O=>l.getSessionDisplay(O)),[l.clineSessions,l.getSessionDisplay]),C=r.useMemo(()=>{const O=l.activeSource==="cline"?l.activeClineSessionId??"":l.sessionId;return O?M.find(Q=>Q.id===O)??P.find(Q=>Q.id===O)??null:null},[l.activeSource,l.activeClineSessionId,l.sessionId,M,P]),D=(()=>{var U;const O=`${h||"Odin"} · ${((U=s.activeProject)==null?void 0:U.name)??"no project"}`,Q=(C==null?void 0:C.state)??"idle";return Q==="streaming"?`Replying · ${O}`:Q==="awaiting"?`Your turn · ${O}`:`${O} · idle`})(),X=l.activeSource==="cline"?"cline":"bizar chat";return e.jsxs("div",{className:"chat-shell",children:[e.jsx(li,{activeProject:s.activeProject,sessionCount:l.sessions.length,sessionsOpen:!0,infoOpen:!0,onToggleSessions:()=>{},onToggleInfo:()=>{},onOpenOverview:()=>a==null?void 0:a("overview")}),e.jsxs("div",{className:"chat-page",children:[e.jsx(lr,{sessions:M,clineSessions:P,activeSessionId:l.sessionId,activeClineSessionId:l.activeClineSessionId,activeProject:s.activeProject,creating:l.busy.create,onCreateSession:f,onSelectSession:l.selectBizarSession,onSelectClineSession:O=>l.loadClineSession(O.id),onRenameSession:L,onDeleteSession:O=>{const Q=l.sessions.find(U=>U.id===O)??l.clineSessions.find(U=>U.id===O);$(O,(Q==null?void 0:Q.title)??"")}}),e.jsxs("section",{className:"chat-thread-section",children:[e.jsxs("div",{className:"chat-thread-head",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"chat-thread-title-row",children:[e.jsx("div",{className:"chat-thread-title",children:(C==null?void 0:C.title)??l.sessionId??"New chat"}),e.jsx("span",{className:`chat-source-badge chat-source-${l.activeSource??"none"}`,title:l.activeSource==="cline"?"Messages go to the cline serve child":"Messages go to the local chat store",children:X})]}),e.jsxs("div",{className:`chat-thread-sub chat-muted state-${(C==null?void 0:C.state)??"idle"}`,children:[e.jsx("span",{className:"chat-thread-dot"}),D]}),l.clineError&&e.jsxs("div",{className:"chat-thread-error",role:"alert",children:[e.jsx("p",{className:"chat-error-message",children:l.clineError}),l.clineSuggestion&&e.jsx("p",{className:"chat-error-suggestion",children:l.clineSuggestion}),l.activeClineSessionId&&e.jsx("button",{className:"btn btn-sm",type:"button",onClick:()=>l.loadClineSession(l.activeClineSessionId),children:"Retry"})]})]}),e.jsxs("div",{className:"chat-thread-actions",children:[C&&e.jsxs("button",{className:"btn btn-ghost",title:"Rename session",type:"button",disabled:l.busy.rename,onClick:()=>L(C.id,C.title??""),children:[e.jsx(Os,{size:12,"aria-hidden":!0})," ",e.jsx("span",{className:"mono",children:"rename"})]}),C&&e.jsxs("button",{className:"btn btn-ghost btn-danger",title:"Delete session",type:"button",disabled:l.busy.delete,onClick:()=>$(C.id,C.title??C.id),children:[e.jsx(we,{size:12,"aria-hidden":!0})," ",e.jsx("span",{className:"mono",children:"delete"})]}),e.jsx("button",{className:"btn btn-ghost",title:"Export transcript",type:"button",onClick:b,children:e.jsx("span",{className:"mono",children:"export"})})]})]}),e.jsx("div",{className:"chat-thread-scroll",ref:l.listRef,onScroll:l.handleScroll,role:"log","aria-live":"polite","aria-relevant":"additions","aria-label":"Chat message thread",children:e.jsx(oi,{messages:l.activeSource==="cline"?l.clineMessages:l.bizarMessages,loading:l.loading,activeProject:s.activeProject,sessionId:l.activeSource==="cline"?l.activeClineSessionId??l.sessionId:l.sessionId,pinned:l.pinned,activeSource:l.activeSource,onPickSuggestion:O=>x(O),onCopy:O=>l.copyMessage(O),onDelete:v,onTogglePin:l.togglePin,onRegenerate:l.onRegenerate})}),!l.stickToBottom&&e.jsx(ur,{streaming:(C==null?void 0:C.state)==="streaming",newMessageCount:l.newMessageCount,onClick:l.jumpToLatest}),e.jsx(or,{agent:h,setAgent:d,model:m,setModel:p,text:u,setText:x,sending:l.sending,activeSource:l.activeSource,onSend:k,attachments:g,setAttachments:N,suggestions:y,onPickSuggestion:O=>x(`${O.split(" ")[0]} `),agents:s.agents||[],onAttach:R}),e.jsx("input",{ref:z,type:"file",multiple:!0,style:{display:"none"},onChange:j,"aria-label":"Attach files to message",tabIndex:-1})]}),e.jsx(mr,{sessionId:l.activeSource==="cline"?l.activeClineSessionId??l.sessionId:l.sessionId,messages:l.activeSource==="cline"?l.clineMessages:l.bizarMessages,pinned:l.pinned,agent:h,model:m,agents:s.agents||[],mcps:s.mcps||[],allCommands:S,activeSource:l.activeSource,onRename:()=>{C&&L(C.id,C.title??"")},onDelete:()=>{C&&$(C.id,C.title??C.id)},onExport:b,busy:l.busy})]})]})}function xr(s){return s==="ok"?"success":s==="warn"?"warning":s==="fail"?"error":s}function Je({kind:s="neutral",children:t,className:a,dot:i=!1}){const n=xr(s);return e.jsxs("span",{className:_("badge",`badge-${n}`,a),title:`status: ${s}`,children:[i&&e.jsx("span",{className:"badge-dot"}),t]})}const Kt=["bash","read","edit","write","webfetch","websearch","task","glob","grep"],Yt=["anthropic/claude-3-5-sonnet","anthropic/claude-3-5-haiku","openai/gpt-4o","openai/gpt-4o-mini","openrouter/minimax/minimax-m3","openrouter/minimax/minimax-m2.7"],Ks=[{id:"reasoning",label:"Reasoning",color:"var(--accent)"},{id:"code",label:"Code",color:"var(--info)"},{id:"design",label:"Design",color:"var(--success)"},{id:"planning",label:"Planning",color:"var(--warning)"},{id:"gitops",label:"GitOps",color:"var(--error)"},{id:"analysis",label:"Analysis",color:"var(--text-dim)"}];function pr(s){var t;return((t=Ks.find(a=>a.id===s))==null?void 0:t.color)||"var(--text-dim)"}function gr({status:s,isStuck:t}){const a=t?"var(--error)":s==="working"?"var(--info)":s==="error"?"var(--error)":"var(--text-dim)";return e.jsx("span",{className:"agent-status-dot",style:{background:a}})}function jr({agent:s}){if(s.isStuck)return e.jsx(Je,{kind:"error",dot:!0,children:"stuck"});const t=s.status||"idle";return t==="working"?e.jsx(Je,{kind:"info",dot:!0,children:"working"}):t==="error"?e.jsx(Je,{kind:"error",dot:!0,children:"error"}):e.jsx(Je,{kind:"neutral",dot:!0,children:"idle"})}function fr({snapshot:s,refreshSnapshot:t}){const a=le(),i=Ee(),[n,c]=r.useState(s.agents||[]),[o,l]=r.useState(!s.agents),[u,x]=r.useState(""),[h,d]=r.useState("");r.useEffect(()=>{c(s.agents||[]),l(!s.agents)},[s.agents]);const m=async()=>{try{const j=await T.get("/agents");c(j.agents||[])}catch(j){a.error(`Agents load failed: ${j.message}`)}finally{l(!1)}},p=r.useMemo(()=>{let j=[...n];if(u&&(j=j.filter(k=>u==="__none__"?!k.category:(k.category||"")===u)),h){const k=h.toLowerCase();j=j.filter(f=>f.name.toLowerCase().includes(k)||(f.description||"").toLowerCase().includes(k)||(f.tags||[]).some(v=>v.toLowerCase().includes(k)))}return j.sort((k,f)=>k.name.localeCompare(f.name))},[n,u,h]),g=r.useMemo(()=>{const j=new Set;for(const k of n)for(const f of k.tags||[])j.add(f);return Array.from(j).sort()},[n]),N=()=>{let j=null,k=null,f=null,v=null,L=null,$=null,b=null,M=null,P=null;i.open({title:"New agent",width:640,children:e.jsxs("div",{className:"agent-form",children:[e.jsx("label",{className:"field-label",htmlFor:"agent-new-name",children:"Name (a-z, 0-9, dashes)"}),e.jsx("input",{id:"agent-new-name",ref:C=>j=C,className:"input",type:"text",placeholder:"my-agent",autoFocus:!0}),e.jsx("label",{className:"field-label",htmlFor:"agent-new-desc",children:"Description"}),e.jsx("input",{id:"agent-new-desc",ref:C=>{k=C},className:"input",type:"text",placeholder:"What does this agent do?"}),e.jsxs("div",{className:"task-form-row",children:[e.jsxs("div",{className:"task-form-field",children:[e.jsx("label",{className:"field-label",htmlFor:"agent-new-model",children:"Model"}),e.jsxs("select",{id:"agent-new-model",ref:C=>f=C,className:"select",defaultValue:"",children:[e.jsx("option",{value:"",children:"(provider default)"}),Yt.map(C=>e.jsx("option",{value:C,children:C},C))]})]}),e.jsxs("div",{className:"task-form-field",children:[e.jsx("label",{className:"field-label",htmlFor:"agent-new-mode",children:"Mode"}),e.jsxs("select",{id:"agent-new-mode",ref:C=>v=C,className:"select",defaultValue:"subagent",children:[e.jsx("option",{value:"primary",children:"primary"}),e.jsx("option",{value:"subagent",children:"subagent"}),e.jsx("option",{value:"all",children:"all"})]})]}),e.jsxs("div",{className:"task-form-field",style:{flex:"0 0 80px"},children:[e.jsx("label",{className:"field-label",htmlFor:"agent-new-color",children:"Color"}),e.jsx("input",{id:"agent-new-color",ref:C=>L=C,className:"input",type:"color",defaultValue:"#8b5cf6"})]})]}),e.jsxs("div",{className:"task-form-row",children:[e.jsxs("div",{className:"task-form-field",style:{flex:1},children:[e.jsx("label",{className:"field-label",htmlFor:"agent-new-category",children:"Category"}),e.jsxs("select",{id:"agent-new-category",ref:C=>P=C,className:"select",defaultValue:"",children:[e.jsx("option",{value:"",children:"(none)"}),Ks.map(C=>e.jsx("option",{value:C.id,children:C.label},C.id))]})]}),e.jsxs("div",{className:"task-form-field",style:{flex:2},children:[e.jsx("label",{className:"field-label",htmlFor:"agent-new-tags",children:"Tags (comma-separated)"}),e.jsx("input",{id:"agent-new-tags",ref:C=>M=C,className:"input",type:"text",placeholder:"reasoning, code, planning"})]})]}),e.jsxs("fieldset",{children:[e.jsx("legend",{className:"field-label",style:{padding:0},children:"Tools"}),e.jsx("div",{ref:C=>b=C,className:"agent-tools",children:Kt.map(C=>e.jsxs("label",{className:"checkbox-row",children:[e.jsx("input",{type:"checkbox",value:C,"aria-label":C}),e.jsx("span",{children:C})]},C))})]}),e.jsx("label",{className:"field-label",htmlFor:"agent-new-prompt",children:"System prompt"}),e.jsx("textarea",{id:"agent-new-prompt",ref:C=>$=C,className:"textarea",rows:6,placeholder:"You are a..."})]}),footer:e.jsxs("div",{className:"modal-footer-actions",children:[e.jsx(A,{variant:"ghost",onClick:()=>i.close(),children:"Cancel"}),e.jsxs(A,{variant:"primary",onClick:async()=>{const C=((j==null?void 0:j.value)||"").trim();if(!/^[a-z0-9][a-z0-9-]{0,63}$/i.test(C)){a.warning("Invalid name (a-z, 0-9, dashes).");return}const D=[];b&&b.querySelectorAll('input[type="checkbox"]:checked').forEach(O=>{D.push(O.value)});const X=((M==null?void 0:M.value)||"").split(",").map(O=>O.trim()).filter(Boolean);try{const O=await T.post("/agents",{name:C,description:((k==null?void 0:k.value)||"").trim(),model:(f==null?void 0:f.value)||"",mode:(v==null?void 0:v.value)||"subagent",color:(L==null?void 0:L.value)||"",tools:D,tags:X,category:(P==null?void 0:P.value)||"",prompt:($==null?void 0:$.value)||""});c(Q=>[...Q,O]),a.success("Agent created."),i.close(),await t()}catch(O){a.error(`Create failed: ${O.message}`)}},children:[e.jsx(bs,{size:12})," Create"]})]})})},z=async j=>{let k=null,f=null,v=null,L=null,$=null,b=null,M=null,P=null;try{const C=await T.get(`/agents/${encodeURIComponent(j.name)}`);i.open({title:`Edit ${j.name}`,width:640,children:e.jsxs("div",{className:"agent-form",children:[e.jsxs("div",{className:"muted",children:["File: ",e.jsx("code",{children:C.path})]}),e.jsx("label",{className:"field-label",htmlFor:"agent-edit-desc",children:"Description"}),e.jsx("input",{id:"agent-edit-desc",ref:D=>{k=D},className:"input",type:"text",defaultValue:C.description}),e.jsxs("div",{className:"task-form-row",children:[e.jsxs("div",{className:"task-form-field",children:[e.jsx("label",{className:"field-label",htmlFor:"agent-edit-model",children:"Model"}),e.jsxs("select",{id:"agent-edit-model",ref:D=>f=D,className:"select",defaultValue:C.model,children:[e.jsx("option",{value:"",children:"(provider default)"}),Yt.map(D=>e.jsx("option",{value:D,children:D},D))]})]}),e.jsxs("div",{className:"task-form-field",children:[e.jsx("label",{className:"field-label",htmlFor:"agent-edit-mode",children:"Mode"}),e.jsxs("select",{id:"agent-edit-mode",ref:D=>v=D,className:"select",defaultValue:C.mode||"subagent",children:[e.jsx("option",{value:"primary",children:"primary"}),e.jsx("option",{value:"subagent",children:"subagent"}),e.jsx("option",{value:"all",children:"all"})]})]}),e.jsxs("div",{className:"task-form-field",style:{flex:"0 0 80px"},children:[e.jsx("label",{className:"field-label",htmlFor:"agent-edit-color",children:"Color"}),e.jsx("input",{id:"agent-edit-color",ref:D=>L=D,className:"input",type:"color",defaultValue:C.color||"#8b5cf6"})]})]}),e.jsxs("div",{className:"task-form-row",children:[e.jsxs("div",{className:"task-form-field",style:{flex:1},children:[e.jsx("label",{className:"field-label",htmlFor:"agent-edit-category",children:"Category"}),e.jsxs("select",{id:"agent-edit-category",ref:D=>P=D,className:"select",defaultValue:C.category||"",children:[e.jsx("option",{value:"",children:"(none)"}),Ks.map(D=>e.jsx("option",{value:D.id,children:D.label},D.id))]})]}),e.jsxs("div",{className:"task-form-field",style:{flex:2},children:[e.jsx("label",{className:"field-label",htmlFor:"agent-edit-tags",children:"Tags (comma-separated)"}),e.jsx("input",{id:"agent-edit-tags",ref:D=>M=D,className:"input",type:"text",defaultValue:(C.tags||[]).join(", ")})]})]}),e.jsxs("fieldset",{children:[e.jsx("legend",{className:"field-label",style:{padding:0},children:"Tools"}),e.jsx("div",{ref:D=>b=D,className:"agent-tools",children:Kt.map(D=>{var X;return e.jsxs("label",{className:"checkbox-row",children:[e.jsx("input",{type:"checkbox",value:D,"aria-label":D,defaultChecked:(X=C.tools)==null?void 0:X.includes(D)}),e.jsx("span",{children:D})]},D)})})]}),e.jsx("label",{className:"field-label",htmlFor:"agent-edit-prompt",children:"System prompt"}),e.jsx("textarea",{id:"agent-edit-prompt",ref:D=>$=D,className:"textarea",rows:8,defaultValue:C.prompt||""})]}),footer:e.jsxs("div",{className:"modal-footer-actions",children:[e.jsx(A,{variant:"ghost",onClick:()=>i.close(),children:"Cancel"}),e.jsxs(A,{variant:"primary",onClick:async()=>{const D=[];b&&b.querySelectorAll('input[type="checkbox"]:checked').forEach(O=>{D.push(O.value)});const X=((M==null?void 0:M.value)||"").split(",").map(O=>O.trim()).filter(Boolean);try{const O=await T.put(`/agents/${encodeURIComponent(j.name)}`,{description:((k==null?void 0:k.value)||"").trim(),model:(f==null?void 0:f.value)||"",mode:(v==null?void 0:v.value)||"subagent",color:(L==null?void 0:L.value)||"",tools:D,tags:X,category:(P==null?void 0:P.value)||"",prompt:($==null?void 0:$.value)||""});c(Q=>Q.map(U=>U.name===j.name?O:U)),a.success("Agent saved."),i.close(),await t()}catch(O){a.error(`Save failed: ${O.message}`)}},children:[e.jsx(bs,{size:12})," Save"]})]})})}catch(C){a.error(`Load failed: ${C.message}`)}},S=async j=>{if(confirm(`Delete agent "${j.name}"? This removes ${j.path}.`))try{await T.del(`/agents/${encodeURIComponent(j.name)}`),c(k=>k.filter(f=>f.name!==j.name)),a.success("Agent deleted.")}catch(k){a.error(`Delete failed: ${k.message}`)}},y=async j=>{let k=null;i.open({title:`Invoke ${j.name}`,children:e.jsxs("div",{className:"invoke-form",children:[e.jsxs("p",{className:"muted invoke-form-meta mono",children:[j.model||"—"," · ",j.path]}),e.jsx("p",{className:"invoke-form-desc",children:j.description}),e.jsx("label",{className:"field-label",htmlFor:"invoke-prompt",children:"Prompt"}),e.jsx("textarea",{ref:f=>k=f,id:"invoke-prompt",className:"textarea",rows:5,placeholder:"What should this agent do?",autoFocus:!0})]}),footer:e.jsxs("div",{className:"modal-footer-actions",children:[e.jsx(A,{variant:"ghost",onClick:()=>i.close(),children:"Cancel"}),e.jsxs(A,{variant:"primary",onClick:async()=>{const f=((k==null?void 0:k.value)||"").trim();if(!f){a.warning("Prompt is required.");return}try{await T.post(`/agents/${encodeURIComponent(j.name)}/invoke`,{prompt:f}),a.success(`Invoked ${j.name}.`),i.close()}catch(v){a.error(`Invoke failed: ${v.message}`)}},children:[e.jsx(ks,{size:14})," Invoke"]})]})})},w=async j=>{try{const k=await T.post(`/agents/${encodeURIComponent(j.name)}/restart`);c(f=>f.map(v=>v.name===j.name?k:v)),a.success(`${j.name} restarted.`)}catch(k){a.error(`Restart failed: ${k.message}`)}},R=async(j,k)=>{try{const f=await T.post(`/agents/${encodeURIComponent(j.name)}/status`,{status:k});c(v=>v.map(L=>L.name===j.name?f:L))}catch(f){a.error(`Status update failed: ${f.message}`)}};return e.jsxs("div",{className:"view view-agents",children:[e.jsxs("header",{className:"view-header",children:[e.jsxs("div",{className:"view-header-text",children:[e.jsxs("h2",{className:"view-title",children:[e.jsx(Xe,{size:18})," Agents (",p.length,")"]}),e.jsxs("p",{className:"view-subtitle",children:["The Norse pantheon — click ",e.jsx("kbd",{children:"Edit"})," to modify or ",e.jsx("kbd",{children:"Invoke"})," to dispatch."]})]}),e.jsxs("div",{className:"view-actions",children:[e.jsxs("div",{className:"search-input",children:[e.jsx("label",{htmlFor:"agents-search",className:"sr-only",children:"Search agents"}),e.jsx("input",{id:"agents-search",className:"input",type:"text",placeholder:"Search…",value:h,onChange:j=>d(j.target.value),"aria-label":"Search agents"})]}),e.jsx("label",{htmlFor:"agents-category-filter",className:"sr-only",children:"Filter by category"}),e.jsxs("select",{id:"agents-category-filter",className:"select select-sm",value:u,onChange:j=>x(j.target.value),children:[e.jsx("option",{value:"",children:"All categories"}),Ks.map(j=>e.jsx("option",{value:j.id,children:j.label},j.id)),e.jsx("option",{value:"__none__",children:"(no category)"})]}),e.jsxs(A,{variant:"secondary",size:"sm",onClick:m,children:[e.jsx(oe,{size:14})," Refresh"]}),e.jsxs(A,{variant:"primary",size:"sm",onClick:N,children:[e.jsx(Ne,{size:14})," New agent"]})]})]}),g.length>0&&e.jsxs("div",{className:"agent-tags-row",children:[e.jsx(pa,{size:12}),g.map(j=>e.jsx("span",{className:"tag",children:j},j))]}),o?e.jsx("div",{className:"view-loading",children:e.jsx(de,{size:"lg"})}):p.length===0?e.jsx(ge,{icon:e.jsx(Xe,{size:32}),title:"No agents found",message:"Run bizar in the terminal to install Bizar."}):e.jsx("div",{className:"agent-grid",children:p.map(j=>e.jsx(vr,{agent:j,onInvoke:()=>y(j),onEdit:()=>z(j),onDelete:()=>S(j),onRestart:()=>w(j),onSetStatus:k=>R(j,k)},j.name))})]})}function vr({agent:s,onInvoke:t,onEdit:a,onDelete:i,onRestart:n,onSetStatus:c}){const[o,l]=r.useState(!1),u=pr(s.category),x=(s.status==="working"||!!s.currentTaskId)&&!s.isStuck;return e.jsxs(K,{variant:"elevated",interactive:!0,className:_("agent-card",x&&"is-working",s.isStuck&&"is-stuck"),children:[e.jsxs("div",{className:"agent-card-head",children:[e.jsxs("div",{className:"agent-card-name",children:[e.jsx(gr,{status:s.status,isStuck:s.isStuck}),s.name]}),e.jsxs("div",{className:"agent-card-badges",children:[s.category&&e.jsx("span",{className:"agent-card-category",style:{background:`color-mix(in srgb, ${u} 18%, transparent)`,color:u},children:s.category}),e.jsx(jr,{agent:s})]})]}),e.jsx("p",{className:"agent-card-desc",children:la(s.description,200)}),e.jsxs("div",{className:"agent-card-meta",children:[e.jsx("span",{className:"mono",title:s.model||"",children:s.model||"—"}),e.jsx("span",{className:"tabular-nums muted",children:Ce(s.mtime)})]}),s.tags&&s.tags.length>0&&e.jsx("div",{className:"agent-card-tags",children:s.tags.map(h=>e.jsx("span",{className:"agent-card-tag",children:h},h))}),(x||s.lastTask)&&e.jsxs("div",{className:"agent-card-activity",children:[s.currentTaskId&&e.jsxs("div",{className:"agent-card-row",children:[e.jsx(Me,{size:12}),e.jsx("span",{className:"muted",children:"Working on"}),e.jsx("code",{className:"mono",children:s.currentTaskId})]}),s.lastTask&&!s.currentTaskId&&e.jsxs("div",{className:"agent-card-row",children:[e.jsx(Ie,{size:12}),e.jsx("span",{className:"muted",children:"Last"}),e.jsx("code",{className:"mono",children:s.lastTask.id}),e.jsx("span",{className:"muted tabular-nums",children:Ce(s.lastTask.finishedAt)})]}),s.tasksTotal!=null&&s.tasksTotal>0&&e.jsxs("div",{className:"agent-card-row",children:[e.jsx(cn,{size:12}),e.jsx("span",{className:"muted",children:"Success rate"}),e.jsxs("span",{className:"tabular-nums",children:[Math.round((s.successRate||0)*100),"%"]}),e.jsxs("span",{className:"muted tabular-nums",children:["(",s.tasksSucceeded,"/",s.tasksTotal,")"]})]})]}),s.lastError&&e.jsxs("div",{className:"agent-card-error",children:[e.jsx(ze,{size:12}),e.jsxs("span",{className:"muted",children:["Last error: ",s.lastError.message]})]}),e.jsxs("div",{className:"agent-card-actions",children:[e.jsxs(A,{variant:"primary",size:"sm",onClick:t,children:[e.jsx(ks,{size:12})," Invoke"]}),e.jsxs(A,{variant:"secondary",size:"sm",onClick:a,children:[e.jsx(Os,{size:12})," Edit"]}),(s.isStuck||s.status==="working"||s.status==="error")&&e.jsxs(A,{variant:"ghost",size:"sm",onClick:n,title:"Reset agent status",children:[e.jsx(nt,{size:12})," Restart"]}),e.jsx(A,{variant:"ghost",size:"sm",onClick:i,children:e.jsx(we,{size:12})}),e.jsx("button",{type:"button",className:"icon-btn","aria-label":o?"Collapse":"Expand",onClick:()=>l(h=>!h),style:{marginLeft:"auto"},children:o?e.jsx(qe,{size:12}):e.jsx(Qe,{size:12})})]}),o&&e.jsxs("div",{className:"agent-card-expanded",children:[e.jsxs("div",{className:"agent-card-status-actions",children:[e.jsx("span",{className:"muted text-sm",children:"Set status:"}),e.jsx(A,{variant:s.status==="idle"?"primary":"ghost",size:"sm",onClick:()=>c("idle"),children:"Idle"}),e.jsx(A,{variant:s.status==="working"?"primary":"ghost",size:"sm",onClick:()=>c("working"),children:"Working"}),e.jsx(A,{variant:s.status==="error"?"primary":"ghost",size:"sm",onClick:()=>c("error"),children:"Error"})]}),e.jsxs("div",{className:"agent-card-meta",children:[e.jsx(Be,{size:11}),e.jsx("code",{className:"mono agent-card-path",children:s.path})]})]})]})}function yr({id:s,children:t}){return e.jsx("div",{id:s,"data-block-id":s,className:_("glyph-richtext"),style:Ra,children:e.jsx(ka,{remarkPlugins:[wa],children:t})})}const br={info:{bg:"var(--info-soft, rgba(96, 165, 250, 0.12))",border:"var(--info)",fg:"var(--info)",icon:$t,label:"Note"},warn:{bg:"var(--warning-soft, rgba(251, 191, 36, 0.15))",border:"var(--warning)",fg:"var(--warning)",icon:ze,label:"Warning"},success:{bg:"var(--success-soft, rgba(52, 211, 153, 0.15))",border:"var(--success)",fg:"var(--success)",icon:Ie,label:"Success"},danger:{bg:"var(--error-soft, rgba(248, 113, 113, 0.12))",border:"var(--error)",fg:"var(--error)",icon:ws,label:"Danger"}};function Nr({id:s,tone:t="info",children:a}){const i=br[t],n=i.icon;return e.jsxs("div",{id:s,"data-block-id":s,className:_("glyph-callout",`glyph-callout-${t}`),style:{display:"flex",gap:12,padding:"12px 16px",margin:"12px 0",borderLeft:`3px solid ${i.border}`,background:i.bg,borderRadius:8,color:"var(--text)"},role:t==="danger"||t==="warn"?"alert":void 0,children:[e.jsx("div",{style:{flexShrink:0,color:i.fg,paddingTop:2},children:e.jsx(n,{size:18})}),e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsx("div",{style:{fontWeight:600,fontSize:13,color:i.fg,marginBottom:4},children:i.label}),e.jsx("div",{className:"glyph-richtext",style:{...Ra,fontSize:14},children:e.jsx(ka,{remarkPlugins:[wa],children:a})})]})]})}function kr({id:s,items:t}){return e.jsx("ul",{id:s,"data-block-id":s,className:"glyph-checklist",style:{listStyle:"none",padding:0,margin:"12px 0",display:"flex",flexDirection:"column",gap:6},children:t.map(a=>e.jsxs("li",{style:{display:"flex",alignItems:"flex-start",gap:10,padding:"6px 10px",borderRadius:6,background:"var(--bg-elev)",border:"1px solid var(--border)",fontSize:14},children:[e.jsx("span",{"aria-hidden":!0,style:{flexShrink:0,marginTop:1,width:16,height:16,borderRadius:4,border:`1.5px solid ${a.checked?"var(--success)":"var(--border-strong)"}`,background:a.checked?"var(--success)":"transparent",color:"var(--bg)",display:"inline-flex",alignItems:"center",justifyContent:"center"},children:a.checked?e.jsx(fs,{size:12,strokeWidth:3}):null}),e.jsx("span",{style:{color:a.checked?"var(--text-dim)":"var(--text)",textDecoration:a.checked?"line-through":"none",wordBreak:"break-word"},children:a.label})]},a.id))})}function wr({id:s,columns:t,rows:a}){return e.jsx("div",{id:s,"data-block-id":s,className:"glyph-table-wrap",style:{margin:"12px 0",border:"1px solid var(--border)",borderRadius:8,overflow:"auto",background:"var(--bg-elev)"},children:e.jsxs("table",{style:{width:"100%",borderCollapse:"collapse",fontSize:13},children:[e.jsx("thead",{children:e.jsx("tr",{children:t.map((i,n)=>e.jsx("th",{style:{textAlign:"left",padding:"8px 12px",borderBottom:"1px solid var(--border-strong)",background:"var(--bg)",color:"var(--text-dim)",fontWeight:600,fontSize:12,textTransform:"uppercase",letterSpacing:.3,whiteSpace:"nowrap"},children:i},n))})}),e.jsx("tbody",{children:a.map((i,n)=>e.jsx("tr",{style:{borderTop:n===0?"none":"1px solid var(--border)"},children:i.map((c,o)=>e.jsx("td",{style:{padding:"8px 12px",color:"var(--text)",verticalAlign:"top",wordBreak:"break-word"},children:c},o))},n))})]})})}function Sr({id:s,tabs:t}){var c;const[a,i]=r.useState(((c=t[0])==null?void 0:c.id)??""),n=r.useMemo(()=>t.find(o=>o.id===a)??t[0],[t,a]);return e.jsxs("div",{id:s,"data-block-id":s,className:"glyph-codetabs",style:{margin:"12px 0",border:"1px solid var(--border)",borderRadius:8,overflow:"hidden",background:"var(--bg-elev)"},children:[e.jsx("div",{role:"tablist",style:{display:"flex",gap:2,padding:4,background:"var(--bg)",borderBottom:"1px solid var(--border)",overflowX:"auto"},children:t.map(o=>{const l=o.id===(n==null?void 0:n.id);return e.jsxs("button",{type:"button",role:"tab","aria-selected":l,onClick:()=>i(o.id),style:{padding:"6px 12px",fontSize:12,fontFamily:"var(--font-mono)",borderRadius:6,border:"none",cursor:"pointer",background:l?"var(--bg-elev)":"transparent",color:l?"var(--text-strong)":"var(--text-dim)",boxShadow:l?"0 0 0 1px var(--border)":"none",whiteSpace:"nowrap"},children:[e.jsx("span",{children:o.label}),o.language&&e.jsx("span",{style:{marginLeft:6,color:"var(--text-dim)",fontSize:11},children:o.language})]},o.id)})}),n&&e.jsxs(e.Fragment,{children:[e.jsx("pre",{style:{margin:0,padding:14,overflowX:"auto",fontFamily:"var(--font-mono)",fontSize:12.5,lineHeight:1.55,color:"var(--text)",background:"var(--bg-elev)"},children:e.jsx("code",{children:n.code})}),n.caption&&e.jsx("div",{style:{padding:"8px 14px",borderTop:"1px solid var(--border)",fontSize:12,color:"var(--text-dim)",background:"var(--bg)"},children:n.caption})]})]})}function Cr({id:s,title:t,question:a,options:i}){return e.jsxs("div",{id:s,"data-block-id":s,className:"glyph-decision",style:{margin:"16px 0",padding:16,border:"1px solid var(--border)",borderRadius:10,background:"var(--bg-elev)"},children:[t&&e.jsx("h3",{style:{margin:0,marginBottom:4,fontSize:15,fontWeight:600,color:"var(--text-strong)"},children:t}),a&&e.jsx("p",{style:{margin:0,marginBottom:12,fontSize:13,color:"var(--text-dim)"},children:a}),e.jsx("div",{style:{display:"grid",gap:10,gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))"},children:i.map(n=>{const c=!!n.recommended;return e.jsxs("div",{style:{position:"relative",padding:12,borderRadius:8,border:c?"2px solid var(--success)":"1px solid var(--border)",background:c?"var(--success-soft)":"var(--bg)"},children:[c&&e.jsx("span",{style:{position:"absolute",top:-10,right:10,padding:"2px 8px",fontSize:11,fontWeight:600,color:"var(--bg)",background:"var(--success)",borderRadius:999},children:"Recommended"}),e.jsx("div",{style:{fontWeight:600,fontSize:14,color:"var(--text-strong)",marginBottom:4},children:n.label}),e.jsx("div",{style:{fontSize:13,color:"var(--text)"},children:n.detail})]},n.id)})})]})}function zr({id:s,questions:t}){const[a,i]=r.useState({});function n(c,o){i(l=>({...l,[c]:o}))}return e.jsxs("div",{id:s,"data-block-id":s,className:"glyph-openquestions",style:{margin:"16px 0",padding:16,border:"1px solid var(--border)",borderRadius:10,background:"var(--bg-elev)",display:"flex",flexDirection:"column",gap:14},children:[e.jsx("div",{style:{fontSize:13,fontWeight:600,color:"var(--text-strong)"},children:"Open questions"}),t.map(c=>e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[e.jsx("label",{htmlFor:`oq-${c.id}`,style:{fontSize:13,color:"var(--text)",fontWeight:500},children:c.label}),c.kind==="choice"&&e.jsxs("select",{id:`oq-${c.id}`,value:a[c.id]??"",onChange:o=>n(c.id,o.target.value),style:Xt,children:[e.jsx("option",{value:"",children:"— select —"}),(c.options??[]).map(o=>e.jsx("option",{value:o,children:o},o))]}),c.kind==="text"&&e.jsx("input",{id:`oq-${c.id}`,type:"text",value:a[c.id]??"",onChange:o=>n(c.id,o.target.value),style:Xt}),c.kind==="multi"&&e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:4},children:(c.options??[]).map(o=>{const l=a[c.id]??[],u=l.includes(o);return e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:8,fontSize:13,color:"var(--text)",cursor:"pointer"},children:[e.jsx("input",{type:"checkbox",checked:u,onChange:()=>{const x=u?l.filter(h=>h!==o):[...l,o];n(c.id,x)}}),e.jsx("span",{children:o})]},o)})})]},c.id))]})}const Xt={padding:"6px 10px",fontSize:13,borderRadius:6,border:"1px solid var(--border-strong)",background:"var(--bg)",color:"var(--text)",fontFamily:"inherit"},Rr={added:{bg:"var(--success-soft)",fg:"var(--success)",label:"A"},modified:{bg:"var(--info-soft, rgba(96, 165, 250, 0.12))",fg:"var(--info)",label:"M"},removed:{bg:"var(--error-soft)",fg:"var(--error)",label:"D"},renamed:{bg:"rgba(139, 92, 246, 0.15)",fg:"var(--accent)",label:"R"}};function Tr({id:s,title:t,entries:a}){return e.jsxs("div",{id:s,"data-block-id":s,className:"glyph-filetree",style:{margin:"12px 0",padding:t?14:8,border:"1px solid var(--border)",borderRadius:8,background:"var(--bg-elev)"},children:[t&&e.jsx("div",{style:{fontSize:12,fontWeight:600,color:"var(--text-dim)",textTransform:"uppercase",letterSpacing:.4,marginBottom:8},children:t}),e.jsx("ul",{style:{listStyle:"none",padding:0,margin:0,display:"flex",flexDirection:"column",gap:2},children:a.map(i=>{const n=Rr[i.change];return e.jsxs("li",{style:{display:"flex",alignItems:"center",gap:10,padding:"5px 8px",borderRadius:5,fontSize:13},children:[e.jsx("span",{"aria-label":i.change,title:i.change,style:{flexShrink:0,width:22,height:18,borderRadius:4,background:n.bg,color:n.fg,display:"inline-flex",alignItems:"center",justifyContent:"center",fontSize:10,fontWeight:700,fontFamily:"var(--font-mono)"},children:n.label}),e.jsx("span",{style:{fontFamily:"var(--font-mono)",color:"var(--text)",wordBreak:"break-all",flex:1},children:i.path}),i.note&&e.jsx("span",{style:{fontSize:12,color:"var(--text-dim)"},children:i.note})]},i.path)})})]})}function $r({id:s,filename:t,language:a,mode:i="unified",before:n,after:c}){const o=n.split(`
|
|
4
4
|
`),l=c.split(`
|