@smartmemory/compose 0.1.36-beta → 0.1.38-beta
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{App-DO9nGI18.js → App-BOmZUQK9.js} +5 -5
- package/dist/assets/{arc-DrI_lR89.js → arc-BFMYxU8d.js} +1 -1
- package/dist/assets/{architectureDiagram-3BPJPVTR-DyS14rP-.js → architectureDiagram-3BPJPVTR-Dr1TLm4n.js} +1 -1
- package/dist/assets/{blockDiagram-GPEHLZMM-elTUtlnM.js → blockDiagram-GPEHLZMM-DfiOIWI5.js} +1 -1
- package/dist/assets/{c4Diagram-AAUBKEIU-CJ_8nsiM.js → c4Diagram-AAUBKEIU-CWZPV6Gi.js} +1 -1
- package/dist/assets/channel-GvJclmQg.js +1 -0
- package/dist/assets/{chunk-2J33WTMH-BllJC9rQ.js → chunk-2J33WTMH-DsfEX96t.js} +1 -1
- package/dist/assets/{chunk-4BX2VUAB-f3EEUpDr.js → chunk-4BX2VUAB-BYmdEdqH.js} +1 -1
- package/dist/assets/{chunk-55IACEB6-CgbUlP7I.js → chunk-55IACEB6-C074eKNZ.js} +1 -1
- package/dist/assets/{chunk-727SXJPM-D9zRfRSY.js → chunk-727SXJPM-rxaajQx0.js} +1 -1
- package/dist/assets/{chunk-AQP2D5EJ-Bjp1xaJ8.js → chunk-AQP2D5EJ-Cg6-5M28.js} +1 -1
- package/dist/assets/{chunk-FMBD7UC4-Dyvhvbkr.js → chunk-FMBD7UC4-FSbyjfSh.js} +1 -1
- package/dist/assets/{chunk-ND2GUHAM-D4dMBzz5.js → chunk-ND2GUHAM-DhD_mt3D.js} +1 -1
- package/dist/assets/{chunk-QZHKN3VN-CVhvkQt1.js → chunk-QZHKN3VN-LMU-D6pF.js} +1 -1
- package/dist/assets/classDiagram-4FO5ZUOK-DV6SPGMl.js +1 -0
- package/dist/assets/classDiagram-v2-Q7XG4LA2-DV6SPGMl.js +1 -0
- package/dist/assets/{cose-bilkent-S5V4N54A-CylcCFl3.js → cose-bilkent-S5V4N54A-CknvjYWn.js} +1 -1
- package/dist/assets/{dagre-BM42HDAG-Dd1Ny0g8.js → dagre-BM42HDAG-BWNVctIO.js} +1 -1
- package/dist/assets/{diagram-2AECGRRQ-tVs4SxwR.js → diagram-2AECGRRQ-DhPeu8mD.js} +1 -1
- package/dist/assets/{diagram-5GNKFQAL-UC1fUNjx.js → diagram-5GNKFQAL-B8e2ppCQ.js} +1 -1
- package/dist/assets/{diagram-KO2AKTUF-Cxhb85Xt.js → diagram-KO2AKTUF-CJ2bkC5P.js} +1 -1
- package/dist/assets/{diagram-LMA3HP47-DJMx1YAp.js → diagram-LMA3HP47-CCyEuSkM.js} +1 -1
- package/dist/assets/{diagram-OG6HWLK6-k_cRur_6.js → diagram-OG6HWLK6-CDe7c8Ym.js} +1 -1
- package/dist/assets/{erDiagram-TEJ5UH35-ClfbMYdQ.js → erDiagram-TEJ5UH35-BDTpNyUZ.js} +1 -1
- package/dist/assets/{flowDiagram-I6XJVG4X-B9KvjWpm.js → flowDiagram-I6XJVG4X-CSEQ9sFL.js} +1 -1
- package/dist/assets/{ganttDiagram-6RSMTGT7-CCqvcQcy.js → ganttDiagram-6RSMTGT7-CJI3ZQCl.js} +1 -1
- package/dist/assets/{gitGraphDiagram-PVQCEYII-DN9gJgDY.js → gitGraphDiagram-PVQCEYII-BmIOl3oN.js} +1 -1
- package/dist/assets/{index-CtjbBZuo.js → index-DHyg44Px.js} +2 -2
- package/dist/assets/{infoDiagram-5YYISTIA-BZjN-ULc.js → infoDiagram-5YYISTIA-BiJXa7xo.js} +1 -1
- package/dist/assets/{ishikawaDiagram-YF4QCWOH-Ck1kwRqz.js → ishikawaDiagram-YF4QCWOH-D2S-R9bH.js} +1 -1
- package/dist/assets/{journeyDiagram-JHISSGLW-CHKyH4p5.js → journeyDiagram-JHISSGLW-Dk6NJYdI.js} +1 -1
- package/dist/assets/{kanban-definition-UN3LZRKU-Bq4CuVJj.js → kanban-definition-UN3LZRKU-DrTme_f5.js} +1 -1
- package/dist/assets/{linear-h6UanLnU.js → linear-DAL46yON.js} +1 -1
- package/dist/assets/{mindmap-definition-RKZ34NQL-IQcATrSw.js → mindmap-definition-RKZ34NQL-lzCtbkrz.js} +1 -1
- package/dist/assets/{pieDiagram-4H26LBE5-B7cw_oKH.js → pieDiagram-4H26LBE5-BGGc2f7U.js} +1 -1
- package/dist/assets/{quadrantDiagram-W4KKPZXB-CqiNInwZ.js → quadrantDiagram-W4KKPZXB-DN8kBgF9.js} +1 -1
- package/dist/assets/{requirementDiagram-4Y6WPE33-CynhQVI1.js → requirementDiagram-4Y6WPE33-CqTXzyF-.js} +1 -1
- package/dist/assets/{sankeyDiagram-5OEKKPKP-aFS3y10_.js → sankeyDiagram-5OEKKPKP-l5oIrkxp.js} +1 -1
- package/dist/assets/{sequenceDiagram-3UESZ5HK-CTvZcil0.js → sequenceDiagram-3UESZ5HK-B5mMGwpr.js} +1 -1
- package/dist/assets/{stateDiagram-AJRCARHV-DYXgroJe.js → stateDiagram-AJRCARHV-B8yZRkdR.js} +1 -1
- package/dist/assets/stateDiagram-v2-BHNVJYJU-BK-1uf4O.js +1 -0
- package/dist/assets/{timeline-definition-PNZ67QCA-BtN3u7JC.js → timeline-definition-PNZ67QCA-uc4a9RNG.js} +1 -1
- package/dist/assets/{vennDiagram-CIIHVFJN-DsssmbTq.js → vennDiagram-CIIHVFJN-Dxp9IL4U.js} +1 -1
- package/dist/assets/{wardley-L42UT6IY-BXD_QFvV.js → wardley-L42UT6IY-1u4vjxUt.js} +1 -1
- package/dist/assets/{wardleyDiagram-YWT4CUSO-CgZmwLSB.js → wardleyDiagram-YWT4CUSO-DWpWWd1b.js} +1 -1
- package/dist/assets/{xychartDiagram-2RQKCTM6-BmiRpk6f.js → xychartDiagram-2RQKCTM6-Cpcj31O3.js} +1 -1
- package/dist/index.html +1 -1
- package/package.json +1 -1
- package/dist/assets/channel-Cda02Ntm.js +0 -1
- package/dist/assets/classDiagram-4FO5ZUOK-BykFns4A.js +0 -1
- package/dist/assets/classDiagram-v2-Q7XG4LA2-BykFns4A.js +0 -1
- package/dist/assets/stateDiagram-v2-BHNVJYJU-BVQEXVG-.js +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/dagre-BM42HDAG-
|
|
2
|
-
var h_=Object.defineProperty;var u_=(t,e,r)=>e in t?h_(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var ie=(t,e,r)=>u_(t,typeof e!="symbol"?e+"":e,r);import{r as C,j as h,R as Yt,b as d_,g as Tc,f as Rt,d as f_,a as tf,w as Mo}from"./mobile-BwduHUEq.js";import{r as p_,_ as Qt,u as m_}from"./index-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/dagre-BM42HDAG-BWNVctIO.js","assets/graph-BEmEBUp_.js","assets/layout-Bw0msyOw.js","assets/mobile-BwduHUEq.js","assets/mobile-5PV1E6OC.css","assets/index-DHyg44Px.js","assets/index-Dh2rRpBR.css","assets/graph-uO5hwVZK.js","assets/cose-bilkent-S5V4N54A-CknvjYWn.js","assets/c4Diagram-AAUBKEIU-CWZPV6Gi.js","assets/chunk-ND2GUHAM-DhD_mt3D.js","assets/flowDiagram-I6XJVG4X-CSEQ9sFL.js","assets/chunk-FMBD7UC4-FSbyjfSh.js","assets/chunk-55IACEB6-C074eKNZ.js","assets/chunk-2J33WTMH-DsfEX96t.js","assets/channel-GvJclmQg.js","assets/erDiagram-TEJ5UH35-BDTpNyUZ.js","assets/gitGraphDiagram-PVQCEYII-BmIOl3oN.js","assets/chunk-4BX2VUAB-BYmdEdqH.js","assets/chunk-QZHKN3VN-LMU-D6pF.js","assets/wardley-L42UT6IY-1u4vjxUt.js","assets/ganttDiagram-6RSMTGT7-CJI3ZQCl.js","assets/linear-DAL46yON.js","assets/init-Gi6I4Gst.js","assets/defaultLocale-CrowFXzY.js","assets/infoDiagram-5YYISTIA-BiJXa7xo.js","assets/pieDiagram-4H26LBE5-BGGc2f7U.js","assets/arc-BFMYxU8d.js","assets/ordinal-Cboi1Yqb.js","assets/quadrantDiagram-W4KKPZXB-DN8kBgF9.js","assets/xychartDiagram-2RQKCTM6-Cpcj31O3.js","assets/requirementDiagram-4Y6WPE33-CqTXzyF-.js","assets/sequenceDiagram-3UESZ5HK-B5mMGwpr.js","assets/classDiagram-4FO5ZUOK-DV6SPGMl.js","assets/chunk-727SXJPM-rxaajQx0.js","assets/classDiagram-v2-Q7XG4LA2-DV6SPGMl.js","assets/stateDiagram-AJRCARHV-B8yZRkdR.js","assets/chunk-AQP2D5EJ-Cg6-5M28.js","assets/stateDiagram-v2-BHNVJYJU-BK-1uf4O.js","assets/journeyDiagram-JHISSGLW-Dk6NJYdI.js","assets/timeline-definition-PNZ67QCA-uc4a9RNG.js","assets/mindmap-definition-RKZ34NQL-lzCtbkrz.js","assets/kanban-definition-UN3LZRKU-DrTme_f5.js","assets/sankeyDiagram-5OEKKPKP-l5oIrkxp.js","assets/diagram-LMA3HP47-CCyEuSkM.js","assets/diagram-2AECGRRQ-DhPeu8mD.js","assets/blockDiagram-GPEHLZMM-DfiOIWI5.js","assets/diagram-5GNKFQAL-B8e2ppCQ.js","assets/architectureDiagram-3BPJPVTR-Dr1TLm4n.js","assets/diagram-KO2AKTUF-CJ2bkC5P.js","assets/ishikawaDiagram-YF4QCWOH-D2S-R9bH.js","assets/vennDiagram-CIIHVFJN-Dxp9IL4U.js","assets/diagram-OG6HWLK6-CDe7c8Ym.js","assets/wardleyDiagram-YWT4CUSO-DWpWWd1b.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
var h_=Object.defineProperty;var u_=(t,e,r)=>e in t?h_(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var ie=(t,e,r)=>u_(t,typeof e!="symbol"?e+"":e,r);import{r as C,j as h,R as Yt,b as d_,g as Tc,f as Rt,d as f_,a as tf,w as Mo}from"./mobile-BwduHUEq.js";import{r as p_,_ as Qt,u as m_}from"./index-DHyg44Px.js";import{a as la,b as ry,f as g_}from"./graph-uO5hwVZK.js";const xr={feature:"#3b82f6",track:"#06b6d4",decision:"#22c55e",task:"#94a3b8",spec:"#8b5cf6",idea:"#f59e0b",question:"#ec4899",evaluation:"#f97316",thread:"#64748b",artifact:"#a855f7"},qn={planned:"#64748b",ready:"#0ea5e9",in_progress:"#3b82f6",review:"#f59e0b",complete:"#22c55e",blocked:"#ef4444",parked:"#475569",killed:"#1e293b"},x_=["planned","ready","in_progress","review","complete","blocked","parked","killed"],ny=["vision","specification","planning","implementation","verification","release"],jl={vision:"Vision",specification:"Specification",planning:"Planning",implementation:"Implementation",verification:"Verification",release:"Release"},ef=["Untested","Low","Moderate","High","Crystallized"],ve={explore_design:"Design",prd:"PRD",architecture:"Architecture",blueprint:"Blueprint",verification:"Verification",plan:"Plan",execute:"Execute",report:"Report",docs:"Docs",ship:"Ship",complete:"Complete",killed:"Killed"},iy={explore_design:"design.md",prd:"prd.md",architecture:"architecture.md",blueprint:"blueprint.md",plan:"plan.md",report:"report.md"},sy=["claude","codex","gemini","human","unassigned"],Gp={building:"bg-blue-500/10 text-blue-400",debugging:"bg-rose-500/10 text-rose-400",testing:"bg-amber-500/10 text-amber-400",exploring:"bg-purple-500/10 text-purple-400",thinking:"bg-cyan-500/10 text-cyan-400",reviewing:"bg-emerald-500/10 text-emerald-400"},ph=[{id:"explore_design",name:"Explore Design",agent:"claude",phase:"design",hasGate:!1},{id:"design_review",name:"Design Review",agent:"codex",phase:"design",hasGate:!1},{id:"design_gate",name:"Design Gate",agent:"human",phase:"design",hasGate:!0},{id:"prd",name:"PRD",agent:"claude",phase:"design",hasGate:!1},{id:"prd_review",name:"PRD Review",agent:"codex",phase:"design",hasGate:!1},{id:"prd_gate",name:"PRD Gate",agent:"human",phase:"design",hasGate:!0},{id:"architecture",name:"Architecture",agent:"claude",phase:"design",hasGate:!1},{id:"architecture_review",name:"Arch Review",agent:"codex",phase:"design",hasGate:!1},{id:"architecture_gate",name:"Arch Gate",agent:"human",phase:"design",hasGate:!0},{id:"blueprint",name:"Blueprint",agent:"claude",phase:"blueprint",hasGate:!1},{id:"verification",name:"Verification",agent:"claude",phase:"blueprint",hasGate:!1},{id:"blueprint_review",name:"BP Review",agent:"codex",phase:"blueprint",hasGate:!1},{id:"plan",name:"Plan",agent:"claude",phase:"implementation",hasGate:!1},{id:"plan_review",name:"Plan Review",agent:"codex",phase:"implementation",hasGate:!1},{id:"plan_gate",name:"Plan Gate",agent:"human",phase:"implementation",hasGate:!0},{id:"execute",name:"Execute",agent:"claude",phase:"implementation",hasGate:!1},{id:"review",name:"Review Loop",agent:"codex",phase:"implementation",hasGate:!1},{id:"coverage",name:"Coverage Sweep",agent:"claude",phase:"implementation",hasGate:!1},{id:"report",name:"Report",agent:"claude",phase:"ship",hasGate:!1},{id:"report_review",name:"Report Review",agent:"codex",phase:"ship",hasGate:!1},{id:"report_gate",name:"Report Gate",agent:"human",phase:"ship",hasGate:!0},{id:"docs",name:"Docs",agent:"claude",phase:"ship",hasGate:!1},{id:"ship",name:"Ship",agent:"claude",phase:"ship",hasGate:!1},{id:"ship_gate",name:"Ship Gate",agent:"human",phase:"ship",hasGate:!0}],vn={design_gate:"Review Design",prd_gate:"Review PRD",architecture_gate:"Review Architecture",plan_gate:"Review Plan",report_gate:"Review Report",ship_gate:"Approve for Ship"};function Go(t,e){const r=vn[t.stepId]??(t.fromPhase&&t.toPhase?`${ve[t.fromPhase]??t.fromPhase} → ${ve[t.toPhase]??t.toPhase}`:"Gate"),n=(e==null?void 0:e.title)||t.featureCode||null;return n?`${r} — ${n}`:r}const Vp={design:{label:"Phase 1: Design",color:"border-blue-500/30 bg-blue-500/5"},blueprint:{label:"Phase 2: Blueprint",color:"border-violet-500/30 bg-violet-500/5"},implementation:{label:"Phase 3: Implement",color:"border-amber-500/30 bg-amber-500/5"},ship:{label:"Phase 4: Ship",color:"border-emerald-500/30 bg-emerald-500/5"}},y_={reading:"hsl(210 70% 60%)",writing:"hsl(142 60% 50%)",executing:"hsl(38 90% 60%)",searching:"hsl(270 60% 65%)",fetching:"hsl(190 70% 55%)",delegating:"hsl(330 60% 65%)",thinking:"hsl(240 30% 70%)"},Yp={complete:"hsl(var(--success, 160 60% 45%))",active:"hsl(var(--accent))",failed:"hsl(var(--destructive))",pending:"hsl(var(--muted-foreground) / 0.3)"},b_={development:"border-blue-500/30 bg-blue-500/5 text-blue-400",quality:"border-emerald-500/30 bg-emerald-500/5 text-emerald-400",maintenance:"border-amber-500/30 bg-amber-500/5 text-amber-400",documentation:"border-violet-500/30 bg-violet-500/5 text-violet-400",exploration:"border-cyan-500/30 bg-cyan-500/5 text-cyan-400"},C_={explore_design:{bg:"bg-blue-500/5",border:"border-blue-500/40",text:"text-blue-300"},prd:{bg:"bg-purple-500/5",border:"border-purple-500/40",text:"text-purple-300"},architecture:{bg:"bg-cyan-500/5",border:"border-cyan-500/40",text:"text-cyan-300"},blueprint:{bg:"bg-violet-500/5",border:"border-violet-500/40",text:"text-violet-300"},plan:{bg:"bg-amber-500/5",border:"border-amber-500/40",text:"text-amber-300"},report:{bg:"bg-emerald-500/5",border:"border-emerald-500/40",text:"text-emerald-300"},ship:{bg:"bg-green-500/5",border:"border-green-500/40",text:"text-green-300"}},k_={bg:"bg-muted/30",border:"border-border",text:"text-muted-foreground"},Xp=["bg-slate-600","bg-rose-500","bg-amber-500","bg-emerald-500","bg-emerald-500"],v_={info:"text-zinc-400",success:"text-emerald-400",warning:"text-amber-400",error:"text-red-400"},w_={phase:"text-blue-400",gate:"text-purple-400",session:"text-zinc-400",iteration:"text-blue-300",error:"text-red-400"},S_={"compose-explorer":"#06b6d4","compose-architect":"#a855f7",codex:"#10b981",claude:"#3b82f6"},Kp={reading:"var(--color-category-reading)",writing:"var(--color-category-writing)",executing:"var(--color-category-executing)",searching:"var(--color-category-searching)",fetching:"var(--color-category-fetching)",delegating:"var(--color-category-delegating)",thinking:"hsl(var(--muted-foreground))"},oy={branch:{label:"Branch",icon:"⑂",color:"text-purple-400"},phase_transition:{label:"Phase",icon:"→",color:"text-blue-400"},iteration:{label:"Iteration",icon:"↻",color:"text-cyan-400"},gate:{label:"Gate",icon:"◈",color:"text-amber-400"},drift_threshold:{label:"Drift",icon:"⚠",color:"text-rose-400"}};function T_(t,e){return!Array.isArray(t)||t.length===0?"hidden":e?"expanded":"collapsed"}function __(t){return`violations (${Array.isArray(t)?t.length:0})`}function E_(t){return t?"▾":"▸"}function N_({violations:t=[],expanded:e,onToggle:r}){const[n,i]=C.useState(!1),s=e!==void 0,o=s?e:n,a=T_(t,o);if(a==="hidden")return null;function l(){s?r==null||r():i(d=>!d)}const c=E_(o),u=__(t);return h.jsxs("div",{style:{background:"hsl(38 90% 50% / 0.06)",borderLeft:"2px solid hsl(38 90% 50% / 0.3)",borderRadius:"3px",marginTop:"4px"},children:[h.jsxs("div",{onClick:l,style:{display:"flex",alignItems:"center",gap:"4px",padding:"3px 8px",cursor:"pointer",color:"hsl(38 90% 70%)",fontSize:"10px",fontFamily:"monospace",userSelect:"none"},children:[h.jsx("span",{style:{opacity:.7},children:c}),h.jsx("span",{children:u})]}),a==="expanded"&&h.jsx("ul",{style:{listStyle:"none",margin:0,padding:"0 8px 6px 16px"},children:t.map((d,p)=>h.jsx("li",{style:{color:"hsl(38 50% 60%)",fontSize:"10px",fontFamily:"monospace",lineHeight:"1.5"},children:d},p))})]})}function j_({msg:t,mode:e="stream"}){const[r,n]=C.useState(!1),i=t.retries??0,s=t.violations??[],o=s.length>0;return e==="strip"?i===0?null:h.jsx("span",{style:{background:"hsl(38 90% 50% / 0.2)",color:"hsl(38 90% 60%)",padding:"0 5px",borderRadius:"9999px",fontSize:"9px"},children:i}):h.jsxs("div",{className:"text-[10px] py-0.5",children:[h.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[h.jsxs("span",{style:{color:"hsl(var(--success, 142 60% 50%))",opacity:.7},children:["step complete -- ",t.stepId]}),i>0&&h.jsxs("span",{onClick:()=>n(a=>!a),style:{background:"hsl(38 90% 50% / 0.15)",color:"hsl(38 90% 60%)",padding:"1px 6px",borderRadius:"9999px",fontSize:"10px",cursor:"pointer"},children:[i," ",i===1?"retry":"retries"]}),o?h.jsxs("span",{onClick:()=>n(a=>!a),style:{color:"hsl(38 90% 60%)",fontSize:"10px",cursor:"pointer"},children:[s.length," ",s.length===1?"violation":"violations"]}):h.jsx("span",{style:{color:"hsl(var(--success, 142 60% 50%))",opacity:.4,fontSize:"10px"},children:"✓ checks passed"})]}),r&&o&&h.jsx(N_,{violations:s,expanded:!0,onToggle:()=>n(!1)})]})}const L_=/\b(Error|error:|Traceback|FAILED|ENOENT|Cannot find)\b/,Zp=20;function B_({summary:t,output:e}){const[r,n]=C.useState(!1),[i,s]=C.useState(!1),o=e?L_.test(e):!1,a=e!=null&&e.length>0,l=a?e.split(`
|
|
3
3
|
`):[],c=l.length>Zp,u=r&&!i&&c?l.slice(0,Zp):l,d=o?"hsl(var(--destructive, 0 84% 60%))":"hsl(215 20% 20%)";return a?h.jsxs("div",{style:{marginLeft:8,borderLeft:`1px solid ${d}`,paddingLeft:8,marginTop:2},children:[h.jsxs("div",{onClick:()=>n(p=>!p),style:{opacity:.6,fontSize:"10px",cursor:"pointer",color:"hsl(var(--muted-foreground))",fontFamily:"ui-monospace, monospace",userSelect:"none",display:"flex",alignItems:"center",gap:4},children:[h.jsx("span",{style:{fontSize:9},children:r?"▾":"▸"}),t]}),r&&h.jsxs("pre",{style:{margin:"4px 0 0 0",padding:0,fontSize:"10px",fontFamily:"ui-monospace, monospace",color:o?"hsl(var(--destructive, 0 84% 60%))":"hsl(var(--muted-foreground))",opacity:o?.9:.7,whiteSpace:"pre-wrap",wordBreak:"break-word",lineHeight:1.5},children:[u.join(`
|
|
4
4
|
`),!i&&c&&h.jsxs(h.Fragment,{children:[`
|
|
5
5
|
`,h.jsxs("span",{onClick:p=>{p.stopPropagation(),s(!0)},style:{color:"hsl(var(--accent))",cursor:"pointer",textDecoration:"underline",fontSize:"10px"},children:["Show all (",l.length," lines)"]})]})]})]}):h.jsx("div",{style:{marginLeft:8,opacity:.6,fontSize:"10px",padding:"2px 0",color:"hsl(var(--muted-foreground))",fontFamily:"ui-monospace, monospace"},children:t})}const A_={Read:"reading",Glob:"searching",Grep:"searching",Write:"writing",Edit:"writing",NotebookEdit:"writing",Bash:"executing",Task:"delegating",Skill:"delegating",WebFetch:"fetching",WebSearch:"searching",TodoRead:"reading",TodoWrite:"writing"};function M_(t){return y_[A_[t]||"thinking"]}function I_(t){return t?t<1e3?`${t}ms`:`${(t/1e3).toFixed(1)}s`:""}function F_(t){return t==null?"":t<.001?"<$0.001":`$${t.toFixed(3)}`}function P_({input:t}){const[e,r]=C.useState(!1);if(!t||Object.keys(t).length===0)return null;const n=Object.keys(t)[0],i=String(t[n]??""),s=i.length>60?i.slice(0,57)+"…":i;return h.jsxs("div",{className:"mt-1",children:[h.jsxs("button",{onClick:()=>r(o=>!o),className:"text-[10px] font-mono flex items-center gap-1",style:{color:"hsl(var(--muted-foreground))",background:"none",border:"none",cursor:"pointer",padding:0},children:[h.jsx("span",{style:{opacity:.6},children:e?"▾":"▸"}),!e&&h.jsxs("span",{style:{opacity:.6},children:[n,": ",s]}),e&&h.jsx("span",{style:{opacity:.6},children:"collapse"})]}),e&&h.jsx("pre",{className:"mt-1 text-[10px] font-mono rounded p-2 overflow-x-auto",style:{background:"hsl(var(--muted) / 0.4)",color:"hsl(var(--muted-foreground))",maxHeight:"200px",overflowY:"auto"},children:JSON.stringify(t,null,2)})]})}function D_({block:t}){const e=M_(t.name);return h.jsxs("div",{className:"rounded px-2 py-1.5 my-1",style:{background:"hsl(var(--muted) / 0.3)",borderLeft:`2px solid ${e}`},children:[h.jsx("div",{className:"flex items-center gap-1.5",children:h.jsx("span",{className:"text-[11px] font-semibold font-mono",style:{color:e},children:t.name})}),h.jsx(P_,{input:t.input})]})}function O_({msg:t}){var r;const e=((r=t.message)==null?void 0:r.content)??[];return h.jsx("div",{className:"flex flex-col gap-1 py-1",children:e.map((n,i)=>{if(n.type==="text")return h.jsx("p",{className:"text-sm leading-relaxed whitespace-pre-wrap",style:{color:"hsl(var(--foreground))"},children:n.text},i);if(n.type==="tool_use"){const s=!e.slice(i+1).some(o=>o.type==="tool_use");return h.jsxs(Yt.Fragment,{children:[h.jsx(D_,{block:n}),s&&t._toolResult&&h.jsx(B_,{summary:t._toolResult.summary,output:t._toolResult.output})]},i)}return null})})}function R_({msg:t}){const e=t.subtype!=="success",r=e?"hsl(var(--destructive))":"hsl(var(--success, 142 60% 50%))";return h.jsxs("div",{className:"rounded px-3 py-2 text-xs font-mono flex items-center gap-3 flex-wrap",style:{background:"hsl(var(--muted) / 0.4)",borderLeft:`2px solid ${r}`,color:r},children:[h.jsx("span",{children:e?"✗ error":"✓ done"}),!e&&t.num_turns!=null&&h.jsxs("span",{style:{color:"hsl(var(--muted-foreground))"},children:[t.num_turns," turn",t.num_turns!==1?"s":""]}),t.duration_ms!=null&&h.jsx("span",{style:{color:"hsl(var(--muted-foreground))"},children:I_(t.duration_ms)}),t.total_cost_usd!=null&&h.jsx("span",{style:{color:"hsl(var(--muted-foreground))"},children:F_(t.total_cost_usd)}),e&&t.errors&&h.jsx("span",{style:{color:"hsl(var(--destructive))"},children:t.errors.join("; ")})]})}function $_({msg:t}){var r,n,i,s;const e=typeof((r=t.message)==null?void 0:r.content)=="string"?t.message.content:((s=(i=(n=t.message)==null?void 0:n.content)==null?void 0:i[0])==null?void 0:s.text)??"";return!e||t.isSynthetic?null:h.jsx("div",{className:"flex justify-end py-1",children:h.jsx("div",{className:"rounded-lg px-3 py-2 text-sm max-w-[80%] whitespace-pre-wrap",style:{background:"hsl(var(--accent) / 0.15)",color:"hsl(var(--foreground))",border:"1px solid hsl(var(--accent) / 0.3)"},children:e})})}function z_({msg:t}){var e,r;if(t.type==="stream_event"||!t.verbose&&t.type==="tool_progress"||!t.verbose&&t.type==="tool_use_summary")return null;if(t.verbose){const n=t.type==="tool_progress"?`${t.tool||"tool"} · ${t.elapsed!=null?t.elapsed+"s":""}`:t.summary||"summary",i=t.type==="tool_progress"?"progress":"summary";return h.jsxs("div",{style:{opacity:.6,fontSize:"10px",padding:"2px 0",paddingLeft:4,borderLeft:"1px solid hsl(215 20% 20%)",color:"hsl(var(--muted-foreground))",fontFamily:"ui-monospace, monospace"},children:[h.jsx("span",{style:{color:"hsl(210 40% 45%)",background:"hsl(210 40% 45% / 0.1)",padding:"0 4px",borderRadius:2,fontSize:"10px"},children:i})," ",n]})}if(t.type==="system"&&t.subtype==="init")return h.jsxs("div",{className:"text-[10px] uppercase tracking-wider py-1 flex gap-3 flex-wrap",style:{color:"hsl(var(--muted-foreground))",opacity:.6},children:[h.jsxs("span",{children:["session ",(e=t.session_id)==null?void 0:e.slice(0,8)]}),h.jsx("span",{children:t.model}),h.jsx("span",{children:t.permissionMode})]});if(t.type==="system"&&t.subtype==="connected")return h.jsxs("div",{className:"text-[10px] py-0.5",style:{color:"hsl(var(--muted-foreground))",opacity:.5},children:["reconnected · session ",(r=t.sessionId)==null?void 0:r.slice(0,8)]});if(t.type==="system"&&(t.subtype==="build_start"||t.subtype==="build_resume")){const n=t.subtype==="build_resume"?"build resumed":"build started";return h.jsxs("div",{className:"text-[10px] uppercase tracking-wider py-1",style:{color:"hsl(var(--accent))",opacity:.8},children:[n," -- ",t.featureCode]})}if(t.type==="system"&&t.subtype==="build_step")return h.jsxs("div",{className:"text-[10px] uppercase tracking-wider py-1 flex gap-2",style:{color:"hsl(var(--muted-foreground))"},children:[h.jsxs("span",{children:["step ",t.stepNum,"/",t.totalSteps]}),h.jsx("span",{className:"font-mono",children:t.stepId}),h.jsx("span",{style:{opacity:.5},children:t.agent})]});if(t.type==="system"&&t.subtype==="build_step_done")return h.jsx(j_,{msg:t,mode:"stream"});if(t.type==="system"&&t.subtype==="build_gate")return h.jsxs("div",{className:"text-[10px] uppercase tracking-wider py-1",style:{color:"hsl(38 90% 60%)"},children:["gate -- ",t.stepId]});if(t.type==="system"&&t.subtype==="build_gate_resolved"){const n=t.outcome==="approved"||t.outcome==="approve"?"hsl(var(--success, 142 60% 50%))":t.outcome==="revise"?"hsl(38 90% 60%)":"hsl(var(--destructive))";return h.jsxs("div",{className:"text-[10px] py-0.5",style:{color:n,opacity:.8},children:["gate ",t.outcome," -- ",t.stepId]})}if(t.type==="system"&&t.subtype==="build_end"){const n=t.status==="complete"?"hsl(var(--success, 142 60% 50%))":"hsl(var(--destructive))";return h.jsxs("div",{className:"text-[10px] uppercase tracking-wider py-1",style:{color:n},children:["build ",t.status," -- ",t.featureCode]})}return t.type==="assistant"?h.jsx(O_,{msg:t}):t.type==="user"?h.jsx($_,{msg:t}):t.type==="result"?h.jsx(R_,{msg:t}):t.type==="error"?h.jsx("div",{className:"text-xs rounded px-2 py-1.5 font-mono",style:{background:"hsl(var(--destructive) / 0.1)",color:"hsl(var(--destructive))",borderLeft:"2px solid hsl(var(--destructive))"},children:t.message}):null}function W_({onSend:t,disabled:e=!1,placeholder:r="Message Claude…"}){const n=C.useRef(null);C.useEffect(()=>{!e&&n.current&&n.current.focus()},[e]);function i(){const a=n.current;a&&(a.style.height="auto",a.style.height=`${Math.min(a.scrollHeight,160)}px`)}function s(a){a.key==="Enter"&&!a.shiftKey&&(a.preventDefault(),o())}function o(){const a=n.current;if(!a)return;const l=a.value.trim();l&&(t(l),a.value="",i())}return h.jsxs("div",{className:"flex items-end gap-2 px-3 py-2",style:{borderTop:"1px solid hsl(var(--border))"},children:[h.jsx("textarea",{ref:n,rows:1,disabled:e,placeholder:r,onKeyDown:s,onInput:i,className:"flex-1 resize-none bg-transparent text-sm outline-none font-mono leading-relaxed",style:{color:"hsl(var(--foreground))",caretColor:"hsl(var(--accent))",maxHeight:"160px",overflowY:"auto",opacity:e?.4:1,transition:"opacity 0.15s"}}),h.jsx("button",{onClick:o,disabled:e,title:"Send (Enter)",className:"shrink-0 rounded px-2 py-1 text-xs font-mono",style:{background:"hsl(var(--accent) / 0.15)",color:"hsl(var(--accent))",border:"1px solid hsl(var(--accent) / 0.3)",cursor:e?"not-allowed":"pointer",opacity:e?.4:1,transition:"opacity 0.15s"},children:"↵"})]})}const ay="compose:verboseStream",Ll={verboseStream:!1};function ly(){return Ll.verboseStream}function q_(t,e){Ll.verboseStream=!!t;const r=typeof localStorage<"u"?localStorage:null;if(r)try{r.setItem(ay,String(Ll.verboseStream))}catch{}}function H_(t){const e=typeof localStorage<"u"?localStorage:null;if(e)try{const r=e.getItem(ay);r!==null&&(Ll.verboseStream=r==="true")}catch{}}function U_(t,e){return t.type==="stream_event"?{include:!1,msg:t}:t.type==="tool_progress"||t.type==="tool_use_summary"?e?{include:!0,msg:{...t,verbose:!0}}:{include:!1,msg:t}:{include:!0,msg:t}}function G_(t){var r,n;const e=[];for(let i=0;i<t.length;i++){const s=t[i],o=t[i+1],a=s.type==="assistant"&&((n=(r=s.message)==null?void 0:r.content)==null?void 0:n.some(c=>c.type==="tool_use")),l=o&&(o.type==="tool_use_summary"||o.type==="assistant"&&o.subtype==="tool_use_summary");a&&l?(e.push({...s,_toolResult:o}),i++):e.push(s)}return e}const cy=parseInt("4002",10),V_="compose-agent-session",Qp=500,Y_=8,X_=2e3,Jp={Read:"reading",Glob:"searching",Grep:"searching",Write:"writing",Edit:"writing",NotebookEdit:"writing",Bash:"executing",Task:"delegating",Skill:"delegating",WebFetch:"fetching",WebSearch:"searching",TodoRead:"reading",TodoWrite:"writing"},K_={reading:"Reading",writing:"Writing",executing:"Running",searching:"Searching",fetching:"Fetching",delegating:"Delegating",thinking:"Thinking",waiting:"Waiting for gate approval"};H_();const ut={es:null,connected:!1,connecting:!1,reconnectTimer:null,reconnectAttempts:0,sessionId:null,messages:[],agentStatus:"idle",agentTool:null,agentCategory:null,currentActivity:null,activityLog:[],_idleTimer:null,sourceStatus:{build:null,interactive:null},parallelTasks:null,onConnectedChange:null,onMessagesChange:null,onAgentStatusChange:null};function Z_(t){var e,r;if(t._source==="build"){if(t.type==="system"){if(t.subtype==="build_step"||t.subtype==="build_step_done"||t.subtype==="build_gate_resolved")return{status:"working",tool:null,category:"thinking",_source:"build"};if(t.subtype==="build_gate")return{status:"working",tool:null,category:"waiting",_source:"build"};if(t.subtype==="build_end")return{status:"idle",tool:null,category:null,_source:"build"}}if(t.type==="error"&&t.source==="build")return{status:"working",tool:null,category:"thinking",_source:"build"};if(t.type==="assistant"){const n=((e=t.message)==null?void 0:e.content)??[];for(const i of n)if(i.type==="tool_use"){const s=Jp[i.name]||"thinking";return{status:"working",tool:i.name,category:s,_source:"build"}}if(n.some(i=>i.type==="text"))return{status:"working",tool:null,category:"thinking",_source:"build"}}return null}if(t.type==="assistant"){const n=((r=t.message)==null?void 0:r.content)??[];for(const i of n)if(i.type==="tool_use"){const s=Jp[i.name]||"thinking";return{status:"working",tool:i.name,category:s}}if(n.some(i=>i.type==="text"))return{status:"working",tool:null,category:"thinking"}}return t.type==="result"?{status:"idle",tool:null,category:null}:null}function mh(t,e,r){const n=Date.now(),i=ut.agentStatus,s=ut.agentTool;if(ut._idleTimer&&(clearTimeout(ut._idleTimer),ut._idleTimer=null),i==="working"&&(t==="idle"||e!==s)){const a=ut.currentActivity;a&&(a.endTime=n,a.duration=n-a.startTime,ut.activityLog.push(a),ut.activityLog.length>Y_&&ut.activityLog.shift())}t==="working"&&e!==s?ut.currentActivity={tool:e,category:r,startTime:n,endTime:null,duration:null}:t==="idle"&&(ut.currentActivity=null),ut.agentStatus=t,ut.agentTool=e,ut.agentCategory=r;const o={status:t,tool:e,category:r,activityLog:ut.activityLog,currentActivity:ut.currentActivity,parallelTasks:ut.parallelTasks};ut.onAgentStatusChange&&ut.onAgentStatusChange({...o}),window.dispatchEvent(new CustomEvent("compose:agent-status",{detail:o}))}function tm(){const t=ut.sourceStatus.build,e=ut.sourceStatus.interactive;(e==null?void 0:e.status)==="working"?mh(e.status,e.tool,e.category):(t==null?void 0:t.status)==="working"?mh(t.status,t.tool,t.category):ut._idleTimer=setTimeout(()=>{ut._idleTimer=null,mh("idle",null,null)},X_)}function ju(t){var i,s,o,a,l,c;t._source==="build"&&t.type==="system"&&t.parallel&&(t.subtype==="build_step"&&((i=t.stepNum)!=null&&i.toString().startsWith("∥"))?(ut.parallelTasks||(ut.parallelTasks={total:0,completed:0,failed:0,active:0,tasks:{}}),ut.parallelTasks.total++,ut.parallelTasks.active++,ut.parallelTasks.tasks[t.stepId]="working"):t.subtype==="build_step_done"&&((o=(s=ut.parallelTasks)==null?void 0:s.tasks)!=null&&o[t.stepId])?(ut.parallelTasks.active=Math.max(0,ut.parallelTasks.active-1),ut.parallelTasks.completed++,ut.parallelTasks.tasks[t.stepId]="complete"):t.subtype==="build_step_done"&&ut.parallelTasks&&!((a=t.stepNum)!=null&&a.toString().startsWith("∥"))&&(ut.parallelTasks=null)),t._source==="build"&&t.type==="error"&&((c=(l=ut.parallelTasks)==null?void 0:l.tasks)!=null&&c[t.stepId])&&(ut.parallelTasks.active=Math.max(0,ut.parallelTasks.active-1),ut.parallelTasks.failed++,ut.parallelTasks.tasks[t.stepId]="failed");const e=Z_(t);if(e){const u=e._source==="build"?"build":"interactive";ut.sourceStatus[u]=e,e.status==="idle"?(ut.parallelTasks=null,tm()):(ut._idleTimer&&(clearTimeout(ut._idleTimer),ut._idleTimer=null),tm())}t.type==="system"&&t.subtype==="init"&&t.session_id&&(ut.sessionId=t.session_id,sessionStorage.setItem(V_,t.session_id));const{include:r,msg:n}=U_(t,ly());r&&(ut.messages=[...ut.messages,n],ut.messages.length>Qp&&(ut.messages=ut.messages.slice(-Qp)),ut.onMessagesChange&&ut.onMessagesChange(ut.messages))}function Q_(){if(ut.es)return;const t=`${window.location.protocol}//${window.location.hostname}:${cy}/api/agent/stream`,e=d_({url:t,namedEvents:["hydrate"],onOpen:()=>{ut.connected=!0,ut.sourceStatus.build=null,ut.onConnectedChange&&ut.onConnectedChange(!0)},onClose:()=>{ut.connected=!1,ut.onConnectedChange&&ut.onConnectedChange(!1)},onEvent:(r,n)=>{if(n==="hydrate"){if(Array.isArray(r))for(const i of r)ju(i);return}ju(r)},maxBackoffMs:8e3});ut.es=e}async function gh(t,e){const r=await fetch(`${window.location.protocol}//${window.location.hostname}:${cy}${t}`,{method:"POST",headers:{"Content-Type":"application/json","x-compose-token":""},body:JSON.stringify(e)});if(!r.ok){const n=await r.json().catch(()=>({error:r.statusText}));throw new Error(n.error||r.statusText)}return r.json()}function em(t){if(!t)return"";if(t<1e3)return"<1s";const e=Math.floor(t/1e3);return e<60?`${e}s`:`${Math.floor(e/60)}m ${e%60}s`}function hy(){var k;const[t,e]=C.useState(ut.connected),[r,n]=C.useState(ut.messages),[i,s]=C.useState({status:ut.agentStatus,tool:ut.agentTool,category:ut.agentCategory,activityLog:ut.activityLog,currentActivity:ut.currentActivity}),[o,a]=C.useState(!1),[l,c]=C.useState(null),u=C.useRef(null),d=r.length===0||r.every(T=>T.type==="system"&&(T.subtype==="init"||T.subtype==="connected"));C.useEffect(()=>(ut.onConnectedChange=e,ut.onMessagesChange=n,ut.onAgentStatusChange=s,()=>{ut.onConnectedChange=null,ut.onMessagesChange=null,ut.onAgentStatusChange=null}),[]),C.useEffect(()=>{Q_()},[]),C.useEffect(()=>{var T;(T=u.current)==null||T.scrollIntoView({behavior:"smooth"})},[r.length]),C.useEffect(()=>{if(i.status!=="working"||!i.currentActivity){c(null);return}const T=i.currentActivity.startTime,_=()=>c(Date.now()-T);_();const w=setInterval(_,1e3);return()=>clearInterval(w)},[i.status,(k=i.currentActivity)==null?void 0:k.startTime]);const p=C.useCallback(async T=>{a(!0);const _=T.match(/[A-Z]+-\d+/);_&&window.dispatchEvent(new CustomEvent("compose:select-feature",{detail:{featureCode:_[0]}}));try{d||!ut.sessionId?await gh("/api/agent/session",{prompt:T}):await gh("/api/agent/message",{prompt:T})}catch(w){ju({type:"error",message:`Failed to send: ${w.message}`})}finally{a(!1)}},[d]),f=C.useCallback(async()=>{try{await gh("/api/agent/interrupt",{})}catch{}},[]),m=t&&(i.status==="working"||o),x=t?m?"#fbbf24":"hsl(var(--success, 142 60% 50%))":"hsl(var(--destructive))",g=i.category?K_[i.category]:null,y=t?m?g||"working":"ready":"offline",b=i.activityLog||[];return h.jsxs("div",{className:"relative w-full h-full flex flex-col",style:{background:"hsl(var(--background))"},children:[h.jsxs("div",{className:"shrink-0 flex items-center justify-between px-3 py-1.5",style:{borderBottom:"1px solid hsl(var(--border) / 0.5)"},children:[h.jsx("div",{className:"flex items-center gap-0.5",children:t&&b.length>0&&b.slice(-5).map((T,_)=>h.jsx("div",{className:"h-1 rounded-full",title:`${T.tool||"thinking"} — ${em(T.duration)}`,style:{width:Math.max(6,Math.min(20,(T.duration||0)/1e3*2)),background:"hsl(var(--muted-foreground))",opacity:.25+_/5*.5}},_))}),h.jsxs("div",{className:"flex items-center gap-1.5",children:[m&&h.jsx("button",{onClick:f,title:"Interrupt",className:"text-[10px] px-1.5 py-0.5 rounded",style:{background:"hsl(var(--destructive) / 0.15)",color:"hsl(var(--destructive))",border:"1px solid hsl(var(--destructive) / 0.3)",cursor:"pointer"},children:"stop"}),h.jsx("div",{className:"w-1.5 h-1.5 rounded-full flex-shrink-0",style:{background:x,animation:m?"pulse 1.5s ease-in-out infinite":"none"}}),h.jsx("span",{className:"text-[10px] uppercase tracking-wider",style:{color:m?"#fbbf24":"hsl(var(--muted-foreground))"},children:y}),m&&i.tool&&h.jsx("span",{className:"text-[10px] font-mono",style:{color:"hsl(var(--muted-foreground))"},children:i.tool}),m&&l!=null&&h.jsx("span",{className:"text-[10px] tabular-nums",style:{color:"hsl(var(--muted-foreground))",opacity:.6},children:em(l)})]})]}),h.jsxs("div",{className:"flex-1 min-h-0 overflow-y-auto px-3 py-2",style:{scrollBehavior:"smooth"},children:[r.length===0&&h.jsxs("div",{className:"flex flex-col items-center justify-center h-full gap-3 opacity-40",children:[h.jsx("span",{className:"text-2xl",children:"⬡"}),h.jsx("span",{className:"text-xs uppercase tracking-widest",style:{color:"hsl(var(--muted-foreground))"},children:t?"ready":"connecting…"})]}),G_(r).map((T,_)=>h.jsx(z_,{msg:T},T.uuid||_)),h.jsx("div",{ref:u})]}),!t&&h.jsx("div",{className:"absolute inset-0 z-20 flex items-center justify-center pointer-events-none",style:{background:"hsl(var(--background) / 0.7)",backdropFilter:"blur(2px)"},children:h.jsxs("div",{className:"flex flex-col items-center gap-3",children:[h.jsx("div",{className:"w-5 h-5 rounded-full animate-spin",style:{border:"2px solid hsl(var(--accent) / 0.2)",borderTopColor:"hsl(var(--accent))"}}),h.jsx("span",{className:"text-xs",style:{color:"hsl(var(--muted-foreground))"},children:"connecting to agent server…"})]})}),h.jsx(W_,{onSend:p,disabled:m||!t,placeholder:m?"Working…":"Message Claude…"})]})}function J_(t,e){const r={};return(t[t.length-1]===""?[...t,""]:t).join((r.padRight?" ":"")+","+(r.padLeft===!1?"":" ")).trim()}const tE=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,eE=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,rE={};function rm(t,e){return(rE.jsx?eE:tE).test(t)}const nE=/[ \t\n\f\r]/g;function iE(t){return typeof t=="object"?t.type==="text"?nm(t.value):!1:nm(t)}function nm(t){return t.replace(nE,"")===""}class ca{constructor(e,r,n){this.normal=r,this.property=e,n&&(this.space=n)}}ca.prototype.normal={};ca.prototype.property={};ca.prototype.space=void 0;function uy(t,e){const r={},n={};for(const i of t)Object.assign(r,i.property),Object.assign(n,i.normal);return new ca(r,n,e)}function Lu(t){return t.toLowerCase()}class yr{constructor(e,r){this.attribute=r,this.property=e}}yr.prototype.attribute="";yr.prototype.booleanish=!1;yr.prototype.boolean=!1;yr.prototype.commaOrSpaceSeparated=!1;yr.prototype.commaSeparated=!1;yr.prototype.defined=!1;yr.prototype.mustUseProperty=!1;yr.prototype.number=!1;yr.prototype.overloadedBoolean=!1;yr.prototype.property="";yr.prototype.spaceSeparated=!1;yr.prototype.space=void 0;let sE=0;const Ht=_i(),je=_i(),Bu=_i(),ot=_i(),he=_i(),as=_i(),Sr=_i();function _i(){return 2**++sE}const Au=Object.freeze(Object.defineProperty({__proto__:null,boolean:Ht,booleanish:je,commaOrSpaceSeparated:Sr,commaSeparated:as,number:ot,overloadedBoolean:Bu,spaceSeparated:he},Symbol.toStringTag,{value:"Module"})),xh=Object.keys(Au);class rf extends yr{constructor(e,r,n,i){let s=-1;if(super(e,r),im(this,"space",i),typeof n=="number")for(;++s<xh.length;){const o=xh[s];im(this,xh[s],(n&Au[o])===Au[o])}}}rf.prototype.defined=!0;function im(t,e,r){r&&(t[e]=r)}function zs(t){const e={},r={};for(const[n,i]of Object.entries(t.properties)){const s=new rf(n,t.transform(t.attributes||{},n),i,t.space);t.mustUseProperty&&t.mustUseProperty.includes(n)&&(s.mustUseProperty=!0),e[n]=s,r[Lu(n)]=n,r[Lu(s.attribute)]=n}return new ca(e,r,t.space)}const dy=zs({properties:{ariaActiveDescendant:null,ariaAtomic:je,ariaAutoComplete:null,ariaBusy:je,ariaChecked:je,ariaColCount:ot,ariaColIndex:ot,ariaColSpan:ot,ariaControls:he,ariaCurrent:null,ariaDescribedBy:he,ariaDetails:null,ariaDisabled:je,ariaDropEffect:he,ariaErrorMessage:null,ariaExpanded:je,ariaFlowTo:he,ariaGrabbed:je,ariaHasPopup:null,ariaHidden:je,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:he,ariaLevel:ot,ariaLive:null,ariaModal:je,ariaMultiLine:je,ariaMultiSelectable:je,ariaOrientation:null,ariaOwns:he,ariaPlaceholder:null,ariaPosInSet:ot,ariaPressed:je,ariaReadOnly:je,ariaRelevant:null,ariaRequired:je,ariaRoleDescription:he,ariaRowCount:ot,ariaRowIndex:ot,ariaRowSpan:ot,ariaSelected:je,ariaSetSize:ot,ariaSort:null,ariaValueMax:ot,ariaValueMin:ot,ariaValueNow:ot,ariaValueText:null,role:null},transform(t,e){return e==="role"?e:"aria-"+e.slice(4).toLowerCase()}});function fy(t,e){return e in t?t[e]:e}function py(t,e){return fy(t,e.toLowerCase())}const oE=zs({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:as,acceptCharset:he,accessKey:he,action:null,allow:null,allowFullScreen:Ht,allowPaymentRequest:Ht,allowUserMedia:Ht,alt:null,as:null,async:Ht,autoCapitalize:null,autoComplete:he,autoFocus:Ht,autoPlay:Ht,blocking:he,capture:null,charSet:null,checked:Ht,cite:null,className:he,cols:ot,colSpan:null,content:null,contentEditable:je,controls:Ht,controlsList:he,coords:ot|as,crossOrigin:null,data:null,dateTime:null,decoding:null,default:Ht,defer:Ht,dir:null,dirName:null,disabled:Ht,download:Bu,draggable:je,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:Ht,formTarget:null,headers:he,height:ot,hidden:Bu,high:ot,href:null,hrefLang:null,htmlFor:he,httpEquiv:he,id:null,imageSizes:null,imageSrcSet:null,inert:Ht,inputMode:null,integrity:null,is:null,isMap:Ht,itemId:null,itemProp:he,itemRef:he,itemScope:Ht,itemType:he,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:Ht,low:ot,manifest:null,max:null,maxLength:ot,media:null,method:null,min:null,minLength:ot,multiple:Ht,muted:Ht,name:null,nonce:null,noModule:Ht,noValidate:Ht,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:Ht,optimum:ot,pattern:null,ping:he,placeholder:null,playsInline:Ht,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:Ht,referrerPolicy:null,rel:he,required:Ht,reversed:Ht,rows:ot,rowSpan:ot,sandbox:he,scope:null,scoped:Ht,seamless:Ht,selected:Ht,shadowRootClonable:Ht,shadowRootDelegatesFocus:Ht,shadowRootMode:null,shape:null,size:ot,sizes:null,slot:null,span:ot,spellCheck:je,src:null,srcDoc:null,srcLang:null,srcSet:null,start:ot,step:null,style:null,tabIndex:ot,target:null,title:null,translate:null,type:null,typeMustMatch:Ht,useMap:null,value:je,width:ot,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:he,axis:null,background:null,bgColor:null,border:ot,borderColor:null,bottomMargin:ot,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:Ht,declare:Ht,event:null,face:null,frame:null,frameBorder:null,hSpace:ot,leftMargin:ot,link:null,longDesc:null,lowSrc:null,marginHeight:ot,marginWidth:ot,noResize:Ht,noHref:Ht,noShade:Ht,noWrap:Ht,object:null,profile:null,prompt:null,rev:null,rightMargin:ot,rules:null,scheme:null,scrolling:je,standby:null,summary:null,text:null,topMargin:ot,valueType:null,version:null,vAlign:null,vLink:null,vSpace:ot,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:Ht,disableRemotePlayback:Ht,prefix:null,property:null,results:ot,security:null,unselectable:null},space:"html",transform:py}),aE=zs({attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},properties:{about:Sr,accentHeight:ot,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:ot,amplitude:ot,arabicForm:null,ascent:ot,attributeName:null,attributeType:null,azimuth:ot,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:ot,by:null,calcMode:null,capHeight:ot,className:he,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:ot,diffuseConstant:ot,direction:null,display:null,dur:null,divisor:ot,dominantBaseline:null,download:Ht,dx:null,dy:null,edgeMode:null,editable:null,elevation:ot,enableBackground:null,end:null,event:null,exponent:ot,externalResourcesRequired:null,fill:null,fillOpacity:ot,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:as,g2:as,glyphName:as,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:ot,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:ot,horizOriginX:ot,horizOriginY:ot,id:null,ideographic:ot,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:ot,k:ot,k1:ot,k2:ot,k3:ot,k4:ot,kernelMatrix:Sr,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:ot,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:ot,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:ot,overlineThickness:ot,paintOrder:null,panose1:null,path:null,pathLength:ot,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:he,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:ot,pointsAtY:ot,pointsAtZ:ot,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:Sr,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:Sr,rev:Sr,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:Sr,requiredFeatures:Sr,requiredFonts:Sr,requiredFormats:Sr,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:ot,specularExponent:ot,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:ot,strikethroughThickness:ot,string:null,stroke:null,strokeDashArray:Sr,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:ot,strokeOpacity:ot,strokeWidth:null,style:null,surfaceScale:ot,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:Sr,tabIndex:ot,tableValues:null,target:null,targetX:ot,targetY:ot,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:Sr,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:ot,underlineThickness:ot,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:ot,values:null,vAlphabetic:ot,vMathematical:ot,vectorEffect:null,vHanging:ot,vIdeographic:ot,version:null,vertAdvY:ot,vertOriginX:ot,vertOriginY:ot,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:ot,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:fy}),my=zs({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform(t,e){return"xlink:"+e.slice(5).toLowerCase()}}),gy=zs({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:py}),xy=zs({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(t,e){return"xml:"+e.slice(3).toLowerCase()}}),lE={classId:"classID",dataType:"datatype",itemId:"itemID",strokeDashArray:"strokeDasharray",strokeDashOffset:"strokeDashoffset",strokeLineCap:"strokeLinecap",strokeLineJoin:"strokeLinejoin",strokeMiterLimit:"strokeMiterlimit",typeOf:"typeof",xLinkActuate:"xlinkActuate",xLinkArcRole:"xlinkArcrole",xLinkHref:"xlinkHref",xLinkRole:"xlinkRole",xLinkShow:"xlinkShow",xLinkTitle:"xlinkTitle",xLinkType:"xlinkType",xmlnsXLink:"xmlnsXlink"},cE=/[A-Z]/g,sm=/-[a-z]/g,hE=/^data[-\w.:]+$/i;function uE(t,e){const r=Lu(e);let n=e,i=yr;if(r in t.normal)return t.property[t.normal[r]];if(r.length>4&&r.slice(0,4)==="data"&&hE.test(e)){if(e.charAt(4)==="-"){const s=e.slice(5).replace(sm,fE);n="data"+s.charAt(0).toUpperCase()+s.slice(1)}else{const s=e.slice(4);if(!sm.test(s)){let o=s.replace(cE,dE);o.charAt(0)!=="-"&&(o="-"+o),e="data"+o}}i=rf}return new i(n,e)}function dE(t){return"-"+t.toLowerCase()}function fE(t){return t.charAt(1).toUpperCase()}const pE=uy([dy,oE,my,gy,xy],"html"),nf=uy([dy,aE,my,gy,xy],"svg");function mE(t){return t.join(" ").trim()}var Pi={},yh,om;function gE(){if(om)return yh;om=1;var t=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,e=/\n/g,r=/^\s*/,n=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,i=/^:\s*/,s=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,o=/^[;\s]*/,a=/^\s+|\s+$/g,l=`
|
|
@@ -636,8 +636,8 @@ Please report this to https://github.com/markedjs/marked.`,e){let i="<p>An error
|
|
|
636
636
|
L0,20`)},"requirement_arrow"),C9=v((t,e,r)=>{const n=me(),{themeVariables:i}=n,{strokeWidth:s}=i;t.append("defs").append("marker").attr("id",r+"_"+e+"-requirement_arrowEnd").attr("refX",20).attr("refY",10).attr("markerWidth",20).attr("markerHeight",20).attr("orient","auto").attr("markerUnits","userSpaceOnUse").attr("stroke-width",`${s}`).attr("viewBox","0 0 25 20").append("path").attr("d",`M0,0
|
|
637
637
|
L20,10
|
|
638
638
|
M20,10
|
|
639
|
-
L0,20`).attr("stroke-linejoin","miter")},"requirement_arrow_neo"),k9=v((t,e,r)=>{const n=t.append("defs").append("marker").attr("id",r+"_"+e+"-requirement_containsStart").attr("refX",0).attr("refY",10).attr("markerWidth",20).attr("markerHeight",20).attr("orient","auto").append("g");n.append("circle").attr("cx",10).attr("cy",10).attr("r",9).attr("fill","none"),n.append("line").attr("x1",1).attr("x2",19).attr("y1",10).attr("y2",10),n.append("line").attr("y1",1).attr("y2",19).attr("x1",10).attr("x2",10)},"requirement_contains"),v9=v((t,e,r)=>{const n=me(),{themeVariables:i}=n,{strokeWidth:s}=i,o=t.append("defs").append("marker").attr("id",r+"_"+e+"-requirement_containsStart").attr("refX",0).attr("refY",10).attr("markerWidth",20).attr("markerHeight",20).attr("orient","auto").attr("markerUnits","userSpaceOnUse").append("g");o.append("circle").attr("cx",10).attr("cy",10).attr("r",9).attr("fill","none"),o.append("line").attr("x1",1).attr("x2",19).attr("y1",10).attr("y2",10),o.append("line").attr("y1",1).attr("y2",19).attr("x1",10).attr("x2",10),o.selectAll("*").attr("stroke-width",`${s}`)},"requirement_contains_neo"),w9={extension:e9,composition:r9,aggregation:n9,dependency:i9,lollipop:s9,point:o9,circle:a9,cross:l9,barb:c9,barbNeo:h9,only_one:u9,zero_or_one:d9,one_or_more:f9,zero_or_more:p9,only_one_neo:m9,zero_or_one_neo:g9,one_or_more_neo:x9,zero_or_more_neo:y9,requirement_arrow:b9,requirement_contains:k9,requirement_arrow_neo:C9,requirement_contains_neo:v9},S9=t9,T9={common:ga,getConfig:me,insertCluster:vz,insertEdge:Jz,insertEdgeLabel:Vz,insertMarkers:S9,insertNode:F2,interpolateToCurve:pp,labelHelper:It,log:Q,positionEdgeLabel:Yz},sa={},R2=v(t=>{for(const e of t)sa[e.name]=e},"registerLayoutLoaders"),_9=v(()=>{R2([{name:"dagre",loader:v(async()=>await Qt(()=>import("./dagre-BM42HDAG-Dd1Ny0g8.js"),__vite__mapDeps([0,1,2,3,4,5,6,7])),"loader")},{name:"cose-bilkent",loader:v(async()=>await Qt(()=>import("./cose-bilkent-S5V4N54A-CylcCFl3.js"),__vite__mapDeps([8,7,3,4,5,6])),"loader")}])},"registerDefaultLayoutLoaders");_9();var IZ=v(async(t,e)=>{if(!(t.layoutAlgorithm in sa))throw new Error(`Unknown layout algorithm: ${t.layoutAlgorithm}`);if(t.diagramId)for(const u of t.nodes){const d=u.domId||u.id;u.domId=`${t.diagramId}-${d}`}const r=sa[t.layoutAlgorithm],n=await r.loader(),{theme:i,themeVariables:s}=t.config,{useGradient:o,gradientStart:a,gradientStop:l}=s,c=e.attr("id");if(e.append("defs").append("filter").attr("id",`${c}-drop-shadow`).attr("height","130%").attr("width","130%").append("feDropShadow").attr("dx","4").attr("dy","4").attr("stdDeviation",0).attr("flood-opacity","0.06").attr("flood-color",`${i!=null&&i.includes("dark")?"#FFFFFF":"#000000"}`),e.append("defs").append("filter").attr("id",`${c}-drop-shadow-small`).attr("height","150%").attr("width","150%").append("feDropShadow").attr("dx","2").attr("dy","2").attr("stdDeviation",0).attr("flood-opacity","0.06").attr("flood-color",`${i!=null&&i.includes("dark")?"#FFFFFF":"#000000"}`),o){const u=e.append("linearGradient").attr("id",e.attr("id")+"-gradient").attr("gradientUnits","objectBoundingBox").attr("x1","0%").attr("y1","0%").attr("x2","100%").attr("y2","0%");u.append("svg:stop").attr("offset","0%").attr("stop-color",a).attr("stop-opacity",1),u.append("svg:stop").attr("offset","100%").attr("stop-color",l).attr("stop-opacity",1)}return n.render(t,e,T9,{algorithm:r.algorithm})},"render"),FZ=v((t="",{fallback:e="dagre"}={})=>{if(t in sa)return t;if(e in sa)return Q.warn(`Layout algorithm ${t} is not registered. Using ${e} as fallback.`),e;throw new Error(`Both layout algorithms ${t} and ${e} are not registered.`)},"getRegisteredLayoutAlgorithm"),Fp="comm",$2="rule",z2="decl",E9="@media",N9="@import",j9="@supports",L9="@namespace",Dd="@keyframes",W2="@layer",B9="@scope",A9=Math.abs,qo=String.fromCharCode;function q2(t){return t.trim()}function Od(t,e,r){return t.replace(e,r)}function us(t,e){return t.charCodeAt(e)|0}function Rs(t,e,r){return t.slice(e,r)}function rn(t){return t.length}function H2(t){return t.length}function Za(t,e){return e.push(t),t}var th=1,$s=1,U2=0,Mr=0,Le=0,Vs="";function Pp(t,e,r,n,i,s,o,a){return{value:t,root:e,parent:r,type:n,props:i,children:s,line:th,column:$s,length:o,return:"",siblings:a}}function M9(){return Le}function I9(){return Le=Mr>0?us(Vs,--Mr):0,$s--,Le===10&&($s=1,th--),Le}function Vr(){return Le=Mr<U2?us(Vs,Mr++):0,$s++,Le===10&&($s=1,th++),Le}function Rn(){return us(Vs,Mr)}function Sl(){return Mr}function eh(t,e){return Rs(Vs,t,e)}function oa(t){switch(t){case 0:case 9:case 10:case 13:case 32:return 5;case 33:case 43:case 44:case 47:case 62:case 64:case 126:case 59:case 123:case 125:return 4;case 58:return 3;case 34:case 39:case 40:case 91:return 2;case 41:case 93:return 1}return 0}function F9(t){return th=$s=1,U2=rn(Vs=t),Mr=0,[]}function P9(t){return Vs="",t}function lu(t){return q2(eh(Mr-1,Rd(t===91?t+2:t===40?t+1:t)))}function D9(t){for(;(Le=Rn())&&Le<33;)Vr();return oa(t)>2||oa(Le)>3?"":" "}function O9(t,e){for(;--e&&Vr()&&!(Le<48||Le>102||Le>57&&Le<65||Le>70&&Le<97););return eh(t,Sl()+(e<6&&Rn()==32&&Vr()==32))}function Rd(t){for(;Vr();)switch(Le){case t:return Mr;case 34:case 39:t!==34&&t!==39&&Rd(Le);break;case 40:t===41&&Rd(t);break;case 92:Vr();break}return Mr}function R9(t,e){for(;Vr()&&t+Le!==57;)if(t+Le===84&&Rn()===47)break;return"/*"+eh(e,Mr-1)+"*"+qo(t===47?t:Vr())}function $9(t){for(;!oa(Rn());)Vr();return eh(t,Mr)}function z9(t){return P9(Tl("",null,null,null,[""],t=F9(t),0,[0],t))}function Tl(t,e,r,n,i,s,o,a,l){for(var c=0,u=0,d=o,p=0,f=0,m=0,x=1,g=1,y=1,b=0,k=0,T="",_=i,w=s,E=n,B=T;g;)switch(m=k,k=Vr()){case 40:m!=108&&us(B,d-1)==58?(b++,B+="("):B+=lu(k);break;case 41:b--,B+=")";break;case 34:case 39:case 91:B+=lu(k);break;case 9:case 10:case 13:case 32:if(b>0){B+=qo(k);break}B+=D9(m);break;case 92:B+=O9(Sl()-1,7);continue;case 47:switch(Rn()){case 42:case 47:Za(W9(R9(Vr(),Sl()),e,r,l),l),(oa(m||1)==5||oa(Rn()||1)==5)&&rn(B)&&Rs(B,-1,void 0)!==" "&&(B+=" ");break;default:B+="/"}break;case 123*x:a[c++]=rn(B)*y;case 125*x:case 59:case 0:if(b>0&&k){B+=qo(k);break}switch(k){case 0:case 125:g=0;case 59+u:y==-1&&(B=Od(B,/\f/g,"")),f>0&&(rn(B)-d||x===0)&&Za(f>32?Gx(B+";",n,r,d-1,l):Gx(Od(B," ","")+";",n,r,d-2,l),l);break;case 59:B+=";";default:if(Za(E=Ux(B,e,r,c,u,i,a,T,_=[],w=[],d,s),s),k===123)if(u===0)Tl(B,e,E,E,_,s,d,a,w);else{switch(p){case 99:if(us(B,3)===110)break;case 108:if(us(B,2)===97)break;default:u=0;case 100:case 109:case 115:}u?Tl(t,E,E,n&&Za(Ux(t,E,E,0,0,i,a,T,i,_=[],d,w),w),i,w,d,a,n?_:w):Tl(B,E,E,E,[""],w,0,a,w)}}c=u=f=0,x=y=1,T=B="",d=o;break;case 58:d=1+rn(B),f=m;default:if(x<1){if(k==123)--x;else if(k==125&&x++==0&&I9()==125)continue}switch(B+=qo(k),k*x){case 38:y=u>0?1:(B+="\f",-1);break;case 44:if(b>0)break;a[c++]=(rn(B)-1)*y,y=1;break;case 64:Rn()===45&&(B+=lu(Vr())),p=Rn(),u=d=rn(T=B+=$9(Sl())),k++;break;case 45:m===45&&rn(B)==2&&(x=0)}}return s}function Ux(t,e,r,n,i,s,o,a,l,c,u,d){for(var p=i-1,f=i===0?s:[""],m=H2(f),x=0,g=0,y=0;x<n;++x)for(var b=0,k=Rs(t,p+1,p=A9(g=o[x])),T=t;b<m;++b)(T=q2(g>0?f[b]+" "+k:Od(k,/&\f/g,f[b])))&&(l[y++]=T);return Pp(t,e,r,i===0?$2:a,l,c,u,d)}function W9(t,e,r,n){return Pp(t,e,r,Fp,qo(M9()),Rs(t,2,-2),0,n)}function Gx(t,e,r,n,i){return Pp(t,e,r,z2,Rs(t,0,n),Rs(t,n+1,-1),n,i)}function $d(t,e){for(var r="",n=0;n<t.length;n++)r+=e(t[n],n,t,e)||"";return r}function q9(t,e,r,n){switch(t.type){case W2:if(t.children.length)break;case N9:case L9:case z2:return t.return=t.return||t.value;case Fp:return"";case Dd:return t.return=t.value+"{"+$d(t.children,n)+"}";case $2:if(!rn(t.value=t.props.join(",")))return""}return rn(r=$d(t.children,n))?t.return=t.value+"{"+r+"}":""}function H9(t){var e=H2(t);return function(r,n,i,s){for(var o="",a=0;a<e;a++)o+=t[a](r,n,i,s)||"";return o}}var G2="c4",U9=v(t=>/^\s*C4Context|C4Container|C4Component|C4Dynamic|C4Deployment/.test(t),"detector"),G9=v(async()=>{const{diagram:t}=await Qt(async()=>{const{diagram:e}=await import("./c4Diagram-AAUBKEIU-CJ_8nsiM.js");return{diagram:e}},__vite__mapDeps([9,10,3,4,5,6,7]));return{id:G2,diagram:t}},"loader"),V9={id:G2,detector:U9,loader:G9},Y9=V9,V2="flowchart",X9=v((t,e)=>{var r,n;return((r=e==null?void 0:e.flowchart)==null?void 0:r.defaultRenderer)==="dagre-wrapper"||((n=e==null?void 0:e.flowchart)==null?void 0:n.defaultRenderer)==="elk"?!1:/^\s*graph/.test(t)},"detector"),K9=v(async()=>{const{diagram:t}=await Qt(async()=>{const{diagram:e}=await import("./flowDiagram-I6XJVG4X-B9KvjWpm.js");return{diagram:e}},__vite__mapDeps([11,12,10,13,14,15,3,4,5,6,7]));return{id:V2,diagram:t}},"loader"),Z9={id:V2,detector:X9,loader:K9},Q9=Z9,Y2="flowchart-v2",J9=v((t,e)=>{var r,n,i;return((r=e==null?void 0:e.flowchart)==null?void 0:r.defaultRenderer)==="dagre-d3"?!1:(((n=e==null?void 0:e.flowchart)==null?void 0:n.defaultRenderer)==="elk"&&(e.layout="elk"),/^\s*graph/.test(t)&&((i=e==null?void 0:e.flowchart)==null?void 0:i.defaultRenderer)==="dagre-wrapper"?!0:/^\s*flowchart/.test(t))},"detector"),t7=v(async()=>{const{diagram:t}=await Qt(async()=>{const{diagram:e}=await import("./flowDiagram-I6XJVG4X-B9KvjWpm.js");return{diagram:e}},__vite__mapDeps([11,12,10,13,14,15,3,4,5,6,7]));return{id:Y2,diagram:t}},"loader"),e7={id:Y2,detector:J9,loader:t7},r7=e7,X2="er",n7=v(t=>/^\s*erDiagram/.test(t),"detector"),i7=v(async()=>{const{diagram:t}=await Qt(async()=>{const{diagram:e}=await import("./erDiagram-TEJ5UH35-ClfbMYdQ.js");return{diagram:e}},__vite__mapDeps([16,13,14,15,3,4,5,6,7]));return{id:X2,diagram:t}},"loader"),s7={id:X2,detector:n7,loader:i7},o7=s7,K2="gitGraph",a7=v(t=>/^\s*gitGraph/.test(t),"detector"),l7=v(async()=>{const{diagram:t}=await Qt(async()=>{const{diagram:e}=await import("./gitGraphDiagram-PVQCEYII-DN9gJgDY.js");return{diagram:e}},__vite__mapDeps([17,18,19,20,5,3,4,6,7]));return{id:K2,diagram:t}},"loader"),c7={id:K2,detector:a7,loader:l7},h7=c7,Z2="gantt",u7=v(t=>/^\s*gantt/.test(t),"detector"),d7=v(async()=>{const{diagram:t}=await Qt(async()=>{const{diagram:e}=await import("./ganttDiagram-6RSMTGT7-CCqvcQcy.js");return{diagram:e}},__vite__mapDeps([21,3,4,22,23,24,5,6,7]));return{id:Z2,diagram:t}},"loader"),f7={id:Z2,detector:u7,loader:d7},p7=f7,Q2="info",m7=v(t=>/^\s*info/.test(t),"detector"),g7=v(async()=>{const{diagram:t}=await Qt(async()=>{const{diagram:e}=await import("./infoDiagram-5YYISTIA-BZjN-ULc.js");return{diagram:e}},__vite__mapDeps([25,20,5,3,4,6,7]));return{id:Q2,diagram:t}},"loader"),x7={id:Q2,detector:m7,loader:g7},J2="pie",y7=v(t=>/^\s*pie/.test(t),"detector"),b7=v(async()=>{const{diagram:t}=await Qt(async()=>{const{diagram:e}=await import("./pieDiagram-4H26LBE5-B7cw_oKH.js");return{diagram:e}},__vite__mapDeps([26,18,20,5,3,4,6,27,28,23,7]));return{id:J2,diagram:t}},"loader"),C7={id:J2,detector:y7,loader:b7},tS="quadrantChart",k7=v(t=>/^\s*quadrantChart/.test(t),"detector"),v7=v(async()=>{const{diagram:t}=await Qt(async()=>{const{diagram:e}=await import("./quadrantDiagram-W4KKPZXB-CqiNInwZ.js");return{diagram:e}},__vite__mapDeps([29,22,23,24,3,4,5,6,7]));return{id:tS,diagram:t}},"loader"),w7={id:tS,detector:k7,loader:v7},S7=w7,eS="xychart",T7=v(t=>/^\s*xychart(-beta)?/.test(t),"detector"),_7=v(async()=>{const{diagram:t}=await Qt(async()=>{const{diagram:e}=await import("./xychartDiagram-2RQKCTM6-BmiRpk6f.js");return{diagram:e}},__vite__mapDeps([30,23,28,22,24,3,4,5,6,7]));return{id:eS,diagram:t}},"loader"),E7={id:eS,detector:T7,loader:_7},N7=E7,rS="requirement",j7=v(t=>/^\s*requirement(Diagram)?/.test(t),"detector"),L7=v(async()=>{const{diagram:t}=await Qt(async()=>{const{diagram:e}=await import("./requirementDiagram-4Y6WPE33-CynhQVI1.js");return{diagram:e}},__vite__mapDeps([31,13,14,3,4,5,6,7]));return{id:rS,diagram:t}},"loader"),B7={id:rS,detector:j7,loader:L7},A7=B7,nS="sequence",M7=v(t=>/^\s*sequenceDiagram/.test(t),"detector"),I7=v(async()=>{const{diagram:t}=await Qt(async()=>{const{diagram:e}=await import("./sequenceDiagram-3UESZ5HK-CTvZcil0.js");return{diagram:e}},__vite__mapDeps([32,10,19,3,4,5,6,7]));return{id:nS,diagram:t}},"loader"),F7={id:nS,detector:M7,loader:I7},P7=F7,iS="class",D7=v((t,e)=>{var r;return((r=e==null?void 0:e.class)==null?void 0:r.defaultRenderer)==="dagre-wrapper"?!1:/^\s*classDiagram/.test(t)},"detector"),O7=v(async()=>{const{diagram:t}=await Qt(async()=>{const{diagram:e}=await import("./classDiagram-4FO5ZUOK-BykFns4A.js");return{diagram:e}},__vite__mapDeps([33,34,12,10,13,14,3,4,5,6,7]));return{id:iS,diagram:t}},"loader"),R7={id:iS,detector:D7,loader:O7},$7=R7,sS="classDiagram",z7=v((t,e)=>{var r;return/^\s*classDiagram/.test(t)&&((r=e==null?void 0:e.class)==null?void 0:r.defaultRenderer)==="dagre-wrapper"?!0:/^\s*classDiagram-v2/.test(t)},"detector"),W7=v(async()=>{const{diagram:t}=await Qt(async()=>{const{diagram:e}=await import("./classDiagram-v2-Q7XG4LA2-BykFns4A.js");return{diagram:e}},__vite__mapDeps([35,34,12,10,13,14,3,4,5,6,7]));return{id:sS,diagram:t}},"loader"),q7={id:sS,detector:z7,loader:W7},H7=q7,oS="state",U7=v((t,e)=>{var r;return((r=e==null?void 0:e.state)==null?void 0:r.defaultRenderer)==="dagre-wrapper"?!1:/^\s*stateDiagram/.test(t)},"detector"),G7=v(async()=>{const{diagram:t}=await Qt(async()=>{const{diagram:e}=await import("./stateDiagram-AJRCARHV-DYXgroJe.js");return{diagram:e}},__vite__mapDeps([36,37,13,14,1,2,3,4,5,6,7]));return{id:oS,diagram:t}},"loader"),V7={id:oS,detector:U7,loader:G7},Y7=V7,aS="stateDiagram",X7=v((t,e)=>{var r;return!!(/^\s*stateDiagram-v2/.test(t)||/^\s*stateDiagram/.test(t)&&((r=e==null?void 0:e.state)==null?void 0:r.defaultRenderer)==="dagre-wrapper")},"detector"),K7=v(async()=>{const{diagram:t}=await Qt(async()=>{const{diagram:e}=await import("./stateDiagram-v2-BHNVJYJU-BVQEXVG-.js");return{diagram:e}},__vite__mapDeps([38,37,13,14,3,4,5,6,7]));return{id:aS,diagram:t}},"loader"),Z7={id:aS,detector:X7,loader:K7},Q7=Z7,lS="journey",J7=v(t=>/^\s*journey/.test(t),"detector"),tW=v(async()=>{const{diagram:t}=await Qt(async()=>{const{diagram:e}=await import("./journeyDiagram-JHISSGLW-CHKyH4p5.js");return{diagram:e}},__vite__mapDeps([39,12,10,27,3,4,5,6,7]));return{id:lS,diagram:t}},"loader"),eW={id:lS,detector:J7,loader:tW},rW=eW,nW=v((t,e,r)=>{Q.debug(`rendering svg for syntax error
|
|
640
|
-
`);const n=RR(e),i=n.append("g");n.attr("viewBox","0 0 2412 512"),R1(n,100,512,!0),i.append("path").attr("class","error-icon").attr("d","m411.313,123.313c6.25-6.25 6.25-16.375 0-22.625s-16.375-6.25-22.625,0l-32,32-9.375,9.375-20.688-20.688c-12.484-12.5-32.766-12.5-45.25,0l-16,16c-1.261,1.261-2.304,2.648-3.31,4.051-21.739-8.561-45.324-13.426-70.065-13.426-105.867,0-192,86.133-192,192s86.133,192 192,192 192-86.133 192-192c0-24.741-4.864-48.327-13.426-70.065 1.402-1.007 2.79-2.049 4.051-3.31l16-16c12.5-12.492 12.5-32.758 0-45.25l-20.688-20.688 9.375-9.375 32.001-31.999zm-219.313,100.687c-52.938,0-96,43.063-96,96 0,8.836-7.164,16-16,16s-16-7.164-16-16c0-70.578 57.422-128 128-128 8.836,0 16,7.164 16,16s-7.164,16-16,16z"),i.append("path").attr("class","error-icon").attr("d","m459.02,148.98c-6.25-6.25-16.375-6.25-22.625,0s-6.25,16.375 0,22.625l16,16c3.125,3.125 7.219,4.688 11.313,4.688 4.094,0 8.188-1.563 11.313-4.688 6.25-6.25 6.25-16.375 0-22.625l-16.001-16z"),i.append("path").attr("class","error-icon").attr("d","m340.395,75.605c3.125,3.125 7.219,4.688 11.313,4.688 4.094,0 8.188-1.563 11.313-4.688 6.25-6.25 6.25-16.375 0-22.625l-16-16c-6.25-6.25-16.375-6.25-22.625,0s-6.25,16.375 0,22.625l15.999,16z"),i.append("path").attr("class","error-icon").attr("d","m400,64c8.844,0 16-7.164 16-16v-32c0-8.836-7.156-16-16-16-8.844,0-16,7.164-16,16v32c0,8.836 7.156,16 16,16z"),i.append("path").attr("class","error-icon").attr("d","m496,96.586h-32c-8.844,0-16,7.164-16,16 0,8.836 7.156,16 16,16h32c8.844,0 16-7.164 16-16 0-8.836-7.156-16-16-16z"),i.append("path").attr("class","error-icon").attr("d","m436.98,75.605c3.125,3.125 7.219,4.688 11.313,4.688 4.094,0 8.188-1.563 11.313-4.688l32-32c6.25-6.25 6.25-16.375 0-22.625s-16.375-6.25-22.625,0l-32,32c-6.251,6.25-6.251,16.375-0.001,22.625z"),i.append("text").attr("class","error-text").attr("x",1440).attr("y",250).attr("font-size","150px").style("text-anchor","middle").text("Syntax error in text"),i.append("text").attr("class","error-text").attr("x",1250).attr("y",400).attr("font-size","100px").style("text-anchor","middle").text(`mermaid version ${r}`)},"draw"),cS={draw:nW},iW=cS,sW={db:{},renderer:cS,parser:{parse:v(()=>{},"parse")}},oW=sW,hS="flowchart-elk",aW=v((t,e={})=>{var r;return/^\s*flowchart-elk/.test(t)||/^\s*(flowchart|graph)/.test(t)&&((r=e==null?void 0:e.flowchart)==null?void 0:r.defaultRenderer)==="elk"?(e.layout="elk",!0):!1},"detector"),lW=v(async()=>{const{diagram:t}=await Qt(async()=>{const{diagram:e}=await import("./flowDiagram-I6XJVG4X-
|
|
639
|
+
L0,20`).attr("stroke-linejoin","miter")},"requirement_arrow_neo"),k9=v((t,e,r)=>{const n=t.append("defs").append("marker").attr("id",r+"_"+e+"-requirement_containsStart").attr("refX",0).attr("refY",10).attr("markerWidth",20).attr("markerHeight",20).attr("orient","auto").append("g");n.append("circle").attr("cx",10).attr("cy",10).attr("r",9).attr("fill","none"),n.append("line").attr("x1",1).attr("x2",19).attr("y1",10).attr("y2",10),n.append("line").attr("y1",1).attr("y2",19).attr("x1",10).attr("x2",10)},"requirement_contains"),v9=v((t,e,r)=>{const n=me(),{themeVariables:i}=n,{strokeWidth:s}=i,o=t.append("defs").append("marker").attr("id",r+"_"+e+"-requirement_containsStart").attr("refX",0).attr("refY",10).attr("markerWidth",20).attr("markerHeight",20).attr("orient","auto").attr("markerUnits","userSpaceOnUse").append("g");o.append("circle").attr("cx",10).attr("cy",10).attr("r",9).attr("fill","none"),o.append("line").attr("x1",1).attr("x2",19).attr("y1",10).attr("y2",10),o.append("line").attr("y1",1).attr("y2",19).attr("x1",10).attr("x2",10),o.selectAll("*").attr("stroke-width",`${s}`)},"requirement_contains_neo"),w9={extension:e9,composition:r9,aggregation:n9,dependency:i9,lollipop:s9,point:o9,circle:a9,cross:l9,barb:c9,barbNeo:h9,only_one:u9,zero_or_one:d9,one_or_more:f9,zero_or_more:p9,only_one_neo:m9,zero_or_one_neo:g9,one_or_more_neo:x9,zero_or_more_neo:y9,requirement_arrow:b9,requirement_contains:k9,requirement_arrow_neo:C9,requirement_contains_neo:v9},S9=t9,T9={common:ga,getConfig:me,insertCluster:vz,insertEdge:Jz,insertEdgeLabel:Vz,insertMarkers:S9,insertNode:F2,interpolateToCurve:pp,labelHelper:It,log:Q,positionEdgeLabel:Yz},sa={},R2=v(t=>{for(const e of t)sa[e.name]=e},"registerLayoutLoaders"),_9=v(()=>{R2([{name:"dagre",loader:v(async()=>await Qt(()=>import("./dagre-BM42HDAG-BWNVctIO.js"),__vite__mapDeps([0,1,2,3,4,5,6,7])),"loader")},{name:"cose-bilkent",loader:v(async()=>await Qt(()=>import("./cose-bilkent-S5V4N54A-CknvjYWn.js"),__vite__mapDeps([8,7,3,4,5,6])),"loader")}])},"registerDefaultLayoutLoaders");_9();var IZ=v(async(t,e)=>{if(!(t.layoutAlgorithm in sa))throw new Error(`Unknown layout algorithm: ${t.layoutAlgorithm}`);if(t.diagramId)for(const u of t.nodes){const d=u.domId||u.id;u.domId=`${t.diagramId}-${d}`}const r=sa[t.layoutAlgorithm],n=await r.loader(),{theme:i,themeVariables:s}=t.config,{useGradient:o,gradientStart:a,gradientStop:l}=s,c=e.attr("id");if(e.append("defs").append("filter").attr("id",`${c}-drop-shadow`).attr("height","130%").attr("width","130%").append("feDropShadow").attr("dx","4").attr("dy","4").attr("stdDeviation",0).attr("flood-opacity","0.06").attr("flood-color",`${i!=null&&i.includes("dark")?"#FFFFFF":"#000000"}`),e.append("defs").append("filter").attr("id",`${c}-drop-shadow-small`).attr("height","150%").attr("width","150%").append("feDropShadow").attr("dx","2").attr("dy","2").attr("stdDeviation",0).attr("flood-opacity","0.06").attr("flood-color",`${i!=null&&i.includes("dark")?"#FFFFFF":"#000000"}`),o){const u=e.append("linearGradient").attr("id",e.attr("id")+"-gradient").attr("gradientUnits","objectBoundingBox").attr("x1","0%").attr("y1","0%").attr("x2","100%").attr("y2","0%");u.append("svg:stop").attr("offset","0%").attr("stop-color",a).attr("stop-opacity",1),u.append("svg:stop").attr("offset","100%").attr("stop-color",l).attr("stop-opacity",1)}return n.render(t,e,T9,{algorithm:r.algorithm})},"render"),FZ=v((t="",{fallback:e="dagre"}={})=>{if(t in sa)return t;if(e in sa)return Q.warn(`Layout algorithm ${t} is not registered. Using ${e} as fallback.`),e;throw new Error(`Both layout algorithms ${t} and ${e} are not registered.`)},"getRegisteredLayoutAlgorithm"),Fp="comm",$2="rule",z2="decl",E9="@media",N9="@import",j9="@supports",L9="@namespace",Dd="@keyframes",W2="@layer",B9="@scope",A9=Math.abs,qo=String.fromCharCode;function q2(t){return t.trim()}function Od(t,e,r){return t.replace(e,r)}function us(t,e){return t.charCodeAt(e)|0}function Rs(t,e,r){return t.slice(e,r)}function rn(t){return t.length}function H2(t){return t.length}function Za(t,e){return e.push(t),t}var th=1,$s=1,U2=0,Mr=0,Le=0,Vs="";function Pp(t,e,r,n,i,s,o,a){return{value:t,root:e,parent:r,type:n,props:i,children:s,line:th,column:$s,length:o,return:"",siblings:a}}function M9(){return Le}function I9(){return Le=Mr>0?us(Vs,--Mr):0,$s--,Le===10&&($s=1,th--),Le}function Vr(){return Le=Mr<U2?us(Vs,Mr++):0,$s++,Le===10&&($s=1,th++),Le}function Rn(){return us(Vs,Mr)}function Sl(){return Mr}function eh(t,e){return Rs(Vs,t,e)}function oa(t){switch(t){case 0:case 9:case 10:case 13:case 32:return 5;case 33:case 43:case 44:case 47:case 62:case 64:case 126:case 59:case 123:case 125:return 4;case 58:return 3;case 34:case 39:case 40:case 91:return 2;case 41:case 93:return 1}return 0}function F9(t){return th=$s=1,U2=rn(Vs=t),Mr=0,[]}function P9(t){return Vs="",t}function lu(t){return q2(eh(Mr-1,Rd(t===91?t+2:t===40?t+1:t)))}function D9(t){for(;(Le=Rn())&&Le<33;)Vr();return oa(t)>2||oa(Le)>3?"":" "}function O9(t,e){for(;--e&&Vr()&&!(Le<48||Le>102||Le>57&&Le<65||Le>70&&Le<97););return eh(t,Sl()+(e<6&&Rn()==32&&Vr()==32))}function Rd(t){for(;Vr();)switch(Le){case t:return Mr;case 34:case 39:t!==34&&t!==39&&Rd(Le);break;case 40:t===41&&Rd(t);break;case 92:Vr();break}return Mr}function R9(t,e){for(;Vr()&&t+Le!==57;)if(t+Le===84&&Rn()===47)break;return"/*"+eh(e,Mr-1)+"*"+qo(t===47?t:Vr())}function $9(t){for(;!oa(Rn());)Vr();return eh(t,Mr)}function z9(t){return P9(Tl("",null,null,null,[""],t=F9(t),0,[0],t))}function Tl(t,e,r,n,i,s,o,a,l){for(var c=0,u=0,d=o,p=0,f=0,m=0,x=1,g=1,y=1,b=0,k=0,T="",_=i,w=s,E=n,B=T;g;)switch(m=k,k=Vr()){case 40:m!=108&&us(B,d-1)==58?(b++,B+="("):B+=lu(k);break;case 41:b--,B+=")";break;case 34:case 39:case 91:B+=lu(k);break;case 9:case 10:case 13:case 32:if(b>0){B+=qo(k);break}B+=D9(m);break;case 92:B+=O9(Sl()-1,7);continue;case 47:switch(Rn()){case 42:case 47:Za(W9(R9(Vr(),Sl()),e,r,l),l),(oa(m||1)==5||oa(Rn()||1)==5)&&rn(B)&&Rs(B,-1,void 0)!==" "&&(B+=" ");break;default:B+="/"}break;case 123*x:a[c++]=rn(B)*y;case 125*x:case 59:case 0:if(b>0&&k){B+=qo(k);break}switch(k){case 0:case 125:g=0;case 59+u:y==-1&&(B=Od(B,/\f/g,"")),f>0&&(rn(B)-d||x===0)&&Za(f>32?Gx(B+";",n,r,d-1,l):Gx(Od(B," ","")+";",n,r,d-2,l),l);break;case 59:B+=";";default:if(Za(E=Ux(B,e,r,c,u,i,a,T,_=[],w=[],d,s),s),k===123)if(u===0)Tl(B,e,E,E,_,s,d,a,w);else{switch(p){case 99:if(us(B,3)===110)break;case 108:if(us(B,2)===97)break;default:u=0;case 100:case 109:case 115:}u?Tl(t,E,E,n&&Za(Ux(t,E,E,0,0,i,a,T,i,_=[],d,w),w),i,w,d,a,n?_:w):Tl(B,E,E,E,[""],w,0,a,w)}}c=u=f=0,x=y=1,T=B="",d=o;break;case 58:d=1+rn(B),f=m;default:if(x<1){if(k==123)--x;else if(k==125&&x++==0&&I9()==125)continue}switch(B+=qo(k),k*x){case 38:y=u>0?1:(B+="\f",-1);break;case 44:if(b>0)break;a[c++]=(rn(B)-1)*y,y=1;break;case 64:Rn()===45&&(B+=lu(Vr())),p=Rn(),u=d=rn(T=B+=$9(Sl())),k++;break;case 45:m===45&&rn(B)==2&&(x=0)}}return s}function Ux(t,e,r,n,i,s,o,a,l,c,u,d){for(var p=i-1,f=i===0?s:[""],m=H2(f),x=0,g=0,y=0;x<n;++x)for(var b=0,k=Rs(t,p+1,p=A9(g=o[x])),T=t;b<m;++b)(T=q2(g>0?f[b]+" "+k:Od(k,/&\f/g,f[b])))&&(l[y++]=T);return Pp(t,e,r,i===0?$2:a,l,c,u,d)}function W9(t,e,r,n){return Pp(t,e,r,Fp,qo(M9()),Rs(t,2,-2),0,n)}function Gx(t,e,r,n,i){return Pp(t,e,r,z2,Rs(t,0,n),Rs(t,n+1,-1),n,i)}function $d(t,e){for(var r="",n=0;n<t.length;n++)r+=e(t[n],n,t,e)||"";return r}function q9(t,e,r,n){switch(t.type){case W2:if(t.children.length)break;case N9:case L9:case z2:return t.return=t.return||t.value;case Fp:return"";case Dd:return t.return=t.value+"{"+$d(t.children,n)+"}";case $2:if(!rn(t.value=t.props.join(",")))return""}return rn(r=$d(t.children,n))?t.return=t.value+"{"+r+"}":""}function H9(t){var e=H2(t);return function(r,n,i,s){for(var o="",a=0;a<e;a++)o+=t[a](r,n,i,s)||"";return o}}var G2="c4",U9=v(t=>/^\s*C4Context|C4Container|C4Component|C4Dynamic|C4Deployment/.test(t),"detector"),G9=v(async()=>{const{diagram:t}=await Qt(async()=>{const{diagram:e}=await import("./c4Diagram-AAUBKEIU-CWZPV6Gi.js");return{diagram:e}},__vite__mapDeps([9,10,3,4,5,6,7]));return{id:G2,diagram:t}},"loader"),V9={id:G2,detector:U9,loader:G9},Y9=V9,V2="flowchart",X9=v((t,e)=>{var r,n;return((r=e==null?void 0:e.flowchart)==null?void 0:r.defaultRenderer)==="dagre-wrapper"||((n=e==null?void 0:e.flowchart)==null?void 0:n.defaultRenderer)==="elk"?!1:/^\s*graph/.test(t)},"detector"),K9=v(async()=>{const{diagram:t}=await Qt(async()=>{const{diagram:e}=await import("./flowDiagram-I6XJVG4X-CSEQ9sFL.js");return{diagram:e}},__vite__mapDeps([11,12,10,13,14,15,3,4,5,6,7]));return{id:V2,diagram:t}},"loader"),Z9={id:V2,detector:X9,loader:K9},Q9=Z9,Y2="flowchart-v2",J9=v((t,e)=>{var r,n,i;return((r=e==null?void 0:e.flowchart)==null?void 0:r.defaultRenderer)==="dagre-d3"?!1:(((n=e==null?void 0:e.flowchart)==null?void 0:n.defaultRenderer)==="elk"&&(e.layout="elk"),/^\s*graph/.test(t)&&((i=e==null?void 0:e.flowchart)==null?void 0:i.defaultRenderer)==="dagre-wrapper"?!0:/^\s*flowchart/.test(t))},"detector"),t7=v(async()=>{const{diagram:t}=await Qt(async()=>{const{diagram:e}=await import("./flowDiagram-I6XJVG4X-CSEQ9sFL.js");return{diagram:e}},__vite__mapDeps([11,12,10,13,14,15,3,4,5,6,7]));return{id:Y2,diagram:t}},"loader"),e7={id:Y2,detector:J9,loader:t7},r7=e7,X2="er",n7=v(t=>/^\s*erDiagram/.test(t),"detector"),i7=v(async()=>{const{diagram:t}=await Qt(async()=>{const{diagram:e}=await import("./erDiagram-TEJ5UH35-BDTpNyUZ.js");return{diagram:e}},__vite__mapDeps([16,13,14,15,3,4,5,6,7]));return{id:X2,diagram:t}},"loader"),s7={id:X2,detector:n7,loader:i7},o7=s7,K2="gitGraph",a7=v(t=>/^\s*gitGraph/.test(t),"detector"),l7=v(async()=>{const{diagram:t}=await Qt(async()=>{const{diagram:e}=await import("./gitGraphDiagram-PVQCEYII-BmIOl3oN.js");return{diagram:e}},__vite__mapDeps([17,18,19,20,5,3,4,6,7]));return{id:K2,diagram:t}},"loader"),c7={id:K2,detector:a7,loader:l7},h7=c7,Z2="gantt",u7=v(t=>/^\s*gantt/.test(t),"detector"),d7=v(async()=>{const{diagram:t}=await Qt(async()=>{const{diagram:e}=await import("./ganttDiagram-6RSMTGT7-CJI3ZQCl.js");return{diagram:e}},__vite__mapDeps([21,3,4,22,23,24,5,6,7]));return{id:Z2,diagram:t}},"loader"),f7={id:Z2,detector:u7,loader:d7},p7=f7,Q2="info",m7=v(t=>/^\s*info/.test(t),"detector"),g7=v(async()=>{const{diagram:t}=await Qt(async()=>{const{diagram:e}=await import("./infoDiagram-5YYISTIA-BiJXa7xo.js");return{diagram:e}},__vite__mapDeps([25,20,5,3,4,6,7]));return{id:Q2,diagram:t}},"loader"),x7={id:Q2,detector:m7,loader:g7},J2="pie",y7=v(t=>/^\s*pie/.test(t),"detector"),b7=v(async()=>{const{diagram:t}=await Qt(async()=>{const{diagram:e}=await import("./pieDiagram-4H26LBE5-BGGc2f7U.js");return{diagram:e}},__vite__mapDeps([26,18,20,5,3,4,6,27,28,23,7]));return{id:J2,diagram:t}},"loader"),C7={id:J2,detector:y7,loader:b7},tS="quadrantChart",k7=v(t=>/^\s*quadrantChart/.test(t),"detector"),v7=v(async()=>{const{diagram:t}=await Qt(async()=>{const{diagram:e}=await import("./quadrantDiagram-W4KKPZXB-DN8kBgF9.js");return{diagram:e}},__vite__mapDeps([29,22,23,24,3,4,5,6,7]));return{id:tS,diagram:t}},"loader"),w7={id:tS,detector:k7,loader:v7},S7=w7,eS="xychart",T7=v(t=>/^\s*xychart(-beta)?/.test(t),"detector"),_7=v(async()=>{const{diagram:t}=await Qt(async()=>{const{diagram:e}=await import("./xychartDiagram-2RQKCTM6-Cpcj31O3.js");return{diagram:e}},__vite__mapDeps([30,23,28,22,24,3,4,5,6,7]));return{id:eS,diagram:t}},"loader"),E7={id:eS,detector:T7,loader:_7},N7=E7,rS="requirement",j7=v(t=>/^\s*requirement(Diagram)?/.test(t),"detector"),L7=v(async()=>{const{diagram:t}=await Qt(async()=>{const{diagram:e}=await import("./requirementDiagram-4Y6WPE33-CqTXzyF-.js");return{diagram:e}},__vite__mapDeps([31,13,14,3,4,5,6,7]));return{id:rS,diagram:t}},"loader"),B7={id:rS,detector:j7,loader:L7},A7=B7,nS="sequence",M7=v(t=>/^\s*sequenceDiagram/.test(t),"detector"),I7=v(async()=>{const{diagram:t}=await Qt(async()=>{const{diagram:e}=await import("./sequenceDiagram-3UESZ5HK-B5mMGwpr.js");return{diagram:e}},__vite__mapDeps([32,10,19,3,4,5,6,7]));return{id:nS,diagram:t}},"loader"),F7={id:nS,detector:M7,loader:I7},P7=F7,iS="class",D7=v((t,e)=>{var r;return((r=e==null?void 0:e.class)==null?void 0:r.defaultRenderer)==="dagre-wrapper"?!1:/^\s*classDiagram/.test(t)},"detector"),O7=v(async()=>{const{diagram:t}=await Qt(async()=>{const{diagram:e}=await import("./classDiagram-4FO5ZUOK-DV6SPGMl.js");return{diagram:e}},__vite__mapDeps([33,34,12,10,13,14,3,4,5,6,7]));return{id:iS,diagram:t}},"loader"),R7={id:iS,detector:D7,loader:O7},$7=R7,sS="classDiagram",z7=v((t,e)=>{var r;return/^\s*classDiagram/.test(t)&&((r=e==null?void 0:e.class)==null?void 0:r.defaultRenderer)==="dagre-wrapper"?!0:/^\s*classDiagram-v2/.test(t)},"detector"),W7=v(async()=>{const{diagram:t}=await Qt(async()=>{const{diagram:e}=await import("./classDiagram-v2-Q7XG4LA2-DV6SPGMl.js");return{diagram:e}},__vite__mapDeps([35,34,12,10,13,14,3,4,5,6,7]));return{id:sS,diagram:t}},"loader"),q7={id:sS,detector:z7,loader:W7},H7=q7,oS="state",U7=v((t,e)=>{var r;return((r=e==null?void 0:e.state)==null?void 0:r.defaultRenderer)==="dagre-wrapper"?!1:/^\s*stateDiagram/.test(t)},"detector"),G7=v(async()=>{const{diagram:t}=await Qt(async()=>{const{diagram:e}=await import("./stateDiagram-AJRCARHV-B8yZRkdR.js");return{diagram:e}},__vite__mapDeps([36,37,13,14,1,2,3,4,5,6,7]));return{id:oS,diagram:t}},"loader"),V7={id:oS,detector:U7,loader:G7},Y7=V7,aS="stateDiagram",X7=v((t,e)=>{var r;return!!(/^\s*stateDiagram-v2/.test(t)||/^\s*stateDiagram/.test(t)&&((r=e==null?void 0:e.state)==null?void 0:r.defaultRenderer)==="dagre-wrapper")},"detector"),K7=v(async()=>{const{diagram:t}=await Qt(async()=>{const{diagram:e}=await import("./stateDiagram-v2-BHNVJYJU-BK-1uf4O.js");return{diagram:e}},__vite__mapDeps([38,37,13,14,3,4,5,6,7]));return{id:aS,diagram:t}},"loader"),Z7={id:aS,detector:X7,loader:K7},Q7=Z7,lS="journey",J7=v(t=>/^\s*journey/.test(t),"detector"),tW=v(async()=>{const{diagram:t}=await Qt(async()=>{const{diagram:e}=await import("./journeyDiagram-JHISSGLW-Dk6NJYdI.js");return{diagram:e}},__vite__mapDeps([39,12,10,27,3,4,5,6,7]));return{id:lS,diagram:t}},"loader"),eW={id:lS,detector:J7,loader:tW},rW=eW,nW=v((t,e,r)=>{Q.debug(`rendering svg for syntax error
|
|
640
|
+
`);const n=RR(e),i=n.append("g");n.attr("viewBox","0 0 2412 512"),R1(n,100,512,!0),i.append("path").attr("class","error-icon").attr("d","m411.313,123.313c6.25-6.25 6.25-16.375 0-22.625s-16.375-6.25-22.625,0l-32,32-9.375,9.375-20.688-20.688c-12.484-12.5-32.766-12.5-45.25,0l-16,16c-1.261,1.261-2.304,2.648-3.31,4.051-21.739-8.561-45.324-13.426-70.065-13.426-105.867,0-192,86.133-192,192s86.133,192 192,192 192-86.133 192-192c0-24.741-4.864-48.327-13.426-70.065 1.402-1.007 2.79-2.049 4.051-3.31l16-16c12.5-12.492 12.5-32.758 0-45.25l-20.688-20.688 9.375-9.375 32.001-31.999zm-219.313,100.687c-52.938,0-96,43.063-96,96 0,8.836-7.164,16-16,16s-16-7.164-16-16c0-70.578 57.422-128 128-128 8.836,0 16,7.164 16,16s-7.164,16-16,16z"),i.append("path").attr("class","error-icon").attr("d","m459.02,148.98c-6.25-6.25-16.375-6.25-22.625,0s-6.25,16.375 0,22.625l16,16c3.125,3.125 7.219,4.688 11.313,4.688 4.094,0 8.188-1.563 11.313-4.688 6.25-6.25 6.25-16.375 0-22.625l-16.001-16z"),i.append("path").attr("class","error-icon").attr("d","m340.395,75.605c3.125,3.125 7.219,4.688 11.313,4.688 4.094,0 8.188-1.563 11.313-4.688 6.25-6.25 6.25-16.375 0-22.625l-16-16c-6.25-6.25-16.375-6.25-22.625,0s-6.25,16.375 0,22.625l15.999,16z"),i.append("path").attr("class","error-icon").attr("d","m400,64c8.844,0 16-7.164 16-16v-32c0-8.836-7.156-16-16-16-8.844,0-16,7.164-16,16v32c0,8.836 7.156,16 16,16z"),i.append("path").attr("class","error-icon").attr("d","m496,96.586h-32c-8.844,0-16,7.164-16,16 0,8.836 7.156,16 16,16h32c8.844,0 16-7.164 16-16 0-8.836-7.156-16-16-16z"),i.append("path").attr("class","error-icon").attr("d","m436.98,75.605c3.125,3.125 7.219,4.688 11.313,4.688 4.094,0 8.188-1.563 11.313-4.688l32-32c6.25-6.25 6.25-16.375 0-22.625s-16.375-6.25-22.625,0l-32,32c-6.251,6.25-6.251,16.375-0.001,22.625z"),i.append("text").attr("class","error-text").attr("x",1440).attr("y",250).attr("font-size","150px").style("text-anchor","middle").text("Syntax error in text"),i.append("text").attr("class","error-text").attr("x",1250).attr("y",400).attr("font-size","100px").style("text-anchor","middle").text(`mermaid version ${r}`)},"draw"),cS={draw:nW},iW=cS,sW={db:{},renderer:cS,parser:{parse:v(()=>{},"parse")}},oW=sW,hS="flowchart-elk",aW=v((t,e={})=>{var r;return/^\s*flowchart-elk/.test(t)||/^\s*(flowchart|graph)/.test(t)&&((r=e==null?void 0:e.flowchart)==null?void 0:r.defaultRenderer)==="elk"?(e.layout="elk",!0):!1},"detector"),lW=v(async()=>{const{diagram:t}=await Qt(async()=>{const{diagram:e}=await import("./flowDiagram-I6XJVG4X-CSEQ9sFL.js");return{diagram:e}},__vite__mapDeps([11,12,10,13,14,15,3,4,5,6,7]));return{id:hS,diagram:t}},"loader"),cW={id:hS,detector:aW,loader:lW},hW=cW,uS="timeline",uW=v(t=>/^\s*timeline/.test(t),"detector"),dW=v(async()=>{const{diagram:t}=await Qt(async()=>{const{diagram:e}=await import("./timeline-definition-PNZ67QCA-uc4a9RNG.js");return{diagram:e}},__vite__mapDeps([40,27,3,4,5,6,7]));return{id:uS,diagram:t}},"loader"),fW={id:uS,detector:uW,loader:dW},pW=fW,dS="mindmap",mW=v(t=>/^\s*mindmap/.test(t),"detector"),gW=v(async()=>{const{diagram:t}=await Qt(async()=>{const{diagram:e}=await import("./mindmap-definition-RKZ34NQL-lzCtbkrz.js");return{diagram:e}},__vite__mapDeps([41,13,14,3,4,5,6,7]));return{id:dS,diagram:t}},"loader"),xW={id:dS,detector:mW,loader:gW},yW=xW,fS="kanban",bW=v(t=>/^\s*kanban/.test(t),"detector"),CW=v(async()=>{const{diagram:t}=await Qt(async()=>{const{diagram:e}=await import("./kanban-definition-UN3LZRKU-DrTme_f5.js");return{diagram:e}},__vite__mapDeps([42,12,3,4,5,6,7]));return{id:fS,diagram:t}},"loader"),kW={id:fS,detector:bW,loader:CW},vW=kW,pS="sankey",wW=v(t=>/^\s*sankey(-beta)?/.test(t),"detector"),SW=v(async()=>{const{diagram:t}=await Qt(async()=>{const{diagram:e}=await import("./sankeyDiagram-5OEKKPKP-l5oIrkxp.js");return{diagram:e}},__vite__mapDeps([43,28,23,3,4,5,6,7]));return{id:pS,diagram:t}},"loader"),TW={id:pS,detector:wW,loader:SW},_W=TW,mS="packet",EW=v(t=>/^\s*packet(-beta)?/.test(t),"detector"),NW=v(async()=>{const{diagram:t}=await Qt(async()=>{const{diagram:e}=await import("./diagram-LMA3HP47-CCyEuSkM.js");return{diagram:e}},__vite__mapDeps([44,18,20,5,3,4,6,7]));return{id:mS,diagram:t}},"loader"),jW={id:mS,detector:EW,loader:NW},gS="radar",LW=v(t=>/^\s*radar-beta/.test(t),"detector"),BW=v(async()=>{const{diagram:t}=await Qt(async()=>{const{diagram:e}=await import("./diagram-2AECGRRQ-DhPeu8mD.js");return{diagram:e}},__vite__mapDeps([45,18,20,5,3,4,6,7]));return{id:gS,diagram:t}},"loader"),AW={id:gS,detector:LW,loader:BW},xS="block",MW=v(t=>/^\s*block(-beta)?/.test(t),"detector"),IW=v(async()=>{const{diagram:t}=await Qt(async()=>{const{diagram:e}=await import("./blockDiagram-GPEHLZMM-DfiOIWI5.js");return{diagram:e}},__vite__mapDeps([46,12,1,15,3,4,5,6,7]));return{id:xS,diagram:t}},"loader"),FW={id:xS,detector:MW,loader:IW},PW=FW,yS="treeView",DW=v(t=>/^\s*treeView-beta/.test(t),"detector"),OW=v(async()=>{const{diagram:t}=await Qt(async()=>{const{diagram:e}=await import("./diagram-5GNKFQAL-B8e2ppCQ.js");return{diagram:e}},__vite__mapDeps([47,18,19,20,5,3,4,6,7]));return{id:yS,diagram:t}},"loader"),RW={id:yS,detector:DW,loader:OW},$W=RW,bS="architecture",zW=v(t=>/^\s*architecture/.test(t),"detector"),WW=v(async()=>{const{diagram:t}=await Qt(async()=>{const{diagram:e}=await import("./architectureDiagram-3BPJPVTR-Dr1TLm4n.js");return{diagram:e}},__vite__mapDeps([48,18,20,5,3,4,6,7]));return{id:bS,diagram:t}},"loader"),qW={id:bS,detector:zW,loader:WW},HW=qW,CS="eventmodeling",UW=v(t=>/^\s*eventmodeling/.test(t),"detector"),GW=v(async()=>{const{diagram:t}=await Qt(async()=>{const{diagram:e}=await import("./diagram-KO2AKTUF-CJ2bkC5P.js");return{diagram:e}},__vite__mapDeps([49,18,20,5,3,4,6,7]));return{id:CS,diagram:t}},"loader"),VW={id:CS,detector:UW,loader:GW},YW=VW,kS="ishikawa",XW=v(t=>/^\s*ishikawa(-beta)?\b/i.test(t),"detector"),KW=v(async()=>{const{diagram:t}=await Qt(async()=>{const{diagram:e}=await import("./ishikawaDiagram-YF4QCWOH-D2S-R9bH.js");return{diagram:e}},__vite__mapDeps([50,3,4,5,6,7]));return{id:kS,diagram:t}},"loader"),ZW={id:kS,detector:XW,loader:KW},vS="venn",QW=v(t=>/^\s*venn-beta/.test(t),"detector"),JW=v(async()=>{const{diagram:t}=await Qt(async()=>{const{diagram:e}=await import("./vennDiagram-CIIHVFJN-Dxp9IL4U.js");return{diagram:e}},__vite__mapDeps([51,3,4,5,6,7]));return{id:vS,diagram:t}},"loader"),tq={id:vS,detector:QW,loader:JW},eq=tq,wS="treemap",rq=v(t=>/^\s*treemap/.test(t),"detector"),nq=v(async()=>{const{diagram:t}=await Qt(async()=>{const{diagram:e}=await import("./diagram-OG6HWLK6-CDe7c8Ym.js");return{diagram:e}},__vite__mapDeps([52,14,18,20,5,3,4,6,24,28,23,7]));return{id:wS,diagram:t}},"loader"),iq={id:wS,detector:rq,loader:nq},SS="wardley-beta",sq=v(t=>/^\s*wardley-beta/i.test(t),"detector"),oq=v(async()=>{const{diagram:t}=await Qt(async()=>{const{diagram:e}=await import("./wardleyDiagram-YWT4CUSO-DWpWWd1b.js");return{diagram:e}},__vite__mapDeps([53,18,20,5,3,4,6,7]));return{id:SS,diagram:t}},"loader"),aq={id:SS,detector:sq,loader:oq},lq=aq,Vx=!1,rh=v(()=>{Vx||(Vx=!0,Vl("error",oW,t=>t.toLowerCase().trim()==="error"),Vl("---",{db:{clear:v(()=>{},"clear")},styles:{},renderer:{draw:v(()=>{},"draw")},parser:{parse:v(()=>{throw new Error("Diagrams beginning with --- are not valid. If you were trying to use a YAML front-matter, please ensure that you've correctly opened and closed the YAML front-matter with un-indented `---` blocks")},"parse")},init:v(()=>null,"init")},t=>t.toLowerCase().trimStart().startsWith("---")),Uu(hW,yW,HW),Uu(Y9,vW,H7,$7,o7,p7,x7,C7,A7,P7,r7,Q9,pW,h7,Q7,Y7,rW,S7,_W,jW,N7,PW,YW,$W,AW,ZW,iq,eq,lq))},"addDiagrams"),cq=v(async()=>{Q.debug("Loading registered diagrams");const e=(await Promise.allSettled(Object.entries(yi).map(async([r,{detector:n,loader:i}])=>{if(i)try{Ku(r)}catch{try{const{diagram:s,id:o}=await i();Vl(o,s,n)}catch(s){throw Q.error(`Failed to load external diagram with key ${r}. Removing from detectors.`),delete yi[r],s}}}))).filter(r=>r.status==="rejected");if(e.length>0){Q.error(`Failed to load ${e.length} external diagrams`);for(const r of e)Q.error(r);throw new Error(`Failed to load ${e.length} external diagrams`)}},"loadRegisteredDiagrams"),hq="graphics-document document";function TS(t,e){t.attr("role",hq),e!==""&&t.attr("aria-roledescription",e)}v(TS,"setA11yDiagramInfo");function _S(t,e,r,n){if(t.insert!==void 0){if(r){const i=`chart-desc-${n}`;t.attr("aria-describedby",i),t.insert("desc",":first-child").attr("id",i).text(r)}if(e){const i=`chart-title-${n}`;t.attr("aria-labelledby",i),t.insert("title",":first-child").attr("id",i).text(e)}}}v(_S,"addSVGa11yTitleDescription");var mi,zd=(mi=class{constructor(e,r,n,i,s){this.type=e,this.text=r,this.db=n,this.parser=i,this.renderer=s}static async fromText(e,r={}){var c,u;const n=me(),i=Of(e,n);e=W6(e)+`
|
|
641
641
|
`;try{Ku(i)}catch{const d=s4(i);if(!d)throw new S1(`Diagram ${i} not found.`);const{id:p,diagram:f}=await d();Vl(p,f)}const{db:s,parser:o,renderer:a,init:l}=Ku(i);return o.parser&&(o.parser.yy=s),(c=s.clear)==null||c.call(s),l==null||l(n),r.title&&((u=s.setDiagramTitle)==null||u.call(s,r.title)),await o.parse(e),new mi(i,e,s,o,a)}async render(e,r){await this.renderer.draw(this.text,e,r,this)}getParser(){return this.parser}getType(){return this.type}},v(mi,"Diagram"),mi),Yx=[],uq=v(()=>{Yx.forEach(t=>{t()}),Yx=[]},"attachFunctions"),dq=v(t=>t.replace(/^\s*%%(?!{)[^\n]+\n?/gm,"").trimStart(),"cleanupComments");function ES(t){const e=t.match(w1);if(!e)return{text:t,metadata:{}};let r=G$(e[1],{schema:U$})??{};r=typeof r=="object"&&!Array.isArray(r)?r:{};const n={};return r.displayMode&&(n.displayMode=r.displayMode.toString()),r.title&&(n.title=r.title.toString()),r.config&&(n.config=r.config),{text:t.slice(e[0].length),metadata:n}}v(ES,"extractFrontMatter");var fq=v(t=>t.replace(/\r\n?/g,`
|
|
642
642
|
`).replace(/<(\w+)([^>]*)>/g,(e,r,n)=>"<"+r+n.replace(/="([^"]*)"/g,"='$1'")+">"),"cleanupText"),pq=v(t=>{const{text:e,metadata:r}=ES(t),{displayMode:n,title:i,config:s={}}=r;return n&&(s.gantt||(s.gantt={}),s.gantt.displayMode=n),{title:i,config:s,text:e}},"processFrontmatter"),mq=v(t=>{const e=Hr.detectInit(t)??{},r=Hr.detectDirective(t,"wrap");return Array.isArray(r)?e.wrap=r.some(({type:n})=>n==="wrap"):(r==null?void 0:r.type)==="wrap"&&(e.wrap=!0),{text:j6(t),directive:e}},"processDirectives");function Dp(t){const e=fq(t),r=pq(e),n=mq(r.text),i=bp(r.config,n.directive);return t=dq(n.text),{code:t,title:r.title,config:i}}v(Dp,"preprocessDiagram");function NS(t){const e=new TextEncoder().encode(t),r=Array.from(e,n=>String.fromCodePoint(n)).join("");return btoa(r)}v(NS,"toBase64");var gq=5e4,xq="graph TB;a[Maximum text size in diagram exceeded];style a fill:#faa",yq="sandbox",bq="loose",Cq="http://www.w3.org/2000/svg",kq="http://www.w3.org/1999/xlink",vq="http://www.w3.org/1999/xhtml",wq="100%",Sq="100%",Tq="border:0;margin:0;",_q="margin:0",Eq="allow-top-navigation-by-user-activation allow-popups",Nq='The "iframe" tag is not supported by your browser.',jq=["foreignobject"],Lq=["dominant-baseline"];function Op(t){const e=Dp(t);return Ul(),A4(e.config??{}),e}v(Op,"processAndSetConfigs");async function jS(t,e){rh();try{const{code:r,config:n}=Op(t);return{diagramType:(await BS(r)).type,config:n}}catch(r){if(e!=null&&e.suppressErrors)return!1;throw r}}v(jS,"parse");var Xx=v((t,e,r=[])=>{const n=j1(`{ ${r.join(" !important; ")} !important; }`);return`.${t} ${e} ${n}`},"cssImportantStyles"),Bq=v((t,e=new Map)=>{const r=new CSSStyleSheet;if(t.fontFamily!==void 0&&r.insertRule(`:root { --mermaid-font-family: ${t.fontFamily}}`,r.cssRules.length),t.altFontFamily!==void 0&&r.insertRule(`:root { --mermaid-alt-font-family: ${t.altFontFamily}}`,r.cssRules.length),e instanceof Map){const a=or(t)?["> *","span"]:["rect","polygon","ellipse","circle","path"];e.forEach(l=>{cx(l.styles)||a.forEach(c=>{r.insertRule(Xx(l.id,c,l.styles),r.cssRules.length)}),cx(l.textStyles)||r.insertRule(Xx(l.id,"tspan",((l==null?void 0:l.textStyles)||[]).map(c=>c.replace("color","fill"))),r.cssRules.length)})}let n="";if(t.themeCSS!==void 0)if(typeof r.replaceSync=="function"){const i=new CSSStyleSheet;i.replaceSync(t.themeCSS),n=Xu(i)+`
|
|
643
643
|
`}else n+=`${t.themeCSS}
|
|
@@ -714,7 +714,7 @@ Description: ${t.description}`:"",g=["Challenge the assumptions of this item and
|
|
|
714
714
|
|
|
715
715
|
If you want to hide the \`${e.titleName}\`, you can wrap it with our VisuallyHidden component.
|
|
716
716
|
|
|
717
|
-
For more information, see https://radix-ui.com/primitives/docs/components/${e.docsSlug}`;return C.useEffect(()=>{t&&(document.getElementById(t)||console.error(r))},[r,t]),null},lV="DialogDescriptionWarning",cV=({contentRef:t,descriptionId:e})=>{const n=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${AT(lV).contentName}}.`;return C.useEffect(()=>{var s;const i=(s=t.current)==null?void 0:s.getAttribute("aria-describedby");e&&i&&(document.getElementById(e)||console.warn(n))},[n,t,e]),null},hV=bT,uV=vT,MT=wT,IT=ST,FT=_T,PT=NT,dV=LT;const qp=hV,fV=uV,DT=C.forwardRef(({className:t,...e},r)=>h.jsx(MT,{ref:r,className:rt("fixed inset-0 z-50 bg-black/60 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",t),...e}));DT.displayName=MT.displayName;const sh=C.forwardRef(({className:t,children:e,...r},n)=>h.jsxs(fV,{children:[h.jsx(DT,{}),h.jsxs(IT,{ref:n,className:rt("fixed left-[50%] top-[50%] z-50 translate-x-[-50%] translate-y-[-50%]","w-full max-w-lg rounded-lg border border-slate-700 bg-card shadow-xl","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","data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%]","data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%]",t),...r,children:[e,h.jsxs(dV,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground",children:[h.jsx(cn,{className:"h-4 w-4"}),h.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));sh.displayName=IT.displayName;const oh=({className:t,...e})=>h.jsx("div",{className:rt("flex flex-col space-y-1.5 p-6 pb-4",t),...e});oh.displayName="DialogHeader";const Hp=({className:t,...e})=>h.jsx("div",{className:rt("flex items-center justify-end gap-2 p-6 pt-4",t),...e});Hp.displayName="DialogFooter";const ah=C.forwardRef(({className:t,...e},r)=>h.jsx(FT,{ref:r,className:rt("text-sm font-semibold text-foreground leading-none tracking-tight",t),...e}));ah.displayName=FT.displayName;const pV=C.forwardRef(({className:t,...e},r)=>h.jsx(PT,{ref:r,className:rt("text-sm text-muted-foreground",t),...e}));pV.displayName=PT.displayName;const k0=[{id:"task",label:"Task",defaults:{type:"task",phase:"planning",priority:1,governance:"flag"}},{id:"decision",label:"Decision",defaults:{type:"decision",phase:"specification",priority:2,governance:"gate"}},{id:"question",label:"Question",defaults:{type:"question",phase:"specification",priority:1,governance:"flag"}},{id:"idea",label:"Idea",defaults:{type:"idea",phase:"vision",priority:0,governance:"skip"}},{id:"spec",label:"Spec",defaults:{type:"spec",phase:"specification",priority:2,governance:"gate"}}],mV=["gate","flag","skip"];function v0(t){return{type:"task",title:"",description:"",phase:(t==null?void 0:t.phase)??"planning",priority:1,assignedTo:"unassigned",governance:"flag",featureCode:""}}function OT({open:t,onClose:e,parentItem:r}){const n=gr(b=>b.createItem),[i,s]=C.useState(()=>v0(r)),[o,a]=C.useState("task"),[l,c]=C.useState(!1),[u,d]=C.useState(!1),[p,f]=C.useState(""),m=C.useRef(null);C.useEffect(()=>{if(t){const b=v0(r);s(b),a("task"),c(!1),f(""),setTimeout(()=>{var k;return(k=m.current)==null?void 0:k.focus()},50)}},[t,r]);const x=b=>{const k=k0.find(T=>T.id===b);k&&(a(b),s(T=>({...T,type:k.defaults.type,phase:(r==null?void 0:r.phase)??k.defaults.phase,priority:k.defaults.priority,governance:k.defaults.governance})))},g=async()=>{if(!i.title.trim()){f("Title is required");return}d(!0),f("");try{const b={type:i.type,title:i.title.trim(),description:i.description.trim()||void 0,phase:i.phase||void 0,status:"planned",confidence:0,priority:i.priority,assignedTo:i.assignedTo!=="unassigned"?i.assignedTo:void 0,governance:i.governance!=="flag"?i.governance:void 0,featureCode:i.featureCode.trim()||void 0};await n(b),e()}catch{f("Failed to create item")}finally{d(!1)}},y=b=>{b.key==="Enter"&&!b.shiftKey&&b.target.tagName!=="TEXTAREA"&&(b.preventDefault(),g())};return h.jsx(qp,{open:t,onOpenChange:b=>!b&&e(),children:h.jsxs(sh,{className:"max-w-md",onKeyDown:y,children:[h.jsx(oh,{children:h.jsx(ah,{children:"New Item"})}),h.jsxs("div",{className:"px-6 pb-2 space-y-4",children:[h.jsx("div",{className:"grid grid-cols-5 gap-1.5",children:k0.map(b=>h.jsx("button",{type:"button",onClick:()=>x(b.id),className:rt("rounded-md px-2 py-1.5 text-[11px] font-medium border transition-colors",o===b.id?"bg-accent/10 border-accent/60 text-accent":"border-border/40 text-muted-foreground hover:border-border hover:text-foreground"),children:b.label},b.id))}),h.jsx("input",{ref:m,type:"text",placeholder:"Item title…",value:i.title,onChange:b=>s(k=>({...k,title:b.target.value})),className:"w-full text-sm bg-muted text-foreground px-3 py-2 rounded-md border border-border outline-none focus:border-ring"}),h.jsx("textarea",{placeholder:"Description (optional)…",value:i.description,onChange:b=>s(k=>({...k,description:b.target.value})),rows:2,className:"w-full text-sm bg-muted text-foreground px-3 py-2 rounded-md border border-border outline-none focus:border-ring resize-none"}),h.jsxs("button",{type:"button",onClick:()=>c(b=>!b),className:"flex items-center gap-1 text-[11px] text-muted-foreground hover:text-foreground transition-colors",children:[l?h.jsx(yb,{className:"h-3 w-3"}):h.jsx(fa,{className:"h-3 w-3"}),"Advanced"]}),l&&h.jsxs("div",{className:"space-y-3 border border-border/40 rounded-md p-3 bg-muted/20",children:[h.jsxs("label",{className:"flex flex-col gap-1",children:[h.jsx("span",{className:"text-[10px] text-muted-foreground uppercase tracking-wider",children:"Feature Code"}),h.jsx("input",{type:"text",placeholder:"e.g. COMP-UI-5",value:i.featureCode,onChange:b=>s(k=>({...k,featureCode:b.target.value})),className:"text-xs bg-muted text-foreground px-2 py-1 rounded border border-border outline-none"})]}),h.jsxs("label",{className:"flex flex-col gap-1",children:[h.jsx("span",{className:"text-[10px] text-muted-foreground uppercase tracking-wider",children:"Phase"}),h.jsx("select",{value:i.phase,onChange:b=>s(k=>({...k,phase:b.target.value})),className:"text-xs bg-muted text-foreground px-2 py-1 rounded border border-border cursor-pointer",children:ny.map(b=>h.jsx("option",{value:b,children:jl[b]??b},b))})]}),h.jsxs("label",{className:"flex flex-col gap-1",children:[h.jsx("span",{className:"text-[10px] text-muted-foreground uppercase tracking-wider",children:"Priority"}),h.jsxs("select",{value:i.priority,onChange:b=>s(k=>({...k,priority:Number(b.target.value)})),className:"text-xs bg-muted text-foreground px-2 py-1 rounded border border-border cursor-pointer",children:[h.jsx("option",{value:0,children:"Low (0)"}),h.jsx("option",{value:1,children:"Normal (1)"}),h.jsx("option",{value:2,children:"High (2)"}),h.jsx("option",{value:3,children:"Critical (3)"})]})]}),h.jsxs("label",{className:"flex flex-col gap-1",children:[h.jsx("span",{className:"text-[10px] text-muted-foreground uppercase tracking-wider",children:"Assign to"}),h.jsx("select",{value:i.assignedTo,onChange:b=>s(k=>({...k,assignedTo:b.target.value})),className:"text-xs bg-muted text-foreground px-2 py-1 rounded border border-border cursor-pointer",children:sy.map(b=>h.jsx("option",{value:b,children:b},b))})]}),h.jsxs("div",{className:"flex flex-col gap-1",children:[h.jsx("span",{className:"text-[10px] text-muted-foreground uppercase tracking-wider",children:"Governance"}),h.jsx("div",{className:"flex gap-1.5",children:mV.map(b=>h.jsx("button",{type:"button",onClick:()=>s(k=>({...k,governance:b})),className:rt("flex-1 text-[11px] px-2 py-1 rounded border transition-colors",i.governance===b?b==="gate"?"bg-amber-500/20 text-amber-300 border-amber-500/40":b==="flag"?"bg-blue-500/20 text-blue-300 border-blue-500/40":"bg-slate-700 text-slate-400 border-slate-600":"border-border/40 text-muted-foreground hover:border-border"),children:b},b))})]})]}),p&&h.jsx("p",{className:"text-xs text-destructive",children:p})]}),h.jsxs(Hp,{children:[h.jsx($t,{variant:"ghost",size:"sm",onClick:e,disabled:u,children:"Cancel"}),h.jsx($t,{size:"sm",onClick:g,disabled:u||!i.title.trim(),children:u?"Creating…":"Create"})]})]})})}const gV=["explore_design","prd","architecture","blueprint","verification","plan","execute","report","docs","ship"],xV=[{id:"gate",Icon:qs,label:"Gate",active:"bg-amber-500/20 text-amber-300 border-amber-500/40"},{id:"flag",Icon:kb,label:"Flag",active:"bg-blue-500/20 text-blue-300 border-blue-500/40"},{id:"skip",Icon:_b,label:"Skip",active:"bg-slate-700 text-slate-400 border-slate-600"}];function yV(t,e){var r,n;return((n=(r=t==null?void 0:t.governance)==null?void 0:r.phases)==null?void 0:n[e])??"flag"}function RT({open:t,onClose:e,settings:r,onSettingsChange:n}){const[i,s]=C.useState(!1),o=C.useRef(null),a=C.useCallback((l,c)=>{n==null||n({governance:{phases:{[l]:c}}}),clearTimeout(o.current),s(!0),o.current=setTimeout(()=>s(!1),1500)},[n]);return h.jsx(qp,{open:t,onOpenChange:l=>!l&&e(),children:h.jsxs(sh,{className:"max-w-sm",children:[h.jsx(oh,{children:h.jsxs("div",{className:"flex items-center justify-between pr-6",children:[h.jsx(ah,{children:"Governance Settings"}),i&&h.jsx("span",{className:"text-[11px] text-emerald-400 font-medium",children:"Saved ✓"})]})}),h.jsx("div",{className:"px-6 pb-6 space-y-1 max-h-96 overflow-y-auto",children:gV.map(l=>{const c=l==="explore_design",u=yV(r,l),d=ve[l]??l;return h.jsxs("div",{className:rt("flex items-center gap-3 rounded-md px-2 py-1.5",c&&"opacity-40"),children:[h.jsx("span",{className:rt("text-xs flex-1 min-w-0 truncate",c?"text-muted-foreground":"text-foreground"),children:d}),c?h.jsx("span",{className:"text-[10px] text-muted-foreground italic",children:"no policy"}):h.jsx("div",{className:"flex gap-1 shrink-0",children:xV.map(p=>{const f=u===p.id,{Icon:m}=p;return h.jsxs("button",{onClick:()=>a(l,p.id),title:p.label,className:rt("flex items-center gap-1 px-2 py-0.5 text-[10px] rounded border transition-colors",f?p.active:"border-border/30 text-muted-foreground hover:border-border hover:text-foreground"),children:[h.jsx(m,{className:"h-2.5 w-2.5"}),p.label]},p.id)})})]},l)})}),h.jsx("div",{className:"px-6 pb-4 text-[10px] text-muted-foreground border-t border-border/30 pt-3",children:"Agent config via Compose CLI"})]})})}function $T({onOpenGate:t}){const{gates:e,items:r}=gr(Li(g=>({gates:g.gates,items:g.items}))),[n,i]=C.useState(new Set),[s,o]=C.useState(0),a=e.filter(g=>g.status==="pending"&&!n.has(g.id));if(a.length===0)return null;const l=Math.min(s,a.length-1),c=a[l],u=r.find(g=>g.id===c.itemId)||r.find(g=>{var y;return((y=g.lifecycle)==null?void 0:y.featureCode)&&c.featureCode&&g.lifecycle.featureCode===c.featureCode}),d=Go(c,u),p=C_[c.fromPhase]??k_,f=()=>{i(g=>new Set([...g,c.id])),l>=a.length-1&&l>0&&o(l-1)},m=()=>o(Math.max(0,l-1)),x=()=>o(Math.min(a.length-1,l+1));return h.jsxs("div",{className:rt("shrink-0 h-10 border-t flex items-center gap-2 px-3",p.bg,p.border),children:[h.jsx(qs,{className:rt("h-3.5 w-3.5 shrink-0",p.text)}),h.jsx("span",{className:rt("text-[11px] font-medium truncate flex-1 min-w-0",p.text),children:d}),a.length>1&&h.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[h.jsx("button",{onClick:m,disabled:l===0,className:"p-0.5 rounded hover:bg-muted/50 disabled:opacity-30 transition-colors",children:h.jsx(xb,{className:"h-3 w-3"})}),h.jsxs("span",{className:"text-[10px] text-muted-foreground tabular-nums",children:[l+1,"/",a.length]}),h.jsx("button",{onClick:x,disabled:l===a.length-1,className:"p-0.5 rounded hover:bg-muted/50 disabled:opacity-30 transition-colors",children:h.jsx(js,{className:"h-3 w-3"})})]}),h.jsx("button",{onClick:()=>t==null?void 0:t(c.id),className:rt("shrink-0 text-[10px] px-2 py-0.5 rounded border transition-colors hover:opacity-80",p.border,p.text),children:"Review"}),h.jsx("button",{onClick:f,className:"shrink-0 p-0.5 rounded hover:bg-muted/50 text-muted-foreground hover:text-foreground transition-colors",title:"Dismiss (page session only)",children:h.jsx(cn,{className:"h-3 w-3"})})]})}const bV="●",CV="text-zinc-400";function kV(t,e){if(!t)return"";const n=(e??Date.now())-new Date(t).getTime(),i=Math.floor(n/6e4);if(i<1)return"now";if(i<60)return`${i}m`;const s=Math.floor(i/60);return s<24?`${s}h`:`${Math.floor(s/24)}d`}function vV(t){var e;return((e=oy[t])==null?void 0:e.icon)??bV}function wV(t){var e;return((e=oy[t])==null?void 0:e.color)??CV}const SV={IMPLEMENTER:"bg-blue-500/15 text-blue-300 border border-blue-500/25",REVIEWER:"bg-emerald-500/15 text-emerald-300 border border-emerald-500/25",PRODUCER:"bg-purple-500/15 text-purple-300 border border-purple-500/25"};function TV(t){return SV[t]??"bg-zinc-500/15 text-zinc-300 border border-zinc-500/25"}function _V(t,e){return t.filter(r=>r.feature_code===e).slice().sort((r,n)=>r.timestamp.localeCompare(n.timestamp))}function EV(t){if(!t)return"";try{return new Date(t).toISOString().slice(11,16)}catch{return""}}function NV({event:t,now:e}){const r=vV(t.kind),n=wV(t.kind),i=kV(t.timestamp,e);return h.jsxs("div",{"data-decision-card":!0,className:"inline-flex flex-col gap-0.5 w-40 shrink-0 rounded border border-border/40 bg-muted/20 px-2 py-1.5 text-left",children:[h.jsxs("div",{className:"flex items-center justify-between gap-1",children:[h.jsx("span",{className:rt("text-[11px] shrink-0",n),children:r}),h.jsx("span",{className:"text-[10px] text-muted-foreground/50 tabular-nums",children:i||EV(t.timestamp)})]}),h.jsx("p",{className:"text-[11px] text-foreground/80 truncate leading-tight",children:t.title}),t.roles&&t.roles.length>0&&h.jsx("div",{className:"flex flex-wrap gap-0.5 mt-0.5",children:t.roles.map((s,o)=>h.jsx("span",{"data-role-chip":!0,className:rt("text-[9px] px-1 py-px rounded-full leading-tight",TV(s.name)),children:s.name},o))})]})}function zT({events:t=[],currentFeatureCode:e,now:r}){const n=_V(t,e);return n.length===0?null:h.jsx("div",{className:"w-full overflow-x-auto whitespace-nowrap border-b border-border/30 bg-background/95 backdrop-blur-sm",style:{height:72,minHeight:72,maxHeight:72,position:"sticky",top:32,zIndex:20},"data-decision-timeline-strip":!0,children:h.jsx("div",{className:"flex items-center gap-2 px-3 h-full",children:n.map(i=>h.jsx(NV,{event:i,now:r},i.id))})})}function jV(t){if(!t)return[];const e=[];t.active_phase!=null&&e.push({label:"Phase",value:t.active_phase});const r=t.pending_gates??[];e.push({label:"Pending gates",value:r.length===0?"none":r.join(", ")}),e.push({label:"Open loops",value:t.open_loops_count??0}),e.push({label:"Gate load (24h)",value:t.gate_load_24h??0});const n=t.drift_alerts??[];return n.length>0?e.push({label:"Drift alerts",value:n.map(i=>i.axis_id||i.name||"unknown").join(", ")}):e.push({label:"Drift alerts",value:"none"}),t.computed_at&&e.push({label:"Updated",value:t.computed_at}),e}const LV="Select a feature to see status.";function WT({featureCode:t,snapshot:e}){const[r,n]=C.useState(!1),i=C.useCallback(()=>{n(a=>!a)},[]),s=(e==null?void 0:e.sentence)??LV,o=jV(e);return h.jsxs(h.Fragment,{children:[h.jsxs("div",{"data-status-band":!0,onClick:i,style:{position:"sticky",top:"0px",zIndex:30,height:"32px",minHeight:"32px",maxHeight:"32px",cursor:"pointer",display:"flex",alignItems:"center",paddingLeft:"12px",paddingRight:"12px",userSelect:"none",overflow:"hidden"},className:"w-full bg-background/95 backdrop-blur-sm border-b border-border/30 text-sm text-foreground/80",title:s,"aria-expanded":r,role:"button",tabIndex:0,onKeyDown:a=>{(a.key==="Enter"||a.key===" ")&&i()},children:[h.jsx("span",{style:{overflow:"hidden",whiteSpace:"nowrap",textOverflow:"ellipsis",flex:1},children:s}),h.jsx("span",{style:{marginLeft:8,opacity:.5,fontSize:10},"aria-hidden":"true",children:r?"▲":"▼"})]}),r&&h.jsx("div",{"data-status-band-expansion":!0,style:{position:"relative",width:"100%",zIndex:29,maxHeight:200,overflowY:"auto"},className:"bg-background/98 border-b border-border/50 text-xs text-foreground/70",children:h.jsx("div",{style:{padding:"8px 12px"},children:o.length===0?h.jsx("span",{className:"text-muted-foreground",children:"No details available."}):h.jsx("table",{style:{width:"100%",borderCollapse:"collapse"},children:h.jsx("tbody",{children:o.map((a,l)=>h.jsxs("tr",{children:[h.jsx("td",{style:{paddingRight:16,paddingBottom:2,fontWeight:500,whiteSpace:"nowrap"},className:"text-foreground/60",children:a.label}),h.jsx("td",{style:{paddingBottom:2},children:String(a.value)})]},l))})})})})]})}function BV({onContextSelect:t,sidebarOpen:e=!0,onToggleSidebar:r}){const{items:n,connections:i,connected:s,uiCommand:o,clearUICommand:a,recentChanges:l,createItem:c,updateItem:u,deleteItem:d,createConnection:p,deleteConnection:f,agentActivity:m,agentErrors:x,sessionState:g,registerSnapshotProvider:y,gates:b,gateEvent:k,resolveGate:T,settings:_,updateSettings:w,resetSettings:E,activeBuild:B,setActiveBuild:P,pipelineDraft:N,sessions:M,selectedPhase:$,setSelectedPhase:q,decisionEvents:O,statusSnapshots:I,setStatusSnapshot:A}=gr(),[D,R]=C.useState(()=>sessionStorage.getItem("vision-selectedItemId")||null),j=C.useRef(!!sessionStorage.getItem("vision-activeView")),[S,W]=C.useState(()=>sessionStorage.getItem("vision-activeView")||"roadmap"),[K,F]=C.useState(""),[ht,st]=C.useState(null),[J,ct]=C.useState(!1),[zt,at]=C.useState(!1),[Z,lt]=C.useState(!1);C.useEffect(()=>{sessionStorage.setItem("vision-activeView",S)},[S]),C.useEffect(()=>{D?sessionStorage.setItem("vision-selectedItemId",D):sessionStorage.removeItem("vision-selectedItemId")},[D]);const Ct=C.useRef(!1);C.useEffect(()=>{var tt;(tt=_==null?void 0:_.ui)!=null&&tt.defaultView&&!Ct.current&&!j.current&&(W(_.ui.defaultView),Ct.current=!0)},[_]),C.useEffect(()=>{o&&(o.view&&W(o.view),o.phase!==void 0&&q(o.phase),o.select!==void 0&&R(o.select),a())},[o,a]),C.useEffect(()=>{const tt=()=>{var G;return["INPUT","TEXTAREA","SELECT"].includes((G=document.activeElement)==null?void 0:G.tagName)},kt=G=>{(G.metaKey||G.ctrlKey)&&G.key==="k"&&(G.preventDefault(),ct(nt=>!nt)),(G.metaKey||G.ctrlKey)&&G.key==="n"&&(G.preventDefault(),at(!0)),G.key===","&&!G.metaKey&&!G.ctrlKey&&!tt()&<(!0)};return window.addEventListener("keydown",kt),()=>window.removeEventListener("keydown",kt)},[]);const Mt=C.useMemo(()=>{let tt=n;if($&&(tt=tt.filter(kt=>kt.phase===$)),K){const kt=K.toLowerCase();tt=tt.filter(G=>G.title.toLowerCase().includes(kt)||(G.description||"").toLowerCase().includes(kt))}return tt},[n,$,K]),Dt=C.useMemo(()=>$?n.filter(tt=>tt.phase===$):n,[n,$]),ne=C.useMemo(()=>new Set(Dt.map(tt=>tt.id)),[Dt]),ue=C.useMemo(()=>$?b.filter(tt=>ne.has(tt.itemId)):b,[b,ne,$]),Se=C.useMemo(()=>{if(!$&&!K)return i;const tt=new Set(Mt.map(kt=>kt.id));return i.filter(kt=>tt.has(kt.fromId)&&tt.has(kt.toId))},[i,Mt,$,K]);C.useEffect(()=>{y(()=>({activeView:S,selectedPhase:$,searchQuery:K,selectedItemId:D,totalItems:n.length,filteredCount:Mt.length,connected:s}))},[y,S,$,K,D,n.length,Mt.length,s]);const te=C.useCallback(tt=>{R(tt),t&&t({type:"item",id:tt})},[t]),Ae=C.useCallback((tt,kt)=>{u(tt,kt)},[u]);C.useCallback(async()=>{const kt=await c({type:"task",title:"New item",description:"",status:"planned",confidence:0,phase:$||"vision"});kt&&kt.id&&R(kt.id)},[c,$]),C.useCallback(async tt=>{await d(tt),D===tt&&(R(null),t&&t(null))},[d,D,t]);const V=C.useCallback(tt=>{const kt=b.find(G=>G.id===tt);kt&&(R(kt.itemId),t&&t({type:"item",id:kt.itemId}))},[b,t]);C.useCallback(async tt=>p(tt),[p]),C.useCallback(async tt=>f(tt),[f]);const it=C.useCallback(()=>{Rt("/api/build/state").then(tt=>tt.json()).then(tt=>P(tt.state??null)).catch(()=>{})},[P]),dt=C.useCallback(tt=>{t&&t({type:"step",id:tt})},[t]),Nt=C.useMemo(()=>{var kt;if(!D)return null;const tt=n.find(G=>G.id===D);return((kt=tt==null?void 0:tt.lifecycle)==null?void 0:kt.featureCode)||null},[D,n]);return C.useEffect(()=>{Nt&&(I&&I[Nt]||Rt(`/api/lifecycle/status?featureCode=${encodeURIComponent(Nt)}`).then(tt=>tt.json()).then(tt=>{tt.snapshot&&A&&A(Nt,tt.snapshot)}).catch(()=>{}))},[Nt]),h.jsx(Mc.Provider,{value:l,children:h.jsxs("div",{className:"h-full flex flex-col bg-background","data-snapshot-root":!0,children:[h.jsx(WT,{featureCode:Nt,snapshot:Nt?(I==null?void 0:I[Nt])??null:null}),Nt&&h.jsx(zT,{events:O,currentFeatureCode:Nt}),h.jsxs("div",{className:"flex-1 flex min-h-0",children:[h.jsxs("div",{className:"flex h-full shrink-0",style:{borderRight:"1px solid hsl(var(--border))"},children:[r&&h.jsx("button",{className:"w-4 h-full flex items-center justify-center text-[10px] text-muted-foreground hover:text-foreground transition-colors select-none",onClick:r,title:e?"Collapse sidebar":"Expand sidebar","aria-expanded":e,"aria-label":"Toggle sidebar",style:{background:"hsl(var(--muted) / 0.3)"},children:e?"‹":"›"}),e&&h.jsx(d1,{items:n,gates:b,activeBuild:B,activeView:S,onViewChange:W,selectedPhase:$,onPhaseSelect:q,searchQuery:K,onSearchChange:F,connected:s,agentActivity:m,agentErrors:x,sessionState:g,onSelectItem:te,onThemeChange:w,onNewItem:()=>at(!0)})]}),h.jsxs("div",{className:"flex-1 flex flex-col min-w-0",children:[!s&&h.jsx("div",{className:"text-center text-[10px] py-0.5 bg-destructive text-destructive-foreground",children:"Disconnected — reconnecting..."}),S==="tree"&&h.jsx(p1,{items:Mt,connections:Se,selectedItemId:D,onSelect:te}),S==="graph"&&h.jsx(g1,{items:Mt,connections:Se,selectedItemId:D,onSelect:te}),S==="pipeline"&&h.jsx(XS,{activeBuild:B,pipelineDraft:N,onSelectStep:dt,onRefresh:it}),S==="sessions"&&h.jsx(eT,{sessions:M,items:n,onSelectItem:te}),S==="docs"&&h.jsx(qS,{items:Dt}),S==="gates"&&h.jsx(US,{gates:ue,items:Dt,onResolve:T,onSelect:te}),S==="settings"&&h.jsx(YS,{settings:_,onSettingsChange:w,onReset:E})]}),h.jsx($T,{onOpenGate:V}),ht&&(()=>{const tt=n.find(kt=>kt.id===ht);return tt?h.jsx(VS,{item:tt,items:n,connections:i,onUpdate:Ae,onClose:()=>st(null)}):null})(),h.jsx(GS,{event:k,items:n,onNavigate:()=>W("gates")}),h.jsx(rT,{open:J,onClose:()=>ct(!1),onSelectItem:tt=>{te(tt),ct(!1)},onSelectGate:tt=>{V(tt),ct(!1)}}),h.jsx(OT,{open:zt,onClose:()=>at(!1)}),h.jsx(RT,{open:Z,onClose:()=>lt(!1),settings:_,onSettingsChange:w})]})]})})}la.use(ry);const AV={background:"#0b0b14",overlay:"#161625",textPrimary:"#f1f5f9",textSecondary:"#94a3b8",textTertiary:"#64748b",textMuted:"#475569",accent:"#FBBF24"},MV={background:"#FFFFFF",overlay:"#F5F5F5",textPrimary:"#0a0a0a",textSecondary:"#404040",textTertiary:"#737373",textMuted:"#a3a3a3",accent:"#FBBF24"};function IV(t){return[{selector:"node",style:{label:"data(label)","text-valign":"center","text-halign":"center","font-size":"11px","font-weight":600,"font-family":'ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace',color:t.textPrimary,"text-wrap":"wrap","text-max-width":"110px","background-color":t.overlay,"border-width":1,"border-color":"data(color)","border-opacity":.5,width:140,height:52,shape:"round-rectangle","text-outline-width":0,"overlay-padding":4,"overlay-opacity":0}},{selector:'node[shape = "diamond"]',style:{shape:"diamond",width:160,height:80,"font-size":"10px"}},{selector:"node:selected",style:{"border-width":2,"border-opacity":1,"border-color":t.accent}},{selector:"edge",style:{width:1,"line-color":t.textMuted,"target-arrow-color":t.textMuted,"target-arrow-shape":"triangle","curve-style":"bezier","arrow-scale":.7,opacity:.5}},{selector:"edge[label]",style:{label:"data(label)","font-size":"10px","font-family":'ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace',color:t.textSecondary,"text-rotation":"autorotate","text-margin-y":-8,"text-outline-width":3,"text-outline-color":t.background}},{selector:"edge[color]",style:{"line-color":"data(color)","target-arrow-color":"data(color)"}},{selector:'edge[lineStyle = "dashed"]',style:{"line-style":"dashed"}},{selector:'edge[lineStyle = "dotted"]',style:{"line-style":"dotted"}},{selector:":parent",style:{"background-color":t.overlay,"background-opacity":.3,"border-width":1,"border-color":"data(color)","border-opacity":.3,"text-valign":"top","text-halign":"center","font-size":"10px",color:t.textTertiary,padding:"16px"}}]}function FV(){const[t,e]=C.useState(()=>document.documentElement.classList.contains("dark"));return C.useEffect(()=>{const r=new MutationObserver(()=>e(document.documentElement.classList.contains("dark")));return r.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}),()=>r.disconnect()},[]),t}const PV={"dagre-tb":{name:"dagre",rankDir:"LR",rankSep:80,nodeSep:50,padding:40},"dagre-lr":{name:"dagre",rankDir:"TB",rankSep:100,nodeSep:40,padding:40},circle:{name:"circle",padding:40},grid:{name:"grid",padding:40,rows:3},concentric:{name:"concentric",padding:40,minNodeSpacing:60},breadthfirst:{name:"breadthfirst",padding:40,spacingFactor:1.2}},DV={"dagre-tb":"Top → Down","dagre-lr":"Left → Right",circle:"Circle",grid:"Grid",concentric:"Concentric",breadthfirst:"Breadthfirst"};function OV(t,e){const r=[];for(const n of t)r.push({data:{id:n.id,label:n.label,sublabel:n.sublabel||void 0,color:n.color||CY.textMuted,parent:n.parent||void 0,shape:n.shape||void 0},...n.position?{position:n.position}:{}});for(const n of e)r.push({data:{id:n.id||`${n.from}-${n.to}-${n.label||""}`,source:n.from,target:n.to,label:n.label||void 0,color:n.color||void 0,lineStyle:n.style||"solid",edgeType:n.type||void 0}});return r}const wc="compose:graph:";function RV(t){try{const e=localStorage.getItem(wc+t);return e?JSON.parse(e):null}catch{return null}}function $V(t,e){try{localStorage.setItem(wc+t,JSON.stringify(e))}catch{}}const zV=[{style:"solid",label:"Structural / hard",dash:null},{style:"dashed",label:"Informational / weak",dash:"4,3"},{style:"dotted",label:"Soft dependency",dash:"1.5,3"}];function os({onClick:t,active:e,children:r,title:n}){return h.jsx("button",{onClick:t,title:n,className:"text-xs rounded cursor-pointer transition-colors font-semibold",style:{padding:"4px 8px",borderRadius:"0.375rem",border:"1px solid",borderColor:e?"hsl(var(--primary) / 0.1)":"hsl(var(--border))",background:e?"hsl(var(--primary) / 0.1)":"hsl(var(--accent))",color:e?"hsl(var(--primary))":"hsl(var(--muted-foreground))"},children:r})}function il({mode:t,active:e,onClick:r}){return h.jsx("button",{onClick:r,className:"text-xs rounded cursor-pointer capitalize transition-colors font-semibold",style:{padding:"4px 8px",borderRadius:"0.375rem",border:"1px solid",borderColor:e?"hsl(var(--primary) / 0.1)":"hsl(var(--border))",background:e?"hsl(var(--primary) / 0.1)":"hsl(var(--accent))",color:e?"hsl(var(--primary))":"hsl(var(--muted-foreground) / 0.6)"},children:t})}function bu(){return h.jsx("div",{className:"w-px h-4 mx-0.5",style:{background:"hsl(var(--border))"}})}function w0({arrow:t,label:e,edgeStyle:r,color:n,targetLabel:i,targetColor:s,suffix:o}){return h.jsxs("div",{className:"flex items-center gap-2 text-xs",style:{padding:"4px 8px",color:"hsl(var(--muted-foreground))"},children:[h.jsx("span",{style:{color:"hsl(var(--muted-foreground) / 0.6)"},children:t}),h.jsx("span",{style:{color:n||"hsl(var(--muted-foreground))",fontStyle:r==="dashed"?"italic":"normal"},children:e||"connects"}),i?h.jsxs(h.Fragment,{children:[h.jsx("span",{style:{color:"hsl(var(--muted-foreground) / 0.6)"},children:"→"}),h.jsxs("span",{className:"flex items-center gap-1.5",children:[h.jsx("span",{className:"w-2 h-2 rounded-sm shrink-0",style:{background:s||"hsl(var(--muted-foreground) / 0.6)"}}),h.jsx("span",{style:{color:"hsl(var(--foreground))"},children:i})]})]}):o?h.jsx("span",{style:{color:"hsl(var(--muted-foreground) / 0.6)"},children:o}):null,r&&r!=="solid"&&h.jsxs("span",{className:"text-[10px]",style:{color:"hsl(var(--muted-foreground) / 0.6)"},children:["(",r,")"]})]})}function WV({nodes:t,edges:e,graphKey:r}){const[n,i]=C.useState(()=>{try{const l=localStorage.getItem(wc+r+":tree-collapsed");return l?new Set(JSON.parse(l)):new Set}catch{return new Set}});C.useEffect(()=>{try{localStorage.setItem(wc+r+":tree-collapsed",JSON.stringify([...n]))}catch{}},[n,r]);const s=C.useMemo(()=>{const l={};for(const c of t)l[c.id]=c;return l},[t]),o=C.useMemo(()=>{var u,d;const l={},c={};for(const p of t)l[p.id]=[],c[p.id]=[];for(const p of e)(u=l[p.from])==null||u.push(p),(d=c[p.to])==null||d.push(p);return{out:l,inc:c}},[t,e]),a=l=>i(c=>{const u=new Set(c);return u.has(l)?u.delete(l):u.add(l),u});return h.jsxs("div",{className:"w-full h-full overflow-y-auto",style:{background:"hsl(var(--background))",padding:"1rem"},children:[h.jsxs("div",{className:"flex items-center mb-4",style:{gap:"8px"},children:[h.jsx(os,{onClick:()=>i(new Set),children:"Expand all"}),h.jsx(os,{onClick:()=>i(new Set(t.map(l=>l.id))),children:"Collapse all"}),h.jsxs("span",{className:"text-xs ml-auto",style:{color:"hsl(var(--muted-foreground))"},children:[t.length," entities · ",e.length," relations"]})]}),t.map(l=>{const c=n.has(l.id),u=o.out[l.id]||[],d=o.inc[l.id]||[],p=u.filter(g=>g.from===g.to),f=u.filter(g=>g.from!==g.to),m=d.filter(g=>g.from!==g.to),x=f.length+m.length+p.length;return h.jsxs("div",{className:"mb-0.5",children:[h.jsxs("button",{onClick:()=>a(l.id),className:"flex items-center w-full text-left bg-transparent border-none cursor-pointer rounded-md transition-colors hover:bg-[hsl(var(--accent))]",style:{gap:"8px",padding:"8px"},children:[h.jsx("span",{className:"text-xs w-4 text-center inline-block transition-transform",style:{color:"hsl(var(--muted-foreground))",transform:c?"rotate(-90deg)":"rotate(0deg)"},children:"▼"}),h.jsx("span",{className:"w-3 h-3 shrink-0",style:{borderRadius:l.shape==="diamond"?0:3,background:l.color,transform:l.shape==="diamond"?"rotate(45deg) scale(0.8)":"none"}}),h.jsx("span",{className:"text-sm font-semibold",style:{color:"hsl(var(--foreground))"},children:l.label}),l.sublabel&&h.jsxs("span",{className:"text-xs",style:{color:"hsl(var(--muted-foreground))"},children:["— ",l.sublabel]}),h.jsx("span",{className:"text-xs ml-auto",style:{color:"hsl(var(--muted-foreground) / 0.6)"},children:x})]}),!c&&h.jsxs("div",{style:{paddingLeft:"32px",paddingBottom:"4px"},children:[f.map((g,y)=>{var b,k;return h.jsx(w0,{arrow:"→",label:g.label,edgeStyle:g.style,color:g.color,targetLabel:((b=s[g.to])==null?void 0:b.label)||g.to,targetColor:(k=s[g.to])==null?void 0:k.color},`out-${y}`)}),p.map((g,y)=>h.jsx(w0,{arrow:"↻",label:g.label,edgeStyle:g.style,color:g.color,suffix:"(self)"},`self-${y}`)),m.map((g,y)=>{var b,k;return h.jsxs("div",{className:"flex items-center gap-2 text-xs",style:{padding:"4px 8px",color:"hsl(var(--muted-foreground))"},children:[h.jsxs("span",{className:"flex items-center gap-1.5",children:[h.jsx("span",{className:"w-2 h-2 rounded-sm shrink-0",style:{background:((b=s[g.from])==null?void 0:b.color)||"hsl(var(--muted-foreground) / 0.6)"}}),h.jsx("span",{style:{color:"hsl(var(--foreground))"},children:((k=s[g.from])==null?void 0:k.label)||g.from})]}),h.jsx("span",{style:{color:"hsl(var(--muted-foreground) / 0.6)"},children:"→"}),h.jsx("span",{style:{color:g.color||"hsl(var(--muted-foreground))",fontStyle:g.style==="dashed"?"italic":"normal"},children:g.label||"connects"}),h.jsx("span",{style:{color:"hsl(var(--muted-foreground) / 0.6)"},children:"→ this"}),g.style&&g.style!=="solid"&&h.jsxs("span",{className:"text-[10px]",style:{color:"hsl(var(--muted-foreground) / 0.6)"},children:["(",g.style,")"]})]},`in-${y}`)}),x===0&&h.jsx("div",{className:"text-xs italic",style:{padding:"4px 8px",color:"hsl(var(--muted-foreground) / 0.6)"},children:"no relations"})]})]},l.id)})]})}function qV({elements:t,nodes:e,edges:r,layout:n,style:i,title:s,subtitle:o,graphKey:a="default",onNodeClick:l}){const c=C.useRef(null),u=C.useRef(null),[d,p]=C.useState(null),f=FV(),m=f?AV:MV,x=C.useMemo(()=>RV(a),[a]),[g,y]=C.useState((x==null?void 0:x.layoutKey)||"dagre-tb"),[b,k]=C.useState((x==null?void 0:x.showEdgeLabels)??!0),[T,_]=C.useState(()=>new Set((x==null?void 0:x.hiddenNodes)||[])),[w,E]=C.useState((x==null?void 0:x.showLegend)??!0),[B,P]=C.useState((x==null?void 0:x.viewMode)||"graph");C.useEffect(()=>{$V(a,{layoutKey:g,showEdgeLabels:b,hiddenNodes:[...T],showLegend:w,viewMode:B})},[a,g,b,T,w,B]);const N=t||(e&&r?OV(e,r):[]),M=C.useMemo(()=>i||IV(m),[i,f]),$=n||PV[g],q=C.useMemo(()=>N.filter(S=>!S.data.source).map(S=>({id:S.data.id,label:S.data.label,color:S.data.color})),[JSON.stringify(N)]),O=C.useMemo(()=>T.size===0?N:N.filter(S=>S.data.source?!T.has(S.data.source)&&!T.has(S.data.target):!T.has(S.data.id)),[N,T]);C.useEffect(()=>{if(!c.current)return;const S=la({container:c.current,elements:O,style:M,layout:$,minZoom:.2,maxZoom:4,wheelSensitivity:.3,boxSelectionEnabled:!1});return u.current=S,S.on("mouseover","node",W=>{const K=W.target;K.style("border-width",2),K.style("border-opacity",1);const F=K.renderedPosition();p({x:F.x,y:F.y-K.renderedHeight()/2-12,label:K.data("label"),sublabel:K.data("sublabel"),id:K.id(),color:K.data("color")})}),S.on("mouseout","node",W=>{W.target.style("border-width",1),W.target.style("border-opacity",.5),p(null)}),l&&S.on("tap","node",W=>l(W.target.id())),S.on("layoutstop",()=>S.fit(void 0,40)),()=>{S.destroy(),u.current=null}},[JSON.stringify(O),JSON.stringify($),f,B]),C.useEffect(()=>{const S=u.current;S&&S.edges().forEach(W=>{W.data("label")&&W.style("label",b?W.data("label"):"")})},[b]);const I=C.useCallback(()=>{var S;return(S=u.current)==null?void 0:S.fit(void 0,40)},[]),A=C.useCallback(()=>{const S=u.current;S&&S.zoom({level:S.zoom()*1.3,renderedPosition:{x:S.width()/2,y:S.height()/2}})},[]),D=C.useCallback(()=>{const S=u.current;S&&S.zoom({level:S.zoom()/1.3,renderedPosition:{x:S.width()/2,y:S.height()/2}})},[]),R=C.useCallback(S=>{_(W=>{const K=new Set(W);return K.has(S)?K.delete(S):K.add(S),K})},[]),j=C.useCallback(()=>_(new Set),[]);return B==="tree"?h.jsxs("div",{className:"w-full h-full flex flex-col",style:{background:"hsl(var(--background))"},children:[h.jsxs("div",{className:"flex items-center justify-between shrink-0",style:{padding:"8px 16px",borderBottom:"1px solid hsl(var(--border))"},children:[h.jsxs("div",{className:"flex items-center",style:{gap:"8px"},children:[s&&h.jsx("span",{className:"text-sm font-semibold",style:{color:"hsl(var(--foreground))"},children:s}),o&&h.jsx("span",{className:"text-xs",style:{color:"hsl(var(--muted-foreground))"},children:o})]}),h.jsxs("div",{className:"flex",style:{gap:"4px"},children:[h.jsx(il,{mode:"graph",active:B==="graph",onClick:()=>P("graph")}),h.jsx(il,{mode:"tree",active:B==="tree",onClick:()=>P("tree")})]})]}),h.jsx("div",{className:"flex-1 min-h-0",children:h.jsx(WV,{nodes:e||[],edges:r||[],graphKey:a})})]}):h.jsxs("div",{className:"w-full h-full relative",style:{background:"hsl(var(--background))"},children:[(s||o)&&h.jsxs("div",{className:"absolute top-0 left-0 right-0 z-[2] pointer-events-none",style:{padding:"8px 16px",background:"linear-gradient(to bottom, hsl(var(--background)) 0%, transparent 100%)"},children:[s&&h.jsx("div",{className:"text-sm font-semibold",style:{color:"hsl(var(--foreground))"},children:s}),o&&h.jsx("div",{className:"text-[10px] mt-0.5",style:{color:"hsl(var(--muted-foreground))"},children:o})]}),h.jsxs("div",{className:"absolute top-2 right-3 z-[2] flex items-center",style:{gap:"4px"},children:[h.jsx("select",{value:g,onChange:S=>y(S.target.value),className:"text-xs rounded cursor-pointer appearance-none",style:{padding:"4px 8px",borderRadius:"0.375rem",background:"hsl(var(--accent))",border:"1px solid hsl(var(--border))",color:"hsl(var(--muted-foreground))"},title:"Graph layout",children:Object.entries(DV).map(([S,W])=>h.jsx("option",{value:S,style:{background:"hsl(var(--accent))",color:"hsl(var(--foreground))"},children:W},S))}),h.jsx(bu,{}),h.jsx(os,{onClick:D,title:"Zoom out",children:"−"}),h.jsx(os,{onClick:I,title:"Fit to view",children:"Fit"}),h.jsx(os,{onClick:A,title:"Zoom in",children:"+"}),h.jsx(bu,{}),h.jsx(os,{onClick:()=>E(!w),active:w,title:w?"Hide legend":"Show legend",children:"Legend"}),h.jsx(bu,{}),h.jsx(il,{mode:"graph",active:B==="graph",onClick:()=>P("graph")}),h.jsx(il,{mode:"tree",active:B==="tree",onClick:()=>P("tree")})]}),w&&h.jsxs("div",{className:"absolute bottom-3 left-3 z-[2]",style:{background:"hsl(var(--card))",border:"1px solid hsl(var(--border))",borderRadius:"0.5rem",padding:"8px 16px",boxShadow:"0 1px 3px rgba(0,0,0,0.1)",minWidth:150,maxWidth:210},children:[h.jsxs("div",{className:"flex justify-between items-center mb-1.5",children:[h.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-wider",style:{color:"hsl(var(--muted-foreground))"},children:"Entities"}),T.size>0&&h.jsx("button",{onClick:j,className:"text-[10px] bg-transparent border-none cursor-pointer p-0",style:{color:"hsl(var(--primary))"},children:"Show all"})]}),h.jsx("div",{className:"flex flex-col gap-1",children:q.map(S=>{const W=T.has(S.id);return h.jsxs("button",{onClick:()=>R(S.id),className:"flex items-center gap-1.5 bg-transparent border-none py-0.5 cursor-pointer transition-opacity",style:{opacity:W?.35:1},title:W?`Show ${S.label}`:`Hide ${S.label}`,children:[h.jsx("span",{className:"w-2 h-2 rounded-sm shrink-0 transition-colors",style:{background:W?"transparent":S.color,border:`1.5px solid ${S.color}`}}),h.jsx("span",{className:"text-xs",style:{color:W?"hsl(var(--muted-foreground) / 0.6)":"hsl(var(--muted-foreground))",textDecoration:W?"line-through":"none"},children:S.label})]},S.id)})}),h.jsxs("div",{className:"flex justify-between items-center mt-2.5 mb-1.5",children:[h.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-wider",style:{color:"hsl(var(--muted-foreground))"},children:"Edges"}),h.jsx("button",{onClick:()=>k(!b),className:"text-[10px] bg-transparent border-none cursor-pointer p-0",style:{color:b?"hsl(var(--primary))":"hsl(var(--muted-foreground) / 0.6)"},children:b?"Hide labels":"Show labels"})]}),h.jsx("div",{className:"flex flex-col gap-1",children:zV.map(S=>h.jsxs("div",{className:"flex items-center gap-1.5",children:[h.jsx("svg",{width:"20",height:"6",className:"shrink-0",children:h.jsx("line",{x1:"0",y1:"3",x2:"20",y2:"3",stroke:"hsl(var(--muted-foreground))",strokeWidth:"1.5",strokeDasharray:S.dash||"none"})}),h.jsx("span",{className:"text-[10px]",style:{color:"hsl(var(--muted-foreground) / 0.6)"},children:S.label})]},S.style))})]}),d&&h.jsxs("div",{className:"absolute z-10 text-center pointer-events-none backdrop-blur-sm",style:{left:d.x,top:d.y,transform:"translate(-50%, -100%)",background:"hsl(var(--accent))",border:"1px solid hsl(var(--border))",borderRadius:"0.5rem",padding:"4px 8px",boxShadow:"0 1px 3px rgba(0,0,0,0.1)",minWidth:110,maxWidth:200},children:[h.jsx("div",{className:"text-sm font-semibold",style:{color:d.color||"hsl(var(--foreground))"},children:d.label}),d.sublabel&&h.jsx("div",{className:"text-xs mt-0.5",style:{color:"hsl(var(--muted-foreground))"},children:d.sublabel}),h.jsx("div",{className:"text-[10px] mt-1 font-mono",style:{color:"hsl(var(--muted-foreground) / 0.6)"},children:d.id})]}),h.jsx("div",{ref:c,className:"w-full h-full"})]})}const Wt={discovery:"#a78bfa",feature:"#3b82f6",track:"#06b6d4",task:"#94a3b8",spec:"#a78bfa",idea:"#fbbf24",question:"#f472b6",evaluation:"#f59e0b",thread:"#64748b",decision:"#22c55e",artifact:"#a87cb8",informs:"#64748b",pipeline:"#6366f1"},HV=[{id:"discovery",label:"Discovery",sublabel:"orthogonal process",color:Wt.discovery,shape:"diamond"},{id:"pipeline",label:"Feature Development Pipeline",color:Wt.pipeline},{id:"p-vision",label:"Vision",parent:"pipeline",color:Wt.pipeline},{id:"p-specification",label:"Specification",parent:"pipeline",color:Wt.pipeline},{id:"p-planning",label:"Planning",parent:"pipeline",color:Wt.pipeline},{id:"p-implementation",label:"Implementation",parent:"pipeline",color:Wt.pipeline},{id:"p-verification",label:"Verification",parent:"pipeline",color:Wt.pipeline},{id:"p-release",label:"Release",parent:"pipeline",color:Wt.pipeline},{id:"feature",label:"Feature",sublabel:"strategic container",color:Wt.feature},{id:"track",label:"Track",sublabel:"deliverable unit",color:Wt.track},{id:"task",label:"Task",sublabel:"planned → doing → done",color:Wt.task},{id:"spec",label:"Spec",sublabel:"behavioral specification",color:Wt.spec},{id:"evaluation",label:"Evaluation",sublabel:"assessment / gap analysis",color:Wt.evaluation},{id:"idea",label:"Idea",sublabel:"can float free",color:Wt.idea},{id:"thread",label:"Thread",sublabel:"deliberation",color:Wt.thread},{id:"decision",label:"Decision",sublabel:"resolved choice",color:Wt.decision},{id:"question",label:"Question",sublabel:"may block progress",color:Wt.question},{id:"artifact",label:"Artifact",sublabel:"journal / doc / output",color:Wt.artifact}],UV=[{from:"p-vision",to:"p-specification",color:Wt.pipeline},{from:"p-specification",to:"p-planning",color:Wt.pipeline},{from:"p-planning",to:"p-implementation",color:Wt.pipeline},{from:"p-implementation",to:"p-verification",color:Wt.pipeline},{from:"p-verification",to:"p-release",color:Wt.pipeline},{from:"idea",to:"p-vision",label:"lives in",color:Wt.idea,style:"dotted"},{from:"spec",to:"p-specification",label:"lives in",color:Wt.spec,style:"dotted"},{from:"task",to:"p-implementation",label:"lives in",color:Wt.task,style:"dotted"},{from:"evaluation",to:"p-verification",label:"lives in",color:Wt.evaluation,style:"dotted"},{from:"discovery",to:"feature",label:"produces",color:Wt.discovery,style:"dashed"},{from:"discovery",to:"idea",label:"produces",color:Wt.discovery,style:"dashed"},{from:"discovery",to:"thread",label:"produces",color:Wt.discovery,style:"dashed"},{from:"discovery",to:"decision",label:"produces",color:Wt.discovery,style:"dashed"},{from:"discovery",to:"question",label:"produces",color:Wt.discovery,style:"dashed"},{from:"discovery",to:"spec",label:"produces",color:Wt.discovery,style:"dashed"},{from:"track",to:"feature",label:"implements",color:Wt.track},{from:"task",to:"feature",label:"implements",color:Wt.task},{from:"spec",to:"feature",label:"implements",color:Wt.spec},{from:"feature",to:"feature",label:"blocks",color:Wt.question,id:"feat-blocks"},{from:"idea",to:"feature",label:"informs",color:Wt.informs,style:"dashed"},{from:"thread",to:"decision",label:"informs",color:Wt.informs,style:"dashed"},{from:"evaluation",to:"decision",label:"informs",color:Wt.informs,style:"dashed"},{from:"artifact",to:"feature",label:"supports",color:Wt.artifact},{from:"question",to:"decision",label:"contradicts",color:Wt.question},{from:"feature",to:"p-vision",label:"enters",color:Wt.feature,style:"dashed"}];function GV(){return h.jsx(qV,{graphKey:"product",nodes:HV,edges:UV,title:"Compose Product Ontology",subtitle:"10 entity types · 6 phases · 5 edge types · Discovery orthogonal"})}const VV="compose-popout";function qT(t){if(t==="vision://surface")return"Vision Tracker";if(t.startsWith("graph://")){const r=t.replace("graph://","");return r.charAt(0).toUpperCase()+r.slice(1)+" Graph"}const e=t.split("/");return e.length>1?e.slice(-2).join("/"):e[e.length-1]}function sl({path:t,onDock:e}){return h.jsxs("div",{className:"flex items-center justify-between px-3 shrink-0",style:{height:"28px",borderBottom:"1px solid hsl(var(--border))",background:"hsl(var(--background))"},children:[h.jsx("span",{className:"text-[11px] text-muted-foreground truncate",children:qT(t)}),h.jsxs("button",{onClick:e,className:"flex items-center gap-1 px-2 py-0.5 rounded text-[10px] uppercase tracking-wider",style:{color:"hsl(var(--primary))",background:"none",border:"none",cursor:"pointer"},title:"Pop back into main window",children:[h.jsx(jA,{style:{width:11,height:11}}),"pop in"]})]})}function YV({path:t}){const[e,r]=C.useState(null),[n,i]=C.useState(!0),s=C.useRef(null),o=C.useRef(null),a=t.startsWith("vision://")?"vision":t.startsWith("graph://")?"graph":t.endsWith(".html")||t.endsWith(".htm")?"html":"markdown";C.useEffect(()=>{document.title=qT(t)+" — Compose"},[t]),C.useEffect(()=>{const c=new BroadcastChannel(VV);s.current=c,c.postMessage({type:"popout-mounted",path:t});const u=()=>{c.postMessage({type:"popout-closed",path:t})};return window.addEventListener("beforeunload",u),()=>{u(),c.close(),window.removeEventListener("beforeunload",u)}},[t]);const l=C.useCallback(()=>{var c;(c=s.current)==null||c.postMessage({type:"popout-dock",path:t}),window.close()},[t]);return C.useEffect(()=>{if(a==="vision"||a==="graph"){i(!1);return}Rt(`/api/file?path=${encodeURIComponent(t)}`).then(c=>c.json()).then(c=>{c.content!==void 0&&r(c.content),i(!1)}).catch(()=>i(!1))},[t,a]),C.useEffect(()=>{if(a==="vision"||a==="graph")return;const c=window.location.protocol==="https:"?"wss:":"ws:",u=new WebSocket(`${c}//${window.location.host}/ws/files`);return o.current=u,u.onmessage=d=>{try{const p=JSON.parse(d.data);p.type==="fileChanged"&&p.path===t&&r(p.content)}catch{}},()=>u.close()},[t,a]),n?h.jsx("div",{className:"h-screen w-screen flex items-center justify-center bg-background",children:h.jsx("span",{className:"text-sm text-muted-foreground",children:"Loading..."})}):a==="vision"?h.jsxs("div",{className:"h-screen w-screen flex flex-col bg-background",children:[h.jsx(sl,{path:t,onDock:l}),h.jsx("div",{className:"flex-1 min-h-0",children:h.jsx(BV,{})})]}):a==="graph"?h.jsxs("div",{className:"h-screen w-screen flex flex-col bg-background",children:[h.jsx(sl,{path:t,onDock:l}),h.jsx("div",{className:"flex-1 min-h-0",children:h.jsx(GV,{})})]}):a==="html"?h.jsxs("div",{className:"h-screen w-screen flex flex-col bg-background",children:[h.jsx(sl,{path:t,onDock:l}),h.jsx("div",{className:"flex-1 min-h-0",children:h.jsx("iframe",{srcDoc:e,className:"w-full h-full border-0",sandbox:"allow-scripts allow-same-origin",title:t})})]}):h.jsxs("div",{className:"h-screen w-screen flex flex-col bg-background",children:[h.jsx(sl,{path:t,onDock:l}),h.jsx("div",{className:"flex-1 overflow-y-auto px-8 py-6",children:h.jsx("div",{className:"canvas-markdown max-w-4xl mx-auto",children:h.jsx(yf,{remarkPlugins:[vf],children:e||""})})})]})}const XV="/api/stratum";async function lh(t,e={}){return(await Rt(`${XV}${t}`,{headers:{"Content-Type":"application/json",...e.headers||{}},...e})).json()}function KV(t,e){return lh(t,{method:"POST",body:JSON.stringify(e)})}function HT({status:t}){const e={running:"hsl(var(--background))",awaiting_gate:"#7c3aed",complete:"#166534",killed:"#7f1d1d",blocked:"#7f1d1d"},r={running:"running",awaiting_gate:"gate pending",complete:"complete",killed:"killed",blocked:"blocked"};return h.jsx("span",{style:{fontSize:"0.72em",padding:"2px 6px",borderRadius:4,background:e[t]||"#333",color:"#e5e7eb",textTransform:"uppercase",letterSpacing:"0.05em"},children:r[t]||t})}function Up(){return h.jsx("span",{style:{opacity:.5,fontSize:"0.85em"},children:"loading…"})}function ZV({onAction:t}){const[e,r]=C.useState(null),[n,i]=C.useState(null),[s,o]=C.useState({}),[a,l]=C.useState({}),c=C.useCallback(()=>{lh("/gates").then(d=>{r(Array.isArray(d)?d:[]),i(null)}).catch(d=>i(d.message))},[]);C.useEffect(()=>{c();const d=setInterval(c,1e4);return()=>clearInterval(d)},[c]);async function u(d,p,f){const m=`${d}/${p}/${f}`;o(g=>({...g,[m]:!0}));const x=a[`${d}/${p}`]||"";try{const g=await KV(`/gates/${d}/${p}/${f}`,{note:x});g.conflict?i(`Gate already resolved (${d}/${p})`):g.error?i(g.error.message):(t==null||t(),c())}catch(g){i(g.message)}finally{o(g=>({...g,[m]:!1}))}}return e===null&&!n?h.jsx(Up,{}):h.jsxs("section",{children:[h.jsxs("h3",{style:{fontSize:"0.8em",textTransform:"uppercase",letterSpacing:"0.08em",opacity:.5,margin:"0 0 8px"},children:["Pending Gates ",(e==null?void 0:e.length)>0&&h.jsxs("span",{style:{opacity:1,color:"#f59e0b"},children:["(",e.length,")"]})]}),n&&h.jsx("p",{style:{color:"#ef4444",fontSize:"0.8em",margin:"0 0 8px"},children:n}),(e==null?void 0:e.length)===0&&h.jsx("p",{style:{opacity:.4,fontSize:"0.85em"},children:"No pending gates."}),e==null?void 0:e.map(d=>{const p=`${d.flow_id}/${d.step_id}`,f=m=>s[`${p}/${m}`];return h.jsxs("div",{style:{border:"1px solid #3f3f46",borderRadius:6,padding:"10px 12px",marginBottom:8,background:"#18181b"},children:[h.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:6},children:[h.jsx("span",{style:{fontWeight:600,fontSize:"0.9em"},children:d.flow_name||d.flow_id}),h.jsx("span",{style:{opacity:.4,fontSize:"0.8em"},children:"›"}),h.jsx("span",{style:{fontFamily:"monospace",fontSize:"0.82em",opacity:.7},children:d.step_id}),d.function&&h.jsxs("span",{style:{opacity:.4,fontSize:"0.78em"},children:["fn:",d.function]})]}),h.jsx("input",{type:"text",placeholder:"Note (optional)",value:a[p]||"",onChange:m=>l(x=>({...x,[p]:m.target.value})),style:{width:"100%",boxSizing:"border-box",marginBottom:8,background:"#27272a",border:"1px solid #3f3f46",borderRadius:4,color:"#e4e4e7",padding:"4px 8px",fontSize:"0.82em"}}),h.jsx("div",{style:{display:"flex",gap:6},children:[{a:"approve",label:"Approve",color:"#166534",hover:"#15803d"},{a:"reject",label:"Reject",color:"#7f1d1d",hover:"#b91c1c"},{a:"revise",label:"Revise",color:"#1e3a5f",hover:"#1d4ed8"}].map(({a:m,label:x,color:g})=>h.jsx("button",{disabled:f(m),onClick:()=>u(d.flow_id,d.step_id,m),style:{padding:"4px 12px",fontSize:"0.8em",borderRadius:4,border:"none",background:g,color:"#e5e7eb",cursor:f(m)?"not-allowed":"pointer",opacity:f(m)?.5:1},children:f(m)?"…":x},m))})]},p)})]})}function QV({flowId:t,onClose:e}){const[r,n]=C.useState(null),[i,s]=C.useState(null);return C.useEffect(()=>{lh(`/flows/${t}`).then(o=>{o.error?s(o.error.message):n(o)}).catch(o=>s(o.message))},[t]),h.jsxs("div",{style:{border:"1px solid #3f3f46",borderRadius:6,padding:"10px 12px",background:"#18181b"},children:[h.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:8},children:[h.jsx("span",{style:{fontWeight:600,fontSize:"0.9em"},children:(r==null?void 0:r.flow_name)||t}),h.jsx("button",{onClick:e,style:{background:"none",border:"none",color:"#9ca3af",cursor:"pointer",fontSize:"1.1em"},children:"✕"})]}),i&&h.jsx("p",{style:{color:"#ef4444",fontSize:"0.8em"},children:i}),!r&&!i&&h.jsx(Up,{}),r&&h.jsx("div",{style:{fontSize:"0.82em",opacity:.8},children:(()=>{const o=new Set(Array.isArray(r.completed_steps)?r.completed_steps:[]),a=new Set(Array.isArray(r.active_steps)?r.active_steps:[]),l=o.size,c=r.step_count??"?";return h.jsxs(h.Fragment,{children:[h.jsxs("div",{style:{display:"flex",gap:12,marginBottom:8,flexWrap:"wrap"},children:[h.jsx("span",{children:h.jsx(HT,{status:r.status})}),h.jsxs("span",{children:["steps ",l,"/",c,a.size>0&&h.jsxs("span",{style:{marginLeft:6,color:"#34d399",fontSize:"0.85em"},children:["∥ ",a.size," running"]})]}),r.round>0&&h.jsxs("span",{children:["round ",r.round]})]}),Array.isArray(r.ordered_steps)&&r.ordered_steps.length>0&&h.jsx("ol",{style:{margin:0,padding:"0 0 0 18px",lineHeight:1.7},children:r.ordered_steps.map(u=>h.jsxs("li",{style:{opacity:o.has(u.id)?.4:1,fontWeight:a.has(u.id)?700:"normal",color:a.has(u.id)?"#34d399":"inherit"},children:[h.jsx("span",{style:{fontFamily:"monospace"},children:u.id}),u.mode==="gate"&&h.jsx("span",{style:{marginLeft:6,color:"#f59e0b",fontSize:"0.9em"},children:"gate"}),a.has(u.id)&&h.jsx("span",{style:{marginLeft:6,fontSize:"0.85em"},children:"∥ running"})]},u.id))})]})})()})]})}function JV({activeBuild:t}){const[e,r]=C.useState(null),[n,i]=C.useState(null),[s,o]=C.useState(null),a=C.useCallback(()=>{lh("/flows").then(l=>{r(Array.isArray(l)?l:[]),i(null)}).catch(l=>i(l.message))},[]);return C.useEffect(()=>{a();const l=setInterval(a,15e3);return()=>clearInterval(l)},[a]),C.useEffect(()=>{t&&a()},[t,a]),e===null&&!n?h.jsx(Up,{}):h.jsxs("section",{children:[h.jsx("h3",{style:{fontSize:"0.8em",textTransform:"uppercase",letterSpacing:"0.08em",opacity:.5,margin:"0 0 8px"},children:"Flows"}),n&&h.jsx("p",{style:{color:"#ef4444",fontSize:"0.8em"},children:n}),(e==null?void 0:e.length)===0&&h.jsx("p",{style:{opacity:.4,fontSize:"0.85em"},children:"No flows found."}),e==null?void 0:e.map(l=>h.jsx("div",{onClick:()=>o(s===l.flow_id?null:l.flow_id),style:{border:`1px solid ${s===l.flow_id?"#6366f1":"#3f3f46"}`,borderRadius:6,padding:"8px 12px",marginBottom:6,background:s===l.flow_id?"#1e1b4b":"#18181b",cursor:"pointer"},children:h.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[h.jsx("span",{style:{fontSize:"0.88em",fontWeight:500},children:l.flow_name||l.flow_id}),h.jsxs("div",{style:{display:"flex",gap:8,alignItems:"center"},children:[h.jsxs("span",{style:{fontSize:"0.78em",opacity:.5},children:[Array.isArray(l.completed_steps)?l.completed_steps.length:l.completed_steps??0,"/",l.step_count??"?"]}),h.jsx(HT,{status:l.status})]})]})},l.flow_id)),s&&h.jsx("div",{style:{marginTop:8},children:h.jsx(QV,{flowId:s,onClose:()=>o(null)})})]})}const tY={display:"inline-block",width:8,height:8,borderRadius:"50%",background:"#22c55e",marginRight:8,animation:"pulse-dot 1.5s ease-in-out infinite"};if(typeof document<"u"&&!document.getElementById("pulse-dot-style")){const t=document.createElement("style");t.id="pulse-dot-style",t.textContent="@keyframes pulse-dot { 0%,100% { opacity: 1; } 50% { opacity: 0.3; } }",document.head.appendChild(t)}function eY({build:t,onDismiss:e}){const r=t.status==="running",n=["complete","failed","aborted"].includes(t.status);C.useEffect(()=>{if(t.status==="complete"){const s=setTimeout(()=>e==null?void 0:e(),5e3);return()=>clearTimeout(s)}},[t.status,e]);const i={running:"#166534",complete:"#14532d",failed:"#7f1d1d",aborted:"#78350f"};return h.jsxs("div",{style:{border:`1px solid ${r?"#22c55e33":"#3f3f46"}`,borderRadius:6,padding:"10px 12px",marginBottom:12,background:i[t.status]||"#18181b"},children:[h.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[h.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[r&&h.jsx("span",{style:tY}),h.jsx("span",{style:{fontWeight:600,fontSize:"0.88em"},children:t.featureCode}),h.jsx("span",{style:{opacity:.5,fontSize:"0.78em"},children:r?"building":t.status})]}),n&&t.status!=="complete"&&h.jsx("button",{onClick:e,style:{background:"none",border:"none",color:"#9ca3af",cursor:"pointer",fontSize:"0.9em"},children:"✕"})]}),h.jsxs("div",{style:{fontSize:"0.8em",opacity:.7,marginTop:4,fontFamily:"monospace"},children:[t.currentStepId,t.stepNum!=null&&t.totalSteps!=null&&h.jsxs("span",{style:{marginLeft:8,opacity:.5},children:["(",t.stepNum,"/",t.totalSteps,")"]}),t.retries>0&&h.jsxs("span",{style:{marginLeft:8,color:"#f59e0b"},children:["retry ",t.retries]})]})]})}function rY(){const t=gr(s=>s.activeBuild),[e,r]=C.useState(null),n=C.useCallback(()=>{t&&r(`${t.flowId}:${t.completedAt}`)},[t]);C.useEffect(()=>{(t==null?void 0:t.status)==="running"&&r(null)},[t==null?void 0:t.status]);const i=t&&!(e&&e===`${t.flowId}:${t.completedAt}`);return h.jsxs("div",{style:{padding:"12px 14px",color:"#e4e4e7",fontSize:"0.9em",overflowY:"auto",height:"100%"},children:[i&&h.jsx(eY,{build:t,onDismiss:n}),h.jsx(ZV,{}),h.jsx("div",{style:{marginTop:20},children:h.jsx(JV,{activeBuild:t})})]})}function nY({projectName:t,projectRoot:e,onSwitch:r}){const[n,i]=C.useState(!1),[s,o]=C.useState(e||""),a=C.useRef(null);return C.useEffect(()=>{o(e||"")},[e]),C.useEffect(()=>{if(!n)return;const l=c=>{var u;(u=a.current)!=null&&u.contains(c.target)||i(!1)};return window.addEventListener("mousedown",l),()=>window.removeEventListener("mousedown",l)},[n]),C.useEffect(()=>{if(!n)return;const l=c=>{c.key==="Escape"&&i(!1)};return window.addEventListener("keydown",l),()=>window.removeEventListener("keydown",l)},[n]),h.jsxs("div",{ref:a,className:"flex items-center shrink-0 gap-2 relative",children:[h.jsx("span",{className:"text-xs font-semibold tracking-widest uppercase text-blue-600 dark:text-accent",children:"Compose"}),h.jsx("button",{"data-testid":"project-btn",className:"text-[10px] uppercase tracking-wider text-muted-foreground hover:text-foreground transition-colors",onClick:()=>i(l=>!l),title:e||"Switch project","aria-label":"Switch project","aria-haspopup":"dialog","aria-expanded":n,children:t||"no project"}),n&&h.jsxs("div",{"data-testid":"project-popover",role:"dialog","aria-label":"Switch project",className:"absolute top-full left-0 mt-1 z-50 p-2 rounded-md shadow-lg",style:{background:"hsl(var(--popover))",border:"1px solid hsl(var(--border))",minWidth:"280px"},children:[h.jsxs("div",{className:"text-[10px] text-muted-foreground mb-1 px-1",children:["Current: ",e]}),h.jsx("input",{autoFocus:!0,"data-testid":"project-input",className:"w-full px-2 py-1 text-xs rounded border bg-background text-foreground",style:{borderColor:"hsl(var(--border))"},placeholder:"Absolute path to project...",value:s,onChange:l=>o(l.target.value),onKeyDown:async l=>{l.key==="Enter"&&await r(s)&&i(!1),l.key==="Escape"&&i(!1)}})]})]})}const iY={dashboard:{label:"Dashboard",icon:uM},tree:{label:"Items",icon:vb},graph:{label:"Graph",icon:vM},pipeline:{label:"Pipeline",icon:UM},sessions:{label:"Sessions",icon:wf},gates:{label:"Gates",icon:qs},docs:{label:"Docs",icon:Ei},design:{label:"Design",icon:Bc},ideabox:{label:"Ideabox",icon:xi}};function sY({tabs:t=[],activeTab:e,onTabChange:r,onOpenPalette:n,badges:i={}}){return h.jsxs("div",{className:"flex items-center gap-0.5 h-full",role:"tablist","aria-label":"Main views",children:[t.map(s=>{const o=iY[s],a=s===e,l=o==null?void 0:o.icon,c=(o==null?void 0:o.label)||s,u=i[s];return h.jsxs("button",{role:"tab","aria-selected":a,className:["flex items-center gap-1.5 px-3 h-full text-[11px] uppercase tracking-wider font-medium transition-colors","border-b-2 -mb-px",a?"border-blue-600 text-blue-600 dark:border-accent dark:text-accent":"border-transparent text-muted-foreground hover:text-foreground hover:border-border"].join(" "),onClick:()=>r==null?void 0:r(s),children:[l&&h.jsx(l,{style:{width:12,height:12}}),c,u>0&&h.jsx("span",{className:"text-[9px] min-w-[16px] h-4 flex items-center justify-center rounded-full px-1 tabular-nums",style:{background:"hsl(var(--destructive) / 0.15)",color:"hsl(var(--destructive))"},children:u})]},s)}),h.jsx("div",{className:"flex-1"}),n&&h.jsxs("button",{onClick:n,className:"flex items-center gap-1.5 px-2.5 h-full text-[11px] text-muted-foreground hover:text-foreground transition-colors",title:"Search (⌘K)",children:[h.jsx(Zn,{style:{width:12,height:12}}),h.jsx("kbd",{className:"text-[9px] font-mono opacity-50 bg-muted px-1 py-0.5 rounded",children:"⌘K"})]})]})}function oY(){const[t,e]=C.useState(ly);function r(){const n=!t;q_(n),e(n)}return h.jsx("button",{className:"compose-btn-icon shrink-0",onClick:r,title:t?"Hide verbose events":"Show verbose events","aria-label":"Toggle verbose stream",style:t?{background:"hsl(210 60% 60% / 0.15)",color:"hsl(210 60% 60%)",borderRadius:"3px",padding:"1px 4px",fontSize:"10px"}:{fontSize:"10px"},children:"{ }"})}const Ve={COLLAPSED:"collapsed",EXPANDED:"expanded",MAXIMIZED:"maximized"},aY={[Ve.COLLAPSED]:Ve.EXPANDED,[Ve.EXPANDED]:Ve.MAXIMIZED,[Ve.MAXIMIZED]:Ve.COLLAPSED};function lY(t){return aY[t]??Ve.COLLAPSED}function cY(t){return Ve.COLLAPSED}function hY(t){return Ve.MAXIMIZED}const uY=new Set(Object.values(Ve));function dY(t){return uY.has(t)}function fY(t){switch(t){case Ve.COLLAPSED:return"h-7";case Ve.EXPANDED:return"h-[40vh]";case Ve.MAXIMIZED:return"flex-1";default:return"h-7"}}const UT="compose:agentBarState";function pY(){var t;try{const e=(t=globalThis.localStorage)==null?void 0:t.getItem(UT);return dY(e)?e:Ve.COLLAPSED}catch{return Ve.COLLAPSED}}function mY(t){var e;try{(e=globalThis.localStorage)==null||e.setItem(UT,t)}catch{}}const S0="▾",gY="▴",xY="⤢";function yY({barState:t="collapsed",onStateChange:e}){const[r,n]=C.useState("ready"),[i,s]=C.useState(null);C.useEffect(()=>{function u(d){const{status:p,tool:f,category:m,parallelTasks:x}=d.detail??{};if(s(x??null),x){const{total:g,completed:y,failed:b,active:k}=x;n(`∥ ${y}/${g} tasks${b?` (${b} failed)`:""}${k?` • ${k} active`:""}`)}else n(p==="idle"?"ready":f?`${f} — ${m??p}`:m||(p==="idle"?"ready":p??"ready"))}return window.addEventListener("compose:agent-status",u),()=>window.removeEventListener("compose:agent-status",u)},[]);const o=C.useCallback(()=>{e==null||e(lY(t))},[t,e]),a=C.useCallback(()=>{e==null||e(cY())},[t,e]);C.useCallback(()=>{e==null||e(hY())},[t,e]);const l=t==="collapsed",c=t==="expanded";return h.jsxs("div",{className:"flex flex-col shrink-0 overflow-hidden",style:{borderTop:"1px solid hsl(var(--border))"},"data-agent-bar-state":t,children:[h.jsxs("div",{className:"flex items-center gap-2 px-3 h-7 shrink-0 select-none",style:{borderBottom:l?"none":"1px solid hsl(var(--border) / 0.5)"},children:[h.jsx("button",{className:"compose-btn-icon shrink-0",onClick:o,title:l?"Expand agent bar":c?"Maximize agent bar":"Collapse agent bar","aria-label":"Toggle agent bar",children:l?gY:c?xY:S0}),h.jsx("span",{className:"text-[10px] uppercase tracking-wider font-semibold shrink-0",style:{color:"hsl(var(--accent))"},children:"Agent"}),h.jsx("span",{className:"flex-1 min-w-0 truncate text-[11px] font-mono",style:{color:"hsl(var(--muted-foreground))"},children:r}),h.jsx(oY,{}),i&&i.total>0&&h.jsx("div",{className:"shrink-0 flex items-center gap-1",title:`${i.completed}/${i.total} tasks complete`,children:h.jsx("div",{style:{width:48,height:4,borderRadius:2,background:"hsl(var(--muted))",overflow:"hidden"},children:h.jsx("div",{style:{width:`${i.completed/i.total*100}%`,height:"100%",borderRadius:2,background:i.failed?"hsl(var(--destructive))":"hsl(var(--accent))",transition:"width 300ms ease"}})})}),!l&&h.jsx("button",{className:"compose-btn-icon shrink-0",onClick:a,title:"Collapse agent bar","aria-label":"Collapse agent bar",children:S0})]}),!l&&h.jsx("div",{className:"flex-1 min-h-0 overflow-hidden",children:h.jsx(hy,{})})]})}const bY=280,kY=.6;function vY({isOpen:t=!1,onToggle:e,widthPx:r=380,onResizePx:n,children:i,activeBuild:s,gates:o=[],agentErrors:a=[],items:l=[]}){const c=C.useRef(!1),u=C.useCallback(p=>{p.preventDefault(),c.current=!0;const f=x=>{if(!c.current)return;const g=window.innerWidth-x.clientX,y=window.innerWidth*kY,b=Math.max(bY,Math.min(y,g));n==null||n(b)},m=()=>{c.current=!1,document.removeEventListener("mousemove",f),document.removeEventListener("mouseup",m)};document.addEventListener("mousemove",f),document.addEventListener("mouseup",m)},[n]),d=o.filter(p=>p.status==="pending"||p.status==="awaiting");return h.jsxs("div",{className:"flex shrink-0 h-full",style:{borderLeft:"1px solid hsl(var(--border))"},"data-context-panel-open":t,children:[t&&n&&h.jsx("div",{className:"w-1 cursor-col-resize hover:bg-accent/30 active:bg-accent/50 transition-colors flex-shrink-0",onMouseDown:u}),h.jsx("button",{className:["w-4 h-full flex items-center justify-center","text-[10px] text-muted-foreground hover:text-foreground","transition-colors select-none"].join(" "),onClick:e,title:t?"Close context panel":"Open context panel","aria-expanded":t,"aria-label":"Toggle context panel",style:{background:"hsl(var(--muted) / 0.3)"},children:t?"›":"‹"}),t&&h.jsx("div",{className:"flex flex-col h-full overflow-hidden",style:{width:`${r}px`},children:Yt.Children.toArray(i).length>0?h.jsx("div",{className:"flex-1 min-h-0 flex flex-col overflow-hidden",children:i}):h.jsx(SY,{activeBuild:s,pendingGates:d,agentErrors:a,items:l})})]})}const wY={implementation:"#3b82f6",vision:"#a855f7",planning:"#f59e0b",specification:"#06b6d4",verification:"#22c55e",design:"#f43f5e"};function T0(t){return wY[t]||"#6b7280"}function SY({activeBuild:t,pendingGates:e,agentErrors:r,items:n}){const i={};for(const a of n){const l=a.phase||"unknown";i[l]=(i[l]||0)+1}const s=n.length||1,o=r.slice(-5);return h.jsxs(h.Fragment,{children:[h.jsx("div",{className:"h-7 flex items-center px-3 shrink-0",style:{borderBottom:"1px solid hsl(var(--border))"},children:h.jsx("span",{className:"text-[10px] uppercase tracking-wider font-semibold text-muted-foreground",children:"Project Overview"})}),h.jsxs("div",{className:"flex-1 min-h-0 overflow-y-auto p-3 space-y-4",children:[t?h.jsxs("div",{children:[h.jsx("p",{className:"text-[10px] font-medium uppercase tracking-wider text-muted-foreground mb-1",children:"Active Build"}),h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("span",{className:"text-xs text-accent font-mono",children:t.featureCode||"—"}),h.jsx("span",{className:"text-[10px] text-muted-foreground",children:"·"}),h.jsx("span",{className:"text-[10px] text-foreground",children:t.currentStep||t.step||"—"})]})]}):h.jsxs("div",{children:[h.jsx("p",{className:"text-[10px] font-medium uppercase tracking-wider text-muted-foreground mb-1",children:"Build Status"}),h.jsx("p",{className:"text-[10px] text-muted-foreground italic",children:"No active build"})]}),h.jsxs("div",{children:[h.jsxs("p",{className:"text-[10px] font-medium uppercase tracking-wider text-muted-foreground mb-1",children:["Pending Gates (",e.length,")"]}),e.length===0?h.jsx("p",{className:"text-[10px] text-muted-foreground italic",children:"None"}):h.jsx("div",{className:"space-y-0.5",children:e.slice(0,5).map((a,l)=>h.jsx("p",{className:"text-[10px] text-amber-400 truncate",children:Go(a,n.find(c=>c.id===a.itemId))},l))})]}),h.jsxs("div",{children:[h.jsxs("p",{className:"text-[10px] font-medium uppercase tracking-wider text-muted-foreground mb-1",children:["Recent Errors (",o.length,")"]}),o.length===0?h.jsx("p",{className:"text-[10px] text-muted-foreground italic",children:"None"}):h.jsx("div",{className:"space-y-0.5",children:o.map((a,l)=>h.jsx("p",{className:"text-[10px] text-destructive truncate",children:a.message||a.error||"Error"},l))})]}),h.jsxs("div",{children:[h.jsx("p",{className:"text-[10px] font-medium uppercase tracking-wider text-muted-foreground mb-1",children:"Phase Distribution"}),h.jsx("div",{className:"flex h-2 rounded overflow-hidden gap-px",children:Object.entries(i).map(([a,l])=>h.jsx("div",{className:"h-full",style:{width:`${l/s*100}%`,background:T0(a),opacity:.75,minWidth:"2px"},title:`${a}: ${l}`},a))}),h.jsx("div",{className:"flex flex-wrap gap-x-3 gap-y-0.5 mt-1",children:Object.entries(i).map(([a,l])=>h.jsxs("span",{className:"text-[9px] text-muted-foreground flex items-center gap-1",children:[h.jsx("span",{className:"inline-block w-1.5 h-1.5 rounded-full",style:{background:T0(a)}}),a,": ",l]},a))})]})]})]})}const In=60,Rr=24,ol=80,Cu=28,ku=48,_0=8,fs=5,Sc=9;function TY(t,e){return t?t.length>e?t.slice(0,e)+"…":t:""}function _Y(t,e,r){const n=new Map(e.map(a=>[a.id,a])),i=[],s=[],o=new Map;for(const a of r){if(a.toId===t.id){const l=n.get(a.fromId);l&&i.push(l)}if(a.fromId===t.id){const l=n.get(a.toId);l&&s.push(l)}}for(const a of s){const l=[];for(const c of r)if(c.fromId===a.id&&c.toId!==t.id){const u=n.get(c.toId);u&&l.push(u)}l.length>0&&o.set(a.id,l)}return{parents:i,children:s,grandchildren:o}}function vu(t,e,r,n,i){const s=Math.min(t,fs),o=s*n+(s-1)*_0,a=(r-o)/2,l=[];for(let c=0;c<s;c++)l.push({x:a+c*(n+_0),y:e,w:n,h:i});return{positions:l,overflow:t>fs?t-fs+1:0}}function al({item:t,x:e,y:r,w:n,h:i,isSelected:s,isDashed:o,onSelect:a,onHover:l,onLeave:c}){const u=xr[t.type]||xr.task,d=s?.2:.08;return h.jsxs("g",{style:{cursor:"pointer"},onClick:()=>a(t.id),onMouseEnter:p=>l(t,p),onMouseLeave:c,children:[h.jsx("rect",{x:e,y:r,width:n,height:i,rx:4,fill:u,fillOpacity:d,stroke:u,strokeWidth:s?2:1.5,strokeDasharray:o?"4 2":void 0}),h.jsx("text",{x:e+n/2,y:r+i/2,textAnchor:"middle",dominantBaseline:"central",fontSize:s?Sc+1:Sc,fontWeight:s?600:400,fill:"hsl(var(--foreground))",children:TY(t.title,s?10:8)})]})}function EY({item:t,pos:e}){if(!t||!e)return null;const r=xr[t.type]||xr.task,n=qn[t.status]||qn.planned;return h.jsxs("div",{className:"absolute z-50 pointer-events-none px-2 py-1.5 rounded bg-popover border border-border shadow-md",style:{left:e.x,top:e.y,transform:"translate(-50%, -100%)"},children:[h.jsx("p",{className:"text-xs font-medium text-foreground whitespace-nowrap",children:t.title}),h.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[h.jsx("span",{className:"text-[10px]",style:{color:r},children:t.type}),h.jsxs("span",{className:"text-[10px] flex items-center gap-1",children:[h.jsx("span",{className:"inline-block w-1.5 h-1.5 rounded-full",style:{background:n}}),t.status]}),h.jsx("span",{className:"text-[10px] text-muted-foreground",children:ef[t.confidence||0]})]})]})}function NY({item:t,items:e,connections:r,onSelect:n}){const[i,s]=C.useState(null),[o,a]=C.useState(null),{parents:l,children:c,grandchildren:u}=C.useMemo(()=>_Y(t,e,r),[t,e,r]),d=C.useCallback((I,A)=>{const D=A.currentTarget.closest(".connection-graph-wrap").getBoundingClientRect(),R=A.currentTarget.getBoundingClientRect();s(I),a({x:R.x+R.width/2-D.x,y:R.y-D.y-4})},[]),p=C.useCallback(()=>{s(null),a(null)},[]);if(!(l.length>0||c.length>0))return null;const m=288,x=[];let g=12,y=[],b=0;if(l.length>0){const I=vu(l.length,g,m,In,Rr);y=I.positions,b=I.overflow,g+=Rr+ku}const k=(m-ol)/2,T=g;g+=Cu+ku;let _=[],w=0;if(c.length>0){const I=vu(c.length,g,m,In,Rr);_=I.positions,w=I.overflow,g+=Rr}let E=new Map,B=new Map;const P=[...u.entries()];let N=[];if(P.length>0){g+=ku;for(const[D,R]of P)for(const j of R)N.push({...j,_parentChildId:D});const I=vu(N.length,g,m,In,Rr);let A=0;for(const[D,R]of P){const j=[];for(let S=0;S<R.length&&A<I.positions.length;S++,A++)j.push(I.positions[A]);E.set(D,j)}I.overflow>0&&B.set("all",I.overflow),g+=Rr}const M=g+12;for(let I=0;I<y.length;I++){const A=y[I];x.push({x1:A.x+A.w/2,y1:A.y+A.h,x2:k+ol/2,y2:T})}for(let I=0;I<_.length;I++){const A=_[I];x.push({x1:k+ol/2,y1:T+Cu,x2:A.x+A.w/2,y2:A.y})}for(const[I,A]of E){const D=c.findIndex(R=>R.id===I);if(D>=0&&D<_.length){const R=_[D];for(const j of A)x.push({x1:R.x+R.w/2,y1:R.y+R.h,x2:j.x+j.w/2,y2:j.y})}}const $=l.slice(0,fs-(b>0?1:0)),q=c.slice(0,fs-(w>0?1:0)),O=N.slice(0,fs-(B.size>0?1:0));return h.jsxs("div",{className:"space-y-1",children:[h.jsx("p",{className:"text-[10px] font-medium uppercase tracking-wider text-muted-foreground",children:"Graph"}),h.jsxs("div",{className:"relative connection-graph-wrap",children:[h.jsxs("svg",{width:m,height:M,className:"w-full",viewBox:`0 0 ${m} ${M}`,children:[x.map((I,A)=>h.jsx("line",{x1:I.x1,y1:I.y1,x2:I.x2,y2:I.y2,stroke:"hsl(var(--muted-foreground))",strokeOpacity:.3,strokeWidth:1},A)),$.map((I,A)=>h.jsx(al,{item:I,x:y[A].x,y:y[A].y,w:In,h:Rr,isSelected:!1,isDashed:!0,onSelect:n,onHover:d,onLeave:p},I.id)),b>0&&h.jsxs("text",{x:y[y.length-1].x+In/2,y:y[0].y+Rr/2,textAnchor:"middle",dominantBaseline:"central",fontSize:Sc,fill:"hsl(var(--muted-foreground))",children:["+",b," more"]}),h.jsx(al,{item:t,x:k,y:T,w:ol,h:Cu,isSelected:!0,isDashed:!1,onSelect:n,onHover:d,onLeave:p}),q.map((I,A)=>h.jsx(al,{item:I,x:_[A].x,y:_[A].y,w:In,h:Rr,isSelected:!1,isDashed:!1,onSelect:n,onHover:d,onLeave:p},I.id)),w>0&&h.jsxs("text",{x:_[_.length-1].x+In/2,y:_[0].y+Rr/2,textAnchor:"middle",dominantBaseline:"central",fontSize:Sc,fill:"hsl(var(--muted-foreground))",children:["+",w," more"]}),O.map((I,A)=>{const R=[...E.values()].flat()[A];return R?h.jsx(al,{item:I,x:R.x,y:R.y,w:In,h:Rr,isSelected:!1,isDashed:!1,onSelect:n,onHover:d,onLeave:p},I.id):null})]}),h.jsx(EY,{item:i,pos:o})]})]})}const jY=["Untested","Low","Moderate","High","Crystallized"];function LY({level:t=0,className:e}){const r=Math.max(0,Math.min(4,t||0)),n=jY[r]??"Untested",i=r===0?Xp[0]:Xp[r];return h.jsxs("span",{className:rt("inline-flex items-center gap-1",e),children:[h.jsx("span",{className:"flex items-center gap-0.5",children:[1,2,3,4].map(s=>h.jsx("span",{className:rt("h-2.5 w-1.5 rounded-sm",s<=r?i:"bg-slate-600")},s))}),h.jsx("span",{className:"text-[10px] text-muted-foreground",children:n})]})}function BY(t,e=Date.now()){if(!t)return null;const r=Date.parse(t);if(Number.isNaN(r))return null;const n=e-r,i=Math.floor(n/36e5);return i<1?"<1h ago":i<48?`${i}h ago`:`${Math.floor(i/24)}d ago`}function E0(t){return t==null?"—":t<1e3?String(t):t<1e6?`${(t/1e3).toFixed(1)}k`:`${(t/1e6).toFixed(1)}M`}function AY(t){return t==null?"—":`$${Number(t).toFixed(t<1?3:2)}`}function MY(t){if(t==null)return"—";const e=Math.round(t/1e3);if(e<60)return`${e}s`;const r=Math.round(e/60);if(r<60)return`${r}m`;const n=Math.floor(r/60),i=r%60;return`${n}h${i?` ${i}m`:""}`}function IY(t,e=Date.now()){const r=(t||[]).filter(i=>i==null?void 0:i.started_at);if(!r.length)return null;let n=null;for(const i of r){const s=Date.parse(i.started_at);!Number.isNaN(s)&&(n==null||s>n)&&(n=s)}return n==null?null:BY(new Date(n).toISOString(),e)}function FY(t,e=Date.now()){const r=(t==null?void 0:t.branches)||[],n=r.filter(c=>c.state==="complete"),i=r.filter(c=>c.state==="running"),s=r.length,o=IY(r,e),a=n.length>=2;return{summary:i.length>0&&n.length<2?`${n.length} of ${s} branches ready`:`${s} branch${s===1?"":"es"}${o?` · last fork ${o}`:""}`,canCompare:a,completeBranches:n,runningCount:i.length,totalCount:s}}function PY(t,e=[]){const r=new Map(t.map(s=>[s.branch_id,s])),n=e[0]&&r.has(e[0])?r.get(e[0]):t[0]||null,i=e[1]&&r.has(e[1])?r.get(e[1]):t[1]||null;return[n,i]}function N0({branch:t,extraRows:e=[]}){var o;const r=t.files_touched||[],n=t.tests||{},i=t.cost||{},s=[{label:"Files touched",value:r.length},{label:"Tests",value:`${n.passed??0} / ${n.failed??0} / ${n.skipped??0}`},{label:"Tokens in / out",value:`${E0(i.tokens_in)} / ${E0(i.tokens_out)}`},{label:"USD",value:AY(i.usd)},{label:"Wall clock",value:MY(i.wall_clock_ms)},{label:"Final artifact",value:((o=t.final_artifact)==null?void 0:o.path)||"—"},...e];return h.jsx("div",{className:"space-y-1",children:s.map((a,l)=>h.jsxs("div",{className:"flex justify-between gap-2 text-[10px]",children:[h.jsx("span",{className:"text-muted-foreground",children:a.label}),h.jsx("span",{className:"font-mono text-right truncate",title:typeof a.value=="string"?a.value:void 0,children:a.value})]},l))})}function DY({lineage:t,selectedPair:e=[],onSelectPair:r=()=>{},extraMetricsForBranch:n=()=>[],now:i=Date.now()}){var g,y;const[s,o]=C.useState(!1),{summary:a,canCompare:l,completeBranches:c}=FY(t,i),[u,d]=PY(c,e),p=()=>{l&&(o(b=>!b),!s&&u&&d&&r([u.branch_id,d.branch_id]))};if(!s)return h.jsxs("div",{className:"flex items-center justify-between text-[10px] text-muted-foreground",children:[h.jsx("span",{children:a}),h.jsx("button",{disabled:!l,onClick:p,className:"text-[10px] px-2 py-0.5 rounded border border-border "+(l?"hover:bg-muted/40 text-foreground cursor-pointer":"opacity-40 cursor-not-allowed"),"data-testid":"branch-compare-toggle",children:"Compare"})]});const f=(g=u==null?void 0:u.final_artifact)==null?void 0:g.snapshot,m=(y=d==null?void 0:d.final_artifact)==null?void 0:y.snapshot,x=!!f&&!!m;return h.jsxs("div",{className:"space-y-2 rounded border border-border p-2 bg-muted/10",children:[h.jsxs("div",{className:"flex items-center justify-between",children:[h.jsx("span",{className:"text-[10px] text-muted-foreground",children:a}),h.jsx("button",{onClick:()=>o(!1),className:"text-[10px] text-muted-foreground hover:text-foreground",children:"Collapse"})]}),h.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[h.jsxs("div",{children:[h.jsx("div",{className:"text-[10px] font-semibold mb-1 font-mono truncate",title:u==null?void 0:u.branch_id,children:u?`A: ${u.branch_id.slice(0,8)}…`:"A: (none)"}),u&&h.jsx(N0,{branch:u,extraRows:n(u)})]}),h.jsxs("div",{children:[h.jsx("div",{className:"text-[10px] font-semibold mb-1 font-mono truncate",title:d==null?void 0:d.branch_id,children:d?`B: ${d.branch_id.slice(0,8)}…`:"B: (none)"}),d&&h.jsx(N0,{branch:d,extraRows:n(d)})]})]}),h.jsx("div",{className:"col-span-2",children:x?h.jsx(Rp,{oldText:f,newText:m}):h.jsxs("div",{className:"text-[10px] italic text-muted-foreground",children:["No artifact produced on ",!f&&!m?"either branch":f?"branch B":"branch A","."]})})]})}const OY={path_drift:"Path drift",contract_drift:"Contract drift",review_debt_drift:"Review debt"};function RY(t){return OY[t]??t}function j0(t){return t==null||typeof t!="number"||isNaN(t)?"—":`${Math.round(t*100)}%`}function $Y(t){var r,n;return(((n=(r=t==null?void 0:t.lifecycle)==null?void 0:r.lifecycle_ext)==null?void 0:n.drift_axes)??[]).filter(i=>i.breached===!0)}function zY({item:t}){const[e,r]=C.useState(!1),n=$Y(t);if(n.length===0)return null;const i=n.length;return h.jsxs("div",{className:"drift-ribbon",style:{background:"hsl(var(--destructive) / 0.12)",borderLeft:"3px solid hsl(var(--destructive))",minHeight:"28px",padding:e?"6px 10px 8px":"0 10px",display:"flex",flexDirection:"column",justifyContent:"center",gap:0,borderRadius:"4px",marginBottom:"4px"},children:[h.jsxs("button",{onClick:()=>r(s=>!s),style:{display:"flex",alignItems:"center",gap:"6px",background:"none",border:"none",cursor:"pointer",padding:"4px 0",color:"hsl(var(--destructive))",fontSize:"12px",fontWeight:600,width:"100%",textAlign:"left"},"aria-expanded":e,"data-testid":"drift-ribbon-toggle",children:[h.jsx(Ac,{size:13}),h.jsxs("span",{children:[i," drift alert",i!==1?"s":""," — click to ",e?"collapse":"expand"]}),e?h.jsx(yb,{size:13,style:{marginLeft:"auto"}}):h.jsx(fa,{size:13,style:{marginLeft:"auto"}})]}),e&&h.jsxs("table",{style:{width:"100%",fontSize:"11px",borderCollapse:"collapse",marginTop:"4px"},"data-testid":"drift-ribbon-table",children:[h.jsx("thead",{children:h.jsxs("tr",{style:{color:"hsl(var(--muted-foreground))"},children:[h.jsx("th",{style:{textAlign:"left",padding:"2px 4px",fontWeight:500},children:"Axis"}),h.jsx("th",{style:{textAlign:"right",padding:"2px 4px",fontWeight:500},children:"Ratio"}),h.jsx("th",{style:{textAlign:"right",padding:"2px 4px",fontWeight:500},children:"Threshold"}),h.jsx("th",{style:{textAlign:"left",padding:"2px 4px",fontWeight:500},children:"Explanation"})]})}),h.jsx("tbody",{children:n.map(s=>h.jsxs("tr",{"data-testid":`drift-axis-row-${s.axis_id}`,children:[h.jsx("td",{style:{padding:"2px 4px",color:"hsl(var(--foreground))",fontWeight:500},children:RY(s.axis_id)}),h.jsx("td",{style:{padding:"2px 4px",textAlign:"right",color:"hsl(var(--destructive))"},children:j0(s.ratio)}),h.jsx("td",{style:{padding:"2px 4px",textAlign:"right",color:"hsl(var(--muted-foreground))"},children:j0(s.threshold)}),h.jsx("td",{style:{padding:"2px 4px",color:"hsl(var(--muted-foreground))",maxWidth:"200px",wordBreak:"break-word"},children:s.explanation??""})]},s.axis_id))})]})]})}function WY({level:t,onChange:e}){const r=["hsl(var(--muted-foreground))","hsl(var(--destructive))","hsl(var(--accent))","hsl(var(--success))","hsl(var(--success))"],n=r[t]||r[0];return h.jsxs("button",{onClick:()=>e((t+1)%5),className:"flex items-center gap-2 px-2 py-1 rounded-md bg-muted hover:bg-muted/80 transition-colors",title:"Click to cycle confidence",children:[h.jsx("span",{className:"text-xs text-muted-foreground",children:ef[t]}),h.jsx("div",{className:"flex items-center gap-0.5",children:[0,1,2,3].map(i=>h.jsx("div",{className:"rounded-full transition-all",style:{width:6,height:6,background:i<t?n:"transparent",border:`1.5px solid ${i<t?n:"hsl(var(--border))"}`}},i))})]})}function qY({item:t,connections:e,items:r,onSelect:n,onDeleteConnection:i}){const s=new Map(r.map(l=>[l.id,l])),o=[];for(const l of e)if(l.type!=="contradicts"){if(l.fromId===t.id){const c=s.get(l.toId);c&&o.push({item:c,type:l.type,direction:"outgoing",connId:l.id})}if(l.toId===t.id){const c=s.get(l.fromId);c&&o.push({item:c,type:l.type,direction:"incoming",connId:l.id})}}if(o.length===0)return null;const a={};for(const l of o){const c=`${l.type}-${l.direction}`;a[c]||(a[c]={type:l.type,direction:l.direction,items:[]}),a[c].items.push({item:l.item,connId:l.connId})}return h.jsxs("div",{className:"space-y-2",children:[h.jsx("p",{className:"text-[10px] font-medium uppercase tracking-wider text-muted-foreground",children:"Connections"}),Object.values(a).map(l=>h.jsxs("div",{children:[h.jsx("p",{className:"text-[10px] text-muted-foreground mb-1",children:l.direction==="incoming"?`${l.type} from`:`${l.type} to`}),h.jsx("div",{className:"space-y-0.5",children:l.items.map(({item:c,connId:u})=>h.jsxs("div",{className:"flex w-full items-center gap-2 px-2 py-1 rounded text-left hover:bg-muted/50 transition-colors group/conn",children:[h.jsxs("button",{onClick:()=>n(c.id),className:"flex flex-1 items-center gap-2 min-w-0",children:[h.jsx("div",{className:"w-1.5 h-1.5 rounded-full shrink-0",style:{background:qn[c.status]||qn.planned}}),h.jsx("span",{className:"text-xs text-foreground truncate",children:c.title}),h.jsx("span",{className:"text-[10px] ml-auto shrink-0",style:{color:xr[c.type]},children:c.type})]}),i&&h.jsx("button",{onClick:()=>i(u),className:"opacity-0 group-hover/conn:opacity-100 p-0.5 rounded hover:bg-destructive/20 text-muted-foreground hover:text-destructive transition-all shrink-0",title:"Remove connection",children:h.jsx(cn,{className:"h-3 w-3"})})]},u))})]},`${l.type}-${l.direction}`))]})}function ll(t){if(!t)return"";const e=new Date(t);return e.toLocaleDateString("en-US",{month:"short",day:"numeric"})+" "+e.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit",hour12:!1})}function HY({featureCode:t,lineage:e}){const r=gr(i=>i.selectedBranches),n=gr(i=>i.setSelectedBranches);return h.jsx(DY,{lineage:e,selectedPair:(r==null?void 0:r[t])||[],onSelectPair:i=>n(t,i)})}function UY({featureCode:t}){const[e,r]=C.useState([]),[n,i]=C.useState(!0);return C.useEffect(()=>{const s=new AbortController;return i(!0),Rt(`/api/session/history?featureCode=${encodeURIComponent(t)}&limit=10`,{signal:s.signal}).then(o=>o.json()).then(o=>{s.signal.aborted||r(o.sessions||[])}).catch(o=>{s.signal.aborted||r([])}).finally(()=>{s.signal.aborted||i(!1)}),()=>s.abort()},[t]),n||e.length===0?null:h.jsxs("div",{children:[h.jsxs("div",{className:"text-[10px] font-medium uppercase tracking-wider text-muted-foreground mb-1.5",children:["Sessions (",e.length,")"]}),h.jsx("div",{className:"space-y-2",children:e.map(s=>{var o;return h.jsxs("div",{className:"text-xs text-muted-foreground border-l-2 border-border pl-2",children:[h.jsxs("div",{className:"font-medium text-foreground",children:[((o=s.phaseAtBind)==null?void 0:o.replace(/_/g," "))||"—",s.phaseAtEnd&&s.phaseAtEnd!==s.phaseAtBind&&` → ${s.phaseAtEnd.replace(/_/g," ")}`]}),h.jsxs("div",{children:[s.toolCount," tools · ",Math.round((new Date(s.endedAt)-new Date(s.startedAt))/6e4),"m"]})]},s.id)})})]})}const GY=["informs","supports","blocks","contradicts"];function VY({item:t,items:e,onCreateConnection:r,onDismiss:n}){const[i,s]=C.useState(""),[o,a]=C.useState("informs"),l=e.filter(u=>u.id===t.id?!1:i?u.title.toLowerCase().includes(i.toLowerCase()):!0).slice(0,8),c=C.useCallback(async u=>{await r({fromId:t.id,toId:u,type:o}),n()},[t.id,o,r,n]);return h.jsx("div",{className:"absolute bottom-full left-0 mb-1 w-64 rounded-md border border-border bg-popover shadow-lg z-50",children:h.jsxs("div",{className:"p-2 space-y-2",children:[h.jsxs("div",{className:"flex items-center gap-1.5",children:[h.jsx("select",{className:"text-[10px] px-1.5 py-1 rounded bg-muted text-foreground border border-border cursor-pointer",value:o,onChange:u=>a(u.target.value),children:GY.map(u=>h.jsx("option",{value:u,children:u},u))}),h.jsx("span",{className:"text-[10px] text-muted-foreground",children:"to..."})]}),h.jsxs("div",{className:"relative",children:[h.jsx(Zn,{className:"absolute left-2 top-1/2 -translate-y-1/2 h-3 w-3 text-muted-foreground"}),h.jsx("input",{className:"w-full text-xs bg-muted text-foreground pl-7 pr-2 py-1.5 rounded border border-border outline-none",placeholder:"Search items...",value:i,onChange:u=>s(u.target.value),autoFocus:!0})]}),h.jsx("div",{className:"max-h-40 overflow-auto space-y-0.5",children:l.length===0?h.jsx("p",{className:"text-[10px] text-muted-foreground text-center py-2",children:"No items found"}):l.map(u=>h.jsxs("button",{onClick:()=>c(u.id),className:"flex w-full items-center gap-2 px-2 py-1 rounded text-left hover:bg-muted/50 transition-colors",children:[h.jsx("div",{className:"w-1.5 h-1.5 rounded-full shrink-0",style:{background:qn[u.status]||qn.planned}}),h.jsx("span",{className:"text-xs text-foreground truncate",children:u.title}),h.jsx("span",{className:"text-[10px] ml-auto shrink-0",style:{color:xr[u.type]},children:u.type})]},u.id))})]})})}function YY({gate:t,onResolveGate:e}){const[r,n]=C.useState(null),[i,s]=C.useState(""),o=()=>{e(t.id,"revised",i||void 0),n(null),s("")},a=()=>{i.trim()&&(e(t.id,"killed",i),n(null),s(""))};return h.jsxs("div",{className:"space-y-1.5",children:[h.jsxs("div",{className:"flex items-center gap-1.5",children:[h.jsx($t,{variant:"outline",size:"sm",className:"h-6 text-[10px] gap-1 text-success border-success/30 hover:bg-success/10",onClick:()=>e(t.id,"approved"),children:"Approve"}),h.jsx($t,{variant:"outline",size:"sm",className:rt("h-6 text-[10px] gap-1 text-amber-400 border-amber-400/30 hover:bg-amber-400/10",r==="revise"&&"bg-amber-400/10"),onClick:()=>{n(r==="revise"?null:"revise"),s("")},children:"Revise"}),h.jsx($t,{variant:"outline",size:"sm",className:rt("h-6 text-[10px] gap-1 text-destructive border-destructive/30 hover:bg-destructive/10",r==="kill"&&"bg-destructive/10"),onClick:()=>{n(r==="kill"?null:"kill"),s("")},children:"Kill"})]}),r&&h.jsxs("div",{className:"flex items-center gap-1.5",children:[h.jsx("input",{className:"flex-1 text-xs bg-muted text-foreground px-2 py-1 rounded border border-border outline-none",placeholder:r==="revise"?"Feedback (optional)...":"Kill reason (required)...",value:i,onChange:l=>s(l.target.value),onKeyDown:l=>{l.key==="Enter"&&(r==="revise"?o():a()),l.key==="Escape"&&n(null)},autoFocus:!0}),h.jsx($t,{variant:"outline",size:"sm",className:"h-6 text-[10px]",disabled:r==="kill"&&!i.trim(),onClick:r==="revise"?o:a,children:r==="revise"?"Submit":"Confirm Kill"})]})]})}function XY({item:t,items:e,connections:r,gates:n,onUpdate:i,onDelete:s,onCreateConnection:o,onDeleteConnection:a,onSelect:l,onClose:c,onPressureTest:u,onResolveGate:d}){var I,A,D,R,j,S;const[p,f]=C.useState(!1),[m,x]=C.useState(""),[g,y]=C.useState(!1),[b,k]=C.useState(""),[T,_]=C.useState(!1),[w,E]=C.useState("");C.useEffect(()=>{E((t==null?void 0:t.group)||"")},[t==null?void 0:t.id,t==null?void 0:t.group]);const B=C.useCallback(()=>{const W=w.trim(),K=(t==null?void 0:t.group)||"";W!==K&&i(t.id,{group:W||null})},[w,t==null?void 0:t.id,t==null?void 0:t.group,i]),P=C.useCallback(()=>{x(t.title),f(!0)},[t==null?void 0:t.title]),N=C.useCallback(()=>{m.trim()&&m!==t.title&&i(t.id,{title:m.trim()}),f(!1)},[m,t==null?void 0:t.id,t==null?void 0:t.title,i]),M=C.useCallback(()=>{k(t.description||""),y(!0)},[t==null?void 0:t.description]),$=C.useCallback(()=>{b!==(t.description||"")&&i(t.id,{description:b}),y(!1)},[b,t==null?void 0:t.id,t==null?void 0:t.description,i]),q=C.useMemo(()=>{if(!t)return 0;let W=0;for(const K of r)K.type==="contradicts"&&(K.fromId===t.id||K.toId===t.id)&&W++;return W},[t==null?void 0:t.id,r]);if(!t)return null;const O=xr[t.type]||xr.task;return h.jsxs("div",{className:"w-full bg-card flex flex-col h-full",children:[h.jsxs("div",{className:"p-3 pb-2 flex items-start gap-2",children:[h.jsxs("div",{className:"flex-1 min-w-0",children:[h.jsxs("div",{className:"flex items-center gap-1.5 mb-1.5",children:[h.jsx(nr,{variant:"outline",className:"text-[10px] px-1.5 py-0 h-4",style:{color:O,borderColor:O},children:t.type}),t.phase&&h.jsx(nr,{variant:"outline",className:"text-[10px] px-1.5 py-0 h-4",children:jl[t.phase]||t.phase})]}),p?h.jsx("input",{className:"w-full text-sm font-semibold bg-muted text-foreground px-1.5 py-0.5 rounded border border-ring outline-none",value:m,onChange:W=>x(W.target.value),onBlur:N,onKeyDown:W=>{W.key==="Enter"&&N(),W.key==="Escape"&&f(!1)},autoFocus:!0}):h.jsx("h3",{className:"text-sm font-semibold text-foreground cursor-pointer hover:text-accent transition-colors",onDoubleClick:P,title:"Double-click to edit",children:t.title})]}),h.jsx($t,{variant:"ghost",size:"icon",className:"h-6 w-6 shrink-0",onClick:c,children:h.jsx(cn,{className:"h-3.5 w-3.5"})})]}),h.jsx(zl,{}),h.jsx(Hn,{className:"flex-1",children:h.jsxs("div",{className:"p-3 space-y-4",children:[h.jsx(zY,{item:t}),((I=t.lifecycle)==null?void 0:I.featureCode)&&h.jsx(HY,{featureCode:t.lifecycle.featureCode,lineage:(A=t.lifecycle.lifecycle_ext)==null?void 0:A.branch_lineage}),h.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[h.jsx("select",{className:"text-xs px-2 py-1 rounded-md bg-muted text-foreground border border-border cursor-pointer",value:t.status||"planned",onChange:W=>i(t.id,{status:W.target.value}),children:x_.map(W=>h.jsx("option",{value:W,children:W.replace("_"," ")},W))}),h.jsx(WY,{level:t.confidence||0,onChange:W=>i(t.id,{confidence:W})})]}),h.jsx(LY,{level:t.confidence||0}),h.jsxs("div",{children:[h.jsx("p",{className:"text-[10px] font-medium uppercase tracking-wider text-muted-foreground mb-1",children:"Phase"}),h.jsxs("select",{className:"text-xs px-2 py-1 rounded-md bg-muted text-foreground border border-border cursor-pointer w-full",value:t.phase||"",onChange:W=>i(t.id,{phase:W.target.value||null}),children:[h.jsx("option",{value:"",children:"No phase"}),ny.map(W=>h.jsx("option",{value:W,children:jl[W]},W))]})]}),h.jsxs("div",{children:[h.jsx("p",{className:"text-[10px] font-medium uppercase tracking-wider text-muted-foreground mb-1",children:"Group"}),h.jsx("input",{type:"text",className:"w-full text-xs bg-muted text-foreground px-2 py-1 rounded-md border border-border outline-none focus:border-ring",value:w,placeholder:"(none)",onChange:W=>E(W.target.value),onBlur:B,onKeyDown:W=>{W.key==="Enter"&&(W.preventDefault(),W.currentTarget.blur()),W.key==="Escape"&&(E(t.group||""),W.currentTarget.blur())},"data-testid":"item-detail-group-input"})]}),h.jsxs("div",{children:[h.jsx("p",{className:"text-[10px] font-medium uppercase tracking-wider text-muted-foreground mb-1",children:"Description"}),g?h.jsx("textarea",{className:"w-full text-xs bg-muted text-foreground px-2 py-1.5 rounded border border-ring outline-none resize-none",rows:4,value:b,onChange:W=>k(W.target.value),onBlur:$,onKeyDown:W=>{W.key==="Escape"&&y(!1)},autoFocus:!0}):h.jsx("p",{className:rt("text-xs leading-relaxed cursor-pointer rounded px-2 py-1.5 hover:bg-muted/50 transition-colors",t.description?"text-muted-foreground":"text-muted-foreground/50 italic"),onClick:M,children:t.description||"Click to add description..."})]}),h.jsx(qY,{item:t,connections:r,items:e,onSelect:l,onDeleteConnection:a}),h.jsx(NY,{item:t,items:e,connections:r,onSelect:l}),((D=t.lifecycle)==null?void 0:D.featureCode)&&h.jsx(UY,{featureCode:t.lifecycle.featureCode}),(t.lifecycle||n&&n.some(W=>W.itemId===t.id))&&(()=>{var st;const W=t.lifecycle,K=n?n.filter(J=>J.itemId===t.id):[],F=K.filter(J=>J.status==="pending"),ht=K.filter(J=>J.status!=="pending");return h.jsxs("div",{children:[h.jsx("p",{className:"text-[10px] font-medium uppercase tracking-wider text-muted-foreground mb-1.5",children:"Lifecycle"}),h.jsxs("div",{className:"space-y-1.5",children:[W&&h.jsxs("div",{className:"flex items-center gap-2 px-2 py-1 rounded bg-muted/30",children:[h.jsx("span",{className:"text-[10px] text-muted-foreground",children:"Phase:"}),h.jsx("span",{className:"text-[10px] text-foreground font-medium",children:ve[W.currentPhase]??W.currentPhase}),W.featureCode&&h.jsx("span",{className:"text-[10px] text-muted-foreground ml-auto font-mono",children:W.featureCode})]}),((st=W==null?void 0:W.phaseHistory)==null?void 0:st.length)>1&&h.jsxs("div",{className:"px-2 py-1 rounded bg-muted/30",children:[h.jsx("p",{className:"text-[10px] text-muted-foreground mb-0.5",children:"History"}),h.jsx("div",{className:"flex flex-wrap gap-x-1 gap-y-0.5",children:W.phaseHistory.map((J,ct)=>h.jsxs("span",{className:rt("text-[10px]",J.phase===W.currentPhase?"text-foreground font-medium":"text-muted-foreground"),children:[ve[J.phase]??J.phase,J.outcome&&J.outcome!=="approved"&&h.jsxs("span",{className:"text-amber-400",children:[" (",J.outcome,")"]}),ct<W.phaseHistory.length-1&&" → "]},ct))})]}),F.map(J=>{var at,Z;const ct=J.artifactAssessment,zt=iy[J.fromPhase];return h.jsxs("div",{className:"rounded bg-amber-400/10 border border-amber-400/20 px-2 py-1.5",children:[h.jsxs("p",{className:"text-[10px] text-amber-400 font-medium mb-1",children:["Pending: ",vn[J.stepId]??`${ve[J.fromPhase]??J.fromPhase} → ${ve[J.toPhase]??J.toPhase}`]}),ct&&ct.exists&&h.jsxs("p",{className:"text-[10px] text-muted-foreground mb-1",children:[zt&&h.jsx("span",{className:"font-mono",children:zt}),zt&&": ",Math.round(ct.completeness*100),"% complete"," · ",ct.wordCount," words",((Z=(at=ct.sections)==null?void 0:at.missing)==null?void 0:Z.length)>0&&h.jsxs("span",{className:"text-amber-400",children:[" (missing: ",ct.sections.missing.join(", "),")"]}),!ct.meetsMinWordCount&&h.jsx("span",{className:"text-amber-400",children:" (below min word count)"})]}),ct&&!ct.exists&&h.jsxs("p",{className:"text-[10px] text-muted-foreground mb-1",children:[zt??"Artifact"," not found"]}),d&&h.jsx(YY,{gate:J,onResolveGate:d})]},J.id)}),ht.map(J=>{const ct={approved:"text-success",revised:"text-amber-400",killed:"text-destructive"};return h.jsxs("div",{className:"flex items-center gap-2 px-2 py-1 rounded bg-muted/30",children:[h.jsx("span",{className:"text-[10px] text-muted-foreground",children:vn[J.stepId]??`${ve[J.fromPhase]??J.fromPhase} → ${ve[J.toPhase]??J.toPhase}`}),h.jsx(nr,{variant:"outline",className:rt("text-[10px] px-1.5 py-0 h-4 ml-auto",ct[J.outcome]||""),children:J.outcome})]},J.id)})]})]})})(),((j=(R=t.evidence)==null?void 0:R.stratumViolations)==null?void 0:j.length)>0&&h.jsxs("div",{children:[h.jsxs("p",{className:"text-[10px] font-medium uppercase tracking-wider text-destructive mb-1.5",children:["Blocked — Ensure Violations",t.evidence.violatedAt&&h.jsx("span",{className:"ml-2 font-normal normal-case text-muted-foreground",children:ll(t.evidence.violatedAt)})]}),h.jsx("div",{className:"space-y-0.5",children:t.evidence.stratumViolations.map((W,K)=>h.jsxs("div",{className:"flex items-start gap-2 px-2 py-1 rounded bg-destructive/10",children:[h.jsx("div",{className:"w-1.5 h-1.5 rounded-full shrink-0 mt-1",style:{background:"hsl(var(--destructive))"}}),h.jsx("span",{className:"text-[10px] text-destructive leading-relaxed",children:W})]},K))})]}),((S=t.evidence)==null?void 0:S.stratumTrace)&&h.jsxs("div",{children:[h.jsxs("p",{className:"text-[10px] font-medium uppercase tracking-wider text-muted-foreground mb-1.5",children:["Stratum Trace",t.evidence.tracedAt&&h.jsx("span",{className:"ml-2 font-normal normal-case",children:ll(t.evidence.tracedAt)})]}),h.jsx("div",{className:"space-y-0.5",children:(t.evidence.stratumTrace.trace||[]).map(W=>h.jsxs("div",{className:"flex items-center gap-2 px-2 py-1 rounded bg-muted/30",children:[h.jsx("div",{className:"w-1.5 h-1.5 rounded-full shrink-0",style:{background:"hsl(var(--success))"}}),h.jsx("span",{className:"text-[10px] font-mono text-foreground truncate flex-1",children:W.step_id}),W.attempts>1&&h.jsxs("span",{className:"text-[10px] text-amber-400 shrink-0",children:[W.attempts,"x"]}),W.duration_ms!=null&&h.jsx("span",{className:"text-[10px] text-muted-foreground shrink-0",children:W.duration_ms<1e3?`${W.duration_ms}ms`:`${(W.duration_ms/1e3).toFixed(1)}s`})]},W.step_id))})]}),h.jsxs("div",{className:"space-y-0.5",children:[h.jsxs("p",{className:"text-[10px] text-muted-foreground",children:["Created ",ll(t.createdAt)]}),h.jsxs("p",{className:"text-[10px] text-muted-foreground",children:["Updated ",ll(t.updatedAt)]})]}),h.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[h.jsxs("div",{className:"relative",children:[h.jsxs($t,{variant:"outline",size:"sm",className:rt("h-7 text-xs gap-1",T&&"bg-accent/10 border-accent"),onClick:()=>_(!T),children:[h.jsx(pM,{className:"h-3 w-3"})," Connect"]}),T&&h.jsx(VY,{item:t,items:e,onCreateConnection:o,onDismiss:()=>_(!1)})]}),h.jsxs($t,{variant:"outline",size:"sm",className:"h-7 text-xs gap-1",onClick:P,children:[h.jsx(Sb,{className:"h-3 w-3"})," Rename"]}),t.type!=="question"&&h.jsxs($t,{variant:"outline",size:"sm",className:"h-7 text-xs gap-1",onClick:()=>u(t.id),title:"Challenge this item's assumptions",children:[h.jsx(Pl,{className:"h-3 w-3"})," Pressure Test",q>0&&h.jsx("span",{className:"ml-0.5 text-[10px] px-1 py-0 rounded-full bg-amber-500/20 text-amber-400",children:q})]}),t.status!=="killed"&&h.jsxs($t,{variant:"outline",size:"sm",className:"h-7 text-xs gap-1 text-destructive border-destructive/30 hover:bg-destructive/10",onClick:async()=>{if(t.lifecycle)try{const W=await Rt(`/api/vision/items/${t.id}/lifecycle/kill`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({reason:"Killed via UI"})});if(!W.ok){const K=await W.json();console.error("[vision] Lifecycle kill failed:",K.error)}}catch(W){console.error("[vision] Lifecycle kill failed:",W.message)}else i(t.id,{status:"killed"})},children:[h.jsx(Vm,{className:"h-3 w-3"})," Kill"]}),s&&h.jsxs($t,{variant:"outline",size:"sm",className:"h-7 text-xs gap-1 text-destructive border-destructive/30 hover:bg-destructive/10",onClick:()=>{window.confirm(`Delete "${t.title}" permanently? This cannot be undone.`)&&s(t.id)},title:"Permanently delete this item",children:[h.jsx(Vm,{className:"h-3 w-3"})," Delete"]})]})]})})]})}const GT=[{id:"overview",label:"Overview"},{id:"pipeline",label:"Pipeline"},{id:"sessions",label:"Sessions"},{id:"errors",label:"Errors"},{id:"files",label:"Files"}];GT.map(t=>t.id);const KY={overview:Ei,pipeline:vb,sessions:Cb,errors:Ac,files:Tf};function ZY({activeTab:t="overview",onTabChange:e,errorCount:r=0}){return h.jsx("div",{className:"flex items-center gap-0 shrink-0",style:{height:"28px",borderBottom:"1px solid hsl(var(--border))",background:"hsl(var(--muted) / 0.3)"},role:"tablist","aria-label":"Detail sections",children:GT.map(({id:n,label:i})=>{const s=KY[n],o=n===t,a=n==="errors"?r:0;return h.jsxs("button",{role:"tab","aria-selected":o,className:["flex items-center gap-1 px-2 h-full text-[10px] uppercase tracking-wider font-medium transition-colors","border-b-2 -mb-px",o?"border-accent text-accent":"border-transparent text-muted-foreground hover:text-foreground hover:border-border"].join(" "),onClick:()=>e==null?void 0:e(n),children:[h.jsx(s,{style:{width:10,height:10}}),i,a>0&&h.jsx("span",{className:"text-[8px] min-w-[14px] h-3.5 flex items-center justify-center rounded-full px-0.5 tabular-nums",style:{background:"hsl(var(--destructive) / 0.15)",color:"hsl(var(--destructive))"},children:a})]},n)})})}const L0=[{id:"design",label:"Design"},{id:"blueprint",label:"Blueprint"},{id:"execute",label:"Execute"},{id:"review",label:"Review"},{id:"coverage",label:"Coverage"},{id:"ship",label:"Ship"}];function Ud(t,e,r,n){if(r&&r.featureCode===n&&r.currentStep===t)return"active";if(e&&Array.isArray(e)){const i=e.find(s=>s.phase===t||s.step===t);if(i)return i.status==="failed"?"failed":"complete"}return"pending"}function QY({item:t,activeBuild:e}){const[r,n]=C.useState(null),i=(t==null?void 0:t.phaseHistory)||[],s=(t==null?void 0:t.featureCode)||(t==null?void 0:t.text)||"";return h.jsxs("div",{className:"p-3",children:[h.jsx("div",{className:"flex items-center gap-0 mb-3",children:L0.map((o,a)=>{const l=Ud(o.id,i,e,s),c=Yp[l],u=r===o.id;return h.jsxs(Yt.Fragment,{children:[a>0&&h.jsx("div",{className:"flex-1 h-px",style:{background:l==="pending"?"hsl(var(--muted-foreground) / 0.2)":c,minWidth:"8px"}}),h.jsxs("button",{onClick:()=>n(u?null:o.id),className:"relative flex flex-col items-center group",title:o.label,children:[h.jsx("div",{className:["w-3 h-3 rounded-full border-2 transition-all",l==="active"?"animate-pulse":"",u?"ring-2 ring-accent/30":""].join(" "),style:{borderColor:c,background:l==="complete"||l==="failed"?c:"transparent"}}),h.jsx("span",{className:"text-[8px] text-muted-foreground mt-1 opacity-0 group-hover:opacity-100 transition-opacity whitespace-nowrap",children:o.label})]})]},o.id)})}),h.jsx("div",{className:"flex justify-between px-0.5",children:L0.map(o=>{const a=Ud(o.id,i,e,s);return h.jsx("span",{className:"text-[8px] font-medium uppercase tracking-wider",style:{color:a==="pending"?"hsl(var(--muted-foreground) / 0.4)":Yp[a]},children:o.label},o.id)})}),r&&h.jsx("div",{className:"mt-3 p-2 rounded border border-border/50 bg-muted/20",children:h.jsx(JY,{stepId:r,phaseHistory:i,activeBuild:e,featureCode:s})})]})}function JY({stepId:t,phaseHistory:e,activeBuild:r,featureCode:n}){const i=Ud(t,e,r,n),s=e==null?void 0:e.find(a=>a.phase===t||a.step===t),o={complete:"text-success",active:"text-accent",failed:"text-destructive",pending:"text-muted-foreground"};return h.jsxs("div",{className:"space-y-1.5",children:[h.jsxs("div",{className:"flex items-center justify-between",children:[h.jsx("span",{className:"text-xs font-semibold text-foreground capitalize",children:t}),h.jsx("span",{className:`text-[10px] font-medium ${o[i]}`,children:i})]}),(s==null?void 0:s.summary)&&h.jsx("p",{className:"text-[10px] text-muted-foreground",children:s.summary}),(s==null?void 0:s.durationMs)!=null&&h.jsxs("p",{className:"text-[10px] text-muted-foreground",children:["Duration: ",s.durationMs<1e3?`${s.durationMs}ms`:`${(s.durationMs/1e3).toFixed(1)}s`]}),(s==null?void 0:s.agent)&&h.jsxs("p",{className:"text-[10px] text-muted-foreground",children:["Agent: ",s.agent]}),i==="active"&&r&&h.jsx("p",{className:"text-[10px] text-accent",children:"Running..."}),i==="pending"&&h.jsx("p",{className:"text-[10px] text-muted-foreground italic",children:"Not started"})]})}function tX(t){if(!t)return"";const e=Date.now()-new Date(t).getTime();return e<6e4?"just now":e<36e5?`${Math.floor(e/6e4)}m ago`:e<864e5?`${Math.floor(e/36e5)}h ago`:`${Math.floor(e/864e5)}d ago`}function eX(t){return t?t<1e3?`${t}ms`:t<6e4?`${(t/1e3).toFixed(0)}s`:`${(t/6e4).toFixed(1)}m`:"—"}function rX({featureCode:t,sessions:e=[],items:r=[]}){const[n,i]=C.useState(null),s=C.useMemo(()=>t?new Set(r.filter(a=>{var l;return((l=a.lifecycle)==null?void 0:l.featureCode)===t||a.featureCode===t||a.feature_code===t}).map(a=>a.id)):new Set,[t,r]),o=C.useMemo(()=>s.size===0?e.slice(0,20):e.filter(a=>!!(a.featureCode===t||a.itemsWorked&&a.itemsWorked.some(l=>s.has(l))||a.summary&&a.summary.includes(t))),[e,t,s]);return o.length===0?h.jsx("div",{className:"p-3 text-[11px] text-muted-foreground italic",children:"No sessions for this feature."}):h.jsxs("div",{className:"p-2 space-y-0.5",children:[h.jsxs("p",{className:"text-[10px] font-medium uppercase tracking-wider text-muted-foreground px-1 mb-1",children:["Sessions (",o.length,")"]}),o.map(a=>{const l=n===a.id;return h.jsxs("div",{children:[h.jsxs("button",{onClick:()=>i(l?null:a.id),className:"flex items-center gap-2 w-full px-2 py-1.5 text-left rounded hover:bg-muted/30 transition-colors",children:[h.jsx("span",{className:"text-[10px] font-mono text-accent shrink-0 w-12 truncate",children:a.source||"agent"}),h.jsx("span",{className:"text-[10px] text-muted-foreground shrink-0 w-16 truncate",children:a.classification||a.workType||"—"}),h.jsxs("span",{className:"text-[9px] text-muted-foreground tabular-nums flex gap-1.5 shrink-0",children:[h.jsxs("span",{title:"reads",children:[a.reads||0,"r"]}),h.jsxs("span",{title:"writes",children:[a.writes||0,"w"]}),h.jsxs("span",{title:"errors",style:a.errors>0?{color:"hsl(var(--destructive))"}:{},children:[a.errors||0,"e"]})]}),h.jsx("span",{className:"text-[9px] text-muted-foreground tabular-nums shrink-0",children:eX(a.durationMs)}),h.jsx("span",{className:"text-[9px] text-muted-foreground ml-auto shrink-0",children:tX(a.startedAt||a.createdAt)})]}),l&&a.summary&&h.jsx("div",{className:"px-3 py-1.5 text-[10px] text-muted-foreground bg-muted/10 rounded mx-1 mb-1",children:a.summary})]},a.id)})]})}function nX(t){if(!t)return"";const e=Date.now()-new Date(t).getTime();return e<6e4?"just now":e<36e5?`${Math.floor(e/6e4)}m ago`:e<864e5?`${Math.floor(e/36e5)}h ago`:`${Math.floor(e/864e5)}d ago`}const wu=10;function iX({featureCode:t,errors:e=[],items:r=[]}){const[n,i]=C.useState(null),[s,o]=C.useState(!1),a=C.useMemo(()=>t?new Set(r.filter(u=>{var d;return((d=u.lifecycle)==null?void 0:d.featureCode)===t||u.featureCode===t||u.feature_code===t}).map(u=>u.id)):new Set,[t,r]),l=C.useMemo(()=>!t&&a.size===0?[]:e.filter(u=>!!(t&&u.featureCode===t||u.itemId&&a.has(u.itemId)||t&&u.message&&u.message.includes(t))),[e,t,a]);if(l.length===0)return h.jsxs("div",{className:"p-3 flex flex-col items-center gap-2 text-muted-foreground",children:[h.jsx(HA,{style:{width:20,height:20,color:"hsl(var(--success, 160 60% 45%))"}}),h.jsx("span",{className:"text-[11px] italic",children:"No errors for this feature."})]});const c=s?l:l.slice(0,wu);return h.jsxs("div",{className:"p-2 space-y-0.5",children:[h.jsxs("p",{className:"text-[10px] font-medium uppercase tracking-wider text-muted-foreground px-1 mb-1",children:["Errors (",l.length,")"]}),c.map((u,d)=>{const p=n===d;return h.jsxs("button",{onClick:()=>i(p?null:d),className:"flex flex-col w-full px-2 py-1.5 text-left rounded hover:bg-destructive/5 transition-colors",children:[h.jsxs("div",{className:"flex items-center gap-2 w-full",children:[h.jsx("span",{className:"text-[10px] text-destructive shrink-0",children:"✕"}),h.jsx("span",{className:"text-[10px] font-mono text-muted-foreground shrink-0 w-16 truncate",children:u.tool||u.toolName||"unknown"}),h.jsx("span",{className:`text-[10px] text-foreground flex-1 ${p?"":"line-clamp-2"} truncate`,children:u.message||u.error||"Unknown error"}),h.jsx("span",{className:"text-[9px] text-muted-foreground shrink-0 ml-auto",children:nX(u.timestamp||u.createdAt)})]}),p&&h.jsx("div",{className:"mt-1.5 px-5 py-1.5 text-[10px] text-foreground font-mono bg-muted/10 rounded whitespace-pre-wrap break-all",children:u.message||u.error||u.stack||"No additional details"})]},d)}),!s&&l.length>wu&&h.jsxs("button",{onClick:()=>o(!0),className:"w-full text-center text-[10px] text-accent hover:underline py-1",children:["Show ",l.length-wu," more"]})]})}function sX(t){return t?t<1024?`${t}B`:t<1048576?`${(t/1024).toFixed(1)}KB`:`${(t/1048576).toFixed(1)}MB`:"—"}function oX(t){if(!t)return"";const e=Date.now()-new Date(t).getTime();return e<6e4?"just now":e<36e5?`${Math.floor(e/6e4)}m ago`:e<864e5?`${Math.floor(e/36e5)}h ago`:`${Math.floor(e/864e5)}d ago`}function aX({featureCode:t,onOpenFile:e}){const[r,n]=C.useState([]),[i,s]=C.useState(!0);C.useEffect(()=>{const l=new AbortController;return s(!0),Rt("/api/files",{signal:l.signal}).then(c=>c.json()).then(c=>{l.signal.aborted||(n(Array.isArray(c)?c:c.files||[]),s(!1))}).catch(c=>{l.signal.aborted||(n([]),s(!1))}),()=>l.abort()},[t]);const o=`docs/features/${t}/`,a=C.useMemo(()=>r.filter(l=>(typeof l=="string"?l:l.path||l.name||"").startsWith(o)),[r,o]);return i?h.jsx("div",{className:"p-3 text-[11px] text-muted-foreground italic",children:"Loading files..."}):a.length===0?h.jsxs("div",{className:"p-3 flex flex-col items-center gap-2 text-muted-foreground",children:[h.jsx(Tf,{style:{width:20,height:20,opacity:.5}}),h.jsx("span",{className:"text-[11px] italic",children:"No files in feature folder."})]}):h.jsxs("div",{className:"p-2 space-y-0.5",children:[h.jsxs("p",{className:"text-[10px] font-medium uppercase tracking-wider text-muted-foreground px-1 mb-1",children:["Files (",a.length,")"]}),a.map((l,c)=>{const u=typeof l=="string"?l:l.path||l.name||"",d=u.split("/").pop(),p=typeof l=="object"?l.size:null,f=typeof l=="object"?l.modified||l.mtime:null;return h.jsxs("button",{onClick:()=>e==null?void 0:e(u),className:"flex items-center gap-2 w-full px-2 py-1.5 text-left rounded hover:bg-accent/10 transition-colors",children:[h.jsx(Ei,{className:"h-3 w-3 shrink-0 text-accent"}),h.jsx("span",{className:"text-xs text-foreground truncate flex-1",children:d}),p!=null&&h.jsx("span",{className:"text-[9px] text-muted-foreground tabular-nums shrink-0",children:sX(p)}),f&&h.jsx("span",{className:"text-[9px] text-muted-foreground shrink-0",children:oX(f)})]},c)})]})}function lX({itemId:t,onSelect:e,onClose:r,onOpenFile:n,onViewInGraph:i,onViewInTree:s}){var w;const{items:o,connections:a,gates:l,updateItem:c,deleteItem:u,createConnection:d,deleteConnection:p,resolveGate:f,activeBuild:m,sessions:x,agentErrors:g}=gr(Li(E=>({items:E.items,connections:E.connections,gates:E.gates,updateItem:E.updateItem,deleteItem:E.deleteItem,createConnection:E.createConnection,deleteConnection:E.deleteConnection,resolveGate:E.resolveGate,activeBuild:E.activeBuild,sessions:E.sessions,agentErrors:E.agentErrors}))),y=o.find(E=>E.id===t)||null,[b,k]=C.useState("overview"),T=((w=y==null?void 0:y.lifecycle)==null?void 0:w.featureCode)||(y==null?void 0:y.featureCode)||(y==null?void 0:y.feature_code)||"",_=C.useMemo(()=>T?g.filter(E=>E.featureCode===T||T&&E.message&&E.message.includes(T)):[],[g,T]);return y?h.jsxs("div",{className:"h-full flex flex-col",children:[h.jsx(ZY,{activeTab:b,onTabChange:k,errorCount:_.length}),h.jsxs("div",{className:"flex-1 min-h-0 overflow-auto",children:[b==="overview"&&h.jsxs(h.Fragment,{children:[h.jsx(XY,{item:y,items:o,connections:a,gates:l,onUpdate:(E,B)=>c(E,B),onDelete:E=>{u(E),r()},onCreateConnection:d,onDeleteConnection:p,onSelect:e,onClose:r,onPressureTest:()=>{},onResolveGate:f}),h.jsxs("div",{className:"flex items-center gap-3 px-4 py-2 mt-1",style:{borderTop:"1px solid hsl(var(--border))"},children:[i&&h.jsxs("button",{onClick:()=>i(t),className:"flex items-center gap-1 text-[11px] text-muted-foreground hover:text-foreground transition-colors",children:[h.jsx("span",{style:{fontSize:10},children:"↑"})," View in Graph"]}),s&&h.jsxs("button",{onClick:()=>s(t),className:"flex items-center gap-1 text-[11px] text-muted-foreground hover:text-foreground transition-colors",children:[h.jsx("span",{style:{fontSize:10},children:"↓"})," View in Tree"]})]})]}),b==="pipeline"&&h.jsx(QY,{item:y,activeBuild:m}),b==="sessions"&&h.jsx(rX,{featureCode:T,sessions:x,items:o}),b==="errors"&&h.jsx(iX,{featureCode:T,errors:g,items:o}),b==="files"&&h.jsx(aX,{featureCode:T,onOpenFile:n})]})]}):h.jsx("div",{className:"p-3 text-[11px] text-muted-foreground italic",children:"Item not found."})}function cX(t){if(!t)return null;const{retries:e}=t;return e==null?null:Array.isArray(e)?e.length===0?null:{count:e.length,isArray:!0,items:e}:typeof e=="number"&&e>0?{count:e,isArray:!1,items:[]}:null}function hX(t){var e;return(e=t==null?void 0:t.violations)!=null&&e.length?t.violations:[]}function uX(t,e){if(!t)return null;for(const r of t.values())if(r.stepId===e)return r;return null}function dX(t,e,r){var c;if(!t||t.status!=="running")return null;const n=t.startedAt?Date.parse(t.startedAt):r,i=r-n,s=t.wallClockTimeout!=null?t.wallClockTimeout*60*1e3:null,o=(c=e==null?void 0:e.per_loop_type)==null?void 0:c[t.loopType],a=(o==null?void 0:o.maxTotal)!=null?o.usedIterations:null,l=(o==null?void 0:o.maxTotal)??null;return{count:t.count??0,maxIterations:t.maxIterations??null,loopType:t.loopType,elapsedMs:i,timeoutMs:s,usedIterations:a,maxTotal:l}}function fX(t){if(!(t!=null&&t.per_loop_type))return"";const e={review:"r",coverage:"c"},r=[];for(const[n,i]of Object.entries(e)){const s=t.per_loop_type[n];!s||s.maxTotal==null||r.push(`${i} ${s.usedIterations}/${s.maxTotal}`)}return r.join(" · ")}function B0(t){return!t||t<=0?"$0.00":`$${t.toFixed(4)}`}const A0=[{id:"T0",name:"schema",label:"T0"},{id:"T1",name:"lint",label:"T1"},{id:"T2",name:"tests",label:"T2"},{id:"T3",name:"review",label:"T3"},{id:"T4",name:"codex",label:"T4"}];function pX({tierMap:t,tierSummary:e}){const[r,n]=C.useState(null),i=s=>n(o=>o===s?null:s);return h.jsxs("div",{children:[h.jsx("p",{className:"text-[10px] font-medium uppercase tracking-wider text-muted-foreground mb-1.5",children:"Tier Pipeline"}),h.jsxs("div",{className:"flex items-center gap-1.5",children:[A0.map((s,o)=>{var d;const a=t[s.id],l=(d=e==null?void 0:e.tiersSkipped)==null?void 0:d.includes(s.id);let c,u;return l?(c="bg-muted-foreground/40",u=`${s.id} (${s.name}): skipped`):a===!0?(c="bg-success",u=`${s.id} (${s.name}): passed`):a===!1?(c="bg-destructive",u=`${s.id} (${s.name}): failed`):(c="bg-muted-foreground/20",u=`${s.id} (${s.name}): not run`),h.jsxs(Yt.Fragment,{children:[o>0&&h.jsx("div",{className:"h-px w-3 bg-muted-foreground/20 shrink-0"}),h.jsxs("button",{className:"flex flex-col items-center gap-0.5 group",onClick:()=>i(s.id),title:u,children:[h.jsx("div",{className:`w-2.5 h-2.5 rounded-full transition-all group-hover:scale-125 ${c} ${r===s.id?"ring-1 ring-foreground/40":""}`}),h.jsx("span",{className:"text-[8px] text-muted-foreground leading-none",children:s.label})]})]},s.id)}),(e==null?void 0:e.costSaved)>0&&h.jsxs("span",{className:"ml-2 text-[9px] text-success/80",children:["saved ~$",e.costSaved.toFixed(2)]})]}),r&&h.jsx("div",{className:"mt-1.5 px-2 py-1 rounded bg-muted/20 text-[9px] text-muted-foreground",children:(()=>{var l;const s=t[r],o=(l=e==null?void 0:e.tiersSkipped)==null?void 0:l.includes(r),a=A0.find(c=>c.id===r);return o?`${r} (${a==null?void 0:a.name}): skipped — short-circuited by earlier failure`:s===!0?`${r} (${a==null?void 0:a.name}): passed`:s===!1?`${r} (${a==null?void 0:a.name}): failed`:`${r} (${a==null?void 0:a.name}): not run this build`})()})]})}function Su(t){return t>=80?"text-success":t>=60?"text-amber-400":"text-destructive"}function mX(t){return t==="improving"?"↑":t==="declining"?"↓":"→"}const M0={test_coverage:"Tests",review_findings:"Review",contract_compliance:"Contracts",runtime_errors:"Runtime",doc_freshness:"Docs",plan_completion:"Plan"};function I0(t){if(t==null)return"—";const e=Math.floor(t/1e3);if(e<60)return`${e}s`;const r=Math.floor(e/60),n=e%60;return`${r}:${String(n).padStart(2,"0")}`}function gX({loopState:t,budget:e}){const[r,n]=C.useState(()=>Date.now());C.useEffect(()=>{if(!t||t.status!=="running")return;const s=setInterval(()=>n(Date.now()),1e3);return()=>clearInterval(s)},[t]);const i=dX(t,e,r);return i?h.jsxs("div",{children:[h.jsx("p",{className:"text-[10px] font-medium uppercase tracking-wider text-muted-foreground mb-1",children:"Live Counters"}),h.jsxs("div",{className:"space-y-0.5 text-[10px]",children:[h.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[h.jsxs("span",{className:"text-foreground font-mono font-medium",children:["attempt ",i.count,"/",i.maxIterations??"?"]}),h.jsx("span",{className:"text-muted-foreground",children:"·"}),h.jsxs("span",{className:"text-foreground font-mono",children:[I0(i.elapsedMs),i.timeoutMs!=null&&h.jsxs("span",{className:"text-muted-foreground",children:[" / ",I0(i.timeoutMs)]})]}),i.usedIterations!=null&&i.maxTotal!=null&&h.jsxs(h.Fragment,{children:[h.jsx("span",{className:"text-muted-foreground",children:"·"}),h.jsxs("span",{className:"text-foreground font-mono",children:["cumulative ",i.usedIterations,"/",i.maxTotal]})]})]}),h.jsxs("div",{className:"text-muted-foreground/70 text-[9px]",children:["loop: ",i.loopType]})]})]}):null}function xX({stepId:t,tierEvents:e=[],healthEvents:r=[],capabilityEvents:n=[]}){const{activeBuild:i,iterationStates:s}=gr(Li(P=>({activeBuild:P.activeBuild,iterationStates:P.iterationStates}))),[o,a]=C.useState(!1),[l,c]=C.useState(null),u=(i==null?void 0:i.featureCode)??null,d=C.useRef(null);C.useEffect(()=>{if(!u){c(null);return}u!==d.current&&(d.current=u,Rt(`/api/lifecycle/budget?featureCode=${encodeURIComponent(u)}`).then(P=>P.json()).then(P=>c(P)).catch(()=>{}))},[u]);const{step:p,allSteps:f}=C.useMemo(()=>i!=null&&i.steps?{step:i.steps.find(N=>N.id===t||N.step_id===t)||null,allSteps:i.steps}:{step:null,allSteps:[]},[i,t]),m=C.useMemo(()=>{if(!r||r.length===0)return null;for(let P=r.length-1;P>=0;P--){const N=r[P];if(N.subtype==="health_score"&&typeof N.score=="number")return N}return null},[r]),{tierMap:x,tierSummary:g}=C.useMemo(()=>{if(!e||e.length===0)return{tierMap:{},tierSummary:null};const P={};let N=null;for(const M of e)M.subtype==="gate_tier_result"?P[M.tierId]=M.passed:M.subtype==="gate_tier_summary"&&(N=M);return{tierMap:P,tierSummary:N}},[e]),y=Object.keys(x).length>0||g!==null,b=C.useMemo(()=>{const P=f.filter(N=>N.cost_usd!=null);return P.length===0?[]:[...P].sort((N,M)=>o?(N.cost_usd??0)-(M.cost_usd??0):(M.cost_usd??0)-(N.cost_usd??0))},[f,o]),k=b.length>0?b[0].id:null,T=C.useMemo(()=>cX(p),[p]),_=C.useMemo(()=>hX(p),[p]),w=C.useMemo(()=>uX(s,t),[s,t]),E=C.useMemo(()=>{if(!n||n.length===0)return null;const P=n.filter($=>$.stepId===t);if(P.length===0)return null;const N=P.filter($=>$.severity==="violation").length,M=P.filter($=>$.severity==="warning").length;return{total:P.length,hardViolations:N,warnings:M}},[n,t]);if(!p)return h.jsxs("div",{className:"p-3 text-[11px] text-muted-foreground italic",children:["Step “",t,"” not found in active build."]});const B={done:"text-success",running:"text-accent",failed:"text-destructive",pending:"text-muted-foreground",skipped:"text-muted-foreground"};return h.jsxs("div",{className:"p-3 space-y-3",children:[h.jsxs("div",{children:[h.jsx("p",{className:"text-[10px] font-medium uppercase tracking-wider text-muted-foreground mb-1",children:"Build Step"}),h.jsx("p",{className:"text-sm font-semibold text-foreground font-mono",children:p.id||p.step_id})]}),h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("span",{className:"text-[10px] text-muted-foreground",children:"Status:"}),h.jsx("span",{className:`text-xs font-medium ${B[p.status]||"text-foreground"}`,children:p.status||"unknown"})]}),T&&h.jsxs("div",{children:[h.jsx("p",{className:"text-[10px] font-medium uppercase tracking-wider text-amber-400/80 mb-1",children:"Retries"}),h.jsxs("p",{className:"text-xs text-amber-400",children:["Retried ",T.count," ",T.count===1?"time":"times"]}),T.isArray&&T.items.length>0&&h.jsx("div",{className:"mt-1 space-y-0.5",children:T.items.map((P,N)=>h.jsxs("div",{className:"text-[10px] text-muted-foreground pl-2",children:["#",N+1,P.reason?`: ${P.reason}`:""]},N))})]}),p.durationMs!=null&&h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("span",{className:"text-[10px] text-muted-foreground",children:"Duration:"}),h.jsx("span",{className:"text-xs text-foreground",children:p.durationMs<1e3?`${p.durationMs}ms`:p.durationMs<6e4?`${(p.durationMs/1e3).toFixed(1)}s`:`${(p.durationMs/6e4).toFixed(1)}m`})]}),p.summary&&h.jsxs("div",{children:[h.jsx("span",{className:"text-[10px] text-muted-foreground",children:"Summary:"}),h.jsx("p",{className:"text-xs text-foreground mt-0.5",children:p.summary})]}),p.artifact&&h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("span",{className:"text-[10px] text-muted-foreground",children:"Artifact:"}),h.jsx("span",{className:"text-xs text-foreground font-mono truncate",children:p.artifact})]}),p.agent&&h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("span",{className:"text-[10px] text-muted-foreground",children:"Agent:"}),h.jsx("span",{className:"text-xs text-foreground font-mono",children:p.agent})]}),p.filesChanged&&p.filesChanged.length>0&&h.jsxs("div",{children:[h.jsxs("p",{className:"text-[10px] font-medium uppercase tracking-wider text-muted-foreground mb-1",children:["Files Changed (",p.filesChanged.length,")"]}),h.jsx("div",{className:"space-y-0.5 max-h-32 overflow-y-auto",children:p.filesChanged.map((P,N)=>h.jsx("p",{className:"text-[10px] text-foreground font-mono truncate",children:P},N))})]}),(p.input_tokens>0||p.output_tokens>0||p.cost_usd>0)&&h.jsxs("div",{children:[h.jsx("p",{className:"text-[10px] font-medium uppercase tracking-wider text-muted-foreground mb-1",children:"Tokens & Cost"}),h.jsxs("div",{className:"grid grid-cols-3 gap-1 text-[10px]",children:[h.jsx("span",{className:"text-muted-foreground",children:"Input"}),h.jsx("span",{className:"text-muted-foreground",children:"Output"}),h.jsx("span",{className:"text-muted-foreground",children:"Cost"}),h.jsx("span",{className:"text-foreground font-mono",children:(p.input_tokens??0).toLocaleString()}),h.jsx("span",{className:"text-foreground font-mono",children:(p.output_tokens??0).toLocaleString()}),h.jsx("span",{className:"text-foreground font-mono",children:B0(p.cost_usd)})]})]}),y&&h.jsx("div",{children:h.jsx(pX,{tierMap:x,tierSummary:g})}),_.length>0&&h.jsxs("div",{children:[h.jsx("p",{className:"text-[10px] font-medium uppercase tracking-wider text-destructive mb-1",children:"Postcondition Violations"}),h.jsx("div",{className:"space-y-0.5",children:_.map((P,N)=>h.jsxs("div",{className:"flex items-start gap-2 px-2 py-1 rounded bg-destructive/10",children:[h.jsx("div",{className:"w-1.5 h-1.5 rounded-full shrink-0 mt-1",style:{background:"hsl(var(--destructive))"}}),h.jsx("span",{className:"text-[10px] text-destructive leading-relaxed",children:typeof P=="string"?P:P.message||JSON.stringify(P)})]},N))})]}),E&&h.jsxs("div",{children:[h.jsx("p",{className:"text-[10px] font-medium uppercase tracking-wider text-amber-400/80 mb-1",children:"Capability Findings"}),h.jsxs("p",{className:"text-xs text-amber-400",children:[E.total," ",E.total===1?"finding":"findings"," ","(",E.hardViolations," ",E.hardViolations===1?"violation":"violations",","," ",E.warnings," ",E.warnings===1?"warning":"warnings",")"]})]}),(w==null?void 0:w.status)==="running"&&h.jsx(gX,{loopState:w,budget:l}),m!=null&&h.jsxs("div",{children:[h.jsx("p",{className:"text-[10px] font-medium uppercase tracking-wider text-muted-foreground mb-1.5",children:"Health Score"}),h.jsxs("div",{className:"flex items-baseline gap-2 mb-2",children:[h.jsx("span",{className:`text-2xl font-bold font-mono tabular-nums ${Su(m.score)}`,children:m.score}),h.jsx("span",{className:"text-[10px] text-muted-foreground",children:"/100"}),m.trend&&h.jsxs("span",{className:`text-sm font-mono ${Su(m.score)}`,children:[mX(m.trend.direction),m.trend.delta!=null&&h.jsxs("span",{className:"text-[10px] ml-0.5",children:[m.trend.delta>0?"+":"",Math.round(m.trend.delta)]})]})]}),m.breakdown&&Object.keys(m.breakdown).length>0&&h.jsxs("div",{className:"space-y-1",children:[Object.entries(m.breakdown).map(([P,N])=>h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("span",{className:"text-[9px] text-muted-foreground w-16 shrink-0",children:M0[P]??P}),h.jsx("div",{className:"flex-1 h-1.5 rounded-full bg-muted-foreground/20 overflow-hidden",children:h.jsx("div",{className:`h-full rounded-full transition-all ${N>=80?"bg-success":N>=60?"bg-amber-400":"bg-destructive"}`,style:{width:`${N}%`}})}),h.jsx("span",{className:`text-[9px] font-mono w-6 text-right ${Su(N)}`,children:N})]},P)),m.missing&&m.missing.length>0&&h.jsxs("p",{className:"text-[9px] text-muted-foreground/60 mt-0.5",children:["No data: ",m.missing.map(P=>M0[P]??P).join(", ")]})]})]}),b.length>1&&h.jsxs("div",{children:[h.jsxs("div",{className:"flex items-center justify-between mb-1",children:[h.jsx("p",{className:"text-[10px] font-medium uppercase tracking-wider text-muted-foreground",children:"Build Cost Breakdown"}),h.jsx("button",{className:"text-[9px] text-muted-foreground hover:text-foreground transition-colors",onClick:()=>a(P=>!P),children:o?"cost asc":"cost desc"})]}),h.jsx("div",{className:"overflow-x-auto",children:h.jsxs("table",{className:"w-full text-[10px] border-collapse",children:[h.jsx("thead",{children:h.jsxs("tr",{className:"text-muted-foreground",children:[h.jsx("th",{className:"text-left pr-2 pb-0.5 font-medium",children:"Step"}),h.jsx("th",{className:"text-right pr-2 pb-0.5 font-medium",children:"In"}),h.jsx("th",{className:"text-right pr-2 pb-0.5 font-medium",children:"Out"}),h.jsx("th",{className:"text-right pb-0.5 font-medium",children:"Cost"}),h.jsx("th",{className:"text-right pb-0.5 pl-2 font-medium",children:"Dur"})]})}),h.jsx("tbody",{children:b.map(P=>{const N=P.id===k,M=P.id===t,$=P.durationMs!=null?P.durationMs<1e3?`${P.durationMs}ms`:P.durationMs<6e4?`${(P.durationMs/1e3).toFixed(1)}s`:`${(P.durationMs/6e4).toFixed(1)}m`:"—";return h.jsxs("tr",{className:`${N?"text-amber-400":"text-foreground"} ${M?"font-semibold":""}`,children:[h.jsx("td",{className:"pr-2 py-0.5 font-mono truncate max-w-[80px]",children:P.id}),h.jsxs("td",{className:"text-right pr-2 py-0.5 font-mono",children:[((P.input_tokens??0)/1e3).toFixed(1),"k"]}),h.jsxs("td",{className:"text-right pr-2 py-0.5 font-mono",children:[((P.output_tokens??0)/1e3).toFixed(1),"k"]}),h.jsx("td",{className:"text-right py-0.5 font-mono",children:B0(P.cost_usd)}),h.jsx("td",{className:"text-right pl-2 py-0.5 text-muted-foreground",children:$})]},P.id)})})]})})]})]})}function VT(t){const e=[],r=/```decision\n([\s\S]*?)```/g;let n=0,i;for(;(i=r.exec(t))!==null;){i.index>n&&e.push({type:"text",content:t.slice(n,i.index)});const s=i[1].trim();try{e.push({type:"decision",content:JSON.parse(s)})}catch{e.push({type:"text",content:s})}n=i.index+i[0].length}return n<t.length&&e.push({type:"text",content:t.slice(n)}),e.length===0&&e.push({type:"text",content:t}),{parts:e}}function F0(t,e){var l;const r=(e||[]).filter(c=>!c.superseded);if(r.length===0)return"";let n=`# Design Document
|
|
717
|
+
For more information, see https://radix-ui.com/primitives/docs/components/${e.docsSlug}`;return C.useEffect(()=>{t&&(document.getElementById(t)||console.error(r))},[r,t]),null},lV="DialogDescriptionWarning",cV=({contentRef:t,descriptionId:e})=>{const n=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${AT(lV).contentName}}.`;return C.useEffect(()=>{var s;const i=(s=t.current)==null?void 0:s.getAttribute("aria-describedby");e&&i&&(document.getElementById(e)||console.warn(n))},[n,t,e]),null},hV=bT,uV=vT,MT=wT,IT=ST,FT=_T,PT=NT,dV=LT;const qp=hV,fV=uV,DT=C.forwardRef(({className:t,...e},r)=>h.jsx(MT,{ref:r,className:rt("fixed inset-0 z-50 bg-black/60 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",t),...e}));DT.displayName=MT.displayName;const sh=C.forwardRef(({className:t,children:e,...r},n)=>h.jsxs(fV,{children:[h.jsx(DT,{}),h.jsxs(IT,{ref:n,className:rt("fixed left-[50%] top-[50%] z-50 translate-x-[-50%] translate-y-[-50%]","w-full max-w-lg rounded-lg border border-slate-700 bg-card shadow-xl","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","data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%]","data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%]",t),...r,children:[e,h.jsxs(dV,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground",children:[h.jsx(cn,{className:"h-4 w-4"}),h.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));sh.displayName=IT.displayName;const oh=({className:t,...e})=>h.jsx("div",{className:rt("flex flex-col space-y-1.5 p-6 pb-4",t),...e});oh.displayName="DialogHeader";const Hp=({className:t,...e})=>h.jsx("div",{className:rt("flex items-center justify-end gap-2 p-6 pt-4",t),...e});Hp.displayName="DialogFooter";const ah=C.forwardRef(({className:t,...e},r)=>h.jsx(FT,{ref:r,className:rt("text-sm font-semibold text-foreground leading-none tracking-tight",t),...e}));ah.displayName=FT.displayName;const pV=C.forwardRef(({className:t,...e},r)=>h.jsx(PT,{ref:r,className:rt("text-sm text-muted-foreground",t),...e}));pV.displayName=PT.displayName;const k0=[{id:"task",label:"Task",defaults:{type:"task",phase:"planning",priority:1,governance:"flag"}},{id:"decision",label:"Decision",defaults:{type:"decision",phase:"specification",priority:2,governance:"gate"}},{id:"question",label:"Question",defaults:{type:"question",phase:"specification",priority:1,governance:"flag"}},{id:"idea",label:"Idea",defaults:{type:"idea",phase:"vision",priority:0,governance:"skip"}},{id:"spec",label:"Spec",defaults:{type:"spec",phase:"specification",priority:2,governance:"gate"}}],mV=["gate","flag","skip"];function v0(t){return{type:"task",title:"",description:"",phase:(t==null?void 0:t.phase)??"planning",priority:1,assignedTo:"unassigned",governance:"flag",featureCode:""}}function OT({open:t,onClose:e,parentItem:r}){const n=gr(b=>b.createItem),[i,s]=C.useState(()=>v0(r)),[o,a]=C.useState("task"),[l,c]=C.useState(!1),[u,d]=C.useState(!1),[p,f]=C.useState(""),m=C.useRef(null);C.useEffect(()=>{if(t){const b=v0(r);s(b),a("task"),c(!1),f(""),setTimeout(()=>{var k;return(k=m.current)==null?void 0:k.focus()},50)}},[t,r]);const x=b=>{const k=k0.find(T=>T.id===b);k&&(a(b),s(T=>({...T,type:k.defaults.type,phase:(r==null?void 0:r.phase)??k.defaults.phase,priority:k.defaults.priority,governance:k.defaults.governance})))},g=async()=>{if(!i.title.trim()){f("Title is required");return}d(!0),f("");try{const b={type:i.type,title:i.title.trim(),description:i.description.trim()||void 0,phase:i.phase||void 0,status:"planned",confidence:0,priority:i.priority,assignedTo:i.assignedTo!=="unassigned"?i.assignedTo:void 0,governance:i.governance!=="flag"?i.governance:void 0,featureCode:i.featureCode.trim()||void 0};await n(b),e()}catch{f("Failed to create item")}finally{d(!1)}},y=b=>{b.key==="Enter"&&!b.shiftKey&&b.target.tagName!=="TEXTAREA"&&(b.preventDefault(),g())};return h.jsx(qp,{open:t,onOpenChange:b=>!b&&e(),children:h.jsxs(sh,{className:"max-w-md",onKeyDown:y,children:[h.jsx(oh,{children:h.jsx(ah,{children:"New Item"})}),h.jsxs("div",{className:"px-6 pb-2 space-y-4",children:[h.jsx("div",{className:"grid grid-cols-5 gap-1.5",children:k0.map(b=>h.jsx("button",{type:"button",onClick:()=>x(b.id),className:rt("rounded-md px-2 py-1.5 text-[11px] font-medium border transition-colors",o===b.id?"bg-accent/10 border-accent/60 text-accent":"border-border/40 text-muted-foreground hover:border-border hover:text-foreground"),children:b.label},b.id))}),h.jsx("input",{ref:m,type:"text",placeholder:"Item title…",value:i.title,onChange:b=>s(k=>({...k,title:b.target.value})),className:"w-full text-sm bg-muted text-foreground px-3 py-2 rounded-md border border-border outline-none focus:border-ring"}),h.jsx("textarea",{placeholder:"Description (optional)…",value:i.description,onChange:b=>s(k=>({...k,description:b.target.value})),rows:2,className:"w-full text-sm bg-muted text-foreground px-3 py-2 rounded-md border border-border outline-none focus:border-ring resize-none"}),h.jsxs("button",{type:"button",onClick:()=>c(b=>!b),className:"flex items-center gap-1 text-[11px] text-muted-foreground hover:text-foreground transition-colors",children:[l?h.jsx(yb,{className:"h-3 w-3"}):h.jsx(fa,{className:"h-3 w-3"}),"Advanced"]}),l&&h.jsxs("div",{className:"space-y-3 border border-border/40 rounded-md p-3 bg-muted/20",children:[h.jsxs("label",{className:"flex flex-col gap-1",children:[h.jsx("span",{className:"text-[10px] text-muted-foreground uppercase tracking-wider",children:"Feature Code"}),h.jsx("input",{type:"text",placeholder:"e.g. COMP-UI-5",value:i.featureCode,onChange:b=>s(k=>({...k,featureCode:b.target.value})),className:"text-xs bg-muted text-foreground px-2 py-1 rounded border border-border outline-none"})]}),h.jsxs("label",{className:"flex flex-col gap-1",children:[h.jsx("span",{className:"text-[10px] text-muted-foreground uppercase tracking-wider",children:"Phase"}),h.jsx("select",{value:i.phase,onChange:b=>s(k=>({...k,phase:b.target.value})),className:"text-xs bg-muted text-foreground px-2 py-1 rounded border border-border cursor-pointer",children:ny.map(b=>h.jsx("option",{value:b,children:jl[b]??b},b))})]}),h.jsxs("label",{className:"flex flex-col gap-1",children:[h.jsx("span",{className:"text-[10px] text-muted-foreground uppercase tracking-wider",children:"Priority"}),h.jsxs("select",{value:i.priority,onChange:b=>s(k=>({...k,priority:Number(b.target.value)})),className:"text-xs bg-muted text-foreground px-2 py-1 rounded border border-border cursor-pointer",children:[h.jsx("option",{value:0,children:"Low (0)"}),h.jsx("option",{value:1,children:"Normal (1)"}),h.jsx("option",{value:2,children:"High (2)"}),h.jsx("option",{value:3,children:"Critical (3)"})]})]}),h.jsxs("label",{className:"flex flex-col gap-1",children:[h.jsx("span",{className:"text-[10px] text-muted-foreground uppercase tracking-wider",children:"Assign to"}),h.jsx("select",{value:i.assignedTo,onChange:b=>s(k=>({...k,assignedTo:b.target.value})),className:"text-xs bg-muted text-foreground px-2 py-1 rounded border border-border cursor-pointer",children:sy.map(b=>h.jsx("option",{value:b,children:b},b))})]}),h.jsxs("div",{className:"flex flex-col gap-1",children:[h.jsx("span",{className:"text-[10px] text-muted-foreground uppercase tracking-wider",children:"Governance"}),h.jsx("div",{className:"flex gap-1.5",children:mV.map(b=>h.jsx("button",{type:"button",onClick:()=>s(k=>({...k,governance:b})),className:rt("flex-1 text-[11px] px-2 py-1 rounded border transition-colors",i.governance===b?b==="gate"?"bg-amber-500/20 text-amber-300 border-amber-500/40":b==="flag"?"bg-blue-500/20 text-blue-300 border-blue-500/40":"bg-slate-700 text-slate-400 border-slate-600":"border-border/40 text-muted-foreground hover:border-border"),children:b},b))})]})]}),p&&h.jsx("p",{className:"text-xs text-destructive",children:p})]}),h.jsxs(Hp,{children:[h.jsx($t,{variant:"ghost",size:"sm",onClick:e,disabled:u,children:"Cancel"}),h.jsx($t,{size:"sm",onClick:g,disabled:u||!i.title.trim(),children:u?"Creating…":"Create"})]})]})})}const gV=["explore_design","prd","architecture","blueprint","verification","plan","execute","report","docs","ship"],xV=[{id:"gate",Icon:qs,label:"Gate",active:"bg-amber-500/20 text-amber-300 border-amber-500/40"},{id:"flag",Icon:kb,label:"Flag",active:"bg-blue-500/20 text-blue-300 border-blue-500/40"},{id:"skip",Icon:_b,label:"Skip",active:"bg-slate-700 text-slate-400 border-slate-600"}];function yV(t,e){var r,n;return((n=(r=t==null?void 0:t.governance)==null?void 0:r.phases)==null?void 0:n[e])??"flag"}function RT({open:t,onClose:e,settings:r,onSettingsChange:n}){const[i,s]=C.useState(!1),o=C.useRef(null),a=C.useCallback((l,c)=>{n==null||n({governance:{phases:{[l]:c}}}),clearTimeout(o.current),s(!0),o.current=setTimeout(()=>s(!1),1500)},[n]);return h.jsx(qp,{open:t,onOpenChange:l=>!l&&e(),children:h.jsxs(sh,{className:"max-w-sm",children:[h.jsx(oh,{children:h.jsxs("div",{className:"flex items-center justify-between pr-6",children:[h.jsx(ah,{children:"Governance Settings"}),i&&h.jsx("span",{className:"text-[11px] text-emerald-400 font-medium",children:"Saved ✓"})]})}),h.jsx("div",{className:"px-6 pb-6 space-y-1 max-h-96 overflow-y-auto",children:gV.map(l=>{const c=l==="explore_design",u=yV(r,l),d=ve[l]??l;return h.jsxs("div",{className:rt("flex items-center gap-3 rounded-md px-2 py-1.5",c&&"opacity-40"),children:[h.jsx("span",{className:rt("text-xs flex-1 min-w-0 truncate",c?"text-muted-foreground":"text-foreground"),children:d}),c?h.jsx("span",{className:"text-[10px] text-muted-foreground italic",children:"no policy"}):h.jsx("div",{className:"flex gap-1 shrink-0",children:xV.map(p=>{const f=u===p.id,{Icon:m}=p;return h.jsxs("button",{onClick:()=>a(l,p.id),title:p.label,className:rt("flex items-center gap-1 px-2 py-0.5 text-[10px] rounded border transition-colors",f?p.active:"border-border/30 text-muted-foreground hover:border-border hover:text-foreground"),children:[h.jsx(m,{className:"h-2.5 w-2.5"}),p.label]},p.id)})})]},l)})}),h.jsx("div",{className:"px-6 pb-4 text-[10px] text-muted-foreground border-t border-border/30 pt-3",children:"Agent config via Compose CLI"})]})})}function $T({onOpenGate:t}){const{gates:e,items:r}=gr(Li(g=>({gates:g.gates,items:g.items}))),[n,i]=C.useState(new Set),[s,o]=C.useState(0),a=e.filter(g=>g.status==="pending"&&!n.has(g.id));if(a.length===0)return null;const l=Math.min(s,a.length-1),c=a[l],u=r.find(g=>g.id===c.itemId)||r.find(g=>{var y;return((y=g.lifecycle)==null?void 0:y.featureCode)&&c.featureCode&&g.lifecycle.featureCode===c.featureCode}),d=Go(c,u),p=C_[c.fromPhase]??k_,f=()=>{i(g=>new Set([...g,c.id])),l>=a.length-1&&l>0&&o(l-1)},m=()=>o(Math.max(0,l-1)),x=()=>o(Math.min(a.length-1,l+1));return h.jsxs("div",{className:rt("shrink-0 h-10 border-t flex items-center gap-2 px-3",p.bg,p.border),children:[h.jsx(qs,{className:rt("h-3.5 w-3.5 shrink-0",p.text)}),h.jsx("span",{className:rt("text-[11px] font-medium truncate flex-1 min-w-0",p.text),children:d}),a.length>1&&h.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[h.jsx("button",{onClick:m,disabled:l===0,className:"p-0.5 rounded hover:bg-muted/50 disabled:opacity-30 transition-colors",children:h.jsx(xb,{className:"h-3 w-3"})}),h.jsxs("span",{className:"text-[10px] text-muted-foreground tabular-nums",children:[l+1,"/",a.length]}),h.jsx("button",{onClick:x,disabled:l===a.length-1,className:"p-0.5 rounded hover:bg-muted/50 disabled:opacity-30 transition-colors",children:h.jsx(js,{className:"h-3 w-3"})})]}),h.jsx("button",{onClick:()=>t==null?void 0:t(c.id),className:rt("shrink-0 text-[10px] px-2 py-0.5 rounded border transition-colors hover:opacity-80",p.border,p.text),children:"Review"}),h.jsx("button",{onClick:f,className:"shrink-0 p-0.5 rounded hover:bg-muted/50 text-muted-foreground hover:text-foreground transition-colors",title:"Dismiss (page session only)",children:h.jsx(cn,{className:"h-3 w-3"})})]})}const bV="●",CV="text-zinc-400";function kV(t,e){if(!t)return"";const n=(e??Date.now())-new Date(t).getTime(),i=Math.floor(n/6e4);if(i<1)return"now";if(i<60)return`${i}m`;const s=Math.floor(i/60);return s<24?`${s}h`:`${Math.floor(s/24)}d`}function vV(t){var e;return((e=oy[t])==null?void 0:e.icon)??bV}function wV(t){var e;return((e=oy[t])==null?void 0:e.color)??CV}const SV={IMPLEMENTER:"bg-blue-500/15 text-blue-300 border border-blue-500/25",REVIEWER:"bg-emerald-500/15 text-emerald-300 border border-emerald-500/25",PRODUCER:"bg-purple-500/15 text-purple-300 border border-purple-500/25"};function TV(t){return SV[t]??"bg-zinc-500/15 text-zinc-300 border border-zinc-500/25"}function _V(t,e){return t.filter(r=>r.feature_code===e).slice().sort((r,n)=>r.timestamp.localeCompare(n.timestamp))}function EV(t){if(!t)return"";try{return new Date(t).toISOString().slice(11,16)}catch{return""}}function NV({event:t,now:e}){const r=vV(t.kind),n=wV(t.kind),i=kV(t.timestamp,e);return h.jsxs("div",{"data-decision-card":!0,className:"inline-flex flex-col gap-0.5 w-40 shrink-0 rounded border border-border/40 bg-muted/20 px-2 py-1.5 text-left",children:[h.jsxs("div",{className:"flex items-center justify-between gap-1",children:[h.jsx("span",{className:rt("text-[11px] shrink-0",n),children:r}),h.jsx("span",{className:"text-[10px] text-muted-foreground/50 tabular-nums",children:i||EV(t.timestamp)})]}),h.jsx("p",{className:"text-[11px] text-foreground/80 truncate leading-tight",children:t.title}),t.roles&&t.roles.length>0&&h.jsx("div",{className:"flex flex-wrap gap-0.5 mt-0.5",children:t.roles.map((s,o)=>h.jsx("span",{"data-role-chip":!0,className:rt("text-[9px] px-1 py-px rounded-full leading-tight",TV(s.name)),children:s.name},o))})]})}function zT({events:t=[],currentFeatureCode:e,now:r}){const n=_V(t,e);return n.length===0?null:h.jsx("div",{className:"w-full overflow-x-auto whitespace-nowrap border-b border-border/30 bg-background/95 backdrop-blur-sm",style:{height:72,minHeight:72,maxHeight:72,position:"sticky",top:32,zIndex:20},"data-decision-timeline-strip":!0,children:h.jsx("div",{className:"flex items-center gap-2 px-3 h-full",children:n.map(i=>h.jsx(NV,{event:i,now:r},i.id))})})}function jV(t){if(!t)return[];const e=[];t.active_phase!=null&&e.push({label:"Phase",value:t.active_phase});const r=t.pending_gates??[];e.push({label:"Pending gates",value:r.length===0?"none":r.join(", ")}),e.push({label:"Open loops",value:t.open_loops_count??0}),e.push({label:"Gate load (24h)",value:t.gate_load_24h??0});const n=t.drift_alerts??[];return n.length>0?e.push({label:"Drift alerts",value:n.map(i=>i.axis_id||i.name||"unknown").join(", ")}):e.push({label:"Drift alerts",value:"none"}),t.computed_at&&e.push({label:"Updated",value:t.computed_at}),e}const LV="Select a feature to see status.";function WT({featureCode:t,snapshot:e}){const[r,n]=C.useState(!1),i=C.useCallback(()=>{n(a=>!a)},[]),s=(e==null?void 0:e.sentence)??LV,o=jV(e);return h.jsxs(h.Fragment,{children:[h.jsxs("div",{"data-status-band":!0,onClick:i,style:{position:"sticky",top:"0px",zIndex:30,height:"32px",minHeight:"32px",maxHeight:"32px",cursor:"pointer",display:"flex",alignItems:"center",paddingLeft:"12px",paddingRight:"12px",userSelect:"none",overflow:"hidden"},className:"w-full bg-background/95 backdrop-blur-sm border-b border-border/30 text-sm text-foreground/80",title:s,"aria-expanded":r,role:"button",tabIndex:0,onKeyDown:a=>{(a.key==="Enter"||a.key===" ")&&i()},children:[h.jsx("span",{style:{overflow:"hidden",whiteSpace:"nowrap",textOverflow:"ellipsis",flex:1},children:s}),h.jsx("span",{style:{marginLeft:8,opacity:.5,fontSize:10},"aria-hidden":"true",children:r?"▲":"▼"})]}),r&&h.jsx("div",{"data-status-band-expansion":!0,style:{position:"relative",width:"100%",zIndex:29,maxHeight:200,overflowY:"auto"},className:"bg-background/98 border-b border-border/50 text-xs text-foreground/70",children:h.jsx("div",{style:{padding:"8px 12px"},children:o.length===0?h.jsx("span",{className:"text-muted-foreground",children:"No details available."}):h.jsx("table",{style:{width:"100%",borderCollapse:"collapse"},children:h.jsx("tbody",{children:o.map((a,l)=>h.jsxs("tr",{children:[h.jsx("td",{style:{paddingRight:16,paddingBottom:2,fontWeight:500,whiteSpace:"nowrap"},className:"text-foreground/60",children:a.label}),h.jsx("td",{style:{paddingBottom:2},children:String(a.value)})]},l))})})})})]})}function BV({onContextSelect:t,sidebarOpen:e=!0,onToggleSidebar:r}){const{items:n,connections:i,connected:s,uiCommand:o,clearUICommand:a,recentChanges:l,createItem:c,updateItem:u,deleteItem:d,createConnection:p,deleteConnection:f,agentActivity:m,agentErrors:x,sessionState:g,registerSnapshotProvider:y,gates:b,gateEvent:k,resolveGate:T,settings:_,updateSettings:w,resetSettings:E,activeBuild:B,setActiveBuild:P,pipelineDraft:N,sessions:M,selectedPhase:$,setSelectedPhase:q,decisionEvents:O,statusSnapshots:I,setStatusSnapshot:A}=gr(),[D,R]=C.useState(()=>sessionStorage.getItem("vision-selectedItemId")||null),j=C.useRef(!!sessionStorage.getItem("vision-activeView")),[S,W]=C.useState(()=>sessionStorage.getItem("vision-activeView")||"roadmap"),[K,F]=C.useState(""),[ht,st]=C.useState(null),[J,ct]=C.useState(!1),[zt,at]=C.useState(!1),[Z,lt]=C.useState(!1);C.useEffect(()=>{sessionStorage.setItem("vision-activeView",S)},[S]),C.useEffect(()=>{D?sessionStorage.setItem("vision-selectedItemId",D):sessionStorage.removeItem("vision-selectedItemId")},[D]);const Ct=C.useRef(!1);C.useEffect(()=>{var tt;(tt=_==null?void 0:_.ui)!=null&&tt.defaultView&&!Ct.current&&!j.current&&(W(_.ui.defaultView),Ct.current=!0)},[_]),C.useEffect(()=>{o&&(o.view&&W(o.view),o.phase!==void 0&&q(o.phase),o.select!==void 0&&R(o.select),a())},[o,a]),C.useEffect(()=>{const tt=()=>{var G;return["INPUT","TEXTAREA","SELECT"].includes((G=document.activeElement)==null?void 0:G.tagName)},kt=G=>{(G.metaKey||G.ctrlKey)&&G.key==="k"&&(G.preventDefault(),ct(nt=>!nt)),(G.metaKey||G.ctrlKey)&&G.key==="n"&&(G.preventDefault(),at(!0)),G.key===","&&!G.metaKey&&!G.ctrlKey&&!tt()&<(!0)};return window.addEventListener("keydown",kt),()=>window.removeEventListener("keydown",kt)},[]);const Mt=C.useMemo(()=>{let tt=n;if($&&(tt=tt.filter(kt=>kt.phase===$)),K){const kt=K.toLowerCase();tt=tt.filter(G=>G.title.toLowerCase().includes(kt)||(G.description||"").toLowerCase().includes(kt))}return tt},[n,$,K]),Dt=C.useMemo(()=>$?n.filter(tt=>tt.phase===$):n,[n,$]),ne=C.useMemo(()=>new Set(Dt.map(tt=>tt.id)),[Dt]),ue=C.useMemo(()=>$?b.filter(tt=>ne.has(tt.itemId)):b,[b,ne,$]),Se=C.useMemo(()=>{if(!$&&!K)return i;const tt=new Set(Mt.map(kt=>kt.id));return i.filter(kt=>tt.has(kt.fromId)&&tt.has(kt.toId))},[i,Mt,$,K]);C.useEffect(()=>{y(()=>({activeView:S,selectedPhase:$,searchQuery:K,selectedItemId:D,totalItems:n.length,filteredCount:Mt.length,connected:s}))},[y,S,$,K,D,n.length,Mt.length,s]);const te=C.useCallback(tt=>{R(tt),t&&t({type:"item",id:tt})},[t]),Ae=C.useCallback((tt,kt)=>{u(tt,kt)},[u]);C.useCallback(async()=>{const kt=await c({type:"task",title:"New item",description:"",status:"planned",confidence:0,phase:$||"vision"});kt&&kt.id&&R(kt.id)},[c,$]),C.useCallback(async tt=>{await d(tt),D===tt&&(R(null),t&&t(null))},[d,D,t]);const V=C.useCallback(tt=>{const kt=b.find(G=>G.id===tt);kt&&(R(kt.itemId),t&&t({type:"item",id:kt.itemId}))},[b,t]);C.useCallback(async tt=>p(tt),[p]),C.useCallback(async tt=>f(tt),[f]);const it=C.useCallback(()=>{Rt("/api/build/state").then(tt=>tt.json()).then(tt=>P(tt.state??null)).catch(()=>{})},[P]),dt=C.useCallback(tt=>{t&&t({type:"step",id:tt})},[t]),Nt=C.useMemo(()=>{var kt;if(!D)return null;const tt=n.find(G=>G.id===D);return((kt=tt==null?void 0:tt.lifecycle)==null?void 0:kt.featureCode)||null},[D,n]);return C.useEffect(()=>{Nt&&(I&&I[Nt]||Rt(`/api/lifecycle/status?featureCode=${encodeURIComponent(Nt)}`).then(tt=>tt.json()).then(tt=>{tt.snapshot&&A&&A(Nt,tt.snapshot)}).catch(()=>{}))},[Nt]),h.jsx(Mc.Provider,{value:l,children:h.jsxs("div",{className:"h-full flex flex-col bg-background","data-snapshot-root":!0,children:[h.jsx(WT,{featureCode:Nt,snapshot:Nt?(I==null?void 0:I[Nt])??null:null}),Nt&&h.jsx(zT,{events:O,currentFeatureCode:Nt}),h.jsxs("div",{className:"flex-1 flex min-h-0",children:[h.jsxs("div",{className:"flex h-full shrink-0",style:{borderRight:"1px solid hsl(var(--border))"},children:[r&&h.jsx("button",{className:"w-4 h-full flex items-center justify-center text-[10px] text-muted-foreground hover:text-foreground transition-colors select-none",onClick:r,title:e?"Collapse sidebar":"Expand sidebar","aria-expanded":e,"aria-label":"Toggle sidebar",style:{background:"hsl(var(--muted) / 0.3)"},children:e?"‹":"›"}),e&&h.jsx(d1,{items:n,gates:b,activeBuild:B,activeView:S,onViewChange:W,selectedPhase:$,onPhaseSelect:q,searchQuery:K,onSearchChange:F,connected:s,agentActivity:m,agentErrors:x,sessionState:g,onSelectItem:te,onThemeChange:w,onNewItem:()=>at(!0)})]}),h.jsxs("div",{className:"flex-1 flex flex-col min-w-0",children:[!s&&h.jsx("div",{className:"text-center text-[10px] py-0.5 bg-destructive text-destructive-foreground",children:"Disconnected — reconnecting..."}),S==="tree"&&h.jsx(p1,{items:Mt,connections:Se,selectedItemId:D,onSelect:te}),S==="graph"&&h.jsx(g1,{items:Mt,connections:Se,selectedItemId:D,onSelect:te}),S==="pipeline"&&h.jsx(XS,{activeBuild:B,pipelineDraft:N,onSelectStep:dt,onRefresh:it}),S==="sessions"&&h.jsx(eT,{sessions:M,items:n,onSelectItem:te}),S==="docs"&&h.jsx(qS,{items:Dt}),S==="gates"&&h.jsx(US,{gates:ue,items:Dt,onResolve:T,onSelect:te}),S==="settings"&&h.jsx(YS,{settings:_,onSettingsChange:w,onReset:E})]}),h.jsx($T,{onOpenGate:V}),ht&&(()=>{const tt=n.find(kt=>kt.id===ht);return tt?h.jsx(VS,{item:tt,items:n,connections:i,onUpdate:Ae,onClose:()=>st(null)}):null})(),h.jsx(GS,{event:k,items:n,onNavigate:()=>W("gates")}),h.jsx(rT,{open:J,onClose:()=>ct(!1),onSelectItem:tt=>{te(tt),ct(!1)},onSelectGate:tt=>{V(tt),ct(!1)}}),h.jsx(OT,{open:zt,onClose:()=>at(!1)}),h.jsx(RT,{open:Z,onClose:()=>lt(!1),settings:_,onSettingsChange:w})]})]})})}la.use(ry);const AV={background:"#0b0b14",overlay:"#161625",textPrimary:"#f1f5f9",textSecondary:"#94a3b8",textTertiary:"#64748b",textMuted:"#475569",accent:"#FBBF24"},MV={background:"#FFFFFF",overlay:"#F5F5F5",textPrimary:"#0a0a0a",textSecondary:"#404040",textTertiary:"#737373",textMuted:"#a3a3a3",accent:"#FBBF24"};function IV(t){return[{selector:"node",style:{label:"data(label)","text-valign":"center","text-halign":"center","font-size":"11px","font-weight":600,"font-family":'ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace',color:t.textPrimary,"text-wrap":"wrap","text-max-width":"110px","background-color":t.overlay,"border-width":1,"border-color":"data(color)","border-opacity":.5,width:140,height:52,shape:"round-rectangle","text-outline-width":0,"overlay-padding":4,"overlay-opacity":0}},{selector:'node[shape = "diamond"]',style:{shape:"diamond",width:160,height:80,"font-size":"10px"}},{selector:"node:selected",style:{"border-width":2,"border-opacity":1,"border-color":t.accent}},{selector:"edge",style:{width:1,"line-color":t.textMuted,"target-arrow-color":t.textMuted,"target-arrow-shape":"triangle","curve-style":"bezier","arrow-scale":.7,opacity:.5}},{selector:"edge[label]",style:{label:"data(label)","font-size":"10px","font-family":'ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace',color:t.textSecondary,"text-rotation":"autorotate","text-margin-y":-8,"text-outline-width":3,"text-outline-color":t.background}},{selector:"edge[color]",style:{"line-color":"data(color)","target-arrow-color":"data(color)"}},{selector:'edge[lineStyle = "dashed"]',style:{"line-style":"dashed"}},{selector:'edge[lineStyle = "dotted"]',style:{"line-style":"dotted"}},{selector:":parent",style:{"background-color":t.overlay,"background-opacity":.3,"border-width":1,"border-color":"data(color)","border-opacity":.3,"text-valign":"top","text-halign":"center","font-size":"10px",color:t.textTertiary,padding:"16px"}}]}function FV(){const[t,e]=C.useState(()=>document.documentElement.classList.contains("dark"));return C.useEffect(()=>{const r=new MutationObserver(()=>e(document.documentElement.classList.contains("dark")));return r.observe(document.documentElement,{attributes:!0,attributeFilter:["class"]}),()=>r.disconnect()},[]),t}const PV={"dagre-tb":{name:"dagre",rankDir:"LR",rankSep:80,nodeSep:50,padding:40},"dagre-lr":{name:"dagre",rankDir:"TB",rankSep:100,nodeSep:40,padding:40},circle:{name:"circle",padding:40},grid:{name:"grid",padding:40,rows:3},concentric:{name:"concentric",padding:40,minNodeSpacing:60},breadthfirst:{name:"breadthfirst",padding:40,spacingFactor:1.2}},DV={"dagre-tb":"Top → Down","dagre-lr":"Left → Right",circle:"Circle",grid:"Grid",concentric:"Concentric",breadthfirst:"Breadthfirst"};function OV(t,e){const r=[];for(const n of t)r.push({data:{id:n.id,label:n.label,sublabel:n.sublabel||void 0,color:n.color||CY.textMuted,parent:n.parent||void 0,shape:n.shape||void 0},...n.position?{position:n.position}:{}});for(const n of e)r.push({data:{id:n.id||`${n.from}-${n.to}-${n.label||""}`,source:n.from,target:n.to,label:n.label||void 0,color:n.color||void 0,lineStyle:n.style||"solid",edgeType:n.type||void 0}});return r}const wc="compose:graph:";function RV(t){try{const e=localStorage.getItem(wc+t);return e?JSON.parse(e):null}catch{return null}}function $V(t,e){try{localStorage.setItem(wc+t,JSON.stringify(e))}catch{}}const zV=[{style:"solid",label:"Structural / hard",dash:null},{style:"dashed",label:"Informational / weak",dash:"4,3"},{style:"dotted",label:"Soft dependency",dash:"1.5,3"}];function os({onClick:t,active:e,children:r,title:n}){return h.jsx("button",{onClick:t,title:n,className:"text-xs rounded cursor-pointer transition-colors font-semibold",style:{padding:"4px 8px",borderRadius:"0.375rem",border:"1px solid",borderColor:e?"hsl(var(--primary) / 0.1)":"hsl(var(--border))",background:e?"hsl(var(--primary) / 0.1)":"hsl(var(--accent))",color:e?"hsl(var(--primary))":"hsl(var(--muted-foreground))"},children:r})}function il({mode:t,active:e,onClick:r}){return h.jsx("button",{onClick:r,className:"text-xs rounded cursor-pointer capitalize transition-colors font-semibold",style:{padding:"4px 8px",borderRadius:"0.375rem",border:"1px solid",borderColor:e?"hsl(var(--primary) / 0.1)":"hsl(var(--border))",background:e?"hsl(var(--primary) / 0.1)":"hsl(var(--accent))",color:e?"hsl(var(--primary))":"hsl(var(--muted-foreground) / 0.6)"},children:t})}function bu(){return h.jsx("div",{className:"w-px h-4 mx-0.5",style:{background:"hsl(var(--border))"}})}function w0({arrow:t,label:e,edgeStyle:r,color:n,targetLabel:i,targetColor:s,suffix:o}){return h.jsxs("div",{className:"flex items-center gap-2 text-xs",style:{padding:"4px 8px",color:"hsl(var(--muted-foreground))"},children:[h.jsx("span",{style:{color:"hsl(var(--muted-foreground) / 0.6)"},children:t}),h.jsx("span",{style:{color:n||"hsl(var(--muted-foreground))",fontStyle:r==="dashed"?"italic":"normal"},children:e||"connects"}),i?h.jsxs(h.Fragment,{children:[h.jsx("span",{style:{color:"hsl(var(--muted-foreground) / 0.6)"},children:"→"}),h.jsxs("span",{className:"flex items-center gap-1.5",children:[h.jsx("span",{className:"w-2 h-2 rounded-sm shrink-0",style:{background:s||"hsl(var(--muted-foreground) / 0.6)"}}),h.jsx("span",{style:{color:"hsl(var(--foreground))"},children:i})]})]}):o?h.jsx("span",{style:{color:"hsl(var(--muted-foreground) / 0.6)"},children:o}):null,r&&r!=="solid"&&h.jsxs("span",{className:"text-[10px]",style:{color:"hsl(var(--muted-foreground) / 0.6)"},children:["(",r,")"]})]})}function WV({nodes:t,edges:e,graphKey:r}){const[n,i]=C.useState(()=>{try{const l=localStorage.getItem(wc+r+":tree-collapsed");return l?new Set(JSON.parse(l)):new Set}catch{return new Set}});C.useEffect(()=>{try{localStorage.setItem(wc+r+":tree-collapsed",JSON.stringify([...n]))}catch{}},[n,r]);const s=C.useMemo(()=>{const l={};for(const c of t)l[c.id]=c;return l},[t]),o=C.useMemo(()=>{var u,d;const l={},c={};for(const p of t)l[p.id]=[],c[p.id]=[];for(const p of e)(u=l[p.from])==null||u.push(p),(d=c[p.to])==null||d.push(p);return{out:l,inc:c}},[t,e]),a=l=>i(c=>{const u=new Set(c);return u.has(l)?u.delete(l):u.add(l),u});return h.jsxs("div",{className:"w-full h-full overflow-y-auto",style:{background:"hsl(var(--background))",padding:"1rem"},children:[h.jsxs("div",{className:"flex items-center mb-4",style:{gap:"8px"},children:[h.jsx(os,{onClick:()=>i(new Set),children:"Expand all"}),h.jsx(os,{onClick:()=>i(new Set(t.map(l=>l.id))),children:"Collapse all"}),h.jsxs("span",{className:"text-xs ml-auto",style:{color:"hsl(var(--muted-foreground))"},children:[t.length," entities · ",e.length," relations"]})]}),t.map(l=>{const c=n.has(l.id),u=o.out[l.id]||[],d=o.inc[l.id]||[],p=u.filter(g=>g.from===g.to),f=u.filter(g=>g.from!==g.to),m=d.filter(g=>g.from!==g.to),x=f.length+m.length+p.length;return h.jsxs("div",{className:"mb-0.5",children:[h.jsxs("button",{onClick:()=>a(l.id),className:"flex items-center w-full text-left bg-transparent border-none cursor-pointer rounded-md transition-colors hover:bg-[hsl(var(--accent))]",style:{gap:"8px",padding:"8px"},children:[h.jsx("span",{className:"text-xs w-4 text-center inline-block transition-transform",style:{color:"hsl(var(--muted-foreground))",transform:c?"rotate(-90deg)":"rotate(0deg)"},children:"▼"}),h.jsx("span",{className:"w-3 h-3 shrink-0",style:{borderRadius:l.shape==="diamond"?0:3,background:l.color,transform:l.shape==="diamond"?"rotate(45deg) scale(0.8)":"none"}}),h.jsx("span",{className:"text-sm font-semibold",style:{color:"hsl(var(--foreground))"},children:l.label}),l.sublabel&&h.jsxs("span",{className:"text-xs",style:{color:"hsl(var(--muted-foreground))"},children:["— ",l.sublabel]}),h.jsx("span",{className:"text-xs ml-auto",style:{color:"hsl(var(--muted-foreground) / 0.6)"},children:x})]}),!c&&h.jsxs("div",{style:{paddingLeft:"32px",paddingBottom:"4px"},children:[f.map((g,y)=>{var b,k;return h.jsx(w0,{arrow:"→",label:g.label,edgeStyle:g.style,color:g.color,targetLabel:((b=s[g.to])==null?void 0:b.label)||g.to,targetColor:(k=s[g.to])==null?void 0:k.color},`out-${y}`)}),p.map((g,y)=>h.jsx(w0,{arrow:"↻",label:g.label,edgeStyle:g.style,color:g.color,suffix:"(self)"},`self-${y}`)),m.map((g,y)=>{var b,k;return h.jsxs("div",{className:"flex items-center gap-2 text-xs",style:{padding:"4px 8px",color:"hsl(var(--muted-foreground))"},children:[h.jsxs("span",{className:"flex items-center gap-1.5",children:[h.jsx("span",{className:"w-2 h-2 rounded-sm shrink-0",style:{background:((b=s[g.from])==null?void 0:b.color)||"hsl(var(--muted-foreground) / 0.6)"}}),h.jsx("span",{style:{color:"hsl(var(--foreground))"},children:((k=s[g.from])==null?void 0:k.label)||g.from})]}),h.jsx("span",{style:{color:"hsl(var(--muted-foreground) / 0.6)"},children:"→"}),h.jsx("span",{style:{color:g.color||"hsl(var(--muted-foreground))",fontStyle:g.style==="dashed"?"italic":"normal"},children:g.label||"connects"}),h.jsx("span",{style:{color:"hsl(var(--muted-foreground) / 0.6)"},children:"→ this"}),g.style&&g.style!=="solid"&&h.jsxs("span",{className:"text-[10px]",style:{color:"hsl(var(--muted-foreground) / 0.6)"},children:["(",g.style,")"]})]},`in-${y}`)}),x===0&&h.jsx("div",{className:"text-xs italic",style:{padding:"4px 8px",color:"hsl(var(--muted-foreground) / 0.6)"},children:"no relations"})]})]},l.id)})]})}function qV({elements:t,nodes:e,edges:r,layout:n,style:i,title:s,subtitle:o,graphKey:a="default",onNodeClick:l}){const c=C.useRef(null),u=C.useRef(null),[d,p]=C.useState(null),f=FV(),m=f?AV:MV,x=C.useMemo(()=>RV(a),[a]),[g,y]=C.useState((x==null?void 0:x.layoutKey)||"dagre-tb"),[b,k]=C.useState((x==null?void 0:x.showEdgeLabels)??!0),[T,_]=C.useState(()=>new Set((x==null?void 0:x.hiddenNodes)||[])),[w,E]=C.useState((x==null?void 0:x.showLegend)??!0),[B,P]=C.useState((x==null?void 0:x.viewMode)||"graph");C.useEffect(()=>{$V(a,{layoutKey:g,showEdgeLabels:b,hiddenNodes:[...T],showLegend:w,viewMode:B})},[a,g,b,T,w,B]);const N=t||(e&&r?OV(e,r):[]),M=C.useMemo(()=>i||IV(m),[i,f]),$=n||PV[g],q=C.useMemo(()=>N.filter(S=>!S.data.source).map(S=>({id:S.data.id,label:S.data.label,color:S.data.color})),[JSON.stringify(N)]),O=C.useMemo(()=>T.size===0?N:N.filter(S=>S.data.source?!T.has(S.data.source)&&!T.has(S.data.target):!T.has(S.data.id)),[N,T]);C.useEffect(()=>{if(!c.current)return;const S=la({container:c.current,elements:O,style:M,layout:$,minZoom:.2,maxZoom:4,wheelSensitivity:.3,boxSelectionEnabled:!1});return u.current=S,S.on("mouseover","node",W=>{const K=W.target;K.style("border-width",2),K.style("border-opacity",1);const F=K.renderedPosition();p({x:F.x,y:F.y-K.renderedHeight()/2-12,label:K.data("label"),sublabel:K.data("sublabel"),id:K.id(),color:K.data("color")})}),S.on("mouseout","node",W=>{W.target.style("border-width",1),W.target.style("border-opacity",.5),p(null)}),l&&S.on("tap","node",W=>l(W.target.id())),S.on("layoutstop",()=>S.fit(void 0,40)),()=>{S.destroy(),u.current=null}},[JSON.stringify(O),JSON.stringify($),f,B]),C.useEffect(()=>{const S=u.current;S&&S.edges().forEach(W=>{W.data("label")&&W.style("label",b?W.data("label"):"")})},[b]);const I=C.useCallback(()=>{var S;return(S=u.current)==null?void 0:S.fit(void 0,40)},[]),A=C.useCallback(()=>{const S=u.current;S&&S.zoom({level:S.zoom()*1.3,renderedPosition:{x:S.width()/2,y:S.height()/2}})},[]),D=C.useCallback(()=>{const S=u.current;S&&S.zoom({level:S.zoom()/1.3,renderedPosition:{x:S.width()/2,y:S.height()/2}})},[]),R=C.useCallback(S=>{_(W=>{const K=new Set(W);return K.has(S)?K.delete(S):K.add(S),K})},[]),j=C.useCallback(()=>_(new Set),[]);return B==="tree"?h.jsxs("div",{className:"w-full h-full flex flex-col",style:{background:"hsl(var(--background))"},children:[h.jsxs("div",{className:"flex items-center justify-between shrink-0",style:{padding:"8px 16px",borderBottom:"1px solid hsl(var(--border))"},children:[h.jsxs("div",{className:"flex items-center",style:{gap:"8px"},children:[s&&h.jsx("span",{className:"text-sm font-semibold",style:{color:"hsl(var(--foreground))"},children:s}),o&&h.jsx("span",{className:"text-xs",style:{color:"hsl(var(--muted-foreground))"},children:o})]}),h.jsxs("div",{className:"flex",style:{gap:"4px"},children:[h.jsx(il,{mode:"graph",active:B==="graph",onClick:()=>P("graph")}),h.jsx(il,{mode:"tree",active:B==="tree",onClick:()=>P("tree")})]})]}),h.jsx("div",{className:"flex-1 min-h-0",children:h.jsx(WV,{nodes:e||[],edges:r||[],graphKey:a})})]}):h.jsxs("div",{className:"w-full h-full relative",style:{background:"hsl(var(--background))"},children:[(s||o)&&h.jsxs("div",{className:"absolute top-0 left-0 right-0 z-[2] pointer-events-none",style:{padding:"8px 16px",background:"linear-gradient(to bottom, hsl(var(--background)) 0%, transparent 100%)"},children:[s&&h.jsx("div",{className:"text-sm font-semibold",style:{color:"hsl(var(--foreground))"},children:s}),o&&h.jsx("div",{className:"text-[10px] mt-0.5",style:{color:"hsl(var(--muted-foreground))"},children:o})]}),h.jsxs("div",{className:"absolute top-2 right-3 z-[2] flex items-center",style:{gap:"4px"},children:[h.jsx("select",{value:g,onChange:S=>y(S.target.value),className:"text-xs rounded cursor-pointer appearance-none",style:{padding:"4px 8px",borderRadius:"0.375rem",background:"hsl(var(--accent))",border:"1px solid hsl(var(--border))",color:"hsl(var(--muted-foreground))"},title:"Graph layout",children:Object.entries(DV).map(([S,W])=>h.jsx("option",{value:S,style:{background:"hsl(var(--accent))",color:"hsl(var(--foreground))"},children:W},S))}),h.jsx(bu,{}),h.jsx(os,{onClick:D,title:"Zoom out",children:"−"}),h.jsx(os,{onClick:I,title:"Fit to view",children:"Fit"}),h.jsx(os,{onClick:A,title:"Zoom in",children:"+"}),h.jsx(bu,{}),h.jsx(os,{onClick:()=>E(!w),active:w,title:w?"Hide legend":"Show legend",children:"Legend"}),h.jsx(bu,{}),h.jsx(il,{mode:"graph",active:B==="graph",onClick:()=>P("graph")}),h.jsx(il,{mode:"tree",active:B==="tree",onClick:()=>P("tree")})]}),w&&h.jsxs("div",{className:"absolute bottom-3 left-3 z-[2]",style:{background:"hsl(var(--card))",border:"1px solid hsl(var(--border))",borderRadius:"0.5rem",padding:"8px 16px",boxShadow:"0 1px 3px rgba(0,0,0,0.1)",minWidth:150,maxWidth:210},children:[h.jsxs("div",{className:"flex justify-between items-center mb-1.5",children:[h.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-wider",style:{color:"hsl(var(--muted-foreground))"},children:"Entities"}),T.size>0&&h.jsx("button",{onClick:j,className:"text-[10px] bg-transparent border-none cursor-pointer p-0",style:{color:"hsl(var(--primary))"},children:"Show all"})]}),h.jsx("div",{className:"flex flex-col gap-1",children:q.map(S=>{const W=T.has(S.id);return h.jsxs("button",{onClick:()=>R(S.id),className:"flex items-center gap-1.5 bg-transparent border-none py-0.5 cursor-pointer transition-opacity",style:{opacity:W?.35:1},title:W?`Show ${S.label}`:`Hide ${S.label}`,children:[h.jsx("span",{className:"w-2 h-2 rounded-sm shrink-0 transition-colors",style:{background:W?"transparent":S.color,border:`1.5px solid ${S.color}`}}),h.jsx("span",{className:"text-xs",style:{color:W?"hsl(var(--muted-foreground) / 0.6)":"hsl(var(--muted-foreground))",textDecoration:W?"line-through":"none"},children:S.label})]},S.id)})}),h.jsxs("div",{className:"flex justify-between items-center mt-2.5 mb-1.5",children:[h.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-wider",style:{color:"hsl(var(--muted-foreground))"},children:"Edges"}),h.jsx("button",{onClick:()=>k(!b),className:"text-[10px] bg-transparent border-none cursor-pointer p-0",style:{color:b?"hsl(var(--primary))":"hsl(var(--muted-foreground) / 0.6)"},children:b?"Hide labels":"Show labels"})]}),h.jsx("div",{className:"flex flex-col gap-1",children:zV.map(S=>h.jsxs("div",{className:"flex items-center gap-1.5",children:[h.jsx("svg",{width:"20",height:"6",className:"shrink-0",children:h.jsx("line",{x1:"0",y1:"3",x2:"20",y2:"3",stroke:"hsl(var(--muted-foreground))",strokeWidth:"1.5",strokeDasharray:S.dash||"none"})}),h.jsx("span",{className:"text-[10px]",style:{color:"hsl(var(--muted-foreground) / 0.6)"},children:S.label})]},S.style))})]}),d&&h.jsxs("div",{className:"absolute z-10 text-center pointer-events-none backdrop-blur-sm",style:{left:d.x,top:d.y,transform:"translate(-50%, -100%)",background:"hsl(var(--accent))",border:"1px solid hsl(var(--border))",borderRadius:"0.5rem",padding:"4px 8px",boxShadow:"0 1px 3px rgba(0,0,0,0.1)",minWidth:110,maxWidth:200},children:[h.jsx("div",{className:"text-sm font-semibold",style:{color:d.color||"hsl(var(--foreground))"},children:d.label}),d.sublabel&&h.jsx("div",{className:"text-xs mt-0.5",style:{color:"hsl(var(--muted-foreground))"},children:d.sublabel}),h.jsx("div",{className:"text-[10px] mt-1 font-mono",style:{color:"hsl(var(--muted-foreground) / 0.6)"},children:d.id})]}),h.jsx("div",{ref:c,className:"w-full h-full"})]})}const Wt={discovery:"#a78bfa",feature:"#3b82f6",track:"#06b6d4",task:"#94a3b8",spec:"#a78bfa",idea:"#fbbf24",question:"#f472b6",evaluation:"#f59e0b",thread:"#64748b",decision:"#22c55e",artifact:"#a87cb8",informs:"#64748b",pipeline:"#6366f1"},HV=[{id:"discovery",label:"Discovery",sublabel:"orthogonal process",color:Wt.discovery,shape:"diamond"},{id:"pipeline",label:"Feature Development Pipeline",color:Wt.pipeline},{id:"p-vision",label:"Vision",parent:"pipeline",color:Wt.pipeline},{id:"p-specification",label:"Specification",parent:"pipeline",color:Wt.pipeline},{id:"p-planning",label:"Planning",parent:"pipeline",color:Wt.pipeline},{id:"p-implementation",label:"Implementation",parent:"pipeline",color:Wt.pipeline},{id:"p-verification",label:"Verification",parent:"pipeline",color:Wt.pipeline},{id:"p-release",label:"Release",parent:"pipeline",color:Wt.pipeline},{id:"feature",label:"Feature",sublabel:"strategic container",color:Wt.feature},{id:"track",label:"Track",sublabel:"deliverable unit",color:Wt.track},{id:"task",label:"Task",sublabel:"planned → doing → done",color:Wt.task},{id:"spec",label:"Spec",sublabel:"behavioral specification",color:Wt.spec},{id:"evaluation",label:"Evaluation",sublabel:"assessment / gap analysis",color:Wt.evaluation},{id:"idea",label:"Idea",sublabel:"can float free",color:Wt.idea},{id:"thread",label:"Thread",sublabel:"deliberation",color:Wt.thread},{id:"decision",label:"Decision",sublabel:"resolved choice",color:Wt.decision},{id:"question",label:"Question",sublabel:"may block progress",color:Wt.question},{id:"artifact",label:"Artifact",sublabel:"journal / doc / output",color:Wt.artifact}],UV=[{from:"p-vision",to:"p-specification",color:Wt.pipeline},{from:"p-specification",to:"p-planning",color:Wt.pipeline},{from:"p-planning",to:"p-implementation",color:Wt.pipeline},{from:"p-implementation",to:"p-verification",color:Wt.pipeline},{from:"p-verification",to:"p-release",color:Wt.pipeline},{from:"idea",to:"p-vision",label:"lives in",color:Wt.idea,style:"dotted"},{from:"spec",to:"p-specification",label:"lives in",color:Wt.spec,style:"dotted"},{from:"task",to:"p-implementation",label:"lives in",color:Wt.task,style:"dotted"},{from:"evaluation",to:"p-verification",label:"lives in",color:Wt.evaluation,style:"dotted"},{from:"discovery",to:"feature",label:"produces",color:Wt.discovery,style:"dashed"},{from:"discovery",to:"idea",label:"produces",color:Wt.discovery,style:"dashed"},{from:"discovery",to:"thread",label:"produces",color:Wt.discovery,style:"dashed"},{from:"discovery",to:"decision",label:"produces",color:Wt.discovery,style:"dashed"},{from:"discovery",to:"question",label:"produces",color:Wt.discovery,style:"dashed"},{from:"discovery",to:"spec",label:"produces",color:Wt.discovery,style:"dashed"},{from:"track",to:"feature",label:"implements",color:Wt.track},{from:"task",to:"feature",label:"implements",color:Wt.task},{from:"spec",to:"feature",label:"implements",color:Wt.spec},{from:"feature",to:"feature",label:"blocks",color:Wt.question,id:"feat-blocks"},{from:"idea",to:"feature",label:"informs",color:Wt.informs,style:"dashed"},{from:"thread",to:"decision",label:"informs",color:Wt.informs,style:"dashed"},{from:"evaluation",to:"decision",label:"informs",color:Wt.informs,style:"dashed"},{from:"artifact",to:"feature",label:"supports",color:Wt.artifact},{from:"question",to:"decision",label:"contradicts",color:Wt.question},{from:"feature",to:"p-vision",label:"enters",color:Wt.feature,style:"dashed"}];function GV(){return h.jsx(qV,{graphKey:"product",nodes:HV,edges:UV,title:"Compose Product Ontology",subtitle:"10 entity types · 6 phases · 5 edge types · Discovery orthogonal"})}const VV="compose-popout";function qT(t){if(t==="vision://surface")return"Vision Tracker";if(t.startsWith("graph://")){const r=t.replace("graph://","");return r.charAt(0).toUpperCase()+r.slice(1)+" Graph"}const e=t.split("/");return e.length>1?e.slice(-2).join("/"):e[e.length-1]}function sl({path:t,onDock:e}){return h.jsxs("div",{className:"flex items-center justify-between px-3 shrink-0",style:{height:"28px",borderBottom:"1px solid hsl(var(--border))",background:"hsl(var(--background))"},children:[h.jsx("span",{className:"text-[11px] text-muted-foreground truncate",children:qT(t)}),h.jsxs("button",{onClick:e,className:"flex items-center gap-1 px-2 py-0.5 rounded text-[10px] uppercase tracking-wider",style:{color:"hsl(var(--primary))",background:"none",border:"none",cursor:"pointer"},title:"Pop back into main window",children:[h.jsx(jA,{style:{width:11,height:11}}),"pop in"]})]})}function YV({path:t}){const[e,r]=C.useState(null),[n,i]=C.useState(!0),s=C.useRef(null),o=C.useRef(null),a=t.startsWith("vision://")?"vision":t.startsWith("graph://")?"graph":t.endsWith(".html")||t.endsWith(".htm")?"html":"markdown";C.useEffect(()=>{document.title=qT(t)+" — Compose"},[t]),C.useEffect(()=>{const c=new BroadcastChannel(VV);s.current=c,c.postMessage({type:"popout-mounted",path:t});const u=()=>{c.postMessage({type:"popout-closed",path:t})};return window.addEventListener("beforeunload",u),()=>{u(),c.close(),window.removeEventListener("beforeunload",u)}},[t]);const l=C.useCallback(()=>{var c;(c=s.current)==null||c.postMessage({type:"popout-dock",path:t}),window.close()},[t]);return C.useEffect(()=>{if(a==="vision"||a==="graph"){i(!1);return}Rt(`/api/file?path=${encodeURIComponent(t)}`).then(c=>c.json()).then(c=>{c.content!==void 0&&r(c.content),i(!1)}).catch(()=>i(!1))},[t,a]),C.useEffect(()=>{if(a==="vision"||a==="graph")return;const c=window.location.protocol==="https:"?"wss:":"ws:",u=new WebSocket(`${c}//${window.location.host}/ws/files`);return o.current=u,u.onmessage=d=>{try{const p=JSON.parse(d.data);p.type==="fileChanged"&&p.path===t&&r(p.content)}catch{}},()=>u.close()},[t,a]),n?h.jsx("div",{className:"h-screen w-screen flex items-center justify-center bg-background",children:h.jsx("span",{className:"text-sm text-muted-foreground",children:"Loading..."})}):a==="vision"?h.jsxs("div",{className:"h-screen w-screen flex flex-col bg-background",children:[h.jsx(sl,{path:t,onDock:l}),h.jsx("div",{className:"flex-1 min-h-0",children:h.jsx(BV,{})})]}):a==="graph"?h.jsxs("div",{className:"h-screen w-screen flex flex-col bg-background",children:[h.jsx(sl,{path:t,onDock:l}),h.jsx("div",{className:"flex-1 min-h-0",children:h.jsx(GV,{})})]}):a==="html"?h.jsxs("div",{className:"h-screen w-screen flex flex-col bg-background",children:[h.jsx(sl,{path:t,onDock:l}),h.jsx("div",{className:"flex-1 min-h-0",children:h.jsx("iframe",{srcDoc:e,className:"w-full h-full border-0",sandbox:"allow-scripts allow-same-origin",title:t})})]}):h.jsxs("div",{className:"h-screen w-screen flex flex-col bg-background",children:[h.jsx(sl,{path:t,onDock:l}),h.jsx("div",{className:"flex-1 overflow-y-auto px-8 py-6",children:h.jsx("div",{className:"canvas-markdown max-w-4xl mx-auto",children:h.jsx(yf,{remarkPlugins:[vf],children:e||""})})})]})}const XV="/api/stratum";async function lh(t,e={}){return(await Rt(`${XV}${t}`,{headers:{"Content-Type":"application/json",...e.headers||{}},...e})).json()}function KV(t,e){return lh(t,{method:"POST",body:JSON.stringify(e)})}function HT({status:t}){const e={running:"hsl(var(--background))",awaiting_gate:"#7c3aed",complete:"#166534",killed:"#7f1d1d",blocked:"#7f1d1d"},r={running:"running",awaiting_gate:"gate pending",complete:"complete",killed:"killed",blocked:"blocked"};return h.jsx("span",{style:{fontSize:"0.72em",padding:"2px 6px",borderRadius:4,background:e[t]||"#333",color:"#e5e7eb",textTransform:"uppercase",letterSpacing:"0.05em"},children:r[t]||t})}function Up(){return h.jsx("span",{style:{opacity:.5,fontSize:"0.85em"},children:"loading…"})}function ZV({onAction:t}){const[e,r]=C.useState(null),[n,i]=C.useState(null),[s,o]=C.useState({}),[a,l]=C.useState({}),c=C.useCallback(()=>{lh("/gates").then(d=>{r(Array.isArray(d)?d:[]),i(null)}).catch(d=>i(d.message))},[]);C.useEffect(()=>{c();const d=setInterval(c,1e4);return()=>clearInterval(d)},[c]);async function u(d,p,f){const m=`${d}/${p}/${f}`;o(g=>({...g,[m]:!0}));const x=a[`${d}/${p}`]||"";try{const g=await KV(`/gates/${d}/${p}/${f}`,{note:x});g.conflict?i(`Gate already resolved (${d}/${p})`):g.error?i(g.error.message):(t==null||t(),c())}catch(g){i(g.message)}finally{o(g=>({...g,[m]:!1}))}}return e===null&&!n?h.jsx(Up,{}):h.jsxs("section",{children:[h.jsxs("h3",{style:{fontSize:"0.8em",textTransform:"uppercase",letterSpacing:"0.08em",opacity:.5,margin:"0 0 8px"},children:["Pending Gates ",(e==null?void 0:e.length)>0&&h.jsxs("span",{style:{opacity:1,color:"#f59e0b"},children:["(",e.length,")"]})]}),n&&h.jsx("p",{style:{color:"#ef4444",fontSize:"0.8em",margin:"0 0 8px"},children:n}),(e==null?void 0:e.length)===0&&h.jsx("p",{style:{opacity:.4,fontSize:"0.85em"},children:"No pending gates."}),e==null?void 0:e.map(d=>{const p=`${d.flow_id}/${d.step_id}`,f=m=>s[`${p}/${m}`];return h.jsxs("div",{style:{border:"1px solid #3f3f46",borderRadius:6,padding:"10px 12px",marginBottom:8,background:"#18181b"},children:[h.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:6},children:[h.jsx("span",{style:{fontWeight:600,fontSize:"0.9em"},children:d.flow_name||d.flow_id}),h.jsx("span",{style:{opacity:.4,fontSize:"0.8em"},children:"›"}),h.jsx("span",{style:{fontFamily:"monospace",fontSize:"0.82em",opacity:.7},children:d.step_id}),d.function&&h.jsxs("span",{style:{opacity:.4,fontSize:"0.78em"},children:["fn:",d.function]})]}),h.jsx("input",{type:"text",placeholder:"Note (optional)",value:a[p]||"",onChange:m=>l(x=>({...x,[p]:m.target.value})),style:{width:"100%",boxSizing:"border-box",marginBottom:8,background:"#27272a",border:"1px solid #3f3f46",borderRadius:4,color:"#e4e4e7",padding:"4px 8px",fontSize:"0.82em"}}),h.jsx("div",{style:{display:"flex",gap:6},children:[{a:"approve",label:"Approve",color:"#166534",hover:"#15803d"},{a:"reject",label:"Reject",color:"#7f1d1d",hover:"#b91c1c"},{a:"revise",label:"Revise",color:"#1e3a5f",hover:"#1d4ed8"}].map(({a:m,label:x,color:g})=>h.jsx("button",{disabled:f(m),onClick:()=>u(d.flow_id,d.step_id,m),style:{padding:"4px 12px",fontSize:"0.8em",borderRadius:4,border:"none",background:g,color:"#e5e7eb",cursor:f(m)?"not-allowed":"pointer",opacity:f(m)?.5:1},children:f(m)?"…":x},m))})]},p)})]})}function QV({flowId:t,onClose:e}){const[r,n]=C.useState(null),[i,s]=C.useState(null);return C.useEffect(()=>{lh(`/flows/${t}`).then(o=>{o.error?s(o.error.message):n(o)}).catch(o=>s(o.message))},[t]),h.jsxs("div",{style:{border:"1px solid #3f3f46",borderRadius:6,padding:"10px 12px",background:"#18181b"},children:[h.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:8},children:[h.jsx("span",{style:{fontWeight:600,fontSize:"0.9em"},children:(r==null?void 0:r.flow_name)||t}),h.jsx("button",{onClick:e,style:{background:"none",border:"none",color:"#9ca3af",cursor:"pointer",fontSize:"1.1em"},children:"✕"})]}),i&&h.jsx("p",{style:{color:"#ef4444",fontSize:"0.8em"},children:i}),!r&&!i&&h.jsx(Up,{}),r&&h.jsx("div",{style:{fontSize:"0.82em",opacity:.8},children:(()=>{const o=new Set(Array.isArray(r.completed_steps)?r.completed_steps:[]),a=new Set(Array.isArray(r.active_steps)?r.active_steps:[]),l=o.size,c=r.step_count??"?";return h.jsxs(h.Fragment,{children:[h.jsxs("div",{style:{display:"flex",gap:12,marginBottom:8,flexWrap:"wrap"},children:[h.jsx("span",{children:h.jsx(HT,{status:r.status})}),h.jsxs("span",{children:["steps ",l,"/",c,a.size>0&&h.jsxs("span",{style:{marginLeft:6,color:"#34d399",fontSize:"0.85em"},children:["∥ ",a.size," running"]})]}),r.round>0&&h.jsxs("span",{children:["round ",r.round]})]}),Array.isArray(r.ordered_steps)&&r.ordered_steps.length>0&&h.jsx("ol",{style:{margin:0,padding:"0 0 0 18px",lineHeight:1.7},children:r.ordered_steps.map(u=>h.jsxs("li",{style:{opacity:o.has(u.id)?.4:1,fontWeight:a.has(u.id)?700:"normal",color:a.has(u.id)?"#34d399":"inherit"},children:[h.jsx("span",{style:{fontFamily:"monospace"},children:u.id}),u.mode==="gate"&&h.jsx("span",{style:{marginLeft:6,color:"#f59e0b",fontSize:"0.9em"},children:"gate"}),a.has(u.id)&&h.jsx("span",{style:{marginLeft:6,fontSize:"0.85em"},children:"∥ running"})]},u.id))})]})})()})]})}function JV({activeBuild:t}){const[e,r]=C.useState(null),[n,i]=C.useState(null),[s,o]=C.useState(null),a=C.useCallback(()=>{lh("/flows").then(l=>{r(Array.isArray(l)?l:[]),i(null)}).catch(l=>i(l.message))},[]);return C.useEffect(()=>{a();const l=setInterval(a,15e3);return()=>clearInterval(l)},[a]),C.useEffect(()=>{t&&a()},[t,a]),e===null&&!n?h.jsx(Up,{}):h.jsxs("section",{children:[h.jsx("h3",{style:{fontSize:"0.8em",textTransform:"uppercase",letterSpacing:"0.08em",opacity:.5,margin:"0 0 8px"},children:"Flows"}),n&&h.jsx("p",{style:{color:"#ef4444",fontSize:"0.8em"},children:n}),(e==null?void 0:e.length)===0&&h.jsx("p",{style:{opacity:.4,fontSize:"0.85em"},children:"No flows found."}),e==null?void 0:e.map(l=>h.jsx("div",{onClick:()=>o(s===l.flow_id?null:l.flow_id),style:{border:`1px solid ${s===l.flow_id?"#6366f1":"#3f3f46"}`,borderRadius:6,padding:"8px 12px",marginBottom:6,background:s===l.flow_id?"#1e1b4b":"#18181b",cursor:"pointer"},children:h.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[h.jsx("span",{style:{fontSize:"0.88em",fontWeight:500},children:l.flow_name||l.flow_id}),h.jsxs("div",{style:{display:"flex",gap:8,alignItems:"center"},children:[h.jsxs("span",{style:{fontSize:"0.78em",opacity:.5},children:[Array.isArray(l.completed_steps)?l.completed_steps.length:l.completed_steps??0,"/",l.step_count??"?"]}),h.jsx(HT,{status:l.status})]})]})},l.flow_id)),s&&h.jsx("div",{style:{marginTop:8},children:h.jsx(QV,{flowId:s,onClose:()=>o(null)})})]})}const tY={display:"inline-block",width:8,height:8,borderRadius:"50%",background:"#22c55e",marginRight:8,animation:"pulse-dot 1.5s ease-in-out infinite"};if(typeof document<"u"&&!document.getElementById("pulse-dot-style")){const t=document.createElement("style");t.id="pulse-dot-style",t.textContent="@keyframes pulse-dot { 0%,100% { opacity: 1; } 50% { opacity: 0.3; } }",document.head.appendChild(t)}function eY({build:t,onDismiss:e}){const r=t.status==="running",n=["complete","failed","aborted"].includes(t.status);C.useEffect(()=>{if(t.status==="complete"){const s=setTimeout(()=>e==null?void 0:e(),5e3);return()=>clearTimeout(s)}},[t.status,e]);const i={running:"#166534",complete:"#14532d",failed:"#7f1d1d",aborted:"#78350f"};return h.jsxs("div",{style:{border:`1px solid ${r?"#22c55e33":"#3f3f46"}`,borderRadius:6,padding:"10px 12px",marginBottom:12,background:i[t.status]||"#18181b"},children:[h.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[h.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[r&&h.jsx("span",{style:tY}),h.jsx("span",{style:{fontWeight:600,fontSize:"0.88em"},children:t.featureCode}),h.jsx("span",{style:{opacity:.5,fontSize:"0.78em"},children:r?"building":t.status})]}),n&&t.status!=="complete"&&h.jsx("button",{onClick:e,style:{background:"none",border:"none",color:"#9ca3af",cursor:"pointer",fontSize:"0.9em"},children:"✕"})]}),h.jsxs("div",{style:{fontSize:"0.8em",opacity:.7,marginTop:4,fontFamily:"monospace"},children:[t.currentStepId,t.stepNum!=null&&t.totalSteps!=null&&h.jsxs("span",{style:{marginLeft:8,opacity:.5},children:["(",t.stepNum,"/",t.totalSteps,")"]}),t.retries>0&&h.jsxs("span",{style:{marginLeft:8,color:"#f59e0b"},children:["retry ",t.retries]})]})]})}function rY(){const t=gr(s=>s.activeBuild),[e,r]=C.useState(null),n=C.useCallback(()=>{t&&r(`${t.flowId}:${t.completedAt}`)},[t]);C.useEffect(()=>{(t==null?void 0:t.status)==="running"&&r(null)},[t==null?void 0:t.status]);const i=t&&!(e&&e===`${t.flowId}:${t.completedAt}`);return h.jsxs("div",{style:{padding:"12px 14px",color:"#e4e4e7",fontSize:"0.9em",overflowY:"auto",height:"100%"},children:[i&&h.jsx(eY,{build:t,onDismiss:n}),h.jsx(ZV,{}),h.jsx("div",{style:{marginTop:20},children:h.jsx(JV,{activeBuild:t})})]})}function nY({projectName:t,projectRoot:e,onSwitch:r}){const[n,i]=C.useState(!1),[s,o]=C.useState(e||""),a=C.useRef(null);return C.useEffect(()=>{o(e||"")},[e]),C.useEffect(()=>{if(!n)return;const l=c=>{var u;(u=a.current)!=null&&u.contains(c.target)||i(!1)};return window.addEventListener("mousedown",l),()=>window.removeEventListener("mousedown",l)},[n]),C.useEffect(()=>{if(!n)return;const l=c=>{c.key==="Escape"&&i(!1)};return window.addEventListener("keydown",l),()=>window.removeEventListener("keydown",l)},[n]),h.jsxs("div",{ref:a,className:"flex items-center shrink-0 gap-2 relative",children:[h.jsx("span",{className:"text-xs font-semibold tracking-widest uppercase text-blue-600 dark:text-accent",children:"Compose"}),h.jsx("button",{"data-testid":"project-btn",className:"text-[10px] uppercase tracking-wider text-muted-foreground hover:text-foreground transition-colors",onClick:()=>i(l=>!l),title:e||"Switch project","aria-label":"Switch project","aria-haspopup":"dialog","aria-expanded":n,children:t||"no project"}),n&&h.jsxs("div",{"data-testid":"project-popover",role:"dialog","aria-label":"Switch project",className:"absolute top-full left-0 mt-1 z-50 p-2 rounded-md shadow-lg",style:{background:"hsl(var(--popover))",border:"1px solid hsl(var(--border))",minWidth:"280px"},children:[h.jsxs("div",{className:"text-[10px] text-muted-foreground mb-1 px-1",children:["Current: ",e]}),h.jsx("input",{autoFocus:!0,"data-testid":"project-input",className:"w-full px-2 py-1 text-xs rounded border bg-background text-foreground",style:{borderColor:"hsl(var(--border))"},placeholder:"Absolute path to project...",value:s,onChange:l=>o(l.target.value),onKeyDown:async l=>{l.key==="Enter"&&await r(s)&&i(!1),l.key==="Escape"&&i(!1)}})]})]})}const iY={dashboard:{label:"Dashboard",icon:uM,tip:"Overview of project status and activity"},tree:{label:"Items",icon:vb,tip:"Hierarchical list of all items and features"},graph:{label:"Graph",icon:vM,tip:"Visual dependency graph of items"},pipeline:{label:"Pipeline",icon:UM,tip:"Build pipeline stages and progress"},sessions:{label:"Sessions",icon:wf,tip:"Active and past agent sessions"},gates:{label:"Gates",icon:qs,tip:"Quality gates and approval checkpoints"},docs:{label:"Docs",icon:Ei,tip:"Project documentation and specs"},design:{label:"Design",icon:Bc,tip:"Design agent conversations and decisions"},ideabox:{label:"Ideabox",icon:xi,tip:"Captured ideas and suggestions"}};function sY({tabs:t=[],activeTab:e,onTabChange:r,onOpenPalette:n,badges:i={}}){return h.jsxs("div",{className:"flex items-center gap-0.5 h-full",role:"tablist","aria-label":"Main views",children:[t.map(s=>{const o=iY[s],a=s===e,l=o==null?void 0:o.icon,c=(o==null?void 0:o.label)||s,u=i[s];return h.jsxs("button",{role:"tab","aria-selected":a,title:o==null?void 0:o.tip,className:["flex items-center gap-1.5 px-3 h-full text-[11px] uppercase tracking-wider font-medium transition-colors","border-b-2 -mb-px",a?"border-blue-600 text-blue-600 dark:border-accent dark:text-accent":"border-transparent text-muted-foreground hover:text-foreground hover:border-border"].join(" "),onClick:()=>r==null?void 0:r(s),children:[l&&h.jsx(l,{style:{width:12,height:12}}),c,u>0&&h.jsx("span",{className:"text-[9px] min-w-[16px] h-4 flex items-center justify-center rounded-full px-1 tabular-nums",style:{background:"hsl(var(--destructive) / 0.15)",color:"hsl(var(--destructive))"},children:u})]},s)}),h.jsx("div",{className:"flex-1"}),n&&h.jsxs("button",{onClick:n,className:"flex items-center gap-1.5 px-2.5 h-full text-[11px] text-muted-foreground hover:text-foreground transition-colors",title:"Search (⌘K)",children:[h.jsx(Zn,{style:{width:12,height:12}}),h.jsx("kbd",{className:"text-[9px] font-mono opacity-50 bg-muted px-1 py-0.5 rounded",children:"⌘K"})]})]})}function oY(){const[t,e]=C.useState(ly);function r(){const n=!t;q_(n),e(n)}return h.jsx("button",{className:"compose-btn-icon shrink-0",onClick:r,title:t?"Hide verbose events":"Show verbose events","aria-label":"Toggle verbose stream",style:t?{background:"hsl(210 60% 60% / 0.15)",color:"hsl(210 60% 60%)",borderRadius:"3px",padding:"1px 4px",fontSize:"10px"}:{fontSize:"10px"},children:"{ }"})}const Ve={COLLAPSED:"collapsed",EXPANDED:"expanded",MAXIMIZED:"maximized"},aY={[Ve.COLLAPSED]:Ve.EXPANDED,[Ve.EXPANDED]:Ve.MAXIMIZED,[Ve.MAXIMIZED]:Ve.COLLAPSED};function lY(t){return aY[t]??Ve.COLLAPSED}function cY(t){return Ve.COLLAPSED}function hY(t){return Ve.MAXIMIZED}const uY=new Set(Object.values(Ve));function dY(t){return uY.has(t)}function fY(t){switch(t){case Ve.COLLAPSED:return"h-7";case Ve.EXPANDED:return"h-[40vh]";case Ve.MAXIMIZED:return"flex-1";default:return"h-7"}}const UT="compose:agentBarState";function pY(){var t;try{const e=(t=globalThis.localStorage)==null?void 0:t.getItem(UT);return dY(e)?e:Ve.COLLAPSED}catch{return Ve.COLLAPSED}}function mY(t){var e;try{(e=globalThis.localStorage)==null||e.setItem(UT,t)}catch{}}const S0="▾",gY="▴",xY="⤢";function yY({barState:t="collapsed",onStateChange:e}){const[r,n]=C.useState("ready"),[i,s]=C.useState(null);C.useEffect(()=>{function u(d){const{status:p,tool:f,category:m,parallelTasks:x}=d.detail??{};if(s(x??null),x){const{total:g,completed:y,failed:b,active:k}=x;n(`∥ ${y}/${g} tasks${b?` (${b} failed)`:""}${k?` • ${k} active`:""}`)}else n(p==="idle"?"ready":f?`${f} — ${m??p}`:m||(p==="idle"?"ready":p??"ready"))}return window.addEventListener("compose:agent-status",u),()=>window.removeEventListener("compose:agent-status",u)},[]);const o=C.useCallback(()=>{e==null||e(lY(t))},[t,e]),a=C.useCallback(()=>{e==null||e(cY())},[t,e]);C.useCallback(()=>{e==null||e(hY())},[t,e]);const l=t==="collapsed",c=t==="expanded";return h.jsxs("div",{className:"flex flex-col shrink-0 overflow-hidden",style:{borderTop:"1px solid hsl(var(--border))"},"data-agent-bar-state":t,children:[h.jsxs("div",{className:"flex items-center gap-2 px-3 h-7 shrink-0 select-none",style:{borderBottom:l?"none":"1px solid hsl(var(--border) / 0.5)"},children:[h.jsx("button",{className:"compose-btn-icon shrink-0",onClick:o,title:l?"Expand agent bar":c?"Maximize agent bar":"Collapse agent bar","aria-label":"Toggle agent bar",children:l?gY:c?xY:S0}),h.jsx("span",{className:"text-[10px] uppercase tracking-wider font-semibold shrink-0",style:{color:"hsl(var(--accent))"},children:"Agent"}),h.jsx("span",{className:"flex-1 min-w-0 truncate text-[11px] font-mono",style:{color:"hsl(var(--muted-foreground))"},children:r}),h.jsx(oY,{}),i&&i.total>0&&h.jsx("div",{className:"shrink-0 flex items-center gap-1",title:`${i.completed}/${i.total} tasks complete`,children:h.jsx("div",{style:{width:48,height:4,borderRadius:2,background:"hsl(var(--muted))",overflow:"hidden"},children:h.jsx("div",{style:{width:`${i.completed/i.total*100}%`,height:"100%",borderRadius:2,background:i.failed?"hsl(var(--destructive))":"hsl(var(--accent))",transition:"width 300ms ease"}})})}),!l&&h.jsx("button",{className:"compose-btn-icon shrink-0",onClick:a,title:"Collapse agent bar","aria-label":"Collapse agent bar",children:S0})]}),!l&&h.jsx("div",{className:"flex-1 min-h-0 overflow-hidden",children:h.jsx(hy,{})})]})}const bY=280,kY=.6;function vY({isOpen:t=!1,onToggle:e,widthPx:r=380,onResizePx:n,children:i,activeBuild:s,gates:o=[],agentErrors:a=[],items:l=[]}){const c=C.useRef(!1),u=C.useCallback(p=>{p.preventDefault(),c.current=!0;const f=x=>{if(!c.current)return;const g=window.innerWidth-x.clientX,y=window.innerWidth*kY,b=Math.max(bY,Math.min(y,g));n==null||n(b)},m=()=>{c.current=!1,document.removeEventListener("mousemove",f),document.removeEventListener("mouseup",m)};document.addEventListener("mousemove",f),document.addEventListener("mouseup",m)},[n]),d=o.filter(p=>p.status==="pending"||p.status==="awaiting");return h.jsxs("div",{className:"flex shrink-0 h-full",style:{borderLeft:"1px solid hsl(var(--border))"},"data-context-panel-open":t,children:[t&&n&&h.jsx("div",{className:"w-1 cursor-col-resize hover:bg-accent/30 active:bg-accent/50 transition-colors flex-shrink-0",onMouseDown:u}),h.jsx("button",{className:["w-4 h-full flex items-center justify-center","text-[10px] text-muted-foreground hover:text-foreground","transition-colors select-none"].join(" "),onClick:e,title:t?"Close context panel":"Open context panel","aria-expanded":t,"aria-label":"Toggle context panel",style:{background:"hsl(var(--muted) / 0.3)"},children:t?"›":"‹"}),t&&h.jsx("div",{className:"flex flex-col h-full overflow-hidden",style:{width:`${r}px`},children:Yt.Children.toArray(i).length>0?h.jsx("div",{className:"flex-1 min-h-0 flex flex-col overflow-hidden",children:i}):h.jsx(SY,{activeBuild:s,pendingGates:d,agentErrors:a,items:l})})]})}const wY={implementation:"#3b82f6",vision:"#a855f7",planning:"#f59e0b",specification:"#06b6d4",verification:"#22c55e",design:"#f43f5e"};function T0(t){return wY[t]||"#6b7280"}function SY({activeBuild:t,pendingGates:e,agentErrors:r,items:n}){const i={};for(const a of n){const l=a.phase||"unknown";i[l]=(i[l]||0)+1}const s=n.length||1,o=r.slice(-5);return h.jsxs(h.Fragment,{children:[h.jsx("div",{className:"h-7 flex items-center px-3 shrink-0",style:{borderBottom:"1px solid hsl(var(--border))"},children:h.jsx("span",{className:"text-[10px] uppercase tracking-wider font-semibold text-muted-foreground",children:"Project Overview"})}),h.jsxs("div",{className:"flex-1 min-h-0 overflow-y-auto p-3 space-y-4",children:[t?h.jsxs("div",{children:[h.jsx("p",{className:"text-[10px] font-medium uppercase tracking-wider text-muted-foreground mb-1",children:"Active Build"}),h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("span",{className:"text-xs text-accent font-mono",children:t.featureCode||"—"}),h.jsx("span",{className:"text-[10px] text-muted-foreground",children:"·"}),h.jsx("span",{className:"text-[10px] text-foreground",children:t.currentStep||t.step||"—"})]})]}):h.jsxs("div",{children:[h.jsx("p",{className:"text-[10px] font-medium uppercase tracking-wider text-muted-foreground mb-1",children:"Build Status"}),h.jsx("p",{className:"text-[10px] text-muted-foreground italic",children:"No active build"})]}),h.jsxs("div",{children:[h.jsxs("p",{className:"text-[10px] font-medium uppercase tracking-wider text-muted-foreground mb-1",children:["Pending Gates (",e.length,")"]}),e.length===0?h.jsx("p",{className:"text-[10px] text-muted-foreground italic",children:"None"}):h.jsx("div",{className:"space-y-0.5",children:e.slice(0,5).map((a,l)=>h.jsx("p",{className:"text-[10px] text-amber-400 truncate",children:Go(a,n.find(c=>c.id===a.itemId))},l))})]}),h.jsxs("div",{children:[h.jsxs("p",{className:"text-[10px] font-medium uppercase tracking-wider text-muted-foreground mb-1",children:["Recent Errors (",o.length,")"]}),o.length===0?h.jsx("p",{className:"text-[10px] text-muted-foreground italic",children:"None"}):h.jsx("div",{className:"space-y-0.5",children:o.map((a,l)=>h.jsx("p",{className:"text-[10px] text-destructive truncate",children:a.message||a.error||"Error"},l))})]}),h.jsxs("div",{children:[h.jsx("p",{className:"text-[10px] font-medium uppercase tracking-wider text-muted-foreground mb-1",children:"Phase Distribution"}),h.jsx("div",{className:"flex h-2 rounded overflow-hidden gap-px",children:Object.entries(i).map(([a,l])=>h.jsx("div",{className:"h-full",style:{width:`${l/s*100}%`,background:T0(a),opacity:.75,minWidth:"2px"},title:`${a}: ${l}`},a))}),h.jsx("div",{className:"flex flex-wrap gap-x-3 gap-y-0.5 mt-1",children:Object.entries(i).map(([a,l])=>h.jsxs("span",{className:"text-[9px] text-muted-foreground flex items-center gap-1",children:[h.jsx("span",{className:"inline-block w-1.5 h-1.5 rounded-full",style:{background:T0(a)}}),a,": ",l]},a))})]})]})]})}const In=60,Rr=24,ol=80,Cu=28,ku=48,_0=8,fs=5,Sc=9;function TY(t,e){return t?t.length>e?t.slice(0,e)+"…":t:""}function _Y(t,e,r){const n=new Map(e.map(a=>[a.id,a])),i=[],s=[],o=new Map;for(const a of r){if(a.toId===t.id){const l=n.get(a.fromId);l&&i.push(l)}if(a.fromId===t.id){const l=n.get(a.toId);l&&s.push(l)}}for(const a of s){const l=[];for(const c of r)if(c.fromId===a.id&&c.toId!==t.id){const u=n.get(c.toId);u&&l.push(u)}l.length>0&&o.set(a.id,l)}return{parents:i,children:s,grandchildren:o}}function vu(t,e,r,n,i){const s=Math.min(t,fs),o=s*n+(s-1)*_0,a=(r-o)/2,l=[];for(let c=0;c<s;c++)l.push({x:a+c*(n+_0),y:e,w:n,h:i});return{positions:l,overflow:t>fs?t-fs+1:0}}function al({item:t,x:e,y:r,w:n,h:i,isSelected:s,isDashed:o,onSelect:a,onHover:l,onLeave:c}){const u=xr[t.type]||xr.task,d=s?.2:.08;return h.jsxs("g",{style:{cursor:"pointer"},onClick:()=>a(t.id),onMouseEnter:p=>l(t,p),onMouseLeave:c,children:[h.jsx("rect",{x:e,y:r,width:n,height:i,rx:4,fill:u,fillOpacity:d,stroke:u,strokeWidth:s?2:1.5,strokeDasharray:o?"4 2":void 0}),h.jsx("text",{x:e+n/2,y:r+i/2,textAnchor:"middle",dominantBaseline:"central",fontSize:s?Sc+1:Sc,fontWeight:s?600:400,fill:"hsl(var(--foreground))",children:TY(t.title,s?10:8)})]})}function EY({item:t,pos:e}){if(!t||!e)return null;const r=xr[t.type]||xr.task,n=qn[t.status]||qn.planned;return h.jsxs("div",{className:"absolute z-50 pointer-events-none px-2 py-1.5 rounded bg-popover border border-border shadow-md",style:{left:e.x,top:e.y,transform:"translate(-50%, -100%)"},children:[h.jsx("p",{className:"text-xs font-medium text-foreground whitespace-nowrap",children:t.title}),h.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[h.jsx("span",{className:"text-[10px]",style:{color:r},children:t.type}),h.jsxs("span",{className:"text-[10px] flex items-center gap-1",children:[h.jsx("span",{className:"inline-block w-1.5 h-1.5 rounded-full",style:{background:n}}),t.status]}),h.jsx("span",{className:"text-[10px] text-muted-foreground",children:ef[t.confidence||0]})]})]})}function NY({item:t,items:e,connections:r,onSelect:n}){const[i,s]=C.useState(null),[o,a]=C.useState(null),{parents:l,children:c,grandchildren:u}=C.useMemo(()=>_Y(t,e,r),[t,e,r]),d=C.useCallback((I,A)=>{const D=A.currentTarget.closest(".connection-graph-wrap").getBoundingClientRect(),R=A.currentTarget.getBoundingClientRect();s(I),a({x:R.x+R.width/2-D.x,y:R.y-D.y-4})},[]),p=C.useCallback(()=>{s(null),a(null)},[]);if(!(l.length>0||c.length>0))return null;const m=288,x=[];let g=12,y=[],b=0;if(l.length>0){const I=vu(l.length,g,m,In,Rr);y=I.positions,b=I.overflow,g+=Rr+ku}const k=(m-ol)/2,T=g;g+=Cu+ku;let _=[],w=0;if(c.length>0){const I=vu(c.length,g,m,In,Rr);_=I.positions,w=I.overflow,g+=Rr}let E=new Map,B=new Map;const P=[...u.entries()];let N=[];if(P.length>0){g+=ku;for(const[D,R]of P)for(const j of R)N.push({...j,_parentChildId:D});const I=vu(N.length,g,m,In,Rr);let A=0;for(const[D,R]of P){const j=[];for(let S=0;S<R.length&&A<I.positions.length;S++,A++)j.push(I.positions[A]);E.set(D,j)}I.overflow>0&&B.set("all",I.overflow),g+=Rr}const M=g+12;for(let I=0;I<y.length;I++){const A=y[I];x.push({x1:A.x+A.w/2,y1:A.y+A.h,x2:k+ol/2,y2:T})}for(let I=0;I<_.length;I++){const A=_[I];x.push({x1:k+ol/2,y1:T+Cu,x2:A.x+A.w/2,y2:A.y})}for(const[I,A]of E){const D=c.findIndex(R=>R.id===I);if(D>=0&&D<_.length){const R=_[D];for(const j of A)x.push({x1:R.x+R.w/2,y1:R.y+R.h,x2:j.x+j.w/2,y2:j.y})}}const $=l.slice(0,fs-(b>0?1:0)),q=c.slice(0,fs-(w>0?1:0)),O=N.slice(0,fs-(B.size>0?1:0));return h.jsxs("div",{className:"space-y-1",children:[h.jsx("p",{className:"text-[10px] font-medium uppercase tracking-wider text-muted-foreground",children:"Graph"}),h.jsxs("div",{className:"relative connection-graph-wrap",children:[h.jsxs("svg",{width:m,height:M,className:"w-full",viewBox:`0 0 ${m} ${M}`,children:[x.map((I,A)=>h.jsx("line",{x1:I.x1,y1:I.y1,x2:I.x2,y2:I.y2,stroke:"hsl(var(--muted-foreground))",strokeOpacity:.3,strokeWidth:1},A)),$.map((I,A)=>h.jsx(al,{item:I,x:y[A].x,y:y[A].y,w:In,h:Rr,isSelected:!1,isDashed:!0,onSelect:n,onHover:d,onLeave:p},I.id)),b>0&&h.jsxs("text",{x:y[y.length-1].x+In/2,y:y[0].y+Rr/2,textAnchor:"middle",dominantBaseline:"central",fontSize:Sc,fill:"hsl(var(--muted-foreground))",children:["+",b," more"]}),h.jsx(al,{item:t,x:k,y:T,w:ol,h:Cu,isSelected:!0,isDashed:!1,onSelect:n,onHover:d,onLeave:p}),q.map((I,A)=>h.jsx(al,{item:I,x:_[A].x,y:_[A].y,w:In,h:Rr,isSelected:!1,isDashed:!1,onSelect:n,onHover:d,onLeave:p},I.id)),w>0&&h.jsxs("text",{x:_[_.length-1].x+In/2,y:_[0].y+Rr/2,textAnchor:"middle",dominantBaseline:"central",fontSize:Sc,fill:"hsl(var(--muted-foreground))",children:["+",w," more"]}),O.map((I,A)=>{const R=[...E.values()].flat()[A];return R?h.jsx(al,{item:I,x:R.x,y:R.y,w:In,h:Rr,isSelected:!1,isDashed:!1,onSelect:n,onHover:d,onLeave:p},I.id):null})]}),h.jsx(EY,{item:i,pos:o})]})]})}const jY=["Untested","Low","Moderate","High","Crystallized"];function LY({level:t=0,className:e}){const r=Math.max(0,Math.min(4,t||0)),n=jY[r]??"Untested",i=r===0?Xp[0]:Xp[r];return h.jsxs("span",{className:rt("inline-flex items-center gap-1",e),children:[h.jsx("span",{className:"flex items-center gap-0.5",children:[1,2,3,4].map(s=>h.jsx("span",{className:rt("h-2.5 w-1.5 rounded-sm",s<=r?i:"bg-slate-600")},s))}),h.jsx("span",{className:"text-[10px] text-muted-foreground",children:n})]})}function BY(t,e=Date.now()){if(!t)return null;const r=Date.parse(t);if(Number.isNaN(r))return null;const n=e-r,i=Math.floor(n/36e5);return i<1?"<1h ago":i<48?`${i}h ago`:`${Math.floor(i/24)}d ago`}function E0(t){return t==null?"—":t<1e3?String(t):t<1e6?`${(t/1e3).toFixed(1)}k`:`${(t/1e6).toFixed(1)}M`}function AY(t){return t==null?"—":`$${Number(t).toFixed(t<1?3:2)}`}function MY(t){if(t==null)return"—";const e=Math.round(t/1e3);if(e<60)return`${e}s`;const r=Math.round(e/60);if(r<60)return`${r}m`;const n=Math.floor(r/60),i=r%60;return`${n}h${i?` ${i}m`:""}`}function IY(t,e=Date.now()){const r=(t||[]).filter(i=>i==null?void 0:i.started_at);if(!r.length)return null;let n=null;for(const i of r){const s=Date.parse(i.started_at);!Number.isNaN(s)&&(n==null||s>n)&&(n=s)}return n==null?null:BY(new Date(n).toISOString(),e)}function FY(t,e=Date.now()){const r=(t==null?void 0:t.branches)||[],n=r.filter(c=>c.state==="complete"),i=r.filter(c=>c.state==="running"),s=r.length,o=IY(r,e),a=n.length>=2;return{summary:i.length>0&&n.length<2?`${n.length} of ${s} branches ready`:`${s} branch${s===1?"":"es"}${o?` · last fork ${o}`:""}`,canCompare:a,completeBranches:n,runningCount:i.length,totalCount:s}}function PY(t,e=[]){const r=new Map(t.map(s=>[s.branch_id,s])),n=e[0]&&r.has(e[0])?r.get(e[0]):t[0]||null,i=e[1]&&r.has(e[1])?r.get(e[1]):t[1]||null;return[n,i]}function N0({branch:t,extraRows:e=[]}){var o;const r=t.files_touched||[],n=t.tests||{},i=t.cost||{},s=[{label:"Files touched",value:r.length},{label:"Tests",value:`${n.passed??0} / ${n.failed??0} / ${n.skipped??0}`},{label:"Tokens in / out",value:`${E0(i.tokens_in)} / ${E0(i.tokens_out)}`},{label:"USD",value:AY(i.usd)},{label:"Wall clock",value:MY(i.wall_clock_ms)},{label:"Final artifact",value:((o=t.final_artifact)==null?void 0:o.path)||"—"},...e];return h.jsx("div",{className:"space-y-1",children:s.map((a,l)=>h.jsxs("div",{className:"flex justify-between gap-2 text-[10px]",children:[h.jsx("span",{className:"text-muted-foreground",children:a.label}),h.jsx("span",{className:"font-mono text-right truncate",title:typeof a.value=="string"?a.value:void 0,children:a.value})]},l))})}function DY({lineage:t,selectedPair:e=[],onSelectPair:r=()=>{},extraMetricsForBranch:n=()=>[],now:i=Date.now()}){var g,y;const[s,o]=C.useState(!1),{summary:a,canCompare:l,completeBranches:c}=FY(t,i),[u,d]=PY(c,e),p=()=>{l&&(o(b=>!b),!s&&u&&d&&r([u.branch_id,d.branch_id]))};if(!s)return h.jsxs("div",{className:"flex items-center justify-between text-[10px] text-muted-foreground",children:[h.jsx("span",{children:a}),h.jsx("button",{disabled:!l,onClick:p,className:"text-[10px] px-2 py-0.5 rounded border border-border "+(l?"hover:bg-muted/40 text-foreground cursor-pointer":"opacity-40 cursor-not-allowed"),"data-testid":"branch-compare-toggle",children:"Compare"})]});const f=(g=u==null?void 0:u.final_artifact)==null?void 0:g.snapshot,m=(y=d==null?void 0:d.final_artifact)==null?void 0:y.snapshot,x=!!f&&!!m;return h.jsxs("div",{className:"space-y-2 rounded border border-border p-2 bg-muted/10",children:[h.jsxs("div",{className:"flex items-center justify-between",children:[h.jsx("span",{className:"text-[10px] text-muted-foreground",children:a}),h.jsx("button",{onClick:()=>o(!1),className:"text-[10px] text-muted-foreground hover:text-foreground",children:"Collapse"})]}),h.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[h.jsxs("div",{children:[h.jsx("div",{className:"text-[10px] font-semibold mb-1 font-mono truncate",title:u==null?void 0:u.branch_id,children:u?`A: ${u.branch_id.slice(0,8)}…`:"A: (none)"}),u&&h.jsx(N0,{branch:u,extraRows:n(u)})]}),h.jsxs("div",{children:[h.jsx("div",{className:"text-[10px] font-semibold mb-1 font-mono truncate",title:d==null?void 0:d.branch_id,children:d?`B: ${d.branch_id.slice(0,8)}…`:"B: (none)"}),d&&h.jsx(N0,{branch:d,extraRows:n(d)})]})]}),h.jsx("div",{className:"col-span-2",children:x?h.jsx(Rp,{oldText:f,newText:m}):h.jsxs("div",{className:"text-[10px] italic text-muted-foreground",children:["No artifact produced on ",!f&&!m?"either branch":f?"branch B":"branch A","."]})})]})}const OY={path_drift:"Path drift",contract_drift:"Contract drift",review_debt_drift:"Review debt"};function RY(t){return OY[t]??t}function j0(t){return t==null||typeof t!="number"||isNaN(t)?"—":`${Math.round(t*100)}%`}function $Y(t){var r,n;return(((n=(r=t==null?void 0:t.lifecycle)==null?void 0:r.lifecycle_ext)==null?void 0:n.drift_axes)??[]).filter(i=>i.breached===!0)}function zY({item:t}){const[e,r]=C.useState(!1),n=$Y(t);if(n.length===0)return null;const i=n.length;return h.jsxs("div",{className:"drift-ribbon",style:{background:"hsl(var(--destructive) / 0.12)",borderLeft:"3px solid hsl(var(--destructive))",minHeight:"28px",padding:e?"6px 10px 8px":"0 10px",display:"flex",flexDirection:"column",justifyContent:"center",gap:0,borderRadius:"4px",marginBottom:"4px"},children:[h.jsxs("button",{onClick:()=>r(s=>!s),style:{display:"flex",alignItems:"center",gap:"6px",background:"none",border:"none",cursor:"pointer",padding:"4px 0",color:"hsl(var(--destructive))",fontSize:"12px",fontWeight:600,width:"100%",textAlign:"left"},"aria-expanded":e,"data-testid":"drift-ribbon-toggle",children:[h.jsx(Ac,{size:13}),h.jsxs("span",{children:[i," drift alert",i!==1?"s":""," — click to ",e?"collapse":"expand"]}),e?h.jsx(yb,{size:13,style:{marginLeft:"auto"}}):h.jsx(fa,{size:13,style:{marginLeft:"auto"}})]}),e&&h.jsxs("table",{style:{width:"100%",fontSize:"11px",borderCollapse:"collapse",marginTop:"4px"},"data-testid":"drift-ribbon-table",children:[h.jsx("thead",{children:h.jsxs("tr",{style:{color:"hsl(var(--muted-foreground))"},children:[h.jsx("th",{style:{textAlign:"left",padding:"2px 4px",fontWeight:500},children:"Axis"}),h.jsx("th",{style:{textAlign:"right",padding:"2px 4px",fontWeight:500},children:"Ratio"}),h.jsx("th",{style:{textAlign:"right",padding:"2px 4px",fontWeight:500},children:"Threshold"}),h.jsx("th",{style:{textAlign:"left",padding:"2px 4px",fontWeight:500},children:"Explanation"})]})}),h.jsx("tbody",{children:n.map(s=>h.jsxs("tr",{"data-testid":`drift-axis-row-${s.axis_id}`,children:[h.jsx("td",{style:{padding:"2px 4px",color:"hsl(var(--foreground))",fontWeight:500},children:RY(s.axis_id)}),h.jsx("td",{style:{padding:"2px 4px",textAlign:"right",color:"hsl(var(--destructive))"},children:j0(s.ratio)}),h.jsx("td",{style:{padding:"2px 4px",textAlign:"right",color:"hsl(var(--muted-foreground))"},children:j0(s.threshold)}),h.jsx("td",{style:{padding:"2px 4px",color:"hsl(var(--muted-foreground))",maxWidth:"200px",wordBreak:"break-word"},children:s.explanation??""})]},s.axis_id))})]})]})}function WY({level:t,onChange:e}){const r=["hsl(var(--muted-foreground))","hsl(var(--destructive))","hsl(var(--accent))","hsl(var(--success))","hsl(var(--success))"],n=r[t]||r[0];return h.jsxs("button",{onClick:()=>e((t+1)%5),className:"flex items-center gap-2 px-2 py-1 rounded-md bg-muted hover:bg-muted/80 transition-colors",title:"Click to cycle confidence",children:[h.jsx("span",{className:"text-xs text-muted-foreground",children:ef[t]}),h.jsx("div",{className:"flex items-center gap-0.5",children:[0,1,2,3].map(i=>h.jsx("div",{className:"rounded-full transition-all",style:{width:6,height:6,background:i<t?n:"transparent",border:`1.5px solid ${i<t?n:"hsl(var(--border))"}`}},i))})]})}function qY({item:t,connections:e,items:r,onSelect:n,onDeleteConnection:i}){const s=new Map(r.map(l=>[l.id,l])),o=[];for(const l of e)if(l.type!=="contradicts"){if(l.fromId===t.id){const c=s.get(l.toId);c&&o.push({item:c,type:l.type,direction:"outgoing",connId:l.id})}if(l.toId===t.id){const c=s.get(l.fromId);c&&o.push({item:c,type:l.type,direction:"incoming",connId:l.id})}}if(o.length===0)return null;const a={};for(const l of o){const c=`${l.type}-${l.direction}`;a[c]||(a[c]={type:l.type,direction:l.direction,items:[]}),a[c].items.push({item:l.item,connId:l.connId})}return h.jsxs("div",{className:"space-y-2",children:[h.jsx("p",{className:"text-[10px] font-medium uppercase tracking-wider text-muted-foreground",children:"Connections"}),Object.values(a).map(l=>h.jsxs("div",{children:[h.jsx("p",{className:"text-[10px] text-muted-foreground mb-1",children:l.direction==="incoming"?`${l.type} from`:`${l.type} to`}),h.jsx("div",{className:"space-y-0.5",children:l.items.map(({item:c,connId:u})=>h.jsxs("div",{className:"flex w-full items-center gap-2 px-2 py-1 rounded text-left hover:bg-muted/50 transition-colors group/conn",children:[h.jsxs("button",{onClick:()=>n(c.id),className:"flex flex-1 items-center gap-2 min-w-0",children:[h.jsx("div",{className:"w-1.5 h-1.5 rounded-full shrink-0",style:{background:qn[c.status]||qn.planned}}),h.jsx("span",{className:"text-xs text-foreground truncate",children:c.title}),h.jsx("span",{className:"text-[10px] ml-auto shrink-0",style:{color:xr[c.type]},children:c.type})]}),i&&h.jsx("button",{onClick:()=>i(u),className:"opacity-0 group-hover/conn:opacity-100 p-0.5 rounded hover:bg-destructive/20 text-muted-foreground hover:text-destructive transition-all shrink-0",title:"Remove connection",children:h.jsx(cn,{className:"h-3 w-3"})})]},u))})]},`${l.type}-${l.direction}`))]})}function ll(t){if(!t)return"";const e=new Date(t);return e.toLocaleDateString("en-US",{month:"short",day:"numeric"})+" "+e.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit",hour12:!1})}function HY({featureCode:t,lineage:e}){const r=gr(i=>i.selectedBranches),n=gr(i=>i.setSelectedBranches);return h.jsx(DY,{lineage:e,selectedPair:(r==null?void 0:r[t])||[],onSelectPair:i=>n(t,i)})}function UY({featureCode:t}){const[e,r]=C.useState([]),[n,i]=C.useState(!0);return C.useEffect(()=>{const s=new AbortController;return i(!0),Rt(`/api/session/history?featureCode=${encodeURIComponent(t)}&limit=10`,{signal:s.signal}).then(o=>o.json()).then(o=>{s.signal.aborted||r(o.sessions||[])}).catch(o=>{s.signal.aborted||r([])}).finally(()=>{s.signal.aborted||i(!1)}),()=>s.abort()},[t]),n||e.length===0?null:h.jsxs("div",{children:[h.jsxs("div",{className:"text-[10px] font-medium uppercase tracking-wider text-muted-foreground mb-1.5",children:["Sessions (",e.length,")"]}),h.jsx("div",{className:"space-y-2",children:e.map(s=>{var o;return h.jsxs("div",{className:"text-xs text-muted-foreground border-l-2 border-border pl-2",children:[h.jsxs("div",{className:"font-medium text-foreground",children:[((o=s.phaseAtBind)==null?void 0:o.replace(/_/g," "))||"—",s.phaseAtEnd&&s.phaseAtEnd!==s.phaseAtBind&&` → ${s.phaseAtEnd.replace(/_/g," ")}`]}),h.jsxs("div",{children:[s.toolCount," tools · ",Math.round((new Date(s.endedAt)-new Date(s.startedAt))/6e4),"m"]})]},s.id)})})]})}const GY=["informs","supports","blocks","contradicts"];function VY({item:t,items:e,onCreateConnection:r,onDismiss:n}){const[i,s]=C.useState(""),[o,a]=C.useState("informs"),l=e.filter(u=>u.id===t.id?!1:i?u.title.toLowerCase().includes(i.toLowerCase()):!0).slice(0,8),c=C.useCallback(async u=>{await r({fromId:t.id,toId:u,type:o}),n()},[t.id,o,r,n]);return h.jsx("div",{className:"absolute bottom-full left-0 mb-1 w-64 rounded-md border border-border bg-popover shadow-lg z-50",children:h.jsxs("div",{className:"p-2 space-y-2",children:[h.jsxs("div",{className:"flex items-center gap-1.5",children:[h.jsx("select",{className:"text-[10px] px-1.5 py-1 rounded bg-muted text-foreground border border-border cursor-pointer",value:o,onChange:u=>a(u.target.value),children:GY.map(u=>h.jsx("option",{value:u,children:u},u))}),h.jsx("span",{className:"text-[10px] text-muted-foreground",children:"to..."})]}),h.jsxs("div",{className:"relative",children:[h.jsx(Zn,{className:"absolute left-2 top-1/2 -translate-y-1/2 h-3 w-3 text-muted-foreground"}),h.jsx("input",{className:"w-full text-xs bg-muted text-foreground pl-7 pr-2 py-1.5 rounded border border-border outline-none",placeholder:"Search items...",value:i,onChange:u=>s(u.target.value),autoFocus:!0})]}),h.jsx("div",{className:"max-h-40 overflow-auto space-y-0.5",children:l.length===0?h.jsx("p",{className:"text-[10px] text-muted-foreground text-center py-2",children:"No items found"}):l.map(u=>h.jsxs("button",{onClick:()=>c(u.id),className:"flex w-full items-center gap-2 px-2 py-1 rounded text-left hover:bg-muted/50 transition-colors",children:[h.jsx("div",{className:"w-1.5 h-1.5 rounded-full shrink-0",style:{background:qn[u.status]||qn.planned}}),h.jsx("span",{className:"text-xs text-foreground truncate",children:u.title}),h.jsx("span",{className:"text-[10px] ml-auto shrink-0",style:{color:xr[u.type]},children:u.type})]},u.id))})]})})}function YY({gate:t,onResolveGate:e}){const[r,n]=C.useState(null),[i,s]=C.useState(""),o=()=>{e(t.id,"revised",i||void 0),n(null),s("")},a=()=>{i.trim()&&(e(t.id,"killed",i),n(null),s(""))};return h.jsxs("div",{className:"space-y-1.5",children:[h.jsxs("div",{className:"flex items-center gap-1.5",children:[h.jsx($t,{variant:"outline",size:"sm",className:"h-6 text-[10px] gap-1 text-success border-success/30 hover:bg-success/10",onClick:()=>e(t.id,"approved"),children:"Approve"}),h.jsx($t,{variant:"outline",size:"sm",className:rt("h-6 text-[10px] gap-1 text-amber-400 border-amber-400/30 hover:bg-amber-400/10",r==="revise"&&"bg-amber-400/10"),onClick:()=>{n(r==="revise"?null:"revise"),s("")},children:"Revise"}),h.jsx($t,{variant:"outline",size:"sm",className:rt("h-6 text-[10px] gap-1 text-destructive border-destructive/30 hover:bg-destructive/10",r==="kill"&&"bg-destructive/10"),onClick:()=>{n(r==="kill"?null:"kill"),s("")},children:"Kill"})]}),r&&h.jsxs("div",{className:"flex items-center gap-1.5",children:[h.jsx("input",{className:"flex-1 text-xs bg-muted text-foreground px-2 py-1 rounded border border-border outline-none",placeholder:r==="revise"?"Feedback (optional)...":"Kill reason (required)...",value:i,onChange:l=>s(l.target.value),onKeyDown:l=>{l.key==="Enter"&&(r==="revise"?o():a()),l.key==="Escape"&&n(null)},autoFocus:!0}),h.jsx($t,{variant:"outline",size:"sm",className:"h-6 text-[10px]",disabled:r==="kill"&&!i.trim(),onClick:r==="revise"?o:a,children:r==="revise"?"Submit":"Confirm Kill"})]})]})}function XY({item:t,items:e,connections:r,gates:n,onUpdate:i,onDelete:s,onCreateConnection:o,onDeleteConnection:a,onSelect:l,onClose:c,onPressureTest:u,onResolveGate:d}){var I,A,D,R,j,S;const[p,f]=C.useState(!1),[m,x]=C.useState(""),[g,y]=C.useState(!1),[b,k]=C.useState(""),[T,_]=C.useState(!1),[w,E]=C.useState("");C.useEffect(()=>{E((t==null?void 0:t.group)||"")},[t==null?void 0:t.id,t==null?void 0:t.group]);const B=C.useCallback(()=>{const W=w.trim(),K=(t==null?void 0:t.group)||"";W!==K&&i(t.id,{group:W||null})},[w,t==null?void 0:t.id,t==null?void 0:t.group,i]),P=C.useCallback(()=>{x(t.title),f(!0)},[t==null?void 0:t.title]),N=C.useCallback(()=>{m.trim()&&m!==t.title&&i(t.id,{title:m.trim()}),f(!1)},[m,t==null?void 0:t.id,t==null?void 0:t.title,i]),M=C.useCallback(()=>{k(t.description||""),y(!0)},[t==null?void 0:t.description]),$=C.useCallback(()=>{b!==(t.description||"")&&i(t.id,{description:b}),y(!1)},[b,t==null?void 0:t.id,t==null?void 0:t.description,i]),q=C.useMemo(()=>{if(!t)return 0;let W=0;for(const K of r)K.type==="contradicts"&&(K.fromId===t.id||K.toId===t.id)&&W++;return W},[t==null?void 0:t.id,r]);if(!t)return null;const O=xr[t.type]||xr.task;return h.jsxs("div",{className:"w-full bg-card flex flex-col h-full",children:[h.jsxs("div",{className:"p-3 pb-2 flex items-start gap-2",children:[h.jsxs("div",{className:"flex-1 min-w-0",children:[h.jsxs("div",{className:"flex items-center gap-1.5 mb-1.5",children:[h.jsx(nr,{variant:"outline",className:"text-[10px] px-1.5 py-0 h-4",style:{color:O,borderColor:O},children:t.type}),t.phase&&h.jsx(nr,{variant:"outline",className:"text-[10px] px-1.5 py-0 h-4",children:jl[t.phase]||t.phase})]}),p?h.jsx("input",{className:"w-full text-sm font-semibold bg-muted text-foreground px-1.5 py-0.5 rounded border border-ring outline-none",value:m,onChange:W=>x(W.target.value),onBlur:N,onKeyDown:W=>{W.key==="Enter"&&N(),W.key==="Escape"&&f(!1)},autoFocus:!0}):h.jsx("h3",{className:"text-sm font-semibold text-foreground cursor-pointer hover:text-accent transition-colors",onDoubleClick:P,title:"Double-click to edit",children:t.title})]}),h.jsx($t,{variant:"ghost",size:"icon",className:"h-6 w-6 shrink-0",onClick:c,children:h.jsx(cn,{className:"h-3.5 w-3.5"})})]}),h.jsx(zl,{}),h.jsx(Hn,{className:"flex-1",children:h.jsxs("div",{className:"p-3 space-y-4",children:[h.jsx(zY,{item:t}),((I=t.lifecycle)==null?void 0:I.featureCode)&&h.jsx(HY,{featureCode:t.lifecycle.featureCode,lineage:(A=t.lifecycle.lifecycle_ext)==null?void 0:A.branch_lineage}),h.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[h.jsx("select",{className:"text-xs px-2 py-1 rounded-md bg-muted text-foreground border border-border cursor-pointer",value:t.status||"planned",onChange:W=>i(t.id,{status:W.target.value}),children:x_.map(W=>h.jsx("option",{value:W,children:W.replace("_"," ")},W))}),h.jsx(WY,{level:t.confidence||0,onChange:W=>i(t.id,{confidence:W})})]}),h.jsx(LY,{level:t.confidence||0}),h.jsxs("div",{children:[h.jsx("p",{className:"text-[10px] font-medium uppercase tracking-wider text-muted-foreground mb-1",children:"Phase"}),h.jsxs("select",{className:"text-xs px-2 py-1 rounded-md bg-muted text-foreground border border-border cursor-pointer w-full",value:t.phase||"",onChange:W=>i(t.id,{phase:W.target.value||null}),children:[h.jsx("option",{value:"",children:"No phase"}),ny.map(W=>h.jsx("option",{value:W,children:jl[W]},W))]})]}),h.jsxs("div",{children:[h.jsx("p",{className:"text-[10px] font-medium uppercase tracking-wider text-muted-foreground mb-1",children:"Group"}),h.jsx("input",{type:"text",className:"w-full text-xs bg-muted text-foreground px-2 py-1 rounded-md border border-border outline-none focus:border-ring",value:w,placeholder:"(none)",onChange:W=>E(W.target.value),onBlur:B,onKeyDown:W=>{W.key==="Enter"&&(W.preventDefault(),W.currentTarget.blur()),W.key==="Escape"&&(E(t.group||""),W.currentTarget.blur())},"data-testid":"item-detail-group-input"})]}),h.jsxs("div",{children:[h.jsx("p",{className:"text-[10px] font-medium uppercase tracking-wider text-muted-foreground mb-1",children:"Description"}),g?h.jsx("textarea",{className:"w-full text-xs bg-muted text-foreground px-2 py-1.5 rounded border border-ring outline-none resize-none",rows:4,value:b,onChange:W=>k(W.target.value),onBlur:$,onKeyDown:W=>{W.key==="Escape"&&y(!1)},autoFocus:!0}):h.jsx("p",{className:rt("text-xs leading-relaxed cursor-pointer rounded px-2 py-1.5 hover:bg-muted/50 transition-colors",t.description?"text-muted-foreground":"text-muted-foreground/50 italic"),onClick:M,children:t.description||"Click to add description..."})]}),h.jsx(qY,{item:t,connections:r,items:e,onSelect:l,onDeleteConnection:a}),h.jsx(NY,{item:t,items:e,connections:r,onSelect:l}),((D=t.lifecycle)==null?void 0:D.featureCode)&&h.jsx(UY,{featureCode:t.lifecycle.featureCode}),(t.lifecycle||n&&n.some(W=>W.itemId===t.id))&&(()=>{var st;const W=t.lifecycle,K=n?n.filter(J=>J.itemId===t.id):[],F=K.filter(J=>J.status==="pending"),ht=K.filter(J=>J.status!=="pending");return h.jsxs("div",{children:[h.jsx("p",{className:"text-[10px] font-medium uppercase tracking-wider text-muted-foreground mb-1.5",children:"Lifecycle"}),h.jsxs("div",{className:"space-y-1.5",children:[W&&h.jsxs("div",{className:"flex items-center gap-2 px-2 py-1 rounded bg-muted/30",children:[h.jsx("span",{className:"text-[10px] text-muted-foreground",children:"Phase:"}),h.jsx("span",{className:"text-[10px] text-foreground font-medium",children:ve[W.currentPhase]??W.currentPhase}),W.featureCode&&h.jsx("span",{className:"text-[10px] text-muted-foreground ml-auto font-mono",children:W.featureCode})]}),((st=W==null?void 0:W.phaseHistory)==null?void 0:st.length)>1&&h.jsxs("div",{className:"px-2 py-1 rounded bg-muted/30",children:[h.jsx("p",{className:"text-[10px] text-muted-foreground mb-0.5",children:"History"}),h.jsx("div",{className:"flex flex-wrap gap-x-1 gap-y-0.5",children:W.phaseHistory.map((J,ct)=>h.jsxs("span",{className:rt("text-[10px]",J.phase===W.currentPhase?"text-foreground font-medium":"text-muted-foreground"),children:[ve[J.phase]??J.phase,J.outcome&&J.outcome!=="approved"&&h.jsxs("span",{className:"text-amber-400",children:[" (",J.outcome,")"]}),ct<W.phaseHistory.length-1&&" → "]},ct))})]}),F.map(J=>{var at,Z;const ct=J.artifactAssessment,zt=iy[J.fromPhase];return h.jsxs("div",{className:"rounded bg-amber-400/10 border border-amber-400/20 px-2 py-1.5",children:[h.jsxs("p",{className:"text-[10px] text-amber-400 font-medium mb-1",children:["Pending: ",vn[J.stepId]??`${ve[J.fromPhase]??J.fromPhase} → ${ve[J.toPhase]??J.toPhase}`]}),ct&&ct.exists&&h.jsxs("p",{className:"text-[10px] text-muted-foreground mb-1",children:[zt&&h.jsx("span",{className:"font-mono",children:zt}),zt&&": ",Math.round(ct.completeness*100),"% complete"," · ",ct.wordCount," words",((Z=(at=ct.sections)==null?void 0:at.missing)==null?void 0:Z.length)>0&&h.jsxs("span",{className:"text-amber-400",children:[" (missing: ",ct.sections.missing.join(", "),")"]}),!ct.meetsMinWordCount&&h.jsx("span",{className:"text-amber-400",children:" (below min word count)"})]}),ct&&!ct.exists&&h.jsxs("p",{className:"text-[10px] text-muted-foreground mb-1",children:[zt??"Artifact"," not found"]}),d&&h.jsx(YY,{gate:J,onResolveGate:d})]},J.id)}),ht.map(J=>{const ct={approved:"text-success",revised:"text-amber-400",killed:"text-destructive"};return h.jsxs("div",{className:"flex items-center gap-2 px-2 py-1 rounded bg-muted/30",children:[h.jsx("span",{className:"text-[10px] text-muted-foreground",children:vn[J.stepId]??`${ve[J.fromPhase]??J.fromPhase} → ${ve[J.toPhase]??J.toPhase}`}),h.jsx(nr,{variant:"outline",className:rt("text-[10px] px-1.5 py-0 h-4 ml-auto",ct[J.outcome]||""),children:J.outcome})]},J.id)})]})]})})(),((j=(R=t.evidence)==null?void 0:R.stratumViolations)==null?void 0:j.length)>0&&h.jsxs("div",{children:[h.jsxs("p",{className:"text-[10px] font-medium uppercase tracking-wider text-destructive mb-1.5",children:["Blocked — Ensure Violations",t.evidence.violatedAt&&h.jsx("span",{className:"ml-2 font-normal normal-case text-muted-foreground",children:ll(t.evidence.violatedAt)})]}),h.jsx("div",{className:"space-y-0.5",children:t.evidence.stratumViolations.map((W,K)=>h.jsxs("div",{className:"flex items-start gap-2 px-2 py-1 rounded bg-destructive/10",children:[h.jsx("div",{className:"w-1.5 h-1.5 rounded-full shrink-0 mt-1",style:{background:"hsl(var(--destructive))"}}),h.jsx("span",{className:"text-[10px] text-destructive leading-relaxed",children:W})]},K))})]}),((S=t.evidence)==null?void 0:S.stratumTrace)&&h.jsxs("div",{children:[h.jsxs("p",{className:"text-[10px] font-medium uppercase tracking-wider text-muted-foreground mb-1.5",children:["Stratum Trace",t.evidence.tracedAt&&h.jsx("span",{className:"ml-2 font-normal normal-case",children:ll(t.evidence.tracedAt)})]}),h.jsx("div",{className:"space-y-0.5",children:(t.evidence.stratumTrace.trace||[]).map(W=>h.jsxs("div",{className:"flex items-center gap-2 px-2 py-1 rounded bg-muted/30",children:[h.jsx("div",{className:"w-1.5 h-1.5 rounded-full shrink-0",style:{background:"hsl(var(--success))"}}),h.jsx("span",{className:"text-[10px] font-mono text-foreground truncate flex-1",children:W.step_id}),W.attempts>1&&h.jsxs("span",{className:"text-[10px] text-amber-400 shrink-0",children:[W.attempts,"x"]}),W.duration_ms!=null&&h.jsx("span",{className:"text-[10px] text-muted-foreground shrink-0",children:W.duration_ms<1e3?`${W.duration_ms}ms`:`${(W.duration_ms/1e3).toFixed(1)}s`})]},W.step_id))})]}),h.jsxs("div",{className:"space-y-0.5",children:[h.jsxs("p",{className:"text-[10px] text-muted-foreground",children:["Created ",ll(t.createdAt)]}),h.jsxs("p",{className:"text-[10px] text-muted-foreground",children:["Updated ",ll(t.updatedAt)]})]}),h.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[h.jsxs("div",{className:"relative",children:[h.jsxs($t,{variant:"outline",size:"sm",className:rt("h-7 text-xs gap-1",T&&"bg-accent/10 border-accent"),onClick:()=>_(!T),children:[h.jsx(pM,{className:"h-3 w-3"})," Connect"]}),T&&h.jsx(VY,{item:t,items:e,onCreateConnection:o,onDismiss:()=>_(!1)})]}),h.jsxs($t,{variant:"outline",size:"sm",className:"h-7 text-xs gap-1",onClick:P,children:[h.jsx(Sb,{className:"h-3 w-3"})," Rename"]}),t.type!=="question"&&h.jsxs($t,{variant:"outline",size:"sm",className:"h-7 text-xs gap-1",onClick:()=>u(t.id),title:"Challenge this item's assumptions",children:[h.jsx(Pl,{className:"h-3 w-3"})," Pressure Test",q>0&&h.jsx("span",{className:"ml-0.5 text-[10px] px-1 py-0 rounded-full bg-amber-500/20 text-amber-400",children:q})]}),t.status!=="killed"&&h.jsxs($t,{variant:"outline",size:"sm",className:"h-7 text-xs gap-1 text-destructive border-destructive/30 hover:bg-destructive/10",onClick:async()=>{if(t.lifecycle)try{const W=await Rt(`/api/vision/items/${t.id}/lifecycle/kill`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({reason:"Killed via UI"})});if(!W.ok){const K=await W.json();console.error("[vision] Lifecycle kill failed:",K.error)}}catch(W){console.error("[vision] Lifecycle kill failed:",W.message)}else i(t.id,{status:"killed"})},children:[h.jsx(Vm,{className:"h-3 w-3"})," Kill"]}),s&&h.jsxs($t,{variant:"outline",size:"sm",className:"h-7 text-xs gap-1 text-destructive border-destructive/30 hover:bg-destructive/10",onClick:()=>{window.confirm(`Delete "${t.title}" permanently? This cannot be undone.`)&&s(t.id)},title:"Permanently delete this item",children:[h.jsx(Vm,{className:"h-3 w-3"})," Delete"]})]})]})})]})}const GT=[{id:"overview",label:"Overview"},{id:"pipeline",label:"Pipeline"},{id:"sessions",label:"Sessions"},{id:"errors",label:"Errors"},{id:"files",label:"Files"}];GT.map(t=>t.id);const KY={overview:Ei,pipeline:vb,sessions:Cb,errors:Ac,files:Tf};function ZY({activeTab:t="overview",onTabChange:e,errorCount:r=0}){return h.jsx("div",{className:"flex items-center gap-0 shrink-0",style:{height:"28px",borderBottom:"1px solid hsl(var(--border))",background:"hsl(var(--muted) / 0.3)"},role:"tablist","aria-label":"Detail sections",children:GT.map(({id:n,label:i})=>{const s=KY[n],o=n===t,a=n==="errors"?r:0;return h.jsxs("button",{role:"tab","aria-selected":o,className:["flex items-center gap-1 px-2 h-full text-[10px] uppercase tracking-wider font-medium transition-colors","border-b-2 -mb-px",o?"border-accent text-accent":"border-transparent text-muted-foreground hover:text-foreground hover:border-border"].join(" "),onClick:()=>e==null?void 0:e(n),children:[h.jsx(s,{style:{width:10,height:10}}),i,a>0&&h.jsx("span",{className:"text-[8px] min-w-[14px] h-3.5 flex items-center justify-center rounded-full px-0.5 tabular-nums",style:{background:"hsl(var(--destructive) / 0.15)",color:"hsl(var(--destructive))"},children:a})]},n)})})}const L0=[{id:"design",label:"Design"},{id:"blueprint",label:"Blueprint"},{id:"execute",label:"Execute"},{id:"review",label:"Review"},{id:"coverage",label:"Coverage"},{id:"ship",label:"Ship"}];function Ud(t,e,r,n){if(r&&r.featureCode===n&&r.currentStep===t)return"active";if(e&&Array.isArray(e)){const i=e.find(s=>s.phase===t||s.step===t);if(i)return i.status==="failed"?"failed":"complete"}return"pending"}function QY({item:t,activeBuild:e}){const[r,n]=C.useState(null),i=(t==null?void 0:t.phaseHistory)||[],s=(t==null?void 0:t.featureCode)||(t==null?void 0:t.text)||"";return h.jsxs("div",{className:"p-3",children:[h.jsx("div",{className:"flex items-center gap-0 mb-3",children:L0.map((o,a)=>{const l=Ud(o.id,i,e,s),c=Yp[l],u=r===o.id;return h.jsxs(Yt.Fragment,{children:[a>0&&h.jsx("div",{className:"flex-1 h-px",style:{background:l==="pending"?"hsl(var(--muted-foreground) / 0.2)":c,minWidth:"8px"}}),h.jsxs("button",{onClick:()=>n(u?null:o.id),className:"relative flex flex-col items-center group",title:o.label,children:[h.jsx("div",{className:["w-3 h-3 rounded-full border-2 transition-all",l==="active"?"animate-pulse":"",u?"ring-2 ring-accent/30":""].join(" "),style:{borderColor:c,background:l==="complete"||l==="failed"?c:"transparent"}}),h.jsx("span",{className:"text-[8px] text-muted-foreground mt-1 opacity-0 group-hover:opacity-100 transition-opacity whitespace-nowrap",children:o.label})]})]},o.id)})}),h.jsx("div",{className:"flex justify-between px-0.5",children:L0.map(o=>{const a=Ud(o.id,i,e,s);return h.jsx("span",{className:"text-[8px] font-medium uppercase tracking-wider",style:{color:a==="pending"?"hsl(var(--muted-foreground) / 0.4)":Yp[a]},children:o.label},o.id)})}),r&&h.jsx("div",{className:"mt-3 p-2 rounded border border-border/50 bg-muted/20",children:h.jsx(JY,{stepId:r,phaseHistory:i,activeBuild:e,featureCode:s})})]})}function JY({stepId:t,phaseHistory:e,activeBuild:r,featureCode:n}){const i=Ud(t,e,r,n),s=e==null?void 0:e.find(a=>a.phase===t||a.step===t),o={complete:"text-success",active:"text-accent",failed:"text-destructive",pending:"text-muted-foreground"};return h.jsxs("div",{className:"space-y-1.5",children:[h.jsxs("div",{className:"flex items-center justify-between",children:[h.jsx("span",{className:"text-xs font-semibold text-foreground capitalize",children:t}),h.jsx("span",{className:`text-[10px] font-medium ${o[i]}`,children:i})]}),(s==null?void 0:s.summary)&&h.jsx("p",{className:"text-[10px] text-muted-foreground",children:s.summary}),(s==null?void 0:s.durationMs)!=null&&h.jsxs("p",{className:"text-[10px] text-muted-foreground",children:["Duration: ",s.durationMs<1e3?`${s.durationMs}ms`:`${(s.durationMs/1e3).toFixed(1)}s`]}),(s==null?void 0:s.agent)&&h.jsxs("p",{className:"text-[10px] text-muted-foreground",children:["Agent: ",s.agent]}),i==="active"&&r&&h.jsx("p",{className:"text-[10px] text-accent",children:"Running..."}),i==="pending"&&h.jsx("p",{className:"text-[10px] text-muted-foreground italic",children:"Not started"})]})}function tX(t){if(!t)return"";const e=Date.now()-new Date(t).getTime();return e<6e4?"just now":e<36e5?`${Math.floor(e/6e4)}m ago`:e<864e5?`${Math.floor(e/36e5)}h ago`:`${Math.floor(e/864e5)}d ago`}function eX(t){return t?t<1e3?`${t}ms`:t<6e4?`${(t/1e3).toFixed(0)}s`:`${(t/6e4).toFixed(1)}m`:"—"}function rX({featureCode:t,sessions:e=[],items:r=[]}){const[n,i]=C.useState(null),s=C.useMemo(()=>t?new Set(r.filter(a=>{var l;return((l=a.lifecycle)==null?void 0:l.featureCode)===t||a.featureCode===t||a.feature_code===t}).map(a=>a.id)):new Set,[t,r]),o=C.useMemo(()=>s.size===0?e.slice(0,20):e.filter(a=>!!(a.featureCode===t||a.itemsWorked&&a.itemsWorked.some(l=>s.has(l))||a.summary&&a.summary.includes(t))),[e,t,s]);return o.length===0?h.jsx("div",{className:"p-3 text-[11px] text-muted-foreground italic",children:"No sessions for this feature."}):h.jsxs("div",{className:"p-2 space-y-0.5",children:[h.jsxs("p",{className:"text-[10px] font-medium uppercase tracking-wider text-muted-foreground px-1 mb-1",children:["Sessions (",o.length,")"]}),o.map(a=>{const l=n===a.id;return h.jsxs("div",{children:[h.jsxs("button",{onClick:()=>i(l?null:a.id),className:"flex items-center gap-2 w-full px-2 py-1.5 text-left rounded hover:bg-muted/30 transition-colors",children:[h.jsx("span",{className:"text-[10px] font-mono text-accent shrink-0 w-12 truncate",children:a.source||"agent"}),h.jsx("span",{className:"text-[10px] text-muted-foreground shrink-0 w-16 truncate",children:a.classification||a.workType||"—"}),h.jsxs("span",{className:"text-[9px] text-muted-foreground tabular-nums flex gap-1.5 shrink-0",children:[h.jsxs("span",{title:"reads",children:[a.reads||0,"r"]}),h.jsxs("span",{title:"writes",children:[a.writes||0,"w"]}),h.jsxs("span",{title:"errors",style:a.errors>0?{color:"hsl(var(--destructive))"}:{},children:[a.errors||0,"e"]})]}),h.jsx("span",{className:"text-[9px] text-muted-foreground tabular-nums shrink-0",children:eX(a.durationMs)}),h.jsx("span",{className:"text-[9px] text-muted-foreground ml-auto shrink-0",children:tX(a.startedAt||a.createdAt)})]}),l&&a.summary&&h.jsx("div",{className:"px-3 py-1.5 text-[10px] text-muted-foreground bg-muted/10 rounded mx-1 mb-1",children:a.summary})]},a.id)})]})}function nX(t){if(!t)return"";const e=Date.now()-new Date(t).getTime();return e<6e4?"just now":e<36e5?`${Math.floor(e/6e4)}m ago`:e<864e5?`${Math.floor(e/36e5)}h ago`:`${Math.floor(e/864e5)}d ago`}const wu=10;function iX({featureCode:t,errors:e=[],items:r=[]}){const[n,i]=C.useState(null),[s,o]=C.useState(!1),a=C.useMemo(()=>t?new Set(r.filter(u=>{var d;return((d=u.lifecycle)==null?void 0:d.featureCode)===t||u.featureCode===t||u.feature_code===t}).map(u=>u.id)):new Set,[t,r]),l=C.useMemo(()=>!t&&a.size===0?[]:e.filter(u=>!!(t&&u.featureCode===t||u.itemId&&a.has(u.itemId)||t&&u.message&&u.message.includes(t))),[e,t,a]);if(l.length===0)return h.jsxs("div",{className:"p-3 flex flex-col items-center gap-2 text-muted-foreground",children:[h.jsx(HA,{style:{width:20,height:20,color:"hsl(var(--success, 160 60% 45%))"}}),h.jsx("span",{className:"text-[11px] italic",children:"No errors for this feature."})]});const c=s?l:l.slice(0,wu);return h.jsxs("div",{className:"p-2 space-y-0.5",children:[h.jsxs("p",{className:"text-[10px] font-medium uppercase tracking-wider text-muted-foreground px-1 mb-1",children:["Errors (",l.length,")"]}),c.map((u,d)=>{const p=n===d;return h.jsxs("button",{onClick:()=>i(p?null:d),className:"flex flex-col w-full px-2 py-1.5 text-left rounded hover:bg-destructive/5 transition-colors",children:[h.jsxs("div",{className:"flex items-center gap-2 w-full",children:[h.jsx("span",{className:"text-[10px] text-destructive shrink-0",children:"✕"}),h.jsx("span",{className:"text-[10px] font-mono text-muted-foreground shrink-0 w-16 truncate",children:u.tool||u.toolName||"unknown"}),h.jsx("span",{className:`text-[10px] text-foreground flex-1 ${p?"":"line-clamp-2"} truncate`,children:u.message||u.error||"Unknown error"}),h.jsx("span",{className:"text-[9px] text-muted-foreground shrink-0 ml-auto",children:nX(u.timestamp||u.createdAt)})]}),p&&h.jsx("div",{className:"mt-1.5 px-5 py-1.5 text-[10px] text-foreground font-mono bg-muted/10 rounded whitespace-pre-wrap break-all",children:u.message||u.error||u.stack||"No additional details"})]},d)}),!s&&l.length>wu&&h.jsxs("button",{onClick:()=>o(!0),className:"w-full text-center text-[10px] text-accent hover:underline py-1",children:["Show ",l.length-wu," more"]})]})}function sX(t){return t?t<1024?`${t}B`:t<1048576?`${(t/1024).toFixed(1)}KB`:`${(t/1048576).toFixed(1)}MB`:"—"}function oX(t){if(!t)return"";const e=Date.now()-new Date(t).getTime();return e<6e4?"just now":e<36e5?`${Math.floor(e/6e4)}m ago`:e<864e5?`${Math.floor(e/36e5)}h ago`:`${Math.floor(e/864e5)}d ago`}function aX({featureCode:t,onOpenFile:e}){const[r,n]=C.useState([]),[i,s]=C.useState(!0);C.useEffect(()=>{const l=new AbortController;return s(!0),Rt("/api/files",{signal:l.signal}).then(c=>c.json()).then(c=>{l.signal.aborted||(n(Array.isArray(c)?c:c.files||[]),s(!1))}).catch(c=>{l.signal.aborted||(n([]),s(!1))}),()=>l.abort()},[t]);const o=`docs/features/${t}/`,a=C.useMemo(()=>r.filter(l=>(typeof l=="string"?l:l.path||l.name||"").startsWith(o)),[r,o]);return i?h.jsx("div",{className:"p-3 text-[11px] text-muted-foreground italic",children:"Loading files..."}):a.length===0?h.jsxs("div",{className:"p-3 flex flex-col items-center gap-2 text-muted-foreground",children:[h.jsx(Tf,{style:{width:20,height:20,opacity:.5}}),h.jsx("span",{className:"text-[11px] italic",children:"No files in feature folder."})]}):h.jsxs("div",{className:"p-2 space-y-0.5",children:[h.jsxs("p",{className:"text-[10px] font-medium uppercase tracking-wider text-muted-foreground px-1 mb-1",children:["Files (",a.length,")"]}),a.map((l,c)=>{const u=typeof l=="string"?l:l.path||l.name||"",d=u.split("/").pop(),p=typeof l=="object"?l.size:null,f=typeof l=="object"?l.modified||l.mtime:null;return h.jsxs("button",{onClick:()=>e==null?void 0:e(u),className:"flex items-center gap-2 w-full px-2 py-1.5 text-left rounded hover:bg-accent/10 transition-colors",children:[h.jsx(Ei,{className:"h-3 w-3 shrink-0 text-accent"}),h.jsx("span",{className:"text-xs text-foreground truncate flex-1",children:d}),p!=null&&h.jsx("span",{className:"text-[9px] text-muted-foreground tabular-nums shrink-0",children:sX(p)}),f&&h.jsx("span",{className:"text-[9px] text-muted-foreground shrink-0",children:oX(f)})]},c)})]})}function lX({itemId:t,onSelect:e,onClose:r,onOpenFile:n,onViewInGraph:i,onViewInTree:s}){var w;const{items:o,connections:a,gates:l,updateItem:c,deleteItem:u,createConnection:d,deleteConnection:p,resolveGate:f,activeBuild:m,sessions:x,agentErrors:g}=gr(Li(E=>({items:E.items,connections:E.connections,gates:E.gates,updateItem:E.updateItem,deleteItem:E.deleteItem,createConnection:E.createConnection,deleteConnection:E.deleteConnection,resolveGate:E.resolveGate,activeBuild:E.activeBuild,sessions:E.sessions,agentErrors:E.agentErrors}))),y=o.find(E=>E.id===t)||null,[b,k]=C.useState("overview"),T=((w=y==null?void 0:y.lifecycle)==null?void 0:w.featureCode)||(y==null?void 0:y.featureCode)||(y==null?void 0:y.feature_code)||"",_=C.useMemo(()=>T?g.filter(E=>E.featureCode===T||T&&E.message&&E.message.includes(T)):[],[g,T]);return y?h.jsxs("div",{className:"h-full flex flex-col",children:[h.jsx(ZY,{activeTab:b,onTabChange:k,errorCount:_.length}),h.jsxs("div",{className:"flex-1 min-h-0 overflow-auto",children:[b==="overview"&&h.jsxs(h.Fragment,{children:[h.jsx(XY,{item:y,items:o,connections:a,gates:l,onUpdate:(E,B)=>c(E,B),onDelete:E=>{u(E),r()},onCreateConnection:d,onDeleteConnection:p,onSelect:e,onClose:r,onPressureTest:()=>{},onResolveGate:f}),h.jsxs("div",{className:"flex items-center gap-3 px-4 py-2 mt-1",style:{borderTop:"1px solid hsl(var(--border))"},children:[i&&h.jsxs("button",{onClick:()=>i(t),className:"flex items-center gap-1 text-[11px] text-muted-foreground hover:text-foreground transition-colors",children:[h.jsx("span",{style:{fontSize:10},children:"↑"})," View in Graph"]}),s&&h.jsxs("button",{onClick:()=>s(t),className:"flex items-center gap-1 text-[11px] text-muted-foreground hover:text-foreground transition-colors",children:[h.jsx("span",{style:{fontSize:10},children:"↓"})," View in Tree"]})]})]}),b==="pipeline"&&h.jsx(QY,{item:y,activeBuild:m}),b==="sessions"&&h.jsx(rX,{featureCode:T,sessions:x,items:o}),b==="errors"&&h.jsx(iX,{featureCode:T,errors:g,items:o}),b==="files"&&h.jsx(aX,{featureCode:T,onOpenFile:n})]})]}):h.jsx("div",{className:"p-3 text-[11px] text-muted-foreground italic",children:"Item not found."})}function cX(t){if(!t)return null;const{retries:e}=t;return e==null?null:Array.isArray(e)?e.length===0?null:{count:e.length,isArray:!0,items:e}:typeof e=="number"&&e>0?{count:e,isArray:!1,items:[]}:null}function hX(t){var e;return(e=t==null?void 0:t.violations)!=null&&e.length?t.violations:[]}function uX(t,e){if(!t)return null;for(const r of t.values())if(r.stepId===e)return r;return null}function dX(t,e,r){var c;if(!t||t.status!=="running")return null;const n=t.startedAt?Date.parse(t.startedAt):r,i=r-n,s=t.wallClockTimeout!=null?t.wallClockTimeout*60*1e3:null,o=(c=e==null?void 0:e.per_loop_type)==null?void 0:c[t.loopType],a=(o==null?void 0:o.maxTotal)!=null?o.usedIterations:null,l=(o==null?void 0:o.maxTotal)??null;return{count:t.count??0,maxIterations:t.maxIterations??null,loopType:t.loopType,elapsedMs:i,timeoutMs:s,usedIterations:a,maxTotal:l}}function fX(t){if(!(t!=null&&t.per_loop_type))return"";const e={review:"r",coverage:"c"},r=[];for(const[n,i]of Object.entries(e)){const s=t.per_loop_type[n];!s||s.maxTotal==null||r.push(`${i} ${s.usedIterations}/${s.maxTotal}`)}return r.join(" · ")}function B0(t){return!t||t<=0?"$0.00":`$${t.toFixed(4)}`}const A0=[{id:"T0",name:"schema",label:"T0"},{id:"T1",name:"lint",label:"T1"},{id:"T2",name:"tests",label:"T2"},{id:"T3",name:"review",label:"T3"},{id:"T4",name:"codex",label:"T4"}];function pX({tierMap:t,tierSummary:e}){const[r,n]=C.useState(null),i=s=>n(o=>o===s?null:s);return h.jsxs("div",{children:[h.jsx("p",{className:"text-[10px] font-medium uppercase tracking-wider text-muted-foreground mb-1.5",children:"Tier Pipeline"}),h.jsxs("div",{className:"flex items-center gap-1.5",children:[A0.map((s,o)=>{var d;const a=t[s.id],l=(d=e==null?void 0:e.tiersSkipped)==null?void 0:d.includes(s.id);let c,u;return l?(c="bg-muted-foreground/40",u=`${s.id} (${s.name}): skipped`):a===!0?(c="bg-success",u=`${s.id} (${s.name}): passed`):a===!1?(c="bg-destructive",u=`${s.id} (${s.name}): failed`):(c="bg-muted-foreground/20",u=`${s.id} (${s.name}): not run`),h.jsxs(Yt.Fragment,{children:[o>0&&h.jsx("div",{className:"h-px w-3 bg-muted-foreground/20 shrink-0"}),h.jsxs("button",{className:"flex flex-col items-center gap-0.5 group",onClick:()=>i(s.id),title:u,children:[h.jsx("div",{className:`w-2.5 h-2.5 rounded-full transition-all group-hover:scale-125 ${c} ${r===s.id?"ring-1 ring-foreground/40":""}`}),h.jsx("span",{className:"text-[8px] text-muted-foreground leading-none",children:s.label})]})]},s.id)}),(e==null?void 0:e.costSaved)>0&&h.jsxs("span",{className:"ml-2 text-[9px] text-success/80",children:["saved ~$",e.costSaved.toFixed(2)]})]}),r&&h.jsx("div",{className:"mt-1.5 px-2 py-1 rounded bg-muted/20 text-[9px] text-muted-foreground",children:(()=>{var l;const s=t[r],o=(l=e==null?void 0:e.tiersSkipped)==null?void 0:l.includes(r),a=A0.find(c=>c.id===r);return o?`${r} (${a==null?void 0:a.name}): skipped — short-circuited by earlier failure`:s===!0?`${r} (${a==null?void 0:a.name}): passed`:s===!1?`${r} (${a==null?void 0:a.name}): failed`:`${r} (${a==null?void 0:a.name}): not run this build`})()})]})}function Su(t){return t>=80?"text-success":t>=60?"text-amber-400":"text-destructive"}function mX(t){return t==="improving"?"↑":t==="declining"?"↓":"→"}const M0={test_coverage:"Tests",review_findings:"Review",contract_compliance:"Contracts",runtime_errors:"Runtime",doc_freshness:"Docs",plan_completion:"Plan"};function I0(t){if(t==null)return"—";const e=Math.floor(t/1e3);if(e<60)return`${e}s`;const r=Math.floor(e/60),n=e%60;return`${r}:${String(n).padStart(2,"0")}`}function gX({loopState:t,budget:e}){const[r,n]=C.useState(()=>Date.now());C.useEffect(()=>{if(!t||t.status!=="running")return;const s=setInterval(()=>n(Date.now()),1e3);return()=>clearInterval(s)},[t]);const i=dX(t,e,r);return i?h.jsxs("div",{children:[h.jsx("p",{className:"text-[10px] font-medium uppercase tracking-wider text-muted-foreground mb-1",children:"Live Counters"}),h.jsxs("div",{className:"space-y-0.5 text-[10px]",children:[h.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap",children:[h.jsxs("span",{className:"text-foreground font-mono font-medium",children:["attempt ",i.count,"/",i.maxIterations??"?"]}),h.jsx("span",{className:"text-muted-foreground",children:"·"}),h.jsxs("span",{className:"text-foreground font-mono",children:[I0(i.elapsedMs),i.timeoutMs!=null&&h.jsxs("span",{className:"text-muted-foreground",children:[" / ",I0(i.timeoutMs)]})]}),i.usedIterations!=null&&i.maxTotal!=null&&h.jsxs(h.Fragment,{children:[h.jsx("span",{className:"text-muted-foreground",children:"·"}),h.jsxs("span",{className:"text-foreground font-mono",children:["cumulative ",i.usedIterations,"/",i.maxTotal]})]})]}),h.jsxs("div",{className:"text-muted-foreground/70 text-[9px]",children:["loop: ",i.loopType]})]})]}):null}function xX({stepId:t,tierEvents:e=[],healthEvents:r=[],capabilityEvents:n=[]}){const{activeBuild:i,iterationStates:s}=gr(Li(P=>({activeBuild:P.activeBuild,iterationStates:P.iterationStates}))),[o,a]=C.useState(!1),[l,c]=C.useState(null),u=(i==null?void 0:i.featureCode)??null,d=C.useRef(null);C.useEffect(()=>{if(!u){c(null);return}u!==d.current&&(d.current=u,Rt(`/api/lifecycle/budget?featureCode=${encodeURIComponent(u)}`).then(P=>P.json()).then(P=>c(P)).catch(()=>{}))},[u]);const{step:p,allSteps:f}=C.useMemo(()=>i!=null&&i.steps?{step:i.steps.find(N=>N.id===t||N.step_id===t)||null,allSteps:i.steps}:{step:null,allSteps:[]},[i,t]),m=C.useMemo(()=>{if(!r||r.length===0)return null;for(let P=r.length-1;P>=0;P--){const N=r[P];if(N.subtype==="health_score"&&typeof N.score=="number")return N}return null},[r]),{tierMap:x,tierSummary:g}=C.useMemo(()=>{if(!e||e.length===0)return{tierMap:{},tierSummary:null};const P={};let N=null;for(const M of e)M.subtype==="gate_tier_result"?P[M.tierId]=M.passed:M.subtype==="gate_tier_summary"&&(N=M);return{tierMap:P,tierSummary:N}},[e]),y=Object.keys(x).length>0||g!==null,b=C.useMemo(()=>{const P=f.filter(N=>N.cost_usd!=null);return P.length===0?[]:[...P].sort((N,M)=>o?(N.cost_usd??0)-(M.cost_usd??0):(M.cost_usd??0)-(N.cost_usd??0))},[f,o]),k=b.length>0?b[0].id:null,T=C.useMemo(()=>cX(p),[p]),_=C.useMemo(()=>hX(p),[p]),w=C.useMemo(()=>uX(s,t),[s,t]),E=C.useMemo(()=>{if(!n||n.length===0)return null;const P=n.filter($=>$.stepId===t);if(P.length===0)return null;const N=P.filter($=>$.severity==="violation").length,M=P.filter($=>$.severity==="warning").length;return{total:P.length,hardViolations:N,warnings:M}},[n,t]);if(!p)return h.jsxs("div",{className:"p-3 text-[11px] text-muted-foreground italic",children:["Step “",t,"” not found in active build."]});const B={done:"text-success",running:"text-accent",failed:"text-destructive",pending:"text-muted-foreground",skipped:"text-muted-foreground"};return h.jsxs("div",{className:"p-3 space-y-3",children:[h.jsxs("div",{children:[h.jsx("p",{className:"text-[10px] font-medium uppercase tracking-wider text-muted-foreground mb-1",children:"Build Step"}),h.jsx("p",{className:"text-sm font-semibold text-foreground font-mono",children:p.id||p.step_id})]}),h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("span",{className:"text-[10px] text-muted-foreground",children:"Status:"}),h.jsx("span",{className:`text-xs font-medium ${B[p.status]||"text-foreground"}`,children:p.status||"unknown"})]}),T&&h.jsxs("div",{children:[h.jsx("p",{className:"text-[10px] font-medium uppercase tracking-wider text-amber-400/80 mb-1",children:"Retries"}),h.jsxs("p",{className:"text-xs text-amber-400",children:["Retried ",T.count," ",T.count===1?"time":"times"]}),T.isArray&&T.items.length>0&&h.jsx("div",{className:"mt-1 space-y-0.5",children:T.items.map((P,N)=>h.jsxs("div",{className:"text-[10px] text-muted-foreground pl-2",children:["#",N+1,P.reason?`: ${P.reason}`:""]},N))})]}),p.durationMs!=null&&h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("span",{className:"text-[10px] text-muted-foreground",children:"Duration:"}),h.jsx("span",{className:"text-xs text-foreground",children:p.durationMs<1e3?`${p.durationMs}ms`:p.durationMs<6e4?`${(p.durationMs/1e3).toFixed(1)}s`:`${(p.durationMs/6e4).toFixed(1)}m`})]}),p.summary&&h.jsxs("div",{children:[h.jsx("span",{className:"text-[10px] text-muted-foreground",children:"Summary:"}),h.jsx("p",{className:"text-xs text-foreground mt-0.5",children:p.summary})]}),p.artifact&&h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("span",{className:"text-[10px] text-muted-foreground",children:"Artifact:"}),h.jsx("span",{className:"text-xs text-foreground font-mono truncate",children:p.artifact})]}),p.agent&&h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("span",{className:"text-[10px] text-muted-foreground",children:"Agent:"}),h.jsx("span",{className:"text-xs text-foreground font-mono",children:p.agent})]}),p.filesChanged&&p.filesChanged.length>0&&h.jsxs("div",{children:[h.jsxs("p",{className:"text-[10px] font-medium uppercase tracking-wider text-muted-foreground mb-1",children:["Files Changed (",p.filesChanged.length,")"]}),h.jsx("div",{className:"space-y-0.5 max-h-32 overflow-y-auto",children:p.filesChanged.map((P,N)=>h.jsx("p",{className:"text-[10px] text-foreground font-mono truncate",children:P},N))})]}),(p.input_tokens>0||p.output_tokens>0||p.cost_usd>0)&&h.jsxs("div",{children:[h.jsx("p",{className:"text-[10px] font-medium uppercase tracking-wider text-muted-foreground mb-1",children:"Tokens & Cost"}),h.jsxs("div",{className:"grid grid-cols-3 gap-1 text-[10px]",children:[h.jsx("span",{className:"text-muted-foreground",children:"Input"}),h.jsx("span",{className:"text-muted-foreground",children:"Output"}),h.jsx("span",{className:"text-muted-foreground",children:"Cost"}),h.jsx("span",{className:"text-foreground font-mono",children:(p.input_tokens??0).toLocaleString()}),h.jsx("span",{className:"text-foreground font-mono",children:(p.output_tokens??0).toLocaleString()}),h.jsx("span",{className:"text-foreground font-mono",children:B0(p.cost_usd)})]})]}),y&&h.jsx("div",{children:h.jsx(pX,{tierMap:x,tierSummary:g})}),_.length>0&&h.jsxs("div",{children:[h.jsx("p",{className:"text-[10px] font-medium uppercase tracking-wider text-destructive mb-1",children:"Postcondition Violations"}),h.jsx("div",{className:"space-y-0.5",children:_.map((P,N)=>h.jsxs("div",{className:"flex items-start gap-2 px-2 py-1 rounded bg-destructive/10",children:[h.jsx("div",{className:"w-1.5 h-1.5 rounded-full shrink-0 mt-1",style:{background:"hsl(var(--destructive))"}}),h.jsx("span",{className:"text-[10px] text-destructive leading-relaxed",children:typeof P=="string"?P:P.message||JSON.stringify(P)})]},N))})]}),E&&h.jsxs("div",{children:[h.jsx("p",{className:"text-[10px] font-medium uppercase tracking-wider text-amber-400/80 mb-1",children:"Capability Findings"}),h.jsxs("p",{className:"text-xs text-amber-400",children:[E.total," ",E.total===1?"finding":"findings"," ","(",E.hardViolations," ",E.hardViolations===1?"violation":"violations",","," ",E.warnings," ",E.warnings===1?"warning":"warnings",")"]})]}),(w==null?void 0:w.status)==="running"&&h.jsx(gX,{loopState:w,budget:l}),m!=null&&h.jsxs("div",{children:[h.jsx("p",{className:"text-[10px] font-medium uppercase tracking-wider text-muted-foreground mb-1.5",children:"Health Score"}),h.jsxs("div",{className:"flex items-baseline gap-2 mb-2",children:[h.jsx("span",{className:`text-2xl font-bold font-mono tabular-nums ${Su(m.score)}`,children:m.score}),h.jsx("span",{className:"text-[10px] text-muted-foreground",children:"/100"}),m.trend&&h.jsxs("span",{className:`text-sm font-mono ${Su(m.score)}`,children:[mX(m.trend.direction),m.trend.delta!=null&&h.jsxs("span",{className:"text-[10px] ml-0.5",children:[m.trend.delta>0?"+":"",Math.round(m.trend.delta)]})]})]}),m.breakdown&&Object.keys(m.breakdown).length>0&&h.jsxs("div",{className:"space-y-1",children:[Object.entries(m.breakdown).map(([P,N])=>h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("span",{className:"text-[9px] text-muted-foreground w-16 shrink-0",children:M0[P]??P}),h.jsx("div",{className:"flex-1 h-1.5 rounded-full bg-muted-foreground/20 overflow-hidden",children:h.jsx("div",{className:`h-full rounded-full transition-all ${N>=80?"bg-success":N>=60?"bg-amber-400":"bg-destructive"}`,style:{width:`${N}%`}})}),h.jsx("span",{className:`text-[9px] font-mono w-6 text-right ${Su(N)}`,children:N})]},P)),m.missing&&m.missing.length>0&&h.jsxs("p",{className:"text-[9px] text-muted-foreground/60 mt-0.5",children:["No data: ",m.missing.map(P=>M0[P]??P).join(", ")]})]})]}),b.length>1&&h.jsxs("div",{children:[h.jsxs("div",{className:"flex items-center justify-between mb-1",children:[h.jsx("p",{className:"text-[10px] font-medium uppercase tracking-wider text-muted-foreground",children:"Build Cost Breakdown"}),h.jsx("button",{className:"text-[9px] text-muted-foreground hover:text-foreground transition-colors",onClick:()=>a(P=>!P),children:o?"cost asc":"cost desc"})]}),h.jsx("div",{className:"overflow-x-auto",children:h.jsxs("table",{className:"w-full text-[10px] border-collapse",children:[h.jsx("thead",{children:h.jsxs("tr",{className:"text-muted-foreground",children:[h.jsx("th",{className:"text-left pr-2 pb-0.5 font-medium",children:"Step"}),h.jsx("th",{className:"text-right pr-2 pb-0.5 font-medium",children:"In"}),h.jsx("th",{className:"text-right pr-2 pb-0.5 font-medium",children:"Out"}),h.jsx("th",{className:"text-right pb-0.5 font-medium",children:"Cost"}),h.jsx("th",{className:"text-right pb-0.5 pl-2 font-medium",children:"Dur"})]})}),h.jsx("tbody",{children:b.map(P=>{const N=P.id===k,M=P.id===t,$=P.durationMs!=null?P.durationMs<1e3?`${P.durationMs}ms`:P.durationMs<6e4?`${(P.durationMs/1e3).toFixed(1)}s`:`${(P.durationMs/6e4).toFixed(1)}m`:"—";return h.jsxs("tr",{className:`${N?"text-amber-400":"text-foreground"} ${M?"font-semibold":""}`,children:[h.jsx("td",{className:"pr-2 py-0.5 font-mono truncate max-w-[80px]",children:P.id}),h.jsxs("td",{className:"text-right pr-2 py-0.5 font-mono",children:[((P.input_tokens??0)/1e3).toFixed(1),"k"]}),h.jsxs("td",{className:"text-right pr-2 py-0.5 font-mono",children:[((P.output_tokens??0)/1e3).toFixed(1),"k"]}),h.jsx("td",{className:"text-right py-0.5 font-mono",children:B0(P.cost_usd)}),h.jsx("td",{className:"text-right pl-2 py-0.5 text-muted-foreground",children:$})]},P.id)})})]})})]})]})}function VT(t){const e=[],r=/```decision\n([\s\S]*?)```/g;let n=0,i;for(;(i=r.exec(t))!==null;){i.index>n&&e.push({type:"text",content:t.slice(n,i.index)});const s=i[1].trim();try{e.push({type:"decision",content:JSON.parse(s)})}catch{e.push({type:"text",content:s})}n=i.index+i[0].length}return n<t.length&&e.push({type:"text",content:t.slice(n)}),e.length===0&&e.push({type:"text",content:t}),{parts:e}}function F0(t,e){var l;const r=(e||[]).filter(c=>!c.superseded);if(r.length===0)return"";let n=`# Design Document
|
|
718
718
|
|
|
719
719
|
`;const i=(t||[]).filter(c=>c.role==="human"&&c.type==="text").slice(0,3);i.length>0&&(n+=`## Problem
|
|
720
720
|
|