maestro-flow 0.3.11 → 0.3.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (164) hide show
  1. package/.claude/agents/conceptual-planning-agent.md +1 -0
  2. package/.claude/agents/workflow-analyzer.md +114 -114
  3. package/.claude/agents/workflow-collab-planner.md +144 -144
  4. package/.claude/agents/workflow-debugger.md +102 -103
  5. package/.claude/agents/workflow-executor.md +127 -128
  6. package/.claude/agents/workflow-integration-checker.md +82 -82
  7. package/.claude/agents/workflow-nyquist-auditor.md +85 -84
  8. package/.claude/agents/workflow-phase-researcher.md +85 -85
  9. package/.claude/agents/workflow-plan-checker.md +90 -90
  10. package/.claude/agents/workflow-planner.md +178 -178
  11. package/.claude/agents/workflow-roadmapper.md +81 -83
  12. package/.claude/agents/workflow-verifier.md +119 -119
  13. package/.claude/commands/learn-retro.md +2 -2
  14. package/.claude/commands/learn-second-opinion.md +2 -2
  15. package/.claude/commands/maestro-brainstorm.md +1 -0
  16. package/.claude/commands/maestro-fork.md +133 -111
  17. package/.claude/commands/maestro-merge.md +85 -77
  18. package/.claude/commands/maestro-plan.md +88 -2
  19. package/.claude/commands/maestro-roadmap.md +113 -2
  20. package/.claude/commands/maestro.md +1 -0
  21. package/.claude/commands/quality-business-test.md +5 -5
  22. package/.claude/commands/quality-debug.md +3 -2
  23. package/.claude/commands/quality-retrospective.md +6 -4
  24. package/.claude/commands/quality-review.md +1 -1
  25. package/.claude/commands/quality-test-gen.md +5 -4
  26. package/.codex/skills/maestro-brainstorm/SKILL.md +1 -1
  27. package/.codex/skills/maestro-fork/SKILL.md +98 -68
  28. package/.codex/skills/maestro-init/SKILL.md +4 -3
  29. package/.codex/skills/maestro-merge/SKILL.md +69 -62
  30. package/.codex/skills/maestro-ui-design/SKILL.md +1 -1
  31. package/.codex/skills/maestro-verify/SKILL.md +12 -12
  32. package/.codex/skills/manage-learn/SKILL.md +1 -1
  33. package/.codex/skills/manage-status/SKILL.md +4 -4
  34. package/.codex/skills/quality-business-test/SKILL.md +2 -2
  35. package/.codex/skills/quality-integration-test/SKILL.md +1 -1
  36. package/.codex/skills/quality-retrospective/SKILL.md +7 -7
  37. package/.codex/skills/quality-review/SKILL.md +2 -2
  38. package/.codex/skills/quality-test/SKILL.md +2 -2
  39. package/.codex/skills/quality-test-gen/SKILL.md +1 -1
  40. package/README.md +2 -0
  41. package/README.zh-CN.md +2 -0
  42. package/dashboard/dist/assets/{ArtifactsPage-DZNCi6tn.js → ArtifactsPage-CUrrDGgN.js} +1 -1
  43. package/dashboard/dist/assets/ChatInput-pUOLJIKE.js +49 -0
  44. package/dashboard/dist/assets/ChatPage-B8Xqkt0v.js +27 -0
  45. package/dashboard/dist/assets/{CollabPage-B4NAHXS2.js → CollabPage-DIUXeazv.js} +1 -1
  46. package/dashboard/dist/assets/{ExecutionPanel-CFt4LJyq.js → ExecutionPanel-VmYeADFj.js} +1 -1
  47. package/dashboard/dist/assets/KanbanPage-DLq8v7hg.js +21 -0
  48. package/dashboard/dist/assets/{MarkdownRenderer-X4af_WNb.js → MarkdownRenderer-D7AehrnR.js} +1 -1
  49. package/dashboard/dist/assets/{McpPage-BKfCVIyU.js → McpPage-BY0SjTgw.js} +2 -2
  50. package/dashboard/dist/assets/{OutputPanel-BlBQFJSW.js → OutputPanel-B-Rjwgmv.js} +1 -1
  51. package/dashboard/dist/assets/{ProblemsPanel-De3DLvoI.js → ProblemsPanel-GEpF-oi4.js} +1 -1
  52. package/dashboard/dist/assets/RequirementBoardPage-xs8uDM7I.js +6 -0
  53. package/dashboard/dist/assets/{RequirementPage-Bllxe2XI.js → RequirementPage-BKDSFwjA.js} +5 -10
  54. package/dashboard/dist/assets/SpecsPage-DLFb9ZH0.js +36 -0
  55. package/dashboard/dist/assets/SupervisorPage-SOki_kgz.js +6 -0
  56. package/dashboard/dist/assets/TeamsPage-BO2kP70F.js +11 -0
  57. package/dashboard/dist/assets/{TreeBrowser-Q12qobZs.js → TreeBrowser-B9DHdULE.js} +1 -1
  58. package/dashboard/dist/assets/{WorkflowPage-D_Fzdy3_.js → WorkflowPage-C8hWbYim.js} +1 -1
  59. package/dashboard/dist/assets/{check-u6fGOwQO.js → check-DJDk3A2a.js} +1 -1
  60. package/dashboard/dist/assets/{chevron-right-Csu22t58.js → chevron-right-C7bVDreZ.js} +1 -1
  61. package/dashboard/dist/assets/{circle-CMrkbRNg.js → circle-Qfgy4LB_.js} +1 -1
  62. package/dashboard/dist/assets/{circle-alert-c3tH1P4z.js → circle-alert-Na1vf6qQ.js} +1 -1
  63. package/dashboard/dist/assets/{circle-check-gYxxSYuH.js → circle-check-CEGgy3NV.js} +1 -1
  64. package/dashboard/dist/assets/{circle-check-big-TDSeWstm.js → circle-check-big-3JB8zRYj.js} +1 -1
  65. package/dashboard/dist/assets/{code-CFN2uX9V.js → code-Ble63Idz.js} +1 -1
  66. package/dashboard/dist/assets/{columns-3-38xIDlzy.js → columns-3-BUcKlxve.js} +1 -1
  67. package/dashboard/dist/assets/{download-DC7KkKyP.js → download-CMqkfn8x.js} +1 -1
  68. package/dashboard/dist/assets/{folder-CWq_lAnf.js → folder-B9ewx9LL.js} +1 -1
  69. package/dashboard/dist/assets/index-C2Mcb4TJ.js +231 -0
  70. package/dashboard/dist/assets/index-DyBbPc18.css +1 -0
  71. package/dashboard/dist/assets/{index-Do71weNR.js → index-JTmGteaT.js} +1 -1
  72. package/dashboard/dist/assets/{list-CgIP_2A-.js → list-DI8Wn2aT.js} +1 -1
  73. package/dashboard/dist/assets/loader-B5F6PzFT.js +11 -0
  74. package/dashboard/dist/assets/{minus-DYoN5UGk.js → minus-Lp_BfctG.js} +1 -1
  75. package/dashboard/dist/assets/{pen-line-Bh_WKYHm.js → pen-line-Ch7sphzZ.js} +1 -1
  76. package/dashboard/dist/assets/pencil-_yRMHmGT.js +6 -0
  77. package/dashboard/dist/assets/{proxy-BKxDAKTj.js → proxy-D72Y8a4Y.js} +1 -1
  78. package/dashboard/dist/assets/{search-SieXnOgr.js → search-BS6fI6Bg.js} +1 -1
  79. package/dashboard/dist/assets/{shallow-Bme1JY57.js → shallow-BXasQBvr.js} +1 -1
  80. package/dashboard/dist/assets/table-CeGlFjlP.js +6 -0
  81. package/dashboard/dist/assets/{terminal-BB3Xfuv5.js → terminal-BJic2yW-.js} +1 -1
  82. package/dashboard/dist/assets/{trash-2-C8f4vFFM.js → trash-2-Czz4X8Fb.js} +1 -1
  83. package/dashboard/dist/assets/{zap-4uwlzVm0.js → zap-C3H0jVFA.js} +1 -1
  84. package/dashboard/dist/index.html +2 -2
  85. package/dashboard/dist-server/dashboard/src/server/agents/agent-manager.js +16 -1
  86. package/dashboard/dist-server/dashboard/src/server/agents/agent-manager.js.map +1 -1
  87. package/dashboard/dist-server/dashboard/src/server/agents/delegate-broker-monitor.js +1 -2
  88. package/dashboard/dist-server/dashboard/src/server/agents/delegate-broker-monitor.js.map +1 -1
  89. package/dashboard/dist-server/dashboard/src/server/commander/commander-prompts.d.ts +1 -1
  90. package/dashboard/dist-server/dashboard/src/server/commander/commander-prompts.js +2 -1
  91. package/dashboard/dist-server/dashboard/src/server/commander/commander-prompts.js.map +1 -1
  92. package/dashboard/dist-server/dashboard/src/server/index.js +3 -0
  93. package/dashboard/dist-server/dashboard/src/server/index.js.map +1 -1
  94. package/dashboard/dist-server/dashboard/src/server/routes/collab.js +124 -0
  95. package/dashboard/dist-server/dashboard/src/server/routes/collab.js.map +1 -1
  96. package/dashboard/dist-server/dashboard/src/server/ws/handlers/team-handler.d.ts +10 -0
  97. package/dashboard/dist-server/dashboard/src/server/ws/handlers/team-handler.js +73 -0
  98. package/dashboard/dist-server/dashboard/src/server/ws/handlers/team-handler.js.map +1 -0
  99. package/dashboard/dist-server/dashboard/src/shared/collab-types.d.ts +31 -0
  100. package/dashboard/dist-server/dashboard/src/shared/collab-types.js +28 -0
  101. package/dashboard/dist-server/dashboard/src/shared/collab-types.js.map +1 -1
  102. package/dashboard/dist-server/dashboard/src/shared/constants.js +5 -0
  103. package/dashboard/dist-server/dashboard/src/shared/constants.js.map +1 -1
  104. package/dashboard/dist-server/dashboard/src/shared/coordinate-types.d.ts +22 -0
  105. package/dashboard/dist-server/dashboard/src/shared/issue-types.d.ts +12 -0
  106. package/dashboard/dist-server/dashboard/src/shared/issue-types.js +12 -0
  107. package/dashboard/dist-server/dashboard/src/shared/issue-types.js.map +1 -1
  108. package/dashboard/dist-server/dashboard/src/shared/team-types.d.ts +1 -0
  109. package/dashboard/dist-server/dashboard/src/shared/team-types.js +7 -0
  110. package/dashboard/dist-server/dashboard/src/shared/team-types.js.map +1 -1
  111. package/dashboard/dist-server/dashboard/src/shared/ws-protocol.d.ts +27 -1
  112. package/dashboard/dist-server/dashboard/src/shared/ws-protocol.js.map +1 -1
  113. package/dashboard/dist-server/shared/agent-types.d.ts +4 -0
  114. package/dashboard/dist-server/src/hooks/constants.d.ts +1 -1
  115. package/dashboard/dist-server/src/hooks/constants.js +2 -2
  116. package/dashboard/dist-server/src/hooks/constants.js.map +1 -1
  117. package/dist/shared/agent-types.d.ts +4 -0
  118. package/dist/shared/agent-types.d.ts.map +1 -1
  119. package/dist/src/commands/install-backend.d.ts.map +1 -1
  120. package/dist/src/commands/install-backend.js +29 -18
  121. package/dist/src/commands/install-backend.js.map +1 -1
  122. package/dist/src/hooks/__tests__/statusline-visual-test.js +23 -1
  123. package/dist/src/hooks/__tests__/statusline-visual-test.js.map +1 -1
  124. package/dist/src/hooks/constants.d.ts +1 -1
  125. package/dist/src/hooks/constants.d.ts.map +1 -1
  126. package/dist/src/hooks/constants.js +2 -2
  127. package/dist/src/hooks/constants.js.map +1 -1
  128. package/dist/src/hooks/skill-context.d.ts +3 -0
  129. package/dist/src/hooks/skill-context.d.ts.map +1 -1
  130. package/dist/src/hooks/skill-context.js +95 -9
  131. package/dist/src/hooks/skill-context.js.map +1 -1
  132. package/dist/src/hooks/statusline.d.ts.map +1 -1
  133. package/dist/src/hooks/statusline.js +6 -3
  134. package/dist/src/hooks/statusline.js.map +1 -1
  135. package/dist/src/tools/merge-validator.d.ts.map +1 -1
  136. package/dist/src/tools/merge-validator.js +114 -16
  137. package/dist/src/tools/merge-validator.js.map +1 -1
  138. package/package.json +1 -1
  139. package/shared/agent-types.ts +4 -0
  140. package/templates/worktree-scope.json +9 -10
  141. package/templates/worktrees.json +26 -27
  142. package/workflows/brainstorm.md +10 -1
  143. package/workflows/debug.md +16 -6
  144. package/workflows/fork.md +100 -36
  145. package/workflows/integration-test.md +14 -2
  146. package/workflows/issue.md +14 -4
  147. package/workflows/learn.md +19 -5
  148. package/workflows/maestro.md +1 -0
  149. package/workflows/merge.md +113 -55
  150. package/workflows/retrospective.md +61 -22
  151. package/workflows/review.md +17 -4
  152. package/workflows/test.md +12 -2
  153. package/workflows/ui-style.md +9 -2
  154. package/dashboard/dist/assets/ChatInput-Bvr-FeEq.js +0 -49
  155. package/dashboard/dist/assets/ChatPage-D9zTkJZo.js +0 -22
  156. package/dashboard/dist/assets/KanbanPage-C8USth6H.js +0 -21
  157. package/dashboard/dist/assets/RequirementBoardPage-Bf1trzqs.js +0 -11
  158. package/dashboard/dist/assets/SpecsPage-9lwxKT27.js +0 -36
  159. package/dashboard/dist/assets/SupervisorPage-SusdfHFq.js +0 -6
  160. package/dashboard/dist/assets/TeamsPage-DsuM6OwC.js +0 -6
  161. package/dashboard/dist/assets/arrow-left-Bqtb2hle.js +0 -6
  162. package/dashboard/dist/assets/index-DWG-WrzT.js +0 -231
  163. package/dashboard/dist/assets/index-GUNJodSR.css +0 -1
  164. package/dashboard/dist/assets/table-llyEtj-7.js +0 -6
@@ -1,26 +1,21 @@
1
- import{d as h,Y as b,r as g,j as e,Q as f,X as C,N as R,M as _}from"./index-DWG-WrzT.js";import{u as y}from"./shallow-Bme1JY57.js";import{Z as D}from"./zap-4uwlzVm0.js";import{T as E}from"./trash-2-C8f4vFFM.js";import{C as L}from"./code-CFN2uX9V.js";/**
1
+ import{d as f,ae as h,r as g,j as e,ab as b,X as C,aa as R,M as D}from"./index-C2Mcb4TJ.js";import{u as y}from"./shallow-BXasQBvr.js";import{Z as E}from"./zap-C3H0jVFA.js";import{P as L}from"./pencil-_yRMHmGT.js";import{T as _}from"./trash-2-Czz4X8Fb.js";import{C as T}from"./code-Ble63Idz.js";/**
2
2
  * @license lucide-react v0.577.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
5
5
  * See the LICENSE file in the root directory of this source tree.
6
- */const M=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]],T=h("arrow-right",M);/**
6
+ */const q=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]],F=f("arrow-right",q);/**
7
7
  * @license lucide-react v0.577.0 - ISC
8
8
  *
9
9
  * This source code is licensed under the ISC license.
10
10
  * See the LICENSE file in the root directory of this source tree.
11
- */const q=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M8 12h8",key:"1wcyev"}],["path",{d:"M12 8v8",key:"napkw2"}]],F=h("circle-plus",q);/**
11
+ */const M=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M8 12h8",key:"1wcyev"}],["path",{d:"M12 8v8",key:"napkw2"}]],S=f("circle-plus",M);/**
12
12
  * @license lucide-react v0.577.0 - ISC
13
13
  *
14
14
  * This source code is licensed under the ISC license.
15
15
  * See the LICENSE file in the root directory of this source tree.
