@wrongstack/webui 0.291.0 → 0.291.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/dist/assets/{AnalyticsDashboard-DGSAut_P.js → AnalyticsDashboard-BBbdycai.js} +1 -1
  2. package/dist/assets/{AudienceMemoryPanel-DjdzWznT.js → AudienceMemoryPanel-BWcCpuCv.js} +1 -1
  3. package/dist/assets/{ChangesView-BY9-680w.js → ChangesView-Bwb4Qh4n.js} +1 -1
  4. package/dist/assets/{ChronicleDashboard-_i-J0z7w.js → ChronicleDashboard-oOlGTsm5.js} +1 -1
  5. package/dist/assets/{CodeEditor-UhIn6DIp.js → CodeEditor-Bt9fqzjU.js} +1 -1
  6. package/dist/assets/{CronJobsPanel-BKknBQzw.js → CronJobsPanel-i2-zcKIC.js} +1 -1
  7. package/dist/assets/{DebugDashboard-D47dsdl6.js → DebugDashboard-CCe1PP60.js} +1 -1
  8. package/dist/assets/{DesignGalleryView-B2yA--3z.js → DesignGalleryView-BDxyVUoW.js} +1 -1
  9. package/dist/assets/{GoalView-BEX-kC__.js → GoalView-Ck6Oa8nh.js} +1 -1
  10. package/dist/assets/{KanbanView-C9EY0_-X.js → KanbanView-BSoNz6a-.js} +1 -1
  11. package/dist/assets/LazyMarkdown-CGMv69IJ.js +3 -0
  12. package/dist/assets/MailboxDetailView-Dr3B9nM0.js +1 -0
  13. package/dist/assets/MemoryManager-BQZeiYDi.js +1 -0
  14. package/dist/assets/{ModelPicker-DPNTWYxu.js → ModelPicker-DwoHlu_Q.js} +1 -1
  15. package/dist/assets/OfficeMapPanel-CA-BmADR.js +4 -0
  16. package/dist/assets/{ProcessMonitor-C9yCk-bu.js → ProcessMonitor-7mzC-JTl.js} +1 -1
  17. package/dist/assets/{QueuePanel-SPyWkHtD.js → QueuePanel-DNccWIKx.js} +1 -1
  18. package/dist/assets/{RefreshDebugView-k1iKV6Hh.js → RefreshDebugView-2Ockf4po.js} +1 -1
  19. package/dist/assets/{SddHub-CktdOif3.js → SddHub-Cg63TJIL.js} +1 -1
  20. package/dist/assets/{SessionsDashboard-DMaHyATc.js → SessionsDashboard-yrSEaUdc.js} +1 -1
  21. package/dist/assets/{SetupScreen-D7_1mlMi.js → SetupScreen-BFfYTt1L.js} +1 -1
  22. package/dist/assets/{SkillDetailView-DGDLax2X.js → SkillDetailView-Sqe-T3-x.js} +2 -2
  23. package/dist/assets/{SpecsView-ecFmV6N0.js → SpecsView-DFj6_8G5.js} +1 -1
  24. package/dist/assets/{TechStackView-CVdayRXB.js → TechStackView-DPxBWfsU.js} +1 -1
  25. package/dist/assets/{TerminalPanel-Dd3kbKFo.js → TerminalPanel-B-BSGITg.js} +1 -1
  26. package/dist/assets/index-CuByAUEC.css +1 -0
  27. package/dist/assets/{index-DeInm8PK.js → index-D_QeLLAg.js} +16 -16
  28. package/dist/assets/{stores-j4CUJPI1.js → stores-BazbaxhT.js} +1 -1
  29. package/dist/assets/{useWebSocket-6y5oEA6Z.js → useWebSocket-BEkBQAAR.js} +2 -2
  30. package/dist/assets/{ws-client-fBMR5Zg-.js → ws-client-BOKgdABR.js} +1 -1
  31. package/dist/components/MemoryManager/index.d.ts.map +1 -1
  32. package/dist/components/MessageBubble/index.d.ts.map +1 -1
  33. package/dist/components/MessageBubble/utils.d.ts.map +1 -1
  34. package/dist/components/WatchMessageBubble.d.ts +1 -1
  35. package/dist/components/WatchMessageBubble.d.ts.map +1 -1
  36. package/dist/hooks/useWebSocket.d.ts +7 -0
  37. package/dist/hooks/useWebSocket.d.ts.map +1 -1
  38. package/dist/index.html +7 -7
  39. package/dist/index.js +625 -340
  40. package/dist/index.js.map +4 -4
  41. package/dist/lib/ws-client.d.ts +12 -0
  42. package/dist/lib/ws-client.d.ts.map +1 -1
  43. package/dist/types.d.ts +20 -1
  44. package/dist/types.d.ts.map +1 -1
  45. package/package.json +6 -6
  46. package/dist/assets/MailboxDetailView-DqCY91Vm.js +0 -1
  47. package/dist/assets/MemoryManager-QB0lTAxf.js +0 -1
  48. package/dist/assets/OfficeMapPanel-Duzb5VQW.js +0 -4
  49. package/dist/assets/index-B-xfHdYd.css +0 -1
  50. package/dist/assets/utils-dYJO5odh.js +0 -3
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{$t as t,Bn as n,Cn as r,Dr as i,Ii as a,Jn as o,Si as s,Zi as c,bi as l,ci as u,hi as d,ln as f,na as p,ot as m,ri as h,si as g,tt as _,zn as v}from"./vendor-BsMARlcy.js";import"./i18n-VQ8IAWEk.js";import{t as y}from"./useWebSocket-6y5oEA6Z.js";import{t as b}from"./utils-Ca0_D_-X.js";import{r as x}from"./stores-j4CUJPI1.js";import{r as S}from"./view-navigation-Dx54K1uS.js";import{t as C}from"./pagination-D2oCHj95.js";import{t as w}from"./button-FFFZxxoZ.js";var T=e(p(),1),E=_(),D={completed:{icon:(0,E.jsx)(d,{className:`h-3.5 w-3.5`}),label:`Completed`,text:`text-success`,ring:`border-success/35`},in_progress:{icon:(0,E.jsx)(n,{className:`h-3.5 w-3.5 animate-spin`}),label:`Running`,text:`text-primary`,ring:`border-primary/45`},queued:{icon:(0,E.jsx)(h,{className:`h-3.5 w-3.5`}),label:`Queued`,text:`text-warning`,ring:`border-warning/35`},blocked:{icon:(0,E.jsx)(v,{className:`h-3.5 w-3.5`}),label:`Blocked`,text:`text-destructive`,ring:`border-destructive/30`},pending:{icon:(0,E.jsx)(g,{className:`h-3.5 w-3.5`}),label:`Pending`,text:`text-muted-foreground`,ring:`border-border/70`},review:{icon:(0,E.jsx)(t,{className:`h-3.5 w-3.5`}),label:`Review`,text:`text-primary`,ring:`border-primary/35`},failed:{icon:(0,E.jsx)(u,{className:`h-3.5 w-3.5`}),label:`Failed`,text:`text-destructive`,ring:`border-destructive/45`},cancelled:{icon:(0,E.jsx)(a,{className:`h-3.5 w-3.5`}),label:`Cancelled`,text:`text-muted-foreground`,ring:`border-border/70`}},O=[`completed`,`in_progress`,`queued`,`blocked`,`pending`,`failed`],k={critical:{label:`Crit`,cls:`bg-destructive/10 text-destructive`},high:{label:`High`,cls:`bg-destructive/10 text-destructive`},medium:{label:`Med`,cls:`bg-warning/12 text-warning`},low:{label:`Low`,cls:`bg-success/12 text-success`}};function A({columns:e,onTaskClick:t}){let{t:n}=c();return e.length===0?(0,E.jsx)(`div`,{className:`flex h-40 items-center justify-center text-sm text-muted-foreground`,children:n(`activity:board.emptySpec`)}):(0,E.jsxs)(`div`,{className:`rounded-xl border border-border/70 bg-card/75 p-4 shadow-sm`,children:[(0,E.jsx)(`h3`,{className:`mb-3 text-sm font-semibold text-foreground`,children:n(`activity:board.depGraphHeading`)}),(0,E.jsx)(`div`,{className:`mb-4 flex flex-wrap items-center gap-x-4 gap-y-1 text-xs`,children:O.map(e=>(0,E.jsxs)(`span`,{className:b(`inline-flex items-center gap-1.5`,D[e].text),children:[D[e].icon,(0,E.jsx)(`span`,{className:`text-muted-foreground`,children:n(`activity:board.status.${e}`)})]},e))}),(0,E.jsx)(`div`,{className:`flex gap-3 overflow-x-auto pb-2`,children:e.map((n,r)=>(0,E.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,E.jsxs)(`div`,{className:`w-60 shrink-0`,children:[(0,E.jsx)(`div`,{className:`mb-2 border-b border-border/60 pb-1 text-center text-xs font-medium uppercase text-muted-foreground`,children:n.label}),(0,E.jsx)(`div`,{className:`space-y-2`,children:n.tasks.map(e=>(0,E.jsx)(j,{task:e,onClick:t},e.id))})]}),r<e.length-1&&(0,E.jsx)(`div`,{className:`flex h-full items-center pt-8 text-muted-foreground/75`,children:(0,E.jsx)(l,{className:`h-5 w-5`})})]},n.label))})]})}function j({task:e,onClick:t}){let r=D[e.displayStatus],i=k[e.priority],{t:a}=c();return(0,E.jsxs)(`button`,{type:`button`,onClick:()=>t?.(e.id),className:b(`w-full rounded-lg border bg-background/55 p-2.5 text-left shadow-sm transition-colors hover:border-primary/35 hover:bg-accent/35`,r.ring),children:[(0,E.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,E.jsxs)(`span`,{className:b(`inline-flex items-center gap-1.5 text-xs font-medium`,r.text),children:[r.icon,(0,E.jsx)(`span`,{className:`font-mono text-foreground`,children:e.shortId})]}),(0,E.jsx)(`span`,{className:b(`rounded px-1.5 py-0.5 text-[10px] font-medium`,i.cls),children:i.label})]}),(0,E.jsx)(`p`,{className:`mt-1.5 text-xs text-foreground`,children:e.title}),e.deps.length>0&&(0,E.jsxs)(`p`,{className:`mt-1 font-mono text-[10px] text-muted-foreground`,children:[`← `,e.deps.join(`, `)]}),e.agentName&&(0,E.jsxs)(`div`,{className:b(`mt-1.5 inline-flex items-center gap-1 rounded-full px-1.5 py-0.5 text-[10px]`,e.displayStatus===`in_progress`?`bg-primary/10 text-primary`:`bg-muted text-muted-foreground`),title:e.worktreeBranch?a(`activity:board.worktreePrefix`,{branch:e.worktreeBranch}):void 0,children:[e.displayStatus===`in_progress`&&(0,E.jsx)(n,{className:`h-3 w-3 animate-spin`}),(0,E.jsx)(`span`,{children:e.agentName})]})]})}var M=12;function N(e){return e.columns.map(e=>({name:e.label,description:``,priority:`medium`,estimateHours:e.tasks.length,parallelizable:!1,taskTemplates:e.tasks.map(e=>({title:e.title,description:e.description,type:e.type,priority:e.priority,estimateHours:1}))}))}function P({onClose:e}){let{client:t}=y(),{t:n}=c(),a=x(e=>e.specs),u=x(e=>e.detail),d=x(e=>e.expandedSpecId),p=x(e=>e.setExpanded),[h,g]=(0,T.useState)(`graph`),[_,v]=(0,T.useState)(1),D=(0,T.useCallback)(e=>{!u||u.specId!==e.id||(t?.send?.({type:`goal.start`,payload:{title:e.title,phases:N(u),autonomous:!0}}),S(`goal`))},[u,t]);(0,T.useEffect)(()=>{t?.send?.({type:`specs.list`})},[t]);let O=(0,T.useCallback)(e=>{d===e.id?p(null):(p(e.id),t?.send?.({type:`specs.get`,payload:{specId:e.id}}))},[d,p,t]),k=u?.columns.flatMap(e=>e.tasks)??[],j={done:k.filter(e=>e.status===`completed`).length,running:k.filter(e=>e.status===`in_progress`).length,pending:k.filter(e=>e.status===`pending`||e.displayStatus===`queued`).length},P=a.slice((_-1)*M,_*M);return(0,T.useEffect)(()=>{let e=Math.max(1,Math.ceil(a.length/M));_>e&&v(e)},[_,a.length]),(0,E.jsxs)(`div`,{className:`flex h-full min-h-0 min-w-0 flex-col bg-background`,children:[(0,E.jsxs)(`header`,{className:`flex shrink-0 items-center justify-between border-b bg-card px-4 py-2`,children:[(0,E.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,E.jsx)(i,{className:`h-5 w-5 text-warning`}),(0,E.jsxs)(`div`,{children:[(0,E.jsx)(`h1`,{className:`text-lg font-semibold`,children:n(`activity:specs.heading`)}),(0,E.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:n(`activity:specs.subtitle`)})]})]}),(0,E.jsx)(w,{variant:`ghost`,size:`icon`,onClick:e,children:(0,E.jsx)(m,{className:`h-4 w-4`})})]}),(0,E.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto overscroll-contain p-4`,children:a.length===0?(0,E.jsx)(`div`,{className:`flex h-40 items-center justify-center text-sm text-muted-foreground`,children:n(`activity:specs.empty`,{command:`/sdd`})}):(0,E.jsx)(`div`,{className:`space-y-3`,children:P.map(e=>{let t=d===e.id,a=e.total>0?Math.round(e.completed/e.total*100):0;return(0,E.jsxs)(`div`,{className:`rounded-lg border border-border bg-card/60`,children:[(0,E.jsxs)(`button`,{type:`button`,onClick:()=>O(e),className:`flex w-full items-start gap-3 p-4 text-left`,children:[(0,E.jsx)(`span`,{className:`mt-1 text-muted-foreground`,children:t?(0,E.jsx)(s,{className:`h-4 w-4`}):(0,E.jsx)(l,{className:`h-4 w-4`})}),(0,E.jsx)(i,{className:`mt-0.5 h-4 w-4 text-muted-foreground`}),(0,E.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,E.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,E.jsx)(`span`,{className:`font-mono text-xs text-muted-foreground`,children:e.displayId}),(0,E.jsx)(`span`,{className:`rounded bg-muted px-1.5 py-0.5 text-[10px] capitalize text-muted-foreground`,children:e.status})]}),(0,E.jsx)(`h2`,{className:`mt-1 text-base font-semibold`,children:e.title}),(0,E.jsxs)(`div`,{className:`mt-2 flex items-center gap-2`,children:[(0,E.jsx)(`div`,{className:`h-2 flex-1 overflow-hidden rounded-full bg-muted`,children:(0,E.jsx)(`div`,{className:`h-full rounded-full bg-success transition-all`,style:{width:`${a}%`}})}),(0,E.jsxs)(`span`,{className:`shrink-0 font-mono text-xs text-muted-foreground`,children:[e.completed,`/`,e.total]})]})]})]}),t&&(0,E.jsxs)(`div`,{className:`border-t border-border p-4`,children:[(0,E.jsxs)(`div`,{className:`mb-3 flex items-center justify-between`,children:[(0,E.jsxs)(`div`,{className:`text-sm font-medium`,children:[n(`activity:specs.tasks`,{count:u?.total??e.total}),u&&(0,E.jsxs)(`span`,{className:`ml-3 text-xs font-normal text-muted-foreground`,children:[(0,E.jsx)(`span`,{className:`text-success`,children:n(`activity:specs.doneCount`,{count:j.done})}),` `,(0,E.jsx)(`span`,{className:`text-primary`,children:n(`activity:specs.runningCount`,{count:j.running})}),` `,(0,E.jsx)(`span`,{children:n(`activity:specs.pendingCount`,{count:j.pending})})]})]}),(0,E.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,E.jsxs)(`button`,{type:`button`,disabled:!u||u.specId!==e.id,onClick:()=>D(e),title:n(`activity:specs.runTitle`),className:`inline-flex items-center gap-1 rounded-md bg-warning/15 px-2.5 py-1 text-xs font-medium text-warning transition-colors hover:bg-warning/25 disabled:opacity-40`,children:[(0,E.jsx)(f,{className:`h-3.5 w-3.5`}),` `,n(`activity:specs.run`)]}),(0,E.jsxs)(`div`,{className:`flex items-center gap-1 rounded-md border border-border p-0.5`,children:[(0,E.jsxs)(`button`,{type:`button`,onClick:()=>g(`list`),className:b(`inline-flex items-center gap-1 rounded px-2 py-1 text-xs`,h===`list`?`bg-primary/15 text-primary`:`text-muted-foreground`),children:[(0,E.jsx)(o,{className:`h-3.5 w-3.5`}),` `,n(`activity:specs.list`)]}),(0,E.jsxs)(`button`,{type:`button`,onClick:()=>g(`graph`),className:b(`inline-flex items-center gap-1 rounded px-2 py-1 text-xs`,h===`graph`?`bg-primary/15 text-primary`:`text-muted-foreground`),children:[(0,E.jsx)(r,{className:`h-3.5 w-3.5`}),` `,n(`activity:specs.graph`)]})]})]})]}),!u||u.specId!==e.id?(0,E.jsx)(`div`,{className:`flex h-24 items-center justify-center text-sm text-muted-foreground`,children:n(`activity:specs.loadingTasks`)}):h===`graph`?(0,E.jsx)(A,{columns:u.columns}):(0,E.jsx)(`div`,{className:`space-y-1.5`,children:k.map(e=>(0,E.jsxs)(`div`,{className:`flex items-center gap-3 rounded-md border border-border bg-card px-3 py-2`,children:[(0,E.jsx)(`span`,{className:`font-mono text-xs text-muted-foreground`,children:e.shortId}),(0,E.jsx)(`span`,{className:`flex-1 text-sm`,children:e.title}),(0,E.jsx)(`span`,{className:`text-xs capitalize text-muted-foreground`,children:e.displayStatus.replace(`_`,` `)})]},e.id))})]})]},e.id)})})}),(0,E.jsx)(C,{page:_,pageSize:M,totalItems:a.length,onPageChange:e=>{v(e),p(null)},itemLabel:`specifications`})]})}export{P as SpecsView};
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{$t as t,Bn as n,Cn as r,Dr as i,Ii as a,Jn as o,Si as s,Zi as c,bi as l,ci as u,hi as d,ln as f,na as p,ot as m,ri as h,si as g,tt as _,zn as v}from"./vendor-BsMARlcy.js";import"./i18n-VQ8IAWEk.js";import{t as y}from"./useWebSocket-BEkBQAAR.js";import{t as b}from"./utils-Ca0_D_-X.js";import{r as x}from"./stores-BazbaxhT.js";import{r as S}from"./view-navigation-Dx54K1uS.js";import{t as C}from"./pagination-D2oCHj95.js";import{t as w}from"./button-FFFZxxoZ.js";var T=e(p(),1),E=_(),D={completed:{icon:(0,E.jsx)(d,{className:`h-3.5 w-3.5`}),label:`Completed`,text:`text-success`,ring:`border-success/35`},in_progress:{icon:(0,E.jsx)(n,{className:`h-3.5 w-3.5 animate-spin`}),label:`Running`,text:`text-primary`,ring:`border-primary/45`},queued:{icon:(0,E.jsx)(h,{className:`h-3.5 w-3.5`}),label:`Queued`,text:`text-warning`,ring:`border-warning/35`},blocked:{icon:(0,E.jsx)(v,{className:`h-3.5 w-3.5`}),label:`Blocked`,text:`text-destructive`,ring:`border-destructive/30`},pending:{icon:(0,E.jsx)(g,{className:`h-3.5 w-3.5`}),label:`Pending`,text:`text-muted-foreground`,ring:`border-border/70`},review:{icon:(0,E.jsx)(t,{className:`h-3.5 w-3.5`}),label:`Review`,text:`text-primary`,ring:`border-primary/35`},failed:{icon:(0,E.jsx)(u,{className:`h-3.5 w-3.5`}),label:`Failed`,text:`text-destructive`,ring:`border-destructive/45`},cancelled:{icon:(0,E.jsx)(a,{className:`h-3.5 w-3.5`}),label:`Cancelled`,text:`text-muted-foreground`,ring:`border-border/70`}},O=[`completed`,`in_progress`,`queued`,`blocked`,`pending`,`failed`],k={critical:{label:`Crit`,cls:`bg-destructive/10 text-destructive`},high:{label:`High`,cls:`bg-destructive/10 text-destructive`},medium:{label:`Med`,cls:`bg-warning/12 text-warning`},low:{label:`Low`,cls:`bg-success/12 text-success`}};function A({columns:e,onTaskClick:t}){let{t:n}=c();return e.length===0?(0,E.jsx)(`div`,{className:`flex h-40 items-center justify-center text-sm text-muted-foreground`,children:n(`activity:board.emptySpec`)}):(0,E.jsxs)(`div`,{className:`rounded-xl border border-border/70 bg-card/75 p-4 shadow-sm`,children:[(0,E.jsx)(`h3`,{className:`mb-3 text-sm font-semibold text-foreground`,children:n(`activity:board.depGraphHeading`)}),(0,E.jsx)(`div`,{className:`mb-4 flex flex-wrap items-center gap-x-4 gap-y-1 text-xs`,children:O.map(e=>(0,E.jsxs)(`span`,{className:b(`inline-flex items-center gap-1.5`,D[e].text),children:[D[e].icon,(0,E.jsx)(`span`,{className:`text-muted-foreground`,children:n(`activity:board.status.${e}`)})]},e))}),(0,E.jsx)(`div`,{className:`flex gap-3 overflow-x-auto pb-2`,children:e.map((n,r)=>(0,E.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,E.jsxs)(`div`,{className:`w-60 shrink-0`,children:[(0,E.jsx)(`div`,{className:`mb-2 border-b border-border/60 pb-1 text-center text-xs font-medium uppercase text-muted-foreground`,children:n.label}),(0,E.jsx)(`div`,{className:`space-y-2`,children:n.tasks.map(e=>(0,E.jsx)(j,{task:e,onClick:t},e.id))})]}),r<e.length-1&&(0,E.jsx)(`div`,{className:`flex h-full items-center pt-8 text-muted-foreground/75`,children:(0,E.jsx)(l,{className:`h-5 w-5`})})]},n.label))})]})}function j({task:e,onClick:t}){let r=D[e.displayStatus],i=k[e.priority],{t:a}=c();return(0,E.jsxs)(`button`,{type:`button`,onClick:()=>t?.(e.id),className:b(`w-full rounded-lg border bg-background/55 p-2.5 text-left shadow-sm transition-colors hover:border-primary/35 hover:bg-accent/35`,r.ring),children:[(0,E.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,E.jsxs)(`span`,{className:b(`inline-flex items-center gap-1.5 text-xs font-medium`,r.text),children:[r.icon,(0,E.jsx)(`span`,{className:`font-mono text-foreground`,children:e.shortId})]}),(0,E.jsx)(`span`,{className:b(`rounded px-1.5 py-0.5 text-[10px] font-medium`,i.cls),children:i.label})]}),(0,E.jsx)(`p`,{className:`mt-1.5 text-xs text-foreground`,children:e.title}),e.deps.length>0&&(0,E.jsxs)(`p`,{className:`mt-1 font-mono text-[10px] text-muted-foreground`,children:[`← `,e.deps.join(`, `)]}),e.agentName&&(0,E.jsxs)(`div`,{className:b(`mt-1.5 inline-flex items-center gap-1 rounded-full px-1.5 py-0.5 text-[10px]`,e.displayStatus===`in_progress`?`bg-primary/10 text-primary`:`bg-muted text-muted-foreground`),title:e.worktreeBranch?a(`activity:board.worktreePrefix`,{branch:e.worktreeBranch}):void 0,children:[e.displayStatus===`in_progress`&&(0,E.jsx)(n,{className:`h-3 w-3 animate-spin`}),(0,E.jsx)(`span`,{children:e.agentName})]})]})}var M=12;function N(e){return e.columns.map(e=>({name:e.label,description:``,priority:`medium`,estimateHours:e.tasks.length,parallelizable:!1,taskTemplates:e.tasks.map(e=>({title:e.title,description:e.description,type:e.type,priority:e.priority,estimateHours:1}))}))}function P({onClose:e}){let{client:t}=y(),{t:n}=c(),a=x(e=>e.specs),u=x(e=>e.detail),d=x(e=>e.expandedSpecId),p=x(e=>e.setExpanded),[h,g]=(0,T.useState)(`graph`),[_,v]=(0,T.useState)(1),D=(0,T.useCallback)(e=>{!u||u.specId!==e.id||(t?.send?.({type:`goal.start`,payload:{title:e.title,phases:N(u),autonomous:!0}}),S(`goal`))},[u,t]);(0,T.useEffect)(()=>{t?.send?.({type:`specs.list`})},[t]);let O=(0,T.useCallback)(e=>{d===e.id?p(null):(p(e.id),t?.send?.({type:`specs.get`,payload:{specId:e.id}}))},[d,p,t]),k=u?.columns.flatMap(e=>e.tasks)??[],j={done:k.filter(e=>e.status===`completed`).length,running:k.filter(e=>e.status===`in_progress`).length,pending:k.filter(e=>e.status===`pending`||e.displayStatus===`queued`).length},P=a.slice((_-1)*M,_*M);return(0,T.useEffect)(()=>{let e=Math.max(1,Math.ceil(a.length/M));_>e&&v(e)},[_,a.length]),(0,E.jsxs)(`div`,{className:`flex h-full min-h-0 min-w-0 flex-col bg-background`,children:[(0,E.jsxs)(`header`,{className:`flex shrink-0 items-center justify-between border-b bg-card px-4 py-2`,children:[(0,E.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,E.jsx)(i,{className:`h-5 w-5 text-warning`}),(0,E.jsxs)(`div`,{children:[(0,E.jsx)(`h1`,{className:`text-lg font-semibold`,children:n(`activity:specs.heading`)}),(0,E.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:n(`activity:specs.subtitle`)})]})]}),(0,E.jsx)(w,{variant:`ghost`,size:`icon`,onClick:e,children:(0,E.jsx)(m,{className:`h-4 w-4`})})]}),(0,E.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto overscroll-contain p-4`,children:a.length===0?(0,E.jsx)(`div`,{className:`flex h-40 items-center justify-center text-sm text-muted-foreground`,children:n(`activity:specs.empty`,{command:`/sdd`})}):(0,E.jsx)(`div`,{className:`space-y-3`,children:P.map(e=>{let t=d===e.id,a=e.total>0?Math.round(e.completed/e.total*100):0;return(0,E.jsxs)(`div`,{className:`rounded-lg border border-border bg-card/60`,children:[(0,E.jsxs)(`button`,{type:`button`,onClick:()=>O(e),className:`flex w-full items-start gap-3 p-4 text-left`,children:[(0,E.jsx)(`span`,{className:`mt-1 text-muted-foreground`,children:t?(0,E.jsx)(s,{className:`h-4 w-4`}):(0,E.jsx)(l,{className:`h-4 w-4`})}),(0,E.jsx)(i,{className:`mt-0.5 h-4 w-4 text-muted-foreground`}),(0,E.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,E.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,E.jsx)(`span`,{className:`font-mono text-xs text-muted-foreground`,children:e.displayId}),(0,E.jsx)(`span`,{className:`rounded bg-muted px-1.5 py-0.5 text-[10px] capitalize text-muted-foreground`,children:e.status})]}),(0,E.jsx)(`h2`,{className:`mt-1 text-base font-semibold`,children:e.title}),(0,E.jsxs)(`div`,{className:`mt-2 flex items-center gap-2`,children:[(0,E.jsx)(`div`,{className:`h-2 flex-1 overflow-hidden rounded-full bg-muted`,children:(0,E.jsx)(`div`,{className:`h-full rounded-full bg-success transition-all`,style:{width:`${a}%`}})}),(0,E.jsxs)(`span`,{className:`shrink-0 font-mono text-xs text-muted-foreground`,children:[e.completed,`/`,e.total]})]})]})]}),t&&(0,E.jsxs)(`div`,{className:`border-t border-border p-4`,children:[(0,E.jsxs)(`div`,{className:`mb-3 flex items-center justify-between`,children:[(0,E.jsxs)(`div`,{className:`text-sm font-medium`,children:[n(`activity:specs.tasks`,{count:u?.total??e.total}),u&&(0,E.jsxs)(`span`,{className:`ml-3 text-xs font-normal text-muted-foreground`,children:[(0,E.jsx)(`span`,{className:`text-success`,children:n(`activity:specs.doneCount`,{count:j.done})}),` `,(0,E.jsx)(`span`,{className:`text-primary`,children:n(`activity:specs.runningCount`,{count:j.running})}),` `,(0,E.jsx)(`span`,{children:n(`activity:specs.pendingCount`,{count:j.pending})})]})]}),(0,E.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,E.jsxs)(`button`,{type:`button`,disabled:!u||u.specId!==e.id,onClick:()=>D(e),title:n(`activity:specs.runTitle`),className:`inline-flex items-center gap-1 rounded-md bg-warning/15 px-2.5 py-1 text-xs font-medium text-warning transition-colors hover:bg-warning/25 disabled:opacity-40`,children:[(0,E.jsx)(f,{className:`h-3.5 w-3.5`}),` `,n(`activity:specs.run`)]}),(0,E.jsxs)(`div`,{className:`flex items-center gap-1 rounded-md border border-border p-0.5`,children:[(0,E.jsxs)(`button`,{type:`button`,onClick:()=>g(`list`),className:b(`inline-flex items-center gap-1 rounded px-2 py-1 text-xs`,h===`list`?`bg-primary/15 text-primary`:`text-muted-foreground`),children:[(0,E.jsx)(o,{className:`h-3.5 w-3.5`}),` `,n(`activity:specs.list`)]}),(0,E.jsxs)(`button`,{type:`button`,onClick:()=>g(`graph`),className:b(`inline-flex items-center gap-1 rounded px-2 py-1 text-xs`,h===`graph`?`bg-primary/15 text-primary`:`text-muted-foreground`),children:[(0,E.jsx)(r,{className:`h-3.5 w-3.5`}),` `,n(`activity:specs.graph`)]})]})]})]}),!u||u.specId!==e.id?(0,E.jsx)(`div`,{className:`flex h-24 items-center justify-center text-sm text-muted-foreground`,children:n(`activity:specs.loadingTasks`)}):h===`graph`?(0,E.jsx)(A,{columns:u.columns}):(0,E.jsx)(`div`,{className:`space-y-1.5`,children:k.map(e=>(0,E.jsxs)(`div`,{className:`flex items-center gap-3 rounded-md border border-border bg-card px-3 py-2`,children:[(0,E.jsx)(`span`,{className:`font-mono text-xs text-muted-foreground`,children:e.shortId}),(0,E.jsx)(`span`,{className:`flex-1 text-sm`,children:e.title}),(0,E.jsx)(`span`,{className:`text-xs capitalize text-muted-foreground`,children:e.displayStatus.replace(`_`,` `)})]},e.id))})]})]},e.id)})})}),(0,E.jsx)(C,{page:_,pageSize:M,totalItems:a.length,onPageChange:e=>{v(e),p(null)},itemLabel:`specifications`})]})}export{P as SpecsView};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{Ai as t,Bn as n,Ft as r,Hi as i,Hr as a,Kr as o,N as s,gr as c,na as l,ot as u,qt as d,rn as f,tt as p}from"./vendor-BsMARlcy.js";import{t as m}from"./utils-Ca0_D_-X.js";import{n as h}from"./stores-j4CUJPI1.js";import{t as g}from"./pagination-D2oCHj95.js";import{t as _}from"./button-FFFZxxoZ.js";import{t as v}from"./input-BpQGvMAi.js";import{S as y}from"./index-DeInm8PK.js";var b=e(l(),1),x=p(),S={current:{label:`Current`,badge:`border-success/35 bg-success/10 text-success`,dot:`bg-success`,weight:0},update_available_safe:{label:`Update available`,badge:`border-info/35 bg-info/10 text-info`,dot:`bg-info`,weight:30},update_available_breaking:{label:`Major update`,badge:`border-warning/35 bg-warning/10 text-warning`,dot:`bg-warning`,weight:50},vulnerable:{label:`Vulnerable`,badge:`border-destructive/45 bg-destructive/15 text-destructive`,dot:`bg-destructive`,weight:100},deprecated:{label:`Deprecated`,badge:`border-destructive/35 bg-destructive/10 text-destructive`,dot:`bg-destructive`,weight:70},yanked:{label:`Yanked`,badge:`border-destructive/45 bg-destructive/15 text-destructive`,dot:`bg-destructive`,weight:80},unmaintained_suspected:{label:`Unmaintained?`,badge:`border-warning/35 bg-warning/10 text-warning`,dot:`bg-warning`,weight:60},blocked_by_constraints:{label:`Blocked`,badge:`border-warning/30 bg-warning/5 text-warning`,dot:`bg-warning`,weight:40},private_or_unresolved:{label:`Private`,badge:`border-border/70 bg-muted text-muted-foreground`,dot:`bg-muted-foreground`,weight:10},local_path:{label:`Local path`,badge:`border-border/70 bg-muted text-muted-foreground`,dot:`bg-muted-foreground`,weight:5},git_dependency:{label:`Git`,badge:`border-border/70 bg-muted text-muted-foreground`,dot:`bg-muted-foreground`,weight:5},unsupported:{label:`Unsupported`,badge:`border-border/70 bg-muted text-muted-foreground`,dot:`bg-muted-foreground`,weight:5},unknown:{label:`Unknown`,badge:`border-border/70 bg-muted text-muted-foreground`,dot:`bg-muted-foreground`,weight:20}},C={label:`Unknown`,badge:`border-border/70 bg-muted text-muted-foreground`,dot:`bg-muted-foreground`,weight:0};function w(e){return S[e]??C}function ee(e){return w(e.status).weight>=50}var T=[`critical`,`high`,`medium`,`low`,`info`],E={critical:{label:`Critical`,badge:`border-destructive/45 bg-destructive/15 text-destructive`},high:{label:`High`,badge:`border-destructive/35 bg-destructive/10 text-destructive`},medium:{label:`Medium`,badge:`border-warning/35 bg-warning/10 text-warning`},low:{label:`Low`,badge:`border-info/35 bg-info/10 text-info`},info:{label:`Info`,badge:`border-border/70 bg-muted text-muted-foreground`}},D={none:`No action`,upgrade_patch:`Patch upgrade`,upgrade_minor:`Minor upgrade`,upgrade_major:`Major upgrade`,replace:`Replace`,remove:`Remove`,investigate:`Investigate`},O={full:{label:`Full`,badge:`border-success/35 bg-success/10 text-success`},partial:{label:`Partial`,badge:`border-warning/35 bg-warning/10 text-warning`},unsupported:{label:`Unsupported`,badge:`border-border/70 bg-muted text-muted-foreground`}};function k(e){if(!e)return null;let t=/^\D*(\d+)/.exec(e);if(!t?.[1])return null;let n=Number(t[1]);return Number.isFinite(n)?n:null}function A(e){let t=k(e.locked??e.installed??e.requested),n=k(e.latestStable);if(t===null||n===null||n<=t)return{majorsBehind:0,label:null};let r=n-t;return{majorsBehind:r,label:`${r} major${r===1?``:`s`} behind`}}function j(e){return e.locked??e.installed??e.requested??null}function M(e){return e.confidence<1}function N({className:e,children:t}){return(0,x.jsx)(`span`,{className:m(`inline-flex shrink-0 items-center gap-1 border px-1.5 py-0.5 text-[10px] font-medium`,e),children:t})}function P({label:e,value:t,hint:n,tone:r=`default`}){let i={default:`text-foreground`,success:`text-success`,warning:`text-warning`,info:`text-info`,destructive:`text-destructive`}[r];return(0,x.jsxs)(`div`,{className:`border border-border/70 bg-card/55 px-3 py-2.5 shadow-[inset_0_1px_0_hsl(var(--foreground)/0.035)]`,children:[(0,x.jsx)(`p`,{className:`text-[9px] font-bold uppercase tracking-[0.16em] text-muted-foreground`,children:e}),(0,x.jsxs)(`div`,{className:`mt-1 flex items-end justify-between gap-2`,children:[(0,x.jsx)(`p`,{className:m(`font-mono text-xl font-bold tabular-nums`,i),children:t}),(0,x.jsx)(`p`,{className:`truncate text-[9px] text-muted-foreground`,children:n})]})]})}function te({dependency:e,findings:t,deepDive:o,onDeepDive:s,onBack:c}){let l=w(e.status),u=j(e),d=A(e);return(0,x.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,x.jsxs)(`header`,{className:`shrink-0 border-b border-border/70 bg-card/45 p-3`,children:[(0,x.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,x.jsx)(_,{variant:`ghost`,size:`icon`,onClick:c,"aria-label":`Back to dependency list`,className:`shrink-0 md:hidden`,children:(0,x.jsx)(i,{className:`size-4`})}),(0,x.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,x.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[(0,x.jsx)(`h2`,{className:`min-w-0 truncate font-mono text-sm font-bold text-foreground`,children:e.name}),(0,x.jsx)(N,{className:l.badge,children:l.label})]}),(0,x.jsxs)(`p`,{className:`mt-0.5 truncate text-[10px] text-muted-foreground`,children:[e.ecosystem,` · `,e.direct?`direct`:`transitive`,` ·`,` `,e.scope,` · `,e.sourceType]})]})]}),(0,x.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-baseline gap-2 font-mono text-xs`,children:[(0,x.jsx)(`span`,{className:`text-foreground`,children:u??`—`}),e.latestStable&&e.latestStable!==u&&(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(`span`,{className:`text-muted-foreground`,children:`→`}),(0,x.jsx)(`span`,{className:`text-info`,children:e.latestStable})]}),d.label&&(0,x.jsxs)(`span`,{className:`text-[10px] text-warning`,children:[`(`,d.label,`)`]})]})]}),(0,x.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-auto p-3`,children:[(0,x.jsxs)(`dl`,{className:`grid grid-cols-2 gap-px border border-border/70 bg-border/60`,children:[(0,x.jsx)(F,{label:`Constraint`,value:e.requested??`—`,mono:!0}),(0,x.jsx)(F,{label:`Locked`,value:e.locked??`—`,mono:!0}),(0,x.jsx)(F,{label:`Latest stable`,value:e.latestStable??`—`,mono:!0}),(0,x.jsx)(F,{label:`License`,value:e.license??`—`}),e.wanted&&(0,x.jsx)(F,{label:`Wanted`,value:e.wanted,mono:!0}),e.resolvable&&(0,x.jsx)(F,{label:`Resolvable`,value:e.resolvable,mono:!0}),e.purl&&(0,x.jsx)(F,{label:`PURL`,value:e.purl,mono:!0}),(0,x.jsx)(F,{label:`Registry flags`,value:[e.deprecated&&`deprecated`,e.yanked&&`yanked`].filter(Boolean).join(`, `)||`none`})]}),(0,x.jsxs)(`section`,{className:`mt-4`,children:[(0,x.jsxs)(`div`,{className:`mb-1.5 flex flex-wrap items-center justify-between gap-2`,children:[(0,x.jsx)(`h3`,{className:`text-[9px] font-bold uppercase tracking-[0.16em] text-muted-foreground`,children:`Findings`}),(0,x.jsxs)(_,{variant:`outline`,size:`sm`,onClick:()=>s(e),disabled:o.status===`loading`,className:`h-7 text-[10px]`,children:[o.status===`loading`?(0,x.jsx)(n,{className:`size-3 animate-spin`}):(0,x.jsx)(r,{className:`size-3`}),o.status===`loading`?`Researching…`:`Deep dive`]})]}),o.status===`error`&&o.error&&(0,x.jsx)(`p`,{role:`alert`,className:`mb-1.5 text-[10px] text-destructive`,children:o.error}),t.length===0?(0,x.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:`Nothing flagged. Run a deep dive to have the model research this package against the web.`}):(0,x.jsx)(`div`,{className:`flex flex-col gap-1.5`,children:t.map(e=>(0,x.jsxs)(`div`,{className:`border border-border/70 bg-card/40 p-2`,children:[(0,x.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[(0,x.jsx)(N,{className:E[e.severity].badge,children:E[e.severity].label}),(0,x.jsx)(N,{className:`border-border/70 bg-muted text-muted-foreground`,children:D[e.action]??e.action}),M(e)&&(0,x.jsxs)(N,{className:`border-info/35 bg-info/10 text-info`,children:[(0,x.jsx)(r,{className:`size-2.5`}),`AI · `,Math.round(e.confidence*100),`%`]})]}),(0,x.jsx)(`p`,{className:`mt-1 text-[11px] leading-relaxed text-muted-foreground`,children:e.rationale}),e.breakingRisk&&(0,x.jsx)(`p`,{className:`mt-1 border-l-2 border-warning/40 pl-2 text-[10px] leading-relaxed text-warning`,children:e.breakingRisk})]},e.id))})]}),(0,x.jsxs)(`section`,{className:`mt-4`,children:[(0,x.jsx)(`h3`,{className:`mb-1.5 text-[9px] font-bold uppercase tracking-[0.16em] text-muted-foreground`,children:`Evidence`}),e.evidence.length===0?(0,x.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:`No evidence recorded.`}):(0,x.jsx)(`ul`,{className:`flex flex-col gap-1`,children:e.evidence.map((t,n)=>(0,x.jsxs)(`li`,{className:`border border-border/70 bg-card/40 p-2`,children:[(0,x.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[(0,x.jsx)(N,{className:`border-border/70 bg-muted text-muted-foreground`,children:t.kind}),(0,x.jsx)(`span`,{className:`font-mono text-[9px] text-muted-foreground`,children:new Date(t.retrievedAt).toLocaleString()})]}),t.source.startsWith(`http`)?(0,x.jsxs)(`a`,{href:t.source,target:`_blank`,rel:`noreferrer noopener`,className:`mt-1 flex min-w-0 items-center gap-1 truncate text-[10px] text-info underline-offset-2 hover:underline`,children:[(0,x.jsx)(`span`,{className:`truncate`,children:t.source}),(0,x.jsx)(a,{className:`size-2.5 shrink-0`})]}):(0,x.jsx)(`p`,{className:`mt-1 truncate font-mono text-[10px] text-muted-foreground`,children:t.source}),t.detail&&(0,x.jsx)(`p`,{className:`mt-0.5 text-[10px] leading-relaxed text-muted-foreground`,children:t.detail})]},`${e.id}-evidence-${n}`))})]})]})]})}function F({label:e,value:t,mono:n}){return(0,x.jsxs)(`div`,{className:`bg-card/55 px-2.5 py-1.5`,children:[(0,x.jsx)(`dt`,{className:`text-[9px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:e}),(0,x.jsx)(`dd`,{className:m(`mt-0.5 truncate text-[11px] text-foreground`,n&&`font-mono`),children:t})]})}var I=`grid grid-cols-[minmax(0,2.2fr)_minmax(0,1.6fr)_minmax(0,1.1fr)] gap-2`;function ne({dependencies:e,selectedId:t,hasDependencies:n,onSelect:r}){let i=y(e,30);return e.length===0?(0,x.jsx)(`div`,{className:`flex flex-1 items-center justify-center p-8 text-center`,children:(0,x.jsx)(`p`,{className:`max-w-xs text-xs text-muted-foreground`,children:n?`No dependencies match the current filters.`:`No dependencies inventoried yet. Run a scan to populate the inventory.`})}):(0,x.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,x.jsxs)(`div`,{className:m(I,`shrink-0 border-b border-border/70 bg-card/45 px-3 py-1.5 text-[9px] font-bold uppercase tracking-[0.14em] text-muted-foreground`),children:[(0,x.jsx)(`span`,{children:`Package`}),(0,x.jsx)(`span`,{children:`Installed → Latest`}),(0,x.jsx)(`span`,{children:`Status`})]}),(0,x.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,x.jsx)(s,{className:`h-full`,"aria-label":`Dependencies`,children:i.pageItems.map(e=>(0,x.jsx)(L,{dependency:e,selected:e.id===t,onSelect:r},e.id))})}),(0,x.jsx)(g,{page:i.page,pageSize:i.pageSize,totalItems:i.totalItems,onPageChange:i.setPage,itemLabel:`dependencies`})]})}function L({dependency:e,selected:t,onSelect:n}){let r=w(e.status),i=j(e),a=A(e);return(0,x.jsxs)(`button`,{type:`button`,onClick:()=>n(e),"aria-current":t,className:m(I,`w-full items-center border-b border-border/40 px-3 py-2 text-left transition-colors hover:bg-accent/40`,t&&`bg-accent/60`),children:[(0,x.jsxs)(`div`,{className:`min-w-0`,children:[(0,x.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,x.jsx)(`span`,{className:m(`size-1.5 shrink-0`,r.dot),"aria-hidden":`true`}),(0,x.jsx)(`span`,{className:`truncate font-mono text-xs text-foreground`,children:e.name})]}),(0,x.jsxs)(`p`,{className:`mt-0.5 truncate text-[10px] text-muted-foreground`,children:[e.ecosystem,` · `,e.direct?`direct`:`transitive`,` · `,e.scope]})]}),(0,x.jsxs)(`div`,{className:`min-w-0`,children:[(0,x.jsxs)(`div`,{className:`flex min-w-0 items-baseline gap-1.5 font-mono text-[11px]`,children:[(0,x.jsx)(`span`,{className:`truncate text-foreground`,children:i??`—`}),e.latestStable&&e.latestStable!==i&&(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(`span`,{className:`shrink-0 text-muted-foreground`,children:`→`}),(0,x.jsx)(`span`,{className:`truncate text-info`,children:e.latestStable})]})]}),a.label?(0,x.jsx)(`p`,{className:`mt-0.5 truncate text-[10px] text-warning`,children:a.label}):e.requested&&(0,x.jsx)(`p`,{className:`mt-0.5 truncate font-mono text-[10px] text-muted-foreground`,children:e.requested})]}),(0,x.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-1`,children:[(0,x.jsx)(N,{className:r.badge,children:r.label}),e.deprecated&&(0,x.jsx)(N,{className:`border-destructive/35 bg-destructive/10 text-destructive`,children:`dep`}),e.yanked&&(0,x.jsx)(N,{className:`border-destructive/45 bg-destructive/15 text-destructive`,children:`yank`})]})]})}function re({findings:e,dependenciesById:t,onSelectDependency:n}){let r=y(e,20);return e.length===0?(0,x.jsx)(`div`,{className:`flex flex-1 items-center justify-center p-8 text-center`,children:(0,x.jsxs)(`p`,{className:`max-w-sm text-xs text-muted-foreground`,children:[`No findings. Run `,(0,x.jsx)(`span`,{className:`font-mono text-foreground`,children:`Analyze`}),` to check versions and advisories against upstream registries, then interpret the results.`]})}):(0,x.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,x.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto p-3`,children:(0,x.jsx)(`div`,{className:`flex flex-col gap-4`,children:T.map(e=>[e,r.pageItems.filter(t=>t.severity===e)]).filter(([,e])=>e.length>0).map(([e,r])=>(0,x.jsxs)(`section`,{children:[(0,x.jsxs)(`div`,{className:`mb-1.5 flex items-center gap-2`,children:[(0,x.jsx)(N,{className:E[e].badge,children:E[e].label}),(0,x.jsx)(`span`,{className:`font-mono text-[10px] tabular-nums text-muted-foreground`,children:r.length})]}),(0,x.jsx)(`div`,{className:`flex flex-col gap-1.5`,children:r.map(e=>(0,x.jsx)(R,{finding:e,dependency:t.get(e.dependencyId),onSelectDependency:n},e.id))})]},e))})}),(0,x.jsx)(g,{page:r.page,pageSize:r.pageSize,totalItems:r.totalItems,onPageChange:r.setPage,itemLabel:`findings`})]})}function R({finding:e,dependency:t,onSelectDependency:n}){let i=M(e);return(0,x.jsxs)(`div`,{className:`border border-border/70 bg-card/40 p-2.5`,children:[(0,x.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[(0,x.jsx)(`button`,{type:`button`,onClick:()=>n(e.dependencyId),className:`min-w-0 truncate font-mono text-xs text-foreground underline-offset-2 hover:underline`,children:t?.name??e.dependencyId}),(0,x.jsx)(N,{className:`border-border/70 bg-muted text-muted-foreground`,children:D[e.action]??e.action}),i&&(0,x.jsxs)(N,{className:`border-info/35 bg-info/10 text-info`,children:[(0,x.jsx)(r,{className:`size-2.5`}),`AI · `,Math.round(e.confidence*100),`%`]})]}),(0,x.jsx)(`p`,{className:`mt-1.5 text-[11px] leading-relaxed text-muted-foreground`,children:e.rationale}),e.breakingRisk&&(0,x.jsx)(`p`,{className:`mt-1 border-l-2 border-warning/40 pl-2 text-[10px] leading-relaxed text-warning`,children:e.breakingRisk}),e.evidence.length>0&&(0,x.jsx)(`ul`,{className:m(`mt-1.5 flex flex-col gap-0.5`),children:e.evidence.slice(0,4).map((t,n)=>(0,x.jsx)(`li`,{className:`min-w-0 truncate text-[10px]`,children:t.source.startsWith(`http`)?(0,x.jsx)(`a`,{href:t.source,target:`_blank`,rel:`noreferrer noopener`,className:`text-info underline-offset-2 hover:underline`,children:t.detail??t.source}):(0,x.jsx)(`span`,{className:`text-muted-foreground`,children:t.detail??t.source})},`${e.id}-${n}`))})]})}function ie({searchQuery:e,ecosystemFilter:t,statusFilter:n,directOnly:r,sort:i,hasFilters:a,ecosystems:o,statuses:s,visibleCount:l,totalCount:f,onSearchChange:p,onEcosystemFilterChange:h,onStatusFilterChange:g,onToggleDirectOnly:y,onSortChange:b,onClearFilters:S}){return(0,x.jsxs)(`div`,{className:`shrink-0 space-y-2 border-b border-border/70 bg-card/45 p-3`,children:[(0,x.jsxs)(`div`,{className:`flex gap-2`,children:[(0,x.jsxs)(`div`,{className:`relative min-w-0 flex-1`,children:[(0,x.jsx)(d,{className:`pointer-events-none absolute left-3 top-1/2 size-3.5 -translate-y-1/2 text-muted-foreground`}),(0,x.jsx)(v,{"aria-label":`Search dependencies`,value:e,onChange:e=>p(e.target.value),placeholder:`Search by package name…`,className:`h-10 min-w-0 bg-background pl-9 pr-8 text-xs`}),e&&(0,x.jsx)(`button`,{type:`button`,"aria-label":`Clear search`,onClick:()=>p(``),className:`absolute right-2 top-1/2 -translate-y-1/2 p-1 text-muted-foreground hover:text-foreground`,children:(0,x.jsx)(u,{className:`size-3.5`})})]}),(0,x.jsx)(_,{variant:r?`default`:`outline`,size:`sm`,onClick:y,"aria-pressed":r,title:`Show only dependencies this project declares itself`,className:`shrink-0`,children:`Direct only`}),a&&(0,x.jsx)(_,{variant:`ghost`,size:`icon`,onClick:S,"aria-label":`Clear all filters`,title:`Clear all filters`,className:`shrink-0`,children:(0,x.jsx)(c,{className:`size-4`})})]}),(0,x.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-3`,children:[(0,x.jsxs)(`div`,{children:[(0,x.jsx)(`label`,{className:`sr-only`,htmlFor:`techstack-ecosystem-filter`,children:`Filter by ecosystem`}),(0,x.jsxs)(`select`,{id:`techstack-ecosystem-filter`,value:t,onChange:e=>h(e.target.value),className:`h-9 w-full min-w-0 border border-input bg-background px-2 text-xs`,children:[(0,x.jsx)(`option`,{value:`all`,children:`All ecosystems`}),o.map(([e,t])=>(0,x.jsxs)(`option`,{value:e,children:[e,` · `,t]},e))]})]}),(0,x.jsxs)(`div`,{children:[(0,x.jsx)(`label`,{className:`sr-only`,htmlFor:`techstack-status-filter`,children:`Filter by status`}),(0,x.jsxs)(`select`,{id:`techstack-status-filter`,value:n,onChange:e=>g(e.target.value),className:`h-9 w-full min-w-0 border border-input bg-background px-2 text-xs`,children:[(0,x.jsx)(`option`,{value:`all`,children:`All statuses`}),s.map(([e,t])=>(0,x.jsxs)(`option`,{value:e,children:[w(e).label,` · `,t]},e))]})]}),(0,x.jsxs)(`div`,{children:[(0,x.jsx)(`label`,{className:`sr-only`,htmlFor:`techstack-sort`,children:`Sort dependencies`}),(0,x.jsxs)(`select`,{id:`techstack-sort`,value:i,onChange:e=>b(e.target.value),className:`h-9 w-full min-w-0 border border-input bg-background px-2 text-xs`,children:[(0,x.jsx)(`option`,{value:`attention`,children:`Sort: needs attention`}),(0,x.jsx)(`option`,{value:`drift`,children:`Sort: most out of date`}),(0,x.jsx)(`option`,{value:`name`,children:`Sort: name`})]})]})]}),(0,x.jsx)(`p`,{className:m(`text-[10px] text-muted-foreground`,a&&`text-info`),children:l===f?`${f} dependencies`:`${l} of ${f} dependencies`})]})}var z=[{id:`dependencies`,label:`Dependencies`},{id:`findings`,label:`Findings`},{id:`workspaces`,label:`Workspaces`}];function B(){let e=h(e=>e.snapshot),t=h(e=>e.stale),i=h(e=>e.loading),a=h(e=>e.error),s=h(e=>e.activeJob),[c,l]=(0,b.useState)(`dependencies`),[d,p]=(0,b.useState)(``),[g,v]=(0,b.useState)(`all`),[y,S]=(0,b.useState)(`all`),[C,T]=(0,b.useState)(!1),[E,D]=(0,b.useState)(`attention`),[O,k]=(0,b.useState)(null),[j,M]=(0,b.useState)([]),[N,F]=(0,b.useState)({status:`idle`,error:null}),I=(0,b.useCallback)(async()=>{let e=h.getState();e.setLoading(!0),e.setError(null);try{let t=await fetch(`/api/techstack/snapshot`);if(t.status===404){e.setSnapshot(null,!1);return}if(!t.ok)throw Error(`HTTP ${t.status}: ${t.statusText}`);let n=await t.json();e.setSnapshot(n.snapshot,n.stale)}catch(t){e.setError(t instanceof Error?t.message:String(t))}},[]),L=(0,b.useCallback)(async e=>{let t=h.getState();t.setLoading(!0),t.setError(null);try{let n=await fetch(`/api/techstack/${e}`,{method:`POST`}),r=await n.json();if(!n.ok||!r.jobId)throw Error(r.error??`HTTP ${n.status}: ${n.statusText}`);t.jobStarted(r.jobId,e)}catch(e){t.setError(e instanceof Error?e.message:String(e))}},[]),R=(0,b.useCallback)(async()=>{let e=h.getState().activeJob;if(e)try{let t=await fetch(`/api/techstack/jobs/${encodeURIComponent(e.id)}/cancel`,{method:`POST`});if(!t.ok)throw Error(`HTTP ${t.status}: ${t.statusText}`);h.getState().jobCancelled(e.id)}catch(e){h.getState().setError(e instanceof Error?e.message:String(e))}},[]),B=(0,b.useCallback)(async e=>{F({status:`loading`,error:null});try{let t=await fetch(`/api/techstack/deps/${encodeURIComponent(e.id)}/research`,{method:`POST`}),n=await t.json();if(!t.ok)throw Error(n.error??`HTTP ${t.status}`);M(n.findings??[]),F({status:`idle`,error:null})}catch(e){F({status:`error`,error:e instanceof Error?e.message:String(e)})}},[]);(0,b.useEffect)(()=>{I()},[I]),(0,b.useEffect)(()=>{M([]),F({status:`idle`,error:null})},[e?.id]);let K=(0,b.useMemo)(()=>e?.dependencies??[],[e]),q=(0,b.useMemo)(()=>e?.findings??[],[e]),J=(0,b.useMemo)(()=>new Map(K.map(e=>[e.id,e])),[K]),ae=(0,b.useMemo)(()=>W(K.map(e=>e.ecosystem)),[K]),oe=(0,b.useMemo)(()=>W(K.map(e=>e.status)),[K]),Y=(0,b.useMemo)(()=>{let e=d.trim().toLowerCase(),t=[...K.filter(t=>!(e&&!t.name.toLowerCase().includes(e)||g!==`all`&&t.ecosystem!==g||y!==`all`&&t.status!==y||C&&!t.direct))];return E===`name`?t.sort((e,t)=>e.name.localeCompare(t.name)):E===`drift`?t.sort((e,t)=>A(t).majorsBehind-A(e).majorsBehind||e.name.localeCompare(t.name)):t.sort((e,t)=>w(t.status).weight-w(e.status).weight||Number(t.direct)-Number(e.direct)||e.name.localeCompare(t.name)),t},[K,d,g,y,C,E]),X=O?J.get(O):void 0,se=(0,b.useMemo)(()=>X?[...q.filter(e=>e.dependencyId===X.id),...j.filter(e=>e.dependencyId===X.id)]:[],[q,j,X]),ce=(0,b.useMemo)(()=>K.filter(ee).length,[K]),Z=(0,b.useMemo)(()=>K.filter(e=>A(e).majorsBehind>0).length,[K]),Q=(0,b.useMemo)(()=>K.filter(e=>e.status===`vulnerable`).length,[K]),le=d.trim()!==``||g!==`all`||y!==`all`||C,ue=(0,b.useCallback)(()=>{p(``),v(`all`),S(`all`),T(!1)},[]),$=!!(s&&![`completed`,`failed`,`cancelled`].includes(s.status)),de=(0,b.useCallback)(e=>{k(e),l(`dependencies`)},[]);return(0,x.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col`,children:[(0,x.jsx)(`header`,{className:`shrink-0 border-b border-border/70 px-4 py-3`,children:(0,x.jsxs)(`div`,{className:`flex flex-wrap items-start gap-3`,children:[(0,x.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,x.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,x.jsx)(`h1`,{className:`text-base font-bold sm:text-lg`,children:`TechStack`}),(0,x.jsx)(`span`,{className:`border border-info/35 bg-info/10 px-2 py-0.5 font-mono text-[9px] font-bold uppercase text-info`,children:e?`${e.workspaces.length} workspaces`:`no scan yet`}),t&&(0,x.jsx)(`span`,{className:`border border-warning/35 bg-warning/10 px-2 py-0.5 font-mono text-[9px] font-bold uppercase text-warning`,children:`stale >24h`})]}),(0,x.jsx)(`p`,{className:`mt-0.5 truncate text-[10px] text-muted-foreground sm:text-xs`,children:e?`${e.targetRoot} · scanned ${new Date(e.createdAt).toLocaleString()}`:`Scan the open project to inventory its dependencies.`})]}),(0,x.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,x.jsxs)(_,{variant:`outline`,size:`sm`,onClick:()=>void L(`inventory`),disabled:$,title:`Offline: re-read manifests and lockfiles`,children:[(0,x.jsx)(f,{className:m(`size-3.5`,$&&`animate-spin`)}),(0,x.jsx)(`span`,{className:`hidden sm:inline`,children:`Refresh`})]}),(0,x.jsxs)(_,{size:`sm`,onClick:()=>void L(`analyze`),disabled:$,title:`Check registries and advisories, then interpret the results with the model`,children:[(0,x.jsx)(r,{className:`size-3.5`}),`Analyze`]}),$&&(0,x.jsx)(_,{variant:`ghost`,size:`icon`,onClick:()=>void R(),"aria-label":`Cancel job`,children:(0,x.jsx)(u,{className:`size-4`})}),(0,x.jsx)(_,{variant:`ghost`,size:`icon`,onClick:()=>e&&G(e),disabled:!e,"aria-label":`Export snapshot as JSON`,title:`Export snapshot as JSON`,children:(0,x.jsx)(o,{className:`size-4`})})]})]})}),e&&(0,x.jsxs)(`div`,{className:`grid shrink-0 grid-cols-2 gap-px border-b border-border/70 bg-border/60 sm:grid-cols-4`,children:[(0,x.jsx)(P,{label:`Dependencies`,value:K.length,hint:`${Y.length} visible`}),(0,x.jsx)(P,{label:`Outdated`,value:Z,hint:`majors behind`,tone:Z>0?`warning`:`success`}),(0,x.jsx)(P,{label:`Vulnerable`,value:Q,hint:`known advisories`,tone:Q>0?`destructive`:`success`}),(0,x.jsx)(P,{label:`Findings`,value:q.length,hint:`${ce} need attention`,tone:q.length>0?`info`:`default`})]}),($||a)&&(0,x.jsxs)(`div`,{className:`shrink-0 border-b border-border/70 px-4 py-2`,"aria-live":`polite`,children:[$&&s&&(0,x.jsxs)(`div`,{role:`status`,className:`flex items-center gap-2 text-xs text-info`,children:[(0,x.jsx)(n,{className:`size-3.5 animate-spin`}),(0,x.jsx)(`span`,{className:`font-mono`,children:s.status}),s.progress&&(0,x.jsxs)(`span`,{className:`text-muted-foreground`,children:[s.progress.completed,`/`,s.progress.total]})]}),a&&(0,x.jsxs)(`div`,{role:`alert`,className:`flex items-center gap-2 text-xs text-destructive`,children:[(0,x.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:a}),(0,x.jsx)(`button`,{type:`button`,onClick:()=>void I(),className:`underline`,children:`Retry`})]})]}),i&&!e?(0,x.jsx)(H,{}):e?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(`nav`,{className:`flex shrink-0 gap-1 border-b border-border/70 px-2`,children:z.map(e=>(0,x.jsxs)(`button`,{type:`button`,onClick:()=>l(e.id),"aria-current":c===e.id,className:m(`border-b-2 px-3 py-2 text-xs font-medium transition-colors`,c===e.id?`border-primary text-foreground`:`border-transparent text-muted-foreground hover:text-foreground`),children:[e.label,e.id===`findings`&&q.length>0&&(0,x.jsx)(`span`,{className:`ml-1.5 font-mono text-[10px] tabular-nums text-muted-foreground`,children:q.length})]},e.id))}),c===`dependencies`&&(0,x.jsxs)(`div`,{className:`grid min-h-0 flex-1 md:grid-cols-[minmax(340px,1fr)_minmax(0,1.15fr)]`,children:[(0,x.jsxs)(`section`,{className:m(`min-h-0 border-r border-border/70`,X?`hidden md:flex md:flex-col`:`flex flex-col`),"aria-label":`Dependency list`,children:[(0,x.jsx)(ie,{searchQuery:d,ecosystemFilter:g,statusFilter:y,directOnly:C,sort:E,hasFilters:le,ecosystems:ae,statuses:oe,visibleCount:Y.length,totalCount:K.length,onSearchChange:p,onEcosystemFilterChange:v,onStatusFilterChange:S,onToggleDirectOnly:()=>T(e=>!e),onSortChange:D,onClearFilters:ue}),(0,x.jsx)(ne,{dependencies:Y,selectedId:O,hasDependencies:K.length>0,onSelect:e=>k(e.id)})]}),(0,x.jsx)(`section`,{className:m(`min-h-0`,X?`flex flex-col`:`hidden md:flex md:flex-col`),"aria-label":`Dependency detail`,children:X?(0,x.jsx)(te,{dependency:X,findings:se,deepDive:N,onDeepDive:B,onBack:()=>k(null)}):(0,x.jsx)(`div`,{className:`flex flex-1 items-center justify-center p-8 text-center`,children:(0,x.jsx)(`p`,{className:`max-w-xs text-xs text-muted-foreground`,children:`Select a dependency to see its versions, evidence, and findings.`})})})]}),c===`findings`&&(0,x.jsx)(re,{findings:q,dependenciesById:J,onSelectDependency:de}),c===`workspaces`&&(0,x.jsx)(V,{snapshot:e})]}):(0,x.jsx)(U,{onScan:()=>void L(`inventory`),disabled:$})]})}function V({snapshot:e}){let t=(0,b.useMemo)(()=>{let t=new Map;for(let n of e.dependencies)t.set(n.workspaceId,(t.get(n.workspaceId)??0)+1);return t},[e]),n=y(e.workspaces,12);return e.workspaces.length===0?(0,x.jsx)(`div`,{className:`flex flex-1 items-center justify-center p-8`,children:(0,x.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`No workspaces detected.`})}):(0,x.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-auto p-3`,children:[(0,x.jsx)(`div`,{className:`flex flex-col gap-1.5`,children:n.pageItems.map(e=>{let n=O[e.coverage];return(0,x.jsxs)(`div`,{className:`border border-border/70 bg-card/40 p-2.5`,children:[(0,x.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,x.jsxs)(`div`,{className:`min-w-0`,children:[(0,x.jsx)(`p`,{className:`truncate font-mono text-xs text-foreground`,children:e.relativeRoot}),(0,x.jsxs)(`p`,{className:`mt-0.5 truncate text-[10px] text-muted-foreground`,children:[e.ecosystem,e.packageManager?` · ${e.packageManager}`:``,` · ${t.get(e.id)??0} deps`]})]}),(0,x.jsx)(`span`,{className:m(`shrink-0 border px-1.5 py-0.5 text-[10px] font-medium`,n.badge),children:n.label})]}),e.manifests.length>0&&(0,x.jsx)(`div`,{className:`mt-1.5 flex flex-wrap gap-1`,children:e.manifests.map(e=>(0,x.jsx)(`span`,{className:`border border-border/70 bg-background/45 px-1.5 py-0.5 font-mono text-[9px] text-muted-foreground`,children:e.split(/[/\\]/).pop()},e))})]},e.id)})}),(0,x.jsx)(g,{page:n.page,pageSize:n.pageSize,totalItems:n.totalItems,onPageChange:n.setPage,className:`mt-3`,itemLabel:`workspaces`})]})}function H(){return(0,x.jsx)(`div`,{className:`flex flex-1 items-center justify-center`,children:(0,x.jsxs)(`div`,{className:`flex flex-col items-center gap-2`,children:[(0,x.jsx)(n,{className:`size-5 animate-spin text-muted-foreground`}),(0,x.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Loading snapshot…`})]})})}function U({onScan:e,disabled:n}){return(0,x.jsx)(`div`,{className:`flex flex-1 items-center justify-center p-8`,children:(0,x.jsxs)(`div`,{className:`flex max-w-md flex-col items-center gap-3 text-center`,children:[(0,x.jsx)(`div`,{className:`flex size-14 items-center justify-center border border-info/25 bg-info/5 text-info`,children:(0,x.jsx)(t,{className:`size-6`})}),(0,x.jsx)(`h2`,{className:`text-sm font-semibold`,children:`No inventory yet`}),(0,x.jsx)(`p`,{className:`text-xs leading-relaxed text-muted-foreground`,children:`TechStack reads every manifest and lockfile in the open project — npm, Python, Rust, Go, .NET, PHP, Dart, Maven, Ruby, Elixir — and compares what you have against the upstream registries.`}),(0,x.jsxs)(_,{size:`sm`,onClick:e,disabled:n,children:[(0,x.jsx)(f,{className:m(`size-3.5`,n&&`animate-spin`)}),`Scan this project`]})]})})}function W(e){let t=new Map;for(let n of e)t.set(n,(t.get(n)??0)+1);return[...t.entries()].sort((e,t)=>t[1]-e[1]||e[0].localeCompare(t[0]))}function G(e){let t=new Blob([JSON.stringify(e,null,2)],{type:`application/json`}),n=URL.createObjectURL(t),r=document.createElement(`a`);r.href=n,r.download=`techstack.json`,r.click(),URL.revokeObjectURL(n)}export{B as TechStackView};
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{Ai as t,Bn as n,Ft as r,Hi as i,Hr as a,Kr as o,N as s,gr as c,na as l,ot as u,qt as d,rn as f,tt as p}from"./vendor-BsMARlcy.js";import{t as m}from"./utils-Ca0_D_-X.js";import{n as h}from"./stores-BazbaxhT.js";import{t as g}from"./pagination-D2oCHj95.js";import{t as _}from"./button-FFFZxxoZ.js";import{t as v}from"./input-BpQGvMAi.js";import{S as y}from"./index-D_QeLLAg.js";var b=e(l(),1),x=p(),S={current:{label:`Current`,badge:`border-success/35 bg-success/10 text-success`,dot:`bg-success`,weight:0},update_available_safe:{label:`Update available`,badge:`border-info/35 bg-info/10 text-info`,dot:`bg-info`,weight:30},update_available_breaking:{label:`Major update`,badge:`border-warning/35 bg-warning/10 text-warning`,dot:`bg-warning`,weight:50},vulnerable:{label:`Vulnerable`,badge:`border-destructive/45 bg-destructive/15 text-destructive`,dot:`bg-destructive`,weight:100},deprecated:{label:`Deprecated`,badge:`border-destructive/35 bg-destructive/10 text-destructive`,dot:`bg-destructive`,weight:70},yanked:{label:`Yanked`,badge:`border-destructive/45 bg-destructive/15 text-destructive`,dot:`bg-destructive`,weight:80},unmaintained_suspected:{label:`Unmaintained?`,badge:`border-warning/35 bg-warning/10 text-warning`,dot:`bg-warning`,weight:60},blocked_by_constraints:{label:`Blocked`,badge:`border-warning/30 bg-warning/5 text-warning`,dot:`bg-warning`,weight:40},private_or_unresolved:{label:`Private`,badge:`border-border/70 bg-muted text-muted-foreground`,dot:`bg-muted-foreground`,weight:10},local_path:{label:`Local path`,badge:`border-border/70 bg-muted text-muted-foreground`,dot:`bg-muted-foreground`,weight:5},git_dependency:{label:`Git`,badge:`border-border/70 bg-muted text-muted-foreground`,dot:`bg-muted-foreground`,weight:5},unsupported:{label:`Unsupported`,badge:`border-border/70 bg-muted text-muted-foreground`,dot:`bg-muted-foreground`,weight:5},unknown:{label:`Unknown`,badge:`border-border/70 bg-muted text-muted-foreground`,dot:`bg-muted-foreground`,weight:20}},C={label:`Unknown`,badge:`border-border/70 bg-muted text-muted-foreground`,dot:`bg-muted-foreground`,weight:0};function w(e){return S[e]??C}function ee(e){return w(e.status).weight>=50}var T=[`critical`,`high`,`medium`,`low`,`info`],E={critical:{label:`Critical`,badge:`border-destructive/45 bg-destructive/15 text-destructive`},high:{label:`High`,badge:`border-destructive/35 bg-destructive/10 text-destructive`},medium:{label:`Medium`,badge:`border-warning/35 bg-warning/10 text-warning`},low:{label:`Low`,badge:`border-info/35 bg-info/10 text-info`},info:{label:`Info`,badge:`border-border/70 bg-muted text-muted-foreground`}},D={none:`No action`,upgrade_patch:`Patch upgrade`,upgrade_minor:`Minor upgrade`,upgrade_major:`Major upgrade`,replace:`Replace`,remove:`Remove`,investigate:`Investigate`},O={full:{label:`Full`,badge:`border-success/35 bg-success/10 text-success`},partial:{label:`Partial`,badge:`border-warning/35 bg-warning/10 text-warning`},unsupported:{label:`Unsupported`,badge:`border-border/70 bg-muted text-muted-foreground`}};function k(e){if(!e)return null;let t=/^\D*(\d+)/.exec(e);if(!t?.[1])return null;let n=Number(t[1]);return Number.isFinite(n)?n:null}function A(e){let t=k(e.locked??e.installed??e.requested),n=k(e.latestStable);if(t===null||n===null||n<=t)return{majorsBehind:0,label:null};let r=n-t;return{majorsBehind:r,label:`${r} major${r===1?``:`s`} behind`}}function j(e){return e.locked??e.installed??e.requested??null}function M(e){return e.confidence<1}function N({className:e,children:t}){return(0,x.jsx)(`span`,{className:m(`inline-flex shrink-0 items-center gap-1 border px-1.5 py-0.5 text-[10px] font-medium`,e),children:t})}function P({label:e,value:t,hint:n,tone:r=`default`}){let i={default:`text-foreground`,success:`text-success`,warning:`text-warning`,info:`text-info`,destructive:`text-destructive`}[r];return(0,x.jsxs)(`div`,{className:`border border-border/70 bg-card/55 px-3 py-2.5 shadow-[inset_0_1px_0_hsl(var(--foreground)/0.035)]`,children:[(0,x.jsx)(`p`,{className:`text-[9px] font-bold uppercase tracking-[0.16em] text-muted-foreground`,children:e}),(0,x.jsxs)(`div`,{className:`mt-1 flex items-end justify-between gap-2`,children:[(0,x.jsx)(`p`,{className:m(`font-mono text-xl font-bold tabular-nums`,i),children:t}),(0,x.jsx)(`p`,{className:`truncate text-[9px] text-muted-foreground`,children:n})]})]})}function te({dependency:e,findings:t,deepDive:o,onDeepDive:s,onBack:c}){let l=w(e.status),u=j(e),d=A(e);return(0,x.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,x.jsxs)(`header`,{className:`shrink-0 border-b border-border/70 bg-card/45 p-3`,children:[(0,x.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,x.jsx)(_,{variant:`ghost`,size:`icon`,onClick:c,"aria-label":`Back to dependency list`,className:`shrink-0 md:hidden`,children:(0,x.jsx)(i,{className:`size-4`})}),(0,x.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,x.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[(0,x.jsx)(`h2`,{className:`min-w-0 truncate font-mono text-sm font-bold text-foreground`,children:e.name}),(0,x.jsx)(N,{className:l.badge,children:l.label})]}),(0,x.jsxs)(`p`,{className:`mt-0.5 truncate text-[10px] text-muted-foreground`,children:[e.ecosystem,` · `,e.direct?`direct`:`transitive`,` ·`,` `,e.scope,` · `,e.sourceType]})]})]}),(0,x.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-baseline gap-2 font-mono text-xs`,children:[(0,x.jsx)(`span`,{className:`text-foreground`,children:u??`—`}),e.latestStable&&e.latestStable!==u&&(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(`span`,{className:`text-muted-foreground`,children:`→`}),(0,x.jsx)(`span`,{className:`text-info`,children:e.latestStable})]}),d.label&&(0,x.jsxs)(`span`,{className:`text-[10px] text-warning`,children:[`(`,d.label,`)`]})]})]}),(0,x.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-auto p-3`,children:[(0,x.jsxs)(`dl`,{className:`grid grid-cols-2 gap-px border border-border/70 bg-border/60`,children:[(0,x.jsx)(F,{label:`Constraint`,value:e.requested??`—`,mono:!0}),(0,x.jsx)(F,{label:`Locked`,value:e.locked??`—`,mono:!0}),(0,x.jsx)(F,{label:`Latest stable`,value:e.latestStable??`—`,mono:!0}),(0,x.jsx)(F,{label:`License`,value:e.license??`—`}),e.wanted&&(0,x.jsx)(F,{label:`Wanted`,value:e.wanted,mono:!0}),e.resolvable&&(0,x.jsx)(F,{label:`Resolvable`,value:e.resolvable,mono:!0}),e.purl&&(0,x.jsx)(F,{label:`PURL`,value:e.purl,mono:!0}),(0,x.jsx)(F,{label:`Registry flags`,value:[e.deprecated&&`deprecated`,e.yanked&&`yanked`].filter(Boolean).join(`, `)||`none`})]}),(0,x.jsxs)(`section`,{className:`mt-4`,children:[(0,x.jsxs)(`div`,{className:`mb-1.5 flex flex-wrap items-center justify-between gap-2`,children:[(0,x.jsx)(`h3`,{className:`text-[9px] font-bold uppercase tracking-[0.16em] text-muted-foreground`,children:`Findings`}),(0,x.jsxs)(_,{variant:`outline`,size:`sm`,onClick:()=>s(e),disabled:o.status===`loading`,className:`h-7 text-[10px]`,children:[o.status===`loading`?(0,x.jsx)(n,{className:`size-3 animate-spin`}):(0,x.jsx)(r,{className:`size-3`}),o.status===`loading`?`Researching…`:`Deep dive`]})]}),o.status===`error`&&o.error&&(0,x.jsx)(`p`,{role:`alert`,className:`mb-1.5 text-[10px] text-destructive`,children:o.error}),t.length===0?(0,x.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:`Nothing flagged. Run a deep dive to have the model research this package against the web.`}):(0,x.jsx)(`div`,{className:`flex flex-col gap-1.5`,children:t.map(e=>(0,x.jsxs)(`div`,{className:`border border-border/70 bg-card/40 p-2`,children:[(0,x.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[(0,x.jsx)(N,{className:E[e.severity].badge,children:E[e.severity].label}),(0,x.jsx)(N,{className:`border-border/70 bg-muted text-muted-foreground`,children:D[e.action]??e.action}),M(e)&&(0,x.jsxs)(N,{className:`border-info/35 bg-info/10 text-info`,children:[(0,x.jsx)(r,{className:`size-2.5`}),`AI · `,Math.round(e.confidence*100),`%`]})]}),(0,x.jsx)(`p`,{className:`mt-1 text-[11px] leading-relaxed text-muted-foreground`,children:e.rationale}),e.breakingRisk&&(0,x.jsx)(`p`,{className:`mt-1 border-l-2 border-warning/40 pl-2 text-[10px] leading-relaxed text-warning`,children:e.breakingRisk})]},e.id))})]}),(0,x.jsxs)(`section`,{className:`mt-4`,children:[(0,x.jsx)(`h3`,{className:`mb-1.5 text-[9px] font-bold uppercase tracking-[0.16em] text-muted-foreground`,children:`Evidence`}),e.evidence.length===0?(0,x.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:`No evidence recorded.`}):(0,x.jsx)(`ul`,{className:`flex flex-col gap-1`,children:e.evidence.map((t,n)=>(0,x.jsxs)(`li`,{className:`border border-border/70 bg-card/40 p-2`,children:[(0,x.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[(0,x.jsx)(N,{className:`border-border/70 bg-muted text-muted-foreground`,children:t.kind}),(0,x.jsx)(`span`,{className:`font-mono text-[9px] text-muted-foreground`,children:new Date(t.retrievedAt).toLocaleString()})]}),t.source.startsWith(`http`)?(0,x.jsxs)(`a`,{href:t.source,target:`_blank`,rel:`noreferrer noopener`,className:`mt-1 flex min-w-0 items-center gap-1 truncate text-[10px] text-info underline-offset-2 hover:underline`,children:[(0,x.jsx)(`span`,{className:`truncate`,children:t.source}),(0,x.jsx)(a,{className:`size-2.5 shrink-0`})]}):(0,x.jsx)(`p`,{className:`mt-1 truncate font-mono text-[10px] text-muted-foreground`,children:t.source}),t.detail&&(0,x.jsx)(`p`,{className:`mt-0.5 text-[10px] leading-relaxed text-muted-foreground`,children:t.detail})]},`${e.id}-evidence-${n}`))})]})]})]})}function F({label:e,value:t,mono:n}){return(0,x.jsxs)(`div`,{className:`bg-card/55 px-2.5 py-1.5`,children:[(0,x.jsx)(`dt`,{className:`text-[9px] font-bold uppercase tracking-[0.14em] text-muted-foreground`,children:e}),(0,x.jsx)(`dd`,{className:m(`mt-0.5 truncate text-[11px] text-foreground`,n&&`font-mono`),children:t})]})}var I=`grid grid-cols-[minmax(0,2.2fr)_minmax(0,1.6fr)_minmax(0,1.1fr)] gap-2`;function ne({dependencies:e,selectedId:t,hasDependencies:n,onSelect:r}){let i=y(e,30);return e.length===0?(0,x.jsx)(`div`,{className:`flex flex-1 items-center justify-center p-8 text-center`,children:(0,x.jsx)(`p`,{className:`max-w-xs text-xs text-muted-foreground`,children:n?`No dependencies match the current filters.`:`No dependencies inventoried yet. Run a scan to populate the inventory.`})}):(0,x.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,x.jsxs)(`div`,{className:m(I,`shrink-0 border-b border-border/70 bg-card/45 px-3 py-1.5 text-[9px] font-bold uppercase tracking-[0.14em] text-muted-foreground`),children:[(0,x.jsx)(`span`,{children:`Package`}),(0,x.jsx)(`span`,{children:`Installed → Latest`}),(0,x.jsx)(`span`,{children:`Status`})]}),(0,x.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,x.jsx)(s,{className:`h-full`,"aria-label":`Dependencies`,children:i.pageItems.map(e=>(0,x.jsx)(L,{dependency:e,selected:e.id===t,onSelect:r},e.id))})}),(0,x.jsx)(g,{page:i.page,pageSize:i.pageSize,totalItems:i.totalItems,onPageChange:i.setPage,itemLabel:`dependencies`})]})}function L({dependency:e,selected:t,onSelect:n}){let r=w(e.status),i=j(e),a=A(e);return(0,x.jsxs)(`button`,{type:`button`,onClick:()=>n(e),"aria-current":t,className:m(I,`w-full items-center border-b border-border/40 px-3 py-2 text-left transition-colors hover:bg-accent/40`,t&&`bg-accent/60`),children:[(0,x.jsxs)(`div`,{className:`min-w-0`,children:[(0,x.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,x.jsx)(`span`,{className:m(`size-1.5 shrink-0`,r.dot),"aria-hidden":`true`}),(0,x.jsx)(`span`,{className:`truncate font-mono text-xs text-foreground`,children:e.name})]}),(0,x.jsxs)(`p`,{className:`mt-0.5 truncate text-[10px] text-muted-foreground`,children:[e.ecosystem,` · `,e.direct?`direct`:`transitive`,` · `,e.scope]})]}),(0,x.jsxs)(`div`,{className:`min-w-0`,children:[(0,x.jsxs)(`div`,{className:`flex min-w-0 items-baseline gap-1.5 font-mono text-[11px]`,children:[(0,x.jsx)(`span`,{className:`truncate text-foreground`,children:i??`—`}),e.latestStable&&e.latestStable!==i&&(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(`span`,{className:`shrink-0 text-muted-foreground`,children:`→`}),(0,x.jsx)(`span`,{className:`truncate text-info`,children:e.latestStable})]})]}),a.label?(0,x.jsx)(`p`,{className:`mt-0.5 truncate text-[10px] text-warning`,children:a.label}):e.requested&&(0,x.jsx)(`p`,{className:`mt-0.5 truncate font-mono text-[10px] text-muted-foreground`,children:e.requested})]}),(0,x.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-1`,children:[(0,x.jsx)(N,{className:r.badge,children:r.label}),e.deprecated&&(0,x.jsx)(N,{className:`border-destructive/35 bg-destructive/10 text-destructive`,children:`dep`}),e.yanked&&(0,x.jsx)(N,{className:`border-destructive/45 bg-destructive/15 text-destructive`,children:`yank`})]})]})}function re({findings:e,dependenciesById:t,onSelectDependency:n}){let r=y(e,20);return e.length===0?(0,x.jsx)(`div`,{className:`flex flex-1 items-center justify-center p-8 text-center`,children:(0,x.jsxs)(`p`,{className:`max-w-sm text-xs text-muted-foreground`,children:[`No findings. Run `,(0,x.jsx)(`span`,{className:`font-mono text-foreground`,children:`Analyze`}),` to check versions and advisories against upstream registries, then interpret the results.`]})}):(0,x.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,x.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto p-3`,children:(0,x.jsx)(`div`,{className:`flex flex-col gap-4`,children:T.map(e=>[e,r.pageItems.filter(t=>t.severity===e)]).filter(([,e])=>e.length>0).map(([e,r])=>(0,x.jsxs)(`section`,{children:[(0,x.jsxs)(`div`,{className:`mb-1.5 flex items-center gap-2`,children:[(0,x.jsx)(N,{className:E[e].badge,children:E[e].label}),(0,x.jsx)(`span`,{className:`font-mono text-[10px] tabular-nums text-muted-foreground`,children:r.length})]}),(0,x.jsx)(`div`,{className:`flex flex-col gap-1.5`,children:r.map(e=>(0,x.jsx)(R,{finding:e,dependency:t.get(e.dependencyId),onSelectDependency:n},e.id))})]},e))})}),(0,x.jsx)(g,{page:r.page,pageSize:r.pageSize,totalItems:r.totalItems,onPageChange:r.setPage,itemLabel:`findings`})]})}function R({finding:e,dependency:t,onSelectDependency:n}){let i=M(e);return(0,x.jsxs)(`div`,{className:`border border-border/70 bg-card/40 p-2.5`,children:[(0,x.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[(0,x.jsx)(`button`,{type:`button`,onClick:()=>n(e.dependencyId),className:`min-w-0 truncate font-mono text-xs text-foreground underline-offset-2 hover:underline`,children:t?.name??e.dependencyId}),(0,x.jsx)(N,{className:`border-border/70 bg-muted text-muted-foreground`,children:D[e.action]??e.action}),i&&(0,x.jsxs)(N,{className:`border-info/35 bg-info/10 text-info`,children:[(0,x.jsx)(r,{className:`size-2.5`}),`AI · `,Math.round(e.confidence*100),`%`]})]}),(0,x.jsx)(`p`,{className:`mt-1.5 text-[11px] leading-relaxed text-muted-foreground`,children:e.rationale}),e.breakingRisk&&(0,x.jsx)(`p`,{className:`mt-1 border-l-2 border-warning/40 pl-2 text-[10px] leading-relaxed text-warning`,children:e.breakingRisk}),e.evidence.length>0&&(0,x.jsx)(`ul`,{className:m(`mt-1.5 flex flex-col gap-0.5`),children:e.evidence.slice(0,4).map((t,n)=>(0,x.jsx)(`li`,{className:`min-w-0 truncate text-[10px]`,children:t.source.startsWith(`http`)?(0,x.jsx)(`a`,{href:t.source,target:`_blank`,rel:`noreferrer noopener`,className:`text-info underline-offset-2 hover:underline`,children:t.detail??t.source}):(0,x.jsx)(`span`,{className:`text-muted-foreground`,children:t.detail??t.source})},`${e.id}-${n}`))})]})}function ie({searchQuery:e,ecosystemFilter:t,statusFilter:n,directOnly:r,sort:i,hasFilters:a,ecosystems:o,statuses:s,visibleCount:l,totalCount:f,onSearchChange:p,onEcosystemFilterChange:h,onStatusFilterChange:g,onToggleDirectOnly:y,onSortChange:b,onClearFilters:S}){return(0,x.jsxs)(`div`,{className:`shrink-0 space-y-2 border-b border-border/70 bg-card/45 p-3`,children:[(0,x.jsxs)(`div`,{className:`flex gap-2`,children:[(0,x.jsxs)(`div`,{className:`relative min-w-0 flex-1`,children:[(0,x.jsx)(d,{className:`pointer-events-none absolute left-3 top-1/2 size-3.5 -translate-y-1/2 text-muted-foreground`}),(0,x.jsx)(v,{"aria-label":`Search dependencies`,value:e,onChange:e=>p(e.target.value),placeholder:`Search by package name…`,className:`h-10 min-w-0 bg-background pl-9 pr-8 text-xs`}),e&&(0,x.jsx)(`button`,{type:`button`,"aria-label":`Clear search`,onClick:()=>p(``),className:`absolute right-2 top-1/2 -translate-y-1/2 p-1 text-muted-foreground hover:text-foreground`,children:(0,x.jsx)(u,{className:`size-3.5`})})]}),(0,x.jsx)(_,{variant:r?`default`:`outline`,size:`sm`,onClick:y,"aria-pressed":r,title:`Show only dependencies this project declares itself`,className:`shrink-0`,children:`Direct only`}),a&&(0,x.jsx)(_,{variant:`ghost`,size:`icon`,onClick:S,"aria-label":`Clear all filters`,title:`Clear all filters`,className:`shrink-0`,children:(0,x.jsx)(c,{className:`size-4`})})]}),(0,x.jsxs)(`div`,{className:`grid gap-2 sm:grid-cols-3`,children:[(0,x.jsxs)(`div`,{children:[(0,x.jsx)(`label`,{className:`sr-only`,htmlFor:`techstack-ecosystem-filter`,children:`Filter by ecosystem`}),(0,x.jsxs)(`select`,{id:`techstack-ecosystem-filter`,value:t,onChange:e=>h(e.target.value),className:`h-9 w-full min-w-0 border border-input bg-background px-2 text-xs`,children:[(0,x.jsx)(`option`,{value:`all`,children:`All ecosystems`}),o.map(([e,t])=>(0,x.jsxs)(`option`,{value:e,children:[e,` · `,t]},e))]})]}),(0,x.jsxs)(`div`,{children:[(0,x.jsx)(`label`,{className:`sr-only`,htmlFor:`techstack-status-filter`,children:`Filter by status`}),(0,x.jsxs)(`select`,{id:`techstack-status-filter`,value:n,onChange:e=>g(e.target.value),className:`h-9 w-full min-w-0 border border-input bg-background px-2 text-xs`,children:[(0,x.jsx)(`option`,{value:`all`,children:`All statuses`}),s.map(([e,t])=>(0,x.jsxs)(`option`,{value:e,children:[w(e).label,` · `,t]},e))]})]}),(0,x.jsxs)(`div`,{children:[(0,x.jsx)(`label`,{className:`sr-only`,htmlFor:`techstack-sort`,children:`Sort dependencies`}),(0,x.jsxs)(`select`,{id:`techstack-sort`,value:i,onChange:e=>b(e.target.value),className:`h-9 w-full min-w-0 border border-input bg-background px-2 text-xs`,children:[(0,x.jsx)(`option`,{value:`attention`,children:`Sort: needs attention`}),(0,x.jsx)(`option`,{value:`drift`,children:`Sort: most out of date`}),(0,x.jsx)(`option`,{value:`name`,children:`Sort: name`})]})]})]}),(0,x.jsx)(`p`,{className:m(`text-[10px] text-muted-foreground`,a&&`text-info`),children:l===f?`${f} dependencies`:`${l} of ${f} dependencies`})]})}var z=[{id:`dependencies`,label:`Dependencies`},{id:`findings`,label:`Findings`},{id:`workspaces`,label:`Workspaces`}];function B(){let e=h(e=>e.snapshot),t=h(e=>e.stale),i=h(e=>e.loading),a=h(e=>e.error),s=h(e=>e.activeJob),[c,l]=(0,b.useState)(`dependencies`),[d,p]=(0,b.useState)(``),[g,v]=(0,b.useState)(`all`),[y,S]=(0,b.useState)(`all`),[C,T]=(0,b.useState)(!1),[E,D]=(0,b.useState)(`attention`),[O,k]=(0,b.useState)(null),[j,M]=(0,b.useState)([]),[N,F]=(0,b.useState)({status:`idle`,error:null}),I=(0,b.useCallback)(async()=>{let e=h.getState();e.setLoading(!0),e.setError(null);try{let t=await fetch(`/api/techstack/snapshot`);if(t.status===404){e.setSnapshot(null,!1);return}if(!t.ok)throw Error(`HTTP ${t.status}: ${t.statusText}`);let n=await t.json();e.setSnapshot(n.snapshot,n.stale)}catch(t){e.setError(t instanceof Error?t.message:String(t))}},[]),L=(0,b.useCallback)(async e=>{let t=h.getState();t.setLoading(!0),t.setError(null);try{let n=await fetch(`/api/techstack/${e}`,{method:`POST`}),r=await n.json();if(!n.ok||!r.jobId)throw Error(r.error??`HTTP ${n.status}: ${n.statusText}`);t.jobStarted(r.jobId,e)}catch(e){t.setError(e instanceof Error?e.message:String(e))}},[]),R=(0,b.useCallback)(async()=>{let e=h.getState().activeJob;if(e)try{let t=await fetch(`/api/techstack/jobs/${encodeURIComponent(e.id)}/cancel`,{method:`POST`});if(!t.ok)throw Error(`HTTP ${t.status}: ${t.statusText}`);h.getState().jobCancelled(e.id)}catch(e){h.getState().setError(e instanceof Error?e.message:String(e))}},[]),B=(0,b.useCallback)(async e=>{F({status:`loading`,error:null});try{let t=await fetch(`/api/techstack/deps/${encodeURIComponent(e.id)}/research`,{method:`POST`}),n=await t.json();if(!t.ok)throw Error(n.error??`HTTP ${t.status}`);M(n.findings??[]),F({status:`idle`,error:null})}catch(e){F({status:`error`,error:e instanceof Error?e.message:String(e)})}},[]);(0,b.useEffect)(()=>{I()},[I]),(0,b.useEffect)(()=>{M([]),F({status:`idle`,error:null})},[e?.id]);let K=(0,b.useMemo)(()=>e?.dependencies??[],[e]),q=(0,b.useMemo)(()=>e?.findings??[],[e]),J=(0,b.useMemo)(()=>new Map(K.map(e=>[e.id,e])),[K]),ae=(0,b.useMemo)(()=>W(K.map(e=>e.ecosystem)),[K]),oe=(0,b.useMemo)(()=>W(K.map(e=>e.status)),[K]),Y=(0,b.useMemo)(()=>{let e=d.trim().toLowerCase(),t=[...K.filter(t=>!(e&&!t.name.toLowerCase().includes(e)||g!==`all`&&t.ecosystem!==g||y!==`all`&&t.status!==y||C&&!t.direct))];return E===`name`?t.sort((e,t)=>e.name.localeCompare(t.name)):E===`drift`?t.sort((e,t)=>A(t).majorsBehind-A(e).majorsBehind||e.name.localeCompare(t.name)):t.sort((e,t)=>w(t.status).weight-w(e.status).weight||Number(t.direct)-Number(e.direct)||e.name.localeCompare(t.name)),t},[K,d,g,y,C,E]),X=O?J.get(O):void 0,se=(0,b.useMemo)(()=>X?[...q.filter(e=>e.dependencyId===X.id),...j.filter(e=>e.dependencyId===X.id)]:[],[q,j,X]),ce=(0,b.useMemo)(()=>K.filter(ee).length,[K]),Z=(0,b.useMemo)(()=>K.filter(e=>A(e).majorsBehind>0).length,[K]),Q=(0,b.useMemo)(()=>K.filter(e=>e.status===`vulnerable`).length,[K]),le=d.trim()!==``||g!==`all`||y!==`all`||C,ue=(0,b.useCallback)(()=>{p(``),v(`all`),S(`all`),T(!1)},[]),$=!!(s&&![`completed`,`failed`,`cancelled`].includes(s.status)),de=(0,b.useCallback)(e=>{k(e),l(`dependencies`)},[]);return(0,x.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col`,children:[(0,x.jsx)(`header`,{className:`shrink-0 border-b border-border/70 px-4 py-3`,children:(0,x.jsxs)(`div`,{className:`flex flex-wrap items-start gap-3`,children:[(0,x.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,x.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,x.jsx)(`h1`,{className:`text-base font-bold sm:text-lg`,children:`TechStack`}),(0,x.jsx)(`span`,{className:`border border-info/35 bg-info/10 px-2 py-0.5 font-mono text-[9px] font-bold uppercase text-info`,children:e?`${e.workspaces.length} workspaces`:`no scan yet`}),t&&(0,x.jsx)(`span`,{className:`border border-warning/35 bg-warning/10 px-2 py-0.5 font-mono text-[9px] font-bold uppercase text-warning`,children:`stale >24h`})]}),(0,x.jsx)(`p`,{className:`mt-0.5 truncate text-[10px] text-muted-foreground sm:text-xs`,children:e?`${e.targetRoot} · scanned ${new Date(e.createdAt).toLocaleString()}`:`Scan the open project to inventory its dependencies.`})]}),(0,x.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,x.jsxs)(_,{variant:`outline`,size:`sm`,onClick:()=>void L(`inventory`),disabled:$,title:`Offline: re-read manifests and lockfiles`,children:[(0,x.jsx)(f,{className:m(`size-3.5`,$&&`animate-spin`)}),(0,x.jsx)(`span`,{className:`hidden sm:inline`,children:`Refresh`})]}),(0,x.jsxs)(_,{size:`sm`,onClick:()=>void L(`analyze`),disabled:$,title:`Check registries and advisories, then interpret the results with the model`,children:[(0,x.jsx)(r,{className:`size-3.5`}),`Analyze`]}),$&&(0,x.jsx)(_,{variant:`ghost`,size:`icon`,onClick:()=>void R(),"aria-label":`Cancel job`,children:(0,x.jsx)(u,{className:`size-4`})}),(0,x.jsx)(_,{variant:`ghost`,size:`icon`,onClick:()=>e&&G(e),disabled:!e,"aria-label":`Export snapshot as JSON`,title:`Export snapshot as JSON`,children:(0,x.jsx)(o,{className:`size-4`})})]})]})}),e&&(0,x.jsxs)(`div`,{className:`grid shrink-0 grid-cols-2 gap-px border-b border-border/70 bg-border/60 sm:grid-cols-4`,children:[(0,x.jsx)(P,{label:`Dependencies`,value:K.length,hint:`${Y.length} visible`}),(0,x.jsx)(P,{label:`Outdated`,value:Z,hint:`majors behind`,tone:Z>0?`warning`:`success`}),(0,x.jsx)(P,{label:`Vulnerable`,value:Q,hint:`known advisories`,tone:Q>0?`destructive`:`success`}),(0,x.jsx)(P,{label:`Findings`,value:q.length,hint:`${ce} need attention`,tone:q.length>0?`info`:`default`})]}),($||a)&&(0,x.jsxs)(`div`,{className:`shrink-0 border-b border-border/70 px-4 py-2`,"aria-live":`polite`,children:[$&&s&&(0,x.jsxs)(`div`,{role:`status`,className:`flex items-center gap-2 text-xs text-info`,children:[(0,x.jsx)(n,{className:`size-3.5 animate-spin`}),(0,x.jsx)(`span`,{className:`font-mono`,children:s.status}),s.progress&&(0,x.jsxs)(`span`,{className:`text-muted-foreground`,children:[s.progress.completed,`/`,s.progress.total]})]}),a&&(0,x.jsxs)(`div`,{role:`alert`,className:`flex items-center gap-2 text-xs text-destructive`,children:[(0,x.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:a}),(0,x.jsx)(`button`,{type:`button`,onClick:()=>void I(),className:`underline`,children:`Retry`})]})]}),i&&!e?(0,x.jsx)(H,{}):e?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(`nav`,{className:`flex shrink-0 gap-1 border-b border-border/70 px-2`,children:z.map(e=>(0,x.jsxs)(`button`,{type:`button`,onClick:()=>l(e.id),"aria-current":c===e.id,className:m(`border-b-2 px-3 py-2 text-xs font-medium transition-colors`,c===e.id?`border-primary text-foreground`:`border-transparent text-muted-foreground hover:text-foreground`),children:[e.label,e.id===`findings`&&q.length>0&&(0,x.jsx)(`span`,{className:`ml-1.5 font-mono text-[10px] tabular-nums text-muted-foreground`,children:q.length})]},e.id))}),c===`dependencies`&&(0,x.jsxs)(`div`,{className:`grid min-h-0 flex-1 md:grid-cols-[minmax(340px,1fr)_minmax(0,1.15fr)]`,children:[(0,x.jsxs)(`section`,{className:m(`min-h-0 border-r border-border/70`,X?`hidden md:flex md:flex-col`:`flex flex-col`),"aria-label":`Dependency list`,children:[(0,x.jsx)(ie,{searchQuery:d,ecosystemFilter:g,statusFilter:y,directOnly:C,sort:E,hasFilters:le,ecosystems:ae,statuses:oe,visibleCount:Y.length,totalCount:K.length,onSearchChange:p,onEcosystemFilterChange:v,onStatusFilterChange:S,onToggleDirectOnly:()=>T(e=>!e),onSortChange:D,onClearFilters:ue}),(0,x.jsx)(ne,{dependencies:Y,selectedId:O,hasDependencies:K.length>0,onSelect:e=>k(e.id)})]}),(0,x.jsx)(`section`,{className:m(`min-h-0`,X?`flex flex-col`:`hidden md:flex md:flex-col`),"aria-label":`Dependency detail`,children:X?(0,x.jsx)(te,{dependency:X,findings:se,deepDive:N,onDeepDive:B,onBack:()=>k(null)}):(0,x.jsx)(`div`,{className:`flex flex-1 items-center justify-center p-8 text-center`,children:(0,x.jsx)(`p`,{className:`max-w-xs text-xs text-muted-foreground`,children:`Select a dependency to see its versions, evidence, and findings.`})})})]}),c===`findings`&&(0,x.jsx)(re,{findings:q,dependenciesById:J,onSelectDependency:de}),c===`workspaces`&&(0,x.jsx)(V,{snapshot:e})]}):(0,x.jsx)(U,{onScan:()=>void L(`inventory`),disabled:$})]})}function V({snapshot:e}){let t=(0,b.useMemo)(()=>{let t=new Map;for(let n of e.dependencies)t.set(n.workspaceId,(t.get(n.workspaceId)??0)+1);return t},[e]),n=y(e.workspaces,12);return e.workspaces.length===0?(0,x.jsx)(`div`,{className:`flex flex-1 items-center justify-center p-8`,children:(0,x.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`No workspaces detected.`})}):(0,x.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-auto p-3`,children:[(0,x.jsx)(`div`,{className:`flex flex-col gap-1.5`,children:n.pageItems.map(e=>{let n=O[e.coverage];return(0,x.jsxs)(`div`,{className:`border border-border/70 bg-card/40 p-2.5`,children:[(0,x.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,x.jsxs)(`div`,{className:`min-w-0`,children:[(0,x.jsx)(`p`,{className:`truncate font-mono text-xs text-foreground`,children:e.relativeRoot}),(0,x.jsxs)(`p`,{className:`mt-0.5 truncate text-[10px] text-muted-foreground`,children:[e.ecosystem,e.packageManager?` · ${e.packageManager}`:``,` · ${t.get(e.id)??0} deps`]})]}),(0,x.jsx)(`span`,{className:m(`shrink-0 border px-1.5 py-0.5 text-[10px] font-medium`,n.badge),children:n.label})]}),e.manifests.length>0&&(0,x.jsx)(`div`,{className:`mt-1.5 flex flex-wrap gap-1`,children:e.manifests.map(e=>(0,x.jsx)(`span`,{className:`border border-border/70 bg-background/45 px-1.5 py-0.5 font-mono text-[9px] text-muted-foreground`,children:e.split(/[/\\]/).pop()},e))})]},e.id)})}),(0,x.jsx)(g,{page:n.page,pageSize:n.pageSize,totalItems:n.totalItems,onPageChange:n.setPage,className:`mt-3`,itemLabel:`workspaces`})]})}function H(){return(0,x.jsx)(`div`,{className:`flex flex-1 items-center justify-center`,children:(0,x.jsxs)(`div`,{className:`flex flex-col items-center gap-2`,children:[(0,x.jsx)(n,{className:`size-5 animate-spin text-muted-foreground`}),(0,x.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Loading snapshot…`})]})})}function U({onScan:e,disabled:n}){return(0,x.jsx)(`div`,{className:`flex flex-1 items-center justify-center p-8`,children:(0,x.jsxs)(`div`,{className:`flex max-w-md flex-col items-center gap-3 text-center`,children:[(0,x.jsx)(`div`,{className:`flex size-14 items-center justify-center border border-info/25 bg-info/5 text-info`,children:(0,x.jsx)(t,{className:`size-6`})}),(0,x.jsx)(`h2`,{className:`text-sm font-semibold`,children:`No inventory yet`}),(0,x.jsx)(`p`,{className:`text-xs leading-relaxed text-muted-foreground`,children:`TechStack reads every manifest and lockfile in the open project — npm, Python, Rust, Go, .NET, PHP, Dart, Maven, Ruby, Elixir — and compares what you have against the upstream registries.`}),(0,x.jsxs)(_,{size:`sm`,onClick:e,disabled:n,children:[(0,x.jsx)(f,{className:m(`size-3.5`,n&&`animate-spin`)}),`Scan this project`]})]})})}function W(e){let t=new Map;for(let n of e)t.set(n,(t.get(n)??0)+1);return[...t.entries()].sort((e,t)=>t[1]-e[1]||e[0].localeCompare(t[0]))}function G(e){let t=new Blob([JSON.stringify(e,null,2)],{type:`application/json`}),n=URL.createObjectURL(t),r=document.createElement(`a`);r.href=n,r.download=`techstack.json`,r.click(),URL.revokeObjectURL(n)}export{B as TechStackView};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{$t as t,Ct as n,Nt as r,Zi as i,cn as a,ea as o,na as s,ot as c,tt as l}from"./vendor-BsMARlcy.js";import"./i18n-VQ8IAWEk.js";import{n as u}from"./ui-store-D_s-_3Y6.js";import{t as d}from"./ws-client-fBMR5Zg-.js";import{n as f,t as p}from"./utils-Ca0_D_-X.js";import{t as m}from"./session-store-BZ4TsTBa.js";import{C as h}from"./stores-j4CUJPI1.js";import{n as g,t as _}from"./xterm-DUBp1lnG.js";var v=e(s(),1),y=`wrongstack.terminalDockHeight`;function b(e){let t=typeof window>`u`?640:Math.max(140,Math.min(640,Math.floor(window.innerHeight*.55),window.innerHeight-260));return Math.min(Math.max(Math.round(e),140),t)}var x=l(),S={background:`#1e1e2e`,foreground:`#cdd6f4`,cursor:`#f5e0dc`,selectionBackground:`#585b70`,black:`#45475a`,red:`#f38ba8`,green:`#a6e3a1`,yellow:`#f9e2af`,blue:`#89b4fa`,magenta:`#f5c2e7`,cyan:`#94e2d5`,white:`#bac2de`,brightBlack:`#585b70`,brightRed:`#f38ba8`,brightGreen:`#a6e3a1`,brightYellow:`#f9e2af`,brightBlue:`#89b4fa`,brightMagenta:`#f5c2e7`,brightCyan:`#94e2d5`,brightWhite:`#a6adc8`},C=8;function w(e=!1){return typeof window>`u`?300:b(window.innerHeight*(e?.32:.4))}function T(e=!1){if(typeof window>`u`)return w(e);try{let t=window.localStorage.getItem(y),n=t?Number.parseInt(t,10):NaN;return Number.isFinite(n)?b(n):w(e)}catch{return w(e)}}function E(e){try{window.localStorage.setItem(y,String(b(e)))}catch{}}function D(){return f()}function O(e){return{id:D(),name:`Terminal ${e}`,status:`starting`}}function k({desktopShell:e=!1,onClose:o}){let s=(0,v.useRef)(null),{t:l}=i(),d=(0,v.useRef)(1),[f,h]=(0,v.useState)(()=>T(e)),[g,_]=(0,v.useState)(()=>[O(1)]),[y,S]=(0,v.useState)(()=>g[0]?.id??``),w=u(e=>e.terminalCreateNonce),k=(0,v.useRef)(w),j=m(e=>e.projectName),M=m(e=>e.cwd);(0,v.useEffect)(()=>{let e=()=>{h(e=>{let t=b(e);return E(t),t})};return window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[]);let N=e=>{e.preventDefault(),s.current?.();let t=e.clientY,n=f,r=document.body.style.cursor,i=document.body.style.userSelect;document.body.style.cursor=`ns-resize`,document.body.style.userSelect=`none`;let a=e=>{let r=b(n+t-e.clientY);h(r),E(r)},o=()=>{document.body.style.cursor=r,document.body.style.userSelect=i,window.removeEventListener(`pointermove`,a),window.removeEventListener(`pointerup`,o),window.removeEventListener(`pointercancel`,o),s.current===o&&(s.current=null)};s.current=o,window.addEventListener(`pointermove`,a),window.addEventListener(`pointerup`,o,{once:!0}),window.addEventListener(`pointercancel`,o,{once:!0})};(0,v.useEffect)(()=>()=>s.current?.(),[]);let P=()=>{_(e=>{if(e.length>=C)return e;d.current+=1;let t=O(d.current);return S(t.id),[...e,t]})};(0,v.useEffect)(()=>{w!==k.current&&(k.current=w,P())},[w]);let F=e=>{_(t=>{let n=t.findIndex(t=>t.id===e);if(n===-1)return t;let r=t.filter(t=>t.id!==e);return r.length===0?(queueMicrotask(o),r):(y===e&&S(r[Math.max(0,n-1)]?.id??r[0]?.id??``),r)})},I=e=>{let t=D();_(n=>{let r=!1,i=n.map(n=>n.id===e?(r=!0,{...n,id:t,status:`starting`,exitCode:void 0}):n);return r&&S(t),i})},L=()=>{_([]),S(``),queueMicrotask(o)},R=(e,t)=>{_(n=>n.map(n=>n.id===e?{...n,...t}:n))},z=g.find(e=>e.id===y)??g[0]??null;return(0,x.jsxs)(`div`,{"data-terminal-dock":!0,style:{height:f},"data-shell":e?`desktop`:`browser`,className:p(`z-30 flex min-h-0 shrink-0 flex-col border-t border-border/70 bg-card shadow-2xl`,e&&`ws-terminal-desktop`),children:[(0,x.jsx)(`hr`,{"aria-orientation":`horizontal`,tabIndex:0,title:l(`activity:terminal.resize`),onPointerDown:N,className:`h-1.5 cursor-ns-resize bg-muted/70 transition-colors hover:bg-primary/35 border-0`}),(0,x.jsxs)(`div`,{className:p(`flex min-w-0 items-center justify-between gap-3 border-b border-border/70 bg-card/85`,e?`px-2 py-1`:`px-3 py-1.5`),children:[(0,x.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 text-xs text-foreground`,children:[(0,x.jsx)(r,{className:`h-3.5 w-3.5 shrink-0 text-primary`}),(0,x.jsx)(`span`,{className:`font-medium`,children:l(e?`activity:terminal.labelSingular`:`activity:terminal.labelPlural`)}),(0,x.jsx)(`span`,{className:`min-w-0 truncate text-muted-foreground`,children:j||M||l(`activity:terminal.projectShell`)})]}),(0,x.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,x.jsx)(`button`,{type:`button`,onClick:P,disabled:g.length>=C,title:g.length>=C?l(`activity:terminal.maxTerminals`,{count:C}):l(`activity:terminal.newTerminal`),className:`inline-flex h-6 w-6 items-center justify-center rounded text-muted-foreground transition-colors hover:bg-accent hover:text-foreground disabled:cursor-not-allowed disabled:opacity-40`,children:(0,x.jsx)(a,{className:`h-4 w-4`})}),(0,x.jsx)(`button`,{type:`button`,onClick:()=>z&&I(z.id),disabled:!z,title:l(`activity:terminal.restart`),className:`inline-flex h-6 w-6 items-center justify-center rounded text-muted-foreground transition-colors hover:bg-accent hover:text-foreground disabled:cursor-not-allowed disabled:opacity-40`,children:(0,x.jsx)(t,{className:`h-3.5 w-3.5`})}),(0,x.jsx)(`button`,{type:`button`,onClick:L,disabled:g.length===0,title:l(`activity:terminal.closeAll`),className:`inline-flex h-6 w-6 items-center justify-center rounded text-muted-foreground transition-colors hover:bg-accent hover:text-foreground disabled:cursor-not-allowed disabled:opacity-40`,children:(0,x.jsx)(n,{className:`h-3.5 w-3.5`})}),(0,x.jsx)(`button`,{type:`button`,onClick:o,title:l(`activity:terminal.closeDock`),className:`inline-flex h-6 w-6 items-center justify-center rounded text-muted-foreground transition-colors hover:bg-accent hover:text-foreground`,children:(0,x.jsx)(c,{className:`h-4 w-4`})})]})]}),(0,x.jsx)(`div`,{className:p(`flex min-w-0 items-center gap-1 overflow-x-auto border-b border-border/70 bg-[hsl(var(--surface-2)/0.45)]`,e?`px-1.5 py-0.5`:`px-2 py-1`),children:g.map(t=>(0,x.jsxs)(`div`,{className:p(`group inline-flex items-center rounded border text-xs transition-colors`,e?`h-6 min-w-[92px] max-w-[148px]`:`h-7 min-w-[112px] max-w-[180px]`,y===t.id?`border-primary/35 bg-primary/10 text-primary`:`border-transparent bg-transparent text-muted-foreground hover:bg-accent hover:text-foreground`),children:[(0,x.jsxs)(`button`,{type:`button`,onClick:()=>S(t.id),title:t.status===`exited`?`${t.name} exited`:t.name,className:`inline-flex min-w-0 flex-1 items-center gap-2 px-2 text-left`,children:[(0,x.jsx)(`span`,{className:p(`h-1.5 w-1.5 shrink-0 rounded-full`,t.status===`running`&&`bg-success`,t.status===`starting`&&`bg-primary`,t.status===`exited`&&`bg-destructive`)}),(0,x.jsxs)(`span`,{className:`min-w-0 flex-1 truncate`,children:[t.name,t.status===`exited`&&typeof t.exitCode==`number`?` (${t.exitCode})`:``]})]}),(0,x.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),F(t.id)},className:`mr-1 inline-flex h-4 w-4 shrink-0 items-center justify-center rounded text-muted-foreground opacity-70 hover:bg-accent hover:text-foreground hover:opacity-100`,title:l(`activity:terminal.closeTab`,{name:t.name}),children:(0,x.jsx)(c,{className:`h-3 w-3`})})]},t.id))}),M&&!e&&(0,x.jsx)(`div`,{className:`min-w-0 truncate border-b border-border/60 bg-muted/30 px-3 py-1 text-[11px] font-mono text-muted-foreground`,children:M}),(0,x.jsx)(`div`,{className:`relative min-h-0 min-w-0 flex-1 overflow-hidden`,children:g.map(e=>(0,x.jsx)(A,{id:e.id,active:e.id===y,onRunning:()=>R(e.id,{status:`running`}),onExit:t=>R(e.id,{status:`exited`,exitCode:t})},e.id))})]})}function A({id:e,active:t,onRunning:n,onExit:r}){let i=(0,v.useRef)(null),a=(0,v.useRef)(null),s=(0,v.useRef)(null),c=(0,v.useRef)(n),l=(0,v.useRef)(r),u=h(e=>e.wsConnected);return(0,v.useEffect)(()=>{c.current=n,l.current=r},[r,n]),(0,v.useEffect)(()=>{let t=i.current;if(!t)return;let n=new _({fontFamily:`"IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace`,fontSize:13,cursorBlink:!0,theme:S,scrollback:5e3}),r=new g;a.current=n,s.current=r,n.loadAddon(r),n.open(t);try{r.fit()}catch{}let u=d(h.getState().wsUrl);u.send({type:`terminal.create`,payload:{id:e,cols:n.cols,rows:n.rows}});let f=!1,p=u.on(`terminal.output`,t=>{t.type===`terminal.output`&&t.payload.id===e&&(f||(f=!0,c.current()),n.write(t.payload.data))}),m=u.on(`terminal.exit`,t=>{t.type===`terminal.exit`&&t.payload.id===e&&(n.write(`\r\n\x1b[2m${o.t(`activity:terminal.processExited`,{code:t.payload.exitCode})}\x1b[0m\r\n`),l.current(t.payload.exitCode))}),v=n.onData(t=>{u.send({type:`terminal.input`,payload:{id:e,data:t}})}),y=new ResizeObserver(()=>{if(t.offsetParent)try{r.fit(),u.send({type:`terminal.resize`,payload:{id:e,cols:n.cols,rows:n.rows}})}catch{}});return y.observe(t),()=>{p(),m(),v.dispose(),y.disconnect(),u.send({type:`terminal.close`,payload:{id:e}}),n.dispose(),a.current=null,s.current=null}},[e,u]),(0,v.useEffect)(()=>{t&&window.requestAnimationFrame(()=>{try{s.current?.fit();let t=a.current;t&&(d(h.getState().wsUrl).send({type:`terminal.resize`,payload:{id:e,cols:t.cols,rows:t.rows}}),t.focus())}catch{}})},[t,e]),(0,x.jsx)(`div`,{ref:i,className:p(`absolute inset-0 min-h-0 min-w-0 overflow-hidden px-2 py-1`,t?`block`:`hidden`)})}export{k as TerminalPanel};
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{$t as t,Ct as n,Nt as r,Zi as i,cn as a,ea as o,na as s,ot as c,tt as l}from"./vendor-BsMARlcy.js";import"./i18n-VQ8IAWEk.js";import{n as u}from"./ui-store-D_s-_3Y6.js";import{t as d}from"./ws-client-BOKgdABR.js";import{n as f,t as p}from"./utils-Ca0_D_-X.js";import{t as m}from"./session-store-BZ4TsTBa.js";import{C as h}from"./stores-BazbaxhT.js";import{n as g,t as _}from"./xterm-DUBp1lnG.js";var v=e(s(),1),y=`wrongstack.terminalDockHeight`;function b(e){let t=typeof window>`u`?640:Math.max(140,Math.min(640,Math.floor(window.innerHeight*.55),window.innerHeight-260));return Math.min(Math.max(Math.round(e),140),t)}var x=l(),S={background:`#1e1e2e`,foreground:`#cdd6f4`,cursor:`#f5e0dc`,selectionBackground:`#585b70`,black:`#45475a`,red:`#f38ba8`,green:`#a6e3a1`,yellow:`#f9e2af`,blue:`#89b4fa`,magenta:`#f5c2e7`,cyan:`#94e2d5`,white:`#bac2de`,brightBlack:`#585b70`,brightRed:`#f38ba8`,brightGreen:`#a6e3a1`,brightYellow:`#f9e2af`,brightBlue:`#89b4fa`,brightMagenta:`#f5c2e7`,brightCyan:`#94e2d5`,brightWhite:`#a6adc8`},C=8;function w(e=!1){return typeof window>`u`?300:b(window.innerHeight*(e?.32:.4))}function T(e=!1){if(typeof window>`u`)return w(e);try{let t=window.localStorage.getItem(y),n=t?Number.parseInt(t,10):NaN;return Number.isFinite(n)?b(n):w(e)}catch{return w(e)}}function E(e){try{window.localStorage.setItem(y,String(b(e)))}catch{}}function D(){return f()}function O(e){return{id:D(),name:`Terminal ${e}`,status:`starting`}}function k({desktopShell:e=!1,onClose:o}){let s=(0,v.useRef)(null),{t:l}=i(),d=(0,v.useRef)(1),[f,h]=(0,v.useState)(()=>T(e)),[g,_]=(0,v.useState)(()=>[O(1)]),[y,S]=(0,v.useState)(()=>g[0]?.id??``),w=u(e=>e.terminalCreateNonce),k=(0,v.useRef)(w),j=m(e=>e.projectName),M=m(e=>e.cwd);(0,v.useEffect)(()=>{let e=()=>{h(e=>{let t=b(e);return E(t),t})};return window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[]);let N=e=>{e.preventDefault(),s.current?.();let t=e.clientY,n=f,r=document.body.style.cursor,i=document.body.style.userSelect;document.body.style.cursor=`ns-resize`,document.body.style.userSelect=`none`;let a=e=>{let r=b(n+t-e.clientY);h(r),E(r)},o=()=>{document.body.style.cursor=r,document.body.style.userSelect=i,window.removeEventListener(`pointermove`,a),window.removeEventListener(`pointerup`,o),window.removeEventListener(`pointercancel`,o),s.current===o&&(s.current=null)};s.current=o,window.addEventListener(`pointermove`,a),window.addEventListener(`pointerup`,o,{once:!0}),window.addEventListener(`pointercancel`,o,{once:!0})};(0,v.useEffect)(()=>()=>s.current?.(),[]);let P=()=>{_(e=>{if(e.length>=C)return e;d.current+=1;let t=O(d.current);return S(t.id),[...e,t]})};(0,v.useEffect)(()=>{w!==k.current&&(k.current=w,P())},[w]);let F=e=>{_(t=>{let n=t.findIndex(t=>t.id===e);if(n===-1)return t;let r=t.filter(t=>t.id!==e);return r.length===0?(queueMicrotask(o),r):(y===e&&S(r[Math.max(0,n-1)]?.id??r[0]?.id??``),r)})},I=e=>{let t=D();_(n=>{let r=!1,i=n.map(n=>n.id===e?(r=!0,{...n,id:t,status:`starting`,exitCode:void 0}):n);return r&&S(t),i})},L=()=>{_([]),S(``),queueMicrotask(o)},R=(e,t)=>{_(n=>n.map(n=>n.id===e?{...n,...t}:n))},z=g.find(e=>e.id===y)??g[0]??null;return(0,x.jsxs)(`div`,{"data-terminal-dock":!0,style:{height:f},"data-shell":e?`desktop`:`browser`,className:p(`z-30 flex min-h-0 shrink-0 flex-col border-t border-border/70 bg-card shadow-2xl`,e&&`ws-terminal-desktop`),children:[(0,x.jsx)(`hr`,{"aria-orientation":`horizontal`,tabIndex:0,title:l(`activity:terminal.resize`),onPointerDown:N,className:`h-1.5 cursor-ns-resize bg-muted/70 transition-colors hover:bg-primary/35 border-0`}),(0,x.jsxs)(`div`,{className:p(`flex min-w-0 items-center justify-between gap-3 border-b border-border/70 bg-card/85`,e?`px-2 py-1`:`px-3 py-1.5`),children:[(0,x.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 text-xs text-foreground`,children:[(0,x.jsx)(r,{className:`h-3.5 w-3.5 shrink-0 text-primary`}),(0,x.jsx)(`span`,{className:`font-medium`,children:l(e?`activity:terminal.labelSingular`:`activity:terminal.labelPlural`)}),(0,x.jsx)(`span`,{className:`min-w-0 truncate text-muted-foreground`,children:j||M||l(`activity:terminal.projectShell`)})]}),(0,x.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,x.jsx)(`button`,{type:`button`,onClick:P,disabled:g.length>=C,title:g.length>=C?l(`activity:terminal.maxTerminals`,{count:C}):l(`activity:terminal.newTerminal`),className:`inline-flex h-6 w-6 items-center justify-center rounded text-muted-foreground transition-colors hover:bg-accent hover:text-foreground disabled:cursor-not-allowed disabled:opacity-40`,children:(0,x.jsx)(a,{className:`h-4 w-4`})}),(0,x.jsx)(`button`,{type:`button`,onClick:()=>z&&I(z.id),disabled:!z,title:l(`activity:terminal.restart`),className:`inline-flex h-6 w-6 items-center justify-center rounded text-muted-foreground transition-colors hover:bg-accent hover:text-foreground disabled:cursor-not-allowed disabled:opacity-40`,children:(0,x.jsx)(t,{className:`h-3.5 w-3.5`})}),(0,x.jsx)(`button`,{type:`button`,onClick:L,disabled:g.length===0,title:l(`activity:terminal.closeAll`),className:`inline-flex h-6 w-6 items-center justify-center rounded text-muted-foreground transition-colors hover:bg-accent hover:text-foreground disabled:cursor-not-allowed disabled:opacity-40`,children:(0,x.jsx)(n,{className:`h-3.5 w-3.5`})}),(0,x.jsx)(`button`,{type:`button`,onClick:o,title:l(`activity:terminal.closeDock`),className:`inline-flex h-6 w-6 items-center justify-center rounded text-muted-foreground transition-colors hover:bg-accent hover:text-foreground`,children:(0,x.jsx)(c,{className:`h-4 w-4`})})]})]}),(0,x.jsx)(`div`,{className:p(`flex min-w-0 items-center gap-1 overflow-x-auto border-b border-border/70 bg-[hsl(var(--surface-2)/0.45)]`,e?`px-1.5 py-0.5`:`px-2 py-1`),children:g.map(t=>(0,x.jsxs)(`div`,{className:p(`group inline-flex items-center rounded border text-xs transition-colors`,e?`h-6 min-w-[92px] max-w-[148px]`:`h-7 min-w-[112px] max-w-[180px]`,y===t.id?`border-primary/35 bg-primary/10 text-primary`:`border-transparent bg-transparent text-muted-foreground hover:bg-accent hover:text-foreground`),children:[(0,x.jsxs)(`button`,{type:`button`,onClick:()=>S(t.id),title:t.status===`exited`?`${t.name} exited`:t.name,className:`inline-flex min-w-0 flex-1 items-center gap-2 px-2 text-left`,children:[(0,x.jsx)(`span`,{className:p(`h-1.5 w-1.5 shrink-0 rounded-full`,t.status===`running`&&`bg-success`,t.status===`starting`&&`bg-primary`,t.status===`exited`&&`bg-destructive`)}),(0,x.jsxs)(`span`,{className:`min-w-0 flex-1 truncate`,children:[t.name,t.status===`exited`&&typeof t.exitCode==`number`?` (${t.exitCode})`:``]})]}),(0,x.jsx)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),F(t.id)},className:`mr-1 inline-flex h-4 w-4 shrink-0 items-center justify-center rounded text-muted-foreground opacity-70 hover:bg-accent hover:text-foreground hover:opacity-100`,title:l(`activity:terminal.closeTab`,{name:t.name}),children:(0,x.jsx)(c,{className:`h-3 w-3`})})]},t.id))}),M&&!e&&(0,x.jsx)(`div`,{className:`min-w-0 truncate border-b border-border/60 bg-muted/30 px-3 py-1 text-[11px] font-mono text-muted-foreground`,children:M}),(0,x.jsx)(`div`,{className:`relative min-h-0 min-w-0 flex-1 overflow-hidden`,children:g.map(e=>(0,x.jsx)(A,{id:e.id,active:e.id===y,onRunning:()=>R(e.id,{status:`running`}),onExit:t=>R(e.id,{status:`exited`,exitCode:t})},e.id))})]})}function A({id:e,active:t,onRunning:n,onExit:r}){let i=(0,v.useRef)(null),a=(0,v.useRef)(null),s=(0,v.useRef)(null),c=(0,v.useRef)(n),l=(0,v.useRef)(r),u=h(e=>e.wsConnected);return(0,v.useEffect)(()=>{c.current=n,l.current=r},[r,n]),(0,v.useEffect)(()=>{let t=i.current;if(!t)return;let n=new _({fontFamily:`"IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace`,fontSize:13,cursorBlink:!0,theme:S,scrollback:5e3}),r=new g;a.current=n,s.current=r,n.loadAddon(r),n.open(t);try{r.fit()}catch{}let u=d(h.getState().wsUrl);u.send({type:`terminal.create`,payload:{id:e,cols:n.cols,rows:n.rows}});let f=!1,p=u.on(`terminal.output`,t=>{t.type===`terminal.output`&&t.payload.id===e&&(f||(f=!0,c.current()),n.write(t.payload.data))}),m=u.on(`terminal.exit`,t=>{t.type===`terminal.exit`&&t.payload.id===e&&(n.write(`\r\n\x1b[2m${o.t(`activity:terminal.processExited`,{code:t.payload.exitCode})}\x1b[0m\r\n`),l.current(t.payload.exitCode))}),v=n.onData(t=>{u.send({type:`terminal.input`,payload:{id:e,data:t}})}),y=new ResizeObserver(()=>{if(t.offsetParent)try{r.fit(),u.send({type:`terminal.resize`,payload:{id:e,cols:n.cols,rows:n.rows}})}catch{}});return y.observe(t),()=>{p(),m(),v.dispose(),y.disconnect(),u.send({type:`terminal.close`,payload:{id:e}}),n.dispose(),a.current=null,s.current=null}},[e,u]),(0,v.useEffect)(()=>{t&&window.requestAnimationFrame(()=>{try{s.current?.fit();let t=a.current;t&&(d(h.getState().wsUrl).send({type:`terminal.resize`,payload:{id:e,cols:t.cols,rows:t.rows}}),t.focus())}catch{}})},[t,e]),(0,x.jsx)(`div`,{ref:i,className:p(`absolute inset-0 min-h-0 min-w-0 overflow-hidden px-2 py-1`,t?`block`:`hidden`)})}export{k as TerminalPanel};