fifony 0.1.25 → 0.1.26-next.f3fade3

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 CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  **AI agents that actually ship code. You just watch.**
6
6
 
7
- Point at a repo. Open the dashboard. AI plans, builds, and reviews — you approve.
7
+ Point at a repo. Open the dashboard. AI plans, builds, and reviews — you approve and merge.
8
8
 
9
9
  [![License](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](LICENSE)
10
10
  [![Node](https://img.shields.io/badge/node-%3E%3D23-brightgreen.svg)]()
@@ -16,42 +16,60 @@ Point at a repo. Open the dashboard. AI plans, builds, and reviews — you appro
16
16
  ## Quick Start
17
17
 
18
18
  ```bash
19
- npx -y fifony --port 4040
19
+ npx -y fifony
20
20
  ```
21
21
 
22
- Open **http://localhost:4040**. The first run launches the onboarding wizard — it detects your CLIs, scans your project, and configures everything in six steps. State lives in `.fifony/`. No accounts, no cloud, no external database.
22
+ Open **http://localhost:4000**. The first run launches the onboarding wizard — it detects your CLIs, scans your project, and configures everything in six steps. State lives in `.fifony/`. No accounts, no cloud, no external database.
23
23
 
24
24
  ---
25
25
 
26
26
  ## How It Works
27
27
 
28
- fifony breaks every task into three stages, each independently configurable:
29
-
30
- ```
31
- Plan Execute Review
32
- ┌──────────────┐ ┌──────────────┐ ┌──────────────┐
33
- │ Claude │─▶│ Codex │─▶│ Claude │
34
- │ Opus 4.5 │ │ │ │ Sonnet 4.5 │
35
- │ effort: high │ │ effort: med │ │ effort: med │
36
- └──────────────┘ └──────────────┘ └──────────────┘
37
- ```
38
-
39
- You set the provider, model, and reasoning effort for each stage. Claude plans, Codex executes, Claude reviews — or any combination you prefer. Configure it in the Settings UI or drop a `WORKFLOW.md` in your project root.
28
+ fifony auto-detects your installed CLI tools (Claude, Codex, Gemini) and routes each pipeline stage to the best available provider. Configure per-stage provider, model, and reasoning effort in the Settings UI or drop a `WORKFLOW.md` in your project root.
40
29
 
41
30
  ### Issue Lifecycle
42
31
 
43
- ```
44
- Planning → Todo → Queued → Running → In Review → Done
45
- ↓ ↓
46
- Interrupted Blocked (retry with backoff)
32
+ ```mermaid
33
+ stateDiagram-v2
34
+ [*] --> Planning
35
+ Planning --> Planned: PLANNED
36
+ Planned --> Queued: QUEUE
37
+ Queued --> Running: RUN
38
+ Running --> Reviewing: REVIEW
39
+ Reviewing --> Reviewed: REVIEWED
40
+ Reviewed --> Done: DONE
41
+ Done --> Merged: MERGE
42
+
43
+ Running --> Blocked: BLOCK
44
+ Reviewing --> Blocked: BLOCK
45
+ Blocked --> Queued: UNBLOCK
46
+ Blocked --> Planning: REPLAN
47
+
48
+ Reviewed --> Queued: REQUEUE (rework)
49
+ Reviewed --> Planning: REPLAN
50
+
51
+ Done --> Planning: REOPEN
52
+ Merged --> Planning: REOPEN
53
+
54
+ Planning --> Cancelled: CANCEL
55
+ Planned --> Cancelled: CANCEL
56
+ Reviewed --> Cancelled: CANCEL
57
+ Blocked --> Cancelled: CANCEL
58
+ Cancelled --> Planning: REOPEN
59
+
60
+ Merged --> [*]
61
+ Cancelled --> [*]
47
62
  ```
48
63
 
49
- 1. **Create** Describe what you want done. fifony AI-enhances the title and description before planning.
50
- 2. **Plan** — The planner agent generates a structured execution plan: phases, steps, target files, complexity, risks.
51
- 3. **Approve** You review the plan. Optionally chat with the AI to refine it before approving.
52
- 4. **Execute** Agents run in an isolated workspace (a copy of your project). Live output streams to the dashboard.
53
- 5. **Review** The reviewer agent inspects the diff and either approves, requests rework, or blocks.
54
- 6. **Merge** You review the diff and merge the workspace back to your project root.
64
+ | Step | What happens |
65
+ |------|-------------|
66
+ | **Create** | Describe what you want done. |
67
+ | **Plan** | The planner agent generates a structured execution plan: phases, steps, target files, complexity, risks. |
68
+ | **Approve** | You review the plan. Optionally refine it with AI chat before approving. |
69
+ | **Execute** | Agents run in an isolated git worktree. Live output streams to the dashboard. |
70
+ | **Review** | The reviewer agent inspects the diff and either approves, requests rework, or blocks. |
71
+ | **Done** | Approved and waiting for merge. You review the diff in the dashboard. |
72
+ | **Merge** | You merge the worktree into your project. Analytics capture lines added/removed. |
55
73
 
56
74
  Agents run as detached child processes, tracked by PID. If the server restarts mid-run, fifony recovers on the next boot.
57
75
 
@@ -63,7 +81,7 @@ The first run walks you through six steps:
63
81
 
64
82
  | Step | What happens |
65
83
  |------|-------------|
66
- | CLI Detection | Finds `claude`, `codex`, `git`, `node`, `docker`, and other tools on your system |
84
+ | CLI Detection | Finds `claude`, `codex`, `gemini`, `git`, `node`, `docker`, and other tools on your system |
67
85
  | Project Scan | Detects language, stack, and build system — 18+ ecosystems supported |
68
86
  | AI Analysis | Uses the detected CLI to extract domain context from your codebase |
69
87
  | Domains | 21 options across Technical / Industry / Role, pre-selected by the AI |
@@ -72,16 +90,14 @@ The first run walks you through six steps:
72
90
 
73
91
  Settings are saved progressively and can be re-run from Settings at any time.
74
92
 
75
- Supported build files include: `package.json`, `Cargo.toml`, `pyproject.toml`, `go.mod`, `build.gradle`, `Gemfile`, `mix.exs`, `pubspec.yaml`, `CMakeLists.txt`, `composer.json`, `Package.swift`, `deno.json`, `pom.xml`, `Dockerfile`, and more.
76
-
77
93
  ---
78
94
 
79
95
  ## Dashboard
80
96
 
81
97
  | Route | What you see |
82
98
  |-------|-------------|
83
- | `/kanban` | Drag-and-drop board. Cards flow through pipeline stages. Desktop click+drag, mobile long-press. |
84
- | `/issues` | Searchable list with multi-state filters, sort options, and capability filters. Shows token usage and duration per issue. |
99
+ | `/kanban` | Drag-and-drop board with 5 columns: Planning, In Progress, Reviewing, Blocked, Done. |
100
+ | `/issues` | Searchable list with multi-state filters, sort options, and capability filters. |
85
101
  | `/agents` | Live cockpit: worker slots, queue depth, real-time log tail, token sparklines per agent. |
86
102
  | `/analytics` | Token usage trends, daily and weekly rollups, top issues by cost, per-model breakdown. |
87
103
  | `/settings` | General, Workflow pipeline config, Notifications, Providers. |
@@ -125,20 +141,20 @@ Agents install to `.claude/agents/` and `.codex/agents/` during onboarding. Skil
125
141
  ## CLI Reference
126
142
 
127
143
  ```bash
128
- # Dashboard + API + scheduler
129
- npx -y fifony --port 4040
144
+ # Dashboard + API (default port 4000)
145
+ npx -y fifony
130
146
 
131
- # With Vite HMR for frontend development
132
- npx -y fifony --port 4040 --dev
147
+ # Custom port
148
+ npx -y fifony --port 8080
133
149
 
134
- # Headless scheduler only, no UI
135
- npx -y fifony
150
+ # With Vite HMR for frontend development
151
+ npx -y fifony --dev
136
152
 
137
153
  # MCP server (stdio)
138
154
  npx -y fifony mcp
139
155
 
140
156
  # Different workspace
141
- npx -y fifony --workspace /path/to/repo --port 4040
157
+ npx -y fifony --workspace /path/to/repo
142
158
 
143
159
  # Run one scheduler cycle and exit
144
160
  npx -y fifony --once
@@ -187,7 +203,7 @@ Add to `claude_desktop_config.json` or VS Code settings:
187
203
 
188
204
  ## REST API
189
205
 
190
- Interactive docs at `http://localhost:4040/docs`.
206
+ Interactive docs at `http://localhost:4000/docs`.
191
207
 
192
208
  | Endpoint | Description |
193
209
  |----------|-------------|
@@ -223,6 +239,7 @@ FIFONY_AGENT_PROVIDER=codex # codex | claude
223
239
  FIFONY_WORKER_CONCURRENCY=2
224
240
  FIFONY_MAX_ATTEMPTS=3
225
241
  FIFONY_AGENT_MAX_TURNS=4
242
+ FIFONY_LOG_FILE=0 # set to 1 to also write .fifony/fifony-local.log
226
243
  ```
227
244
 
228
245
  ---
@@ -233,49 +250,23 @@ FIFONY_AGENT_MAX_TURNS=4
233
250
  .fifony/
234
251
  s3db/ ← durable database (issues, events, sessions, settings)
235
252
  source/ ← project snapshot used for workspace seeding
236
- workspaces/ ← isolated per-issue execution directories
253
+ workspaces/ ← isolated per-issue execution directories (git worktrees)
237
254
  ```
238
255
 
239
- fifony is split into an explicit runtime contract:
240
-
241
- - **Persistence layer (s3db.js + resource config):**
242
- - Issues, events, sessions, states, and settings are first-class resources under `.fifony/s3db/`.
243
- - No external DB is required in normal mode.
244
- - **Eventual consistency analytics:**
245
- - `EventualConsistencyPlugin` is enabled for issue metrics and supports counters, incremental updates, and analytics rollups.
246
- - Metrics tracked include:
247
- - `usage.tokens` and `tokenUsage` by phase/model,
248
- - `eventsCount`,
249
- - `linesAdded`, `linesRemoved`, `filesChanged`.
250
- - We query this through `getLastNDays/getLastNHours` to feed `/api/analytics/lines` and `/api/analytics/tokens`.
251
- - **Issue lifecycle in StateMachinePlugin (single source of truth):**
252
- - States, guarded transitions, actions, and triggers are centralized in `issue-state-machine.ts`.
253
- - Public commands (`approve`, `execute`, `queue`, `retry`, `merge`) only emit transitions; the workflow behavior is not duplicated in route handlers.
254
- - The machine also owns interruption recovery, retry delays, terminal transitions, and rollback edges.
255
- - **Queue and execution pool:**
256
- - `s3queue` is the runtime queue adapter with polling workers.
257
- - Workers consume planning/execution/review jobs and run concurrently respecting configured concurrency.
258
- - **Agent abstraction:**
259
- - fifony wraps local CLIs, not proprietary model logic.
260
- - Per stage we configure `cli`, `model`, and `reasoningEffort` independently (`planning`, `execute`, `review`).
261
- - This lets you swap providers by issue without changing core orchestration.
262
- - **Per-issue isolation:**
263
- - Each issue has its own execution workspace and Git worktree branch.
264
- - That avoids file conflicts and enables parallel work on the same repo safely.
265
- - **Review and execution observability:**
266
- - Diff stats are computed from git `--stat` output (`linesAdded`, `linesRemoved`, `filesChanged`).
267
- - Runtime events are emitted for state transitions, review path decisions, and merge outcomes.
268
- - CLI output and audit trails are stored to make mid-run interruptions recoverable.
269
- - **Capability routing:**
270
- - Routing derives issue labels (`capability:<category>`, `overlay:<name>`) from issue text and inferred file paths.
271
- - This improves queue triage and worker assignment.
256
+ - **State machine (single source of truth):** States, guarded transitions, actions, and triggers are centralized in `issue-state-machine.ts`. All side effects (events, field mutations, EC tracking) happen in FSM entry actions.
257
+ - **Persistence (s3db.js):** Issues, events, sessions, and settings are first-class resources. No external DB required.
258
+ - **Eventual consistency analytics:** `EventualConsistencyPlugin` tracks `linesAdded`, `linesRemoved`, `filesChanged`, token usage, and event counts with daily cohort rollups.
259
+ - **Queue workers:** `S3QueuePlugin` dispatches planning/execution/review jobs to concurrent workers.
260
+ - **Agent abstraction:** Wraps local CLIs (Claude, Codex, Gemini), not proprietary model logic. Per-stage provider/model/effort configuration.
261
+ - **Per-issue isolation:** Each issue gets its own git worktree branch. No file conflicts, safe parallel work.
262
+ - **Capability routing:** Issue labels derived from text and file paths drive automatic provider/agent selection.
272
263
 
273
264
  ---
274
265
 
275
266
  ## Requirements
276
267
 
277
268
  - Node.js 23 or newer
278
- - At least one of: `claude` CLI, `codex` CLI
269
+ - At least one of: `claude` CLI, `codex` CLI, `gemini` CLI
279
270
 
280
271
  ---
281
272
 
@@ -1 +1 @@
1
- import{n as e}from"./rolldown-runtime-DF2fYuay.js";import{I as t,h as n}from"./vendor-BTlTWMUF.js";import{t as r}from"./createLucideIcon-BWC-guQt.js";import{r as i}from"./index-Dau_ep-t.js";var a=r(`keyboard`,[[`path`,{d:`M10 8h.01`,key:`1r9ogq`}],[`path`,{d:`M12 12h.01`,key:`1mp3jc`}],[`path`,{d:`M14 8h.01`,key:`1primd`}],[`path`,{d:`M16 12h.01`,key:`1l6xoz`}],[`path`,{d:`M18 8h.01`,key:`emo2bl`}],[`path`,{d:`M6 8h.01`,key:`x9i8wu`}],[`path`,{d:`M7 16h10`,key:`wp8him`}],[`path`,{d:`M8 12h.01`,key:`czm47f`}],[`rect`,{width:`20`,height:`16`,x:`2`,y:`4`,rx:`2`,key:`18n3k1`}]]),o=e(t(),1),s=n(),c=[{key:`n`,description:`Open New Issue drawer`},{key:`k`,description:`Navigate to Kanban`},{key:`i`,description:`Navigate to Issues`},{key:`a`,description:`Navigate to Agents`},{key:`t`,description:`Navigate to Analytics`},{key:`s`,description:`Navigate to Settings`},{key:`1–6`,description:`Jump to kanban column by index`},{key:`Esc`,description:`Close any open drawer / modal`},{key:`?`,description:`Show this help`}];function l({open:e,onClose:t}){let n=(0,o.useRef)(null);return(0,o.useEffect)(()=>{let t=n.current;t&&(e&&!t.open?t.showModal():!e&&t.open&&t.close())},[e]),(0,s.jsxs)(`dialog`,{ref:n,className:`modal modal-bottom sm:modal-middle`,onClose:t,children:[(0,s.jsxs)(`div`,{className:`modal-box max-w-md`,children:[(0,s.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,s.jsxs)(`h3`,{className:`font-bold text-lg flex items-center gap-2`,children:[(0,s.jsx)(a,{className:`size-5 opacity-60`}),`Keyboard Shortcuts`]}),(0,s.jsx)(`button`,{className:`btn btn-sm btn-ghost btn-circle`,onClick:t,children:(0,s.jsx)(i,{className:`size-4`})})]}),(0,s.jsx)(`div`,{className:`overflow-x-auto`,children:(0,s.jsxs)(`table`,{className:`table table-sm`,children:[(0,s.jsx)(`thead`,{children:(0,s.jsxs)(`tr`,{children:[(0,s.jsx)(`th`,{children:`Key`}),(0,s.jsx)(`th`,{children:`Action`})]})}),(0,s.jsx)(`tbody`,{children:c.map(e=>(0,s.jsxs)(`tr`,{children:[(0,s.jsx)(`td`,{children:(0,s.jsx)(`kbd`,{className:`kbd kbd-sm`,children:e.key})}),(0,s.jsx)(`td`,{children:e.description})]},e.key))})]})}),(0,s.jsx)(`div`,{className:`modal-action`,children:(0,s.jsx)(`button`,{className:`btn btn-sm`,onClick:t,children:`Close`})})]}),(0,s.jsx)(`form`,{method:`dialog`,className:`modal-backdrop`,children:(0,s.jsx)(`button`,{children:`close`})})]})}export{l as default};
1
+ import{n as e}from"./rolldown-runtime-DF2fYuay.js";import{I as t,h as n}from"./vendor-BTlTWMUF.js";import{t as r}from"./createLucideIcon-BWC-guQt.js";import{r as i}from"./index-fVSxs9d5.js";var a=r(`keyboard`,[[`path`,{d:`M10 8h.01`,key:`1r9ogq`}],[`path`,{d:`M12 12h.01`,key:`1mp3jc`}],[`path`,{d:`M14 8h.01`,key:`1primd`}],[`path`,{d:`M16 12h.01`,key:`1l6xoz`}],[`path`,{d:`M18 8h.01`,key:`emo2bl`}],[`path`,{d:`M6 8h.01`,key:`x9i8wu`}],[`path`,{d:`M7 16h10`,key:`wp8him`}],[`path`,{d:`M8 12h.01`,key:`czm47f`}],[`rect`,{width:`20`,height:`16`,x:`2`,y:`4`,rx:`2`,key:`18n3k1`}]]),o=e(t(),1),s=n(),c=[{key:`n`,description:`Open New Issue drawer`},{key:`k`,description:`Navigate to Kanban`},{key:`i`,description:`Navigate to Issues`},{key:`a`,description:`Navigate to Agents`},{key:`t`,description:`Navigate to Analytics`},{key:`s`,description:`Navigate to Settings`},{key:`1–6`,description:`Jump to kanban column by index`},{key:`Esc`,description:`Close any open drawer / modal`},{key:`?`,description:`Show this help`}];function l({open:e,onClose:t}){let n=(0,o.useRef)(null);return(0,o.useEffect)(()=>{let t=n.current;t&&(e&&!t.open?t.showModal():!e&&t.open&&t.close())},[e]),(0,s.jsxs)(`dialog`,{ref:n,className:`modal modal-bottom sm:modal-middle`,onClose:t,children:[(0,s.jsxs)(`div`,{className:`modal-box max-w-md`,children:[(0,s.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,s.jsxs)(`h3`,{className:`font-bold text-lg flex items-center gap-2`,children:[(0,s.jsx)(a,{className:`size-5 opacity-60`}),`Keyboard Shortcuts`]}),(0,s.jsx)(`button`,{className:`btn btn-sm btn-ghost btn-circle`,onClick:t,children:(0,s.jsx)(i,{className:`size-4`})})]}),(0,s.jsx)(`div`,{className:`overflow-x-auto`,children:(0,s.jsxs)(`table`,{className:`table table-sm`,children:[(0,s.jsx)(`thead`,{children:(0,s.jsxs)(`tr`,{children:[(0,s.jsx)(`th`,{children:`Key`}),(0,s.jsx)(`th`,{children:`Action`})]})}),(0,s.jsx)(`tbody`,{children:c.map(e=>(0,s.jsxs)(`tr`,{children:[(0,s.jsx)(`td`,{children:(0,s.jsx)(`kbd`,{className:`kbd kbd-sm`,children:e.key})}),(0,s.jsx)(`td`,{children:e.description})]},e.key))})]})}),(0,s.jsx)(`div`,{className:`modal-action`,children:(0,s.jsx)(`button`,{className:`btn btn-sm`,onClick:t,children:`Close`})})]}),(0,s.jsx)(`form`,{method:`dialog`,className:`modal-backdrop`,children:(0,s.jsx)(`button`,{children:`close`})})]})}export{l as default};
@@ -0,0 +1 @@
1
+ import{n as e}from"./rolldown-runtime-DF2fYuay.js";import{I as t,h as n,m as r}from"./vendor-BTlTWMUF.js";import{t as i}from"./createLucideIcon-BWC-guQt.js";import{A as a,B as o,C as s,E as c,F as l,M as u,N as d,O as f,P as p,R as m,S as h,T as g,_,a as v,c as y,d as b,f as x,g as S,i as C,j as w,k as T,l as E,n as D,p as O,t as k,u as A,v as j,w as M,x as N}from"./index-fVSxs9d5.js";var P=i(`brain`,[[`path`,{d:`M12 18V5`,key:`adv99a`}],[`path`,{d:`M15 13a4.17 4.17 0 0 1-3-4 4.17 4.17 0 0 1-3 4`,key:`1e3is1`}],[`path`,{d:`M17.598 6.5A3 3 0 1 0 12 5a3 3 0 1 0-5.598 1.5`,key:`1gqd8o`}],[`path`,{d:`M17.997 5.125a4 4 0 0 1 2.526 5.77`,key:`iwvgf7`}],[`path`,{d:`M18 18a4 4 0 0 0 2-7.464`,key:`efp6ie`}],[`path`,{d:`M19.967 17.483A4 4 0 1 1 12 18a4 4 0 1 1-7.967-.517`,key:`1gq6am`}],[`path`,{d:`M6 18a4 4 0 0 1-2-7.464`,key:`k1g0md`}],[`path`,{d:`M6.003 5.125a4 4 0 0 0-2.526 5.77`,key:`q97ue3`}]]),ee=i(`chevron-left`,[[`path`,{d:`m15 18-6-6 6-6`,key:`1wnfg3`}]]),F=i(`chevron-right`,[[`path`,{d:`m9 18 6-6-6-6`,key:`mthhwq`}]]),I=i(`flame`,[[`path`,{d:`M12 3q1 4 4 6.5t3 5.5a1 1 0 0 1-14 0 5 5 0 0 1 1-3 1 1 0 0 0 5 0c0-2-1.5-3-1.5-5q0-2 2.5-4`,key:`1slcih`}]]),L=i(`folder-root`,[[`path`,{d:`M4 20h16a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.93a2 2 0 0 1-1.66-.9l-.82-1.2A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13c0 1.1.9 2 2 2Z`,key:`1fr9dc`}],[`circle`,{cx:`12`,cy:`13`,r:`2`,key:`1c1ljs`}],[`path`,{d:`M12 15v5`,key:`11xva1`}]]),R=i(`pencil-line`,[[`path`,{d:`M13 21h8`,key:`1jsn5i`}],[`path`,{d:`m15 5 4 4`,key:`1mk7zo`}],[`path`,{d:`M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z`,key:`1a8usu`}]]),z=i(`rocket`,[[`path`,{d:`M12 15v5s3.03-.55 4-2c1.08-1.62 0-5 0-5`,key:`qeys4`}],[`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-.09`,key:`u4xsad`}],[`path`,{d:`M9 12a22 22 0 0 1 2-3.95A12.88 12.88 0 0 1 22 2c0 2.72-.78 7.5-6 11a22.4 22.4 0 0 1-4 2z`,key:`676m9`}],[`path`,{d:`M9 12H4s.55-3.03 2-4c1.62-1.08 5 .05 5 .05`,key:`92ym6u`}]]),te=i(`shield-check`,[[`path`,{d:`M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z`,key:`oel41y`}],[`path`,{d:`m9 12 2 2 4-4`,key:`dzmm74`}]]),B=e(t(),1),V=n();function ne(){let e=(0,B.useRef)(null),t=(0,B.useRef)([]),n=(0,B.useRef)(null);return(0,B.useEffect)(()=>{let r=e.current;if(!r)return;let i=r.getContext(`2d`),a=[`♪`,`♫`,`♩`,`♬`],o=[`oklch(0.75 0.18 250)`,`oklch(0.80 0.16 200)`,`oklch(0.70 0.20 330)`,`oklch(0.85 0.14 85)`,`oklch(0.75 0.18 145)`,`oklch(0.80 0.12 280)`,`oklch(0.78 0.15 30)`],s=o.length,c=a.length,l=document.createElement(`canvas`);l.width=s*56,l.height=c*56;let u=l.getContext(`2d`);u.textAlign=`center`,u.textBaseline=`middle`,u.font=`48px serif`;let d=[];for(let e=0;e<c;e++){d[e]=[];for(let t=0;t<s;t++){let n=t*56+56/2,r=e*56+56/2;u.fillStyle=o[t],u.fillText(a[e],n,r),d[e][t]={x:t*56,y:e*56}}}let f=0,p=0,m=()=>{let e=window.devicePixelRatio||1;f=window.innerWidth,p=window.innerHeight,r.width=f*e,r.height=p*e,r.style.width=f+`px`,r.style.height=p+`px`,i.setTransform(e,0,0,e,0,0)};m();function h(){let e=f/2,t=p*.38,n=Math.random()*Math.PI*2,r=Math.random()*1.8+.4,i=Math.random()*20,a=Math.floor(Math.random()*c),o=Math.floor(Math.random()*s);return{x:e+Math.cos(n)*i,y:t+Math.sin(n)*i,vx:Math.cos(n)*r,vy:Math.sin(n)*r,gravity:.003+Math.random()*.005,scale:Math.random()*.4+.25,si:a,ci:o,rotation:Math.random()*Math.PI*2,rotationSpeed:(Math.random()-.5)*.04,life:0,maxLife:180+Math.random()*200,fadeIn:15}}let g=Math.min(Math.floor(f*p/6e3),120);t.current=[];for(let e=0;e<g;e++){let e=h(),n=Math.random()*e.maxLife*.8;e.x+=e.vx*n,e.y+=e.vy*n+.5*e.gravity*n*n,e.rotation+=e.rotationSpeed*n,e.life=n,t.current.push(e)}let _=Math.max(1,Math.floor(g/90)),v=0,y=()=>{if(i.clearRect(0,0,f,p),v++,v%2==0)for(let e=0;e<_;e++)t.current.push(h());let e=[];for(let n of t.current){if(n.life++,n.x+=n.vx,n.y+=n.vy,n.vy+=n.gravity,n.rotation+=n.rotationSpeed,n.vx*=.998,n.vy*=.998,n.life>n.maxLife||n.x<-60||n.x>f+60||n.y<-60||n.y>p+60)continue;e.push(n);let t=Math.min(1,n.life/n.fadeIn),r=n.maxLife*.6,a=t*(n.life>r?1-(n.life-r)/(n.maxLife-r):1)*.45;if(a<=.01)continue;let o=d[n.si][n.ci],s=56*n.scale,c=s/2;i.save(),i.translate(n.x,n.y),i.rotate(n.rotation),i.globalAlpha=a,i.drawImage(l,o.x,o.y,56,56,-c,-c,s,s),i.restore()}t.current=e,n.current=requestAnimationFrame(y)};return n.current=requestAnimationFrame(y),window.addEventListener(`resize`,m),()=>{cancelAnimationFrame(n.current),window.removeEventListener(`resize`,m)}},[]),(0,V.jsx)(`canvas`,{ref:e,className:`fixed inset-0 pointer-events-none`,style:{zIndex:0},"aria-hidden":`true`})}var H=[`Welcome`,`Setup`,`Pipeline`,`Agents & Skills`,`Preferences`,`Launch`];function re(){return H}function ie(){return H.length}var ae=[`Setup`,`Pipeline`,`Agents`,`Preferences`,`Launch`];function U(){return ae}var W=[{value:`low`,label:`Low`,icon:D,description:`Quick and light -- fast responses, less thorough`,color:`text-info`},{value:`medium`,label:`Medium`,icon:j,description:`Balanced -- good mix of speed and quality`,color:`text-success`},{value:`high`,label:`High`,icon:P,description:`Thorough -- deeper analysis, takes more time`,color:`text-warning`},{value:`extra-high`,label:`Extra High`,icon:I,description:`Maximum depth -- most thorough, slowest`,color:`text-error`}],G={codex:W,claude:W.filter(e=>e.value!==`extra-high`),gemini:W.filter(e=>e.value!==`extra-high`)};function K(e,t){return G[t?.[e]||`codex`]||W}var q=[{value:`auto`,label:`Auto`},{value:`light`,label:`Light`},{value:`dark`,label:`Dark`},{value:`black`,label:`Black`},{value:`cupcake`,label:`Cupcake`},{value:`night`,label:`Night`},{value:`sunset`,label:`Sunset`}],J=[{role:`planner`,label:`Planner`,description:`Scopes the issue, breaks it into steps, and decides the approach`,icon:P,color:`text-info`},{role:`executor`,label:`Executor`,description:`Implements the plan — writes code, edits files, runs commands`,icon:D,color:`text-primary`},{role:`reviewer`,label:`Reviewer`,description:`Validates the result — checks correctness, scope, and quality`,icon:E,color:`text-secondary`}];async function Y(e,t,n=`ui`){return o.post(`/settings/${encodeURIComponent(e)}`,{value:t,scope:n,source:`user`})}function X(e,t=`medium`){return W.some(t=>t.value===e)?e:t}function oe(e){return!e||typeof e!=`object`||Array.isArray(e)?{planner:`medium`,executor:`medium`,reviewer:`medium`}:{planner:X(e.planner??e.default,`medium`),executor:X(e.executor??e.default,`medium`),reviewer:X(e.reviewer??e.default,`medium`)}}function se(e,t,n={}){return{plan:{provider:e.planner||e.executor||``,model:n.plan||``,effort:t.planner||`medium`},execute:{provider:e.executor||``,model:n.execute||``,effort:t.executor||`medium`},review:{provider:e.reviewer||e.executor||``,model:n.review||``,effort:t.reviewer||`medium`}}}function ce({current:e}){let t=U(),n=e-1;return(0,V.jsx)(`ul`,{className:`steps steps-horizontal w-full max-w-2xl text-xs`,children:t.map((e,t)=>{let r=t<n,i=t===n;return(0,V.jsx)(`li`,{"data-content":r?`✓`:t+1,className:`step ${r||i?`step-primary`:``}`,style:{transition:`color 0.3s ease`},children:e},e)})})}function le({direction:e,stepKey:t,center:n,children:r}){return(0,V.jsx)(`div`,{className:`${e===`forward`?`animate-slide-in-right`:`animate-slide-in-left`} w-full max-w-2xl mx-auto ${n?`my-auto`:``}`,children:r},t)}function ue({step:e,stepCount:t,stepName:n,canProceed:r,launching:i,onBack:a,onNext:o,onLaunch:s}){return e===0?null:(0,V.jsxs)(`div`,{className:`relative z-10 p-4 pb-6 flex items-center max-w-2xl mx-auto w-full justify-between`,children:[(0,V.jsxs)(`button`,{className:`btn btn-ghost gap-1`,onClick:a,disabled:i,children:[(0,V.jsx)(ee,{className:`size-4`}),` Back`]}),e<t-1?(0,V.jsxs)(`button`,{className:`btn btn-primary gap-1`,onClick:o,disabled:!r,children:[`Next `,(0,V.jsx)(F,{className:`size-4`})]}):(0,V.jsx)(`button`,{className:`btn btn-primary btn-lg gap-2 animate-pulse-soft`,onClick:s,disabled:i,children:i?(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(O,{className:`size-5 animate-spin`}),` Launching...`]}):(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(z,{className:`size-5`}),` Launch fifony`]})})]})}function de({workspacePath:e,onGetStarted:t}){return(0,V.jsxs)(`div`,{className:`flex flex-col items-center text-center gap-6 stagger-children py-4`,children:[(0,V.jsx)(`img`,{src:`/assets/dinofffaur.png`,alt:`fifony mascot`,className:`h-72 sm:h-96 object-contain animate-bounce-in select-none pointer-events-none`,style:{filter:`drop-shadow(0 12px 40px rgba(128, 0, 255, 0.3))`}}),(0,V.jsxs)(`h1`,{className:`text-4xl sm:text-5xl font-bold tracking-tight leading-none`,style:{fontFamily:`'Space Grotesk', system-ui, sans-serif`},children:[`Welcome to `,(0,V.jsx)(`span`,{className:`text-primary`,children:`fifony`})]}),(0,V.jsx)(`p`,{className:`text-base-content/60 text-lg max-w-md`,children:`Let's set up your AI orchestration project in just a few steps.`}),e&&(0,V.jsxs)(`div`,{className:`badge badge-lg badge-soft badge-primary gap-2`,children:[(0,V.jsx)(y,{className:`size-3.5`}),`Project target: `,e]}),(0,V.jsxs)(`button`,{className:`btn btn-primary btn-lg gap-2 mt-2`,onClick:t,children:[`Get Started `,(0,V.jsx)(F,{className:`size-5`})]})]})}var fe=new Set([`main`,`master`]);function Z(){let[e,t]=(0,B.useState)(null),[n,r]=(0,B.useState)(!1),[i,a]=(0,B.useState)(!1);return(0,B.useEffect)(()=>{o.get(`/gitignore/status`).then(t).catch(()=>t({exists:!1,hasFifony:!1}))},[]),e===null||e.hasFifony?null:i?(0,V.jsxs)(`div`,{className:`alert alert-success py-2.5 text-sm animate-fade-in`,children:[(0,V.jsx)(te,{className:`size-4 shrink-0`}),(0,V.jsxs)(`span`,{children:[(0,V.jsx)(`code`,{children:`.fifony/`}),` adicionado ao `,(0,V.jsx)(`code`,{children:`.gitignore`})]})]}):(0,V.jsxs)(`div`,{className:`alert alert-warning py-2.5 text-sm`,children:[(0,V.jsx)(te,{className:`size-4 shrink-0`}),(0,V.jsxs)(`div`,{className:`flex-1`,children:[(0,V.jsxs)(`span`,{children:[(0,V.jsx)(`code`,{children:`.fifony/`}),` não está no `,(0,V.jsx)(`code`,{children:`.gitignore`})]}),(0,V.jsx)(`span`,{className:`text-base-content/50 block text-xs mt-0.5`,children:`O fifony guarda estado local lá — não deve ser commitado.`})]}),(0,V.jsx)(`button`,{className:`btn btn-xs btn-warning`,onClick:async()=>{r(!0);try{await o.post(`/gitignore/add`),a(!0)}catch{}finally{r(!1)}},disabled:n,children:n?(0,V.jsx)(O,{className:`size-3 animate-spin`}):`Adicionar`})]})}function Q({currentBranch:e,onBranchCreated:t}){let[n,r]=(0,B.useState)(null),[i,a]=(0,B.useState)(!1),[c,l]=(0,B.useState)(null),[u,d]=(0,B.useState)(e);(0,B.useEffect)(()=>{o.get(`/git/status`).then(e=>{r(e),e.branch&&d(e.branch)}).catch(()=>r({isGit:!0,branch:e,hasCommits:!0}))},[]);let[f,p]=(0,B.useState)(`develop`),[m,h]=(0,B.useState)(!1),[g,y]=(0,B.useState)(null),[b,C]=(0,B.useState)(!1),w=n===null||n.isGit,T=fe.has(u),E=/^[a-zA-Z0-9/_.-]+$/.test(f.trim())&&f.trim().length>0;async function D(){a(!0),l(null);try{let e=await o.post(`/git/init`,{});if(!e.ok)throw Error(e.error||`Failed to initialize git.`);r({isGit:!0,branch:e.branch,hasCommits:!0}),d(e.branch)}catch(e){l(e instanceof Error?e.message:String(e))}finally{a(!1)}}async function k(){if(!(!E||m)){h(!0),y(null);try{let e=await o.post(`/git/branch`,{branchName:f.trim()});if(!e.ok)throw Error(e.error||`Failed to create branch.`);C(!0),t?.(f.trim())}catch(e){y(e instanceof Error?e.message:String(e))}finally{h(!1)}}}return(0,V.jsxs)(`div`,{className:`bg-base-200 rounded-2xl p-5 flex flex-col gap-4`,children:[(0,V.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,V.jsx)(_,{className:`size-4 text-primary`}),(0,V.jsx)(`div`,{className:`text-sm font-semibold`,children:`Working branch`})]}),(0,V.jsx)(`p`,{className:`text-xs text-base-content/50 -mt-2`,children:`Agents create worktrees based on the current branch. We recommend not working directly on main.`}),n!==null&&!n.isGit&&(0,V.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,V.jsxs)(`div`,{className:`alert alert-warning py-3`,children:[(0,V.jsx)(S,{className:`size-4 shrink-0`}),(0,V.jsxs)(`div`,{className:`text-sm`,children:[(0,V.jsx)(`p`,{className:`font-semibold`,children:`Not a git repository`}),(0,V.jsx)(`p`,{className:`opacity-80 mt-0.5`,children:`fifony requires git to create agent worktrees. Initialize one here.`})]})]}),c&&(0,V.jsxs)(`p`,{className:`text-xs text-error flex items-center gap-1`,children:[(0,V.jsx)(v,{className:`size-3`}),` `,c]}),(0,V.jsxs)(`button`,{className:`btn btn-primary gap-2 self-start`,onClick:D,disabled:i,children:[i?(0,V.jsx)(O,{className:`size-4 animate-spin`}):(0,V.jsx)(S,{className:`size-4`}),`Initialize git repository`]})]}),w&&(0,V.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,V.jsxs)(`div`,{className:`flex items-center gap-2 px-4 py-3 rounded-box border border-base-300 bg-base-100`,children:[(0,V.jsx)(_,{className:`size-4 opacity-50 shrink-0`}),(0,V.jsx)(`span`,{className:`text-sm opacity-50`,children:`Current branch:`}),(0,V.jsx)(`span`,{className:`font-mono text-sm font-semibold`,children:u||(n===null?`…`:`—`)}),T&&(0,V.jsx)(`span`,{className:`badge badge-warning badge-sm ml-auto shrink-0`,children:`protected`})]}),T&&(0,V.jsxs)(`div`,{className:`alert alert-warning py-3`,children:[(0,V.jsx)(v,{className:`size-4 shrink-0`}),(0,V.jsxs)(`div`,{className:`text-sm`,children:[(0,V.jsxs)(`p`,{className:`font-semibold`,children:[`Working directly on `,(0,V.jsx)(`span`,{className:`font-mono`,children:u})]}),(0,V.jsx)(`p`,{className:`opacity-80 mt-0.5`,children:`In teams with protected branches, local merges are rejected. Create a working branch or use Push PR mode.`})]})]}),b?(0,V.jsxs)(`div`,{className:`alert alert-success py-3 text-sm`,children:[(0,V.jsx)(s,{className:`size-4 shrink-0`}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`p`,{className:`font-semibold`,children:`Branch created successfully`}),(0,V.jsxs)(`p`,{className:`opacity-75 font-mono mt-0.5`,children:[`Now on `,(0,V.jsx)(`span`,{className:`text-success-content`,children:f.trim()}),` — agents will use this as the base branch`]})]})]}):(0,V.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,V.jsx)(`label`,{className:`text-sm font-medium`,children:`Create a new branch now`}),(0,V.jsxs)(`div`,{className:`flex gap-2`,children:[(0,V.jsxs)(`label`,{className:`input input-bordered flex items-center gap-2 flex-1`,children:[(0,V.jsx)(_,{className:`size-3.5 opacity-40`}),(0,V.jsx)(`input`,{type:`text`,className:`grow font-mono text-sm`,value:f,onChange:e=>{p(e.target.value),y(null)},onKeyDown:e=>e.key===`Enter`&&k(),placeholder:`develop`,disabled:m})]}),(0,V.jsx)(`button`,{className:`btn btn-primary`,onClick:k,disabled:!E||m,children:m?(0,V.jsx)(x,{className:`size-4 animate-spin`}):`Create`})]}),g&&(0,V.jsxs)(`p`,{className:`text-xs text-error flex items-center gap-1`,children:[(0,V.jsx)(v,{className:`size-3`}),` `,g]}),(0,V.jsxs)(`p`,{className:`text-xs opacity-40`,children:[`Equivalent to: `,(0,V.jsxs)(`span`,{className:`font-mono`,children:[`git checkout -b `,f.trim()||`develop`]})]})]}),(0,V.jsx)(Z,{})]})]})}function pe({projectName:e,setProjectName:t,detectedProjectName:n,projectSource:r,workspacePath:i,currentBranch:o,onBranchCreated:s}){let c=a(e),l=T(c||n),u=c?r===`saved`||r===`detected`?r:`manual`:n?`detected`:`missing`;return(0,V.jsxs)(`div`,{className:`flex flex-col gap-6 py-4`,children:[(0,V.jsxs)(`div`,{className:`text-center space-y-3`,children:[(0,V.jsx)(`div`,{className:`inline-flex size-14 items-center justify-center rounded-full bg-primary/10 text-primary mx-auto`,children:(0,V.jsx)(L,{className:`size-7`})}),(0,V.jsxs)(`div`,{className:`space-y-2`,children:[(0,V.jsx)(`h2`,{className:`text-2xl font-bold tracking-tight`,children:`Set up your workspace`}),(0,V.jsx)(`p`,{className:`text-base-content/60 max-w-xl mx-auto text-sm`,children:`Name your project and configure the working branch`})]})]}),(0,V.jsxs)(`div`,{className:`bg-base-200 rounded-2xl p-5 flex flex-col gap-4`,children:[(0,V.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`div`,{className:`text-sm font-semibold`,children:`Project name`}),(0,V.jsx)(`div`,{className:`text-xs text-base-content/50`,children:`This becomes the default queue title for future runs.`})]}),u===`saved`&&(0,V.jsxs)(`span`,{className:`badge badge-primary badge-soft gap-1.5`,children:[(0,V.jsx)(y,{className:`size-3`}),`Saved configuration`]}),u===`detected`&&(0,V.jsxs)(`span`,{className:`badge badge-secondary badge-soft gap-1.5`,children:[(0,V.jsx)(y,{className:`size-3`}),`Detected automatically`]}),u===`manual`&&(0,V.jsxs)(`span`,{className:`badge badge-accent badge-soft gap-1.5`,children:[(0,V.jsx)(R,{className:`size-3`}),`Edited manually`]}),u===`missing`&&(0,V.jsxs)(`span`,{className:`badge badge-warning badge-soft gap-1.5`,children:[(0,V.jsx)(v,{className:`size-3`}),`Manual entry required`]})]}),(0,V.jsxs)(`label`,{className:`form-control w-full gap-2`,children:[(0,V.jsx)(`span`,{className:`label-text text-sm font-medium`,children:`Project`}),(0,V.jsx)(`input`,{type:`text`,className:`input input-bordered w-full text-base`,placeholder:n||`Enter your project name`,value:e,onChange:e=>t(e.target.value),onBlur:n=>{let r=a(n.target.value);r!==e&&t(r)}})]}),i&&(0,V.jsxs)(`div`,{className:`text-xs text-base-content/50 break-all`,children:[`Workspace: `,i]}),!n&&!c&&(0,V.jsxs)(`div`,{className:`alert alert-warning text-sm`,children:[(0,V.jsx)(v,{className:`size-4 shrink-0`}),(0,V.jsx)(`span`,{children:`We could not detect a project name from the current directory. Enter one to continue.`})]}),(0,V.jsxs)(`div`,{className:`rounded-xl border border-base-300/70 bg-base-100 px-4 py-3`,children:[(0,V.jsx)(`div`,{className:`text-xs uppercase tracking-[0.2em] text-base-content/40`,children:`Queue title preview`}),(0,V.jsx)(`div`,{className:`mt-1.5 text-base font-semibold tracking-tight break-words`,children:l})]})]}),(0,V.jsx)(Q,{currentBranch:o,onBranchCreated:s})]})}var me={planner:`plan`,executor:`execute`,reviewer:`review`};function he({options:e,value:t,onChange:n}){return(0,V.jsx)(`div`,{className:`flex gap-1 flex-wrap`,children:e.map(e=>{let r=e.value===t,i=e.icon;return(0,V.jsxs)(`button`,{type:`button`,onClick:()=>n(e.value),className:`flex items-center gap-1 px-2.5 py-1 rounded-full text-[11px] font-medium border transition-all ${r?`${e.color} border-current bg-base-300`:`text-base-content/35 border-base-content/10 hover:border-base-content/30 hover:text-base-content/60`}`,children:[(0,V.jsx)(i,{className:`size-2.5`}),e.label]},e.value)})})}function ge({providers:e,providersLoading:t,pipeline:n,setPipeline:r,efforts:i,setEfforts:a,models:o,setModels:s,modelsByProvider:l}){let u=Array.isArray(e)?e:[],d=u.filter(e=>e.available!==!1);return(0,B.useEffect)(()=>{for(let e of[`planner`,`executor`,`reviewer`]){let t=K(e,n),r=i[e];r&&!t.some(e=>e.value===r)&&a(t=>({...t,[e]:`high`}))}},[n,i,a]),(0,V.jsxs)(`div`,{className:`flex flex-col gap-5 w-full max-w-lg`,children:[(0,V.jsxs)(`div`,{className:`text-center`,children:[(0,V.jsx)(z,{className:`size-9 text-primary mx-auto mb-2`}),(0,V.jsx)(`h2`,{className:`text-2xl font-bold`,children:`Agent Pipeline`}),(0,V.jsx)(`p`,{className:`text-sm text-base-content/50 mt-1`,children:`Configure which CLI and reasoning depth runs each stage`})]}),t?(0,V.jsxs)(`div`,{className:`flex flex-col items-center gap-3 py-10`,children:[(0,V.jsx)(O,{className:`size-7 text-primary animate-spin`}),(0,V.jsx)(`p`,{className:`text-sm text-base-content/50`,children:`Detecting available CLIs…`})]}):d.length===0?(0,V.jsx)(`div`,{className:`alert alert-warning text-sm`,children:`No providers detected. Install claude, codex, or gemini CLI first.`}):(0,V.jsxs)(V.Fragment,{children:[(0,V.jsx)(`div`,{className:`flex flex-wrap gap-2 justify-center`,children:u.map(e=>{let t=e.id||e.name||e,n=e.available!==!1;return(0,V.jsxs)(`span`,{className:`badge gap-1.5 badge-sm ${n?`badge-success`:`badge-ghost opacity-40`}`,children:[n?(0,V.jsx)(h,{className:`size-3`}):(0,V.jsx)(N,{className:`size-3`}),(0,V.jsx)(`span`,{className:`font-mono`,children:t}),e.path&&(0,V.jsx)(`span`,{className:`opacity-50 text-[9px] hidden sm:inline`,children:e.path})]},t)})}),(0,V.jsx)(`div`,{className:`flex flex-col`,children:J.map((e,t)=>{let u=e.icon,f=n[e.role]||d[0]?.id||d[0]?.name||``,p=me[e.role],m=o?.[p]||``,h=l?.[f]||[],g=K(e.role,n),_=i?.[e.role]||`high`;return(0,V.jsxs)(`div`,{children:[t>0&&(0,V.jsx)(`div`,{className:`flex justify-center py-1.5 text-base-content/20`,children:(0,V.jsx)(c,{className:`size-4`})}),(0,V.jsx)(`div`,{className:`bg-base-200 rounded-xl p-4`,children:(0,V.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,V.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,V.jsx)(`div`,{className:`size-8 rounded-lg flex items-center justify-center bg-base-300 shrink-0 ${e.color}`,children:(0,V.jsx)(u,{className:`size-4`})}),(0,V.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,V.jsx)(`span`,{className:`font-semibold text-sm`,children:e.label}),(0,V.jsx)(`p`,{className:`text-[11px] text-base-content/40 leading-tight mt-0.5 truncate`,children:e.description})]}),(0,V.jsx)(`select`,{className:`select select-sm select-bordered w-28 shrink-0`,value:f,onChange:t=>{let n=t.target.value;r(t=>({...t,[e.role]:n}));let i=l?.[n]?.[0]?.id||``;s(e=>({...e,[p]:i}))},children:d.map(e=>{let t=e.id||e.name||e;return(0,V.jsx)(`option`,{value:t,children:t},t)})})]}),(0,V.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,V.jsx)(`span`,{className:`text-[10px] text-base-content/40 shrink-0 w-10`,children:`Effort`}),(0,V.jsx)(he,{options:g,value:_,onChange:t=>a(n=>({...n,[e.role]:t}))})]}),h.length>0&&(0,V.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,V.jsx)(`span`,{className:`text-[10px] text-base-content/40 shrink-0 w-10`,children:`Model`}),(0,V.jsx)(`select`,{className:`select select-xs select-bordered flex-1`,value:m,onChange:e=>s(t=>({...t,[p]:e.target.value})),children:h.map(e=>(0,V.jsx)(`option`,{value:e.id,children:e.label||e.id},e.id))})]})]})})]},e.role)})}),(0,V.jsx)(`p`,{className:`text-[11px] text-base-content/35 text-center`,children:`Pipeline runs top to bottom: plan → execute → review`})]})]})}function _e({selectedAgents:e,setSelectedAgents:t,existingAgents:n}){let[r,i]=(0,B.useState)([]),[a,s]=(0,B.useState)(!1),c=(0,B.useRef)(!1),[l,u]=(0,B.useState)([]),[d,f]=(0,B.useState)(!1),[p,m]=(0,B.useState)(``),[h,_]=(0,B.useState)(()=>new Set),[v,y]=(0,B.useState)({}),b=(0,B.useRef)(!1),[x,S]=(0,B.useState)(``),C=(0,B.useCallback)(()=>o.get(`/catalog/agents`).catch(()=>({agents:[]})).then(e=>{let t=e?.agents||[];return i(t),t}),[]);(0,B.useEffect)(()=>{c.current||(c.current=!0,s(!0),C().then(r=>{let i=new Set((n||[]).map(e=>e.name)),a=r.filter(e=>!i.has(e.name)).map(e=>e.name);a.length>0&&e.length===0&&t(a)}).finally(()=>s(!1)))},[]);let w=(0,B.useCallback)(()=>(m(``),f(!0),o.get(`/reference-repositories`).then(e=>{u(e?.repositories||[])}).catch(e=>{let t=e?.message||`Failed to load reference repositories.`;t.toLowerCase().includes(`route not found`)?m(`Backend route not loaded. Start Fifony with --dev (or run pnpm build:server) and retry.`):m(t)}).finally(()=>f(!1))),[]);(0,B.useEffect)(()=>{b.current||(b.current=!0,w())},[w]);let T=(0,B.useMemo)(()=>new Set((n||[]).map(e=>e.name)),[n]),D=(0,B.useMemo)(()=>{let e=x.trim().toLowerCase();return e?r.filter(t=>[t?.name,t?.displayName,t?.description].filter(Boolean).join(` `).toLowerCase().includes(e)):r},[x,r]),k=(0,B.useCallback)(e=>{t(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])},[t]),j=(0,B.useCallback)(()=>{t(r.filter(e=>!T.has(e.name)).map(e=>e.name))},[r,T,t]),N=(0,B.useCallback)(()=>t([]),[t]),P=(0,B.useCallback)(async e=>{_(t=>new Set([...t,e])),y(t=>({...t,[e]:``}));try{let t=((await o.post(`/reference-repositories/sync`,{repository:e}))?.results||[]).find(t=>t.id===e);if(t?.action===`failed`){y(n=>({...n,[e]:t.message||`Sync failed.`}));return}await o.post(`/reference-repositories/import`,{repository:e,kind:`agents`,global:!1}),await Promise.all([w(),C()]),y(t=>({...t,[e]:`Synced & imported.`}))}catch(t){y(n=>({...n,[e]:t?.message||`Failed.`}))}finally{_(t=>{let n=new Set(t);return n.delete(e),n})}},[w,C]);return a?(0,V.jsxs)(`div`,{className:`flex flex-col items-center gap-3 py-12`,children:[(0,V.jsx)(O,{className:`size-8 text-primary animate-spin`}),(0,V.jsx)(`p`,{className:`text-sm text-base-content/50`,children:`Loading catalog...`})]}):(0,V.jsxs)(`div`,{className:`flex flex-col gap-6 stagger-children`,children:[(0,V.jsxs)(`div`,{className:`text-center`,children:[(0,V.jsx)(g,{className:`size-10 text-primary mx-auto mb-3`}),(0,V.jsx)(`h2`,{className:`text-2xl font-bold`,children:`Agents`}),(0,V.jsx)(`p`,{className:`text-base-content/60 mt-1`,children:`Choose which agents to install`})]}),(0,V.jsx)(`div`,{className:`card bg-base-200`,children:(0,V.jsxs)(`div`,{className:`card-body gap-3 p-4`,children:[(0,V.jsx)(`h3`,{className:`font-semibold text-sm`,children:`Sources`}),p&&(0,V.jsx)(`div`,{className:`alert alert-warning text-xs`,children:p}),d?(0,V.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-base-content/60`,children:[(0,V.jsx)(O,{className:`size-3 animate-spin`}),` Loading...`]}):(0,V.jsx)(`div`,{className:`grid grid-cols-2 xl:grid-cols-4 gap-2`,children:l.map(e=>{let t=h.has(e.id),n=e?.artifactCounts??null,r=e?.present&&e?.synced;return(0,V.jsxs)(`div`,{className:`rounded-lg border border-base-300/70 bg-base-100 p-2 flex flex-col gap-1.5`,children:[(0,V.jsx)(`div`,{className:`font-medium text-xs truncate`,children:e.name}),r&&n?(0,V.jsxs)(`div`,{className:`text-[11px] text-base-content/60`,children:[n.agents,` agents`]}):(0,V.jsx)(`span`,{className:`badge badge-xs badge-warning`,children:`Not synced`}),v[e.id]&&(0,V.jsx)(`p`,{className:`text-[11px] text-base-content/60 truncate`,children:v[e.id]}),(0,V.jsxs)(`button`,{className:`btn btn-xs btn-outline gap-1 mt-auto`,onClick:()=>P(e.id),disabled:t,children:[t?(0,V.jsx)(O,{className:`size-3 animate-spin`}):(0,V.jsx)(A,{className:`size-3`}),t?`Syncing…`:r?`Re-sync`:`Sync`]})]},e.id)})})]})}),(0,V.jsxs)(`div`,{className:`space-y-2`,children:[(0,V.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,V.jsxs)(`h3`,{className:`font-semibold text-sm flex items-center gap-2`,children:[(0,V.jsx)(g,{className:`size-4 opacity-50`}),`Agents (`,r.length,`)`]}),(0,V.jsxs)(`div`,{className:`flex gap-1`,children:[(0,V.jsx)(`button`,{className:`btn btn-xs btn-ghost`,onClick:j,children:`Select All`}),(0,V.jsx)(`button`,{className:`btn btn-xs btn-ghost`,onClick:N,children:`None`})]})]}),(0,V.jsxs)(`label`,{className:`input input-bordered input-sm flex items-center gap-2`,children:[(0,V.jsx)(E,{className:`size-4 opacity-60`}),(0,V.jsx)(`input`,{type:`text`,className:`grow`,placeholder:`Search agents...`,value:x,onChange:e=>S(e.target.value)})]}),D.length===0&&r.length>0&&(0,V.jsx)(`div`,{className:`text-sm text-base-content/60`,children:`No agents match your search.`}),(0,V.jsx)(`div`,{className:`space-y-1 pt-1`,children:D.map(t=>{let n=T.has(t.name),r=n||e.includes(t.name);return(0,V.jsx)(`button`,{className:`w-full rounded-md border border-transparent px-2 py-2 text-left transition-all ${n?`opacity-70 bg-base-100/40`:`hover:bg-base-100`} ${r&&!n?`ring-1 ring-primary ring-offset-1 ring-offset-base-200`:``}`,onClick:()=>!n&&k(t.name),disabled:n,children:(0,V.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,V.jsx)(`span`,{className:`mt-0.5 text-base`,children:t.emoji||`🤖`}),(0,V.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,V.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,V.jsx)(`span`,{className:`font-medium text-sm truncate`,children:t.displayName||t.name}),t.source&&(0,V.jsx)(`span`,{className:`badge badge-xs badge-ghost shrink-0`,children:t.source}),n?(0,V.jsxs)(`span`,{className:`badge badge-xs badge-success gap-1 shrink-0`,children:[(0,V.jsx)(M,{className:`size-3`}),` Installed`]}):(0,V.jsx)(`input`,{type:`checkbox`,className:`checkbox checkbox-primary checkbox-sm self-start mt-0.5 shrink-0`,checked:r,readOnly:!0,tabIndex:-1})]}),t.description&&(0,V.jsx)(`p`,{className:`text-xs text-base-content/60 mt-1 truncate`,children:t.description})]})]})},t.name)})})]}),r.length===0&&(0,V.jsx)(`div`,{className:`alert alert-info text-sm`,children:`No agents found in the catalog. Sync a source above or add them later from the settings page.`})]})}var ve={auto:{bg:null,label:`Auto`},light:{bg:`#ffffff`,accent:`#7c3aed`},dark:{bg:`#1d232a`,accent:`#661ae6`},black:{bg:`#000000`,accent:`#ffffff`},cupcake:{bg:`#faf7f5`,accent:`#ef9fbc`},night:{bg:`#0f172a`,accent:`#38bdf8`},sunset:{bg:`#1a1019`,accent:`#ff865b`}};function ye({theme:e,selected:t,onClick:n}){let r=ve[e.value];return(0,V.jsxs)(`button`,{onClick:n,title:e.label,className:`flex flex-col items-center gap-1.5 group focus:outline-none`,children:[(0,V.jsx)(`div`,{className:`w-10 h-10 rounded-xl border-2 transition-all overflow-hidden flex-shrink-0 ${t?`border-primary ring-2 ring-primary ring-offset-2 ring-offset-base-200 scale-110`:`border-base-300 group-hover:border-base-content/30 group-hover:scale-105`}`,style:r.bg?{background:r.bg}:void 0,children:r.bg?(0,V.jsxs)(`div`,{className:`w-full h-full flex flex-col`,children:[(0,V.jsx)(`div`,{className:`flex-1`,style:{background:r.bg}}),(0,V.jsx)(`div`,{className:`h-3 w-full`,style:{background:r.accent}})]}):(0,V.jsxs)(`div`,{className:`w-full h-full flex`,children:[(0,V.jsx)(`div`,{className:`flex-1 bg-white`}),(0,V.jsx)(`div`,{className:`flex-1 bg-neutral`})]})}),(0,V.jsx)(`span`,{className:`text-xs font-medium transition-colors ${t?`text-primary`:`text-base-content/50 group-hover:text-base-content/80`}`,children:e.label})]})}function be({concurrency:e,setConcurrency:t,selectedTheme:n,setSelectedTheme:r}){let i=Number.isFinite(e)?Math.max(1,Math.min(10,e)):1;return(0,V.jsxs)(`div`,{className:`flex flex-col gap-6 stagger-children`,children:[(0,V.jsxs)(`div`,{className:`text-center`,children:[(0,V.jsx)(C,{className:`size-10 text-primary mx-auto mb-3`}),(0,V.jsx)(`h2`,{className:`text-2xl font-bold`,children:`Workers & Theme`}),(0,V.jsx)(`p`,{className:`text-base-content/60 mt-1 text-sm`,children:`Configure parallel workers and visual theme`})]}),(0,V.jsx)(`div`,{className:`card bg-base-200`,children:(0,V.jsxs)(`div`,{className:`card-body p-5 gap-3`,children:[(0,V.jsxs)(`h3`,{className:`font-semibold text-sm flex items-center gap-2`,children:[(0,V.jsx)(C,{className:`size-4 opacity-50`}),`Worker Concurrency`]}),(0,V.jsxs)(`p`,{className:`text-xs text-base-content/60`,children:[`How many agents can work in parallel (`,i,` worker`,i===1?``:`s`,`)`]}),(0,V.jsxs)(`div`,{className:`w-full max-w-xs`,children:[(0,V.jsx)(`input`,{type:`range`,min:1,max:10,step:1,value:i,onChange:e=>t(Math.round(Number(e.target.value))),"aria-label":`Number of parallel workers`,className:`range range-primary range-sm w-full`}),(0,V.jsx)(`div`,{className:`flex justify-between px-2.5 mt-2 text-xs`,children:Array.from({length:10},(e,t)=>(0,V.jsx)(`span`,{children:`|`},t))}),(0,V.jsx)(`div`,{className:`flex justify-between px-2.5 mt-2 text-xs`,children:Array.from({length:10},(e,t)=>(0,V.jsx)(`span`,{children:t+1},t))})]}),(0,V.jsxs)(`p`,{className:`text-xs text-base-content/50 bg-base-100 rounded-lg px-3 py-2 mt-1`,children:[(0,V.jsx)(`span`,{className:`font-medium text-base-content/70`,children:`Tip:`}),` 2–4 workers is recommended for most projects. More workers consume more API quota and may hit rate limits.`]})]})}),(0,V.jsx)(`div`,{className:`card bg-base-200`,children:(0,V.jsxs)(`div`,{className:`card-body p-5 gap-4`,children:[(0,V.jsxs)(`h3`,{className:`font-semibold text-sm flex items-center gap-2`,children:[(0,V.jsx)(b,{className:`size-4 opacity-50`}),`Theme`]}),(0,V.jsx)(`div`,{className:`flex flex-wrap gap-5 justify-center py-1`,children:q.map(e=>(0,V.jsx)(ye,{theme:e,selected:n===e.value,onClick:()=>r(e.value)},e.value))})]})})]})}function xe({config:e,launching:t}){return(0,V.jsxs)(`div`,{className:`flex flex-col items-center text-center gap-6 stagger-children py-4`,children:[(0,V.jsx)(`div`,{className:`animate-bounce-in`,children:(0,V.jsx)(z,{className:`size-16 sm:size-20 text-primary mx-auto`})}),(0,V.jsx)(`h2`,{className:`text-2xl sm:text-3xl font-bold`,children:`You're All Set!`}),(0,V.jsx)(`p`,{className:`text-base-content/60 max-w-md`,children:`Here's a summary of your configuration. Hit launch when you're ready.`}),(0,V.jsx)(`div`,{className:`card bg-base-200 w-full max-w-sm`,children:(0,V.jsxs)(`div`,{className:`card-body p-4 gap-2 text-sm text-left`,children:[(0,V.jsxs)(`div`,{className:`flex justify-between gap-4`,children:[(0,V.jsx)(`span`,{className:`text-base-content/60`,children:`Queue title`}),(0,V.jsx)(`span`,{className:`font-semibold text-right break-words`,children:e.queueTitle||`fifony`})]}),(0,V.jsx)(`div`,{className:`divider my-0`}),(0,V.jsxs)(`div`,{className:`flex justify-between`,children:[(0,V.jsx)(`span`,{className:`text-base-content/60`,children:`Pipeline`}),(0,V.jsxs)(`span`,{className:`font-semibold capitalize text-xs font-mono`,children:[e.pipeline?.planner||`?`,` → `,e.pipeline?.executor||`?`,` → `,e.pipeline?.reviewer||`?`]})]}),(0,V.jsx)(`div`,{className:`divider my-0`}),(0,V.jsxs)(`div`,{className:`flex justify-between`,children:[(0,V.jsx)(`span`,{className:`text-base-content/60`,children:`Domains`}),(0,V.jsx)(`span`,{className:`font-semibold`,children:e.domains?.length>0?e.domains.length+` selected`:`none`})]}),(0,V.jsx)(`div`,{className:`divider my-0`}),(0,V.jsxs)(`div`,{className:`flex justify-between`,children:[(0,V.jsx)(`span`,{className:`text-base-content/60`,children:`Agents`}),(0,V.jsxs)(`span`,{className:`font-semibold`,children:[e.agents?.length||0,` to install`]})]}),(0,V.jsx)(`div`,{className:`divider my-0`}),(0,V.jsxs)(`div`,{className:`flex justify-between`,children:[(0,V.jsx)(`span`,{className:`text-base-content/60`,children:`Skills`}),(0,V.jsxs)(`span`,{className:`font-semibold`,children:[e.skills?.length||0,` to install`]})]}),(0,V.jsx)(`div`,{className:`divider my-0`}),(0,V.jsxs)(`div`,{className:`flex justify-between`,children:[(0,V.jsx)(`span`,{className:`text-base-content/60`,children:`Plan`}),(0,V.jsx)(`span`,{className:`font-semibold capitalize`,children:e.efforts.planner})]}),(0,V.jsx)(`div`,{className:`divider my-0`}),(0,V.jsxs)(`div`,{className:`flex justify-between`,children:[(0,V.jsx)(`span`,{className:`text-base-content/60`,children:`Execute`}),(0,V.jsx)(`span`,{className:`font-semibold capitalize`,children:e.efforts.executor})]}),(0,V.jsx)(`div`,{className:`divider my-0`}),(0,V.jsxs)(`div`,{className:`flex justify-between`,children:[(0,V.jsx)(`span`,{className:`text-base-content/60`,children:`Review`}),(0,V.jsx)(`span`,{className:`font-semibold capitalize`,children:e.efforts.reviewer})]}),(0,V.jsx)(`div`,{className:`divider my-0`}),(0,V.jsxs)(`div`,{className:`flex justify-between`,children:[(0,V.jsx)(`span`,{className:`text-base-content/60`,children:`Workers`}),(0,V.jsx)(`span`,{className:`font-semibold`,children:e.concurrency})]}),(0,V.jsx)(`div`,{className:`divider my-0`}),(0,V.jsxs)(`div`,{className:`flex justify-between`,children:[(0,V.jsx)(`span`,{className:`text-base-content/60`,children:`Theme`}),(0,V.jsx)(`span`,{className:`font-semibold capitalize`,children:e.theme})]})]})}),t&&(0,V.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-base-content/50`,children:[(0,V.jsx)(O,{className:`size-4 animate-spin`}),`Saving configuration & installing agents...`]})]})}function Se({onComplete:e}){let t=r(),n=m(),i=p(n.data),[s,c]=(0,B.useState)(0),[h,g]=(0,B.useState)(`forward`),[_,v]=(0,B.useState)(!1),[y,b]=(0,B.useState)(null),x=(0,B.useRef)(!1),S=(0,B.useRef)(!1),[C,E]=(0,B.useState)({planner:``,executor:``,reviewer:``}),[D,O]=(0,B.useState)(()=>oe(null)),[A,j]=(0,B.useState)(3),[M,N]=(0,B.useState)(`auto`),[P,ee]=(0,B.useState)(``),[F,I]=(0,B.useState)(`missing`),[L,R]=(0,B.useState)(null),[z,te]=(0,B.useState)([]),[H,ae]=(0,B.useState)([]),U=ie(),W=re()[s]||``,[G,K]=(0,B.useState)(null),[q,J]=(0,B.useState)(!1),[X,fe]=(0,B.useState)({}),[Z,Q]=(0,B.useState)({plan:``,execute:``,review:``}),[me,he]=(0,B.useState)(``),[ve,ye]=(0,B.useState)(``);(0,B.useEffect)(()=>{o.get(`/state`).then(e=>{R(e||{}),he(e?.sourceRepoUrl||e?.config?.sourceRepo||``),ye(e?.config?.defaultBranch||``)}).catch(()=>{R({})})},[]),(0,B.useEffect)(()=>{if(x.current||n.isLoading)return;x.current=!0;let e=d(i,`runtime.pipeline`,null),t=d(i,`runtime.workflowConfig`,null),r=d(i,`runtime.defaultEffort`,null),a=d(i,`ui.theme`,`auto`),o=d(i,`runtime.workerConcurrency`,3);if(Array.isArray(e)&&e.length>0){let t=Object.fromEntries(e.map(e=>[e.role,e.provider]));E({planner:t.planner||``,executor:t.executor||``,reviewer:t.reviewer||``})}t&&typeof t==`object`&&Q({plan:t.plan?.model||``,execute:t.execute?.model||``,review:t.review?.model||``}),O(oe(r)),typeof a==`string`&&a.trim()&&N(a);let s=Number.parseInt(String(o??2),10);Number.isFinite(s)&&j(Math.min(10,Math.max(1,s)))},[i,n.isLoading]),(0,B.useEffect)(()=>{if(S.current||n.isLoading||L===null)return;S.current=!0;let e=w(i,L);ee(e.projectName),I(e.source)},[L,i,n.isLoading]);let Se=(0,B.useCallback)(e=>{ee(e),I(`manual`)},[]),$=a(P),Ce=T($);(0,B.useEffect)(()=>{document.title=T($||L?.detectedProjectName||L?.projectName||``)},[$,L]),(0,B.useEffect)(()=>{s>=1&&G===null&&(J(!0),Promise.all([o.get(`/providers`),o.get(`/config/workflow?details=1`).catch(()=>null)]).then(([e,t])=>{let n=Array.isArray(e)?e:e?.providers||[];K(n);let r=t?.models||{};fe(r);let i=n.filter(e=>e.available!==!1),a=i[0]?.id||i[0]?.name||``,o=i.find(e=>(e.id||e.name)===`claude`),s=a,c=o?`claude`:s,l={planner:c,executor:s,reviewer:c};E(e=>({planner:e.planner||l.planner,executor:e.executor||l.executor,reviewer:e.reviewer||l.reviewer})),Q(e=>({plan:e.plan||r[c]?.[0]?.id||``,execute:e.execute||r[s]?.[0]?.id||``,review:e.review||r[c]?.[0]?.id||``}))}).catch(()=>{K([])}).finally(()=>{J(!1)}))},[s,G]),(0,B.useEffect)(()=>{let e=M===`auto`?window.matchMedia(`(prefers-color-scheme: dark)`).matches?`dark`:`light`:M;document.documentElement.setAttribute(`data-theme`,e)},[M]);let we=(0,B.useCallback)(e=>{if(e===`Setup`)$&&Y(f,$,`system`).catch(()=>{});else if(e===`Pipeline`){let e=[{provider:C.planner,role:`planner`},{provider:C.executor,role:`executor`},{provider:C.reviewer,role:`reviewer`}];Y(`runtime.agentProvider`,C.executor,`runtime`).catch(()=>{}),Y(`runtime.pipeline`,e,`runtime`).catch(()=>{}),Y(`runtime.defaultEffort`,D,`runtime`).catch(()=>{}),Y(`runtime.workflowConfig`,se(C,D,Z),`runtime`).catch(()=>{})}else e===`Preferences`&&(Y(`ui.theme`,M,`ui`).catch(()=>{}),o.post(`/config/concurrency`,{concurrency:A}).catch(()=>{}))},[C,D,Z,A,M,$]),Te=(0,B.useCallback)(()=>{s<U-1&&(we(W),g(`forward`),c(e=>e+1))},[s,U,W,we]),Ee=(0,B.useCallback)(()=>{s>0&&(g(`backward`),c(e=>e-1))},[s]),De=(0,B.useCallback)(async()=>{if($){v(!0);try{let n=[Y(f,$,`system`),Y(`ui.theme`,M,`ui`),Y(`ui.onboarding.completed`,!0,`ui`)],r=[{provider:C.planner,role:`planner`},{provider:C.executor,role:`executor`},{provider:C.reviewer,role:`reviewer`}];n.push(Y(`runtime.agentProvider`,C.executor,`runtime`)),n.push(Y(`runtime.pipeline`,r,`runtime`)),n.push(Y(`runtime.defaultEffort`,D,`runtime`)),n.push(Y(`runtime.workflowConfig`,se(C,D,Z),`runtime`)),n.push(o.post(`/config/concurrency`,{concurrency:A})),z.length>0&&n.push(o.post(`/install/agents`,{agents:z})),H.length>0&&n.push(o.post(`/install/skills`,{skills:H})),await Promise.allSettled(n),t.setQueryData(u,e=>l(e,{id:f,scope:`system`,value:$,source:`user`,updatedAt:new Date().toISOString()})),t.setQueryData(u,e=>l(e,{id:`ui.onboarding.completed`,scope:`ui`,value:!0,source:`user`,updatedAt:new Date().toISOString()})),b({x:window.innerWidth/2,y:window.innerHeight/3}),setTimeout(()=>{t.invalidateQueries({queryKey:u}),e?.()},1200)}catch{t.setQueryData(u,e=>l(e,{id:f,scope:`system`,value:$,source:`user`,updatedAt:new Date().toISOString()})),t.setQueryData(u,e=>l(e,{id:`ui.onboarding.completed`,scope:`ui`,value:!0,source:`user`,updatedAt:new Date().toISOString()})),await Y(`ui.onboarding.completed`,!0,`ui`).catch(()=>{}),t.invalidateQueries({queryKey:u}),e?.()}}},[$,C,D,Z,A,M,z,H,t,e]),Oe=W===`Welcome`||W===`Setup`&&!!$||W===`Pipeline`&&(C.executor||q)||W===`Agents & Skills`||W===`Preferences`||W===`Launch`,ke=[],Ae=[],je={projectName:$,queueTitle:Ce,pipeline:C,efforts:D,concurrency:A,theme:M,agents:z,skills:H};return(0,V.jsxs)(`div`,{className:`fixed inset-0 z-50 bg-base-100 flex flex-col overflow-hidden`,children:[s===0&&(0,V.jsx)(ne,{}),y&&(0,V.jsx)(k,{x:y.x,y:y.y,active:!0,onDone:()=>b(null)}),s>0&&(0,V.jsx)(`div`,{className:`relative z-10 pt-6 pb-2 px-4 flex justify-center`,children:(0,V.jsx)(ce,{current:s})}),(0,V.jsx)(`div`,{className:`relative z-10 flex-1 flex flex-col items-center justify-start px-4 py-6 overflow-y-auto`,children:(0,V.jsxs)(le,{direction:h,stepKey:s,center:W===`Welcome`||W===`Setup`||W===`Pipeline`||W===`Launch`,children:[W===`Welcome`&&(0,V.jsx)(de,{workspacePath:me,onGetStarted:Te}),W===`Setup`&&(0,V.jsx)(pe,{projectName:P,setProjectName:Se,detectedProjectName:L?.detectedProjectName||``,projectSource:F,workspacePath:me,currentBranch:ve,onBranchCreated:e=>ye(e)}),W===`Pipeline`&&(0,V.jsx)(ge,{providers:G||[],providersLoading:q,pipeline:C,setPipeline:E,efforts:D,setEfforts:O,models:Z,setModels:Q,modelsByProvider:X}),W===`Agents & Skills`&&(0,V.jsx)(_e,{selectedAgents:z,setSelectedAgents:te,selectedSkills:H,setSelectedSkills:ae,existingAgents:ke,existingSkills:Ae}),W===`Preferences`&&(0,V.jsx)(be,{concurrency:A,setConcurrency:j,selectedTheme:M,setSelectedTheme:N}),W===`Launch`&&(0,V.jsx)(xe,{config:je,launching:_})]})}),(0,V.jsx)(ue,{step:s,stepCount:U,stepName:W,canProceed:Oe,launching:_,onBack:Ee,onNext:Te,onLaunch:De})]})}export{Se as default};
@@ -1 +1 @@
1
- import{n as e}from"./rolldown-runtime-DF2fYuay.js";import{I as t,a as n,h as r}from"./vendor-BTlTWMUF.js";import{D as i,I as a,L as o,V as s,b as c,g as l,h as u,m as d,n as f,o as p,s as m,y as h,z as g}from"./index-Dau_ep-t.js";var _=e(t(),1),v=r();function y(e){return!e||e===0?`0`:e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:String(e)}function b(e){return!e||e===0?`0`:e.toLocaleString()}function x({value:e,format:t=y,className:n=``}){let[r,i]=(0,_.useState)(()=>t(e)),a=(0,_.useRef)(e),o=(0,_.useRef)(null);return(0,_.useEffect)(()=>{let n=a.current||0,r=e||0;if(a.current=r,n===r){i(t(r));return}let s=performance.now(),c=e=>{let a=e-s,l=Math.min(a/600,1),u=1-(1-l)**3,d=n+(r-n)*u;i(t(Math.round(d))),l<1&&(o.current=requestAnimationFrame(c))};return cancelAnimationFrame(o.current),o.current=requestAnimationFrame(c),()=>cancelAnimationFrame(o.current)},[e,t]),(0,v.jsx)(`span`,{className:`${n} inline-block tabular-nums`,children:r})}var S=[{key:`planner`,label:`Plan`,color:`bg-info`,textColor:`text-info`},{key:`executor`,label:`Execute`,color:`bg-primary`,textColor:`text-primary`},{key:`reviewer`,label:`Review`,color:`bg-secondary`,textColor:`text-secondary`}];function C({byPhase:e}){if(!e)return null;let t=S.reduce((t,n)=>t+(e[n.key]?.totalTokens||0),0);return t===0?null:(0,v.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,v.jsx)(`div`,{className:`flex h-4 rounded-full overflow-hidden bg-base-300 w-full`,children:S.map(n=>{let r=e[n.key]?.totalTokens||0,i=r/t*100;return i===0?null:(0,v.jsx)(`div`,{className:`${n.color} opacity-80 transition-all duration-500`,style:{width:`${i}%`},title:`${n.label}: ${b(r)} (${Math.round(i)}%)`},n.key)})}),(0,v.jsx)(`div`,{className:`flex items-center gap-3 flex-wrap text-xs`,children:S.map(n=>{let r=e[n.key]?.totalTokens||0,i=t>0?Math.round(r/t*100):0;return r===0?null:(0,v.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,v.jsx)(`span`,{className:`inline-block size-2 rounded-full ${n.color} shrink-0`}),(0,v.jsx)(`span`,{className:`opacity-60`,children:n.label}),(0,v.jsx)(`span`,{className:`font-mono font-semibold`,children:y(r)}),(0,v.jsxs)(`span`,{className:`opacity-40`,children:[`(`,i,`%)`]})]},n.key)})})]})}function w({data:e,valueKey:t,barClass:n,label:r,height:i=64,showXAxis:a=!1,hoveredIdx:o,onHover:s,formatTooltip:c}){if(!e||e.length===0)return null;let l=new Date().toISOString().slice(0,10),u=Math.max(...e.map(e=>e[t]||0),1),d=e.length<=7?1:e.length<=14?2:e.length<=21?3:5,f=o==null?null:e[o],p=o==null?`center`:o<e.length/3?`left`:o>e.length*2/3?`right`:`center`;return(0,v.jsxs)(`div`,{className:`relative`,children:[(0,v.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs opacity-50 mb-2`,children:[(0,v.jsx)(`span`,{className:`inline-block w-2.5 h-2.5 rounded-sm ${n}`}),r]}),f&&(0,v.jsx)(`div`,{className:`absolute top-5 z-10 pointer-events-none`,style:{left:p===`right`?void 0:`${(o+.5)/e.length*100}%`,right:p===`right`?`${(e.length-1-o)/e.length*100}%`:void 0,transform:p===`center`?`translateX(-50%) translateY(-100%)`:`translateY(-100%)`},children:(0,v.jsxs)(`div`,{className:`bg-base-300 border border-base-content/10 rounded-lg px-2.5 py-1.5 shadow-lg text-left whitespace-nowrap`,children:[(0,v.jsx)(`div`,{className:`text-[10px] font-semibold opacity-60 mb-0.5`,children:f.date===l?`Today`:new Date(f.date+`T00:00:00`).toLocaleDateString(void 0,{weekday:`short`,month:`short`,day:`numeric`})}),(0,v.jsxs)(`span`,{className:`flex items-center gap-1.5 text-xs`,children:[(0,v.jsx)(`span`,{className:`inline-block w-2 h-2 rounded-sm ${n} shrink-0`}),(0,v.jsx)(`span`,{className:`font-mono font-semibold`,children:c?c(f[t]||0):(f[t]||0).toLocaleString()})]})]})}),(0,v.jsx)(`div`,{className:`flex gap-px`,style:{height:i},children:e.map((e,r)=>{let a=e[t]||0,c=a>0?Math.max(3,Math.round(a/u*i)):0,d=e.date===l,f=o===r;return(0,v.jsxs)(`div`,{className:`flex-1 relative cursor-default`,onMouseEnter:()=>s?.(r),onMouseLeave:()=>s?.(null),children:[c>0&&(0,v.jsx)(`div`,{className:`absolute bottom-0 left-0 right-0 rounded-t-[2px] ${n} transition-opacity duration-100 ${f?`opacity-80`:d?`opacity-90`:`opacity-35`}`,style:{height:c}}),f&&(0,v.jsx)(`div`,{className:`absolute inset-0 bg-base-content/5 rounded-sm`})]},e.date)})}),a&&(0,v.jsx)(`div`,{className:`flex gap-px mt-1.5`,children:e.map((e,t)=>{let n=e.date===l,r=o===t,i=n||t===0||t%d===0,a=e.date?new Date(e.date+`T00:00:00`).toLocaleDateString(void 0,{month:`numeric`,day:`numeric`}):``;return(0,v.jsx)(`div`,{className:`flex-1 overflow-hidden`,children:i&&(0,v.jsx)(`span`,{className:`block text-center text-[9px] truncate transition-opacity duration-100 ${r?`opacity-80`:n?`opacity-60 font-semibold`:`opacity-30`}`,children:n?`today`:a})},e.date)})})]})}function T({daily:e}){let[t,n]=(0,_.useState)(null),r=e||[];return(0,v.jsxs)(`div`,{className:`space-y-4`,children:[(0,v.jsx)(w,{data:r,valueKey:`totalTokens`,barClass:`bg-primary`,label:`Tokens / day`,height:64,showXAxis:!1,hoveredIdx:t,onHover:n,formatTooltip:e=>e.toLocaleString()}),(0,v.jsx)(w,{data:r,valueKey:`events`,barClass:`bg-secondary`,label:`Events / day`,height:36,showXAxis:!0,hoveredIdx:t,onHover:n})]})}function E({byModel:e}){if(!e)return null;let t=Object.entries(e).map(([e,t])=>({model:e,inputTokens:t?.inputTokens||0,outputTokens:t?.outputTokens||0,totalTokens:t?.totalTokens||0})).sort((e,t)=>t.totalTokens-e.totalTokens);if(t.length===0)return null;let n=t.reduce((e,t)=>e+t.totalTokens,0);return(0,v.jsx)(`div`,{className:`overflow-x-auto`,children:(0,v.jsxs)(`table`,{className:`table table-sm`,children:[(0,v.jsx)(`thead`,{children:(0,v.jsxs)(`tr`,{children:[(0,v.jsx)(`th`,{children:`Model`}),(0,v.jsx)(`th`,{className:`text-right`,children:`Input`}),(0,v.jsx)(`th`,{className:`text-right`,children:`Output`}),(0,v.jsx)(`th`,{className:`text-right`,children:`Total`}),(0,v.jsx)(`th`,{className:`text-right`,children:`Share`})]})}),(0,v.jsx)(`tbody`,{children:t.map(e=>{let t=n>0?Math.round(e.totalTokens/n*100):0,r=e.model.includes(`claude`)?`bg-primary`:e.model.includes(`codex`)?`bg-secondary`:`bg-accent`;return(0,v.jsxs)(`tr`,{children:[(0,v.jsxs)(`td`,{className:`flex items-center gap-2`,children:[(0,v.jsx)(`span`,{className:`inline-block w-2.5 h-2.5 rounded-full ${r} shrink-0`}),(0,v.jsx)(`span`,{className:`font-mono text-xs`,children:e.model})]}),(0,v.jsx)(`td`,{className:`text-right font-mono text-xs`,children:y(e.inputTokens)}),(0,v.jsx)(`td`,{className:`text-right font-mono text-xs`,children:y(e.outputTokens)}),(0,v.jsx)(`td`,{className:`text-right font-mono text-xs font-semibold`,children:y(e.totalTokens)}),(0,v.jsx)(`td`,{className:`text-right`,children:(0,v.jsxs)(`div`,{className:`flex items-center justify-end gap-1.5`,children:[(0,v.jsx)(`div`,{className:`w-12 h-1.5 bg-base-300 rounded-full overflow-hidden`,children:(0,v.jsx)(`div`,{className:`h-full ${r} rounded-full`,style:{width:`${t}%`}})}),(0,v.jsxs)(`span`,{className:`text-xs opacity-60 w-8 text-right`,children:[t,`%`]})]})})]},e.model)})})]})})}function D({topIssues:e}){return!e||e.length===0?null:(0,v.jsx)(`div`,{className:`overflow-x-auto`,children:(0,v.jsxs)(`table`,{className:`table table-sm`,children:[(0,v.jsx)(`thead`,{children:(0,v.jsxs)(`tr`,{children:[(0,v.jsx)(`th`,{className:`w-20`,children:`Issue`}),(0,v.jsx)(`th`,{children:`Title`}),(0,v.jsx)(`th`,{className:`text-right`,children:`Tokens`}),(0,v.jsx)(`th`,{className:`hidden sm:table-cell`,children:`Phase Split`})]})}),(0,v.jsx)(`tbody`,{children:e.slice(0,10).map(e=>{let t=e.byPhase,n=e.totalTokens||0;return(0,v.jsxs)(`tr`,{children:[(0,v.jsx)(`td`,{className:`font-mono text-xs font-semibold text-primary`,children:e.identifier}),(0,v.jsx)(`td`,{className:`max-w-[200px] truncate text-sm`,title:e.title,children:e.title||`-`}),(0,v.jsx)(`td`,{className:`text-right font-mono text-xs font-semibold`,children:y(n)}),(0,v.jsx)(`td`,{className:`hidden sm:table-cell`,children:t?(0,v.jsx)(`div`,{className:`flex h-1.5 rounded-full overflow-hidden bg-base-300 w-24`,children:S.map(e=>{let r=t[e.key]?.totalTokens||0,i=n>0?r/n*100:0;return i===0?null:(0,v.jsx)(`div`,{className:`${e.color} opacity-80`,style:{width:`${i}%`},title:`${e.label}: ${y(r)}`},e.key)})}):(0,v.jsx)(`span`,{className:`opacity-30 text-xs`,children:`-`})})]},e.id||e.identifier)})})]})})}function O({daily:e}){let t=e||[],[n,r]=(0,_.useState)(null),i=new Date().toISOString().slice(0,10),a=Math.max(...t.map(e=>e.linesAdded||0),1),o=Math.max(...t.map(e=>e.linesRemoved||0),1),s=t.length<=7?1:t.length<=14?2:t.length<=21?3:5,c=n==null?null:t[n],l=n==null?`center`:n<t.length/3?`left`:n>t.length*2/3?`right`:`center`;return(0,v.jsxs)(`div`,{children:[(0,v.jsxs)(`div`,{className:`flex items-center gap-5 mb-3`,children:[(0,v.jsxs)(`span`,{className:`flex items-center gap-1.5 text-xs opacity-50`,children:[(0,v.jsx)(`span`,{className:`inline-block w-2.5 h-2.5 rounded-sm bg-success`}),`Lines added / day`]}),(0,v.jsxs)(`span`,{className:`flex items-center gap-1.5 text-xs opacity-50`,children:[(0,v.jsx)(`span`,{className:`inline-block w-2.5 h-2.5 rounded-sm bg-error`}),`Lines removed / day`]})]}),(0,v.jsxs)(`div`,{className:`relative`,children:[c&&(0,v.jsx)(`div`,{className:`absolute -top-1 z-10 pointer-events-none`,style:{left:l===`right`?void 0:`${(n+.5)/t.length*100}%`,right:l===`right`?`${(t.length-1-n)/t.length*100}%`:void 0,transform:l===`center`?`translateX(-50%) translateY(-100%)`:`translateY(-100%)`},children:(0,v.jsxs)(`div`,{className:`bg-base-300 border border-base-content/10 rounded-lg px-2.5 py-1.5 shadow-lg text-left whitespace-nowrap`,children:[(0,v.jsx)(`div`,{className:`text-[10px] font-semibold opacity-60 mb-1`,children:c.date===i?`Today`:new Date(c.date+`T00:00:00`).toLocaleDateString(void 0,{weekday:`short`,month:`short`,day:`numeric`})}),(0,v.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,v.jsxs)(`span`,{className:`flex items-center gap-1.5 text-xs`,children:[(0,v.jsx)(`span`,{className:`inline-block w-2 h-2 rounded-sm bg-success shrink-0`}),(0,v.jsxs)(`span`,{className:`font-mono font-semibold`,children:[`+`,(c.linesAdded||0).toLocaleString()]}),(0,v.jsx)(`span`,{className:`opacity-50`,children:`added`})]}),(0,v.jsxs)(`span`,{className:`flex items-center gap-1.5 text-xs`,children:[(0,v.jsx)(`span`,{className:`inline-block w-2 h-2 rounded-sm bg-error shrink-0`}),(0,v.jsxs)(`span`,{className:`font-mono font-semibold`,children:[`-`,(c.linesRemoved||0).toLocaleString()]}),(0,v.jsx)(`span`,{className:`opacity-50`,children:`removed`})]}),(c.filesChanged||0)>0&&(0,v.jsx)(`span`,{className:`flex items-center gap-1.5 text-xs`,children:(0,v.jsxs)(`span`,{className:`opacity-50`,children:[c.filesChanged,` file`,c.filesChanged===1?``:`s`]})})]})]})}),(0,v.jsx)(`div`,{className:`flex gap-px`,children:t.map((e,t)=>{let s=e.linesAdded||0,c=e.linesRemoved||0,l=s>0?Math.max(3,Math.round(s/a*64)):0,u=c>0?Math.max(3,Math.round(c/o*24)):0,d=e.date===i,f=n===t;return(0,v.jsxs)(`div`,{className:`flex-1 flex flex-col cursor-default`,onMouseEnter:()=>r(t),onMouseLeave:()=>r(null),children:[(0,v.jsxs)(`div`,{className:`relative`,style:{height:64},children:[l>0&&(0,v.jsx)(`div`,{className:`absolute bottom-0 left-0 right-0 rounded-t-[2px] bg-success transition-opacity duration-100 ${f?`opacity-80`:d?`opacity-90`:`opacity-35`}`,style:{height:l}}),f&&(0,v.jsx)(`div`,{className:`absolute inset-0 bg-base-content/5 rounded-sm`})]}),(0,v.jsx)(`div`,{className:`h-px transition-colors duration-100 ${f?`bg-base-content/20`:`bg-base-300`}`}),(0,v.jsxs)(`div`,{className:`relative`,style:{height:24},children:[u>0&&(0,v.jsx)(`div`,{className:`absolute bottom-0 left-0 right-0 rounded-t-[2px] bg-error transition-opacity duration-100 ${f?`opacity-80`:d?`opacity-90`:`opacity-35`}`,style:{height:u}}),f&&(0,v.jsx)(`div`,{className:`absolute inset-0 bg-base-content/5 rounded-sm`})]})]},e.date)})}),(0,v.jsx)(`div`,{className:`flex gap-px mt-1.5`,children:t.map((e,t)=>{let r=e.date===i,a=n===t,o=r||t===0||t%s===0,c=e.date?new Date(e.date+`T00:00:00`).toLocaleDateString(void 0,{month:`numeric`,day:`numeric`}):``;return(0,v.jsx)(`div`,{className:`flex-1 overflow-hidden`,children:o&&(0,v.jsx)(`span`,{className:`block text-center text-[9px] truncate transition-opacity duration-100 ${a?`opacity-80`:r?`opacity-60 font-semibold`:`opacity-30`}`,children:r?`today`:c})},e.date)})})]})]})}function k(e){return e==null||!Number.isFinite(e)?`–`:e<1/24?`${Math.round(e*24*60)}m`:e<1?`${(e*24).toFixed(1)}h`:`${e.toFixed(1)}d`}function A(e){return e==null||!Number.isFinite(e)?`–`:e>=1e3?`${(e/1e3).toFixed(1)}K`:Math.round(e).toString()}function j({icon:e,iconClass:t,title:n,avg:r,median:i,n:a,formatValue:o,unit:s}){return(0,v.jsxs)(`div`,{className:`stat bg-base-200 rounded-box`,children:[(0,v.jsx)(`div`,{className:`stat-figure ${t}`,children:(0,v.jsx)(e,{className:`size-6`})}),(0,v.jsx)(`div`,{className:`stat-title`,children:n}),(0,v.jsxs)(`div`,{className:`stat-value text-2xl ${t}`,children:[o(r),s&&(0,v.jsx)(`span`,{className:`text-base font-normal opacity-50 ml-1`,children:s})]}),(0,v.jsxs)(`div`,{className:`stat-desc`,children:[i==null?`–`:`median ${o(i)}`,a!=null&&(0,v.jsxs)(`span`,{className:`opacity-40`,children:[` · n=`,a]})]})]})}function M(){return(0,v.jsx)(`div`,{className:`flex-1 flex flex-col min-h-0 px-4 pb-4 pt-3`,children:(0,v.jsxs)(`div`,{className:`max-w-6xl w-full mx-auto space-y-6`,children:[(0,v.jsx)(`div`,{className:`skeleton-line h-8 w-48`}),(0,v.jsx)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4`,children:[...[,,,]].map((e,t)=>(0,v.jsx)(`div`,{className:`skeleton-card h-28`,style:{animationDelay:`${t*80}ms`}},t))}),(0,v.jsx)(`div`,{className:`skeleton-card h-52`}),(0,v.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[(0,v.jsx)(`div`,{className:`skeleton-card h-32`}),(0,v.jsx)(`div`,{className:`skeleton-card h-32`})]}),(0,v.jsx)(`div`,{className:`skeleton-card h-64`})]})})}var N=n(`/analytics`)({component:P});function P(){let{data:e,isLoading:t}=g(),{data:n}=a(),{data:r}=o();if(t&&!e)return(0,v.jsx)(M,{});let _=e?.overall?.totalTokens||0,S=e?.byPhase||null,w=e?.byModel||{},N=s(e?.daily,32),P=e?.topIssues||[],F=new Date().toISOString().slice(0,10),I=N.find(e=>e.date===F),L=I?.totalTokens||0,R=N.reduce((e,t)=>e+(t.totalTokens||0),0),z=N.reduce((e,t)=>e+(t.events||0),0),B=I?.events||0,V=(()=>{let e=new Map((n?.lines||[]).filter(e=>e.date).map(e=>[e.date,e])),t=[];for(let n=31;n>=0;n--){let r=new Date;r.setDate(r.getDate()-n);let i=r.toISOString().slice(0,10);t.push(e.get(i)??{date:i,linesAdded:0,linesRemoved:0,filesChanged:0})}return t})(),H=V.reduce((e,t)=>e+(t.linesAdded||0),0),U=V.reduce((e,t)=>e+(t.linesRemoved||0),0),W=r?.ok?r:null;return(0,v.jsx)(`div`,{className:`flex-1 flex flex-col min-h-0 px-4 pb-4 pt-3 overflow-y-auto`,children:(0,v.jsxs)(`div`,{className:`max-w-6xl w-full mx-auto space-y-6 stagger-children`,children:[(0,v.jsx)(`section`,{children:(0,v.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-7 gap-4`,children:[(0,v.jsxs)(`div`,{className:`stat bg-base-200 rounded-box`,children:[(0,v.jsx)(`div`,{className:`stat-figure text-primary`,children:(0,v.jsx)(f,{className:`size-6`})}),(0,v.jsx)(`div`,{className:`stat-title`,children:`Total Tokens`}),(0,v.jsx)(`div`,{className:`stat-value text-2xl`,children:(0,v.jsx)(x,{value:_})}),(0,v.jsx)(`div`,{className:`stat-desc font-mono`,children:b(_)})]}),(0,v.jsxs)(`div`,{className:`stat bg-base-200 rounded-box`,children:[(0,v.jsx)(`div`,{className:`stat-figure text-accent`,children:(0,v.jsx)(c,{className:`size-6`})}),(0,v.jsx)(`div`,{className:`stat-title`,children:`Tokens Today`}),(0,v.jsx)(`div`,{className:`stat-value text-2xl`,children:(0,v.jsx)(x,{value:L})}),(0,v.jsxs)(`div`,{className:`stat-desc`,children:[`30d: `,y(R)]})]}),(0,v.jsxs)(`div`,{className:`stat bg-base-200 rounded-box`,children:[(0,v.jsx)(`div`,{className:`stat-figure text-secondary`,children:(0,v.jsx)(i,{className:`size-6`})}),(0,v.jsx)(`div`,{className:`stat-title`,children:`Total Events`}),(0,v.jsx)(`div`,{className:`stat-value text-2xl`,children:(0,v.jsx)(x,{value:z,format:e=>String(e||0)})}),(0,v.jsxs)(`div`,{className:`stat-desc`,children:[`Today: `,B]})]}),(0,v.jsxs)(`div`,{className:`stat bg-base-200 rounded-box xl:col-span-2 overflow-hidden`,children:[(0,v.jsx)(`div`,{className:`stat-figure text-info`,children:(0,v.jsx)(d,{className:`size-6`})}),(0,v.jsx)(`div`,{className:`stat-title`,children:`Phase Split`}),(0,v.jsx)(`div`,{className:`stat-value text-2xl p-0`,children:S?(0,v.jsx)(C,{byPhase:S}):(0,v.jsx)(`span`,{className:`opacity-30`,children:`-`})})]}),(0,v.jsxs)(`div`,{className:`stat bg-base-200 rounded-box`,children:[(0,v.jsx)(`div`,{className:`stat-figure text-success`,children:(0,v.jsx)(l,{className:`size-6`})}),(0,v.jsx)(`div`,{className:`stat-title`,children:`Lines Added`}),(0,v.jsx)(`div`,{className:`stat-value text-2xl text-success`,children:(0,v.jsx)(x,{value:H,format:e=>e>=1e3?`${(e/1e3).toFixed(1)}K`:String(e||0)})}),(0,v.jsx)(`div`,{className:`stat-desc`,children:`30d total`})]}),(0,v.jsxs)(`div`,{className:`stat bg-base-200 rounded-box`,children:[(0,v.jsx)(`div`,{className:`stat-figure text-error`,children:(0,v.jsx)(l,{className:`size-6`})}),(0,v.jsx)(`div`,{className:`stat-title`,children:`Lines Removed`}),(0,v.jsx)(`div`,{className:`stat-value text-2xl text-error`,children:(0,v.jsx)(x,{value:U,format:e=>e>=1e3?`${(e/1e3).toFixed(1)}K`:String(e||0)})}),(0,v.jsx)(`div`,{className:`stat-desc`,children:`30d total`})]})]})}),(0,v.jsxs)(`section`,{className:`bg-base-200 rounded-box p-5`,children:[(0,v.jsx)(`div`,{className:`flex items-center justify-between mb-4`,children:(0,v.jsxs)(`h2`,{className:`text-sm font-semibold flex items-center gap-2`,children:[(0,v.jsx)(p,{className:`size-4 text-primary`}),`Daily Activity`]})}),(0,v.jsx)(T,{daily:N}),(0,v.jsx)(`div`,{className:`border-t border-base-300 my-5`}),(0,v.jsx)(O,{daily:V})]}),(0,v.jsxs)(`section`,{className:`bg-base-200 rounded-box p-5`,children:[(0,v.jsxs)(`h2`,{className:`text-sm font-semibold flex items-center gap-2 mb-4`,children:[(0,v.jsx)(m,{className:`size-4 text-warning`}),`Engineering KPIs`,W?.sampleSize>0&&(0,v.jsxs)(`span`,{className:`text-xs font-normal opacity-40 ml-1`,children:[`based on `,W.sampleSize,` completed issue`,W.sampleSize===1?``:`s`]})]}),(0,v.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 xl:grid-cols-4 gap-4`,children:[(0,v.jsx)(j,{icon:c,iconClass:`text-primary`,title:`Issue Cycle Time`,avg:W?.issueCycleTimeDays?.avg??null,median:W?.issueCycleTimeDays?.median??null,n:W?.issueCycleTimeDays?.n??null,formatValue:k}),(0,v.jsx)(j,{icon:u,iconClass:`text-secondary`,title:`PR Cycle Time`,avg:W?.prCycleTimeDays?.avg??null,median:W?.prCycleTimeDays?.median??null,n:W?.prCycleTimeDays?.n??null,formatValue:k}),(0,v.jsx)(j,{icon:m,iconClass:`text-warning`,title:`Review Turnaround`,avg:W?.reviewTurnaroundDays?.avg??null,median:W?.reviewTurnaroundDays?.median??null,n:W?.reviewTurnaroundDays?.n??null,formatValue:k}),(0,v.jsx)(j,{icon:l,iconClass:`text-info`,title:`PR Size`,avg:W?.prSizeLines?.avg??null,median:W?.prSizeLines?.median??null,n:W?.prSizeLines?.n??null,formatValue:A,unit:`lines`})]})]}),P.length>0&&(0,v.jsxs)(`section`,{className:`bg-base-200 rounded-box p-5`,children:[(0,v.jsxs)(`h2`,{className:`text-sm font-semibold flex items-center gap-2 mb-4`,children:[(0,v.jsx)(f,{className:`size-4 text-accent`}),`Top Issues by Token Usage`]}),(0,v.jsx)(D,{topIssues:P})]}),Object.keys(w).length>0&&(0,v.jsxs)(`section`,{className:`bg-base-200 rounded-box p-5`,children:[(0,v.jsxs)(`h2`,{className:`text-sm font-semibold flex items-center gap-2 mb-4`,children:[(0,v.jsx)(h,{className:`size-4 text-info`}),`Model Breakdown`]}),(0,v.jsx)(E,{byModel:w})]})]})})}export{N as Route};
1
+ import{n as e}from"./rolldown-runtime-DF2fYuay.js";import{I as t,a as n,h as r}from"./vendor-BTlTWMUF.js";import{D as i,I as a,L as o,V as s,b as c,g as l,h as u,m as d,n as f,o as p,s as m,y as h,z as g}from"./index-fVSxs9d5.js";var _=e(t(),1),v=r();function y(e){return!e||e===0?`0`:e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:String(e)}function b(e){return!e||e===0?`0`:e.toLocaleString()}function x({value:e,format:t=y,className:n=``}){let[r,i]=(0,_.useState)(()=>t(e)),a=(0,_.useRef)(e),o=(0,_.useRef)(null);return(0,_.useEffect)(()=>{let n=a.current||0,r=e||0;if(a.current=r,n===r){i(t(r));return}let s=performance.now(),c=e=>{let a=e-s,l=Math.min(a/600,1),u=1-(1-l)**3,d=n+(r-n)*u;i(t(Math.round(d))),l<1&&(o.current=requestAnimationFrame(c))};return cancelAnimationFrame(o.current),o.current=requestAnimationFrame(c),()=>cancelAnimationFrame(o.current)},[e,t]),(0,v.jsx)(`span`,{className:`${n} inline-block tabular-nums`,children:r})}var S=[{key:`planner`,label:`Plan`,color:`bg-info`,textColor:`text-info`},{key:`executor`,label:`Execute`,color:`bg-primary`,textColor:`text-primary`},{key:`reviewer`,label:`Review`,color:`bg-secondary`,textColor:`text-secondary`}];function C({byPhase:e}){if(!e)return null;let t=S.reduce((t,n)=>t+(e[n.key]?.totalTokens||0),0);return t===0?null:(0,v.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,v.jsx)(`div`,{className:`flex h-4 rounded-full overflow-hidden bg-base-300 w-full`,children:S.map(n=>{let r=e[n.key]?.totalTokens||0,i=r/t*100;return i===0?null:(0,v.jsx)(`div`,{className:`${n.color} opacity-80 transition-all duration-500`,style:{width:`${i}%`},title:`${n.label}: ${b(r)} (${Math.round(i)}%)`},n.key)})}),(0,v.jsx)(`div`,{className:`flex items-center gap-3 flex-wrap text-xs`,children:S.map(n=>{let r=e[n.key]?.totalTokens||0,i=t>0?Math.round(r/t*100):0;return r===0?null:(0,v.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,v.jsx)(`span`,{className:`inline-block size-2 rounded-full ${n.color} shrink-0`}),(0,v.jsx)(`span`,{className:`opacity-60`,children:n.label}),(0,v.jsx)(`span`,{className:`font-mono font-semibold`,children:y(r)}),(0,v.jsxs)(`span`,{className:`opacity-40`,children:[`(`,i,`%)`]})]},n.key)})})]})}function w({data:e,valueKey:t,barClass:n,label:r,height:i=64,showXAxis:a=!1,hoveredIdx:o,onHover:s,formatTooltip:c}){if(!e||e.length===0)return null;let l=new Date().toISOString().slice(0,10),u=Math.max(...e.map(e=>e[t]||0),1),d=e.length<=7?1:e.length<=14?2:e.length<=21?3:5,f=o==null?null:e[o],p=o==null?`center`:o<e.length/3?`left`:o>e.length*2/3?`right`:`center`;return(0,v.jsxs)(`div`,{className:`relative`,children:[(0,v.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs opacity-50 mb-2`,children:[(0,v.jsx)(`span`,{className:`inline-block w-2.5 h-2.5 rounded-sm ${n}`}),r]}),f&&(0,v.jsx)(`div`,{className:`absolute top-5 z-10 pointer-events-none`,style:{left:p===`right`?void 0:`${(o+.5)/e.length*100}%`,right:p===`right`?`${(e.length-1-o)/e.length*100}%`:void 0,transform:p===`center`?`translateX(-50%) translateY(-100%)`:`translateY(-100%)`},children:(0,v.jsxs)(`div`,{className:`bg-base-300 border border-base-content/10 rounded-lg px-2.5 py-1.5 shadow-lg text-left whitespace-nowrap`,children:[(0,v.jsx)(`div`,{className:`text-[10px] font-semibold opacity-60 mb-0.5`,children:f.date===l?`Today`:new Date(f.date+`T00:00:00`).toLocaleDateString(void 0,{weekday:`short`,month:`short`,day:`numeric`})}),(0,v.jsxs)(`span`,{className:`flex items-center gap-1.5 text-xs`,children:[(0,v.jsx)(`span`,{className:`inline-block w-2 h-2 rounded-sm ${n} shrink-0`}),(0,v.jsx)(`span`,{className:`font-mono font-semibold`,children:c?c(f[t]||0):(f[t]||0).toLocaleString()})]})]})}),(0,v.jsx)(`div`,{className:`flex gap-px`,style:{height:i},children:e.map((e,r)=>{let a=e[t]||0,c=a>0?Math.max(3,Math.round(a/u*i)):0,d=e.date===l,f=o===r;return(0,v.jsxs)(`div`,{className:`flex-1 relative cursor-default`,onMouseEnter:()=>s?.(r),onMouseLeave:()=>s?.(null),children:[c>0&&(0,v.jsx)(`div`,{className:`absolute bottom-0 left-0 right-0 rounded-t-[2px] ${n} transition-opacity duration-100 ${f?`opacity-80`:d?`opacity-90`:`opacity-35`}`,style:{height:c}}),f&&(0,v.jsx)(`div`,{className:`absolute inset-0 bg-base-content/5 rounded-sm`})]},e.date)})}),a&&(0,v.jsx)(`div`,{className:`flex gap-px mt-1.5`,children:e.map((e,t)=>{let n=e.date===l,r=o===t,i=n||t===0||t%d===0,a=e.date?new Date(e.date+`T00:00:00`).toLocaleDateString(void 0,{month:`numeric`,day:`numeric`}):``;return(0,v.jsx)(`div`,{className:`flex-1 overflow-hidden`,children:i&&(0,v.jsx)(`span`,{className:`block text-center text-[9px] truncate transition-opacity duration-100 ${r?`opacity-80`:n?`opacity-60 font-semibold`:`opacity-30`}`,children:n?`today`:a})},e.date)})})]})}function T({daily:e}){let[t,n]=(0,_.useState)(null),r=e||[];return(0,v.jsxs)(`div`,{className:`space-y-4`,children:[(0,v.jsx)(w,{data:r,valueKey:`totalTokens`,barClass:`bg-primary`,label:`Tokens / day`,height:64,showXAxis:!1,hoveredIdx:t,onHover:n,formatTooltip:e=>e.toLocaleString()}),(0,v.jsx)(w,{data:r,valueKey:`events`,barClass:`bg-secondary`,label:`Events / day`,height:36,showXAxis:!0,hoveredIdx:t,onHover:n})]})}function E({byModel:e}){if(!e)return null;let t=Object.entries(e).map(([e,t])=>({model:e,inputTokens:t?.inputTokens||0,outputTokens:t?.outputTokens||0,totalTokens:t?.totalTokens||0})).sort((e,t)=>t.totalTokens-e.totalTokens);if(t.length===0)return null;let n=t.reduce((e,t)=>e+t.totalTokens,0);return(0,v.jsx)(`div`,{className:`overflow-x-auto`,children:(0,v.jsxs)(`table`,{className:`table table-sm`,children:[(0,v.jsx)(`thead`,{children:(0,v.jsxs)(`tr`,{children:[(0,v.jsx)(`th`,{children:`Model`}),(0,v.jsx)(`th`,{className:`text-right`,children:`Input`}),(0,v.jsx)(`th`,{className:`text-right`,children:`Output`}),(0,v.jsx)(`th`,{className:`text-right`,children:`Total`}),(0,v.jsx)(`th`,{className:`text-right`,children:`Share`})]})}),(0,v.jsx)(`tbody`,{children:t.map(e=>{let t=n>0?Math.round(e.totalTokens/n*100):0,r=e.model.includes(`claude`)?`bg-primary`:e.model.includes(`codex`)?`bg-secondary`:`bg-accent`;return(0,v.jsxs)(`tr`,{children:[(0,v.jsxs)(`td`,{className:`flex items-center gap-2`,children:[(0,v.jsx)(`span`,{className:`inline-block w-2.5 h-2.5 rounded-full ${r} shrink-0`}),(0,v.jsx)(`span`,{className:`font-mono text-xs`,children:e.model})]}),(0,v.jsx)(`td`,{className:`text-right font-mono text-xs`,children:y(e.inputTokens)}),(0,v.jsx)(`td`,{className:`text-right font-mono text-xs`,children:y(e.outputTokens)}),(0,v.jsx)(`td`,{className:`text-right font-mono text-xs font-semibold`,children:y(e.totalTokens)}),(0,v.jsx)(`td`,{className:`text-right`,children:(0,v.jsxs)(`div`,{className:`flex items-center justify-end gap-1.5`,children:[(0,v.jsx)(`div`,{className:`w-12 h-1.5 bg-base-300 rounded-full overflow-hidden`,children:(0,v.jsx)(`div`,{className:`h-full ${r} rounded-full`,style:{width:`${t}%`}})}),(0,v.jsxs)(`span`,{className:`text-xs opacity-60 w-8 text-right`,children:[t,`%`]})]})})]},e.model)})})]})})}function D({topIssues:e}){return!e||e.length===0?null:(0,v.jsx)(`div`,{className:`overflow-x-auto`,children:(0,v.jsxs)(`table`,{className:`table table-sm`,children:[(0,v.jsx)(`thead`,{children:(0,v.jsxs)(`tr`,{children:[(0,v.jsx)(`th`,{className:`w-20`,children:`Issue`}),(0,v.jsx)(`th`,{children:`Title`}),(0,v.jsx)(`th`,{className:`text-right`,children:`Tokens`}),(0,v.jsx)(`th`,{className:`hidden sm:table-cell`,children:`Phase Split`})]})}),(0,v.jsx)(`tbody`,{children:e.slice(0,10).map(e=>{let t=e.byPhase,n=e.totalTokens||0;return(0,v.jsxs)(`tr`,{children:[(0,v.jsx)(`td`,{className:`font-mono text-xs font-semibold text-primary`,children:e.identifier}),(0,v.jsx)(`td`,{className:`max-w-[200px] truncate text-sm`,title:e.title,children:e.title||`-`}),(0,v.jsx)(`td`,{className:`text-right font-mono text-xs font-semibold`,children:y(n)}),(0,v.jsx)(`td`,{className:`hidden sm:table-cell`,children:t?(0,v.jsx)(`div`,{className:`flex h-1.5 rounded-full overflow-hidden bg-base-300 w-24`,children:S.map(e=>{let r=t[e.key]?.totalTokens||0,i=n>0?r/n*100:0;return i===0?null:(0,v.jsx)(`div`,{className:`${e.color} opacity-80`,style:{width:`${i}%`},title:`${e.label}: ${y(r)}`},e.key)})}):(0,v.jsx)(`span`,{className:`opacity-30 text-xs`,children:`-`})})]},e.id||e.identifier)})})]})})}function O({daily:e}){let t=e||[],[n,r]=(0,_.useState)(null),i=new Date().toISOString().slice(0,10),a=Math.max(...t.map(e=>e.linesAdded||0),1),o=Math.max(...t.map(e=>e.linesRemoved||0),1),s=t.length<=7?1:t.length<=14?2:t.length<=21?3:5,c=n==null?null:t[n],l=n==null?`center`:n<t.length/3?`left`:n>t.length*2/3?`right`:`center`;return(0,v.jsxs)(`div`,{children:[(0,v.jsxs)(`div`,{className:`flex items-center gap-5 mb-3`,children:[(0,v.jsxs)(`span`,{className:`flex items-center gap-1.5 text-xs opacity-50`,children:[(0,v.jsx)(`span`,{className:`inline-block w-2.5 h-2.5 rounded-sm bg-success`}),`Lines added / day`]}),(0,v.jsxs)(`span`,{className:`flex items-center gap-1.5 text-xs opacity-50`,children:[(0,v.jsx)(`span`,{className:`inline-block w-2.5 h-2.5 rounded-sm bg-error`}),`Lines removed / day`]})]}),(0,v.jsxs)(`div`,{className:`relative`,children:[c&&(0,v.jsx)(`div`,{className:`absolute -top-1 z-10 pointer-events-none`,style:{left:l===`right`?void 0:`${(n+.5)/t.length*100}%`,right:l===`right`?`${(t.length-1-n)/t.length*100}%`:void 0,transform:l===`center`?`translateX(-50%) translateY(-100%)`:`translateY(-100%)`},children:(0,v.jsxs)(`div`,{className:`bg-base-300 border border-base-content/10 rounded-lg px-2.5 py-1.5 shadow-lg text-left whitespace-nowrap`,children:[(0,v.jsx)(`div`,{className:`text-[10px] font-semibold opacity-60 mb-1`,children:c.date===i?`Today`:new Date(c.date+`T00:00:00`).toLocaleDateString(void 0,{weekday:`short`,month:`short`,day:`numeric`})}),(0,v.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,v.jsxs)(`span`,{className:`flex items-center gap-1.5 text-xs`,children:[(0,v.jsx)(`span`,{className:`inline-block w-2 h-2 rounded-sm bg-success shrink-0`}),(0,v.jsxs)(`span`,{className:`font-mono font-semibold`,children:[`+`,(c.linesAdded||0).toLocaleString()]}),(0,v.jsx)(`span`,{className:`opacity-50`,children:`added`})]}),(0,v.jsxs)(`span`,{className:`flex items-center gap-1.5 text-xs`,children:[(0,v.jsx)(`span`,{className:`inline-block w-2 h-2 rounded-sm bg-error shrink-0`}),(0,v.jsxs)(`span`,{className:`font-mono font-semibold`,children:[`-`,(c.linesRemoved||0).toLocaleString()]}),(0,v.jsx)(`span`,{className:`opacity-50`,children:`removed`})]}),(c.filesChanged||0)>0&&(0,v.jsx)(`span`,{className:`flex items-center gap-1.5 text-xs`,children:(0,v.jsxs)(`span`,{className:`opacity-50`,children:[c.filesChanged,` file`,c.filesChanged===1?``:`s`]})})]})]})}),(0,v.jsx)(`div`,{className:`flex gap-px`,children:t.map((e,t)=>{let s=e.linesAdded||0,c=e.linesRemoved||0,l=s>0?Math.max(3,Math.round(s/a*64)):0,u=c>0?Math.max(3,Math.round(c/o*24)):0,d=e.date===i,f=n===t;return(0,v.jsxs)(`div`,{className:`flex-1 flex flex-col cursor-default`,onMouseEnter:()=>r(t),onMouseLeave:()=>r(null),children:[(0,v.jsxs)(`div`,{className:`relative`,style:{height:64},children:[l>0&&(0,v.jsx)(`div`,{className:`absolute bottom-0 left-0 right-0 rounded-t-[2px] bg-success transition-opacity duration-100 ${f?`opacity-80`:d?`opacity-90`:`opacity-35`}`,style:{height:l}}),f&&(0,v.jsx)(`div`,{className:`absolute inset-0 bg-base-content/5 rounded-sm`})]}),(0,v.jsx)(`div`,{className:`h-px transition-colors duration-100 ${f?`bg-base-content/20`:`bg-base-300`}`}),(0,v.jsxs)(`div`,{className:`relative`,style:{height:24},children:[u>0&&(0,v.jsx)(`div`,{className:`absolute bottom-0 left-0 right-0 rounded-t-[2px] bg-error transition-opacity duration-100 ${f?`opacity-80`:d?`opacity-90`:`opacity-35`}`,style:{height:u}}),f&&(0,v.jsx)(`div`,{className:`absolute inset-0 bg-base-content/5 rounded-sm`})]})]},e.date)})}),(0,v.jsx)(`div`,{className:`flex gap-px mt-1.5`,children:t.map((e,t)=>{let r=e.date===i,a=n===t,o=r||t===0||t%s===0,c=e.date?new Date(e.date+`T00:00:00`).toLocaleDateString(void 0,{month:`numeric`,day:`numeric`}):``;return(0,v.jsx)(`div`,{className:`flex-1 overflow-hidden`,children:o&&(0,v.jsx)(`span`,{className:`block text-center text-[9px] truncate transition-opacity duration-100 ${a?`opacity-80`:r?`opacity-60 font-semibold`:`opacity-30`}`,children:r?`today`:c})},e.date)})})]})]})}function k(e){return e==null||!Number.isFinite(e)?`–`:e<1/24?`${Math.round(e*24*60)}m`:e<1?`${(e*24).toFixed(1)}h`:`${e.toFixed(1)}d`}function A(e){return e==null||!Number.isFinite(e)?`–`:e>=1e3?`${(e/1e3).toFixed(1)}K`:Math.round(e).toString()}function j({icon:e,iconClass:t,title:n,avg:r,median:i,n:a,formatValue:o,unit:s}){return(0,v.jsxs)(`div`,{className:`stat bg-base-200 rounded-box`,children:[(0,v.jsx)(`div`,{className:`stat-figure ${t}`,children:(0,v.jsx)(e,{className:`size-6`})}),(0,v.jsx)(`div`,{className:`stat-title`,children:n}),(0,v.jsxs)(`div`,{className:`stat-value text-2xl ${t}`,children:[o(r),s&&(0,v.jsx)(`span`,{className:`text-base font-normal opacity-50 ml-1`,children:s})]}),(0,v.jsxs)(`div`,{className:`stat-desc`,children:[i==null?`–`:`median ${o(i)}`,a!=null&&(0,v.jsxs)(`span`,{className:`opacity-40`,children:[` · n=`,a]})]})]})}function M(){return(0,v.jsx)(`div`,{className:`flex-1 flex flex-col min-h-0 px-4 pb-4 pt-3`,children:(0,v.jsxs)(`div`,{className:`max-w-6xl w-full mx-auto space-y-6`,children:[(0,v.jsx)(`div`,{className:`skeleton-line h-8 w-48`}),(0,v.jsx)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4`,children:[...[,,,]].map((e,t)=>(0,v.jsx)(`div`,{className:`skeleton-card h-28`,style:{animationDelay:`${t*80}ms`}},t))}),(0,v.jsx)(`div`,{className:`skeleton-card h-52`}),(0,v.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[(0,v.jsx)(`div`,{className:`skeleton-card h-32`}),(0,v.jsx)(`div`,{className:`skeleton-card h-32`})]}),(0,v.jsx)(`div`,{className:`skeleton-card h-64`})]})})}var N=n(`/analytics`)({component:P});function P(){let{data:e,isLoading:t}=g(),{data:n}=a(),{data:r}=o();if(t&&!e)return(0,v.jsx)(M,{});let _=e?.overall?.totalTokens||0,S=e?.byPhase||null,w=e?.byModel||{},N=s(e?.daily,32),P=e?.topIssues||[],F=new Date().toISOString().slice(0,10),I=N.find(e=>e.date===F),L=I?.totalTokens||0,R=N.reduce((e,t)=>e+(t.totalTokens||0),0),z=N.reduce((e,t)=>e+(t.events||0),0),B=I?.events||0,V=(()=>{let e=new Map((n?.lines||[]).filter(e=>e.date).map(e=>[e.date,e])),t=[];for(let n=31;n>=0;n--){let r=new Date;r.setDate(r.getDate()-n);let i=r.toISOString().slice(0,10);t.push(e.get(i)??{date:i,linesAdded:0,linesRemoved:0,filesChanged:0})}return t})(),H=V.reduce((e,t)=>e+(t.linesAdded||0),0),U=V.reduce((e,t)=>e+(t.linesRemoved||0),0),W=r?.ok?r:null;return(0,v.jsx)(`div`,{className:`flex-1 flex flex-col min-h-0 px-4 pb-4 pt-3 overflow-y-auto`,children:(0,v.jsxs)(`div`,{className:`max-w-6xl w-full mx-auto space-y-6 stagger-children`,children:[(0,v.jsx)(`section`,{children:(0,v.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-7 gap-4`,children:[(0,v.jsxs)(`div`,{className:`stat bg-base-200 rounded-box`,children:[(0,v.jsx)(`div`,{className:`stat-figure text-primary`,children:(0,v.jsx)(f,{className:`size-6`})}),(0,v.jsx)(`div`,{className:`stat-title`,children:`Total Tokens`}),(0,v.jsx)(`div`,{className:`stat-value text-2xl`,children:(0,v.jsx)(x,{value:_})}),(0,v.jsx)(`div`,{className:`stat-desc font-mono`,children:b(_)})]}),(0,v.jsxs)(`div`,{className:`stat bg-base-200 rounded-box`,children:[(0,v.jsx)(`div`,{className:`stat-figure text-accent`,children:(0,v.jsx)(c,{className:`size-6`})}),(0,v.jsx)(`div`,{className:`stat-title`,children:`Tokens Today`}),(0,v.jsx)(`div`,{className:`stat-value text-2xl`,children:(0,v.jsx)(x,{value:L})}),(0,v.jsxs)(`div`,{className:`stat-desc`,children:[`30d: `,y(R)]})]}),(0,v.jsxs)(`div`,{className:`stat bg-base-200 rounded-box`,children:[(0,v.jsx)(`div`,{className:`stat-figure text-secondary`,children:(0,v.jsx)(i,{className:`size-6`})}),(0,v.jsx)(`div`,{className:`stat-title`,children:`Total Events`}),(0,v.jsx)(`div`,{className:`stat-value text-2xl`,children:(0,v.jsx)(x,{value:z,format:e=>String(e||0)})}),(0,v.jsxs)(`div`,{className:`stat-desc`,children:[`Today: `,B]})]}),(0,v.jsxs)(`div`,{className:`stat bg-base-200 rounded-box xl:col-span-2 overflow-hidden`,children:[(0,v.jsx)(`div`,{className:`stat-figure text-info`,children:(0,v.jsx)(d,{className:`size-6`})}),(0,v.jsx)(`div`,{className:`stat-title`,children:`Phase Split`}),(0,v.jsx)(`div`,{className:`stat-value text-2xl p-0`,children:S?(0,v.jsx)(C,{byPhase:S}):(0,v.jsx)(`span`,{className:`opacity-30`,children:`-`})})]}),(0,v.jsxs)(`div`,{className:`stat bg-base-200 rounded-box`,children:[(0,v.jsx)(`div`,{className:`stat-figure text-success`,children:(0,v.jsx)(l,{className:`size-6`})}),(0,v.jsx)(`div`,{className:`stat-title`,children:`Lines Added`}),(0,v.jsx)(`div`,{className:`stat-value text-2xl text-success`,children:(0,v.jsx)(x,{value:H,format:e=>e>=1e3?`${(e/1e3).toFixed(1)}K`:String(e||0)})}),(0,v.jsx)(`div`,{className:`stat-desc`,children:`30d total`})]}),(0,v.jsxs)(`div`,{className:`stat bg-base-200 rounded-box`,children:[(0,v.jsx)(`div`,{className:`stat-figure text-error`,children:(0,v.jsx)(l,{className:`size-6`})}),(0,v.jsx)(`div`,{className:`stat-title`,children:`Lines Removed`}),(0,v.jsx)(`div`,{className:`stat-value text-2xl text-error`,children:(0,v.jsx)(x,{value:U,format:e=>e>=1e3?`${(e/1e3).toFixed(1)}K`:String(e||0)})}),(0,v.jsx)(`div`,{className:`stat-desc`,children:`30d total`})]})]})}),(0,v.jsxs)(`section`,{className:`bg-base-200 rounded-box p-5`,children:[(0,v.jsx)(`div`,{className:`flex items-center justify-between mb-4`,children:(0,v.jsxs)(`h2`,{className:`text-sm font-semibold flex items-center gap-2`,children:[(0,v.jsx)(p,{className:`size-4 text-primary`}),`Daily Activity`]})}),(0,v.jsx)(T,{daily:N}),(0,v.jsx)(`div`,{className:`border-t border-base-300 my-5`}),(0,v.jsx)(O,{daily:V})]}),(0,v.jsxs)(`section`,{className:`bg-base-200 rounded-box p-5`,children:[(0,v.jsxs)(`h2`,{className:`text-sm font-semibold flex items-center gap-2 mb-4`,children:[(0,v.jsx)(m,{className:`size-4 text-warning`}),`Engineering KPIs`,W?.sampleSize>0&&(0,v.jsxs)(`span`,{className:`text-xs font-normal opacity-40 ml-1`,children:[`based on `,W.sampleSize,` completed issue`,W.sampleSize===1?``:`s`]})]}),(0,v.jsxs)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 xl:grid-cols-4 gap-4`,children:[(0,v.jsx)(j,{icon:c,iconClass:`text-primary`,title:`Issue Cycle Time`,avg:W?.issueCycleTimeDays?.avg??null,median:W?.issueCycleTimeDays?.median??null,n:W?.issueCycleTimeDays?.n??null,formatValue:k}),(0,v.jsx)(j,{icon:u,iconClass:`text-secondary`,title:`PR Cycle Time`,avg:W?.prCycleTimeDays?.avg??null,median:W?.prCycleTimeDays?.median??null,n:W?.prCycleTimeDays?.n??null,formatValue:k}),(0,v.jsx)(j,{icon:m,iconClass:`text-warning`,title:`Review Turnaround`,avg:W?.reviewTurnaroundDays?.avg??null,median:W?.reviewTurnaroundDays?.median??null,n:W?.reviewTurnaroundDays?.n??null,formatValue:k}),(0,v.jsx)(j,{icon:l,iconClass:`text-info`,title:`PR Size`,avg:W?.prSizeLines?.avg??null,median:W?.prSizeLines?.median??null,n:W?.prSizeLines?.n??null,formatValue:A,unit:`lines`})]})]}),P.length>0&&(0,v.jsxs)(`section`,{className:`bg-base-200 rounded-box p-5`,children:[(0,v.jsxs)(`h2`,{className:`text-sm font-semibold flex items-center gap-2 mb-4`,children:[(0,v.jsx)(f,{className:`size-4 text-accent`}),`Top Issues by Token Usage`]}),(0,v.jsx)(D,{topIssues:P})]}),Object.keys(w).length>0&&(0,v.jsxs)(`section`,{className:`bg-base-200 rounded-box p-5`,children:[(0,v.jsxs)(`h2`,{className:`text-sm font-semibold flex items-center gap-2 mb-4`,children:[(0,v.jsx)(h,{className:`size-4 text-info`}),`Model Breakdown`]}),(0,v.jsx)(E,{byModel:w})]})]})})}export{N as Route};