16
- */const S=[["path",{d:"M15 6a9 9 0 0 0-9 9V3",key:"1cii5b"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}]],$=h("git-branch",S);/**
16
+ */const I=[["path",{d:"M15 6a9 9 0 0 0-9 9V3",key:"1cii5b"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}]],$=f("git-branch",I);/**
17
17
  * @license lucide-react v0.577.0 - ISC
18
18
  *
19
19
  * This source code is licensed under the ISC license.
20
20
  * See the LICENSE file in the root directory of this source tree.
21
- */const I=[["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"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]],W=h("pencil",I);/**
22
- * @license lucide-react v0.577.0 - ISC
23
- *
24
- * This source code is licensed under the ISC license.
25
- * See the LICENSE file in the root directory of this source tree.
26
- */const P=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]],H=h("rotate-ccw",P),A=[{value:"high-level",label:"High-level",desc:"3-5 epics"},{value:"standard",label:"Standard",desc:"5-10 tasks"},{value:"atomic",label:"Atomic",desc:"10-20 steps"}],O={done:"bg-accent-green",failed:"bg-accent-red",reviewing:"bg-accent-orange",expanding:"bg-accent-blue",committing:"bg-accent-orange",draft:"bg-text-tertiary"},N={feature:"bg-[var(--color-tint-exploring)] text-[var(--color-accent-blue)]",task:"bg-[var(--color-tint-planning)] text-[var(--color-accent-purple)]",bug:"bg-[var(--color-tint-blocked)] text-[var(--color-accent-red)]",improvement:"bg-[var(--color-tint-completed)] text-[var(--color-accent-green)]"},k={urgent:"bg-accent-red",high:"bg-accent-orange",medium:"bg-accent-yellow",low:"bg-text-placeholder"},K={small:"S",medium:"M",large:"L","1h":"1h","2h":"2h","4h":"4h","1d":"1d","2d":"2d","1w":"1w"};function B(){const[t,l]=g.useState(""),[s,c]=g.useState("standard"),[o,p]=g.useState("sdk"),{expand:d,isLoading:i,continueFrom:a,setContinueFrom:x}=b(y(r=>({expand:r.expand,isLoading:r.isLoading,continueFrom:r.continueFrom,setContinueFrom:r.setContinueFrom}))),m=g.useCallback(()=>{const r=t.trim();!r||i||d(r,s,o)},[t,s,o,d,i]),v=g.useCallback(r=>{r.key==="Enter"&&(r.ctrlKey||r.metaKey)&&(r.preventDefault(),m())},[m]);return e.jsxs("div",{className:"px-[var(--spacing-5)] pt-[var(--spacing-6)] shrink-0",children:[e.jsx("h1",{className:"text-[length:var(--font-size-xl)] font-bold text-text-primary mb-[var(--spacing-1)]",style:{fontFamily:"var(--style-heading-font)",letterSpacing:"var(--style-heading-letter-spacing)"},children:"Expand requirements"}),e.jsx("p",{className:"text-[length:var(--font-size-xs)] text-text-tertiary mb-[var(--spacing-4)]",children:"Natural language to structured decomposition"}),e.jsxs("div",{className:`bg-bg-card border rounded-[var(--style-composer-radius)] shadow-sm transition-all duration-[var(--duration-normal)] focus-within:shadow-[0_2px_10px_rgba(0,0,0,0.03),0_0_0_3px_rgba(200,134,58,0.08)] ${a?"border-[var(--color-accent-purple)] focus-within:border-[var(--color-accent-purple)]":"border-border focus-within:border-[var(--color-accent-orange)]"}`,children:[a&&e.jsxs("div",{className:"flex items-center gap-[var(--spacing-2)] px-[var(--spacing-3)] pt-[var(--spacing-2-5)]",children:[e.jsxs("div",{className:"flex items-center gap-[var(--spacing-1-5)] flex-1 min-w-0 px-[var(--spacing-2-5)] py-[var(--spacing-1-5)] rounded-[var(--radius-default)] bg-[var(--color-tint-planning)]",children:[e.jsx(f,{size:12,strokeWidth:2,className:"text-[var(--color-accent-purple)] shrink-0"}),e.jsx("span",{className:"text-[10px] font-semibold text-[var(--color-accent-purple)] shrink-0",children:"Continue from"}),e.jsx("span",{className:"text-[10px] font-medium text-text-secondary truncate",children:a.title||a.userInput.substring(0,40)}),e.jsxs("span",{className:"text-[9px] text-text-placeholder shrink-0",children:[a.items.length," items"]})]}),e.jsx("button",{type:"button",className:"w-[20px] h-[20px] rounded-[var(--radius-sm)] flex items-center justify-center text-text-placeholder hover:bg-bg-hover hover:text-text-primary transition-all duration-[var(--duration-fast)] shrink-0",onClick:()=>x(null),title:"Dismiss context",children:e.jsx(C,{size:12,strokeWidth:2})})]}),e.jsx("textarea",{className:"w-full border-none bg-transparent resize-none outline-none text-text-primary leading-relaxed font-sans",style:{fontSize:"var(--style-composer-textarea-size)",padding:"var(--style-composer-padding)",paddingBottom:"var(--spacing-2)",paddingTop:a?"var(--spacing-2)":void 0},placeholder:a?"Describe additional requirements to build upon...":"Describe a feature, user story, or requirement...",rows:3,value:t,onChange:r=>l(r.target.value),onKeyDown:v}),e.jsxs("div",{className:"flex items-center px-[var(--spacing-3)] pb-[var(--spacing-2)] gap-[var(--spacing-1)]",children:[e.jsx("div",{className:"flex gap-[1px] bg-bg-secondary rounded-[var(--radius-default)] p-[2px]",children:A.map(r=>e.jsx("button",{type:"button",className:`text-[length:var(--font-size-xs)] font-medium px-[var(--spacing-2-5)] py-[3px] rounded-[var(--radius-sm)] transition-all duration-[var(--duration-fast)] ${s===r.value?"bg-bg-card text-text-primary shadow-sm":"text-text-tertiary hover:text-text-secondary"}`,onClick:()=>c(r.value),children:r.label},r.value))}),e.jsx("div",{className:"flex gap-[1px] bg-bg-secondary rounded-[var(--radius-default)] p-[2px] ml-[var(--spacing-1)]",children:["sdk","cli"].map(r=>e.jsx("button",{type:"button",className:`text-[length:var(--font-size-xs)] font-medium px-[var(--spacing-2)] py-[3px] rounded-[var(--radius-sm)] transition-all duration-[var(--duration-fast)] ${o===r?"bg-bg-card text-text-primary shadow-sm":"text-text-tertiary hover:text-text-secondary"}`,onClick:()=>p(r),children:r==="sdk"?"SDK":"CLI"},r))}),e.jsx("div",{className:"flex-1"}),e.jsxs("button",{type:"button",className:"flex items-center gap-[var(--spacing-1)] text-[length:var(--font-size-xs)] font-semibold px-[var(--spacing-4)] py-[5px] rounded-[var(--radius-default)] bg-text-primary text-text-inverse hover:opacity-85 transition-opacity duration-[var(--duration-fast)] disabled:opacity-[var(--opacity-disabled)]",disabled:!t.trim()||i,onClick:m,children:[a?e.jsx(f,{size:13,strokeWidth:2}):e.jsx(D,{size:13,strokeWidth:2}),i?"Expanding...":a?"Continue":"Expand"]})]})]}),e.jsxs("div",{className:"flex gap-[var(--spacing-2-5)] px-[var(--spacing-1)] mt-[var(--spacing-1-5)] text-[length:10px] text-text-placeholder",children:[e.jsxs("span",{children:[e.jsx("kbd",{className:"font-mono text-[10px] px-[5px] py-[1px] border border-border-divider rounded-[3px] bg-bg-secondary",children:"Ctrl+Enter"})," ","expand"]}),e.jsxs("span",{children:[e.jsx("kbd",{className:"font-mono text-[10px] px-[5px] py-[1px] border border-border-divider rounded-[3px] bg-bg-secondary",children:"Tab"})," ","depth"]})]})]})}function Y(){const{history:t,currentRequirement:l,loadHistory:s}=b(y(i=>({history:i.history,currentRequirement:i.currentRequirement,loadHistory:i.loadHistory})));if(t.length===0)return e.jsx("div",{className:"flex-1 flex items-center justify-center px-[var(--spacing-5)]",children:e.jsx("p",{className:"text-[length:var(--font-size-xs)] text-text-placeholder text-center",children:"No expansion history yet"})});const c=new Date,o=[],p=[],d=[];for(const i of t){const a=new Date(i.createdAt);a.getDate()===c.getDate()&&a.getMonth()===c.getMonth()&&a.getFullYear()===c.getFullYear()?p.push(i):d.push(i)}return p.length&&o.push({label:"Today",items:p}),d.length&&o.push({label:"Earlier",items:d}),e.jsxs("div",{className:"flex-1 overflow-y-auto px-[var(--spacing-5)] mt-[var(--spacing-5)]",children:[e.jsxs("div",{className:"flex items-center gap-[var(--spacing-1-5)] text-[length:10px] font-semibold text-text-tertiary uppercase tracking-[0.06em] mb-[var(--spacing-2)]",children:[e.jsx(R,{size:12,strokeWidth:2}),"History"]}),e.jsx("div",{className:"flex flex-col gap-[2px]",children:o.map(i=>e.jsxs("div",{children:[o.length>1&&e.jsx("div",{className:"text-[length:10px] text-text-placeholder px-[var(--spacing-2-5)] py-[var(--spacing-1)] mt-[var(--spacing-1)]",children:i.label}),i.items.map(a=>{const x=(l==null?void 0:l.id)===a.id;return e.jsxs("button",{type:"button",className:`w-full text-left flex items-center gap-[var(--spacing-3)] px-[var(--spacing-2-5)] py-[var(--spacing-2)] rounded-[var(--radius-md)] transition-all duration-[var(--duration-normal)] ${x?"bg-bg-active":"hover:bg-bg-hover"}`,onClick:()=>s(a.id),children:[e.jsx("span",{className:`inline-block w-[8px] h-[8px] rounded-full shrink-0 ${O[a.status]??"bg-text-tertiary"}`}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-[length:var(--font-size-xs)] font-semibold truncate text-text-primary",children:a.title||a.userInput.substring(0,50)}),e.jsxs("div",{className:"flex items-center gap-[var(--spacing-2)] mt-[2px]",children:[a.status==="done"&&e.jsx("span",{className:"text-[9px] font-semibold px-[6px] py-[1px] rounded-full bg-[var(--color-tint-completed)] text-[var(--color-accent-green)]",children:"done"}),a.status==="failed"&&e.jsx("span",{className:"text-[9px] font-semibold px-[6px] py-[1px] rounded-full bg-[var(--color-tint-blocked)] text-[var(--color-accent-red)]",children:"failed"}),a.items.length>0&&e.jsxs("span",{className:"text-[9px] font-semibold px-[6px] py-[1px] rounded-full bg-[var(--color-tint-exploring)] text-[var(--color-accent-blue)]",children:[a.items.length," items"]}),e.jsx("span",{className:"text-[9px] font-semibold px-[6px] py-[1px] rounded-full bg-[var(--color-tint-planning)] text-[var(--color-accent-purple)]",children:a.depth})]})]}),e.jsx("span",{className:"text-[10px] text-text-placeholder shrink-0",children:U(a.createdAt)})]},a.id)})]},i.label))})]})}function U(t){const l=Date.now()-new Date(t).getTime(),s=Math.floor(l/6e4);if(s<1)return"now";if(s<60)return`${s}m`;const c=Math.floor(s/60);return c<24?`${c}h`:`${Math.floor(c/24)}d`}function V(){const{currentRequirement:t,isLoading:l,error:s,progressMessage:c}=b(y(p=>({currentRequirement:p.currentRequirement,isLoading:p.isLoading,error:p.error,progressMessage:p.progressMessage}))),o=t==null?void 0:t.status;return t?o==="expanding"||o==="committing"?e.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-[var(--spacing-5)]",children:[e.jsxs("div",{className:"relative w-12 h-12",children:[e.jsx("div",{className:"absolute inset-0 rounded-full border-2 border-bg-tertiary"}),e.jsx("div",{className:"absolute inset-0 rounded-full border-2 border-transparent animate-spin",style:{borderTopColor:o==="expanding"?"var(--color-accent-blue)":"var(--color-accent-orange)"}})]}),e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"text-[length:var(--font-size-sm)] font-medium text-text-primary",children:o==="expanding"?"Expanding requirement":"Committing"}),e.jsx("p",{className:"text-[length:var(--font-size-xs)] text-text-tertiary mt-[var(--spacing-1)]",children:c||(o==="expanding"?"Analyzing and structuring...":"Creating issues...")})]})]}):o==="failed"?e.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-[var(--spacing-4)]",children:[e.jsx("div",{className:"w-12 h-12 rounded-full bg-[var(--color-tint-blocked)] flex items-center justify-center",children:e.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"var(--color-accent-red)",strokeWidth:"2",strokeLinecap:"round",children:e.jsx("path",{d:"M18 6 6 18M6 6l12 12"})})}),e.jsxs("div",{className:"text-center max-w-sm",children:[e.jsx("p",{className:"text-[length:var(--font-size-sm)] font-medium text-text-primary",children:"Expansion Failed"}),(s??t.error)&&e.jsx("p",{className:"text-[length:var(--font-size-xs)] text-accent-red mt-[var(--spacing-2)] leading-relaxed",children:s??t.error})]})]}):e.jsx(Z,{}):e.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-[var(--spacing-4)] text-text-placeholder",children:[e.jsxs("svg",{width:"40",height:"40",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),e.jsx("polyline",{points:"14 2 14 8 20 8"}),e.jsx("line",{x1:"16",y1:"13",x2:"8",y2:"13"}),e.jsx("line",{x1:"16",y1:"17",x2:"8",y2:"17"}),e.jsx("polyline",{points:"10 9 9 9 8 9"})]}),e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"text-[length:var(--font-size-sm)] font-medium text-text-secondary",children:"No expansion yet"}),e.jsx("p",{className:"text-[length:var(--font-size-xs)] text-text-tertiary mt-[var(--spacing-1)]",children:"Enter a requirement and click Expand to generate a structured checklist"})]})]})}function Z(){const[t,l]=g.useState(""),{currentRequirement:s,refine:c,commit:o,updateItem:p,isLoading:d,committedResult:i,resetRequirement:a,setContinueFrom:x}=b(y(n=>({currentRequirement:n.currentRequirement,refine:n.refine,commit:n.commit,updateItem:n.updateItem,isLoading:n.isLoading,committedResult:n.committedResult,resetRequirement:n.resetRequirement,setContinueFrom:n.setContinueFrom}))),m=g.useCallback(()=>{const n=t.trim();n&&(c(n),l(""))},[t,c]);if(!s)return null;const v=s.status==="done",r=s.items,j=Q(r);return e.jsxs("div",{className:"flex flex-col h-full",children:[e.jsx("div",{className:"px-[var(--spacing-5)] py-[var(--spacing-4)] border-b border-border-divider shrink-0",children:e.jsx("div",{className:"flex items-start gap-[var(--spacing-3)]",children:e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h2",{className:"text-[length:var(--font-size-md)] font-bold text-text-primary truncate",children:s.title||"Expanded Requirement"}),s.summary&&e.jsx("p",{className:"text-[length:var(--font-size-xs)] text-text-secondary leading-relaxed mt-[var(--spacing-1)] line-clamp-2",children:s.summary}),e.jsxs("div",{className:"flex gap-[var(--spacing-2)] mt-[var(--spacing-2)]",children:[e.jsxs("span",{className:"text-[10px] font-semibold px-[var(--spacing-2-5)] py-[2px] rounded-full bg-[var(--color-tint-exploring)] text-[var(--color-accent-blue)]",children:[r.length," items"]}),e.jsxs("span",{className:"text-[10px] font-semibold px-[var(--spacing-2-5)] py-[2px] rounded-full bg-[var(--color-tint-planning)] text-[var(--color-accent-purple)]",children:[r.filter(n=>n.dependencies.length>0).length," deps"]}),e.jsx("span",{className:"text-[10px] font-semibold px-[var(--spacing-2-5)] py-[2px] rounded-full bg-[var(--color-tint-verifying)] text-[var(--color-accent-orange)]",children:s.depth}),v&&e.jsx("span",{className:"text-[10px] font-semibold px-[var(--spacing-2-5)] py-[2px] rounded-full bg-[var(--color-tint-completed)] text-[var(--color-accent-green)]",children:i?`committed · ${i.mode}`:"done"})]})]})})}),j.length>1&&e.jsxs("div",{className:"px-[var(--spacing-5)] py-[var(--spacing-3)] border-b border-border-divider bg-bg-secondary shrink-0",children:[e.jsxs("div",{className:"flex items-center gap-[var(--spacing-1-5)] text-[10px] font-semibold text-text-tertiary uppercase tracking-[0.04em] mb-[var(--spacing-2)]",children:[e.jsx($,{size:12,strokeWidth:2}),"Dependency Flow"]}),e.jsx("div",{className:"flex items-center gap-[var(--spacing-1)] overflow-x-auto pb-[var(--spacing-1)]",children:j.map((n,u)=>e.jsxs("span",{className:"flex items-center gap-[var(--spacing-1)] shrink-0",children:[u>0&&e.jsx(T,{size:10,className:"text-text-placeholder"}),e.jsxs("span",{className:`text-[10px] font-semibold px-[var(--spacing-2-5)] py-[3px] rounded-[var(--radius-sm)] whitespace-nowrap ${w[u%w.length]}`,children:[u+1,". ",n]})]},u))})]}),e.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto",children:e.jsxs("table",{className:"w-full border-collapse",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{className:"text-[10px] font-semibold uppercase tracking-[0.04em] text-text-tertiary text-left px-[var(--spacing-3-5)] py-[var(--spacing-2-5)] border-b border-border-divider bg-bg-primary sticky top-0 z-[1] w-[28px]",children:"#"}),e.jsx("th",{className:"text-[10px] font-semibold uppercase tracking-[0.04em] text-text-tertiary text-left px-[var(--spacing-3-5)] py-[var(--spacing-2-5)] border-b border-border-divider bg-bg-primary sticky top-0 z-[1]",children:"Item"}),e.jsx("th",{className:"text-[10px] font-semibold uppercase tracking-[0.04em] text-text-tertiary text-left px-[var(--spacing-3-5)] py-[var(--spacing-2-5)] border-b border-border-divider bg-bg-primary sticky top-0 z-[1] w-[68px]",children:"Type"}),e.jsx("th",{className:"text-[10px] font-semibold uppercase tracking-[0.04em] text-text-tertiary text-left px-[var(--spacing-3-5)] py-[var(--spacing-2-5)] border-b border-border-divider bg-bg-primary sticky top-0 z-[1] w-[88px]",children:"Priority"}),e.jsx("th",{className:"text-[10px] font-semibold uppercase tracking-[0.04em] text-text-tertiary text-left px-[var(--spacing-3-5)] py-[var(--spacing-2-5)] border-b border-border-divider bg-bg-primary sticky top-0 z-[1] w-[52px]",children:"Effort"}),e.jsx("th",{className:"text-[10px] font-semibold uppercase tracking-[0.04em] text-text-tertiary text-left px-[var(--spacing-3-5)] py-[var(--spacing-2-5)] border-b border-border-divider bg-bg-primary sticky top-0 z-[1] w-[76px]",children:"Deps"}),e.jsx("th",{className:"text-[10px] font-semibold uppercase tracking-[0.04em] text-text-tertiary text-left px-[var(--spacing-3-5)] py-[var(--spacing-2-5)] border-b border-border-divider bg-bg-primary sticky top-0 z-[1] w-[56px]"})]})}),e.jsx("tbody",{children:r.map((n,u)=>e.jsx(G,{item:n,index:u,items:r,disabled:v,onUpdate:z=>p(n.id,z)},n.id))})]})}),!v&&e.jsxs("div",{className:"flex gap-[var(--spacing-2)] px-[var(--spacing-5)] py-[var(--spacing-3)] border-t border-border-divider bg-bg-primary shrink-0",children:[e.jsx("textarea",{className:"flex-1 border border-border rounded-[var(--radius-md)] px-[var(--spacing-3-5)] py-[var(--spacing-2)] text-[length:var(--font-size-sm)] text-text-primary bg-bg-card outline-none resize-none placeholder:text-text-placeholder focus:border-[var(--color-accent-purple)] transition-colors duration-[var(--duration-normal)]",rows:1,placeholder:"Provide feedback to refine this expansion...",value:t,onChange:n=>l(n.target.value),onKeyDown:n=>{n.key==="Enter"&&!n.shiftKey&&(n.preventDefault(),m())}}),e.jsxs("button",{type:"button",className:"flex items-center gap-[var(--spacing-1-5)] shrink-0 px-[var(--spacing-4)] py-[var(--spacing-2)] rounded-[var(--radius-md)] border border-border text-text-secondary text-[length:var(--font-size-xs)] font-semibold hover:text-text-primary hover:bg-bg-hover transition-all duration-[var(--duration-normal)] disabled:opacity-[var(--opacity-disabled)]",disabled:!t.trim()||d,onClick:m,children:[e.jsx(_,{size:14,strokeWidth:1.8}),"Refine"]})]}),e.jsxs("div",{className:"flex items-center gap-[var(--spacing-2)] px-[var(--spacing-5)] py-[var(--spacing-3)] border-t border-border bg-bg-primary shrink-0",children:[v?e.jsxs(e.Fragment,{children:[e.jsxs("button",{type:"button",className:"flex items-center gap-[var(--spacing-1-5)] px-[var(--spacing-4)] py-[var(--spacing-2)] rounded-[var(--radius-md)] border border-border text-text-secondary text-[length:var(--font-size-xs)] font-semibold hover:text-text-primary hover:bg-bg-hover transition-all duration-[var(--duration-normal)]",onClick:a,children:[e.jsx(H,{size:14,strokeWidth:1.8}),"New Requirement"]}),e.jsxs("button",{type:"button",className:"flex items-center gap-[var(--spacing-1-5)] px-[var(--spacing-3)] py-[var(--spacing-2)] rounded-[var(--radius-md)] border border-[var(--color-accent-purple)]/20 text-[var(--color-accent-purple)] text-[length:var(--font-size-xs)] font-semibold hover:bg-[var(--color-tint-planning)] transition-all duration-[var(--duration-normal)]",onClick:()=>x(s),title:"Use this expansion as context for further planning",children:[e.jsx(f,{size:14,strokeWidth:1.8}),"Continue Planning"]})]}):e.jsxs(e.Fragment,{children:[e.jsxs("button",{type:"button",className:"flex items-center gap-[var(--spacing-1-5)] px-[var(--spacing-4)] py-[var(--spacing-2)] rounded-[var(--radius-md)] bg-accent-green text-text-inverse text-[length:var(--font-size-xs)] font-semibold hover:opacity-85 transition-opacity duration-[var(--duration-fast)] disabled:opacity-[var(--opacity-disabled)]",disabled:d,onClick:()=>o("issues"),children:[e.jsx(F,{size:14,strokeWidth:1.8}),"Commit as Issues"]}),e.jsxs("button",{type:"button",className:"flex items-center gap-[var(--spacing-1-5)] px-[var(--spacing-4)] py-[var(--spacing-2)] rounded-[var(--radius-md)] border border-border text-text-secondary text-[length:var(--font-size-xs)] font-semibold hover:text-text-primary hover:bg-bg-hover transition-all duration-[var(--duration-normal)] disabled:opacity-[var(--opacity-disabled)]",disabled:d,onClick:()=>o("coordinate"),children:[e.jsx(L,{size:14,strokeWidth:1.8}),"Coordinate"]}),e.jsx("div",{className:"w-px h-[20px] bg-border-divider mx-[var(--spacing-1)]"}),e.jsxs("button",{type:"button",className:"flex items-center gap-[var(--spacing-1-5)] px-[var(--spacing-3)] py-[var(--spacing-2)] rounded-[var(--radius-md)] border border-[var(--color-accent-purple)]/20 text-[var(--color-accent-purple)] text-[length:var(--font-size-xs)] font-semibold hover:bg-[var(--color-tint-planning)] transition-all duration-[var(--duration-normal)] disabled:opacity-[var(--opacity-disabled)]",disabled:d,onClick:()=>x(s),title:"Use this expansion as context for further planning",children:[e.jsx(f,{size:14,strokeWidth:1.8}),"Continue"]})]}),e.jsx("div",{className:"flex-1"}),e.jsxs("span",{className:"text-[10px] text-text-tertiary",children:[r.length," items · ",s.depth]})]})]})}function G({item:t,index:l,items:s,disabled:c,onUpdate:o}){const p=t.dependencies.map(d=>{const i=s.findIndex(a=>a.id===d);return i>=0?`#${i+1}`:null}).filter(Boolean);return e.jsxs("tr",{className:"transition-colors duration-[var(--duration-normal)] hover:bg-bg-hover",children:[e.jsx("td",{className:"px-[var(--spacing-3-5)] py-[var(--spacing-3)] border-b border-border-divider align-top text-[length:var(--font-size-xs)] font-semibold text-text-placeholder text-center",children:l+1}),e.jsxs("td",{className:"px-[var(--spacing-3-5)] py-[var(--spacing-3)] border-b border-border-divider align-top",children:[e.jsx("div",{className:"text-[length:var(--font-size-sm)] font-semibold text-text-primary leading-tight",children:t.title}),e.jsx("div",{className:"text-[length:var(--font-size-xs)] text-text-tertiary mt-[2px] leading-snug",children:t.description})]}),e.jsx("td",{className:"px-[var(--spacing-3-5)] py-[var(--spacing-3)] border-b border-border-divider align-top",children:e.jsx("span",{className:`inline-flex text-[9px] font-semibold px-[7px] py-[2px] rounded-full uppercase tracking-[0.03em] ${N[t.type]??N.task}`,children:t.type})}),e.jsx("td",{className:"px-[var(--spacing-3-5)] py-[var(--spacing-3)] border-b border-border-divider align-top",children:e.jsxs("div",{className:"flex items-center gap-[var(--spacing-1)]",children:[e.jsx("span",{className:`inline-block w-[6px] h-[6px] rounded-full ${k[t.priority]??k.medium}`}),e.jsx("span",{className:"text-[length:var(--font-size-xs)] text-text-secondary capitalize",children:t.priority})]})}),e.jsx("td",{className:"px-[var(--spacing-3-5)] py-[var(--spacing-3)] border-b border-border-divider align-top",children:e.jsx("span",{className:"text-[10px] font-semibold px-[var(--spacing-2)] py-[2px] rounded-[var(--radius-sm)] bg-bg-secondary text-text-secondary",children:K[t.estimated_effort]??t.estimated_effort??"—"})}),e.jsx("td",{className:"px-[var(--spacing-3-5)] py-[var(--spacing-3)] border-b border-border-divider align-top",children:p.length>0?e.jsx("div",{className:"flex flex-wrap gap-[3px]",children:p.map(d=>e.jsx("span",{className:"text-[9px] font-semibold px-[6px] py-[1px] rounded-[var(--radius-sm)] bg-[var(--color-tint-planning)] text-[var(--color-accent-purple)] cursor-pointer hover:bg-[var(--color-accent-purple)] hover:text-white transition-colors duration-[var(--duration-fast)]",children:d},d))}):e.jsx("span",{className:"text-[10px] text-text-placeholder",children:"—"})}),e.jsx("td",{className:"px-[var(--spacing-3-5)] py-[var(--spacing-3)] border-b border-border-divider align-top",children:!c&&e.jsxs("div",{className:"flex gap-[2px]",children:[e.jsx("button",{type:"button",className:"w-[26px] h-[26px] rounded-[var(--radius-default)] flex items-center justify-center text-text-placeholder hover:bg-bg-hover hover:text-text-primary transition-all duration-[var(--duration-normal)]",title:"Edit",children:e.jsx(W,{size:14,strokeWidth:1.8})}),e.jsx("button",{type:"button",className:"w-[26px] h-[26px] rounded-[var(--radius-default)] flex items-center justify-center text-text-placeholder hover:bg-bg-hover hover:text-text-primary transition-all duration-[var(--duration-normal)]",title:"Remove",children:e.jsx(E,{size:14,strokeWidth:1.8})})]})})]})}const w=["bg-[var(--color-tint-exploring)] text-[var(--color-accent-blue)]","bg-[var(--color-tint-planning)] text-[var(--color-accent-purple)]","bg-[var(--color-tint-verifying)] text-[var(--color-accent-orange)]","bg-[var(--color-tint-completed)] text-[var(--color-accent-green)]"];function Q(t){return t.length===0?[]:t.map(l=>{const s=l.title.split(/\s+/);return s.length>3?s.slice(0,3).join(" "):l.title})}function ae(){const t=b(l=>l.fetchHistory);return g.useEffect(()=>{t()},[t]),e.jsxs("div",{className:"h-full flex",children:[e.jsxs("div",{className:"w-[40%] shrink-0 border-r border-border flex flex-col overflow-hidden bg-bg-primary",children:[e.jsx(B,{}),e.jsx(Y,{})]}),e.jsx("div",{className:"w-[60%] flex flex-col overflow-hidden bg-bg-primary",children:e.jsx(V,{})})]})}export{ae as RequirementPage};
21
+ */const W=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]],P=f("rotate-ccw",W),H=[{value:"high-level",label:"High-level",desc:"3-5 epics"},{value:"standard",label:"Standard",desc:"5-10 tasks"},{value:"atomic",label:"Atomic",desc:"10-20 steps"}],A={done:"bg-accent-green",failed:"bg-accent-red",reviewing:"bg-accent-orange",expanding:"bg-accent-blue",committing:"bg-accent-orange",draft:"bg-text-tertiary"},N={feature:"bg-[var(--color-tint-exploring)] text-[var(--color-accent-blue)]",task:"bg-[var(--color-tint-planning)] text-[var(--color-accent-purple)]",bug:"bg-[var(--color-tint-blocked)] text-[var(--color-accent-red)]",improvement:"bg-[var(--color-tint-completed)] text-[var(--color-accent-green)]"},k={urgent:"bg-accent-red",high:"bg-accent-orange",medium:"bg-accent-yellow",low:"bg-text-placeholder"},O={small:"S",medium:"M",large:"L","1h":"1h","2h":"2h","4h":"4h","1d":"1d","2d":"2d","1w":"1w"};function K(){const[t,l]=g.useState(""),[s,c]=g.useState("standard"),[o,p]=g.useState("sdk"),{expand:d,isLoading:i,continueFrom:a,setContinueFrom:x}=h(y(r=>({expand:r.expand,isLoading:r.isLoading,continueFrom:r.continueFrom,setContinueFrom:r.setContinueFrom}))),m=g.useCallback(()=>{const r=t.trim();!r||i||d(r,s,o)},[t,s,o,d,i]),v=g.useCallback(r=>{r.key==="Enter"&&(r.ctrlKey||r.metaKey)&&(r.preventDefault(),m())},[m]);return e.jsxs("div",{className:"px-[var(--spacing-5)] pt-[var(--spacing-6)] shrink-0",children:[e.jsx("h1",{className:"text-[length:var(--font-size-xl)] font-bold text-text-primary mb-[var(--spacing-1)]",style:{fontFamily:"var(--style-heading-font)",letterSpacing:"var(--style-heading-letter-spacing)"},children:"Expand requirements"}),e.jsx("p",{className:"text-[length:var(--font-size-xs)] text-text-tertiary mb-[var(--spacing-4)]",children:"Natural language to structured decomposition"}),e.jsxs("div",{className:`bg-bg-card border rounded-[var(--style-composer-radius)] shadow-sm transition-all duration-[var(--duration-normal)] focus-within:shadow-[0_2px_10px_rgba(0,0,0,0.03),0_0_0_3px_rgba(200,134,58,0.08)] ${a?"border-[var(--color-accent-purple)] focus-within:border-[var(--color-accent-purple)]":"border-border focus-within:border-[var(--color-accent-orange)]"}`,children:[a&&e.jsxs("div",{className:"flex items-center gap-[var(--spacing-2)] px-[var(--spacing-3)] pt-[var(--spacing-2-5)]",children:[e.jsxs("div",{className:"flex items-center gap-[var(--spacing-1-5)] flex-1 min-w-0 px-[var(--spacing-2-5)] py-[var(--spacing-1-5)] rounded-[var(--radius-default)] bg-[var(--color-tint-planning)]",children:[e.jsx(b,{size:12,strokeWidth:2,className:"text-[var(--color-accent-purple)] shrink-0"}),e.jsx("span",{className:"text-[10px] font-semibold text-[var(--color-accent-purple)] shrink-0",children:"Continue from"}),e.jsx("span",{className:"text-[10px] font-medium text-text-secondary truncate",children:a.title||a.userInput.substring(0,40)}),e.jsxs("span",{className:"text-[9px] text-text-placeholder shrink-0",children:[a.items.length," items"]})]}),e.jsx("button",{type:"button",className:"w-[20px] h-[20px] rounded-[var(--radius-sm)] flex items-center justify-center text-text-placeholder hover:bg-bg-hover hover:text-text-primary transition-all duration-[var(--duration-fast)] shrink-0",onClick:()=>x(null),title:"Dismiss context",children:e.jsx(C,{size:12,strokeWidth:2})})]}),e.jsx("textarea",{className:"w-full border-none bg-transparent resize-none outline-none text-text-primary leading-relaxed font-sans",style:{fontSize:"var(--style-composer-textarea-size)",padding:"var(--style-composer-padding)",paddingBottom:"var(--spacing-2)",paddingTop:a?"var(--spacing-2)":void 0},placeholder:a?"Describe additional requirements to build upon...":"Describe a feature, user story, or requirement...",rows:3,value:t,onChange:r=>l(r.target.value),onKeyDown:v}),e.jsxs("div",{className:"flex items-center px-[var(--spacing-3)] pb-[var(--spacing-2)] gap-[var(--spacing-1)]",children:[e.jsx("div",{className:"flex gap-[1px] bg-bg-secondary rounded-[var(--radius-default)] p-[2px]",children:H.map(r=>e.jsx("button",{type:"button",className:`text-[length:var(--font-size-xs)] font-medium px-[var(--spacing-2-5)] py-[3px] rounded-[var(--radius-sm)] transition-all duration-[var(--duration-fast)] ${s===r.value?"bg-bg-card text-text-primary shadow-sm":"text-text-tertiary hover:text-text-secondary"}`,onClick:()=>c(r.value),children:r.label},r.value))}),e.jsx("div",{className:"flex gap-[1px] bg-bg-secondary rounded-[var(--radius-default)] p-[2px] ml-[var(--spacing-1)]",children:["sdk","cli"].map(r=>e.jsx("button",{type:"button",className:`text-[length:var(--font-size-xs)] font-medium px-[var(--spacing-2)] py-[3px] rounded-[var(--radius-sm)] transition-all duration-[var(--duration-fast)] ${o===r?"bg-bg-card text-text-primary shadow-sm":"text-text-tertiary hover:text-text-secondary"}`,onClick:()=>p(r),children:r==="sdk"?"SDK":"CLI"},r))}),e.jsx("div",{className:"flex-1"}),e.jsxs("button",{type:"button",className:"flex items-center gap-[var(--spacing-1)] text-[length:var(--font-size-xs)] font-semibold px-[var(--spacing-4)] py-[5px] rounded-[var(--radius-default)] bg-text-primary text-text-inverse hover:opacity-85 transition-opacity duration-[var(--duration-fast)] disabled:opacity-[var(--opacity-disabled)]",disabled:!t.trim()||i,onClick:m,children:[a?e.jsx(b,{size:13,strokeWidth:2}):e.jsx(E,{size:13,strokeWidth:2}),i?"Expanding...":a?"Continue":"Expand"]})]})]}),e.jsxs("div",{className:"flex gap-[var(--spacing-2-5)] px-[var(--spacing-1)] mt-[var(--spacing-1-5)] text-[length:10px] text-text-placeholder",children:[e.jsxs("span",{children:[e.jsx("kbd",{className:"font-mono text-[10px] px-[5px] py-[1px] border border-border-divider rounded-[3px] bg-bg-secondary",children:"Ctrl+Enter"})," ","expand"]}),e.jsxs("span",{children:[e.jsx("kbd",{className:"font-mono text-[10px] px-[5px] py-[1px] border border-border-divider rounded-[3px] bg-bg-secondary",children:"Tab"})," ","depth"]})]})]})}function B(){const{history:t,currentRequirement:l,loadHistory:s}=h(y(i=>({history:i.history,currentRequirement:i.currentRequirement,loadHistory:i.loadHistory})));if(t.length===0)return e.jsx("div",{className:"flex-1 flex items-center justify-center px-[var(--spacing-5)]",children:e.jsx("p",{className:"text-[length:var(--font-size-xs)] text-text-placeholder text-center",children:"No expansion history yet"})});const c=new Date,o=[],p=[],d=[];for(const i of t){const a=new Date(i.createdAt);a.getDate()===c.getDate()&&a.getMonth()===c.getMonth()&&a.getFullYear()===c.getFullYear()?p.push(i):d.push(i)}return p.length&&o.push({label:"Today",items:p}),d.length&&o.push({label:"Earlier",items:d}),e.jsxs("div",{className:"flex-1 overflow-y-auto px-[var(--spacing-5)] mt-[var(--spacing-5)]",children:[e.jsxs("div",{className:"flex items-center gap-[var(--spacing-1-5)] text-[length:10px] font-semibold text-text-tertiary uppercase tracking-[0.06em] mb-[var(--spacing-2)]",children:[e.jsx(R,{size:12,strokeWidth:2}),"History"]}),e.jsx("div",{className:"flex flex-col gap-[2px]",children:o.map(i=>e.jsxs("div",{children:[o.length>1&&e.jsx("div",{className:"text-[length:10px] text-text-placeholder px-[var(--spacing-2-5)] py-[var(--spacing-1)] mt-[var(--spacing-1)]",children:i.label}),i.items.map(a=>{const x=(l==null?void 0:l.id)===a.id;return e.jsxs("button",{type:"button",className:`w-full text-left flex items-center gap-[var(--spacing-3)] px-[var(--spacing-2-5)] py-[var(--spacing-2)] rounded-[var(--radius-md)] transition-all duration-[var(--duration-normal)] ${x?"bg-bg-active":"hover:bg-bg-hover"}`,onClick:()=>s(a.id),children:[e.jsx("span",{className:`inline-block w-[8px] h-[8px] rounded-full shrink-0 ${A[a.status]??"bg-text-tertiary"}`}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-[length:var(--font-size-xs)] font-semibold truncate text-text-primary",children:a.title||a.userInput.substring(0,50)}),e.jsxs("div",{className:"flex items-center gap-[var(--spacing-2)] mt-[2px]",children:[a.status==="done"&&e.jsx("span",{className:"text-[9px] font-semibold px-[6px] py-[1px] rounded-full bg-[var(--color-tint-completed)] text-[var(--color-accent-green)]",children:"done"}),a.status==="failed"&&e.jsx("span",{className:"text-[9px] font-semibold px-[6px] py-[1px] rounded-full bg-[var(--color-tint-blocked)] text-[var(--color-accent-red)]",children:"failed"}),a.items.length>0&&e.jsxs("span",{className:"text-[9px] font-semibold px-[6px] py-[1px] rounded-full bg-[var(--color-tint-exploring)] text-[var(--color-accent-blue)]",children:[a.items.length," items"]}),e.jsx("span",{className:"text-[9px] font-semibold px-[6px] py-[1px] rounded-full bg-[var(--color-tint-planning)] text-[var(--color-accent-purple)]",children:a.depth})]})]}),e.jsx("span",{className:"text-[10px] text-text-placeholder shrink-0",children:U(a.createdAt)})]},a.id)})]},i.label))})]})}function U(t){const l=Date.now()-new Date(t).getTime(),s=Math.floor(l/6e4);if(s<1)return"now";if(s<60)return`${s}m`;const c=Math.floor(s/60);return c<24?`${c}h`:`${Math.floor(c/24)}d`}function Y(){const{currentRequirement:t,isLoading:l,error:s,progressMessage:c}=h(y(p=>({currentRequirement:p.currentRequirement,isLoading:p.isLoading,error:p.error,progressMessage:p.progressMessage}))),o=t==null?void 0:t.status;return t?o==="expanding"||o==="committing"?e.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-[var(--spacing-5)]",children:[e.jsxs("div",{className:"relative w-12 h-12",children:[e.jsx("div",{className:"absolute inset-0 rounded-full border-2 border-bg-tertiary"}),e.jsx("div",{className:"absolute inset-0 rounded-full border-2 border-transparent animate-spin",style:{borderTopColor:o==="expanding"?"var(--color-accent-blue)":"var(--color-accent-orange)"}})]}),e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"text-[length:var(--font-size-sm)] font-medium text-text-primary",children:o==="expanding"?"Expanding requirement":"Committing"}),e.jsx("p",{className:"text-[length:var(--font-size-xs)] text-text-tertiary mt-[var(--spacing-1)]",children:c||(o==="expanding"?"Analyzing and structuring...":"Creating issues...")})]})]}):o==="failed"?e.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-[var(--spacing-4)]",children:[e.jsx("div",{className:"w-12 h-12 rounded-full bg-[var(--color-tint-blocked)] flex items-center justify-center",children:e.jsx("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"var(--color-accent-red)",strokeWidth:"2",strokeLinecap:"round",children:e.jsx("path",{d:"M18 6 6 18M6 6l12 12"})})}),e.jsxs("div",{className:"text-center max-w-sm",children:[e.jsx("p",{className:"text-[length:var(--font-size-sm)] font-medium text-text-primary",children:"Expansion Failed"}),(s??t.error)&&e.jsx("p",{className:"text-[length:var(--font-size-xs)] text-accent-red mt-[var(--spacing-2)] leading-relaxed",children:s??t.error})]})]}):e.jsx(V,{}):e.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-[var(--spacing-4)] text-text-placeholder",children:[e.jsxs("svg",{width:"40",height:"40",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"}),e.jsx("polyline",{points:"14 2 14 8 20 8"}),e.jsx("line",{x1:"16",y1:"13",x2:"8",y2:"13"}),e.jsx("line",{x1:"16",y1:"17",x2:"8",y2:"17"}),e.jsx("polyline",{points:"10 9 9 9 8 9"})]}),e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"text-[length:var(--font-size-sm)] font-medium text-text-secondary",children:"No expansion yet"}),e.jsx("p",{className:"text-[length:var(--font-size-xs)] text-text-tertiary mt-[var(--spacing-1)]",children:"Enter a requirement and click Expand to generate a structured checklist"})]})]})}function V(){const[t,l]=g.useState(""),{currentRequirement:s,refine:c,commit:o,updateItem:p,isLoading:d,committedResult:i,resetRequirement:a,setContinueFrom:x}=h(y(n=>({currentRequirement:n.currentRequirement,refine:n.refine,commit:n.commit,updateItem:n.updateItem,isLoading:n.isLoading,committedResult:n.committedResult,resetRequirement:n.resetRequirement,setContinueFrom:n.setContinueFrom}))),m=g.useCallback(()=>{const n=t.trim();n&&(c(n),l(""))},[t,c]);if(!s)return null;const v=s.status==="done",r=s.items,j=G(r);return e.jsxs("div",{className:"flex flex-col h-full",children:[e.jsx("div",{className:"px-[var(--spacing-5)] py-[var(--spacing-4)] border-b border-border-divider shrink-0",children:e.jsx("div",{className:"flex items-start gap-[var(--spacing-3)]",children:e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h2",{className:"text-[length:var(--font-size-md)] font-bold text-text-primary truncate",children:s.title||"Expanded Requirement"}),s.summary&&e.jsx("p",{className:"text-[length:var(--font-size-xs)] text-text-secondary leading-relaxed mt-[var(--spacing-1)] line-clamp-2",children:s.summary}),e.jsxs("div",{className:"flex gap-[var(--spacing-2)] mt-[var(--spacing-2)]",children:[e.jsxs("span",{className:"text-[10px] font-semibold px-[var(--spacing-2-5)] py-[2px] rounded-full bg-[var(--color-tint-exploring)] text-[var(--color-accent-blue)]",children:[r.length," items"]}),e.jsxs("span",{className:"text-[10px] font-semibold px-[var(--spacing-2-5)] py-[2px] rounded-full bg-[var(--color-tint-planning)] text-[var(--color-accent-purple)]",children:[r.filter(n=>n.dependencies.length>0).length," deps"]}),e.jsx("span",{className:"text-[10px] font-semibold px-[var(--spacing-2-5)] py-[2px] rounded-full bg-[var(--color-tint-verifying)] text-[var(--color-accent-orange)]",children:s.depth}),v&&e.jsx("span",{className:"text-[10px] font-semibold px-[var(--spacing-2-5)] py-[2px] rounded-full bg-[var(--color-tint-completed)] text-[var(--color-accent-green)]",children:i?`committed · ${i.mode}`:"done"})]})]})})}),j.length>1&&e.jsxs("div",{className:"px-[var(--spacing-5)] py-[var(--spacing-3)] border-b border-border-divider bg-bg-secondary shrink-0",children:[e.jsxs("div",{className:"flex items-center gap-[var(--spacing-1-5)] text-[10px] font-semibold text-text-tertiary uppercase tracking-[0.04em] mb-[var(--spacing-2)]",children:[e.jsx($,{size:12,strokeWidth:2}),"Dependency Flow"]}),e.jsx("div",{className:"flex items-center gap-[var(--spacing-1)] overflow-x-auto pb-[var(--spacing-1)]",children:j.map((n,u)=>e.jsxs("span",{className:"flex items-center gap-[var(--spacing-1)] shrink-0",children:[u>0&&e.jsx(F,{size:10,className:"text-text-placeholder"}),e.jsxs("span",{className:`text-[10px] font-semibold px-[var(--spacing-2-5)] py-[3px] rounded-[var(--radius-sm)] whitespace-nowrap ${w[u%w.length]}`,children:[u+1,". ",n]})]},u))})]}),e.jsx("div",{className:"flex-1 min-h-0 overflow-y-auto",children:e.jsxs("table",{className:"w-full border-collapse",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{className:"text-[10px] font-semibold uppercase tracking-[0.04em] text-text-tertiary text-left px-[var(--spacing-3-5)] py-[var(--spacing-2-5)] border-b border-border-divider bg-bg-primary sticky top-0 z-[1] w-[28px]",children:"#"}),e.jsx("th",{className:"text-[10px] font-semibold uppercase tracking-[0.04em] text-text-tertiary text-left px-[var(--spacing-3-5)] py-[var(--spacing-2-5)] border-b border-border-divider bg-bg-primary sticky top-0 z-[1]",children:"Item"}),e.jsx("th",{className:"text-[10px] font-semibold uppercase tracking-[0.04em] text-text-tertiary text-left px-[var(--spacing-3-5)] py-[var(--spacing-2-5)] border-b border-border-divider bg-bg-primary sticky top-0 z-[1] w-[68px]",children:"Type"}),e.jsx("th",{className:"text-[10px] font-semibold uppercase tracking-[0.04em] text-text-tertiary text-left px-[var(--spacing-3-5)] py-[var(--spacing-2-5)] border-b border-border-divider bg-bg-primary sticky top-0 z-[1] w-[88px]",children:"Priority"}),e.jsx("th",{className:"text-[10px] font-semibold uppercase tracking-[0.04em] text-text-tertiary text-left px-[var(--spacing-3-5)] py-[var(--spacing-2-5)] border-b border-border-divider bg-bg-primary sticky top-0 z-[1] w-[52px]",children:"Effort"}),e.jsx("th",{className:"text-[10px] font-semibold uppercase tracking-[0.04em] text-text-tertiary text-left px-[var(--spacing-3-5)] py-[var(--spacing-2-5)] border-b border-border-divider bg-bg-primary sticky top-0 z-[1] w-[76px]",children:"Deps"}),e.jsx("th",{className:"text-[10px] font-semibold uppercase tracking-[0.04em] text-text-tertiary text-left px-[var(--spacing-3-5)] py-[var(--spacing-2-5)] border-b border-border-divider bg-bg-primary sticky top-0 z-[1] w-[56px]"})]})}),e.jsx("tbody",{children:r.map((n,u)=>e.jsx(Z,{item:n,index:u,items:r,disabled:v,onUpdate:z=>p(n.id,z)},n.id))})]})}),!v&&e.jsxs("div",{className:"flex gap-[var(--spacing-2)] px-[var(--spacing-5)] py-[var(--spacing-3)] border-t border-border-divider bg-bg-primary shrink-0",children:[e.jsx("textarea",{className:"flex-1 border border-border rounded-[var(--radius-md)] px-[var(--spacing-3-5)] py-[var(--spacing-2)] text-[length:var(--font-size-sm)] text-text-primary bg-bg-card outline-none resize-none placeholder:text-text-placeholder focus:border-[var(--color-accent-purple)] transition-colors duration-[var(--duration-normal)]",rows:1,placeholder:"Provide feedback to refine this expansion...",value:t,onChange:n=>l(n.target.value),onKeyDown:n=>{n.key==="Enter"&&!n.shiftKey&&(n.preventDefault(),m())}}),e.jsxs("button",{type:"button",className:"flex items-center gap-[var(--spacing-1-5)] shrink-0 px-[var(--spacing-4)] py-[var(--spacing-2)] rounded-[var(--radius-md)] border border-border text-text-secondary text-[length:var(--font-size-xs)] font-semibold hover:text-text-primary hover:bg-bg-hover transition-all duration-[var(--duration-normal)] disabled:opacity-[var(--opacity-disabled)]",disabled:!t.trim()||d,onClick:m,children:[e.jsx(D,{size:14,strokeWidth:1.8}),"Refine"]})]}),e.jsxs("div",{className:"flex items-center gap-[var(--spacing-2)] px-[var(--spacing-5)] py-[var(--spacing-3)] border-t border-border bg-bg-primary shrink-0",children:[v?e.jsxs(e.Fragment,{children:[e.jsxs("button",{type:"button",className:"flex items-center gap-[var(--spacing-1-5)] px-[var(--spacing-4)] py-[var(--spacing-2)] rounded-[var(--radius-md)] border border-border text-text-secondary text-[length:var(--font-size-xs)] font-semibold hover:text-text-primary hover:bg-bg-hover transition-all duration-[var(--duration-normal)]",onClick:a,children:[e.jsx(P,{size:14,strokeWidth:1.8}),"New Requirement"]}),e.jsxs("button",{type:"button",className:"flex items-center gap-[var(--spacing-1-5)] px-[var(--spacing-3)] py-[var(--spacing-2)] rounded-[var(--radius-md)] border border-[var(--color-accent-purple)]/20 text-[var(--color-accent-purple)] text-[length:var(--font-size-xs)] font-semibold hover:bg-[var(--color-tint-planning)] transition-all duration-[var(--duration-normal)]",onClick:()=>x(s),title:"Use this expansion as context for further planning",children:[e.jsx(b,{size:14,strokeWidth:1.8}),"Continue Planning"]})]}):e.jsxs(e.Fragment,{children:[e.jsxs("button",{type:"button",className:"flex items-center gap-[var(--spacing-1-5)] px-[var(--spacing-4)] py-[var(--spacing-2)] rounded-[var(--radius-md)] bg-accent-green text-text-inverse text-[length:var(--font-size-xs)] font-semibold hover:opacity-85 transition-opacity duration-[var(--duration-fast)] disabled:opacity-[var(--opacity-disabled)]",disabled:d,onClick:()=>o("issues"),children:[e.jsx(S,{size:14,strokeWidth:1.8}),"Commit as Issues"]}),e.jsxs("button",{type:"button",className:"flex items-center gap-[var(--spacing-1-5)] px-[var(--spacing-4)] py-[var(--spacing-2)] rounded-[var(--radius-md)] border border-border text-text-secondary text-[length:var(--font-size-xs)] font-semibold hover:text-text-primary hover:bg-bg-hover transition-all duration-[var(--duration-normal)] disabled:opacity-[var(--opacity-disabled)]",disabled:d,onClick:()=>o("coordinate"),children:[e.jsx(T,{size:14,strokeWidth:1.8}),"Coordinate"]}),e.jsx("div",{className:"w-px h-[20px] bg-border-divider mx-[var(--spacing-1)]"}),e.jsxs("button",{type:"button",className:"flex items-center gap-[var(--spacing-1-5)] px-[var(--spacing-3)] py-[var(--spacing-2)] rounded-[var(--radius-md)] border border-[var(--color-accent-purple)]/20 text-[var(--color-accent-purple)] text-[length:var(--font-size-xs)] font-semibold hover:bg-[var(--color-tint-planning)] transition-all duration-[var(--duration-normal)] disabled:opacity-[var(--opacity-disabled)]",disabled:d,onClick:()=>x(s),title:"Use this expansion as context for further planning",children:[e.jsx(b,{size:14,strokeWidth:1.8}),"Continue"]})]}),e.jsx("div",{className:"flex-1"}),e.jsxs("span",{className:"text-[10px] text-text-tertiary",children:[r.length," items · ",s.depth]})]})]})}function Z({item:t,index:l,items:s,disabled:c,onUpdate:o}){const p=t.dependencies.map(d=>{const i=s.findIndex(a=>a.id===d);return i>=0?`#${i+1}`:null}).filter(Boolean);return e.jsxs("tr",{className:"transition-colors duration-[var(--duration-normal)] hover:bg-bg-hover",children:[e.jsx("td",{className:"px-[var(--spacing-3-5)] py-[var(--spacing-3)] border-b border-border-divider align-top text-[length:var(--font-size-xs)] font-semibold text-text-placeholder text-center",children:l+1}),e.jsxs("td",{className:"px-[var(--spacing-3-5)] py-[var(--spacing-3)] border-b border-border-divider align-top",children:[e.jsx("div",{className:"text-[length:var(--font-size-sm)] font-semibold text-text-primary leading-tight",children:t.title}),e.jsx("div",{className:"text-[length:var(--font-size-xs)] text-text-tertiary mt-[2px] leading-snug",children:t.description})]}),e.jsx("td",{className:"px-[var(--spacing-3-5)] py-[var(--spacing-3)] border-b border-border-divider align-top",children:e.jsx("span",{className:`inline-flex text-[9px] font-semibold px-[7px] py-[2px] rounded-full uppercase tracking-[0.03em] ${N[t.type]??N.task}`,children:t.type})}),e.jsx("td",{className:"px-[var(--spacing-3-5)] py-[var(--spacing-3)] border-b border-border-divider align-top",children:e.jsxs("div",{className:"flex items-center gap-[var(--spacing-1)]",children:[e.jsx("span",{className:`inline-block w-[6px] h-[6px] rounded-full ${k[t.priority]??k.medium}`}),e.jsx("span",{className:"text-[length:var(--font-size-xs)] text-text-secondary capitalize",children:t.priority})]})}),e.jsx("td",{className:"px-[var(--spacing-3-5)] py-[var(--spacing-3)] border-b border-border-divider align-top",children:e.jsx("span",{className:"text-[10px] font-semibold px-[var(--spacing-2)] py-[2px] rounded-[var(--radius-sm)] bg-bg-secondary text-text-secondary",children:O[t.estimated_effort]??t.estimated_effort??"—"})}),e.jsx("td",{className:"px-[var(--spacing-3-5)] py-[var(--spacing-3)] border-b border-border-divider align-top",children:p.length>0?e.jsx("div",{className:"flex flex-wrap gap-[3px]",children:p.map(d=>e.jsx("span",{className:"text-[9px] font-semibold px-[6px] py-[1px] rounded-[var(--radius-sm)] bg-[var(--color-tint-planning)] text-[var(--color-accent-purple)] cursor-pointer hover:bg-[var(--color-accent-purple)] hover:text-white transition-colors duration-[var(--duration-fast)]",children:d},d))}):e.jsx("span",{className:"text-[10px] text-text-placeholder",children:"—"})}),e.jsx("td",{className:"px-[var(--spacing-3-5)] py-[var(--spacing-3)] border-b border-border-divider align-top",children:!c&&e.jsxs("div",{className:"flex gap-[2px]",children:[e.jsx("button",{type:"button",className:"w-[26px] h-[26px] rounded-[var(--radius-default)] flex items-center justify-center text-text-placeholder hover:bg-bg-hover hover:text-text-primary transition-all duration-[var(--duration-normal)]",title:"Edit",children:e.jsx(L,{size:14,strokeWidth:1.8})}),e.jsx("button",{type:"button",className:"w-[26px] h-[26px] rounded-[var(--radius-default)] flex items-center justify-center text-text-placeholder hover:bg-bg-hover hover:text-text-primary transition-all duration-[var(--duration-normal)]",title:"Remove",children:e.jsx(_,{size:14,strokeWidth:1.8})})]})})]})}const w=["bg-[var(--color-tint-exploring)] text-[var(--color-accent-blue)]","bg-[var(--color-tint-planning)] text-[var(--color-accent-purple)]","bg-[var(--color-tint-verifying)] text-[var(--color-accent-orange)]","bg-[var(--color-tint-completed)] text-[var(--color-accent-green)]"];function G(t){return t.length===0?[]:t.map(l=>{const s=l.title.split(/\s+/);return s.length>3?s.slice(0,3).join(" "):l.title})}function ae(){const t=h(l=>l.fetchHistory);return g.useEffect(()=>{t()},[t]),e.jsxs("div",{className:"h-full flex",children:[e.jsxs("div",{className:"w-[40%] shrink-0 border-r border-border flex flex-col overflow-hidden bg-bg-primary",children:[e.jsx(K,{}),e.jsx(B,{})]}),e.jsx("div",{className:"w-[60%] flex flex-col overflow-hidden bg-bg-primary",children:e.jsx(Y,{})})]})}export{ae as RequirementPage};
@@ -0,0 +1,36 @@
1
+ import{d as S,o as se,a9 as F,r as p,j as e,a5 as H,aa as ie,F as U,ab as le,X as ce,R as de,P as xe,O as pe,f as be,T as ue,h as O,i as A,V as me}from"./index-C2Mcb4TJ.js";import{u as ge}from"./shallow-BXasQBvr.js";import{C as fe}from"./columns-3-BUcKlxve.js";import{L as ye}from"./list-DI8Wn2aT.js";import{S as he}from"./search-BS6fI6Bg.js";import{C as Y}from"./circle-Qfgy4LB_.js";import{m as z}from"./proxy-D72Y8a4Y.js";import{C as ve}from"./circle-alert-Na1vf6qQ.js";import{T as J}from"./trash-2-Czz4X8Fb.js";import{P as X}from"./pen-line-Ch7sphzZ.js";import{C as we}from"./check-DJDk3A2a.js";/**
2
+ * @license lucide-react v0.577.0 - ISC
3
+ *
4
+ * This source code is licensed under the ISC license.
5
+ * See the LICENSE file in the root directory of this source tree.
6
+ */const je=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],Q=S("arrow-down",je);/**
7
+ * @license lucide-react v0.577.0 - ISC
8
+ *
9
+ * This source code is licensed under the ISC license.
10
+ * See the LICENSE file in the root directory of this source tree.
11
+ */const ke=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m16.24 7.76-1.804 5.411a2 2 0 0 1-1.265 1.265L7.76 16.24l1.804-5.411a2 2 0 0 1 1.265-1.265z",key:"9ktpf1"}]],Ne=S("compass",ke);/**
12
+ * @license lucide-react v0.577.0 - ISC
13
+ *
14
+ * This source code is licensed under the ISC license.
15
+ * See the LICENSE file in the root directory of this source tree.
16
+ */const Ce=[["path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49",key:"ct8e1f"}],["path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242",key:"151rxh"}],["path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143",key:"13bj9a"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]],Ee=S("eye-off",Ce);/**
17
+ * @license lucide-react v0.577.0 - ISC
18
+ *
19
+ * This source code is licensed under the ISC license.
20
+ * See the LICENSE file in the root directory of this source tree.
21
+ */const Be=[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],Ae=S("eye",Be);/**
22
+ * @license lucide-react v0.577.0 - ISC
23
+ *
24
+ * This source code is licensed under the ISC license.
25
+ * See the LICENSE file in the root directory of this source tree.
26
+ */const Se=[["path",{d:"M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915",key:"1i5ecw"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],De=S("settings",Se);/**
27
+ * @license lucide-react v0.577.0 - ISC
28
+ *
29
+ * This source code is licensed under the ISC license.
30
+ * See the LICENSE file in the root directory of this source tree.
31
+ */const Te=[["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"}]],R=S("shield",Te);/**
32
+ * @license lucide-react v0.577.0 - ISC
33
+ *
34
+ * This source code is licensed under the ISC license.
35
+ * See the LICENSE file in the root directory of this source tree.
36
+ */const Fe=[["path",{d:"M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z",key:"vktsd0"}],["circle",{cx:"7.5",cy:"7.5",r:".5",fill:"currentColor",key:"kqv944"}]],Z=S("tag",Fe),f=se((r,c)=>({entries:[],files:[],loading:!1,error:null,activeView:"kanban",typeFilter:"all",categoryFilter:"all",keywordFilter:"all",search:"",selectedEntry:null,hiddenColumns:new Set,setActiveView:o=>r({activeView:o}),setTypeFilter:o=>r({typeFilter:o}),setCategoryFilter:o=>r({categoryFilter:o}),setKeywordFilter:o=>r({keywordFilter:o}),setSearch:o=>r({search:o}),setSelectedEntry:o=>r({selectedEntry:o}),toggleColumn:o=>r(n=>{const s=new Set(n.hiddenColumns);return s.has(o)?s.delete(o):s.add(o),{hiddenColumns:s}}),fetchEntries:async()=>{r({loading:!0,error:null});try{const o=await fetch(F.SPECS);if(!o.ok)throw new Error(`Failed: ${o.status}`);const n=await o.json();r({entries:n.entries??[],loading:!1})}catch(o){r({loading:!1,error:String(o)})}},fetchFiles:async()=>{try{const o=await fetch(F.SPECS_FILES);if(!o.ok)return;const n=await o.json();r({files:n.files??[]})}catch{}},addEntry:async(o,n,s)=>{r({error:null});try{const d=await fetch(F.SPECS,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:o,content:n,file:s})});if(!d.ok){const g=await d.json().catch(()=>({error:`HTTP ${d.status}`}));throw new Error(g.error)}return c().fetchEntries(),null}catch(d){return r({error:String(d)}),null}},deleteEntry:async o=>{r({error:null});const n=c().entries;r(s=>({entries:s.entries.filter(d=>d.id!==o)}));try{(await fetch(`${F.SPECS}/${o}`,{method:"DELETE"})).ok||r({entries:n})}catch{r({entries:n})}},filteredEntries:()=>{const{entries:o,typeFilter:n,categoryFilter:s,keywordFilter:d,search:g}=c();let y=o;if(n!=="all"&&(y=y.filter(u=>u.type===n)),s!=="all"&&(y=y.filter(u=>u.category===s)),d!=="all"&&(y=y.filter(u=>u.keywords.includes(d))),g){const u=g.toLowerCase();y=y.filter(h=>h.title.toLowerCase().includes(u)||h.content.toLowerCase().includes(u)||h.id.toLowerCase().includes(u)||h.keywords.some(v=>v.toLowerCase().includes(u)))}return y},entriesByType:()=>{const o=c().filteredEntries(),n={bug:[],pattern:[],decision:[],rule:[],debug:[],test:[],review:[],validation:[],general:[],learning:[],coding:[],arch:[],quality:[]};for(const s of o)(n[s.type]??n.general).push(s);return n},typeCounts:()=>{const{entries:o}=c(),n={all:o.length,bug:0,pattern:0,decision:0,rule:0,debug:0,test:0,review:0,validation:0,general:0};for(const s of o)n[s.type]=(n[s.type]??0)+1;return n},allCategories:()=>{const{entries:o}=c(),n=new Set;for(const s of o)s.category&&n.add(s.category);return Array.from(n).sort()},allKeywords:()=>{const{entries:o}=c(),n=new Set;for(const s of o)for(const d of s.keywords)n.add(d);return Array.from(n).sort()}})),_e={general:{label:"General",icon:e.jsx(Y,{size:14,strokeWidth:1.8}),tintBg:"var(--color-tint-pending)",color:"#A09D97"},planning:{label:"Planning",icon:e.jsx(Ne,{size:14,strokeWidth:1.8}),tintBg:"var(--color-tint-planning)",color:"#9178B5"},execution:{label:"Execution",icon:e.jsx(De,{size:14,strokeWidth:1.8}),tintBg:"var(--color-tint-exploring)",color:"#5B8DB8"},debug:{label:"Debug",icon:e.jsx(ve,{size:14,strokeWidth:1.8}),tintBg:"var(--color-tint-blocked)",color:"#C46555"},test:{label:"Test",icon:e.jsx(R,{size:14,strokeWidth:1.8}),tintBg:"var(--color-tint-completed)",color:"#5A9E78"},review:{label:"Review",icon:e.jsx(le,{size:14,strokeWidth:1.8}),tintBg:"rgba(219,176,108,0.12)",color:"#C4A055"},validation:{label:"Validation",icon:e.jsx(R,{size:14,strokeWidth:1.8}),tintBg:"rgba(90,158,120,0.10)",color:"#3D8B5F"}},Le=["general","planning","execution","debug","test","review","validation"],ze={label:"",icon:e.jsx(Y,{size:14,strokeWidth:1.8}),tintBg:"var(--color-tint-pending)",color:"#A09D97"};function I(r){return _e[r]??{...ze,label:r.charAt(0).toUpperCase()+r.slice(1)}}const Me={coding:{bg:"var(--color-tint-exploring)",text:"#5B8DB8"},arch:{bg:"var(--color-tint-planning)",text:"#9178B5"},quality:{bg:"var(--color-tint-completed)",text:"#5A9E78"},debug:{bg:"rgba(196,101,85,0.10)",text:"#B85B4A"},test:{bg:"rgba(90,158,120,0.10)",text:"#3D8B5F"},review:{bg:"rgba(219,176,108,0.12)",text:"#C4A055"},learning:{bg:"var(--color-tint-blocked)",text:"#C46555"},bug:{bg:"var(--color-tint-blocked)",text:"#C46555"},pattern:{bg:"var(--color-tint-exploring)",text:"#5B8DB8"},decision:{bg:"var(--color-tint-planning)",text:"#9178B5"},rule:{bg:"var(--color-tint-completed)",text:"#5A9E78"},validation:{bg:"rgba(91,141,184,0.10)",text:"#4A7DA8"},general:{bg:"var(--color-tint-pending)",text:"#A09D97"}},We={bg:"var(--color-tint-pending)",text:"#A09D97"};function qe(r){if(!r)return"--";const c=new Date(r);if(isNaN(c.getTime()))return"--";const n=Date.now()-c.getTime(),s=Math.floor(n/6e4);if(s<1)return"now";if(s<60)return`${s}m ago`;const d=Math.floor(s/60);return d<24?`${d}h ago`:`${Math.floor(d/24)}d ago`}function $e({onAddEntry:r}){const c=f(a=>a.entries),o=f(a=>a.typeFilter),n=f(a=>a.keywordFilter),s=f(a=>a.search),d=f(a=>a.selectedEntry),g=f(a=>a.setSelectedEntry),y=f(a=>a.setKeywordFilter),u=f(a=>a.hiddenColumns),h=f(a=>a.toggleColumn),v=p.useMemo(()=>{const a=new Set;for(const x of c)x.category&&a.add(x.category);const i=[];for(const x of Le)a.has(x)&&(i.push(x),a.delete(x));for(const x of Array.from(a).sort())i.push(x);return i},[c]),N=p.useMemo(()=>{const a=new Set;for(const i of c)for(const x of i.keywords)a.add(x);return Array.from(a).sort()},[c]),w=p.useMemo(()=>{let a=c;if(o!=="all"&&(a=a.filter(i=>i.type===o)),n!=="all"&&(a=a.filter(i=>i.keywords.includes(n))),s){const i=s.toLowerCase();a=a.filter(x=>x.title.toLowerCase().includes(i)||x.content.toLowerCase().includes(i)||x.id.toLowerCase().includes(i)||x.keywords.some(C=>C.toLowerCase().includes(i)))}return a},[c,o,n,s]),m=p.useMemo(()=>{const a={};for(const i of v)a[i]=[];for(const i of w){const x=i.category||"general";a[x]||(a[x]=[]),a[x].push(i)}return a},[w,v]),k=p.useMemo(()=>{const a={};for(const i of c){const x=i.category||"general";a[x]=(a[x]??0)+1}return a},[c]),B=p.useMemo(()=>v.filter(a=>!u.has(a)),[v,u]);return e.jsxs("div",{className:"flex flex-col flex-1 overflow-hidden",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-[6px] px-5 py-2 border-b border-border-divider bg-bg-primary shrink-0",children:[v.map(a=>{const i=I(a),x=!u.has(a),C=k[a]??0;return e.jsxs("button",{type:"button",onClick:()=>h(a),className:["text-[11px] font-medium px-[10px] py-[4px] rounded-full border cursor-pointer transition-all","flex items-center gap-[5px]",x?"bg-bg-card text-text-primary border-border hover:shadow-sm":"bg-bg-secondary text-text-quaternary border-border-divider opacity-60"].join(" "),style:x?{borderColor:i.color,boxShadow:`0 0 0 1px ${i.color}22`}:void 0,children:[e.jsx("span",{className:"w-2 h-2 rounded-full shrink-0 transition-opacity",style:{background:i.color,opacity:x?1:.35}}),i.label,e.jsx("span",{className:"text-[10px] font-mono opacity-60",children:C})]},a)}),N.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w-px h-[18px] bg-border-divider mx-1"}),e.jsx(Z,{size:11,strokeWidth:2,className:"text-text-quaternary shrink-0"}),N.map(a=>{const i=n===a;return e.jsx("button",{type:"button",onClick:()=>y(i?"all":a),className:["text-[10px] font-medium px-2 py-[2px] rounded-[4px] border cursor-pointer transition-all",i?"bg-text-primary text-white border-text-primary":"bg-bg-card text-text-tertiary border-border-divider hover:border-text-tertiary hover:text-text-primary"].join(" "),children:a},a)})]})]}),e.jsxs("div",{className:"flex gap-3 flex-1 overflow-x-auto p-3",children:[B.map((a,i)=>{const x=I(a),C=m[a]??[];return e.jsxs("div",{className:"flex flex-col min-w-[260px] flex-1 bg-bg-secondary rounded-[12px] overflow-hidden",children:[e.jsxs("div",{className:"flex items-center gap-2 px-[14px] py-3 border-b border-black/[0.04]",children:[e.jsx("div",{className:"w-7 h-7 rounded-[8px] flex items-center justify-center shrink-0",style:{background:x.tintBg,color:x.color},children:x.icon}),e.jsx("span",{className:"text-[13px] font-bold text-text-primary",children:x.label}),e.jsx("span",{className:"text-[10px] text-text-tertiary bg-bg-card px-[6px] rounded-full font-mono",children:C.length}),e.jsx("button",{type:"button",onClick:r,className:"ml-auto w-6 h-6 rounded-[6px] border border-dashed border-border bg-transparent cursor-pointer flex items-center justify-center text-text-quaternary hover:border-text-tertiary hover:text-text-primary hover:bg-bg-card transition-all",children:e.jsx(H,{size:12,strokeWidth:2})})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto p-2 flex flex-col gap-2",children:[C.map((E,D)=>e.jsx(Ve,{entry:E,selected:d===E.id,onClick:()=>g(E.id),index:i*100+D},E.id)),C.length===0&&e.jsx("div",{className:"flex items-center justify-center py-8 text-[11px] text-text-quaternary",children:"No entries"})]})]},a)}),B.length===0&&e.jsx("div",{className:"flex items-center justify-center flex-1 text-[13px] text-text-tertiary",children:"All columns hidden — click a category tag above to show it."})]})]})}function Ve({entry:r,selected:c,onClick:o,index:n}){const s=Me[r.type]??We;return e.jsxs(z.div,{initial:{opacity:0,y:6},animate:{opacity:1,y:0},transition:{duration:.2,delay:Math.min(n*.03,.3)},onClick:o,className:["bg-bg-card rounded-[10px] px-[14px] py-3 border cursor-pointer","transition-all duration-[180ms]","hover:-translate-y-[2px] hover:shadow-[0_4px_16px_rgba(0,0,0,0.06)] hover:border-border",c?"border-[#9178B5] shadow-[0_0_0_2px_rgba(145,120,181,0.2)]":"border-border-divider"].join(" "),children:[e.jsxs("div",{className:"flex items-center gap-[6px] mb-2",children:[e.jsx("span",{className:"text-[9px] font-bold px-[7px] py-[2px] rounded-[4px] uppercase font-mono tracking-[0.04em]",style:{background:s.bg,color:s.text},children:r.type}),e.jsx("span",{className:"text-[10px] font-mono text-text-quaternary ml-auto",children:r.id})]}),e.jsx("div",{className:"text-[13px] text-text-primary font-medium leading-[1.5] mb-2 line-clamp-3",children:r.content||r.title}),r.keywords.length>0&&e.jsxs("div",{className:"flex flex-wrap gap-1 mb-2",children:[r.keywords.slice(0,4).map(d=>e.jsx("span",{className:"text-[9px] px-[5px] py-[1px] rounded-[3px] bg-bg-secondary text-text-tertiary font-mono",children:d},d)),r.keywords.length>4&&e.jsxs("span",{className:"text-[9px] text-text-quaternary font-mono",children:["+",r.keywords.length-4]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:"text-[10px] text-text-quaternary font-mono flex items-center gap-[3px]",children:[e.jsx(ie,{size:10,strokeWidth:2}),qe(r.timestamp)]}),r.file&&e.jsxs("span",{className:"text-[10px] text-text-tertiary flex items-center gap-[3px] ml-auto",children:[e.jsx(U,{size:10,strokeWidth:2}),r.file.split("/").pop()]})]})]})}const Pe={coding:{bg:"var(--color-tint-exploring)",text:"#5B8DB8"},arch:{bg:"var(--color-tint-planning)",text:"#9178B5"},quality:{bg:"var(--color-tint-completed)",text:"#5A9E78"},debug:{bg:"rgba(196,101,85,0.10)",text:"#B85B4A"},test:{bg:"rgba(90,158,120,0.10)",text:"#3D8B5F"},review:{bg:"rgba(219,176,108,0.12)",text:"#C4A055"},learning:{bg:"var(--color-tint-blocked)",text:"#C46555"},bug:{bg:"var(--color-tint-blocked)",text:"#C46555"},pattern:{bg:"var(--color-tint-exploring)",text:"#5B8DB8"},decision:{bg:"var(--color-tint-planning)",text:"#9178B5"},rule:{bg:"var(--color-tint-completed)",text:"#5A9E78"},validation:{bg:"rgba(91,141,184,0.10)",text:"#4A7DA8"},general:{bg:"var(--color-tint-pending)",text:"#A09D97"}},Oe={bg:"var(--color-tint-pending)",text:"#A09D97"},Re={coding:"#5B8DB8",arch:"#9178B5",quality:"#5A9E78",debug:"#B85B4A",test:"#3D8B5F",review:"#C4A055",learning:"#C46555",bug:"#C46555",pattern:"#5B8DB8",decision:"#9178B5",rule:"#5A9E78",validation:"#4A7DA8",general:"#A09D97"},ee={coding:"#5B8DB8",arch:"#9178B5",quality:"#5A9E78",learning:"#A09D97",debug:"#C46555",test:"#5A9E78",review:"#C4A055"},Ie=[{value:"all",label:"All"},{value:"bug",label:"Bug"},{value:"pattern",label:"Pattern"},{value:"decision",label:"Decision"},{value:"rule",label:"Rule"},{value:"debug",label:"Debug"},{value:"test",label:"Test"},{value:"review",label:"Review"},{value:"validation",label:"Validation"},{value:"general",label:"General"}],K=[{key:"id",label:"ID",width:60},{key:"type",label:"Type",width:80},{key:"category",label:"Category",width:100},{key:"content",label:"Content",alwaysVisible:!0},{key:"keywords",label:"Keywords",width:180},{key:"file",label:"File",width:140},{key:"added",label:"Added",width:90},{key:"actions",label:"",width:80,alwaysVisible:!0}];function Ke(r){if(!r)return"--";const c=new Date(r);if(isNaN(c.getTime()))return"--";const n=Date.now()-c.getTime(),s=Math.floor(n/6e4);if(s<1)return"now";if(s<60)return`${s}m ago`;const d=Math.floor(s/60);return d<24?`${d}h ago`:`${Math.floor(d/24)}d ago`}function Ge(){const r=f(t=>t.entries),c=f(t=>t.typeFilter),o=f(t=>t.setTypeFilter),n=f(t=>t.categoryFilter),s=f(t=>t.setCategoryFilter),d=f(t=>t.keywordFilter),g=f(t=>t.setKeywordFilter),y=f(t=>t.search),u=f(t=>t.selectedEntry),h=f(t=>t.setSelectedEntry),v=f(t=>t.deleteEntry),N=f(t=>t.addEntry),[w,m]=p.useState("timestamp"),[k,B]=p.useState("desc"),[a,i]=p.useState(!1),[x,C]=p.useState("bug"),[E,D]=p.useState(""),[L,te]=p.useState(new Set),re=p.useCallback(t=>{te(l=>{const b=new Set(l);return b.has(t)?b.delete(t):b.add(t),b})},[]),T=p.useMemo(()=>K.filter(t=>t.alwaysVisible||!L.has(t.key)),[L]),M=p.useMemo(()=>{const t=new Set;for(const l of r)l.category&&t.add(l.category);return Array.from(t).sort()},[r]),W=p.useMemo(()=>{const t=new Set;for(const l of r)for(const b of l.keywords)t.add(b);return Array.from(t).sort()},[r]),oe=p.useMemo(()=>{const t={all:r.length,bug:0,pattern:0,decision:0,rule:0,general:0};for(const l of r)t[l.type]=(t[l.type]??0)+1;return t},[r]),ae=p.useMemo(()=>{const t={};for(const l of r){const b=l.category||"general";t[b]=(t[b]??0)+1}return t},[r]),q=p.useMemo(()=>{let t=r;if(c!=="all"&&(t=t.filter(l=>l.type===c)),n!=="all"&&(t=t.filter(l=>l.category===n)),d!=="all"&&(t=t.filter(l=>l.keywords.includes(d))),y){const l=y.toLowerCase();t=t.filter(b=>b.title.toLowerCase().includes(l)||b.content.toLowerCase().includes(l)||b.id.toLowerCase().includes(l)||b.keywords.some(j=>j.toLowerCase().includes(l)))}return t},[r,c,n,d,y]),$=p.useMemo(()=>{const t=[...q];return t.sort((l,b)=>{let j=0;return w==="timestamp"?j=new Date(l.timestamp).getTime()-new Date(b.timestamp).getTime():w==="id"?j=l.id.localeCompare(b.id):w==="type"?j=l.type.localeCompare(b.type):w==="category"&&(j=(l.category||"").localeCompare(b.category||"")),k==="desc"?-j:j}),t},[q,w,k]),V=p.useCallback(t=>{m(l=>l===t?(B(b=>b==="desc"?"asc":"desc"),l):(B("desc"),t))},[]),P=p.useCallback(async()=>{E.trim()&&(await N(x,E.trim(),"learnings.md"),D(""),i(!1))},[x,E,N]),ne=p.useCallback((t,l)=>{t.stopPropagation(),v(l)},[v]);return e.jsxs("div",{className:"flex flex-col flex-1 overflow-hidden",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2 px-5 py-2 border-b border-border-divider bg-bg-primary shrink-0",children:[e.jsx("span",{className:"text-[10px] font-semibold text-text-quaternary uppercase tracking-[0.06em]",children:"Type"}),Ie.map(t=>{const l=c===t.value;return e.jsxs("button",{type:"button",onClick:()=>o(t.value),className:["text-[11px] font-medium px-3 py-1 rounded-full border cursor-pointer transition-all","flex items-center gap-[5px]",l?"bg-text-primary text-white border-text-primary":"bg-bg-card text-text-secondary border-border hover:border-text-tertiary hover:text-text-primary"].join(" "),children:[t.value!=="all"&&e.jsx("span",{className:"w-[6px] h-[6px] rounded-full",style:{background:l?"#fff":Re[t.value]}}),t.label,e.jsx("span",{className:"text-[10px] font-mono opacity-70",children:oe[t.value]??0})]},t.value)}),M.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w-px h-[18px] bg-border-divider mx-1"}),e.jsx("span",{className:"text-[10px] font-semibold text-text-quaternary uppercase tracking-[0.06em]",children:"Category"}),e.jsx("button",{type:"button",onClick:()=>s("all"),className:["text-[11px] font-medium px-2 py-[3px] rounded-full border cursor-pointer transition-all",n==="all"?"bg-text-primary text-white border-text-primary":"bg-bg-card text-text-secondary border-border hover:border-text-tertiary hover:text-text-primary"].join(" "),children:"All"}),M.map(t=>{const l=n===t,b=ee[t]??"#A09D97";return e.jsxs("button",{type:"button",onClick:()=>s(l?"all":t),className:["text-[11px] font-medium px-[10px] py-[3px] rounded-full border cursor-pointer transition-all","flex items-center gap-[5px]",l?"border-transparent text-white":"bg-bg-card text-text-secondary border-border hover:border-text-tertiary hover:text-text-primary"].join(" "),style:l?{background:b}:void 0,children:[e.jsx("span",{className:"w-[6px] h-[6px] rounded-full",style:{background:l?"#fff":b}}),t.charAt(0).toUpperCase()+t.slice(1),e.jsx("span",{className:"text-[10px] font-mono opacity-70",children:ae[t]??0})]},t)})]}),W.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w-px h-[18px] bg-border-divider mx-1"}),e.jsx("span",{className:"text-[10px] font-semibold text-text-quaternary uppercase tracking-[0.06em]",children:e.jsx(Z,{size:10,strokeWidth:2,className:"inline-block mr-[2px] align-middle"})}),W.map(t=>{const l=d===t;return e.jsx("button",{type:"button",onClick:()=>g(l?"all":t),className:["text-[10px] font-medium px-2 py-[2px] rounded-[4px] border cursor-pointer transition-all",l?"bg-text-primary text-white border-text-primary":"bg-bg-card text-text-tertiary border-border-divider hover:border-text-tertiary hover:text-text-primary"].join(" "),children:t},t)})]}),e.jsx("div",{className:"flex-1"}),e.jsx("div",{className:"flex items-center gap-1",children:K.filter(t=>!t.alwaysVisible).map(t=>{const l=L.has(t.key);return e.jsxs("button",{type:"button",onClick:()=>re(t.key),className:["text-[10px] font-medium px-[6px] py-[3px] rounded-[4px] border cursor-pointer transition-all","flex items-center gap-[3px]",l?"bg-bg-secondary text-text-quaternary border-border-divider opacity-50":"bg-bg-card text-text-tertiary border-border hover:text-text-primary"].join(" "),title:`${l?"Show":"Hide"} ${t.label} column`,children:[l?e.jsx(Ee,{size:9,strokeWidth:2}):e.jsx(Ae,{size:9,strokeWidth:2}),t.label]},t.key)})}),e.jsx("div",{className:"w-px h-[18px] bg-border-divider"}),e.jsxs("button",{type:"button",onClick:()=>V("timestamp"),className:"text-[11px] font-medium px-[10px] py-1 rounded-[6px] border border-border bg-bg-card text-text-tertiary cursor-pointer font-sans transition-all hover:border-text-tertiary hover:text-text-primary flex items-center gap-1",children:[e.jsx(Q,{size:12,strokeWidth:2,className:k==="asc"?"rotate-180 transition-transform":"transition-transform"}),k==="desc"?"Newest":"Oldest"]})]}),e.jsx("div",{className:"flex-1 overflow-y-auto",children:e.jsxs("table",{className:"w-full border-collapse",children:[e.jsx("thead",{children:e.jsx("tr",{children:T.map(t=>{const b={id:"id",type:"type",category:"category",added:"timestamp"}[t.key];return e.jsx(He,{width:t.width,active:b?w===b:!1,onClick:b?()=>V(b):void 0,children:t.label},t.key)})})}),e.jsxs("tbody",{children:[a&&e.jsx("tr",{children:T.map(t=>{const l="var(--color-tint-planning)",b="rgba(145,120,181,0.3)";return t.key==="id"?e.jsx("td",{className:"px-3 py-[10px] border-b-2 align-top",style:{background:l,borderBottomColor:b},children:e.jsx("span",{className:"font-mono text-[11px] font-semibold",style:{color:"#9178B5"},children:"NEW"})},t.key):t.key==="type"?e.jsx("td",{className:"px-3 py-[10px] border-b-2 align-top",style:{background:l,borderBottomColor:b},children:e.jsxs("select",{value:x,onChange:j=>C(j.target.value),className:"px-2 py-1 rounded-[6px] border border-border bg-bg-card text-[11px] text-text-primary font-sans outline-none cursor-pointer",children:[e.jsx("option",{value:"bug",children:"bug"}),e.jsx("option",{value:"pattern",children:"pattern"}),e.jsx("option",{value:"decision",children:"decision"}),e.jsx("option",{value:"rule",children:"rule"}),e.jsx("option",{value:"debug",children:"debug"}),e.jsx("option",{value:"test",children:"test"}),e.jsx("option",{value:"review",children:"review"}),e.jsx("option",{value:"validation",children:"validation"}),e.jsx("option",{value:"general",children:"general"})]})},t.key):t.key==="content"?e.jsx("td",{className:"px-3 py-[10px] border-b-2 align-top",style:{background:l,borderBottomColor:b},children:e.jsx("input",{type:"text",value:E,onChange:j=>D(j.target.value),placeholder:"Describe the entry...",autoFocus:!0,onKeyDown:j=>{j.key==="Enter"&&P(),j.key==="Escape"&&i(!1)},className:"w-full px-[10px] py-[6px] rounded-[6px] border border-border bg-bg-card text-[13px] text-text-primary font-sans outline-none focus:border-[#9178B5] transition-colors"})},t.key):t.key==="actions"?e.jsx("td",{className:"px-3 py-[10px] border-b-2 align-top",style:{background:l,borderBottomColor:b},children:e.jsxs("div",{className:"flex gap-1",children:[e.jsx("button",{type:"button",onClick:()=>void P(),className:"px-3 py-[5px] rounded-[6px] border-none bg-text-primary text-white text-[11px] font-semibold cursor-pointer font-sans hover:bg-[#1A1816] transition-all",children:"Save"}),e.jsx("button",{type:"button",onClick:()=>i(!1),className:"px-3 py-[5px] rounded-[6px] border-none bg-bg-secondary text-text-secondary text-[11px] font-semibold cursor-pointer font-sans hover:bg-bg-tertiary transition-all",children:"Cancel"})]})},t.key):e.jsx("td",{className:"px-3 py-[10px] border-b-2 align-top font-mono text-[11px] text-text-tertiary",style:{background:l,borderBottomColor:b},children:"—"},t.key)})}),$.map((t,l)=>e.jsx(Ue,{entry:t,selected:u===t.id,onClick:()=>h(t.id),onDelete:ne,index:l,visibleColumns:T},t.id)),$.length===0&&e.jsx("tr",{children:e.jsx("td",{colSpan:T.length,className:"text-center py-12 text-[13px] text-text-tertiary",children:"No entries found"})})]})]})})]})}function He({children:r,width:c,active:o,onClick:n}){return e.jsxs("th",{style:{width:c?`${c}px`:void 0},onClick:n,className:["sticky top-0 z-10 text-left text-[10px] font-semibold uppercase tracking-[0.06em] px-3 py-2","bg-bg-secondary border-b border-border select-none whitespace-nowrap",n?"cursor-pointer":"",o?"text-text-primary":"text-text-tertiary hover:text-text-primary"].join(" "),children:[r,o&&e.jsx(Q,{size:10,strokeWidth:2,className:"inline-block align-middle ml-[3px]"})]})}function Ue({entry:r,selected:c,onClick:o,onDelete:n,index:s,visibleColumns:d}){const g=Pe[r.type]??Oe,y=ee[r.category]??"#A09D97",u={id:e.jsx("span",{className:"font-mono text-[11px] text-text-tertiary whitespace-nowrap",children:r.id}),type:e.jsx("span",{className:"text-[9px] font-bold px-[7px] py-[2px] rounded-[4px] uppercase font-mono tracking-[0.04em] whitespace-nowrap inline-block",style:{background:g.bg,color:g.text},children:r.type}),category:e.jsx("span",{className:"text-[10px] font-semibold px-[7px] py-[2px] rounded-[4px] uppercase font-mono tracking-[0.04em] whitespace-nowrap inline-block",style:{background:`${y}15`,color:y},children:r.category||"general"}),content:e.jsx("span",{className:"text-[13px] text-text-primary font-medium leading-[1.5] max-w-[500px] block",children:r.content||r.title}),keywords:e.jsxs("div",{className:"flex flex-wrap gap-[3px]",children:[r.keywords.slice(0,3).map(h=>e.jsx("span",{className:"text-[9px] px-[5px] py-[1px] rounded-[3px] bg-bg-secondary text-text-tertiary font-mono whitespace-nowrap",children:h},h)),r.keywords.length>3&&e.jsxs("span",{className:"text-[9px] text-text-quaternary font-mono",children:["+",r.keywords.length-3]})]}),file:e.jsx("span",{className:"font-mono text-[11px] text-text-tertiary whitespace-nowrap",children:r.file?r.file.split("/").pop():""}),added:e.jsx("span",{className:"font-mono text-[11px] text-text-quaternary whitespace-nowrap",children:Ke(r.timestamp)}),actions:e.jsxs("div",{className:"flex gap-[2px] whitespace-nowrap",children:[e.jsx("button",{type:"button",onClick:h=>{h.stopPropagation(),o()},className:"w-7 h-7 rounded-[6px] border-none bg-transparent cursor-pointer text-text-quaternary flex items-center justify-center transition-all opacity-0 group-hover:opacity-100 hover:bg-bg-hover hover:text-text-primary",children:e.jsx(X,{size:14,strokeWidth:1.8})}),e.jsx("button",{type:"button",onClick:h=>n(h,r.id),className:"w-7 h-7 rounded-[6px] border-none bg-transparent cursor-pointer text-text-quaternary flex items-center justify-center transition-all opacity-0 group-hover:opacity-100 hover:bg-[rgba(196,101,85,0.08)] hover:text-[#C46555]",children:e.jsx(J,{size:14,strokeWidth:1.8})})]})};return e.jsx(z.tr,{initial:{opacity:0},animate:{opacity:1},transition:{duration:.15,delay:Math.min(s*.02,.3)},onClick:o,className:["cursor-pointer transition-colors group",c?"[&>td]:bg-tint-planning":"hover:[&>td]:bg-bg-hover"].join(" "),children:d.map(h=>e.jsx("td",{className:"px-3 py-[10px] border-b border-border-divider align-top",children:u[h.key]},h.key))})}const Ye={coding:{bg:"var(--color-tint-exploring)",text:"#5B8DB8"},arch:{bg:"var(--color-tint-planning)",text:"#9178B5"},quality:{bg:"var(--color-tint-completed)",text:"#5A9E78"},debug:{bg:"rgba(196,101,85,0.10)",text:"#B85B4A"},test:{bg:"rgba(90,158,120,0.10)",text:"#3D8B5F"},review:{bg:"rgba(219,176,108,0.12)",text:"#C4A055"},learning:{bg:"var(--color-tint-blocked)",text:"#C46555"},bug:{bg:"var(--color-tint-blocked)",text:"#C46555"},pattern:{bg:"var(--color-tint-exploring)",text:"#5B8DB8"},decision:{bg:"var(--color-tint-planning)",text:"#9178B5"},rule:{bg:"var(--color-tint-completed)",text:"#5A9E78"},validation:{bg:"rgba(91,141,184,0.10)",text:"#4A7DA8"},general:{bg:"var(--color-tint-pending)",text:"#A09D97"}},Je={bg:"var(--color-tint-pending)",text:"#A09D97"};function Xe(r){if(!r)return"--";const c=new Date(r);if(isNaN(c.getTime()))return"--";const n=Date.now()-c.getTime(),s=Math.floor(n/6e4);if(s<1)return"now";if(s<60)return`${s}m ago`;const d=Math.floor(s/60);if(d<24)return`${d}h ago`;const g=Math.floor(d/24);return g<7?`${g}d ago`:c.toLocaleDateString()}function Qe({entry:r,onClose:c}){const o=f(g=>g.deleteEntry),n=p.useMemo(()=>Ye[r.type]??Je,[r.type]),s=p.useMemo(()=>r.file?r.file.split("/").pop():"",[r.file]);function d(){o(r.id),c()}return e.jsxs(z.aside,{initial:{width:0,opacity:0},animate:{width:380,opacity:1},exit:{width:0,opacity:0},transition:{type:"spring",stiffness:400,damping:30},className:"shrink-0 border-l border-border bg-bg-primary overflow-hidden flex flex-col",children:[e.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-border-divider shrink-0 min-h-[48px]",children:[e.jsx("span",{className:"text-[12px] font-semibold text-text-primary",children:"Entry Detail"}),e.jsx("button",{type:"button",onClick:c,"aria-label":"Close detail panel",className:"w-7 h-7 rounded-[8px] border-none bg-transparent cursor-pointer text-text-tertiary flex items-center justify-center hover:bg-bg-hover hover:text-text-primary transition-colors",children:e.jsx(ce,{size:14,strokeWidth:2})})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto px-4 py-4",style:{width:380},children:[e.jsx("span",{className:"inline-flex items-center gap-[5px] text-[10px] font-bold px-[10px] py-[3px] rounded-[6px] mb-3 uppercase tracking-[0.04em]",style:{background:n.bg,color:n.text},children:r.type}),e.jsx("div",{className:"text-[16px] font-bold text-text-primary leading-[1.5] mb-4",children:r.title||r.content}),e.jsxs("div",{className:"grid grid-cols-2 gap-2 mb-4",children:[e.jsx(_,{label:"ID",value:r.id,mono:!0}),e.jsx(_,{label:"Added",value:Xe(r.timestamp),mono:!0}),e.jsx(_,{label:"File",value:s||"--",mono:!0}),e.jsx(_,{label:"Type",value:r.type})]}),r.content&&r.title&&r.content!==r.title&&e.jsxs("div",{className:"mb-4",children:[e.jsx("div",{className:"text-[9px] font-semibold uppercase tracking-[0.06em] text-text-quaternary mb-[6px]",children:"Description"}),e.jsx("div",{className:"text-[13px] text-text-secondary leading-[1.6] whitespace-pre-wrap",children:r.content})]}),e.jsxs("div",{className:"flex gap-2 pt-3 border-t border-border-divider",children:[e.jsxs("button",{type:"button",className:"flex-1 py-2 rounded-[8px] border border-text-primary bg-text-primary text-[12px] font-semibold text-white cursor-pointer font-sans flex items-center justify-center gap-[6px] hover:bg-[#1A1816] transition-all",children:[e.jsx(X,{size:13,strokeWidth:2}),"Edit"]}),e.jsxs("button",{type:"button",onClick:d,className:"flex-1 py-2 rounded-[8px] border border-border bg-bg-card text-[12px] font-semibold text-text-secondary cursor-pointer font-sans flex items-center justify-center gap-[6px] hover:border-[#C46555] hover:text-[#C46555] hover:bg-[rgba(196,101,85,0.08)] transition-all",children:[e.jsx(J,{size:13,strokeWidth:2}),"Delete"]})]})]})]})}function _({label:r,value:c,mono:o}){return e.jsxs("div",{className:"px-3 py-2 bg-bg-secondary rounded-[8px]",children:[e.jsx("div",{className:"text-[9px] font-semibold uppercase tracking-[0.04em] text-text-quaternary mb-[2px]",children:r}),e.jsx("div",{className:["text-[13px] font-semibold text-text-primary",o?"font-mono text-[12px]":""].join(" "),children:c})]})}const Ze=[{value:"bug",label:"Bug",activeBg:"var(--color-tint-blocked)",activeText:"#C46555",activeBorder:"#C46555"},{value:"pattern",label:"Pattern",activeBg:"var(--color-tint-exploring)",activeText:"#5B8DB8",activeBorder:"#5B8DB8"},{value:"decision",label:"Decision",activeBg:"var(--color-tint-planning)",activeText:"#9178B5",activeBorder:"#9178B5"},{value:"rule",label:"Rule",activeBg:"var(--color-tint-completed)",activeText:"#5A9E78",activeBorder:"#5A9E78"},{value:"debug",label:"Debug",activeBg:"rgba(196,101,85,0.10)",activeText:"#B85B4A",activeBorder:"#B85B4A"},{value:"test",label:"Test",activeBg:"rgba(90,158,120,0.10)",activeText:"#3D8B5F",activeBorder:"#3D8B5F"},{value:"review",label:"Review",activeBg:"rgba(219,176,108,0.12)",activeText:"#C4A055",activeBorder:"#C4A055"},{value:"validation",label:"Validation",activeBg:"rgba(91,141,184,0.10)",activeText:"#4A7DA8",activeBorder:"#4A7DA8"}];function et({open:r,onOpenChange:c}){const o=f(m=>m.addEntry),n=f(m=>m.files),[s,d]=p.useState("bug"),[g,y]=p.useState(""),[u,h]=p.useState(""),[v,N]=p.useState(!1);p.useEffect(()=>{r||(d("bug"),y(""),h(""))},[r]),p.useEffect(()=>{n.length>0&&!u&&h(n[0].path)},[n,u]);const w=p.useCallback(async()=>{g.trim()&&(N(!0),await o(s,g.trim(),u),N(!1),c(!1))},[s,g,u,o,c]);return e.jsx(de,{open:r,onOpenChange:c,children:e.jsxs(xe,{children:[e.jsx(pe,{className:"fixed inset-0 z-50 bg-black/40 backdrop-blur-sm data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0"}),e.jsxs(be,{className:A("fixed left-1/2 top-1/2 z-50 -translate-x-1/2 -translate-y-1/2","w-[480px] max-w-[95vw] max-h-[80vh]","rounded-[16px] border border-border bg-bg-card shadow-lg","flex flex-col overflow-hidden","focus:outline-none","data-[state=open]:animate-in data-[state=closed]:animate-out","data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0","data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95"),children:[e.jsxs("div",{className:"flex items-center justify-between px-5 py-4 border-b border-border-divider shrink-0",children:[e.jsx(ue,{className:"text-[16px] font-bold text-text-primary",children:"New Spec Entry"}),e.jsx(O,{className:A("w-7 h-7 flex items-center justify-center rounded-[8px]","text-text-tertiary hover:text-text-primary hover:bg-bg-hover","transition-colors border-none bg-transparent cursor-pointer"),"aria-label":"Close",children:e.jsxs("svg",{className:"w-[14px] h-[14px]",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),e.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto p-5",children:[e.jsxs("div",{className:"mb-4",children:[e.jsx("label",{className:"block text-[11px] font-semibold text-text-tertiary uppercase tracking-[0.04em] mb-[6px]",children:"Type"}),e.jsx("div",{className:"grid grid-cols-4 gap-2",children:Ze.map(m=>{const k=s===m.value;return e.jsx("button",{type:"button",onClick:()=>d(m.value),className:A("py-[10px] rounded-[10px] border-[1.5px] bg-bg-card cursor-pointer","text-center text-[11px] font-semibold font-sans transition-all"),style:k?{borderColor:m.activeBorder,color:m.activeText,background:m.activeBg,fontWeight:700}:{borderColor:"var(--color-border, #E8E5DE)",color:"var(--color-text-tertiary, #A09D97)"},children:m.label},m.value)})})]}),e.jsxs("div",{className:"mb-4",children:[e.jsx("label",{className:"block text-[11px] font-semibold text-text-tertiary uppercase tracking-[0.04em] mb-[6px]",children:"Content"}),e.jsx("textarea",{value:g,onChange:m=>y(m.target.value),placeholder:"Describe the bug, pattern, decision, or rule...",rows:5,className:A("w-full min-h-[120px] px-[14px] py-[10px] rounded-[8px]","border border-border bg-bg-primary text-[13px] text-text-primary","font-sans leading-[1.6] resize-y outline-none","focus:border-[#9178B5] transition-colors","placeholder:text-text-quaternary")}),e.jsx("div",{className:"text-[11px] text-text-quaternary mt-1",children:"Supports markdown. Will be timestamped automatically."})]}),n.length>0&&e.jsxs("div",{className:"mb-4",children:[e.jsx("label",{className:"block text-[11px] font-semibold text-text-tertiary uppercase tracking-[0.04em] mb-[6px]",children:"Target File"}),e.jsx("select",{value:u,onChange:m=>h(m.target.value),className:A("w-full px-3 py-2 rounded-[8px] border border-border","bg-bg-primary text-[12px] text-text-primary font-sans","outline-none cursor-pointer","focus:border-[#9178B5] transition-colors"),children:n.map(m=>e.jsxs("option",{value:m.path,children:[m.name," (",m.category,")"]},m.path))})]}),u&&e.jsxs("div",{className:"bg-bg-primary rounded-[10px] px-4 py-[14px] border border-border-divider",children:[e.jsx("div",{className:"text-[9px] font-semibold uppercase tracking-[0.06em] text-text-quaternary mb-2",children:"Will write to"}),e.jsxs("div",{className:"flex items-center gap-[6px] px-[10px] py-[6px] rounded-[6px] bg-bg-card border border-border-divider text-[11px] font-mono text-text-secondary",children:[e.jsx(U,{size:12,strokeWidth:1.8,className:"text-text-tertiary"}),e.jsx("span",{className:"text-text-primary font-semibold",children:u})]})]})]}),e.jsxs("div",{className:"flex items-center justify-end gap-2 px-5 py-4 border-t border-border-divider shrink-0",children:[e.jsx(O,{className:A("px-4 py-2 rounded-[8px] border border-border bg-bg-card","text-[12px] font-semibold text-text-secondary cursor-pointer font-sans","hover:border-text-tertiary hover:text-text-primary transition-all"),children:"Cancel"}),e.jsxs("button",{type:"button",disabled:!g.trim()||v,onClick:()=>void w(),className:A("flex items-center gap-[6px] px-[14px] py-2 rounded-[8px] border-none","bg-text-primary text-white text-[12px] font-semibold cursor-pointer font-sans","hover:bg-[#1A1816] hover:-translate-y-px hover:shadow-md transition-all","disabled:opacity-50 disabled:cursor-not-allowed disabled:hover:translate-y-0 disabled:hover:shadow-none"),children:[e.jsx(we,{size:14,strokeWidth:2}),v?"Adding...":"Add Entry"]})]})]})]})})}const tt=[{label:"Kanban",icon:e.jsx(fe,{size:14,strokeWidth:1.8}),shortcut:"1"},{label:"Table",icon:e.jsx(ye,{size:14,strokeWidth:1.8}),shortcut:"2"}],G=["kanban","table"];function bt(){const{activeView:r,setActiveView:c,fetchEntries:o,fetchFiles:n,entries:s,search:d,setSearch:g,selectedEntry:y,setSelectedEntry:u,loading:h,error:v}=f(ge(i=>({activeView:i.activeView,setActiveView:i.setActiveView,fetchEntries:i.fetchEntries,fetchFiles:i.fetchFiles,entries:i.entries,search:i.search,setSearch:i.setSearch,selectedEntry:i.selectedEntry,setSelectedEntry:i.setSelectedEntry,loading:i.loading,error:i.error}))),[N,w]=p.useState(!1),{register:m,unregister:k}=p.useContext(me),B=p.useCallback(i=>c(G[i]),[c]);p.useEffect(()=>{m({items:tt.map(i=>({label:i.label,icon:i.icon,shortcut:i.shortcut})),activeIndex:G.indexOf(r),onSwitch:B})},[r,m,B]),p.useEffect(()=>()=>k(),[k]),p.useEffect(()=>{function i(x){x.target instanceof HTMLInputElement||x.target instanceof HTMLTextAreaElement||(x.key==="1"?c("kanban"):x.key==="2"&&c("table"))}return window.addEventListener("keydown",i),()=>window.removeEventListener("keydown",i)},[c]),p.useEffect(()=>{o(),n()},[o,n]);const a=y?s.find(i=>i.id===y)??null:null;return h&&s.length===0?e.jsx("div",{className:"flex items-center justify-center h-full text-text-secondary text-[length:var(--font-size-sm)]",children:"Loading specs..."}):v&&s.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-3",children:[e.jsx("span",{className:"text-status-failed text-[length:var(--font-size-sm)]",children:"Failed to load specs"}),e.jsx("span",{className:"text-text-tertiary text-[length:var(--font-size-xs)]",children:v}),e.jsx("button",{type:"button",onClick:()=>void o(),className:"px-3 py-1 rounded-[var(--radius-md)] border border-border bg-bg-card text-[11px] font-semibold text-text-secondary hover:text-text-primary transition-all",children:"Retry"})]}):e.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[e.jsxs("div",{className:"flex items-center gap-[10px] px-5 py-[10px] border-b border-border-divider shrink-0",children:[e.jsx("span",{className:"text-[16px] font-bold text-text-primary",children:"Specs"}),e.jsxs("span",{className:"text-[11px] text-text-tertiary font-mono tabular-nums",children:[s.length," entries"]}),e.jsx("div",{className:"flex-1"}),e.jsxs("div",{className:"flex items-center gap-[6px] px-3 py-[5px] rounded-[8px] bg-bg-card w-[240px] focus-within:border-[#9178B5] transition-colors",style:{border:"var(--style-btn-secondary-border)"},children:[e.jsx(he,{size:13,strokeWidth:2,className:"text-text-quaternary shrink-0"}),e.jsx("input",{type:"text",placeholder:"Search specs...",value:d,onChange:i=>g(i.target.value),className:"border-none bg-transparent outline-none text-[12px] text-text-primary font-sans w-full placeholder:text-text-quaternary"})]}),e.jsxs("button",{type:"button",onClick:()=>w(!0),className:"flex items-center gap-[6px] px-[14px] py-[6px] rounded-[8px] border-none bg-text-primary text-white text-[12px] font-semibold cursor-pointer font-sans hover:bg-[#1A1816] hover:[transform:var(--style-card-hover-transform)] hover:[box-shadow:var(--style-card-hover-shadow)] transition-all",children:[e.jsx(H,{size:14,strokeWidth:2}),"New Entry"]})]}),e.jsxs("div",{className:"flex flex-1 overflow-hidden",children:[e.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden min-w-0",children:[r==="kanban"&&e.jsx("div",{className:"flex-1 flex flex-col overflow-hidden motion-safe:animate-[view-fade-in_250ms_ease-out_both]",children:e.jsx($e,{onAddEntry:()=>w(!0)})}),r==="table"&&e.jsx("div",{className:"flex-1 flex flex-col overflow-hidden motion-safe:animate-[view-fade-in_250ms_ease-out_both]",children:e.jsx(Ge,{})})]}),a&&e.jsx(Qe,{entry:a,onClose:()=>u(null)})]}),e.jsx(et,{open:N,onOpenChange:w})]})}export{bt as SpecsPage};
@@ -0,0 +1,6 @@
1
+ import{o as _e,u as T,b as R,j as e,a4 as Be,w as Me,r as g,s as X,ah as _}from"./index-C2Mcb4TJ.js";const m=_e((r,o)=>({activeTab:"commander",learningStats:null,learningPatterns:[],knowledgeEntries:[],scheduledTasks:[],extensions:[],promptModes:[],promptBindings:{},error:null,onLearningUpdate:t=>r({learningStats:t,learningPatterns:t.topPatterns}),onScheduleUpdate:t=>r({scheduledTasks:t}),onScheduleTriggered:t=>r(n=>{const s=new Date().toISOString();return{scheduledTasks:n.scheduledTasks.map(a=>{if(a.id!==t.taskId)return a;const v=a.lastRun?new Date(a.lastRun).getTime():0,p=v>0?Date.now()-v:0;return{...a,lastRun:s,history:[...a.history,{timestamp:s,status:"success",duration:p}]}})}}),onExtensionLoaded:t=>r({extensions:t.extensions}),onExtensionError:t=>r(n=>({extensions:n.extensions.map(x=>x.name!==t.name?x:{...x,status:"disabled"})})),fetchLearningStats:async()=>{try{const t=await fetch("/api/supervisor/learning/stats");if(!t.ok){r({error:`Failed to fetch learning stats: ${t.status}`});return}const n=await t.json();if(n&&typeof n=="object"&&"topPatterns"in n){const s=n;r({learningStats:s,learningPatterns:s.topPatterns,error:null})}}catch(t){r({error:`Failed to fetch learning stats: ${t instanceof Error?t.message:String(t)}`})}},fetchSchedules:async()=>{try{const t=await fetch("/api/supervisor/schedules");if(!t.ok){r({error:`Failed to fetch schedules: ${t.status}`});return}const n=await t.json(),s=n&&typeof n=="object"&&"tasks"in n?n.tasks:Array.isArray(n)?n:[];r({scheduledTasks:s,error:null})}catch(t){r({error:`Failed to fetch schedules: ${t instanceof Error?t.message:String(t)}`})}},fetchExtensions:async()=>{try{const t=await fetch("/api/supervisor/extensions");if(!t.ok){r({error:`Failed to fetch extensions: ${t.status}`});return}const n=await t.json(),s=n&&typeof n=="object"&&"extensions"in n?n.extensions:Array.isArray(n)?n:[];r({extensions:s,error:null})}catch(t){r({error:`Failed to fetch extensions: ${t instanceof Error?t.message:String(t)}`})}},fetchPromptModes:async()=>{try{const t=await fetch("/api/supervisor/prompts");if(!t.ok){r({error:`Failed to fetch prompt modes: ${t.status}`});return}const n=await t.json();if(n&&typeof n=="object"){const s=n,x=Array.isArray(s.builders)?s.builders:[],a=s.bindings&&typeof s.bindings=="object"?s.bindings:{};r({promptModes:x,promptBindings:a,error:null})}}catch(t){r({error:`Failed to fetch prompt modes: ${t instanceof Error?t.message:String(t)}`})}},createSchedule:async t=>{try{const n=await fetch("/api/supervisor/schedules",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!n.ok){r({error:`Failed to create schedule: ${n.status}`});return}const s=await n.json();if(s&&typeof s=="object"&&"task"in s){const x=s.task;r(a=>({scheduledTasks:[...a.scheduledTasks,x],error:null}))}}catch(n){r({error:`Failed to create schedule: ${n instanceof Error?n.message:String(n)}`})}},updateSchedule:async(t,n)=>{try{const s=await fetch(`/api/supervisor/schedules/${encodeURIComponent(t)}`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});if(!s.ok){r({error:`Failed to update schedule: ${s.status}`});return}const x=await s.json();if(x&&typeof x=="object"&&"task"in x){const a=x.task;r(v=>({scheduledTasks:v.scheduledTasks.map(p=>p.id===t?a:p),error:null}))}}catch(s){r({error:`Failed to update schedule: ${s instanceof Error?s.message:String(s)}`})}},deleteSchedule:async t=>{try{const n=await fetch(`/api/supervisor/schedules/${encodeURIComponent(t)}`,{method:"DELETE"});if(!n.ok){r({error:`Failed to delete schedule: ${n.status}`});return}r(s=>({scheduledTasks:s.scheduledTasks.filter(x=>x.id!==t),error:null}))}catch(n){r({error:`Failed to delete schedule: ${n instanceof Error?n.message:String(n)}`})}},toggleSchedule:async(t,n)=>{await o().updateSchedule(t,{enabled:n})},runSchedule:async t=>{try{const n=await fetch(`/api/supervisor/schedules/${encodeURIComponent(t)}/run`,{method:"POST"});n.ok||r({error:`Failed to run schedule: ${n.status}`})}catch(n){r({error:`Failed to run schedule: ${n instanceof Error?n.message:String(n)}`})}},setActiveTab:t=>r({activeTab:t}),clearError:()=>r({error:null})}));function $e(r){const o=Date.now()-new Date(r).getTime(),t=Math.floor(o/1e3);if(t<60)return`${t}s`;const n=Math.floor(t/60);return n<60?`${n}m`:`${Math.floor(n/60)}h ${n%60}m`}function Ae(){var y;const{t:r}=T(),o=R(i=>i.slots),t=R(i=>i.queue),n=R(i=>i.supervisorStatus),s=Object.values(o),x=(n==null?void 0:n.stats.totalDispatched)??0,a=(n==null?void 0:n.stats.totalCompleted)??0,v=(n==null?void 0:n.stats.totalFailed)??0,p=x>0?Math.round(a/x*100):0;return e.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100%",overflowY:"auto",padding:24,gap:20},children:[e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(4, 1fr)",gap:12},children:[e.jsx(Z,{label:r("supervisor.overview.dispatched"),value:String(x),sub:`${s.length} ${r("supervisor.overview.active")}`}),e.jsx(Z,{label:r("supervisor.overview.success_rate"),value:x?`${p}%`:"-",valueColor:"var(--color-accent-green)",sub:`${a} ${r("supervisor.overview.completed")}`}),e.jsx(Z,{label:r("supervisor.overview.queued"),value:String(t.length),sub:`${((y=n==null?void 0:n.retrying)==null?void 0:y.length)??0} retrying`}),e.jsx(Z,{label:"Failed",value:String(v),valueColor:v>0?"var(--color-accent-red)":void 0,sub:x>0?`${Math.round(v/x*100)}% fail rate`:"-"})]}),e.jsxs("div",{style:{borderRadius:12,background:"var(--color-bg-card)",border:"1px solid var(--color-border-divider)",overflow:"hidden"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"12px 16px",borderBottom:"1px solid var(--color-border-divider)"},children:[e.jsx("span",{style:{fontSize:12,fontWeight:600,color:"var(--color-text-primary)"},children:r("supervisor.overview.active_executions")}),e.jsx("span",{style:{fontSize:11,color:"var(--color-text-tertiary)"},children:r("supervisor.overview.running_count",{count:s.length})})]}),e.jsx("div",{children:s.length===0?e.jsx("div",{style:{fontSize:11,color:"var(--color-text-tertiary)",textAlign:"center",padding:16},children:"No active executions"}):s.map(i=>{const d=Be[i.executor]??"var(--color-text-tertiary)",k=Me[i.executor]??i.executor;return e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,padding:"10px 16px",borderBottom:"1px solid var(--color-border-divider)"},children:[e.jsx("span",{style:{width:8,height:8,borderRadius:"50%",background:d,flexShrink:0}}),e.jsx("span",{style:{fontSize:12,fontWeight:500,color:"var(--color-text-primary)"},children:i.issueId}),e.jsx("span",{style:{fontSize:11,color:"var(--color-text-secondary)"},children:k}),e.jsxs("span",{style:{fontSize:11,color:"var(--color-text-tertiary)"},children:["Turn ",i.turnNumber,"/",i.maxTurns]}),e.jsx("span",{style:{fontSize:11,color:"var(--color-text-tertiary)",marginLeft:"auto"},children:$e(i.startedAt)})]},i.processId)})})]}),t.length>0&&e.jsxs("div",{style:{borderRadius:12,background:"var(--color-bg-card)",border:"1px solid var(--color-border-divider)",overflow:"hidden"},children:[e.jsx("div",{style:{padding:"12px 16px",borderBottom:"1px solid var(--color-border-divider)"},children:e.jsxs("span",{style:{fontSize:12,fontWeight:600,color:"var(--color-text-primary)"},children:["Queue (",t.length,")"]})}),e.jsx("div",{children:t.map((i,d)=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,padding:"10px 16px",borderBottom:"1px solid var(--color-border-divider)"},children:[e.jsxs("span",{style:{fontSize:10,fontWeight:600,color:"var(--color-text-tertiary)",minWidth:20},children:["#",d+1]}),e.jsx("span",{style:{fontSize:12,fontWeight:500,color:"var(--color-text-primary)"},children:i})]},i))})]})]})}function Z({label:r,value:o,sub:t,valueColor:n}){return e.jsxs("div",{style:{flex:1,background:"var(--color-bg-primary)",borderRadius:10,padding:14,border:"1px solid var(--color-border-divider)"},children:[e.jsx("div",{style:{fontSize:10,fontWeight:600,textTransform:"uppercase",letterSpacing:".04em",color:"var(--color-text-tertiary)"},children:r}),e.jsx("div",{style:{fontSize:22,fontWeight:700,color:n??"var(--color-text-primary)",marginTop:2},children:o}),e.jsx("div",{style:{fontSize:10,color:"var(--color-text-secondary)"},children:t})]})}const De={optimize:"var(--color-accent-green)",alert:"var(--color-accent-orange)",automate:"var(--color-accent-purple)"};function Ee(){const{t:r}=T(),o=R(i=>i.commanderState),t=R(i=>i.commanderConfig),n=R(i=>i.fetchCommanderConfig),s=R(i=>i.recentDecisions),x=m(i=>i.setActiveTab),a=m(i=>i.learningStats);g.useEffect(()=>{n()},[n]);const v=()=>X({action:"commander:stop"}),p=s.length>0?s[s.length-1]:null,y=(a==null?void 0:a.suggestions)??[];return e.jsxs("div",{style:{flex:1,overflowY:"auto",padding:"20px 24px 40px"},children:[e.jsxs("div",{style:re,children:[e.jsxs("div",{style:K,children:[e.jsx("div",{style:Q,children:r("supervisor.commander.metrics")}),e.jsxs("div",{style:{display:"flex",gap:6},children:[e.jsx("button",{type:"button",onClick:()=>x("executions"),style:Pe,children:r("supervisor.commander.view_executions")??"View Executions"}),e.jsx("button",{type:"button",onClick:v,style:Ne,children:r("supervisor.commander.stop")})]})]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(3, 1fr)",gap:12},children:[e.jsx(ge,{label:r("supervisor.commander.ticks"),value:String((o==null?void 0:o.tickCount)??0),sub:o!=null&&o.sessionId?`Session ${o.sessionId.slice(0,8)}`:void 0}),e.jsx(ge,{label:r("supervisor.commander.workers"),value:String((o==null?void 0:o.activeWorkers)??0),sub:t?`Max: ${t.maxConcurrentWorkers}`:void 0}),e.jsx(ge,{label:r("supervisor.commander.last_tick"),value:o!=null&&o.lastTickAt?we(o.lastTickAt):"--:--:--",valueStyle:{fontSize:16},sub:o!=null&&o.lastTickAt?Fe(o.lastTickAt):void 0})]})]}),t&&e.jsxs("div",{style:re,children:[e.jsx("div",{style:K,children:e.jsx("div",{style:Q,children:r("supervisor.commander.config")})}),e.jsxs("div",{style:He,children:[e.jsx(ee,{label:r("supervisor.commander.profile"),desc:r("supervisor.commander.profile_desc")??"Environment-specific behavior preset",children:e.jsx("select",{value:t.profile,onChange:i=>X({action:"commander:config",config:{profile:i.target.value}}),style:fe,children:["development","staging","production"].map(i=>e.jsx("option",{value:i,children:i},i))})}),e.jsx(ee,{label:r("supervisor.commander.decision_model"),desc:r("supervisor.commander.decision_model_desc")??"AI model for orchestration decisions",children:e.jsx("select",{value:t.decisionModel,onChange:i=>X({action:"commander:config",config:{decisionModel:i.target.value}}),style:fe,children:["haiku","sonnet","opus"].map(i=>e.jsx("option",{value:i,children:i},i))})}),e.jsx(ee,{label:r("supervisor.commander.auto_approve"),desc:r("supervisor.commander.auto_approve_desc")??"Confidence threshold for auto-approval",children:e.jsx("select",{value:t.autoApproveThreshold,onChange:i=>X({action:"commander:config",config:{autoApproveThreshold:i.target.value}}),style:fe,children:["low","medium","high"].map(i=>e.jsx("option",{value:i,children:i},i))})}),e.jsx(ee,{label:r("supervisor.commander.max_workers")??"Max Workers",desc:r("supervisor.commander.max_workers_desc")??"Maximum parallel agent executions",isLast:!0,children:e.jsx("span",{style:{fontSize:12,fontWeight:600,color:"var(--color-text-primary)",padding:"4px 10px"},children:t.maxConcurrentWorkers})})]})]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:16},children:[e.jsxs("div",{style:re,children:[e.jsxs("div",{style:K,children:[e.jsx("div",{style:Q,children:r("supervisor.commander.decision_history")}),e.jsx("div",{style:{fontSize:10,color:"var(--color-text-tertiary)"},children:r("supervisor.commander.decisions_count",{count:s.length})})]}),e.jsx("div",{style:ye,children:e.jsx("div",{style:{padding:"14px 16px"},children:s.length===0?e.jsx("div",{style:{fontSize:11,color:"var(--color-text-tertiary)",textAlign:"center",padding:16},children:r("supervisor.commander.no_decisions")}):s.slice().reverse().map((i,d,k)=>{const j=we(i.timestamp),f=i.actions.length>0?"var(--color-accent-green)":"var(--color-accent-gray)",I=d===k.length-1;return e.jsxs("div",{style:{display:"flex",gap:12,padding:"10px 0",position:"relative"},children:[!I&&e.jsx("div",{style:{position:"absolute",left:11,top:30,bottom:-10,width:1,background:"var(--color-border-divider)"}}),e.jsx("div",{style:qe,children:e.jsx("div",{style:{width:8,height:8,borderRadius:"50%",background:f}})}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:10,fontFamily:"'SF Mono', Consolas, monospace",color:"var(--color-text-placeholder)"},children:j}),e.jsxs("div",{style:{fontSize:12,color:"var(--color-text-primary)"},children:[i.trigger," - ",i.actions.length," action",i.actions.length!==1?"s":""]}),i.deferred.length>0&&e.jsxs("div",{style:{fontSize:10,color:"var(--color-text-tertiary)"},children:[i.deferred.length," deferred"]})]})]},i.id)})})})]}),e.jsxs("div",{style:re,children:[e.jsx("div",{style:K,children:e.jsx("div",{style:Q,children:r("supervisor.commander.latest_assessment")})}),e.jsx("div",{style:ye,children:e.jsx("div",{style:{padding:"14px 16px"},children:p!=null&&p.assessment?e.jsxs(e.Fragment,{children:[p.assessment.observations.length>0&&e.jsxs("div",{style:{marginBottom:12},children:[e.jsx("div",{style:Ce,children:r("supervisor.commander.observations")}),e.jsx("div",{style:{fontSize:11,color:"var(--color-text-secondary)",paddingLeft:8,lineHeight:1.8},children:p.assessment.observations.map((i,d)=>e.jsxs("div",{children:["- ",i]},d))})]}),p.assessment.risks.length>0&&e.jsxs("div",{children:[e.jsx("div",{style:Ce,children:r("supervisor.commander.risks")}),e.jsx("div",{style:{fontSize:11,color:"var(--color-accent-red)",paddingLeft:8,lineHeight:1.8},children:p.assessment.risks.map((i,d)=>e.jsxs("div",{children:["- ",i]},d))})]})]}):e.jsx("div",{style:{fontSize:11,color:"var(--color-text-tertiary)",textAlign:"center",padding:8},children:r("supervisor.commander.no_decisions")})})}),e.jsxs("div",{style:{marginTop:16},children:[e.jsxs("div",{style:K,children:[e.jsx("div",{style:Q,children:r("supervisor.commander.suggestions")??"Suggestions"}),y.length>0&&e.jsxs("span",{style:{fontSize:9,fontWeight:700,padding:"2px 8px",borderRadius:100,background:"var(--color-tint-verifying)",color:"var(--color-accent-orange)"},children:[y.length," new"]})]}),e.jsx("div",{style:ye,children:e.jsx("div",{style:{padding:"14px 16px"},children:y.length===0?e.jsx("div",{style:{fontSize:11,color:"var(--color-text-tertiary)",textAlign:"center",padding:8},children:r("supervisor.commander.no_suggestions")??"No suggestions"}):y.map((i,d)=>e.jsxs("div",{style:{display:"flex",gap:10,padding:"10px 0",borderBottom:d<y.length-1?"1px solid var(--color-border-divider)":"none"},children:[e.jsx("div",{style:{width:8,height:8,borderRadius:"50%",marginTop:5,flexShrink:0,background:De[i.type]??"var(--color-accent-gray)"}}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:12,fontWeight:600,color:"var(--color-text-primary)"},children:i.title}),e.jsxs("div",{style:{fontSize:11,color:"var(--color-text-secondary)",marginTop:1},children:[i.description," (",Math.round(i.confidence*100),"%)"]})]})]},d))})})]})]})]})]})}function ge({label:r,value:o,sub:t,valueStyle:n}){return e.jsxs("div",{style:Oe,children:[e.jsx("div",{style:{fontSize:10,fontWeight:600,textTransform:"uppercase",letterSpacing:".04em",color:"var(--color-text-tertiary)"},children:r}),e.jsx("div",{style:{fontSize:20,fontWeight:800,color:"var(--color-text-primary)",marginTop:2,...n},children:o}),t&&e.jsx("div",{style:{fontSize:10,color:"var(--color-text-tertiary)"},children:t})]})}function ee({label:r,desc:o,children:t,isLast:n}){return e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"12px 16px",borderBottom:n?"none":"1px solid var(--color-border-divider)"},children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:12,fontWeight:500,color:"var(--color-text-primary)"},children:r}),e.jsx("div",{style:{fontSize:10,color:"var(--color-text-tertiary)",marginTop:2},children:o})]}),t]})}function we(r){const o=new Date(r);return`${String(o.getHours()).padStart(2,"0")}:${String(o.getMinutes()).padStart(2,"0")}:${String(o.getSeconds()).padStart(2,"0")}`}function Fe(r){const o=Math.floor((Date.now()-new Date(r).getTime())/1e3);return o<60?`${o}s ago`:o<3600?`${Math.floor(o/60)} min ago`:`${Math.floor(o/3600)}h ago`}const re={marginBottom:24},K={display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:12},Q={fontSize:13,fontWeight:700,color:"var(--color-text-primary)"},ye={background:"var(--color-bg-card)",borderRadius:12,border:"1px solid var(--color-border-divider)",overflow:"hidden"},Oe={background:"var(--color-bg-card)",borderRadius:10,padding:"14px 16px",border:"1px solid var(--color-border-divider)"},He={background:"var(--color-bg-card)",borderRadius:12,border:"1px solid var(--color-border-divider)",overflow:"hidden"},fe={fontSize:12,fontWeight:600,color:"var(--color-text-primary)",padding:"4px 10px",borderRadius:6,border:"1px solid var(--color-border)",background:"var(--color-bg-primary)",minWidth:100,textAlign:"center",cursor:"pointer"},qe={width:22,height:22,borderRadius:"50%",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,border:"2px solid var(--color-bg-primary)"},Ce={fontSize:10,fontWeight:600,textTransform:"uppercase",letterSpacing:".06em",color:"var(--color-text-tertiary)",marginBottom:6},Ie={fontSize:11,fontWeight:600,padding:"5px 12px",borderRadius:8,border:"1px solid var(--color-border)",background:"none",cursor:"pointer",color:"var(--color-text-secondary)",transition:"all 150ms"},Pe={...Ie},Ne={...Ie,color:"var(--color-accent-red)",borderColor:"var(--color-accent-red)"},Ye=["claude","gemini","codex","qwen","opencode"],oe={running:{bg:"var(--color-tint-running)",color:"var(--color-accent-blue)"},awaiting_clarification:{bg:"var(--color-tint-verifying)",color:"var(--color-accent-orange)"},completed:{bg:"var(--color-tint-completed)",color:"var(--color-accent-green)"},failed:{bg:"var(--color-tint-failed)",color:"var(--color-accent-red)"},paused:{bg:"var(--color-tint-pending)",color:"var(--color-accent-gray)"},idle:{bg:"var(--color-tint-pending)",color:"var(--color-accent-gray)"}},P={completed:{bg:"var(--color-tint-completed)",dot:"var(--color-accent-green)"},running:{bg:"var(--color-tint-running)",dot:"var(--color-accent-blue)"},pending:{bg:"transparent",dot:"var(--color-accent-gray)"},failed:{bg:"var(--color-tint-failed)",dot:"var(--color-accent-red)"},skipped:{bg:"var(--color-tint-pending)",dot:"var(--color-accent-gray)"}};function Ke(){const{t:r}=T(),o=_(l=>l.session),t=_(l=>l.selectedStepIndex),n=_(l=>l.clarificationQuestion),s=_(l=>l.start),x=_(l=>l.stop),a=_(l=>l.resume),v=_(l=>l.selectStep),p=_(l=>l.sendClarification),[y,i]=g.useState(""),[d,k]=g.useState("claude"),[j,f]=g.useState(!0),[I,$]=g.useState(""),[L,B]=g.useState(""),C=g.useRef(null),b=o!=null&&o.status!=="idle",u=b&&o.status==="running",E=(o==null?void 0:o.status)==="awaiting_clarification",w=(o==null?void 0:o.steps)??[],h=t!=null?w[t]??null:null,z=w.filter(l=>l.status==="completed"),F=w.length,he=F>0?Math.round(z.length/F*100):0,O=(o==null?void 0:o.avgQuality)??(z.length>0?z.reduce((l,S)=>l+(S.qualityScore??0),0)/z.length:null),H=g.useCallback(()=>{var q;if(!o||!w.length)return"--";const l=(q=w[0])==null?void 0:q.startedAt;if(!l)return"--";const S=Date.now()-new Date(l).getTime();if(S<0)return"--";const W=Math.floor(S/1e3),M=Math.floor(W/60),J=Math.floor(M/60);return J>0?`${J}h ${M%60}m`:M>0?`${M}m ${W%60}s`:`${W}s`},[o,w]);g.useEffect(()=>(u?(B(H()),C.current=setInterval(()=>B(H()),1e3)):(B(H()),C.current&&clearInterval(C.current)),()=>{C.current&&clearInterval(C.current)}),[u,H]),g.useEffect(()=>{if(!b||t!=null)return;const l=w.findIndex(S=>S.status==="running");l>=0?v(l):w.length>0&&v(0)},[b,w,t,v]);const G=()=>{y.trim()&&(s(y.trim(),d,j),i(""))},c=()=>{!I.trim()||!o||(p(o.sessionId,I.trim()),$(""))},Y=l=>{if(l.durationMs!=null){const S=Math.floor(l.durationMs/1e3),W=Math.floor(S/60);return W>0?`${W}m ${S%60}s`:`${S}s`}if(l.status==="running"&&l.startedAt){const S=Math.floor((Date.now()-new Date(l.startedAt).getTime())/1e3),W=Math.floor(S/60);return W>0?`${W}m ${S%60}s...`:`${S}s...`}return""},A=l=>l>=70?"var(--color-accent-green)":l>=40?"var(--color-accent-orange)":"var(--color-accent-red)",ke=l=>l>=70?"var(--color-tint-completed)":l>=40?"var(--color-tint-verifying)":"var(--color-tint-failed)",Le=l=>{switch(l){case"running":return"Running";case"awaiting_clarification":return"Needs Clarification";case"completed":return"Completed";case"failed":return"Failed";case"paused":return"Paused";default:return l}};return e.jsxs("div",{style:{flex:1,overflowY:"auto",padding:"20px 24px 40px"},children:[e.jsxs("div",{style:V,children:[e.jsxs("div",{style:te,children:[e.jsx("div",{style:ne,children:r("supervisor.coordinator.title")}),b&&e.jsxs("div",{style:{display:"flex",gap:6},children:[u&&e.jsx("button",{type:"button",onClick:x,style:Ve,children:r("supervisor.coordinator.stop")}),(o.status==="paused"||o.status==="failed")&&e.jsx("button",{type:"button",onClick:()=>a(),style:Ue,children:r("supervisor.coordinator.resume")})]})]}),e.jsx("div",{style:Ge,children:e.jsxs("div",{style:Je,children:[e.jsx("input",{style:Xe,placeholder:r("supervisor.coordinator.describe_intent"),value:y,onChange:l=>i(l.target.value),onKeyDown:l=>{l.key==="Enter"&&G()}}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,flexShrink:0},children:[e.jsx("select",{style:Ze,value:d,onChange:l=>k(l.target.value),children:Ye.map(l=>e.jsx("option",{value:l,children:l},l))}),e.jsx("button",{type:"button",style:j?er:rr,onClick:()=>f(!j),children:r(j?"supervisor.coordinator.auto":"supervisor.coordinator.manual")}),e.jsx("button",{type:"button",style:Qe,onClick:G,children:r("supervisor.coordinator.start")})]})]})})]}),b&&e.jsxs("div",{style:V,children:[e.jsxs("div",{style:te,children:[e.jsx("div",{style:ne,children:"Session"}),e.jsx("span",{style:{fontSize:9,fontWeight:700,padding:"2px 8px",borderRadius:100,background:(oe[o.status]??oe.idle).bg,color:(oe[o.status]??oe.idle).color},children:Le(o.status)})]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(4, 1fr)",gap:12},children:[e.jsxs("div",{style:ie,children:[e.jsx("div",{style:se,children:r("supervisor.coordinator.chain")}),e.jsx("div",{style:{...le,fontSize:16},children:o.chainName??"--"}),e.jsx("div",{style:ae,children:o.intent||"--"})]}),e.jsxs("div",{style:ie,children:[e.jsx("div",{style:se,children:r("supervisor.coordinator.progress")}),e.jsxs("div",{style:le,children:[z.length,e.jsxs("span",{style:{fontSize:13,fontWeight:500,color:"var(--color-text-tertiary)"},children:[" / ",F]})]}),e.jsx("div",{style:ae,children:e.jsx("div",{style:{height:3,background:"rgba(0,0,0,0.06)",borderRadius:100,overflow:"hidden",marginTop:4},children:e.jsx("div",{style:{height:"100%",borderRadius:100,background:"linear-gradient(90deg, var(--color-accent-blue), var(--color-accent-green))",width:`${he}%`,transition:"width 0.6s"}})})})]}),e.jsxs("div",{style:ie,children:[e.jsx("div",{style:se,children:r("supervisor.coordinator.avg_quality")}),e.jsx("div",{style:{...le,color:O!=null?A(O):"var(--color-text-primary)"},children:O!=null?O.toFixed(1):"--"}),e.jsx("div",{style:ae,children:z.length>0?r("supervisor.coordinator.from_steps",{count:z.length}):"--"})]}),e.jsxs("div",{style:ie,children:[e.jsx("div",{style:se,children:r("supervisor.coordinator.elapsed")}),e.jsx("div",{style:{...le,fontSize:16},children:L}),e.jsxs("div",{style:ae,children:[r("supervisor.coordinator.tool_label"),": ",o.tool??d]})]})]})]}),E&&n&&e.jsx("div",{style:V,children:e.jsxs("div",{style:or,children:[e.jsxs("div",{style:tr,children:[e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"})}),e.jsx("span",{style:nr,children:r("supervisor.coordinator.clarification_needed")})]}),e.jsxs("div",{style:{padding:"14px 16px"},children:[e.jsx("div",{style:ir,children:n}),e.jsxs("div",{style:{display:"flex",gap:8},children:[e.jsx("input",{style:sr,placeholder:r("supervisor.coordinator.type_response"),value:I,onChange:l=>$(l.target.value),onKeyDown:l=>{l.key==="Enter"&&c()}}),e.jsxs("button",{type:"button",style:lr,onClick:c,children:[e.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("line",{x1:"22",y1:"2",x2:"11",y2:"13"}),e.jsx("polygon",{points:"22 2 15 22 11 13 2 9 22 2"})]}),r("supervisor.coordinator.send")]})]})]})]})}),b&&w.length>0&&e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:16},children:[e.jsxs("div",{style:V,children:[e.jsxs("div",{style:te,children:[e.jsx("div",{style:ne,children:r("supervisor.coordinator.chain_steps")}),e.jsx("div",{style:{fontSize:10,color:"var(--color-text-tertiary)"},children:r("supervisor.coordinator.steps_count",{count:F})})]}),e.jsx("div",{style:D,children:e.jsx("div",{style:{padding:"14px 16px"},children:w.map((l,S)=>{const W=P[l.status]??P.pending,M=t===S,J=S===w.length-1,q=Y(l);return e.jsxs("div",{onClick:()=>v(S),style:{display:"flex",gap:12,padding:"10px 8px",position:"relative",cursor:"pointer",background:M?"var(--color-bg-hover)":"transparent",borderRadius:M?8:0,margin:M?"0 -8px":"0"},children:[!J&&e.jsx("div",{style:{position:"absolute",left:M?19:11,top:30,bottom:-10,width:1,background:l.status==="completed"?"var(--color-accent-green)":"var(--color-border-divider)",opacity:l.status==="completed"?.4:1}}),e.jsx("div",{style:{width:22,height:22,borderRadius:"50%",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,background:W.bg,border:"2px solid var(--color-bg-primary)"},children:e.jsx("div",{style:{width:8,height:8,borderRadius:"50%",background:W.dot,animation:l.status==="running"?"pulse 2s infinite":void 0}})}),e.jsxs("div",{style:{flex:1},children:[e.jsx("div",{style:{fontSize:12,fontWeight:600,color:"var(--color-text-primary)"},children:l.cmd}),l.args&&e.jsx("div",{style:{fontSize:10,color:"var(--color-text-tertiary)"},children:l.args}),(q||l.qualityScore!=null||l.status==="running")&&e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginTop:3},children:[q&&e.jsx("span",{style:{fontSize:10,fontFamily:"'SF Mono', Consolas, monospace",color:"var(--color-text-placeholder)"},children:q}),l.qualityScore!=null&&e.jsx("span",{style:{fontSize:9,fontWeight:600,padding:"1px 7px",borderRadius:100,background:ke(l.qualityScore),color:A(l.qualityScore)},children:l.qualityScore}),l.status==="running"&&l.qualityScore==null&&e.jsx("span",{style:{fontSize:9,fontWeight:700,padding:"2px 8px",borderRadius:100,background:"var(--color-tint-running)",color:"var(--color-accent-blue)"},children:"running"})]})]})]},l.index)})})})]}),e.jsx("div",{style:V,children:h?e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:te,children:[e.jsxs("div",{style:ne,children:["Step ",(t??0)+1,": ",h.cmd]}),e.jsx("span",{style:{fontSize:9,fontWeight:700,padding:"2px 8px",borderRadius:100,background:(P[h.status]??P.pending).bg||"var(--color-tint-pending)",color:(P[h.status]??P.pending).dot},children:h.status})]}),h.status==="completed"&&h.qualityScore!=null&&e.jsx("div",{style:{marginBottom:16},children:e.jsxs("div",{style:D,children:[e.jsxs("div",{style:je,children:[e.jsx("span",{style:me,children:r("supervisor.coordinator.quality_score")}),e.jsx("span",{style:{fontSize:9,fontWeight:700,padding:"2px 8px",borderRadius:100,background:ke(h.qualityScore),color:A(h.qualityScore)},children:h.qualityScore})]}),e.jsx("div",{style:{padding:"14px 16px"},children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:16},children:[e.jsxs("div",{style:{width:48,height:48,position:"relative",flexShrink:0},children:[e.jsxs("svg",{viewBox:"0 0 36 36",width:"48",height:"48",style:{transform:"rotate(-90deg)"},children:[e.jsx("circle",{cx:"18",cy:"18",r:"15.9",fill:"none",stroke:"var(--color-bg-secondary)",strokeWidth:"5"}),e.jsx("circle",{cx:"18",cy:"18",r:"15.9",fill:"none",stroke:A(h.qualityScore),strokeWidth:"5",strokeLinecap:"round",strokeDasharray:"100",strokeDashoffset:100-h.qualityScore})]}),e.jsx("div",{style:{position:"absolute",inset:0,display:"flex",alignItems:"center",justifyContent:"center",fontSize:13,fontWeight:800,color:"var(--color-text-primary)"},children:h.qualityScore})]}),h.summary&&e.jsx("div",{style:{flex:1,fontSize:11,color:"var(--color-text-secondary)",lineHeight:1.6},children:h.summary})]})})]})}),h.status==="completed"&&h.summary&&e.jsx("div",{style:{marginBottom:16},children:e.jsxs("div",{style:D,children:[e.jsx("div",{style:je,children:e.jsx("span",{style:me,children:r("supervisor.coordinator.summary")})}),e.jsx("div",{style:{padding:"14px 16px"},children:e.jsx("div",{style:{fontSize:12,color:"var(--color-text-primary)",lineHeight:1.7},children:h.summary})})]})}),(h.status==="running"||h.status==="completed")&&h.analysis&&e.jsx("div",{style:{marginBottom:16},children:e.jsxs("div",{style:D,children:[e.jsx("div",{style:je,children:e.jsx("span",{style:me,children:r("supervisor.coordinator.analysis")})}),e.jsx("pre",{style:ar,children:h.analysis})]})}),(h.status==="pending"||h.status==="skipped")&&e.jsx("div",{style:D,children:e.jsx("div",{style:{padding:"14px 16px"},children:e.jsxs("div",{style:{textAlign:"center",padding:"48px 20px",color:"var(--color-text-tertiary)"},children:[e.jsxs("svg",{width:"40",height:"40",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round",style:{opacity:.2,margin:"0 auto 10px",display:"block"},children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("polyline",{points:"12 6 12 12 16 14"})]}),e.jsx("div",{style:{fontSize:13,fontWeight:600,color:"var(--color-text-secondary)"},children:r("supervisor.coordinator.waiting_execute")}),e.jsx("div",{style:{fontSize:11,marginTop:4,maxWidth:300,marginLeft:"auto",marginRight:"auto",lineHeight:1.6},children:r("supervisor.coordinator.pending_desc")})]})})})]}):e.jsx("div",{style:D,children:e.jsx("div",{style:{padding:"14px 16px"},children:e.jsx("div",{style:{textAlign:"center",padding:"48px 20px",color:"var(--color-text-tertiary)",fontSize:11},children:"Select a step to view details"})})})})]}),!b&&e.jsx("div",{style:D,children:e.jsx("div",{style:{padding:"14px 16px"},children:e.jsxs("div",{style:{textAlign:"center",padding:"48px 20px",color:"var(--color-text-tertiary)"},children:[e.jsxs("svg",{width:"40",height:"40",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round",style:{opacity:.2,margin:"0 auto 10px",display:"block"},children:[e.jsx("circle",{cx:"12",cy:"12",r:"3"}),e.jsx("path",{d:"M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1-2.83 2.83l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-4 0v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83-2.83l.06-.06A1.65 1.65 0 0 0 5.6 15a1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1 0-4h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 2.83-2.83l.06.06A1.65 1.65 0 0 0 9 4.6a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 2.83l-.06.06A1.65 1.65 0 0 0 19.4 9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 0 4h-.09a1.65 1.65 0 0 0-1.51 1z"})]}),e.jsx("div",{style:{fontSize:13,fontWeight:600,color:"var(--color-text-secondary)"},children:r("supervisor.coordinator.no_session")}),e.jsx("div",{style:{fontSize:11,marginTop:4,maxWidth:300,marginLeft:"auto",marginRight:"auto",lineHeight:1.6},children:r("supervisor.coordinator.no_session_desc")})]})})})]})}const V={marginBottom:24},te={display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:12},ne={fontSize:13,fontWeight:700,color:"var(--color-text-primary)"},D={background:"var(--color-bg-card)",borderRadius:12,border:"1px solid var(--color-border-divider)",overflow:"hidden"},je={display:"flex",alignItems:"center",justifyContent:"space-between",padding:"12px 16px",borderBottom:"1px solid var(--color-border-divider)"},me={fontSize:12,fontWeight:700,color:"var(--color-text-primary)"},ie={background:"var(--color-bg-card)",borderRadius:10,padding:"14px 16px",border:"1px solid var(--color-border-divider)"},se={fontSize:10,fontWeight:600,textTransform:"uppercase",letterSpacing:".04em",color:"var(--color-text-tertiary)"},le={fontSize:20,fontWeight:800,color:"var(--color-text-primary)",marginTop:2},ae={fontSize:10,color:"var(--color-text-tertiary)"},Se={fontSize:11,fontWeight:600,padding:"5px 12px",borderRadius:8,border:"1px solid var(--color-border)",background:"none",cursor:"pointer",color:"var(--color-text-secondary)",transition:"all 150ms"},Qe={...Se,background:"var(--color-text-primary)",color:"#fff",borderColor:"var(--color-text-primary)"},Ve={...Se,color:"var(--color-accent-red)",borderColor:"var(--color-accent-red)"},Ue={...Se,color:"var(--color-accent-green)",borderColor:"var(--color-accent-green)"},Ge={background:"var(--color-bg-card)",borderRadius:12,border:"1px solid var(--color-border-divider)",overflow:"hidden"},Je={display:"flex",alignItems:"center",gap:10,padding:"10px 16px"},Xe={flex:1,border:"none",background:"transparent",fontSize:13,color:"var(--color-text-primary)",outline:"none",fontFamily:"inherit",lineHeight:1.5},Ze={padding:"4px 8px",borderRadius:6,fontSize:11,fontWeight:600,border:"1px solid var(--color-border-divider)",background:"var(--color-bg-primary)",color:"var(--color-text-secondary)",cursor:"pointer",outline:"none"},er={fontSize:9,fontWeight:700,padding:"3px 8px",borderRadius:100,border:"none",cursor:"pointer",transition:"all 150ms",background:"var(--color-tint-completed)",color:"var(--color-accent-green)"},rr={fontSize:9,fontWeight:700,padding:"3px 8px",borderRadius:100,border:"none",cursor:"pointer",transition:"all 150ms",background:"var(--color-tint-pending)",color:"var(--color-accent-gray)"},or={background:"var(--color-bg-card)",borderRadius:12,border:"2px solid var(--color-accent-orange)",overflow:"hidden"},tr={display:"flex",alignItems:"center",gap:8,padding:"10px 16px",background:"var(--color-tint-verifying)",color:"var(--color-accent-orange)"},nr={fontSize:11,fontWeight:700,textTransform:"uppercase",letterSpacing:".04em"},ir={fontSize:12,color:"var(--color-text-primary)",lineHeight:1.6,marginBottom:10},sr={flex:1,padding:"7px 12px",fontSize:12,borderRadius:8,border:"1px solid var(--color-border)",background:"var(--color-bg-primary)",color:"var(--color-text-primary)",outline:"none"},lr={padding:"7px 14px",border:"none",borderRadius:8,background:"var(--color-accent-orange)",color:"#fff",fontSize:11,fontWeight:600,cursor:"pointer",display:"flex",alignItems:"center",gap:4},ar={margin:0,padding:"14px 16px",fontSize:11,lineHeight:1.6,whiteSpace:"pre-wrap",wordBreak:"break-word",fontFamily:"'SF Mono', Consolas, monospace",background:"#2C2723",color:"#D9D0C4",borderRadius:"0 0 12px 12px",maxHeight:220,overflowY:"auto"};function dr(){const{t:r}=T(),o=m(d=>d.promptModes),t=m(d=>d.promptBindings),[n,s]=g.useState(null),[x,a]=g.useState(""),[v,p]=g.useState(""),y=v?o.filter(d=>d.toLowerCase().includes(v.toLowerCase())):o,i=d=>{s(d),a(t[d]??"")};return e.jsxs("div",{className:"flex h-full overflow-hidden",children:[e.jsxs("div",{style:{width:320,background:"var(--color-bg-primary)",borderRight:"1px solid var(--color-border)",flexShrink:0,display:"flex",flexDirection:"column",overflow:"hidden"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"14px 16px",borderBottom:"1px solid var(--color-border-divider)"},children:[e.jsx("span",{style:{fontSize:14,fontWeight:700,color:"var(--color-text-primary)"},children:r("supervisor.prompts.title")}),e.jsx("span",{style:{fontSize:10,color:"var(--color-text-tertiary)"},children:r("supervisor.prompts.builders_count",{count:o.length})})]}),e.jsx("input",{value:v,onChange:d=>p(d.target.value),placeholder:r("supervisor.prompts.filter"),style:{margin:"10px 12px 6px",padding:"8px 12px",borderRadius:8,border:"1px solid var(--color-border-divider)",background:"var(--color-bg-card)",fontSize:12,color:"var(--color-text-primary)",outline:"none"}}),e.jsx("div",{style:{flex:1,overflowY:"auto"},children:y.length===0?e.jsx("div",{style:{fontSize:11,color:"var(--color-text-tertiary)",textAlign:"center",padding:16},children:r(v?"supervisor.prompts.no_matches":"supervisor.prompts.no_modes")}):y.map(d=>{const k=d===n,j=!!t[d];return e.jsxs("button",{type:"button",onClick:()=>i(d),style:{display:"flex",alignItems:"center",gap:12,padding:"10px 16px",cursor:"pointer",border:"none",width:"100%",textAlign:"left",background:k?"var(--color-tint-exploring)":"none",borderLeft:`3px solid ${k?"var(--color-accent-blue)":"transparent"}`,transition:"all 120ms"},children:[e.jsx("div",{style:{width:32,height:32,borderRadius:8,display:"flex",alignItems:"center",justifyContent:"center",background:"var(--color-tint-planning)",color:"var(--color-accent-purple)",flexShrink:0},children:e.jsxs("svg",{style:{width:14,height:14,strokeWidth:1.8},viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("polyline",{points:"4 7 4 4 20 4 20 7"}),e.jsx("line",{x1:"9",y1:"20",x2:"15",y2:"20"}),e.jsx("line",{x1:"12",y1:"4",x2:"12",y2:"20"})]})}),e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsx("div",{style:{fontSize:12,fontWeight:600,color:"var(--color-text-primary)",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:d}),e.jsx("div",{style:{fontSize:10,color:"var(--color-text-tertiary)"},children:r(j?"supervisor.prompts.bound":"supervisor.prompts.unbound")})]}),j&&e.jsx("span",{style:{fontSize:9,fontWeight:600,padding:"2px 8px",borderRadius:100,background:"rgba(90,158,120,0.12)",color:"var(--color-accent-green)"},children:"active"})]},d)})})]}),e.jsx("div",{style:{flex:1,overflowY:"auto",display:"flex",flexDirection:"column"},children:n?e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"16px 24px",borderBottom:"1px solid var(--color-border-divider)",flexShrink:0},children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx("div",{style:{width:40,height:40,borderRadius:10,display:"flex",alignItems:"center",justifyContent:"center",background:"var(--color-tint-planning)",color:"var(--color-accent-purple)"},children:e.jsxs("svg",{style:{width:18,height:18,strokeWidth:1.8},viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("polyline",{points:"4 7 4 4 20 4 20 7"}),e.jsx("line",{x1:"9",y1:"20",x2:"15",y2:"20"}),e.jsx("line",{x1:"12",y1:"4",x2:"12",y2:"20"})]})}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:16,fontWeight:700,color:"var(--color-text-primary)"},children:n}),e.jsx("div",{style:{fontSize:11,color:"var(--color-text-secondary)"},children:r("supervisor.prompts.prompt_builder")})]})]})}),e.jsxs("div",{style:{flex:1,overflowY:"auto",padding:"20px 24px",display:"flex",flexDirection:"column",gap:20},children:[e.jsxs("div",{style:{borderRadius:12,background:"var(--color-bg-card)",border:"1px solid var(--color-border-divider)",overflow:"hidden"},children:[e.jsx("div",{style:{display:"flex",alignItems:"center",padding:"12px 16px",borderBottom:"1px solid var(--color-border-divider)"},children:e.jsx("span",{style:{fontSize:12,fontWeight:600,color:"var(--color-text-primary)"},children:r("supervisor.prompts.binding")})}),e.jsxs("div",{style:{padding:"14px 16px"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",padding:"8px 0",borderBottom:"1px solid var(--color-border-divider)"},children:[e.jsx("span",{style:{fontSize:11,color:"var(--color-text-tertiary)",width:120,flexShrink:0},children:r("supervisor.prompts.mode")}),e.jsx("span",{style:{fontSize:12,color:"var(--color-text-primary)",fontWeight:500},children:n})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",padding:"8px 0"},children:[e.jsx("span",{style:{fontSize:11,color:"var(--color-text-tertiary)",width:120,flexShrink:0},children:r("supervisor.prompts.status")}),e.jsx("span",{style:{fontSize:10,fontWeight:600,padding:"2px 8px",borderRadius:100,background:t[n]?"rgba(90,158,120,0.12)":"rgba(160,157,151,0.12)",color:t[n]?"var(--color-accent-green)":"var(--color-accent-gray)"},children:t[n]?r("supervisor.prompts.bound"):r("supervisor.prompts.unbound")})]})]})]}),e.jsxs("div",{style:{borderRadius:12,background:"var(--color-bg-card)",border:"1px solid var(--color-border-divider)",overflow:"hidden"},children:[e.jsx("div",{style:{display:"flex",alignItems:"center",padding:"12px 16px",borderBottom:"1px solid var(--color-border-divider)"},children:e.jsx("span",{style:{fontSize:12,fontWeight:600,color:"var(--color-text-primary)"},children:r("supervisor.prompts.template")})}),e.jsx("div",{style:{padding:"14px 16px"},children:e.jsx("textarea",{value:x,onChange:d=>a(d.target.value),placeholder:r("supervisor.prompts.edit_placeholder"),style:{width:"100%",minHeight:160,resize:"vertical",borderRadius:8,padding:12,fontSize:12,fontFamily:"'SF Mono', Consolas, monospace",lineHeight:1.6,background:"var(--color-bg-secondary)",color:"var(--color-text-primary)",border:"1px solid var(--color-border-divider)",outline:"none"}})})]}),x&&e.jsxs("div",{style:{borderRadius:12,background:"var(--color-bg-card)",border:"1px solid var(--color-border-divider)",overflow:"hidden"},children:[e.jsx("div",{style:{display:"flex",alignItems:"center",padding:"12px 16px",borderBottom:"1px solid var(--color-border-divider)"},children:e.jsx("span",{style:{fontSize:12,fontWeight:600,color:"var(--color-text-primary)"},children:r("supervisor.prompts.preview")})}),e.jsx("div",{style:{padding:0},children:e.jsx("pre",{style:{margin:0,padding:16,fontSize:11,lineHeight:1.6,whiteSpace:"pre-wrap",wordBreak:"break-word",fontFamily:"'SF Mono', Consolas, monospace",maxHeight:200,overflowY:"auto",background:"var(--color-text-primary)",color:"#d4d0ca",borderRadius:"0 0 12px 12px"},children:x})})]})]})]}):e.jsx("div",{style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",color:"var(--color-text-tertiary)",fontSize:13},children:r("supervisor.prompts.select_detail")})})]})}const pe={strategy:{bg:"var(--color-tint-exploring)",fg:"var(--color-accent-blue)"},builder:{bg:"var(--color-tint-completed)",fg:"var(--color-accent-green)"},adapter:{bg:"var(--color-tint-verifying)",fg:"var(--color-accent-orange)"},task:{bg:"var(--color-tint-planning)",fg:"var(--color-accent-purple)"},tool:{bg:"var(--color-tint-pending)",fg:"var(--color-accent-gray)"}},xe={strategy:e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M12 2L2 7l10 5 10-5-10-5z"}),e.jsx("path",{d:"M2 17l10 5 10-5"}),e.jsx("path",{d:"M2 12l10 5 10-5"})]}),builder:e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",ry:"2"}),e.jsx("line",{x1:"3",y1:"9",x2:"21",y2:"9"}),e.jsx("line",{x1:"9",y1:"21",x2:"9",y2:"9"})]}),adapter:e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("polyline",{points:"16 18 22 12 16 6"}),e.jsx("polyline",{points:"8 6 2 12 8 18"})]}),task:e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M22 11.08V12a10 10 0 1 1-5.93-9.14"}),e.jsx("polyline",{points:"22 4 12 14.01 9 11.01"})]}),tool:e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("circle",{cx:"12",cy:"12",r:"3"}),e.jsx("path",{d:"M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1-2.83 2.83l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-4 0v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1 0-4h.09"})]})};function cr(){const{t:r}=T(),o=m(p=>p.extensions),[t,n]=g.useState(null),[s,x]=g.useState(""),a=s?o.filter(p=>p.name.toLowerCase().includes(s.toLowerCase())||p.type.toLowerCase().includes(s.toLowerCase())):o,v=o.find(p=>p.name===t)??null;return e.jsxs("div",{className:"flex h-full overflow-hidden",children:[e.jsxs("div",{style:{width:320,background:"var(--color-bg-primary)",borderRight:"1px solid var(--color-border)",flexShrink:0,display:"flex",flexDirection:"column",overflow:"hidden"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"14px 16px",borderBottom:"1px solid var(--color-border-divider)"},children:[e.jsx("span",{style:{fontSize:14,fontWeight:700,color:"var(--color-text-primary)"},children:r("supervisor.extensions.title")}),e.jsx("span",{style:{fontSize:10,color:"var(--color-text-tertiary)"},children:r("supervisor.extensions.loaded_count",{count:o.length})})]}),e.jsx("input",{value:s,onChange:p=>x(p.target.value),placeholder:r("supervisor.extensions.filter"),style:{margin:"10px 12px 6px",padding:"8px 12px",borderRadius:8,border:"1px solid var(--color-border-divider)",background:"var(--color-bg-card)",fontSize:12,color:"var(--color-text-primary)",outline:"none"}}),e.jsx("div",{style:{flex:1,overflowY:"auto"},children:a.length===0?e.jsx("div",{style:{fontSize:11,color:"var(--color-text-tertiary)",textAlign:"center",padding:16},children:r(s?"supervisor.extensions.no_matches":"supervisor.extensions.no_extensions")}):a.map(p=>{const y=p.name===t,i=pe[p.type]??pe.tool;return e.jsxs("button",{type:"button",onClick:()=>n(p.name),style:{display:"flex",alignItems:"center",gap:12,padding:"10px 16px",cursor:"pointer",border:"none",width:"100%",textAlign:"left",background:y?"var(--color-tint-exploring)":"none",borderLeft:`3px solid ${y?"var(--color-accent-blue)":"transparent"}`,transition:"all 120ms"},children:[e.jsx("div",{style:{width:32,height:32,borderRadius:8,display:"flex",alignItems:"center",justifyContent:"center",background:i.bg,color:i.fg,flexShrink:0},children:e.jsx("span",{style:{width:14,height:14,strokeWidth:1.8,display:"flex"},children:xe[p.type]??xe.tool})}),e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsx("div",{style:{fontSize:12,fontWeight:600,color:"var(--color-text-primary)",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:p.name}),e.jsxs("div",{style:{fontSize:10,color:"var(--color-text-tertiary)",display:"flex",gap:8},children:[e.jsxs("span",{children:["v",p.version]}),e.jsx("span",{children:p.type})]})]}),e.jsx("div",{style:{flexShrink:0},children:e.jsx("span",{style:{width:8,height:8,borderRadius:"50%",display:"inline-block",background:p.status==="enabled"?"var(--color-accent-green)":"var(--color-text-tertiary)"}})})]},p.name)})})]}),e.jsx("div",{style:{flex:1,overflowY:"auto",display:"flex",flexDirection:"column"},children:v?e.jsx(pr,{ext:v}):e.jsx("div",{style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",color:"var(--color-text-tertiary)",fontSize:13},children:r("supervisor.extensions.select_detail")})})]})}function pr({ext:r}){const{t:o}=T(),t=pe[r.type]??pe.tool;return e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"16px 24px",borderBottom:"1px solid var(--color-border-divider)",flexShrink:0},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx("div",{style:{width:40,height:40,borderRadius:10,display:"flex",alignItems:"center",justifyContent:"center",background:t.bg,color:t.fg},children:e.jsx("span",{style:{width:18,height:18,strokeWidth:1.8,display:"flex"},children:xe[r.type]??xe.tool})}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:16,fontWeight:700,color:"var(--color-text-primary)"},children:r.name}),e.jsxs("div",{style:{fontSize:11,color:"var(--color-text-secondary)"},children:["v",r.version]})]})]}),e.jsx("span",{style:{fontSize:10,fontWeight:600,padding:"2px 8px",borderRadius:100,background:r.status==="enabled"?"rgba(90,158,120,0.12)":"rgba(160,157,151,0.12)",color:r.status==="enabled"?"var(--color-accent-green)":"var(--color-accent-gray)"},children:r.status})]}),e.jsxs("div",{style:{flex:1,overflowY:"auto",padding:"20px 24px",display:"flex",flexDirection:"column",gap:20},children:[e.jsx(ze,{title:o("supervisor.extensions.about"),children:e.jsx("div",{style:{fontSize:12,color:"var(--color-text-primary)",lineHeight:1.6},children:r.description||o("supervisor.extensions.no_description")})}),e.jsxs(ze,{title:o("supervisor.extensions.details"),children:[e.jsx(de,{label:o("supervisor.extensions.name"),value:r.name}),e.jsx(de,{label:o("supervisor.extensions.version"),value:r.version}),e.jsx(de,{label:o("supervisor.extensions.type"),value:r.type}),e.jsx(de,{label:o("supervisor.extensions.status"),value:r.status})]})]})]})}function ze({title:r,children:o}){return e.jsxs("div",{style:{borderRadius:12,background:"var(--color-bg-card)",border:"1px solid var(--color-border-divider)",overflow:"hidden"},children:[e.jsx("div",{style:{display:"flex",alignItems:"center",padding:"12px 16px",borderBottom:"1px solid var(--color-border-divider)"},children:e.jsx("span",{style:{fontSize:12,fontWeight:600,color:"var(--color-text-primary)"},children:r})}),e.jsx("div",{style:{padding:"14px 16px"},children:o})]})}function de({label:r,value:o}){return e.jsxs("div",{style:{display:"flex",alignItems:"center",padding:"8px 0",borderBottom:"1px solid var(--color-border-divider)"},children:[e.jsx("span",{style:{fontSize:11,color:"var(--color-text-tertiary)",width:120,flexShrink:0},children:r}),e.jsx("span",{style:{fontSize:12,color:"var(--color-text-primary)",fontWeight:500},children:o})]})}const xr={optimize:"var(--color-accent-blue)",alert:"var(--color-accent-red)",automate:"var(--color-accent-green)"};function ur(){const{t:r}=T(),o=m(i=>i.learningStats),t=m(i=>i.learningPatterns),n=m(i=>i.knowledgeEntries),[s,x]=g.useState(""),[a,v]=g.useState(null),p=s?n.filter(i=>i.topic.toLowerCase().includes(s.toLowerCase())||i.content.toLowerCase().includes(s.toLowerCase())||i.tags.some(d=>d.toLowerCase().includes(s.toLowerCase()))):n,y=t.reduce((i,d)=>Math.max(i,d.frequency),1);return e.jsxs("div",{className:"flex h-full overflow-hidden",children:[e.jsxs("div",{style:{width:320,background:"var(--color-bg-primary)",borderRight:"1px solid var(--color-border)",flexShrink:0,display:"flex",flexDirection:"column",overflow:"hidden"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"14px 16px",borderBottom:"1px solid var(--color-border-divider)"},children:[e.jsx("span",{style:{fontSize:14,fontWeight:700,color:"var(--color-text-primary)"},children:r("supervisor.learning.title")}),o&&e.jsx("span",{style:{fontSize:10,color:"var(--color-text-tertiary)"},children:r("supervisor.learning.cmds_patterns",{cmds:o.totalCommands,patterns:o.uniquePatterns})})]}),e.jsx("input",{value:s,onChange:i=>x(i.target.value),placeholder:r("supervisor.learning.search"),style:{margin:"10px 12px 6px",padding:"8px 12px",borderRadius:8,border:"1px solid var(--color-border-divider)",background:"var(--color-bg-card)",fontSize:12,color:"var(--color-text-primary)",outline:"none"}}),e.jsxs("div",{style:{flex:1,overflowY:"auto"},children:[e.jsx("div",{style:{fontSize:10,fontWeight:600,textTransform:"uppercase",letterSpacing:".06em",color:"var(--color-text-tertiary)",padding:"10px 16px 4px"},children:r("supervisor.learning.command_patterns")}),t.length===0?e.jsx("div",{style:{fontSize:11,color:"var(--color-text-tertiary)",textAlign:"center",padding:12},children:r("supervisor.learning.no_patterns")}):t.map(i=>{const d=(a==null?void 0:a.type)==="pattern"&&a.data.command===i.command;return e.jsxs("button",{type:"button",onClick:()=>v({type:"pattern",data:i}),style:{display:"flex",alignItems:"center",gap:12,padding:"10px 16px",cursor:"pointer",border:"none",width:"100%",textAlign:"left",background:d?"var(--color-tint-exploring)":"none",borderLeft:`3px solid ${d?"var(--color-accent-blue)":"transparent"}`,transition:"all 120ms"},children:[e.jsx("div",{style:{width:32,height:32,borderRadius:8,display:"flex",alignItems:"center",justifyContent:"center",background:"var(--color-tint-exploring)",color:"var(--color-accent-blue)",flexShrink:0},children:e.jsxs("svg",{style:{width:14,height:14,strokeWidth:1.8},viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("polyline",{points:"4 17 10 11 4 5"}),e.jsx("line",{x1:"12",y1:"19",x2:"20",y2:"19"})]})}),e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsx("div",{style:{fontSize:12,fontWeight:600,color:"var(--color-text-primary)",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:i.command}),e.jsxs("div",{style:{fontSize:10,color:"var(--color-text-tertiary)",display:"flex",gap:8},children:[e.jsxs("span",{children:["x",i.frequency]}),e.jsxs("span",{children:[Math.round(i.successRate*100),"% ",r("supervisor.learning.success_label")]})]})]})]},i.command)}),e.jsxs("div",{style:{fontSize:10,fontWeight:600,textTransform:"uppercase",letterSpacing:".06em",color:"var(--color-text-tertiary)",padding:"10px 16px 4px"},children:[r("supervisor.learning.knowledge_base")," (",p.length,")"]}),p.length===0?e.jsx("div",{style:{fontSize:11,color:"var(--color-text-tertiary)",textAlign:"center",padding:12},children:r(s?"supervisor.learning.no_matches":"supervisor.learning.empty")}):p.map(i=>{const d=(a==null?void 0:a.type)==="knowledge"&&a.data.id===i.id;return e.jsxs("button",{type:"button",onClick:()=>v({type:"knowledge",data:i}),style:{display:"flex",alignItems:"center",gap:12,padding:"10px 16px",cursor:"pointer",border:"none",width:"100%",textAlign:"left",background:d?"var(--color-tint-exploring)":"none",borderLeft:`3px solid ${d?"var(--color-accent-blue)":"transparent"}`,transition:"all 120ms"},children:[e.jsx("div",{style:{width:32,height:32,borderRadius:8,display:"flex",alignItems:"center",justifyContent:"center",background:"var(--color-tint-completed)",color:"var(--color-accent-green)",flexShrink:0},children:e.jsxs("svg",{style:{width:14,height:14,strokeWidth:1.8},viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M2 3h6a4 4 0 0 1 4 4v14a3 3 0 0 0-3-3H2z"}),e.jsx("path",{d:"M22 3h-6a4 4 0 0 0-4 4v14a3 3 0 0 1 3-3h7z"})]})}),e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsx("div",{style:{fontSize:12,fontWeight:600,color:"var(--color-text-primary)",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:i.topic}),e.jsxs("div",{style:{fontSize:10,color:"var(--color-text-tertiary)",display:"flex",gap:8},children:[e.jsx("span",{children:i.source}),e.jsx("span",{children:r("supervisor.learning.used_count",{count:i.usageCount})})]})]})]},i.id)})]})]}),e.jsx("div",{style:{flex:1,overflowY:"auto",display:"flex",flexDirection:"column"},children:a?a.type==="pattern"?e.jsx(vr,{pattern:a.data,maxFrequency:y,suggestions:(o==null?void 0:o.suggestions)??[]}):e.jsx(hr,{entry:a.data}):e.jsx("div",{style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",color:"var(--color-text-tertiary)",fontSize:13},children:r("supervisor.learning.select_detail")})})]})}function vr({pattern:r,maxFrequency:o,suggestions:t}){const{t:n}=T(),s=Math.round(r.frequency/o*100),x=r.successRate>=.9?"var(--color-accent-green)":r.successRate>=.7?"var(--color-accent-blue)":"var(--color-accent-yellow)";return e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"16px 24px",borderBottom:"1px solid var(--color-border-divider)",flexShrink:0},children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx("div",{style:{width:40,height:40,borderRadius:10,display:"flex",alignItems:"center",justifyContent:"center",background:"var(--color-tint-exploring)",color:"var(--color-accent-blue)"},children:e.jsxs("svg",{style:{width:18,height:18,strokeWidth:1.8},viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("polyline",{points:"4 17 10 11 4 5"}),e.jsx("line",{x1:"12",y1:"19",x2:"20",y2:"19"})]})}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:16,fontWeight:700,color:"var(--color-text-primary)"},children:r.command}),e.jsx("div",{style:{fontSize:11,color:"var(--color-text-secondary)"},children:n("supervisor.learning.command_pattern")})]})]})}),e.jsxs("div",{style:{flex:1,overflowY:"auto",padding:"20px 24px",display:"flex",flexDirection:"column",gap:20},children:[e.jsxs("div",{style:{display:"flex",gap:16},children:[e.jsx(N,{label:n("supervisor.learning.frequency"),value:String(r.frequency)}),e.jsx(N,{label:n("supervisor.learning.success_rate"),value:`${Math.round(r.successRate*100)}%`,valueColor:x}),e.jsx(N,{label:n("supervisor.learning.avg_duration"),value:`${Math.round(r.avgDuration/1e3)}s`})]}),e.jsxs(U,{title:n("supervisor.learning.usage"),children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,padding:"8px 0"},children:[e.jsx("span",{style:{fontSize:11,color:"var(--color-text-tertiary)",width:80},children:n("supervisor.learning.relative")}),e.jsx("div",{style:{flex:1,height:6,background:"rgba(0,0,0,0.04)",borderRadius:100,overflow:"hidden"},children:e.jsx("div",{style:{height:"100%",width:`${s}%`,borderRadius:100,background:x}})}),e.jsxs("span",{style:{fontSize:11,color:"var(--color-text-tertiary)"},children:[s,"%"]})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",padding:"8px 0",borderTop:"1px solid var(--color-border-divider)"},children:[e.jsx("span",{style:{fontSize:11,color:"var(--color-text-tertiary)",width:120},children:n("supervisor.learning.last_used")}),e.jsx("span",{style:{fontSize:12,color:"var(--color-text-primary)",fontWeight:500},children:r.lastUsed?new Date(r.lastUsed).toLocaleString():"-"})]})]}),r.contexts&&r.contexts.length>0&&e.jsx(U,{title:n("supervisor.learning.contexts"),children:e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:6},children:r.contexts.map(a=>e.jsx("span",{style:{fontSize:10,fontWeight:600,padding:"2px 8px",borderRadius:100,background:"rgba(145,120,181,0.12)",color:"var(--color-accent-purple)"},children:a},a))})}),t.length>0&&e.jsx(U,{title:n("supervisor.learning.suggestions"),children:e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:10},children:t.map((a,v)=>e.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:8},children:[e.jsx("span",{style:{fontSize:10,fontWeight:600,padding:"2px 8px",borderRadius:100,background:xr[a.type]??"var(--color-bg-tertiary)",color:"#fff",flexShrink:0},children:a.type}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:12,fontWeight:600,color:"var(--color-text-primary)"},children:a.title}),e.jsx("div",{style:{fontSize:11,color:"var(--color-text-secondary)"},children:a.description})]})]},v))})})]})]})}function hr({entry:r}){const{t:o}=T();return e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"16px 24px",borderBottom:"1px solid var(--color-border-divider)",flexShrink:0},children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx("div",{style:{width:40,height:40,borderRadius:10,display:"flex",alignItems:"center",justifyContent:"center",background:"var(--color-tint-completed)",color:"var(--color-accent-green)"},children:e.jsxs("svg",{style:{width:18,height:18,strokeWidth:1.8},viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M2 3h6a4 4 0 0 1 4 4v14a3 3 0 0 0-3-3H2z"}),e.jsx("path",{d:"M22 3h-6a4 4 0 0 0-4 4v14a3 3 0 0 1 3-3h7z"})]})}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:16,fontWeight:700,color:"var(--color-text-primary)"},children:r.topic}),e.jsxs("div",{style:{fontSize:11,color:"var(--color-text-secondary)"},children:[o("supervisor.learning.knowledge_entry")," - ",r.source]})]})]})}),e.jsxs("div",{style:{flex:1,overflowY:"auto",padding:"20px 24px",display:"flex",flexDirection:"column",gap:20},children:[e.jsxs("div",{style:{display:"flex",gap:16},children:[e.jsx(N,{label:o("supervisor.learning.usage_count"),value:String(r.usageCount)}),e.jsx(N,{label:o("supervisor.learning.source"),value:r.source}),e.jsx(N,{label:o("supervisor.learning.last_accessed"),value:r.lastAccessed?new Date(r.lastAccessed).toLocaleDateString():"-"})]}),e.jsx(U,{title:o("supervisor.learning.content"),children:e.jsx("div",{style:{fontSize:12,color:"var(--color-text-primary)",lineHeight:1.6,whiteSpace:"pre-wrap"},children:r.content})}),r.tags.length>0&&e.jsx(U,{title:o("supervisor.learning.tags"),children:e.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:6},children:r.tags.map(t=>e.jsx("span",{style:{fontSize:10,fontWeight:600,padding:"2px 8px",borderRadius:100,background:"rgba(91,141,184,0.12)",color:"var(--color-accent-blue)"},children:t},t))})})]})]})}function N({label:r,value:o,valueColor:t}){return e.jsxs("div",{style:{flex:1,background:"var(--color-bg-primary)",borderRadius:10,padding:14,border:"1px solid var(--color-border-divider)"},children:[e.jsx("div",{style:{fontSize:10,fontWeight:600,textTransform:"uppercase",letterSpacing:".04em",color:"var(--color-text-tertiary)"},children:r}),e.jsx("div",{style:{fontSize:22,fontWeight:700,color:t??"var(--color-text-primary)",marginTop:2},children:o})]})}function U({title:r,children:o}){return e.jsxs("div",{style:{borderRadius:12,background:"var(--color-bg-card)",border:"1px solid var(--color-border-divider)",overflow:"hidden"},children:[e.jsx("div",{style:{display:"flex",alignItems:"center",padding:"12px 16px",borderBottom:"1px solid var(--color-border-divider)"},children:e.jsx("span",{style:{fontSize:12,fontWeight:600,color:"var(--color-text-primary)"},children:r})}),e.jsx("div",{style:{padding:"14px 16px"},children:o})]})}const gr=["auto-dispatch","cleanup","report","health-check","learning-analysis","custom"],ue={"auto-dispatch":{bg:"var(--color-tint-verifying)",fg:"var(--color-accent-orange)"},cleanup:{bg:"var(--color-tint-exploring)",fg:"var(--color-accent-blue)"},report:{bg:"var(--color-tint-planning)",fg:"var(--color-accent-purple)"},"health-check":{bg:"var(--color-tint-completed)",fg:"var(--color-accent-green)"},"learning-analysis":{bg:"var(--color-tint-executing)",fg:"var(--color-accent-yellow)"},custom:{bg:"var(--color-tint-pending)",fg:"var(--color-accent-gray)"}},ve={"auto-dispatch":e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("polyline",{points:"13 17 18 12 13 7"}),e.jsx("polyline",{points:"6 17 11 12 6 7"})]}),cleanup:e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("polyline",{points:"3 6 5 6 21 6"}),e.jsx("path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"})]}),report:e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M14.5 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7.5L14.5 2z"}),e.jsx("polyline",{points:"14 2 14 8 20 8"})]}),"health-check":e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M22 11.08V12a10 10 0 1 1-5.93-9.14"}),e.jsx("polyline",{points:"22 4 12 14.01 9 11.01"})]}),"learning-analysis":e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M2 3h6a4 4 0 0 1 4 4v14a3 3 0 0 0-3-3H2z"}),e.jsx("path",{d:"M22 3h-6a4 4 0 0 0-4 4v14a3 3 0 0 1 3-3h7z"})]}),custom:e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("circle",{cx:"12",cy:"12",r:"3"}),e.jsx("path",{d:"M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1-2.83 2.83l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-4 0v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1 0-4h.09"})]})};function yr(){const{t:r}=T(),o=m(u=>u.scheduledTasks),t=m(u=>u.createSchedule),n=m(u=>u.deleteSchedule),s=m(u=>u.toggleSchedule),x=m(u=>u.runSchedule),[a,v]=g.useState(null),[p,y]=g.useState(""),[i,d]=g.useState(!1),[k,j]=g.useState(""),[f,I]=g.useState(""),[$,L]=g.useState("custom"),B=p?o.filter(u=>u.name.toLowerCase().includes(p.toLowerCase())):o,C=o.find(u=>u.id===a)??null,b=async()=>{!k.trim()||!f.trim()||(await t({name:k.trim(),cronExpression:f.trim(),taskType:$,config:{},enabled:!0}),j(""),I(""),L("custom"),d(!1))};return e.jsxs("div",{className:"flex h-full overflow-hidden",children:[e.jsxs("div",{style:{width:320,background:"var(--color-bg-primary)",borderRight:"1px solid var(--color-border)",flexShrink:0,display:"flex",flexDirection:"column",overflow:"hidden"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"14px 16px",borderBottom:"1px solid var(--color-border-divider)"},children:[e.jsx("span",{style:{fontSize:14,fontWeight:700,color:"var(--color-text-primary)"},children:r("supervisor.schedule.title")}),e.jsx("button",{type:"button",onClick:()=>d(!i),style:{fontSize:12,fontWeight:600,padding:"7px 16px",borderRadius:8,border:"none",cursor:"pointer",background:"var(--color-text-primary)",color:"#fff"},children:r(i?"supervisor.schedule.cancel":"supervisor.schedule.new")})]}),i&&e.jsxs("div",{style:{padding:"12px 16px",borderBottom:"1px solid var(--color-border-divider)",display:"flex",flexDirection:"column",gap:8},children:[e.jsx("input",{value:k,onChange:u=>j(u.target.value),placeholder:r("supervisor.schedule.task_name"),style:{...be}}),e.jsx("input",{value:f,onChange:u=>I(u.target.value),placeholder:"*/5 * * * *",style:{...be,fontFamily:"'SF Mono', Consolas, monospace"}}),e.jsx("select",{value:$,onChange:u=>L(u.target.value),style:{...be},children:gr.map(u=>e.jsx("option",{value:u,children:u},u))}),e.jsx("button",{type:"button",onClick:b,disabled:!k.trim()||!f.trim(),style:{fontSize:12,fontWeight:600,padding:"7px 16px",borderRadius:8,border:"none",cursor:"pointer",background:"var(--color-accent-green)",color:"#fff",opacity:!k.trim()||!f.trim()?.4:1},children:r("supervisor.schedule.create")})]}),e.jsx("input",{value:p,onChange:u=>y(u.target.value),placeholder:r("supervisor.schedule.filter"),style:{margin:"10px 12px 6px",padding:"8px 12px",borderRadius:8,border:"1px solid var(--color-border-divider)",background:"var(--color-bg-card)",fontSize:12,color:"var(--color-text-primary)",outline:"none"}}),e.jsx("div",{style:{flex:1,overflowY:"auto"},children:B.map(u=>{const E=u.id===a,w=ue[u.taskType]??ue.custom;return e.jsxs("button",{type:"button",onClick:()=>v(u.id),style:{display:"flex",alignItems:"center",gap:12,padding:"10px 16px",cursor:"pointer",border:"none",background:E?"var(--color-tint-exploring)":"none",borderLeft:`3px solid ${E?"var(--color-accent-blue)":"transparent"}`,width:"100%",textAlign:"left",transition:"all 120ms"},children:[e.jsx("div",{style:{width:32,height:32,borderRadius:8,display:"flex",alignItems:"center",justifyContent:"center",background:w.bg,color:w.fg,flexShrink:0},children:e.jsx("span",{style:{width:14,height:14,strokeWidth:1.8,display:"flex"},children:ve[u.taskType]??ve.custom})}),e.jsxs("div",{style:{flex:1,minWidth:0},children:[e.jsx("div",{style:{fontSize:12,fontWeight:600,color:"var(--color-text-primary)",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:u.name}),e.jsxs("div",{style:{fontSize:10,color:"var(--color-text-tertiary)",display:"flex",gap:8},children:[e.jsx("span",{style:{fontFamily:"'SF Mono', Consolas, monospace"},children:u.cronExpression}),u.lastRun&&e.jsx("span",{children:mr(u.lastRun)})]})]}),e.jsx("div",{style:{display:"flex",flexDirection:"column",alignItems:"flex-end",gap:2,flexShrink:0},children:e.jsx("span",{style:{fontSize:9,fontWeight:600,padding:"2px 8px",borderRadius:100,background:u.enabled?"rgba(90,158,120,0.12)":"rgba(160,157,151,0.12)",color:u.enabled?"var(--color-accent-green)":"var(--color-accent-gray)"},children:u.enabled?r("supervisor.schedule.active"):r("supervisor.schedule.paused")})})]},u.id)})})]}),e.jsx("div",{style:{flex:1,overflowY:"auto",display:"flex",flexDirection:"column"},children:C?e.jsx(fr,{task:C,onToggle:s,onRun:x,onDelete:n}):e.jsx("div",{style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",color:"var(--color-text-tertiary)",fontSize:13},children:r("supervisor.schedule.select_detail")})})]})}function fr({task:r,onToggle:o,onRun:t,onDelete:n}){const{t:s}=T(),x=ue[r.taskType]??ue.custom;return e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"16px 24px",borderBottom:"1px solid var(--color-border-divider)",flexShrink:0},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[e.jsx("div",{style:{width:40,height:40,borderRadius:10,display:"flex",alignItems:"center",justifyContent:"center",background:x.bg,color:x.fg},children:e.jsx("span",{style:{width:18,height:18,strokeWidth:1.8,display:"flex"},children:ve[r.taskType]??ve.custom})}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:16,fontWeight:700,color:"var(--color-text-primary)"},children:r.name}),e.jsx("div",{style:{fontSize:11,color:"var(--color-text-secondary)"},children:r.taskType})]})]}),e.jsxs("div",{style:{display:"flex",gap:8},children:[e.jsx("button",{type:"button",onClick:()=>t(r.id),style:{...Re},children:s("supervisor.schedule.run_now")}),e.jsx(jr,{on:r.enabled,onToggle:()=>o(r.id,!r.enabled)}),e.jsx("button",{type:"button",onClick:()=>n(r.id),style:{...Re,color:"var(--color-accent-red)"},children:s("supervisor.schedule.delete")})]})]}),e.jsxs("div",{style:{flex:1,overflowY:"auto",padding:"20px 24px",display:"flex",flexDirection:"column",gap:20},children:[e.jsxs("div",{style:{display:"flex",gap:16},children:[e.jsxs("div",{style:{flex:1,background:"var(--color-bg-primary)",borderRadius:10,padding:14,border:"1px solid var(--color-border-divider)"},children:[e.jsx("div",{style:{fontSize:10,fontWeight:600,textTransform:"uppercase",letterSpacing:".04em",color:"var(--color-text-tertiary)"},children:s("supervisor.schedule.total_runs")}),e.jsx("div",{style:{fontSize:22,fontWeight:700,color:"var(--color-text-primary)",marginTop:2},children:r.history.length})]}),e.jsxs("div",{style:{flex:1,background:"var(--color-bg-primary)",borderRadius:10,padding:14,border:"1px solid var(--color-border-divider)"},children:[e.jsx("div",{style:{fontSize:10,fontWeight:600,textTransform:"uppercase",letterSpacing:".04em",color:"var(--color-text-tertiary)"},children:s("supervisor.schedule.success_rate")}),e.jsx("div",{style:{fontSize:22,fontWeight:700,color:"var(--color-accent-green)",marginTop:2},children:r.history.length>0?`${Math.round(r.history.filter(a=>a.status==="success").length/r.history.length*100)}%`:"-"})]}),e.jsxs("div",{style:{flex:1,background:"var(--color-bg-primary)",borderRadius:10,padding:14,border:"1px solid var(--color-border-divider)"},children:[e.jsx("div",{style:{fontSize:10,fontWeight:600,textTransform:"uppercase",letterSpacing:".04em",color:"var(--color-text-tertiary)"},children:s("supervisor.schedule.next_run")}),e.jsx("div",{style:{fontSize:14,fontWeight:700,color:"var(--color-text-primary)",marginTop:6},children:r.nextRun?new Date(r.nextRun).toLocaleString():"-"})]})]}),e.jsxs(We,{title:s("supervisor.schedule.configuration"),children:[e.jsx(ce,{label:s("supervisor.schedule.schedule_label"),value:r.cronExpression,mono:!0}),e.jsx(ce,{label:s("supervisor.schedule.type"),value:r.taskType}),e.jsx(ce,{label:s("supervisor.schedule.last_run"),value:r.lastRun?new Date(r.lastRun).toLocaleString():s("supervisor.schedule.never")}),Object.entries(r.config).map(([a,v])=>e.jsx(ce,{label:a,value:String(v)},a))]}),e.jsx(We,{title:s("supervisor.schedule.run_history"),children:r.history.length===0?e.jsx("div",{style:{fontSize:11,color:"var(--color-text-tertiary)",textAlign:"center",padding:"8px 0"},children:s("supervisor.schedule.no_runs")}):e.jsx("div",{style:{display:"flex",flexDirection:"column"},children:r.history.slice(-10).reverse().map((a,v)=>{const p=a.status==="success"?"var(--color-accent-green)":a.status==="failed"?"var(--color-accent-red)":"var(--color-accent-gray)";return e.jsxs("div",{style:{display:"flex",gap:12,padding:"8px 0",position:"relative"},children:[v<Math.min(r.history.length,10)-1&&e.jsx("div",{style:{position:"absolute",left:11,top:24,bottom:-8,width:1,background:"var(--color-border-divider)"}}),e.jsx("div",{style:{width:22,height:22,borderRadius:"50%",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,border:"2px solid var(--color-bg-card)"},children:e.jsx("div",{style:{width:8,height:8,borderRadius:"50%",background:p}})}),e.jsxs("div",{style:{flex:1},children:[e.jsx("div",{style:{fontSize:10,color:"var(--color-text-placeholder)",fontFamily:"'SF Mono', Consolas, monospace"},children:new Date(a.timestamp).toLocaleString()}),e.jsx("div",{style:{fontSize:12,color:"var(--color-text-primary)"},children:a.status}),a.duration!=null&&e.jsxs("div",{style:{fontSize:10,color:"var(--color-text-tertiary)"},children:[Math.round(a.duration/1e3),"s"]})]})]},v)})})})]})]})}function We({title:r,children:o}){return e.jsxs("div",{style:{borderRadius:12,background:"var(--color-bg-card)",border:"1px solid var(--color-border-divider)",overflow:"hidden"},children:[e.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"12px 16px",borderBottom:"1px solid var(--color-border-divider)"},children:e.jsx("span",{style:{fontSize:12,fontWeight:600,color:"var(--color-text-primary)"},children:r})}),e.jsx("div",{style:{padding:"14px 16px"},children:o})]})}function ce({label:r,value:o,mono:t}){return e.jsxs("div",{style:{display:"flex",alignItems:"center",padding:"8px 0",borderBottom:"1px solid var(--color-border-divider)"},children:[e.jsx("span",{style:{fontSize:11,color:"var(--color-text-tertiary)",width:120,flexShrink:0},children:r}),e.jsx("span",{style:{fontSize:12,color:"var(--color-text-primary)",fontWeight:500,fontFamily:t?"'SF Mono', Consolas, monospace":void 0},children:o})]})}function jr({on:r,onToggle:o}){return e.jsx("button",{type:"button",onClick:o,style:{width:36,height:20,borderRadius:100,background:r?"var(--color-accent-green)":"var(--color-border)",border:"none",cursor:"pointer",position:"relative",transition:"background 200ms"},children:e.jsx("span",{style:{position:"absolute",top:2,left:r?18:2,width:16,height:16,borderRadius:"50%",background:"#fff",transition:"left 200ms",boxShadow:"0 1px 3px rgba(0,0,0,0.15)"}})})}function mr(r){const o=Date.now()-new Date(r).getTime(),t=Math.floor(o/6e4);if(t<1)return"just now";if(t<60)return`${t}m ago`;const n=Math.floor(t/60);return n<24?`${n}h ago`:new Date(r).toLocaleDateString()}const be={padding:"8px 12px",borderRadius:8,border:"1px solid var(--color-border-divider)",background:"var(--color-bg-card)",fontSize:12,color:"var(--color-text-primary)",outline:"none"},Re={fontSize:11,fontWeight:600,padding:"5px 12px",borderRadius:8,border:"1px solid var(--color-border)",background:"none",color:"var(--color-text-secondary)",cursor:"pointer"},Te=[{id:"commander",labelKey:"supervisor.tabs.commander",icon:e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M12 2L2 7l10 5 10-5-10-5z"}),e.jsx("path",{d:"M2 17l10 5 10-5"}),e.jsx("path",{d:"M2 12l10 5 10-5"})]})},{id:"executions",labelKey:"supervisor.tabs.executions",icon:e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{x:"3",y:"3",width:"7",height:"7",rx:"1"}),e.jsx("rect",{x:"14",y:"3",width:"7",height:"7",rx:"1"}),e.jsx("rect",{x:"3",y:"14",width:"7",height:"7",rx:"1"}),e.jsx("rect",{x:"14",y:"14",width:"7",height:"7",rx:"1"})]})},{id:"schedule",labelKey:"supervisor.tabs.schedules",icon:e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("circle",{cx:"12",cy:"12",r:"10"}),e.jsx("polyline",{points:"12 6 12 12 16 14"})]})},{id:"learning",labelKey:"supervisor.tabs.learning",icon:e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M2 3h6a4 4 0 0 1 4 4v14a3 3 0 0 0-3-3H2z"}),e.jsx("path",{d:"M22 3h-6a4 4 0 0 0-4 4v14a3 3 0 0 1 3-3h7z"})]})},{id:"extensions",labelKey:"supervisor.tabs.extensions",icon:e.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M14.7 6.3a1 1 0 000 1.4l1.6 1.6a1 1 0 001.4 0l3.77-3.77a6 6 0 01-7.94 7.94l-6.91 6.91a2.12 2.12 0 01-3-3l6.91-6.91a6 6 0 017.94-7.94l-3.76 3.76z"})})},{id:"prompts",labelKey:"supervisor.tabs.prompts",icon:e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("polyline",{points:"4 7 4 4 20 4 20 7"}),e.jsx("line",{x1:"9",y1:"20",x2:"15",y2:"20"}),e.jsx("line",{x1:"12",y1:"4",x2:"12",y2:"20"})]})},{id:"coordinator",labelKey:"supervisor.tabs.coordinator",icon:e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("circle",{cx:"12",cy:"12",r:"3"}),e.jsx("path",{d:"M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1-2.83 2.83l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-4 0v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83-2.83l.06-.06A1.65 1.65 0 0 0 4.68 15a1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1 0-4h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 2.83-2.83l.06.06A1.65 1.65 0 0 0 9 4.68a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 2.83l-.06.06A1.65 1.65 0 0 0 19.4 9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 0 4h-.09a1.65 1.65 0 0 0-1.51 1z"})]})}];function Sr(){const{t:r}=T(),o=m(c=>c.activeTab),t=m(c=>c.setActiveTab),n=m(c=>c.fetchLearningStats),s=m(c=>c.fetchSchedules),x=m(c=>c.fetchExtensions),a=m(c=>c.fetchPromptModes),v=m(c=>c.scheduledTasks),p=m(c=>c.extensions),y=R(c=>c.slots),i=R(c=>c.queue),d=R(c=>c.supervisorStatus),k=R(c=>c.toggleSupervisor),j=R(c=>c.commanderState),f=_(c=>c.session),I=_(c=>c.start),$=_(c=>c.stop),[L,B]=g.useState(!1);g.useEffect(()=>{n(),s(),x(),a()},[n,s,x,a]);const C=g.useMemo(()=>Object.values(y),[y]),b=(d==null?void 0:d.enabled)??!1,u=(d==null?void 0:d.stats.totalDispatched)??0,E=(d==null?void 0:d.stats.totalCompleted)??0,w=u>0?`${Math.round(E/u*100)}%`:"-",h=f!=null&&f.status!=="idle"&&f.status!=="completed"&&f.status!=="failed",z=(f==null?void 0:f.steps)??[],F=z.filter(c=>c.status==="completed"||c.status==="skipped").length,he=g.useCallback(async()=>{await k(!b)},[k,b]),O=g.useCallback(()=>{h?$():I("continue",void 0,!0)},[h,$,I]),H=g.useCallback(c=>{t(c),B(!1)},[t]),G={schedule:v.length,extensions:p.length};return e.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100%",overflow:"hidden",background:"var(--color-bg-primary)"},children:[e.jsx("nav",{style:{flexShrink:0,display:"flex",alignItems:"center",padding:"0 24px",background:"var(--color-bg-secondary)",borderBottom:"1px solid var(--color-border)"},children:Te.map(c=>{const Y=o===c.id,A=G[c.id]??0;return e.jsxs("button",{type:"button",onClick:()=>t(c.id),style:{display:"flex",alignItems:"center",gap:6,padding:"10px 16px",fontSize:12,fontWeight:Y?600:500,color:Y?"var(--color-text-primary)":"var(--color-text-tertiary)",background:"none",border:"none",borderBottom:`2px solid ${Y?"var(--color-text-primary)":"transparent"}`,cursor:"pointer",transition:"color 120ms, border-color 120ms"},children:[e.jsx("span",{style:{width:14,height:14,display:"flex"},children:c.icon}),r(c.labelKey),A>0&&e.jsx("span",{style:{fontSize:9,fontWeight:700,padding:"1px 6px",borderRadius:100,background:"var(--color-bg-card)",color:"var(--color-text-tertiary)"},children:A})]},c.id)})}),e.jsxs("main",{style:{flex:1,minHeight:0,overflow:"hidden"},children:[o==="commander"&&e.jsx(Ee,{}),o==="executions"&&e.jsx(Ae,{}),o==="coordinator"&&e.jsx(Ke,{}),o==="prompts"&&e.jsx(dr,{}),o==="extensions"&&e.jsx(cr,{}),o==="learning"&&e.jsx(ur,{}),o==="schedule"&&e.jsx(yr,{})]}),L&&e.jsx("div",{onClick:()=>B(!1),style:{position:"fixed",inset:0,background:"rgba(0,0,0,0.25)",zIndex:90,transition:"opacity 200ms"}}),e.jsxs("div",{style:{position:"fixed",left:0,right:0,bottom:36,maxHeight:L?"60vh":0,overflow:"hidden",background:"var(--color-bg-card)",borderTop:L?"1px solid var(--color-border)":"none",borderRadius:"12px 12px 0 0",zIndex:91,transition:"max-height 300ms cubic-bezier(0.4,0,0.2,1)",boxShadow:L?"0 -4px 24px rgba(0,0,0,0.08)":"none"},children:[e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"8px 0 4px",cursor:"pointer"},onClick:()=>B(!1),children:e.jsx("div",{style:{width:32,height:4,borderRadius:2,background:"var(--color-border)"}})}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"180px 1fr 1fr",gap:16,padding:"8px 24px 24px",overflowY:"auto",maxHeight:"calc(60vh - 40px)"},children:[e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:2},children:[e.jsx("div",{style:{fontSize:10,fontWeight:600,textTransform:"uppercase",letterSpacing:".04em",color:"var(--color-text-tertiary)",padding:"4px 8px",marginBottom:4},children:"Navigate"}),Te.map(c=>e.jsxs("button",{type:"button",onClick:()=>H(c.id),style:{display:"flex",alignItems:"center",gap:8,padding:"8px 10px",fontSize:12,fontWeight:o===c.id?600:400,color:o===c.id?"var(--color-text-primary)":"var(--color-text-secondary)",background:o===c.id?"var(--color-bg-active)":"none",border:"none",borderRadius:6,cursor:"pointer",textAlign:"left",transition:"background 120ms"},children:[e.jsx("span",{style:{width:14,height:14,display:"flex"},children:c.icon}),r(c.labelKey)]},c.id))]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:16},children:[e.jsxs("div",{style:{borderRadius:10,border:"1px solid var(--color-border-divider)",overflow:"hidden"},children:[e.jsxs("div",{style:{padding:"10px 14px",borderBottom:"1px solid var(--color-border-divider)",display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsx("span",{style:{fontSize:11,fontWeight:600,color:"var(--color-accent-blue)"},children:"Issue Executions"}),e.jsxs("span",{style:{fontSize:10,color:"var(--color-text-tertiary)"},children:[C.length," running"]})]}),e.jsx("div",{style:{padding:"8px 14px"},children:C.length===0?e.jsx("div",{style:{fontSize:11,color:"var(--color-text-tertiary)",padding:"4px 0"},children:"No active slots"}):C.slice(0,5).map(c=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"5px 0",fontSize:11},children:[e.jsx("span",{style:{width:6,height:6,borderRadius:"50%",background:"var(--color-accent-blue)",flexShrink:0}}),e.jsx("span",{style:{fontWeight:500,color:"var(--color-text-primary)"},children:c.issueId}),e.jsx("span",{style:{color:"var(--color-text-tertiary)",marginLeft:"auto"},children:c.executor})]},c.processId))})]}),e.jsxs("div",{style:{borderRadius:10,border:"1px solid var(--color-border-divider)",overflow:"hidden"},children:[e.jsxs("div",{style:{padding:"10px 14px",borderBottom:"1px solid var(--color-border-divider)",display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsx("span",{style:{fontSize:11,fontWeight:600,color:"var(--color-accent-purple)"},children:"Workflow Sessions"}),e.jsx("span",{style:{fontSize:10,color:"var(--color-text-tertiary)"},children:f?f.status:"idle"})]}),e.jsx("div",{style:{padding:"8px 14px"},children:f?e.jsxs("div",{style:{fontSize:11},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,padding:"4px 0"},children:[e.jsx("span",{style:{fontWeight:500,color:"var(--color-text-primary)"},children:f.chainName??"Session"}),e.jsxs("span",{style:{color:"var(--color-text-tertiary)"},children:["Step ",f.currentStep+1,"/",z.length]})]}),f.intent&&e.jsx("div",{style:{color:"var(--color-text-secondary)",padding:"2px 0",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:f.intent})]}):e.jsx("div",{style:{fontSize:11,color:"var(--color-text-tertiary)",padding:"4px 0"},children:"No active session"})})]})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:16},children:[e.jsxs("div",{style:{borderRadius:10,border:"1px solid var(--color-border-divider)",overflow:"hidden"},children:[e.jsx("div",{style:{padding:"10px 14px",borderBottom:"1px solid var(--color-border-divider)"},children:e.jsx("span",{style:{fontSize:11,fontWeight:600,color:"var(--color-text-primary)"},children:"Commander"})}),e.jsxs("div",{style:{padding:"8px 14px",fontSize:11},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,padding:"4px 0"},children:[e.jsx("span",{style:{fontWeight:500,color:"var(--color-text-secondary)"},children:"Status:"}),e.jsx("span",{style:{fontWeight:600,color:(j==null?void 0:j.status)==="dispatching"?"var(--color-accent-green)":(j==null?void 0:j.status)==="thinking"?"var(--color-accent-blue)":"var(--color-text-tertiary)"},children:(j==null?void 0:j.status)??"idle"})]}),(d==null?void 0:d.isCommanderActive)!==void 0&&e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,padding:"4px 0"},children:[e.jsx("span",{style:{fontWeight:500,color:"var(--color-text-secondary)"},children:"Active:"}),e.jsx("span",{style:{color:d.isCommanderActive?"var(--color-accent-green)":"var(--color-text-tertiary)"},children:d.isCommanderActive?"Yes":"No"})]})]})]}),e.jsxs("div",{style:{borderRadius:10,border:"1px solid var(--color-border-divider)",overflow:"hidden"},children:[e.jsx("div",{style:{padding:"10px 14px",borderBottom:"1px solid var(--color-border-divider)"},children:e.jsx("span",{style:{fontSize:11,fontWeight:600,color:"var(--color-text-primary)"},children:"Suggestions"})}),e.jsx("div",{style:{padding:"8px 14px",fontSize:11,color:"var(--color-text-tertiary)"},children:"No suggestions"})]})]})]})]}),e.jsxs("footer",{style:{flexShrink:0,display:"flex",alignItems:"center",height:36,padding:"0 16px",background:"var(--color-bg-secondary)",borderTop:"1px solid var(--color-border)",gap:12,fontSize:11,zIndex:92},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[e.jsx("span",{style:{fontWeight:600,color:"var(--color-text-primary)"},children:"Supervisor"}),e.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:5,fontSize:10,fontWeight:600,padding:"2px 8px",borderRadius:100,background:b?"rgba(90,158,120,0.12)":"rgba(160,157,151,0.12)",color:b?"var(--color-accent-green)":"var(--color-accent-gray)"},children:[b&&e.jsx("span",{style:{width:6,height:6,borderRadius:"50%",background:"var(--color-accent-green)",animation:"pulse 2s ease-in-out infinite"}}),b?"Active":"Inactive"]})]}),e.jsx("div",{style:{width:1,height:16,background:"var(--color-border-divider)"}}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[e.jsx("span",{style:{fontSize:10,fontWeight:600,color:"var(--color-accent-blue)"},children:"Issues"}),e.jsxs("span",{style:{color:"var(--color-text-secondary)"},children:[C.length," running"]}),e.jsxs("span",{style:{color:"var(--color-text-tertiary)"},children:[i.length," queued"]}),e.jsxs("span",{style:{color:"var(--color-text-secondary)"},children:[w," success"]})]}),e.jsx("div",{style:{width:1,height:16,background:"var(--color-border-divider)"}}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[e.jsx("span",{style:{fontSize:10,fontWeight:600,color:"var(--color-accent-purple)"},children:"Workflow"}),e.jsx("span",{style:{color:"var(--color-text-secondary)"},children:h?"1 running":"0 running"}),e.jsx("span",{style:{color:"var(--color-text-tertiary)"},children:z.length>0?`${F}/${z.length} steps`:"-"})]}),e.jsxs("div",{style:{marginLeft:"auto",display:"flex",alignItems:"center",gap:8},children:[e.jsxs("button",{type:"button",onClick:()=>B(c=>!c),style:{display:"flex",alignItems:"center",gap:4,padding:"3px 10px",fontSize:10,fontWeight:600,borderRadius:6,border:"1px solid var(--color-border)",background:L?"var(--color-bg-active)":"none",color:"var(--color-text-secondary)",cursor:"pointer",transition:"background 120ms"},children:[e.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{width:12,height:12},children:e.jsx("polyline",{points:L?"6 15 12 9 18 15":"6 9 12 15 18 9"})}),"Overview"]}),e.jsx("button",{type:"button",onClick:he,style:{padding:"3px 10px",fontSize:10,fontWeight:600,borderRadius:6,border:"1px solid",borderColor:b?"var(--color-accent-blue)":"var(--color-border)",background:b?"rgba(91,141,184,0.12)":"none",color:b?"var(--color-accent-blue)":"var(--color-text-tertiary)",cursor:"pointer",transition:"all 120ms"},children:"Issues"}),e.jsx("button",{type:"button",onClick:O,style:{padding:"3px 10px",fontSize:10,fontWeight:600,borderRadius:6,border:"1px solid",borderColor:h?"var(--color-accent-purple)":"var(--color-border)",background:h?"rgba(145,120,181,0.12)":"none",color:h?"var(--color-accent-purple)":"var(--color-text-tertiary)",cursor:"pointer",transition:"all 120ms"},children:"Workflow"})]})]}),e.jsx("style",{children:`
2
+ @keyframes pulse {
3
+ 0%, 100% { opacity: 1; }
4
+ 50% { opacity: 0.4; }
5
+ }
6
+ `})]})}export{Sr as SupervisorPage};