agent-relay 1.1.0 → 1.2.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/README.md +1 -1
- package/dist/bridge/spawner.d.ts +53 -0
- package/dist/bridge/spawner.d.ts.map +1 -1
- package/dist/bridge/spawner.js +203 -19
- package/dist/bridge/spawner.js.map +1 -1
- package/dist/bridge/types.d.ts +12 -0
- package/dist/bridge/types.d.ts.map +1 -1
- package/dist/cli/index.js +401 -5
- package/dist/cli/index.js.map +1 -1
- package/dist/cloud/api/auth.d.ts +3 -2
- package/dist/cloud/api/auth.d.ts.map +1 -1
- package/dist/cloud/api/auth.js +10 -98
- package/dist/cloud/api/auth.js.map +1 -1
- package/dist/cloud/api/cli-pty-runner.d.ts +54 -0
- package/dist/cloud/api/cli-pty-runner.d.ts.map +1 -0
- package/dist/cloud/api/cli-pty-runner.js +119 -0
- package/dist/cloud/api/cli-pty-runner.js.map +1 -0
- package/dist/cloud/api/generic-webhooks.d.ts +8 -0
- package/dist/cloud/api/generic-webhooks.d.ts.map +1 -0
- package/dist/cloud/api/generic-webhooks.js +129 -0
- package/dist/cloud/api/generic-webhooks.js.map +1 -0
- package/dist/cloud/api/git.d.ts +8 -0
- package/dist/cloud/api/git.d.ts.map +1 -0
- package/dist/cloud/api/git.js +131 -0
- package/dist/cloud/api/git.js.map +1 -0
- package/dist/cloud/api/github-app.d.ts +11 -0
- package/dist/cloud/api/github-app.d.ts.map +1 -0
- package/dist/cloud/api/github-app.js +189 -0
- package/dist/cloud/api/github-app.js.map +1 -0
- package/dist/cloud/api/middleware/planLimits.d.ts +7 -0
- package/dist/cloud/api/middleware/planLimits.d.ts.map +1 -1
- package/dist/cloud/api/middleware/planLimits.js +39 -1
- package/dist/cloud/api/middleware/planLimits.js.map +1 -1
- package/dist/cloud/api/monitoring.d.ts +11 -0
- package/dist/cloud/api/monitoring.d.ts.map +1 -0
- package/dist/cloud/api/monitoring.js +578 -0
- package/dist/cloud/api/monitoring.js.map +1 -0
- package/dist/cloud/api/nango-auth.d.ts +9 -0
- package/dist/cloud/api/nango-auth.d.ts.map +1 -0
- package/dist/cloud/api/nango-auth.js +377 -0
- package/dist/cloud/api/nango-auth.js.map +1 -0
- package/dist/cloud/api/onboarding.d.ts +8 -1
- package/dist/cloud/api/onboarding.d.ts.map +1 -1
- package/dist/cloud/api/onboarding.js +300 -119
- package/dist/cloud/api/onboarding.js.map +1 -1
- package/dist/cloud/api/policy.d.ts +8 -0
- package/dist/cloud/api/policy.d.ts.map +1 -0
- package/dist/cloud/api/policy.js +229 -0
- package/dist/cloud/api/policy.js.map +1 -0
- package/dist/cloud/api/providers.js +114 -42
- package/dist/cloud/api/providers.js.map +1 -1
- package/dist/cloud/api/test-helpers.d.ts +10 -0
- package/dist/cloud/api/test-helpers.d.ts.map +1 -0
- package/dist/cloud/api/test-helpers.js +575 -0
- package/dist/cloud/api/test-helpers.js.map +1 -0
- package/dist/cloud/api/webhooks.d.ts +7 -0
- package/dist/cloud/api/webhooks.d.ts.map +1 -0
- package/dist/cloud/api/webhooks.js +496 -0
- package/dist/cloud/api/webhooks.js.map +1 -0
- package/dist/cloud/api/workspaces.js +225 -8
- package/dist/cloud/api/workspaces.js.map +1 -1
- package/dist/cloud/billing/plans.d.ts.map +1 -1
- package/dist/cloud/billing/plans.js +13 -0
- package/dist/cloud/billing/plans.js.map +1 -1
- package/dist/cloud/billing/types.d.ts +9 -3
- package/dist/cloud/billing/types.d.ts.map +1 -1
- package/dist/cloud/config.d.ts +9 -2
- package/dist/cloud/config.d.ts.map +1 -1
- package/dist/cloud/config.js +13 -4
- package/dist/cloud/config.js.map +1 -1
- package/dist/cloud/db/drizzle.d.ts +84 -1
- package/dist/cloud/db/drizzle.d.ts.map +1 -1
- package/dist/cloud/db/drizzle.js +470 -0
- package/dist/cloud/db/drizzle.js.map +1 -1
- package/dist/cloud/db/index.d.ts +9 -4
- package/dist/cloud/db/index.d.ts.map +1 -1
- package/dist/cloud/db/index.js +11 -3
- package/dist/cloud/db/index.js.map +1 -1
- package/dist/cloud/db/schema.d.ts +3283 -556
- package/dist/cloud/db/schema.d.ts.map +1 -1
- package/dist/cloud/db/schema.js +314 -1
- package/dist/cloud/db/schema.js.map +1 -1
- package/dist/cloud/index.d.ts +1 -0
- package/dist/cloud/index.d.ts.map +1 -1
- package/dist/cloud/index.js +2 -0
- package/dist/cloud/index.js.map +1 -1
- package/dist/cloud/provisioner/index.d.ts +24 -0
- package/dist/cloud/provisioner/index.d.ts.map +1 -1
- package/dist/cloud/provisioner/index.js +319 -18
- package/dist/cloud/provisioner/index.js.map +1 -1
- package/dist/cloud/server.d.ts +1 -0
- package/dist/cloud/server.d.ts.map +1 -1
- package/dist/cloud/server.js +357 -13
- package/dist/cloud/server.js.map +1 -1
- package/dist/cloud/services/auto-scaler.d.ts +152 -0
- package/dist/cloud/services/auto-scaler.d.ts.map +1 -0
- package/dist/cloud/services/auto-scaler.js +439 -0
- package/dist/cloud/services/auto-scaler.js.map +1 -0
- package/dist/cloud/services/capacity-manager.d.ts +148 -0
- package/dist/cloud/services/capacity-manager.d.ts.map +1 -0
- package/dist/cloud/services/capacity-manager.js +449 -0
- package/dist/cloud/services/capacity-manager.js.map +1 -0
- package/dist/cloud/services/ci-agent-spawner.d.ts +49 -0
- package/dist/cloud/services/ci-agent-spawner.d.ts.map +1 -0
- package/dist/cloud/services/ci-agent-spawner.js +373 -0
- package/dist/cloud/services/ci-agent-spawner.js.map +1 -0
- package/dist/cloud/services/index.d.ts +12 -0
- package/dist/cloud/services/index.d.ts.map +1 -0
- package/dist/cloud/services/index.js +15 -0
- package/dist/cloud/services/index.js.map +1 -0
- package/dist/cloud/services/mention-handler.d.ts +65 -0
- package/dist/cloud/services/mention-handler.d.ts.map +1 -0
- package/dist/cloud/services/mention-handler.js +405 -0
- package/dist/cloud/services/mention-handler.js.map +1 -0
- package/dist/cloud/services/nango.d.ts +126 -0
- package/dist/cloud/services/nango.d.ts.map +1 -0
- package/dist/cloud/services/nango.js +191 -0
- package/dist/cloud/services/nango.js.map +1 -0
- package/dist/cloud/services/persistence.d.ts +131 -0
- package/dist/cloud/services/persistence.d.ts.map +1 -0
- package/dist/cloud/services/persistence.js +200 -0
- package/dist/cloud/services/persistence.js.map +1 -0
- package/dist/cloud/services/planLimits.d.ts +15 -0
- package/dist/cloud/services/planLimits.d.ts.map +1 -1
- package/dist/cloud/services/planLimits.js +28 -0
- package/dist/cloud/services/planLimits.js.map +1 -1
- package/dist/cloud/services/scaling-orchestrator.d.ts +159 -0
- package/dist/cloud/services/scaling-orchestrator.d.ts.map +1 -0
- package/dist/cloud/services/scaling-orchestrator.js +502 -0
- package/dist/cloud/services/scaling-orchestrator.js.map +1 -0
- package/dist/cloud/services/scaling-policy.d.ts +121 -0
- package/dist/cloud/services/scaling-policy.d.ts.map +1 -0
- package/dist/cloud/services/scaling-policy.js +415 -0
- package/dist/cloud/services/scaling-policy.js.map +1 -0
- package/dist/cloud/vault/index.js +1 -1
- package/dist/cloud/vault/index.js.map +1 -1
- package/dist/cloud/webhooks/index.d.ts +24 -0
- package/dist/cloud/webhooks/index.d.ts.map +1 -0
- package/dist/cloud/webhooks/index.js +29 -0
- package/dist/cloud/webhooks/index.js.map +1 -0
- package/dist/cloud/webhooks/parsers/github.d.ts +8 -0
- package/dist/cloud/webhooks/parsers/github.d.ts.map +1 -0
- package/dist/cloud/webhooks/parsers/github.js +234 -0
- package/dist/cloud/webhooks/parsers/github.js.map +1 -0
- package/dist/cloud/webhooks/parsers/index.d.ts +23 -0
- package/dist/cloud/webhooks/parsers/index.d.ts.map +1 -0
- package/dist/cloud/webhooks/parsers/index.js +30 -0
- package/dist/cloud/webhooks/parsers/index.js.map +1 -0
- package/dist/cloud/webhooks/parsers/linear.d.ts +9 -0
- package/dist/cloud/webhooks/parsers/linear.d.ts.map +1 -0
- package/dist/cloud/webhooks/parsers/linear.js +258 -0
- package/dist/cloud/webhooks/parsers/linear.js.map +1 -0
- package/dist/cloud/webhooks/parsers/slack.d.ts +9 -0
- package/dist/cloud/webhooks/parsers/slack.d.ts.map +1 -0
- package/dist/cloud/webhooks/parsers/slack.js +214 -0
- package/dist/cloud/webhooks/parsers/slack.js.map +1 -0
- package/dist/cloud/webhooks/responders/github.d.ts +8 -0
- package/dist/cloud/webhooks/responders/github.d.ts.map +1 -0
- package/dist/cloud/webhooks/responders/github.js +73 -0
- package/dist/cloud/webhooks/responders/github.js.map +1 -0
- package/dist/cloud/webhooks/responders/index.d.ts +23 -0
- package/dist/cloud/webhooks/responders/index.d.ts.map +1 -0
- package/dist/cloud/webhooks/responders/index.js +30 -0
- package/dist/cloud/webhooks/responders/index.js.map +1 -0
- package/dist/cloud/webhooks/responders/linear.d.ts +9 -0
- package/dist/cloud/webhooks/responders/linear.d.ts.map +1 -0
- package/dist/cloud/webhooks/responders/linear.js +149 -0
- package/dist/cloud/webhooks/responders/linear.js.map +1 -0
- package/dist/cloud/webhooks/responders/slack.d.ts +20 -0
- package/dist/cloud/webhooks/responders/slack.d.ts.map +1 -0
- package/dist/cloud/webhooks/responders/slack.js +178 -0
- package/dist/cloud/webhooks/responders/slack.js.map +1 -0
- package/dist/cloud/webhooks/router.d.ts +25 -0
- package/dist/cloud/webhooks/router.d.ts.map +1 -0
- package/dist/cloud/webhooks/router.js +504 -0
- package/dist/cloud/webhooks/router.js.map +1 -0
- package/dist/cloud/webhooks/rules-engine.d.ts +24 -0
- package/dist/cloud/webhooks/rules-engine.d.ts.map +1 -0
- package/dist/cloud/webhooks/rules-engine.js +287 -0
- package/dist/cloud/webhooks/rules-engine.js.map +1 -0
- package/dist/cloud/webhooks/types.d.ts +186 -0
- package/dist/cloud/webhooks/types.d.ts.map +1 -0
- package/dist/cloud/webhooks/types.js +8 -0
- package/dist/cloud/webhooks/types.js.map +1 -0
- package/dist/continuity/formatter.d.ts +51 -0
- package/dist/continuity/formatter.d.ts.map +1 -0
- package/dist/continuity/formatter.js +313 -0
- package/dist/continuity/formatter.js.map +1 -0
- package/dist/continuity/handoff-store.d.ts +67 -0
- package/dist/continuity/handoff-store.d.ts.map +1 -0
- package/dist/continuity/handoff-store.js +472 -0
- package/dist/continuity/handoff-store.js.map +1 -0
- package/dist/continuity/index.d.ts +45 -0
- package/dist/continuity/index.d.ts.map +1 -0
- package/dist/continuity/index.js +48 -0
- package/dist/continuity/index.js.map +1 -0
- package/dist/continuity/ledger-store.d.ts +110 -0
- package/dist/continuity/ledger-store.d.ts.map +1 -0
- package/dist/continuity/ledger-store.js +500 -0
- package/dist/continuity/ledger-store.js.map +1 -0
- package/dist/continuity/manager.d.ts +178 -0
- package/dist/continuity/manager.d.ts.map +1 -0
- package/dist/continuity/manager.js +562 -0
- package/dist/continuity/manager.js.map +1 -0
- package/dist/continuity/parser.d.ts +76 -0
- package/dist/continuity/parser.d.ts.map +1 -0
- package/dist/continuity/parser.js +579 -0
- package/dist/continuity/parser.js.map +1 -0
- package/dist/continuity/types.d.ts +180 -0
- package/dist/continuity/types.d.ts.map +1 -0
- package/dist/continuity/types.js +9 -0
- package/dist/continuity/types.js.map +1 -0
- package/dist/daemon/agent-manager.d.ts +27 -0
- package/dist/daemon/agent-manager.d.ts.map +1 -1
- package/dist/daemon/agent-manager.js +107 -6
- package/dist/daemon/agent-manager.js.map +1 -1
- package/dist/daemon/agent-registry.d.ts +32 -0
- package/dist/daemon/agent-registry.d.ts.map +1 -1
- package/dist/daemon/agent-registry.js +42 -2
- package/dist/daemon/agent-registry.js.map +1 -1
- package/dist/daemon/api.d.ts +12 -0
- package/dist/daemon/api.d.ts.map +1 -1
- package/dist/daemon/api.js +131 -2
- package/dist/daemon/api.js.map +1 -1
- package/dist/daemon/cli-auth.d.ts +67 -0
- package/dist/daemon/cli-auth.d.ts.map +1 -0
- package/dist/daemon/cli-auth.js +537 -0
- package/dist/daemon/cli-auth.js.map +1 -0
- package/dist/daemon/cloud-sync.d.ts.map +1 -1
- package/dist/daemon/cloud-sync.js +9 -7
- package/dist/daemon/cloud-sync.js.map +1 -1
- package/dist/daemon/orchestrator.d.ts.map +1 -1
- package/dist/daemon/orchestrator.js +30 -0
- package/dist/daemon/orchestrator.js.map +1 -1
- package/dist/daemon/router.d.ts +5 -0
- package/dist/daemon/router.d.ts.map +1 -1
- package/dist/daemon/router.js +78 -26
- package/dist/daemon/router.js.map +1 -1
- package/dist/daemon/server.d.ts +5 -0
- package/dist/daemon/server.d.ts.map +1 -1
- package/dist/daemon/server.js +9 -1
- package/dist/daemon/server.js.map +1 -1
- package/dist/daemon/services/browser-testing.d.ts +88 -0
- package/dist/daemon/services/browser-testing.d.ts.map +1 -0
- package/dist/daemon/services/browser-testing.js +244 -0
- package/dist/daemon/services/browser-testing.js.map +1 -0
- package/dist/daemon/services/container-spawner.d.ts +135 -0
- package/dist/daemon/services/container-spawner.d.ts.map +1 -0
- package/dist/daemon/services/container-spawner.js +313 -0
- package/dist/daemon/services/container-spawner.js.map +1 -0
- package/dist/daemon/types.d.ts +5 -1
- package/dist/daemon/types.d.ts.map +1 -1
- package/dist/dashboard/out/404.html +1 -1
- package/dist/dashboard/out/_next/static/chunks/116-2502180def231162.js +1 -0
- package/dist/dashboard/out/_next/static/chunks/282-980c2eb8fff20123.js +1 -0
- package/dist/dashboard/out/_next/static/chunks/480-2d4111711d4e473c.js +1 -0
- package/dist/dashboard/out/_next/static/chunks/724-73c1ee5f60abe860.js +9 -0
- package/dist/dashboard/out/_next/static/chunks/766-c3a14283c88d815b.js +1 -0
- package/dist/dashboard/out/_next/static/chunks/app/app/page-7120be68bea622f3.js +1 -0
- package/dist/dashboard/out/_next/static/chunks/app/connect-repos/page-dc2e3a1a22478efc.js +1 -0
- package/dist/dashboard/out/_next/static/chunks/app/history/{page-b6edd4dde8d08194.js → page-56a8b4616a90dc43.js} +1 -1
- package/dist/dashboard/out/_next/static/chunks/app/login/page-3eac37ea6f5dd153.js +1 -0
- package/dist/dashboard/out/_next/static/chunks/app/metrics/page-1081dd190a331a91.js +1 -0
- package/dist/dashboard/out/_next/static/chunks/app/page-daf87e86f783f980.js +1 -0
- package/dist/dashboard/out/_next/static/chunks/app/providers/page-b68a681526eb145e.js +1 -0
- package/dist/dashboard/out/_next/static/chunks/app/signup/page-fee4ed1709070bcd.js +1 -0
- package/dist/dashboard/out/_next/static/chunks/e868780c-48e5f147c90a3a41.js +18 -0
- package/dist/dashboard/out/_next/static/chunks/{main-c2f423b9c9f4591b.js → main-97850e03d723ea8c.js} +1 -1
- package/dist/dashboard/out/_next/static/chunks/webpack-1cdd8ed57114d5e1.js +1 -0
- package/dist/dashboard/out/_next/static/css/29852f26181969a0.css +1 -0
- package/dist/dashboard/out/_next/static/css/411ce23ffeae9f76.css +1 -0
- package/dist/dashboard/out/app.html +1 -14
- package/dist/dashboard/out/app.txt +2 -2
- package/dist/dashboard/out/connect-repos.html +1 -0
- package/dist/dashboard/out/connect-repos.txt +7 -0
- package/dist/dashboard/out/history.html +1 -1
- package/dist/dashboard/out/history.txt +2 -2
- package/dist/dashboard/out/index.html +1 -1
- package/dist/dashboard/out/index.txt +2 -2
- package/dist/dashboard/out/login.html +6 -0
- package/dist/dashboard/out/login.txt +7 -0
- package/dist/dashboard/out/metrics.html +1 -1
- package/dist/dashboard/out/metrics.txt +2 -2
- package/dist/dashboard/out/pricing.html +2 -2
- package/dist/dashboard/out/pricing.txt +2 -2
- package/dist/dashboard/out/providers.html +1 -0
- package/dist/dashboard/out/providers.txt +7 -0
- package/dist/dashboard/out/signup.html +6 -0
- package/dist/dashboard/out/signup.txt +7 -0
- package/dist/dashboard-server/server.d.ts.map +1 -1
- package/dist/dashboard-server/server.js +1308 -8
- package/dist/dashboard-server/server.js.map +1 -1
- package/dist/hooks/emitter.d.ts +40 -0
- package/dist/hooks/emitter.d.ts.map +1 -0
- package/dist/hooks/emitter.js +63 -0
- package/dist/hooks/emitter.js.map +1 -0
- package/dist/hooks/index.d.ts +3 -0
- package/dist/hooks/index.d.ts.map +1 -1
- package/dist/hooks/index.js +3 -0
- package/dist/hooks/index.js.map +1 -1
- package/dist/hooks/registry.d.ts +173 -0
- package/dist/hooks/registry.d.ts.map +1 -0
- package/dist/hooks/registry.js +476 -0
- package/dist/hooks/registry.js.map +1 -0
- package/dist/hooks/trajectory-hooks.d.ts +52 -0
- package/dist/hooks/trajectory-hooks.d.ts.map +1 -0
- package/dist/hooks/trajectory-hooks.js +183 -0
- package/dist/hooks/trajectory-hooks.js.map +1 -0
- package/dist/hooks/types.d.ts +141 -0
- package/dist/hooks/types.d.ts.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/memory/adapters/index.d.ts +8 -0
- package/dist/memory/adapters/index.d.ts.map +1 -0
- package/dist/memory/adapters/index.js +8 -0
- package/dist/memory/adapters/index.js.map +1 -0
- package/dist/memory/adapters/inmemory.d.ts +59 -0
- package/dist/memory/adapters/inmemory.d.ts.map +1 -0
- package/dist/memory/adapters/inmemory.js +195 -0
- package/dist/memory/adapters/inmemory.js.map +1 -0
- package/dist/memory/adapters/supermemory.d.ts +71 -0
- package/dist/memory/adapters/supermemory.d.ts.map +1 -0
- package/dist/memory/adapters/supermemory.js +338 -0
- package/dist/memory/adapters/supermemory.js.map +1 -0
- package/dist/memory/factory.d.ts +48 -0
- package/dist/memory/factory.d.ts.map +1 -0
- package/dist/memory/factory.js +143 -0
- package/dist/memory/factory.js.map +1 -0
- package/dist/memory/index.d.ts +32 -0
- package/dist/memory/index.d.ts.map +1 -0
- package/dist/memory/index.js +32 -0
- package/dist/memory/index.js.map +1 -0
- package/dist/memory/memory-hooks.d.ts +60 -0
- package/dist/memory/memory-hooks.d.ts.map +1 -0
- package/dist/memory/memory-hooks.js +313 -0
- package/dist/memory/memory-hooks.js.map +1 -0
- package/dist/memory/service.d.ts +49 -0
- package/dist/memory/service.d.ts.map +1 -0
- package/dist/memory/service.js +146 -0
- package/dist/memory/service.js.map +1 -0
- package/dist/memory/types.d.ts +195 -0
- package/dist/memory/types.d.ts.map +1 -0
- package/dist/memory/types.js +8 -0
- package/dist/memory/types.js.map +1 -0
- package/dist/policy/agent-policy.d.ts +225 -0
- package/dist/policy/agent-policy.d.ts.map +1 -0
- package/dist/policy/agent-policy.js +665 -0
- package/dist/policy/agent-policy.js.map +1 -0
- package/dist/policy/cloud-policy-fetcher.d.ts +12 -0
- package/dist/policy/cloud-policy-fetcher.d.ts.map +1 -0
- package/dist/policy/cloud-policy-fetcher.js +64 -0
- package/dist/policy/cloud-policy-fetcher.js.map +1 -0
- package/dist/resiliency/crash-insights.d.ts +156 -0
- package/dist/resiliency/crash-insights.d.ts.map +1 -0
- package/dist/resiliency/crash-insights.js +492 -0
- package/dist/resiliency/crash-insights.js.map +1 -0
- package/dist/resiliency/gossip-health.d.ts +137 -0
- package/dist/resiliency/gossip-health.d.ts.map +1 -0
- package/dist/resiliency/gossip-health.js +241 -0
- package/dist/resiliency/gossip-health.js.map +1 -0
- package/dist/resiliency/index.d.ts +5 -0
- package/dist/resiliency/index.d.ts.map +1 -1
- package/dist/resiliency/index.js +5 -0
- package/dist/resiliency/index.js.map +1 -1
- package/dist/resiliency/leader-watchdog.d.ts +109 -0
- package/dist/resiliency/leader-watchdog.d.ts.map +1 -0
- package/dist/resiliency/leader-watchdog.js +189 -0
- package/dist/resiliency/leader-watchdog.js.map +1 -0
- package/dist/resiliency/memory-monitor.d.ts +172 -0
- package/dist/resiliency/memory-monitor.d.ts.map +1 -0
- package/dist/resiliency/memory-monitor.js +593 -0
- package/dist/resiliency/memory-monitor.js.map +1 -0
- package/dist/resiliency/stateless-lead.d.ts +149 -0
- package/dist/resiliency/stateless-lead.d.ts.map +1 -0
- package/dist/resiliency/stateless-lead.js +308 -0
- package/dist/resiliency/stateless-lead.js.map +1 -0
- package/dist/resiliency/supervisor.d.ts +38 -0
- package/dist/resiliency/supervisor.d.ts.map +1 -1
- package/dist/resiliency/supervisor.js +122 -0
- package/dist/resiliency/supervisor.js.map +1 -1
- package/dist/shared/cli-auth-config.d.ts +91 -0
- package/dist/shared/cli-auth-config.d.ts.map +1 -0
- package/dist/shared/cli-auth-config.js +264 -0
- package/dist/shared/cli-auth-config.js.map +1 -0
- package/dist/storage/adapter.d.ts +1 -1
- package/dist/storage/adapter.d.ts.map +1 -1
- package/dist/trajectory/config.d.ts +84 -0
- package/dist/trajectory/config.d.ts.map +1 -0
- package/dist/trajectory/config.js +163 -0
- package/dist/trajectory/config.js.map +1 -0
- package/dist/trajectory/index.d.ts +8 -0
- package/dist/trajectory/index.d.ts.map +1 -0
- package/dist/trajectory/index.js +8 -0
- package/dist/trajectory/index.js.map +1 -0
- package/dist/trajectory/integration.d.ts +292 -0
- package/dist/trajectory/integration.d.ts.map +1 -0
- package/dist/trajectory/integration.js +834 -0
- package/dist/trajectory/integration.js.map +1 -0
- package/dist/utils/logger.js +1 -1
- package/dist/utils/logger.js.map +1 -1
- package/dist/utils/project-namespace.d.ts +24 -0
- package/dist/utils/project-namespace.d.ts.map +1 -1
- package/dist/utils/project-namespace.js +84 -0
- package/dist/utils/project-namespace.js.map +1 -1
- package/dist/wrapper/parser.d.ts +10 -0
- package/dist/wrapper/parser.d.ts.map +1 -1
- package/dist/wrapper/parser.js +100 -33
- package/dist/wrapper/parser.js.map +1 -1
- package/dist/wrapper/pty-wrapper.d.ts +197 -16
- package/dist/wrapper/pty-wrapper.d.ts.map +1 -1
- package/dist/wrapper/pty-wrapper.js +943 -106
- package/dist/wrapper/pty-wrapper.js.map +1 -1
- package/dist/wrapper/shared.d.ts +165 -0
- package/dist/wrapper/shared.d.ts.map +1 -0
- package/dist/wrapper/shared.js +270 -0
- package/dist/wrapper/shared.js.map +1 -0
- package/dist/wrapper/tmux-wrapper.d.ts +73 -11
- package/dist/wrapper/tmux-wrapper.d.ts.map +1 -1
- package/dist/wrapper/tmux-wrapper.js +541 -120
- package/dist/wrapper/tmux-wrapper.js.map +1 -1
- package/docs/CLOUD-ARCHITECTURE.md +152 -0
- package/docs/HOOKS_API.md +394 -0
- package/docs/WRAPPER_EVENTS.md +358 -0
- package/docs/agent-policy-snippet.md +40 -0
- package/docs/agent-relay-protocol.md +238 -0
- package/docs/agent-relay-snippet.md +53 -47
- package/docs/archive/EXECUTIVE_SUMMARY.md +358 -0
- package/docs/archive/ROADMAP.md +329 -0
- package/docs/competitive/GASTOWN.md +451 -0
- package/docs/{COMPETITIVE_ANALYSIS.md → competitive/OVERVIEW.md} +1 -0
- package/docs/competitive/README.md +34 -0
- package/docs/competitive/TMUX_ORCHESTRATOR.md +605 -0
- package/docs/dashboard.png +0 -0
- package/docs/design/ci-failure-webhooks.md +812 -0
- package/docs/design/comprehensive-integrations.md +238 -0
- package/docs/design/e2b-sandbox-integration.md +504 -0
- package/docs/design/github-app-permissions.md +264 -0
- package/docs/local-testing.md +428 -0
- package/docs/proposals/continuous-claude-integration.md +622 -0
- package/docs/proposals/custom-commands.md +368 -0
- package/docs/tasks/global-skills-system.tasks.md +230 -0
- package/docs/tasks/webhook-integrations.tasks.md +184 -0
- package/docs/tasks/workspace-capabilities.tasks.md +121 -0
- package/docs/testing/RESILIENCY-TEST-PLAN-2026-01-01.md +366 -0
- package/package.json +16 -7
- package/scripts/cloud-setup.sh +96 -0
- package/scripts/manual-qa.sh +293 -0
- package/scripts/postinstall.js +60 -0
- package/scripts/run-cloud-qa.sh +220 -0
- package/scripts/test-cli-auth/Dockerfile +44 -0
- package/scripts/test-cli-auth/Dockerfile.real +79 -0
- package/scripts/test-cli-auth/README.md +286 -0
- package/scripts/test-cli-auth/ci-test-real-clis.ts +251 -0
- package/scripts/test-cli-auth/ci-test-runner.ts +263 -0
- package/scripts/test-cli-auth/mock-cli.sh +147 -0
- package/scripts/test-cli-auth/package.json +14 -0
- package/scripts/test-cli-auth/test-oauth-flow.ts +220 -0
- package/scripts/test-pty-input-auto.js +222 -0
- package/scripts/test-pty-input.js +150 -0
- package/dist/dashboard/out/_next/static/chunks/693-7b3301d8f6bc5014.js +0 -1
- package/dist/dashboard/out/_next/static/chunks/713-f78477eb185f1f4d.js +0 -1
- package/dist/dashboard/out/_next/static/chunks/766-e53e1cfe39b0b5b5.js +0 -1
- package/dist/dashboard/out/_next/static/chunks/900-037c64bfd797fb2a.js +0 -1
- package/dist/dashboard/out/_next/static/chunks/app/app/page-e3d9e1f4466b9bae.js +0 -1
- package/dist/dashboard/out/_next/static/chunks/app/metrics/page-e68825a81db67ba1.js +0 -1
- package/dist/dashboard/out/_next/static/chunks/app/page-cc108bf68c8a657f.js +0 -1
- package/dist/dashboard/out/_next/static/chunks/webpack-a5acc2831d094776.js +0 -1
- package/dist/dashboard/out/_next/static/css/79b80143647a07d7.css +0 -1
- package/dist/dashboard/out/_next/static/css/8cf277370ad48cfe.css +0 -1
- /package/dist/dashboard/out/_next/static/{6HHWb2ZmnJ4OSm0zUP7h4 → H5aWG0udPB4iOUIl_gytz}/_buildManifest.js +0 -0
- /package/dist/dashboard/out/_next/static/{6HHWb2ZmnJ4OSm0zUP7h4 → H5aWG0udPB4iOUIl_gytz}/_ssgManifest.js +0 -0
- /package/dist/dashboard/out/_next/static/chunks/{117-b2cd8d6485aacf2b.js → 117-b100311aff8d5c61.js} +0 -0
- /package/dist/dashboard/out/_next/static/chunks/{648-8f3f26864ce515e5.js → 648-a13d3c2b1be45466.js} +0 -0
- /package/dist/dashboard/out/_next/static/chunks/app/_not-found/{page-0b990dbb71d72a98.js → page-a4973f3e3c82fb67.js} +0 -0
- /package/dist/dashboard/out/_next/static/chunks/app/pricing/{page-d80e03a5297f95b6.js → page-4d72d5a5d8a9b618.js} +0 -0
- /package/docs/{CHANGELOG.md → archive/CHANGELOG.md} +0 -0
- /package/docs/{CLI-SIMPLIFICATION-COMPLETE.md → archive/CLI-SIMPLIFICATION-COMPLETE.md} +0 -0
- /package/docs/{DESIGN_BRIDGE_STAFFING.md → archive/DESIGN_BRIDGE_STAFFING.md} +0 -0
- /package/docs/{DESIGN_V2.md → archive/DESIGN_V2.md} +0 -0
- /package/docs/{MONETIZATION.md → archive/MONETIZATION.md} +0 -0
- /package/docs/{PROPOSAL-trajectories.md → archive/PROPOSAL-trajectories.md} +0 -0
- /package/docs/{SCALING_ANALYSIS.md → archive/SCALING_ANALYSIS.md} +0 -0
- /package/docs/{TESTING_PRESENCE_FEATURES.md → archive/TESTING_PRESENCE_FEATURES.md} +0 -0
- /package/docs/{TMUX_IMPLEMENTATION_NOTES.md → archive/TMUX_IMPLEMENTATION_NOTES.md} +0 -0
- /package/docs/{TMUX_IMPROVEMENTS.md → archive/TMUX_IMPROVEMENTS.md} +0 -0
- /package/docs/{dashboard-v2-plan.md → archive/dashboard-v2-plan.md} +0 -0
- /package/docs/{removable-code-analysis.md → archive/removable-code-analysis.md} +0 -0
- /package/docs/{competitive-analysis-mcp-agent-mail.md → competitive/MCP_AGENT_MAIL.md} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[480],{9165:function(e,t,r){r.d(t,{Zk:function(){return l},_V:function(){return o},xv:function(){return d}});var s=r(9116);let n=new Set,a=null;function o(){return a}function i(e){let t=e.headers.get("X-CSRF-Token");t&&(a=t,(0,s.aM)(t))}function l(e){return n.add(e),()=>n.delete(e)}async function c(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};try{let r={"Content-Type":"application/json",...t.headers};t.method&&"GET"!==t.method&&a&&(r["X-CSRF-Token"]=a);let s=await fetch(e,{...t,credentials:"include",headers:r});i(s);let o=await s.json();if(401===s.status||"object"==typeof o&&null!==o&&("SESSION_EXPIRED"===o.code||"USER_NOT_FOUND"===o.code)){let e={error:o.error||"Session expired",code:o.code||"SESSION_EXPIRED",message:o.message||"Your session has expired. Please log in again."};return!function(e){for(let t of n)try{t(e)}catch(e){console.error("[cloudApi] Session expired listener error:",e)}}(e),{success:!1,error:e.message,sessionExpired:!0}}if(!s.ok)return{success:!1,error:o.error||"Request failed with status ".concat(s.status)};return{success:!0,data:o}}catch(e){return{success:!1,error:e instanceof Error?e.message:"Network error"}}}let d={async getNangoLoginSession(){try{let e=await fetch("/api/auth/nango/login-session",{credentials:"include"});i(e);let t=await e.json();if(!e.ok)return{success:!1,error:t.error||"Failed to create login session"};return{success:!0,data:t}}catch(e){return{success:!1,error:e instanceof Error?e.message:"Network error"}}},async checkNangoLoginStatus(e){try{let t=await fetch("/api/auth/nango/login-status/".concat(encodeURIComponent(e)),{credentials:"include"});i(t);let r=await t.json();if(!t.ok)return{success:!1,error:r.error||"Failed to check login status"};return{success:!0,data:r}}catch(e){return{success:!1,error:e instanceof Error?e.message:"Network error"}}},getNangoRepoSession:async()=>c("/api/auth/nango/repo-session"),checkNangoRepoStatus:async e=>c("/api/auth/nango/repo-status/".concat(encodeURIComponent(e))),async checkSession(){try{let e=await fetch("/api/auth/session",{credentials:"include"});return i(e),await e.json()}catch(e){return{authenticated:!1,code:"SESSION_ERROR",message:"Failed to check session status"}}},getMe:async()=>c("/api/auth/me"),async logout(){try{let e={};a&&(e["X-CSRF-Token"]=a);let t=await fetch("/api/auth/logout",{method:"POST",credentials:"include",headers:e});return await t.json()}catch(e){return{success:!1,error:"Network error"}}},getWorkspaces:async()=>c("/api/workspaces"),getWorkspace:async e=>c("/api/workspaces/".concat(encodeURIComponent(e))),createWorkspace:async e=>c("/api/workspaces",{method:"POST",body:JSON.stringify(e)}),getPrimaryWorkspace:async()=>c("/api/workspaces/primary"),getWorkspaceSummary:async()=>c("/api/workspaces/summary"),getWorkspaceStatus:async e=>c("/api/workspaces/".concat(encodeURIComponent(e),"/status")),wakeupWorkspace:async e=>c("/api/workspaces/".concat(encodeURIComponent(e),"/wakeup"),{method:"POST"}),restartWorkspace:async e=>c("/api/workspaces/".concat(encodeURIComponent(e),"/restart"),{method:"POST"}),getProviders:async()=>c("/api/providers"),disconnectProvider:async e=>c("/api/providers/".concat(encodeURIComponent(e)),{method:"DELETE"}),getWorkspaceMembers:async e=>c("/api/workspaces/".concat(encodeURIComponent(e),"/members")),async inviteMember(e,t){let r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"member";return c("/api/workspaces/".concat(encodeURIComponent(e),"/members"),{method:"POST",body:JSON.stringify({githubUsername:t,role:r})})},getPendingInvites:async()=>c("/api/invites"),acceptInvite:async e=>c("/api/invites/".concat(encodeURIComponent(e),"/accept"),{method:"POST"}),declineInvite:async e=>c("/api/invites/".concat(encodeURIComponent(e),"/decline"),{method:"POST"}),updateMemberRole:async(e,t,r)=>c("/api/workspaces/".concat(encodeURIComponent(e),"/members/").concat(encodeURIComponent(t)),{method:"PATCH",body:JSON.stringify({role:r})}),removeMember:async(e,t)=>c("/api/workspaces/".concat(encodeURIComponent(e),"/members/").concat(encodeURIComponent(t)),{method:"DELETE"}),getBillingPlans:async()=>c("/api/billing/plans"),getSubscription:async()=>c("/api/billing/subscription"),async createCheckoutSession(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"month";return c("/api/billing/checkout",{method:"POST",body:JSON.stringify({tier:e,interval:t})})},createBillingPortal:async()=>c("/api/billing/portal",{method:"POST"}),async changeSubscription(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"month";return c("/api/billing/change",{method:"POST",body:JSON.stringify({tier:e,interval:t})})},cancelSubscription:async()=>c("/api/billing/cancel",{method:"POST"}),resumeSubscription:async()=>c("/api/billing/resume",{method:"POST"}),getInvoices:async()=>c("/api/billing/invoices"),stopWorkspace:async e=>c("/api/workspaces/".concat(encodeURIComponent(e),"/stop"),{method:"POST"}),deleteWorkspace:async e=>c("/api/workspaces/".concat(encodeURIComponent(e)),{method:"DELETE"}),addReposToWorkspace:async(e,t)=>c("/api/workspaces/".concat(encodeURIComponent(e),"/repos"),{method:"POST",body:JSON.stringify({repositoryIds:t})}),setCustomDomain:async(e,t)=>c("/api/workspaces/".concat(encodeURIComponent(e),"/domain"),{method:"POST",body:JSON.stringify({domain:t})}),verifyCustomDomain:async e=>c("/api/workspaces/".concat(encodeURIComponent(e),"/domain/verify"),{method:"POST"}),removeCustomDomain:async e=>c("/api/workspaces/".concat(encodeURIComponent(e),"/domain"),{method:"DELETE"}),getWorkspaceDetails:async e=>c("/api/workspaces/".concat(encodeURIComponent(e))),getRepos:async()=>c("/api/github-app/repos")}},637:function(e,t,r){r.d(t,{GW:function(){return l},hP:function(){return c},oU:function(){return i},yh:function(){return a}});let s={backend:{primary:"#1264a3",light:"#e8f4fd",dark:"#0d4f82",text:"#ffffff"},frontend:{primary:"#7c3aed",light:"#f3e8ff",dark:"#5b21b6",text:"#ffffff"},infra:{primary:"#ea580c",light:"#fff7ed",dark:"#c2410c",text:"#ffffff"},lead:{primary:"#2bac76",light:"#ecfdf5",dark:"#059669",text:"#ffffff"},test:{primary:"#0d9488",light:"#f0fdfa",dark:"#0f766e",text:"#ffffff"},data:{primary:"#dc2626",light:"#fef2f2",dark:"#b91c1c",text:"#ffffff"},api:{primary:"#2563eb",light:"#eff6ff",dark:"#1d4ed8",text:"#ffffff"},worker:{primary:"#9333ea",light:"#faf5ff",dark:"#7e22ce",text:"#ffffff"},monitor:{primary:"#0891b2",light:"#ecfeff",dark:"#0e7490",text:"#ffffff"},security:{primary:"#be123c",light:"#fff1f2",dark:"#9f1239",text:"#ffffff"}},n=[{primary:"#6366f1",light:"#eef2ff",dark:"#4f46e5",text:"#ffffff"},{primary:"#ec4899",light:"#fdf2f8",dark:"#db2777",text:"#ffffff"},{primary:"#14b8a6",light:"#f0fdfa",dark:"#0d9488",text:"#ffffff"},{primary:"#f59e0b",light:"#fffbeb",dark:"#d97706",text:"#000000"},{primary:"#8b5cf6",light:"#f5f3ff",dark:"#7c3aed",text:"#ffffff"},{primary:"#06b6d4",light:"#ecfeff",dark:"#0891b2",text:"#ffffff"},{primary:"#f43f5e",light:"#fff1f2",dark:"#e11d48",text:"#ffffff"},{primary:"#84cc16",light:"#f7fee7",dark:"#65a30d",text:"#000000"}],a={online:"#22c55e",offline:"#6b7280",busy:"#eab308",processing:"#6366f1",error:"#ef4444",attention:"#ef4444",stuck:"#f97316"};function o(e){return e.toLowerCase().split("-").filter(Boolean)}function i(e){return o(e)[0]||e.toLowerCase()}function l(e){let t=i(e);return t in s?s[t]:n[function(e){let t=0;for(let r=0;r<e.length;r++)t=(t<<5)-t+e.charCodeAt(r),t&=t;return Math.abs(t)}(t)%n.length]}function c(e){let t=o(e);return 0===t.length?e.substring(0,2).toUpperCase():t.length>=2?(t[0][0]+t[1][0]).toUpperCase():t[0].substring(0,2).toUpperCase()}},6480:function(e,t,r){r.d(t,{g:function(){return sq}});var s=r(7437),n=r(2265),a=r(637);function o(e){let t=new Map;for(let r of e){let e=r.team||(0,a.oU)(r.name),s=(0,a.GW)(r.name),n=t.get(e);n||(n={prefix:e,displayName:d(e),color:s,agents:[],isExpanded:!0},t.set(e,n)),n.agents.push(r)}let r=Array.from(t.values()).sort((e,t)=>e.prefix.localeCompare(t.prefix));for(let e of r)e.agents.sort((e,t)=>e.name.localeCompare(t.name));return r}function i(e){let t=e.split("-").filter(Boolean);return 0===t.length?e:d(t[t.length-1])}function l(e){return e.split("-").filter(Boolean).map(d).join(" > ")}function c(e,t){return t?e.filter(e=>(function(e,t){if(!t)return!0;let r=t.toLowerCase(),s=e.toLowerCase();return!!s.includes(r)||s.split("-").some(e=>e.includes(r))})(e.name,t)):e}function d(e){return e?e.charAt(0).toUpperCase()+e.slice(1):e}function x(e){let t=0,r=0,s=0;for(let n of e)"online"===n.status?t++:"offline"===n.status&&r++,n.needsAttention&&s++;return{total:e.length,online:t,offline:r,needsAttention:s}}function u(e){let{isProcessing:t,processingStartedAt:r,size:a="medium",showElapsed:o=!1,showLabel:i=!1}=e,[l,c]=(0,n.useState)(0);if((0,n.useEffect)(()=>{if(!t||!r){c(0);return}let e=()=>{c(Date.now()-r)};e();let s=setInterval(e,1e3);return()=>clearInterval(s)},[t,r]),!t)return null;let d={small:"w-1 h-1",medium:"w-1.5 h-1.5",large:"w-2 h-2"};return(0,s.jsxs)("span",{className:"inline-flex items-center gap-1.5 text-accent-purple",title:"Processing...",children:[(0,s.jsxs)("span",{className:"inline-flex items-center ".concat({small:"gap-0.5",medium:"gap-1",large:"gap-1.5"}[a]),children:[(0,s.jsx)("span",{className:"".concat(d[a]," rounded-full bg-accent-purple animate-bounce"),style:{animationDelay:"0ms",animationDuration:"800ms"}}),(0,s.jsx)("span",{className:"".concat(d[a]," rounded-full bg-accent-purple animate-bounce"),style:{animationDelay:"150ms",animationDuration:"800ms"}}),(0,s.jsx)("span",{className:"".concat(d[a]," rounded-full bg-accent-purple animate-bounce"),style:{animationDelay:"300ms",animationDuration:"800ms"}})]}),i&&(0,s.jsx)("span",{className:"text-xs font-medium text-accent-purple",children:"thinking"}),o&&l>0&&(0,s.jsx)("span",{className:"text-xs text-accent-purple/70",children:(e=>{let t=Math.floor(e/1e3);return t<60?"".concat(t,"s"):"".concat(Math.floor(t/60),"m ").concat(t%60,"s")})(l)})]})}function m(e){let{isProcessing:t}=e;return t?(0,s.jsx)("span",{className:"thinking-dot-inline",title:"Processing...",children:(0,s.jsx)("span",{className:"thinking-dot-pulse"})}):null}function h(e){if(e<6e4)return"<1m";let t=Math.floor(e/6e4);if(t<60)return"".concat(t,"m");let r=Math.floor(t/60),s=t%60;return 0===s?"".concat(r,"h"):"".concat(r,"h ").concat(s,"m")}function p(e){let{agent:t,isSelected:r=!1,showBreadcrumb:n=!1,compact:o=!1,displayNameOverride:c,onClick:d,onMessageClick:x,onReleaseClick:p,onLogsClick:v,onProfileClick:w}=e,N=(0,a.GW)(t.name),k=(0,a.hP)(t.name),C=c||i(t.name),S=!t.lastMessageReceivedAt||t.lastOutputAt&&t.lastOutputAt>=t.lastMessageReceivedAt?0:Date.now()-t.lastMessageReceivedAt,A=t.isStuck||S>0,L=A?a.yh.stuck:a.yh[t.status]||a.yh.offline,E="online"===t.status,W=function(e,t,r,s){if(r&&s)return"Stuck - Agent received message ".concat(h(s)," ago but hasn't responded");if(t)return"Processing - Agent is actively working";switch(e){case"online":return"Connected - Agent is online and ready";case"offline":return"Disconnected - Agent is not connected";case"busy":return"Busy - Agent is occupied with a task";case"processing":return"Processing - Agent is actively working";case"error":return"Error - Agent encountered an error";case"attention":return"Attention - Agent requires user input";case"stuck":return"Stuck - Agent may be blocked or unresponsive";default:return"Status: ".concat(e)}}(t.status,t.isProcessing,A,S),D=()=>{null==d||d(t)},M=e=>{e.stopPropagation(),null==p||p(t)},T=e=>{e.stopPropagation(),null==v||v(t)},R=e=>{e.stopPropagation(),null==w||w(t)};return o?(0,s.jsxs)("div",{className:"\n group relative flex items-center gap-3 py-2.5 px-3 rounded-lg cursor-pointer\n transition-all duration-300 ease-out\n hover:bg-gradient-to-r hover:from-[rgba(255,255,255,0.03)] hover:to-transparent\n ".concat(r?"bg-gradient-to-r from-[rgba(255,255,255,0.06)] to-transparent":"","\n "),onClick:D,style:{borderLeft:r?"2px solid ".concat(N.primary):"2px solid transparent",boxShadow:r?"inset 4px 0 12px -4px ".concat(N.primary,"40"):"none"},children:[(0,s.jsxs)("div",{className:"relative",children:[(0,s.jsxs)("div",{className:"\n w-8 h-8 rounded-lg flex items-center justify-center font-bold text-[11px] tracking-wide\n transition-all duration-300 relative overflow-hidden\n ".concat(E?"shadow-lg":"opacity-60","\n "),style:{background:"linear-gradient(135deg, ".concat(N.primary,", ").concat(N.primary,"99)"),boxShadow:E?"0 2px 12px ".concat(N.primary,"50"):"none"},children:[(0,s.jsx)("div",{className:"absolute inset-0 opacity-30",style:{background:"linear-gradient(135deg, rgba(255,255,255,0.3) 0%, transparent 50%)"}}),(0,s.jsx)("span",{className:"relative z-10",style:{color:N.text},children:k})]}),E&&(0,s.jsx)("div",{className:"absolute -bottom-0.5 -right-0.5 w-3 h-3 rounded-full border-2 border-bg-primary",style:{backgroundColor:L,boxShadow:"0 0 8px ".concat(L)},title:W})]}),(0,s.jsxs)("div",{className:"flex-1 min-w-0 flex flex-col gap-0.5",children:[(0,s.jsx)("span",{className:"\n text-[13px] font-semibold tracking-tight truncate transition-colors duration-200\n ".concat(E?"text-text-primary":"text-text-secondary","\n "),children:C}),!c&&(0,s.jsx)("span",{className:"text-[10px] text-text-muted truncate font-mono opacity-70",children:l(t.name)})]}),(0,s.jsxs)("div",{className:"flex items-center gap-2 shrink-0",children:[w&&(0,s.jsx)("button",{className:"relative bg-transparent border border-transparent text-text-dim p-1.5 cursor-pointer flex items-center justify-center rounded-md transition-all duration-200 opacity-0 group-hover:opacity-100 hover:bg-[#a855f7]/10 hover:border-[#a855f7]/30 hover:text-[#a855f7] hover:shadow-[0_0_12px_rgba(168,85,247,0.25)]",onClick:R,title:"View profile",children:(0,s.jsx)(y,{})}),t.isSpawned&&v&&(0,s.jsx)("button",{className:"relative bg-transparent border border-transparent text-text-dim p-1.5 cursor-pointer flex items-center justify-center rounded-md transition-all duration-200 opacity-0 group-hover:opacity-100 hover:bg-accent-cyan/10 hover:border-accent-cyan/30 hover:text-accent-cyan hover:shadow-[0_0_12px_rgba(0,217,255,0.25)]",onClick:T,title:"View logs",children:(0,s.jsx)(f,{})}),t.isSpawned&&p&&(0,s.jsx)("button",{className:"relative bg-transparent border border-transparent text-text-dim p-1.5 cursor-pointer flex items-center justify-center rounded-md transition-all duration-200 opacity-0 group-hover:opacity-100 hover:bg-error/10 hover:border-error/30 hover:text-error hover:shadow-[0_0_12px_rgba(255,68,68,0.25)]",onClick:M,title:"Kill agent",children:(0,s.jsx)(b,{})}),t.isProcessing?(0,s.jsx)("div",{title:W,children:(0,s.jsx)(m,{isProcessing:!0})}):(0,s.jsx)("div",{className:"\n w-2 h-2 rounded-full transition-all duration-300\n ".concat(E?"animate-pulse":"","\n "),style:{backgroundColor:L,boxShadow:E?"0 0 6px ".concat(L):"none"},title:W}),t.needsAttention&&(0,s.jsx)("div",{className:"w-2 h-2 rounded-full bg-warning animate-pulse shadow-[0_0_8px_rgba(255,107,53,0.5)]",title:"Needs Attention - Agent requires user input or has pending decisions"}),A&&(0,s.jsxs)("div",{className:"flex items-center gap-1 px-1.5 py-0.5 rounded bg-[#f97316]/20 text-[#f97316] text-[10px] font-medium animate-pulse",title:W,children:[(0,s.jsx)(j,{}),(0,s.jsx)("span",{children:h(S)})]})]})]}):(0,s.jsxs)("div",{className:"\n rounded-lg p-3 cursor-pointer transition-all duration-200\n hover:shadow-md hover:-translate-y-px\n ".concat(r?"border-2 shadow-[0_0_0_2px_rgba(74,158,255,0.15)]":"border","\n "),onClick:D,style:{backgroundColor:N.light,borderColor:N.primary},children:[(0,s.jsxs)("div",{className:"flex items-center gap-3",children:[(0,s.jsxs)("div",{className:"w-10 h-10 rounded-lg flex items-center justify-center font-semibold text-sm relative",style:{backgroundColor:N.primary},children:[(0,s.jsx)("span",{style:{color:N.text},children:k}),(0,s.jsx)("div",{className:"absolute -bottom-0.5 -right-0.5 w-3 h-3 rounded-full border-2 border-white",style:{backgroundColor:L},title:W})]}),(0,s.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)("span",{className:"font-semibold text-sm text-text-primary",children:C}),t.needsAttention&&(0,s.jsx)("span",{className:"bg-red-500 text-white text-[10px] font-bold w-4 h-4 rounded-full flex items-center justify-center",title:"Needs Attention - Agent requires user input or has pending decisions",children:"!"}),A&&(0,s.jsxs)("span",{className:"bg-[#f97316] text-white text-[10px] font-bold px-1.5 py-0.5 rounded flex items-center gap-1",title:W,children:[(0,s.jsx)(j,{})," ",h(S)]})]}),n?(0,s.jsx)("span",{className:"text-xs text-text-muted truncate block",children:l(t.name)}):(0,s.jsx)("span",{className:"text-xs text-text-muted truncate block",children:t.name}),t.agentId&&(0,s.jsxs)("span",{className:"text-[10px] text-text-muted font-mono opacity-70",title:"Agent ID (use to resume)",children:["ID: ",t.agentId]})]})]}),t.isProcessing&&(0,s.jsxs)("div",{className:"mt-2 p-2 bg-indigo-50 rounded flex items-center gap-2 border border-indigo-200",children:[(0,s.jsx)(u,{isProcessing:!0,processingStartedAt:t.processingStartedAt,size:"medium",showElapsed:!0}),(0,s.jsx)("span",{className:"text-xs text-indigo-500 font-medium",children:"Thinking..."})]}),t.currentTask&&!t.isProcessing&&(0,s.jsxs)("div",{className:"mt-2 p-2 bg-bg-hover rounded text-xs",children:[(0,s.jsx)("span",{className:"text-text-muted mr-1",children:"Working on:"}),(0,s.jsx)("span",{className:"text-text-primary line-clamp-2",title:t.currentTask,children:t.currentTask})]}),(0,s.jsxs)("div",{className:"mt-3 flex justify-between items-center",children:[(0,s.jsxs)("div",{className:"flex gap-2 text-xs text-text-muted",children:[t.cli&&(0,s.jsx)("span",{className:"bg-bg-hover py-0.5 px-1.5 rounded",children:t.cli}),void 0!==t.messageCount&&t.messageCount>0&&(0,s.jsxs)("span",{style:{color:N.primary},children:[t.messageCount," msgs"]}),t.isSpawned&&(0,s.jsx)("span",{className:"bg-accent-light text-accent text-[10px] py-0.5 px-1.5 rounded uppercase font-medium",children:"spawned"})]}),(0,s.jsxs)("div",{className:"flex gap-1.5",children:[w&&(0,s.jsx)("button",{className:"relative bg-gradient-to-b from-[#2a1a3a] to-[#1a0f2a] text-[#a855f7] border border-[#402060] rounded-md py-1.5 px-2.5 cursor-pointer flex items-center justify-center gap-1 transition-all duration-200 shadow-[inset_0_1px_0_rgba(168,85,247,0.1),0_2px_4px_rgba(0,0,0,0.3)] overflow-hidden hover:bg-gradient-to-b hover:from-[#402060] hover:to-[#301a50] hover:border-[#a855f7] hover:shadow-[inset_0_1px_0_rgba(168,85,247,0.2),0_0_12px_rgba(168,85,247,0.4),0_2px_8px_rgba(0,0,0,0.4)] hover:scale-105 active:scale-[0.98]",onClick:R,title:"View profile",children:(0,s.jsx)(y,{})}),t.isSpawned&&v&&(0,s.jsx)("button",{className:"relative bg-gradient-to-b from-[#1a2a3a] to-[#0f1a2a] text-accent-cyan border border-[#204060] rounded-md py-1.5 px-2.5 cursor-pointer flex items-center justify-center gap-1 transition-all duration-200 shadow-[inset_0_1px_0_rgba(0,217,255,0.1),0_2px_4px_rgba(0,0,0,0.3)] overflow-hidden hover:bg-gradient-to-b hover:from-[#204060] hover:to-[#1a3a50] hover:border-accent-cyan hover:shadow-[inset_0_1px_0_rgba(0,217,255,0.2),0_0_12px_rgba(0,217,255,0.4),0_2px_8px_rgba(0,0,0,0.4)] hover:scale-105 active:scale-[0.98]",onClick:T,title:"View logs",children:(0,s.jsx)(f,{})}),t.isSpawned&&p&&(0,s.jsx)("button",{className:"relative bg-gradient-to-b from-[#3a1a1a] to-[#2a0f0f] text-[#ff6b6b] border border-[#4a2020] rounded-md py-1.5 px-2.5 cursor-pointer flex items-center justify-center gap-1 transition-all duration-200 shadow-[inset_0_1px_0_rgba(255,107,107,0.1),0_2px_4px_rgba(0,0,0,0.3)] overflow-hidden hover:bg-gradient-to-b hover:from-[#4a2020] hover:to-[#3a1515] hover:border-[#ff4444] hover:text-[#ff4444] hover:shadow-[inset_0_1px_0_rgba(255,68,68,0.2),0_0_12px_rgba(255,68,68,0.4),0_2px_8px_rgba(0,0,0,0.4)] hover:scale-105 active:scale-[0.98]",onClick:M,title:"Release agent",children:(0,s.jsx)(b,{})}),x&&(0,s.jsx)("button",{className:"text-white border-none rounded py-1 px-2 cursor-pointer flex items-center justify-center transition-opacity duration-200 hover:opacity-90",style:{backgroundColor:N.primary},onClick:e=>{e.stopPropagation(),null==x||x(t)},title:"Send message",children:(0,s.jsx)(g,{})})]})]})]})}function g(){return(0,s.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:(0,s.jsx)("path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})})}function b(){return(0,s.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",className:"release-icon",children:[(0,s.jsx)("path",{d:"M12 22c5.523 0 10-4.477 10-10a9.96 9.96 0 0 0-3-7.141",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"}),(0,s.jsx)("path",{d:"M12 22C6.477 22 2 17.523 2 12a9.96 9.96 0 0 1 3-7.141",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"}),(0,s.jsx)("line",{x1:"12",y1:"2",x2:"12",y2:"12",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round"})]})}function f(){return(0,s.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,s.jsx)("polyline",{points:"4 17 10 11 4 5"}),(0,s.jsx)("line",{x1:"12",y1:"19",x2:"20",y2:"19"})]})}function j(){return(0,s.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,s.jsx)("circle",{cx:"12",cy:"12",r:"10"}),(0,s.jsx)("line",{x1:"12",y1:"8",x2:"12",y2:"12"}),(0,s.jsx)("line",{x1:"12",y1:"16",x2:"12.01",y2:"16"})]})}function y(){return(0,s.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,s.jsx)("path",{d:"M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2"}),(0,s.jsx)("circle",{cx:"12",cy:"7",r:"4"})]})}function v(e){let{agents:t,selectedAgent:r,searchQuery:a="",onAgentSelect:i,onAgentMessage:l,onReleaseClick:d,onLogsClick:x,compact:u=!1,showGroupStats:m=!0}=e,[h,p]=(0,n.useState)(new Set),[g,b]=(0,n.useState)(!0),f=(0,n.useMemo)(()=>c(t,a),[t,a]),j=(0,n.useMemo)(()=>o(f),[f]);(0,n.useMemo)(()=>{0===h.size&&j.length>0&&p(new Set(j.map(e=>e.prefix)))},[j]);let y=e=>{p(t=>{let r=new Set(t);return r.has(e)?r.delete(e):r.add(e),r})};return 0===t.length?(0,s.jsxs)("div",{className:"flex flex-col items-center justify-center py-10 px-5 text-text-muted text-center",children:[(0,s.jsx)(k,{}),(0,s.jsx)("p",{children:"No agents connected"})]}):0===f.length?(0,s.jsxs)("div",{className:"flex flex-col items-center justify-center py-10 px-5 text-text-muted text-center",children:[(0,s.jsx)(C,{}),(0,s.jsxs)("p",{children:['No agents match "',a,'"']})]}):(0,s.jsxs)("div",{className:"flex flex-col gap-1",children:[j.length>1&&(0,s.jsxs)("div",{className:"flex justify-between items-center py-2 px-3 text-xs text-text-muted",children:[(0,s.jsxs)("span",{children:[f.length," agents"]}),(0,s.jsx)("button",{className:"bg-transparent border-none text-accent cursor-pointer text-xs hover:underline",onClick:()=>{g?p(new Set):p(new Set(j.map(e=>e.prefix))),b(!g)},children:g?"Collapse all":"Expand all"})]}),j.map(e=>(0,s.jsx)(w,{group:e,isExpanded:h.has(e.prefix),selectedAgent:r,compact:u,showStats:m,onToggle:()=>y(e.prefix),onAgentSelect:i,onAgentMessage:l,onReleaseClick:d,onLogsClick:x},e.prefix))]})}function w(e){let{group:t,isExpanded:r,selectedAgent:n,compact:o,showStats:l,onToggle:c,onAgentSelect:d,onAgentMessage:u,onReleaseClick:m,onLogsClick:h}=e,g=l?x(t.agents):null;if(1===t.agents.length&&t.agents[0].name.toLowerCase()===t.prefix.toLowerCase()){let e=t.agents[0];return(0,s.jsx)("div",{className:"mb-1 py-1 px-2",children:(0,s.jsx)(p,{agent:e,isSelected:e.name===n,compact:o,onClick:d,onMessageClick:u,onReleaseClick:m,onLogsClick:h},e.name)})}return(0,s.jsxs)("div",{className:"mb-1",children:[(0,s.jsxs)("button",{className:"flex items-center gap-2 w-full py-2 px-3 bg-transparent border-none cursor-pointer text-sm text-left rounded transition-colors duration-200 relative hover:bg-[var(--group-light)]",onClick:c,style:{"--group-color":t.color.primary,"--group-light":t.color.light},children:[(0,s.jsx)("div",{className:"absolute left-0 top-1 bottom-1 w-[3px] rounded-sm",style:{backgroundColor:t.color.primary}}),(0,s.jsx)(N,{expanded:r}),(0,s.jsx)("span",{className:"font-semibold text-text-primary",children:t.displayName}),(0,s.jsxs)("span",{className:"text-text-muted font-normal",children:["(",t.agents.length,")"]}),l&&g&&(0,s.jsxs)("div",{className:"ml-auto flex gap-2",children:[g.online>0&&(0,s.jsxs)("span",{className:"flex items-center gap-1 text-xs text-text-muted",title:"".concat(g.online," agent").concat(g.online>1?"s":""," online"),children:[(0,s.jsx)("span",{className:"w-1.5 h-1.5 rounded-full",style:{backgroundColor:a.yh.online}}),g.online]}),g.needsAttention>0&&(0,s.jsxs)("span",{className:"flex items-center gap-1 text-xs text-text-muted",title:"".concat(g.needsAttention," agent").concat(g.needsAttention>1?"s":""," need").concat(1===g.needsAttention?"s":""," attention"),children:[(0,s.jsx)("span",{className:"w-1.5 h-1.5 rounded-full",style:{backgroundColor:a.yh.attention}}),g.needsAttention]})]})]}),r&&(0,s.jsx)("div",{className:"py-1 pl-4 flex flex-col gap-1",children:t.agents.map(e=>(0,s.jsx)(p,{agent:e,isSelected:e.name===n,compact:o,displayNameOverride:i(e.name),onClick:d,onMessageClick:u,onReleaseClick:m,onLogsClick:h},e.name))})]})}function N(e){let{expanded:t}=e;return(0,s.jsx)("svg",{className:"text-text-muted transition-transform duration-200 ".concat(t?"rotate-90":""),width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:(0,s.jsx)("polyline",{points:"9 18 15 12 9 6"})})}function k(){return(0,s.jsxs)("svg",{className:"mb-3 opacity-50",width:"48",height:"48",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1",children:[(0,s.jsx)("circle",{cx:"12",cy:"8",r:"5"}),(0,s.jsx)("path",{d:"M20 21a8 8 0 1 0-16 0"})]})}function C(){return(0,s.jsxs)("svg",{className:"mb-3 opacity-50",width:"48",height:"48",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1",children:[(0,s.jsx)("circle",{cx:"11",cy:"11",r:"8"}),(0,s.jsx)("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]})}function S(e){return e.split(/[-_]/).map(e=>e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()).join(" ")}function A(e){let{projects:t,localAgents:r=[],bridgeAgents:a=[],currentProject:o,selectedAgent:i,searchQuery:l="",onProjectSelect:c,onAgentSelect:d,onReleaseClick:x,onLogsClick:u,compact:m=!1}=e,[h,p]=(0,n.useState)(()=>new Set(t.map(e=>e.id))),g=(0,n.useMemo)(()=>{let e=l.toLowerCase().trim();if(!e)return{projects:t,localAgents:r,bridgeAgents:a};let s=r.filter(t=>{var r;return t.name.toLowerCase().includes(e)||(null===(r=t.currentTask)||void 0===r?void 0:r.toLowerCase().includes(e))}),n=a.filter(t=>{var r;return t.name.toLowerCase().includes(e)||(null===(r=t.currentTask)||void 0===r?void 0:r.toLowerCase().includes(e))});return{projects:t.map(t=>{var r;let s=(null===(r=t.name)||void 0===r?void 0:r.toLowerCase().includes(e))||t.path.toLowerCase().includes(e),n=t.agents.filter(t=>{var r;return t.name.toLowerCase().includes(e)||(null===(r=t.currentTask)||void 0===r?void 0:r.toLowerCase().includes(e))});return s||n.length>0?{...t,agents:s?t.agents:n}:null}).filter(Boolean),localAgents:s,bridgeAgents:n}},[t,r,a,l]),b=e=>{p(t=>{let r=new Set(t);return r.has(e)?r.delete(e):r.add(e),r})},f=g.localAgents.length+g.projects.reduce((e,t)=>e+t.agents.length,0);if(0===f&&0===t.length&&0===r.length)return(0,s.jsxs)("div",{className:"flex flex-col items-center justify-center py-10 px-5 text-[#888] text-center",children:[(0,s.jsx)(R,{}),(0,s.jsx)("p",{children:"No projects or agents"})]});if(0===f&&l)return(0,s.jsxs)("div",{className:"flex flex-col items-center justify-center py-10 px-5 text-[#888] text-center",children:[(0,s.jsx)(P,{}),(0,s.jsxs)("p",{children:['No results for "',l,'"']})]});let j=g.projects.length>1;return(0,s.jsxs)("div",{className:"flex flex-col gap-1",children:[j&&g.bridgeAgents.length>0&&(0,s.jsx)(E,{agents:g.bridgeAgents,selectedAgent:i,compact:m,onAgentSelect:e=>null==d?void 0:d(e),onReleaseClick:x,onLogsClick:u}),!j&&g.localAgents.length>0&&(0,s.jsx)(L,{project:{id:"__local__",path:"",name:"Local",agents:g.localAgents},isExpanded:h.has("__local__"),isCurrentProject:!0,selectedAgent:i,compact:m,onToggle:()=>b("__local__"),onAgentSelect:e=>null==d?void 0:d(e),onReleaseClick:x,onLogsClick:u}),g.projects.map(e=>(0,s.jsx)(L,{project:e,isExpanded:h.has(e.id),isCurrentProject:e.id===o,selectedAgent:i,compact:m,isBridgeMode:j,onToggle:()=>b(e.id),onProjectSelect:()=>null==c?void 0:c(e),onAgentSelect:t=>null==d?void 0:d(t,e),onReleaseClick:x,onLogsClick:u},e.id))]})}function L(e){var t;let{project:r,isExpanded:o,isCurrentProject:i,selectedAgent:l,compact:c,isBridgeMode:d=!1,onToggle:x,onProjectSelect:u,onAgentSelect:m,onReleaseClick:h,onLogsClick:g}=e,[b,f]=(0,n.useState)(new Set),j=(0,n.useMemo)(()=>{let e=0,t=0;for(let s of r.agents)"online"===s.status&&e++,s.needsAttention&&t++;return{online:e,needsAttention:t,total:r.agents.length}},[r.agents]),{teams:y,ungroupedAgents:v}=(0,n.useMemo)(()=>{let e=new Map,t=[];for(let s of r.agents)if(s.team){let t=e.get(s.team)||[];t.push(s),e.set(s.team,t)}else t.push(s);return{teams:Array.from(e.entries()).map(e=>{let[t,r]=e;return{name:t,agents:r}}).sort((e,t)=>e.name.localeCompare(t.name)),ungroupedAgents:t}},[r.agents]),w=e=>{f(t=>{let r=new Set(t);return r.has(e)?r.delete(e):r.add(e),r})};(0,n.useEffect)(()=>{o&&0===b.size&&y.length>0&&f(new Set(y.map(e=>e.name)))},[o,y,b]);let N=(0,a.GW)(r.name||r.id),k=r.name||r.path.split("/").pop()||r.id;return(0,s.jsxs)("div",{className:"mb-1",children:[(0,s.jsxs)("button",{className:"group flex items-center gap-2 w-full py-2.5 px-3 bg-none border-none cursor-pointer text-[13px] text-left rounded-md transition-colors duration-200 relative text-[#e8e8e8] hover:bg-[var(--project-light)] ".concat(i?"bg-[rgba(0,255,200,0.08)]":""),onClick:x,onDoubleClick:u,style:{"--project-color":N.primary,"--project-light":N.light},children:[(0,s.jsx)("div",{className:"absolute left-0 top-1 bottom-1 w-[3px] rounded-sm",style:{background:N.primary}}),(0,s.jsx)(D,{expanded:o}),(0,s.jsx)(M,{color:N.primary}),(0,s.jsx)("span",{className:"font-semibold text-[#e8e8e8] whitespace-nowrap overflow-hidden text-ellipsis",children:k}),(0,s.jsxs)("span",{className:"text-[#888] font-normal flex-shrink-0",children:["(",j.total,")"]}),(0,s.jsxs)("div",{className:"ml-auto flex gap-2 flex-shrink-0",children:[j.online>0&&(0,s.jsxs)("span",{className:"flex items-center gap-1 text-[11px] text-[#666]",children:[(0,s.jsx)("span",{className:"w-1.5 h-1.5 rounded-full",style:{backgroundColor:a.yh.online}}),j.online]}),j.needsAttention>0&&(0,s.jsxs)("span",{className:"flex items-center gap-1 text-[11px] text-[#666]",children:[(0,s.jsx)("span",{className:"w-1.5 h-1.5 rounded-full",style:{backgroundColor:a.yh.attention}}),j.needsAttention]})]}),(null===(t=r.lead)||void 0===t?void 0:t.connected)&&(0,s.jsx)("span",{className:"text-[#ffd700] text-xs ml-1",title:"Lead: ".concat(r.lead.name),children:"★"}),d&&!i&&u&&(0,s.jsx)("button",{className:"ml-2 py-1 px-2 text-[10px] font-medium bg-accent-cyan/20 text-accent-cyan rounded border-none cursor-pointer opacity-0 group-hover:opacity-100 transition-opacity hover:bg-accent-cyan/30",onClick:e=>{e.stopPropagation(),u()},title:"Switch to this project",children:"Switch"})]}),o&&(0,s.jsxs)("div",{className:"py-1 pl-5 flex flex-col gap-1",children:[y.map(e=>(0,s.jsxs)("div",{className:"mb-0.5",children:[(0,s.jsxs)("button",{className:"flex items-center gap-1.5 w-full py-1.5 px-2 bg-none border-none cursor-pointer text-xs text-left rounded transition-colors duration-200 text-[#b8b8b8] hover:bg-white/5",onClick:()=>w(e.name),children:[(0,s.jsx)(D,{expanded:b.has(e.name)}),(0,s.jsx)(T,{}),(0,s.jsx)("span",{className:"font-medium text-[#b8b8b8]",children:e.name}),(0,s.jsxs)("span",{className:"text-[#666] font-normal",children:["(",e.agents.length,")"]})]}),b.has(e.name)&&(0,s.jsx)("div",{className:"py-0.5 pl-4 flex flex-col gap-1",children:e.agents.map(t=>(0,s.jsx)(p,{agent:t,isSelected:t.name===l,compact:c,displayNameOverride:function(e,t){let r=e.toLowerCase(),s=t.toLowerCase().replace(/-?team$/i,"");if(s&&r.startsWith(s+"-")||s&&r.startsWith(s+"_"))return S(e.substring(s.length+1));let n=e.split("-");return n.length>1?S(n[n.length-1]):S(e)}(t.name,e.name),onClick:m,onReleaseClick:h,onLogsClick:g},t.name))})]},e.name)),v.map(e=>(0,s.jsx)(p,{agent:e,isSelected:e.name===l,compact:c,onClick:m,onReleaseClick:h,onLogsClick:g},e.name))]})]})}function E(e){let{agents:t,selectedAgent:r,compact:a,onAgentSelect:o,onReleaseClick:i,onLogsClick:l}=e,[c,d]=(0,n.useState)(!0);return(0,s.jsxs)("div",{className:"mb-2",children:[(0,s.jsxs)("button",{className:"flex items-center gap-2 w-full py-2.5 px-3 bg-none border-none cursor-pointer text-[13px] text-left rounded-md transition-colors duration-200 relative text-[#e8e8e8] hover:bg-[rgba(168,85,247,0.1)]",onClick:()=>d(!c),children:[(0,s.jsx)("div",{className:"absolute left-0 top-1 bottom-1 w-[3px] rounded-sm",style:{background:"#a855f7"}}),(0,s.jsx)(D,{expanded:c}),(0,s.jsx)(W,{}),(0,s.jsx)("span",{className:"font-semibold text-[#e8e8e8]",children:"Bridge"}),(0,s.jsxs)("span",{className:"text-[#888] font-normal flex-shrink-0",children:["(",t.length,")"]})]}),c&&(0,s.jsx)("div",{className:"py-1 pl-5 flex flex-col gap-1",children:t.map(e=>(0,s.jsx)(p,{agent:e,isSelected:e.name===r,compact:a,onClick:o,onReleaseClick:i,onLogsClick:l},e.name))})]})}function W(){return(0,s.jsxs)("svg",{className:"flex-shrink-0 text-[#a855f7]",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,s.jsx)("circle",{cx:"12",cy:"12",r:"3"}),(0,s.jsx)("circle",{cx:"5",cy:"5",r:"2"}),(0,s.jsx)("circle",{cx:"19",cy:"5",r:"2"}),(0,s.jsx)("circle",{cx:"5",cy:"19",r:"2"}),(0,s.jsx)("circle",{cx:"19",cy:"19",r:"2"}),(0,s.jsx)("line",{x1:"9.5",y1:"9.5",x2:"6.5",y2:"6.5"}),(0,s.jsx)("line",{x1:"14.5",y1:"9.5",x2:"17.5",y2:"6.5"}),(0,s.jsx)("line",{x1:"9.5",y1:"14.5",x2:"6.5",y2:"17.5"}),(0,s.jsx)("line",{x1:"14.5",y1:"14.5",x2:"17.5",y2:"17.5"})]})}function D(e){let{expanded:t}=e;return(0,s.jsx)("svg",{className:"transition-transform duration-200 text-[#888] flex-shrink-0 ".concat(t?"rotate-90":""),width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:(0,s.jsx)("polyline",{points:"9 18 15 12 9 6"})})}function M(e){let{color:t}=e;return(0,s.jsx)("svg",{className:"flex-shrink-0",style:{color:t},width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:(0,s.jsx)("path",{d:"M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z"})})}function T(){return(0,s.jsxs)("svg",{className:"text-[#888] flex-shrink-0",width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,s.jsx)("path",{d:"M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2"}),(0,s.jsx)("circle",{cx:"9",cy:"7",r:"4"}),(0,s.jsx)("path",{d:"M23 21v-2a4 4 0 0 0-3-3.87"}),(0,s.jsx)("path",{d:"M16 3.13a4 4 0 0 1 0 7.75"})]})}function R(){return(0,s.jsx)("svg",{className:"mb-3 opacity-50",width:"48",height:"48",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1",children:(0,s.jsx)("path",{d:"M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z"})})}function P(){return(0,s.jsxs)("svg",{className:"mb-3 opacity-50",width:"48",height:"48",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1",children:[(0,s.jsx)("circle",{cx:"11",cy:"11",r:"8"}),(0,s.jsx)("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]})}function B(e){let{threads:t,currentThread:r,onThreadSelect:n,totalUnreadCount:a=0,isCollapsed:o=!1,onToggleCollapse:i}=e;return 0===t.length?null:(0,s.jsxs)("div",{className:"px-2 py-2",children:[(0,s.jsxs)("button",{className:"w-full flex items-center justify-between px-2 py-2 mb-1.5 bg-transparent border-none cursor-pointer rounded-lg transition-all duration-200 hover:bg-gradient-to-r hover:from-[rgba(255,255,255,0.03)] hover:to-transparent",onClick:i,"aria-expanded":!o,"aria-label":o?"Expand threads":"Collapse threads",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)(U,{isCollapsed:o}),(0,s.jsx)("span",{className:"text-xs font-semibold uppercase tracking-wider text-text-muted",children:"Threads"}),(0,s.jsxs)("span",{className:"text-xs text-text-dim font-mono",children:["(",t.length,")"]})]}),a>0&&(0,s.jsx)("span",{className:"min-w-[18px] h-[18px] flex items-center justify-center text-[10px] font-bold bg-accent-cyan text-bg-deep rounded-full px-1.5",style:{boxShadow:"0 0 8px rgba(0, 217, 255, 0.5)"},children:a>99?"99+":a})]}),!o&&(0,s.jsx)("div",{className:"space-y-1",children:t.map(e=>(0,s.jsx)(_,{thread:e,isSelected:r===e.id,onClick:()=>n(e.id)},e.id))})]})}function _(e){let{thread:t,isSelected:r,onClick:n}=e,a=t.unreadCount>0,o=function(e){let t=new Date(e),r=new Date().getTime()-t.getTime(),s=Math.floor(r/6e4),n=Math.floor(r/36e5),a=Math.floor(r/864e5);return s<1?"now":s<60?"".concat(s,"m"):n<24?"".concat(n,"h"):a<7?"".concat(a,"d"):t.toLocaleDateString([],{month:"short",day:"numeric"})}(t.lastMessage.timestamp);return(0,s.jsxs)("button",{className:"\n group w-full flex items-center gap-3 px-2.5 py-2.5 rounded-lg text-left transition-all duration-200 cursor-pointer border-none\n hover:bg-gradient-to-r hover:from-[rgba(255,255,255,0.03)] hover:to-transparent\n ".concat(r?"bg-gradient-to-r from-[rgba(255,255,255,0.06)] to-transparent":"bg-transparent","\n "),onClick:n,style:{borderLeft:r?"2px solid #00d9ff":"2px solid transparent",boxShadow:r?"inset 4px 0 12px -4px rgba(0, 217, 255, 0.25)":"none"},children:[(0,s.jsxs)("div",{className:"\n relative shrink-0 w-8 h-8 rounded-lg flex items-center justify-center overflow-hidden transition-all duration-200\n ".concat(a?"text-accent-cyan":"text-text-muted","\n "),style:{background:a?"linear-gradient(135deg, rgba(0, 217, 255, 0.2), rgba(0, 217, 255, 0.1))":"rgba(255, 255, 255, 0.03)",boxShadow:a?"0 0 8px rgba(0, 217, 255, 0.2)":"none"},children:[(0,s.jsx)("div",{className:"absolute inset-0 opacity-20",style:{background:"linear-gradient(135deg, rgba(255,255,255,0.2) 0%, transparent 50%)"}}),(0,s.jsx)(I,{})]}),(0,s.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)("span",{className:"\n text-[13px] truncate transition-colors duration-200\n ".concat(a?"font-semibold text-text-primary":"text-text-secondary group-hover:text-text-primary","\n "),children:t.name}),a&&(0,s.jsx)("span",{className:"shrink-0 min-w-[16px] h-[16px] flex items-center justify-center text-[9px] font-bold bg-accent-cyan text-bg-deep rounded-full px-1",style:{boxShadow:"0 0 6px rgba(0, 217, 255, 0.4)"},children:t.unreadCount>99?"99+":t.unreadCount})]}),(0,s.jsxs)("div",{className:"flex items-center gap-1.5 text-[11px] text-text-muted font-mono",children:[(0,s.jsx)("span",{className:"truncate",children:t.participants.slice(0,2).join(", ")}),t.participants.length>2&&(0,s.jsxs)("span",{className:"text-text-dim",children:["+",t.participants.length-2]}),(0,s.jsx)("span",{className:"text-text-dim opacity-50",children:"\xb7"}),(0,s.jsx)("span",{className:"text-text-dim",children:o})]})]})]})}function I(){return(0,s.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:(0,s.jsx)("path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})})}function U(e){let{isCollapsed:t}=e;return(0,s.jsx)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"text-text-muted transition-transform duration-200 ".concat(t?"":"rotate-90"),children:(0,s.jsx)("polyline",{points:"9 18 15 12 9 6"})})}var F=r(6272);let O="agent-relay-threads-collapsed",z="agent-relay-sidebar-tab";function H(e){let{agents:t,bridgeAgents:r=[],projects:a=[],currentProject:o,selectedAgent:i,viewMode:l,isFleetAvailable:c,isConnected:d,isOpen:x=!1,activeThreads:u=[],currentThread:m,totalUnreadThreadCount:h=0,onAgentSelect:p,onProjectSelect:g,onViewModeChange:b,onSpawnClick:f,onReleaseClick:j,onLogsClick:y,onThreadSelect:w,onClose:N,onSettingsClick:k}=e,[C,S]=(0,n.useState)(""),[L,E]=(0,n.useState)(()=>{try{let e=localStorage.getItem(z);return"team"===e?"team":"agents"}catch(e){return"agents"}}),[W,D]=(0,n.useState)(()=>{try{let e=localStorage.getItem(O);return"true"===e}catch(e){return!1}});(0,n.useEffect)(()=>{try{localStorage.setItem(z,L)}catch(e){}},[L]),(0,n.useEffect)(()=>{try{localStorage.setItem(O,String(W))}catch(e){}},[W]);let M=t.filter(e=>!e.isHuman),T=t.filter(e=>e.isHuman),R=a.length>0;return(0,s.jsxs)("aside",{className:"flex-1 flex flex-col overflow-hidden",children:[(0,s.jsxs)("div",{className:"p-4 border-b border-border-subtle",children:[(0,s.jsxs)("div",{className:"flex items-center gap-3 mb-3",children:[(0,s.jsx)(F.K7,{size:28,withGlow:!0}),(0,s.jsx)("h1",{className:"text-lg font-display font-semibold m-0 text-text-primary",children:"Agent Relay"}),(0,s.jsx)(V,{isConnected:d}),(0,s.jsx)("button",{className:"md:hidden ml-auto p-2 -mr-2 bg-transparent border-none text-text-muted cursor-pointer rounded-lg transition-colors hover:bg-bg-hover hover:text-text-primary",onClick:N,"aria-label":"Close sidebar",children:(0,s.jsx)(q,{})})]}),c&&(0,s.jsxs)("div",{className:"flex bg-bg-tertiary rounded-lg p-1",children:[(0,s.jsx)("button",{className:"\n flex-1 py-2 px-4 bg-transparent border-none text-xs font-medium cursor-pointer rounded-md transition-all duration-150\n ".concat("local"===l?"bg-bg-elevated text-accent-cyan shadow-sm":"text-text-muted hover:text-text-secondary","\n "),onClick:()=>null==b?void 0:b("local"),children:"Local"}),(0,s.jsx)("button",{className:"\n flex-1 py-2 px-4 bg-transparent border-none text-xs font-medium cursor-pointer rounded-md transition-all duration-150\n ".concat("fleet"===l?"bg-bg-elevated text-accent-cyan shadow-sm":"text-text-muted hover:text-text-secondary","\n "),onClick:()=>null==b?void 0:b("fleet"),children:"Fleet"})]})]}),T.length>0&&(0,s.jsxs)("div",{className:"flex bg-bg-tertiary rounded-lg p-1 mx-3 mt-3",children:[(0,s.jsxs)("button",{className:"\n flex-1 py-2 px-4 bg-transparent border-none text-xs font-medium cursor-pointer rounded-md transition-all duration-150 flex items-center justify-center gap-1.5\n ".concat("agents"===L?"bg-bg-elevated text-accent-cyan shadow-sm":"text-text-muted hover:text-text-secondary","\n "),onClick:()=>E("agents"),children:[(0,s.jsx)(Y,{}),"Agents",M.length>0&&(0,s.jsxs)("span",{className:"text-[10px] opacity-70",children:["(",M.length,")"]})]}),(0,s.jsxs)("button",{className:"\n flex-1 py-2 px-4 bg-transparent border-none text-xs font-medium cursor-pointer rounded-md transition-all duration-150 flex items-center justify-center gap-1.5\n ".concat("team"===L?"bg-bg-elevated text-accent-cyan shadow-sm":"text-text-muted hover:text-text-secondary","\n "),onClick:()=>E("team"),children:[(0,s.jsx)($,{}),"Team",T.length>0&&(0,s.jsxs)("span",{className:"text-[10px] opacity-70",children:["(",T.length,")"]})]})]}),(0,s.jsxs)("div",{className:"flex items-center gap-2 py-2.5 px-3 bg-bg-tertiary m-3 rounded-lg border border-border-subtle focus-within:border-accent-cyan/50 transition-colors",children:[(0,s.jsx)(G,{}),(0,s.jsx)("input",{type:"text",placeholder:"agents"===L?"Search agents...":"Search team...",value:C,onChange:e=>S(e.target.value),className:"flex-1 bg-transparent border-none text-text-primary text-sm outline-none placeholder:text-text-muted"}),C&&(0,s.jsx)("button",{className:"bg-transparent border-none text-text-muted cursor-pointer p-1 flex items-center justify-center hover:text-text-secondary rounded transition-colors",onClick:()=>S(""),children:(0,s.jsx)(K,{})})]}),u.length>0&&(0,s.jsx)("div",{className:"border-b border-border-subtle",children:(0,s.jsx)(B,{threads:u,currentThread:m,onThreadSelect:e=>null==w?void 0:w(e),totalUnreadCount:h,isCollapsed:W,onToggleCollapse:()=>D(!W)})}),(0,s.jsx)("div",{className:"flex-1 overflow-y-auto px-2",children:"team"===L&&T.length>0?(0,s.jsxs)("div",{className:"flex flex-col gap-1 py-2",children:[T.filter(e=>!C||e.name.toLowerCase().includes(C.toLowerCase())).map(e=>(0,s.jsxs)("button",{onClick:()=>null==p?void 0:p(e),className:"\n flex items-center gap-3 p-3 rounded-lg border transition-all duration-150 text-left w-full\n ".concat(i===e.name?"bg-accent-cyan/10 border-accent-cyan/30":"bg-bg-tertiary border-border-subtle hover:border-accent-cyan/30 hover:bg-bg-hover","\n "),children:[e.avatarUrl?(0,s.jsx)("img",{src:e.avatarUrl,alt:e.name,className:"w-9 h-9 rounded-full object-cover"}):(0,s.jsx)("div",{className:"w-9 h-9 rounded-full bg-gradient-to-br from-purple-500 to-pink-500 flex items-center justify-center text-white font-medium text-sm",children:e.name.charAt(0).toUpperCase()}),(0,s.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,s.jsx)("p",{className:"text-sm font-medium text-text-primary truncate",children:e.name}),(0,s.jsx)("p",{className:"text-xs text-text-muted truncate",children:e.role||"Team Member"})]}),(0,s.jsx)("div",{className:"w-2 h-2 rounded-full ".concat("online"===e.status?"bg-success":"bg-text-dim")})]},e.name)),0===T.filter(e=>!C||e.name.toLowerCase().includes(C.toLowerCase())).length&&(0,s.jsxs)("div",{className:"flex flex-col items-center justify-center py-10 px-5 text-text-muted text-center",children:[(0,s.jsx)(G,{}),(0,s.jsxs)("p",{className:"mt-3",children:['No team members match "',C,'"']})]})]}):R?(0,s.jsx)(A,{projects:a,localAgents:M,bridgeAgents:r,currentProject:o,selectedAgent:i,searchQuery:C,onProjectSelect:g,onAgentSelect:p,onReleaseClick:j,onLogsClick:y,compact:!0}):(0,s.jsx)(v,{agents:M,selectedAgent:i,searchQuery:C,onAgentSelect:e=>null==p?void 0:p(e),onReleaseClick:j,onLogsClick:y,compact:!0,showGroupStats:!0})}),(0,s.jsxs)("div",{className:"p-4 border-t border-border-subtle space-y-2",children:[(0,s.jsxs)("button",{className:"w-full py-3 px-4 bg-gradient-to-r from-accent-cyan to-[#00b8d9] text-bg-deep font-semibold text-sm cursor-pointer flex items-center justify-center gap-2 rounded-lg transition-all duration-150 hover:shadow-glow-cyan hover:-translate-y-0.5",onClick:f,children:[(0,s.jsx)(J,{}),"Spawn Agent"]}),(0,s.jsxs)("button",{className:"w-full py-2.5 px-4 bg-bg-tertiary text-text-secondary text-sm cursor-pointer flex items-center justify-center gap-2 rounded-lg border border-border-subtle transition-all duration-150 hover:bg-bg-hover hover:text-text-primary hover:border-border-subtle",onClick:k,children:[(0,s.jsx)(X,{}),"Settings"]})]})]})}function V(e){let{isConnected:t}=e;return(0,s.jsxs)("div",{className:"flex items-center gap-1.5 ml-auto",children:[(0,s.jsx)("div",{className:"w-2 h-2 rounded-full ".concat(t?"bg-success animate-pulse-glow":"bg-text-dim")}),(0,s.jsx)("span",{className:"text-xs text-text-muted",children:t?"Live":"Offline"})]})}function G(){return(0,s.jsxs)("svg",{className:"text-text-muted",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,s.jsx)("circle",{cx:"11",cy:"11",r:"8"}),(0,s.jsx)("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]})}function K(){return(0,s.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,s.jsx)("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),(0,s.jsx)("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})}function J(){return(0,s.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:[(0,s.jsx)("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),(0,s.jsx)("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]})}function q(){return(0,s.jsxs)("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,s.jsx)("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),(0,s.jsx)("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})}function X(){return(0,s.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,s.jsx)("circle",{cx:"12",cy:"12",r:"3"}),(0,s.jsx)("path",{d:"M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-2 2 2 2 0 0 1-2-2v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1-2-2 2 2 0 0 1 2-2h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 2-2 2 2 0 0 1 2 2v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 2 2 2 2 0 0 1-2 2h-.09a1.65 1.65 0 0 0-1.51 1z"})]})}function Y(){return(0,s.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,s.jsx)("rect",{x:"3",y:"11",width:"18",height:"10",rx:"2"}),(0,s.jsx)("circle",{cx:"12",cy:"5",r:"2"}),(0,s.jsx)("path",{d:"M12 7v4"}),(0,s.jsx)("line",{x1:"8",y1:"16",x2:"8",y2:"16"}),(0,s.jsx)("line",{x1:"16",y1:"16",x2:"16",y2:"16"})]})}function $(){return(0,s.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,s.jsx)("path",{d:"M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2"}),(0,s.jsx)("circle",{cx:"9",cy:"7",r:"4"}),(0,s.jsx)("path",{d:"M23 21v-2a4 4 0 0 0-3-3.87"}),(0,s.jsx)("path",{d:"M16 3.13a4 4 0 0 1 0 7.75"})]})}function Z(e){let{projects:t,recentProjects:r=[],currentProject:a,onProjectChange:o}=e,[i,l]=(0,n.useState)(!1),[c,d]=(0,n.useState)(-1),x=(0,n.useRef)(null),u=(0,n.useRef)([]),m=t.length>1,h=new Set(r.map(e=>e.id)),p=t.filter(e=>!h.has(e.id)),g=[...r,...p],b=e=>{if(!e)return"No project";if(e.name)return e.name;let t=e.path.split("/").filter(Boolean);return t.length>=2?"".concat(t[t.length-2],"/").concat(t[t.length-1]):t[t.length-1]||e.id};return((0,n.useEffect)(()=>{let e=e=>{x.current&&!x.current.contains(e.target)&&l(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[]),(0,n.useEffect)(()=>{let e=e=>{if(i)switch(e.key){case"Escape":l(!1),d(-1);break;case"ArrowDown":e.preventDefault(),d(e=>{var t;let r=e<g.length-1?e+1:0;return null===(t=u.current[r])||void 0===t||t.focus(),r});break;case"ArrowUp":e.preventDefault(),d(e=>{var t;let r=e>0?e-1:g.length-1;return null===(t=u.current[r])||void 0===t||t.focus(),r});break;case"Enter":c>=0&&c<g.length&&(o(g[c]),l(!1),d(-1))}};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[i,c,g,o]),(0,n.useEffect)(()=>{if(i){let e=g.findIndex(e=>e.id===(null==a?void 0:a.id));d(e>=0?e:0)}else d(-1)},[i,g,a]),0===t.length)?null:(0,s.jsxs)("div",{className:"relative",ref:x,children:[(0,s.jsxs)("button",{className:"flex items-center gap-2 px-3 py-1.5 rounded-lg text-sm font-medium transition-all duration-150 border ".concat(m?"bg-bg-tertiary/80 border-border-subtle hover:bg-bg-elevated hover:border-border-medium cursor-pointer":"bg-transparent border-transparent cursor-default"),onClick:()=>m&&l(!i),disabled:!m,"aria-expanded":i,"aria-haspopup":"listbox",children:[(0,s.jsx)(et,{}),(0,s.jsx)("span",{className:"text-text-primary truncate max-w-[200px]",children:b(a)}),m&&(0,s.jsx)(er,{isOpen:i})]}),i&&m&&(0,s.jsxs)("div",{className:"absolute top-[calc(100%+4px)] left-0 min-w-[280px] bg-bg-primary border border-border-subtle rounded-xl shadow-[0_10px_40px_rgba(0,0,0,0.4)] z-[1000] overflow-hidden",children:[(0,s.jsx)("div",{className:"px-3 py-2 border-b border-border-subtle",children:(0,s.jsx)("span",{className:"text-xs font-medium text-text-muted uppercase tracking-wider",children:"Switch Project"})}),(0,s.jsxs)("div",{className:"max-h-[300px] overflow-y-auto",role:"listbox",children:[r.length>0&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("div",{className:"px-3 py-1.5 bg-bg-tertiary/50",children:(0,s.jsxs)("span",{className:"text-[10px] font-medium text-text-muted uppercase tracking-wider flex items-center gap-1.5",children:[(0,s.jsx)(ee,{}),"Recent"]})}),(0,s.jsx)("div",{className:"py-1",children:r.map((e,t)=>(0,s.jsx)(Q,{project:e,index:t,isActive:(null==a?void 0:a.id)===e.id,isFocused:c===t,formatProjectName:b,buttonRefs:u,onSelect:()=>{o(e),l(!1)}},e.id))})]}),p.length>0&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("div",{className:"px-3 py-1.5 bg-bg-tertiary/50",children:(0,s.jsx)("span",{className:"text-[10px] font-medium text-text-muted uppercase tracking-wider",children:r.length>0?"All Projects":"Projects"})}),(0,s.jsx)("div",{className:"py-1",children:p.map((e,t)=>{let n=r.length+t;return(0,s.jsx)(Q,{project:e,index:n,isActive:(null==a?void 0:a.id)===e.id,isFocused:c===n,formatProjectName:b,buttonRefs:u,onSelect:()=>{o(e),l(!1)}},e.id)})})]})]})]})]})}function Q(e){var t,r;let{project:n,index:a,isActive:o,isFocused:i,formatProjectName:l,buttonRefs:c,onSelect:d}=e,x=l(n),u=(null===(t=n.agents)||void 0===t?void 0:t.length)||0;return(0,s.jsxs)("button",{ref:e=>{c.current[a]=e},className:"w-full flex items-center gap-3 px-3 py-2.5 text-left transition-colors border-none cursor-pointer ".concat(o?"bg-accent-cyan/10 text-accent-cyan":i?"bg-bg-hover text-text-primary":"bg-transparent text-text-primary hover:bg-bg-hover"),onClick:d,role:"option","aria-selected":o,tabIndex:i?0:-1,children:[(0,s.jsx)(et,{className:o?"text-accent-cyan":"text-text-muted"}),(0,s.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,s.jsx)("div",{className:"font-medium text-sm truncate",children:x}),(0,s.jsx)("div",{className:"text-xs text-text-muted truncate",children:n.path})]}),(0,s.jsxs)("span",{className:"text-xs px-2 py-0.5 rounded-full ".concat(o?"bg-accent-cyan/20 text-accent-cyan":"bg-bg-tertiary text-text-muted"),children:[u," ",1===u?"agent":"agents"]}),(null===(r=n.lead)||void 0===r?void 0:r.connected)&&(0,s.jsx)("span",{className:"w-2 h-2 rounded-full bg-success animate-pulse",title:"Lead: ".concat(n.lead.name)}),o&&(0,s.jsx)(es,{})]})}function ee(){return(0,s.jsxs)("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,s.jsx)("circle",{cx:"12",cy:"12",r:"10"}),(0,s.jsx)("polyline",{points:"12 6 12 12 16 14"})]})}function et(e){let{className:t="text-text-muted"}=e;return(0,s.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:(0,s.jsx)("path",{d:"M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z"})})}function er(e){let{isOpen:t}=e;return(0,s.jsx)("svg",{className:"text-text-muted transition-transform duration-150 ".concat(t?"rotate-180":""),width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:(0,s.jsx)("polyline",{points:"6 9 12 15 18 9"})})}function es(){return(0,s.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",className:"text-accent-cyan",children:(0,s.jsx)("polyline",{points:"20 6 9 17 4 12"})})}var en=r(9165);let ea={autoRefresh:!0,refreshInterval:3e4,autoWakeup:!1,onStatusChange:()=>{}};function eo(e){let{expanded:t=!1,autoWakeup:r=!1,onWakeup:a,onStatusChange:o,className:i=""}=e,[l,c]=(0,n.useState)(!1),[d,x]=(0,n.useState)(""),{workspace:u,exists:m,isLoading:h,isWakingUp:p,statusMessage:g,actionNeeded:b,wakeup:f}=function(){var e,t,r,s,a;let o=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},i=null!==(e=o.autoRefresh)&&void 0!==e?e:ea.autoRefresh,l=null!==(t=o.refreshInterval)&&void 0!==t?t:ea.refreshInterval,c=null!==(r=o.autoWakeup)&&void 0!==r?r:ea.autoWakeup,d=(0,n.useRef)(null!==(s=o.onStatusChange)&&void 0!==s?s:ea.onStatusChange);d.current=null!==(a=o.onStatusChange)&&void 0!==a?a:ea.onStatusChange;let[x,u]=(0,n.useState)(null),[m,h]=(0,n.useState)(!1),[p,g]=(0,n.useState)(!0),[b,f]=(0,n.useState)(!1),[j,y]=(0,n.useState)(""),[v,w]=(0,n.useState)(null),[N,k]=(0,n.useState)(null),C=(0,n.useRef)(null),S=(0,n.useRef)(!0),A=(0,n.useRef)(null),L=(0,n.useCallback)(async()=>{try{g(!0),k(null);let e=await en.xv.getPrimaryWorkspace();if(!S.current)return;if(e.success){if(h(e.data.exists),y(e.data.statusMessage),w(e.data.actionNeeded||null),e.data.workspace){let t=e.data.workspace;u(t),A.current&&A.current!==t.status&&d.current(t.status,!1),A.current=t.status}else u(null)}else k(e.error)}catch(e){S.current&&k("Failed to fetch workspace status")}finally{S.current&&g(!1)}},[]),E=(0,n.useRef)(l);E.current=l;let W=(0,n.useRef)(i);W.current=i;let D=(0,n.useCallback)(async()=>{if(!(null==x?void 0:x.id))return{success:!1,message:"No workspace to wake up"};try{f(!0),k(null);let e=await en.xv.wakeupWorkspace(x.id);if(!S.current)return{success:!1,message:"Component unmounted"};if(e.success)return e.data.wasRestarted&&(y(e.data.message),w(null),d.current("starting",!0),C.current&&clearInterval(C.current),C.current=setInterval(L,5e3),setTimeout(()=>{S.current&&C.current&&(clearInterval(C.current),W.current&&(C.current=setInterval(L,E.current)))},12e4)),{success:!0,message:e.data.message};return k(e.error),{success:!1,message:e.error}}catch(t){let e=t instanceof Error?t.message:"Failed to wake up workspace";return S.current&&k(e),{success:!1,message:e}}finally{S.current&&f(!1)}},[null==x?void 0:x.id,L]);return(0,n.useEffect)(()=>(S.current=!0,L(),()=>{S.current=!1}),[L]),(0,n.useEffect)(()=>{if(i)return C.current=setInterval(L,l),()=>{C.current&&(clearInterval(C.current),C.current=null)}},[i,l,L]),(0,n.useEffect)(()=>{c&&(null==x?void 0:x.isStopped)&&!b&&D()},[c,null==x?void 0:x.isStopped,b,D]),{workspace:x,exists:m,isLoading:p,isWakingUp:b,statusMessage:j,actionNeeded:v,error:N,refresh:L,wakeup:D}}({autoWakeup:r,onStatusChange:(e,t)=>{null==o||o(e),t?(x("Workspace is starting up..."),c(!0),setTimeout(()=>c(!1),5e3)):"running"===e&&(x("Workspace is ready!"),c(!0),setTimeout(()=>c(!1),3e3))}}),j=(0,n.useCallback)(async()=>{let e=await f();e.success&&(null==a||a(),x(e.message),c(!0),setTimeout(()=>c(!1),5e3))},[f,a]),y=m?h&&!u?{color:"text-text-muted",bgColor:"bg-bg-tertiary",borderColor:"border-border-subtle",icon:(0,s.jsx)(eu,{}),label:"Loading...",pulseColor:null}:(null==u?void 0:u.isRunning)?{color:"text-success",bgColor:"bg-success/10",borderColor:"border-success/30",icon:(0,s.jsx)(ei,{}),label:"Running",pulseColor:"bg-success"}:(null==u?void 0:u.isStopped)?{color:"text-amber-400",bgColor:"bg-amber-400/10",borderColor:"border-amber-400/30",icon:(0,s.jsx)(el,{}),label:"Stopped",pulseColor:null}:(null==u?void 0:u.isProvisioning)||p?{color:"text-accent-cyan",bgColor:"bg-accent-cyan/10",borderColor:"border-accent-cyan/30",icon:(0,s.jsx)(ec,{}),label:p?"Starting...":"Provisioning",pulseColor:"bg-accent-cyan"}:(null==u?void 0:u.hasError)?{color:"text-error",bgColor:"bg-error/10",borderColor:"border-error/30",icon:(0,s.jsx)(ed,{}),label:"Error",pulseColor:null}:{color:"text-text-muted",bgColor:"bg-bg-tertiary",borderColor:"border-border-subtle",icon:(0,s.jsx)(ex,{}),label:"Unknown",pulseColor:null}:{color:"text-text-muted",bgColor:"bg-bg-tertiary",borderColor:"border-border-subtle",icon:(0,s.jsx)(ex,{}),label:"No workspace",pulseColor:null};return t?(0,s.jsxs)("div",{className:"rounded-lg border ".concat(y.borderColor," ").concat(y.bgColor," p-4 ").concat(i),children:[(0,s.jsxs)("div",{className:"flex items-center justify-between mb-3",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)("span",{className:y.color,children:y.icon}),(0,s.jsx)("span",{className:"text-sm font-semibold ".concat(y.color),children:"Workspace Status"})]}),y.pulseColor&&(0,s.jsx)("span",{className:"w-2.5 h-2.5 rounded-full ".concat(y.pulseColor," animate-pulse")})]}),(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between",children:[(0,s.jsx)("span",{className:"text-xs text-text-muted",children:"Name"}),(0,s.jsx)("span",{className:"text-sm text-text-primary font-medium truncate max-w-[150px]",children:(null==u?void 0:u.name)||"None"})]}),(0,s.jsxs)("div",{className:"flex items-center justify-between",children:[(0,s.jsx)("span",{className:"text-xs text-text-muted",children:"Status"}),(0,s.jsx)("span",{className:"text-sm font-medium ".concat(y.color),children:y.label})]}),g&&(0,s.jsx)("p",{className:"text-xs text-text-muted mt-2",children:g}),"wakeup"===b&&!p&&(0,s.jsx)("button",{onClick:j,className:"w-full mt-3 px-3 py-2 text-sm font-medium text-amber-400 bg-amber-400/10 border border-amber-400/30 rounded-lg hover:bg-amber-400/20 transition-colors",children:"Wake up workspace"}),"check_error"===b&&(0,s.jsx)("a",{href:"/workspaces/".concat(null==u?void 0:u.id),className:"block w-full mt-3 px-3 py-2 text-sm font-medium text-center text-error bg-error/10 border border-error/30 rounded-lg hover:bg-error/20 transition-colors no-underline",children:"View error details"})]}),l&&(0,s.jsx)("div",{className:"mt-3 px-3 py-2 bg-bg-card border border-border-medium rounded-lg text-sm text-text-primary animate-in fade-in",children:d})]}):(0,s.jsxs)("div",{className:"relative ".concat(i),children:[(0,s.jsxs)("div",{className:"flex items-center gap-2 px-2.5 py-1.5 rounded-lg border ".concat(y.bgColor," ").concat(y.borderColor," cursor-default"),title:g||y.label,children:[(0,s.jsx)("span",{className:y.color,children:y.icon}),(0,s.jsx)("span",{className:"text-xs font-medium ".concat(y.color),children:y.label}),y.pulseColor&&(0,s.jsx)("span",{className:"w-2 h-2 rounded-full ".concat(y.pulseColor," animate-pulse")})]}),"wakeup"===b&&!p&&(0,s.jsx)("button",{onClick:j,className:"ml-2 px-2 py-1 text-xs font-medium text-amber-400 bg-amber-400/10 border border-amber-400/30 rounded hover:bg-amber-400/20 transition-colors",children:"Wake up"}),l&&(0,s.jsx)("div",{className:"absolute top-full mt-2 left-0 z-50 px-3 py-2 bg-bg-card border border-border-medium rounded-lg shadow-lg text-sm text-text-primary whitespace-nowrap animate-in fade-in slide-in-from-top-2",children:d})]})}function ei(){return(0,s.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:(0,s.jsx)("polygon",{points:"5 3 19 12 5 21 5 3"})})}function el(){return(0,s.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:(0,s.jsx)("rect",{x:"6",y:"6",width:"12",height:"12"})})}function ec(){return(0,s.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"animate-spin",children:(0,s.jsx)("path",{d:"M21 12a9 9 0 1 1-6.219-8.56"})})}function ed(){return(0,s.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,s.jsx)("circle",{cx:"12",cy:"12",r:"10"}),(0,s.jsx)("line",{x1:"15",y1:"9",x2:"9",y2:"15"}),(0,s.jsx)("line",{x1:"9",y1:"9",x2:"15",y2:"15"})]})}function ex(){return(0,s.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,s.jsx)("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",ry:"2"}),(0,s.jsx)("line",{x1:"12",y1:"8",x2:"12",y2:"16"}),(0,s.jsx)("line",{x1:"8",y1:"12",x2:"16",y2:"12"})]})}function eu(){return(0,s.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"animate-spin",children:[(0,s.jsx)("circle",{cx:"12",cy:"12",r:"10",strokeOpacity:"0.25"}),(0,s.jsx)("path",{d:"M12 2a10 10 0 0 1 10 10"})]})}function em(e){let{currentChannel:t,selectedAgent:r,projects:n=[],currentProject:o,recentProjects:i=[],onProjectChange:c,onCommandPaletteOpen:d,onSettingsClick:x,onHistoryClick:u,onNewConversationClick:m,onCoordinatorClick:h,onFleetClick:p,isFleetViewActive:g,onTrajectoryClick:b,hasActiveTrajectory:f,onMenuClick:j,hasUnreadNotifications:y}=e,v="general"===t,w=r?(0,a.GW)(r.name):null,N=n.length>1;return(0,s.jsxs)("header",{className:"h-[52px] bg-bg-secondary border-b border-border-subtle flex items-center justify-between px-4",children:[(0,s.jsxs)("button",{className:"hidden max-md:flex items-center justify-center w-11 h-11 bg-transparent border-none text-text-primary cursor-pointer rounded-lg transition-colors hover:bg-bg-hover relative",onClick:j,"aria-label":"Open menu",children:[(0,s.jsx)(ev,{}),y&&(0,s.jsx)("span",{className:"absolute top-1.5 right-1.5 w-2.5 h-2.5 bg-error rounded-full animate-pulse shadow-[0_0_8px_rgba(239,68,68,0.6)]"})]}),n.length>0&&c&&(0,s.jsx)("div",{className:"max-md:hidden mr-3",children:(0,s.jsx)(Z,{projects:n,recentProjects:i,currentProject:null!=o?o:null,onProjectChange:c})}),n.length>0&&c&&(0,s.jsx)("div",{className:"w-px h-6 bg-border-subtle mr-3 max-md:hidden"}),(0,s.jsx)(eo,{className:"max-md:hidden mr-3"}),(0,s.jsx)("div",{className:"w-px h-6 bg-border-subtle mr-3 max-md:hidden"}),(0,s.jsx)("div",{className:"flex items-center gap-3 flex-1 min-w-0",children:v?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("span",{className:"text-accent-cyan text-lg font-mono",children:"#"}),(0,s.jsx)("span",{className:"font-display font-semibold text-base text-text-primary max-md:max-w-[150px] max-md:truncate",children:"general"}),(0,s.jsx)("span",{className:"text-text-muted text-sm ml-2 pl-3 border-l border-border-subtle max-md:hidden",children:"All agent communications"})]}):r?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("div",{className:"w-8 h-8 rounded-lg flex items-center justify-center font-semibold text-xs border-2",style:{backgroundColor:null==w?void 0:w.primary,borderColor:null==w?void 0:w.primary,boxShadow:"0 0 12px ".concat(null==w?void 0:w.primary,"40")},children:(0,s.jsx)("span",{style:{color:null==w?void 0:w.text},children:(0,a.hP)(r.name)})}),(0,s.jsxs)("div",{className:"flex flex-col",children:[(0,s.jsx)("span",{className:"font-display font-semibold text-base text-text-primary max-md:max-w-[150px] max-md:truncate",children:r.name}),(0,s.jsx)("span",{className:"text-text-muted text-xs font-mono max-md:hidden",children:l(r.name)})]}),r.status&&(0,s.jsx)("span",{className:"text-xs py-1 px-2.5 rounded-full font-medium ml-2 ".concat("online"===r.status?"bg-success/20 text-success":"bg-bg-tertiary text-text-muted"),children:r.status})]}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("span",{className:"text-accent-cyan text-lg font-mono",children:"@"}),(0,s.jsx)("span",{className:"font-display font-semibold text-base text-text-primary",children:t})]})}),(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsxs)("button",{className:"flex items-center gap-2 py-2 px-4 bg-gradient-to-r from-accent-cyan to-[#00b8d9] text-bg-deep font-semibold border-none rounded-lg text-sm cursor-pointer transition-all duration-150 hover:shadow-glow-cyan hover:-translate-y-0.5",onClick:m,title:"Start new conversation (⌘N)",children:[(0,s.jsx)(eh,{}),(0,s.jsx)("span",{className:"max-md:hidden",children:"New Message"})]}),(0,s.jsxs)("button",{className:"flex items-center gap-2 py-2 px-3 bg-bg-tertiary border border-border-subtle rounded-lg text-text-secondary text-sm cursor-pointer transition-all duration-150 hover:bg-bg-elevated hover:border-border-medium hover:text-text-primary",onClick:d,title:"Command Palette (⌘K)",children:[(0,s.jsx)(ep,{}),(0,s.jsx)("span",{className:"max-md:hidden",children:"Search"}),(0,s.jsx)("kbd",{className:"bg-bg-card border border-border-subtle rounded px-1.5 py-0.5 text-xs text-text-muted font-mono max-md:hidden",children:"⌘K"})]}),(0,s.jsx)("button",{className:"flex items-center justify-center p-2 bg-bg-tertiary border border-border-subtle rounded-lg text-text-secondary cursor-pointer transition-all duration-150 hover:bg-bg-elevated hover:border-border-medium hover:text-accent-cyan",onClick:u,title:"Message History",children:(0,s.jsx)(eg,{})}),N&&(0,s.jsx)("button",{className:"flex items-center justify-center p-2 bg-bg-tertiary border border-border-subtle rounded-lg text-text-secondary cursor-pointer transition-all duration-150 hover:bg-bg-elevated hover:border-border-medium hover:text-accent-purple",onClick:h,title:"Coordinator Agent",children:(0,s.jsx)(ew,{})}),p&&(0,s.jsx)("button",{className:"flex items-center justify-center p-2 border rounded-lg cursor-pointer transition-all duration-150 ".concat(g?"bg-accent-cyan/20 border-accent-cyan text-accent-cyan":"bg-bg-tertiary border-border-subtle text-text-secondary hover:bg-bg-elevated hover:border-border-medium hover:text-accent-cyan"),onClick:p,title:g?"Back to Chat":"Fleet Overview",children:(0,s.jsx)(ef,{})}),b&&(0,s.jsxs)("button",{className:"flex items-center justify-center p-2 border rounded-lg cursor-pointer transition-all duration-150 relative ".concat(f?"bg-accent-cyan/20 border-accent-cyan text-accent-cyan":"bg-bg-tertiary border-border-subtle text-text-secondary hover:bg-bg-elevated hover:border-border-medium hover:text-accent-cyan"),onClick:b,title:"Trajectory Viewer",children:[(0,s.jsx)(ej,{}),f&&(0,s.jsx)("span",{className:"absolute -top-1 -right-1 w-2 h-2 bg-accent-cyan rounded-full animate-pulse"})]}),(0,s.jsx)("a",{href:"/metrics",className:"flex items-center justify-center p-2 bg-bg-tertiary border border-border-subtle rounded-lg text-text-secondary cursor-pointer transition-all duration-150 hover:bg-bg-elevated hover:border-border-medium hover:text-accent-orange no-underline",title:"Fleet Metrics",children:(0,s.jsx)(eb,{})}),(0,s.jsx)("button",{className:"flex items-center justify-center p-2 bg-bg-tertiary border border-border-subtle rounded-lg text-text-secondary cursor-pointer transition-all duration-150 hover:bg-bg-elevated hover:border-border-medium hover:text-accent-purple",onClick:x,title:"Settings",children:(0,s.jsx)(ey,{})})]})]})}function eh(){return(0,s.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:[(0,s.jsx)("path",{d:"M12 20h9"}),(0,s.jsx)("path",{d:"M16.5 3.5a2.121 2.121 0 0 1 3 3L7 19l-4 1 1-4L16.5 3.5z"})]})}function ep(){return(0,s.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,s.jsx)("circle",{cx:"11",cy:"11",r:"8"}),(0,s.jsx)("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]})}function eg(){return(0,s.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,s.jsx)("circle",{cx:"12",cy:"12",r:"10"}),(0,s.jsx)("polyline",{points:"12 6 12 12 16 14"})]})}function eb(){return(0,s.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,s.jsx)("path",{d:"M3 3v18h18"}),(0,s.jsx)("path",{d:"M18 17V9"}),(0,s.jsx)("path",{d:"M13 17V5"}),(0,s.jsx)("path",{d:"M8 17v-3"})]})}function ef(){return(0,s.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,s.jsx)("rect",{x:"2",y:"3",width:"20",height:"14",rx:"2",ry:"2"}),(0,s.jsx)("line",{x1:"8",y1:"21",x2:"16",y2:"21"}),(0,s.jsx)("line",{x1:"12",y1:"17",x2:"12",y2:"21"})]})}function ej(){return(0,s.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:(0,s.jsx)("path",{d:"M3 12h4l3 9 4-18 3 9h4"})})}function ey(){return(0,s.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,s.jsx)("circle",{cx:"12",cy:"12",r:"3"}),(0,s.jsx)("path",{d:"M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-2 2 2 2 0 0 1-2-2v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1-2-2 2 2 0 0 1 2-2h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 2-2 2 2 0 0 1 2 2v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 2 2 2 2 0 0 1-2 2h-.09a1.65 1.65 0 0 0-1.51 1z"})]})}function ev(){return(0,s.jsxs)("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,s.jsx)("line",{x1:"3",y1:"12",x2:"21",y2:"12"}),(0,s.jsx)("line",{x1:"3",y1:"6",x2:"21",y2:"6"}),(0,s.jsx)("line",{x1:"3",y1:"18",x2:"21",y2:"18"})]})}function ew(){return(0,s.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,s.jsx)("circle",{cx:"12",cy:"12",r:"3"}),(0,s.jsx)("circle",{cx:"5",cy:"5",r:"2"}),(0,s.jsx)("circle",{cx:"19",cy:"5",r:"2"}),(0,s.jsx)("circle",{cx:"5",cy:"19",r:"2"}),(0,s.jsx)("circle",{cx:"19",cy:"19",r:"2"}),(0,s.jsx)("line",{x1:"9.5",y1:"9.5",x2:"6.5",y2:"6.5"}),(0,s.jsx)("line",{x1:"14.5",y1:"9.5",x2:"17.5",y2:"6.5"}),(0,s.jsx)("line",{x1:"9.5",y1:"14.5",x2:"6.5",y2:"17.5"}),(0,s.jsx)("line",{x1:"14.5",y1:"14.5",x2:"17.5",y2:"17.5"})]})}var eN=r(2500),ek=r(9880);function eC(e){let{status:t,size:r="small"}=e;if(!t)return null;let n={small:"w-3.5 h-3.5",medium:"w-4 h-4"}[r];return"sending"===t||"unread"===t?(0,s.jsx)("span",{className:"inline-flex items-center justify-center ".concat(n," text-text-muted"),title:"Sending...",children:(0,s.jsx)(eS,{className:n})}):"acked"===t||"read"===t?(0,s.jsx)("span",{className:"inline-flex items-center justify-center ".concat(n," text-success"),title:"Delivered",children:(0,s.jsx)(eA,{className:n})}):"failed"===t?(0,s.jsx)("span",{className:"inline-flex items-center justify-center ".concat(n," text-error"),title:"Delivery failed",children:(0,s.jsx)(eL,{className:n})}):null}function eS(e){let{className:t}=e;return(0,s.jsxs)("svg",{className:"animate-pulse ".concat(t),viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[(0,s.jsx)("circle",{cx:"8",cy:"8",r:"6"}),(0,s.jsx)("path",{d:"M8 5v3l2 1",strokeLinecap:"round",strokeLinejoin:"round"})]})}function eA(e){let{className:t}=e;return(0,s.jsx)("svg",{className:t,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",children:(0,s.jsx)("path",{d:"M3 8l3 3 7-7",strokeLinecap:"round",strokeLinejoin:"round"})})}function eL(e){let{className:t}=e;return(0,s.jsxs)("svg",{className:t,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,s.jsx)("circle",{cx:"8",cy:"8",r:"6"}),(0,s.jsx)("line",{x1:"8",y1:"5",x2:"8",y2:"8",strokeLinecap:"round"}),(0,s.jsx)("circle",{cx:"8",cy:"11",r:"0.5",fill:"currentColor",stroke:"none"})]})}let eE={claude:{icon:"◈",color:"#00d9ff"},codex:{icon:"⬡",color:"#ff6b35"},gemini:{icon:"◇",color:"#a855f7"},openai:{icon:"◆",color:"#10a37f"},default:{icon:"●",color:"#00d9ff"}};function eW(e){let{messages:t,currentChannel:r,onThreadClick:a,highlightedMessageId:o,currentThread:i,agents:l=[],currentUser:c}=e,d=new Map;for(let e of l)e.isProcessing&&d.set(e.name,{isProcessing:!0,processingStartedAt:e.processingStartedAt});let x=new Map,u=(0,n.useRef)(null),[m,h]=(0,n.useState)(!0),p=(0,n.useRef)(0),g=(0,n.useRef)(r),b=(0,n.useRef)(!1),f=(0,n.useRef)(!1),j=t.filter(e=>i?e.id===i||e.thread===i:"general"===r?"*"===e.to||e.isBroadcast||"general"===e.channel:e.from===r||e.to===r);for(let e of j)("Dashboard"===e.from||c&&e.from===c.displayName)&&"*"!==e.to&&x.set(e.to,e.id);let y=j.length;if(y>p.current){let e=j[j.length-1],t=(null==e?void 0:e.from)==="Dashboard"||c&&(null==e?void 0:e.from)===c.displayName;(t||m)&&(b.current=!0,t&&!m&&h(!0))}p.current=y;let v=(0,n.useCallback)(()=>{if(!u.current||f.current)return;let e=u.current,t=e.scrollHeight-e.scrollTop-e.clientHeight;t<50&&!m?h(!0):t>150&&m&&h(!1)},[m]);return((0,n.useLayoutEffect)(()=>{if(b.current&&u.current){b.current=!1,f.current=!0;let e=u.current;e.scrollTop=e.scrollHeight,requestAnimationFrame(()=>{setTimeout(()=>{f.current=!1},50)})}},[j.length]),(0,n.useLayoutEffect)(()=>{if(r!==g.current&&(g.current=r,p.current=j.length,h(!0),u.current)){f.current=!0;let e=u.current;e.scrollTop=e.scrollHeight,requestAnimationFrame(()=>{setTimeout(()=>{f.current=!1},50)})}},[r,j.length]),0===j.length)?(0,s.jsxs)("div",{className:"flex flex-col items-center justify-center h-full text-text-muted text-center",children:[(0,s.jsx)(e_,{}),(0,s.jsx)("h3",{className:"m-0 mb-2 text-base font-display text-text-secondary",children:"No messages yet"}),(0,s.jsx)("p",{className:"m-0 text-sm",children:"general"===r?"Broadcast messages will appear here":"Messages with ".concat(r," will appear here")})]}):(0,s.jsx)("div",{className:"flex flex-col gap-1 p-4 bg-bg-secondary h-full overflow-y-auto",ref:u,onScroll:v,children:j.map(e=>{let t=("Dashboard"===e.from||c&&e.from===c.displayName)&&"*"!==e.to&&x.get(e.to)===e.id?d.get(e.to):void 0;return(0,s.jsx)(eD,{message:e,isHighlighted:e.id===o,onThreadClick:a,recipientProcessing:t,currentUser:c},e.id)})})}function eD(e){let{message:t,isHighlighted:r,onThreadClick:a,recipientProcessing:o,currentUser:i}=e,l=function(e){let t=new Date(e),r=new Date;if(t.toDateString()===r.toDateString())return t.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"});let s=new Date(r);return(s.setDate(s.getDate()-1),t.toDateString()===s.toDateString())?"Yesterday ".concat(t.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})):t.toLocaleDateString([],{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}(t.timestamp),c="Dashboard"===t.from||i&&t.from===i.displayName,d=c&&i?{icon:"",color:"#a855f7"}:function(e){let t=e.toLowerCase();if(t.includes("claude")||t.includes("anthropic"))return eE.claude;if(t.includes("codex")||t.includes("openai")||t.includes("gpt"))return eE.codex;if(t.includes("gemini")||t.includes("google")||t.includes("bard"))return eE.gemini;let r=e.split("").reduce((e,t)=>e+t.charCodeAt(0),0),s=Object.keys(eE).filter(e=>"default"!==e);return eE[s[r%s.length]]}(t.from),x=c&&i?i.displayName:t.from,m=t.replyCount&&t.replyCount>0,h=c&&("acked"===t.status||"read"===t.status)&&(null==o?void 0:o.isProcessing);return(0,s.jsxs)("div",{className:"\n group flex gap-3 py-3 px-4 rounded-xl transition-all duration-150\n hover:bg-bg-card/50\n ".concat(r?"bg-warning-light/20 border-l-2 border-l-warning pl-3":"","\n "),children:[c&&(null==i?void 0:i.avatarUrl)?(0,s.jsx)("img",{src:i.avatarUrl,alt:x,className:"shrink-0 w-10 h-10 rounded-xl border-2 object-cover",style:{borderColor:d.color,boxShadow:"0 0 16px ".concat(d.color,"30")}}):(0,s.jsx)("div",{className:"shrink-0 w-10 h-10 rounded-xl flex items-center justify-center text-lg font-medium border-2",style:{backgroundColor:"".concat(d.color,"15"),borderColor:d.color,color:d.color,boxShadow:"0 0 16px ".concat(d.color,"30")},children:d.icon}),(0,s.jsxs)("div",{className:"flex-1 min-w-0 overflow-hidden",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2 mb-1.5 flex-wrap",children:[(0,s.jsx)("span",{className:"font-display font-semibold text-sm",style:{color:d.color},children:x}),"*"!==t.to&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("span",{className:"text-text-dim text-xs",children:"→"}),(0,s.jsx)("span",{className:"font-medium text-sm text-accent-cyan",children:t.to})]}),t.thread&&(0,s.jsx)("span",{className:"text-xs py-0.5 px-2 rounded-full font-mono font-medium bg-accent-purple/20 text-accent-purple",children:t.thread}),"*"===t.to&&(0,s.jsx)("span",{className:"text-xs py-0.5 px-2 rounded-full uppercase font-medium bg-warning/20 text-warning",children:"broadcast"}),(0,s.jsx)("span",{className:"text-text-dim text-xs ml-auto font-mono",children:l}),c&&(0,s.jsx)(eC,{status:t.status,size:"small"}),h&&(0,s.jsx)(u,{isProcessing:!0,processingStartedAt:null==o?void 0:o.processingStartedAt,size:"small",showLabel:!0}),(0,s.jsxs)("button",{className:"\n inline-flex items-center gap-1.5 p-1.5 rounded-lg transition-all duration-150 cursor-pointer border-none\n ".concat(m||t.thread?"text-accent-cyan bg-accent-cyan/10 hover:bg-accent-cyan/20":"text-text-muted bg-transparent opacity-0 group-hover:opacity-100 hover:text-accent-cyan hover:bg-accent-cyan/10","\n "),onClick:()=>null==a?void 0:a(t.thread||t.id),title:t.thread?"View thread: ".concat(t.thread):m?"".concat(t.replyCount," ").concat(1===t.replyCount?"reply":"replies"):"Reply in thread",children:[(0,s.jsx)(eI,{}),m&&(0,s.jsx)("span",{className:"text-xs font-medium",children:t.replyCount})]})]}),(0,s.jsx)("div",{className:"text-sm leading-relaxed text-text-primary whitespace-pre-wrap break-words",children:function(e){let t=e.replace(/\\n/g,"\n").replace(/\r\n/g,"\n").replace(/\r/g,"\n"),r=function(e){let t;let r=[],s=/```(\w*)\n([\s\S]*?)```/g,n=0;for(;null!==(t=s.exec(e));){if(t.index>n){let s=eP(e.slice(n,t.index));r.push(...s)}r.push({type:"code",language:t[1]||"text",content:t[2]}),n=t.index+t[0].length}if(n<e.length){let t=eP(e.slice(n));r.push(...t)}return 0===r.length?eP(e):r}(t);return 1===r.length&&"text"===r[0].type?t.split("\n").map((e,t)=>(0,s.jsxs)(n.Fragment,{children:[t>0&&(0,s.jsx)("br",{}),eB(e)]},t)):r.map((e,t)=>{if("code"===e.type)return(0,s.jsx)(eR,{code:e.content,language:e.language||"text"},t);if("table"===e.type)return(0,s.jsx)("pre",{className:"font-mono text-xs leading-relaxed whitespace-pre overflow-x-auto my-2 p-3 bg-bg-tertiary/50 rounded-lg border border-border-subtle",children:e.content},t);let r=e.content.split("\n");return(0,s.jsx)("span",{children:r.map((e,t)=>(0,s.jsxs)(n.Fragment,{children:[t>0&&(0,s.jsx)("br",{}),eB(e)]},t))},t)})}(t.content)}),t.attachments&&t.attachments.length>0&&(0,s.jsx)(eM,{attachments:t.attachments})]})]})}function eM(e){let{attachments:t}=e,[r,a]=(0,n.useState)(null),o=t.filter(e=>e.mimeType.startsWith("image/"));return 0===o.length?null:(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("div",{className:"flex flex-wrap gap-2 mt-2",children:o.map(e=>(0,s.jsxs)("button",{type:"button",onClick:()=>a(e),className:"relative group cursor-pointer bg-transparent border-0 p-0",title:"View ".concat(e.filename),children:[(0,s.jsx)("img",{src:e.data||e.url,alt:e.filename,className:"max-h-48 max-w-xs rounded-lg border border-border-subtle object-cover transition-all duration-150 group-hover:border-accent-cyan/50 group-hover:shadow-[0_0_8px_rgba(0,217,255,0.2)]",loading:"lazy"}),(0,s.jsx)("div",{className:"absolute inset-0 bg-black/0 group-hover:bg-black/10 rounded-lg transition-colors flex items-center justify-center opacity-0 group-hover:opacity-100",children:(0,s.jsxs)("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"white",strokeWidth:"2",className:"drop-shadow-lg",children:[(0,s.jsx)("circle",{cx:"11",cy:"11",r:"8"}),(0,s.jsx)("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"}),(0,s.jsx)("line",{x1:"11",y1:"8",x2:"11",y2:"14"}),(0,s.jsx)("line",{x1:"8",y1:"11",x2:"14",y2:"11"})]})})]},e.id))}),r&&(0,s.jsx)("div",{className:"fixed inset-0 z-[9999] flex items-center justify-center bg-black/80 backdrop-blur-sm",onClick:()=>a(null),children:(0,s.jsxs)("div",{className:"relative max-w-[90vw] max-h-[90vh]",children:[(0,s.jsx)("img",{src:r.data||r.url,alt:r.filename,className:"max-w-full max-h-[90vh] rounded-lg shadow-2xl",onClick:e=>e.stopPropagation()}),(0,s.jsx)("button",{type:"button",onClick:()=>a(null),className:"absolute -top-3 -right-3 w-8 h-8 bg-bg-tertiary border border-border-subtle rounded-full flex items-center justify-center text-text-muted hover:text-text-primary hover:bg-bg-card transition-colors shadow-lg",title:"Close",children:(0,s.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,s.jsx)("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),(0,s.jsx)("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})}),(0,s.jsx)("div",{className:"absolute bottom-0 left-0 right-0 p-3 bg-gradient-to-t from-black/60 to-transparent rounded-b-lg",children:(0,s.jsx)("p",{className:"text-white text-sm truncate",children:r.filename})})]})})]})}let eT={...ek.Z,'pre[class*="language-"]':{...ek.Z['pre[class*="language-"]'],background:"rgba(15, 23, 42, 0.8)",margin:"0.5rem 0",padding:"1rem",borderRadius:"0.5rem",border:"1px solid rgba(148, 163, 184, 0.1)",fontSize:"0.75rem",lineHeight:"1.5"},'code[class*="language-"]':{...ek.Z['code[class*="language-"]'],background:"transparent",fontSize:"0.75rem"}};function eR(e){let{code:t,language:r}=e,[a,o]=(0,n.useState)(!1),i=(0,n.useCallback)(async()=>{try{await navigator.clipboard.writeText(t),o(!0),setTimeout(()=>o(!1),2e3)}catch(e){console.error("Failed to copy:",e)}},[t]),l=r.toLowerCase().replace(/^(js|jsx)$/,"javascript").replace(/^(ts|tsx)$/,"typescript").replace(/^(py)$/,"python").replace(/^(rb)$/,"ruby").replace(/^(sh|shell|zsh)$/,"bash");return(0,s.jsxs)("div",{className:"relative group my-2",children:[(0,s.jsxs)("div",{className:"absolute top-2 right-2 flex items-center gap-2 z-10",children:[r&&"text"!==r&&(0,s.jsx)("span",{className:"text-xs px-2 py-0.5 rounded bg-accent-cyan/20 text-accent-cyan font-mono",children:r}),(0,s.jsx)("button",{onClick:i,className:"opacity-0 group-hover:opacity-100 transition-opacity text-xs px-2 py-1 rounded bg-bg-tertiary hover:bg-bg-card text-text-muted hover:text-text-primary border border-border-subtle",title:"Copy code",children:a?"✓ Copied":"Copy"})]}),(0,s.jsx)(eN.Z,{language:l,style:eT,customStyle:{margin:0,background:"rgba(15, 23, 42, 0.8)"},showLineNumbers:t.split("\n").length>3,lineNumberStyle:{minWidth:"2.5em",paddingRight:"1em",color:"rgba(148, 163, 184, 0.4)",userSelect:"none"},children:t.trim()})]})}function eP(e){let t=e.split("\n"),r=[],s=null;for(let e of t){let t=(e.match(/\|/g)||[]).length>=2||e.trim().startsWith("|")&&e.trim().endsWith("|")||/^[\s|:-]+$/.test(e)&&e.includes("-")&&e.includes("|")?"table":"text";s&&s.type===t?s.content+="\n"+e:(s&&r.push(s),s={type:t,content:e})}return s&&r.push(s),r}function eB(e){return e.split(/(`[^`]+`|https?:\/\/[^\s]+)/g).map((e,t)=>{if(!e)return null;if(e.startsWith("`")&&e.endsWith("`")&&e.length>2){let r=e.slice(1,-1);return(0,s.jsx)("code",{className:"px-1.5 py-0.5 mx-0.5 rounded bg-bg-elevated/80 text-accent-cyan font-mono text-[0.85em] border border-border-subtle/50",children:r},t)}return/^https?:\/\//.test(e)?(0,s.jsx)("a",{href:e,target:"_blank",rel:"noopener noreferrer",className:"text-accent-cyan no-underline hover:underline",children:e},t):e})}function e_(){return(0,s.jsx)("svg",{className:"mb-4 opacity-50 text-text-muted",width:"48",height:"48",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:(0,s.jsx)("path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})})}function eI(){return(0,s.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:(0,s.jsx)("path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})})}function eU(e){let{originalMessage:t,replies:r,onClose:a,onReply:o,isSending:i=!1,currentUser:l}=e,[c,d]=(0,n.useState)(""),x=(0,n.useRef)(null),u=(0,n.useRef)(null);(0,n.useEffect)(()=>{requestAnimationFrame(()=>{var e;null===(e=x.current)||void 0===e||e.scrollIntoView({behavior:"smooth"})})},[r.length]),(0,n.useEffect)(()=>{var e;null===(e=u.current)||void 0===e||e.focus()},[null==t?void 0:t.id]);let m=async e=>{e.preventDefault(),c.trim()&&!i&&await o(c.trim())&&d("")};return t?(0,s.jsxs)("div",{className:"flex flex-col h-full bg-bg-primary border-l border-border",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border bg-bg-secondary",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)(ez,{}),(0,s.jsx)("span",{className:"font-semibold text-sm text-text-primary",children:"Thread"}),(0,s.jsxs)("span",{className:"text-text-muted text-xs",children:[r.length," ",1===r.length?"reply":"replies"]})]}),(0,s.jsx)("button",{onClick:a,className:"p-1.5 rounded hover:bg-bg-hover transition-colors text-text-muted hover:text-text-primary",title:"Close thread",children:(0,s.jsx)(eH,{})})]}),(0,s.jsxs)("div",{className:"flex-1 overflow-y-auto",children:[(0,s.jsx)("div",{className:"p-4 border-b border-border",children:(0,s.jsx)(eF,{message:t,isOriginal:!0,currentUser:l})}),(0,s.jsxs)("div",{className:"p-4 space-y-3",children:[0===r.length?(0,s.jsx)("div",{className:"text-center text-text-muted text-sm py-8",children:"No replies yet. Be the first to reply!"}):r.map(e=>(0,s.jsx)(eF,{message:e,currentUser:l},e.id)),(0,s.jsx)("div",{ref:x})]})]}),(0,s.jsx)("div",{className:"p-4 border-t border-border bg-bg-secondary",children:(0,s.jsxs)("form",{onSubmit:m,className:"flex gap-2",children:[(0,s.jsx)("textarea",{ref:u,value:c,onChange:e=>d(e.target.value),onKeyDown:e=>{"Enter"!==e.key||e.shiftKey||(e.preventDefault(),m(e))},placeholder:"Reply to thread...",disabled:i,rows:1,className:"flex-1 py-2 px-3 bg-bg-primary border border-border rounded-md text-sm text-text-primary resize-none min-h-[40px] max-h-[100px] overflow-y-auto focus:outline-none focus:border-accent transition-colors placeholder:text-text-muted"}),(0,s.jsx)("button",{type:"submit",disabled:!c.trim()||i,className:"px-4 py-2 bg-accent text-white rounded-md text-sm font-medium transition-colors hover:bg-accent-hover disabled:opacity-50 disabled:cursor-not-allowed",children:i?"Sending...":"Reply"})]})})]}):null}function eF(e){let{message:t,isOriginal:r,currentUser:o}=e,i=(0,a.GW)(t.from),l=function(e){let t=new Date(e),r=new Date;return t.toDateString()===r.toDateString()?t.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):t.toLocaleDateString([],{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}(t.timestamp),c="Dashboard"===t.from||o&&t.from===o.displayName,d=c&&o?o.displayName:t.from;return(0,s.jsxs)("div",{className:"flex gap-3 ".concat(r?"":"pl-2"),children:[c&&(null==o?void 0:o.avatarUrl)?(0,s.jsx)("img",{src:o.avatarUrl,alt:d,className:"shrink-0 w-8 h-8 rounded-lg object-cover"}):(0,s.jsx)("div",{className:"shrink-0 w-8 h-8 rounded-lg flex items-center justify-center font-semibold text-xs",style:{backgroundColor:i.primary,color:i.text},children:(0,a.hP)(t.from)}),(0,s.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2 mb-1",children:[(0,s.jsx)("span",{className:"font-semibold text-sm text-text-primary",children:d}),"*"!==t.to&&!r&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("span",{className:"text-text-muted text-xs",children:"→"}),(0,s.jsx)("span",{className:"text-sm text-accent",children:t.to})]}),(0,s.jsx)("span",{className:"text-text-muted text-xs",children:l}),r&&(0,s.jsx)("span",{className:"text-[10px] py-0.5 px-1.5 rounded bg-accent-light text-accent font-medium",children:"Original"})]}),(0,s.jsx)("div",{className:"text-sm leading-relaxed text-text-primary whitespace-pre-wrap break-words",children:t.content.replace(/\\n/g,"\n").replace(/\r\n/g,"\n").replace(/\r/g,"\n").split("\n").map((e,t)=>(0,s.jsxs)(n.Fragment,{children:[t>0&&(0,s.jsx)("br",{}),function(e){let t=/(https?:\/\/[^\s]+)/g;return e.split(t).map((e,r)=>t.test(e)?(0,s.jsx)("a",{href:e,target:"_blank",rel:"noopener noreferrer",className:"text-accent hover:underline",children:e},r):e)}(e)]},t))}),t.attachments&&t.attachments.length>0&&(0,s.jsx)(eO,{attachments:t.attachments})]})]})}function eO(e){let{attachments:t}=e,[r,a]=(0,n.useState)(null),o=t.filter(e=>e.mimeType.startsWith("image/"));return 0===o.length?null:(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("div",{className:"flex flex-wrap gap-2 mt-2",children:o.map(e=>(0,s.jsxs)("button",{type:"button",onClick:()=>a(e),className:"relative group cursor-pointer bg-transparent border-0 p-0",title:"View ".concat(e.filename),children:[(0,s.jsx)("img",{src:e.data||e.url,alt:e.filename,className:"max-h-32 max-w-[200px] rounded-lg border border-border object-cover transition-all duration-150 group-hover:border-accent/50 group-hover:shadow-md",loading:"lazy"}),(0,s.jsx)("div",{className:"absolute inset-0 bg-black/0 group-hover:bg-black/10 rounded-lg transition-colors flex items-center justify-center opacity-0 group-hover:opacity-100",children:(0,s.jsxs)("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"white",strokeWidth:"2",className:"drop-shadow-lg",children:[(0,s.jsx)("circle",{cx:"11",cy:"11",r:"8"}),(0,s.jsx)("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"}),(0,s.jsx)("line",{x1:"11",y1:"8",x2:"11",y2:"14"}),(0,s.jsx)("line",{x1:"8",y1:"11",x2:"14",y2:"11"})]})})]},e.id))}),r&&(0,s.jsx)("div",{className:"fixed inset-0 z-[9999] flex items-center justify-center bg-black/80 backdrop-blur-sm",onClick:()=>a(null),children:(0,s.jsxs)("div",{className:"relative max-w-[90vw] max-h-[90vh]",children:[(0,s.jsx)("img",{src:r.data||r.url,alt:r.filename,className:"max-w-full max-h-[90vh] rounded-lg shadow-2xl",onClick:e=>e.stopPropagation()}),(0,s.jsx)("button",{type:"button",onClick:()=>a(null),className:"absolute -top-3 -right-3 w-8 h-8 bg-bg-primary border border-border rounded-full flex items-center justify-center text-text-muted hover:text-text-primary hover:bg-bg-secondary transition-colors shadow-lg",title:"Close",children:(0,s.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,s.jsx)("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),(0,s.jsx)("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})}),(0,s.jsx)("div",{className:"absolute bottom-0 left-0 right-0 p-3 bg-gradient-to-t from-black/60 to-transparent rounded-b-lg",children:(0,s.jsx)("p",{className:"text-white text-sm truncate",children:r.filename})})]})})]})}function ez(){return(0,s.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:"text-text-primary",children:(0,s.jsx)("path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})})}function eH(){return(0,s.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,s.jsx)("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),(0,s.jsx)("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})}let eV=["projects","agents","actions","navigation","settings"],eG={critical:{label:"Critical",beadsPriority:0,color:"#ef4444"},high:{label:"High",beadsPriority:1,color:"#f97316"},medium:{label:"Medium",beadsPriority:2,color:"#f59e0b"},low:{label:"Low",beadsPriority:3,color:"#6366f1"}};function eK(e){return e.isOpen?(0,s.jsx)(eJ,{...e}):null}function eJ(e){let{onClose:t,agents:r,projects:o=[],currentProject:i,onAgentSelect:l,onProjectSelect:c,onSpawnClick:d,onTaskCreate:x,onSettingsClick:u,onGeneralClick:m,customCommands:h=[]}=e,[p,g]=(0,n.useState)(""),[b,f]=(0,n.useState)(0),[j,y]=(0,n.useState)(null),v=(0,n.useRef)(b),w=(0,n.useRef)(null),N=(0,n.useRef)(null),k=(0,n.useRef)([]),[C,S]=(0,n.useState)("search"),[A,L]=(0,n.useState)(null),[E,W]=(0,n.useState)(""),[D,M]=(0,n.useState)("medium"),[T,R]=(0,n.useState)(!1),P=(0,n.useMemo)(()=>r.filter(e=>"offline"!==e.status&&"error"!==e.status),[r]),B=(0,n.useMemo)(()=>{if(!p.trim())return P;let e=p.toLowerCase();return P.filter(t=>t.name.toLowerCase().includes(e))},[P,p]),_=(0,n.useCallback)(()=>{S("task-select-agent"),g(""),f(0),L(null),W(""),M("medium")},[]),I=(0,n.useCallback)(async()=>{if(A&&E.trim()&&x){R(!0);try{await x({agentName:A.name,title:E.trim(),priority:D}),t()}catch(e){console.error("Failed to create task:",e)}finally{R(!1)}}},[A,E,D,x,t]);(0,n.useEffect)(()=>{v.current=b},[b]);let U=(0,n.useMemo)(()=>[...[...o].sort((e,t)=>{let r=e.id===i,s=t.id===i;if(r&&!s)return -1;if(!r&&s)return 1;let n=e.name||e.path.split("/").pop()||e.id,a=t.name||t.path.split("/").pop()||t.id;return n.localeCompare(a)}).map(e=>{let r=e.name||e.path.split("/").pop()||e.id,n=e.id===i;return{id:"project-".concat(e.id),label:r,description:n?"Current project • ".concat(e.agents.length," agents"):"".concat(e.agents.length," agents"),category:"projects",icon:n?(0,s.jsx)(e1,{}):(0,s.jsx)(e0,{}),action:()=>{null==c||c(e),t()}}}),...r.map(e=>({id:"agent-".concat(e.name),label:e.name,description:e.currentTask||e.status,category:"agents",icon:(0,s.jsx)(eq,{name:e.name}),action:()=>{l(e),t()}})),{id:"spawn-agent",label:"Spawn Agent",description:"Launch a new agent instance",category:"actions",icon:(0,s.jsx)(eY,{}),shortcut:"⌘⇧S",action:()=>{d(),t()}},{id:"broadcast",label:"Broadcast Message",description:"Send message to all agents",category:"actions",icon:(0,s.jsx)(e$,{}),action:()=>{t()}},...x?[{id:"assign-task",label:"Assign Task",description:"Create a task for an agent (creates bead)",category:"actions",icon:(0,s.jsx)(e2,{}),shortcut:"⌘⇧T",action:()=>{_()}}]:[],{id:"nav-general",label:"Go to #general",description:"View all broadcast messages",category:"navigation",icon:(0,s.jsx)(eZ,{}),action:()=>{null==m||m(),t()}},...u?[{id:"settings",label:"Settings",description:"Configure dashboard preferences",category:"settings",icon:(0,s.jsx)(eQ,{}),shortcut:"⌘,",action:()=>{u(),t()}}]:[],...h],[r,o,i,l,c,d,u,m,t,h]),F=(0,n.useMemo)(()=>{let e=U;if(j&&(e=e.filter(e=>e.category===j)),p.trim()){let t=p.toLowerCase();e=e.filter(e=>{var r;return e.label.toLowerCase().includes(t)||(null===(r=e.description)||void 0===r?void 0:r.toLowerCase().includes(t))||e.category.toLowerCase().includes(t)})}return e},[U,p,j]),O=(0,n.useMemo)(()=>{let e={};for(let t of F)e[t.category]||(e[t.category]=[]),e[t.category].push(t);return e},[F]),z=(0,n.useMemo)(()=>eV.flatMap(e=>O[e]||[]),[O]);(0,n.useEffect)(()=>{f(0)},[p]),(0,n.useEffect)(()=>{g(""),f(0),y(null),S("search"),L(null),W(""),M("medium")},[]),(0,n.useEffect)(()=>{let e=k.current[b];e&&e.scrollIntoView({block:"nearest",behavior:"smooth"})},[b]),(0,n.useEffect)(()=>{let e=e=>{if("task-details"===C){"Escape"===e.key?(e.preventDefault(),S("task-select-agent"),g("")):"Enter"===e.key&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),I());return}if("task-select-agent"===C){switch(e.key){case"ArrowDown":e.preventDefault(),f(e=>Math.min(e+1,B.length-1));break;case"ArrowUp":e.preventDefault(),f(e=>Math.max(e-1,0));break;case"Enter":e.preventDefault(),B[v.current]&&(L(B[v.current]),S("task-details"),g(""));break;case"Escape":e.preventDefault(),S("search"),g("")}return}switch(e.key){case"ArrowDown":e.preventDefault(),f(e=>Math.min(e+1,z.length-1));break;case"ArrowUp":e.preventDefault(),f(e=>Math.max(e-1,0));break;case"Enter":e.preventDefault(),z[v.current]&&z[v.current].action();break;case"Tab":e.preventDefault(),y(t=>{if(null===t)return eV[0];let r=eV.indexOf(t);return e.shiftKey?0===r?null:eV[r-1]:r===eV.length-1?null:eV[r+1]}),f(0);break;case"Escape":e.preventDefault(),j?(y(null),f(0)):t()}};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[z,B,C,b,j,t,I]);let H={projects:"Projects",agents:"Agents",actions:"Actions",navigation:"Navigation",settings:"Settings"},V=0;if("task-select-agent"===C)return(0,s.jsx)("div",{className:"fixed inset-0 bg-black/60 flex items-start justify-center pt-[15vh] z-[1000] animate-fade-in",onClick:()=>{S("search"),g("")},children:(0,s.jsxs)("div",{className:"bg-sidebar-bg border border-sidebar-border rounded-xl w-[560px] max-w-[90vw] max-h-[60vh] flex flex-col shadow-modal animate-slide-down",onClick:e=>e.stopPropagation(),children:[(0,s.jsxs)("div",{className:"flex items-center gap-3 p-4 border-b border-sidebar-border",children:[(0,s.jsx)("button",{className:"p-1 rounded hover:bg-sidebar-border text-text-muted",onClick:()=>{S("search"),g("")},children:(0,s.jsx)(e5,{})}),(0,s.jsx)(e2,{}),(0,s.jsx)("input",{ref:w,autoFocus:!0,type:"text",className:"flex-1 border-none text-base font-sans outline-none bg-transparent text-text-primary placeholder:text-text-muted",placeholder:"Select agent to assign task...",value:p,onChange:e=>{g(e.target.value),f(0)}}),(0,s.jsx)("kbd",{className:"bg-sidebar-border border border-sidebar-hover rounded px-1.5 py-0.5 text-xs text-text-muted font-sans",children:"ESC"})]}),(0,s.jsx)("div",{className:"flex-1 overflow-y-auto p-2",ref:N,children:0===B.length?(0,s.jsx)("div",{className:"py-8 text-center text-text-muted text-sm",children:p?'No agents matching "'.concat(p,'"'):"No available agents"}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("div",{className:"text-xs font-semibold text-text-muted uppercase tracking-wider py-2 px-3",children:"Select Agent"}),B.map((e,t)=>{let r=(0,a.GW)(e.name);return(0,s.jsxs)("button",{ref:e=>{k.current[t]=e},className:"\n flex items-center gap-3 w-full py-2.5 px-3 border-none rounded-lg cursor-pointer text-left font-sans transition-colors duration-100\n ".concat(t===b?"bg-accent-light border border-accent/30":"bg-transparent hover:bg-sidebar-border","\n "),onClick:()=>{L(e),S("task-details"),g("")},onMouseEnter:()=>f(t),children:[(0,s.jsx)("div",{className:"w-7 h-7 rounded-md flex items-center justify-center text-xs font-semibold",style:{backgroundColor:r.primary,color:r.text},children:(0,a.hP)(e.name)}),(0,s.jsxs)("span",{className:"flex-1 min-w-0 flex flex-col gap-0.5",children:[(0,s.jsx)("span",{className:"text-sm font-medium text-text-primary",children:e.name}),(0,s.jsx)("span",{className:"text-xs text-text-muted truncate",children:e.currentTask||e.status})]})]},e.name)})]})})]})});if("task-details"===C&&A){let e=(0,a.GW)(A.name);return(0,s.jsx)("div",{className:"fixed inset-0 bg-black/60 flex items-start justify-center pt-[15vh] z-[1000] animate-fade-in",onClick:()=>{S("task-select-agent"),g("")},children:(0,s.jsxs)("div",{className:"bg-sidebar-bg border border-sidebar-border rounded-xl w-[560px] max-w-[90vw] flex flex-col shadow-modal animate-slide-down",onClick:e=>e.stopPropagation(),children:[(0,s.jsxs)("div",{className:"flex items-center gap-3 p-4 border-b border-sidebar-border",children:[(0,s.jsx)("button",{className:"p-1 rounded hover:bg-sidebar-border text-text-muted",onClick:()=>{S("task-select-agent"),g("")},children:(0,s.jsx)(e5,{})}),(0,s.jsx)("div",{className:"w-7 h-7 rounded-md flex items-center justify-center text-xs font-semibold",style:{backgroundColor:e.primary,color:e.text},children:(0,a.hP)(A.name)}),(0,s.jsxs)("span",{className:"text-base font-medium text-text-primary",children:["Assign task to ",A.name]})]}),(0,s.jsxs)("div",{className:"p-4 flex flex-col gap-4",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"block text-xs font-medium text-text-muted mb-1.5",children:"Task Title"}),(0,s.jsx)("input",{autoFocus:!0,type:"text",value:E,onChange:e=>W(e.target.value),placeholder:"What needs to be done?",className:"w-full px-3 py-2 text-sm bg-bg-tertiary border border-sidebar-border rounded-md text-text-primary placeholder:text-text-dim focus:outline-none focus:border-accent-cyan"})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"block text-xs font-medium text-text-muted mb-1.5",children:"Priority"}),(0,s.jsx)("div",{className:"flex gap-2",children:Object.keys(eG).map(e=>{let t=eG[e],r=D===e;return(0,s.jsx)("button",{type:"button",className:"px-3 py-1.5 text-xs font-medium rounded-md border transition-all ".concat(r?"border-transparent text-white":"border-sidebar-border text-text-muted hover:border-sidebar-hover"),style:{backgroundColor:r?t.color:"transparent"},onClick:()=>M(e),children:t.label},e)})}),(0,s.jsxs)("p",{className:"text-xs text-text-dim mt-1.5",children:["Maps to beads priority P",eG[D].beadsPriority]})]}),(0,s.jsxs)("div",{className:"flex justify-end gap-2 pt-2 border-t border-sidebar-border",children:[(0,s.jsx)("button",{type:"button",className:"px-4 py-2 text-sm text-text-muted hover:text-text-primary transition-colors",onClick:()=>{S("task-select-agent"),g("")},children:"Back"}),(0,s.jsx)("button",{type:"button",disabled:!E.trim()||T,onClick:I,className:"px-4 py-2 text-sm font-medium bg-accent-cyan text-bg-deep rounded-md hover:bg-accent-cyan/90 transition-colors disabled:opacity-50 disabled:cursor-not-allowed flex items-center gap-2",children:T?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(e4,{}),"Creating..."]}):(0,s.jsxs)(s.Fragment,{children:["Create Task",(0,s.jsx)("kbd",{className:"bg-black/20 rounded px-1 py-0.5 text-[10px]",children:"⌘↵"})]})})]})]})]})})}return(0,s.jsx)("div",{className:"fixed inset-0 bg-black/60 flex items-start justify-center pt-[15vh] z-[1000] animate-fade-in",onClick:t,children:(0,s.jsxs)("div",{className:"bg-sidebar-bg border border-sidebar-border rounded-xl w-[560px] max-w-[90vw] max-h-[60vh] flex flex-col shadow-modal animate-slide-down",onClick:e=>e.stopPropagation(),children:[(0,s.jsxs)("div",{className:"flex items-center gap-3 p-4 border-b border-sidebar-border",children:[(0,s.jsx)(eX,{}),j&&(0,s.jsxs)("button",{onClick:()=>{y(null),f(0)},className:"flex items-center gap-1 px-2 py-0.5 text-xs font-medium bg-accent-cyan/20 text-accent-cyan rounded-md hover:bg-accent-cyan/30 transition-colors",children:[H[j],(0,s.jsx)("span",{className:"text-accent-cyan/60",children:"\xd7"})]}),(0,s.jsx)("input",{ref:w,autoFocus:!0,type:"text",className:"flex-1 border-none text-base font-sans outline-none bg-transparent text-text-primary placeholder:text-text-muted",placeholder:j?"Search ".concat(H[j].toLowerCase(),"..."):"Search commands, agents...",value:p,onChange:e=>g(e.target.value)}),(0,s.jsx)("kbd",{className:"bg-sidebar-border border border-sidebar-hover rounded px-1.5 py-0.5 text-xs text-text-muted font-sans",title:"Cycle categories",children:"Tab"}),(0,s.jsx)("kbd",{className:"bg-sidebar-border border border-sidebar-hover rounded px-1.5 py-0.5 text-xs text-text-muted font-sans",children:"ESC"})]}),(0,s.jsx)("div",{className:"flex-1 overflow-y-auto p-2",ref:N,children:0===z.length?(0,s.jsxs)("div",{className:"py-8 text-center text-text-muted text-sm",children:['No results for "',p,'"']}):eV.map(e=>{let t=O[e];return(null==t?void 0:t.length)?(0,s.jsxs)("div",{className:"mb-2",children:[(0,s.jsx)("div",{className:"text-xs font-semibold text-text-muted uppercase tracking-wider py-2 px-3",children:H[e]||e}),t.map(e=>{let t=V++;return(0,s.jsxs)("button",{ref:e=>{k.current[t]=e},className:"\n flex items-center gap-3 w-full py-2.5 px-3 border-none rounded-lg cursor-pointer text-left font-sans transition-colors duration-100\n ".concat(t===b?"bg-accent-light border border-accent/30":"bg-transparent hover:bg-sidebar-border","\n "),onClick:e.action,onMouseEnter:()=>f(t),children:[(0,s.jsx)("span",{className:"flex items-center justify-center w-7 h-7 text-text-muted",children:e.icon}),(0,s.jsxs)("span",{className:"flex-1 min-w-0 flex flex-col gap-0.5",children:[(0,s.jsx)("span",{className:"text-sm font-medium text-text-primary",children:e.label}),e.description&&(0,s.jsx)("span",{className:"text-xs text-text-muted truncate",children:e.description})]}),e.shortcut&&(0,s.jsx)("kbd",{className:"bg-sidebar-border border border-sidebar-hover rounded px-1.5 py-0.5 text-xs text-text-muted font-sans",children:e.shortcut})]},e.id)})]},e):null})})]})})}function eq(e){let{name:t}=e,r=(0,a.GW)(t);return(0,s.jsx)("div",{className:"w-7 h-7 rounded-md flex items-center justify-center text-xs font-semibold",style:{backgroundColor:r.primary,color:r.text},children:(0,a.hP)(t)})}function eX(){return(0,s.jsxs)("svg",{className:"text-text-muted shrink-0",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,s.jsx)("circle",{cx:"11",cy:"11",r:"8"}),(0,s.jsx)("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]})}function eY(){return(0,s.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,s.jsx)("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),(0,s.jsx)("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]})}function e$(){return(0,s.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,s.jsx)("circle",{cx:"12",cy:"12",r:"2"}),(0,s.jsx)("path",{d:"M16.24 7.76a6 6 0 0 1 0 8.49m-8.48-.01a6 6 0 0 1 0-8.49m11.31-2.82a10 10 0 0 1 0 14.14m-14.14 0a10 10 0 0 1 0-14.14"})]})}function eZ(){return(0,s.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,s.jsx)("line",{x1:"4",y1:"9",x2:"20",y2:"9"}),(0,s.jsx)("line",{x1:"4",y1:"15",x2:"20",y2:"15"}),(0,s.jsx)("line",{x1:"10",y1:"3",x2:"8",y2:"21"}),(0,s.jsx)("line",{x1:"16",y1:"3",x2:"14",y2:"21"})]})}function eQ(){return(0,s.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,s.jsx)("circle",{cx:"12",cy:"12",r:"3"}),(0,s.jsx)("path",{d:"M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-2 2 2 2 0 0 1-2-2v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1-2-2 2 2 0 0 1 2-2h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 2-2 2 2 0 0 1 2 2v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 2 2 2 2 0 0 1-2 2h-.09a1.65 1.65 0 0 0-1.51 1z"})]})}function e0(){return(0,s.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:(0,s.jsx)("path",{d:"M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z"})})}function e1(){return(0,s.jsxs)("div",{className:"relative",children:[(0,s.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:"text-accent-cyan",children:(0,s.jsx)("path",{d:"M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z"})}),(0,s.jsx)("svg",{className:"absolute -bottom-0.5 -right-0.5 text-accent-cyan bg-sidebar-bg rounded-full",width:"10",height:"10",viewBox:"0 0 24 24",fill:"currentColor",children:(0,s.jsx)("path",{d:"M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z"})})]})}function e2(){return(0,s.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:"text-text-muted",children:[(0,s.jsx)("path",{d:"M9 11l3 3L22 4"}),(0,s.jsx)("path",{d:"M21 12v7a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11"})]})}function e5(){return(0,s.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:(0,s.jsx)("polyline",{points:"15 18 9 12 15 6"})})}function e4(){return(0,s.jsx)("svg",{className:"animate-spin",width:"14",height:"14",viewBox:"0 0 24 24",children:(0,s.jsx)("circle",{cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"2",fill:"none",strokeDasharray:"32",strokeLinecap:"round"})})}let e3=[{id:"claude",name:"Claude",command:"claude",description:"Claude Code CLI agent",icon:"\uD83E\uDD16"},{id:"codex",name:"Codex",command:"codex",description:"OpenAI Codex agent",icon:"⚡"},{id:"gemini",name:"Gemini",command:"gemini",description:"Google Gemini CLI agent",icon:"\uD83D\uDC8E"},{id:"opencode",name:"OpenCode",command:"opencode",description:"OpenCode AI agent",icon:"\uD83D\uDD37"},{id:"droid",name:"Droid",command:"droid",description:"Factory Droid agent",icon:"\uD83E\uDD16"},{id:"custom",name:"Custom",command:"",description:"Custom command",icon:"\uD83D\uDD27"}];function e6(e){let{isOpen:t,onClose:r,onSpawn:o,existingAgents:i,isSpawning:l=!1,error:c}=e,[d,x]=(0,n.useState)(e3[0]),[u,m]=(0,n.useState)(""),[h,p]=(0,n.useState)(""),[g,b]=(0,n.useState)(""),[f,j]=(0,n.useState)(""),[y,v]=(0,n.useState)(!1),[w,N]=(0,n.useState)(""),[k,C]=(0,n.useState)(""),[S,A]=(0,n.useState)(["EXPLICIT_ASK"]),[L,E]=(0,n.useState)(null),W=(0,n.useRef)(null),D="custom"===d.id?h:d.command,M=(0,n.useMemo)(()=>(function(e){let t=e.trim().split(" ")[0].toLowerCase();return t.startsWith("claude")||"codex"===t||"opencode"===t||"gemini"===t||"droid"===t?"subagent":"process"})(D),[D]),T=(0,n.useCallback)(()=>{let e="claude"===d.id?"claude":d.id,t=1;for(;i.includes("".concat(e,"-").concat(t));)t++;return"".concat(e,"-").concat(t)},[d,i]);(0,n.useEffect)(()=>{t&&(x(e3[0]),m(""),p(""),b(""),j(""),v(!1),N(""),C(""),A(["EXPLICIT_ASK"]),E(null),setTimeout(()=>{var e;return null===(e=W.current)||void 0===e?void 0:e.focus()},100))},[t]);let R=(0,n.useCallback)(e=>e.trim()?/^[a-zA-Z][a-zA-Z0-9-]*$/.test(e)?i.includes(e)?"An agent with this name already exists":null:"Name must start with a letter and contain only letters, numbers, and hyphens":"Name is required",[i]),P=async e=>{e.preventDefault();let t=u.trim()||T(),s=R(t);if(s){E(s);return}if(!D.trim()){E("Command is required");return}if(y&&!w){E("Please select an agent to shadow");return}E(null),await o({name:t,command:D.trim(),cwd:g.trim()||void 0,team:f.trim()||void 0,shadowMode:M,shadowOf:y?w:void 0,shadowAgent:k.trim()||void 0,shadowTriggers:y?S:void 0,shadowSpeakOn:y?S:void 0})&&r()};if(!t)return null;let B=u?(0,a.GW)(u):(0,a.GW)(T()),_=c||L;return(0,s.jsx)("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-[1000] animate-fade-in",onClick:r,children:(0,s.jsxs)("div",{className:"bg-bg-primary border border-border rounded-xl w-[480px] max-w-[90vw] max-h-[90vh] overflow-y-auto shadow-modal animate-slide-up",onClick:e=>e.stopPropagation(),onKeyDown:e=>{"Escape"===e.key&&(e.preventDefault(),r())},children:[(0,s.jsxs)("div",{className:"flex items-center justify-between p-5 border-b border-border",children:[(0,s.jsx)("h2",{className:"m-0 text-lg font-semibold text-text-primary",children:"Spawn New Agent"}),(0,s.jsx)("button",{className:"flex items-center justify-center w-8 h-8 bg-transparent border-none rounded-md text-text-muted cursor-pointer transition-all duration-150 hover:bg-bg-hover hover:text-text-primary",onClick:r,"aria-label":"Close",children:(0,s.jsx)(e8,{})})]}),(0,s.jsxs)("form",{onSubmit:P,className:"p-6",children:[(0,s.jsxs)("div",{className:"mb-5",children:[(0,s.jsx)("label",{className:"block text-sm font-semibold text-text-primary mb-2",children:"Agent Type"}),(0,s.jsx)("div",{className:"grid grid-cols-3 gap-2",children:e3.map(e=>(0,s.jsxs)("button",{type:"button",className:"\n flex flex-col items-center gap-1 py-3 px-2 border-2 rounded-lg cursor-pointer font-sans transition-all duration-150\n ".concat(d.id===e.id?"bg-accent/10 border-accent":"bg-bg-hover border-transparent hover:bg-bg-active","\n "),onClick:()=>x(e),children:[(0,s.jsx)("span",{className:"text-2xl",children:e.icon}),(0,s.jsx)("span",{className:"text-sm font-semibold text-text-primary",children:e.name}),(0,s.jsx)("span",{className:"text-xs text-text-muted text-center",children:e.description})]},e.id))})]}),(0,s.jsxs)("div",{className:"mb-5",children:[(0,s.jsx)("label",{className:"block text-sm font-semibold text-text-primary mb-2",htmlFor:"agent-name",children:"Agent Name"}),(0,s.jsxs)("div",{className:"flex items-center gap-3",children:[(0,s.jsx)("div",{className:"shrink-0 w-10 h-10 rounded-lg flex items-center justify-center text-sm font-semibold",style:{backgroundColor:B.primary,color:B.text},children:(0,a.hP)(u||T())}),(0,s.jsx)("input",{ref:W,id:"agent-name",type:"text",className:"flex-1 py-2.5 px-3.5 border border-border rounded-md text-sm font-sans outline-none bg-transparent text-text-primary transition-colors duration-150 focus:border-accent disabled:bg-bg-hover disabled:text-text-muted placeholder:text-text-muted",placeholder:T(),value:u,onChange:e=>{m(e.target.value),E(null)},disabled:l})]})]}),(0,s.jsxs)("div",{className:"mb-5",children:[(0,s.jsxs)("label",{className:"block text-sm font-semibold text-text-primary mb-2",htmlFor:"agent-team",children:["Team ",(0,s.jsx)("span",{className:"font-normal text-text-muted",children:"(optional)"})]}),(0,s.jsx)("input",{id:"agent-team",type:"text",className:"w-full py-2.5 px-3.5 border border-border rounded-md text-sm font-sans outline-none bg-transparent text-text-primary transition-colors duration-150 focus:border-accent disabled:bg-bg-hover disabled:text-text-muted placeholder:text-text-muted",placeholder:"e.g., frontend, backend, infra",value:f,onChange:e=>j(e.target.value),disabled:l})]}),"custom"===d.id&&(0,s.jsxs)("div",{className:"mb-5",children:[(0,s.jsx)("label",{className:"block text-sm font-semibold text-text-primary mb-2",htmlFor:"agent-command",children:"Command"}),(0,s.jsx)("input",{id:"agent-command",type:"text",className:"w-full py-2.5 px-3.5 border border-border rounded-md text-sm font-sans outline-none bg-transparent text-text-primary transition-colors duration-150 focus:border-accent disabled:bg-bg-hover disabled:text-text-muted placeholder:text-text-muted",placeholder:"e.g., python agent.py",value:h,onChange:e=>p(e.target.value),disabled:l})]}),(0,s.jsxs)("div",{className:"mb-5",children:[(0,s.jsxs)("label",{className:"block text-sm font-semibold text-text-primary mb-2",htmlFor:"agent-cwd",children:["Working Directory ",(0,s.jsx)("span",{className:"font-normal text-text-muted",children:"(optional)"})]}),(0,s.jsx)("input",{id:"agent-cwd",type:"text",className:"w-full py-2.5 px-3.5 border border-border rounded-md text-sm font-sans outline-none bg-transparent text-text-primary transition-colors duration-150 focus:border-accent disabled:bg-bg-hover disabled:text-text-muted placeholder:text-text-muted",placeholder:"Current directory",value:g,onChange:e=>b(e.target.value),disabled:l})]}),(0,s.jsxs)("div",{className:"mb-5 p-4 border border-border rounded-lg bg-bg-hover/50",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between mb-3",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"block text-sm font-semibold text-text-primary",children:"Shadow Mode"}),(0,s.jsxs)("span",{className:"text-xs text-text-muted",children:["Shadow execution: ","subagent"===M?"Subagent (in-process)":"Process (separate)"]})]}),(0,s.jsx)("button",{type:"button",className:"\n relative w-11 h-6 rounded-full transition-colors duration-200\n ".concat(y?"bg-accent":"bg-bg-active","\n "),onClick:()=>v(!y),disabled:l,"aria-pressed":y,children:(0,s.jsx)("span",{className:"\n absolute top-0.5 left-0.5 w-5 h-5 bg-white rounded-full transition-transform duration-200 shadow-sm\n ".concat(y?"translate-x-5":"translate-x-0","\n ")})})]}),y&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{className:"mb-4",children:[(0,s.jsx)("label",{className:"block text-sm font-medium text-text-secondary mb-2",htmlFor:"shadow-of",children:"Shadow Agent"}),(0,s.jsxs)("select",{id:"shadow-of",className:"w-full py-2.5 px-3.5 border border-border rounded-md text-sm font-sans outline-none bg-bg-primary text-text-primary transition-colors duration-150 focus:border-accent disabled:bg-bg-hover disabled:text-text-muted",value:w,onChange:e=>N(e.target.value),disabled:l,children:[(0,s.jsx)("option",{value:"",children:"Select an agent to shadow..."}),i.map(e=>(0,s.jsx)("option",{value:e,children:e},e))]})]}),(0,s.jsxs)("div",{className:"mb-4",children:[(0,s.jsxs)("label",{className:"block text-sm font-medium text-text-secondary mb-2",htmlFor:"shadow-agent",children:["Shadow Agent Profile ",(0,s.jsx)("span",{className:"font-normal text-text-muted",children:"(optional)"})]}),(0,s.jsx)("input",{id:"shadow-agent",type:"text",className:"w-full py-2.5 px-3.5 border border-border rounded-md text-sm font-sans outline-none bg-bg-primary text-text-primary transition-colors duration-150 focus:border-accent disabled:bg-bg-hover disabled:text-text-muted placeholder:text-text-muted",placeholder:"e.g., shadow-reviewer",value:k,onChange:e=>C(e.target.value),disabled:l})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"block text-sm font-medium text-text-secondary mb-2",children:"Speak When"}),(0,s.jsx)("div",{className:"flex flex-wrap gap-2",children:[{value:"EXPLICIT_ASK",label:"Explicit Ask",description:"When directly asked"},{value:"SESSION_END",label:"Session End",description:"When session ends"},{value:"CODE_WRITTEN",label:"Code Written",description:"When code is written"},{value:"REVIEW_REQUEST",label:"Review Request",description:"When review requested"},{value:"ALL_MESSAGES",label:"All Messages",description:"On every message"}].map(e=>(0,s.jsx)("button",{type:"button",className:"\n py-1.5 px-3 rounded-md text-xs font-medium transition-all duration-150 border\n ".concat(S.includes(e.value)?"bg-accent/20 border-accent text-accent":"bg-bg-primary border-border text-text-secondary hover:bg-bg-active hover:text-text-primary","\n "),onClick:()=>{S.includes(e.value)?A(S.filter(t=>t!==e.value)):A([...S,e.value])},disabled:l,title:e.description,children:e.label},e.value))})]})]})]}),_&&(0,s.jsxs)("div",{className:"flex items-center gap-2 p-3 bg-error/10 border border-error/30 rounded-md text-error text-sm mb-5",children:[(0,s.jsx)(e9,{}),(0,s.jsx)("span",{children:_})]}),(0,s.jsxs)("div",{className:"flex justify-end gap-2 pt-2 border-t border-border",children:[(0,s.jsx)("button",{type:"button",className:"flex items-center gap-1.5 py-2.5 px-4 border-none rounded-md text-sm font-medium cursor-pointer font-sans transition-all duration-150 bg-bg-hover text-text-secondary hover:bg-bg-active hover:text-text-primary disabled:opacity-50 disabled:cursor-not-allowed",onClick:r,disabled:l,children:"Cancel"}),(0,s.jsx)("button",{type:"submit",className:"flex items-center gap-1.5 py-2.5 px-4 border-none rounded-md text-sm font-medium cursor-pointer font-sans transition-all duration-150 bg-accent text-white hover:bg-accent-hover disabled:opacity-50 disabled:cursor-not-allowed",disabled:l,children:l?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(te,{}),"Spawning..."]}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(e7,{}),"Spawn Agent"]})})]})]})]})})}function e8(){return(0,s.jsxs)("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,s.jsx)("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),(0,s.jsx)("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})}function e9(){return(0,s.jsxs)("svg",{className:"shrink-0",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,s.jsx)("circle",{cx:"12",cy:"12",r:"10"}),(0,s.jsx)("line",{x1:"12",y1:"8",x2:"12",y2:"12"}),(0,s.jsx)("line",{x1:"12",y1:"16",x2:"12.01",y2:"16"})]})}function e7(){return(0,s.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,s.jsx)("path",{d:"M4.5 16.5c-1.5 1.26-2 5-2 5s3.74-.5 5-2c.71-.84.7-2.13-.09-2.91a2.18 2.18 0 0 0-2.91-.09z"}),(0,s.jsx)("path",{d:"m12 15-3-3a22 22 0 0 1 2-3.95A12.88 12.88 0 0 1 22 2c0 2.72-.78 7.5-6 11a22.35 22.35 0 0 1-4 2z"}),(0,s.jsx)("path",{d:"M9 12H4s.55-3.03 2-4c1.62-1.08 5 0 5 0"}),(0,s.jsx)("path",{d:"M12 15v5s3.03-.55 4-2c1.08-1.62 0-5 0-5"})]})}function te(){return(0,s.jsx)("svg",{className:"animate-spin",width:"16",height:"16",viewBox:"0 0 24 24",children:(0,s.jsx)("circle",{cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"2",fill:"none",strokeDasharray:"32",strokeLinecap:"round"})})}function tt(e){let{isOpen:t,onClose:r,onSend:o,agents:i,isSending:l=!1,error:c,preselectedAgent:d}=e,[x,u]=(0,n.useState)(""),[m,h]=(0,n.useState)(""),[p,g]=(0,n.useState)(""),[b,f]=(0,n.useState)(null),j=(0,n.useRef)(null),y=(0,n.useRef)(null),v=(0,n.useMemo)(()=>{if(!p.trim())return i;let e=p.toLowerCase();return i.filter(t=>{var r,s;return t.name.toLowerCase().includes(e)||(null===(r=t.role)||void 0===r?void 0:r.toLowerCase().includes(e))||(null===(s=t.team)||void 0===s?void 0:s.toLowerCase().includes(e))})},[i,p]);(0,n.useEffect)(()=>{t&&(u(d||""),h(""),g(""),f(null),setTimeout(()=>{var e,t;d?null===(e=j.current)||void 0===e||e.focus():null===(t=y.current)||void 0===t||t.focus()},100))},[t,d]);let w=async e=>{if(e.preventDefault(),!x){f("Please select an agent");return}if(!m.trim()){f("Please enter a message");return}f(null),await o(x,m.trim())&&r()},N=(0,n.useCallback)(e=>{u(e),f(null),setTimeout(()=>{var e;return null===(e=j.current)||void 0===e?void 0:e.focus()},50)},[]);if(!t)return null;let k=c||b,C=i.find(e=>e.name===x),S=C?(0,a.GW)(C.name):null;return(0,s.jsx)("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-[1000] animate-fade-in",onClick:r,children:(0,s.jsxs)("div",{className:"bg-bg-primary border border-border rounded-xl w-[520px] max-w-[90vw] max-h-[85vh] overflow-hidden shadow-modal animate-slide-up flex flex-col",onClick:e=>e.stopPropagation(),onKeyDown:e=>{"Escape"===e.key&&(e.preventDefault(),r())},children:[(0,s.jsxs)("div",{className:"flex items-center justify-between p-5 border-b border-border shrink-0",children:[(0,s.jsxs)("div",{className:"flex items-center gap-3",children:[(0,s.jsx)("div",{className:"w-9 h-9 rounded-lg bg-accent/10 flex items-center justify-center",children:(0,s.jsx)(tr,{})}),(0,s.jsxs)("div",{children:[(0,s.jsx)("h2",{className:"m-0 text-lg font-semibold text-text-primary",children:"New Conversation"}),(0,s.jsx)("p",{className:"m-0 text-xs text-text-muted",children:"Start a direct message with an agent"})]})]}),(0,s.jsx)("button",{className:"flex items-center justify-center w-8 h-8 bg-transparent border-none rounded-md text-text-muted cursor-pointer transition-all duration-150 hover:bg-bg-hover hover:text-text-primary",onClick:r,"aria-label":"Close",children:(0,s.jsx)(ts,{})})]}),(0,s.jsxs)("form",{onSubmit:w,className:"flex flex-col flex-1 overflow-hidden",children:[(0,s.jsxs)("div",{className:"p-5 border-b border-border",children:[(0,s.jsx)("label",{className:"block text-sm font-semibold text-text-primary mb-2",children:"To"}),x?(0,s.jsxs)("div",{className:"flex items-center gap-3 p-3 bg-bg-hover rounded-lg",children:[(0,s.jsx)("div",{className:"shrink-0 w-10 h-10 rounded-lg flex items-center justify-center text-sm font-semibold",style:{backgroundColor:null==S?void 0:S.primary,color:null==S?void 0:S.text},children:(0,a.hP)(x)}),(0,s.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,s.jsx)("div",{className:"font-semibold text-text-primary",children:x}),(null==C?void 0:C.role)&&(0,s.jsx)("div",{className:"text-xs text-text-muted truncate",children:C.role})]}),(0,s.jsx)("button",{type:"button",className:"flex items-center justify-center w-8 h-8 bg-bg-active border-none rounded-md text-text-muted cursor-pointer transition-all duration-150 hover:bg-bg-tertiary hover:text-text-primary",onClick:()=>{u(""),setTimeout(()=>{var e;return null===(e=y.current)||void 0===e?void 0:e.focus()},50)},"aria-label":"Change agent",children:(0,s.jsx)(ta,{})})]}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{className:"relative mb-3",children:[(0,s.jsx)("div",{className:"absolute left-3 top-1/2 -translate-y-1/2 text-text-muted",children:(0,s.jsx)(tn,{})}),(0,s.jsx)("input",{ref:y,type:"text",className:"w-full py-2.5 pl-10 pr-3.5 border border-border rounded-md text-sm font-sans outline-none bg-transparent text-text-primary transition-colors duration-150 focus:border-accent placeholder:text-text-muted",placeholder:"Search agents...",value:p,onChange:e=>g(e.target.value)})]}),(0,s.jsx)("div",{className:"max-h-[200px] overflow-y-auto border border-border rounded-lg",children:0===v.length?(0,s.jsx)("div",{className:"p-4 text-center text-text-muted text-sm",children:p?"No agents found":"No agents available"}):(0,s.jsxs)("div",{className:"divide-y divide-border",children:[(0,s.jsxs)("button",{type:"button",className:"w-full flex items-center gap-3 p-3 bg-transparent border-none cursor-pointer transition-colors duration-150 hover:bg-bg-hover text-left",onClick:()=>N("*"),children:[(0,s.jsx)("div",{className:"shrink-0 w-9 h-9 rounded-lg bg-warning/20 flex items-center justify-center",children:(0,s.jsx)(to,{})}),(0,s.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,s.jsx)("div",{className:"font-semibold text-text-primary",children:"Everyone"}),(0,s.jsx)("div",{className:"text-xs text-text-muted",children:"Broadcast to all agents"})]})]}),v.map(e=>{let t=(0,a.GW)(e.name);return(0,s.jsxs)("button",{type:"button",className:"w-full flex items-center gap-3 p-3 bg-transparent border-none cursor-pointer transition-colors duration-150 hover:bg-bg-hover text-left",onClick:()=>N(e.name),children:[(0,s.jsx)("div",{className:"shrink-0 w-9 h-9 rounded-lg flex items-center justify-center text-xs font-semibold",style:{backgroundColor:t.primary,color:t.text},children:(0,a.hP)(e.name)}),(0,s.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)("span",{className:"font-semibold text-text-primary",children:e.name}),(0,s.jsx)("span",{className:"w-2 h-2 rounded-full ".concat("online"===e.status?"bg-success":"bg-text-muted")})]}),(e.role||e.team)&&(0,s.jsxs)("div",{className:"text-xs text-text-muted truncate",children:[e.role,e.role&&e.team&&" - ",e.team]})]})]},e.name)})]})})]})]}),(0,s.jsxs)("div",{className:"p-5 flex-1 overflow-hidden flex flex-col",children:[(0,s.jsx)("label",{className:"block text-sm font-semibold text-text-primary mb-2",htmlFor:"message",children:"Message"}),(0,s.jsx)("textarea",{ref:j,id:"message",className:"flex-1 min-h-[120px] w-full py-3 px-3.5 border border-border rounded-md text-sm font-sans outline-none bg-transparent text-text-primary transition-colors duration-150 focus:border-accent resize-none placeholder:text-text-muted",placeholder:"*"===x?"Write a message to all agents...":x?"Write a message to ".concat(x,"..."):"Select an agent first...",value:m,onChange:e=>{h(e.target.value),f(null)},disabled:l||!x})]}),k&&(0,s.jsxs)("div",{className:"flex items-center gap-2 mx-5 mb-4 p-3 bg-error/10 border border-error/30 rounded-md text-error text-sm",children:[(0,s.jsx)(tl,{}),(0,s.jsx)("span",{children:k})]}),(0,s.jsxs)("div",{className:"flex justify-end gap-2 p-5 pt-0 border-t border-border",children:[(0,s.jsx)("button",{type:"button",className:"flex items-center gap-1.5 py-2.5 px-4 border-none rounded-md text-sm font-medium cursor-pointer font-sans transition-all duration-150 bg-bg-hover text-text-secondary hover:bg-bg-active hover:text-text-primary disabled:opacity-50 disabled:cursor-not-allowed",onClick:r,disabled:l,children:"Cancel"}),(0,s.jsx)("button",{type:"submit",className:"flex items-center gap-1.5 py-2.5 px-4 border-none rounded-md text-sm font-medium cursor-pointer font-sans transition-all duration-150 bg-accent text-white hover:bg-accent-hover disabled:opacity-50 disabled:cursor-not-allowed",disabled:l||!x||!m.trim(),children:l?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(tc,{}),"Sending..."]}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(ti,{}),"Send Message"]})})]})]})]})})}function tr(){return(0,s.jsxs)("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:"text-accent",children:[(0,s.jsx)("path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"}),(0,s.jsx)("line",{x1:"9",y1:"10",x2:"15",y2:"10"})]})}function ts(){return(0,s.jsxs)("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,s.jsx)("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),(0,s.jsx)("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})}function tn(){return(0,s.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,s.jsx)("circle",{cx:"11",cy:"11",r:"8"}),(0,s.jsx)("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]})}function ta(){return(0,s.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,s.jsx)("polyline",{points:"1 4 1 10 7 10"}),(0,s.jsx)("path",{d:"M3.51 15a9 9 0 1 0 2.13-9.36L1 10"})]})}function to(){return(0,s.jsxs)("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:"text-warning",children:[(0,s.jsx)("circle",{cx:"12",cy:"12",r:"2"}),(0,s.jsx)("path",{d:"M16.24 7.76a6 6 0 0 1 0 8.49m-8.48-.01a6 6 0 0 1 0-8.49m11.31-2.82a10 10 0 0 1 0 14.14m-14.14 0a10 10 0 0 1 0-14.14"})]})}function ti(){return(0,s.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,s.jsx)("line",{x1:"22",y1:"2",x2:"11",y2:"13"}),(0,s.jsx)("polygon",{points:"22 2 15 22 11 13 2 9 22 2"})]})}function tl(){return(0,s.jsxs)("svg",{className:"shrink-0",width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,s.jsx)("circle",{cx:"12",cy:"12",r:"10"}),(0,s.jsx)("line",{x1:"12",y1:"8",x2:"12",y2:"12"}),(0,s.jsx)("line",{x1:"12",y1:"16",x2:"12.01",y2:"16"})]})}function tc(){return(0,s.jsx)("svg",{className:"animate-spin",width:"16",height:"16",viewBox:"0 0 24 24",children:(0,s.jsx)("circle",{cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"2",fill:"none",strokeDasharray:"32",strokeLinecap:"round"})})}let td={theme:"system",notifications:{enabled:!0,sound:!0,desktop:!1,mentionsOnly:!1},display:{compactMode:!1,showTimestamps:!0,showAvatars:!0,animationsEnabled:!0},connection:{autoReconnect:!0,reconnectDelay:3e3,keepAliveInterval:3e4}},tx=[{id:"anthropic",name:"Anthropic",displayName:"Claude",description:"Claude Code - recommended for code tasks",color:"#D97757",cliCommand:"claude",apiKeyUrl:"https://console.anthropic.com/settings/keys",apiKeyName:"API key",supportsOAuth:!0},{id:"openai",name:"OpenAI",displayName:"Codex",description:"Codex - OpenAI coding assistant",color:"#10A37F",cliCommand:"codex login",apiKeyUrl:"https://platform.openai.com/api-keys",apiKeyName:"API key",supportsOAuth:!0},{id:"google",name:"Google",displayName:"Gemini",description:"Gemini - Google AI coding assistant",color:"#4285F4",cliCommand:"gemini",apiKeyUrl:"https://aistudio.google.com/app/apikey",apiKeyName:"API key",supportsOAuth:!0},{id:"opencode",name:"OpenCode",displayName:"OpenCode",description:"OpenCode - AI coding assistant",color:"#00D4AA",cliCommand:"opencode",supportsOAuth:!0},{id:"droid",name:"Factory",displayName:"Droid",description:"Droid - Factory AI coding agent",color:"#6366F1",cliCommand:"droid",supportsOAuth:!0}];function tu(e){var t,r,a,o;let{isOpen:i,onClose:l,settings:c,onSettingsChange:d,onResetSettings:x,workspaceId:u,csrfToken:m}=e,[h,p]=(0,n.useState)("appearance"),[g,b]=(0,n.useState)({}),[f,j]=(0,n.useState)(null),[y,v]=(0,n.useState)(""),[w,N]=(0,n.useState)(null),[k,C]=(0,n.useState)(null),[S,A]=(0,n.useState)({}),[L,E]=(0,n.useState)({storeInRepo:!1,storageLocation:"",loading:!0,error:null});n.useEffect(()=>{i&&"trajectories"===h&&W()},[i,h]);let W=async()=>{try{E(e=>({...e,loading:!0,error:null}));let e=await fetch("/api/settings/trajectory");if(!e.ok)throw Error("Failed to load settings");let t=await e.json();E({storeInRepo:t.settings.storeInRepo,storageLocation:t.settings.storageLocation,loading:!1,error:null,documentation:t.documentation})}catch(e){E(t=>({...t,loading:!1,error:e instanceof Error?e.message:"Failed to load settings"}))}},D=async e=>{try{E(e=>({...e,loading:!0,error:null}));let t={"Content-Type":"application/json"};m&&(t["X-CSRF-Token"]=m);let r=await fetch("/api/settings/trajectory",{method:"PUT",credentials:"include",headers:t,body:JSON.stringify({storeInRepo:e})});if(!r.ok){let e=await r.json();throw Error(e.error||"Failed to update settings")}let s=await r.json();E(e=>({...e,storeInRepo:s.settings.storeInRepo,storageLocation:s.settings.storageLocation,loading:!1,error:null}))}catch(e){E(t=>({...t,loading:!1,error:e instanceof Error?e.message:"Failed to update settings"}))}},M=async e=>{N(null),j(e.id),C({providerId:e.id,sessionId:"",status:"starting"});try{let t={"Content-Type":"application/json"};m&&(t["X-CSRF-Token"]=m);let r=await fetch("/api/onboarding/cli/".concat(e.id,"/start"),{method:"POST",credentials:"include",headers:t}),s=await r.json();if(!r.ok)throw Error(s.error||"Failed to start authentication");if("success"===s.status||s.alreadyAuthenticated){b(t=>({...t,[e.id]:!0})),C(null),j(null);return}let n={providerId:e.id,sessionId:s.sessionId,authUrl:s.authUrl,status:s.status||"starting"};C(n),s.authUrl?(T(s.authUrl,e.displayName),R(e.id,s.sessionId)):"starting"===s.status&&R(e.id,s.sessionId)}catch(e){N(e instanceof Error?e.message:"Failed to start OAuth"),C(null),j(null)}},T=(e,t)=>{let r=window.screenX+(window.outerWidth-600)/2,s=window.screenY+(window.outerHeight-700)/2;window.open(e,"".concat(t," Login"),"width=".concat(600,",height=").concat(700,",left=").concat(r,",top=").concat(s,",popup=yes"))},R=async(e,t)=>{let r=0,s=async()=>{if(r>=60){N("Authentication timed out. Please try again."),C(null),j(null);return}try{let a=await fetch("/api/onboarding/cli/".concat(e,"/status/").concat(t),{credentials:"include"}),o=await a.json();if(!a.ok)throw Error(o.error||"Failed to check status");if("success"===o.status){await P(e,t);return}if("error"===o.status)throw Error(o.error||"Authentication failed");if("waiting_auth"===o.status&&o.authUrl&&!(null==k?void 0:k.authUrl)){var n;C(e=>e?{...e,authUrl:o.authUrl,status:"waiting_auth"}:null),T(o.authUrl,(null===(n=tx.find(t=>t.id===e))||void 0===n?void 0:n.displayName)||"Provider")}r++,setTimeout(s,5e3)}catch(e){N(e instanceof Error?e.message:"Auth check failed"),C(null),j(null)}};s()},P=async(e,t)=>{try{let r={"Content-Type":"application/json"};m&&(r["X-CSRF-Token"]=m);let s=await fetch("/api/onboarding/cli/".concat(e,"/complete/").concat(t),{method:"POST",credentials:"include",headers:r});if(!s.ok){let e=await s.json();throw Error(e.error||"Failed to complete authentication")}b(t=>({...t,[e]:!0})),C(null),j(null)}catch(e){N(e instanceof Error?e.message:"Failed to complete auth"),C(null),j(null)}},B=async()=>{if(null==k?void 0:k.sessionId)try{await fetch("/api/onboarding/cli/".concat(k.providerId,"/cancel/").concat(k.sessionId),{method:"POST",credentials:"include"})}catch(e){}C(null),j(null)},_=async e=>{if(!y.trim()){N("Please enter an API key");return}N(null),j(e.id);try{let t={"Content-Type":"application/json"};m&&(t["X-CSRF-Token"]=m);let r=await fetch("/api/onboarding/token/".concat(e.id),{method:"POST",credentials:"include",headers:t,body:JSON.stringify({token:y.trim()})});if(!r.ok){let e=await r.json();throw Error(e.error||"Failed to connect")}b(t=>({...t,[e.id]:!0})),v(""),j(null),A(t=>({...t,[e.id]:!1}))}catch(e){N(e instanceof Error?e.message:"Failed to connect"),j(null)}},I=(0,n.useCallback)((e,t,r)=>{let s=c[e];d({...c,[e]:{...s,[t]:r}})},[c,d]),U=(0,n.useCallback)(e=>{d({...c,theme:e})},[c,d]);return i?(0,s.jsx)("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-[1000] animate-fade-in",onClick:l,children:(0,s.jsxs)("div",{className:"bg-bg-secondary rounded-xl w-[500px] max-w-[90vw] max-h-[80vh] flex flex-col shadow-modal animate-slide-up",onClick:e=>e.stopPropagation(),children:[(0,s.jsxs)("div",{className:"flex items-center justify-between py-5 px-6 border-b border-border",children:[(0,s.jsx)("h2",{className:"m-0 text-lg font-semibold text-text-primary",children:"Settings"}),(0,s.jsx)("button",{className:"flex items-center justify-center w-8 h-8 bg-transparent border-none rounded-md text-text-secondary cursor-pointer transition-all duration-150 hover:bg-bg-hover hover:text-text-primary",onClick:l,children:(0,s.jsx)(th,{})})]}),(0,s.jsxs)("div",{className:"flex gap-1 py-3 px-6 border-b border-border bg-bg-tertiary",children:[(0,s.jsxs)("button",{className:"flex items-center gap-1.5 py-2 px-3.5 bg-transparent border-none rounded-md text-[13px] cursor-pointer font-[inherit] transition-all duration-150 ".concat("appearance"===h?"bg-accent text-white":"text-text-secondary hover:bg-bg-hover hover:text-text-primary"),onClick:()=>p("appearance"),children:[(0,s.jsx)(tp,{}),"Appearance"]}),(0,s.jsxs)("button",{className:"flex items-center gap-1.5 py-2 px-3.5 bg-transparent border-none rounded-md text-[13px] cursor-pointer font-[inherit] transition-all duration-150 ".concat("notifications"===h?"bg-accent text-white":"text-text-secondary hover:bg-bg-hover hover:text-text-primary"),onClick:()=>p("notifications"),children:[(0,s.jsx)(tg,{}),"Notifications"]}),(0,s.jsxs)("button",{className:"flex items-center gap-1.5 py-2 px-3.5 bg-transparent border-none rounded-md text-[13px] cursor-pointer font-[inherit] transition-all duration-150 ".concat("connection"===h?"bg-accent text-white":"text-text-secondary hover:bg-bg-hover hover:text-text-primary"),onClick:()=>p("connection"),children:[(0,s.jsx)(tb,{}),"Connection"]}),(0,s.jsxs)("button",{className:"flex items-center gap-1.5 py-2 px-3.5 bg-transparent border-none rounded-md text-[13px] cursor-pointer font-[inherit] transition-all duration-150 ".concat("providers"===h?"bg-accent text-white":"text-text-secondary hover:bg-bg-hover hover:text-text-primary"),onClick:()=>p("providers"),children:[(0,s.jsx)(tv,{}),"Providers"]}),(0,s.jsxs)("button",{className:"flex items-center gap-1.5 py-2 px-3.5 bg-transparent border-none rounded-md text-[13px] cursor-pointer font-[inherit] transition-all duration-150 ".concat("trajectories"===h?"bg-accent text-white":"text-text-secondary hover:bg-bg-hover hover:text-text-primary"),onClick:()=>p("trajectories"),children:[(0,s.jsx)(tw,{}),"Trajectories"]})]}),(0,s.jsxs)("div",{className:"flex-1 overflow-y-auto p-6",children:["appearance"===h&&(0,s.jsxs)("div",{className:"flex flex-col gap-6",children:[(0,s.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,s.jsx)("label",{className:"text-xs font-semibold text-text-muted uppercase tracking-[0.5px]",children:"Theme"}),(0,s.jsx)("div",{className:"flex gap-2",children:["light","dark","system"].map(e=>(0,s.jsxs)("button",{className:"flex flex-col items-center gap-1.5 py-4 px-5 border-2 rounded-lg text-xs cursor-pointer font-[inherit] transition-all duration-150 flex-1 ".concat(c.theme===e?"bg-accent-light border-accent text-accent":"bg-bg-hover border-transparent text-text-secondary hover:bg-bg-active"),onClick:()=>U(e),children:["light"===e&&(0,s.jsx)(tf,{}),"dark"===e&&(0,s.jsx)(tj,{}),"system"===e&&(0,s.jsx)(ty,{}),(0,s.jsx)("span",{children:e.charAt(0).toUpperCase()+e.slice(1)})]},e))})]}),(0,s.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,s.jsx)("label",{className:"text-xs font-semibold text-text-muted uppercase tracking-[0.5px]",children:"Display Options"}),(0,s.jsx)(tm,{label:"Compact mode",description:"Show more content in less space",checked:c.display.compactMode,onChange:e=>I("display","compactMode",e)}),(0,s.jsx)(tm,{label:"Show timestamps",description:"Display time for each message",checked:c.display.showTimestamps,onChange:e=>I("display","showTimestamps",e)}),(0,s.jsx)(tm,{label:"Show avatars",description:"Display agent avatars in messages",checked:c.display.showAvatars,onChange:e=>I("display","showAvatars",e)}),(0,s.jsx)(tm,{label:"Enable animations",description:"Smooth transitions and effects",checked:c.display.animationsEnabled,onChange:e=>I("display","animationsEnabled",e)})]})]}),"notifications"===h&&(0,s.jsx)("div",{className:"flex flex-col gap-6",children:(0,s.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,s.jsx)("label",{className:"text-xs font-semibold text-text-muted uppercase tracking-[0.5px]",children:"Notification Preferences"}),(0,s.jsx)(tm,{label:"Enable notifications",description:"Receive alerts for new messages",checked:c.notifications.enabled,onChange:e=>I("notifications","enabled",e)}),(0,s.jsx)(tm,{label:"Sound alerts",description:"Play sound for new messages",checked:c.notifications.sound,onChange:e=>I("notifications","sound",e),disabled:!c.notifications.enabled}),(0,s.jsx)(tm,{label:"Desktop notifications",description:"Show system notifications",checked:c.notifications.desktop,onChange:e=>I("notifications","desktop",e),disabled:!c.notifications.enabled}),(0,s.jsx)(tm,{label:"Mentions only",description:"Only notify when mentioned",checked:c.notifications.mentionsOnly,onChange:e=>I("notifications","mentionsOnly",e),disabled:!c.notifications.enabled})]})}),"connection"===h&&(0,s.jsx)("div",{className:"flex flex-col gap-6",children:(0,s.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,s.jsx)("label",{className:"text-xs font-semibold text-text-muted uppercase tracking-[0.5px]",children:"Connection Settings"}),(0,s.jsx)(tm,{label:"Auto-reconnect",description:"Automatically reconnect on disconnect",checked:c.connection.autoReconnect,onChange:e=>I("connection","autoReconnect",e)}),(0,s.jsxs)("div",{className:"flex flex-col gap-1.5 p-3 bg-bg-hover rounded-lg",children:[(0,s.jsx)("label",{className:"text-sm font-medium text-text-primary",children:"Reconnect delay (ms)"}),(0,s.jsx)("input",{type:"number",className:"py-2 px-3 border border-border rounded-md text-sm font-[inherit] outline-none transition-colors duration-150 bg-bg-tertiary text-text-primary focus:border-accent disabled:bg-bg-hover disabled:text-text-muted",value:c.connection.reconnectDelay,onChange:e=>I("connection","reconnectDelay",parseInt(e.target.value)||3e3),min:1e3,max:3e4,step:1e3,disabled:!c.connection.autoReconnect})]}),(0,s.jsxs)("div",{className:"flex flex-col gap-1.5 p-3 bg-bg-hover rounded-lg",children:[(0,s.jsx)("label",{className:"text-sm font-medium text-text-primary",children:"Keep-alive interval (ms)"}),(0,s.jsx)("input",{type:"number",className:"py-2 px-3 border border-border rounded-md text-sm font-[inherit] outline-none transition-colors duration-150 bg-bg-tertiary text-text-primary focus:border-accent disabled:bg-bg-hover disabled:text-text-muted",value:c.connection.keepAliveInterval,onChange:e=>I("connection","keepAliveInterval",parseInt(e.target.value)||3e4),min:5e3,max:12e4,step:5e3})]})]})}),"providers"===h&&(0,s.jsx)("div",{className:"flex flex-col gap-6",children:(0,s.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,s.jsx)("label",{className:"text-xs font-semibold text-text-muted uppercase tracking-[0.5px]",children:"AI Providers"}),(0,s.jsx)("p",{className:"text-sm text-text-secondary",children:"Connect AI providers to spawn agents. API keys are stored securely."}),w&&(0,s.jsx)("div",{className:"p-3 bg-red-500/10 border border-red-500/30 rounded-md text-red-400 text-sm",children:w}),(0,s.jsx)("div",{className:"flex flex-col gap-2",children:tx.map(e=>(0,s.jsxs)("div",{className:"p-4 bg-bg-hover rounded-lg border border-border",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,s.jsxs)("div",{className:"flex items-center gap-3",children:[(0,s.jsx)("div",{className:"w-10 h-10 rounded-lg flex items-center justify-center text-white font-bold text-sm",style:{backgroundColor:e.color},children:e.displayName[0]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("h4",{className:"text-sm font-semibold text-text-primary",children:e.displayName}),(0,s.jsx)("p",{className:"text-xs text-text-muted",children:e.description})]})]}),g[e.id]&&(0,s.jsx)("span",{className:"px-2 py-1 bg-green-500/20 text-green-400 text-xs rounded-full",children:"Connected"})]}),!g[e.id]&&(0,s.jsx)("div",{className:"mt-3",children:(null==k?void 0:k.providerId)===e.id?(0,s.jsxs)("div",{className:"space-y-3",children:["starting"===k.status&&(0,s.jsxs)("div",{className:"flex items-center gap-2 text-sm text-text-secondary",children:[(0,s.jsx)("span",{className:"animate-spin",children:"⏳"}),"Starting authentication..."]}),"waiting_auth"===k.status&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{className:"flex items-center gap-2 text-sm text-text-secondary",children:[(0,s.jsx)("span",{className:"animate-pulse",children:"\uD83D\uDD10"}),"Complete login in the popup window"]}),k.authUrl&&(0,s.jsxs)("div",{className:"text-xs text-text-muted",children:["Popup didn't open?"," ",(0,s.jsx)("button",{onClick:()=>T(k.authUrl,e.displayName),className:"text-accent hover:underline",children:"Click here"})]})]}),(0,s.jsx)("button",{onClick:B,className:"text-sm text-text-muted hover:text-text-secondary",children:"Cancel"})]}):S[e.id]?(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)("input",{type:"password",placeholder:"Enter ".concat(e.displayName," ").concat(e.apiKeyName||"API key"),value:f===e.id?y:"",onChange:t=>{j(e.id),v(t.target.value)},onFocus:()=>j(e.id),className:"flex-1 py-2 px-3 border border-border rounded-md text-sm bg-bg-tertiary text-text-primary placeholder-text-muted focus:outline-none focus:border-accent"}),(0,s.jsx)("button",{onClick:()=>_(e),disabled:f!==e.id||!y.trim(),className:"px-4 py-2 bg-accent text-white text-sm font-medium rounded-md hover:bg-accent-hover disabled:opacity-50 disabled:cursor-not-allowed transition-colors",children:"Connect"})]}),e.apiKeyUrl&&(0,s.jsxs)("div",{className:"text-xs text-text-muted",children:["Get your API key from"," ",(0,s.jsx)("a",{href:e.apiKeyUrl,target:"_blank",rel:"noopener noreferrer",className:"text-accent hover:underline",children:new URL(e.apiKeyUrl).hostname})]}),(0,s.jsx)("button",{onClick:()=>A(t=>({...t,[e.id]:!1})),className:"text-xs text-text-muted hover:text-text-secondary",children:"← Back to OAuth login"})]}):(0,s.jsxs)("div",{className:"space-y-2",children:[(0,s.jsxs)("button",{onClick:()=>M(e),disabled:null!==f,className:"w-full py-2.5 px-4 bg-accent text-white text-sm font-medium rounded-md hover:bg-accent-hover disabled:opacity-50 disabled:cursor-not-allowed transition-colors flex items-center justify-center gap-2",children:[(0,s.jsx)("span",{children:"\uD83D\uDD10"}),"Connect with ",e.displayName]}),e.apiKeyUrl&&(0,s.jsx)("button",{onClick:()=>A(t=>({...t,[e.id]:!0})),className:"w-full text-xs text-text-muted hover:text-text-secondary",children:"Or enter API key manually"})]})}),(0,s.jsxs)("div",{className:"mt-2 text-xs text-text-dim",children:["CLI: ",(0,s.jsx)("code",{className:"px-1 py-0.5 bg-bg-tertiary rounded",children:e.cliCommand})]})]},e.id))})]})}),"trajectories"===h&&(0,s.jsx)("div",{className:"flex flex-col gap-6",children:L.loading?(0,s.jsx)("div",{className:"flex items-center justify-center py-8",children:(0,s.jsx)("div",{className:"text-text-muted",children:"Loading settings..."})}):L.error?(0,s.jsxs)("div",{className:"p-4 bg-red-500/10 border border-red-500/30 rounded-lg",children:[(0,s.jsx)("p",{className:"text-red-400 text-sm",children:L.error}),(0,s.jsx)("button",{className:"mt-2 text-sm text-accent hover:underline",onClick:W,children:"Retry"})]}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("div",{className:"p-4 bg-gradient-to-r from-accent/10 to-accent/5 border border-accent/20 rounded-lg",children:[(0,s.jsxs)("h3",{className:"text-base font-semibold text-text-primary mb-2 flex items-center gap-2",children:[(0,s.jsx)(tw,{}),"What are Trajectories?"]}),(0,s.jsx)("p",{className:"text-sm text-text-secondary mb-3",children:(null===(t=L.documentation)||void 0===t?void 0:t.description)||"Trajectories record the journey of agent work using the PDERO paradigm (Plan, Design, Execute, Review, Observe). They capture decisions, phase transitions, and retrospectives."}),(0,s.jsxs)("div",{className:"mb-3",children:[(0,s.jsx)("h4",{className:"text-xs font-semibold text-text-muted uppercase mb-2",children:"Benefits"}),(0,s.jsx)("ul",{className:"list-none p-0 m-0 space-y-1.5",children:((null===(r=L.documentation)||void 0===r?void 0:r.benefits)||["Track why decisions were made, not just what was built","Enable session recovery when agents crash","Provide learning data for future agents","Create audit trails of AI work"]).map((e,t)=>(0,s.jsxs)("li",{className:"flex items-start gap-2 text-sm text-text-secondary",children:[(0,s.jsx)("span",{className:"text-accent",children:"✓"}),e]},t))})]}),(0,s.jsxs)("a",{href:(null===(a=L.documentation)||void 0===a?void 0:a.learnMore)||"https://pdero.com",target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-sm text-accent hover:underline",children:["Learn more about PDERO",(0,s.jsx)(tN,{})]})]}),(0,s.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,s.jsx)("label",{className:"text-xs font-semibold text-text-muted uppercase tracking-[0.5px]",children:"Storage Settings"}),(0,s.jsx)(tm,{label:"Store trajectories in repository",description:(null===(o=L.documentation)||void 0===o?void 0:o.storeInRepoExplanation)||"When enabled, trajectories are saved to .trajectories/ in your repo and can be committed to source control.",checked:L.storeInRepo,onChange:e=>D(e)}),(0,s.jsxs)("div",{className:"p-3 bg-bg-hover rounded-lg",children:[(0,s.jsx)("div",{className:"flex items-center gap-2 mb-1",children:(0,s.jsx)("span",{className:"text-sm font-medium text-text-primary",children:"Current storage location"})}),(0,s.jsx)("code",{className:"text-xs text-text-muted bg-bg-tertiary px-2 py-1 rounded",children:L.storageLocation||"user (~/.config/agent-relay/trajectories/)"})]})]}),(0,s.jsxs)("div",{className:"p-3 bg-bg-hover rounded-lg border border-border",children:[(0,s.jsx)("h4",{className:"text-sm font-medium text-text-primary mb-1",children:"Why opt-in to repo storage?"}),(0,s.jsx)("p",{className:"text-xs text-text-muted",children:"Teams who want to review agent decision-making processes can store trajectories in the repo to version control them alongside code. This makes it easy to understand why agents made specific choices during code review."})]})]})})]}),(0,s.jsxs)("div",{className:"flex items-center justify-between py-4 px-6 border-t border-border",children:[x&&(0,s.jsx)("button",{className:"py-2 px-4 bg-transparent border border-border rounded-md text-[13px] text-text-secondary cursor-pointer font-[inherit] transition-all duration-150 hover:bg-bg-hover hover:text-text-primary",onClick:x,children:"Reset to defaults"}),(0,s.jsx)("button",{className:"py-2 px-5 bg-accent border-none rounded-md text-[13px] font-medium text-white cursor-pointer font-[inherit] transition-colors duration-150 hover:bg-accent-hover",onClick:l,children:"Done"})]})]})}):null}function tm(e){let{label:t,description:r,checked:n,onChange:a,disabled:o}=e;return(0,s.jsxs)("div",{className:"flex items-center justify-between p-3 bg-bg-hover rounded-lg ".concat(o?"opacity-50":""),children:[(0,s.jsxs)("div",{className:"flex flex-col gap-0.5",children:[(0,s.jsx)("span",{className:"text-sm font-medium text-text-primary",children:t}),(0,s.jsx)("span",{className:"text-xs text-text-muted",children:r})]}),(0,s.jsx)("button",{className:"w-11 h-6 border-none rounded-xl cursor-pointer relative transition-colors duration-200 ".concat(n?"bg-accent":"bg-border-medium"," ").concat(o?"cursor-not-allowed":""),onClick:()=>!o&&a(!n),disabled:o,role:"switch","aria-checked":n,children:(0,s.jsx)("span",{className:"absolute top-0.5 left-0.5 w-5 h-5 bg-white rounded-full transition-transform duration-200 shadow-[0_1px_3px_rgba(0,0,0,0.2)] ".concat(n?"translate-x-5":"")})})]})}function th(){return(0,s.jsxs)("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,s.jsx)("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),(0,s.jsx)("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})}function tp(){return(0,s.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,s.jsx)("circle",{cx:"13.5",cy:"6.5",r:".5"}),(0,s.jsx)("circle",{cx:"17.5",cy:"10.5",r:".5"}),(0,s.jsx)("circle",{cx:"8.5",cy:"7.5",r:".5"}),(0,s.jsx)("circle",{cx:"6.5",cy:"12.5",r:".5"}),(0,s.jsx)("path",{d:"M12 2C6.5 2 2 6.5 2 12s4.5 10 10 10c.926 0 1.648-.746 1.648-1.688 0-.437-.18-.835-.437-1.125-.29-.289-.438-.652-.438-1.125a1.64 1.64 0 0 1 1.668-1.668h1.996c3.051 0 5.555-2.503 5.555-5.555C21.965 6.012 17.461 2 12 2z"})]})}function tg(){return(0,s.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,s.jsx)("path",{d:"M18 8A6 6 0 0 0 6 8c0 7-3 9-3 9h18s-3-2-3-9"}),(0,s.jsx)("path",{d:"M13.73 21a2 2 0 0 1-3.46 0"})]})}function tb(){return(0,s.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,s.jsx)("path",{d:"M5 12.55a11 11 0 0 1 14.08 0"}),(0,s.jsx)("path",{d:"M1.42 9a16 16 0 0 1 21.16 0"}),(0,s.jsx)("path",{d:"M8.53 16.11a6 6 0 0 1 6.95 0"}),(0,s.jsx)("line",{x1:"12",y1:"20",x2:"12.01",y2:"20"})]})}function tf(){return(0,s.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,s.jsx)("circle",{cx:"12",cy:"12",r:"5"}),(0,s.jsx)("line",{x1:"12",y1:"1",x2:"12",y2:"3"}),(0,s.jsx)("line",{x1:"12",y1:"21",x2:"12",y2:"23"}),(0,s.jsx)("line",{x1:"4.22",y1:"4.22",x2:"5.64",y2:"5.64"}),(0,s.jsx)("line",{x1:"18.36",y1:"18.36",x2:"19.78",y2:"19.78"}),(0,s.jsx)("line",{x1:"1",y1:"12",x2:"3",y2:"12"}),(0,s.jsx)("line",{x1:"21",y1:"12",x2:"23",y2:"12"}),(0,s.jsx)("line",{x1:"4.22",y1:"19.78",x2:"5.64",y2:"18.36"}),(0,s.jsx)("line",{x1:"18.36",y1:"5.64",x2:"19.78",y2:"4.22"})]})}function tj(){return(0,s.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:(0,s.jsx)("path",{d:"M21 12.79A9 9 0 1 1 11.21 3 7 7 0 0 0 21 12.79z"})})}function ty(){return(0,s.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,s.jsx)("rect",{x:"2",y:"3",width:"20",height:"14",rx:"2",ry:"2"}),(0,s.jsx)("line",{x1:"8",y1:"21",x2:"16",y2:"21"}),(0,s.jsx)("line",{x1:"12",y1:"17",x2:"12",y2:"21"})]})}function tv(){return(0,s.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,s.jsx)("path",{d:"M12 2L2 7l10 5 10-5-10-5z"}),(0,s.jsx)("path",{d:"M2 17l10 5 10-5"}),(0,s.jsx)("path",{d:"M2 12l10 5 10-5"})]})}function tw(){return(0,s.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:(0,s.jsx)("path",{d:"M22 12h-4l-3 9L9 3l-3 9H2"})})}function tN(){return(0,s.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,s.jsx)("path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"}),(0,s.jsx)("polyline",{points:"15 3 21 3 21 9"}),(0,s.jsx)("line",{x1:"10",y1:"14",x2:"21",y2:"3"})]})}var tk=r(3083);let tC=[{id:"anthropic",name:"Anthropic",displayName:"Claude",description:"Claude Code - recommended for code tasks",color:"#D97757",cliCommand:"claude",apiKeyUrl:"https://console.anthropic.com/settings/keys",apiKeyName:"API key",supportsOAuth:!0},{id:"openai",name:"OpenAI",displayName:"Codex",description:"Codex - OpenAI coding assistant",color:"#10A37F",cliCommand:"codex login",apiKeyUrl:"https://platform.openai.com/api-keys",apiKeyName:"API key",supportsOAuth:!0,supportsDeviceFlow:!0},{id:"google",name:"Google",displayName:"Gemini",description:"Gemini - Google AI coding assistant",color:"#4285F4",cliCommand:"gemini",apiKeyUrl:"https://aistudio.google.com/app/apikey",apiKeyName:"API key",supportsOAuth:!0},{id:"opencode",name:"OpenCode",displayName:"OpenCode",description:"OpenCode - AI coding assistant",color:"#00D4AA",cliCommand:"opencode",supportsOAuth:!0},{id:"droid",name:"Factory",displayName:"Droid",description:"Droid - Factory AI coding agent",color:"#6366F1",cliCommand:"droid",supportsOAuth:!0}];function tS(e){let{workspaceId:t,csrfToken:r,onClose:a}=e,[o,i]=(0,n.useState)(null),[l,c]=(0,n.useState)([]),[d,x]=(0,n.useState)(!0),[u,m]=(0,n.useState)(null),[h,p]=(0,n.useState)("general"),[g,b]=(0,n.useState)({}),[f,j]=(0,n.useState)(null),[y,v]=(0,n.useState)(""),[w,N]=(0,n.useState)(""),[k,C]=(0,n.useState)(null),[S,A]=(0,n.useState)(null),[L,E]=(0,n.useState)({}),W=(0,n.useRef)(null),[D,M]=(0,n.useState)({}),[T,R]=(0,n.useState)(""),[P,B]=(0,n.useState)(!1),[_,I]=(0,n.useState)(null),[U,F]=(0,n.useState)(null);(0,n.useEffect)(()=>{!async function(){x(!0),m(null);let[e,r]=await Promise.all([en.xv.getWorkspaceDetails(t),en.xv.getRepos()]);if(e.success){i(e.data),e.data.customDomain&&R(e.data.customDomain);let t={};e.data.config.providers.forEach(e=>{t[e]=!0}),b(t)}else m(e.error);r.success&&c(r.data.repositories),x(!1)}()},[t]);let O=async e=>{C(null),j(e.id),A({providerId:e.id,sessionId:"",status:"starting"}),W.current=null;try{let s={"Content-Type":"application/json"};r&&(s["X-CSRF-Token"]=r);let n=await fetch("/api/onboarding/cli/".concat(e.id,"/start"),{method:"POST",credentials:"include",headers:s,body:JSON.stringify({workspaceId:t,useDeviceFlow:D[e.id]||!1})}),a=await n.json();if(!n.ok)throw Error(a.error||"Failed to start authentication");if("success"===a.status||a.alreadyAuthenticated){b(t=>({...t,[e.id]:!0})),A(null),j(null);return}let o={providerId:e.id,sessionId:a.sessionId,authUrl:a.authUrl,status:a.authUrl?"waiting_auth":a.status||"starting"};A(o),a.authUrl?(W.current=a.sessionId,z(a.authUrl,e.displayName),H(e.id,a.sessionId)):"starting"===a.status&&H(e.id,a.sessionId)}catch(e){C(e instanceof Error?e.message:"Failed to start OAuth"),A(null),j(null)}},z=(e,t)=>{let r=window.screenX+(window.outerWidth-600)/2,s=window.screenY+(window.outerHeight-700)/2;window.open(e,"".concat(t," Login"),"width=".concat(600,",height=").concat(700,",left=").concat(r,",top=").concat(s,",popup=yes"))},H=async(e,t)=>{let r=0,s=async()=>{if(r>=60){C("Authentication timed out. Please try again."),A(null),j(null),W.current=null;return}try{let a=await fetch("/api/onboarding/cli/".concat(e,"/status/").concat(t),{credentials:"include"}),o=await a.json();if(!a.ok)throw Error(o.error||"Failed to check status");if("success"===o.status){await V(e,t);return}if("error"===o.status)throw Error(o.error||"Authentication failed");if("waiting_auth"===o.status&&o.authUrl&&W.current!==t){var n;W.current=t,A(e=>e?{...e,authUrl:o.authUrl,status:"waiting_auth"}:null),z(o.authUrl,(null===(n=tC.find(t=>t.id===e))||void 0===n?void 0:n.displayName)||"Provider")}r++,setTimeout(s,5e3)}catch(e){C(e instanceof Error?e.message:"Auth check failed"),A(null),j(null),W.current=null}};s()},V=async(e,t)=>{try{let s={"Content-Type":"application/json"};r&&(s["X-CSRF-Token"]=r);let n=await fetch("/api/onboarding/cli/".concat(e,"/complete/").concat(t),{method:"POST",credentials:"include",headers:s});if(!n.ok){let e=await n.json();throw Error(e.error||"Failed to complete authentication")}b(t=>({...t,[e]:!0})),A(null),j(null),W.current=null}catch(e){C(e instanceof Error?e.message:"Failed to complete auth"),A(null),j(null),W.current=null}},G=async e=>{if(!y.trim()){C("Please enter an API key");return}C(null),j(e.id);try{let t={"Content-Type":"application/json"};r&&(t["X-CSRF-Token"]=r);let s=await fetch("/api/onboarding/token/".concat(e.id),{method:"POST",credentials:"include",headers:t,body:JSON.stringify({token:y.trim()})});if(!s.ok){let e=await s.json();throw Error(e.error||"Failed to connect")}b(t=>({...t,[e.id]:!0})),v(""),j(null),E(t=>({...t,[e.id]:!1}))}catch(e){C(e instanceof Error?e.message:"Failed to connect"),j(null)}},K=(0,n.useCallback)(async()=>{if(!o||!window.confirm("Are you sure you want to restart this workspace?"))return;let e=await en.xv.restartWorkspace(o.id);if(e.success){let e=await en.xv.getWorkspaceDetails(t);e.success&&i(e.data)}else m(e.error)},[o,t]),J=(0,n.useCallback)(async()=>{if(!o||!window.confirm("Are you sure you want to stop this workspace?"))return;let e=await en.xv.stopWorkspace(o.id);if(e.success){let e=await en.xv.getWorkspaceDetails(t);e.success&&i(e.data)}else m(e.error)},[o,t]),q=(0,n.useCallback)(async e=>{if(!o)return;let r=await en.xv.addReposToWorkspace(o.id,[e]);if(r.success){let e=await en.xv.getWorkspaceDetails(t);e.success&&i(e.data)}else m(r.error)},[o,t]),X=(0,n.useCallback)(async()=>{if(!o||!T.trim())return;B(!0),I(null),F(null);let e=await en.xv.setCustomDomain(o.id,T.trim());if(e.success){F(e.data.instructions);let r=await en.xv.getWorkspaceDetails(t);r.success&&i(r.data)}else I(e.error);B(!1)},[o,T,t]),Y=(0,n.useCallback)(async()=>{if(!o)return;B(!0),I(null);let e=await en.xv.verifyCustomDomain(o.id);if(e.success){let r=await en.xv.getWorkspaceDetails(t);r.success&&i(r.data),"active"===e.data.status&&F(null)}else I(e.error);B(!1)},[o,t]),$=(0,n.useCallback)(async()=>{if(!o||!window.confirm("Are you sure you want to remove the custom domain?"))return;B(!0);let e=await en.xv.removeCustomDomain(o.id);if(e.success){R(""),F(null);let e=await en.xv.getWorkspaceDetails(t);e.success&&i(e.data)}else I(e.error);B(!1)},[o,t]),Z=(0,n.useCallback)(async()=>{if(!o||!window.confirm('Are you sure you want to delete "'.concat(o.name,'"? This action cannot be undone.'))||!window.confirm("This will permanently delete all workspace data. Are you absolutely sure?"))return;let e=await en.xv.deleteWorkspace(o.id);e.success?null==a||a():m(e.error)},[o,a]);if(d)return(0,s.jsxs)("div",{className:"flex items-center justify-center h-64",children:[(0,s.jsxs)("div",{className:"relative",children:[(0,s.jsx)("div",{className:"w-12 h-12 rounded-full border-2 border-accent-cyan/20 border-t-accent-cyan animate-spin"}),(0,s.jsx)("div",{className:"absolute inset-0 flex items-center justify-center",children:(0,s.jsx)("div",{className:"w-4 h-4 rounded-full bg-accent-cyan/40 animate-pulse"})})]}),(0,s.jsx)("span",{className:"ml-4 text-text-muted font-mono text-sm tracking-wide",children:"LOADING WORKSPACE CONFIG..."})]});if(u&&!o)return(0,s.jsx)("div",{className:"p-6",children:(0,s.jsxs)("div",{className:"p-4 bg-error/10 border border-error/30 rounded-lg text-error flex items-center gap-3",children:[(0,s.jsx)(tB,{}),(0,s.jsx)("span",{children:u})]})});if(!o)return null;let Q=l.filter(e=>!o.repositories.some(t=>t.id===e.id)),ee=[{id:"general",label:"General",icon:(0,s.jsx)(tM,{})},{id:"providers",label:"AI Providers",icon:(0,s.jsx)(tT,{})},{id:"repos",label:"Repositories",icon:(0,s.jsx)(tR,{})},{id:"domain",label:"Domain",icon:(0,s.jsx)(tP,{})},{id:"danger",label:"Danger",icon:(0,s.jsx)(tB,{})}];return(0,s.jsxs)("div",{className:"flex flex-col h-full bg-bg-primary",children:[(0,s.jsx)("div",{className:"flex gap-1 p-3 border-b border-border-subtle bg-gradient-to-b from-bg-tertiary to-bg-primary",children:ee.map(e=>(0,s.jsxs)("button",{onClick:()=>p(e.id),className:"flex items-center gap-2 px-4 py-2.5 rounded-lg text-sm font-medium transition-all duration-200 ".concat(h===e.id?"bg-accent-cyan/15 text-accent-cyan border border-accent-cyan/30 shadow-[0_0_12px_rgba(0,217,255,0.15)]":"text-text-secondary hover:bg-bg-hover hover:text-text-primary border border-transparent"),children:[(0,s.jsx)("span",{className:h===e.id?"text-accent-cyan":"text-text-muted",children:e.icon}),e.label]},e.id))}),(0,s.jsxs)("div",{className:"flex-1 overflow-y-auto p-6",children:[u&&(0,s.jsxs)("div",{className:"mb-6 p-4 bg-error/10 border border-error/30 rounded-lg text-error text-sm flex items-center gap-3",children:[(0,s.jsx)(tB,{}),(0,s.jsx)("span",{className:"flex-1",children:u}),(0,s.jsx)("button",{onClick:()=>m(null),className:"text-error/60 hover:text-error",children:(0,s.jsx)(tz,{})})]}),"general"===h&&(0,s.jsxs)("div",{className:"space-y-8",children:[(0,s.jsx)(tA,{title:"Workspace Overview",subtitle:"Core configuration and status"}),(0,s.jsxs)("div",{className:"grid grid-cols-2 gap-4",children:[(0,s.jsx)(tL,{label:"Name",value:o.name}),(0,s.jsx)(tL,{label:"Status",value:o.status.charAt(0).toUpperCase()+o.status.slice(1),valueColor:"running"===o.status?"text-success":"stopped"===o.status?"text-amber-400":"error"===o.status?"text-error":"text-text-muted",indicator:"running"===o.status}),(0,s.jsx)(tL,{label:"Public URL",value:o.publicUrl||"Not available",mono:!0}),(0,s.jsx)(tL,{label:"Compute Provider",value:o.computeProvider.charAt(0).toUpperCase()+o.computeProvider.slice(1)})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)(tA,{title:"Actions",subtitle:"Manage workspace state"}),(0,s.jsxs)("div",{className:"flex gap-3 mt-4",children:["running"===o.status&&(0,s.jsx)(tE,{onClick:J,variant:"warning",icon:(0,s.jsx)(tI,{}),children:"Stop Workspace"}),(0,s.jsx)(tE,{onClick:K,variant:"primary",icon:(0,s.jsx)(tU,{}),children:"Restart Workspace"})]})]})]}),"providers"===h&&(0,s.jsxs)("div",{className:"space-y-8",children:[(0,s.jsx)(tA,{title:"AI Providers",subtitle:"Connect AI providers to spawn agents in this workspace"}),k&&(0,s.jsxs)("div",{className:"p-4 bg-error/10 border border-error/30 rounded-lg text-error text-sm flex items-center gap-3",children:[(0,s.jsx)(tB,{}),(0,s.jsx)("span",{children:k})]}),(0,s.jsx)("div",{className:"space-y-4",children:tC.map(e=>(0,s.jsxs)("div",{className:"p-5 bg-bg-tertiary rounded-xl border border-border-subtle hover:border-border-medium transition-all duration-200",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between",children:[(0,s.jsxs)("div",{className:"flex items-center gap-4",children:[(0,s.jsx)("div",{className:"w-12 h-12 rounded-xl flex items-center justify-center text-white font-bold text-lg shadow-lg",style:{backgroundColor:e.color,boxShadow:"0 4px 20px ".concat(e.color,"40")},children:e.displayName[0]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("h4",{className:"text-base font-semibold text-text-primary",children:e.displayName}),(0,s.jsx)("p",{className:"text-sm text-text-muted",children:e.description})]})]}),g[e.id]?(0,s.jsxs)("div",{className:"flex items-center gap-2 px-4 py-2 bg-success/15 rounded-full border border-success/30",children:[(0,s.jsx)("div",{className:"w-2 h-2 rounded-full bg-success animate-pulse"}),(0,s.jsx)("span",{className:"text-sm font-medium text-success",children:"Connected"})]}):null]}),!g[e.id]&&(0,s.jsx)("div",{className:"mt-5 pt-5 border-t border-border-subtle",children:f===e.id?(0,s.jsx)(tk.j,{provider:{id:e.id,name:e.name,displayName:e.displayName,color:e.color,requiresUrlCopy:"openai"===e.id},workspaceId:t,csrfToken:r,useDeviceFlow:D[e.id]||!1,onSuccess:()=>{b(t=>({...t,[e.id]:!0})),j(null),A(null)},onCancel:()=>{j(null),A(null)},onError:e=>{C(e),j(null),A(null)}}):L[e.id]?(0,s.jsxs)("div",{className:"space-y-4",children:[(0,s.jsxs)("div",{className:"flex gap-3",children:[(0,s.jsx)("input",{type:"password",placeholder:"Enter ".concat(e.displayName," ").concat(e.apiKeyName||"API key"),value:f===e.id?y:"",onChange:t=>{j(e.id),v(t.target.value)},onFocus:()=>j(e.id),className:"flex-1 px-4 py-3 bg-bg-card border border-border-subtle rounded-lg text-sm text-text-primary placeholder:text-text-muted focus:outline-none focus:border-accent-cyan focus:ring-1 focus:ring-accent-cyan/30 transition-all"}),(0,s.jsx)("button",{onClick:()=>G(e),disabled:f!==e.id||!y.trim(),className:"px-5 py-3 bg-accent-cyan text-bg-deep font-semibold rounded-lg text-sm hover:bg-accent-cyan/90 disabled:opacity-50 disabled:cursor-not-allowed transition-all",children:"Connect"})]}),e.apiKeyUrl&&(0,s.jsxs)("p",{className:"text-xs text-text-muted",children:["Get your API key from"," ",(0,s.jsx)("a",{href:e.apiKeyUrl,target:"_blank",rel:"noopener noreferrer",className:"text-accent-cyan hover:underline",children:new URL(e.apiKeyUrl).hostname})]}),e.supportsOAuth&&(0,s.jsx)("button",{onClick:()=>E(t=>({...t,[e.id]:!1})),className:"text-xs text-text-muted hover:text-text-secondary transition-colors",children:"← Back to OAuth login"})]}):e.supportsOAuth?(0,s.jsxs)("div",{className:"space-y-3",children:[e.supportsDeviceFlow&&(0,s.jsxs)("label",{className:"flex items-center gap-2 text-xs text-text-secondary cursor-pointer",children:[(0,s.jsx)("input",{type:"checkbox",checked:D[e.id]||!1,onChange:t=>M(r=>({...r,[e.id]:t.target.checked})),className:"w-4 h-4 rounded border-border-subtle bg-bg-card text-accent-cyan focus:ring-accent-cyan/30 cursor-pointer"}),"Use device flow (easier for containers/headless)"]}),(0,s.jsxs)("button",{onClick:()=>O(e),disabled:null!==f,className:"w-full py-3 px-4 bg-gradient-to-r from-accent-cyan to-[#00b8d9] text-bg-deep font-semibold rounded-lg text-sm hover:shadow-glow-cyan hover:-translate-y-0.5 disabled:opacity-50 disabled:cursor-not-allowed disabled:hover:translate-y-0 disabled:hover:shadow-none transition-all duration-200 flex items-center justify-center gap-2",children:[(0,s.jsx)(t_,{}),"Connect with ",e.displayName]}),e.apiKeyUrl&&(0,s.jsx)("button",{onClick:()=>E(t=>({...t,[e.id]:!0})),className:"w-full text-xs text-text-muted hover:text-text-secondary transition-colors",children:"Or enter API key manually"})]}):(0,s.jsxs)("div",{className:"space-y-4",children:[(0,s.jsxs)("div",{className:"flex gap-3",children:[(0,s.jsx)("input",{type:"password",placeholder:"Enter ".concat(e.displayName," ").concat(e.apiKeyName||"API key"),value:f===e.id?y:"",onChange:t=>{j(e.id),v(t.target.value)},onFocus:()=>j(e.id),className:"flex-1 px-4 py-3 bg-bg-card border border-border-subtle rounded-lg text-sm text-text-primary placeholder:text-text-muted focus:outline-none focus:border-accent-cyan focus:ring-1 focus:ring-accent-cyan/30 transition-all"}),(0,s.jsx)("button",{onClick:()=>G(e),disabled:f!==e.id||!y.trim(),className:"px-5 py-3 bg-accent-cyan text-bg-deep font-semibold rounded-lg text-sm hover:bg-accent-cyan/90 disabled:opacity-50 disabled:cursor-not-allowed transition-all",children:"Connect"})]}),e.apiKeyUrl&&(0,s.jsxs)("p",{className:"text-xs text-text-muted",children:["Get your API key from"," ",(0,s.jsx)("a",{href:e.apiKeyUrl,target:"_blank",rel:"noopener noreferrer",className:"text-accent-cyan hover:underline",children:new URL(e.apiKeyUrl).hostname})]}),(0,s.jsxs)("p",{className:"text-xs text-amber-400/80",children:["OAuth not available for ",e.displayName," in container environments"]})]})}),(0,s.jsx)("div",{className:"mt-4 pt-4 border-t border-border-subtle",children:(0,s.jsxs)("p",{className:"text-xs text-text-muted",children:["CLI: ",(0,s.jsx)("code",{className:"px-2 py-1 bg-bg-card rounded font-mono",children:e.cliCommand})]})})]},e.id))})]}),"repos"===h&&(0,s.jsxs)("div",{className:"space-y-8",children:[(0,s.jsx)(tA,{title:"Connected Repositories",subtitle:"Repositories linked to this workspace"}),(0,s.jsx)("div",{className:"space-y-3",children:o.repositories.length>0?o.repositories.map(e=>(0,s.jsxs)("div",{className:"flex items-center justify-between p-4 bg-bg-tertiary rounded-lg border border-border-subtle",children:[(0,s.jsxs)("div",{className:"flex items-center gap-3",children:[(0,s.jsx)("div",{className:"w-10 h-10 rounded-lg bg-bg-card flex items-center justify-center",children:(0,s.jsx)(tR,{})}),(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"text-sm font-medium text-text-primary",children:e.fullName}),(0,s.jsx)("p",{className:"text-xs text-text-muted",children:e.lastSyncedAt?"Synced ".concat(new Date(e.lastSyncedAt).toLocaleDateString()):"Not synced"})]})]}),(0,s.jsx)(tW,{status:e.syncStatus})]},e.id)):(0,s.jsxs)("div",{className:"p-6 bg-bg-tertiary rounded-lg border border-border-subtle border-dashed text-center",children:[(0,s.jsx)(tR,{className:"w-8 h-8 mx-auto mb-3 text-text-muted"}),(0,s.jsx)("p",{className:"text-sm text-text-muted",children:"No repositories connected"})]})}),Q.length>0&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(tA,{title:"Available Repositories",subtitle:"Add more repositories to this workspace"}),(0,s.jsx)("div",{className:"space-y-3",children:Q.map(e=>(0,s.jsxs)("div",{className:"flex items-center justify-between p-4 bg-bg-tertiary rounded-lg border border-border-subtle hover:border-accent-cyan/30 transition-colors",children:[(0,s.jsxs)("div",{className:"flex items-center gap-3",children:[(0,s.jsx)("div",{className:"w-10 h-10 rounded-lg bg-bg-card flex items-center justify-center",children:(0,s.jsx)(tR,{})}),(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"text-sm font-medium text-text-primary",children:e.fullName}),(0,s.jsx)("p",{className:"text-xs text-text-muted",children:e.isPrivate?"Private":"Public"})]})]}),(0,s.jsx)("button",{onClick:()=>q(e.id),className:"px-4 py-2 bg-accent-cyan/10 border border-accent-cyan/30 text-accent-cyan rounded-lg text-xs font-semibold hover:bg-accent-cyan/20 transition-colors",children:"Add to Workspace"})]},e.id))})]})]}),"domain"===h&&(0,s.jsxs)("div",{className:"space-y-8",children:[(0,s.jsx)(tA,{title:"Custom Domain",subtitle:"Connect your own domain to this workspace"}),(0,s.jsx)("div",{className:"p-5 bg-gradient-to-r from-accent-purple/10 to-accent-cyan/10 border border-accent-purple/20 rounded-xl",children:(0,s.jsxs)("div",{className:"flex items-center gap-3 mb-3",children:[(0,s.jsx)("div",{className:"w-10 h-10 rounded-lg bg-accent-purple/20 flex items-center justify-center",children:(0,s.jsx)(tP,{className:"text-accent-purple"})}),(0,s.jsxs)("div",{children:[(0,s.jsx)("h4",{className:"text-sm font-semibold text-text-primary",children:"Premium Feature"}),(0,s.jsx)("p",{className:"text-xs text-text-secondary",children:"Requires Team or Enterprise plan"})]})]})}),o.customDomain?(0,s.jsxs)("div",{className:"space-y-4",children:[(0,s.jsxs)("div",{className:"p-5 bg-bg-tertiary rounded-xl border border-border-subtle",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between mb-3",children:[(0,s.jsx)("span",{className:"text-xs text-text-muted uppercase tracking-wide font-semibold",children:"Current Domain"}),(0,s.jsx)(tW,{status:o.customDomainStatus||"pending"})]}),(0,s.jsx)("p",{className:"text-lg font-mono text-text-primary",children:o.customDomain})]}),"pending"===o.customDomainStatus&&(0,s.jsx)(tE,{onClick:Y,disabled:P,variant:"primary",icon:(0,s.jsx)(tF,{}),fullWidth:!0,children:P?"Verifying...":"Verify DNS Configuration"}),(0,s.jsx)(tE,{onClick:$,disabled:P,variant:"danger",icon:(0,s.jsx)(tO,{}),fullWidth:!0,children:"Remove Custom Domain"})]}):(0,s.jsxs)("div",{className:"space-y-4",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"text-xs font-semibold text-text-muted uppercase tracking-wide mb-2 block",children:"Domain Name"}),(0,s.jsx)("input",{type:"text",value:T,onChange:e=>R(e.target.value),placeholder:"workspace.yourdomain.com",className:"w-full px-4 py-3 bg-bg-tertiary border border-border-subtle rounded-lg text-sm text-text-primary font-mono placeholder:text-text-muted focus:outline-none focus:border-accent-cyan focus:ring-1 focus:ring-accent-cyan/30 transition-all"})]}),(0,s.jsx)(tE,{onClick:X,disabled:P||!T.trim(),variant:"primary",icon:(0,s.jsx)(tP,{}),fullWidth:!0,children:P?"Setting up...":"Set Custom Domain"})]}),_&&(0,s.jsx)("div",{className:"p-4 bg-error/10 border border-error/30 rounded-lg text-error text-sm",children:_}),U&&(0,s.jsxs)("div",{className:"p-5 bg-bg-tertiary rounded-xl border border-border-subtle space-y-4",children:[(0,s.jsxs)("h4",{className:"text-sm font-semibold text-text-primary flex items-center gap-2",children:[(0,s.jsx)(tH,{}),"DNS Configuration Required"]}),(0,s.jsx)("p",{className:"text-xs text-text-secondary",children:"Add the following DNS record to your domain provider:"}),(0,s.jsxs)("div",{className:"grid grid-cols-3 gap-3",children:[(0,s.jsx)(tD,{label:"Type",value:U.type}),(0,s.jsx)(tD,{label:"Name",value:U.name}),(0,s.jsx)(tD,{label:"Value",value:U.value})]})]})]}),"danger"===h&&(0,s.jsx)("div",{className:"space-y-8",children:(0,s.jsxs)("div",{className:"p-6 bg-error/5 border-2 border-error/20 rounded-xl",children:[(0,s.jsxs)("div",{className:"flex items-center gap-3 mb-4",children:[(0,s.jsx)("div",{className:"w-10 h-10 rounded-lg bg-error/20 flex items-center justify-center",children:(0,s.jsx)(tB,{className:"text-error"})}),(0,s.jsxs)("div",{children:[(0,s.jsx)("h3",{className:"text-base font-semibold text-error",children:"Danger Zone"}),(0,s.jsx)("p",{className:"text-xs text-text-secondary",children:"These actions are destructive and cannot be undone"})]})]}),(0,s.jsx)("div",{className:"p-5 border border-error/30 rounded-lg bg-bg-primary",children:(0,s.jsxs)("div",{className:"flex items-center justify-between",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("h4",{className:"text-sm font-semibold text-text-primary",children:"Delete Workspace"}),(0,s.jsx)("p",{className:"text-xs text-text-muted mt-1",children:"Permanently delete this workspace and all its data"})]}),(0,s.jsx)("button",{onClick:Z,className:"px-5 py-2.5 bg-error text-white rounded-lg text-sm font-semibold hover:bg-error/90 transition-colors",children:"Delete Workspace"})]})})]})})]})]})}function tA(e){let{title:t,subtitle:r}=e;return(0,s.jsxs)("div",{className:"mb-4",children:[(0,s.jsx)("h3",{className:"text-sm font-semibold text-text-muted uppercase tracking-wide",children:t}),(0,s.jsx)("p",{className:"text-xs text-text-muted mt-1",children:r})]})}function tL(e){let{label:t,value:r,valueColor:n="text-text-primary",mono:a=!1,indicator:o=!1}=e;return(0,s.jsxs)("div",{className:"p-4 bg-bg-tertiary rounded-lg border border-border-subtle",children:[(0,s.jsx)("label",{className:"text-xs text-text-muted uppercase tracking-wide font-medium",children:t}),(0,s.jsxs)("div",{className:"flex items-center gap-2 mt-1",children:[o&&(0,s.jsx)("div",{className:"w-2 h-2 rounded-full bg-success animate-pulse"}),(0,s.jsx)("p",{className:"text-sm font-medium ".concat(n," ").concat(a?"font-mono":""," break-all"),children:r})]})]})}function tE(e){let{children:t,onClick:r,disabled:n,variant:a,icon:o,fullWidth:i}=e;return(0,s.jsxs)("button",{onClick:r,disabled:n,className:"".concat(i?"w-full":""," px-5 py-2.5 border rounded-lg text-sm font-semibold transition-all duration-200 disabled:opacity-50 disabled:cursor-not-allowed flex items-center justify-center gap-2 ").concat({primary:"bg-accent-cyan/10 border-accent-cyan/30 text-accent-cyan hover:bg-accent-cyan/20",warning:"bg-amber-400/10 border-amber-400/30 text-amber-400 hover:bg-amber-400/20",danger:"bg-error/10 border-error/30 text-error hover:bg-error/20"}[a]),children:[o,t]})}function tW(e){let{status:t}=e;return(0,s.jsx)("span",{className:"text-xs px-3 py-1 rounded-full border ".concat({synced:"bg-success/15 text-success border-success/30",active:"bg-success/15 text-success border-success/30",syncing:"bg-accent-cyan/15 text-accent-cyan border-accent-cyan/30",verifying:"bg-accent-cyan/15 text-accent-cyan border-accent-cyan/30",pending:"bg-amber-400/15 text-amber-400 border-amber-400/30",error:"bg-error/15 text-error border-error/30"}[t]||"bg-bg-hover text-text-muted border-border-subtle"),children:t})}function tD(e){let{label:t,value:r}=e;return(0,s.jsxs)("div",{className:"p-3 bg-bg-card rounded-lg",children:[(0,s.jsx)("label",{className:"text-xs text-text-muted block mb-1",children:t}),(0,s.jsx)("p",{className:"font-mono text-sm text-text-primary break-all",children:r})]})}function tM(){return(0,s.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,s.jsx)("circle",{cx:"12",cy:"12",r:"3"}),(0,s.jsx)("path",{d:"M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-2 2 2 2 0 0 1-2-2v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1-2-2 2 2 0 0 1 2-2h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 2-2 2 2 0 0 1 2 2v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 2 2 2 2 0 0 1-2 2h-.09a1.65 1.65 0 0 0-1.51 1z"})]})}function tT(){return(0,s.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,s.jsx)("path",{d:"M12 2L2 7l10 5 10-5-10-5z"}),(0,s.jsx)("path",{d:"M2 17l10 5 10-5"}),(0,s.jsx)("path",{d:"M2 12l10 5 10-5"})]})}function tR(e){let{className:t=""}=e;return(0,s.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"text-text-muted ".concat(t),children:(0,s.jsx)("path",{d:"M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z"})})}function tP(e){let{className:t=""}=e;return(0,s.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:[(0,s.jsx)("circle",{cx:"12",cy:"12",r:"10"}),(0,s.jsx)("line",{x1:"2",y1:"12",x2:"22",y2:"12"}),(0,s.jsx)("path",{d:"M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z"})]})}function tB(e){let{className:t=""}=e;return(0,s.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:[(0,s.jsx)("path",{d:"M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z"}),(0,s.jsx)("line",{x1:"12",y1:"9",x2:"12",y2:"13"}),(0,s.jsx)("line",{x1:"12",y1:"17",x2:"12.01",y2:"17"})]})}function t_(){return(0,s.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,s.jsx)("rect",{x:"3",y:"11",width:"18",height:"11",rx:"2",ry:"2"}),(0,s.jsx)("path",{d:"M7 11V7a5 5 0 0 1 10 0v4"})]})}function tI(){return(0,s.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:(0,s.jsx)("rect",{x:"6",y:"6",width:"12",height:"12"})})}function tU(){return(0,s.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,s.jsx)("path",{d:"M23 4v6h-6"}),(0,s.jsx)("path",{d:"M20.49 15a9 9 0 1 1-2.12-9.36L23 10"})]})}function tF(){return(0,s.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:(0,s.jsx)("polyline",{points:"20 6 9 17 4 12"})})}function tO(){return(0,s.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,s.jsx)("polyline",{points:"3 6 5 6 21 6"}),(0,s.jsx)("path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"})]})}function tz(){return(0,s.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,s.jsx)("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),(0,s.jsx)("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})}function tH(){return(0,s.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,s.jsx)("circle",{cx:"12",cy:"12",r:"10"}),(0,s.jsx)("line",{x1:"12",y1:"16",x2:"12",y2:"12"}),(0,s.jsx)("line",{x1:"12",y1:"8",x2:"12.01",y2:"8"})]})}let tV={owner:"bg-accent-purple/20 text-accent-purple",admin:"bg-accent-cyan/20 text-accent-cyan",member:"bg-success/20 text-success",viewer:"bg-bg-hover text-text-muted"},tG={owner:"Full access, can delete workspace and transfer ownership",admin:"Can manage members, settings, and all workspace features",member:"Can use workspace, spawn agents, and send messages",viewer:"Read-only access to workspace activity"};function tK(e){var t;let{workspaceId:r,currentUserId:a}=e,[o,i]=(0,n.useState)([]),[l,c]=(0,n.useState)([]),[d,x]=(0,n.useState)(!0),[u,m]=(0,n.useState)(null),[h,p]=(0,n.useState)(null),[g,b]=(0,n.useState)(!1),[f,j]=(0,n.useState)(""),[y,v]=(0,n.useState)("member"),[w,N]=(0,n.useState)(!1),[k,C]=(0,n.useState)(null),[S,A]=(0,n.useState)(null);(0,n.useEffect)(()=>{!async function(){x(!0),m(null);let[e,t]=await Promise.all([en.xv.getWorkspaceMembers(r),en.xv.getPendingInvites()]);e.success?i(e.data.members):m(e.error),t.success&&c(t.data.invites.filter(e=>e.workspaceId===r)),x(!1)}()},[r]);let L=(0,n.useCallback)(async()=>{if(!f.trim()){C("Please enter a GitHub username");return}N(!0),C(null);let e=await en.xv.inviteMember(r,f.trim(),y);if(e.success){let e=await en.xv.getWorkspaceMembers(r);e.success&&i(e.data.members),j(""),b(!1),p("Invitation sent to ".concat(f)),setTimeout(()=>p(null),3e3)}else C(e.error);N(!1)},[r,f,y]),E=(0,n.useCallback)(async(e,t)=>{A(e);let s=await en.xv.updateMemberRole(r,e,t);s.success?(i(r=>r.map(r=>r.id===e?{...r,role:t}:r)),p("Role updated successfully"),setTimeout(()=>p(null),3e3)):m(s.error),A(null)},[r]),W=(0,n.useCallback)(async e=>{var t;if(!window.confirm("Are you sure you want to remove ".concat((null===(t=e.user)||void 0===t?void 0:t.githubUsername)||"this member"," from the workspace?")))return;let s=await en.xv.removeMember(r,e.id);s.success?(i(t=>t.filter(t=>t.id!==e.id)),p("Member removed successfully"),setTimeout(()=>p(null),3e3)):m(s.error)},[r]),D=null===(t=o.find(e=>e.userId===a))||void 0===t?void 0:t.role,M="owner"===D||"admin"===D;return d?(0,s.jsxs)("div",{className:"flex items-center justify-center h-64",children:[(0,s.jsx)(tJ,{}),(0,s.jsx)("span",{className:"ml-3 text-text-muted",children:"Loading team members..."})]}):(0,s.jsxs)("div",{className:"space-y-6",children:[(0,s.jsxs)("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-3",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("h3",{className:"text-sm font-semibold text-text-muted uppercase tracking-wide",children:"Team Members"}),(0,s.jsxs)("p",{className:"text-xs text-text-muted mt-1",children:[o.length," member",1!==o.length?"s":""]})]}),M&&(0,s.jsxs)("button",{onClick:()=>b(!g),className:"px-3 md:px-4 py-2 bg-accent-cyan text-bg-deep rounded-lg text-xs md:text-sm font-medium hover:bg-accent-cyan/90 transition-colors flex items-center justify-center gap-2 w-full sm:w-auto",children:[(0,s.jsx)(tq,{}),"Invite Member"]})]}),u&&(0,s.jsxs)("div",{className:"p-3 bg-error/10 border border-error/30 rounded-lg text-error text-sm",children:[u,(0,s.jsx)("button",{onClick:()=>m(null),className:"ml-2 text-error/70 hover:text-error",children:"\xd7"})]}),h&&(0,s.jsx)("div",{className:"p-3 bg-success/10 border border-success/30 rounded-lg text-success text-sm",children:h}),g&&(0,s.jsxs)("div",{className:"p-4 bg-bg-tertiary rounded-lg border border-border-subtle space-y-4",children:[(0,s.jsx)("h4",{className:"text-sm font-medium text-text-primary",children:"Invite New Member"}),k&&(0,s.jsx)("div",{className:"p-2 bg-error/10 border border-error/30 rounded text-error text-xs",children:k}),(0,s.jsxs)("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"text-xs text-text-muted mb-1 block",children:"GitHub Username"}),(0,s.jsx)("input",{type:"text",value:f,onChange:e=>j(e.target.value),placeholder:"username",className:"w-full px-3 py-2 bg-bg-card border border-border-subtle rounded-lg text-sm text-text-primary placeholder:text-text-muted focus:outline-none focus:border-accent-cyan"})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"text-xs text-text-muted mb-1 block",children:"Role"}),(0,s.jsxs)("select",{value:y,onChange:e=>v(e.target.value),className:"w-full px-3 py-2 bg-bg-card border border-border-subtle rounded-lg text-sm text-text-primary focus:outline-none focus:border-accent-cyan",children:[(0,s.jsx)("option",{value:"admin",children:"Admin"}),(0,s.jsx)("option",{value:"member",children:"Member"}),(0,s.jsx)("option",{value:"viewer",children:"Viewer"})]})]})]}),(0,s.jsx)("p",{className:"text-xs text-text-muted",children:tG[y]}),(0,s.jsxs)("div",{className:"flex flex-col sm:flex-row gap-2",children:[(0,s.jsx)("button",{onClick:L,disabled:w||!f.trim(),className:"px-4 py-2 bg-accent-cyan text-bg-deep rounded-lg text-sm font-medium hover:bg-accent-cyan/90 disabled:opacity-50 transition-colors",children:w?"Sending...":"Send Invitation"}),(0,s.jsx)("button",{onClick:()=>{b(!1),j(""),C(null)},className:"px-4 py-2 bg-bg-hover text-text-secondary rounded-lg text-sm font-medium hover:text-text-primary transition-colors",children:"Cancel"})]})]}),(0,s.jsx)("div",{className:"space-y-2",children:o.map(e=>{var t,r,n,o,i,l;return(0,s.jsxs)("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-3 p-3 md:p-4 bg-bg-tertiary rounded-lg",children:[(0,s.jsxs)("div",{className:"flex items-center gap-3",children:[(null===(t=e.user)||void 0===t?void 0:t.avatarUrl)?(0,s.jsx)("img",{src:e.user.avatarUrl,alt:e.user.githubUsername,className:"w-9 h-9 md:w-10 md:h-10 rounded-full"}):(0,s.jsx)("div",{className:"w-9 h-9 md:w-10 md:h-10 rounded-full bg-accent-cyan/20 flex items-center justify-center text-accent-cyan font-bold text-xs md:text-sm",children:(null===(o=e.user)||void 0===o?void 0:null===(n=o.githubUsername)||void 0===n?void 0:null===(r=n[0])||void 0===r?void 0:r.toUpperCase())||"?"}),(0,s.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,s.jsx)("p",{className:"text-sm font-medium text-text-primary truncate",children:(null===(i=e.user)||void 0===i?void 0:i.githubUsername)||"Unknown User"}),e.isPending&&(0,s.jsx)("span",{className:"text-[10px] px-2 py-0.5 bg-amber-400/20 text-amber-400 rounded-full",children:"Pending"}),e.userId===a&&(0,s.jsx)("span",{className:"text-xs text-text-muted",children:"(you)"})]}),(null===(l=e.user)||void 0===l?void 0:l.email)&&(0,s.jsx)("p",{className:"text-xs text-text-muted truncate",children:e.user.email})]})]}),(0,s.jsxs)("div",{className:"flex items-center gap-2 sm:gap-3 ml-12 sm:ml-0",children:[M&&"owner"!==e.role&&e.userId!==a?(0,s.jsxs)("select",{value:e.role,onChange:t=>E(e.id,t.target.value),disabled:S===e.id,className:"px-2 md:px-3 py-1 md:py-1.5 rounded-full text-[10px] md:text-xs font-medium border-none cursor-pointer ".concat(tV[e.role]," focus:outline-none"),children:[(0,s.jsx)("option",{value:"admin",children:"Admin"}),(0,s.jsx)("option",{value:"member",children:"Member"}),(0,s.jsx)("option",{value:"viewer",children:"Viewer"})]}):(0,s.jsx)("span",{className:"px-2 md:px-3 py-1 md:py-1.5 rounded-full text-[10px] md:text-xs font-medium ".concat(tV[e.role]),children:e.role.charAt(0).toUpperCase()+e.role.slice(1)}),M&&"owner"!==e.role&&e.userId!==a&&(0,s.jsx)("button",{onClick:()=>W(e),className:"p-1.5 text-text-muted hover:text-error rounded transition-colors",title:"Remove member",children:(0,s.jsx)(tX,{})})]})]},e.id)})}),l.length>0&&(0,s.jsxs)("div",{className:"mt-8",children:[(0,s.jsx)("h3",{className:"text-sm font-semibold text-text-muted uppercase tracking-wide mb-4",children:"Your Pending Invitations"}),(0,s.jsx)("div",{className:"space-y-2",children:l.map(e=>(0,s.jsxs)("div",{className:"flex items-center justify-between p-4 bg-bg-tertiary rounded-lg border border-accent-cyan/30",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"text-sm font-medium text-text-primary",children:e.workspaceName}),(0,s.jsxs)("p",{className:"text-xs text-text-muted",children:["Invited by ",e.invitedBy," as ",e.role]})]}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)("button",{onClick:async()=>{(await en.xv.acceptInvite(e.id)).success&&(c(t=>t.filter(t=>t.id!==e.id)),p("Invitation accepted!"),setTimeout(()=>p(null),3e3))},className:"px-3 py-1.5 bg-success/20 text-success rounded text-xs font-medium hover:bg-success/30 transition-colors",children:"Accept"}),(0,s.jsx)("button",{onClick:async()=>{(await en.xv.declineInvite(e.id)).success&&c(t=>t.filter(t=>t.id!==e.id))},className:"px-3 py-1.5 bg-bg-hover text-text-muted rounded text-xs font-medium hover:text-text-primary transition-colors",children:"Decline"})]})]},e.id))})]}),(0,s.jsxs)("div",{className:"mt-8 p-4 bg-bg-tertiary/50 rounded-lg",children:[(0,s.jsx)("h4",{className:"text-xs font-semibold text-text-muted uppercase tracking-wide mb-3",children:"Role Permissions"}),(0,s.jsx)("div",{className:"space-y-2",children:Object.entries(tG).map(e=>{let[t,r]=e;return(0,s.jsxs)("div",{className:"flex items-start gap-2",children:[(0,s.jsx)("span",{className:"px-2 py-0.5 rounded-full text-xs font-medium ".concat(tV[t]," shrink-0"),children:t.charAt(0).toUpperCase()+t.slice(1)}),(0,s.jsx)("p",{className:"text-xs text-text-muted",children:r})]},t)})})]})]})}function tJ(){return(0,s.jsx)("svg",{className:"animate-spin h-5 w-5 text-accent-cyan",viewBox:"0 0 24 24",children:(0,s.jsx)("circle",{cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"2",fill:"none",strokeDasharray:"32",strokeLinecap:"round"})})}function tq(){return(0,s.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,s.jsx)("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),(0,s.jsx)("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]})}function tX(){return(0,s.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,s.jsx)("polyline",{points:"3 6 5 6 21 6"}),(0,s.jsx)("path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"})]})}let tY={free:"bg-bg-tertiary border-border-subtle text-text-muted",pro:"bg-accent-cyan/10 border-accent-cyan/30 text-accent-cyan",team:"bg-accent-purple/10 border-accent-purple/30 text-accent-purple",enterprise:"bg-amber-400/10 border-amber-400/30 text-amber-400"};function t$(e){let{onUpgrade:t}=e,[r,a]=(0,n.useState)([]),[o,i]=(0,n.useState)("free"),[l,c]=(0,n.useState)(null),[d,x]=(0,n.useState)([]),[u,m]=(0,n.useState)(!0),[h,p]=(0,n.useState)(null),[g,b]=(0,n.useState)(null),[f,j]=(0,n.useState)("month"),[y,v]=(0,n.useState)(null),[w,N]=(0,n.useState)(!1),[k,C]=(0,n.useState)(!1),[S,A]=(0,n.useState)(!1);(0,n.useEffect)(()=>{!async function(){m(!0),p(null);let[e,t,r]=await Promise.all([en.xv.getBillingPlans(),en.xv.getSubscription(),en.xv.getInvoices()]);if(e.success&&a(e.data.plans),t.success){var s;i(t.data.tier),c(t.data.subscription),(null===(s=t.data.subscription)||void 0===s?void 0:s.interval)&&j(t.data.subscription.interval)}r.success&&x(r.data.invoices),e.success||p(e.error),m(!1)}()},[]);let L=(0,n.useCallback)(async e=>{v(e);let t=await en.xv.createCheckoutSession(e,f);t.success&&t.data.checkoutUrl?window.location.href=t.data.checkoutUrl:t.success||(p(t.error),v(null))},[f]),E=(0,n.useCallback)(async()=>{N(!0);let e=await en.xv.createBillingPortal();e.success&&e.data.portalUrl?window.location.href=e.data.portalUrl:e.success||p(e.error),N(!1)},[]),W=(0,n.useCallback)(async()=>{if(!window.confirm("Are you sure you want to cancel your subscription? You will retain access until the end of your billing period."))return;C(!0);let e=await en.xv.cancelSubscription();e.success?(c(e=>e?{...e,cancelAtPeriodEnd:!0}:null),b(e.data.message),setTimeout(()=>b(null),5e3)):p(e.error),C(!1)},[]),D=(0,n.useCallback)(async()=>{A(!0);let e=await en.xv.resumeSubscription();e.success?(c(e=>e?{...e,cancelAtPeriodEnd:!1}:null),b(e.data.message),setTimeout(()=>b(null),3e3)):p(e.error),A(!1)},[]);return u?(0,s.jsxs)("div",{className:"flex items-center justify-center h-64",children:[(0,s.jsx)(tZ,{}),(0,s.jsx)("span",{className:"ml-3 text-text-muted",children:"Loading billing information..."})]}):(0,s.jsxs)("div",{className:"space-y-8",children:[h&&(0,s.jsxs)("div",{className:"p-3 bg-error/10 border border-error/30 rounded-lg text-error text-sm",children:[h,(0,s.jsx)("button",{onClick:()=>p(null),className:"ml-2 text-error/70 hover:text-error",children:"\xd7"})]}),g&&(0,s.jsx)("div",{className:"p-3 bg-success/10 border border-success/30 rounded-lg text-success text-sm",children:g}),(0,s.jsxs)("div",{children:[(0,s.jsx)("h3",{className:"text-sm font-semibold text-text-muted uppercase tracking-wide mb-4",children:"Current Plan"}),(0,s.jsx)("div",{className:"p-4 md:p-6 rounded-lg border-2 ".concat(tY[o]),children:(0,s.jsxs)("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4",children:[(0,s.jsxs)("div",{children:[(0,s.jsxs)("h4",{className:"text-lg md:text-xl font-bold text-text-primary capitalize",children:[o," Plan"]}),l?(0,s.jsx)("p",{className:"text-xs md:text-sm text-text-secondary mt-1",children:l.cancelAtPeriodEnd?(0,s.jsxs)("span",{className:"text-amber-400",children:["Cancels on ",new Date(l.currentPeriodEnd).toLocaleDateString()]}):(0,s.jsxs)(s.Fragment,{children:["Renews on ",new Date(l.currentPeriodEnd).toLocaleDateString(),(0,s.jsxs)("span",{className:"text-text-muted ml-2",children:["(","year"===l.interval?"Yearly":"Monthly",")"]})]})}):(0,s.jsx)("p",{className:"text-xs md:text-sm text-text-muted mt-1",children:"Free tier - upgrade to unlock more features"})]}),(0,s.jsxs)("div",{className:"flex flex-wrap gap-2",children:[l&&!l.cancelAtPeriodEnd&&(0,s.jsx)("button",{onClick:W,disabled:k,className:"px-3 md:px-4 py-2 bg-bg-hover text-text-secondary rounded-lg text-xs md:text-sm font-medium hover:text-text-primary disabled:opacity-50 transition-colors",children:k?"Canceling...":"Cancel Plan"}),(null==l?void 0:l.cancelAtPeriodEnd)&&(0,s.jsx)("button",{onClick:D,disabled:S,className:"px-3 md:px-4 py-2 bg-success/20 text-success rounded-lg text-xs md:text-sm font-medium hover:bg-success/30 disabled:opacity-50 transition-colors",children:S?"Resuming...":"Resume Plan"}),l&&(0,s.jsx)("button",{onClick:E,disabled:w,className:"px-3 md:px-4 py-2 bg-accent-cyan text-bg-deep rounded-lg text-xs md:text-sm font-medium hover:bg-accent-cyan/90 disabled:opacity-50 transition-colors",children:w?"Opening...":"Manage Billing"})]})]})})]}),(0,s.jsxs)("div",{className:"flex items-center justify-center gap-4",children:[(0,s.jsx)("span",{className:"text-sm font-medium ".concat("month"===f?"text-text-primary":"text-text-muted"),children:"Monthly"}),(0,s.jsx)("button",{onClick:()=>j(e=>"month"===e?"year":"month"),className:"relative w-14 h-7 bg-bg-tertiary rounded-full transition-colors",children:(0,s.jsx)("span",{className:"absolute top-1 w-5 h-5 bg-accent-cyan rounded-full transition-transform ".concat("year"===f?"translate-x-8":"translate-x-1")})}),(0,s.jsxs)("span",{className:"text-sm font-medium ".concat("year"===f?"text-text-primary":"text-text-muted"),children:["Yearly",(0,s.jsx)("span",{className:"ml-1 text-xs text-success",children:"(Save 20%)"})]})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("h3",{className:"text-sm font-semibold text-text-muted uppercase tracking-wide mb-4",children:"Available Plans"}),(0,s.jsx)("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4",children:r.filter(e=>"free"!==e.tier).map(e=>(0,s.jsxs)("div",{className:"relative p-6 rounded-lg border ".concat(e.recommended?"border-accent-cyan shadow-glow-cyan":"border-border-subtle"," bg-bg-tertiary"),children:[e.recommended&&(0,s.jsx)("div",{className:"absolute -top-3 left-1/2 -translate-x-1/2 px-3 py-1 bg-accent-cyan text-bg-deep text-xs font-bold rounded-full",children:"Most Popular"}),(0,s.jsx)("h4",{className:"text-lg font-bold text-text-primary",children:e.name}),(0,s.jsx)("p",{className:"text-xs text-text-muted mt-1 mb-4",children:e.description}),(0,s.jsxs)("div",{className:"mb-4",children:[(0,s.jsxs)("span",{className:"text-3xl font-bold text-text-primary",children:["$","year"===f?e.price.yearly:e.price.monthly]}),(0,s.jsxs)("span",{className:"text-text-muted",children:["/","year"===f?"year":"month"]})]}),(0,s.jsx)("ul",{className:"space-y-2 mb-6",children:e.features.slice(0,5).map((e,t)=>(0,s.jsxs)("li",{className:"flex items-start gap-2 text-sm text-text-secondary",children:[(0,s.jsx)(tQ,{className:"text-success shrink-0 mt-0.5"}),e]},t))}),o===e.tier?(0,s.jsx)("button",{disabled:!0,className:"w-full py-2.5 bg-bg-hover text-text-muted rounded-lg text-sm font-medium cursor-default",children:"Current Plan"}):(0,s.jsx)("button",{onClick:()=>L(e.tier),disabled:null!==y,className:"w-full py-2.5 rounded-lg text-sm font-medium transition-colors disabled:opacity-50 ".concat(e.recommended?"bg-accent-cyan text-bg-deep hover:bg-accent-cyan/90":"bg-bg-hover text-text-primary hover:bg-bg-active"),children:y===e.tier?"Loading...":"free"===o?"Upgrade":"Switch"})]},e.tier))})]}),(0,s.jsx)("div",{className:"p-4 md:p-6 bg-gradient-to-r from-amber-400/10 to-accent-purple/10 border border-amber-400/20 rounded-lg",children:(0,s.jsxs)("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("h4",{className:"text-base md:text-lg font-bold text-text-primary",children:"Enterprise"}),(0,s.jsx)("p",{className:"text-xs md:text-sm text-text-secondary mt-1",children:"Custom solutions for large teams with dedicated support, SLA, and custom integrations."})]}),(0,s.jsx)("a",{href:"mailto:enterprise@agentrelay.dev",className:"px-4 md:px-6 py-2 md:py-2.5 bg-amber-400 text-bg-deep rounded-lg text-xs md:text-sm font-bold hover:bg-amber-300 transition-colors text-center shrink-0",children:"Contact Sales"})]})}),d.length>0&&(0,s.jsxs)("div",{children:[(0,s.jsx)("h3",{className:"text-sm font-semibold text-text-muted uppercase tracking-wide mb-4",children:"Billing History"}),(0,s.jsx)("div",{className:"hidden md:block bg-bg-tertiary rounded-lg overflow-hidden",children:(0,s.jsxs)("table",{className:"w-full",children:[(0,s.jsx)("thead",{children:(0,s.jsxs)("tr",{className:"border-b border-border-subtle",children:[(0,s.jsx)("th",{className:"text-left px-4 py-3 text-xs font-semibold text-text-muted uppercase",children:"Invoice"}),(0,s.jsx)("th",{className:"text-left px-4 py-3 text-xs font-semibold text-text-muted uppercase",children:"Date"}),(0,s.jsx)("th",{className:"text-left px-4 py-3 text-xs font-semibold text-text-muted uppercase",children:"Amount"}),(0,s.jsx)("th",{className:"text-left px-4 py-3 text-xs font-semibold text-text-muted uppercase",children:"Status"}),(0,s.jsx)("th",{className:"text-right px-4 py-3 text-xs font-semibold text-text-muted uppercase"})]})}),(0,s.jsx)("tbody",{children:d.map(e=>(0,s.jsxs)("tr",{className:"border-b border-border-subtle last:border-0",children:[(0,s.jsx)("td",{className:"px-4 py-3 text-sm text-text-primary font-medium",children:e.number}),(0,s.jsx)("td",{className:"px-4 py-3 text-sm text-text-secondary",children:new Date(e.date).toLocaleDateString()}),(0,s.jsxs)("td",{className:"px-4 py-3 text-sm text-text-primary",children:["$",(e.amount/100).toFixed(2)]}),(0,s.jsx)("td",{className:"px-4 py-3",children:(0,s.jsx)("span",{className:"text-xs px-2 py-1 rounded-full ".concat("paid"===e.status?"bg-success/20 text-success":"open"===e.status?"bg-amber-400/20 text-amber-400":"bg-error/20 text-error"),children:e.status})}),(0,s.jsx)("td",{className:"px-4 py-3 text-right",children:e.pdfUrl&&(0,s.jsx)("a",{href:e.pdfUrl,target:"_blank",rel:"noopener noreferrer",className:"text-xs text-accent-cyan hover:underline",children:"Download"})})]},e.id))})]})}),(0,s.jsx)("div",{className:"md:hidden space-y-3",children:d.map(e=>(0,s.jsxs)("div",{className:"bg-bg-tertiary rounded-lg p-4",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,s.jsx)("span",{className:"text-sm font-medium text-text-primary",children:e.number}),(0,s.jsx)("span",{className:"text-xs px-2 py-1 rounded-full ".concat("paid"===e.status?"bg-success/20 text-success":"open"===e.status?"bg-amber-400/20 text-amber-400":"bg-error/20 text-error"),children:e.status})]}),(0,s.jsxs)("div",{className:"flex items-center justify-between text-xs",children:[(0,s.jsx)("span",{className:"text-text-muted",children:new Date(e.date).toLocaleDateString()}),(0,s.jsxs)("span",{className:"text-text-primary font-medium",children:["$",(e.amount/100).toFixed(2)]})]}),e.pdfUrl&&(0,s.jsx)("a",{href:e.pdfUrl,target:"_blank",rel:"noopener noreferrer",className:"mt-3 block text-center text-xs text-accent-cyan py-2 border border-accent-cyan/30 rounded-lg hover:bg-accent-cyan/10 transition-colors",children:"Download PDF"})]},e.id))})]})]})}function tZ(){return(0,s.jsx)("svg",{className:"animate-spin h-5 w-5 text-accent-cyan",viewBox:"0 0 24 24",children:(0,s.jsx)("circle",{cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"2",fill:"none",strokeDasharray:"32",strokeLinecap:"round"})})}function tQ(e){let{className:t=""}=e;return(0,s.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:(0,s.jsx)("polyline",{points:"20 6 9 17 4 12"})})}let t0={theme:"dark",compactMode:!1,showTimestamps:!0,soundEnabled:!0,notificationsEnabled:!0,autoScrollMessages:!0};function t1(e){var t,r;let{currentUserId:a,initialTab:o="dashboard",onClose:i}=e,[l,c]=(0,n.useState)(o),[d,x]=(0,n.useState)([]),[u,m]=(0,n.useState)(null),[h,p]=(0,n.useState)(!0),[g,b]=(0,n.useState)(t0);(0,n.useEffect)(()=>{(async function(){p(!0);let e=await en.xv.getWorkspaceSummary();e.success&&e.data.workspaces.length>0&&(x(e.data.workspaces),m(e.data.workspaces[0].id)),p(!1)})()},[]),(0,n.useEffect)(()=>{let e=localStorage.getItem("dashboard-settings");if(e)try{b({...t0,...JSON.parse(e)})}catch(e){}},[]);let f=(e,t)=>{let r={...g,[e]:t};b(r),localStorage.setItem("dashboard-settings",JSON.stringify(r)),"theme"===e&&document.documentElement.setAttribute("data-theme",t)},j=[{id:"dashboard",label:"Dashboard",icon:(0,s.jsx)(t9,{})},{id:"workspace",label:"Workspace",icon:(0,s.jsx)(t7,{})},{id:"team",label:"Team",icon:(0,s.jsx)(re,{})},{id:"billing",label:"Billing",icon:(0,s.jsx)(rt,{})}];return(0,s.jsxs)("div",{className:"fixed inset-0 z-50 bg-bg-deep",children:[(0,s.jsxs)("div",{className:"absolute inset-0 opacity-30",children:[(0,s.jsx)("div",{className:"absolute inset-0 bg-[radial-gradient(ellipse_at_top_right,_rgba(0,217,255,0.08)_0%,_transparent_50%)]"}),(0,s.jsx)("div",{className:"absolute inset-0 bg-[radial-gradient(ellipse_at_bottom_left,_rgba(168,85,247,0.06)_0%,_transparent_50%)]"})]}),(0,s.jsxs)("div",{className:"relative h-full flex flex-col",children:[(0,s.jsxs)("header",{className:"h-14 md:h-16 px-4 md:px-6 flex items-center justify-between border-b border-border-subtle bg-bg-secondary/80 backdrop-blur-sm",children:[(0,s.jsxs)("div",{className:"flex items-center gap-3 md:gap-4",children:[(0,s.jsx)("div",{className:"w-8 h-8 md:w-10 md:h-10 rounded-xl bg-gradient-to-br from-accent-cyan to-accent-purple flex items-center justify-center shadow-lg shadow-accent-cyan/20",children:(0,s.jsx)(t8,{className:"text-white w-4 h-4 md:w-[18px] md:h-[18px]"})}),(0,s.jsxs)("div",{children:[(0,s.jsx)("h1",{className:"text-base md:text-lg font-bold text-text-primary tracking-tight",children:"Settings"}),(0,s.jsx)("p",{className:"text-[10px] md:text-xs text-text-muted hidden sm:block",children:"Manage your workspace and preferences"})]})]}),(0,s.jsx)("button",{onClick:i,className:"w-9 h-9 md:w-10 md:h-10 rounded-lg bg-bg-tertiary border border-border-subtle flex items-center justify-center text-text-muted hover:text-text-primary hover:bg-bg-hover transition-colors",children:(0,s.jsx)(rr,{})})]}),(0,s.jsx)("div",{className:"md:hidden flex border-b border-border-subtle bg-bg-secondary/50 overflow-x-auto scrollbar-hide",children:j.map(e=>(0,s.jsxs)("button",{onClick:()=>c(e.id),className:"flex-1 min-w-[80px] flex flex-col items-center gap-1 px-3 py-3 text-xs font-medium transition-all ".concat(l===e.id?"text-accent-cyan border-b-2 border-accent-cyan bg-accent-cyan/5":"text-text-muted border-b-2 border-transparent"),children:[(0,s.jsx)("span",{className:l===e.id?"text-accent-cyan":"text-text-muted",children:e.icon}),e.label]},e.id))}),("workspace"===l||"team"===l)&&d.length>0&&(0,s.jsx)("div",{className:"md:hidden px-4 py-2 border-b border-border-subtle bg-bg-tertiary/50",children:(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)("div",{className:"w-2 h-2 rounded-full shrink-0 ".concat((null===(t=d.find(e=>e.id===u))||void 0===t?void 0:t.status)==="running"?"bg-success":(null===(r=d.find(e=>e.id===u))||void 0===r?void 0:r.status)==="stopped"?"bg-amber-400":"bg-text-muted")}),1===d.length?(0,s.jsx)("span",{className:"text-sm text-text-primary",children:d[0].name}):(0,s.jsx)("select",{value:u||"",onChange:e=>m(e.target.value),className:"flex-1 px-3 py-2 bg-bg-card border border-border-subtle rounded-lg text-sm text-text-primary focus:outline-none focus:border-accent-cyan",children:d.map(e=>(0,s.jsx)("option",{value:e.id,children:e.name},e.id))})]})}),(0,s.jsxs)("div",{className:"flex-1 flex overflow-hidden",children:[(0,s.jsxs)("nav",{className:"hidden md:flex w-64 border-r border-border-subtle bg-bg-secondary/50 p-4 flex-col",children:[(0,s.jsx)("div",{className:"space-y-1",children:j.map(e=>(0,s.jsxs)("button",{onClick:()=>c(e.id),className:"w-full flex items-center gap-3 px-4 py-3 rounded-xl text-sm font-medium transition-all duration-200 ".concat(l===e.id?"bg-accent-cyan/15 text-accent-cyan border border-accent-cyan/30 shadow-[0_0_20px_rgba(0,217,255,0.1)]":"text-text-secondary hover:bg-bg-hover hover:text-text-primary border border-transparent"),children:[(0,s.jsx)("span",{className:l===e.id?"text-accent-cyan":"text-text-muted",children:e.icon}),e.label]},e.id))}),("workspace"===l||"team"===l)&&d.length>0&&(0,s.jsxs)("div",{className:"mt-8 pt-6 border-t border-border-subtle",children:[(0,s.jsx)("label",{className:"text-xs font-semibold text-text-muted uppercase tracking-wider mb-3 block",children:"Select Workspace"}),(0,s.jsx)("div",{className:"space-y-2",children:d.map(e=>(0,s.jsxs)("button",{onClick:()=>m(e.id),className:"w-full flex items-center gap-3 px-3 py-2.5 rounded-lg text-sm transition-all ".concat(u===e.id?"bg-bg-tertiary border border-accent-cyan/30 text-text-primary":"text-text-secondary hover:bg-bg-hover hover:text-text-primary border border-transparent"),children:[(0,s.jsx)("div",{className:"w-2 h-2 rounded-full ".concat("running"===e.status?"bg-success":"stopped"===e.status?"bg-amber-400":"bg-text-muted")}),(0,s.jsx)("span",{className:"truncate",children:e.name})]},e.id))})]}),(0,s.jsx)("div",{className:"mt-auto pt-6",children:(0,s.jsxs)("div",{className:"px-4 py-3 bg-bg-tertiary/50 rounded-lg",children:[(0,s.jsx)("p",{className:"text-xs text-text-muted",children:"Agent Relay"}),(0,s.jsx)("p",{className:"text-xs font-mono text-text-muted/60",children:"v1.0.0"})]})})]}),(0,s.jsx)("main",{className:"flex-1 overflow-y-auto",children:(0,s.jsxs)("div",{className:"max-w-4xl mx-auto p-4 md:p-8",children:["dashboard"===l&&(0,s.jsxs)("div",{className:"space-y-8",children:[(0,s.jsx)(t2,{title:"Dashboard Settings",subtitle:"Customize your dashboard experience"}),(0,s.jsxs)(t5,{title:"Appearance",icon:(0,s.jsx)(rs,{}),children:[(0,s.jsx)(t4,{label:"Theme",description:"Choose your preferred color scheme",children:(0,s.jsxs)("select",{value:g.theme,onChange:e=>f("theme",e.target.value),className:"px-4 py-2 bg-bg-tertiary border border-border-subtle rounded-lg text-sm text-text-primary focus:outline-none focus:border-accent-cyan",children:[(0,s.jsx)("option",{value:"dark",children:"Dark"}),(0,s.jsx)("option",{value:"light",children:"Light"}),(0,s.jsx)("option",{value:"system",children:"System"})]})}),(0,s.jsx)(t4,{label:"Compact Mode",description:"Reduce spacing and show more content",children:(0,s.jsx)(t3,{checked:g.compactMode,onChange:e=>f("compactMode",e)})}),(0,s.jsx)(t4,{label:"Show Timestamps",description:"Display timestamps on messages",children:(0,s.jsx)(t3,{checked:g.showTimestamps,onChange:e=>f("showTimestamps",e)})})]}),(0,s.jsxs)(t5,{title:"Notifications",icon:(0,s.jsx)(rn,{}),children:[(0,s.jsx)(t4,{label:"Sound Effects",description:"Play sounds for new messages",children:(0,s.jsx)(t3,{checked:g.soundEnabled,onChange:e=>f("soundEnabled",e)})}),(0,s.jsx)(t4,{label:"Browser Notifications",description:"Show desktop notifications",children:(0,s.jsx)(t3,{checked:g.notificationsEnabled,onChange:e=>f("notificationsEnabled",e)})})]}),(0,s.jsx)(t5,{title:"Behavior",icon:(0,s.jsx)(t8,{}),children:(0,s.jsx)(t4,{label:"Auto-scroll Messages",description:"Automatically scroll to new messages",children:(0,s.jsx)(t3,{checked:g.autoScrollMessages,onChange:e=>f("autoScrollMessages",e)})})})]}),"workspace"===l&&(0,s.jsx)(s.Fragment,{children:h?(0,s.jsxs)("div",{className:"flex items-center justify-center h-64",children:[(0,s.jsx)("div",{className:"relative",children:(0,s.jsx)("div",{className:"w-12 h-12 rounded-full border-2 border-accent-cyan/20 border-t-accent-cyan animate-spin"})}),(0,s.jsx)("span",{className:"ml-4 text-text-muted",children:"Loading workspaces..."})]}):u?(0,s.jsx)(tS,{workspaceId:u,csrfToken:(0,en._V)()||void 0,onClose:i}):(0,s.jsx)(t6,{icon:(0,s.jsx)(t7,{}),title:"No Workspace",description:"Create a workspace to get started with Agent Relay.",action:(0,s.jsx)("button",{className:"px-6 py-3 bg-accent-cyan text-bg-deep font-semibold rounded-lg hover:bg-accent-cyan/90 transition-colors",children:"Create Workspace"})})}),"team"===l&&(0,s.jsx)(s.Fragment,{children:u?(0,s.jsxs)("div",{className:"space-y-8",children:[(0,s.jsx)(t2,{title:"Team Settings",subtitle:"Manage workspace members and permissions"}),(0,s.jsx)(tK,{workspaceId:u,currentUserId:a})]}):(0,s.jsx)(t6,{icon:(0,s.jsx)(re,{}),title:"No Workspace Selected",description:"Select a workspace to manage team members."})}),"billing"===l&&(0,s.jsxs)("div",{className:"space-y-8",children:[(0,s.jsx)(t2,{title:"Billing & Subscription",subtitle:"Manage your plan and payment methods"}),(0,s.jsx)(t$,{})]})]})})]})]})]})}function t2(e){let{title:t,subtitle:r}=e;return(0,s.jsxs)("div",{className:"mb-8",children:[(0,s.jsx)("h2",{className:"text-2xl font-bold text-text-primary",children:t}),(0,s.jsx)("p",{className:"text-sm text-text-muted mt-1",children:r})]})}function t5(e){let{title:t,icon:r,children:n}=e;return(0,s.jsxs)("div",{className:"bg-bg-tertiary rounded-xl border border-border-subtle overflow-hidden",children:[(0,s.jsxs)("div",{className:"px-6 py-4 border-b border-border-subtle bg-bg-secondary/50 flex items-center gap-3",children:[(0,s.jsx)("span",{className:"text-accent-cyan",children:r}),(0,s.jsx)("h3",{className:"text-sm font-semibold text-text-primary uppercase tracking-wide",children:t})]}),(0,s.jsx)("div",{className:"divide-y divide-border-subtle",children:n})]})}function t4(e){let{label:t,description:r,children:n}=e;return(0,s.jsxs)("div",{className:"px-6 py-4 flex items-center justify-between",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{className:"text-sm font-medium text-text-primary",children:t}),(0,s.jsx)("p",{className:"text-xs text-text-muted mt-0.5",children:r})]}),n]})}function t3(e){let{checked:t,onChange:r}=e;return(0,s.jsx)("button",{onClick:()=>r(!t),className:"relative w-12 h-6 rounded-full transition-colors ".concat(t?"bg-accent-cyan":"bg-bg-hover"),children:(0,s.jsx)("span",{className:"absolute top-1 w-4 h-4 bg-white rounded-full shadow transition-transform ".concat(t?"translate-x-7":"translate-x-1")})})}function t6(e){let{icon:t,title:r,description:n,action:a}=e;return(0,s.jsxs)("div",{className:"flex flex-col items-center justify-center h-64 text-center",children:[(0,s.jsx)("div",{className:"w-16 h-16 rounded-2xl bg-bg-tertiary flex items-center justify-center text-text-muted mb-4",children:t}),(0,s.jsx)("h3",{className:"text-lg font-semibold text-text-primary mb-2",children:r}),(0,s.jsx)("p",{className:"text-sm text-text-muted max-w-sm mb-6",children:n}),a]})}function t8(e){let{className:t=""}=e;return(0,s.jsxs)("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:t,children:[(0,s.jsx)("circle",{cx:"12",cy:"12",r:"3"}),(0,s.jsx)("path",{d:"M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-2 2 2 2 0 0 1-2-2v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1-2-2 2 2 0 0 1 2-2h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 2-2 2 2 0 0 1 2 2v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 2 2 2 2 0 0 1-2 2h-.09a1.65 1.65 0 0 0-1.51 1z"})]})}function t9(){return(0,s.jsxs)("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,s.jsx)("rect",{x:"3",y:"3",width:"7",height:"9"}),(0,s.jsx)("rect",{x:"14",y:"3",width:"7",height:"5"}),(0,s.jsx)("rect",{x:"14",y:"12",width:"7",height:"9"}),(0,s.jsx)("rect",{x:"3",y:"16",width:"7",height:"5"})]})}function t7(){return(0,s.jsx)("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:(0,s.jsx)("path",{d:"M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z"})})}function re(){return(0,s.jsxs)("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,s.jsx)("path",{d:"M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2"}),(0,s.jsx)("circle",{cx:"9",cy:"7",r:"4"}),(0,s.jsx)("path",{d:"M23 21v-2a4 4 0 0 0-3-3.87"}),(0,s.jsx)("path",{d:"M16 3.13a4 4 0 0 1 0 7.75"})]})}function rt(){return(0,s.jsxs)("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,s.jsx)("rect",{x:"1",y:"4",width:"22",height:"16",rx:"2",ry:"2"}),(0,s.jsx)("line",{x1:"1",y1:"10",x2:"23",y2:"10"})]})}function rr(){return(0,s.jsxs)("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,s.jsx)("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),(0,s.jsx)("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})}function rs(){return(0,s.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,s.jsx)("circle",{cx:"13.5",cy:"6.5",r:"2.5"}),(0,s.jsx)("circle",{cx:"19",cy:"13.5",r:"2.5"}),(0,s.jsx)("circle",{cx:"6",cy:"12",r:"2.5"}),(0,s.jsx)("circle",{cx:"11",cy:"19",r:"2.5"}),(0,s.jsx)("path",{d:"M12 2C6.5 2 2 6.5 2 12s4.5 10 10 10c.926 0 1.648-.746 1.648-1.688 0-.437-.18-.835-.437-1.125-.29-.289-.438-.652-.438-1.125a1.64 1.64 0 0 1 1.668-1.668h1.996c3.051 0 5.555-2.503 5.555-5.555C21.965 6.012 17.461 2 12 2z"})]})}function rn(){return(0,s.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,s.jsx)("path",{d:"M18 8A6 6 0 0 0 6 8c0 7-3 9-3 9h18s-3-2-3-9"}),(0,s.jsx)("path",{d:"M13.73 21a2 2 0 0 1-3.46 0"})]})}var ra=r(9116);function ro(e){let{isOpen:t,onClose:r}=e,[a,o]=(0,n.useState)("conversations"),[i,l]=(0,n.useState)([]),[c,d]=(0,n.useState)([]),[x,u]=(0,n.useState)([]),[m,h]=(0,n.useState)(null),[p,g]=(0,n.useState)(!1),[b,f]=(0,n.useState)(null),[j,y]=(0,n.useState)(""),[v,w]=(0,n.useState)(""),[N,k]=(0,n.useState)(null);(0,n.useEffect)(()=>{t&&(async()=>{let e=await ra.hi.getHistoryStats();e.success&&e.data&&h(e.data)})()},[t]),(0,n.useEffect)(()=>{t&&(async()=>{g(!0),f(null);try{if("conversations"===a){let e=await ra.hi.getHistoryConversations();e.success&&e.data?l(e.data.conversations):f(e.error||"Failed to fetch conversations")}else if("sessions"===a){let e=await ra.hi.getHistorySessions({agent:v||void 0,limit:50});e.success&&e.data?d(e.data.sessions):f(e.error||"Failed to fetch sessions")}else if("messages"===a){let r={limit:100,order:"desc"};if(j&&(r.search=j),N){let[s,n]=N.participants,a=await ra.hi.getHistoryMessages({...r,from:s,to:n}),o=await ra.hi.getHistoryMessages({...r,from:n,to:s});if(a.success&&o.success){var e,t;let r=[...(null===(e=a.data)||void 0===e?void 0:e.messages)||[],...(null===(t=o.data)||void 0===t?void 0:t.messages)||[]].sort((e,t)=>new Date(t.timestamp).getTime()-new Date(e.timestamp).getTime());u(r)}}else{let e=await ra.hi.getHistoryMessages(r);e.success&&e.data?u(e.data.messages):f(e.error||"Failed to fetch messages")}}}catch(e){f("Failed to load data")}finally{g(!1)}})()},[t,a,v,j,N]);let C=(0,n.useCallback)(e=>{k(e),o("messages")},[]),S=(0,n.useCallback)(()=>{k(null),o("conversations")},[]);return t?(0,s.jsx)("div",{className:"fixed inset-0 z-[1000] flex items-center justify-center bg-black/50",children:(0,s.jsxs)("div",{className:"bg-bg-primary rounded-lg shadow-xl w-[90vw] max-w-4xl h-[80vh] flex flex-col",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between p-4 border-b border-border",children:[(0,s.jsxs)("div",{className:"flex items-center gap-4",children:[(0,s.jsx)("h2",{className:"text-lg font-semibold text-text-primary",children:"Conversation History"}),m&&(0,s.jsxs)("div",{className:"flex gap-4 text-sm text-text-muted",children:[(0,s.jsxs)("span",{children:[m.messageCount," messages"]}),(0,s.jsxs)("span",{children:[m.sessionCount," sessions"]}),(0,s.jsxs)("span",{children:[m.uniqueAgents," agents"]})]})]}),(0,s.jsx)("button",{onClick:r,className:"p-2 text-text-muted hover:text-text-primary rounded transition-colors","aria-label":"Close",children:(0,s.jsx)(rm,{})})]}),(0,s.jsxs)("div",{className:"flex items-center gap-4 p-4 border-b border-border",children:[(0,s.jsxs)("div",{className:"flex gap-1 bg-bg-secondary rounded-md p-1",children:[(0,s.jsx)(ri,{active:"conversations"===a,onClick:()=>{k(null),o("conversations")},children:"Conversations"}),(0,s.jsx)(ri,{active:"sessions"===a,onClick:()=>o("sessions"),children:"Sessions"}),(0,s.jsx)(ri,{active:"messages"===a,onClick:()=>o("messages"),children:"Messages"})]}),"messages"===a&&(0,s.jsx)("div",{className:"flex-1 max-w-xs",children:(0,s.jsx)("input",{type:"text",placeholder:"Search messages...",value:j,onChange:e=>y(e.target.value),className:"w-full px-3 py-2 bg-bg-secondary border border-border rounded-md text-sm text-text-primary placeholder:text-text-muted focus:outline-none focus:border-accent"})}),"sessions"===a&&(0,s.jsx)("div",{className:"flex-1 max-w-xs",children:(0,s.jsx)("input",{type:"text",placeholder:"Filter by agent...",value:v,onChange:e=>w(e.target.value),className:"w-full px-3 py-2 bg-bg-secondary border border-border rounded-md text-sm text-text-primary placeholder:text-text-muted focus:outline-none focus:border-accent"})}),N&&(0,s.jsxs)("button",{onClick:S,className:"flex items-center gap-1 px-3 py-2 text-sm text-text-muted hover:text-text-primary",children:[(0,s.jsx)(rh,{})," Back to conversations"]})]}),(0,s.jsx)("div",{className:"flex-1 overflow-y-auto p-4",children:p?(0,s.jsx)("div",{className:"flex items-center justify-center h-full",children:(0,s.jsx)(rp,{})}):b?(0,s.jsx)("div",{className:"flex items-center justify-center h-full text-error",children:b}):"conversations"===a?(0,s.jsx)(rl,{conversations:i,onConversationClick:C}):"sessions"===a?(0,s.jsx)(rc,{sessions:c}):(0,s.jsx)(rx,{messages:x,conversationTitle:N?"".concat(N.participants[0]," & ").concat(N.participants[1]):void 0})})]})}):null}function ri(e){let{active:t,onClick:r,children:n}=e;return(0,s.jsx)("button",{onClick:r,className:"px-3 py-1.5 text-sm rounded transition-colors ".concat(t?"bg-accent text-white":"text-text-muted hover:text-text-primary hover:bg-bg-primary"),children:n})}function rl(e){let{conversations:t,onConversationClick:r}=e;return 0===t.length?(0,s.jsx)("div",{className:"flex items-center justify-center h-full text-text-muted",children:"No conversations found"}):(0,s.jsx)("div",{className:"space-y-2",children:t.map((e,t)=>(0,s.jsxs)("div",{onClick:()=>r(e),className:"p-4 bg-bg-secondary rounded-lg cursor-pointer hover:bg-bg-tertiary transition-colors",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)("span",{className:"font-medium text-text-primary",children:e.participants.join(" & ")}),(0,s.jsxs)("span",{className:"text-xs px-2 py-0.5 bg-accent/10 text-accent rounded-full",children:[e.messageCount," messages"]})]}),(0,s.jsx)("span",{className:"text-xs text-text-muted",children:ru(e.lastTimestamp)})]}),(0,s.jsx)("p",{className:"text-sm text-text-muted truncate",children:e.lastMessage})]},t))})}function rc(e){let{sessions:t}=e;return 0===t.length?(0,s.jsx)("div",{className:"flex items-center justify-center h-full text-text-muted",children:"No sessions found"}):(0,s.jsx)("div",{className:"space-y-2",children:t.map(e=>(0,s.jsxs)("div",{className:"p-4 bg-bg-secondary rounded-lg",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)("span",{className:"font-medium text-text-primary",children:e.agentName}),e.cli&&(0,s.jsx)("span",{className:"text-xs px-2 py-0.5 bg-bg-tertiary text-text-muted rounded",children:e.cli}),(0,s.jsx)(rd,{isActive:e.isActive,closedBy:e.closedBy})]}),(0,s.jsx)("span",{className:"text-xs text-text-muted",children:e.duration})]}),(0,s.jsxs)("div",{className:"flex items-center gap-4 text-sm text-text-muted",children:[(0,s.jsx)("span",{children:new Date(e.startedAt).toLocaleString()}),(0,s.jsxs)("span",{children:[e.messageCount," messages"]})]}),e.summary&&(0,s.jsx)("p",{className:"mt-2 text-sm text-text-muted truncate",children:e.summary})]},e.id))})}function rd(e){let{isActive:t,closedBy:r}=e;if(t)return(0,s.jsx)("span",{className:"text-xs px-2 py-0.5 bg-success/10 text-success rounded-full",children:"Active"});let n={agent:"bg-text-muted/10 text-text-muted",disconnect:"bg-warning/10 text-warning",error:"bg-error/10 text-error"},a=r?n[r]:n.agent;return(0,s.jsx)("span",{className:"text-xs px-2 py-0.5 rounded-full ".concat(a),children:r?({agent:"Closed",disconnect:"Disconnected",error:"Error"})[r]:"Ended"})}function rx(e){let{messages:t,conversationTitle:r}=e;return 0===t.length?(0,s.jsx)("div",{className:"flex items-center justify-center h-full text-text-muted",children:"No messages found"}):(0,s.jsxs)("div",{className:"space-y-4",children:[r&&(0,s.jsx)("h3",{className:"text-lg font-medium text-text-primary mb-4",children:r}),t.map(e=>(0,s.jsxs)("div",{className:"p-4 bg-bg-secondary rounded-lg",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)("span",{className:"font-medium text-accent",children:e.from}),(0,s.jsx)("span",{className:"text-text-muted",children:"to"}),(0,s.jsx)("span",{className:"font-medium text-text-primary",children:"*"===e.to?"Everyone":e.to}),e.isBroadcast&&(0,s.jsx)("span",{className:"text-xs px-2 py-0.5 bg-accent/10 text-accent rounded-full",children:"Broadcast"}),e.isUrgent&&(0,s.jsx)("span",{className:"text-xs px-2 py-0.5 bg-error/10 text-error rounded-full",children:"Urgent"})]}),(0,s.jsx)("span",{className:"text-xs text-text-muted",children:ru(e.timestamp)})]}),(0,s.jsx)("p",{className:"text-sm text-text-primary whitespace-pre-wrap",children:e.content}),e.thread&&(0,s.jsxs)("div",{className:"mt-2 text-xs text-text-muted",children:["Thread: ",e.thread.slice(0,8),"..."]})]},e.id))]})}function ru(e){let t=new Date(e),r=new Date().getTime()-t.getTime(),s=Math.floor(r/6e4),n=Math.floor(r/36e5),a=Math.floor(r/864e5);return s<1?"just now":s<60?"".concat(s,"m ago"):n<24?"".concat(n,"h ago"):a<7?"".concat(a,"d ago"):t.toLocaleDateString()}function rm(){return(0,s.jsxs)("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,s.jsx)("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),(0,s.jsx)("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})}function rh(){return(0,s.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:(0,s.jsx)("polyline",{points:"15 18 9 12 15 6"})})}function rp(){return(0,s.jsx)("svg",{className:"animate-spin text-accent",width:"24",height:"24",viewBox:"0 0 24 24",children:(0,s.jsx)("circle",{cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"2",fill:"none",strokeDasharray:"32",strokeLinecap:"round"})})}function rg(e,t){let r=e.substring(0,t).match(/(?:^|[\s(])@(\S*)$/);return r?r[1]:null}function rb(e,t,r){let s=e.substring(0,r),n=e.substring(r),a=s.match(/(?:^|[\s(])@(\S*)$/);if(a){let r=a.index||0,s=a[0].charAt(0),o=e.substring(0,"@"===s?r:r+1),i="@".concat(t," "),l=o.length+i.length;return{value:o+i+n,cursorPosition:l}}return{value:e,cursorPosition:r}}function rf(e){let{agents:t,humanUsers:r=[],inputValue:o,cursorPosition:i,onSelect:l,onClose:c,isVisible:d}=e,[x,u]=(0,n.useState)(0),m=(0,n.useRef)(null),h=(0,n.useMemo)(()=>rg(o,i),[o,i]),p=(0,n.useMemo)(()=>{let e=new Map;return t.forEach(t=>{if(t.team){let r=e.get(t.team)||[];r.push(t),e.set(t.team,r)}}),e},[t]),g=(0,n.useMemo)(()=>{if(null===h)return[];let e=h.toLowerCase(),s=[];("*".includes(e)||"everyone".includes(e)||"all".includes(e)||"broadcast".includes(e)||""===e)&&s.push({name:"*",displayName:"@everyone",description:"Broadcast to all agents",isBroadcast:!0});let n=e.startsWith("team:")||e.startsWith("team"),a=e.startsWith("team:")?e.substring(5):e.replace(/^team/,"");(n||""===e)&&p.forEach((t,r)=>{let n=r.toLowerCase();(""===a||n.includes(a)||"team:".concat(n).includes(e))&&s.push({name:"team:".concat(r),displayName:"@team:".concat(r),description:"".concat(t.length," agent").concat(1!==t.length?"s":"",": ").concat(t.map(e=>e.name).join(", ")),isTeam:!0,memberCount:t.length})});let o=new Set(t.map(e=>e.name.toLowerCase()));return r.filter(t=>{let r=t.username.toLowerCase();return r.includes(e)&&!o.has(r)}).forEach(e=>{s.push({name:e.username,displayName:"@".concat(e.username),description:"Human user",isHuman:!0,avatarUrl:e.avatarUrl})}),t.filter(t=>t.name.toLowerCase().includes(e)).forEach(e=>{s.push({name:e.name,displayName:"@".concat(e.name),description:e.team?"".concat(e.status||"Agent"," \xb7 ").concat(e.team):e.status||"Agent"})}),s},[h,t,r,p]);(0,n.useEffect)(()=>{u(0)},[g.length]),(0,n.useEffect)(()=>{if(!m.current)return;let e=m.current.querySelector('[data-selected="true"]');e&&e.scrollIntoView({block:"nearest"})},[x]);let b=(0,n.useCallback)(e=>{if(d&&0!==g.length)switch(e.key){case"ArrowDown":e.preventDefault(),u(e=>(e+1)%g.length);break;case"ArrowUp":e.preventDefault(),u(e=>(e-1+g.length)%g.length);break;case"Enter":case"Tab":e.preventDefault();let t=g[x];if(t){let e=rb(o,t.name,i);l(t.name,e.value)}break;case"Escape":e.preventDefault(),c()}},[d,g,x,o,i,l,c]);(0,n.useEffect)(()=>{if(d)return window.addEventListener("keydown",b),()=>window.removeEventListener("keydown",b)},[d,b]);let f=(0,n.useCallback)(e=>{let t=rb(o,e.name,i);l(e.name,t.value)},[o,i,l]);return d&&0!==g.length?(0,s.jsx)("div",{className:"absolute bottom-full left-0 right-0 max-h-[200px] overflow-y-auto bg-[#1a1d21] border border-white/10 rounded-lg shadow-[0_-4px_20px_rgba(0,0,0,0.4)] z-[100] mb-1",ref:m,children:g.map((e,t)=>(0,s.jsxs)("div",{"data-selected":t===x,className:"flex items-center gap-2.5 py-2 px-3 cursor-pointer transition-colors duration-150 ".concat(t===x?"bg-white/[0.08]":"hover:bg-white/[0.08]"),onClick:()=>f(e),onMouseEnter:()=>u(t),children:[e.isHuman&&e.avatarUrl?(0,s.jsx)("img",{src:e.avatarUrl,alt:e.name,className:"w-7 h-7 rounded-md object-cover"}):(0,s.jsx)("div",{className:"w-7 h-7 rounded-md flex items-center justify-center text-white text-[11px] font-semibold",style:{background:e.isBroadcast?"var(--color-warning, #f59e0b)":e.isTeam?"var(--color-accent-purple, #a855f7)":e.isHuman?"#a855f7":(0,a.GW)(e.name).primary},children:e.isBroadcast?"*":e.isTeam?(0,s.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,s.jsx)("path",{d:"M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2"}),(0,s.jsx)("circle",{cx:"9",cy:"7",r:"4"}),(0,s.jsx)("path",{d:"M23 21v-2a4 4 0 0 0-3-3.87"}),(0,s.jsx)("path",{d:"M16 3.13a4 4 0 0 1 0 7.75"})]}):e.isHuman?(0,s.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,s.jsx)("path",{d:"M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2"}),(0,s.jsx)("circle",{cx:"12",cy:"7",r:"4"})]}):(0,a.hP)(e.name)}),(0,s.jsxs)("div",{className:"flex flex-col gap-0.5 min-w-0 flex-1",children:[(0,s.jsx)("span",{className:"text-sm font-medium text-[#d1d2d3]",children:e.displayName}),(0,s.jsx)("span",{className:"text-xs text-[#8d8d8e] truncate",children:e.description})]})]},e.name))}):null}function rj(e,t){let r=e.substring(0,t).match(/(?:^|[\s(])@(\S*)$/);if(r){let e=r[1];if(e.includes("/")||/\.[a-zA-Z0-9]{1,10}$/.test(e))return e}return null}function ry(e,t,r){let s=e.substring(0,r),n=e.substring(r),a=s.match(/(?:^|[\s(])@(\S*)$/);if(a){let r=a.index||0,s=a[0].charAt(0);return e.substring(0,"@"===s?r:r+1)+"@".concat(t," ")+n}return e}let rv=new Map;function rw(e){let{inputValue:t,cursorPosition:r,onSelect:a,onClose:o,isVisible:i,apiBase:l=""}=e,[c,d]=(0,n.useState)(0),[x,u]=(0,n.useState)([]),[m,h]=(0,n.useState)(!1),[p,g]=(0,n.useState)(null),b=(0,n.useRef)(null),f=(0,n.useRef)(null),j=(0,n.useMemo)(()=>rj(t,r),[t,r]);(0,n.useEffect)(()=>{if(!i||null===j){u([]);return}let e=j||"__root__",t=rv.get(e);if(t&&Date.now()-t.timestamp<3e4){u(t.files),g(null);return}f.current&&f.current.abort();let r=new AbortController;f.current=r;let s=setTimeout(async()=>{h(!0),g(null);try{let t=j||"",s=await fetch("".concat(l,"/api/files?q=").concat(encodeURIComponent(t),"&limit=15"),{signal:r.signal});if(!s.ok)throw Error("Failed to fetch files");let n=((await s.json()).files||[]).map(e=>({path:e.path,name:e.name,isDirectory:e.isDirectory||!1}));rv.set(e,{files:n,timestamp:Date.now()}),u(n)}catch(e){if(e instanceof Error&&"AbortError"===e.name)return;g("Failed to load files"),u([])}finally{h(!1)}},150);return()=>{clearTimeout(s),r.abort()}},[i,j,l]),(0,n.useEffect)(()=>{d(0)},[x.length]),(0,n.useEffect)(()=>{if(!b.current)return;let e=b.current.querySelector('[data-selected="true"]');e&&e.scrollIntoView({block:"nearest"})},[c]);let y=(0,n.useCallback)(e=>{if(i&&0!==x.length)switch(e.key){case"ArrowDown":e.preventDefault(),d(e=>(e+1)%x.length);break;case"ArrowUp":e.preventDefault(),d(e=>(e-1+x.length)%x.length);break;case"Enter":case"Tab":e.preventDefault();let s=x[c];if(s){let e=ry(t,s.path,r);a(s.path,e)}break;case"Escape":e.preventDefault(),o()}},[i,x,c,t,r,a,o]);(0,n.useEffect)(()=>{if(i)return window.addEventListener("keydown",y),()=>window.removeEventListener("keydown",y)},[i,y]);let v=(0,n.useCallback)(e=>{let s=ry(t,e.path,r);a(e.path,s)},[t,r,a]);return i&&(0!==x.length||m||p)?(0,s.jsxs)("div",{className:"absolute bottom-full left-0 right-0 max-h-[240px] overflow-y-auto bg-[#1a1d21] border border-white/10 rounded-lg shadow-[0_-4px_20px_rgba(0,0,0,0.4)] z-[100] mb-1",ref:b,children:[(0,s.jsxs)("div",{className:"px-3 py-1.5 text-[10px] uppercase tracking-wider text-[#8d8d8e] border-b border-white/5 flex items-center gap-2",children:[(0,s.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,s.jsx)("path",{d:"M13 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V9z"}),(0,s.jsx)("polyline",{points:"13 2 13 9 20 9"})]}),"Files ",j&&(0,s.jsxs)("span",{className:"text-[#6b6b6c]",children:['matching "',j,'"']})]}),m&&0===x.length&&(0,s.jsxs)("div",{className:"px-3 py-4 text-sm text-[#8d8d8e] text-center",children:[(0,s.jsx)("svg",{className:"animate-spin mx-auto mb-2",width:"16",height:"16",viewBox:"0 0 24 24",children:(0,s.jsx)("circle",{cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"2",fill:"none",strokeDasharray:"32",strokeLinecap:"round"})}),"Searching files..."]}),p&&(0,s.jsx)("div",{className:"px-3 py-4 text-sm text-red-400 text-center",children:p}),x.map((e,t)=>(0,s.jsxs)("div",{"data-selected":t===c,className:"flex items-center gap-2.5 py-2 px-3 cursor-pointer transition-colors duration-150 ".concat(t===c?"bg-white/[0.08]":"hover:bg-white/[0.08]"),onClick:()=>v(e),onMouseEnter:()=>d(t),children:[(0,s.jsx)("div",{className:"w-7 h-7 rounded-md flex items-center justify-center text-[#8d8d8e]",style:{background:e.isDirectory?"rgba(251, 191, 36, 0.15)":"rgba(96, 165, 250, 0.15)"},children:e.isDirectory?(0,s.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"#fbbf24",strokeWidth:"2",children:(0,s.jsx)("path",{d:"M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z"})}):(0,s.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"#60a5fa",strokeWidth:"2",children:[(0,s.jsx)("path",{d:"M13 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V9z"}),(0,s.jsx)("polyline",{points:"13 2 13 9 20 9"})]})}),(0,s.jsxs)("div",{className:"flex flex-col gap-0.5 min-w-0 flex-1",children:[(0,s.jsx)("span",{className:"text-sm font-medium text-[#d1d2d3] truncate",children:e.name}),(0,s.jsx)("span",{className:"text-xs text-[#6b6b6c] truncate",children:e.path})]})]},e.path)),!m&&!p&&0===x.length&&j&&(0,s.jsxs)("div",{className:"px-3 py-4 text-sm text-[#8d8d8e] text-center",children:['No files found matching "',j,'"']})]}):null}function rN(e){let{workspaces:t,activeWorkspaceId:r,onSelect:a,onAddWorkspace:o,onWorkspaceSettings:i,isLoading:l=!1}=e,[c,d]=(0,n.useState)(!1),x=(0,n.useRef)(null),u=t.find(e=>e.id===r);return(0,n.useEffect)(()=>{let e=e=>{x.current&&!x.current.contains(e.target)&&d(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[]),(0,n.useEffect)(()=>{let e=e=>{"Escape"===e.key&&d(!1)};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[]),(0,s.jsxs)("div",{className:"relative w-full",ref:x,children:[(0,s.jsxs)("button",{className:"w-full flex items-center gap-2 px-3 py-2.5 bg-[#2a2a3e] border border-[#3a3a4e] rounded-lg text-[#e8e8e8] text-sm cursor-pointer transition-all hover:bg-[#3a3a4e] hover:border-[#4a4a5e] disabled:opacity-60 disabled:cursor-not-allowed",onClick:()=>d(!c),disabled:l,children:[l?(0,s.jsx)("span",{className:"flex-1 text-left text-[#666]",children:"Loading..."}):u?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(rk,{provider:u.provider}),(0,s.jsx)("span",{className:"flex-1 text-left font-medium",children:u.name}),u.gitBranch&&(0,s.jsxs)("span",{className:"flex items-center gap-1 text-xs text-[#888] bg-white/5 px-1.5 py-0.5 rounded",children:[(0,s.jsx)(rA,{}),u.gitBranch]})]}):(0,s.jsx)("span",{className:"flex-1 text-left text-[#666]",children:"Select workspace..."}),(0,s.jsx)(rS,{isOpen:c})]}),c&&(0,s.jsxs)("div",{className:"absolute top-[calc(100%+4px)] left-0 right-0 bg-[#1a1a2e] border border-[#3a3a4e] rounded-lg shadow-[0_10px_40px_rgba(0,0,0,0.4)] z-[1000] overflow-hidden",children:[(0,s.jsx)("div",{className:"max-h-[300px] overflow-y-auto",children:0===t.length?(0,s.jsxs)("div",{className:"py-6 px-4 text-center text-[#666] text-[13px] leading-relaxed",children:["No workspaces added yet.",(0,s.jsx)("br",{}),"Add a repository to get started."]}):t.map(e=>(0,s.jsxs)("button",{className:"w-full flex items-center gap-2.5 px-3 py-2.5 bg-transparent border-none text-[#e8e8e8] text-sm cursor-pointer transition-colors text-left hover:bg-white/5 ".concat(e.id===r?"bg-[rgba(0,200,150,0.1)]":""),onClick:()=>{a(e),d(!1)},children:[(0,s.jsx)(rk,{provider:e.provider}),(0,s.jsxs)("div",{className:"flex-1 flex flex-col gap-0.5 min-w-0",children:[(0,s.jsx)("span",{className:"font-medium",children:e.name}),(0,s.jsx)("span",{className:"text-[11px] text-[#666] overflow-hidden text-ellipsis whitespace-nowrap",children:e.path})]}),(0,s.jsx)(rC,{status:e.status})]},e.id))}),(0,s.jsxs)("div",{className:"p-2 border-t border-[#3a3a4e] space-y-1.5",children:[i&&u&&(0,s.jsxs)("button",{className:"w-full flex items-center justify-center gap-1.5 px-3 py-2 bg-transparent border border-[#3a3a4e] rounded-md text-[#888] text-[13px] cursor-pointer transition-all hover:bg-white/5 hover:border-[#4a4a5e] hover:text-[#e8e8e8]",onClick:()=>{i(),d(!1)},children:[(0,s.jsx)(rE,{}),"Workspace Settings"]}),(0,s.jsxs)("button",{className:"w-full flex items-center justify-center gap-1.5 px-3 py-2 bg-transparent border border-dashed border-[#3a3a4e] rounded-md text-[#888] text-[13px] cursor-pointer transition-all hover:bg-white/5 hover:border-[#4a4a5e] hover:text-[#e8e8e8]",onClick:o,children:[(0,s.jsx)(rL,{}),"Add Workspace"]})]})]})]})}function rk(e){let{provider:t}=e,r={claude:"\uD83E\uDD16",codex:"\uD83E\uDDE0",gemini:"✨",generic:"\uD83D\uDCC1"};return(0,s.jsx)("span",{className:"text-base",title:t,children:r[t]||r.generic})}function rC(e){let{status:t}=e,r={active:"bg-green-500",inactive:"bg-gray-500",error:"bg-red-500"};return(0,s.jsx)("span",{className:"w-2 h-2 rounded-full flex-shrink-0 ".concat(r[t]||r.inactive),title:t})}function rS(e){let{isOpen:t}=e;return(0,s.jsx)("svg",{className:"text-[#666] transition-transform ".concat(t?"rotate-180":""),width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:(0,s.jsx)("polyline",{points:"6 9 12 15 18 9"})})}function rA(){return(0,s.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,s.jsx)("line",{x1:"6",y1:"3",x2:"6",y2:"15"}),(0,s.jsx)("circle",{cx:"18",cy:"6",r:"3"}),(0,s.jsx)("circle",{cx:"6",cy:"18",r:"3"}),(0,s.jsx)("path",{d:"M18 9a9 9 0 0 1-9 9"})]})}function rL(){return(0,s.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,s.jsx)("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),(0,s.jsx)("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]})}function rE(){return(0,s.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,s.jsx)("circle",{cx:"12",cy:"12",r:"3"}),(0,s.jsx)("path",{d:"M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-2 2 2 2 0 0 1-2-2v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1-2-2 2 2 0 0 1 2-2h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 2-2 2 2 0 0 1 2 2v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 2 2 2 2 0 0 1-2 2h-.09a1.65 1.65 0 0 0-1.51 1z"})]})}function rW(e){let{isOpen:t,onClose:r,onAdd:a,isAdding:o=!1,error:i}=e,[l,c]=(0,n.useState)(""),[d,x]=(0,n.useState)(""),[u,m]=(0,n.useState)(null),h=(0,n.useRef)(null);(0,n.useEffect)(()=>{t&&h.current&&h.current.focus()},[t]),(0,n.useEffect)(()=>{t||(c(""),x(""),m(null))},[t]);let p=async e=>{if(e.preventDefault(),!l.trim()){m("Path is required");return}try{await a(l.trim(),d.trim()||void 0),r()}catch(e){m(e instanceof Error?e.message:"Failed to add workspace")}};if(!t)return null;let g=i||u;return(0,s.jsx)("div",{className:"fixed inset-0 bg-black/60 flex items-center justify-center z-[9999] backdrop-blur-sm",onClick:r,onKeyDown:e=>{"Escape"===e.key&&r()},children:(0,s.jsxs)("div",{className:"bg-[#1a1a2e] border border-[#3a3a4e] rounded-xl p-6 min-w-[450px] max-w-[90vw] shadow-[0_20px_60px_rgba(0,0,0,0.5)]",onClick:e=>e.stopPropagation(),children:[(0,s.jsxs)("div",{className:"flex items-center justify-between mb-6",children:[(0,s.jsx)("h2",{className:"m-0 text-lg font-semibold text-[#e8e8e8]",children:"Add Workspace"}),(0,s.jsx)("button",{className:"bg-transparent border-none text-[#666] cursor-pointer p-1 flex items-center justify-center rounded transition-all hover:bg-white/10 hover:text-[#e8e8e8]",onClick:r,children:(0,s.jsx)(rD,{})})]}),(0,s.jsxs)("form",{onSubmit:p,children:[(0,s.jsxs)("div",{className:"mb-5",children:[(0,s.jsx)("label",{htmlFor:"workspace-path",className:"block mb-2 text-[13px] font-medium text-[#e8e8e8]",children:"Repository Path"}),(0,s.jsx)("input",{ref:h,id:"workspace-path",type:"text",value:l,onChange:e=>{c(e.target.value),m(null)},placeholder:"/path/to/repository",disabled:o,autoComplete:"off",className:"w-full px-3 py-2.5 bg-[#2a2a3e] border border-[#3a3a4e] rounded-md text-[#e8e8e8] text-sm outline-none transition-colors box-border focus:border-[#00c896] placeholder:text-[#666] disabled:opacity-60 disabled:cursor-not-allowed"}),(0,s.jsx)("p",{className:"mt-1.5 text-xs text-[#666] leading-relaxed",children:"Enter the full path to your repository. Use ~ for home directory."})]}),(0,s.jsxs)("div",{className:"mb-5",children:[(0,s.jsx)("label",{htmlFor:"workspace-name",className:"block mb-2 text-[13px] font-medium text-[#e8e8e8]",children:"Display Name (optional)"}),(0,s.jsx)("input",{id:"workspace-name",type:"text",value:d,onChange:e=>x(e.target.value),placeholder:"My Project",disabled:o,autoComplete:"off",className:"w-full px-3 py-2.5 bg-[#2a2a3e] border border-[#3a3a4e] rounded-md text-[#e8e8e8] text-sm outline-none transition-colors box-border focus:border-[#00c896] placeholder:text-[#666] disabled:opacity-60 disabled:cursor-not-allowed"}),(0,s.jsx)("p",{className:"mt-1.5 text-xs text-[#666] leading-relaxed",children:"A friendly name for this workspace. Defaults to the folder name."})]}),g&&(0,s.jsx)("div",{className:"px-3 py-2.5 bg-red-500/10 border border-red-500/30 rounded-md text-red-500 text-[13px] mb-5",children:g}),(0,s.jsxs)("div",{className:"flex gap-3 justify-end mt-6",children:[(0,s.jsx)("button",{type:"button",className:"px-5 py-2.5 rounded-md text-sm font-medium cursor-pointer transition-all bg-transparent border border-[#3a3a4e] text-[#e8e8e8] hover:bg-white/5 disabled:opacity-50 disabled:cursor-not-allowed",onClick:r,disabled:o,children:"Cancel"}),(0,s.jsx)("button",{type:"submit",className:"px-5 py-2.5 rounded-md text-sm font-medium cursor-pointer transition-all bg-[#00c896] border-none text-[#1a1a2e] hover:bg-[#00a87d] disabled:opacity-50 disabled:cursor-not-allowed",disabled:o||!l.trim(),children:o?"Adding...":"Add Workspace"})]})]})]})})}function rD(){return(0,s.jsxs)("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,s.jsx)("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),(0,s.jsx)("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})}let rM=0;function rT(){return"log-".concat(Date.now(),"-").concat(++rM)}var rR=r(9540),rP=r(1561),rB=r(7418);let r_=(0,n.createContext)({wsBaseUrl:null,isCloudMode:!1});function rI(e){let{children:t,wsUrl:r}=e,a=(0,n.useMemo)(()=>{if(!r)return{wsBaseUrl:null,isCloudMode:!1};let e=function(e){try{let t=new URL(e);return"".concat(t.protocol,"//").concat(t.host)}catch(t){return e}}(r),t=!1;try{t=new URL(r).host!==window.location.host}catch(e){}return{wsBaseUrl:e,isCloudMode:t}},[r]);return(0,s.jsx)(r_.Provider,{value:a,children:t})}let rU={background:"#0d0f14",foreground:"#c9d1d9",cursor:"#58a6ff",cursorAccent:"#0d0f14",selectionBackground:"#264f78",selectionForeground:"#ffffff",black:"#484f58",red:"#f85149",green:"#3fb950",yellow:"#d29922",blue:"#58a6ff",magenta:"#bc8cff",cyan:"#39c5cf",white:"#b1bac4",brightBlack:"#6e7681",brightRed:"#ff7b72",brightGreen:"#56d364",brightYellow:"#e3b341",brightBlue:"#79c0ff",brightMagenta:"#d2a8ff",brightCyan:"#56d4dd",brightWhite:"#ffffff"};function rF(e){let{agentName:t,maxHeight:r="500px",showHeader:o=!0,onClose:i,className:l=""}=e,c=(0,n.useRef)(null),d=(0,n.useRef)(null),x=(0,n.useRef)(null),u=(0,n.useRef)(null),m=(0,n.useRef)(null),h=(0,n.useRef)(null),p=(0,n.useRef)(0),[g,b]=(0,n.useState)(!1),[f,j]=(0,n.useState)(!1),[y,v]=(0,n.useState)(null),[w,N]=(0,n.useState)(!1),[k,C]=(0,n.useState)(""),[S,A]=(0,n.useState)(0),L=(0,n.useRef)(null),E=(0,a.GW)(t),W=function(e){let{wsBaseUrl:t}=(0,n.useContext)(r_);return(0,n.useMemo)(()=>{if(t)return"".concat(t).concat(e);let r="https:"===window.location.protocol?"wss:":"ws:",{hostname:s,port:n}=window.location;return"".concat(r,"//").concat(window.location.host).concat(e)},[t,e])}("/ws/logs/".concat(encodeURIComponent(t)));(0,n.useEffect)(()=>{if(!c.current)return;let e=new rR.o({theme:rU,fontFamily:'ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace',fontSize:12,lineHeight:1.4,convertEol:!0,scrollback:1e4,cursorBlink:!1,cursorStyle:"bar",disableStdin:!0,allowProposedApi:!0}),t=new rP.X,r=new rB.Z;e.loadAddon(t),e.loadAddon(r),e.open(c.current),t.fit(),d.current=e,x.current=t,u.current=r;let s=new ResizeObserver(()=>{t.fit()});return s.observe(c.current),()=>{s.disconnect(),e.dispose(),d.current=null,x.current=null,u.current=null}},[]);let D=(0,n.useCallback)(()=>{var e,r;if((null===(e=m.current)||void 0===e?void 0:e.readyState)===WebSocket.OPEN||(null===(r=m.current)||void 0===r?void 0:r.readyState)===WebSocket.CONNECTING)return;j(!0),v(null);let s=new WebSocket(W);m.current=s,s.onopen=()=>{var e;b(!0),j(!1),v(null),p.current=0,null===(e=d.current)||void 0===e||e.writeln("\x1b[90m[Connected to ".concat(t," log stream]\x1b[0m"))},s.onclose=e=>{var t,r;if(b(!1),j(!1),m.current=null,h.current&&(clearTimeout(h.current),h.current=null),4404===e.code){null===(r=d.current)||void 0===r||r.writeln("\x1b[31m[Agent not found]\x1b[0m");return}let s=Math.min(1e3*Math.pow(2,p.current),3e4);p.current++,null===(t=d.current)||void 0===t||t.writeln("\x1b[90m[Disconnected. Reconnecting in ".concat(s/1e3,"s...]\x1b[0m")),h.current=setTimeout(()=>{D()},s)},s.onerror=()=>{v(Error("WebSocket connection error")),j(!1)},s.onmessage=e=>{var t,r,s;try{let s=JSON.parse(e.data);if("error"===s.type){null===(t=d.current)||void 0===t||t.writeln("\x1b[31mError: ".concat(s.error,"\x1b[0m"));return}if("subscribed"===s.type)return;if("history"===s.type&&Array.isArray(s.lines)){s.lines.forEach(e=>{var t;null===(t=d.current)||void 0===t||t.writeln(e),A(e=>e+1)});return}if("log"===s.type||"output"===s.type){let e=s.content||s.data||s.message||"";if(e){null===(r=d.current)||void 0===r||r.write(e);let t=(e.match(/\n/g)||[]).length;t>0&&A(e=>e+t)}return}s.lines&&Array.isArray(s.lines)&&s.lines.forEach(e=>{var t;let r="string"==typeof e?e:e.content;null===(t=d.current)||void 0===t||t.writeln(r),A(e=>e+1)})}catch(t){if("string"==typeof e.data){null===(s=d.current)||void 0===s||s.write(e.data);let t=(e.data.match(/\n/g)||[]).length;t>0&&A(e=>e+t)}}}},[W,t]),M=(0,n.useCallback)(()=>{h.current&&(clearTimeout(h.current),h.current=null),m.current&&(m.current.close(),m.current=null),b(!1),j(!1)},[]),T=(0,n.useCallback)(()=>{var e;null===(e=d.current)||void 0===e||e.clear(),A(0)},[]),R=(0,n.useCallback)(e=>{C(e),e&&u.current&&u.current.findNext(e,{caseSensitive:!1})},[]),P=(0,n.useCallback)(()=>{k&&u.current&&u.current.findNext(k,{caseSensitive:!1})},[k]),B=(0,n.useCallback)(()=>{k&&u.current&&u.current.findPrevious(k,{caseSensitive:!1})},[k]);return(0,n.useEffect)(()=>(D(),()=>{M()}),[D,M]),(0,n.useEffect)(()=>{let e=e=>{(e.metaKey||e.ctrlKey)&&"f"===e.key&&(e.preventDefault(),N(!0),setTimeout(()=>{var e;return null===(e=L.current)||void 0===e?void 0:e.focus()},0)),"Escape"===e.key&&w&&(N(!1),C("")),"Enter"===e.key&&w&&(e.preventDefault(),e.shiftKey?B():P())};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[w,P,B]),(0,s.jsxs)("div",{className:"xterm-log-viewer flex flex-col rounded-xl overflow-hidden border border-[#2a2d35] shadow-2xl ".concat(l),style:{background:"linear-gradient(180deg, #0d0f14 0%, #0a0c10 100%)",boxShadow:"0 0 60px -15px ".concat(E.primary,"25, 0 25px 50px -12px rgba(0, 0, 0, 0.8), inset 0 1px 0 rgba(255,255,255,0.02)")},children:[o&&(0,s.jsxs)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-[#21262d]",style:{background:"linear-gradient(180deg, #161b22 0%, #0d1117 100%)"},children:[(0,s.jsxs)("div",{className:"flex items-center gap-3",children:[(0,s.jsx)("div",{className:"flex items-center gap-2",children:(0,s.jsxs)("div",{className:"flex gap-1.5",children:[(0,s.jsx)("div",{className:"w-3 h-3 rounded-full bg-[#ff5f56] border border-[#e0443e] transition-shadow hover:shadow-[0_0_8px_rgba(255,95,86,0.5)]"}),(0,s.jsx)("div",{className:"w-3 h-3 rounded-full bg-[#ffbd2e] border border-[#dea123] transition-shadow hover:shadow-[0_0_8px_rgba(255,189,46,0.5)]"}),(0,s.jsx)("div",{className:"w-3 h-3 rounded-full bg-[#27c93f] border border-[#1aab29] transition-shadow hover:shadow-[0_0_8px_rgba(39,201,63,0.5)]"})]})}),(0,s.jsx)("div",{className:"w-px h-4 bg-[#30363d]"}),(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)(rO,{}),(0,s.jsx)("span",{className:"text-sm font-semibold",style:{color:E.primary},children:t}),(0,s.jsx)(rq,{isConnected:g,isConnecting:f})]})]}),(0,s.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,s.jsx)("button",{className:"p-1.5 rounded-lg transition-all duration-200 ".concat(w?"bg-accent-cyan/20 text-accent-cyan shadow-[0_0_12px_rgba(0,217,255,0.25)]":"hover:bg-[#21262d] text-[#8b949e] hover:text-[#c9d1d9]"),onClick:()=>{N(!w),w||setTimeout(()=>{var e;return null===(e=L.current)||void 0===e?void 0:e.focus()},0)},title:"Search (Cmd+F)",children:(0,s.jsx)(rz,{})}),(0,s.jsx)("button",{className:"p-1.5 rounded-lg hover:bg-[#21262d] text-[#8b949e] hover:text-[#c9d1d9] transition-all duration-200",onClick:T,title:"Clear logs",children:(0,s.jsx)(rH,{})}),(0,s.jsx)("button",{className:"p-1.5 rounded-lg transition-all duration-200 ".concat(g?"hover:bg-[#f85149]/10 text-[#8b949e] hover:text-[#f85149]":"bg-[#3fb950]/20 text-[#3fb950] shadow-[0_0_12px_rgba(63,185,80,0.25)]"),onClick:g?M:D,title:g?"Disconnect":"Connect",children:g?(0,s.jsx)(rK,{}):(0,s.jsx)(rG,{})}),i&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("div",{className:"w-px h-4 bg-[#30363d] mx-1"}),(0,s.jsx)("button",{className:"p-1.5 rounded-lg hover:bg-[#f85149]/10 text-[#8b949e] hover:text-[#f85149] transition-all duration-200",onClick:i,title:"Close",children:(0,s.jsx)(rV,{})})]})]})]}),w&&(0,s.jsxs)("div",{className:"flex items-center gap-3 px-4 py-2 border-b border-[#21262d] bg-[#161b22]",children:[(0,s.jsx)(rz,{}),(0,s.jsx)("input",{ref:L,type:"text",className:"flex-1 bg-transparent border-none text-sm text-[#c9d1d9] placeholder:text-[#484f58] outline-none font-mono",placeholder:"Search logs... (Enter: next, Shift+Enter: prev)",value:k,onChange:e=>R(e.target.value)}),(0,s.jsxs)("div",{className:"flex items-center gap-1",children:[(0,s.jsx)("button",{className:"px-2 py-0.5 text-xs rounded bg-[#21262d] text-[#8b949e] hover:text-[#c9d1d9] transition-colors",onClick:B,title:"Previous (Shift+Enter)",children:"↑"}),(0,s.jsx)("button",{className:"px-2 py-0.5 text-xs rounded bg-[#21262d] text-[#8b949e] hover:text-[#c9d1d9] transition-colors",onClick:P,title:"Next (Enter)",children:"↓"})]})]}),y&&(0,s.jsxs)("div",{className:"px-4 py-2 bg-[#3d1d20] border-b border-[#f85149]/30 text-sm text-[#f85149] flex items-center gap-2",children:[(0,s.jsx)(rJ,{}),(0,s.jsx)("span",{children:y.message}),(0,s.jsx)("button",{className:"ml-auto text-xs px-2 py-0.5 rounded bg-[#f85149]/20 hover:bg-[#f85149]/30 transition-colors",onClick:D,children:"Retry"})]}),(0,s.jsx)("div",{ref:c,className:"flex-1 overflow-hidden",style:{maxHeight:r,minHeight:"200px"}}),(0,s.jsxs)("div",{className:"flex items-center justify-between px-4 py-2.5 border-t border-[#21262d] text-xs",style:{background:"linear-gradient(180deg, #0d1117 0%, #0a0c10 100%)"},children:[(0,s.jsx)("div",{className:"flex items-center gap-3",children:(0,s.jsxs)("span",{className:"tabular-nums font-mono text-[#6e7681]",children:[S," lines"]})}),(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)("span",{className:"text-[#6e7681] font-mono uppercase tracking-wider text-[10px]",children:"PTY stream"}),(0,s.jsx)("div",{className:"w-2 h-2 rounded-full transition-all duration-300 ".concat(g?"bg-[#3fb950]":f?"bg-[#d29922] animate-pulse":"bg-[#484f58]"),style:{boxShadow:g?"0 0 8px rgba(63,185,80,0.6)":"none"}})]})]})]})}function rO(){return(0,s.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"text-[#8b949e]",children:[(0,s.jsx)("polyline",{points:"4 17 10 11 4 5"}),(0,s.jsx)("line",{x1:"12",y1:"19",x2:"20",y2:"19"})]})}function rz(){return(0,s.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:"text-[#8b949e]",children:[(0,s.jsx)("circle",{cx:"11",cy:"11",r:"8"}),(0,s.jsx)("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]})}function rH(){return(0,s.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,s.jsx)("polyline",{points:"3 6 5 6 21 6"}),(0,s.jsx)("path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"})]})}function rV(){return(0,s.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,s.jsx)("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),(0,s.jsx)("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})}function rG(){return(0,s.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"currentColor",children:(0,s.jsx)("polygon",{points:"5 3 19 12 5 21 5 3"})})}function rK(){return(0,s.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"currentColor",children:[(0,s.jsx)("rect",{x:"6",y:"4",width:"4",height:"16"}),(0,s.jsx)("rect",{x:"14",y:"4",width:"4",height:"16"})]})}function rJ(){return(0,s.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,s.jsx)("circle",{cx:"12",cy:"12",r:"10"}),(0,s.jsx)("line",{x1:"12",y1:"8",x2:"12",y2:"12"}),(0,s.jsx)("line",{x1:"12",y1:"16",x2:"12.01",y2:"16"})]})}function rq(e){let{isConnected:t,isConnecting:r}=e;return r?(0,s.jsxs)("span",{className:"flex items-center gap-1 px-1.5 py-0.5 rounded-full bg-[#d29922]/20 text-[10px] text-[#d29922] uppercase tracking-wider",children:[(0,s.jsx)("span",{className:"w-1.5 h-1.5 rounded-full bg-[#d29922] animate-pulse"}),"connecting"]}):t?(0,s.jsxs)("span",{className:"flex items-center gap-1 px-1.5 py-0.5 rounded-full bg-[#238636]/20 text-[10px] text-[#3fb950] uppercase tracking-wider",children:[(0,s.jsx)("span",{className:"w-1.5 h-1.5 rounded-full bg-[#3fb950] shadow-[0_0_4px_rgba(63,185,80,0.5)]"}),"live"]}):(0,s.jsxs)("span",{className:"flex items-center gap-1 px-1.5 py-0.5 rounded-full bg-[#484f58]/20 text-[10px] text-[#484f58] uppercase tracking-wider",children:[(0,s.jsx)("span",{className:"w-1.5 h-1.5 rounded-full bg-[#484f58]"}),"offline"]})}function rX(e){let{agentName:t,mode:r="panel",maxHeight:o="500px",showHeader:i=!0,autoScrollDefault:l=!0,onClose:c,onExpand:d,className:x=""}=e,[u,m]=(0,n.useState)(l),h=(0,n.useRef)(null),{logs:p,isConnected:g,isConnecting:b}=function(e){let{agentName:t,maxLines:r=5e3,autoConnect:s=!0,reconnect:a=!0,maxReconnectAttempts:o=1/0}=e,[i,l]=(0,n.useState)([]),[c,d]=(0,n.useState)(!1),[x,u]=(0,n.useState)(!1),[m,h]=(0,n.useState)(null),p=(0,n.useRef)(null),g=(0,n.useRef)(0),b=(0,n.useRef)(null),f=(0,n.useRef)(t),j=(0,n.useRef)(!0),y=(0,n.useRef)(!1),v=(0,n.useRef)(new WeakMap),w=(0,n.useRef)(new WeakMap);f.current=t;let N=(0,n.useCallback)(()=>{var e,t;if(j.current=!0,(null===(e=p.current)||void 0===e?void 0:e.readyState)===WebSocket.OPEN||(null===(t=p.current)||void 0===t?void 0:t.readyState)===WebSocket.CONNECTING||y.current)return;y.current=!0,u(!0),h(null);let s=function(e){let t="/ws/logs/".concat(encodeURIComponent(e)),r="https:"===window.location.protocol?"wss:":"ws:",{hostname:s,port:n}=window.location;return"".concat(r,"//").concat(window.location.host).concat(t)}(f.current);try{let e=new WebSocket(s);p.current=e,v.current.set(e,!1),w.current.set(e,!1),e.onopen=()=>{y.current=!1,d(!0),u(!1),h(null),g.current=0,l(e=>[...e,{id:rT(),timestamp:Date.now(),content:"Connected to ".concat(f.current," log stream"),type:"system",agentName:f.current}])},e.onclose=t=>{var r,s;let n=null!==(r=v.current.get(e))&&void 0!==r&&r,i=null!==(s=w.current.get(e))&&void 0!==s&&s;if(y.current=!1,d(!1),u(!1),p.current=null,b.current&&(clearTimeout(b.current),b.current=null),!n&&4404!==t.code){if(!t.wasClean&&i){let e=j.current&&a&&g.current<o;l(r=>[...r,{id:rT(),timestamp:Date.now(),content:e?"Lost connection to log stream (code: ".concat(t.code,"). Reconnecting..."):"Disconnected from log stream (code: ".concat(t.code,")"),type:"system",agentName:f.current}])}if(j.current&&a&&g.current<o){let e=Math.min(1e3*Math.pow(2,g.current),3e4);g.current++,b.current=setTimeout(()=>{N()},e)}}},e.onerror=()=>{y.current=!1,h(Error("WebSocket connection error")),u(!1)},e.onmessage=t=>{try{let s=JSON.parse(t.data);if("error"===s.type){h(Error(s.error||"Failed to stream logs for ".concat(s.agent||f.current))),l(e=>[...e,{id:rT(),timestamp:Date.now(),content:"Error: ".concat(s.error||"Unknown error"),type:"system",agentName:s.agent||f.current}]);return}if("subscribed"===s.type){console.log("[useAgentLogs] Subscribed to ".concat(s.agent));return}if("history"===s.type&&Array.isArray(s.lines)){s.lines.length>0&&w.current.set(e,!0),l(e=>{let t=s.lines.map(e=>({id:rT(),timestamp:Date.now(),content:e,type:"stdout",agentName:s.agent||f.current}));return[...e,...t].slice(-r)});return}"string"==typeof s?(w.current.set(e,!0),l(e=>[...e,{id:rT(),timestamp:Date.now(),content:s,type:"stdout",agentName:f.current}].slice(-r))):"log"===s.type||"output"===s.type?(w.current.set(e,!0),l(e=>{let t="stderr"===s.stream?"stderr":"stdout";return[...e,{id:rT(),timestamp:s.timestamp||Date.now(),content:s.content||s.data||s.message||"",type:t,agentName:s.agentName||f.current}].slice(-r)})):s.lines&&Array.isArray(s.lines)&&(w.current.set(e,!0),l(e=>{let t=s.lines.map(e=>{let t="object"==typeof e&&"stderr"===e.type?"stderr":"stdout";return{id:rT(),timestamp:Date.now(),content:"string"==typeof e?e:e.content,type:t,agentName:f.current}});return[...e,...t].slice(-r)}))}catch(s){"string"==typeof t.data&&(w.current.set(e,!0),l(e=>[...e,{id:rT(),timestamp:Date.now(),content:t.data,type:"stdout",agentName:f.current}].slice(-r)))}}}catch(e){y.current=!1,h(e instanceof Error?e:Error("Failed to create WebSocket")),u(!1)}},[r,a,o]),k=(0,n.useCallback)(()=>{j.current=!1,b.current&&(clearTimeout(b.current),b.current=null),p.current&&(v.current.set(p.current,!0),p.current.close(),p.current=null),y.current=!1,d(!1),u(!1)},[]),C=(0,n.useCallback)(()=>{l([])},[]);return(0,n.useEffect)(()=>(s&&t&&N(),()=>{k()}),[t,s,N,k]),{logs:i,isConnected:c,isConnecting:x,error:m,connect:N,disconnect:k,clear:C}}({agentName:t,autoConnect:!0}),f=(0,a.GW)(t),j=(0,n.useMemo)(()=>p.filter(e=>{let t=rZ(e.content).trim();return 0!==t.length&&!(t.length<=2&&/^[⠋⠙⠹⠸⠼⠴⠦⠧⠇⠏⣾⣽⣻⢿⡿⣟⣯⣷◐◓◑◒●○◉◎|\\\/\-*.\u2800-\u28FF]+$/.test(t))}),[p]);(0,n.useEffect)(()=>{if(u&&h.current){let e=h.current;e.scrollTop=e.scrollHeight}},[p,u]);let y=(0,n.useCallback)(()=>{if(!h.current)return;let e=h.current,t=e.scrollHeight-e.scrollTop-e.clientHeight<50;t&&!u?m(!0):!t&&u&&m(!1)},[u]);return"inline"===r?(0,s.jsxs)("div",{className:"log-viewer-inline rounded-lg overflow-hidden border border-[#2a2d35] ".concat(x),style:{background:"linear-gradient(180deg, #0d0f14 0%, #12151c 100%)",boxShadow:"inset 0 1px 0 rgba(255,255,255,0.02), 0 4px 12px rgba(0,0,0,0.3)"},children:[(0,s.jsxs)("div",{className:"flex items-center justify-between px-3 py-2 border-b border-[#2a2d35]",style:{background:"linear-gradient(180deg, #161b22 0%, #0d1117 100%)"},children:[(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)(rQ,{}),(0,s.jsx)("span",{className:"text-xs font-medium",style:{color:f.primary},children:"Live logs"}),(0,s.jsx)(r$,{isConnected:g,isConnecting:b})]}),(0,s.jsx)("div",{className:"flex items-center gap-1",children:(0,s.jsx)("button",{className:"p-1.5 rounded-lg hover:bg-[#21262d] text-[#8b949e] hover:text-accent-cyan transition-all duration-200 hover:shadow-[0_0_8px_rgba(0,217,255,0.15)]",onClick:d,title:"Expand",children:(0,s.jsx)(r0,{})})})]}),(0,s.jsxs)("div",{className:"font-mono text-xs leading-relaxed p-3 overflow-y-auto",style:{maxHeight:"150px"},ref:h,onScroll:y,children:[j.slice(-20).map(e=>(0,s.jsx)(rY,{log:e,compact:!0},e.id)),0===j.length&&(0,s.jsxs)("div",{className:"text-[#484f58] italic flex items-center gap-2",children:[(0,s.jsx)("span",{className:"w-1.5 h-1.5 rounded-full bg-[#484f58] animate-pulse"}),"Waiting for output..."]})]})]}):(0,s.jsx)(rF,{agentName:t,maxHeight:o,showHeader:i,onClose:c,className:x})}function rY(e){let{log:t,compact:r=!1}=e,n=rZ(t.content);return(0,s.jsx)("div",{className:"".concat((()=>{switch(t.type){case"stderr":return"text-[#f85149]";case"system":return"text-[#58a6ff] italic";case"input":return"text-[#d29922]";default:return"text-[#c9d1d9]"}})()," leading-5 whitespace-pre-wrap break-all min-w-0 overflow-hidden"),children:n})}function r$(e){let{isConnected:t,isConnecting:r}=e;return r?(0,s.jsxs)("span",{className:"flex items-center gap-1 px-1.5 py-0.5 rounded-full bg-[#d29922]/20 text-[10px] text-[#d29922] uppercase tracking-wider",children:[(0,s.jsx)("span",{className:"w-1.5 h-1.5 rounded-full bg-[#d29922] animate-pulse"}),"connecting"]}):t?(0,s.jsxs)("span",{className:"flex items-center gap-1 px-1.5 py-0.5 rounded-full bg-[#238636]/20 text-[10px] text-[#3fb950] uppercase tracking-wider",children:[(0,s.jsx)("span",{className:"w-1.5 h-1.5 rounded-full bg-[#3fb950] shadow-[0_0_4px_rgba(63,185,80,0.5)]"}),"live"]}):(0,s.jsxs)("span",{className:"flex items-center gap-1 px-1.5 py-0.5 rounded-full bg-[#484f58]/20 text-[10px] text-[#484f58] uppercase tracking-wider",children:[(0,s.jsx)("span",{className:"w-1.5 h-1.5 rounded-full bg-[#484f58]"}),"offline"]})}function rZ(e){if(!e)return"";let t=e;return(t=(t=(t=(t=(t=(t=(t=(t=(t=t.replace(RegExp("\\x1b\\].*?(?:\\x07|\\x1b\\\\)","gs"),"")).replace(RegExp("\\x1bP.*?\\x1b\\\\","gs"),"")).replace(/\x1b\[[0-9;?]*[ -/]*[@-~]/g,"")).replace(/\x1b[@-Z\\-_]/g,"")).replace(/^\[\??\d+[hlKJHfABCDGPXsu]/gm,"")).replace(/\[\d+(?:;\d+)*m/g,"")).replace(/\r/g,"")).replace(/.\x08/g,"")).replace(/\x08+/g,"")).replace(/[\x00-\x08\x0B\x0C\x0E-\x1F]/g,"")}function rQ(e){let{size:t=16}=e;return(0,s.jsxs)("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"text-[#8b949e]",children:[(0,s.jsx)("polyline",{points:"4 17 10 11 4 5"}),(0,s.jsx)("line",{x1:"12",y1:"19",x2:"20",y2:"19"})]})}function r0(){return(0,s.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,s.jsx)("polyline",{points:"15 3 21 3 21 9"}),(0,s.jsx)("polyline",{points:"9 21 3 21 3 15"}),(0,s.jsx)("line",{x1:"21",y1:"3",x2:"14",y2:"10"}),(0,s.jsx)("line",{x1:"3",y1:"21",x2:"10",y2:"14"})]})}function r1(e){let{agent:t,position:r="right",isOpen:o,onClose:i,onAgentChange:l,availableAgents:c=[]}=e,d=(0,a.GW)(t.name),[x,u]=(0,n.useState)(!0);return((0,n.useEffect)(()=>{let e=e=>{"Escape"===e.key&&o&&i()};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[o,i]),(0,n.useEffect)(()=>{if(o&&"fullscreen"===r)return document.body.style.overflow="hidden",()=>{document.body.style.overflow=""}},[o,r]),o)?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("div",{className:"fixed inset-0 bg-black/60 z-[1099] animate-fade-in",onClick:i}),(0,s.jsxs)("div",{className:"flex flex-col ".concat((()=>{switch(r){case"right":return"animate-slide-in-right";case"bottom":return"animate-slide-in-bottom";case"fullscreen":return"animate-fade-in"}})()),style:(()=>{let e={position:"fixed",zIndex:1100,background:"linear-gradient(180deg, #0d0f14 0%, #0a0c10 100%)"};switch(r){case"right":return{...e,top:0,right:0,bottom:0,width:"600px",maxWidth:"100vw",borderLeft:"1px solid #21262d",boxShadow:"-20px 0 60px rgba(0, 0, 0, 0.5)"};case"bottom":return{...e,left:0,right:0,bottom:0,height:"400px",maxHeight:"60vh",borderTop:"1px solid #21262d",boxShadow:"0 -20px 60px rgba(0, 0, 0, 0.5)"};case"fullscreen":return{...e,inset:0}}})(),children:[(0,s.jsxs)("div",{className:"flex items-center justify-between border-b border-[#21262d] transition-all duration-200 ".concat(x?"px-4 py-2":"px-5 py-4"),style:{background:"linear-gradient(180deg, #161b22 0%, #0d1117 100%)"},children:[(0,s.jsxs)("div",{className:"flex items-center gap-3",children:[(0,s.jsx)("button",{className:"p-1 rounded-md text-[#8b949e] hover:text-[#c9d1d9] hover:bg-[#21262d] transition-colors",onClick:()=>u(!x),title:x?"Expand header":"Collapse header",children:(0,s.jsx)(r7,{collapsed:x})}),(0,s.jsxs)("div",{className:"relative shrink-0 rounded-xl flex items-center justify-center font-bold overflow-hidden transition-all duration-200 ".concat(x?"w-8 h-8 text-xs":"w-11 h-11 text-sm"),style:{backgroundColor:d.primary,color:d.text,boxShadow:x?"0 0 12px ".concat(d.primary,"40"):"0 0 24px ".concat(d.primary,"50, inset 0 1px 0 rgba(255,255,255,0.2)")},children:[(0,s.jsx)("div",{className:"absolute inset-0 opacity-30",style:{background:"linear-gradient(135deg, rgba(255,255,255,0.35) 0%, transparent 50%)"}}),(0,s.jsx)("span",{className:"relative z-10",children:(0,a.hP)(t.name)})]}),x?(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)("span",{className:"text-sm font-semibold",style:{color:d.primary},children:t.name}),(0,s.jsx)("span",{className:"px-2 py-0.5 rounded text-[9px] uppercase tracking-wider font-medium ".concat("online"===t.status?"bg-[#3fb950]/15 text-[#3fb950]":"busy"===t.status?"bg-[#d29922]/15 text-[#d29922]":"bg-[#484f58]/15 text-[#484f58]"),children:t.status})]}):(0,s.jsxs)("div",{className:"flex flex-col",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2.5",children:[(0,s.jsx)("h2",{className:"text-lg font-semibold m-0",style:{color:d.primary},children:t.name}),(0,s.jsx)("span",{className:"px-2.5 py-0.5 rounded-md text-[10px] uppercase tracking-wider font-medium ".concat("online"===t.status?"bg-[#3fb950]/15 text-[#3fb950]":"busy"===t.status?"bg-[#d29922]/15 text-[#d29922]":"bg-[#484f58]/15 text-[#484f58]"),style:{boxShadow:"online"===t.status?"0 0 8px rgba(63,185,80,0.2)":"none"},children:t.status})]}),t.currentTask&&(0,s.jsx)("span",{className:"text-sm text-[#8b949e] truncate max-w-[300px] mt-0.5",children:t.currentTask})]})]}),(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[c.length>1&&l&&(0,s.jsx)(r2,{agents:c,currentAgent:t,onSelect:l}),(0,s.jsxs)("div",{className:"flex items-center gap-1 bg-[#21262d]/80 rounded-lg p-1 border border-[#30363d]/50",children:[(0,s.jsx)("button",{className:"p-1.5 rounded-md transition-all duration-200 ".concat("right"===r?"bg-accent-cyan/15 text-accent-cyan shadow-[0_0_8px_rgba(0,217,255,0.15)]":"text-[#8b949e] hover:text-[#c9d1d9] hover:bg-[#30363d]"),title:"Sidebar view",children:(0,s.jsx)(r4,{})}),(0,s.jsx)("button",{className:"p-1.5 rounded-md transition-all duration-200 ".concat("bottom"===r?"bg-accent-cyan/15 text-accent-cyan shadow-[0_0_8px_rgba(0,217,255,0.15)]":"text-[#8b949e] hover:text-[#c9d1d9] hover:bg-[#30363d]"),title:"Bottom panel",children:(0,s.jsx)(r3,{})}),(0,s.jsx)("button",{className:"p-1.5 rounded-md transition-all duration-200 ".concat("fullscreen"===r?"bg-accent-cyan/15 text-accent-cyan shadow-[0_0_8px_rgba(0,217,255,0.15)]":"text-[#8b949e] hover:text-[#c9d1d9] hover:bg-[#30363d]"),title:"Fullscreen",children:(0,s.jsx)(r6,{})})]}),(0,s.jsx)("button",{className:"p-2 rounded-lg text-[#8b949e] hover:text-[#f85149] hover:bg-[#f85149]/10 transition-all duration-200 hover:shadow-[0_0_8px_rgba(248,81,73,0.2)]",onClick:i,children:(0,s.jsx)(r5,{})})]})]}),(0,s.jsx)("div",{className:"flex-1 min-h-0",children:(0,s.jsx)(rX,{agentName:t.name,mode:"panel",showHeader:!1,maxHeight:"100%",className:"h-full rounded-none border-none"})})]}),(0,s.jsx)("style",{children:"\n @keyframes slideInRight {\n from {\n transform: translateX(100%);\n opacity: 0;\n }\n to {\n transform: translateX(0);\n opacity: 1;\n }\n }\n\n @keyframes slideInBottom {\n from {\n transform: translateY(100%);\n opacity: 0;\n }\n to {\n transform: translateY(0);\n opacity: 1;\n }\n }\n\n .animate-slide-in-right {\n animation: slideInRight 0.3s cubic-bezier(0.32, 0.72, 0, 1);\n }\n\n .animate-slide-in-bottom {\n animation: slideInBottom 0.3s cubic-bezier(0.32, 0.72, 0, 1);\n }\n "})]}):null}function r2(e){let{agents:t,currentAgent:r,onSelect:o}=e,[i,l]=n.useState(!1),c=n.useRef(null);return(0,n.useEffect)(()=>{let e=e=>{c.current&&!c.current.contains(e.target)&&l(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[]),(0,s.jsxs)("div",{className:"relative",ref:c,children:[(0,s.jsxs)("button",{className:"flex items-center gap-2 px-3 py-1.5 bg-[#21262d] hover:bg-[#30363d] rounded-lg text-sm text-[#c9d1d9] transition-colors",onClick:()=>l(!i),children:[(0,s.jsx)("span",{children:"Switch agent"}),(0,s.jsx)(r8,{})]}),i&&(0,s.jsx)("div",{className:"absolute right-0 top-full mt-2 w-64 bg-[#161b22] border border-[#30363d] rounded-lg shadow-xl overflow-hidden z-10",children:(0,s.jsx)("div",{className:"max-h-64 overflow-y-auto",children:t.map(e=>{let t=(0,a.GW)(e.name),n=e.name===r.name;return(0,s.jsxs)("button",{className:"w-full flex items-center gap-3 px-3 py-2 text-left transition-colors ".concat(n?"bg-[#238636]/20":"hover:bg-[#21262d]"),onClick:()=>{o(e),l(!1)},children:[(0,s.jsx)("div",{className:"w-8 h-8 rounded flex items-center justify-center text-xs font-semibold shrink-0",style:{backgroundColor:t.primary,color:t.text},children:(0,a.hP)(e.name)}),(0,s.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,s.jsx)("div",{className:"text-sm text-[#c9d1d9] truncate",children:e.name}),(0,s.jsx)("div",{className:"text-xs text-[#8b949e]",children:e.status})]}),n&&(0,s.jsx)(r9,{})]},e.name)})})})]})}function r5(){return(0,s.jsxs)("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,s.jsx)("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),(0,s.jsx)("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})}function r4(){return(0,s.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,s.jsx)("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),(0,s.jsx)("line",{x1:"15",y1:"3",x2:"15",y2:"21"})]})}function r3(){return(0,s.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,s.jsx)("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),(0,s.jsx)("line",{x1:"3",y1:"15",x2:"21",y2:"15"})]})}function r6(){return(0,s.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,s.jsx)("polyline",{points:"15 3 21 3 21 9"}),(0,s.jsx)("polyline",{points:"9 21 3 21 3 15"}),(0,s.jsx)("line",{x1:"21",y1:"3",x2:"14",y2:"10"}),(0,s.jsx)("line",{x1:"3",y1:"21",x2:"10",y2:"14"})]})}function r8(){return(0,s.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:(0,s.jsx)("polyline",{points:"6 9 12 15 18 9"})})}function r9(){return(0,s.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"#3fb950",strokeWidth:"2",children:(0,s.jsx)("polyline",{points:"20 6 9 17 4 12"})})}function r7(e){let{collapsed:t}=e;return(0,s.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"transition-transform duration-200 ".concat(t?"":"rotate-90"),children:(0,s.jsx)("polyline",{points:"9 18 15 12 9 6"})})}function se(e){let{agentName:t,steps:r,history:a=[],selectedTrajectoryId:o,onSelectTrajectory:i,isLoading:l=!1,onStepClick:c,compact:d=!1}=e,[x,u]=(0,n.useState)(new Set),[m,h]=(0,n.useState)("all"),p=(0,n.useMemo)(()=>"all"===m?r:r.filter(e=>e.type===m),[r,m]),g=e=>{u(t=>{let r=new Set(t);return r.has(e)?r.delete(e):r.add(e),r})},b=[{value:"all",label:"All",icon:(0,s.jsx)(sn,{})},{value:"tool_call",label:"Tools",icon:(0,s.jsx)(sa,{})},{value:"decision",label:"Decisions",icon:(0,s.jsx)(so,{})},{value:"message",label:"Messages",icon:(0,s.jsx)(si,{})},{value:"state_change",label:"State",icon:(0,s.jsx)(sl,{})},{value:"phase_transition",label:"Phases",icon:(0,s.jsx)(sc,{})},{value:"error",label:"Errors",icon:(0,s.jsx)(sd,{})}],f=(0,n.useMemo)(()=>{let e=r.filter(e=>e.phase).reduce((e,t)=>(t.phase&&(e[t.phase]=(e[t.phase]||0)+1),e),{}),t=Object.values(e).reduce((e,t)=>e+t,0);return{phases:e,total:t}},[r]);return(0,s.jsxs)("div",{className:"h-full flex flex-col bg-gradient-to-b from-bg-card to-bg-tertiary rounded-xl border border-border/50 overflow-hidden shadow-lg backdrop-blur-sm",children:[(0,s.jsxs)("div",{className:"relative",children:[(0,s.jsx)("div",{className:"absolute top-0 left-0 right-0 h-[2px] bg-gradient-to-r from-blue-500 via-accent-cyan to-blue-500 opacity-60"}),(0,s.jsxs)("div",{className:"flex items-center justify-between px-5 py-4 border-b border-border/30",children:[(0,s.jsxs)("div",{className:"flex items-center gap-3",children:[o&&i&&(0,s.jsxs)("button",{onClick:()=>i(null),className:"flex items-center gap-1.5 px-2 py-1.5 text-[11px] font-medium text-text-muted hover:text-accent-cyan bg-bg-elevated/50 hover:bg-bg-elevated rounded-lg border border-border/30 hover:border-accent-cyan/30 transition-all duration-200",title:"Back to trajectory list",children:[(0,s.jsx)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:(0,s.jsx)("path",{d:"M19 12H5M12 19l-7-7 7-7",strokeLinecap:"round",strokeLinejoin:"round"})}),(0,s.jsx)("span",{children:"List"})]}),(0,s.jsxs)("div",{className:"relative",children:[(0,s.jsx)("div",{className:"w-9 h-9 rounded-lg bg-gradient-to-br from-blue-500/20 to-accent-cyan/20 flex items-center justify-center border border-blue-500/30",children:(0,s.jsx)(ss,{})}),r.some(e=>"running"===e.status)&&(0,s.jsx)("span",{className:"absolute -top-1 -right-1 w-3 h-3 bg-accent-cyan rounded-full animate-pulse shadow-[0_0_8px_rgba(0,217,255,0.6)]"})]}),(0,s.jsxs)("div",{className:"flex flex-col",children:[(0,s.jsx)("span",{className:"font-semibold text-sm text-text-primary tracking-wide",children:"Trajectory"}),(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsxs)("span",{className:"text-[11px] text-text-muted font-mono",children:[r.length," ",1===r.length?"step":"steps"]}),t&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("span",{className:"text-text-dim",children:"|"}),(0,s.jsx)("span",{className:"text-[11px] text-accent-cyan/80 font-medium truncate max-w-[120px]",children:t})]})]})]})]}),f.total>0&&!d&&(0,s.jsx)("div",{className:"flex items-center gap-1.5",children:["plan","design","execute","review","observe"].map(e=>{let t=f.phases[e]||0,r=sr(e);return t>0?(0,s.jsx)("div",{className:"h-1.5 rounded-full transition-all duration-300",style:{width:"".concat(Math.max(8,t/f.total*48),"px"),backgroundColor:r||"var(--color-border)"},title:"".concat(e,": ").concat(t)},e):null})})]}),!d&&(0,s.jsx)("div",{className:"flex items-center gap-1 px-4 py-2 bg-bg-elevated/50 border-b border-border/20 overflow-x-auto scrollbar-thin",children:b.map(e=>(0,s.jsxs)("button",{className:"flex items-center gap-1.5 px-3 py-1.5 text-[11px] font-medium rounded-lg transition-all duration-200 whitespace-nowrap ".concat(m===e.value?"bg-blue-500/20 text-blue-500 border border-blue-500/30 shadow-[0_0_12px_rgba(59,130,246,0.15)]":"text-text-muted hover:text-text-secondary hover:bg-bg-hover/50"),onClick:()=>h(e.value),children:[(0,s.jsx)("span",{className:"opacity-70",children:e.icon}),e.label]},e.value))})]}),(0,s.jsx)("div",{className:"flex-1 min-h-0 overflow-y-auto px-4 py-3 scrollbar-thin scrollbar-thumb-border scrollbar-track-transparent",children:l?(0,s.jsxs)("div",{className:"flex flex-col items-center justify-center gap-4 py-12 text-text-muted",children:[(0,s.jsxs)("div",{className:"relative",children:[(0,s.jsx)(sm,{}),(0,s.jsx)("div",{className:"absolute inset-0 bg-accent-cyan/10 rounded-full blur-xl"})]}),(0,s.jsx)("span",{className:"text-sm font-medium",children:"Loading trajectory..."})]}):0===p.length?(0,s.jsx)("div",{className:"flex flex-col gap-4 py-4 text-text-muted",children:0===r.length&&a.length>0?(0,s.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between px-2",children:[(0,s.jsx)("span",{className:"text-xs font-medium text-text-secondary uppercase tracking-wider",children:"Recent Trajectories"}),o&&i&&(0,s.jsx)("button",{onClick:()=>i(null),className:"text-[10px] text-accent-cyan hover:underline",children:"← Back to current"})]}),(0,s.jsx)("div",{className:"flex flex-col gap-1",children:a.slice(0,10).map(e=>(0,s.jsxs)("button",{onClick:()=>null==i?void 0:i(e.id),className:"w-full text-left px-3 py-2.5 rounded-lg transition-all duration-200 border ".concat(o===e.id?"bg-blue-500/15 border-blue-500/40 text-text-primary":"bg-bg-tertiary/50 border-transparent hover:bg-bg-elevated/60 hover:border-border/40"),children:[(0,s.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,s.jsx)("span",{className:"text-[13px] font-medium text-text-primary truncate flex-1",children:e.title}),(0,s.jsx)("span",{className:"text-[10px] px-1.5 py-0.5 rounded font-medium flex-shrink-0 ".concat("completed"===e.status?"bg-green-500/15 text-green-500":"active"===e.status?"bg-blue-500/15 text-blue-500":"bg-amber-500/15 text-amber-500"),children:e.status})]}),(0,s.jsxs)("div",{className:"flex items-center gap-2 mt-1",children:[(0,s.jsx)("span",{className:"text-[10px] text-text-dim",children:function(e){let t=new Date(e),r=new Date().getTime()-t.getTime(),s=Math.floor(r/6e4),n=Math.floor(r/36e5),a=Math.floor(r/864e5);return s<1?"just now":s<60?"".concat(s,"m ago"):n<24?"".concat(n,"h ago"):a<7?"".concat(a,"d ago"):t.toLocaleDateString()}(e.startedAt)}),e.confidence&&(0,s.jsxs)("span",{className:"text-[10px] text-text-dim",children:["• ",Math.round(100*e.confidence),"% confidence"]})]}),e.summary&&(0,s.jsx)("p",{className:"text-[11px] text-text-muted mt-1 line-clamp-2",children:e.summary})]},e.id))})]}):0===r.length?(0,s.jsxs)("div",{className:"flex flex-col items-center justify-center gap-4 py-8",children:[(0,s.jsx)("div",{className:"w-16 h-16 rounded-2xl bg-bg-elevated/50 flex items-center justify-center border border-border/30",children:(0,s.jsx)(su,{})}),(0,s.jsxs)("div",{className:"text-center",children:[(0,s.jsx)("p",{className:"text-sm font-medium text-text-secondary",children:"No steps recorded"}),(0,s.jsx)("p",{className:"text-xs text-text-dim mt-1",children:"Steps will appear here as the agent works"})]})]}):(0,s.jsxs)("div",{className:"flex flex-col items-center justify-center gap-4 py-8",children:[(0,s.jsx)("div",{className:"w-16 h-16 rounded-2xl bg-bg-elevated/50 flex items-center justify-center border border-border/30",children:(0,s.jsx)(su,{})}),(0,s.jsxs)("div",{className:"text-center",children:[(0,s.jsx)("p",{className:"text-sm font-medium text-text-secondary",children:"No matching steps"}),(0,s.jsx)("p",{className:"text-xs text-text-dim mt-1",children:'Try a different filter or select "All"'})]})]})}):(0,s.jsx)("div",{className:"flex flex-col gap-0.5",children:p.map((e,t)=>(0,s.jsx)(st,{step:e,isExpanded:x.has(e.id),isLast:t===p.length-1,isFirst:0===t,compact:d,onToggle:()=>g(e.id),onClick:c?()=>c(e):void 0},e.id))})})]})}function st(e){var t;let{step:r,isExpanded:n,isLast:a,isFirst:o=!1,compact:i=!1,onToggle:l,onClick:c}=e,d=new Date(r.timestamp).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"}),x=function(e){switch(e){case"tool_call":return(0,s.jsx)(sa,{});case"decision":return(0,s.jsx)(so,{});case"message":return(0,s.jsx)(si,{});case"state_change":return(0,s.jsx)(sl,{});case"phase_transition":return(0,s.jsx)(sc,{});case"error":return(0,s.jsx)(sd,{});default:return null}}(r.type),u=function(e){switch(e){case"running":return"#ff6b35";case"success":return"#00ffc8";case"error":return"#ff4757";default:return null}}(r.status),m=sr(r.phase),h=function(e){switch(e){case"tool_call":return"#00d9ff";case"decision":case"message":return"#3b82f6";case"state_change":return"#10b981";case"phase_transition":return"#f59e0b";case"error":return"#ef4444";default:return"#6b7280"}}(r.type),p=r.metadata&&Object.keys(r.metadata).length>0,g=!!r.description||p||!!c;return(0,s.jsxs)("div",{className:"flex gap-3 group",children:[(0,s.jsxs)("div",{className:"flex flex-col items-center w-7 relative",children:[!o&&(0,s.jsx)("div",{className:"absolute top-0 w-px h-2 transition-colors",style:{backgroundColor:m?"".concat(m,"40"):"var(--color-border)"}}),(0,s.jsx)("div",{className:"w-7 h-7 rounded-lg flex items-center justify-center flex-shrink-0 z-10 mt-2 transition-all duration-200 ".concat("running"===r.status?"animate-pulse shadow-[0_0_12px_rgba(0,217,255,0.4)]":"group-hover:scale-110"),style:{background:u?"linear-gradient(135deg, ".concat(u,"40, ").concat(u,"20)"):m?"linear-gradient(135deg, ".concat(m,"30, ").concat(m,"10)"):"linear-gradient(135deg, ".concat(h,"30, ").concat(h,"10)"),borderWidth:"1px",borderStyle:"solid",borderColor:u||m||h||"var(--color-border)",color:u||m||h||"var(--color-text-secondary)"},children:x}),!a&&(0,s.jsx)("div",{className:"w-px flex-1 mt-1 transition-colors",style:{background:"linear-gradient(to bottom, ".concat(m||h||"var(--color-border)","40, transparent)")}})]}),(0,s.jsxs)("div",{className:"flex-1 min-w-0 pt-1 ".concat(a?"pb-1":"pb-3"),children:[(0,s.jsxs)("button",{className:"w-full flex items-center justify-between gap-3 px-3 py-2.5 rounded-lg transition-all duration-200 text-left border ".concat(n?"bg-bg-elevated/80 border-border/60 shadow-sm":"bg-bg-tertiary/50 border-transparent hover:bg-bg-elevated/60 hover:border-border/40"),onClick:l,children:[(0,s.jsxs)("div",{className:"flex items-center gap-2 min-w-0 flex-1",children:[(0,s.jsx)("span",{className:"text-[13px] font-medium text-text-primary truncate",children:r.title}),(0,s.jsx)("span",{className:"text-[10px] px-1.5 py-0.5 rounded font-medium flex-shrink-0",style:{backgroundColor:"".concat(h,"15"),color:h},children:{tool_call:"Tool",decision:"Decision",message:"Message",state_change:"State",phase_transition:"Phase",error:"Error"}[r.type]}),r.phase&&m&&(0,s.jsx)("span",{className:"text-[10px] px-1.5 py-0.5 rounded font-medium flex-shrink-0",style:{backgroundColor:"".concat(m,"15"),color:m},children:r.phase})]}),(0,s.jsxs)("div",{className:"flex items-center gap-2 flex-shrink-0",children:[void 0!==r.duration&&(0,s.jsx)("span",{className:"text-[10px] font-mono text-text-muted px-1.5 py-0.5 bg-bg-elevated/50 rounded",children:(t=r.duration)<1e3?"".concat(t,"ms"):t<6e4?"".concat((t/1e3).toFixed(1),"s"):"".concat((t/6e4).toFixed(1),"m")}),(0,s.jsx)("span",{className:"text-[10px] text-text-dim",children:d}),!i&&(0,s.jsx)(sx,{isExpanded:n})]})]}),n&&!i&&g&&(0,s.jsxs)("div",{className:"mt-2 ml-1 pl-3 border-l-2 border-border/30",children:[r.description&&(0,s.jsx)("p",{className:"text-[13px] text-text-secondary mb-3 leading-relaxed",children:r.description}),p&&(0,s.jsx)("div",{className:"bg-bg-elevated/50 rounded-lg p-3 mb-3 overflow-x-auto border border-border/20",children:(0,s.jsx)("pre",{className:"text-[11px] font-mono text-text-muted whitespace-pre-wrap break-words leading-relaxed",children:JSON.stringify(r.metadata,null,2)})}),c&&(0,s.jsxs)("button",{className:"inline-flex items-center gap-1.5 px-3 py-1.5 text-[11px] font-medium text-accent-cyan bg-accent-cyan/10 border border-accent-cyan/20 rounded-md hover:bg-accent-cyan/20 hover:border-accent-cyan/30 transition-colors",onClick:e=>{e.stopPropagation(),c()},children:[(0,s.jsxs)("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:[(0,s.jsx)("path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"}),(0,s.jsx)("polyline",{points:"15 3 21 3 21 9"}),(0,s.jsx)("line",{x1:"10",y1:"14",x2:"21",y2:"3"})]}),"View Details"]})]})]})]})}function sr(e){switch(e){case"plan":return"#3b82f6";case"design":return"#00d9ff";case"execute":return"#ff6b35";case"review":return"#00ffc8";case"observe":return"#fbbf24";default:return null}}function ss(){return(0,s.jsx)("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",className:"text-blue-500",children:(0,s.jsx)("path",{d:"M3 12h4l3 9 4-18 3 9h4",strokeLinecap:"round",strokeLinejoin:"round"})})}function sn(){return(0,s.jsxs)("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:[(0,s.jsx)("circle",{cx:"12",cy:"12",r:"3"}),(0,s.jsx)("path",{d:"M12 2v4m0 12v4m-7.07-14.93l2.83 2.83m8.48 8.48l2.83 2.83M2 12h4m12 0h4M4.93 19.07l2.83-2.83m8.48-8.48l2.83-2.83"})]})}function sa(){return(0,s.jsx)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:(0,s.jsx)("path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.77-3.77a6 6 0 0 1-7.94 7.94l-6.91 6.91a2.12 2.12 0 0 1-3-3l6.91-6.91a6 6 0 0 1 7.94-7.94l-3.76 3.76z"})})}function so(){return(0,s.jsx)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:(0,s.jsx)("path",{d:"M12 2l2.4 7.4H22l-6 4.6 2.3 7-6.3-4.6L5.7 21l2.3-7-6-4.6h7.6z"})})}function si(){return(0,s.jsx)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:(0,s.jsx)("path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})})}function sl(){return(0,s.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,s.jsx)("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",ry:"2"}),(0,s.jsx)("path",{d:"M9 12h6m-3-3v6"})]})}function sc(){return(0,s.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,s.jsx)("circle",{cx:"12",cy:"12",r:"10"}),(0,s.jsx)("path",{d:"M12 6v6l4 2"})]})}function sd(){return(0,s.jsxs)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,s.jsx)("circle",{cx:"12",cy:"12",r:"10"}),(0,s.jsx)("line",{x1:"12",y1:"8",x2:"12",y2:"12"}),(0,s.jsx)("circle",{cx:"12",cy:"16",r:"0.5",fill:"currentColor"})]})}function sx(e){let{isExpanded:t}=e;return(0,s.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:"text-text-muted transition-transform duration-200 ".concat(t?"rotate-180":""),children:(0,s.jsx)("polyline",{points:"6 9 12 15 18 9"})})}function su(){return(0,s.jsxs)("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",className:"text-text-dim",children:[(0,s.jsx)("circle",{cx:"12",cy:"12",r:"10"}),(0,s.jsx)("line",{x1:"8",y1:"12",x2:"16",y2:"12"})]})}function sm(){return(0,s.jsx)("svg",{className:"animate-spin",width:"20",height:"20",viewBox:"0 0 24 24",children:(0,s.jsx)("circle",{cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"2",fill:"none",strokeDasharray:"32",strokeLinecap:"round",className:"text-accent"})})}function sh(e){let{decisions:t,onApprove:r,onReject:a,onDismiss:o,isProcessing:i={}}=e,[l,c]=(0,n.useState)(null),[d,x]=(0,n.useState)({}),u=(0,n.useMemo)(()=>{let e={critical:0,high:1,medium:2,low:3};return[...t].sort((t,r)=>{let s=e[t.priority]-e[r.priority];return 0!==s?s:new Date(t.timestamp).getTime()-new Date(r.timestamp).getTime()})},[t]),m=(0,n.useMemo)(()=>t.reduce((e,t)=>(e[t.priority]=(e[t.priority]||0)+1,e),{}),[t]),h=async(e,t)=>{await (null==r?void 0:r(e.id,t))},p=async e=>{await (null==a?void 0:a(e.id,d[e.id])),x(t=>{let r={...t};return delete r[e.id],r})};return 0===t.length?(0,s.jsxs)("div",{className:"decision-queue decision-queue-empty",children:[(0,s.jsx)(sf,{}),(0,s.jsx)("span",{children:"No pending decisions"})]}):(0,s.jsxs)("div",{className:"decision-queue",children:[(0,s.jsxs)("div",{className:"decision-queue-header",children:[(0,s.jsxs)("div",{className:"decision-queue-title",children:[(0,s.jsx)(sb,{}),(0,s.jsx)("span",{children:"Pending Decisions"}),(0,s.jsx)("span",{className:"decision-queue-count",children:t.length})]}),(0,s.jsxs)("div",{className:"decision-queue-summary",children:[m.critical&&(0,s.jsxs)("span",{className:"decision-priority-badge critical",children:[m.critical," critical"]}),m.high&&(0,s.jsxs)("span",{className:"decision-priority-badge high",children:[m.high," high"]})]})]}),(0,s.jsx)("div",{className:"decision-queue-list",children:u.map(e=>(0,s.jsx)(sp,{decision:e,isExpanded:l===e.id,isProcessing:i[e.id]||!1,rejectReason:d[e.id]||"",onToggle:()=>c(t=>t===e.id?null:e.id),onApprove:t=>h(e,t),onReject:()=>p(e),onRejectReasonChange:t=>x(r=>({...r,[e.id]:t})),onDismiss:()=>null==o?void 0:o(e.id)},e.id))})]})}function sp(e){let{decision:t,isExpanded:r,isProcessing:n,rejectReason:o,onToggle:i,onApprove:l,onReject:c,onRejectReasonChange:d,onDismiss:x}=e,u=(0,a.GW)(t.agentName),m=function(e){let t=new Date(e),r=Math.floor((new Date().getTime()-t.getTime())/6e4);return r<1?"just now":r<60?"".concat(r,"m ago"):r<1440?"".concat(Math.floor(r/60),"h ago"):t.toLocaleDateString()}(t.timestamp),h=t.expiresAt?function(e){let t=new Date(e),r=new Date,s=t.getTime()-r.getTime();if(s<=0)return{text:"Expired",urgent:!0};let n=Math.floor(s/6e4);return n<5?{text:"".concat(n,"m left"),urgent:!0}:n<60?{text:"".concat(n,"m left"),urgent:!1}:{text:"".concat(Math.floor(n/60),"h left"),urgent:!1}}(t.expiresAt):null;return(0,s.jsxs)("div",{className:"decision-card ".concat(t.priority),children:[(0,s.jsxs)("div",{className:"decision-card-header",onClick:i,children:[(0,s.jsx)("div",{className:"decision-card-avatar",style:{backgroundColor:u.primary,color:u.text},children:(0,a.hP)(t.agentName)}),(0,s.jsxs)("div",{className:"decision-card-info",children:[(0,s.jsxs)("div",{className:"decision-card-title",children:[(0,s.jsx)("span",{className:"decision-card-agent",children:t.agentName}),(0,s.jsx)("span",{className:"decision-card-type",children:{approval:"Approval",choice:"Choice",confirmation:"Confirm",input:"Input"}[t.type]}),(0,s.jsx)(sg,{priority:t.priority})]}),(0,s.jsx)("div",{className:"decision-card-subtitle",children:t.title})]}),(0,s.jsxs)("div",{className:"decision-card-meta",children:[h&&(0,s.jsx)("span",{className:"decision-card-expires ".concat(h.urgent?"urgent":""),children:h.text}),(0,s.jsx)("span",{className:"decision-card-time",children:m}),(0,s.jsx)(sy,{isExpanded:r})]})]}),r&&(0,s.jsxs)("div",{className:"decision-card-body",children:[(0,s.jsx)("p",{className:"decision-card-desc",children:t.description}),t.context&&Object.keys(t.context).length>0&&(0,s.jsxs)("div",{className:"decision-card-context",children:[(0,s.jsx)("span",{className:"decision-card-context-label",children:"Context"}),(0,s.jsx)("pre",{children:JSON.stringify(t.context,null,2)})]}),"choice"===t.type&&t.options&&(0,s.jsx)("div",{className:"decision-card-options",children:t.options.map(e=>(0,s.jsxs)("button",{className:"decision-card-option",onClick:()=>l(e.id),disabled:n,children:[(0,s.jsx)("span",{className:"decision-option-label",children:e.label}),e.description&&(0,s.jsx)("span",{className:"decision-option-desc",children:e.description})]},e.id))}),"choice"!==t.type&&(0,s.jsxs)("div",{className:"decision-card-actions",children:[(0,s.jsxs)("button",{className:"decision-btn decision-btn-approve",onClick:()=>l(),disabled:n,children:[n?(0,s.jsx)(sv,{}):(0,s.jsx)(sf,{}),"confirmation"===t.type?"Confirm":"Approve"]}),(0,s.jsxs)("div",{className:"decision-reject-group",children:[(0,s.jsx)("input",{type:"text",className:"decision-reject-input",placeholder:"Reason (optional)",value:o,onChange:e=>d(e.target.value),disabled:n}),(0,s.jsxs)("button",{className:"decision-btn decision-btn-reject",onClick:c,disabled:n,children:[(0,s.jsx)(sj,{}),"Reject"]})]})]}),(0,s.jsx)("button",{className:"decision-card-dismiss",onClick:x,disabled:n,children:"Dismiss without action"})]})]})}function sg(e){let{priority:t}=e;return(0,s.jsx)("span",{className:"decision-priority-badge ".concat(t),children:t})}function sb(){return(0,s.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,s.jsx)("circle",{cx:"12",cy:"12",r:"10"}),(0,s.jsx)("line",{x1:"12",y1:"8",x2:"12",y2:"12"}),(0,s.jsx)("line",{x1:"12",y1:"16",x2:"12.01",y2:"16"})]})}function sf(){return(0,s.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:(0,s.jsx)("polyline",{points:"20 6 9 17 4 12"})})}function sj(){return(0,s.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,s.jsx)("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),(0,s.jsx)("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})}function sy(e){let{isExpanded:t}=e;return(0,s.jsx)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",style:{transform:t?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.2s"},children:(0,s.jsx)("polyline",{points:"6 9 12 15 18 9"})})}function sv(){return(0,s.jsx)("svg",{className:"decision-spinner",width:"14",height:"14",viewBox:"0 0 24 24",children:(0,s.jsx)("circle",{cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"2",fill:"none",strokeDasharray:"32",strokeLinecap:"round"})})}function sw(e){var t;let{server:r,isSelected:n=!1,onClick:a,onReconnect:o,compact:i=!1}=e,l=function(e){switch(e){case"online":return"#10b981";case"offline":return"#ef4444";case"degraded":return"#f59e0b";case"connecting":return"#6366f1";default:return"#888888"}}(r.status),c=function(e){switch(e){case"online":return"Online";case"offline":return"Offline";case"degraded":return"Degraded";case"connecting":return"Connecting...";default:return"Unknown"}}(r.status);return i?(0,s.jsxs)("button",{className:"\n flex items-center gap-2 py-2 px-3 bg-bg-tertiary border border-border-subtle rounded-md cursor-pointer font-inherit transition-all duration-150\n hover:bg-bg-hover\n ".concat(n?"bg-bg-elevated border-accent-cyan":"","\n ").concat("offline"===r.status?"opacity-70":"","\n "),onClick:a,children:[(0,s.jsx)("div",{className:"w-2 h-2 rounded-full flex-shrink-0",style:{backgroundColor:l}}),(0,s.jsx)("span",{className:"flex-1 text-sm font-medium text-text-primary text-left",children:r.name}),(0,s.jsx)("span",{className:"text-xs text-text-muted bg-bg-tertiary px-1.5 py-0.5 rounded-full",children:r.agentCount})]}):(0,s.jsxs)("div",{className:"\n bg-bg-card border border-border-subtle rounded-lg p-4 cursor-pointer transition-all duration-150\n hover:border-border-hover hover:shadow-md\n ".concat(n?"border-accent-cyan bg-bg-elevated":"","\n ").concat("offline"===r.status?"opacity-70":"","\n ").concat("degraded"===r.status?"border-l-[3px] border-l-warning":"","\n "),onClick:a,role:a?"button":void 0,tabIndex:a?0:void 0,children:[(0,s.jsxs)("div",{className:"flex items-start justify-between mb-4",children:[(0,s.jsxs)("div",{className:"flex items-center gap-3",children:[(0,s.jsx)(sN,{}),(0,s.jsxs)("div",{className:"flex flex-col",children:[(0,s.jsx)("span",{className:"font-semibold text-sm text-text-primary",children:r.name}),r.region&&(0,s.jsx)("span",{className:"text-xs text-text-muted",children:r.region})]})]}),(0,s.jsxs)("div",{className:"flex items-center gap-1.5 text-xs font-medium",style:{color:l},children:[(0,s.jsx)("span",{className:"w-2 h-2 rounded-full flex-shrink-0 ".concat("connecting"===r.status?"animate-pulse":""),style:{backgroundColor:l}}),(0,s.jsx)("span",{children:c})]})]}),(0,s.jsxs)("div",{className:"grid grid-cols-[repeat(auto-fit,minmax(60px,1fr))] gap-3 mb-4",children:[(0,s.jsxs)("div",{className:"flex flex-col items-center text-center",children:[(0,s.jsx)("span",{className:"text-lg font-semibold text-text-primary",children:r.agentCount}),(0,s.jsx)("span",{className:"text-[11px] text-text-muted uppercase tracking-wide",children:"Agents"})]}),void 0!==r.messageRate&&(0,s.jsxs)("div",{className:"flex flex-col items-center text-center",children:[(0,s.jsxs)("span",{className:"text-lg font-semibold text-text-primary",children:[r.messageRate,"/s"]}),(0,s.jsx)("span",{className:"text-[11px] text-text-muted uppercase tracking-wide",children:"Messages"})]}),void 0!==r.latency&&(0,s.jsxs)("div",{className:"flex flex-col items-center text-center",children:[(0,s.jsxs)("span",{className:"text-lg font-semibold text-text-primary",children:[r.latency,"ms"]}),(0,s.jsx)("span",{className:"text-[11px] text-text-muted uppercase tracking-wide",children:"Latency"})]}),void 0!==r.uptime&&(0,s.jsxs)("div",{className:"flex flex-col items-center text-center",children:[(0,s.jsx)("span",{className:"text-lg font-semibold text-text-primary",children:(t=r.uptime)<60?"".concat(t,"s"):t<3600?"".concat(Math.floor(t/60),"m"):t<86400?"".concat(Math.floor(t/3600),"h"):"".concat(Math.floor(t/86400),"d")}),(0,s.jsx)("span",{className:"text-[11px] text-text-muted uppercase tracking-wide",children:"Uptime"})]})]}),(0,s.jsxs)("div",{className:"flex items-center justify-between pt-3 border-t border-border-subtle",children:[(0,s.jsx)("span",{className:"text-[11px] text-text-muted font-mono",children:r.url}),r.version&&(0,s.jsxs)("span",{className:"text-[11px] text-text-muted bg-bg-tertiary px-1.5 py-0.5 rounded",children:["v",r.version]})]}),"offline"===r.status&&o&&(0,s.jsxs)("button",{className:"flex items-center justify-center gap-1.5 w-full mt-3 py-2 px-3 bg-error/10 border border-error/30 rounded-md text-error text-xs font-medium cursor-pointer font-inherit transition-all duration-150 hover:bg-error/20 hover:border-error/50",onClick:e=>{e.stopPropagation(),o()},children:[(0,s.jsx)(sk,{}),"Reconnect"]})]})}function sN(){return(0,s.jsxs)("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,s.jsx)("rect",{x:"2",y:"2",width:"20",height:"8",rx:"2",ry:"2"}),(0,s.jsx)("rect",{x:"2",y:"14",width:"20",height:"8",rx:"2",ry:"2"}),(0,s.jsx)("line",{x1:"6",y1:"6",x2:"6.01",y2:"6"}),(0,s.jsx)("line",{x1:"6",y1:"18",x2:"6.01",y2:"18"})]})}function sk(){return(0,s.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,s.jsx)("polyline",{points:"23 4 23 10 17 10"}),(0,s.jsx)("polyline",{points:"1 20 1 14 7 14"}),(0,s.jsx)("path",{d:"M3.51 9a9 9 0 0 1 14.85-3.36L23 10M1 14l4.64 4.36A9 9 0 0 0 20.49 15"})]})}function sC(e){let{servers:t,agents:r,selectedServerId:o,onServerSelect:i,onServerReconnect:l,isLoading:c=!1}=e,[d,x]=(0,n.useState)("grid"),u=(0,n.useMemo)(()=>{let e=t.filter(e=>"online"===e.status).length,r=t.reduce((e,t)=>e+t.agentCount,0),s=t.filter(e=>void 0!==e.latency).length>0?Math.round(t.reduce((e,t)=>e+(t.latency||0),0)/t.filter(e=>void 0!==e.latency).length):null,n=t.reduce((e,t)=>e+(t.messageRate||0),0);return{online:e,total:t.length,totalAgents:r,avgLatency:s,totalMessages:n}},[t]),m=(0,n.useMemo)(()=>{let e={};return t.forEach(t=>{e[t.id]=[]}),r.forEach((r,s)=>{let n=s%t.length;t[n]&&e[t[n].id].push(r)}),e},[t,r]);return c?(0,s.jsxs)("div",{className:"bg-bg-card rounded-lg border border-border-subtle overflow-hidden flex flex-col items-center justify-center p-12 text-text-muted text-center",children:[(0,s.jsx)(sW,{}),(0,s.jsx)("span",{className:"mt-3 text-sm",children:"Loading fleet data..."})]}):0===t.length?(0,s.jsxs)("div",{className:"bg-bg-card rounded-lg border border-border-subtle overflow-hidden flex flex-col items-center justify-center p-12 text-text-muted text-center",children:[(0,s.jsx)(sE,{}),(0,s.jsx)("h3",{className:"mt-4 mb-2 text-base font-semibold text-text-primary",children:"No Fleet Servers"}),(0,s.jsx)("p",{className:"text-sm",children:"Connect to peer servers to enable fleet view"})]}):(0,s.jsxs)("div",{className:"bg-bg-card rounded-lg border border-border-subtle overflow-hidden",children:[(0,s.jsxs)("div",{className:"flex items-center gap-6 p-4 border-b border-border-subtle bg-bg-secondary",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2 font-semibold text-sm text-text-primary",children:[(0,s.jsx)(sS,{}),(0,s.jsx)("span",{children:"Fleet Overview"})]}),(0,s.jsxs)("div",{className:"flex gap-6 flex-1",children:[(0,s.jsxs)("div",{className:"flex flex-col items-center",children:[(0,s.jsxs)("span",{className:"text-base font-semibold text-text-primary",children:[u.online,"/",u.total]}),(0,s.jsx)("span",{className:"text-xs text-text-muted uppercase tracking-wide",children:"Servers"})]}),(0,s.jsxs)("div",{className:"flex flex-col items-center",children:[(0,s.jsx)("span",{className:"text-base font-semibold text-text-primary",children:u.totalAgents}),(0,s.jsx)("span",{className:"text-xs text-text-muted uppercase tracking-wide",children:"Agents"})]}),null!==u.avgLatency&&(0,s.jsxs)("div",{className:"flex flex-col items-center",children:[(0,s.jsxs)("span",{className:"text-base font-semibold text-text-primary",children:[u.avgLatency,"ms"]}),(0,s.jsx)("span",{className:"text-xs text-text-muted uppercase tracking-wide",children:"Avg Latency"})]}),(0,s.jsxs)("div",{className:"flex flex-col items-center",children:[(0,s.jsxs)("span",{className:"text-base font-semibold text-text-primary",children:[u.totalMessages,"/s"]}),(0,s.jsx)("span",{className:"text-xs text-text-muted uppercase tracking-wide",children:"Messages"})]})]}),(0,s.jsxs)("div",{className:"flex gap-1 bg-bg-tertiary rounded-md p-0.5",children:[(0,s.jsx)("button",{className:"flex items-center justify-center w-7 h-7 bg-transparent border-none rounded cursor-pointer transition-all duration-150 ".concat("grid"===d?"bg-bg-card text-text-primary shadow-sm":"text-text-muted hover:text-text-secondary"),onClick:()=>x("grid"),title:"Grid view",children:(0,s.jsx)(sA,{})}),(0,s.jsx)("button",{className:"flex items-center justify-center w-7 h-7 bg-transparent border-none rounded cursor-pointer transition-all duration-150 ".concat("list"===d?"bg-bg-card text-text-primary shadow-sm":"text-text-muted hover:text-text-secondary"),onClick:()=>x("list"),title:"List view",children:(0,s.jsx)(sL,{})})]})]}),(0,s.jsx)("div",{className:"flex h-1 bg-bg-tertiary",children:t.map(e=>(0,s.jsx)("div",{className:"transition-all duration-300 ".concat({online:"bg-success",offline:"bg-error",degraded:"bg-warning",connecting:"bg-accent-purple"}[e.status]||"bg-text-dim"),style:{flex:e.agentCount||1},title:"".concat(e.name,": ").concat(e.agentCount," agents")},e.id))}),(0,s.jsx)("div",{className:"p-4 ".concat("grid"===d?"grid grid-cols-[repeat(auto-fill,minmax(280px,1fr))] gap-4":"flex flex-col gap-2"),children:t.map(e=>{var t;return(0,s.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,s.jsx)(sw,{server:e,isSelected:e.id===o,onClick:()=>null==i?void 0:i(e.id),onReconnect:()=>null==l?void 0:l(e.id),compact:"list"===d}),"grid"===d&&(null===(t=m[e.id])||void 0===t?void 0:t.length)>0&&(0,s.jsxs)("div",{className:"flex gap-1 px-2",children:[m[e.id].slice(0,5).map((e,t)=>{let r=(0,a.GW)(e.name);return(0,s.jsx)("div",{className:"w-6 h-6 rounded-md flex items-center justify-center text-[9px] font-semibold border-2 border-bg-card",style:{backgroundColor:r.primary,color:r.text,marginLeft:t>0?"-4px":0},title:e.name,children:(0,a.hP)(e.name)},e.name)}),m[e.id].length>5&&(0,s.jsxs)("div",{className:"w-6 h-6 rounded-md flex items-center justify-center text-[9px] font-semibold bg-bg-tertiary text-text-muted border-2 border-bg-card",style:{marginLeft:"-4px"},children:["+",m[e.id].length-5]})]})]},e.id)})})]})}function sS(){return(0,s.jsxs)("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,s.jsx)("rect",{x:"2",y:"3",width:"20",height:"14",rx:"2",ry:"2"}),(0,s.jsx)("line",{x1:"8",y1:"21",x2:"16",y2:"21"}),(0,s.jsx)("line",{x1:"12",y1:"17",x2:"12",y2:"21"})]})}function sA(){return(0,s.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,s.jsx)("rect",{x:"3",y:"3",width:"7",height:"7"}),(0,s.jsx)("rect",{x:"14",y:"3",width:"7",height:"7"}),(0,s.jsx)("rect",{x:"3",y:"14",width:"7",height:"7"}),(0,s.jsx)("rect",{x:"14",y:"14",width:"7",height:"7"})]})}function sL(){return(0,s.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,s.jsx)("line",{x1:"8",y1:"6",x2:"21",y2:"6"}),(0,s.jsx)("line",{x1:"8",y1:"12",x2:"21",y2:"12"}),(0,s.jsx)("line",{x1:"8",y1:"18",x2:"21",y2:"18"}),(0,s.jsx)("line",{x1:"3",y1:"6",x2:"3.01",y2:"6"}),(0,s.jsx)("line",{x1:"3",y1:"12",x2:"3.01",y2:"12"}),(0,s.jsx)("line",{x1:"3",y1:"18",x2:"3.01",y2:"18"})]})}function sE(){return(0,s.jsxs)("svg",{width:"48",height:"48",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[(0,s.jsx)("rect",{x:"2",y:"2",width:"20",height:"8",rx:"2",ry:"2"}),(0,s.jsx)("rect",{x:"2",y:"14",width:"20",height:"8",rx:"2",ry:"2"}),(0,s.jsx)("line",{x1:"6",y1:"6",x2:"6.01",y2:"6"}),(0,s.jsx)("line",{x1:"6",y1:"18",x2:"6.01",y2:"18"})]})}function sW(){return(0,s.jsx)("svg",{className:"animate-spin",width:"24",height:"24",viewBox:"0 0 24 24",children:(0,s.jsx)("circle",{cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"2",fill:"none",strokeDasharray:"32",strokeLinecap:"round"})})}function sD(e){let{typingUsers:t}=e;return 0===t.length?null:(0,s.jsxs)("div",{className:"flex items-center gap-2 px-4 py-2 text-sm text-[#8d8d8e]",children:[(0,s.jsx)("div",{className:"flex -space-x-1.5",children:t.slice(0,3).map(e=>(0,s.jsx)("div",{className:"relative",title:e.username,children:e.avatarUrl?(0,s.jsx)("img",{src:e.avatarUrl,alt:e.username,className:"w-5 h-5 rounded-full border border-[#1a1d21]"}):(0,s.jsx)("div",{className:"w-5 h-5 rounded-full bg-[#a855f7] border border-[#1a1d21] flex items-center justify-center text-[9px] text-white font-medium",children:e.username.charAt(0).toUpperCase()})},e.username))}),(0,s.jsxs)("span",{className:"flex items-center gap-1",children:[1===t.length?"".concat(t[0].username," is typing"):2===t.length?"".concat(t[0].username," and ").concat(t[1].username," are typing"):"".concat(t[0].username," and ").concat(t.length-1," others are typing"),(0,s.jsxs)("span",{className:"flex gap-0.5",children:[(0,s.jsx)("span",{className:"w-1 h-1 bg-[#8d8d8e] rounded-full animate-bounce",style:{animationDelay:"0ms"}}),(0,s.jsx)("span",{className:"w-1 h-1 bg-[#8d8d8e] rounded-full animate-bounce",style:{animationDelay:"150ms"}}),(0,s.jsx)("span",{className:"w-1 h-1 bg-[#8d8d8e] rounded-full animate-bounce",style:{animationDelay:"300ms"}})]})]})]})}function sM(e){let{onlineUsers:t,onUserClick:r,maxAvatars:a=4}=e,[o,i]=(0,n.useState)(!1),l=(0,n.useRef)(null);if((0,n.useEffect)(()=>{let e=e=>{l.current&&!l.current.contains(e.target)&&i(!1)};return o&&document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[o]),0===t.length)return null;let c=t.slice(0,a),d=Math.max(0,t.length-a);return(0,s.jsxs)("div",{className:"relative",ref:l,children:[(0,s.jsxs)("button",{onClick:()=>i(!o),className:"flex items-center gap-1.5 px-2 py-1 rounded-md hover:bg-white/[0.05] transition-colors",title:"".concat(t.length," user").concat(1!==t.length?"s":""," online"),children:[(0,s.jsx)("div",{className:"w-2 h-2 bg-green-500 rounded-full"}),(0,s.jsxs)("div",{className:"flex -space-x-1.5",children:[c.map(e=>(0,s.jsx)("div",{className:"relative ring-2 ring-[#1a1d21] rounded-full",title:e.username,children:e.avatarUrl?(0,s.jsx)("img",{src:e.avatarUrl,alt:e.username,className:"w-6 h-6 rounded-full object-cover"}):(0,s.jsx)("div",{className:"w-6 h-6 rounded-full bg-[#a855f7] flex items-center justify-center text-[10px] text-white font-medium",children:e.username.charAt(0).toUpperCase()})},e.username)),d>0&&(0,s.jsxs)("div",{className:"w-6 h-6 rounded-full bg-[#3d4043] ring-2 ring-[#1a1d21] flex items-center justify-center text-[10px] text-[#d1d2d3] font-medium",children:["+",d]})]}),(0,s.jsxs)("span",{className:"text-xs text-[#8d8d8e]",children:[t.length," online"]})]}),o&&(0,s.jsxs)("div",{className:"absolute right-0 top-full mt-1 w-64 bg-[#1a1d21] border border-white/10 rounded-lg shadow-xl z-50 max-h-[300px] overflow-y-auto",children:[(0,s.jsx)("div",{className:"p-2 border-b border-white/10",children:(0,s.jsx)("h3",{className:"text-sm font-medium text-[#d1d2d3]",children:"Online Users"})}),(0,s.jsx)("div",{className:"py-1",children:t.map(e=>(0,s.jsxs)("button",{onClick:()=>{null==r||r(e),i(!1)},className:"w-full flex items-center gap-3 px-3 py-2 hover:bg-white/[0.05] transition-colors text-left",children:[(0,s.jsxs)("div",{className:"relative",children:[e.avatarUrl?(0,s.jsx)("img",{src:e.avatarUrl,alt:e.username,className:"w-8 h-8 rounded-full object-cover"}):(0,s.jsx)("div",{className:"w-8 h-8 rounded-full bg-[#a855f7] flex items-center justify-center text-xs text-white font-medium",children:e.username.charAt(0).toUpperCase()}),(0,s.jsx)("div",{className:"absolute -bottom-0.5 -right-0.5 w-3 h-3 bg-green-500 rounded-full border-2 border-[#1a1d21]"})]}),(0,s.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,s.jsx)("div",{className:"text-sm font-medium text-[#d1d2d3] truncate",children:e.username}),(0,s.jsxs)("div",{className:"text-xs text-[#8d8d8e]",children:["Online since ",function(e){let t=new Date(e),r=new Date;return t.toDateString()===r.toDateString()?t.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):t.toLocaleDateString([],{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}(e.connectedAt)]})]})]},e.username))})]})]})}function sT(e){let{user:t,onClose:r,onMention:a}=e,o=(0,n.useRef)(null);(0,n.useEffect)(()=>{let e=e=>{"Escape"===e.key&&r()};return t&&window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[t,r]);let i=(0,n.useRef)(!1);if((0,n.useEffect)(()=>{t&&(i.current=!0)},[t]),(0,n.useEffect)(()=>{let e=e=>{if(i.current){i.current=!1;return}o.current&&!o.current.contains(e.target)&&r()};if(t)return document.addEventListener("mousedown",e),()=>{document.removeEventListener("mousedown",e)}},[t,r]),!t)return null;let l="https://github.com/".concat(t.username);return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("div",{className:"fixed inset-0 bg-black/50 z-40"}),(0,s.jsxs)("div",{ref:o,className:"fixed right-0 top-0 h-full w-80 bg-[#1a1d21] border-l border-white/10 shadow-2xl z-50 flex flex-col animate-slide-in-right",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between p-4 border-b border-white/10",children:[(0,s.jsx)("h2",{className:"text-lg font-semibold text-[#d1d2d3]",children:"Profile"}),(0,s.jsx)("button",{onClick:r,className:"p-1 hover:bg-white/10 rounded-md transition-colors",title:"Close",children:(0,s.jsx)("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:(0,s.jsx)("path",{d:"M18 6L6 18M6 6l12 12"})})})]}),(0,s.jsxs)("div",{className:"flex flex-col items-center p-6 border-b border-white/10",children:[(0,s.jsxs)("div",{className:"relative mb-4",children:[t.avatarUrl?(0,s.jsx)("img",{src:t.avatarUrl,alt:t.username,className:"w-24 h-24 rounded-full object-cover border-4 border-[#a855f7]/30"}):(0,s.jsx)("div",{className:"w-24 h-24 rounded-full bg-[#a855f7] flex items-center justify-center text-3xl text-white font-bold border-4 border-[#a855f7]/30",children:t.username.charAt(0).toUpperCase()}),(0,s.jsx)("div",{className:"absolute bottom-1 right-1 w-5 h-5 bg-green-500 rounded-full border-4 border-[#1a1d21]"})]}),(0,s.jsx)("h3",{className:"text-xl font-semibold text-[#d1d2d3] mb-1",children:t.username}),(0,s.jsxs)("span",{className:"text-sm text-green-400 flex items-center gap-1.5",children:[(0,s.jsx)("div",{className:"w-2 h-2 bg-green-500 rounded-full"}),"Online"]})]}),(0,s.jsx)("div",{className:"flex-1 p-4 overflow-y-auto",children:(0,s.jsxs)("div",{className:"space-y-4",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"text-xs text-[#8d8d8e] uppercase tracking-wide",children:"Online Since"}),(0,s.jsx)("p",{className:"text-sm text-[#d1d2d3] mt-1",children:sR(t.connectedAt)})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"text-xs text-[#8d8d8e] uppercase tracking-wide",children:"Last Active"}),(0,s.jsx)("p",{className:"text-sm text-[#d1d2d3] mt-1",children:sR(t.lastSeen)})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"text-xs text-[#8d8d8e] uppercase tracking-wide",children:"GitHub"}),(0,s.jsxs)("a",{href:l,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-2 mt-1 text-sm text-[#a855f7] hover:text-[#c084fc] transition-colors",children:[(0,s.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:(0,s.jsx)("path",{d:"M12 0C5.37 0 0 5.37 0 12c0 5.31 3.435 9.795 8.205 11.385.6.105.825-.255.825-.57 0-.285-.015-1.23-.015-2.235-3.015.555-3.795-.735-4.035-1.41-.135-.345-.72-1.41-1.23-1.695-.42-.225-1.02-.78-.015-.795.945-.015 1.62.87 1.845 1.23 1.08 1.815 2.805 1.305 3.495.99.105-.78.42-1.305.765-1.605-2.67-.3-5.46-1.335-5.46-5.925 0-1.305.465-2.385 1.23-3.225-.12-.3-.54-1.53.12-3.18 0 0 1.005-.315 3.3 1.23.96-.27 1.98-.405 3-.405s2.04.135 3 .405c2.295-1.56 3.3-1.23 3.3-1.23.66 1.65.24 2.88.12 3.18.765.84 1.23 1.905 1.23 3.225 0 4.605-2.805 5.625-5.475 5.925.435.375.81 1.095.81 2.22 0 1.605-.015 2.895-.015 3.3 0 .315.225.69.825.57A12.02 12.02 0 0024 12c0-6.63-5.37-12-12-12z"})}),"@",t.username,(0,s.jsx)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:(0,s.jsx)("path",{d:"M18 13v6a2 2 0 01-2 2H5a2 2 0 01-2-2V8a2 2 0 012-2h6M15 3h6v6M10 14L21 3"})})]})]})]})}),(0,s.jsxs)("div",{className:"p-4 border-t border-white/10 space-y-2",children:[(0,s.jsxs)("button",{onClick:()=>{null==a||a(t.username),r()},className:"w-full flex items-center justify-center gap-2 py-2.5 bg-[#a855f7] hover:bg-[#9333ea] text-white font-medium rounded-lg transition-colors",children:[(0,s.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,s.jsx)("circle",{cx:"12",cy:"12",r:"4"}),(0,s.jsx)("path",{d:"M16 8v5a3 3 0 006 0v-1a10 10 0 10-3.92 7.94"})]}),"Mention @",t.username]}),(0,s.jsxs)("a",{href:l,target:"_blank",rel:"noopener noreferrer",className:"w-full flex items-center justify-center gap-2 py-2.5 border border-white/20 text-[#d1d2d3] hover:bg-white/5 font-medium rounded-lg transition-colors",children:[(0,s.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:(0,s.jsx)("path",{d:"M12 0C5.37 0 0 5.37 0 12c0 5.31 3.435 9.795 8.205 11.385.6.105.825-.255.825-.57 0-.285-.015-1.23-.015-2.235-3.015.555-3.795-.735-4.035-1.41-.135-.345-.72-1.41-1.23-1.695-.42-.225-1.02-.78-.015-.795.945-.015 1.62.87 1.845 1.23 1.08 1.815 2.805 1.305 3.495.99.105-.78.42-1.305.765-1.605-2.67-.3-5.46-1.335-5.46-5.925 0-1.305.465-2.385 1.23-3.225-.12-.3-.54-1.53.12-3.18 0 0 1.005-.315 3.3 1.23.96-.27 1.98-.405 3-.405s2.04.135 3 .405c2.295-1.56 3.3-1.23 3.3-1.23.66 1.65.24 2.88.12 3.18.765.84 1.23 1.905 1.23 3.225 0 4.605-2.805 5.625-5.475 5.925.435.375.81 1.095.81 2.22 0 1.605-.015 2.895-.015 3.3 0 .315.225.69.825.57A12.02 12.02 0 0024 12c0-6.63-5.37-12-12-12z"})}),"View on GitHub"]})]})]})]})}function sR(e){return new Date(e).toLocaleString([],{month:"short",day:"numeric",year:"numeric",hour:"2-digit",minute:"2-digit"})}function sP(e){let{isOpen:t,onClose:r,projects:a,isCloudMode:o=!1,hasArchitect:i=!1,onArchitectSpawned:l}=e,[c,d]=(0,n.useState)([]),[x,u]=(0,n.useState)(!1),[m,h]=(0,n.useState)(null),[p,g]=(0,n.useState)(!1),[b,f]=(0,n.useState)(""),[j,y]=(0,n.useState)(new Set),[v,w]=(0,n.useState)(!1),[N,k]=(0,n.useState)("claude");(0,n.useEffect)(()=>{t&&o&&C()},[t,o]);let C=async()=>{u(!0),h(null);try{let e=await fetch("/api/project-groups");if(e.ok){let t=await e.json();d(t.groups||[])}else h("Failed to load project groups")}catch(e){h("Failed to load project groups")}finally{u(!1)}},S=async()=>{if(b.trim()&&0!==j.size){u(!0),h(null);try{let e=await fetch("/api/project-groups",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:b,repositoryIds:Array.from(j)})});if(e.ok){let t=await e.json();t.group&&(d(e=>[...e,t.group]),g(!1),f(""),y(new Set))}else h("Failed to create project group")}catch(e){h("Failed to create project group")}finally{u(!1)}}},A=async(e,t)=>{h(null);try{let r="/api/project-groups/".concat(e,"/coordinator/").concat(t?"enable":"disable");(await fetch(r,{method:"POST"})).ok?d(r=>r.map(r=>r.id===e?{...r,coordinator:{...r.coordinator,enabled:t,status:t?"starting":"stopped"}}:r)):h("Failed to ".concat(t?"enable":"disable"," coordinator"))}catch(e){h("Failed to ".concat(t?"enable":"disable"," coordinator"))}},L=async e=>{if(window.confirm("Delete this project group? The coordinator will be stopped."))try{(await fetch("/api/project-groups/".concat(e),{method:"DELETE"})).ok?d(t=>t.filter(t=>t.id!==e)):h("Failed to delete project group")}catch(e){h("Failed to delete project group")}},E=e=>{y(t=>{let r=new Set(t);return r.has(e)?r.delete(e):r.add(e),r})};if(!t)return null;let W=async()=>{w(!0),h(null);try{let e=await fetch("/api/spawn/architect",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cli:N})}),t=await e.json();e.ok&&t.success?(null==l||l(),r()):h(t.error||"Failed to spawn Architect")}catch(e){h("Failed to spawn Architect")}finally{w(!1)}};if(!o){let e=a.length>1;return(0,s.jsx)("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-[1000] animate-fade-in",onClick:r,children:(0,s.jsxs)("div",{className:"bg-bg-secondary rounded-xl w-[500px] max-w-[90vw] max-h-[80vh] flex flex-col shadow-modal animate-slide-up",onClick:e=>e.stopPropagation(),children:[(0,s.jsxs)("div",{className:"flex items-center justify-between py-5 px-6 border-b border-border-subtle",children:[(0,s.jsxs)("div",{className:"flex items-center gap-3",children:[(0,s.jsx)(sI,{}),(0,s.jsx)("h2",{className:"m-0 text-lg font-semibold text-text-primary",children:"Coordinator Agent"})]}),(0,s.jsx)("button",{className:"flex items-center justify-center w-8 h-8 bg-transparent border-none rounded-md text-text-secondary cursor-pointer transition-all duration-150 hover:bg-bg-hover hover:text-text-primary",onClick:r,children:(0,s.jsx)(sU,{})})]}),(0,s.jsxs)("div",{className:"flex-1 overflow-y-auto p-6",children:[m&&(0,s.jsx)("div",{className:"bg-error/10 border border-error/30 rounded-lg p-3 mb-4 text-error text-sm",children:m}),e&&(0,s.jsxs)("div",{className:"bg-gradient-to-r from-accent-purple/10 to-accent-cyan/10 border border-accent-purple/30 rounded-lg p-4 mb-4",children:[(0,s.jsxs)("h3",{className:"text-sm font-semibold text-text-primary mb-3 flex items-center gap-2",children:[(0,s.jsx)(sI,{}),"Spawn Architect"]}),i?(0,s.jsxs)("div",{className:"flex items-center gap-2 text-sm text-success",children:[(0,s.jsx)(sH,{}),"Architect is running"]}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsxs)("p",{className:"text-sm text-text-secondary mb-4",children:["Spawn an Architect agent to coordinate across your ",a.length," connected projects."]}),(0,s.jsxs)("div",{className:"flex items-center gap-3",children:[(0,s.jsxs)("select",{className:"flex-1 py-2 px-3 bg-bg-card border border-border-subtle rounded-md text-sm text-text-primary outline-none focus:border-accent-purple/50",value:N,onChange:e=>k(e.target.value),children:[(0,s.jsx)("option",{value:"claude",children:"Claude (default)"}),(0,s.jsx)("option",{value:"claude:opus",children:"Claude Opus"}),(0,s.jsx)("option",{value:"claude:sonnet",children:"Claude Sonnet"}),(0,s.jsx)("option",{value:"codex",children:"Codex"})]}),(0,s.jsx)("button",{className:"py-2 px-4 bg-gradient-to-r from-accent-purple to-accent-cyan text-bg-deep rounded-md text-sm font-semibold hover:shadow-lg transition-all disabled:opacity-50",onClick:W,disabled:v,children:v?"Spawning...":"Spawn"})]})]})]}),!e&&(0,s.jsxs)("div",{className:"bg-bg-tertiary rounded-lg p-4 mb-4 border border-border-subtle",children:[(0,s.jsx)("h3",{className:"text-sm font-semibold text-text-primary mb-2",children:"Not in Bridge Mode"}),(0,s.jsx)("p",{className:"text-sm text-text-secondary",children:"The Architect coordinates multiple projects. Start bridge mode to enable:"}),(0,s.jsxs)("div",{className:"bg-bg-card rounded-lg p-3 font-mono text-sm mt-3",children:[(0,s.jsx)("span",{className:"text-text-muted",children:"$"})," ",(0,s.jsx)("span",{className:"text-accent-cyan",children:"relay bridge"})," ",(0,s.jsx)("span",{className:"text-accent-orange",children:"~/project1 ~/project2"})]})]}),(0,s.jsxs)("div",{className:"bg-bg-tertiary rounded-lg p-4 mb-4",children:[(0,s.jsx)("h3",{className:"text-sm font-semibold text-text-primary mb-2",children:"CLI Alternative"}),(0,s.jsxs)("p",{className:"text-sm text-text-secondary mb-3",children:["You can also spawn the Architect via CLI with the ",(0,s.jsx)("code",{className:"bg-bg-card px-1.5 py-0.5 rounded text-accent-cyan",children:"--architect"})," flag:"]}),(0,s.jsxs)("div",{className:"bg-bg-card rounded-lg p-3 font-mono text-sm",children:[(0,s.jsx)("span",{className:"text-text-muted",children:"$"})," ",(0,s.jsx)("span",{className:"text-accent-cyan",children:"relay bridge"})," ",(0,s.jsx)("span",{className:"text-accent-orange",children:"~/project1 ~/project2"})," ",(0,s.jsx)("span",{className:"text-accent-purple",children:"--architect"})]})]})]}),(0,s.jsx)("div",{className:"flex justify-end py-4 px-6 border-t border-border-subtle",children:(0,s.jsx)("button",{className:"py-2 px-5 bg-bg-tertiary border border-border-subtle rounded-md text-sm text-text-secondary cursor-pointer transition-colors duration-150 hover:bg-bg-hover",onClick:r,children:"Close"})})]})})}return(0,s.jsx)("div",{className:"fixed inset-0 bg-black/70 flex items-center justify-center z-[1000] animate-fade-in",onClick:r,children:(0,s.jsxs)("div",{className:"bg-bg-secondary rounded-xl w-[600px] max-w-[90vw] max-h-[80vh] flex flex-col shadow-modal animate-slide-up",onClick:e=>e.stopPropagation(),children:[(0,s.jsxs)("div",{className:"flex items-center justify-between py-5 px-6 border-b border-border-subtle",children:[(0,s.jsxs)("div",{className:"flex items-center gap-3",children:[(0,s.jsx)(sI,{}),(0,s.jsx)("h2",{className:"m-0 text-lg font-semibold text-text-primary",children:"Coordinator Agents"})]}),(0,s.jsx)("button",{className:"flex items-center justify-center w-8 h-8 bg-transparent border-none rounded-md text-text-secondary cursor-pointer transition-all duration-150 hover:bg-bg-hover hover:text-text-primary",onClick:r,children:(0,s.jsx)(sU,{})})]}),(0,s.jsxs)("div",{className:"flex-1 overflow-y-auto p-6",children:[m&&(0,s.jsx)("div",{className:"bg-error/10 border border-error/30 rounded-lg p-3 mb-4 text-error text-sm",children:m}),x&&0===c.length?(0,s.jsx)("div",{className:"flex items-center justify-center py-12 text-text-muted",children:(0,s.jsx)(s_,{})}):(0,s.jsxs)(s.Fragment,{children:[c.length>0&&(0,s.jsxs)("div",{className:"space-y-3 mb-6",children:[(0,s.jsx)("h4",{className:"text-xs font-semibold text-text-muted uppercase tracking-wider",children:"Project Groups"}),c.map(e=>{var t,r,n,a;return(0,s.jsxs)("div",{className:"bg-bg-tertiary rounded-lg p-4 border border-border-subtle",children:[(0,s.jsxs)("div",{className:"flex items-center justify-between mb-3",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)("span",{className:"font-semibold text-text-primary",children:e.name}),(0,s.jsxs)("span",{className:"text-xs text-text-muted",children:[e.repositoryIds.length," repos"]})]}),(0,s.jsx)("button",{className:"text-text-muted hover:text-error transition-colors p-1",onClick:()=>L(e.id),title:"Delete group",children:(0,s.jsx)(sO,{})})]}),(0,s.jsxs)("div",{className:"flex items-center justify-between",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)(sB,{status:(null===(t=e.coordinator)||void 0===t?void 0:t.status)||"stopped"}),(null===(r=e.coordinator)||void 0===r?void 0:r.name)&&(0,s.jsx)("span",{className:"text-sm text-text-secondary",children:e.coordinator.name})]}),(0,s.jsxs)("button",{className:"py-1.5 px-3 rounded-md text-xs font-medium transition-colors ".concat((null===(n=e.coordinator)||void 0===n?void 0:n.enabled)?"bg-error/20 text-error hover:bg-error/30":"bg-accent-cyan/20 text-accent-cyan hover:bg-accent-cyan/30"),onClick:()=>{var t;return A(e.id,!(null===(t=e.coordinator)||void 0===t?void 0:t.enabled))},children:[(null===(a=e.coordinator)||void 0===a?void 0:a.enabled)?"Stop":"Start"," Coordinator"]})]})]},e.id)})]}),p?(0,s.jsxs)("div",{className:"bg-bg-tertiary rounded-lg p-4 border border-accent-cyan/30",children:[(0,s.jsx)("h4",{className:"text-sm font-semibold text-text-primary mb-4",children:"Create Project Group"}),(0,s.jsxs)("div",{className:"space-y-4",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"block text-xs font-medium text-text-muted mb-1.5",children:"Group Name"}),(0,s.jsx)("input",{type:"text",className:"w-full py-2 px-3 bg-bg-card border border-border-subtle rounded-md text-sm text-text-primary outline-none focus:border-accent-cyan/50",placeholder:"e.g., Frontend Team",value:b,onChange:e=>f(e.target.value)})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"block text-xs font-medium text-text-muted mb-1.5",children:"Select Projects"}),(0,s.jsxs)("div",{className:"space-y-2 max-h-[200px] overflow-y-auto",children:[a.map(e=>(0,s.jsxs)("label",{className:"flex items-center gap-2 p-2 bg-bg-card rounded-md cursor-pointer hover:bg-bg-hover",children:[(0,s.jsx)("input",{type:"checkbox",className:"accent-accent-cyan",checked:j.has(e.id),onChange:()=>E(e.id)}),(0,s.jsx)("span",{className:"text-sm text-text-primary",children:e.name||e.path})]},e.id)),0===a.length&&(0,s.jsx)("p",{className:"text-sm text-text-muted py-4 text-center",children:"No projects available. Add workspaces first."})]})]}),(0,s.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,s.jsx)("button",{className:"py-2 px-4 bg-transparent border border-border-subtle rounded-md text-sm text-text-secondary hover:bg-bg-hover",onClick:()=>{g(!1),f(""),y(new Set)},children:"Cancel"}),(0,s.jsx)("button",{className:"py-2 px-4 bg-accent-cyan text-bg-deep rounded-md text-sm font-medium hover:bg-accent-cyan/90 disabled:opacity-50",onClick:S,disabled:!b.trim()||0===j.size||x,children:"Create Group"})]})]})]}):(0,s.jsxs)("button",{className:"w-full py-3 px-4 border-2 border-dashed border-border-subtle rounded-lg text-text-muted hover:border-accent-cyan/50 hover:text-accent-cyan transition-colors flex items-center justify-center gap-2",onClick:()=>g(!0),children:[(0,s.jsx)(sF,{}),"Create Project Group"]}),(0,s.jsxs)("div",{className:"mt-6 p-4 bg-bg-tertiary/50 rounded-lg border border-border-subtle",children:[(0,s.jsxs)("h4",{className:"text-sm font-semibold text-text-primary mb-2 flex items-center gap-2",children:[(0,s.jsx)(sz,{}),"What is a Coordinator?"]}),(0,s.jsx)("p",{className:"text-sm text-text-secondary",children:"A coordinator is a high-level AI agent that oversees multiple projects. It can delegate tasks to project leads, ensure consistency across codebases, and manage cross-project dependencies."})]})]})]})]})})}function sB(e){let{status:t}=e,r={stopped:"bg-text-muted/20 text-text-muted",starting:"bg-accent-orange/20 text-accent-orange",running:"bg-success/20 text-success",error:"bg-error/20 text-error"};return(0,s.jsx)("span",{className:"px-2 py-0.5 rounded-full text-xs font-medium ".concat(r[t]||r.stopped),children:t})}function s_(){return(0,s.jsx)("svg",{className:"animate-spin h-6 w-6 text-accent-cyan",viewBox:"0 0 24 24",children:(0,s.jsx)("circle",{cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"2",fill:"none",strokeDasharray:"32",strokeLinecap:"round"})})}function sI(){return(0,s.jsxs)("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:"text-accent-cyan",children:[(0,s.jsx)("circle",{cx:"12",cy:"12",r:"3"}),(0,s.jsx)("circle",{cx:"5",cy:"5",r:"2"}),(0,s.jsx)("circle",{cx:"19",cy:"5",r:"2"}),(0,s.jsx)("circle",{cx:"5",cy:"19",r:"2"}),(0,s.jsx)("circle",{cx:"19",cy:"19",r:"2"}),(0,s.jsx)("line",{x1:"9.5",y1:"9.5",x2:"6.5",y2:"6.5"}),(0,s.jsx)("line",{x1:"14.5",y1:"9.5",x2:"17.5",y2:"6.5"}),(0,s.jsx)("line",{x1:"9.5",y1:"14.5",x2:"6.5",y2:"17.5"}),(0,s.jsx)("line",{x1:"14.5",y1:"14.5",x2:"17.5",y2:"17.5"})]})}function sU(){return(0,s.jsxs)("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,s.jsx)("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),(0,s.jsx)("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})}function sF(){return(0,s.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,s.jsx)("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),(0,s.jsx)("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]})}function sO(){return(0,s.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,s.jsx)("polyline",{points:"3 6 5 6 21 6"}),(0,s.jsx)("path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"})]})}function sz(){return(0,s.jsxs)("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:"text-accent-cyan",children:[(0,s.jsx)("circle",{cx:"12",cy:"12",r:"10"}),(0,s.jsx)("line",{x1:"12",y1:"16",x2:"12",y2:"12"}),(0,s.jsx)("line",{x1:"12",y1:"8",x2:"12.01",y2:"8"})]})}function sH(){return(0,s.jsx)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",className:"text-success",children:(0,s.jsx)("polyline",{points:"20 6 9 17 4 12"})})}let sV={url:"",autoConnect:!0,reconnect:!0,maxReconnectAttempts:10,reconnectDelay:1e3},sG="relay:recentRepos";function sK(e){try{localStorage.setItem(sG,JSON.stringify(e))}catch(e){}}var sJ=r(5372);function sq(e){var t,r,i,l,d,u,m;let{wsUrl:h,orchestratorUrl:p}=e,{data:g,isConnected:b,error:f}=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t={...sV,...e},[r,s]=(0,n.useState)(null),[a,o]=(0,n.useState)(!1),[i,l]=(0,n.useState)(null),c=(0,n.useRef)(null),d=(0,n.useRef)(0),x=(0,n.useRef)(null),u=(0,n.useCallback)(()=>{var e;if((null===(e=c.current)||void 0===e?void 0:e.readyState)===WebSocket.OPEN)return;let r=t.url||function(){let e="https:"===window.location.protocol?"wss:":"ws:";return"".concat(e,"//").concat(window.location.host,"/ws")}();try{let e=new WebSocket(r);e.onopen=()=>{o(!0),l(null),d.current=0},e.onclose=()=>{if(o(!1),c.current=null,t.reconnect&&d.current<t.maxReconnectAttempts){let e=Math.min(t.reconnectDelay*Math.pow(2,d.current),3e4);d.current++,x.current=setTimeout(()=>{u()},e)}},e.onerror=e=>{l(Error("WebSocket connection error")),console.error("[useWebSocket] Error:",e)},e.onmessage=e=>{try{let t=JSON.parse(e.data);s(t)}catch(e){console.error("[useWebSocket] Failed to parse message:",e)}},c.current=e}catch(e){l(e instanceof Error?e:Error("Failed to create WebSocket"))}},[t.url,t.reconnect,t.maxReconnectAttempts,t.reconnectDelay]),m=(0,n.useCallback)(()=>{x.current&&(clearTimeout(x.current),x.current=null),c.current&&(c.current.close(),c.current=null),o(!1)},[]);return(0,n.useEffect)(()=>(t.autoConnect&&u(),()=>{m()}),[t.autoConnect,u,m]),{data:r,isConnected:a,error:i,connect:u,disconnect:m}}({url:h}),{workspaces:j,activeWorkspaceId:y,agents:v,isConnected:w,isLoading:N,error:k,switchWorkspace:C,addWorkspace:S,removeWorkspace:A,spawnAgent:L,stopAgent:E}=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},{apiUrl:t="http://localhost:3456",enabled:r=!1}=e,[s,a]=(0,n.useState)([]),[o,i]=(0,n.useState)(),[l,c]=(0,n.useState)([]),[d,x]=(0,n.useState)(!1),[u,m]=(0,n.useState)(r),[h,p]=(0,n.useState)(null),g=(0,n.useRef)(null),b=(0,n.useRef)(),f=t.replace(/^http/,"ws"),j=(0,n.useCallback)(async()=>{if(r)try{m(!0),p(null);let e=await fetch("".concat(t,"/workspaces"));if(!e.ok)throw Error("Failed to fetch workspaces: ".concat(e.statusText));let r=await e.json();if(a(r.workspaces.map(e=>({...e,lastActiveAt:new Date(e.lastActiveAt)}))),i(r.activeWorkspaceId),r.activeWorkspaceId){let e=await fetch("".concat(t,"/workspaces/").concat(r.activeWorkspaceId,"/agents"));if(e.ok){let t=await e.json();c(t.agents.map(e=>({...e,spawnedAt:new Date(e.spawnedAt)})))}}}catch(e){p(e instanceof Error?e:Error(String(e)))}finally{m(!1)}},[t,r]);(0,n.useEffect)(()=>{if(!r)return;let e=()=>{try{let t=new WebSocket(f);t.onopen=()=>{x(!0),p(null)},t.onmessage=e=>{try{let r=JSON.parse(e.data);if("init"===r.type){var t;a(r.data.workspaces.map(e=>({...e,lastActiveAt:new Date(e.lastActiveAt)}))),i(r.data.activeWorkspaceId),c((null===(t=r.data.agents)||void 0===t?void 0:t.map(e=>({...e,spawnedAt:new Date(e.spawnedAt)})))||[]),m(!1)}else"event"===r.type&&y(r.data)}catch(e){console.error("Failed to parse WebSocket message:",e)}},t.onclose=()=>{x(!1),g.current=null,b.current=setTimeout(e,3e3)},t.onerror=e=>{console.error("WebSocket error:",e),t.close()},g.current=t}catch(t){p(t instanceof Error?t:Error(String(t))),b.current=setTimeout(e,3e3)}};return j().then(e),()=>{b.current&&clearTimeout(b.current),g.current&&g.current.close()}},[f,j,r]);let y=(0,n.useCallback)(e=>{switch(e.type){case"workspace:added":a(t=>[...t,e.data]);break;case"workspace:removed":a(t=>t.filter(t=>t.id!==e.workspaceId));break;case"workspace:updated":a(t=>t.map(t=>t.id===e.workspaceId?{...t,...e.data}:t));break;case"workspace:switched":i(e.data.currentId);break;case"agent:spawned":c(t=>[...t,e.data]);break;case"agent:stopped":case"agent:crashed":c(t=>t.filter(t=>t.name!==e.data.name));break;case"agent:restarted":c(t=>t.map(t=>t.name===e.data.name?{...t,status:"running",restartCount:t.restartCount+1}:t))}},[]),v=(0,n.useCallback)(async e=>{let r=await fetch("".concat(t,"/workspaces/").concat(e,"/switch"),{method:"POST"});if(!r.ok)throw Error("Failed to switch workspace: ".concat(r.statusText));let s=await fetch("".concat(t,"/workspaces/").concat(e,"/agents"));s.ok&&c((await s.json()).agents.map(e=>({...e,spawnedAt:new Date(e.spawnedAt)})))},[t]),w=(0,n.useCallback)(async(e,r)=>{let s=await fetch("".concat(t,"/workspaces"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({path:e,name:r})});if(!s.ok)throw Error((await s.json()).error||"Failed to add workspace");return s.json()},[t]),N=(0,n.useCallback)(async e=>{let r=await fetch("".concat(t,"/workspaces/").concat(e),{method:"DELETE"});if(!r.ok)throw Error("Failed to remove workspace: ".concat(r.statusText))},[t]),k=(0,n.useCallback)(async(e,r,s)=>{if(!o)throw Error("No active workspace");let n=await fetch("".concat(t,"/workspaces/").concat(o,"/agents"),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:e,task:r,provider:s})});if(!n.ok)throw Error((await n.json()).error||"Failed to spawn agent");return n.json()},[t,o]),C=(0,n.useCallback)(async e=>{if(!o)throw Error("No active workspace");let r=await fetch("".concat(t,"/workspaces/").concat(o,"/agents/").concat(e),{method:"DELETE"});if(!r.ok)throw Error("Failed to stop agent: ".concat(r.statusText))},[t,o]);return{workspaces:s,activeWorkspaceId:o,agents:l,isConnected:d,isLoading:u,error:h,switchWorkspace:v,addWorkspace:w,removeWorkspace:N,spawnAgent:k,stopAgent:C,refresh:j}}({apiUrl:p}),W=(0,sJ.uo)(),D=(null==W?void 0:W.user)?{displayName:W.user.githubUsername,avatarUrl:W.user.avatarUrl}:void 0,[M,T]=(0,n.useState)([]),[R,P]=(0,n.useState)(null),[B,_]=(0,n.useState)(!1);(0,n.useEffect)(()=>{if(!(null==W?void 0:W.user))return;let e=async()=>{_(!0);try{let e=await en.xv.getWorkspaceSummary();e.success&&e.data.workspaces&&(T(e.data.workspaces),!R&&e.data.workspaces.length>0&&P(e.data.workspaces[0].id))}catch(e){console.error("Failed to fetch cloud workspaces:",e)}finally{_(!1)}};e();let t=setInterval(e,3e4);return()=>clearInterval(t)},[null==W?void 0:W.user,R]);let I=!!(null==W?void 0:W.user),U=(0,n.useMemo)(()=>I&&M.length>0?M.map(e=>({id:e.id,name:e.name,path:e.path||"/workspace/".concat(e.name),status:"running"===e.status?"active":"inactive",provider:"claude",lastActiveAt:new Date})):j,[I,M,j]),F=I?R:y,O=I?B:N;(0,n.useEffect)(()=>{I&&R?(0,ra.hc)(R):I||(0,ra.hc)(null)},[I,R]);let z=(0,n.useCallback)(async e=>{I?P(e.id):await C(e.id)},[I,C]),{onlineUsers:V,typingUsers:G,sendTyping:K,isConnected:J}=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},{currentUser:t,wsUrl:r,autoConnect:s=!0}=e,[a,o]=(0,n.useState)([]),[i,l]=(0,n.useState)([]),[c,d]=(0,n.useState)(!1),x=(0,n.useRef)(null),u=(0,n.useRef)(null),m=(0,n.useRef)(null),h=(0,n.useRef)(!1);(0,n.useEffect)(()=>{let e=setInterval(()=>{let e=Date.now();l(t=>t.filter(t=>e-t.startedAt<3e3))},1e3);return()=>clearInterval(e)},[]);let p=(0,n.useCallback)(()=>{var e;if(!t||(null===(e=x.current)||void 0===e?void 0:e.readyState)===WebSocket.OPEN||h.current)return;h.current=!0;let s=r||function(){let e="https:"===window.location.protocol?"wss:":"ws:";return"".concat(e,"//").concat(window.location.host,"/ws/presence")}();try{let e=new WebSocket(s);e.onopen=()=>{h.current=!1,d(!0),e.send(JSON.stringify({type:"presence",action:"join",user:{username:t.username,avatarUrl:t.avatarUrl}}))},e.onclose=()=>{h.current=!1,d(!1),x.current=null,t&&(u.current=setTimeout(()=>{p()},2e3))},e.onerror=e=>{console.error("[usePresence] Error:",e)},e.onmessage=e=>{try{let r=JSON.parse(e.data);switch(r.type){case"presence_list":o(r.users||[]);break;case"presence_join":o(e=>[...e.filter(e=>e.username!==r.user.username),r.user]);break;case"presence_leave":o(e=>e.filter(e=>e.username!==r.username)),l(e=>e.filter(e=>e.username!==r.username));break;case"typing":if(r.username===(null==t?void 0:t.username))break;r.isTyping?l(e=>[...e.filter(e=>e.username!==r.username),{username:r.username,avatarUrl:r.avatarUrl,startedAt:Date.now()}]):l(e=>e.filter(e=>e.username!==r.username))}}catch(e){console.error("[usePresence] Failed to parse message:",e)}},x.current=e}catch(e){console.error("[usePresence] Failed to create WebSocket:",e)}},[t,r]),g=(0,n.useCallback)(()=>{if(u.current&&(clearTimeout(u.current),u.current=null),h.current=!1,x.current){let e=x.current;e.onclose=null,e.onerror=null,e.readyState===WebSocket.OPEN&&t&&e.send(JSON.stringify({type:"presence",action:"leave",username:t.username})),e.close(),x.current=null}d(!1)},[t]),b=(0,n.useCallback)(e=>{x.current&&x.current.readyState===WebSocket.OPEN&&t&&(m.current&&(clearTimeout(m.current),m.current=null),x.current.send(JSON.stringify({type:"typing",isTyping:e,username:t.username,avatarUrl:t.avatarUrl})),e&&(m.current=setTimeout(()=>{m.current=null,b(!1)},3e3)))},[t]),f=(0,n.useRef)(t);return f.current=t,(0,n.useEffect)(()=>{if(s&&f.current&&(!x.current||x.current.readyState===WebSocket.CLOSED))return p(),()=>{g()}},[s,null==t?void 0:t.username,p,g]),(0,n.useEffect)(()=>{let e=()=>{var e;(null===(e=x.current)||void 0===e?void 0:e.readyState)===WebSocket.OPEN&&t&&x.current.send(JSON.stringify({type:"presence",action:"leave",username:t.username}))};return window.addEventListener("beforeunload",e),()=>window.removeEventListener("beforeunload",e)},[t]),{onlineUsers:a,typingUsers:i,sendTyping:b,isConnected:c}}({currentUser:D?{username:D.displayName,avatarUrl:D.avatarUrl}:void 0}),[q,X]=(0,n.useState)(null),[Y,$]=(0,n.useState)("local"),[Z,Q]=(0,n.useState)([]),[ee,et]=(0,n.useState)(),[er,es]=(0,n.useState)(!1),[ea,eo]=(0,n.useState)(!1),[ei,el]=(0,n.useState)(null),[ec,ed]=(0,n.useState)(!1),[ex,eu]=(0,n.useState)(!1),[eh,ep]=(0,n.useState)(null),[eg,eb]=(0,n.useState)(!1),[ef,ej]=(0,n.useState)(!1),[ey,ev]=(0,n.useState)(td),[ew,eN]=(0,n.useState)(!1),[ek,eC]=(0,n.useState)("dashboard"),[eS,eA]=(0,n.useState)(!1),[eL,eE]=(0,n.useState)(!1),[eD,eM]=(0,n.useState)(null),[eT,eR]=(0,n.useState)(!1),{steps:eP,status:eB,history:e_,isLoading:eI,selectTrajectory:eF,selectedTrajectoryId:eO}=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},{pollInterval:t=2e3,autoPoll:r=!0,trajectoryId:s,apiBaseUrl:a=""}=e,[o,i]=(0,n.useState)([]),[l,c]=(0,n.useState)(null),[d,x]=(0,n.useState)([]),[u,m]=(0,n.useState)(!0),[h,p]=(0,n.useState)(null),[g,b]=(0,n.useState)(s||null),f=(0,n.useRef)(null),j=(0,n.useCallback)(async()=>{try{let e=a?"".concat(a,"/api/trajectory"):(0,ra.kG)("/api/trajectory"),t=await fetch(e,{credentials:"include"}),r=await t.json();!1!==r.success&&c({active:r.active,trajectoryId:r.trajectoryId,phase:r.phase,task:r.task})}catch(e){console.error("[useTrajectory] Status fetch error:",e)}},[a]),y=(0,n.useCallback)(async()=>{try{let e=a?"".concat(a,"/api/trajectory/history"):(0,ra.kG)("/api/trajectory/history"),t=await fetch(e,{credentials:"include"}),r=await t.json();r.success&&x(r.trajectories||[])}catch(e){console.error("[useTrajectory] History fetch error:",e)}},[a]),v=(0,n.useCallback)(async()=>{try{let e=g?"/api/trajectory/steps?trajectoryId=".concat(encodeURIComponent(g)):"/api/trajectory/steps",t=a?"".concat(a).concat(e):(0,ra.kG)(e),r=await fetch(t,{credentials:"include"}),s=await r.json();s.success?(i(s.steps||[]),p(null)):p(s.error||"Failed to fetch trajectory steps")}catch(e){console.error("[useTrajectory] Steps fetch error:",e),p(e.message)}},[a,g]),w=(0,n.useCallback)(e=>{b(e)},[]),N=(0,n.useCallback)(async()=>{m(!0),await Promise.all([j(),v(),y()]),m(!1)},[j,v,y]);return(0,n.useEffect)(()=>{N()},[N]),(0,n.useEffect)(()=>{v()},[g,v]),(0,n.useEffect)(()=>{if(!r)return;f.current=setInterval(()=>{v(),j()},t);let e=setInterval(y,1e4);return()=>{f.current&&clearInterval(f.current),clearInterval(e)}},[r,t,v,j,y]),{steps:o,status:l,history:d,isLoading:u,error:h,refresh:N,selectTrajectory:w,selectedTrajectoryId:g}}({autoPoll:eT}),{recentRepos:ez,addRecentRepo:eH,getRecentProjects:eV}=function(){var e;let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=null!==(e=t.maxRecent)&&void 0!==e?e:5,[s,a]=(0,n.useState)([]);(0,n.useEffect)(()=>{a(function(){try{let e=localStorage.getItem(sG);if(!e)return[];let t=JSON.parse(e);if(!Array.isArray(t))return[];return t}catch(e){return[]}}())},[]);let o=(0,n.useCallback)(e=>{a(t=>{let s=t.filter(t=>t.id!==e.id),n=[{id:e.id,path:e.path,name:e.name,lastAccessed:Date.now()},...s].slice(0,r);return sK(n),n})},[r]),i=(0,n.useCallback)(e=>{a(t=>{let r=t.filter(t=>t.id!==e);return sK(r),r})},[]),l=(0,n.useCallback)(()=>{a([]),sK([])},[]),c=(0,n.useCallback)(e=>{let t=new Map(e.map(e=>[e.id,e]));return s.map(e=>t.get(e.id)).filter(e=>void 0!==e)},[s]);return{recentRepos:s,addRecentRepo:o,removeRecentRepo:i,clearRecentRepos:l,getRecentProjects:c}}(),[eJ,eq]=(0,n.useState)(!1),[eX,eY]=(0,n.useState)(!1),[e$,eZ]=(0,n.useState)([]),[eQ,e0]=(0,n.useState)({}),[e1,e2]=(0,n.useState)(!1),[e5,e4]=(0,n.useState)([]),[e3,e8]=(0,n.useState)(),[e9,e7]=(0,n.useState)(!1),[te,tr]=(0,n.useState)(!1),[ts,tn]=(0,n.useState)(!1),ta=(0,n.useRef)(0),to=(0,n.useRef)(!0),ti=(0,n.useCallback)(()=>{window.innerWidth<=768&&tr(!1)},[]),{agents:tl,groups:tc,selectedAgent:tx,selectAgent:tm,searchQuery:th,setSearchQuery:tp,totalCount:tg,onlineCount:tb,needsAttentionCount:tf}=function(e){let{agents:t,initialSelected:r,initialSearchQuery:s=""}=e,[i,l]=(0,n.useState)(null!=r?r:null),[d,u]=(0,n.useState)(s),m=(0,n.useMemo)(()=>c(t,d),[t,d]),h=(0,n.useMemo)(()=>o(m),[m]),p=(0,n.useMemo)(()=>[...m].sort((e,t)=>e.name.localeCompare(t.name)),[m]),g=(0,n.useMemo)(()=>{var e;return null!==(e=t.find(e=>e.name===i))&&void 0!==e?e:null},[t,i]),b=(0,n.useMemo)(()=>{let e=x(t);return{totalCount:e.total,onlineCount:e.online,needsAttentionCount:e.needsAttention}},[t]),f=(0,n.useCallback)(e=>{l(e)},[]),j=(0,n.useCallback)(e=>t.find(t=>t.name===e),[t]),y=(0,n.useCallback)(e=>({...e,color:(0,a.GW)(e.name)}),[]);return{agents:m,groups:h,sortedAgents:p,selectedAgent:g,selectAgent:f,searchQuery:d,setSearchQuery:u,...b,getAgentByName:j,getAgentWithColor:y}}({agents:null!==(d=null==g?void 0:g.agents)&&void 0!==d?d:[]}),{messages:tj,threadMessages:ty,currentChannel:tv,setCurrentChannel:tw,currentThread:tN,setCurrentThread:tk,activeThreads:tC,totalUnreadThreadCount:tS,sendMessage:tA,isSending:tL,sendError:tE}=function(e){let{messages:t,currentChannel:r="general",senderName:s}=e,[a,o]=(0,n.useState)(r),[i,l]=(0,n.useState)(null),[c,d]=(0,n.useState)(!1),[x,u]=(0,n.useState)(null),[m,h]=(0,n.useState)(new Map),p=s||"Dashboard",[g,b]=(0,n.useState)([]);(0,n.useEffect)(()=>{if(0===g.length)return;let e=new Set(t.slice(-50).map(e=>"".concat(e.from,":").concat(e.to,":").concat(e.content.slice(0,100))));b(t=>t.filter(t=>{let r="".concat(t.from,":").concat(t.to,":").concat(t.content.slice(0,100));return!e.has(r)}))},[t,g.length]);let f=(0,n.useMemo)(()=>0===g.length?t:[...t,...g],[t,g]),j=(0,n.useMemo)(()=>{let e=new Set(f.map(e=>e.id)),t=f.filter(t=>!t.thread||!e.has(t.thread));return"general"===a?t:t.filter(e=>e.from===a||e.to===a)},[f,a]),y=(0,n.useCallback)(e=>f.filter(t=>t.thread===e),[f]),v=(0,n.useMemo)(()=>{let e=new Map,t=new Set(f.map(e=>e.id));for(let t of f)if(t.thread){let r=e.get(t.thread)||[];r.push(t),e.set(t.thread,r)}let r=[];for(let[s,n]of e.entries()){let e=[...n].sort((e,t)=>new Date(t.timestamp).getTime()-new Date(e.timestamp).getTime()),a=[...new Set(n.flatMap(e=>[e.from,e.to]))].filter(e=>"*"!==e),o=m.get(s),i=n.filter(e=>e.from!==p&&!e.isRead&&(!o||new Date(e.timestamp).getTime()>o)).length,l=s;if(t.has(s)){let e=f.find(e=>e.id===s);if(e){let t=e.content.split("\n")[0];l=t.length>30?t.substring(0,30)+"...":t}}r.push({id:s,name:l,lastMessage:e[0],messageCount:n.length,unreadCount:i,participants:a})}return r.sort((e,t)=>new Date(t.lastMessage.timestamp).getTime()-new Date(e.lastMessage.timestamp).getTime())},[f,m]),w=(0,n.useCallback)(e=>{l(e),e&&h(t=>{let r=new Map(t);return r.set(e,Date.now()),r})},[]),N=(0,n.useMemo)(()=>v.filter(e=>e.unreadCount>0).length,[v]),k=(0,n.useMemo)(()=>{let e=f.filter(e=>!e.isRead).length;return{totalCount:f.length,unreadCount:e}},[f]);return{messages:j,threadMessages:y,currentChannel:a,setCurrentChannel:o,currentThread:i,setCurrentThread:w,activeThreads:v,totalUnreadThreadCount:N,sendMessage:(0,n.useCallback)(async(e,t,r,n)=>{d(!0),u(null);let a="optimistic-".concat(Date.now(),"-").concat(Math.random().toString(36).slice(2,9)),o={id:a,from:p,to:e,content:t,timestamp:new Date().toISOString(),status:"sending",thread:r,isRead:!0};b(e=>[...e,o]);try{let o={to:e,message:t,thread:r,attachments:n};s&&(o.from=s);let i=await ra.hi.sendMessage(o);if(i.success)return!0;return b(e=>e.filter(e=>e.id!==a)),u(i.error||"Failed to send message"),!1}catch(e){return b(e=>e.filter(e=>e.id!==a)),u("Network error"),!1}finally{d(!1)}},[p,s]),isSending:c,sendError:x,...k}}({messages:null!==(u=null==g?void 0:g.messages)&&void 0!==u?u:[],senderName:null==D?void 0:D.displayName}),tW=(0,n.useMemo)(()=>{var e;let t=new Set(tl.map(e=>e.name.toLowerCase())),r=new Map;for(let s of(D&&r.set(D.displayName.toLowerCase(),{username:D.displayName,avatarUrl:D.avatarUrl}),null!==(e=null==g?void 0:g.messages)&&void 0!==e?e:[])){let e=s.from;!e||"Dashboard"===e||"*"===e||t.has(e.toLowerCase())||r.has(e.toLowerCase())||r.set(e.toLowerCase(),{username:e})}return Array.from(r.values())},[null==g?void 0:g.messages,tl,D]);(0,n.useEffect)(()=>{if(!(window.innerWidth<=768)){tn(!1);return}let e=tj.length;!te&&e>ta.current&&tn(!0),to.current=!te},[tj.length,te]),(0,n.useEffect)(()=>{te&&(tn(!1),ta.current=tj.length)},[te,tj.length]),(0,n.useEffect)(()=>{ta.current=tj.length},[]);let tD=!!(null==g?void 0:null===(r=g.fleet)||void 0===r?void 0:null===(t=r.servers)||void 0===t?void 0:t.length)||j.length>0;(0,n.useEffect)(()=>{j.length>0&&(Q(j.map(e=>({id:e.id,path:e.path,name:e.name,agents:v.filter(t=>t.workspaceId===e.id).map(e=>({name:e.name,status:"running"===e.status?"online":"offline",isSpawned:!0,cli:e.provider})),lead:void 0}))),et(y))},[j,v,y]),(0,n.useEffect)(()=>{if(j.length>0)return;let e=async()=>{let e=await ra.hi.getBridgeData();if(e.success&&e.data){let t=e.data;if(t.projects&&t.projects.length>0){let e=t.projects.map(e=>({id:e.id,path:e.path,name:e.name||e.path.split("/").pop(),agents:(e.agents||[]).map(e=>({name:e.name,status:"online"===e.status||"active"===e.status?"online":"offline",currentTask:e.task,cli:e.cli})),lead:e.lead}));Q(e),!ee&&e.length>0&&et(e[0].id)}}};e();let t=setInterval(e,5e3);return()=>clearInterval(t)},[j.length,ee]);let tM=["architect"],{bridgeAgents:tT,projectAgents:tR}=(0,n.useMemo)(()=>{let e=[],t=[];for(let r of tl)tM.includes(r.name.toLowerCase())?e.push(r):t.push(r);return{bridgeAgents:e,projectAgents:t}},[tl]),tP=(0,n.useMemo)(()=>0===Z.length||0===new Set(tR.map(e=>e.name.toLowerCase())).size?Z:Z.map((e,t)=>{if(0===t||e.id===ee){let t=new Set(e.agents.map(e=>e.name.toLowerCase())),r=tR.filter(e=>!t.has(e.name.toLowerCase()));return{...e,agents:[...e.agents,...r]}}return e}),[Z,tR,ee]),tB=(0,n.useMemo)(()=>tP.length>0?[]:tR,[tP,tR]);(0,n.useCallback)(async e=>{try{await C(e.id)}catch(e){console.error("Failed to switch workspace:",e)}},[C]);let t_=(0,n.useCallback)(async(e,t)=>{eu(!0),ep(null);try{await S(e,t),ed(!1)}catch(e){throw ep(e instanceof Error?e.message:"Failed to add workspace"),e}finally{eu(!1)}},[S]),tI=(0,n.useCallback)(e=>{et(e.id),eH(e),j.length>0&&C(e.id).catch(e=>{console.error("Failed to switch workspace:",e)}),e.agents.length>0&&(tm(e.agents[0].name),tw(e.agents[0].name)),ti()},[tm,tw,ti,j.length,C,eH]),tU=(0,n.useCallback)(e=>{tm(e.name),tw(e.name),ti()},[tm,tw,ti]),tF=(0,n.useCallback)(()=>{el(null),es(!0)},[]),tO=(0,n.useCallback)(()=>{eC("dashboard"),eN(!0)},[]),tz=(0,n.useCallback)(()=>{eC("workspace"),eN(!0)},[]),tH=(0,n.useCallback)(()=>{eA(!0)},[]),tV=(0,n.useCallback)(()=>{eE(!0)},[]),tG=(0,n.useCallback)(()=>{eq(!0)},[]),tK=(0,n.useCallback)(async(e,t)=>{let r=await tA(e,t);if(r){if("*"===e)tm(null),tw("general");else{let t=tl.find(t=>t.name===e);t?(tm(t.name),tw(t.name)):tw(e)}}return r},[tA,tm,tw,tl]),tJ=(0,n.useCallback)(async e=>{eo(!0),el(null);try{if(j.length>0&&y)return await L(e.name,void 0,e.command),!0;let t=await ra.hi.spawnAgent({name:e.name,cli:e.command,team:e.team,shadowMode:e.shadowMode,shadowOf:e.shadowOf,shadowAgent:e.shadowAgent,shadowTriggers:e.shadowTriggers,shadowSpeakOn:e.shadowSpeakOn});if(!t.success)return el(t.error||"Failed to spawn agent"),!1;return!0}catch(e){return el(e instanceof Error?e.message:"Failed to spawn agent"),!1}finally{eo(!1)}},[j.length,y,L]),tq=(0,n.useCallback)(async e=>{if(e.isSpawned&&window.confirm('Are you sure you want to release agent "'.concat(e.name,'"?')))try{if(j.length>0&&y){await E(e.name);return}let t=await ra.hi.releaseAgent(e.name);t.success||console.error("Failed to release agent:",t.error)}catch(e){console.error("Failed to release agent:",e)}},[j.length,y,E]),tX=(0,n.useCallback)(e=>{eM(e)},[]);(0,n.useEffect)(()=>{if(!e1)return;let e=async()=>{let e=await ra.hi.getFleetServers();e.success&&e.data&&e4(e.data.servers.map(e=>({id:e.id,name:e.name,url:"local"===e.id?window.location.origin:"http://".concat(e.id),status:"healthy"===e.status?"online":"degraded"===e.status?"degraded":"offline",agentCount:e.agents.length,uptime:e.uptime,lastSeen:e.lastHeartbeat})))};e();let t=setInterval(e,5e3);return()=>clearInterval(t)},[e1]),(0,n.useEffect)(()=>{if(!eX)return;let e=async()=>{let e=await ra.hi.getDecisions();e.success&&e.data&&eZ(e.data.decisions.map(ra.XP))};e();let t=setInterval(e,5e3);return()=>clearInterval(t)},[eX]);let tY=(0,n.useCallback)(async(e,t)=>{e0(t=>({...t,[e]:!0}));try{let r=await ra.hi.approveDecision(e,t);r.success?eZ(t=>t.filter(t=>t.id!==e)):console.error("Failed to approve decision:",r.error)}catch(e){console.error("Failed to approve decision:",e)}finally{e0(t=>({...t,[e]:!1}))}},[]),t$=(0,n.useCallback)(async(e,t)=>{e0(t=>({...t,[e]:!0}));try{let r=await ra.hi.rejectDecision(e,t);r.success?eZ(t=>t.filter(t=>t.id!==e)):console.error("Failed to reject decision:",r.error)}catch(e){console.error("Failed to reject decision:",e)}finally{e0(t=>({...t,[e]:!1}))}},[]),tZ=(0,n.useCallback)(async e=>{(await ra.hi.dismissDecision(e)).success&&eZ(t=>t.filter(t=>t.id!==e))},[]),tQ=(0,n.useCallback)(async e=>{e7(!0);try{var t;let r=eG[e.priority].beadsPriority,s=await ra.hi.createBead({title:e.title,assignee:e.agentName,priority:r,type:"task"});if(s.success&&(null===(t=s.data)||void 0===t?void 0:t.bead))await ra.hi.sendRelayMessage({to:e.agentName,content:'\uD83D\uDCCB New task assigned: "'.concat(e.title,'" (P').concat(r,")\nCheck `bd ready` for details.")}),console.log("Task created:",s.data.bead.id);else throw console.error("Failed to create task bead:",s.error),Error(s.error||"Failed to create task")}catch(e){throw console.error("Failed to create task:",e),e}finally{e7(!1)}},[]),t0=(0,n.useCallback)(()=>{eb(!0)},[]),t2=(0,n.useCallback)(()=>{eb(!1)},[]);return n.useEffect(()=>{let e=e=>{let t;t="system"===e?window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light":e,document.documentElement.setAttribute("data-theme",t)};if(e(ey.theme),"system"===ey.theme){let t=window.matchMedia("(prefers-color-scheme: dark)"),r=()=>e("system");return t.addEventListener("change",r),()=>t.removeEventListener("change",r)}},[ey.theme]),n.useEffect(()=>{let e=e=>{(e.metaKey||e.ctrlKey)&&"k"===e.key&&(e.preventDefault(),eb(!0)),(e.metaKey||e.ctrlKey)&&e.shiftKey&&"s"===e.key&&(e.preventDefault(),tF()),(e.metaKey||e.ctrlKey)&&"n"===e.key&&(e.preventDefault(),tV()),"Escape"===e.key&&(eb(!1),es(!1),eE(!1),eR(!1),eN(!1))};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[tF,tV]),(0,s.jsx)(rI,{wsUrl:h,children:(0,s.jsxs)("div",{className:"flex h-screen bg-bg-deep font-sans text-text-primary",children:[(0,s.jsx)("div",{className:"\n fixed inset-0 bg-black/60 backdrop-blur-sm z-[999] transition-opacity duration-200\n md:hidden\n ".concat(te?"opacity-100 pointer-events-auto":"opacity-0 pointer-events-none","\n "),onClick:()=>tr(!1)}),(0,s.jsxs)("div",{className:"\n flex flex-col w-[280px] max-md:w-[85vw] max-md:max-w-[280px] h-screen bg-bg-primary border-r border-border-subtle\n fixed left-0 top-0 z-[1000] transition-transform duration-200\n md:relative md:translate-x-0 md:flex-shrink-0\n ".concat(te?"translate-x-0":"-translate-x-full","\n "),children:[(0,s.jsx)("div",{className:"p-3 border-b border-sidebar-border",children:(0,s.jsx)(rN,{workspaces:U,activeWorkspaceId:null!=F?F:void 0,onSelect:z,onAddWorkspace:()=>ed(!0),onWorkspaceSettings:tz,isLoading:O})}),(0,s.jsx)(H,{agents:tB,bridgeAgents:tT,projects:tP,currentProject:ee,selectedAgent:null==tx?void 0:tx.name,viewMode:Y,isFleetAvailable:tD,isConnected:b||w,isOpen:te,activeThreads:tC,currentThread:tN,totalUnreadThreadCount:tS,onAgentSelect:tU,onProjectSelect:tI,onViewModeChange:$,onSpawnClick:tF,onReleaseClick:tq,onLogsClick:tX,onThreadSelect:tk,onClose:()=>tr(!1),onSettingsClick:tO})]}),(0,s.jsxs)("main",{className:"flex-1 flex flex-col min-w-0 bg-bg-secondary/50 overflow-hidden",children:[(0,s.jsxs)("div",{className:"sticky top-0 z-50 flex-shrink-0",children:[(0,s.jsx)(em,{currentChannel:tv,selectedAgent:tx,projects:tP,currentProject:tP.find(e=>e.id===ee)||null,recentProjects:eV(tP),onProjectChange:tI,onCommandPaletteOpen:t0,onSettingsClick:tO,onHistoryClick:tH,onNewConversationClick:tV,onCoordinatorClick:tG,onFleetClick:()=>e2(!e1),isFleetViewActive:e1,onTrajectoryClick:()=>eR(!0),hasActiveTrajectory:null==eB?void 0:eB.active,onMenuClick:()=>tr(!0),hasUnreadNotifications:ts}),D&&V.length>0&&(0,s.jsx)("div",{className:"flex items-center justify-end px-4 py-1 bg-bg-tertiary/80 border-b border-border-subtle",children:(0,s.jsx)(sM,{onlineUsers:V,onUserClick:X})})]}),(0,s.jsxs)("div",{className:"flex-1 flex overflow-hidden min-h-0",children:[(0,s.jsx)("div",{className:"flex-1 min-h-0 overflow-y-auto ".concat(tN?"hidden md:block md:flex-[2]":""),children:f?(0,s.jsxs)("div",{className:"flex flex-col items-center justify-center h-full text-text-muted text-center px-4",children:[(0,s.jsx)(s$,{}),(0,s.jsx)("h2",{className:"m-0 mb-2 font-display text-text-primary",children:"Connection Error"}),(0,s.jsx)("p",{className:"text-text-secondary",children:f.message}),(0,s.jsx)("button",{className:"mt-6 py-3 px-6 bg-gradient-to-r from-accent-cyan to-[#00b8d9] text-bg-deep font-semibold border-none rounded-xl cursor-pointer transition-all duration-150 hover:shadow-glow-cyan hover:-translate-y-0.5",onClick:()=>window.location.reload(),children:"Retry Connection"})]}):g?e1?(0,s.jsx)("div",{className:"p-4 h-full overflow-y-auto",children:(0,s.jsx)(sC,{servers:e5,agents:tl,selectedServerId:e3,onServerSelect:e8,onServerReconnect:e=>{console.log("Reconnecting to server:",e)},isLoading:!g})}):(0,s.jsx)(eW,{messages:tj,currentChannel:tv,currentThread:tN,onThreadClick:e=>tk(e),highlightedMessageId:null!=tN?tN:void 0,agents:null==g?void 0:g.agents,currentUser:D}):(0,s.jsxs)("div",{className:"flex flex-col items-center justify-center h-full text-text-muted text-center",children:[(0,s.jsx)(sY,{}),(0,s.jsx)("p",{className:"font-display text-text-secondary",children:"Connecting to dashboard..."})]})}),tN&&(()=>{let e=tj.find(e=>e.id===tN),t=!e;if(!e){var r;e=null!==(r=tj.filter(e=>e.thread===tN).sort((e,t)=>new Date(e.timestamp).getTime()-new Date(t.timestamp).getTime())[0])&&void 0!==r?r:null}return(0,s.jsx)("div",{className:"w-full md:w-[400px] md:min-w-[320px] md:max-w-[500px] flex-shrink-0",children:(0,s.jsx)(eU,{originalMessage:null!=e?e:null,replies:ty(tN),onClose:()=>tk(null),onReply:async r=>{let s="*";return!t&&e&&(s="Dashboard"===e.from||D&&e.from===D.displayName?e.to:e.from),tA(s,r,tN)},isSending:tL,currentUser:D})})})()]}),G.length>0&&(0,s.jsx)("div",{className:"px-4 bg-bg-tertiary border-t border-border-subtle",children:(0,s.jsx)(sD,{typingUsers:G})}),(0,s.jsx)("div",{className:"p-4 bg-bg-tertiary border-t border-border-subtle",children:(0,s.jsx)(sX,{recipient:"general"===tv?"*":tv,agents:tl,humanUsers:tW,onSend:tA,onTyping:K,isSending:tL,error:tE})})]}),(0,s.jsx)(eK,{isOpen:eg,onClose:t2,agents:tl,projects:Z,currentProject:ee,onAgentSelect:tU,onProjectSelect:tI,onSpawnClick:tF,onTaskCreate:tQ,onGeneralClick:()=>{tm(null),tw("general")}}),(0,s.jsx)(e6,{isOpen:er,onClose:()=>es(!1),onSpawn:tJ,existingAgents:tl.map(e=>e.name),isSpawning:ea,error:ei}),(0,s.jsx)(tu,{isOpen:ef,onClose:()=>ej(!1),settings:ey,onSettingsChange:ev,onResetSettings:()=>ev(td),csrfToken:null!==(m=null==W?void 0:W.csrfToken)&&void 0!==m?m:void 0}),(0,s.jsx)(rW,{isOpen:ec,onClose:()=>{ed(!1),ep(null)},onAdd:t_,isAdding:ex,error:eh}),(0,s.jsx)(ro,{isOpen:eS,onClose:()=>eA(!1)}),(0,s.jsx)(tt,{isOpen:eL,onClose:()=>eE(!1),onSend:tK,agents:tl,isSending:tL,error:tE}),eD&&(0,s.jsx)(r1,{agent:eD,isOpen:!0,onClose:()=>eM(null),availableAgents:tl,onAgentChange:eM}),eT&&(0,s.jsx)("div",{className:"fixed inset-0 z-50 flex bg-black/50 backdrop-blur-sm",onClick:()=>eR(!1),children:(0,s.jsxs)("div",{className:"ml-auto w-full max-w-3xl h-full bg-bg-primary shadow-2xl animate-in slide-in-from-right duration-300 flex flex-col",onClick:e=>e.stopPropagation(),children:[(0,s.jsxs)("div",{className:"flex items-center justify-between px-6 py-4 border-b border-border-subtle bg-bg-secondary",children:[(0,s.jsxs)("div",{className:"flex items-center gap-3",children:[(0,s.jsx)("div",{className:"w-10 h-10 rounded-xl bg-gradient-to-br from-blue-500/20 to-accent-cyan/20 flex items-center justify-center border border-blue-500/30",children:(0,s.jsx)("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",className:"text-blue-500",children:(0,s.jsx)("path",{d:"M3 12h4l3 9 4-18 3 9h4",strokeLinecap:"round",strokeLinejoin:"round"})})}),(0,s.jsxs)("div",{children:[(0,s.jsx)("h2",{className:"text-lg font-semibold text-text-primary m-0",children:"Trajectory Viewer"}),(0,s.jsx)("p",{className:"text-xs text-text-muted m-0",children:(null==eB?void 0:eB.active)?"Active: ".concat(eB.task||"Working..."):"Browse past trajectories"})]})]}),(0,s.jsx)("button",{onClick:()=>eR(!1),className:"w-10 h-10 rounded-lg bg-bg-tertiary border border-border-subtle flex items-center justify-center text-text-muted hover:text-text-primary hover:bg-bg-hover hover:border-blue-500/50 transition-all",title:"Close (Esc)",children:(0,s.jsx)("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:(0,s.jsx)("path",{d:"M18 6L6 18M6 6l12 12"})})})]}),(0,s.jsx)("div",{className:"flex-1 overflow-hidden p-6",children:(0,s.jsx)(se,{agentName:(null==eB?void 0:null===(i=eB.task)||void 0===i?void 0:i.slice(0,30))||"Current",steps:eP,history:e_,selectedTrajectoryId:eO,onSelectTrajectory:eF,isLoading:eI})})]})}),eX&&(0,s.jsx)("div",{className:"fixed left-4 bottom-4 w-[400px] max-h-[500px] z-50 shadow-modal",children:(0,s.jsxs)("div",{className:"relative",children:[(0,s.jsx)("button",{onClick:()=>eY(!1),className:"absolute -top-2 -right-2 w-6 h-6 bg-bg-elevated border border-border rounded-full flex items-center justify-center text-text-muted hover:text-text-primary hover:bg-bg-hover z-10",title:"Close decisions",children:(0,s.jsx)("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:(0,s.jsx)("path",{d:"M18 6L6 18M6 6l12 12"})})}),(0,s.jsx)(sh,{decisions:e$,onApprove:tY,onReject:t$,onDismiss:tZ,isProcessing:eQ})]})}),!eX&&e$.length>0&&(0,s.jsxs)("button",{onClick:()=>eY(!0),className:"fixed left-4 bottom-4 w-12 h-12 bg-warning text-bg-deep rounded-full shadow-[0_0_20px_rgba(255,107,53,0.4)] flex items-center justify-center hover:scale-105 transition-transform z-50",title:"".concat(e$.length," pending decision").concat(e$.length>1?"s":""),children:[(0,s.jsxs)("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[(0,s.jsx)("circle",{cx:"12",cy:"12",r:"10"}),(0,s.jsx)("line",{x1:"12",y1:"8",x2:"12",y2:"12"}),(0,s.jsx)("line",{x1:"12",y1:"16",x2:"12.01",y2:"16"})]}),e$.length>0&&(0,s.jsx)("span",{className:"absolute -top-1 -right-1 w-5 h-5 bg-error text-white text-[10px] font-bold rounded-full flex items-center justify-center",children:e$.length})]}),(0,s.jsx)(sT,{user:q,onClose:()=>X(null),onMention:e=>{X(null)}}),(0,s.jsx)(sP,{isOpen:eJ,onClose:()=>eq(!1),projects:tP,isCloudMode:!!D,hasArchitect:tT.some(e=>"architect"===e.name.toLowerCase()),onArchitectSpawned:()=>{eq(!1)}}),ew&&(0,s.jsx)(t1,{currentUserId:null==W?void 0:null===(l=W.user)||void 0===l?void 0:l.id,initialTab:ek,onClose:()=>eN(!1)})]})})}function sX(e){let{recipient:t,agents:r,humanUsers:a,onSend:o,onTyping:i,isSending:l,error:c}=e,[d,x]=(0,n.useState)(""),[u,m]=(0,n.useState)(0),[h,p]=(0,n.useState)(!1),[g,b]=(0,n.useState)(!1),[f,j]=(0,n.useState)([]),y=(0,n.useRef)(null),v=(0,n.useRef)(null),w=(0,n.useCallback)(async e=>{for(let t of e){let e=crypto.randomUUID(),r=URL.createObjectURL(t);j(s=>[...s,{id:e,file:t,preview:r,isUploading:!0}]);try{let r=await ra.hi.uploadAttachment(t);r.success&&r.data?j(t=>t.map(t=>t.id===e?{...t,isUploading:!1,uploadedId:r.data.attachment.id}:t)):j(t=>t.map(t=>t.id===e?{...t,isUploading:!1,error:r.error||"Upload failed"}:t))}catch(t){j(t=>t.map(t=>t.id===e?{...t,isUploading:!1,error:"Upload failed"}:t))}}},[]),N=(0,n.useCallback)(e=>{if(!e||0===e.length)return;let t=Array.from(e).filter(e=>e.type.startsWith("image/"));t.length>0&&w(t)},[w]),k=(0,n.useCallback)(e=>{let t=e.clipboardData;if(!t)return;let r=[];if(t.files&&t.files.length>0&&(r=Array.from(t.files).filter(e=>e.type.startsWith("image/"))),0===r.length&&t.items){for(let e of Array.from(t.items))if("file"===e.kind&&e.type.startsWith("image/")){let t=e.getAsFile();t&&r.push(t)}}r.length>0&&(e.preventDefault(),w(r))},[w]),C=(0,n.useCallback)(e=>{j(t=>{let r=t.find(t=>t.id===e);return r&&URL.revokeObjectURL(r.preview),t.filter(t=>t.id!==e)})},[]),S=async e=>{let r,s;e.preventDefault();let n=d.trim().length>0,a=f.length>0;if(!n&&!a||l||f.some(e=>e.isUploading))return;let i=f.filter(e=>e.uploadedId).map(e=>e.uploadedId),c=d.match(/^@(\S+)\s*([\s\S]*)/);if(c){let e=c[1];s=c[2]||"","*"===e||"everyone"===e.toLowerCase()||"all"===e.toLowerCase()?r="*":e.toLowerCase().startsWith("team:")?r=e:e.includes("/")||/\.(ts|tsx|js|jsx|json|md|py|go|rs|java|c|cpp|h|css|html|yaml|yml|toml)$/i.test(e)?(r=t,s=d):r=e}else r=t,s=d;!s.trim()&&i.length>0&&(s="[Screenshot attached]"),await o(r,s||d,void 0,i.length>0?i:void 0)&&(f.forEach(e=>URL.revokeObjectURL(e.preview)),x(""),j([]),p(!1),b(!1))},A=(d.trim()||f.length>0)&&!l&&!f.some(e=>e.isUploading);return(0,s.jsxs)("form",{className:"flex flex-col gap-2",onSubmit:S,children:[f.length>0&&(0,s.jsx)("div",{className:"flex flex-wrap gap-2 p-2 bg-bg-card rounded-lg border border-border-subtle",children:f.map(e=>(0,s.jsxs)("div",{className:"relative group",children:[(0,s.jsx)("img",{src:e.preview,alt:e.file.name,className:"h-16 w-auto rounded-lg object-cover ".concat(e.isUploading?"opacity-50":""," ").concat(e.error?"border-2 border-error":"")}),e.isUploading&&(0,s.jsx)("div",{className:"absolute inset-0 flex items-center justify-center",children:(0,s.jsx)("svg",{className:"animate-spin h-5 w-5 text-accent-cyan",viewBox:"0 0 24 24",children:(0,s.jsx)("circle",{cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"2",fill:"none",strokeDasharray:"32",strokeLinecap:"round"})})}),e.error&&(0,s.jsx)("div",{className:"absolute bottom-0 left-0 right-0 bg-error/90 text-white text-[10px] px-1 py-0.5 truncate",children:e.error}),(0,s.jsx)("button",{type:"button",onClick:()=>C(e.id),className:"absolute -top-1.5 -right-1.5 w-5 h-5 bg-bg-tertiary border border-border-subtle rounded-full flex items-center justify-center text-text-muted hover:text-error hover:border-error transition-colors opacity-0 group-hover:opacity-100",title:"Remove",children:(0,s.jsxs)("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",children:[(0,s.jsx)("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),(0,s.jsx)("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]},e.id))}),(0,s.jsxs)("div",{className:"flex items-center gap-3",children:[(0,s.jsx)("input",{ref:v,type:"file",accept:"image/*",multiple:!0,className:"hidden",onChange:e=>N(e.target.files)}),(0,s.jsx)("button",{type:"button",onClick:()=>{var e;return null===(e=v.current)||void 0===e?void 0:e.click()},className:"p-2.5 bg-bg-card border border-border-subtle rounded-xl text-text-muted hover:text-accent-cyan hover:border-accent-cyan/50 transition-colors",title:"Attach screenshot (or paste from clipboard)",children:(0,s.jsxs)("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,s.jsx)("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",ry:"2"}),(0,s.jsx)("circle",{cx:"8.5",cy:"8.5",r:"1.5"}),(0,s.jsx)("polyline",{points:"21 15 16 10 5 21"})]})}),(0,s.jsxs)("div",{className:"flex-1 relative",children:[(0,s.jsx)(rf,{agents:r,humanUsers:a,inputValue:d,cursorPosition:u,onSelect:(e,t)=>{x(t),p(!1),b(!1),setTimeout(()=>{if(y.current){y.current.focus();let e=t.indexOf(" ")+1;y.current.setSelectionRange(e,e)}},0)},onClose:()=>p(!1),isVisible:h}),(0,s.jsx)(rw,{inputValue:d,cursorPosition:u,onSelect:(e,t)=>{x(t),b(!1),p(!1),setTimeout(()=>{if(y.current){y.current.focus();let e=t.indexOf(" ",1)+1;y.current.setSelectionRange(e,e)}},0)},onClose:()=>b(!1),isVisible:g}),(0,s.jsx)("textarea",{ref:y,className:"w-full py-3 px-4 bg-bg-card border border-border-subtle rounded-xl text-sm font-sans text-text-primary outline-none transition-all duration-200 resize-none min-h-[44px] max-h-[120px] overflow-y-auto focus:border-accent-cyan/50 focus:shadow-[0_0_0_3px_rgba(0,217,255,0.1)] placeholder:text-text-muted",placeholder:"Message ".concat("*"===t?"everyone":"@"+t,"... (@ for agents/files)"),value:d,onChange:e=>{let t=e.target.value,r=e.target.selectionStart||0;if(x(t),m(r),null==i||i(t.trim().length>0),null!==rj(t,r)){b(!0),p(!1);return}if(null!==rg(t,r)){p(!0),b(!1);return}p(!1),b(!1)},onKeyDown:e=>{(!h&&!g||"ArrowDown"!==e.key&&"ArrowUp"!==e.key&&"Tab"!==e.key)&&("Enter"!==e.key||e.shiftKey||h||g||(e.preventDefault(),(d.trim()||f.length>0)&&!l&&S(e)))},onPaste:k,onSelect:e=>m(e.target.selectionStart||0),disabled:l,rows:1})]}),(0,s.jsx)("button",{type:"submit",className:"py-3 px-5 bg-gradient-to-r from-accent-cyan to-[#00b8d9] text-bg-deep font-semibold border-none rounded-xl text-sm cursor-pointer transition-all duration-150 hover:shadow-glow-cyan hover:-translate-y-0.5 disabled:opacity-50 disabled:cursor-not-allowed disabled:hover:translate-y-0 disabled:hover:shadow-none",disabled:!A,title:l?"Sending...":f.some(e=>e.isUploading)?"Uploading...":"Send message",children:l?(0,s.jsx)("span",{children:"Sending..."}):f.some(e=>e.isUploading)?(0,s.jsx)("span",{children:"Uploading..."}):(0,s.jsxs)("span",{className:"flex items-center gap-2",children:["Send",(0,s.jsxs)("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[(0,s.jsx)("line",{x1:"22",y1:"2",x2:"11",y2:"13"}),(0,s.jsx)("polygon",{points:"22 2 15 22 11 13 2 9 22 2"})]})]})}),c&&(0,s.jsx)("span",{className:"text-error text-xs ml-2",children:c})]})]})}function sY(){return(0,s.jsx)("svg",{className:"animate-spin mb-4 text-accent-cyan",width:"28",height:"28",viewBox:"0 0 24 24",children:(0,s.jsx)("circle",{cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"2",fill:"none",strokeDasharray:"32",strokeLinecap:"round"})})}function s$(){return(0,s.jsxs)("svg",{className:"text-error mb-4",width:"48",height:"48",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[(0,s.jsx)("circle",{cx:"12",cy:"12",r:"10"}),(0,s.jsx)("line",{x1:"12",y1:"8",x2:"12",y2:"12"}),(0,s.jsx)("line",{x1:"12",y1:"16",x2:"12.01",y2:"16"})]})}},5372:function(e,t,r){r.d(t,{TI:function(){return c},uo:function(){return d}});var s=r(7437),n=r(2265),a=r(9165);let o={checkOnMount:!0,checkInterval:6e4,onExpired:()=>{}};function i(e){let{isOpen:t,error:r,onLogin:n,onDismiss:a}=e;return t?(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("div",{className:"fixed inset-0 bg-black/60 backdrop-blur-sm z-[9998]",onClick:a,"aria-hidden":"true"}),(0,s.jsx)("div",{className:"fixed inset-0 flex items-center justify-center z-[9999] p-4",role:"dialog","aria-modal":"true","aria-labelledby":"session-expired-title",children:(0,s.jsxs)("div",{className:"bg-bg-primary rounded-lg shadow-xl max-w-md w-full p-6 animate-in fade-in zoom-in-95 duration-200",children:[(0,s.jsx)("div",{className:"flex justify-center mb-4",children:(0,s.jsx)("div",{className:"w-16 h-16 rounded-full bg-warning/10 flex items-center justify-center",children:(0,s.jsx)("svg",{className:"w-8 h-8 text-warning",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:2,children:(0,s.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"})})})}),(0,s.jsx)("h2",{id:"session-expired-title",className:"text-xl font-semibold text-text-primary text-center mb-2",children:"Session Expired"}),(0,s.jsx)("p",{className:"text-text-muted text-center mb-6",children:(()=>{if(!r)return"Your session has expired. Please log in again to continue.";switch(r.code){case"SESSION_EXPIRED":return"Your session has expired. Please log in again to continue.";case"USER_NOT_FOUND":return"Your account was not found. Please log in again.";case"SESSION_ERROR":return"There was a problem with your session. Please log in again.";default:return r.message||"Your session has expired. Please log in again."}})()}),(0,s.jsxs)("div",{className:"flex flex-col gap-3",children:[(0,s.jsx)("button",{onClick:n,className:"w-full py-3 px-4 bg-accent text-white font-medium rounded-lg hover:bg-accent-hover transition-colors duration-200 focus:outline-none focus:ring-2 focus:ring-accent focus:ring-offset-2 focus:ring-offset-bg-primary",children:"Log In Again"}),a&&(0,s.jsx)("button",{onClick:a,className:"w-full py-3 px-4 text-text-muted hover:text-text-primary font-medium rounded-lg transition-colors duration-200 hover:bg-bg-secondary",children:"Dismiss"})]}),(0,s.jsx)("p",{className:"text-xs text-text-muted text-center mt-4",children:"You'll be redirected to the login page where you can sign in with GitHub."})]})})]}):null}let l=(0,n.createContext)(void 0);function c(e){let{children:t,cloudMode:r,checkInterval:c=6e4,onSessionExpired:d}=e,x=null!=r?r:function(){let e=window.location.hostname;if(e.includes("agent-relay.com")||e.includes("agentrelay.cloud"))return!0;let t=document.querySelector('meta[name="agent-relay-cloud"]');return(null==t?void 0:t.getAttribute("content"))==="true"||"true"===localStorage.getItem("agent-relay-cloud-mode")}(),u=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t={...o,...e},[r,s]=(0,n.useState)(null),[i,l]=(0,n.useState)(!0),[c,d]=(0,n.useState)(!1),[x,u]=(0,n.useState)(null),m=(0,n.useRef)(null),h=(0,n.useRef)(!0),p=(0,n.useCallback)(async()=>{try{let e=await a.xv.checkSession();if(!h.current)return e;if(!e.authenticated&&(s(null),e.code)){let r={error:"Session expired",code:e.code,message:e.message||"Your session has expired. Please log in again."};u(r),d(!0),t.onExpired(r)}return e}catch(e){return{authenticated:!1,code:"SESSION_ERROR",message:"Failed to check session"}}},[t]),g=(0,n.useCallback)(async()=>{l(!0);try{let e=await a.xv.getMe();if(!h.current)return;e.success?(s(e.data),d(!1),u(null)):e.sessionExpired?(s(null),d(!0)):u({error:e.error,code:"SESSION_ERROR",message:e.error})}finally{h.current&&l(!1)}},[]);(0,n.useEffect)(()=>(0,a.Zk)(e=>{h.current&&(s(null),d(!0),u(e),t.onExpired(e))}),[t]),(0,n.useEffect)(()=>(h.current=!0,t.checkOnMount&&g(),()=>{h.current=!1}),[t.checkOnMount,g]),(0,n.useEffect)(()=>{if(!(t.checkInterval<=0))return m.current=setInterval(()=>{r&&p()},t.checkInterval),()=>{m.current&&(clearInterval(m.current),m.current=null)}},[t.checkInterval,r,p]);let b=(0,n.useCallback)(()=>{d(!1),u(null)},[]),f=(0,n.useCallback)(()=>{let e=encodeURIComponent(window.location.pathname+window.location.search);window.location.href="/login?returnTo=".concat(e)},[]),j=(0,n.useCallback)(async()=>{await a.xv.logout(),s(null),d(!1),u(null),window.location.href="/login"},[]);return{user:r,isLoading:i,isAuthenticated:null!==r,isExpired:c,error:x,csrfToken:(0,a._V)(),checkSession:p,clearExpired:b,redirectToLogin:f,logout:j}}({checkOnMount:x,checkInterval:x?c:0,onExpired:d}),m=(0,n.useCallback)(()=>{u.redirectToLogin()},[u]),h=(0,n.useCallback)(()=>{u.clearExpired()},[u]),p={...u,isCloudMode:x};return(0,s.jsxs)(l.Provider,{value:p,children:[t,x&&(0,s.jsx)(i,{isOpen:u.isExpired,error:u.error,onLogin:m,onDismiss:h})]})}function d(){return(0,n.useContext)(l)}},6272:function(e,t,r){r.d(t,{K7:function(){return n}});var s=r(7437);function n(e){let{size:t=24,className:r="",withGlow:n=!1}=e;return(0,s.jsxs)("svg",{width:t,height:t,viewBox:"0 0 100 100",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"\n transition-all duration-300\n ".concat(n?"drop-shadow-[0_0_8px_rgba(0,217,255,0.3)]":"","\n ").concat(r,"\n "),"aria-label":"Agent Relay Logo",role:"img",children:[(0,s.jsx)("path",{d:"M30 80 L 50 20 L 70 80",stroke:"#00d9ff",strokeWidth:"5",strokeLinejoin:"round",strokeLinecap:"round",fill:"none"}),(0,s.jsx)("line",{x1:"40",y1:"50",x2:"60",y2:"50",stroke:"#00d9ff",strokeWidth:"5",strokeLinecap:"round"}),(0,s.jsx)("path",{d:"M50 20 L 50 80",stroke:"#00ffc8",strokeWidth:"2.5",strokeLinecap:"round",opacity:"0.7"}),(0,s.jsx)("path",{d:"M50 20 C 80 20 80 50 50 50 L 80 80",stroke:"#00ffc8",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",fill:"none",opacity:"0.7"})]})}r(2265)},3083:function(e,t,r){r.d(t,{j:function(){return o}});var s=r(7437),n=r(2265);let a={codex:"openai"};function o(e){let{provider:t,workspaceId:r,csrfToken:o,onSuccess:i,onCancel:l,onError:c,useDeviceFlow:d=!1}=e,[x,u]=(0,n.useState)("idle"),[m,h]=(0,n.useState)(null),[p,g]=(0,n.useState)(null),[b,f]=(0,n.useState)(""),[j,y]=(0,n.useState)(null),v=(0,n.useRef)(!1),w=(0,n.useRef)(!1),N=a[t.id]||t.id,k=(0,n.useCallback)(async()=>{u("starting"),y(null),v.current=!1;try{let e={"Content-Type":"application/json"};o&&(e["X-CSRF-Token"]=o);let t=await fetch("/api/onboarding/cli/".concat(N,"/start"),{method:"POST",credentials:"include",headers:e,body:JSON.stringify({workspaceId:r,useDeviceFlow:d})}),s=await t.json();if(!t.ok)throw Error(s.error||"Failed to start authentication");if("success"===s.status||s.alreadyAuthenticated){u("success"),i();return}g(s.sessionId),s.authUrl?(h(s.authUrl),u("waiting"),C(s.authUrl),S(s.sessionId)):s.sessionId&&S(s.sessionId)}catch(t){let e=t instanceof Error?t.message:"Failed to start authentication";y(e),u("error"),c(e)}},[N,r,o,d,i,c]),C=(0,n.useCallback)(e=>{let r=window.screenX+(window.outerWidth-600)/2,s=window.screenY+(window.outerHeight-700)/2;window.open(e,"".concat(t.displayName," Login"),"width=".concat(600,",height=").concat(700,",left=").concat(r,",top=").concat(s,",popup=yes")),v.current=!0},[t.displayName]),S=(0,n.useCallback)(e=>{if(w.current)return;w.current=!0;let t=0,r=async()=>{if(t>=60){w.current=!1,y("Authentication timed out. Please try again."),u("error"),c("Authentication timed out");return}try{let s=await fetch("/api/onboarding/cli/".concat(N,"/status/").concat(e),{credentials:"include"}),n=await s.json();if(!s.ok)throw Error(n.error||"Failed to check status");if("success"===n.status){w.current=!1,await A(e);return}if("error"===n.status)throw Error(n.error||"Authentication failed");"waiting_auth"===n.status&&n.authUrl&&(h(n.authUrl),u("waiting"),v.current||C(n.authUrl)),t++,setTimeout(r,5e3)}catch(t){w.current=!1;let e=t instanceof Error?t.message:"Auth check failed";y(e),u("error"),c(e)}};r()},[N,C,c]),A=(0,n.useCallback)(async e=>{let t=e||p;if(t){u("submitting"),y(null);try{let e={"Content-Type":"application/json"};o&&(e["X-CSRF-Token"]=o);let r=await fetch("/api/onboarding/cli/".concat(N,"/complete/").concat(t),{method:"POST",credentials:"include",headers:e}),s=await r.json();if(!r.ok)throw Error(s.error||"Failed to complete authentication");u("success"),setTimeout(()=>i(),1500)}catch(t){let e=t instanceof Error?t.message:"Failed to complete authentication";y(e),u("error"),c(e)}}},[p,N,o,i,c]),L=(0,n.useCallback)(async()=>{if(!p||!b.trim())return;u("submitting"),y(null);let e=b.trim();if(e.includes("code="))try{let t=new URL(e).searchParams.get("code");t&&(e=t)}catch(r){let t=e.match(/code=([^&\s]+)/);t&&(e=t[1])}try{let t={"Content-Type":"application/json"};o&&(t["X-CSRF-Token"]=o);let r=await fetch("/api/onboarding/cli/".concat(N,"/code/").concat(p),{method:"POST",credentials:"include",headers:t,body:JSON.stringify({code:e})}),s=await r.json();if(!r.ok){if(s.needsRestart){y('The authentication session timed out. Please click "Try Again" to restart.'),u("error");return}throw Error(s.error||"Failed to submit auth code")}f(""),s.success&&await A()}catch(t){let e=t instanceof Error?t.message:"Failed to submit auth code";y(e),u("error"),c(e)}},[p,b,N,o,A,c]),E=(0,n.useCallback)(async()=>{if(w.current=!1,p)try{await fetch("/api/onboarding/cli/".concat(N,"/cancel/").concat(p),{method:"POST",credentials:"include"})}catch(e){}u("idle"),h(null),g(null),f(""),y(null),l()},[p,N,l]);(0,n.useEffect)(()=>("idle"===x&&k(),()=>{w.current=!1}),[k,x]);let W=t.requiresUrlCopy||"codex"===t.id||"openai"===N,D="anthropic"===t.id||"anthropic"===N;return(0,s.jsxs)("div",{className:"space-y-4",children:[(0,s.jsxs)("div",{className:"flex items-center gap-3",children:[(0,s.jsx)("div",{className:"w-10 h-10 rounded-lg flex items-center justify-center text-white font-bold",style:{backgroundColor:t.color},children:t.displayName[0]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("h3",{className:"font-medium text-white",children:t.displayName}),(0,s.jsxs)("p",{className:"text-sm text-text-muted",children:["starting"===x&&"Starting authentication...","waiting"===x&&"Complete authentication below","submitting"===x&&"Verifying...","success"===x&&"Connected!","error"===x&&(j||"Authentication failed")]})]})]}),"starting"===x&&(0,s.jsxs)("div",{className:"flex items-center justify-center gap-3 py-4",children:[(0,s.jsxs)("svg",{className:"w-5 h-5 text-accent-cyan animate-spin",fill:"none",viewBox:"0 0 24 24",children:[(0,s.jsx)("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),(0,s.jsx)("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),(0,s.jsx)("span",{className:"text-text-muted",children:"Preparing authentication..."})]}),"waiting"===x&&m&&(0,s.jsxs)("div",{className:"space-y-4",children:[(0,s.jsxs)("div",{className:"p-4 bg-bg-tertiary rounded-lg border border-border-subtle",children:[(0,s.jsx)("h4",{className:"font-medium text-white mb-2",children:"Complete authentication:"}),W?(0,s.jsxs)("ol",{className:"text-sm text-text-muted space-y-2 list-decimal list-inside",children:[(0,s.jsx)("li",{children:"Click the button below to open the login page"}),(0,s.jsxs)("li",{children:["Sign in with your ",t.displayName," account"]}),(0,s.jsxs)("li",{className:"text-amber-400",children:[(0,s.jsx)("strong",{children:"Important:"})," After signing in, you'll see a \"This site can't be reached\" error - this is expected!"]}),(0,s.jsxs)("li",{children:["Copy the ",(0,s.jsx)("strong",{children:"entire URL"})," from your browser's address bar (it starts with ",(0,s.jsx)("code",{className:"px-1 py-0.5 bg-bg-card rounded text-xs",children:"http://localhost..."}),")"]}),(0,s.jsx)("li",{children:"Paste it in the input below and click Submit"})]}):D?(0,s.jsxs)("ol",{className:"text-sm text-text-muted space-y-2 list-decimal list-inside",children:[(0,s.jsx)("li",{children:"Click the button below to open the login page"}),(0,s.jsx)("li",{children:"Sign in with your Anthropic account"}),(0,s.jsxs)("li",{children:["After signing in, Anthropic will display an ",(0,s.jsx)("strong",{children:"authentication code"})]}),(0,s.jsx)("li",{children:"Copy that code and paste it in the input below"}),(0,s.jsx)("li",{children:"Click Submit to complete authentication"})]}):(0,s.jsxs)("ol",{className:"text-sm text-text-muted space-y-2 list-decimal list-inside",children:[(0,s.jsx)("li",{children:"Click the button below to open the login page"}),(0,s.jsxs)("li",{children:["Sign in with your ",t.displayName," account"]}),(0,s.jsx)("li",{children:'If you receive a code, paste it below. Otherwise click "I\'ve completed login"'})]})]}),(0,s.jsxs)("a",{href:m,target:"_blank",rel:"noopener noreferrer",className:"block w-full py-3 px-4 bg-gradient-to-r from-accent-cyan to-[#00b8d9] text-bg-deep font-semibold rounded-xl text-center hover:shadow-glow-cyan transition-all",children:["Open ",t.displayName," Login Page"]}),W?(0,s.jsxs)("div",{className:"space-y-3",children:[(0,s.jsx)("div",{className:"p-3 bg-amber-500/10 border border-amber-500/30 rounded-lg",children:(0,s.jsxs)("p",{className:"text-xs text-amber-400",children:[(0,s.jsx)("strong",{children:"Expected behavior:"})," After login, you'll see \"This site can't be reached\" - this is normal! Copy the full URL from your browser's address bar and paste it below."]})}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)("input",{type:"text",placeholder:"Paste the localhost URL here (e.g., http://localhost:...)",value:b,onChange:e=>f(e.target.value),className:"flex-1 px-4 py-3 bg-bg-tertiary border border-border-subtle rounded-xl text-white placeholder-text-muted focus:outline-none focus:border-accent-cyan transition-colors font-mono text-sm",onKeyDown:e=>{"Enter"===e.key&&b.trim()&&L()}}),(0,s.jsx)("button",{onClick:L,disabled:!b.trim(),className:"px-6 py-3 bg-accent-cyan text-bg-deep font-semibold rounded-xl hover:bg-accent-cyan/90 disabled:opacity-50 disabled:cursor-not-allowed transition-all",children:"Submit"})]})]}):D?(0,s.jsxs)("div",{className:"space-y-3",children:[(0,s.jsx)("div",{className:"p-3 bg-accent-cyan/10 border border-accent-cyan/30 rounded-lg",children:(0,s.jsxs)("p",{className:"text-xs text-accent-cyan",children:[(0,s.jsx)("strong",{children:"Look for the code:"})," After signing in, Anthropic will show you an authentication code. Copy it and paste it below."]})}),(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)("input",{type:"text",placeholder:"Paste the authentication code here",value:b,onChange:e=>f(e.target.value),className:"flex-1 px-4 py-3 bg-bg-tertiary border border-border-subtle rounded-xl text-white placeholder-text-muted focus:outline-none focus:border-accent-cyan transition-colors font-mono text-sm",onKeyDown:e=>{"Enter"===e.key&&b.trim()&&L()}}),(0,s.jsx)("button",{onClick:L,disabled:!b.trim(),className:"px-6 py-3 bg-accent-cyan text-bg-deep font-semibold rounded-xl hover:bg-accent-cyan/90 disabled:opacity-50 disabled:cursor-not-allowed transition-all",children:"Submit"})]})]}):(0,s.jsxs)("div",{className:"space-y-3",children:[(0,s.jsxs)("div",{className:"flex gap-2",children:[(0,s.jsx)("input",{type:"text",placeholder:"Paste authentication code (if provided)",value:b,onChange:e=>f(e.target.value),className:"flex-1 px-4 py-3 bg-bg-tertiary border border-border-subtle rounded-xl text-white placeholder-text-muted focus:outline-none focus:border-accent-cyan transition-colors font-mono text-sm",onKeyDown:e=>{"Enter"===e.key&&b.trim()&&L()}}),(0,s.jsx)("button",{onClick:L,disabled:!b.trim(),className:"px-6 py-3 bg-accent-cyan text-bg-deep font-semibold rounded-xl hover:bg-accent-cyan/90 disabled:opacity-50 disabled:cursor-not-allowed transition-all",children:"Submit"})]}),(0,s.jsx)("button",{onClick:()=>A(),className:"w-full py-2 text-text-muted hover:text-white transition-colors text-sm",children:"No code? Click here if you've completed login"})]}),(0,s.jsx)("button",{onClick:E,className:"w-full py-2 text-text-muted hover:text-white transition-colors text-sm",children:"Cancel"})]}),"submitting"===x&&(0,s.jsxs)("div",{className:"flex items-center justify-center gap-3 py-4",children:[(0,s.jsxs)("svg",{className:"w-5 h-5 text-accent-cyan animate-spin",fill:"none",viewBox:"0 0 24 24",children:[(0,s.jsx)("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),(0,s.jsx)("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),(0,s.jsx)("span",{className:"text-text-muted",children:"Verifying authentication..."})]}),"success"===x&&(0,s.jsxs)("div",{className:"flex items-center justify-center gap-3 py-4",children:[(0,s.jsx)("div",{className:"w-10 h-10 bg-success/20 rounded-full flex items-center justify-center",children:(0,s.jsx)("svg",{className:"w-6 h-6 text-success",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:(0,s.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 13l4 4L19 7"})})}),(0,s.jsxs)("span",{className:"text-white font-medium",children:[t.displayName," connected!"]})]}),"error"===x&&(0,s.jsxs)("div",{className:"space-y-3",children:[(0,s.jsx)("div",{className:"p-4 bg-error/10 border border-error/30 rounded-lg text-error text-sm",children:j||"Authentication failed. Please try again."}),(0,s.jsxs)("div",{className:"flex gap-3",children:[(0,s.jsx)("button",{onClick:k,className:"flex-1 py-2 px-4 bg-bg-tertiary border border-border-subtle text-white rounded-lg hover:border-accent-cyan/50 transition-colors",children:"Try Again"}),(0,s.jsx)("button",{onClick:E,className:"py-2 px-4 text-text-muted hover:text-white transition-colors",children:"Cancel"})]})]})]})}}}]);
|