@wrongstack/webui 0.298.3 → 0.299.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (102) hide show
  1. package/dist/assets/{AgentRosterView-RvxaV08Y.js → AgentRosterView-BqojERFR.js} +4 -4
  2. package/dist/assets/{AnalyticsDashboard-irejsLMt.js → AnalyticsDashboard-D58kSekC.js} +1 -1
  3. package/dist/assets/{AudienceMemoryPanel-DDW_WPjf.js → AudienceMemoryPanel-Cc1UkbDl.js} +1 -1
  4. package/dist/assets/ChangesView-BKU80ANq.js +1 -0
  5. package/dist/assets/ChronicleDashboard-CvCS1Dj1.js +1 -0
  6. package/dist/assets/CodeEditor-BHZQhx_8.js +1 -0
  7. package/dist/assets/CodeMap-qllGEFLB.js +1 -0
  8. package/dist/assets/{CronJobsPanel-BXujnpGC.js → CronJobsPanel-DD5mhZ4Q.js} +1 -1
  9. package/dist/assets/{DeadCodeScanPanel-HTbGUTMl.js → DeadCodeScanPanel-PB-c8et_.js} +1 -1
  10. package/dist/assets/{DebugDashboard-B5kJBUv0.js → DebugDashboard-Q8QiVflQ.js} +1 -1
  11. package/dist/assets/{DesignGalleryView-BQ0CZpQm.js → DesignGalleryView-CGOtWO7s.js} +1 -1
  12. package/dist/assets/{GoalView-DvaSR6CO.js → GoalView-Dlk42vW7.js} +1 -1
  13. package/dist/assets/KanbanView-DIP6kKmU.js +3 -0
  14. package/dist/assets/{MailboxDetailView-Dh8ekyMw.js → MailboxDetailView-ZcKcOEAe.js} +1 -1
  15. package/dist/assets/MemoryManager-B7620q_K.js +1 -0
  16. package/dist/assets/{ModelPicker-BxYMTEEN.js → ModelPicker-DvNLZzkm.js} +1 -1
  17. package/dist/assets/OfficeMapPanel-DKJNTtOZ.js +4 -0
  18. package/dist/assets/{ProcessMonitor-DVUCtVHZ.js → ProcessMonitor-2nSk6sXA.js} +1 -1
  19. package/dist/assets/{QueuePanel-n9lScdWu.js → QueuePanel-4KBBWFxj.js} +1 -1
  20. package/dist/assets/{RefreshDebugView-eZQ3wdxU.js → RefreshDebugView-D3XnE53y.js} +1 -1
  21. package/dist/assets/RequirementIntakeView-BMxlf8bt.js +1 -0
  22. package/dist/assets/{SageTabs-B-eQ--Sb.js → SageTabs-g1hO2hJ0.js} +2 -2
  23. package/dist/assets/SddHub-Kv_TbTgT.js +2 -0
  24. package/dist/assets/SessionInspectView-PnKTvyvP.js +1 -0
  25. package/dist/assets/SessionList-BeinIC-h.js +1 -0
  26. package/dist/assets/SessionsDashboard-DEG_BylE.js +1 -0
  27. package/dist/assets/SetupScreen-DxJwZ1OZ.js +1 -0
  28. package/dist/assets/SkillDetailView-D7EQ2XtV.js +3 -0
  29. package/dist/assets/{SpecsView-BYiJr__T.js → SpecsView-Fm7pYYcj.js} +1 -1
  30. package/dist/assets/TechStackView-Bo_UenRF.js +1 -0
  31. package/dist/assets/{TerminalPanel-BgMsGfGa.js → TerminalPanel-BL9ZPGJt.js} +1 -1
  32. package/dist/assets/{Toaster-EXqX2jqp.js → Toaster-CJI70aa-.js} +1 -1
  33. package/dist/assets/{activity-DReNmuta.js → activity-BCgOEWgR.js} +2 -2
  34. package/dist/assets/{activity-Dyh19u3P.js → activity-BQ0zqkw2.js} +2 -2
  35. package/dist/assets/{activity-BJijwuIr.js → activity-CAovbq3e.js} +2 -2
  36. package/dist/assets/{activity-BBPMHCAJ.js → activity-CFQyCvgu.js} +2 -2
  37. package/dist/assets/{activity-GR8KiHvf.js → activity-CdQf7zRK.js} +2 -2
  38. package/dist/assets/{activity-iuGHFz2B.js → activity-DACvyn2-.js} +2 -2
  39. package/dist/assets/{activity-DeEOo2zu.js → activity-DOwYydU-.js} +2 -2
  40. package/dist/assets/{button-DwmC7ENW.js → button-Dcy288Mc.js} +1 -1
  41. package/dist/assets/{chat-store-LHzJqRCp.js → chat-store-CtOyUCdF.js} +2 -2
  42. package/dist/assets/{codemap-activity-store-B6n7KiS8.js → codemap-activity-store-DQfjo7-j.js} +1 -1
  43. package/dist/assets/codemap-index-store-COStDU-8.js +1 -0
  44. package/dist/assets/{dialog-DsCmc6eL.js → dialog-ftgTihmF.js} +1 -1
  45. package/dist/assets/{empty-state-02bIS4x7.js → empty-state-RRSqQaCk.js} +1 -1
  46. package/dist/assets/{i18n-DxnYsmc-.js → i18n-B0hsnanh.js} +2 -2
  47. package/dist/assets/index-DHdO0CRE.js +132 -0
  48. package/dist/assets/index-DKrFQ76m.css +1 -0
  49. package/dist/assets/{input-UhWgodVi.js → input-fo9-BPBC.js} +1 -1
  50. package/dist/assets/{mailbox-store-xh2Ux-Xs.js → mailbox-store-D8TvJsuk.js} +1 -1
  51. package/dist/assets/{progress-ring-C0O73ZjR.js → progress-ring-61A-xUEl.js} +1 -1
  52. package/dist/assets/{roster-ws-DlQQL7Eh.js → roster-ws-Dfg_187V.js} +1 -1
  53. package/dist/assets/{session-store-BE_S1f5v.js → session-store-b2KGFwkX.js} +1 -1
  54. package/dist/assets/{shared-bBntASiy.js → shared-KAzksK0C.js} +1 -1
  55. package/dist/assets/stores-BptlyD_v.js +7 -0
  56. package/dist/assets/ui-store-BsBnjO3w.js +1 -0
  57. package/dist/assets/useWebSocket-Bc4S0N4r.js +29 -0
  58. package/dist/assets/{utils-_s0GyctV.js → utils-B-9lSDIn.js} +1 -1
  59. package/dist/assets/{vendor-CxV3l5PQ.js → vendor-BuarzSSb.js} +30 -30
  60. package/dist/assets/{view-navigation-DLdE7qHU.js → view-navigation-DxfiZrXS.js} +1 -1
  61. package/dist/assets/ws-client-DqFoX4jJ.js +1 -0
  62. package/dist/components/CouncilLogTimeline.d.ts +2 -0
  63. package/dist/components/QuickModelSwitcher.filter.d.ts +9 -4
  64. package/dist/components/RequirementIntakeView.d.ts +2 -0
  65. package/dist/components/SessionInspectView.d.ts +2 -0
  66. package/dist/components/SettingsPanel/ModelCatalogPicker.d.ts +1 -2
  67. package/dist/components/SettingsPanel/brain-section-options.d.ts +16 -0
  68. package/dist/components/ViewRouter.d.ts +1 -1
  69. package/dist/hooks/useWebSocket.d.ts +1 -0
  70. package/dist/index.html +21 -21
  71. package/dist/index.js +10761 -9484
  72. package/dist/lib/view-navigation.d.ts +2 -2
  73. package/dist/lib/ws-client-actions.d.ts +1 -0
  74. package/dist/stores/council-log-store.d.ts +67 -0
  75. package/dist/stores/index.d.ts +3 -1
  76. package/dist/stores/session-inspect-store.d.ts +51 -0
  77. package/dist/stores/ui-store.d.ts +19 -7
  78. package/dist/stores/viz-store.d.ts +1 -1
  79. package/dist/types/brain.d.ts +15 -0
  80. package/dist/types/client-message.d.ts +5 -0
  81. package/dist/types/server-message.d.ts +2 -2
  82. package/dist/types/system.d.ts +35 -0
  83. package/package.json +8 -8
  84. package/dist/assets/ChangesView-Bnd167hf.js +0 -1
  85. package/dist/assets/ChronicleDashboard-DC62FDEt.js +0 -1
  86. package/dist/assets/CodeEditor-DCWcCQPO.js +0 -1
  87. package/dist/assets/CodeMap-DSqqgBuD.js +0 -1
  88. package/dist/assets/KanbanView-DpWs_i8T.js +0 -3
  89. package/dist/assets/MemoryManager-CUAbNwsz.js +0 -1
  90. package/dist/assets/OfficeMapPanel-HgERknuN.js +0 -4
  91. package/dist/assets/SddHub-D81poT6w.js +0 -2
  92. package/dist/assets/SessionsDashboard-CR3NZeHw.js +0 -1
  93. package/dist/assets/SetupScreen-t6wrhv6l.js +0 -1
  94. package/dist/assets/SkillDetailView-D6TOvMQU.js +0 -3
  95. package/dist/assets/TechStackView-HEMM3PkG.js +0 -1
  96. package/dist/assets/codemap-index-store-oapPwtvI.js +0 -1
  97. package/dist/assets/index-Bf75VrDE.js +0 -132
  98. package/dist/assets/index-NFp5CXyK.css +0 -1
  99. package/dist/assets/stores-BS-Bdi-5.js +0 -7
  100. package/dist/assets/ui-store-C4Ybfoon.js +0 -1
  101. package/dist/assets/useWebSocket-x8PMoTq8.js +0 -28
  102. package/dist/assets/ws-client-Cy3oRAmZ.js +0 -1
@@ -1 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{Cr as t,Dn as n,Fn as r,Ia as i,In as a,Ln as o,Oa as s,Pt as c,Rr as l,Sn as u,Ta as d,Vr as f,Yi as p,Zt as m,_ as h,_n as g,a as ee,aa as _,an as te,c as v,ci as y,dt as b,f as x,g as ne,h as re,i as S,jr as C,lt as w,m as ie,mr as ae,n as oe,ni as se,nr as T,p as ce,qi as E,r as le,s as D,u as ue,va as de}from"./vendor-CxV3l5PQ.js";import{t as O}from"./utils-_s0GyctV.js";import{i as fe,r as pe,t as me}from"./codemap-activity-store-B6n7KiS8.js";import{t as he}from"./codemap-index-store-oapPwtvI.js";var k=e(i(),1),A=4096,j=new Map;function M(e){let t=j.get(e);if(t!==void 0)return t;let n=e.replace(/\\/g,`/`).replace(/^\.\//,``).toLocaleLowerCase();for(;j.size>=A;){let e=j.keys().next().value;if(e===void 0)break;j.delete(e)}return j.set(e,n),n}function N(e){return e.level===`packages`?`packages`:e.level===`files`?`files:${e.package}`:`symbols:${e.file}`}function ge(e){return e.level===`packages`?`/api/codemap/packages`:e.level===`files`?`/api/codemap/files?package=${encodeURIComponent(e.package)}`:`/api/codemap/symbols?file=${encodeURIComponent(e.file)}`}function _e(e,t,n){let r=new Map(e.nodes.map(e=>[e.id,e])),i=[];for(let a of e.edges){let e=n===`incoming`?a.target===t?a.source:void 0:a.source===t?a.target:void 0;if(!e)continue;let o=r.get(e);o&&i.push({node:o,edge:a})}return i.sort((e,t)=>t.edge.weight-e.edge.weight||e.node.label.localeCompare(t.node.label))}function ve(e,t){let n=new Set([t]);for(let r of e.edges)r.source===t&&n.add(r.target),r.target===t&&n.add(r.source);return n}function ye(e,t){let n=new Map(e.nodes.map(e=>[e.id,0]));for(let r of e.edges)!t.has(r.source)||!t.has(r.target)||(n.set(r.source,(n.get(r.source)??0)+r.weight),r.target!==r.source&&n.set(r.target,(n.get(r.target)??0)+r.weight));return n}function be(e){let t=new Set(e.nodes.map(e=>e.id)),n=ye(e,t),r=new Map(e.nodes.map(e=>[e.id,0])),i=new Map;for(let n of e.edges){if(!t.has(n.source)||!t.has(n.target)||n.source===n.target)continue;r.set(n.target,(r.get(n.target)??0)+1);let e=i.get(n.source)??[];e.push(n.target),i.set(n.source,e)}let a=new Map,o=e.nodes.filter(e=>(r.get(e.id)??0)===0).sort((e,t)=>(n.get(t.id)??0)-(n.get(e.id)??0)).map(e=>e.id);o.length===0&&e.nodes[0]&&o.push(e.nodes[0].id);for(let e of o)a.set(e,0);let s=new Set,c=0;for(;c<o.length;){let e=o[c++];if(!s.has(e)){s.add(e);for(let t of i.get(e)??[])a.set(t,Math.max(a.get(t)??0,Math.min((a.get(e)??0)+1,7))),r.set(t,(r.get(t)??1)-1),(r.get(t)??0)<=0&&o.push(t)}}let l=e.nodes.filter(e=>!a.has(e.id)).sort((e,t)=>(n.get(t.id)??0)-(n.get(e.id)??0));l.forEach((e,t)=>{a.set(e.id,t%Math.min(4,Math.max(1,l.length)))});let u=new Map;for(let t of e.nodes){let e=a.get(t.id)??0,n=u.get(e)??[];n.push(t),u.set(e,n)}for(let e of u.values())e.sort((e,t)=>Number(e.external)-Number(t.external)||(n.get(t.id)??0)-(n.get(e.id)??0)||e.label.localeCompare(t.label));let d=Math.max(1,...[...u.values()].map(e=>e.length))*160,f=[];for(let[e,t]of[...u.entries()].sort(([e],[t])=>e-t)){let n=(d-t.length*160)/2;t.forEach((t,r)=>{f.push({node:t,position:{x:e*386,y:n+r*160}})})}return f}function P(e,t){if(e.nodes.length===0)return[];let n=ye(e,new Set(e.nodes.map(e=>e.id))),r=e.nodes.find(e=>e.id===t)??[...e.nodes].sort((e,t)=>(n.get(t.id)??0)-(n.get(e.id)??0))[0],i=ve(e,r.id);i.delete(r.id);let a=e.nodes.filter(e=>i.has(e.id)),o=e.nodes.filter(e=>e.id!==r.id&&!i.has(e.id)),s=[{node:r,position:{x:0,y:0}}],c=(e,t,n)=>{e.forEach((r,i)=>{let a=n+Math.PI*2*i/Math.max(1,e.length);s.push({node:r,position:{x:Math.cos(a)*t,y:Math.sin(a)*t}})})};c(a,Math.max(330,a.length*34),-Math.PI/2);for(let e=0;e<o.length;e+=18)c(o.slice(e,e+18),620+Math.floor(e/18)*280,-Math.PI/2+.12);return s}function xe(e,t,n){return t===`orbit`?P(e,n):be(e)}function Se(e,t,n){if(e.length<=n)return e;let r=t?e.filter(e=>e.source===t||e.target===t):[],i=e.filter(e=>!t||e.source!==t&&e.target!==t).sort((e,t)=>t.weight-e.weight||e.source.localeCompare(t.source)||e.target.localeCompare(t.target)),a=Math.max(0,n-r.length);return[...r,...i.slice(0,a)]}function Ce(e,t,n){if(n===`all`)return e;let r=e.nodes;if(e.nodes.length>96){let n=new Map(e.nodes.map(e=>[e.id,e])),i=new Map;for(let t of e.edges)i.set(t.source,(i.get(t.source)??0)+t.weight),i.set(t.target,(i.get(t.target)??0)+t.weight);let a=[...e.nodes].sort((e,t)=>(i.get(t.id)??0)-(i.get(e.id)??0)||e.label.localeCompare(t.label)),o=new Set,s=e=>{n.has(e)&&o.size<96&&o.add(e)};if(t&&n.has(t)){s(t);let n=e.edges.filter(e=>e.source===t||e.target===t).sort((e,t)=>t.weight-e.weight);for(let e of n)s(e.source),s(e.target);let r=new Set(o),i=e.edges.filter(e=>r.has(e.source)||r.has(e.target)).sort((e,t)=>t.weight-e.weight);for(let e of i)s(e.source),s(e.target)}else{let e=a.filter(e=>!e.external).slice(0,72),t=a.filter(e=>e.external).slice(0,24);for(let n of[...e,...t])s(n.id)}for(let e of a)s(e.id);r=e.nodes.filter(e=>o.has(e.id))}let i=new Set(r.map(e=>e.id)),a=e.edges.filter(e=>i.has(e.source)&&i.has(e.target));return{nodes:r,edges:Se(a,t,180)}}function F(e){let t=(e.file??e.label).replace(/\\/g,`/`),n=e.package??``,r=n.startsWith(`@wrongstack/`)?`/packages/${n.slice(12)}/`:n.startsWith(`app:`)?`/apps/${n.slice(4)}/`:void 0;if(r){let e=t.indexOf(r);if(e>=0)return t.slice(e+r.length)}let i=t.lastIndexOf(`/src/`);return i>=0?t.slice(i+1):t.split(`/`).slice(-3).join(`/`)}var we=new WeakMap;function Te(e){let t=we.get(e);if(t)return t;let n={name:``,path:``,directories:[],files:[]};for(let t of e.filter(e=>e.kind===`file`&&!e.external)){let e=F(t).split(`/`).filter(Boolean),r=e.pop()??t.label,i=n;for(let t of e){let e=i.path?`${i.path}/${t}`:t,n=i.directories.find(e=>e.name===t);n||(n={name:t,path:e,directories:[],files:[]},i.directories.push(n)),i=n}i.files.push({...t,label:r})}let r=e=>{e.directories.sort((e,t)=>e.name.localeCompare(t.name)),e.files.sort((e,t)=>e.label.localeCompare(t.label)),e.directories.forEach(r)};return r(n),we.set(e,n),n}function Ee(e){let t=2166136261,n=e=>{for(let n=0;n<e.length;n++)t^=e.charCodeAt(n),t=Math.imul(t,16777619)};for(let t of e.nodes)n(t.id);for(let r of e.edges)n(r.source),n(r.target),n(r.refType),t^=r.weight|0,t=Math.imul(t,16777619);return`${e.nodes.length}:${e.edges.length}:${t>>>0}`}function De(e,t,n,r){for(e.has(t)&&e.delete(t),e.set(t,n);e.size>r;){let t=e.keys().next().value;if(t===void 0)break;e.delete(t)}}function Oe(e,t){if(!e||!t)return!1;let n=M(e),r=M(t);return n===r||n.endsWith(`/${r}`)||r.endsWith(`/${n}`)}function ke(e){let t=M(e),n=t.match(/\/packages\/([^/]+)\//);if(n?.[1])return`@wrongstack/${n[1]}`;let r=t.match(/\/apps\/([^/]+)\//);return r?.[1]?`app:${r[1]}`:`(root)`}function Ae(e,t){return t.kind===`package`?ke(e.filePath)===(t.package??t.label):Oe(e.filePath,t.file)?t.kind!==`symbol`||e.symbol?.id===t.id:!1}function je(e){let t=new Map;for(let n of e){let e=M(n.filePath),r=t.get(e);r?r.push(n):t.set(e,[n])}return t}function Me(e,t){let n=new Map;if(t.length===0||e.length===0)return n;let r=je(t),i=new Map;for(let a of e){let e;if(a.kind===`package`){let n=a.package??a.label,r=i.get(n);r||(r=t.filter(e=>ke(e.filePath)===n),i.set(n,r)),e=r}else if(a.file){let t=M(a.file),n=r.get(t);if(!n){n=[];for(let[e,i]of r)(e.endsWith(`/${t}`)||t.endsWith(`/${e}`))&&n.push(...i)}e=a.kind===`symbol`?n.filter(e=>e.symbol?.id===a.id):n}else e=[];e.length>0&&n.set(a.id,e)}return n}function Ne(e){if(e.length===0)return``;let t=`${e.length}`;for(let n=0;n<e.length;n++){let r=e[n];t+=`|${r.id??``}:${r.toolUseId??``}:${r.filePath}:${r.type}:${r.status??``}:${r.symbol?.id??``}:${r.timestamp}`}return t}function Pe(e,t){let n=t.filter(t=>t.kind===`symbol`&&!t.external&&Oe(t.file,e.filePath));if(n.length===0)return;if(e.line)return[...n].sort((e,t)=>(t.line??0)-(e.line??0)).find(t=>(t.line??0)<=e.line)??n[0];let r=e.summary.toLocaleLowerCase();return n.find(e=>e.label.length>2&&(r.includes(e.label.toLocaleLowerCase())||!!(e.signature&&r.includes(e.signature.toLocaleLowerCase()))))}var I=w();function Fe({historyFile:e,fileHistory:t,onClose:n}){return(0,I.jsxs)(`div`,{className:`absolute right-0 top-0 z-50 flex h-full w-[390px] max-w-[90%] flex-col border-l bg-card shadow-2xl`,children:[(0,I.jsxs)(`div`,{className:`flex h-12 items-center justify-between border-b px-4`,children:[(0,I.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,I.jsx)(d,{className:`h-4 w-4 shrink-0 text-warning`}),(0,I.jsx)(`span`,{className:`truncate font-mono text-[11px] font-semibold`,title:e,children:e})]}),(0,I.jsx)(`button`,{type:`button`,onClick:n,className:`flex h-7 w-7 items-center justify-center border text-muted-foreground hover:bg-muted`,"aria-label":`Close activity`,children:(0,I.jsx)(b,{className:`h-3.5 w-3.5`})})]}),(0,I.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-3`,children:t.length===0?(0,I.jsx)(`p`,{className:`py-12 text-center text-[10px] text-muted-foreground`,children:`No activity recorded for this file yet.`}):t.map((e,t)=>(0,I.jsxs)(`div`,{className:`mb-1 flex items-start gap-2 border p-2 text-[10px]`,children:[(0,I.jsx)(`span`,{className:O(`border px-1.5 py-0.5 font-mono text-[8px] font-bold uppercase`,e.type===`delete`?`border-destructive/40 text-destructive`:e.type===`read`?`border-info/40 text-info`:`border-warning/40 text-warning`),children:e.type}),(0,I.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,I.jsx)(`div`,{className:`font-mono text-[9px] text-muted-foreground`,children:new Date(e.timestamp).toLocaleTimeString()}),e.toolName&&(0,I.jsxs)(`div`,{className:`mt-1`,children:[`via `,e.toolName]}),e.agent&&(0,I.jsx)(`div`,{className:`text-muted-foreground`,children:e.agent}),e.summary&&(0,I.jsx)(`div`,{className:`mt-1 text-muted-foreground`,children:e.summary}),e.change&&(0,I.jsxs)(`div`,{className:`mt-1 flex items-center gap-1 font-mono text-[8px]`,children:[(0,I.jsxs)(`span`,{className:`border border-success/40 bg-success/10 px-1 text-success`,children:[`+`,e.change.added]}),(0,I.jsxs)(`span`,{className:`border border-destructive/40 bg-destructive/10 px-1 text-destructive`,children:[`−`,e.change.removed]}),e.change.before&&(0,I.jsx)(`span`,{className:`ml-1 truncate text-destructive/80`,title:e.change.before,children:e.change.before}),e.change.after&&(0,I.jsxs)(`span`,{className:`truncate text-success/80`,title:e.change.after,children:[`→ `,e.change.after]})]}),(0,I.jsxs)(`div`,{className:`mt-1 flex gap-2 font-mono text-[8px] uppercase text-muted-foreground`,children:[(0,I.jsx)(`span`,{children:e.status??`observed`}),(0,I.jsx)(`span`,{children:e.source??`legacy`}),e.durationMs!==void 0&&(0,I.jsxs)(`span`,{children:[e.durationMs,`ms`]}),e.watcherConfirmed&&(0,I.jsx)(`span`,{className:`text-success`,children:`fs verified`})]})]})]},`${e.timestamp}-${t}`))}),(0,I.jsxs)(`div`,{className:`border-t px-4 py-2 font-mono text-[9px] text-muted-foreground`,children:[t.length,` events · newest first`]})]})}var L={package:{icon:r,accent:`border-l-primary`,iconStyle:`bg-primary/12 text-primary`},file:{icon:se,accent:`border-l-info`,iconStyle:`bg-info/12 text-info`},symbol:{icon:_,accent:`border-l-success`,iconStyle:`bg-success/12 text-success`}},Ie={call:`hsl(var(--primary))`,import:`hsl(var(--info))`,type_ref:`hsl(var(--success))`,inherit:`hsl(var(--warning))`,implement:`hsl(var(--destructive))`},Le={read:`ring-2 ring-info/60 shadow-info/20`,write:`ring-2 ring-warning/70 shadow-warning/30`,edit:`ring-2 ring-warning/80 shadow-warning/40`,delete:`ring-2 ring-destructive/70 shadow-destructive/30`,search:`ring-2 ring-primary/55 shadow-primary/20`,memory:`ring-2 ring-success/60 shadow-success/30`,index:`ring-2 ring-info/50 shadow-info/20`,execute:`ring-2 ring-primary/55 shadow-primary/25`},Re=[`bg-primary text-primary-foreground`,`bg-info text-info-foreground`,`bg-success text-success-foreground`,`bg-warning text-warning-foreground`,`bg-destructive text-destructive-foreground`];function ze(e){let t=e.trim().split(/[\s:_-]+/).filter(Boolean);return(t.length>1?`${t[0]?.[0]??``}${t[1]?.[0]??``}`:e.slice(0,2)).toLocaleUpperCase()}function R(e){let t=0;for(let n of e)t=t*31+n.charCodeAt(0)|0;return Re[Math.abs(t)%Re.length]??Re[0]}function Be(e){let t=0;for(let n of e)t=t*31+n.charCodeAt(0)|0;return`hsl(${Math.abs(t)%360} 82% 58%)`}function z(e){let t=e.replace(/\\/g,`/`),n=t.lastIndexOf(`/packages/`),r=t.lastIndexOf(`/apps/`),i=Math.max(n,r);return i>=0?t.slice(i+1):t.split(`/`).slice(-3).join(`/`)}function B(e){return[e.symbol?.name,e.line?`L${e.line}`:void 0].filter(Boolean).join(` · `)}function Ve({data:e}){let{graphNode:t,selected:n,dimmed:r,incoming:i,outgoing:a,isActive:o,activityType:s,activeOperations:c}=e,l=L[t.kind],u=l.icon,d=t.kind!==`symbol`,f=t.kind===`symbol`?`${t.symbolKind??`symbol`}${t.line?` · L${t.line}`:``}`:t.kind===`file`?F(t):`${t.fileCount??0} files · ${t.symbolCount??0} symbols`;return(0,I.jsxs)(`div`,{className:O(`group relative w-[236px] border border-l-[3px] bg-card text-card-foreground shadow-[0_8px_24px_hsl(var(--shadow-color)/0.08)] transition-[opacity,box-shadow,border-color,background-color]`,l.accent,n&&`border-primary bg-primary/5 shadow-[0_0_0_2px_hsl(var(--primary)/0.18),0_16px_36px_hsl(var(--shadow-color)/0.18)]`,t.external&&`border-dashed bg-muted/75`,r&&`opacity-25 grayscale`,o&&s&&Le[s]),children:[c.length>0&&(0,I.jsxs)(`div`,{className:`absolute -top-5 left-2 z-20 flex max-w-[210px] items-center gap-1`,children:[c.slice(0,4).map(e=>{let t=e.agentName??e.agent??`External`,n=`${e.sessionId??`none`}:${e.agentId??t}`;return(0,I.jsxs)(`span`,{className:O(`flex h-6 items-center gap-1 border-2 border-background px-1.5 font-mono text-[8px] font-bold shadow-md`,R(n)),title:`${t} · ${e.type} ${B(e)}`,children:[(0,I.jsx)(`span`,{className:`h-1.5 w-1.5 animate-pulse bg-current`}),ze(t),e.symbol&&(0,I.jsx)(`span`,{className:`max-w-[80px] truncate`,children:e.symbol.name})]},e.id??`${n}:${e.filePath}`)}),c.length>4&&(0,I.jsxs)(`span`,{className:`border bg-card px-1 font-mono text-[8px] shadow`,children:[`+`,c.length-4]})]}),(0,I.jsx)(D,{type:`target`,position:h.Left,className:`!h-2.5 !w-2.5 !border-2 !border-card !bg-muted-foreground`}),(0,I.jsxs)(`button`,{type:`button`,className:`block w-full text-left`,onClick:n=>{if(n.shiftKey&&t.file){e.onShowHistory(t.file);return}e.onSelect(t)},onDoubleClick:()=>d&&e.onOpen(t),"aria-label":`${t.kind} ${t.label}`,children:[(0,I.jsxs)(`div`,{className:`flex items-start gap-3 p-3 pr-10`,children:[(0,I.jsx)(`span`,{className:O(`flex h-8 w-8 shrink-0 items-center justify-center border`,l.iconStyle),children:(0,I.jsx)(u,{className:`h-4 w-4`})}),(0,I.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,I.jsxs)(`div`,{className:`mb-1 flex items-center gap-1.5 text-[9px] font-bold uppercase tracking-[0.18em] text-muted-foreground`,children:[(0,I.jsx)(`span`,{children:t.kind}),t.external&&(0,I.jsx)(`span`,{className:`border border-border px-1 py-0.5 text-[8px] text-warning`,children:`external`}),t.lang&&(0,I.jsx)(`span`,{className:`ml-auto font-mono normal-case tracking-normal`,children:t.lang})]}),(0,I.jsx)(`div`,{className:`truncate font-mono text-[13px] font-semibold`,title:t.label,children:t.label}),(0,I.jsx)(`div`,{className:`mt-1 truncate text-[10px] text-muted-foreground`,title:f,children:f})]})]}),(0,I.jsxs)(`div`,{className:`flex items-center gap-3 border-t bg-muted/30 px-3 py-1.5 font-mono text-[9px] text-muted-foreground`,children:[(0,I.jsxs)(`span`,{title:`Incoming relationships`,children:[`← `,i]}),(0,I.jsxs)(`span`,{title:`Outgoing relationships`,children:[`→ `,a]}),t.symbolCount!==void 0&&t.kind===`file`&&(0,I.jsxs)(`span`,{className:`ml-auto`,children:[t.symbolCount,` sym`]}),o&&(0,I.jsxs)(`span`,{className:`ml-auto flex items-center gap-1 font-bold text-warning`,children:[(0,I.jsx)(g,{className:`h-2.5 w-2.5 animate-pulse`}),` LIVE`]})]})]}),d&&(0,I.jsx)(`button`,{type:`button`,className:`absolute right-2 top-2 z-10 flex h-7 w-7 items-center justify-center border border-transparent text-muted-foreground opacity-0 transition hover:border-border hover:bg-muted hover:text-foreground group-hover:opacity-100 focus:opacity-100`,onClick:()=>e.onOpen(t),title:t.kind===`package`?`Open file map`:`Open symbol map`,"aria-label":`Open ${t.label} map`,children:(0,I.jsx)(y,{className:`h-3.5 w-3.5`})}),(0,I.jsx)(D,{type:`source`,position:h.Right,className:`!h-2.5 !w-2.5 !border-2 !border-card !bg-muted-foreground`})]})}function He(e,t){return e.length===t.length&&e.every((e,n)=>e===t[n])}function V(e,t){return e.graphNode===t.graphNode&&e.selected===t.selected&&e.dimmed===t.dimmed&&e.incoming===t.incoming&&e.outgoing===t.outgoing&&e.isActive===t.isActive&&e.activityType===t.activityType&&e.onSelect===t.onSelect&&e.onOpen===t.onOpen&&e.onShowHistory===t.onShowHistory&&He(e.activeOperations,t.activeOperations)}var Ue={codemap:(0,k.memo)(Ve,(e,t)=>V(e.data,t.data))},We={nodes:[],edges:[]};function Ge({loading:e,error:t,graph:n,canvasNodeCount:r,flowNodes:i,flowEdges:a,onNodesChange:s,onEdgesChange:c,agentTrailCount:l}){return(0,I.jsxs)(I.Fragment,{children:[e&&(0,I.jsxs)(`div`,{className:`absolute inset-0 z-20 flex flex-col items-center justify-center gap-3 bg-background/75 backdrop-blur-sm`,children:[(0,I.jsx)(T,{className:`h-7 w-7 animate-spin text-primary`}),(0,I.jsx)(`span`,{className:`font-mono text-[10px] uppercase tracking-widest text-muted-foreground`,children:`Mapping relationships`})]}),t&&!e&&(0,I.jsxs)(`div`,{className:`absolute inset-0 z-20 flex flex-col items-center justify-center gap-3 p-8 text-center`,children:[(0,I.jsx)(o,{className:`h-10 w-10 text-destructive`}),(0,I.jsx)(`p`,{className:`font-mono text-sm text-destructive`,children:t}),(0,I.jsxs)(`p`,{className:`max-w-md text-xs text-muted-foreground`,children:[`The map needs a codebase index. Run`,` `,(0,I.jsx)(`code`,{className:`border bg-muted px-1.5 py-0.5`,children:`codebase-index`}),` once, then reopen this view.`]})]}),!e&&!t&&n.nodes.length===0&&(0,I.jsxs)(`div`,{className:`absolute inset-0 flex flex-col items-center justify-center gap-2 text-muted-foreground`,children:[(0,I.jsx)(o,{className:`h-8 w-8 opacity-40`}),(0,I.jsx)(`p`,{className:`text-xs`,children:`No indexed nodes at this level.`})]}),!e&&!t&&n.nodes.length>1&&n.edges.length===0&&(0,I.jsxs)(`div`,{className:`pointer-events-none absolute left-1/2 top-14 z-10 -translate-x-1/2 border border-warning/40 bg-warning/10 px-3 py-2 text-center shadow backdrop-blur`,children:[(0,I.jsx)(`div`,{className:`font-mono text-[9px] font-bold uppercase tracking-wider text-warning`,children:`No resolved relations in this scope`}),(0,I.jsx)(`div`,{className:`mt-0.5 text-[8px] text-muted-foreground`,children:`The upgraded index will rebuild and resolve call/import/type links automatically.`})]}),!t&&n.nodes.length>0&&(0,I.jsxs)(x,{nodes:i,edges:a,onNodesChange:s,onEdgesChange:c,nodeTypes:Ue,nodesConnectable:!1,nodesDraggable:!1,edgesFocusable:!1,elementsSelectable:!1,onlyRenderVisibleElements:!0,minZoom:.08,maxZoom:2.2,proOptions:{hideAttribution:!0},children:[(0,I.jsx)(le,{variant:S.Dots,gap:r>60?32:22,size:1,color:`hsl(var(--muted-foreground))`,className:`!opacity-25`}),(0,I.jsx)(ee,{position:`bottom-left`,showInteractive:!1,className:`!border !border-border !bg-card !shadow-md [&>button]:!border-border [&>button]:!bg-card [&>button]:!fill-foreground`}),r<=48&&(0,I.jsx)(v,{position:`bottom-right`,pannable:!0,zoomable:!0,className:`!h-[112px] !w-[180px] !border !border-border !bg-card !shadow-md`,maskColor:`hsl(var(--background) / 0.72)`,nodeColor:e=>{let t=e.data?.graphNode.kind;return t===`package`?`hsl(var(--primary))`:t===`file`?`hsl(var(--info))`:`hsl(var(--success))`}})]}),(0,I.jsxs)(`div`,{className:`pointer-events-none absolute bottom-3 left-1/2 z-10 flex -translate-x-1/2 items-center gap-3 border bg-card/90 px-3 py-1.5 font-mono text-[8px] text-muted-foreground shadow backdrop-blur`,children:[Object.entries(Ie).map(([e,t])=>(0,I.jsxs)(`span`,{className:`flex items-center gap-1`,children:[(0,I.jsx)(`span`,{className:`h-0.5 w-3`,style:{backgroundColor:t}}),e.replace(`_`,` `)]},e)),(0,I.jsxs)(`span`,{className:`flex items-center gap-1 text-primary`,"data-testid":`agent-trail-count`,children:[(0,I.jsx)(`span`,{className:`w-4 border-t-2 border-dashed border-primary`}),`agent trail`,l>0?` ×${l}`:``]})]})]})}function Ke({layout:e,canvasMode:t,edgeFilter:n,canvasNodeCount:r,graphNodeCount:i,onLayoutChange:o,onCanvasModeChange:s,onEdgeFilterChange:c}){return(0,I.jsxs)(`div`,{className:`pointer-events-none absolute left-3 right-3 top-3 z-10 flex items-center gap-2`,children:[(0,I.jsxs)(`div`,{className:`pointer-events-auto flex border bg-card/95 shadow-md backdrop-blur`,children:[(0,I.jsxs)(`button`,{type:`button`,className:O(`flex h-8 items-center gap-1.5 border-r px-2.5 text-[9px] font-semibold uppercase tracking-wider`,e===`layers`?`bg-primary text-primary-foreground`:`text-muted-foreground hover:bg-muted`),onClick:()=>o(`layers`),children:[(0,I.jsx)(ae,{className:`h-3 w-3`}),` Layers`]}),(0,I.jsxs)(`button`,{type:`button`,className:O(`flex h-8 items-center gap-1.5 px-2.5 text-[9px] font-semibold uppercase tracking-wider`,e===`orbit`?`bg-primary text-primary-foreground`:`text-muted-foreground hover:bg-muted`),onClick:()=>o(`orbit`),children:[(0,I.jsx)(a,{className:`h-3 w-3`}),` Relations`]})]}),(0,I.jsxs)(`div`,{className:`pointer-events-auto flex border bg-card/95 shadow-md backdrop-blur`,children:[(0,I.jsxs)(`button`,{type:`button`,className:O(`h-8 border-r px-2.5 font-mono text-[9px] font-bold`,t===`smart`?`bg-success text-success-foreground`:`text-muted-foreground hover:bg-muted`),onClick:()=>s(`smart`),title:`Keep the full tree, show the strongest relations and selected neighbourhood`,children:[`SMART `,r,`/`,i]}),(0,I.jsx)(`button`,{type:`button`,className:O(`h-8 px-2.5 font-mono text-[9px] font-bold`,t===`all`?`bg-foreground text-background`:`text-muted-foreground hover:bg-muted`),onClick:()=>s(`all`),title:`Render every node and relation in this scope`,children:`ALL`})]}),(0,I.jsx)(`div`,{className:`pointer-events-auto ml-auto flex max-w-[60%] overflow-x-auto border bg-card/95 shadow-md backdrop-blur`,children:[`all`,`import`,`call`,`type_ref`,`inherit`,`implement`].map(e=>(0,I.jsx)(`button`,{type:`button`,className:O(`h-8 whitespace-nowrap border-r px-2.5 font-mono text-[9px] last:border-r-0`,n===e?`bg-foreground text-background`:`text-muted-foreground hover:bg-muted`),onClick:()=>c(e),children:e===`all`?`ALL LINKS`:e.replace(`_`,` `).toUpperCase()},e))})]})}function qe({scope:e,graph:n,agentPresences:r,edgeWeight:i,connectedNodeCount:a,navigate:s}){return(0,I.jsxs)(`header`,{className:`flex h-[62px] shrink-0 items-center gap-4 border-b bg-card px-4`,children:[(0,I.jsxs)(`div`,{className:`flex min-w-[220px] items-center gap-3`,children:[(0,I.jsx)(`span`,{className:`flex h-9 w-9 items-center justify-center border border-primary bg-primary/10 text-primary`,children:(0,I.jsx)(o,{className:`h-4 w-4`})}),(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`h1`,{className:`font-display text-sm font-semibold tracking-tight`,children:`Code Atlas`}),(0,I.jsx)(`p`,{className:`text-[9px] uppercase tracking-[0.18em] text-muted-foreground`,children:`Architecture intelligence`})]})]}),(0,I.jsxs)(`nav`,{className:`flex min-w-0 flex-1 items-center gap-1 font-mono text-[10px]`,"aria-label":`Code map breadcrumb`,children:[e.level!==`packages`&&(0,I.jsx)(`button`,{type:`button`,className:`mr-1 flex h-7 w-7 items-center justify-center border text-muted-foreground hover:bg-muted`,onClick:()=>{e.level===`symbols`?s({level:`files`,package:e.package??`(root)`}):s({level:`packages`})},"aria-label":`Back`,children:(0,I.jsx)(de,{className:`h-3.5 w-3.5`})}),(0,I.jsxs)(`button`,{type:`button`,className:`flex items-center gap-1.5 px-1.5 py-1 text-muted-foreground hover:text-foreground`,onClick:()=>s({level:`packages`}),children:[(0,I.jsx)(t,{className:`h-3 w-3`}),` workspace`]}),e.level!==`packages`&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(E,{className:`h-3 w-3 text-muted-foreground`}),(0,I.jsx)(`button`,{type:`button`,className:`max-w-[220px] truncate px-1.5 py-1 hover:text-primary`,onClick:()=>s({level:`files`,package:e.package??`(root)`}),children:e.package??`(root)`})]}),e.level===`symbols`&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(E,{className:`h-3 w-3 text-muted-foreground`}),(0,I.jsx)(`span`,{className:`truncate px-1.5 py-1 text-primary`,children:F({id:``,label:e.file,kind:`file`,file:e.file,package:e.package})})]})]}),(0,I.jsxs)(`div`,{className:`hidden items-center gap-5 xl:flex`,children:[(0,I.jsxs)(`div`,{className:O(`flex h-8 items-center gap-2 border px-2.5`,r.length>0?`border-success/50 bg-success/10 text-success`:`text-muted-foreground`),children:[(0,I.jsx)(g,{className:O(`h-3 w-3`,r.length>0&&`animate-pulse`)}),(0,I.jsxs)(`div`,{children:[(0,I.jsxs)(`div`,{className:`font-mono text-[10px] font-bold`,children:[r.length,` LIVE`]}),(0,I.jsx)(`div`,{className:`text-[7px] uppercase tracking-wider`,children:`agents`})]})]}),(0,I.jsxs)(`div`,{className:`text-right`,children:[(0,I.jsx)(`div`,{className:`font-mono text-sm font-semibold`,children:n.nodes.length}),(0,I.jsx)(`div`,{className:`text-[8px] uppercase tracking-wider text-muted-foreground`,children:`nodes`})]}),(0,I.jsxs)(`div`,{className:`text-right`,children:[(0,I.jsx)(`div`,{className:`font-mono text-sm font-semibold`,children:n.edges.length}),(0,I.jsx)(`div`,{className:`text-[8px] uppercase tracking-wider text-muted-foreground`,children:`links`})]}),(0,I.jsxs)(`div`,{className:`text-right`,children:[(0,I.jsx)(`div`,{className:`font-mono text-sm font-semibold`,children:i}),(0,I.jsx)(`div`,{className:`text-[8px] uppercase tracking-wider text-muted-foreground`,children:`references`})]}),(0,I.jsxs)(`div`,{className:`text-right`,children:[(0,I.jsx)(`div`,{className:`font-mono text-sm font-semibold`,children:a}),(0,I.jsx)(`div`,{className:`text-[8px] uppercase tracking-wider text-muted-foreground`,children:`connected`})]})]})]})}function H({activity:e}){return(0,I.jsx)(`span`,{className:O(`shrink-0 border px-1.5 py-0.5 font-mono text-[8px] font-bold uppercase`,e.type===`delete`?`border-destructive/50 bg-destructive/10 text-destructive`:e.type===`read`?`border-info/50 bg-info/10 text-info`:e.type===`search`||e.type===`index`?`border-primary/50 bg-primary/10 text-primary`:`border-warning/50 bg-warning/10 text-warning`),children:e.filePath.startsWith(`(tool:`)?e.toolName:e.type})}function U({activity:e,onLocate:t,showAgent:n=!1}){let r=e.agentName??e.agent??`External process`,i=`${e.sessionId??`none`}:${e.agentId??r}`;return(0,I.jsxs)(`button`,{type:`button`,className:`group flex w-full items-start gap-2 border-b px-3 py-2 text-left last:border-b-0 hover:bg-muted/70`,onClick:()=>!e.filePath.startsWith(`(`)&&t(e),title:`Locate ${e.filePath}`,children:[n&&(0,I.jsx)(`span`,{className:O(`mt-0.5 flex h-6 w-6 shrink-0 items-center justify-center font-mono text-[8px] font-black`,R(i)),children:ze(r)}),(0,I.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,I.jsx)(H,{activity:e}),n&&(0,I.jsx)(`span`,{className:`truncate text-[9px] font-semibold`,children:r}),e.status===`active`&&(0,I.jsxs)(`span`,{className:`ml-auto flex items-center gap-1 font-mono text-[8px] font-bold text-success`,children:[(0,I.jsx)(`span`,{className:`h-1.5 w-1.5 animate-pulse bg-success`}),` LIVE`]}),e.watcherConfirmed&&(0,I.jsx)(m,{className:`ml-auto h-3 w-3 text-success`,"aria-label":`Filesystem confirmed`}),e.attribution===`correlated`&&!e.watcherConfirmed&&(0,I.jsx)(`span`,{className:`ml-auto font-mono text-[7px] uppercase text-warning`,title:`Correlated from the only active tool`,children:`~ correlated`}),e.attribution===`external`&&(0,I.jsx)(`span`,{className:`ml-auto font-mono text-[7px] uppercase text-destructive`,children:`external`})]}),(0,I.jsx)(`div`,{className:`mt-1 truncate font-mono text-[9px] font-semibold`,title:e.filePath,children:z(e.filePath)}),(e.symbol||e.line)&&(0,I.jsxs)(`div`,{className:`mt-0.5 flex items-center gap-1 truncate font-mono text-[8px] text-success`,children:[(0,I.jsx)(c,{className:`h-2.5 w-2.5 shrink-0`}),e.symbol?.name??`line ${e.line}`,e.symbol?.kind&&(0,I.jsxs)(`span`,{className:`text-muted-foreground`,children:[`· `,e.symbol.kind]})]}),e.change&&(0,I.jsxs)(`div`,{className:`mt-1 flex items-center gap-1 font-mono text-[8px]`,children:[(0,I.jsxs)(`span`,{className:`border border-success/40 bg-success/10 px-1 text-success`,children:[`+`,e.change.added]}),(0,I.jsxs)(`span`,{className:`border border-destructive/40 bg-destructive/10 px-1 text-destructive`,children:[`−`,e.change.removed]}),e.durationMs!==void 0&&(0,I.jsxs)(`span`,{className:`ml-auto text-muted-foreground`,children:[e.durationMs,`ms`]})]}),e.summary&&e.summary!==e.toolName&&(0,I.jsx)(`div`,{className:`mt-1 line-clamp-2 text-[8px] leading-3 text-muted-foreground`,children:e.summary})]}),!e.filePath.startsWith(`(`)&&(0,I.jsx)(y,{className:`mt-1 h-3 w-3 shrink-0 text-muted-foreground opacity-0 group-hover:opacity-100`})]})}function Je({presences:e,onLocate:t}){return e.length===0?null:(0,I.jsxs)(`section`,{className:`pointer-events-auto absolute left-3 top-14 z-20 w-[304px] border bg-card/95 shadow-xl backdrop-blur`,children:[(0,I.jsxs)(`div`,{className:`flex h-9 items-center gap-2 border-b px-3`,children:[(0,I.jsx)(g,{className:`h-3.5 w-3.5 animate-pulse text-success`}),(0,I.jsx)(`h2`,{className:`text-[9px] font-black uppercase tracking-[0.18em]`,children:`Live agent operations`}),(0,I.jsxs)(`span`,{className:`ml-auto bg-success px-1.5 py-0.5 font-mono text-[8px] font-bold text-success-foreground`,children:[e.length,` ONLINE`]})]}),(0,I.jsx)(`div`,{className:`max-h-[330px] overflow-y-auto`,children:e.map(e=>(0,I.jsxs)(`div`,{className:`border-b last:border-b-0`,children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-2 bg-muted/35 px-3 py-1.5`,children:[(0,I.jsx)(`span`,{className:O(`flex h-6 w-6 items-center justify-center font-mono text-[8px] font-black`,R(e.key)),children:ze(e.agentName)}),(0,I.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,I.jsx)(`div`,{className:`truncate text-[9px] font-bold`,children:e.agentName}),(0,I.jsxs)(`div`,{className:`truncate font-mono text-[7px] text-muted-foreground`,children:[`session `,e.sessionId.slice(0,12),` · agent `,e.agentId.slice(0,12)]})]}),(0,I.jsxs)(`span`,{className:`font-mono text-[8px] text-success`,children:[e.operations.length,` op`]})]}),e.operations.map(e=>(0,I.jsx)(U,{activity:e,onLocate:t},e.id??`${e.toolUseId}:${e.filePath}`))]},e.key))})]})}function Ye({paused:e,followLive:t,agentFilter:r,agents:i,onTogglePaused:a,onToggleFollow:o,onAgentFilter:s}){return(0,I.jsxs)(`div`,{className:`pointer-events-auto absolute right-3 top-14 z-20 flex h-9 items-center border bg-card/95 shadow-lg backdrop-blur`,children:[(0,I.jsxs)(`button`,{type:`button`,className:O(`flex h-full items-center gap-1.5 border-r px-2.5 text-[8px] font-bold uppercase tracking-wider`,t?`bg-primary text-primary-foreground`:`text-muted-foreground hover:bg-muted`),onClick:o,title:`Automatically enter the file/function used by the newest visible agent`,children:[(0,I.jsx)(c,{className:`h-3 w-3`}),` Follow`]}),(0,I.jsxs)(`button`,{type:`button`,className:O(`flex h-full items-center gap-1.5 border-r px-2.5 text-[8px] font-bold uppercase tracking-wider`,e?`bg-warning text-warning-foreground`:`text-success hover:bg-success/10`),onClick:a,title:e?`Resume the live telemetry stream`:`Freeze the current telemetry frame`,children:[e?(0,I.jsx)(u,{className:`h-3 w-3`}):(0,I.jsx)(n,{className:`h-3 w-3`}),e?`Resume`:`Live`]}),(0,I.jsxs)(`label`,{className:`flex h-full items-center gap-1.5 px-2 text-[8px] uppercase text-muted-foreground`,children:[`Agent`,(0,I.jsxs)(`select`,{"aria-label":`Filter CodeMap by agent and session`,className:`h-6 max-w-[170px] border bg-background px-1.5 font-mono text-[8px] text-foreground outline-none focus:border-primary`,value:r,onChange:e=>s(e.target.value),children:[(0,I.jsx)(`option`,{value:`all`,children:`ALL AGENTS`}),i.map(e=>(0,I.jsxs)(`option`,{value:e.key,children:[e.agentName,` · `,e.sessionId.slice(0,10)]},e.key))]})]})]})}function Xe({activeOperations:e,recentActivities:t,activityTotalCount:n,onLocate:r}){return(0,I.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:[e.length>0&&(0,I.jsxs)(`section`,{className:`border-b`,children:[(0,I.jsxs)(`div`,{className:`flex h-9 items-center gap-2 border-b bg-success/5 px-3`,children:[(0,I.jsx)(g,{className:`h-3 w-3 animate-pulse text-success`}),(0,I.jsx)(`h3`,{className:`text-[9px] font-bold uppercase tracking-[0.16em]`,children:`Active now`}),(0,I.jsx)(`span`,{className:`ml-auto font-mono text-[9px] text-success`,children:e.length})]}),e.map(e=>(0,I.jsx)(U,{activity:e,onLocate:r,showAgent:!0},e.id??`${e.toolUseId}:${e.filePath}`))]}),(0,I.jsxs)(`section`,{children:[(0,I.jsxs)(`div`,{className:`flex h-9 items-center gap-2 border-b px-3`,children:[(0,I.jsx)(d,{className:`h-3 w-3 text-muted-foreground`}),(0,I.jsx)(`h3`,{className:`text-[9px] font-bold uppercase tracking-[0.16em]`,children:`Event stream`}),(0,I.jsxs)(`span`,{className:`ml-auto font-mono text-[8px] text-muted-foreground`,children:[n,` total`]})]}),t.length>0?t.map((e,t)=>(0,I.jsx)(U,{activity:e,onLocate:r,showAgent:!0},e.id??`${e.timestamp}:${t}`)):(0,I.jsxs)(`div`,{className:`flex flex-col items-center justify-center px-7 py-16 text-center`,children:[(0,I.jsx)(`span`,{className:`mb-4 flex h-12 w-12 items-center justify-center border bg-muted text-muted-foreground`,children:(0,I.jsx)(C,{className:`h-5 w-5`})}),(0,I.jsx)(`h3`,{className:`text-xs font-semibold`,children:`Select a node or wait for an agent`}),(0,I.jsx)(`p`,{className:`mt-2 text-[10px] leading-relaxed text-muted-foreground`,children:`Relations appear on selection. Tool calls and external filesystem touches stream here live.`})]})]})]})}function Ze({node:e,incomingCount:t,outgoingCount:n,onOpenNode:r,onOpenActivity:i}){let a=L[e.kind].icon;return(0,I.jsxs)(`div`,{className:`border-b bg-muted/25 p-3`,children:[(0,I.jsxs)(`div`,{className:`mb-2 flex items-center gap-2`,children:[(0,I.jsx)(`span`,{className:O(`flex h-8 w-8 items-center justify-center border`,L[e.kind].iconStyle),children:(0,I.jsx)(a,{className:`h-4 w-4`})}),(0,I.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,I.jsxs)(`div`,{className:`text-[8px] font-bold uppercase tracking-[0.18em] text-muted-foreground`,children:[e.external?`external `:``,e.kind]}),(0,I.jsx)(`div`,{className:`truncate font-mono text-xs font-semibold`,title:e.label,children:e.label})]})]}),(0,I.jsx)(`div`,{className:`break-all font-mono text-[9px] leading-relaxed text-muted-foreground`,children:e.file?F(e):e.package}),e.signature&&(0,I.jsx)(`pre`,{className:`mt-3 overflow-x-auto border bg-background p-2 font-mono text-[9px] leading-relaxed text-foreground`,children:e.signature}),(0,I.jsxs)(`div`,{className:`mt-3 grid grid-cols-3 border`,children:[(0,I.jsx)(W,{value:t,label:`incoming`,className:`border-r text-info`}),(0,I.jsx)(W,{value:n,label:`outgoing`,className:`border-r text-primary`}),(0,I.jsx)(W,{value:e.symbolCount??e.fileCount??e.line??`—`,label:e.kind===`package`?`files`:e.kind===`file`?`symbols`:`line`})]}),(0,I.jsxs)(`div`,{className:`mt-2 flex gap-2`,children:[e.kind!==`symbol`&&(0,I.jsxs)(`button`,{type:`button`,className:`flex h-7 flex-1 items-center justify-center gap-1.5 border bg-foreground text-[9px] font-semibold uppercase tracking-wider text-background hover:opacity-90`,onClick:()=>r(e),children:[(0,I.jsx)(y,{className:`h-3 w-3`}),` Open `,e.kind===`package`?`files`:`symbols`]}),e.file&&(0,I.jsxs)(`button`,{type:`button`,className:`flex h-7 items-center justify-center gap-1.5 border px-2 text-[9px] uppercase text-muted-foreground hover:bg-muted`,onClick:()=>i(e.file),children:[(0,I.jsx)(d,{className:`h-3 w-3`}),` Activity`]})]})]})}function W({value:e,label:t,className:n}){return(0,I.jsxs)(`div`,{className:O(`p-2 text-center`,n),children:[(0,I.jsx)(`div`,{className:`font-mono text-sm font-semibold`,children:e}),(0,I.jsx)(`div`,{className:`text-[8px] uppercase text-muted-foreground`,children:t})]})}function Qe(e){let{title:t,subtitle:n,items:r,graph:i,selectedId:a,expanded:o,onToggle:s,onSelect:c}=e;return(0,I.jsxs)(`section`,{className:`border-b py-3`,children:[(0,I.jsxs)(`div`,{className:`mb-2 flex items-end justify-between px-3`,children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`h3`,{className:`text-[10px] font-bold uppercase tracking-[0.16em]`,children:t}),(0,I.jsx)(`p`,{className:`mt-0.5 text-[9px] text-muted-foreground`,children:n})]}),(0,I.jsx)(`span`,{className:`border bg-muted px-1.5 py-0.5 font-mono text-[9px]`,children:r.length})]}),r.length===0?(0,I.jsx)(`p`,{className:`px-3 py-2 text-[10px] text-muted-foreground`,children:`No relationships in this view.`}):r.map(e=>{let n=`${t}:${e.node.id}`,r=o.has(n),l=[..._e(i,e.node.id,`incoming`),..._e(i,e.node.id,`outgoing`)].filter((e,t,n)=>e.node.id!==a&&n.findIndex(t=>t.node.id===e.node.id)===t).slice(0,8);return(0,I.jsxs)(`div`,{children:[(0,I.jsxs)(`div`,{className:`group flex min-h-9 items-center gap-1 px-2 hover:bg-muted/70`,children:[(0,I.jsx)(`button`,{type:`button`,className:`flex h-6 w-5 shrink-0 items-center justify-center text-muted-foreground`,onClick:()=>l.length>0&&s(n),"aria-label":`${r?`Collapse`:`Expand`} relation ${e.node.label}`,children:l.length>0?r?(0,I.jsx)(p,{className:`h-3 w-3`}):(0,I.jsx)(E,{className:`h-3 w-3`}):(0,I.jsx)(`span`,{className:`h-px w-2 bg-border`})}),(0,I.jsxs)(`button`,{type:`button`,className:`min-w-0 flex-1 py-1 text-left`,onClick:()=>c(e.node),children:[(0,I.jsx)(`span`,{className:`block truncate font-mono text-[10px] font-semibold`,title:e.node.label,children:e.node.label}),(0,I.jsx)(`span`,{className:`block truncate text-[9px] text-muted-foreground`,children:e.node.package??e.node.symbolKind??e.node.kind})]}),(0,I.jsx)(`span`,{className:`border px-1 py-0.5 font-mono text-[8px] text-muted-foreground`,children:e.edge.refType}),(0,I.jsxs)(`span`,{className:`w-5 text-right font-mono text-[9px] text-muted-foreground`,children:[`×`,e.edge.weight]})]}),r&&l.map(e=>(0,I.jsxs)(`button`,{type:`button`,className:`relative flex h-7 w-full items-center gap-2 border-l border-border pl-11 pr-3 text-left text-[9px] text-muted-foreground hover:bg-muted hover:text-foreground`,onClick:()=>c(e.node),children:[(0,I.jsx)(`span`,{className:`absolute left-7 top-1/2 h-px w-3 bg-border`}),(0,I.jsx)(C,{className:`h-3 w-3 shrink-0`}),(0,I.jsx)(`span`,{className:`truncate font-mono`,children:e.node.label}),(0,I.jsx)(`span`,{className:`ml-auto font-mono opacity-70`,children:e.edge.refType})]},`${n}:${e.node.id}`))]},n)})]})}function $e({selectedNode:e,incoming:t,outgoing:n,filteredGraph:r,expandedRelations:i,activeOperations:a,recentActivities:o,activityTotalCount:s,selectedActivities:c,onClearSelection:l,onOpenNode:u,onOpenActivity:d,onLocateActivity:f,onToggleRelation:p,onSelectNode:m}){return(0,I.jsxs)(`aside`,{className:`flex w-[326px] shrink-0 flex-col border-l bg-card/80`,children:[(0,I.jsxs)(`div`,{className:`flex h-10 items-center justify-between border-b px-3`,children:[(0,I.jsx)(`h2`,{className:`text-[10px] font-bold uppercase tracking-[0.18em]`,children:`Relation inspector`}),e&&(0,I.jsx)(`button`,{type:`button`,className:`text-muted-foreground hover:text-foreground`,onClick:l,"aria-label":`Clear selection`,children:(0,I.jsx)(b,{className:`h-3.5 w-3.5`})})]}),e?(0,I.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:[(0,I.jsx)(Ze,{node:e,incomingCount:t.length,outgoingCount:n.length,onOpenNode:u,onOpenActivity:d}),c.length>0&&(0,I.jsxs)(`section`,{className:`border-b bg-success/5 py-2`,children:[(0,I.jsxs)(`div`,{className:`mb-1 flex items-center gap-2 px-3`,children:[(0,I.jsx)(g,{className:`h-3 w-3 animate-pulse text-success`}),(0,I.jsx)(`h3`,{className:`text-[9px] font-bold uppercase tracking-[0.16em]`,children:`Agents on this node`}),(0,I.jsx)(`span`,{className:`ml-auto font-mono text-[9px] text-success`,children:c.length})]}),c.map(e=>(0,I.jsx)(U,{activity:e,onLocate:f,showAgent:!0},e.id??`${e.toolUseId}:${e.filePath}`))]}),(0,I.jsx)(Qe,{title:`Incoming`,subtitle:`Who depends on this`,items:t,graph:r,selectedId:e.id,expanded:i,onToggle:p,onSelect:m}),(0,I.jsx)(Qe,{title:`Outgoing`,subtitle:`What this depends on`,items:n,graph:r,selectedId:e.id,expanded:i,onToggle:p,onSelect:m})]}):(0,I.jsx)(Xe,{activeOperations:a,recentActivities:o,activityTotalCount:s,onLocate:f})]})}function et({node:e,onSelect:t,virtual:n}){let r=L[e.kind].icon;return(0,I.jsxs)(`button`,{type:`button`,"data-index":n?.index,ref:n?e=>n.measureElement(e):void 0,className:O(`min-h-8 items-center gap-2 px-3 py-1 text-left hover:bg-muted`,n?`absolute left-0 flex w-full`:`flex w-full`),style:n?{transform:`translateY(${n.start}px)`}:void 0,onClick:()=>t(e),children:[(0,I.jsx)(r,{className:O(`h-3.5 w-3.5 shrink-0`,e.kind===`package`?`text-primary`:e.kind===`file`?`text-info`:`text-success`)}),(0,I.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,I.jsx)(`span`,{className:`block truncate font-mono text-[10px]`,children:e.label}),(0,I.jsx)(`span`,{className:`block truncate text-[8px] text-muted-foreground`,children:e.file??e.package??e.symbolKind})]}),(0,I.jsx)(`span`,{className:`text-[8px] uppercase text-muted-foreground`,children:e.kind.slice(0,3)})]},e.id)}var G=80,tt=40;function K(e,t){if(!e||t.size===0)return!1;let n=M(e);if(t.has(n))return!0;for(let e of t)if(e.endsWith(`/${n}`)||n.endsWith(`/${e}`))return!0;return!1}var nt=(0,k.memo)(function e(t){let{directory:n,packageName:r,depth:i,expandedDirectories:a,expandedFiles:o,loadingBranches:s,graphForFile:c,onToggleDirectory:u,onToggleFile:d,onSelectFile:m,onOpenFile:h,onSelectSymbol:ee,selectedId:te,activeFileNorms:v,activeSymbolIds:b,revealAllKeys:x,onRevealAll:ne}=t,re=`files:${r}:${n.path||`.`}`,S=x.has(re)?n.files:n.files.slice(0,G),C=n.files.length-S.length;return(0,I.jsxs)(I.Fragment,{children:[n.directories.map(n=>{let o=`${r}:${n.path}`,s=a.has(o);return(0,I.jsxs)(`div`,{children:[(0,I.jsxs)(`button`,{type:`button`,className:`flex h-7 w-full items-center gap-1.5 pr-2 text-left text-[11px] text-muted-foreground hover:bg-muted hover:text-foreground`,style:{paddingLeft:8+i*12},onClick:()=>u(o),children:[s?(0,I.jsx)(p,{className:`h-3 w-3`}):(0,I.jsx)(E,{className:`h-3 w-3`}),s?(0,I.jsx)(f,{className:`h-3.5 w-3.5 text-warning`}):(0,I.jsx)(l,{className:`h-3.5 w-3.5 text-warning`}),(0,I.jsx)(`span`,{className:`truncate`,children:n.name})]}),s&&(0,I.jsx)(e,{...t,directory:n,depth:i+1})]},o)}),S.map(e=>{let t=o.has(e.file??e.id),n=N({level:`symbols`,file:e.file??e.label}),r=(e.file?c(e.file):void 0)?.nodes.filter(t=>t.kind===`symbol`&&t.file===e.file&&!t.external)??[],a=`symbols:${e.file??e.id}`,l=x.has(a)?r:r.slice(0,tt),u=r.length-l.length,f=K(e.file,v);return(0,I.jsxs)(`div`,{children:[(0,I.jsxs)(`div`,{className:O(`group flex h-7 items-center pr-1 text-[11px] hover:bg-muted`,te===e.id&&`bg-primary/10 text-primary`),style:{paddingLeft:8+i*12},children:[(0,I.jsx)(`button`,{type:`button`,className:`flex h-6 w-4 shrink-0 items-center justify-center text-muted-foreground`,onClick:()=>d(e),"aria-label":`${t?`Collapse`:`Expand`} ${e.label}`,children:s.has(n)?(0,I.jsx)(T,{className:`h-3 w-3 animate-spin`}):t?(0,I.jsx)(p,{className:`h-3 w-3`}):(0,I.jsx)(E,{className:`h-3 w-3`})}),(0,I.jsxs)(`button`,{type:`button`,className:`flex min-w-0 flex-1 items-center gap-1.5 text-left`,onClick:()=>m(e),onDoubleClick:()=>h(e),children:[(0,I.jsx)(se,{className:`h-3.5 w-3.5 shrink-0 text-info`}),f&&(0,I.jsx)(`span`,{className:`h-1.5 w-1.5 shrink-0 animate-pulse bg-success`,title:`Live operation`}),(0,I.jsx)(`span`,{className:`truncate font-mono`,title:e.file,children:e.label}),(0,I.jsx)(`span`,{className:`ml-auto text-[9px] text-muted-foreground`,children:e.symbolCount??0})]}),(0,I.jsx)(`button`,{type:`button`,className:`ml-1 hidden h-5 w-5 items-center justify-center text-muted-foreground hover:text-foreground group-hover:flex`,onClick:()=>h(e),title:`Open symbol map`,"aria-label":`Open ${e.label} map`,children:(0,I.jsx)(y,{className:`h-3 w-3`})})]}),t&&l.map(e=>(0,I.jsxs)(`button`,{type:`button`,className:O(`flex h-7 w-full items-center gap-1.5 pr-2 text-left text-[10px] hover:bg-muted`,te===e.id?`bg-primary/10 text-primary`:`text-muted-foreground`),style:{paddingLeft:38+i*12},onClick:()=>ee(e),children:[(0,I.jsx)(_,{className:`h-3 w-3 shrink-0 text-success`}),b.has(e.id)&&(0,I.jsx)(g,{className:`h-3 w-3 shrink-0 animate-pulse text-success`}),(0,I.jsx)(`span`,{className:`truncate font-mono`,children:e.label}),e.line&&(0,I.jsxs)(`span`,{className:`ml-auto font-mono text-[8px] opacity-60`,children:[`:`,e.line]})]},e.id)),t&&u>0&&(0,I.jsxs)(`button`,{type:`button`,className:`flex h-7 w-full items-center text-left font-mono text-[9px] text-primary hover:bg-muted`,style:{paddingLeft:38+i*12},onClick:()=>ne(a),children:[`Show `,u,` more symbols`]})]},e.id)}),C>0&&(0,I.jsxs)(`button`,{type:`button`,className:`flex h-7 w-full items-center text-left font-mono text-[9px] text-primary hover:bg-muted`,style:{paddingLeft:8+i*12},onClick:()=>ne(re),children:[`Show `,C,` more files`]})]})});function rt({rootGraph:e,search:t,searchInput:n,searchResults:i,virtualizeSearch:a,searchVirtualizer:o,treeScrollRef:s,selectedId:c,expandedPackages:l,expandedDirectories:u,expandedFiles:d,loadingBranches:f,activeFileNorms:m,activeSymbolIds:h,revealAllKeys:g,packageGraph:ee,graphForFile:_,navigate:v,togglePackage:x,toggleDirectory:ne,toggleFile:re,revealAllTree:S,selectFileFromTree:C,selectSymbolFromTree:w,selectSearchResult:ie,handleOpenNode:ae,onSearchInputChange:oe,onSearchChange:se}){return(0,I.jsxs)(`aside`,{className:`flex w-[286px] shrink-0 flex-col border-r bg-card/70`,children:[(0,I.jsxs)(`div`,{className:`border-b p-3`,children:[(0,I.jsxs)(`div`,{className:`mb-2 flex items-center justify-between`,children:[(0,I.jsx)(`h2`,{className:`text-[10px] font-bold uppercase tracking-[0.18em]`,children:`Code tree`}),(0,I.jsxs)(`span`,{className:`font-mono text-[9px] text-muted-foreground`,children:[e.nodes.length,` roots`]})]}),(0,I.jsxs)(`label`,{className:`flex h-8 items-center gap-2 border bg-background px-2 focus-within:border-primary`,children:[(0,I.jsx)(te,{className:`h-3.5 w-3.5 text-muted-foreground`}),(0,I.jsx)(`input`,{className:`min-w-0 flex-1 bg-transparent font-mono text-[10px] outline-none placeholder:text-muted-foreground`,value:n,onChange:e=>oe(e.target.value),placeholder:`Find package, file, symbol…`}),n&&(0,I.jsx)(`button`,{type:`button`,onClick:()=>{oe(``),se(``)},"aria-label":`Clear search`,children:(0,I.jsx)(b,{className:`h-3 w-3 text-muted-foreground`})})]})]}),(0,I.jsx)(`div`,{ref:s,className:`min-h-0 flex-1 overflow-y-auto py-2`,children:t.trim()?(0,I.jsxs)(`div`,{children:[(0,I.jsxs)(`div`,{className:`px-3 pb-2 text-[9px] text-muted-foreground`,children:[i.length,` loaded-map results`]}),i.length===0?(0,I.jsxs)(`p`,{className:`px-3 py-8 text-center text-[10px] text-muted-foreground`,children:[`No match in loaded branches.`,(0,I.jsx)(`br`,{}),`Expand a package to search its files.`]}):a?(0,I.jsx)(`div`,{style:{height:`${o.getTotalSize()}px`,width:`100%`,position:`relative`},children:o.getVirtualItems().map(e=>{let t=i[e.index];return t?(0,I.jsx)(et,{node:t,onSelect:ie,virtual:{index:e.index,start:e.start,measureElement:o.measureElement}},t.id):null})}):i.map(e=>(0,I.jsx)(et,{node:e,onSelect:ie},e.id))]}):e.nodes.map(e=>{let t=e.package??e.label,n=l.has(t),i=N({level:`files`,package:t}),a=ee(t),o=a?Te(a.nodes):void 0;return(0,I.jsxs)(`div`,{children:[(0,I.jsxs)(`div`,{className:O(`group flex h-8 items-center px-2 hover:bg-muted`,c===e.id&&`bg-primary/10 text-primary`),children:[(0,I.jsx)(`button`,{type:`button`,className:`flex h-6 w-5 items-center justify-center text-muted-foreground`,onClick:()=>x(e),"aria-label":`${n?`Collapse`:`Expand`} ${t}`,children:f.has(i)?(0,I.jsx)(T,{className:`h-3 w-3 animate-spin`}):n?(0,I.jsx)(p,{className:`h-3 w-3`}):(0,I.jsx)(E,{className:`h-3 w-3`})}),(0,I.jsxs)(`button`,{type:`button`,className:`flex min-w-0 flex-1 items-center gap-2 text-left`,onClick:()=>v({level:`packages`},e.id),onDoubleClick:()=>v({level:`files`,package:t}),children:[(0,I.jsx)(r,{className:`h-3.5 w-3.5 shrink-0 text-primary`}),(0,I.jsx)(`span`,{className:`truncate font-mono text-[10px] font-semibold`,children:e.label}),(0,I.jsx)(`span`,{className:`ml-auto text-[9px] text-muted-foreground`,children:e.fileCount??0})]}),(0,I.jsx)(`button`,{type:`button`,className:`ml-1 hidden h-5 w-5 items-center justify-center text-muted-foreground hover:text-foreground group-hover:flex`,onClick:()=>v({level:`files`,package:t}),title:`Open file map`,"aria-label":`Open ${t} map`,children:(0,I.jsx)(y,{className:`h-3 w-3`})})]}),n&&o&&(0,I.jsx)(nt,{directory:o,packageName:t,depth:1,expandedDirectories:u,expandedFiles:d,loadingBranches:f,graphForFile:_,onToggleDirectory:ne,onToggleFile:re,onSelectFile:C,onOpenFile:ae,onSelectSymbol:w,selectedId:c,activeFileNorms:m,activeSymbolIds:h,revealAllKeys:g,onRevealAll:S})]},e.id)})}),(0,I.jsxs)(`div`,{className:`border-t px-3 py-2 text-[9px] leading-relaxed text-muted-foreground`,children:[`Click to focus · double-click to enter`,(0,I.jsx)(`br`,{}),`Branches stay open while the map changes`]})]})}function it(e,t){let n=new Map(e.map(e=>[e.id,e])),r=e.length!==t.length,i=t.map((t,i)=>{let a=n.get(t.id);return a?a.type===t.type&&a.position.x===t.position.x&&a.position.y===t.position.y&&V(a.data,t.data)?(e[i]!==a&&(r=!0),a):(r=!0,{...a,...t,measured:a.measured}):(r=!0,t)});return r?i:e}function q(e){return e.data?.renderKey}function at(e,t){let n=new Map(e.map(e=>[e.id,e])),r=e.length!==t.length,i=t.map((t,i)=>{let a=n.get(t.id);return a&&q(a)===q(t)?(e[i]!==a&&(r=!0),a):(r=!0,t)});return r?i:e}function ot(){let[e,t]=(0,k.useState)({level:`packages`}),n=N(e),[r,i]=(0,k.useState)(We),[a,o]=(0,k.useState)(!0),[c,l]=(0,k.useState)(null),[u,d]=(0,k.useState)(null),[f,p]=(0,k.useState)(`layers`),[m,h]=(0,k.useState)(`smart`),[g,ee]=(0,k.useState)(`all`),[_,te]=(0,k.useState)(``),[v,y]=(0,k.useState)(``),[b,x]=(0,k.useState)(new Set),[S,C]=(0,k.useState)(new Set),[w,ae]=(0,k.useState)(new Set),[se,T]=(0,k.useState)(new Set),[E,le]=(0,k.useState)(new Set),[D,ue]=(0,k.useState)(new Set),[de,O]=(0,k.useState)(0),[A,j]=(0,k.useState)(null),[ye,be]=(0,k.useState)(!1),[P,Se]=(0,k.useState)(`all`),[F,we]=(0,k.useState)(null),[je,L]=(0,k.useState)(null),[Le,Re]=(0,k.useState)(0),R=(0,k.useRef)(new Map),z=(0,k.useRef)(null),B=(0,k.useRef)(null),Ve=(0,k.useRef)(``),He=(0,k.useRef)(``),V=(0,k.useRef)(null),Ue=(0,k.useRef)(new Set),{history:H,pulses:U,activeOperationsMap:Xe,activityTotalCount:Ze,resolveActivitySymbol:W,getActivityForFile:Qe,sweepActivity:et}=fe(s(e=>({history:e.history,pulses:e.pulses,activeOperationsMap:e.activeOperations,activityTotalCount:e.totalCount,resolveActivitySymbol:e.resolveActivitySymbol,getActivityForFile:e.getActivityForFile,sweepActivity:e._sweep}))),G=(0,k.useMemo)(()=>[...Xe.values()].flat(),[Xe]),tt=(0,k.useMemo)(()=>[...U.keys()].map(e=>H.get(e)?.[0]).filter(e=>!!e),[H,U]),K=(0,k.useMemo)(()=>{let e=[];for(let t of H.values())e.push(...t.slice(0,16));return e.sort((e,t)=>t.timestamp-e.timestamp).slice(0,16)},[H]),nt=(0,k.useMemo)(()=>pe([...G,...K]),[G,K]),q=(0,k.useMemo)(()=>{let e=F??G;return P===`all`?e:e.filter(e=>me(e)===P)},[G,P,F]),ot=(0,k.useMemo)(()=>{let e=je??K;return P===`all`?e:e.filter(e=>me(e)===P)},[P,je,K]),J=(0,k.useDeferredValue)(q),st=(0,k.useDeferredValue)(ot),ct=(0,k.useDeferredValue)(tt),lt=(0,k.useMemo)(()=>pe(q),[q]),[ut,dt,ft]=ie([]),[pt,mt,ht]=ce([]),{fitView:gt}=re(),Y=(0,k.useCallback)(async(e,t=!1)=>{let n=N(e),r=R.current.get(n);if(r&&!t)return De(R.current,n,r,48),r;let i=await fetch(ge(e));if(!i.ok){let e=await i.json().catch(()=>({error:i.statusText}));throw Error(e.error??`HTTP ${i.status}`)}let a=await i.json();return De(R.current,n,a,48),O(e=>e+1),a},[]);(0,k.useEffect)(()=>{let e=window.setTimeout(()=>y(_),150);return()=>window.clearTimeout(e)},[_]);let _t=he(e=>e.generation),vt=(0,k.useRef)(0),yt=(0,k.useRef)(null);(0,k.useEffect)(()=>{let t=!1,n=_t>vt.current;return n&&(vt.current=_t,R.current.clear(),O(e=>e+1),x(new Set),C(new Set),ae(new Set),le(new Set)),o(!0),l(null),Y(e,n).then(e=>{if(!t){if(i(e),!n){let t=z.current;z.current=null,d(t&&e.nodes.some(e=>e.id===t)?t:null)}o(!1)}}).catch(e=>{t||(l(e instanceof Error?e.message:String(e)),i(We),o(!1))}),()=>{t=!0}},[n,Y,_t,e]);let X=(0,k.useCallback)((e,r)=>{if(z.current=r??null,N(e)===n){d(r??null),z.current=null;return}t(e)},[n]),bt=(0,k.useCallback)(async e=>{let t=N(e);if(!(R.current.has(t)||D.has(t))){ue(e=>new Set(e).add(t));try{await Y(e)}finally{ue(e=>{let n=new Set(e);return n.delete(t),n})}}},[Y,D]);(0,k.useEffect)(()=>{let e=!1,t=0;for(let n of G){if(t>=2)break;if(n.symbol||!n.toolUseId||n.filePath.startsWith(`(`))continue;let r=n.filePath;Ue.current.has(r)||(Ue.current.add(r),t+=1,Y({level:`symbols`,file:r}).then(t=>{if(e)return;let i=Pe(n,t.nodes);i&&W(n.toolUseId,r,{id:i.id,name:i.label,...i.symbolKind?{kind:i.symbolKind}:{},...i.line?{line:i.line}:{}})}).catch(()=>void 0).finally(()=>{Ue.current.delete(r)}))}return()=>{e=!0}},[G,Y,W]);let Z=(0,k.useMemo)(()=>({nodes:r.nodes,edges:g===`all`?r.edges:r.edges.filter(e=>e.refType===g)}),[r,g]),Q=r.nodes.find(e=>e.id===u),$=(0,k.useMemo)(()=>Ce(Z,u,m),[m,Z,u]),xt=(0,k.useMemo)(()=>u?ve(Z,u):new Set,[Z,u]),{incomingCounts:St,outgoingCounts:Ct}=(0,k.useMemo)(()=>{let e=new Map,t=new Map;for(let n of Z.edges)t.set(n.source,(t.get(n.source)??0)+1),e.set(n.target,(e.get(n.target)??0)+1);return{incomingCounts:e,outgoingCounts:t}},[Z]),wt=f===`orbit`?u??void 0:void 0,Tt=(0,k.useMemo)(()=>xe($,f,wt),[$,f,wt]),Et=(0,k.useMemo)(()=>[n,f,f===`orbit`?u??``:``,Ee($)].join(``),[$,n,f,u]),Dt=(0,k.useCallback)(e=>{d(e.id),T(new Set)},[]),Ot=(0,k.useCallback)(e=>{e.kind===`package`&&X({level:`files`,package:e.package??e.label}),e.kind===`file`&&e.file&&X({level:`symbols`,file:e.file,package:e.package})},[X]),kt=(0,k.useMemo)(()=>[Ne(J),Ne(ct),Ne(st)].join(``),[J,ct,st]),At=(0,k.useMemo)(()=>{let e=new Set;for(let t of q)e.add(M(t.filePath));return e},[q]),jt=(0,k.useMemo)(()=>{let e=new Set;for(let t of q)t.symbol?.id&&e.add(t.symbol.id);return e},[q]);(0,k.useEffect)(()=>{let e=()=>{let e=Tt.map(({node:e})=>e),t=Me(e,J),n=Me(e,ct),r=new Set(t.keys()),i=Tt.map(({node:e,position:r})=>{let i=t.get(e.id)??[],a=i[0]??n.get(e.id)?.[0];return{id:e.id,type:`codemap`,position:r,data:{graphNode:e,selected:e.id===u,dimmed:!!u&&!xt.has(e.id),incoming:St.get(e.id)??0,outgoing:Ct.get(e.id)??0,isActive:!!a,...a?{activityType:a.type}:{},activeOperations:i,onSelect:Dt,onOpen:Ot,onShowHistory:j}}});dt(e=>it(e,i));let a=6,o=$.edges.map((e,t)=>{let n=!!u&&(e.source===u||e.target===u),i=r.has(e.source)||r.has(e.target),o=i&&(n||a>0);o&&--a;let s=Ie[e.refType]??`hsl(var(--muted-foreground))`,c=n||i?`smoothstep`:`default`;return{id:`edge:${e.source}:${e.target}:${t}`,source:e.source,target:e.target,type:c,animated:o,label:n?`${e.refType}${e.weight>1?` ×${e.weight}`:``}`:void 0,markerEnd:{type:ne.ArrowClosed,color:s,width:14,height:14},style:{stroke:s,strokeWidth:i?Math.min(2.5+Math.log2(e.weight+1)*.65,5):n?Math.min(1.25+Math.log2(e.weight+1)*.65,4):1,opacity:i?1:u?n?.88:.08:.52},labelStyle:{fontSize:9,fontFamily:`var(--font-mono)`,fill:`hsl(var(--muted-foreground))`},labelBgStyle:{fill:`hsl(var(--card))`,fillOpacity:.92},labelBgPadding:[4,2],zIndex:i?4:n?2:0,data:{renderKey:`${e.refType}:${e.weight}:${u?n?`focused`:`dimmed`:`idle`}:${i?`live`:`still`}:${o?`anim`:`still`}:${c}`}}}),s=new Map,c=new Set(J.map(me));for(let e of[...st].sort((e,t)=>e.timestamp-t.timestamp)){let t=me(e),n=s.get(t);n?n.push(e):s.set(t,[e])}let l=[...s.entries()].map(([e,t])=>({agentKey:e,activities:t,live:c.has(e),latest:t[t.length-1]?.timestamp??0})).sort((e,t)=>Number(t.live)-Number(e.live)||t.latest-e.latest).slice(0,4),d=[];for(let{agentKey:e,activities:t,live:n}of l){let r=t.slice(-7).map(e=>({activity:e,node:$.nodes.find(t=>Ae(e,t))})).filter(e=>!!e.node).filter((e,t,n)=>t===0||e.node.id!==n[t-1]?.node.id),i=Be(e);for(let t=1;t<r.length;t++){let o=r[t-1],s=r[t],c=n&&a>0;c&&--a,d.push({id:`trail:${e}:${o.activity.timestamp}:${s.activity.timestamp}`,source:o.node.id,target:s.node.id,type:`smoothstep`,animated:c,label:t===r.length-1?`${ze(s.activity.agentName??s.activity.agent??`agent`)} TRAIL`:void 0,markerEnd:{type:ne.ArrowClosed,color:i,width:13,height:13},style:{stroke:i,strokeWidth:2.5,strokeDasharray:`7 5`,opacity:.9},labelStyle:{fontSize:8,fontWeight:700,fill:i},labelBgStyle:{fill:`hsl(var(--card))`,fillOpacity:.94},labelBgPadding:[4,2],zIndex:6,data:{renderKey:`${i}:${t===r.length-1?`label`:`plain`}:${n?`live`:`still`}:${c?`anim`:`still`}`}})}}Re(d.length),mt(e=>at(e,[...o,...d]))},t=Et,n=He.current!==t;He.current=t,V.current!==null&&(window.clearTimeout(V.current),V.current=null),n?e():V.current=window.setTimeout(()=>{V.current=null,e()},120);let r;return Ve.current!==Et&&(r=window.setTimeout(()=>{Ve.current=Et;let e=$.nodes.length>48?0:240;gt({padding:.2,duration:e,maxZoom:1.25})},20)),()=>{V.current!==null&&(window.clearTimeout(V.current),V.current=null),r!==void 0&&window.clearTimeout(r)}},[kt,$,u,J,st,ct,Et,xt,gt,Ot,Dt,St,Ct,Tt,mt,dt]),(0,k.useEffect)(()=>{let e=window.setInterval(()=>{et()},2e3);return()=>window.clearInterval(e)},[et]);let Mt=R.current.get(`packages`)??(e.level===`packages`?r:We),Nt=(0,k.useCallback)(e=>R.current.get(N({level:`files`,package:e})),[de]),Pt=(0,k.useCallback)(e=>R.current.get(N({level:`symbols`,file:e})),[de]),Ft=(0,k.useCallback)(e=>{let t=e.filePath,n=ke(e.filePath),r=`file:${e.filePath}`;for(let i of R.current.values()){let a=i.nodes.find(t=>t.kind===`file`&&!t.external&&Oe(t.file,e.filePath));if(a){t=a.file??t,n=a.package??n,r=a.id;break}}if(e.symbol){X({level:`symbols`,file:t,package:n},e.symbol.id);return}X({level:`files`,package:n},r)},[X]);(0,k.useEffect)(()=>{if(!ye||F)return;let e=[...q].filter(e=>!e.filePath.startsWith(`(`)).sort((e,t)=>t.timestamp-e.timestamp)[0];if(!e)return;let t=`${e.id??e.toolUseId}:${e.filePath}:${e.symbol?.id??`file`}`;B.current!==t&&(B.current=t,Ft(e))},[q,ye,Ft,F]);let It=(0,k.useCallback)(()=>{if(F){we(null),L(null);return}we([...G]),L([...K])},[G,F,K]),Lt=(0,k.useCallback)(e=>{let t=e.package??e.label,n=!b.has(t);x(e=>{let r=new Set(e);return n?r.add(t):r.delete(t),r}),n&&bt({level:`files`,package:t}).then(()=>{let e=R.current.get(N({level:`files`,package:t})),n=e?Te(e.nodes):void 0;n?.directories.length===1&&n.directories[0]&&C(e=>new Set(e).add(`${t}:${n.directories[0].path}`))}).catch(()=>void 0)},[bt,b]),Rt=(0,k.useCallback)(e=>{if(!e.file)return;let t=!w.has(e.file);ae(n=>{let r=new Set(n);return t?r.add(e.file):r.delete(e.file),r}),t&&bt({level:`symbols`,file:e.file,package:e.package}).catch(()=>void 0)},[bt,w]),zt=(0,k.useCallback)(e=>{C(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),Bt=(0,k.useCallback)(e=>{le(t=>new Set(t).add(e))},[]),Vt=(0,k.useCallback)(e=>{X({level:`files`,package:e.package??`(root)`},e.id)},[X]),Ht=(0,k.useCallback)(e=>{e.file&&X({level:`symbols`,file:e.file,package:e.package},e.id)},[X]),Ut=(0,k.useMemo)(()=>{let e=v.trim().toLocaleLowerCase();if(!e)return[];let t=new Map;for(let n of R.current.values())for(let r of n.nodes)`${r.label} ${r.file??``} ${r.signature??``} ${r.package??``}`.toLocaleLowerCase().includes(e)&&t.set(r.id,r);return[...t.values()].sort((e,t)=>e.kind.localeCompare(t.kind)||e.label.localeCompare(t.label)).slice(0,80)},[v,de]),Wt=Ut.length>40,Gt=oe({count:Ut.length,getScrollElement:()=>yt.current,estimateSize:()=>40,overscan:8,enabled:Wt}),Kt=(0,k.useCallback)(e=>{e.kind===`package`?X({level:`packages`},e.id):e.kind===`file`?X({level:`files`,package:e.package??`(root)`},e.id):e.file&&X({level:`symbols`,file:e.file,package:e.package},e.id)},[X]),{incoming:qt,outgoing:Jt}=(0,k.useMemo)(()=>({incoming:Q?_e(Z,Q.id,`incoming`):[],outgoing:Q?_e(Z,Q.id,`outgoing`):[]}),[Z,Q]),{edgeWeight:Yt,connectedNodeCount:Xt}=(0,k.useMemo)(()=>{let e=0,t=new Set;for(let n of Z.edges)e+=n.weight,t.add(n.source),t.add(n.target);return{edgeWeight:e,connectedNodeCount:t.size}},[Z]),Zt=Q?q.filter(e=>Ae(e,Q)):[],Qt=A?Qe(A):[];return(0,I.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col bg-background`,children:[(0,I.jsx)(qe,{scope:e,graph:r,agentPresences:lt,edgeWeight:Yt,connectedNodeCount:Xt,navigate:X}),(0,I.jsxs)(`div`,{className:`flex min-h-0 flex-1`,children:[(0,I.jsx)(rt,{rootGraph:Mt,search:v,searchInput:_,searchResults:Ut,virtualizeSearch:Wt,searchVirtualizer:Gt,treeScrollRef:yt,selectedId:u,expandedPackages:b,expandedDirectories:S,expandedFiles:w,loadingBranches:D,activeFileNorms:At,activeSymbolIds:jt,revealAllKeys:E,packageGraph:Nt,graphForFile:Pt,navigate:X,togglePackage:Lt,toggleDirectory:zt,toggleFile:Rt,revealAllTree:Bt,selectFileFromTree:Vt,selectSymbolFromTree:Ht,selectSearchResult:Kt,handleOpenNode:Ot,onSearchInputChange:te,onSearchChange:y}),(0,I.jsxs)(`main`,{className:`relative min-w-0 flex-1 bg-[radial-gradient(circle_at_50%_0%,hsl(var(--primary)/0.055),transparent_38%)]`,children:[(0,I.jsx)(Ke,{layout:f,canvasMode:m,edgeFilter:g,canvasNodeCount:$.nodes.length,graphNodeCount:r.nodes.length,onLayoutChange:p,onCanvasModeChange:h,onEdgeFilterChange:ee}),(0,I.jsx)(Je,{presences:lt,onLocate:Ft}),(0,I.jsx)(Ye,{paused:F!==null,followLive:ye,agentFilter:P,agents:nt,onTogglePaused:It,onToggleFollow:()=>{B.current=null,be(e=>!e)},onAgentFilter:e=>{B.current=null,Se(e)}}),(0,I.jsx)(Ge,{loading:a,error:c,graph:r,canvasNodeCount:$.nodes.length,flowNodes:ut,flowEdges:pt,onNodesChange:ft,onEdgesChange:ht,agentTrailCount:Le})]}),(0,I.jsx)($e,{selectedNode:Q,incoming:qt,outgoing:Jt,filteredGraph:Z,expandedRelations:se,activeOperations:q,recentActivities:ot,activityTotalCount:Ze,selectedActivities:Zt,onClearSelection:()=>d(null),onOpenNode:Ot,onOpenActivity:j,onLocateActivity:Ft,onToggleRelation:e=>T(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),onSelectNode:Dt})]}),A&&(0,I.jsx)(Fe,{historyFile:A,fileHistory:Qt,onClose:()=>j(null)})]})}function J(){return(0,I.jsx)(ue,{children:(0,I.jsx)(ot,{})})}export{J as CodeMap};
@@ -1,3 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{Bi as t,Bt as n,Dn as r,Ia as i,Mt as a,Ni as o,Oi as s,Ot as c,Pi as l,Qt as u,Rn as d,Si as f,Sn as p,St as m,Ta as h,Ui as g,Un as _,Vi as v,Wt as y,Xi as b,Yi as x,Yn as S,Yt as C,Zt as w,an as T,cn as ee,dt as E,fn as D,gn as O,hi as te,in as ne,jr as re,jt as ie,lt as k,nr as ae,oa as A,pi as oe,pn as se,qi as ce,qr as le,qt as ue,ra as de,ri as fe,rr as pe,sn as me,un as j,va as he,wr as ge,xn as M,yi as _e}from"./vendor-CxV3l5PQ.js";import{n as N}from"./ui-store-C4Ybfoon.js";import{t as ve}from"./ws-client-Cy3oRAmZ.js";import{t as P}from"./utils-_s0GyctV.js";import{t as ye}from"./session-store-BE_S1f5v.js";import{M as be,u as xe,x as F}from"./stores-BS-Bdi-5.js";import{n as Se,t as Ce}from"./ModelPicker-BxYMTEEN.js";import{C as we,S as I,c as Te}from"./index-Bf75VrDE.js";import{n as Ee,t as L}from"./progress-ring-C0O73ZjR.js";var R=e(i(),1);function De(e,t=!0){(0,R.useEffect)(()=>{let n=e.current;if(!n||!t)return;let r=e=>{if(!e.shiftKey||n.scrollWidth<=n.clientWidth+1)return;let t=Math.abs(e.deltaY)>Math.abs(e.deltaX)?e.deltaY:e.deltaX;t!==0&&(e.preventDefault(),n.scrollLeft+=t)},i=e=>{if(!e.ctrlKey&&!e.metaKey||n.scrollWidth<=n.clientWidth+1)return;let t=n.clientWidth*.8;e.key===`ArrowLeft`?(e.preventDefault(),n.scrollLeft-=t):e.key===`ArrowRight`&&(e.preventDefault(),n.scrollLeft+=t)};return n.addEventListener(`wheel`,r,{passive:!1}),n.addEventListener(`keydown`,i),()=>{n.removeEventListener(`wheel`,r),n.removeEventListener(`keydown`,i)}},[e,t])}var z=4320*60*1e3,Oe=new Set([`completed`,`archived`]);function ke(e,t){let n=We(t.now);if(n===null)throw TypeError(`Kanban audit requires a valid current time`);let r=Be(t.liveAgentIdentities),i=Fe(e,t.defaultReviewStaleAfterMs??z),a=Pe(e),o=[];for(let s of e.tasks)Oe.has(s.status)||(Ae(o,s,t.requireDueDate===!0),je(o,s,n,r),Me(o,s,n,i),a.length>1&&Ne(o,s,a));return o.sort(Ge),{issues:o,counts:{error:o.filter(e=>e.severity===`error`).length,warning:o.filter(e=>e.severity===`warning`).length},affectedTaskCount:new Set(o.map(e=>e.taskId)).size}}function Ae(e,t,n){V(t.description)||H(e,t,`missing-description`,`warning`,`Add a description`),Re(t).length===0&&H(e,t,`missing-assignee`,`warning`,`Assign an owner`),n&&!V(t.dueDate)&&H(e,t,`missing-due-date`,`warning`,`Set a due date`),!He(t.labels)&&!He(t.tags)&&H(e,t,`missing-labels`,`warning`,`Add labels or tags`),!He(t.childTaskIds)&&!He(t.subtasks)&&H(e,t,`missing-subtasks`,`warning`,`Define subtasks`),He(t.successCriteria)||H(e,t,`missing-success-criteria`,`warning`,`Add success criteria`)}function je(e,t,n,r){let i=t.assignment;if(!(t.status===`in_progress`||i?.status===`running`))return;let a=Re(t);if(!i||a.length===0||!V(i.leaseId)||!V(i.leaseExpiresAt)){H(e,t,`abandoned-running-task`,`error`,`Running without a complete assignment lease`);return}let o=We(i.leaseExpiresAt);if(o===null||o<=n){H(e,t,`stale-running-task`,`error`,`Assignment lease is expired`);return}a.some(e=>r.has(B(e)))||H(e,t,`abandoned-running-task`,`error`,`Assigned agent is not live`)}function Me(e,t,n,r){if(t.status!==`review`)return;let i=Le(t,`review`)??We(t.updatedAt);i===null||n-i<=r||H(e,t,`stale-review`,`warning`,`Waiting in review for ${Math.max(1,Math.floor((n-i)/(3600*1e3)))}h`)}function Ne(e,t,n){let r=Ie(t);if(r.length<2)return;let i=new Map(n.map((e,t)=>[B(e),t]));for(let n=1;n<r.length;n+=1){let a=r[n-1],o=r[n];if(!a||!o)continue;let s=i.get(B(a.state)),c=i.get(B(o.state));if(!(s===void 0||c===void 0||Math.abs(c-s)<=1)){H(e,t,`skipped-lifecycle-state`,`error`,`Lifecycle skipped ${a.state} → ${o.state}`);return}}}function Pe(e){let t=[e.lifecycle,e.lifecyclePolicy,e.managedLifecycle];for(let e of t){let t=ze(e);if(t.length>1)return t;if(!e||typeof e!=`object`||Array.isArray(e))continue;let n=e;if(n.mode===`managed`&&n.columns){let e=[`backlog`,`todo`,`running`,`review`,`done`].map(e=>n.columns?.[e]).filter(e=>V(e));if(e.length===5)return e}for(let e of[n.states,n.statuses,n.order,n.managedStatuses]){let t=ze(e);if(t.length>1)return t}}return[]}function Fe(e,t){let n=[e,e.lifecycle,e.lifecyclePolicy,e.managedLifecycle];for(let e of n){if(!e||typeof e!=`object`||Array.isArray(e))continue;let t=e;if(Ue(t.staleReviewAfterMs))return t.staleReviewAfterMs;if(Ue(t.reviewStaleAfterMs))return t.reviewStaleAfterMs;if(Ue(t.reviewStaleHours))return t.reviewStaleHours*60*60*1e3}return t}function Ie(e){let t=e.lifecycle?.history??e.lifecycleHistory??e.statusHistory??e.history;if(!Array.isArray(t))return[];let n=[];for(let e of t){if(typeof e==`string`&&V(e)){n.push({state:e.trim(),at:null});continue}if(!e||typeof e!=`object`)continue;let t=e,r=Ve(t.status,t.state,t.toStatus,t.to,t.columnId);r&&n.push({state:r,at:We(t.at??t.ts??t.timestamp??t.changedAt??t.createdAt)})}return n}function Le(e,t){let n=null;for(let r of Ie(e))B(r.state)!==B(t)||r.at===null||(n=n===null?r.at:Math.max(n,r.at));return n}function Re(e){let t=e.assignment;return[e.assignee,e.assignedAgent,t?.agentId,t?.subagentId,t?.name].filter(V)}function ze(e){if(!Array.isArray(e))return[];let t=[];for(let n of e){if(V(n)){t.push(n.trim());continue}if(!n||typeof n!=`object`)continue;let e=n,r=Ve(e.id,e.status,e.state,e.name);r&&t.push(r)}return t}function Be(e){let t=new Set;if(!e)return t;for(let n of e)V(n)&&t.add(B(n));return t}function B(e){return e.trim().toLocaleLowerCase()}function Ve(...e){for(let t of e)if(V(t))return t.trim();return null}function V(e){return typeof e==`string`&&e.trim().length>0}function He(e){return Array.isArray(e)&&e.length>0}function Ue(e){return typeof e==`number`&&Number.isFinite(e)&&e>0}function We(e){if(e instanceof Date){let t=e.getTime();return Number.isFinite(t)?t:null}if(typeof e==`number`)return Number.isFinite(e)?e:null;if(typeof e!=`string`||!e.trim())return null;let t=Date.parse(e);return Number.isFinite(t)?t:null}function H(e,t,n,r,i){e.push({id:`${t.id}:${n}`,taskId:t.id,taskTitle:t.title,code:n,severity:r,message:i})}function Ge(e,t){let n=Ke(e.severity)-Ke(t.severity);if(n!==0)return n;let r=e.taskTitle.localeCompare(t.taskTitle);return r===0?e.message.localeCompare(t.message):r}function Ke(e){return e===`error`?0:1}function qe(e){let t=be(e=>e.wsUrl),n=be(e=>e.provider),r=be(e=>e.model),[i,a]=(0,R.useState)([]),[o,s]=(0,R.useState)([]),[c,l]=(0,R.useState)({}),[u,d]=(0,R.useState)(``),[f,p]=(0,R.useState)(``);return(0,R.useEffect)(()=>{let e=ve(t).on(`kanban.meta`,e=>{let t=e.payload?.data;t&&(a(t.tools??[]),s(t.skills??[]),l(t.fallbackProfiles??{}),t.sessionProvider&&d(t.sessionProvider),t.sessionModel&&p(t.sessionModel))});return()=>e()},[t]),(0,R.useEffect)(()=>{e&&ve(t).send({type:`kanban.meta`})},[e,t]),{tools:i,skills:o,fallbackProfiles:c,sessionProvider:u||n,sessionModel:f||r}}var U=k();function W({options:e,selected:t,onChange:n,placeholder:r,emptyLabel:i}){let[a,o]=(0,R.useState)(!1),[s,c]=(0,R.useState)(``),l=(0,R.useRef)(null);(0,R.useEffect)(()=>{if(!a)return;let e=e=>{l.current&&!l.current.contains(e.target)&&o(!1)};return window.addEventListener(`mousedown`,e),()=>window.removeEventListener(`mousedown`,e)},[a]);let u=(0,R.useMemo)(()=>{let t=new Map(e.map(e=>[e.value,e.label]));return e=>t.get(e)??e},[e]),d=(0,R.useMemo)(()=>{let t=s.trim().toLowerCase();return(t?e.filter(e=>`${e.value} ${e.label} ${e.tag??``}`.toLowerCase().includes(t)):e).slice(0,80)},[e,s]),f=e=>{n(t.includes(e)?t.filter(t=>t!==e):[...t,e])};return(0,U.jsxs)(`div`,{ref:l,className:`relative`,children:[t.length>0&&(0,U.jsx)(`div`,{className:`mb-1 flex flex-wrap gap-1`,children:t.map(e=>(0,U.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded bg-muted px-1.5 py-0.5 text-[11px]`,children:[(0,U.jsx)(`span`,{className:`max-w-[150px] truncate`,children:u(e)}),(0,U.jsx)(`button`,{type:`button`,onClick:()=>f(e),className:`text-muted-foreground hover:text-destructive`,"aria-label":`Remove ${u(e)}`,children:(0,U.jsx)(E,{size:11})})]},e))}),(0,U.jsxs)(`button`,{type:`button`,onClick:()=>o(e=>!e),className:`flex w-full items-center gap-1.5 rounded-md border border-border bg-muted px-2 py-1.5 text-left text-xs transition-colors hover:border-primary/45 hover:bg-muted/80`,children:[(0,U.jsx)(M,{className:`h-3.5 w-3.5 shrink-0 text-primary`}),(0,U.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-muted-foreground`,children:r??`Add…`}),(0,U.jsx)(x,{className:`h-3.5 w-3.5 shrink-0 text-muted-foreground`})]}),a&&(0,U.jsxs)(`div`,{className:`absolute z-50 mt-1 max-h-72 w-full min-w-[240px] overflow-hidden rounded-md border border-border/80 bg-popover shadow-xl`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-1.5 border-b border-border/70 bg-muted/20 px-2 py-1.5`,children:[(0,U.jsx)(`input`,{value:s,onChange:e=>c(e.target.value),placeholder:`Filter…`,className:`min-w-0 flex-1 bg-transparent text-xs outline-none placeholder:text-muted-foreground`}),s&&(0,U.jsx)(`button`,{type:`button`,onClick:()=>c(``),className:`text-muted-foreground hover:text-foreground`,children:(0,U.jsx)(E,{className:`h-3 w-3`})})]}),(0,U.jsxs)(`div`,{className:`max-h-60 overflow-y-auto py-1`,children:[d.map(e=>{let n=t.includes(e.value);return(0,U.jsxs)(`button`,{type:`button`,onClick:()=>f(e.value),className:P(`flex w-full items-start gap-1.5 px-2 py-1.5 text-left text-xs transition-colors hover:bg-muted`,n?`bg-primary/8 text-primary`:`text-foreground`),children:[n?(0,U.jsx)(b,{className:`mt-0.5 h-3 w-3 shrink-0 text-primary`}):(0,U.jsx)(`span`,{className:`w-3 shrink-0`}),(0,U.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,U.jsx)(`span`,{className:`block truncate`,children:e.label}),e.description&&(0,U.jsx)(`span`,{className:`mt-0.5 block truncate text-[10px] text-muted-foreground`,children:e.description})]}),e.tag&&(0,U.jsx)(`span`,{className:`mt-0.5 shrink-0 font-mono text-[9px] text-muted-foreground`,children:e.tag})]},e.value)}),d.length===0&&(0,U.jsx)(`div`,{className:`px-2 py-3 text-center text-[11px] text-muted-foreground`,children:e.length===0?i??`Nothing available`:`No match`})]})]})]})}function Je(e){let t=Math.max(0,Date.now()-Date.parse(e));return t<6e4?`just now`:t<36e5?`${Math.floor(t/6e4)}m ago`:`${Math.floor(t/36e5)}h ago`}function Ye(e,t){if(!e)return null;let n=Date.parse(e),r=t?Date.parse(t):Date.now();if(!Number.isFinite(n)||!Number.isFinite(r))return null;let i=Math.max(0,Math.floor((r-n)/1e3));if(i<60)return`${i}s`;let a=Math.floor(i/60);if(a<60)return`${a}m`;let o=Math.floor(a/60);return o<24?`${o}h`:`${Math.floor(o/24)}d`}function Xe({presence:e=[]}){return e.length===0?null:(0,U.jsxs)(`section`,{"aria-label":`Board presence`,className:`flex shrink-0 flex-wrap items-center gap-2 border-b border-border bg-card/50 px-4 py-2`,children:[(0,U.jsx)(`span`,{className:`text-[10px] font-semibold uppercase tracking-wider text-muted-foreground`,children:`Live board users`}),e.map(e=>(0,U.jsxs)(`span`,{className:`inline-flex min-w-0 items-center gap-1.5 rounded-full border border-border bg-background px-2.5 py-1 text-xs shadow-sm`,title:`Session ${e.sessionId} · last seen ${e.lastSeenAt}`,children:[(0,U.jsx)(`span`,{role:`img`,"aria-label":e.active?`active`:`inactive`,className:P(`h-2 w-2 shrink-0 rounded-full`,e.active?`bg-success`:`bg-muted-foreground/50`)}),(0,U.jsx)(l,{size:13,"aria-hidden":`true`}),(0,U.jsx)(`span`,{className:`max-w-32 truncate font-medium`,children:e.agentName??e.agentId}),(0,U.jsx)(`span`,{className:`max-w-32 truncate text-muted-foreground`,children:e.sessionId}),(0,U.jsx)(s,{size:12,className:`text-muted-foreground`,"aria-hidden":`true`}),(0,U.jsx)(`time`,{dateTime:e.lastSeenAt,className:`tabular-nums text-muted-foreground`,children:Je(e.lastSeenAt)})]},e.id))]})}function Ze({board:e,snapshot:t,sendKanban:n}){let[r,i]=(0,R.useState)(!1),[a,o]=(0,R.useState)(!0),[s,c]=(0,R.useState)(`deterministic`),[l,u]=(0,R.useState)(`session`),[d,f]=(0,R.useState)(``),[p,m]=(0,R.useState)(``),[g,_]=(0,R.useState)(``),[v,y]=(0,R.useState)([]),[b,S]=(0,R.useState)([]),[C,T]=(0,R.useState)(10),E=Se(r&&s===`agentic`),D=qe(r&&s===`agentic`);(0,R.useEffect)(()=>{let t=e.supervisor;o(t?.enabled??!0),c(t?.mode??`deterministic`),u(t?.routing?.mode??`session`),f(t?.routing?.provider??``),m(t?.routing?.model??``),_(t?.routing?.fallbackProfile??``),y(t?.routing?.fallbackModels??[]),S(t?.skills??[]),T(Math.max(2,Math.round((t?.intervalMs??1e4)/1e3)))},[e.id,e.supervisor]);let O=()=>{let t={mode:l,...l===`fixed`&&d?{provider:d}:{},...l===`fixed`&&p?{model:p}:{},...l===`fallback_profile`&&g?{fallbackProfile:g}:{},...v.length?{fallbackModels:v}:{}};n(`kanban.update`,{boardId:e.id,supervisor:{enabled:a,mode:s,intervalMs:Math.max(2,C)*1e3,recoveryMode:`auto`,...s===`agentic`?{routing:t,skills:b}:{}}}),window.setTimeout(()=>n(`kanban.supervisor.audit`,{boardId:e.id}),150)},te=a?t?.status??`starting`:`disabled`;return(0,U.jsxs)(`div`,{className:`shrink-0 border-b bg-background/80`,children:[(0,U.jsxs)(`button`,{type:`button`,onClick:()=>i(e=>!e),className:`flex w-full items-center gap-2 px-4 py-1.5 text-left text-[11px] hover:bg-muted/40`,children:[(0,U.jsx)(w,{size:13,className:te===`healthy`?`text-success`:`text-warning`}),(0,U.jsx)(`span`,{className:`font-semibold`,children:`Kanban Agent`}),(0,U.jsxs)(`span`,{className:`rounded bg-muted px-1.5 py-0.5 capitalize text-muted-foreground`,children:[s,` · `,te]}),t?.summary&&(0,U.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-muted-foreground`,children:t.summary}),(0,U.jsx)(`span`,{className:`ml-auto text-muted-foreground`,children:t?.lastAuditAt?`checked ${Ye(t.lastAuditAt)} ago`:`not checked`}),(0,U.jsx)(x,{size:13,className:P(`transition-transform`,r&&`rotate-180`)})]}),r&&(0,U.jsxs)(`div`,{className:`grid gap-3 border-t p-3 text-xs lg:grid-cols-[220px_220px_1fr_auto]`,children:[(0,U.jsxs)(`label`,{className:`flex items-center gap-2 rounded-md border bg-card px-2 py-2`,children:[(0,U.jsx)(`input`,{type:`checkbox`,checked:a,onChange:e=>o(e.target.checked)}),(0,U.jsx)(`span`,{children:`Watch this board`})]}),(0,U.jsx)(Qe,{label:`Supervisor engine`,value:s,options:[`deterministic`,`agentic`],onChange:e=>c(e)}),(0,U.jsxs)(`label`,{className:`block`,children:[(0,U.jsx)(`span`,{className:`mb-1 block text-[11px] font-medium text-muted-foreground`,children:`Audit interval (seconds)`}),(0,U.jsx)(`input`,{type:`number`,min:2,value:C,onChange:e=>T(Number(e.target.value)||2),className:`h-8 w-full rounded-md border bg-background px-2 outline-none focus:border-primary`})]}),(0,U.jsxs)(`div`,{className:`flex items-end gap-2`,children:[(0,U.jsxs)(`button`,{type:`button`,onClick:O,className:`inline-flex h-8 items-center gap-1 rounded-md bg-primary px-3 text-primary-foreground`,children:[(0,U.jsx)(ee,{size:13}),` Save`]}),(0,U.jsxs)(`button`,{type:`button`,onClick:()=>n(`kanban.supervisor.audit`,{boardId:e.id}),className:`inline-flex h-8 items-center gap-1 rounded-md border px-3 hover:bg-muted`,children:[(0,U.jsx)(h,{size:13}),` Audit now`]})]}),s===`deterministic`?(0,U.jsx)(`div`,{className:`lg:col-span-4 rounded-md border border-success/20 bg-success/5 px-3 py-2 text-muted-foreground`,children:`Deterministic mode uses no provider, model, token, or billing. It repairs assignment/status/column drift and recovers expired leases.`}):(0,U.jsxs)(`div`,{className:`grid gap-3 lg:col-span-4 lg:grid-cols-2`,children:[(0,U.jsx)(Qe,{label:`Kanban Agent model source`,value:l,options:[`session`,`fixed`,`fallback_profile`],onChange:e=>u(e)}),l===`fixed`&&(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`span`,{className:`mb-1 block text-[11px] font-medium text-muted-foreground`,children:`Fixed provider / model`}),(0,U.jsx)(Ce,{value:p||void 0,provider:d||void 0,candidates:E,placeholder:`Select exact provider / model…`,onPick:(e,t)=>{m(e),f(t)}})]}),l===`fallback_profile`&&(0,U.jsx)(Qe,{label:`Fallback profile (first model is primary)`,value:g,options:Object.keys(D.fallbackProfiles),placeholder:`Select configured profile…`,onChange:_}),(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`span`,{className:`mb-1 block text-[11px] font-medium text-muted-foreground`,children:`Supervisor skills`}),(0,U.jsx)(W,{options:D.skills.map(e=>({value:e.name,label:e.name,description:e.description,tag:e.source})),selected:b,onChange:S,placeholder:`Force-load agentic skills…`})]}),(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`span`,{className:`mb-1 block text-[11px] font-medium text-muted-foreground`,children:`Extra fallback models`}),(0,U.jsx)(W,{options:E.map(e=>({value:`${e.provider}/${e.model}`,label:e.label,tag:e.provider})),selected:v,onChange:y,placeholder:`Optional ordered fallbacks…`})]})]})]})]})}function Qe({label:e,value:t,options:n,onChange:r,placeholder:i}){return(0,U.jsxs)(`label`,{className:`block`,children:[(0,U.jsx)(`span`,{className:`mb-1 block text-[11px] font-medium text-muted-foreground`,children:e}),(0,U.jsxs)(`select`,{value:t,onChange:e=>r(e.target.value),className:`h-8 w-full rounded-md border bg-background px-2 text-xs outline-none focus:border-primary`,children:[i&&(0,U.jsx)(`option`,{value:``,children:i}),n.map(e=>(0,U.jsx)(`option`,{value:e,children:e},e))]})]})}function $e(e){let t=new Set;for(let n of e)n.status===`running`&&(t.add(n.id),t.add(n.name));return t}function et(e){let t=new Set;e.sessionId&&t.add(e.sessionId);for(let n of e.registrySessionIds)t.add(n);for(let n of e.agents)n.status===`running`&&n.sessionId&&t.add(n.sessionId);return[...t]}function tt(e,t){return e.presence?.some(e=>e.active)===!0||e.tags?.some(e=>e.startsWith(`session:`)&&t.includes(e.slice(8)))===!0}function nt(e){return e?e.tasks.filter(e=>e.status===`in_progress`||e.assignment?.status===`running`||e.assignment?.status===`queued`).reduce((e,t)=>e+(t.costCeilingUsd??0),0):0}function rt(e){let t=e?.tags??[],n=t.includes(`sdd`)?`sdd`:t.includes(`goal`)?`goal`:null;if(!n)return null;let r=t.find(e=>e.startsWith(`run:`))?.slice(4);return{engine:n,...r?{runId:r}:{}}}function it({boardTotal:e,activeBoardTotal:t,orphanedBoardTotal:n,activeBoardId:r,activeBoards:i,orphanedBoards:a,boardPage:o,boardPageSize:s,loading:c,newBoardTitle:l,onClose:u,onRefresh:d,onNewBoardTitleChange:p,onCreateBoard:m,onBoardSelect:h,onBoardPageChange:g}){return(0,U.jsxs)(`aside`,{className:`flex max-h-[45dvh] w-full shrink-0 flex-col border-b bg-card/40 md:max-h-none md:w-[280px] md:border-b-0 md:border-r`,children:[(0,U.jsxs)(`div`,{className:`flex h-12 items-center gap-2 border-b px-3`,children:[(0,U.jsx)(`button`,{type:`button`,title:`Back`,onClick:u,className:`flex h-8 w-8 items-center justify-center rounded-md text-muted-foreground hover:bg-muted hover:text-foreground`,children:(0,U.jsx)(he,{size:16})}),(0,U.jsx)(f,{size:17,className:`text-primary`}),(0,U.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,U.jsx)(`div`,{className:`truncate text-sm font-semibold`,children:`Kanban`}),(0,U.jsxs)(`div`,{className:`truncate text-[11px] text-muted-foreground`,children:[e,` boards · `,t,` active · `,n,` orphaned`]})]}),(0,U.jsx)(`button`,{type:`button`,title:`Refresh`,onClick:d,className:`flex h-8 w-8 items-center justify-center rounded-md text-muted-foreground hover:bg-muted hover:text-foreground`,children:(0,U.jsx)(O,{size:15,className:c?`animate-spin`:void 0})})]}),(0,U.jsxs)(`div`,{className:`flex gap-1 border-b p-2`,children:[(0,U.jsx)(`input`,{value:l,onChange:e=>p(e.target.value),onKeyDown:e=>{e.key===`Enter`&&m()},placeholder:`New board`,className:`min-w-0 flex-1 rounded-md border bg-background px-2 py-1.5 text-sm outline-none focus:border-primary`}),(0,U.jsx)(`button`,{type:`button`,title:`Create board`,onClick:m,className:`flex h-8 w-8 items-center justify-center rounded-md bg-primary text-primary-foreground hover:bg-primary/90`,children:(0,U.jsx)(M,{size:16})})]}),(0,U.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto overscroll-contain p-2`,children:[i.length>0&&(0,U.jsxs)(`div`,{className:`mb-1 px-2 py-1 text-[10px] font-semibold uppercase tracking-wider text-success`,children:[`Active session · `,t]}),i.map(e=>(0,U.jsx)(at,{board:e,active:r===e.id,dotClassName:`bg-success`,onSelect:h},e.id)),a.length>0&&(0,U.jsxs)(`div`,{className:`mb-1 mt-2 px-2 py-1 text-[10px] font-semibold uppercase tracking-wider text-muted-foreground`,children:[`No active session · `,n]}),a.map(e=>(0,U.jsx)(at,{board:e,active:r===e.id,dotClassName:`bg-muted-foreground/45`,onSelect:h},e.id))]}),(0,U.jsx)(I,{page:o,pageSize:s,totalItems:e,onPageChange:g,compact:!0,itemLabel:`boards`})]})}function at({board:e,active:t,dotClassName:n,onSelect:r}){return(0,U.jsxs)(`button`,{type:`button`,onClick:()=>r(e.id),className:P(`mb-1 w-full rounded-md px-2 py-2 text-left transition-colors`,t?`bg-primary/10 text-foreground`:`text-muted-foreground hover:bg-muted hover:text-foreground`),children:[(0,U.jsx)(`div`,{className:`truncate text-sm font-medium`,children:e.title}),(0,U.jsxs)(`div`,{className:`mt-0.5 flex items-center justify-between text-[11px]`,children:[(0,U.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,U.jsx)(`span`,{className:P(`h-1.5 w-1.5 rounded-full`,n)}),e.taskCount,` tasks`]}),(0,U.jsxs)(`span`,{children:[e.completedTaskCount,` done`]})]})]})}var ot={enabled:!1,enforcement:`confirm`,shellAccess:`confirm`,allow:[]};function st({title:e,value:t,inherited:n,onSave:r}){let[i,a]=(0,R.useState)(t??ot),[o,s]=(0,R.useState)(lt(t?.allow??[])),[c,l]=(0,R.useState)(lt(t?.deny??[])),[u,d]=(0,R.useState)(null);return(0,R.useEffect)(()=>{a(t??ot),s(lt(t?.allow??[])),l(lt(t?.deny??[])),d(null)},[t]),(0,U.jsxs)(`details`,{className:`rounded-md border border-primary/25 bg-primary/5`,children:[(0,U.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center gap-2 px-3 py-2 text-xs font-semibold`,children:[(0,U.jsx)(w,{size:14,className:`text-primary`}),(0,U.jsx)(`span`,{children:e}),(0,U.jsx)(`span`,{className:`ml-auto font-normal text-muted-foreground`,children:t?.enabled?`${t.enforcement} · ${t.allow.length} allow · shell ${t.shellAccess}`:n?.enabled?`inherits board boundary`:`unrestricted`})]}),(0,U.jsxs)(`div`,{className:`space-y-2 border-t p-3 text-xs`,children:[n?.enabled&&(0,U.jsx)(`div`,{className:`rounded border border-warning/25 bg-warning/10 px-2 py-1.5 text-muted-foreground`,children:`Board policy remains authoritative. This task policy can only narrow that scope.`}),(0,U.jsxs)(`label`,{className:`flex items-center gap-2`,children:[(0,U.jsx)(`input`,{type:`checkbox`,checked:i.enabled,onChange:e=>a({...i,enabled:e.target.checked})}),`Enable this boundary layer`]}),(0,U.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,U.jsxs)(`label`,{children:[(0,U.jsx)(`span`,{className:`mb-1 block text-[10px] font-medium uppercase text-muted-foreground`,children:`Outside scope`}),(0,U.jsxs)(`select`,{value:i.enforcement,onChange:e=>a({...i,enforcement:e.target.value}),className:`h-8 w-full rounded border bg-background px-2`,children:[(0,U.jsx)(`option`,{value:`confirm`,children:`Ask permission`}),(0,U.jsx)(`option`,{value:`block`,children:`Always block`})]})]}),(0,U.jsxs)(`label`,{children:[(0,U.jsx)(`span`,{className:`mb-1 block text-[10px] font-medium uppercase text-muted-foreground`,children:`Shell / opaque tools`}),(0,U.jsxs)(`select`,{value:i.shellAccess,onChange:e=>a({...i,shellAccess:e.target.value}),className:`h-8 w-full rounded border bg-background px-2`,children:[(0,U.jsx)(`option`,{value:`confirm`,children:`Ask permission`}),(0,U.jsx)(`option`,{value:`block`,children:`Always block`}),(0,U.jsx)(`option`,{value:`allow`,children:`Allow`})]})]})]}),(0,U.jsx)(ct,{label:`Allow selectors`,value:o,onChange:s}),(0,U.jsx)(ct,{label:`Deny selectors`,value:c,onChange:l}),(0,U.jsx)(`div`,{className:`text-[10px] text-muted-foreground`,children:`One per line: kind:access:path — for example directory:read_write:packages/webui or file:read:README.md. Kinds: file, directory, package, glob. If an access type has no allow selector, it remains unrestricted except for deny rules. Shell “Allow” is opaque and can cross path selectors.`}),u&&(0,U.jsx)(`div`,{className:`text-destructive`,children:u}),(0,U.jsxs)(`div`,{className:`flex gap-2`,children:[(0,U.jsxs)(`button`,{type:`button`,onClick:()=>{try{let e=ut(o),t=ut(c);r({...i,allow:e,...t.length?{deny:t}:{}}),d(null)}catch(e){d(e instanceof Error?e.message:String(e))}},className:`inline-flex h-8 flex-1 items-center justify-center gap-2 rounded bg-primary text-primary-foreground`,children:[(0,U.jsx)(ee,{size:13}),` Save boundary`]}),t&&(0,U.jsx)(`button`,{type:`button`,onClick:()=>r(null),className:`h-8 rounded border px-3 text-muted-foreground hover:bg-muted`,children:`Remove layer`})]})]})]})}function ct({label:e,value:t,onChange:n}){return(0,U.jsxs)(`label`,{className:`block`,children:[(0,U.jsx)(`span`,{className:`mb-1 block text-[10px] font-medium uppercase text-muted-foreground`,children:e}),(0,U.jsx)(`textarea`,{rows:3,value:t,onChange:e=>n(e.target.value),className:`w-full resize-y rounded border bg-background px-2 py-1.5 font-mono text-[11px] outline-none focus:border-primary`})]})}function lt(e){return e.map(e=>`${e.kind}:${e.access}:${e.path}`).join(`
2
- `)}function ut(e){let t=new Set([`file`,`directory`,`package`,`glob`]),n=new Set([`read`,`write`,`read_write`]);return e.split(/\r?\n/).map(e=>e.trim()).filter(Boolean).map((e,r)=>{let i=e.indexOf(`:`),a=e.indexOf(`:`,i+1);if(i<=0||a<=i+1||a===e.length-1)throw Error(`Boundary line ${r+1} must use kind:access:path.`);let o=e.slice(0,i),s=e.slice(i+1,a),c=e.slice(a+1).trim();if(!t.has(o))throw Error(`Boundary line ${r+1} has unknown kind.`);if(!n.has(s))throw Error(`Boundary line ${r+1} has unknown access.`);return{kind:o,access:s,path:c}})}function dt({audit:e,onSelectTask:t}){let[n,r]=(0,R.useState)(!0),i=(0,R.useId)();if((0,R.useEffect)(()=>{e.issues.length>0&&r(!0)},[e.issues.length]),e.issues.length===0)return null;let a=ft(e.issues);return(0,U.jsxs)(`section`,{"aria-labelledby":`${i}-title`,className:`shrink-0 border-b border-warning/25 bg-card/95 shadow-[inset_0_1px_0_hsl(var(--warning)/0.08)]`,children:[(0,U.jsxs)(`div`,{className:`flex min-h-10 flex-wrap items-center gap-2 px-3 py-2 sm:px-4`,children:[(0,U.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-2`,role:`status`,"aria-live":`polite`,children:[(0,U.jsx)(`span`,{className:`flex h-7 w-7 shrink-0 items-center justify-center rounded-md border border-warning/25 bg-warning/10 text-warning`,children:(0,U.jsx)(y,{size:14,"aria-hidden":`true`})}),(0,U.jsxs)(`div`,{className:`min-w-0`,children:[(0,U.jsxs)(`h2`,{id:`${i}-title`,className:`text-xs font-semibold text-foreground`,children:[`Kanban Cleaner found `,e.issues.length,` `,e.issues.length===1?`issue`:`issues`]}),(0,U.jsxs)(`p`,{className:`truncate text-[10px] text-muted-foreground`,children:[e.affectedTaskCount,` `,e.affectedTaskCount===1?`card needs`:`cards need`,` attention`]})]})]}),e.counts.error>0&&(0,U.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full border border-destructive/25 bg-destructive/10 px-2 py-0.5 text-[10px] font-medium text-destructive`,children:[(0,U.jsx)(g,{size:11,"aria-hidden":`true`}),` `,e.counts.error,` critical`]}),e.counts.warning>0&&(0,U.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded-full border border-warning/25 bg-warning/10 px-2 py-0.5 text-[10px] font-medium text-warning`,children:[(0,U.jsx)(c,{size:11,"aria-hidden":`true`}),` `,e.counts.warning,` warning`]}),(0,U.jsx)(`button`,{type:`button`,"aria-expanded":n,"aria-controls":i,"aria-label":n?`Collapse Kanban Cleaner issues`:`Expand Kanban Cleaner issues`,onClick:()=>r(e=>!e),className:`flex h-7 w-7 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-muted hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,children:(0,U.jsx)(x,{size:14,"aria-hidden":`true`,className:P(`transition-transform`,n&&`rotate-180`)})})]}),n&&(0,U.jsx)(`ul`,{id:i,className:`grid max-h-36 gap-1 overflow-y-auto px-3 pb-2 sm:grid-cols-2 sm:px-4 xl:grid-cols-3`,children:a.map(({taskId:e,taskTitle:n,issues:r})=>(0,U.jsx)(`li`,{children:(0,U.jsxs)(`button`,{type:`button`,onClick:()=>t(e),"aria-label":`Open ${n}: ${r.map(e=>e.message).join(`, `)}`,className:`group flex w-full items-start gap-2 rounded-md border border-border/70 bg-background/70 px-2.5 py-2 text-left transition-colors hover:border-primary/40 hover:bg-primary/5 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-primary`,children:[(0,U.jsx)(`span`,{className:P(`mt-1 h-1.5 w-1.5 shrink-0 rounded-full`,r.some(e=>e.severity===`error`)?`bg-destructive shadow-[0_0_8px_hsl(var(--destructive)/0.55)]`:`bg-warning shadow-[0_0_8px_hsl(var(--warning)/0.45)]`),"aria-hidden":`true`}),(0,U.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,U.jsx)(`span`,{className:`block truncate text-[11px] font-semibold text-foreground group-hover:text-primary`,children:n}),(0,U.jsx)(`span`,{className:`mt-0.5 block line-clamp-2 text-[10px] leading-4 text-muted-foreground`,children:r.map(e=>e.message).join(` · `)})]})]})},e))})]})}function ft(e){let t=new Map;for(let n of e){let e=t.get(n.taskId);e?e.issues.push(n):t.set(n.taskId,{taskId:n.taskId,taskTitle:n.taskTitle,issues:[n]})}return[...t.values()]}function pt({board:e,sendKanban:t,onSelectTask:n}){let[r,i]=(0,R.useState)(!1),a=e.tasks.filter(e=>e.decomposition?.status===`proposed`);return a.length?(0,U.jsxs)(`div`,{className:`shrink-0 border-b border-warning/30 bg-warning/5 px-4 py-2`,children:[(0,U.jsxs)(`button`,{type:`button`,onClick:()=>i(e=>!e),className:`flex w-full items-center gap-2 text-left text-xs font-semibold text-warning`,children:[r?(0,U.jsx)(ce,{size:13}):(0,U.jsx)(x,{size:13}),(0,U.jsx)(me,{size:13}),a.length,` decomposition proposal`,a.length>1?`s`:``,` awaiting approval`]}),!r&&(0,U.jsx)(`ul`,{className:`mt-1.5 space-y-1`,children:a.map(r=>(0,U.jsxs)(`li`,{className:`flex items-center gap-2 text-xs`,children:[(0,U.jsxs)(`button`,{type:`button`,onClick:()=>n(r.id),className:`min-w-0 flex-1 truncate text-left hover:underline`,children:[r.title,(0,U.jsxs)(`span`,{className:`ml-1.5 text-muted-foreground`,children:[`→ `,r.decomposition?.proposedSubtasks.length??0,` subtasks`]})]}),(0,U.jsxs)(`button`,{type:`button`,onClick:()=>t(`kanban.decomposition.approve`,{boardId:e.id,taskId:r.id,proposalId:r.decomposition.id}),className:`inline-flex items-center gap-1 rounded-md bg-success/10 px-2 py-1 text-[11px] font-medium text-success hover:bg-success/20`,children:[(0,U.jsx)(b,{size:12}),` Approve`]}),(0,U.jsxs)(`button`,{type:`button`,onClick:()=>t(`kanban.decomposition.reject`,{boardId:e.id,taskId:r.id,proposalId:r.decomposition.id}),className:`inline-flex items-center gap-1 rounded-md bg-destructive/10 px-2 py-1 text-[11px] font-medium text-destructive hover:bg-destructive/20`,children:[(0,U.jsx)(E,{size:12}),` Reject`]})]},r.id))})]}):null}var mt=[`assessed`,`proposed`,`approval`,`applied`];function ht(e){let t=e.decomposition?.status;return t===`applied`?3:t===`approved`||t===`rejected`?2:t===`proposed`?1:e.atomicityAssessment?0:-1}function gt({board:e,task:t,sendKanban:n,onSelectTask:r}){let i=t.decomposition,a=ht(t),o=(0,R.useMemo)(()=>{if(!i)return null;let n=(i.appliedChildTaskIds??[]).map(t=>e.tasks.find(e=>e.id===t)).filter(e=>!!e);return{tasks:[{id:t.id,shortId:`parent`,title:t.title,displayStatus:i.status===`applied`?`completed`:`in_progress`,priority:t.priority,deps:[]},...i.proposedSubtasks.map((e,r)=>{let a=n[r];return{id:a?.id??`proposed-${r}`,shortId:`s${r}`,title:e.title,displayStatus:a?a.status===`completed`?`completed`:a.status===`failed`?`failed`:a.status===`in_progress`?`in_progress`:`pending`:i.status===`approved`?`queued`:`pending`,priority:t.priority,deps:(e.dependsOnIndex??[]).map(e=>`s${e}`)}})],columns:[{label:`Parent`,taskIds:[`parent`]},{label:i.status===`applied`?`Subtasks`:`Proposed subtasks`,taskIds:i.proposedSubtasks.map((e,t)=>`s${t}`)}],appliedChildren:n}},[e,i,t]);return!i&&!t.atomicityAssessment?null:(0,U.jsxs)(`div`,{className:`mt-4 rounded-md border p-3`,children:[(0,U.jsxs)(`div`,{className:`mb-2 flex items-center gap-2 text-xs font-semibold uppercase text-muted-foreground`,children:[(0,U.jsx)(me,{size:13}),`Decomposition`]}),(0,U.jsxs)(`div`,{className:`mb-2 flex items-center gap-1 text-[11px]`,children:[mt.map((e,t)=>(0,U.jsxs)(`div`,{className:`flex items-center gap-1`,children:[t>0&&(0,U.jsx)(`span`,{className:`text-muted-foreground/50`,children:`→`}),(0,U.jsx)(`span`,{className:P(`rounded px-1.5 py-0.5`,i?.status===`rejected`&&t===2?`bg-destructive/10 text-destructive`:t<=a?`bg-primary/10 font-medium text-primary`:`bg-muted text-muted-foreground`),children:i?.status===`rejected`&&t===2?`rejected`:e})]},e)),t.atomicityAssessment&&(0,U.jsxs)(`span`,{className:`ml-auto text-muted-foreground`,children:[t.atomicityAssessment.verdict,` · score `,t.atomicityAssessment.score]})]}),!i&&t.atomicityAssessment?.verdict===`needs_decomposition`&&(0,U.jsxs)(`div`,{className:`rounded-md border border-warning/30 bg-warning/5 p-2 text-[11px] text-warning`,children:[`This task should be split before dispatch:`,(0,U.jsx)(`ul`,{className:`ml-4 mt-1 list-disc`,children:t.atomicityAssessment.criteria.filter(e=>e.score<1).map(e=>(0,U.jsx)(`li`,{children:e.reason},e.id))})]}),i&&o&&(0,U.jsxs)(U.Fragment,{children:[i.rationale&&(0,U.jsxs)(`div`,{className:`mb-2 text-[11px] text-muted-foreground`,children:[`“`,i.rationale,`”`]}),(0,U.jsx)(`div`,{className:`h-64 overflow-hidden rounded-md border`,children:(0,U.jsx)(Ee,{tasks:o.tasks,columns:o.columns,onTaskClick:t=>{e.tasks.some(e=>e.id===t)&&r(t)}})}),(0,U.jsx)(`ul`,{className:`mt-2 space-y-1 text-[11px]`,children:i.proposedSubtasks.map((e,t)=>(0,U.jsxs)(`li`,{className:`rounded bg-muted/40 px-2 py-1`,children:[(0,U.jsx)(`span`,{className:`font-medium`,children:e.title}),e.successCriteria?.length?(0,U.jsxs)(`span`,{className:`ml-1.5 text-muted-foreground`,children:[`✓ `,e.successCriteria.join(` · `)]}):null]},`${e.title}-${t}`))}),i.status===`proposed`&&(0,U.jsxs)(`div`,{className:`mt-2 flex gap-1.5`,children:[(0,U.jsxs)(`button`,{type:`button`,onClick:()=>n(`kanban.decomposition.approve`,{boardId:e.id,taskId:t.id,proposalId:i.id}),className:`inline-flex items-center gap-1 rounded-md bg-success/10 px-2.5 py-1.5 text-xs font-medium text-success hover:bg-success/20`,children:[(0,U.jsx)(b,{size:13}),` Approve & split`]}),(0,U.jsxs)(`button`,{type:`button`,onClick:()=>n(`kanban.decomposition.reject`,{boardId:e.id,taskId:t.id,proposalId:i.id}),className:`inline-flex items-center gap-1 rounded-md bg-destructive/10 px-2.5 py-1.5 text-xs font-medium text-destructive hover:bg-destructive/20`,children:[(0,U.jsx)(E,{size:13}),` Reject`]})]}),i.status===`applied`&&o.appliedChildren.length>0&&(0,U.jsx)(`div`,{className:`mt-2 flex flex-wrap gap-1.5`,children:o.appliedChildren.map(e=>(0,U.jsxs)(`button`,{type:`button`,onClick:()=>r(e.id),className:`rounded-md border px-2 py-1 text-[11px] hover:bg-muted`,children:[e.title,(0,U.jsxs)(`span`,{className:`ml-1 text-muted-foreground`,children:[`[`,e.status,`]`]})]},e.id))}),i.status===`rejected`&&i.resolutionReason&&(0,U.jsxs)(`div`,{className:`mt-2 text-[11px] text-muted-foreground`,children:[`Rejected: `,i.resolutionReason]})]})]})}var _t=[`id`,`name`,`type`];function G(e){if(typeof e==`string`)return e.trim()||void 0;if(typeof e==`number`||typeof e==`boolean`)return String(e);if(!e||typeof e!=`object`||Array.isArray(e))return;let t=e;for(let e of _t){let n=t[e];if(typeof n==`string`&&n.trim())return n.trim()}}function vt(e,t){return t?`running`:e.verificationReport?.verdict||`unverified`}var yt=new Set([`completed`,`review`,`failed`]);function bt(e){let t={totalTasks:e.tasks.length,gradedTasks:0,passed:0,failed:0,needsHuman:0,incomplete:0,unverified:0,failingChecks:[],missingEvidence:[],needsDecomposition:[],pendingProposals:[]};for(let n of e.tasks){if(n.status===`archived`)continue;let e=n.verificationReport;if(yt.has(n.status)&&(t.gradedTasks+=1,e?e.verdict===`passed`?t.passed+=1:e.verdict===`failed`?t.failed+=1:e.verdict===`needs_human`?t.needsHuman+=1:t.incomplete+=1:t.unverified+=1),e)for(let r of e.checks)(r.status===`failed`||r.status===`error`)&&t.failingChecks.push({task:n,check:r}),(r.type===`agent`||r.type===`council`)&&r.status===`passed`&&!r.backingRefs?.length&&t.missingEvidence.push({task:n,check:r});!n.childTaskIds?.length&&n.atomicityAssessment?.verdict===`needs_decomposition`&&n.status!==`completed`&&t.needsDecomposition.push(n),n.decomposition?.status===`proposed`&&t.pendingProposals.push(n)}return t}function xt(e){let t=new Map(e.tasks.map(e=>[e.id,e])),n=new Set,r=(e,i)=>{n.add(e.id);let a=e.childTaskIds??[],o=[];for(let e of a){let a=t.get(e);!a||n.has(a.id)||o.push(r(a,i+1))}return{task:e,children:o,depth:i}},i=[];for(let a of e.tasks)a.parentTaskId&&t.get(a.parentTaskId)||n.has(a.id)||i.push(r(a,0));return i}function St(e){let t=[],n=e=>{t.push(e);for(let t of e.children)n(t)};for(let t of e)n(t);return t}function Ct(e,t){return e?.columns.find(e=>e.id===t)?.title??t}function wt({label:e,value:t}){return(0,U.jsxs)(`div`,{className:`rounded-md border bg-background px-2 py-1.5`,children:[(0,U.jsx)(`div`,{className:`text-[10px] uppercase text-muted-foreground`,children:e}),(0,U.jsx)(`div`,{className:`mt-0.5 truncate text-xs font-medium`,children:t})]})}function K({label:e,value:t,onChange:n}){return(0,U.jsxs)(`label`,{className:`block`,children:[(0,U.jsx)(`span`,{className:`mb-1 block text-[11px] font-medium text-muted-foreground`,children:e}),(0,U.jsx)(`input`,{value:t,onChange:e=>n(e.target.value),className:`h-8 w-full rounded-md border bg-background px-2 text-sm outline-none focus:border-primary`})]})}function q({label:e,value:t,options:n,placeholder:r,onChange:i}){return(0,U.jsxs)(`label`,{className:`block`,children:[(0,U.jsx)(`span`,{className:`mb-1 block text-[11px] font-medium text-muted-foreground`,children:e}),(0,U.jsxs)(`select`,{value:t,onChange:e=>i(e.target.value),className:`h-8 w-full rounded-md border bg-background px-2 text-sm outline-none focus:border-primary`,children:[r&&(0,U.jsx)(`option`,{value:``,children:r}),n.map(e=>(0,U.jsx)(`option`,{value:e,children:e},e))]})]})}function Tt(e){let t=`rounded px-1.5 py-0.5`;return e===`critical`?`${t} bg-destructive/10 text-destructive`:e===`high`?`${t} bg-warning/10 text-warning`:e===`low`?`${t} bg-muted text-muted-foreground`:`${t} bg-info/10 text-info`}function Et(e){return e&&typeof e==`object`&&!Array.isArray(e)?e:{}}function Dt(e){return e===`completed`||e===`failed`||e===`cancelled`}function Ot(e,t){return t?Math.round(e/t*100):0}function kt(e,t,n,r=new Date){let i=[],a=n.filter(e=>e.taskId===t.id),o=a.filter(e=>e.type!==`task.created`),s=o.filter(e=>e.type!==`task.assignment.heartbeat`&&e.type!==`task.assignment.snapshot`),c=s.filter(e=>!!e.note?.trim()),l=t.assignment,u=r.getTime(),d=100,f=(e,t=0)=>{i.some(t=>t.id===e.id)||(i.push(e),d=Math.max(0,d-t))};t.dueDate&&![`completed`,`archived`].includes(t.status)&&Date.parse(t.dueDate)<u&&f({id:`overdue`,severity:`critical`,category:`operational`,title:`Task is overdue`,detail:`Due date ${t.dueDate} has passed while status is ${t.status}.`,remediation:`Re-plan the due date or record the blocker and owner response.`});let p=(t.dependsOn??[]).filter(t=>!e.tasks.some(e=>e.id===t));p.length&&f({id:`missing-dependency`,severity:`critical`,category:`operational`,title:`Dependency references are broken`,detail:`${p.length} dependency task${p.length===1?``:`s`} cannot be found.`,remediation:`Repair or remove the missing dependency IDs before dispatch.`});let m=(t.dependsOn??[]).filter(t=>{let n=e.tasks.find(e=>e.id===t);return n&&![`completed`,`archived`].includes(n.status)});m.length&&f({id:`unresolved-dependency`,severity:`warning`,category:`operational`,title:`Dependencies are unresolved`,detail:`${m.length} dependency task${m.length===1?``:`s`} still block execution.`,remediation:`Complete dependencies or explicitly waive them with a decision event.`}),(l?.status===`failed`||l?.error)&&f({id:`assignment-failed`,severity:`critical`,category:`operational`,title:`Latest agent run failed`,detail:l.error??l.lastFailureKind??`Assignment status is failed.`,remediation:`Review the failed attempt evidence, adjust routing, then retry or block the task.`}),l?.status===`failed`&&l.maxAttempts!==void 0&&(l.attempt??0)>=l.maxAttempts&&f({id:`retry-exhausted`,severity:`critical`,category:`operational`,title:`Retry budget is exhausted`,detail:`${l.attempt??0}/${l.maxAttempts} attempts have been consumed.`,remediation:`Escalate for a new route or explicitly increase the attempt budget.`}),l&&[`queued`,`running`].includes(l.status)&&l.leaseExpiresAt&&Date.parse(l.leaseExpiresAt)<=u&&f({id:`lease-expired`,severity:`critical`,category:`operational`,title:`Assignment lease has expired`,detail:`Lease expired at ${l.leaseExpiresAt} while run status is ${l.status}.`,remediation:`Recover, release, or retry the stale assignment.`}),l?.status===`running`&&l.heartbeatAt&&u-Date.parse(l.heartbeatAt)>5*6e4&&f({id:`heartbeat-stale`,severity:`warning`,category:`operational`,title:`Agent heartbeat is stale`,detail:`No heartbeat has been recorded since ${l.heartbeatAt}.`,remediation:`Inspect the subagent/run and recover the assignment if it is no longer alive.`}),t.status===`in_progress`&&!l&&f({id:`unowned-in-progress`,severity:`warning`,category:`operational`,title:`In-progress task has no assignment`,detail:`The task claims active work but has no inspectable agent assignment.`,remediation:`Assign an agent or return the task to ready/blocked.`});let h=(t.successCriteria??[]).filter(e=>e.status===`failed`),g=(t.successCriteria??[]).filter(e=>e.status===`pending`);h.length&&f({id:`failed-checks`,severity:t.status===`completed`?`critical`:`warning`,category:`operational`,title:`Acceptance checks failed`,detail:`${h.length} completion check${h.length===1?``:`s`} failed.`,remediation:`Resolve or explicitly waive failed acceptance evidence.`}),t.status===`completed`&&g.length&&f({id:`completed-with-pending-checks`,severity:`critical`,category:`operational`,title:`Completed task still has pending checks`,detail:`${g.length} acceptance check${g.length===1?``:`s`} remain pending.`,remediation:`Move the task back to review or complete the missing checks.`}),a.length?a.some(e=>e.type===`task.created`)||f({id:`missing-creation-event`,severity:`warning`,category:`audit`,title:`Creation provenance is missing`,detail:`The loaded event range does not contain task.created.`,remediation:`Load deeper history or record the legacy origin explicitly.`},10):f({id:`no-durable-events`,severity:`critical`,category:`audit`,title:`No durable activity events loaded`,detail:`Current state cannot be traced to an append-only task event.`,remediation:`Refresh activity; migrate legacy state or record an observation event.`},25);let _=Ot(o.filter(e=>!!e.actor).length,o.length),v=Ot(o.filter(e=>!!e.sessionId).length,o.length),y=Ot(c.length,s.length);o.length&&_<100&&f({id:`actor-coverage`,severity:`warning`,category:`audit`,title:`Some mutations have no actor`,detail:`Actor coverage is ${_}%.`,remediation:`Ensure every route/tool mutation supplies agent or operator identity.`},10),o.length&&v<100&&f({id:`session-coverage`,severity:`warning`,category:`audit`,title:`Some mutations have no session`,detail:`Session coverage is ${v}%.`,remediation:`Propagate session identity into all task event contexts.`},10),s.length&&y<50&&f({id:`reason-coverage`,severity:`info`,category:`audit`,title:`Decision rationale is sparse`,detail:`Only ${y}% of mutations include a reason or outcome.`,remediation:`Use the change-reason and decision/outcome fields for meaningful mutations.`},10);let b={...Et([...a].sort((e,t)=>t.ts.localeCompare(e.ts)).find(e=>e.type===`task.assigned`||e.type.startsWith(`task.assignment.`))?.after),...l??{}},x=!!(b.provider||b.model||b.modelRouting);l&&!x&&f({id:`missing-route`,severity:`warning`,category:`audit`,title:`Execution route is not inspectable`,detail:`Assignment has no routing mode, provider, or model.`,remediation:`Reassign with explicit session/fixed/fallback routing metadata.`},10);let S=!!(l?.lastResult||l?.error||a.some(e=>Dt(String(Et(e.after).status??``))&&!!e.note?.trim()));return Dt(l?.status)&&!S&&f({id:`missing-terminal-evidence`,severity:`critical`,category:`audit`,title:`Terminal run has no result or error evidence`,detail:`Assignment ended as ${l?.status} without an inspectable output.`,remediation:`Record the final result/error and supporting evidence.`},15),i.sort((e,t)=>{let n={critical:0,warning:1,info:2};return n[e.severity]-n[t.severity]}),{score:d,findings:i,critical:i.filter(e=>e.severity===`critical`).length,warnings:i.filter(e=>e.severity===`warning`).length,coverage:{durableEvents:a.length,actorPercent:_,sessionPercent:v,reasonPercent:y,hasExecutionRoute:x,hasTerminalEvidence:S}}}function At(e){return e===`critical`?`border-destructive/30 bg-destructive/5 text-destructive`:e===`warning`?`border-warning/30 bg-warning/5 text-warning`:`border-info/30 bg-info/5 text-info`}function jt({board:e,task:t,events:n}){let r=kt(e,t,n),i=we(r.findings,8,t.id);return(0,U.jsxs)(`details`,{open:!0,className:`mt-3 rounded-md border border-border/70 bg-muted/10`,children:[(0,U.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center gap-2 px-3 py-2.5 [&::-webkit-details-marker]:hidden`,children:[(0,U.jsx)(u,{className:`size-4 text-primary`}),(0,U.jsx)(`span`,{className:`text-xs font-semibold`,children:`Risk & audit quality`}),(0,U.jsxs)(`span`,{className:`rounded px-1.5 py-0.5 text-[9px] ${r.score>=90?`bg-success/10 text-success`:r.score>=70?`bg-warning/10 text-warning`:`bg-destructive/10 text-destructive`}`,children:[`audit `,r.score,`/100`]}),r.critical>0&&(0,U.jsxs)(`span`,{className:`rounded bg-destructive/10 px-1.5 py-0.5 text-[9px] text-destructive`,children:[r.critical,` critical`]}),(0,U.jsx)(x,{className:`ml-auto size-3.5 text-muted-foreground`})]}),(0,U.jsxs)(`div`,{className:`space-y-2 border-t border-border/60 p-2.5`,children:[(0,U.jsx)(`div`,{className:`grid grid-cols-3 gap-1 text-center sm:grid-cols-6`,children:[[`Events`,r.coverage.durableEvents],[`Actor`,`${r.coverage.actorPercent}%`],[`Session`,`${r.coverage.sessionPercent}%`],[`Reasons`,`${r.coverage.reasonPercent}%`],[`Route`,r.coverage.hasExecutionRoute?`yes`:`no`],[`Outcome`,r.coverage.hasTerminalEvidence?`yes`:`no`]].map(([e,t])=>(0,U.jsxs)(`div`,{className:`rounded border bg-background/70 px-1 py-1.5`,children:[(0,U.jsx)(`div`,{className:`text-[11px] font-semibold`,children:t}),(0,U.jsx)(`div`,{className:`text-[8px] uppercase text-muted-foreground`,children:e})]},String(e)))}),r.findings.length===0?(0,U.jsxs)(`div`,{className:`flex items-center gap-2 rounded border border-success/30 bg-success/5 px-2.5 py-2 text-[11px] text-success`,children:[(0,U.jsx)(v,{className:`size-4`}),` No deterministic task risks detected.`]}):(0,U.jsxs)(`div`,{className:`space-y-1.5`,children:[i.pageItems.map(e=>(0,U.jsxs)(`section`,{className:`rounded border px-2.5 py-2 ${At(e.severity)}`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-1.5 text-[11px] font-semibold`,children:[e.category===`audit`?(0,U.jsx)(te,{className:`size-3.5`}):(0,U.jsx)(c,{className:`size-3.5`}),e.title,(0,U.jsxs)(`span`,{className:`ml-auto text-[8px] uppercase opacity-75`,children:[e.category,` · `,e.severity]})]}),(0,U.jsx)(`p`,{className:`mt-1 text-[10px] leading-4 opacity-90`,children:e.detail}),(0,U.jsxs)(`p`,{className:`mt-1 text-[9px] leading-4 opacity-75`,children:[(0,U.jsx)(`strong`,{children:`Next:`}),` `,e.remediation]})]},e.id)),(0,U.jsx)(I,{page:i.page,pageSize:i.pageSize,totalItems:i.totalItems,onPageChange:i.setPage,compact:!0,itemLabel:`risk findings`})]})]})]})}function Mt(e,t,n){let r=t.assignment,i=kt(e,t,[]).findings.filter(e=>e.category===`operational`),a=G(r?.provider),o=G(r?.model);return{owner:G(r?.name)??G(r?.agentId)??G(r?.role)??G(t.assignee)??G(t.assignedAgent)??`Unassigned`,route:a||o?`${a?`${a}/`:``}${o??`default`}`:r?.modelRouting===`session`?`session default`:`default route`,blockers:(t.dependsOn??[]).filter(t=>{let n=e.tasks.find(e=>e.id===t);return!n||![`completed`,`archived`].includes(n.status)}).length,attempts:r?.attempt?`${r.attempt}${r.maxAttempts?`/${r.maxAttempts}`:``}`:`0`,fallbackCount:+!!r?.fallbackProfile+(r?.fallbackModels?.length??0),activeUsers:(e.presence??[]).filter(e=>e.taskId===t.id&&e.active).length,failed:t.status===`failed`||r?.status===`failed`||!!r?.error,criticalRisks:i.filter(e=>e.severity===`critical`).length,warningRisks:i.filter(e=>e.severity===`warning`).length,verification:vt(t,n?.[`${e.id}:${t.id}`]),subtaskCounts:(()=>{let n=t.childTaskIds??[];if(!n.length)return null;let r=n.map(t=>e.tasks.find(e=>e.id===t)).filter(e=>!!e);return r.length?{done:r.filter(e=>[`completed`,`review`,`archived`].includes(e.status)).length,total:r.length}:null})(),atomicityVerdict:t.atomicityAssessment?.verdict??null,evidenceCount:t.verificationReport?.attachments.length??0,pendingDecomposition:t.decomposition?.status===`proposed`}}function Nt({board:e,column:t,selectedTaskId:n,dragTaskId:r,setDragTaskId:i,onSelectTask:a,onDeleteTask:o,onMoveTask:s}){let c=xe(e=>e.verificationActivity),l=e.tasks.filter(e=>e.columnId===t.id).sort((e,t)=>e.order-t.order);return(0,U.jsxs)(`section`,{className:P(`flex h-full shrink-0 flex-col rounded-md border bg-muted/25 transition-[width] duration-200`,l.length===0?`w-[180px]`:`w-[310px]`),children:[(0,U.jsxs)(`div`,{className:`flex h-10 shrink-0 items-center gap-2 border-b px-3`,children:[(0,U.jsx)(`span`,{className:`h-2.5 w-2.5 rounded-full`,style:{background:t.color??`hsl(var(--primary))`}}),(0,U.jsx)(`div`,{className:`min-w-0 flex-1 truncate text-sm font-semibold`,children:t.title}),(0,U.jsx)(`span`,{className:`rounded bg-background px-1.5 py-0.5 text-[11px] text-muted-foreground`,children:l.length})]}),(0,U.jsx)(`ul`,{className:`min-h-0 flex-1 space-y-2 overflow-y-auto p-2 [scrollbar-gutter:stable]`,onDragOver:e=>e.preventDefault(),onDrop:n=>{n.preventDefault(),e.lifecycle?.mode!==`managed`&&r&&s(r,t.id),i(null)},children:l.map(t=>{let r=Mt(e,t,c);return(0,U.jsxs)(`li`,{draggable:e.lifecycle?.mode!==`managed`,onDragStart:()=>{e.lifecycle?.mode!==`managed`&&i(t.id)},onDragEnd:()=>i(null),className:P(`relative rounded-md border bg-background p-3 shadow-sm transition-colors`,n===t.id?`border-primary`:`hover:border-primary/50`),children:[(0,U.jsx)(`button`,{type:`button`,"aria-label":`Select task: ${t.title}`,onClick:()=>a(t.id),className:`absolute inset-0 cursor-pointer rounded-md`}),(0,U.jsxs)(`div`,{className:`pointer-events-none relative flex items-start gap-2`,children:[(0,U.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(t.atomic||r.atomicityVerdict)&&(0,U.jsx)(`span`,{className:P(`shrink-0 rounded px-1 py-0.5 text-[10px] font-medium`,r.atomicityVerdict===`needs_decomposition`?`bg-destructive/15 text-destructive`:r.atomicityVerdict===`composite`?`bg-info/15 text-info`:r.atomicityVerdict===`borderline`||t.atomic?`bg-warning/15 text-warning`:`bg-muted text-muted-foreground`),title:r.atomicityVerdict?`Atomicity: ${r.atomicityVerdict}`:`Atomic task (subtree verification required)`,children:t.atomic?`atomic`:r.atomicityVerdict===`needs_decomposition`?`split me`:r.atomicityVerdict}),(0,U.jsx)(`span`,{className:`line-clamp-2 text-sm font-medium leading-5`,children:t.title})]}),t.description&&(0,U.jsx)(`div`,{className:`mt-1 line-clamp-2 text-xs leading-4 text-muted-foreground`,children:t.description})]}),(0,U.jsx)(`button`,{type:`button`,title:`Delete task`,"aria-label":`Delete task: ${t.title}`,onClick:()=>o(t),className:`pointer-events-auto relative flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-muted-foreground hover:bg-destructive/10 hover:text-destructive`,children:(0,U.jsx)(ie,{size:14})})]}),(0,U.jsxs)(`div`,{className:`pointer-events-none relative mt-2 flex flex-wrap items-center gap-1.5 text-[11px]`,children:[(0,U.jsx)(`span`,{className:Tt(t.priority),children:t.priority}),(0,U.jsx)(`span`,{className:`rounded bg-muted px-1.5 py-0.5 text-muted-foreground`,children:t.status}),r.owner!==`Unassigned`&&(0,U.jsx)(`span`,{className:`rounded bg-primary/10 px-1.5 py-0.5 text-primary`,children:r.owner}),t.assignment&&(0,U.jsx)(`span`,{className:`rounded bg-muted px-1.5 py-0.5 text-muted-foreground`,children:r.route}),t.assignment?.attempt?(0,U.jsxs)(`span`,{className:`rounded bg-info/10 px-1.5 py-0.5 text-info`,children:[`attempt `,r.attempts]}):null,r.fallbackCount>0&&(0,U.jsxs)(`span`,{className:`rounded bg-info/10 px-1.5 py-0.5 text-info`,children:[r.fallbackCount,` fallback`]}),r.blockers>0?(0,U.jsxs)(`span`,{className:`rounded bg-warning/10 px-1.5 py-0.5 text-warning`,children:[r.blockers,` blocker`]}):null,r.activeUsers>0&&(0,U.jsxs)(`span`,{className:`rounded bg-success/10 px-1.5 py-0.5 text-success`,children:[r.activeUsers,` active`]}),r.failed&&(0,U.jsx)(`span`,{className:`rounded bg-destructive/10 px-1.5 py-0.5 text-destructive`,children:`run failed`}),r.criticalRisks>0&&(0,U.jsxs)(`span`,{className:`rounded bg-destructive/10 px-1.5 py-0.5 text-destructive`,children:[r.criticalRisks,` critical risk`]}),r.warningRisks>0&&(0,U.jsxs)(`span`,{className:`rounded bg-warning/10 px-1.5 py-0.5 text-warning`,children:[r.warningRisks,` warning`]}),t.chain&&(0,U.jsxs)(`span`,{className:`rounded bg-primary/10 px-1.5 py-0.5 text-primary`,children:[`chain `,t.chain.order+1]}),t.assignment?.skills?.length?(0,U.jsxs)(`span`,{className:`rounded bg-success/10 px-1.5 py-0.5 text-success`,children:[t.assignment.skills.length,` skills`]}):null,r.verification!==`unverified`&&(0,U.jsxs)(`span`,{className:P(`rounded px-1.5 py-0.5`,r.verification===`passed`?`bg-success/10 text-success`:r.verification===`failed`?`bg-destructive/10 text-destructive`:`bg-warning/10 text-warning`),children:[`✓ `,r.verification]}),r.subtaskCounts&&(0,U.jsxs)(`span`,{className:`rounded bg-info/10 px-1.5 py-0.5 text-info`,children:[r.subtaskCounts.done,`/`,r.subtaskCounts.total,` subtasks`]}),r.evidenceCount>0&&(0,U.jsxs)(`span`,{className:`rounded bg-muted px-1.5 py-0.5 text-muted-foreground`,children:[r.evidenceCount,` evidence`]}),r.pendingDecomposition&&(0,U.jsx)(`span`,{className:`rounded bg-warning/10 px-1.5 py-0.5 text-warning`,children:`split pending approval`})]})]},t.id)})})]})}function Pt({queueHealth:e,runningCostTotal:t}){return(0,U.jsxs)(`div`,{className:`flex shrink-0 items-center gap-4 border-b px-4 py-2 text-xs text-muted-foreground`,children:[(0,U.jsx)(`span`,{className:`font-medium text-foreground`,children:`Queue health`}),e.counts.ready>0&&(0,U.jsxs)(`span`,{title:`Claimable tasks`,className:`inline-flex items-center gap-1 text-success`,children:[e.counts.ready,` ready`]}),e.counts.running>0&&(0,U.jsxs)(`span`,{title:`Running assignments`,className:`inline-flex items-center gap-1 text-warning`,children:[e.counts.running,` running`]}),e.counts.review>0&&(0,U.jsxs)(`span`,{title:`In review`,className:`inline-flex items-center gap-1 text-primary`,children:[e.counts.review,` review`]}),e.counts.blocked>0&&(0,U.jsxs)(`span`,{title:`Manually blocked`,className:`inline-flex items-center gap-1 text-destructive`,children:[e.counts.blocked,` blocked`]}),e.counts.failed>0&&(0,U.jsxs)(`span`,{title:`Failed tasks`,className:`inline-flex items-center gap-1 text-destructive`,children:[e.counts.failed,` failed`]}),e.dependencyBlocked.count>0&&(0,U.jsxs)(`span`,{title:`Ready/pending tasks blocked by dependencies`,className:`inline-flex items-center gap-1 rounded bg-warning/10 px-1.5 py-0.5 text-warning`,children:[e.dependencyBlocked.count,` blocked by deps`]}),e.staleAssignments.count>0&&(0,U.jsxs)(`span`,{title:`Expired lease assignments`,className:`inline-flex items-center gap-1 rounded bg-destructive/10 px-1.5 py-0.5 text-destructive`,children:[e.staleAssignments.count,` stale`]}),e.heartbeatDue.count===0&&e.staleAssignments.count===0&&e.dependencyBlocked.count===0&&(0,U.jsx)(`span`,{className:`text-success`,children:`healthy`}),t>0&&(0,U.jsxs)(`span`,{title:`Sum of costCeilingUsd for running/queued tasks`,className:`inline-flex items-center gap-1 text-info`,children:[`~$`,t.toFixed(2),` running cost`]})]})}function Ft({runLink:e,sendRaw:t}){let i=e.engine===`sdd`,a=i?`sdd.board`:`goal`,o=N(e=>e.setCurrentView),s=`inline-flex items-center gap-1 rounded-md border px-2 py-1 text-[11px] font-medium hover:bg-muted`;return(0,U.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2 border-b bg-primary/5 px-4 py-1.5`,children:[(0,U.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded bg-primary/15 px-1.5 py-0.5 text-[10px] font-semibold uppercase text-primary`,children:[(0,U.jsx)(se,{size:11}),` `,e.engine]}),(0,U.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:`Live run — steer it from here`}),i&&(0,U.jsxs)(`button`,{type:`button`,className:s,title:`Open the live run view (SDD Hub)`,onClick:()=>o(`sddhub`),children:[(0,U.jsx)(se,{size:12}),` Open live run`]}),(0,U.jsxs)(`div`,{className:`ml-auto flex items-center gap-1`,children:[(0,U.jsxs)(`button`,{type:`button`,className:s,onClick:()=>t(`${a}.pause`),children:[(0,U.jsx)(r,{size:12}),` Pause`]}),(0,U.jsxs)(`button`,{type:`button`,className:s,onClick:()=>t(`${a}.resume`),children:[(0,U.jsx)(p,{size:12}),` Resume`]}),i&&(0,U.jsxs)(`button`,{type:`button`,className:s,onClick:()=>t(`sdd.board.retry_all_failed`),children:[(0,U.jsx)(D,{size:12}),` Retry failed`]}),(0,U.jsxs)(`button`,{type:`button`,className:P(s,`text-destructive hover:bg-destructive/10`),onClick:()=>t(`${a}.stop`),children:[(0,U.jsx)(n,{size:12}),` Stop`]})]})]})}function It({boardId:e,sendKanban:t}){let n=`inline-flex items-center gap-1 rounded-md border px-2 py-1 text-[11px] font-medium text-primary hover:bg-primary/10`;return(0,U.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2 border-b bg-muted/30 px-4 py-1.5`,children:[(0,U.jsx)(se,{size:13,className:`text-primary`}),(0,U.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:`Run this board as a live agent job:`}),(0,U.jsxs)(`div`,{className:`ml-auto flex items-center gap-1`,children:[(0,U.jsx)(`button`,{type:`button`,className:n,onClick:()=>t(`kanban.run.start`,{boardId:e,engine:`goal`}),children:`Start as Goal`}),(0,U.jsx)(`button`,{type:`button`,className:n,onClick:()=>t(`kanban.run.start`,{boardId:e,engine:`sdd`}),children:`Start as SDD`})]})]})}function Lt({runLink:e,runTaskId:t,modelCandidates:r,sendRaw:i}){let a=e.engine===`sdd`,[o,s]=(0,R.useState)(!1),[c,l]=(0,R.useState)(``),u=`inline-flex flex-1 items-center justify-center gap-1 rounded-md border py-1.5 text-xs font-medium hover:bg-muted`,d=()=>{let e=c.trim();e&&(i(a?`sdd.board.reassign`:`goal.assignTask`,{taskId:t,agentName:e}),s(!1),l(``))};return(0,U.jsxs)(`div`,{className:`mt-4 rounded-md border bg-primary/5 p-2.5`,children:[(0,U.jsx)(`div`,{className:`mb-2 text-[10px] font-semibold uppercase tracking-wide text-primary`,children:`Run controls`}),a&&(0,U.jsxs)(`div`,{className:`mb-2`,children:[(0,U.jsx)(`div`,{className:`mb-1 text-[10px] uppercase text-muted-foreground`,children:`Worker model`}),(0,U.jsx)(Ce,{candidates:r,placeholder:`Set model for this task…`,onPick:(e,n)=>i(`sdd.board.set_task_model`,{taskId:t,model:e,provider:n})})]}),o?(0,U.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,U.jsx)(`input`,{value:c,onChange:e=>l(e.target.value),onKeyDown:e=>{e.key===`Enter`&&d(),e.key===`Escape`&&s(!1)},placeholder:`New worker name`,className:`min-w-0 flex-1 rounded-md border bg-background px-2 py-1.5 text-xs outline-none focus:border-primary`}),(0,U.jsx)(`button`,{type:`button`,onClick:d,className:`rounded-md bg-primary/10 px-2 py-1.5 text-primary`,children:(0,U.jsx)(b,{size:14})}),(0,U.jsx)(`button`,{type:`button`,onClick:()=>s(!1),className:`rounded-md bg-muted px-2 py-1.5`,children:(0,U.jsx)(E,{size:14})})]}):(0,U.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,U.jsxs)(`button`,{type:`button`,className:u,onClick:()=>i(a?`sdd.board.retry`:`goal.retryTask`,{taskId:t}),children:[(0,U.jsx)(D,{size:13}),` Retry`]}),(0,U.jsxs)(`button`,{type:`button`,className:u,onClick:()=>s(!0),children:[(0,U.jsx)(m,{size:13}),` Reassign`]}),a?(0,U.jsxs)(`button`,{type:`button`,className:P(u,`text-destructive hover:bg-destructive/10`),onClick:()=>i(`sdd.board.cancel_task`,{taskId:t}),children:[(0,U.jsx)(n,{size:13}),` Cancel`]}):(0,U.jsxs)(`button`,{type:`button`,className:u,onClick:()=>i(`goal.runTask`,{taskId:t}),children:[(0,U.jsx)(p,{size:13}),` Run now`]})]})]})}var Rt={unverified:{label:`unverified`,className:`bg-muted text-muted-foreground`,icon:C},running:{label:`verifying…`,className:`bg-info/10 text-info`,icon:ae},passed:{label:`verified`,className:`bg-success/10 text-success`,icon:w},failed:{label:`verification failed`,className:`bg-destructive/10 text-destructive`,icon:ue},needs_human:{label:`needs review`,className:`bg-warning/10 text-warning`,icon:c},incomplete:{label:`incomplete`,className:`bg-warning/10 text-warning`,icon:c}};function zt({task:e}){return e.status===`completed`?(0,U.jsx)(b,{size:13,className:`text-success`}):e.status===`failed`?(0,U.jsx)(E,{size:13,className:`text-destructive`}):e.status===`in_progress`?(0,U.jsx)(ae,{size:13,className:`animate-spin text-info`}):(0,U.jsx)(t,{size:13,className:`text-muted-foreground`})}function Bt({board:e,selectedTaskId:t,onSelectTask:n}){let r=xe(e=>e.verificationActivity),i=(0,R.useMemo)(()=>St(xt(e)),[e]);return i.length?(0,U.jsx)(`div`,{className:`h-full overflow-y-auto p-4`,children:(0,U.jsx)(`ul`,{className:`space-y-0.5`,children:i.map(({task:i,depth:a,children:o})=>{let s=Rt[vt(i,r[`${e.id}:${i.id}`])],c=s.icon,l=i.atomicityAssessment?.verdict;return(0,U.jsx)(`li`,{children:(0,U.jsxs)(`button`,{type:`button`,onClick:()=>n(i.id),style:{paddingLeft:`${a*22+8}px`},className:P(`flex w-full items-center gap-2 rounded-md border py-1.5 pr-2 text-left text-xs transition-colors`,t===i.id?`border-primary bg-primary/5`:`border-transparent hover:border-primary/40 hover:bg-muted/40`),children:[o.length>0?(0,U.jsx)(ce,{size:12,className:`shrink-0 text-muted-foreground`}):(0,U.jsx)(`span`,{className:`w-3 shrink-0`}),(0,U.jsx)(zt,{task:i}),(0,U.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-medium`,children:i.title}),i.atomic&&(0,U.jsx)(`span`,{className:`shrink-0 rounded bg-warning/15 px-1 py-0.5 text-[10px] text-warning`,children:`atomic`}),l&&l!==`atomic`&&(0,U.jsx)(`span`,{className:P(`shrink-0 rounded px-1 py-0.5 text-[10px]`,l===`needs_decomposition`?`bg-destructive/15 text-destructive`:l===`composite`?`bg-info/15 text-info`:`bg-warning/15 text-warning`),children:l===`needs_decomposition`?`split me`:l}),i.decomposition?.status===`proposed`&&(0,U.jsx)(`span`,{className:`shrink-0 rounded bg-warning/10 px-1 py-0.5 text-[10px] text-warning`,children:`proposal pending`}),(0,U.jsxs)(`span`,{className:P(`inline-flex shrink-0 items-center gap-1 rounded px-1.5 py-0.5 text-[10px]`,s.className),children:[(0,U.jsx)(c,{size:11,className:s.label===`verifying…`?`animate-spin`:void 0}),s.label]})]})},i.id)})})}):(0,U.jsx)(`div`,{className:`flex h-full items-center justify-center text-sm text-muted-foreground`,children:`No tasks on this board yet.`})}function Vt({label:e,value:t,tone:n}){return(0,U.jsxs)(`div`,{className:`rounded-md border bg-background p-3`,children:[(0,U.jsx)(`div`,{className:P(`text-xl font-bold`,n===`success`&&`text-success`,n===`destructive`&&`text-destructive`,n===`warning`&&`text-warning`,n===`muted`&&`text-muted-foreground`),children:t}),(0,U.jsx)(`div`,{className:`text-[11px] text-muted-foreground`,children:e})]})}function Ht({title:e,icon:t,tone:n,rows:r,onSelectTask:i}){return r.length?(0,U.jsxs)(`div`,{className:`rounded-md border bg-background`,children:[(0,U.jsxs)(`div`,{className:P(`flex items-center gap-2 border-b px-3 py-2 text-xs font-semibold`,n),children:[(0,U.jsx)(t,{size:14}),e,(0,U.jsx)(`span`,{className:`rounded bg-muted px-1.5 py-0.5 text-[10px] text-muted-foreground`,children:r.length})]}),(0,U.jsx)(`ul`,{className:`divide-y`,children:r.map(e=>(0,U.jsx)(`li`,{children:(0,U.jsxs)(`button`,{type:`button`,onClick:()=>i(e.taskId),className:`flex w-full flex-col items-start gap-0.5 px-3 py-2 text-left text-xs hover:bg-muted/40`,children:[(0,U.jsx)(`span`,{className:`font-medium`,children:e.primary}),e.secondary&&(0,U.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:e.secondary})]})},e.id))})]}):null}function Ut({board:e,onSelectTask:t}){let n=(0,R.useMemo)(()=>bt(e),[e]);return(0,U.jsxs)(`div`,{className:`h-full space-y-4 overflow-y-auto p-4`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-4 rounded-md border bg-background p-4`,children:[(0,U.jsx)(L,{pct:n.gradedTasks?n.passed/n.gradedTasks*100:0}),(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`div`,{className:`text-sm font-semibold`,children:`Definition of Done`}),(0,U.jsxs)(`div`,{className:`text-xs text-muted-foreground`,children:[n.passed,` of `,n.gradedTasks,` graded tasks verified passed ·`,` `,n.totalTasks,` tasks total`]})]})]}),(0,U.jsxs)(`div`,{className:`grid grid-cols-2 gap-2 sm:grid-cols-5`,children:[(0,U.jsx)(Vt,{label:`verified`,value:n.passed,tone:`success`}),(0,U.jsx)(Vt,{label:`failed`,value:n.failed,tone:`destructive`}),(0,U.jsx)(Vt,{label:`needs human`,value:n.needsHuman,tone:`warning`}),(0,U.jsx)(Vt,{label:`incomplete`,value:n.incomplete,tone:`warning`}),(0,U.jsx)(Vt,{label:`unverified`,value:n.unverified,tone:`muted`})]}),(0,U.jsx)(Ht,{title:`Failing checks`,icon:ue,tone:`text-destructive`,onSelectTask:t,rows:n.failingChecks.map(({task:e,check:t})=>({id:`${e.id}:${t.checkId}`,taskId:e.id,primary:e.title,secondary:`${t.description}${t.error?` — ${t.error}`:``}`}))}),(0,U.jsx)(Ht,{title:`Evidence missing (agent/council checks without backing refs)`,icon:c,tone:`text-warning`,onSelectTask:t,rows:n.missingEvidence.map(({task:e,check:t})=>({id:`${e.id}:${t.checkId}`,taskId:e.id,primary:e.title,secondary:t.description}))}),(0,U.jsx)(Ht,{title:`Needs decomposition`,icon:me,tone:`text-warning`,onSelectTask:t,rows:n.needsDecomposition.map(e=>({id:e.id,taskId:e.id,primary:e.title,secondary:`atomicity score ${e.atomicityAssessment?.score??`?`} — split before dispatch`}))}),(0,U.jsx)(Ht,{title:`Decomposition proposals awaiting approval`,icon:C,tone:`text-info`,onSelectTask:t,rows:n.pendingProposals.map(e=>({id:e.id,taskId:e.id,primary:e.title,secondary:`${e.decomposition?.proposedSubtasks.length??0} proposed subtasks`}))}),n.failingChecks.length===0&&n.missingEvidence.length===0&&n.needsDecomposition.length===0&&n.pendingProposals.length===0&&(0,U.jsxs)(`div`,{className:`flex items-center gap-2 rounded-md border border-success/30 bg-success/5 p-3 text-xs text-success`,children:[(0,U.jsx)(w,{size:14}),`No outstanding verification or decomposition issues on this board.`]})]})}var Wt={assigned:`bg-info/10 text-info`,queued:`bg-info/10 text-info`,running:`bg-warning/10 text-warning`,completed:`bg-success/10 text-success`,failed:`bg-destructive/10 text-destructive`,cancelled:`bg-muted text-muted-foreground`};function Gt(e,t){if(!e)return null;let n=Date.parse(e);if(Number.isNaN(n))return null;let r=t?Date.parse(t):Date.now();if(Number.isNaN(r))return null;let i=Math.max(0,Math.round((r-n)/1e3));if(i<60)return`${i}s`;let a=Math.floor(i/60);return a<60?`${a}m ${i%60}s`:`${Math.floor(a/60)}h ${a%60}m`}function Kt({assignment:e}){let t=e.status===`running`,n=Gt(e.dispatchedAt,e.completedAt),r=G(e.name)??G(e.agentId),i=G(e.role),a=G(e.provider),o=G(e.model),s=[];return r&&s.push({label:`Agent`,value:r}),i&&s.push({label:`Role`,value:i}),e.modelRouting&&s.push({label:`Model source`,value:e.modelRouting}),(a||o)&&s.push({label:`Model`,value:(0,U.jsxs)(`span`,{className:`font-mono text-[11px]`,children:[a?`${a}/`:``,o??`—`]})}),e.subagentId&&s.push({label:`Subagent`,value:(0,U.jsx)(`span`,{className:`font-mono text-[11px]`,children:e.subagentId})}),n&&s.push({label:e.completedAt?`Duration`:`Elapsed`,value:n}),typeof e.attempt==`number`&&s.push({label:`Attempt`,value:`${e.attempt}${e.maxAttempts?` / ${e.maxAttempts}`:``}`}),e.costCeilingUsd&&s.push({label:`Cost ceiling`,value:`$${e.costCeilingUsd.toFixed(2)}`}),e.fallbackProfile&&s.push({label:`Fallback profile`,value:e.fallbackProfile}),e.fallbackModels?.length&&s.push({label:`Fallbacks`,value:e.fallbackModels.join(` → `)}),e.skills?.length&&s.push({label:`Skills`,value:e.skills.join(`, `)}),e.tools?.length&&s.push({label:`Tools`,value:e.tools.join(`, `)}),e.leaseExpiresAt&&s.push({label:`Lease expires`,value:new Date(e.leaseExpiresAt).toLocaleString()}),(0,U.jsxs)(`div`,{className:`mt-4 rounded-md border bg-background p-2.5`,children:[(0,U.jsxs)(`div`,{className:`mb-2 flex items-center gap-2`,children:[(0,U.jsx)(`span`,{className:`text-[10px] font-semibold uppercase tracking-wide text-muted-foreground`,children:`Live run`}),(0,U.jsxs)(`span`,{className:P(`ml-auto inline-flex items-center gap-1 rounded px-1.5 py-0.5 text-[10px] font-medium capitalize`,Wt[e.status]??`bg-muted text-muted-foreground`),children:[t&&(0,U.jsx)(`span`,{className:`h-1.5 w-1.5 animate-pulse rounded-full bg-current`,"aria-hidden":!0}),e.status]})]}),s.length>0&&(0,U.jsx)(`dl`,{className:`grid grid-cols-[auto_1fr] gap-x-3 gap-y-1 text-xs`,children:s.map(e=>(0,U.jsxs)(`div`,{className:`contents`,children:[(0,U.jsx)(`dt`,{className:`text-muted-foreground`,children:e.label}),(0,U.jsx)(`dd`,{className:`min-w-0 truncate text-right text-foreground`,children:e.value})]},e.label))}),e.lastResult&&(0,U.jsxs)(`div`,{className:`mt-2`,children:[(0,U.jsx)(`div`,{className:`mb-1 text-[10px] uppercase text-muted-foreground`,children:`Last result`}),(0,U.jsx)(`div`,{className:`max-h-24 overflow-y-auto whitespace-pre-wrap rounded bg-muted px-2 py-1 text-[11px] leading-relaxed text-foreground`,children:e.lastResult})]}),e.error&&(0,U.jsx)(`div`,{className:`mt-2 rounded border border-destructive/30 bg-destructive/10 px-2 py-1 text-[11px] text-destructive`,children:e.error})]})}function qt({activityKind:e,activityOutcome:t,note:n,details:r,onActivityKindChange:i,onActivityOutcomeChange:a,onNoteChange:o,onDetailsChange:s,onRecordActivity:c}){return(0,U.jsxs)(`div`,{className:`mt-4`,children:[(0,U.jsx)(`div`,{className:`mb-2 text-xs font-semibold uppercase text-muted-foreground`,children:`Record decision / outcome`}),(0,U.jsxs)(`div`,{className:`mb-1.5 grid grid-cols-2 gap-1.5`,children:[(0,U.jsx)(`select`,{value:e,onChange:e=>i(e.target.value),"aria-label":`Task activity kind`,className:`h-8 rounded-md border bg-background px-2 text-xs`,children:[`decision`,`attempt`,`result`,`blocker`,`observation`].map(e=>(0,U.jsx)(`option`,{value:e,children:e},e))}),(0,U.jsx)(`select`,{value:t,onChange:e=>a(e.target.value),"aria-label":`Task activity outcome`,className:`h-8 rounded-md border bg-background px-2 text-xs`,children:[`unknown`,`succeeded`,`failed`,`partial`,`skipped`].map(e=>(0,U.jsx)(`option`,{value:e,children:e},e))})]}),(0,U.jsxs)(`div`,{className:`flex gap-1.5`,children:[(0,U.jsx)(`input`,{value:n,onChange:e=>o(e.target.value),onKeyDown:e=>e.key===`Enter`&&c(),placeholder:`What was decided, attempted, or produced?`,className:`h-8 min-w-0 flex-1 rounded-md border bg-background px-2 text-xs outline-none focus:border-primary`}),(0,U.jsx)(`button`,{type:`button`,onClick:c,className:`h-8 rounded-md border px-2 hover:bg-muted`,"aria-label":`Record task decision or outcome`,children:(0,U.jsx)(M,{size:14})})]}),(0,U.jsx)(`input`,{value:r,onChange:e=>s(e.target.value),placeholder:`Optional evidence, rationale, command, link, or failure detail…`,"aria-label":`Task activity details`,className:`mt-1.5 h-8 w-full rounded-md border bg-background px-2 text-xs outline-none focus:border-primary`})]})}function Jt({board:e,task:t,newCheck:n,onNewCheckChange:r,onAddCheck:i,sendKanban:a}){return(0,U.jsxs)(`div`,{className:`mt-5`,children:[(0,U.jsx)(`div`,{className:`mb-2 text-xs font-semibold uppercase text-muted-foreground`,children:`Completion checks`}),(0,U.jsxs)(`div`,{className:`space-y-1.5`,children:[(t.successCriteria??[]).map(n=>(0,U.jsxs)(`div`,{className:`grid grid-cols-[auto_1fr_92px] items-center gap-2 rounded-md border bg-background px-2 py-1.5 text-xs`,children:[(0,U.jsx)(b,{size:13,className:n.status===`passed`?`text-success`:`text-muted-foreground`}),(0,U.jsx)(`span`,{className:`min-w-0 truncate`,children:n.description}),(0,U.jsx)(`select`,{value:n.status,onChange:r=>a(`kanban.task.check.update`,{boardId:e?.id,taskId:t.id,checkId:n.id,status:r.target.value}),className:`h-7 rounded border bg-background px-1 text-[11px]`,children:[`pending`,`passed`,`failed`,`skipped`].map(e=>(0,U.jsx)(`option`,{value:e,children:e},e))})]},n.id)),(0,U.jsxs)(`div`,{className:`flex gap-1.5`,children:[(0,U.jsx)(`input`,{value:n,onChange:e=>r(e.target.value),onKeyDown:e=>e.key===`Enter`&&i(),placeholder:`Add a verifiable completion check…`,className:`h-8 min-w-0 flex-1 rounded-md border bg-background px-2 text-xs outline-none focus:border-primary`}),(0,U.jsx)(`button`,{type:`button`,onClick:i,className:`h-8 rounded-md border px-2 hover:bg-muted`,children:(0,U.jsx)(M,{size:14})})]})]})]})}var Yt=[`architect`,`developer`,`reviewer`,`tester`,`verifier`,`security`,`documenter`,`external`,`leader`,`shadow`,`subagent`],Xt=[{value:`fs.read`,label:`Read files`,description:`fs.read`},{value:`fs.write`,label:`Write files (in project)`,description:`fs.write`},{value:`fs.write.outside-project`,label:`Write outside project`,description:`fs.write.outside-project`},{value:`net.outbound`,label:`Outbound network`,description:`net.outbound`},{value:`shell.exec`,label:`Run project commands`,description:`shell.exec`},{value:`shell.restricted`,label:`Restricted shell`,description:`shell.restricted`},{value:`shell.arbitrary`,label:`Arbitrary shell`,description:`shell.arbitrary`},{value:`session.todo`,label:`Session todos`,description:`session.todo`},{value:`tool.meta`,label:`Tool metadata`,description:`tool.meta`},{value:`tool.mutate.any`,label:`Invoke any tool`,description:`tool.mutate.any`},{value:`memory.read`,label:`Read memory`,description:`memory.read`},{value:`memory.write`,label:`Write memory`,description:`memory.write`},{value:`package.install`,label:`Install packages`,description:`package.install`},{value:`subagent.spawn`,label:`Spawn subagents`,description:`subagent.spawn`},{value:`config.mutate`,label:`Mutate config / trust`,description:`config.mutate`}];function Zt(e,t,n,r=new Date().toISOString()){return{format:`wrongstack-kanban-task-activity`,version:1,exportedAt:r,scope:n,task:e,events:t}}function J(e){return e&&typeof e==`object`&&!Array.isArray(e)?e:{}}function Y(e){return typeof e==`string`&&e.trim()?e.trim():void 0}function Qt(e){return e.type.startsWith(`task.file.`)?e.type===`task.file.read`?`execution`:`changes`:e.type.startsWith(`task.activity.`)?Y(J(e.after).outcome)===`failed`?`failures`:e.type===`task.activity.attempt`?`execution`:`notes`:e.type.includes(`failed`)||e.type.includes(`cancelled`)?`failures`:e.type===`task.assigned`||e.type===`task.claimed`||e.type===`task.released`||e.type.startsWith(`task.assignment.`)||e.type===`task.stale_recovered`?`execution`:e.type.includes(`note`)||e.type.includes(`check`)||e.type.includes(`metric`)?`notes`:`changes`}function $t(e){let t=J(e.before),n=J(e.after);return[...new Set([...Object.keys(t),...Object.keys(n)])].filter(e=>JSON.stringify(t[e])!==JSON.stringify(n[e])).map(e=>({field:e,before:t[e],after:n[e]}))}function en(e){if(e.type.startsWith(`task.file.`))return`File ${e.type.slice(10)}`.replace(/\b\w/g,e=>e.toUpperCase());if(e.type.startsWith(`task.activity.`))return`Recorded ${e.type.slice(14)}`.replace(/\b\w/g,e=>e.toUpperCase());switch(e.type){case`task.created`:return`Task created`;case`task.copied`:return`Task copied`;case`task.updated`:return`Task contract updated`;case`task.moved`:return`Task moved`;case`task.assigned`:return`Agent assigned`;case`task.claimed`:return`Task claimed`;case`task.released`:return`Assignment released`;case`task.assignment.updated`:return`Assignment updated`;case`task.assignment.running`:return`Agent started work`;case`task.assignment.completed`:return`Agent completed work`;case`task.assignment.failed`:return`Agent run failed`;case`task.assignment.cancelled`:return`Agent run cancelled`;case`task.assignment.heartbeat`:return`Agent heartbeat`;case`task.note.added`:return`Operator note added`;case`task.check.added`:return`Acceptance check added`;case`task.check.updated`:return`Acceptance check updated`;case`task.metric.added`:return`Goal metric added`;case`task.metric.updated`:return`Goal metric updated`;case`task.lifecycle.transition`:return`Lifecycle advanced`;case`task.assignment.snapshot`:return`Current assignment observed`;case`task.stale_recovered`:return`Stale assignment recovered`;case`task.reconciled`:return`Task state reconciled`;default:return e.type.replace(/^task\./,``).replaceAll(`.`,` `).replace(/\b\w/g,e=>e.toUpperCase())}}function tn(e){let t=J(e.before),n=J(e.after);if(e.type.startsWith(`task.file.`)){let e=Y(n.filePath),t=Y(n.toolName),r=typeof n.durationMs==`number`?n.durationMs:void 0,i=typeof n.lines==`number`?n.lines:void 0;return[e,t?`tool:${t}`:void 0,r===void 0?void 0:`${r}ms`,i===void 0?void 0:`${i} lines`].filter(Boolean).join(` · `)||void 0}if(e.type.startsWith(`task.activity.`))return[Y(n.outcome),Y(n.details)].filter(Boolean).join(` · `)||void 0;if(e.type===`task.moved`){let e=Y(t.columnId),r=Y(n.columnId);if(e||r)return`${e??`unknown`} → ${r??`unknown`}`}if(e.type===`task.updated`){let t=$t(e);if(t.length)return`${t.length} field${t.length===1?``:`s`} changed: ${t.map(e=>e.field).join(`, `)}`}if(e.type===`task.lifecycle.transition`){let e=Y(t.stage),r=Y(n.stage);if(r)return e?`${e} → ${r}`:`Entered ${r}`}if(e.type===`task.assigned`||e.type===`task.assignment.snapshot`){let e=Y(n.name)??Y(n.agentId)??Y(n.role),t=Y(n.provider),r=Y(n.model);return[e,t||r?`${t?`${t}/`:``}${r??`default`}`:void 0].filter(Boolean).join(` · `)||void 0}if(e.type.startsWith(`task.check.`))return[Y(n.description),Y(n.status)].filter(Boolean).join(` · `)||void 0;if(e.type.startsWith(`task.metric.`))return[Y(n.name),Y(n.status)].filter(Boolean).join(` · `)||void 0}function nn(e){let t=e.type;return Y(J(e.after).outcome)===`failed`||t.includes(`failed`)||t.includes(`cancelled`)?`bg-destructive ring-destructive/20`:t.includes(`completed`)||t.includes(`reconciled`)?`bg-success ring-success/20`:t.includes(`running`)||t.includes(`claimed`)||t.includes(`assigned`)?`bg-info ring-info/20`:t.includes(`note`)?`bg-warning ring-warning/20`:`bg-primary ring-primary/20`}function rn(e){let t=Date.parse(e);return Number.isFinite(t)?new Intl.DateTimeFormat(void 0,{month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`,second:`2-digit`}).format(t):e}function an(e){if(e===void 0)return`unset`;if(e===null)return`none`;if(typeof e==`string`)return e||`empty`;if(typeof e==`number`||typeof e==`boolean`)return String(e);try{return JSON.stringify(e)}catch{return String(e)}}function on(e,t,n){let r=t.filter(t=>t.taskId===e.id).map(e=>({...e}));(e=>r.some(t=>t.type===e))(`task.created`)||r.push({id:`created:${e.id}`,boardId:``,taskId:e.id,type:`task.created`,ts:e.createdAt,...n?{sessionId:n}:{},after:{title:e.title,status:`created`,columnId:e.columnId}});for(let[t,i]of(e.lifecycle?.history??[]).entries())r.some(e=>e.type===`task.lifecycle.transition`&&e.ts===i.at&&e.actor===i.actor)||r.push({id:`lifecycle:${e.id}:${t}`,boardId:``,taskId:e.id,type:`task.lifecycle.transition`,ts:i.at,actor:i.actor,...n?{sessionId:n}:{},before:i.from?{stage:i.from}:void 0,after:{stage:i.to,action:i.action,attachment:i.attachment},note:i.comment});for(let t of e.notes??[])r.some(e=>e.type===`task.note.added`&&e.note===t.content&&Math.abs(Date.parse(e.ts)-Date.parse(t.createdAt))<2e3)||r.push({id:`note:${t.id}`,boardId:``,taskId:e.id,type:`task.note.added`,ts:t.createdAt,actor:t.author,...n?{sessionId:n}:{},note:t.content});let i=r.some(e=>e.type===`task.assigned`||e.type===`task.claimed`||e.type.startsWith(`task.assignment.`));return e.assignment&&!i&&r.push({id:`assignment:${e.id}`,boardId:``,taskId:e.id,type:`task.assignment.snapshot`,ts:e.assignment.completedAt??e.assignment.dispatchedAt??e.assignment.claimedAt??e.updatedAt,actor:e.assignment.agentId??e.assignment.name??e.assignment.role,...n?{sessionId:n}:{},subagentId:e.assignment.subagentId,runTaskId:e.assignment.runTaskId,after:{...e.assignment},note:e.assignment.error??e.assignment.lastResult}),r.sort((e,t)=>t.ts.localeCompare(e.ts))}function sn({event:e}){let t=J(e.after),n=Y(t.provider),r=Y(t.model),i=Y(t.modelRouting),a=Y(t.fallbackProfile),o=Array.isArray(t.fallbackModels)?t.fallbackModels.filter(e=>typeof e==`string`):[],s=typeof t.attempt==`number`?t.attempt:void 0,c=typeof t.maxAttempts==`number`?t.maxAttempts:void 0,l=Y(t.status);return!n&&!r&&!i&&!a&&!o.length&&s===void 0&&!l?null:(0,U.jsxs)(`div`,{className:`mt-1.5 flex flex-wrap gap-1 font-mono text-[9px] text-muted-foreground`,children:[l&&(0,U.jsxs)(`span`,{className:`rounded border border-border/60 px-1.5 py-0.5`,children:[`status:`,l]}),i&&(0,U.jsxs)(`span`,{className:`rounded border border-border/60 px-1.5 py-0.5`,children:[`route:`,i]}),(n||r)&&(0,U.jsxs)(`span`,{className:`rounded border border-border/60 px-1.5 py-0.5`,children:[`model:`,n?`${n}/`:``,r??`default`]}),a&&(0,U.jsxs)(`span`,{className:`rounded border border-border/60 px-1.5 py-0.5`,children:[`profile:`,a]}),o.map((e,t)=>(0,U.jsxs)(`span`,{className:`rounded border border-border/60 px-1.5 py-0.5`,children:[`fallback-`,t+1,`:`,e]},`${e}:${t}`)),s!==void 0&&(0,U.jsxs)(`span`,{className:`rounded border border-border/60 px-1.5 py-0.5`,children:[`attempt:`,s,c?`/${c}`:``]})]})}function cn({task:e,events:t,sessionId:n,loading:r=!1,error:i,onRefresh:a}){let[o,s]=(0,R.useState)(`all`),[c,l]=(0,R.useState)(``),[u,d]=(0,R.useState)(!1),f=(0,R.useMemo)(()=>on(e,t,n),[e,t,n]),p=(0,R.useMemo)(()=>({all:f.length,execution:f.filter(e=>Qt(e)===`execution`).length,changes:f.filter(e=>Qt(e)===`changes`).length,notes:f.filter(e=>Qt(e)===`notes`).length,failures:f.filter(e=>Qt(e)===`failures`).length}),[f]),m=(0,R.useMemo)(()=>{let e=c.trim().toLowerCase();return f.filter(t=>o!==`all`&&Qt(t)!==o?!1:!e||[en(t),t.type,t.actor,t.sessionId,t.subagentId,t.runTaskId,t.note,JSON.stringify(t.before),JSON.stringify(t.after)].filter(Boolean).join(` `).toLowerCase().includes(e))},[f,o,c]),g=we(m,50,`${o}:${c}`),_=g.pageItems,v=[...new Set(f.map(e=>e.actor).filter(Boolean))].length,y=[...new Set(f.map(e=>e.sessionId??n).filter(Boolean))].length;return(0,U.jsxs)(`section`,{"aria-label":`Task activity`,className:`mt-5`,children:[(0,U.jsxs)(`div`,{className:`mb-2 flex items-center gap-2`,children:[(0,U.jsx)(h,{className:`size-3.5 text-primary`}),(0,U.jsx)(`h3`,{className:`text-xs font-semibold uppercase text-muted-foreground`,children:`Activity ledger`}),(0,U.jsxs)(`span`,{className:`rounded bg-muted px-1.5 py-0.5 text-[10px] tabular-nums text-muted-foreground`,children:[m.length,`/`,f.length]}),(0,U.jsxs)(`div`,{className:`ml-auto flex items-center gap-0.5`,children:[(0,U.jsx)(`button`,{type:`button`,onClick:async()=>{try{await navigator.clipboard.writeText(JSON.stringify(Zt(e,m,`filtered`),null,2)),d(!0)}catch{d(!1)}},className:`flex size-7 items-center justify-center rounded-md text-muted-foreground hover:bg-muted hover:text-foreground`,"aria-label":`Copy visible task activity JSON`,title:`Copy filtered activity JSON`,children:u?(0,U.jsx)(b,{className:`size-3 text-success`}):(0,U.jsx)(_e,{className:`size-3`})}),(0,U.jsx)(`button`,{type:`button`,onClick:()=>{let t=JSON.stringify(Zt(e,f,`full`),null,2),n=URL.createObjectURL(new Blob([t],{type:`application/json`})),r=document.createElement(`a`);r.href=n,r.download=`${e.title.replace(/[^a-z0-9]+/gi,`-`).replace(/^-|-$/g,``).toLowerCase()||e.id}-activity.json`,r.click(),URL.revokeObjectURL(n)},className:`flex size-7 items-center justify-center rounded-md text-muted-foreground hover:bg-muted hover:text-foreground`,"aria-label":`Download full task activity JSON`,title:`Download full activity JSON`,children:(0,U.jsx)(oe,{className:`size-3`})}),a&&(0,U.jsx)(`button`,{type:`button`,onClick:a,className:`flex size-7 items-center justify-center rounded-md text-muted-foreground hover:bg-muted hover:text-foreground`,"aria-label":`Refresh task activity`,children:(0,U.jsx)(O,{className:P(`size-3`,r&&`animate-spin`)})})]})]}),(0,U.jsx)(`div`,{className:`mb-2 grid grid-cols-4 gap-px overflow-hidden rounded-md border border-border/60 bg-border/60 text-center`,children:[[`Events`,f.length],[`Actors`,v],[`Sessions`,y],[`Failures`,p.failures]].map(([e,t])=>(0,U.jsxs)(`div`,{className:`bg-background/90 px-1 py-1.5`,children:[(0,U.jsx)(`div`,{className:`text-xs font-semibold tabular-nums`,children:t}),(0,U.jsx)(`div`,{className:`text-[8px] uppercase text-muted-foreground`,children:e})]},String(e)))}),(0,U.jsx)(`div`,{className:`mb-2 flex flex-wrap gap-1`,children:[`all`,`execution`,`changes`,`notes`,`failures`].map(e=>(0,U.jsxs)(`button`,{type:`button`,onClick:()=>s(e),className:P(`rounded border px-1.5 py-1 text-[9px] capitalize`,o===e?`border-primary/50 bg-primary/10 text-primary`:`border-border text-muted-foreground hover:text-foreground`),children:[e,` `,p[e]]},e))}),(0,U.jsxs)(`div`,{className:`relative mb-3`,children:[(0,U.jsx)(T,{className:`pointer-events-none absolute left-2 top-1/2 size-3 -translate-y-1/2 text-muted-foreground`}),(0,U.jsx)(`input`,{value:c,onChange:e=>l(e.target.value),"aria-label":`Search task activity`,placeholder:`Search agent, session, model, result, field…`,className:`h-8 w-full rounded-md border bg-background pl-7 pr-7 text-[11px] outline-none focus:border-primary`}),c&&(0,U.jsx)(`button`,{type:`button`,onClick:()=>l(``),"aria-label":`Clear task activity search`,className:`absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground`,children:(0,U.jsx)(E,{className:`size-3`})})]}),i&&(0,U.jsx)(`div`,{className:`mb-2 rounded-md border border-destructive/30 bg-destructive/5 px-2.5 py-2 text-[11px] text-destructive`,children:i}),m.length===0?(0,U.jsx)(`div`,{className:`rounded-md border border-dashed px-3 py-6 text-center text-[11px] text-muted-foreground`,children:`No activity matches this filter.`}):(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`ol`,{className:`relative ml-1.5 space-y-0 border-l border-border/70`,children:_.map(e=>{let t=tn(e),r=e.sessionId??n,i=$t(e),a=Qt(e)===`failures`,o=e.type.includes(`completed`)||Y(J(e.after).outcome)===`succeeded`;return(0,U.jsxs)(`li`,{className:`relative pb-4 pl-4 last:pb-0`,children:[(0,U.jsx)(`span`,{className:P(`absolute -left-[5px] top-1.5 size-2 rounded-full ring-4`,nn(e))}),(0,U.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,U.jsxs)(`div`,{className:`min-w-0`,children:[(0,U.jsx)(`p`,{className:`text-xs font-medium leading-5`,children:en(e)}),(0,U.jsx)(`code`,{className:`block truncate text-[8px] text-muted-foreground/70`,title:e.type,children:e.type})]}),(0,U.jsx)(`time`,{dateTime:e.ts,title:new Date(e.ts).toLocaleString(),className:`shrink-0 text-[9px] text-muted-foreground`,children:rn(e.ts)})]}),t&&(0,U.jsx)(`p`,{className:`mt-1 whitespace-pre-wrap text-[11px] leading-4 text-muted-foreground`,children:t}),e.note&&(0,U.jsxs)(`div`,{className:P(`mt-1.5 max-h-32 overflow-y-auto whitespace-pre-wrap rounded border px-2 py-1.5 text-[10px] leading-4`,a?`border-destructive/30 bg-destructive/5 text-destructive`:o?`border-success/30 bg-success/5 text-success`:`border-border/70 bg-muted/35 text-foreground`),children:[(0,U.jsxs)(`strong`,{children:[a?`Error`:o?`Result`:`Reason / result`,`:`]}),` `,e.note]}),i.length>0&&e.type!==`task.assigned`&&e.type!==`task.assignment.snapshot`&&!e.type.startsWith(`task.file.`)&&(0,U.jsx)(`div`,{className:`mt-1.5 space-y-1 rounded border border-border/60 bg-background/50 p-1.5`,children:i.map(e=>(0,U.jsxs)(`div`,{className:`grid grid-cols-[5rem_minmax(0,1fr)] gap-1.5 text-[9px] leading-4`,children:[(0,U.jsx)(`code`,{className:`truncate text-primary`,title:e.field,children:e.field}),(0,U.jsxs)(`span`,{className:`min-w-0 break-all text-muted-foreground`,children:[(0,U.jsx)(`span`,{className:`line-through opacity-70`,children:an(e.before)}),` `,(0,U.jsx)(`span`,{"aria-hidden":!0,children:`→`}),` `,(0,U.jsx)(`span`,{className:`text-foreground`,children:an(e.after)})]})]},e.field))}),(0,U.jsx)(sn,{event:e}),(e.actor||r||e.subagentId||e.runTaskId||e.correlationId)&&(0,U.jsxs)(`div`,{className:`mt-1.5 flex flex-wrap gap-1 font-mono text-[9px] text-muted-foreground`,children:[e.actor&&(0,U.jsxs)(`span`,{className:`rounded bg-muted px-1.5 py-0.5`,children:[`agent:`,e.actor]}),r&&(0,U.jsxs)(`span`,{className:`max-w-52 truncate rounded bg-muted px-1.5 py-0.5`,title:r,children:[`session:`,r]}),e.subagentId&&(0,U.jsxs)(`span`,{className:`rounded bg-muted px-1.5 py-0.5`,children:[`subagent:`,e.subagentId]}),e.runTaskId&&(0,U.jsxs)(`span`,{className:`rounded bg-muted px-1.5 py-0.5`,children:[`run:`,e.runTaskId]}),e.correlationId&&(0,U.jsxs)(`span`,{className:`rounded bg-muted px-1.5 py-0.5`,children:[`trace:`,e.correlationId]})]}),(0,U.jsxs)(`details`,{className:`mt-1.5 text-[9px] text-muted-foreground`,children:[(0,U.jsx)(`summary`,{className:`cursor-pointer hover:text-foreground`,children:`Full event payload`}),(0,U.jsx)(`pre`,{className:`mt-1 max-h-64 overflow-auto rounded border bg-muted/30 p-2 text-[9px] leading-4 text-foreground`,children:JSON.stringify(e,null,2)})]})]},e.id)})}),(0,U.jsx)(I,{page:g.page,pageSize:g.pageSize,totalItems:g.totalItems,onPageChange:g.setPage,className:`mt-3`,itemLabel:`activity events`})]})]})}function ln(e){return e&&typeof e==`object`&&!Array.isArray(e)?e:{}}function X(e){return typeof e==`string`&&e.trim()?e.trim():void 0}function un(e){return e.type===`task.assigned`||e.type===`task.claimed`||e.type===`task.released`||e.type===`task.assignment.snapshot`||e.type===`task.stale_recovered`||e.type.startsWith(`task.assignment.`)}function dn(e,t){return X(t.status)||(e.type===`task.claimed`?`claimed`:e.type===`task.released`?`released`:e.type===`task.stale_recovered`?`recovered`:e.type.split(`.`).at(-1)??`unknown`)}function fn(e){return[`completed`,`failed`,`cancelled`,`released`,`recovered`].includes(e)}function pn(e,t){if(!t)return;let n=Date.parse(e),r=Date.parse(t);return Number.isFinite(n)&&Number.isFinite(r)?Math.max(0,r-n):void 0}function mn(e,t,n){let r=on(e,t,n).filter(un).sort((e,t)=>e.ts.localeCompare(t.ts)),i=new Map,a=0,o=0,s=!1;for(let e of r){let t=ln(e.after),r=Number(t.attempt),c=e.type===`task.assigned`||e.type===`task.claimed`;Number.isFinite(r)&&r>0?a=Math.trunc(r):c&&(a===0||s)?a=o+1:a===0&&(a=1),o=Math.max(o,a);let l=dn(e,t),u=i.get(a)??{attempt:a,status:l,startedAt:e.ts,fallbackModels:[],sessionIds:new Set,eventCount:0};u.status=l,u.eventCount+=1,(e.sessionId??n)&&u.sessionIds.add(e.sessionId??n),u.owner=X(t.name)??X(t.agentId)??X(t.role)??e.actor??u.owner,u.provider=X(t.provider)??u.provider,u.model=X(t.model)??u.model,u.routingMode=X(t.modelRouting)??u.routingMode,u.fallbackProfile=X(t.fallbackProfile)??u.fallbackProfile,Array.isArray(t.fallbackModels)&&(u.fallbackModels=t.fallbackModels.filter(e=>typeof e==`string`)),u.subagentId=e.subagentId??X(t.subagentId)??u.subagentId,u.runTaskId=e.runTaskId??X(t.runTaskId)??u.runTaskId,l===`running`&&!u.runningAt&&(u.runningAt=e.ts),l===`completed`&&(u.result=X(t.lastResult)??e.note??u.result),(l===`failed`||l===`cancelled`)&&(u.error=X(t.error)??e.note??u.error),fn(l)&&(u.endedAt=e.ts),i.set(a,u),s=fn(l)}return[...i.values()].map(e=>({...e,sessionIds:[...e.sessionIds],durationMs:pn(e.startedAt,e.endedAt)})).sort((e,t)=>t.attempt-e.attempt)}function hn(e){if(e===void 0)return`running`;if(e<1e3)return`${e}ms`;let t=Math.round(e/1e3);return t<60?`${t}s`:`${Math.floor(t/60)}m ${t%60}s`}function gn(e){return e===`completed`?`bg-success/10 text-success`:e===`failed`||e===`cancelled`?`bg-destructive/10 text-destructive`:e===`running`?`bg-info/10 text-info`:`bg-muted text-muted-foreground`}function _n({task:e,events:t,sessionId:n}){let r=mn(e,t,n),i=we(r,8,e.id);return r.length?(0,U.jsxs)(`details`,{open:!0,className:`mt-3 rounded-md border border-border/70 bg-muted/15`,children:[(0,U.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center gap-2 px-3 py-2.5 [&::-webkit-details-marker]:hidden`,children:[(0,U.jsx)(ge,{className:`size-4 text-primary`}),(0,U.jsx)(`span`,{className:`text-xs font-semibold`,children:`Execution attempts`}),(0,U.jsxs)(`span`,{className:`rounded bg-muted px-1.5 py-0.5 text-[9px] text-muted-foreground`,children:[r.length,` total`]}),(0,U.jsxs)(`span`,{className:`rounded px-1.5 py-0.5 text-[9px] ${gn(r[0].status)}`,children:[`latest:`,r[0].status]}),(0,U.jsx)(x,{className:`ml-auto size-3.5 text-muted-foreground`})]}),(0,U.jsxs)(`div`,{className:`space-y-2 border-t border-border/60 p-2.5`,children:[i.pageItems.map(e=>(0,U.jsxs)(`section`,{className:`rounded-md border bg-background/70 p-2.5`,children:[(0,U.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5 text-[10px]`,children:[(0,U.jsxs)(`strong`,{className:`text-xs`,children:[`Attempt #`,e.attempt]}),(0,U.jsx)(`span`,{className:`rounded px-1.5 py-0.5 ${gn(e.status)}`,children:e.status}),(0,U.jsxs)(`span`,{className:`ml-auto inline-flex items-center gap-1 text-muted-foreground`,children:[(0,U.jsx)(a,{className:`size-3`}),` `,hn(e.durationMs),` · `,e.eventCount,` `,`events`]})]}),(0,U.jsxs)(`div`,{className:`mt-2 grid gap-1 text-[10px] text-muted-foreground sm:grid-cols-2`,children:[(0,U.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,U.jsx)(A,{className:`size-3`}),` `,e.owner??`Unknown agent`]}),(0,U.jsxs)(`span`,{className:`inline-flex items-center gap-1 font-mono`,children:[(0,U.jsx)(j,{className:`size-3`}),e.provider||e.model?`${e.provider?`${e.provider}/`:``}${e.model??`default`}`:e.routingMode??`default route`]}),(0,U.jsxs)(`span`,{className:`font-mono`,children:[`session:`,e.sessionIds.join(`, `)||`unknown`]}),(0,U.jsxs)(`span`,{className:`font-mono`,children:[`subagent:`,e.subagentId??`—`,` · run:`,e.runTaskId??`—`]})]}),(e.fallbackProfile||e.fallbackModels.length>0)&&(0,U.jsxs)(`p`,{className:`mt-1.5 break-all font-mono text-[9px] text-muted-foreground`,children:[`fallback:`,[e.fallbackProfile?`profile:${e.fallbackProfile}`:``,...e.fallbackModels].filter(Boolean).join(` → `)]}),e.error&&(0,U.jsxs)(`p`,{className:`mt-2 whitespace-pre-wrap rounded border border-destructive/30 bg-destructive/5 px-2 py-1.5 text-[10px] text-destructive`,children:[(0,U.jsx)(`strong`,{children:`Error:`}),` `,e.error]}),e.result&&(0,U.jsxs)(`p`,{className:`mt-2 max-h-32 overflow-y-auto whitespace-pre-wrap rounded border border-success/30 bg-success/5 px-2 py-1.5 text-[10px] text-success`,children:[(0,U.jsx)(`strong`,{children:`Result:`}),` `,e.result]})]},e.attempt)),(0,U.jsx)(I,{page:i.page,pageSize:i.pageSize,totalItems:i.totalItems,onPageChange:i.setPage,compact:!0,itemLabel:`execution attempts`})]})]}):null}function vn(e){return e&&typeof e==`object`&&!Array.isArray(e)?e:{}}function Z(e){return G(e)}function yn(e,t){return(t??[]).map(t=>{let n=e.tasks.find(e=>e.id===t);return{id:t,title:n?.title??t,status:n?.status??`missing`}})}function bn(e,t,n,r,i,a,o){let s=on(t,n,r),c=yn(e,t.dependsOn),l=c.filter(e=>![`completed`,`archived`].includes(e.status)),u=t.assignment,d=(o??e.presence??[]).filter(e=>e.taskId===t.id),f=vn(s.find(e=>e.type===`task.assigned`||e.type===`task.claimed`||e.type.startsWith(`task.assignment.`))?.after),p=Z(u?.modelRouting)??Z(f.modelRouting)??`session`,m=Z(u?.provider)??Z(f.provider)??(p===`session`?Z(i):void 0),h=Z(u?.model)??Z(f.model)??(p===`session`?Z(a):void 0),g=(Array.isArray(u?.fallbackModels)?u.fallbackModels:Array.isArray(f.fallbackModels)?f.fallbackModels:[]).map(Z).filter(e=>e!==void 0),_=Z(u?.fallbackProfile)??Z(f.fallbackProfile),v=Z(u?.name)??Z(u?.agentId)??Z(u?.role)??Z(t.assignee)??Z(t.assignedAgent)??`Unassigned`,y=t.lifecycle?.history.at(-1),b=s.find(e=>e.note&&e.type!==`task.note.added`)?.note,x=`Placed in ${e.columns.find(e=>e.id===t.columnId)?.title??t.columnId}.`;u?.error?x=`Agent run failed: ${u.error}`:l.length?x=`Blocked by ${l.map(e=>e.title).join(`, `)}.`:y?.comment?x=y.comment:b?x=b:t.status===`review`?x=`Implementation is waiting for review evidence or approval.`:t.status===`in_progress`?x=`${v} is currently working on this task.`:t.status===`completed`&&(x=`The task and its current assignment are complete.`);let S=s.map(e=>Number(vn(e.after).attempt)).filter(e=>Number.isFinite(e)),C=s.filter(e=>e.type===`task.claimed`||e.type===`task.assigned`).length,w=s.find(e=>Qt(e)===`failures`),T=s.find(e=>e.type.includes(`completed`));return{column:e.columns.find(e=>e.id===t.columnId)?.title??t.columnId,reason:x,owner:v,routingMode:p,provider:m,model:h,primaryModel:m||h?`${m?`${m}/`:``}${h??`default`}`:`Session default`,fallbackRoute:[_?`profile:${_}`:``,...g].filter(Boolean).join(` → `)||`None configured`,blockers:l,dependencies:c,actors:[...new Set([...s.map(e=>e.actor).filter(e=>!!e),...d.map(e=>e.agentId)])],sessions:[...new Set([...s.map(e=>e.sessionId??r),...d.map(e=>e.sessionId)].filter(e=>!!e))],presence:d.map(e=>`${e.agentName??e.agentId} · ${e.active?`active`:`last seen ${Q(e.lastSeenAt)}`}`),activePresence:d.filter(e=>e.active).length,attempts:Math.max(u?.attempt??0,...S,C),failures:s.filter(e=>e.type.includes(`failed`)).length,completions:s.filter(e=>e.type.includes(`completed`)).length,lastFailure:u?.lastFailureKind??u?.error??w?.note,lastResult:u?.lastResult??T?.note,eventCount:s.length,lastActivity:s[0]}}function Q(e){if(!e)return`—`;let t=Date.parse(e);return Number.isFinite(t)?new Date(t).toLocaleString():e}function xn(e,t){if(!e)return`—`;let n=Date.parse(e),r=t?Date.parse(t):Date.now();if(!Number.isFinite(n)||!Number.isFinite(r))return`—`;let i=Math.max(0,Math.round((r-n)/6e4));return i<1?`<1m`:i<60?`${i}m`:`${Math.floor(i/60)}h ${i%60}m`}function $({label:e,value:t,mono:n=!1}){return(0,U.jsxs)(`div`,{className:`grid grid-cols-[7rem_minmax(0,1fr)] gap-2 py-1 text-[11px]`,children:[(0,U.jsx)(`dt`,{className:`text-muted-foreground`,children:e}),(0,U.jsx)(`dd`,{className:n?`break-all font-mono text-[10px]`:`min-w-0 break-words`,children:t})]})}function Sn({icon:e,title:t,children:n}){return(0,U.jsxs)(`section`,{className:`rounded-md border border-border/70 bg-background/55 p-2.5`,children:[(0,U.jsxs)(`h4`,{className:`mb-1.5 flex items-center gap-1.5 text-[10px] font-semibold uppercase tracking-wide text-muted-foreground`,children:[e,t]}),(0,U.jsx)(`dl`,{className:`divide-y divide-border/35`,children:n})]})}function Cn({items:e}){return e.length?(0,U.jsx)(`span`,{className:`space-y-1`,children:e.map(e=>(0,U.jsxs)(`span`,{className:`flex items-center justify-between gap-2`,children:[(0,U.jsx)(`span`,{className:`truncate`,title:e.title,children:e.title}),(0,U.jsx)(`span`,{className:`shrink-0 rounded bg-muted px-1 py-0.5 text-[9px]`,children:e.status})]},e.id))}):(0,U.jsx)(`span`,{className:`text-muted-foreground`,children:`None`})}function wn({board:e,task:t,events:n,presence:r,sessionId:i,sessionProvider:a,sessionModel:o}){let s=bn(e,t,n,i,a,o,r),c=t.assignment,l=t.successCriteria?.length??0,u=t.successCriteria?.filter(e=>e.status===`passed`).length??0,d=[t.parentTaskId,...t.childTaskIds??[],t.chain?.previousTaskId,t.chain?.nextTaskId,t.mergedIntoTaskId,...t.mergedFromTaskIds??[]].filter(e=>!!e),f=yn(e,[...new Set(d)]);return(0,U.jsxs)(`details`,{open:!0,className:`mt-3 rounded-md border border-primary/25 bg-primary/[0.025]`,children:[(0,U.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center gap-2 px-3 py-2.5 [&::-webkit-details-marker]:hidden`,children:[(0,U.jsx)(de,{className:`size-4 text-primary`}),(0,U.jsx)(`span`,{className:`text-xs font-semibold`,children:`Task intelligence`}),(0,U.jsx)(`span`,{className:`rounded bg-muted px-1.5 py-0.5 text-[9px] uppercase text-muted-foreground`,children:t.status}),(0,U.jsxs)(`span`,{className:`ml-auto text-[10px] text-muted-foreground`,children:[s.eventCount,` events`]}),(0,U.jsx)(x,{className:`size-3.5 text-muted-foreground`})]}),(0,U.jsxs)(`div`,{className:`space-y-2.5 border-t border-border/60 p-2.5`,children:[(0,U.jsxs)(`section`,{className:`rounded-md border border-info/25 bg-info/5 p-2.5`,children:[(0,U.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5 text-[10px]`,children:[(0,U.jsx)(`span`,{className:`rounded bg-info/10 px-1.5 py-0.5 font-semibold text-info`,children:s.column}),(0,U.jsxs)(`span`,{className:`rounded bg-muted px-1.5 py-0.5`,children:[`stage:`,t.lifecycle?.currentStage??`legacy`]}),(0,U.jsxs)(`span`,{className:`rounded bg-muted px-1.5 py-0.5`,children:[`priority:`,t.priority]}),(0,U.jsxs)(`span`,{className:`rounded bg-muted px-1.5 py-0.5`,children:[`type:`,t.type??`inferred`]})]}),(0,U.jsxs)(`p`,{className:`mt-2 text-[11px] leading-4`,children:[(0,U.jsx)(`strong`,{children:`Why here:`}),` `,s.reason]}),s.blockers.length>0&&(0,U.jsxs)(`p`,{className:`mt-1 text-[10px] text-warning`,children:[s.blockers.length,` unresolved blocker`,s.blockers.length===1?``:`s`]})]}),(0,U.jsxs)(`div`,{className:`grid gap-2 xl:grid-cols-2`,children:[(0,U.jsxs)(Sn,{icon:(0,U.jsx)(A,{className:`size-3`}),title:`Ownership & runtime`,children:[(0,U.jsx)($,{label:`Owner`,value:s.owner}),(0,U.jsx)($,{label:`Assignee`,value:Z(t.assignee)??Z(t.assignedAgent)??`—`}),(0,U.jsx)($,{label:`Agent ID`,value:Z(c?.agentId)??`—`,mono:!0}),(0,U.jsx)($,{label:`Agent name / role`,value:[Z(c?.name),Z(c?.role)].filter(Boolean).join(` · `)||`—`}),(0,U.jsx)($,{label:`Run status`,value:Z(c?.status)??`unassigned`}),(0,U.jsx)($,{label:`Subagent`,value:Z(c?.subagentId)??`—`,mono:!0}),(0,U.jsx)($,{label:`Run task`,value:Z(c?.runTaskId)??`—`,mono:!0}),(0,U.jsx)($,{label:`Session(s)`,value:s.sessions.join(`, `)||`Unknown`,mono:!0}),(0,U.jsx)($,{label:`Users / presence`,value:s.presence.length?s.presence.join(`, `):`No task-scoped presence recorded`})]}),(0,U.jsxs)(Sn,{icon:(0,U.jsx)(j,{className:`size-3`}),title:`Model route & fallback`,children:[(0,U.jsx)($,{label:`Routing mode`,value:s.routingMode}),(0,U.jsx)($,{label:`Primary`,value:s.primaryModel,mono:!0}),(0,U.jsx)($,{label:`Provider`,value:s.provider??`—`,mono:!0}),(0,U.jsx)($,{label:`Model`,value:s.model??`—`,mono:!0}),(0,U.jsx)($,{label:`Fallback route`,value:s.fallbackRoute,mono:!0}),(0,U.jsx)($,{label:`Skills`,value:c?.skills?.map(Z).filter(Boolean).join(`, `)||`Default`}),(0,U.jsx)($,{label:`Tools`,value:c?.tools?.map(Z).filter(Boolean).join(`, `)||`Default toolset`}),(0,U.jsx)($,{label:`Capabilities`,value:c?.allowedCapabilities?.map(Z).filter(Boolean).join(`, `)||`Safe defaults`,mono:!0})]}),(0,U.jsxs)(Sn,{icon:(0,U.jsx)(w,{className:`size-3`}),title:`Execution policy & outcome`,children:[(0,U.jsx)($,{label:`Attempts`,value:`${s.attempts}${c?.maxAttempts?` / ${c.maxAttempts}`:``}`}),(0,U.jsx)($,{label:`Retry policy`,value:c?.retryPolicy??t.retryPolicy??`off`}),(0,U.jsx)($,{label:`Cost ceiling`,value:(c?.costCeilingUsd??t.costCeilingUsd)==null?`Unbounded`:`$${(c?.costCeilingUsd??t.costCeilingUsd).toFixed(2)}`}),(0,U.jsx)($,{label:`Failures / done`,value:`${s.failures} / ${s.completions}`}),(0,U.jsx)($,{label:`Checks`,value:`${u} / ${l} passed`}),(0,U.jsx)($,{label:`Last failure`,value:s.lastFailure??`—`}),(0,U.jsx)($,{label:`Result`,value:s.lastResult??`No result recorded`})]}),(0,U.jsxs)(Sn,{icon:(0,U.jsx)(h,{className:`size-3`}),title:`Timing & audit coverage`,children:[(0,U.jsx)($,{label:`Created`,value:Q(t.createdAt)}),(0,U.jsx)($,{label:`Updated`,value:Q(t.updatedAt)}),(0,U.jsx)($,{label:`Due`,value:Q(t.dueDate)}),(0,U.jsx)($,{label:`Dispatched`,value:Q(c?.dispatchedAt??c?.claimedAt)}),(0,U.jsx)($,{label:`Completed`,value:Q(c?.completedAt??t.completedAt)}),(0,U.jsx)($,{label:`Duration`,value:xn(c?.dispatchedAt??c?.claimedAt,c?.completedAt)}),(0,U.jsx)($,{label:`Heartbeat`,value:Q(c?.heartbeatAt)}),(0,U.jsx)($,{label:`Lease expires`,value:Q(c?.leaseExpiresAt)}),(0,U.jsx)($,{label:`Actors`,value:s.actors.join(`, `)||`Unknown`,mono:!0})]})]}),(0,U.jsxs)(Sn,{icon:(0,U.jsx)(re,{className:`size-3`}),title:`Dependencies, chain & provenance`,children:[(0,U.jsx)($,{label:`Dependencies`,value:(0,U.jsx)(Cn,{items:s.dependencies})}),(0,U.jsx)($,{label:`Other relations`,value:(0,U.jsx)(Cn,{items:f})}),(0,U.jsx)($,{label:`Chain`,value:t.chain?`${t.chain.chainId} · position ${t.chain.order}`:`None`,mono:!0}),(0,U.jsx)($,{label:`Origin system`,value:t.origin?.system??`manual`}),(0,U.jsx)($,{label:`Origin IDs`,value:t.origin&&[t.origin.graphId,t.origin.phaseId,t.origin.taskId,t.origin.specId].filter(Boolean).join(` · `)||`—`,mono:!0}),(0,U.jsx)($,{label:`Task ID`,value:t.id,mono:!0}),(0,U.jsx)($,{label:`Board ID`,value:e.id,mono:!0})]})]})]})}var Tn={passed:{icon:v,label:`Passed`,className:`text-success`},failed:{icon:o,label:`Failed`,className:`text-destructive`},needs_human:{icon:c,label:`Needs Review`,className:`text-warning`},incomplete:{icon:u,label:`Incomplete`,className:`text-muted-foreground`}},En={passed:{label:`Passed`,className:`text-success`},failed:{label:`Failed`,className:`text-destructive`},skipped:{label:`Skipped`,className:`text-muted-foreground`},error:{label:`Error`,className:`text-warning`}};function Dn(e,t){let n=Date.parse(t)-Date.parse(e);return Number.isNaN(n)||n<0?``:n<1e3?`${n}ms`:n<6e4?`${Math.round(n/1e3)}s`:`${Math.floor(n/6e4)}m ${Math.round(n%6e4/1e3)}s`}function On({verdict:e}){let t=Tn[e],n=t.icon;return(0,U.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 rounded-full px-2.5 py-0.5 text-xs font-semibold ${t.className}`,children:[(0,U.jsx)(n,{size:13}),t.label]})}function kn({title:e,icon:t,defaultOpen:n=!1,children:r}){let[i,a]=(0,R.useState)(n);return(0,U.jsxs)(`div`,{className:`rounded-md border bg-background`,children:[(0,U.jsxs)(`button`,{type:`button`,onClick:()=>a(!i),className:`flex w-full items-center gap-2 px-3 py-2 text-xs font-semibold uppercase text-muted-foreground hover:bg-muted/50`,children:[i?(0,U.jsx)(x,{size:13}):(0,U.jsx)(ce,{size:13}),(0,U.jsx)(t,{size:13}),e]}),i&&(0,U.jsx)(`div`,{className:`border-t px-3 py-2 space-y-2`,children:r})]})}function An({check:e}){let t=En[e.status],[n,r]=(0,R.useState)(!1),i=e.error||e.backingRefs?.length;return(0,U.jsxs)(`div`,{className:`rounded border bg-muted/30 px-2.5 py-2 text-xs`,children:[(0,U.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,U.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,U.jsx)(`span`,{className:`font-medium ${t.className}`,children:t.label}),(0,U.jsx)(`span`,{className:`rounded bg-muted px-1 text-[10px] text-muted-foreground`,children:e.type})]}),(0,U.jsx)(`p`,{className:`mt-0.5 text-muted-foreground`,children:e.description})]}),i&&(0,U.jsx)(`button`,{type:`button`,onClick:()=>r(!n),className:`shrink-0 text-muted-foreground hover:text-foreground`,children:n?(0,U.jsx)(x,{size:13}):(0,U.jsx)(ce,{size:13})})]}),n&&(0,U.jsxs)(`div`,{className:`mt-2 space-y-1.5 border-t pt-2`,children:[e.error&&(0,U.jsx)(`div`,{className:`rounded bg-destructive/10 px-2 py-1 text-destructive`,children:e.error}),e.backingRefs?.map((e,t)=>(0,U.jsxs)(`div`,{className:`flex items-center gap-1.5 text-muted-foreground`,children:[(0,U.jsx)(fe,{size:11}),(0,U.jsx)(`span`,{className:`font-mono text-[11px]`,children:e.path}),(0,U.jsxs)(`span`,{className:`text-[10px]`,children:[`(`,e.kind,`)`]}),e.summary&&(0,U.jsxs)(`span`,{className:`truncate`,children:[`— `,e.summary]})]},t))]})]})}function jn({fileScope:e}){return(0,U.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-3 text-xs`,children:[(0,U.jsxs)(`span`,{className:`text-muted-foreground`,children:[`Expected `,(0,U.jsx)(`strong`,{children:e.expectedChanges}),` changes`]}),(0,U.jsxs)(`span`,{className:`text-muted-foreground`,children:[`Actual `,(0,U.jsx)(`strong`,{children:e.actualChanges}),` changes`]}),(0,U.jsx)(`span`,{className:e.scopeMatches?`text-success`:`text-destructive`,children:e.scopeMatches?`✅ Scope matches`:`❌ Scope mismatch`})]}),(0,U.jsx)(`div`,{className:`space-y-1`,children:e.files.map((e,t)=>(0,U.jsxs)(`div`,{className:`flex items-center gap-2 text-xs font-mono text-muted-foreground`,children:[(0,U.jsx)(`span`,{className:e.operation===`create`?`text-success`:e.operation===`delete`?`text-destructive`:`text-muted-foreground`,children:e.operation===`create`?`+`:e.operation===`delete`?`−`:`∼`}),(0,U.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.path}),(0,U.jsxs)(`span`,{className:`text-[10px]`,children:[e.linesChanged,` line`,e.linesChanged===1?``:`s`]}),!e.expected&&(0,U.jsx)(`span`,{className:`rounded bg-warning/10 px-1 text-[10px] text-warning`,children:`unexpected`})]},t))})]})}function Mn({subtasks:e}){return(0,U.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-3 text-xs text-muted-foreground`,children:[(0,U.jsxs)(`span`,{children:[`Total `,(0,U.jsx)(`strong`,{children:e.total})]}),(0,U.jsxs)(`span`,{className:`text-success`,children:[`Completed `,(0,U.jsx)(`strong`,{children:e.completed})]}),e.failed>0&&(0,U.jsxs)(`span`,{className:`text-destructive`,children:[`Failed `,(0,U.jsx)(`strong`,{children:e.failed})]})]}),(0,U.jsx)(`div`,{className:`space-y-1`,children:e.children.map((e,t)=>(0,U.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[e.verdict===`passed`?(0,U.jsx)(`span`,{className:`text-success`,children:`✓`}):e.verdict===`failed`?(0,U.jsx)(`span`,{className:`text-destructive`,children:`✗`}):e.verdict===`needs_human`?(0,U.jsx)(`span`,{className:`text-warning`,children:`⚠`}):(0,U.jsx)(`span`,{className:`text-muted-foreground`,children:`○`}),(0,U.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.title})]},t))})]})}function Nn({attachments:e}){return(0,U.jsx)(`div`,{className:`space-y-1`,children:e.map((e,t)=>(0,U.jsxs)(`div`,{className:`flex items-start gap-2 rounded border bg-muted/30 px-2 py-1.5 text-xs`,children:[(0,U.jsx)(le,{size:12,className:`mt-0.5 shrink-0 text-muted-foreground`}),(0,U.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,U.jsx)(`div`,{className:`font-medium`,children:e.label}),(0,U.jsx)(`div`,{className:`mt-0.5 font-mono text-[11px] text-muted-foreground`,children:e.path?(0,U.jsxs)(`span`,{className:`truncate block`,children:[e.path,(0,U.jsx)(`span`,{className:`ml-1 rounded bg-muted px-1 text-[10px]`,children:e.kind})]}):(0,U.jsx)(`span`,{className:`rounded bg-muted px-1 text-[10px]`,children:e.kind})}),e.content&&(0,U.jsxs)(`pre`,{className:`mt-1 max-h-20 overflow-auto rounded bg-background p-1 text-[10px] text-muted-foreground`,children:[e.content.slice(0,500),e.content.length>500?`
3
- …`:``]})]})]},t))})}function Pn({report:e}){return(0,U.jsxs)(`div`,{className:`mt-5 space-y-3`,children:[(0,U.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,U.jsx)(`div`,{className:`text-xs font-semibold uppercase text-muted-foreground`,children:`Verification Report`}),(0,U.jsx)(On,{verdict:e.verdict})]}),e.markdownSummary&&(0,U.jsx)(`div`,{className:`text-[11px] text-muted-foreground`,children:Dn(e.startedAt,e.completedAt)})]}),e.markdownSummary&&(0,U.jsx)(`div`,{className:`rounded-md border bg-background px-3 py-2 text-xs text-muted-foreground whitespace-pre-wrap`,children:e.markdownSummary}),e.checks.length>0&&(0,U.jsx)(kn,{title:`Check Results`,icon:pe,defaultOpen:e.verdict!==`passed`,children:e.checks.map(e=>(0,U.jsx)(An,{check:e},e.checkId))}),e.fileScope&&(0,U.jsx)(kn,{title:`File Scope`,icon:fe,defaultOpen:!e.fileScope.scopeMatches,children:(0,U.jsx)(jn,{fileScope:e.fileScope})}),e.subtasks&&(0,U.jsx)(kn,{title:`Sub-Tasks`,icon:pe,children:(0,U.jsx)(Mn,{subtasks:e.subtasks})}),e.attachments.length>0&&(0,U.jsx)(kn,{title:`Attachments (${e.attachments.length})`,icon:le,children:(0,U.jsx)(Nn,{attachments:e.attachments})})]})}function Fn({boardId:e,task:t,sendKanban:n}){return vt(t,xe(n=>n.verificationActivity[`${e}:${t.id}`]))===`running`?(0,U.jsxs)(`div`,{className:`mt-4 flex items-center gap-2 rounded-md border border-info/30 bg-info/5 p-3 text-xs text-info`,children:[(0,U.jsx)(ae,{size:14,className:`animate-spin`}),`Verification running — checks are being executed…`]}):t.verificationReport?(0,U.jsxs)(`div`,{className:`mt-4`,children:[(0,U.jsx)(Pn,{report:t.verificationReport}),(0,U.jsx)(`button`,{type:`button`,onClick:()=>n(`kanban.task.verify`,{boardId:e,taskId:t.id}),className:`mt-1.5 rounded-md border px-2 py-1 text-[11px] text-muted-foreground hover:bg-muted`,children:`Re-run verification`})]}):(0,U.jsxs)(`div`,{className:`mt-4 rounded-md border border-dashed p-3`,children:[(0,U.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,U.jsx)(C,{size:14}),(0,U.jsx)(`span`,{className:`font-medium`,children:`Unverified`}),(0,U.jsx)(`span`,{children:`— no verification report exists for this task yet.`})]}),(0,U.jsx)(`button`,{type:`button`,onClick:()=>n(`kanban.task.verify`,{boardId:e,taskId:t.id}),className:`mt-2 rounded-md bg-primary/10 px-2.5 py-1.5 text-xs font-medium text-primary hover:bg-primary/20`,children:`Run verification`})]})}function In({boards:e,board:t,task:n,runLink:r,onClose:i,onSelectTask:a,sendKanban:o,sendRaw:s,refreshBoard:c,activityEvents:l,activityPresence:u,activityLoading:f,activityError:p,activitySessionId:h,refreshActivity:g}){let[v,y]=(0,R.useState)(``),[b,C]=(0,R.useState)(``),[T,D]=(0,R.useState)(``),[O,te]=(0,R.useState)(``),[re,ie]=(0,R.useState)(``),[k,ae]=(0,R.useState)(`session`),[A,oe]=(0,R.useState)(``),[se,ce]=(0,R.useState)([]),[le,ue]=(0,R.useState)([]),[de,fe]=(0,R.useState)([]),[pe,me]=(0,R.useState)([]),[j,he]=(0,R.useState)(``),ge=Se(!!n),M=qe(!!n),N=G(M.sessionProvider),ve=G(M.sessionModel),ye=Te(`kanban-task-inspector`,!!n),[be,xe]=(0,R.useState)(!1),[F,we]=(0,R.useState)(!1),[I,Ee]=(0,R.useState)(``),[L,De]=(0,R.useState)(``),[z,Oe]=(0,R.useState)(``),[ke,Ae]=(0,R.useState)(`pending`),[je,Me]=(0,R.useState)(``),[Ne,Pe]=(0,R.useState)(``),[Fe,Ie]=(0,R.useState)(``),[Le,Re]=(0,R.useState)(`medium`),[ze,Be]=(0,R.useState)(`chore`),[B,Ve]=(0,R.useState)(``),[V,He]=(0,R.useState)([]),[Ue,We]=(0,R.useState)([]),[H,Ge]=(0,R.useState)(!1),[Ke,Je]=(0,R.useState)(``),[Ye,Xe]=(0,R.useState)(``),[Ze,Qe]=(0,R.useState)(`off`),[$e,et]=(0,R.useState)(``),[tt,nt]=(0,R.useState)(``),[rt,it]=(0,R.useState)(``),[at,ot]=(0,R.useState)(``),[ct,lt]=(0,R.useState)(``),[ut,dt]=(0,R.useState)(`observation`),[ft,pt]=(0,R.useState)(`unknown`),[mt,ht]=(0,R.useState)(``);(0,R.useEffect)(()=>{let r=G(n?.assignment?.provider),i=G(n?.assignment?.model);y(G(n?.assignment?.agentId)??G(n?.assignedAgent)??``),C(G(n?.assignment?.name)??``),D(G(n?.assignment?.role)??``),te(r??``),ie(i??``),ae(n?.assignment?.modelRouting??(r||i?`fixed`:`session`)),oe(G(n?.assignment?.fallbackProfile)??``),ce(n?.assignment?.fallbackModels??[]),ue(n?.assignment?.skills??[]),fe(n?.assignment?.tools??[]),me(n?.assignment?.allowedCapabilities??[]),he(e.find(e=>e.id!==t?.id)?.id??``),Ee(n?.title??``),De(n?.description??``),Oe(n?.dueDate??``),Ae(n?.status??`pending`),Me(``),Pe(``),Ie(``),Re(n?.priority??`medium`),Be(n?.type??`chore`),Ve(n?.labels?.join(`, `)??``),He(n?.dependsOn??[]),We(n?.chain&&t?t.tasks.filter(e=>e.chain?.chainId===n.chain?.chainId).sort((e,t)=>(e.chain?.order??0)-(t.chain?.order??0)).map(e=>e.id):n?[n.id]:[]),Ge(!1),Je(n?.estimatedHours?.toString()??``),Xe(n?.actualHours?.toString()??``),Qe(n?.retryPolicy??n?.assignment?.retryPolicy??`off`),et((n?.costCeilingUsd??n?.assignment?.costCeilingUsd)?.toString()??``),nt(n?.assignment?.maxAttempts?.toString()??``),it(``),ot(``),lt(``),dt(`observation`),pt(`unknown`),ht(``)},[t?.id,e,n]);let _t=e=>({boardId:t?.id,taskId:n?.id,...v.trim()?{agentId:v.trim()}:{},...b.trim()?{name:b.trim()}:{},...T.trim()?{role:T.trim()}:{},modelRouting:k,...k===`fixed`&&O.trim()?{provider:O.trim()}:{},...k===`fixed`&&re.trim()?{model:re.trim()}:{},...k===`fallback_profile`&&A.trim()?{fallbackProfile:A.trim()}:{},fallbackModels:se,skills:le,tools:de,allowedCapabilities:pe,...tt?{maxAttempts:Number(tt)}:{},...$e?{costCeilingUsd:Number($e)}:{},retryPolicy:Ze,activityNote:mt.trim()||`${e===`dispatch`?`Dispatched`:`Assigned`} from WebUI to ${b.trim()||v.trim()||T.trim()||`the configured agent route`}.`}),vt=()=>{!t||!n||!I.trim()||(o(`kanban.task.update`,{boardId:t.id,taskId:n.id,title:I.trim(),description:L,dueDate:z||null,...t.lifecycle?.mode===`managed`?{}:{status:ke},priority:Le,type:ze,labels:B.split(`,`).map(e=>e.trim()).filter(Boolean),dependsOn:V,...n.chain&&Ue.length<=1?{chain:null}:{},estimatedHours:Ke?Number(Ke):0,actualHours:Ye?Number(Ye):0,retryPolicy:Ze,costCeilingUsd:$e?Number($e):null,activityNote:mt.trim()||`Task contract edited in WebUI.`}),Ue.length>1&&o(`kanban.task.chain`,{boardId:t.id,taskIds:Ue,enforceDependencies:H}),window.setTimeout(()=>c(t.id),180),ht(``))},yt=[`backlog`,`todo`,`running`,`review`,`done`],bt=n?.lifecycle?.currentStage,xt=bt?yt.indexOf(bt):-1,St=xt>=0&&xt<yt.length-1?yt[xt+1]:void 0;return n?(0,U.jsxs)(`aside`,{"aria-label":`Task inspector`,"data-expanded":F?`true`:`false`,className:P(`flex max-h-[42dvh] w-full shrink-0 flex-col border-t bg-card/40 transition-[width] duration-200 ease-out md:max-h-none md:border-l md:border-t-0`,F?`fixed inset-0 z-50 h-dvh max-h-none w-screen border-0 bg-card transition-none md:w-screen md:border-0`:`md:w-[420px] xl:w-[480px]`),children:[(0,U.jsxs)(`div`,{className:P(`flex h-12 items-center gap-2 border-b px-3`,F&&`px-5`),children:[(0,U.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,U.jsx)(`div`,{className:`truncate text-sm font-semibold`,children:`Task`}),(0,U.jsx)(`div`,{className:`truncate text-[11px] text-muted-foreground`,children:n.id.slice(0,8)})]}),(0,U.jsx)(`button`,{type:`button`,title:F?`Collapse task details`:`Expand task details`,"aria-label":F?`Collapse task details`:`Expand task details`,"aria-pressed":F,onClick:()=>we(e=>!e),className:`flex h-8 w-8 items-center justify-center rounded-md text-muted-foreground hover:bg-muted hover:text-foreground`,children:F?(0,U.jsx)(_,{size:16}):(0,U.jsx)(S,{size:16})}),(0,U.jsx)(`button`,{type:`button`,title:`Close`,onClick:()=>{we(!1),i()},className:`flex h-8 w-8 items-center justify-center rounded-md text-muted-foreground hover:bg-muted hover:text-foreground`,children:(0,U.jsx)(E,{size:16})})]}),n?(0,U.jsxs)(`div`,{ref:ye,className:P(`min-h-0 flex-1 overflow-y-auto overscroll-contain p-3`,F&&`px-5 py-4 xl:px-7`),children:[(0,U.jsxs)(`div`,{className:`space-y-3 rounded-md border bg-background p-2.5`,children:[(0,U.jsx)(st,{title:`Task boundary`,value:n.boundary,inherited:t?.boundary,onSave:e=>{t&&(o(`kanban.task.update`,{boardId:t.id,taskId:n.id,boundary:e,activityNote:`Task boundary edited in WebUI.`}),window.setTimeout(()=>c(t.id),150))}}),(0,U.jsx)(K,{label:`Title`,value:I,onChange:Ee}),(0,U.jsxs)(`label`,{className:`block`,children:[(0,U.jsx)(`span`,{className:`mb-1 block text-[11px] font-medium text-muted-foreground`,children:`Description / working context`}),(0,U.jsx)(`textarea`,{value:L,onChange:e=>De(e.target.value),rows:5,className:`w-full resize-y rounded-md border bg-background px-2 py-1.5 text-xs leading-5 outline-none focus:border-primary`})]}),(0,U.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[t?.lifecycle?.mode===`managed`?(0,U.jsxs)(`div`,{className:`rounded-md border bg-muted/30 px-2 py-1.5`,children:[(0,U.jsx)(`div`,{className:`text-[10px] font-medium uppercase tracking-wide text-muted-foreground`,children:`Managed stage`}),(0,U.jsx)(`div`,{className:`mt-1 text-xs font-semibold capitalize`,children:n.lifecycle?.currentStage??`Backlog`})]}):(0,U.jsx)(q,{label:`Status`,value:ke,options:[`pending`,`ready`,`in_progress`,`blocked`,`review`,`completed`,`failed`,`archived`],onChange:e=>Ae(e)}),(0,U.jsx)(q,{label:`Priority`,value:Le,options:[`critical`,`high`,`medium`,`low`],onChange:e=>Re(e)}),(0,U.jsx)(q,{label:`Type`,value:ze,options:[`feature`,`bugfix`,`refactor`,`docs`,`test`,`chore`],onChange:e=>Be(e)}),(0,U.jsx)(K,{label:`Labels (comma separated)`,value:B,onChange:Ve})]}),(0,U.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,U.jsx)(K,{label:`Due date (ISO or YYYY-MM-DD)`,value:z,onChange:Oe}),(0,U.jsx)(K,{label:`Estimated hours`,value:Ke,onChange:Je}),(0,U.jsx)(K,{label:`Actual hours`,value:Ye,onChange:Xe})]}),(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`span`,{className:`mb-1 block text-[11px] font-medium text-muted-foreground`,children:`Dependencies`}),(0,U.jsx)(W,{options:(t?.tasks??[]).filter(e=>e.id!==n.id).map(e=>({value:e.id,label:e.title,description:e.status})),selected:V,onChange:He,placeholder:`Select blocking tasks…`})]}),(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`span`,{className:`mb-1 block text-[11px] font-medium text-muted-foreground`,children:`Task chain (selection order)`}),(0,U.jsx)(W,{options:(t?.tasks??[]).map(e=>({value:e.id,label:e.title,description:e.status})),selected:Ue,onChange:e=>We(e.includes(n.id)?e:[n.id,...e]),placeholder:`Add tasks to a sequential chain…`}),(0,U.jsxs)(`label`,{className:`mt-1.5 flex items-center gap-2 text-[11px] text-muted-foreground`,children:[(0,U.jsx)(`input`,{type:`checkbox`,checked:H,onChange:e=>Ge(e.target.checked)}),`Enforce chain order as dependencies`]})]}),(0,U.jsx)(K,{label:`Change / assignment reason (persisted to activity)`,value:mt,onChange:ht}),(0,U.jsxs)(`button`,{type:`button`,onClick:vt,className:`inline-flex h-9 w-full items-center justify-center gap-2 rounded-md bg-primary text-sm text-primary-foreground hover:bg-primary/90`,children:[(0,U.jsx)(ee,{size:15}),` Save task contract`]}),t?.lifecycle?.mode===`managed`&&St&&(0,U.jsxs)(`section`,{"aria-label":`Managed lifecycle transition`,className:`space-y-2 rounded-md border border-primary/30 bg-primary/5 p-2.5`,children:[(0,U.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`div`,{className:`text-[10px] font-semibold uppercase tracking-wide text-primary`,children:`Kanban Agent transition`}),(0,U.jsxs)(`div`,{className:`text-xs text-muted-foreground`,children:[bt,` → `,St,`; no stages can be skipped.`]})]}),(0,U.jsx)(w,{size:16,className:`text-primary`})]}),(0,U.jsx)(K,{label:`Completed action / reviewer action`,value:Ne,onChange:Pe}),(0,U.jsx)(K,{label:`Truthful progress comment (required)`,value:je,onChange:Me}),(0,U.jsx)(K,{label:`Evidence attachment URL`,value:Fe,onChange:Ie}),(0,U.jsxs)(`button`,{type:`button`,disabled:!je.trim(),onClick:()=>{!t||!n||!St||!je.trim()||(o(`kanban.task.transition`,{boardId:t.id,taskId:n.id,to:St,actor:v.trim()||b.trim()||n.assignee||n.assignedAgent||`webui-agent`,comment:je.trim(),...Ne.trim()?{action:Ne.trim()}:{},...Fe.trim()?{attachment:{url:Fe.trim(),type:`url`,title:`Evidence for ${n.title}`}}:{}}),window.setTimeout(()=>c(t.id),180))},className:`inline-flex h-9 w-full items-center justify-center gap-2 rounded-md bg-primary text-sm text-primary-foreground hover:bg-primary/90 disabled:cursor-not-allowed disabled:opacity-50`,children:[(0,U.jsx)(d,{size:15}),` Advance to `,St]})]})]}),t&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(wn,{board:t,task:n,events:l,presence:u,sessionId:h,sessionProvider:N,sessionModel:ve}),(0,U.jsx)(_n,{task:n,events:l,sessionId:h}),(0,U.jsx)(jt,{board:t,task:n,events:l})]}),(0,U.jsxs)(`div`,{className:`mt-3 grid grid-cols-2 gap-2 text-xs`,children:[(0,U.jsx)(wt,{label:`Source`,value:n.origin?.system??`manual`}),(0,U.jsx)(wt,{label:`Task ID`,value:n.id.slice(0,8)}),(0,U.jsx)(wt,{label:`Run`,value:n.assignment?.status??`unassigned`}),(0,U.jsx)(wt,{label:`Column`,value:Ct(t,n.columnId)})]}),n.assignment&&(0,U.jsx)(Kt,{assignment:n.assignment}),r&&n.origin?.taskId&&(0,U.jsx)(Lt,{runLink:r,runTaskId:n.origin.taskId,modelCandidates:ge,sendRaw:s}),!r&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsxs)(`div`,{className:`mt-4 space-y-3`,children:[(0,U.jsx)(q,{label:`Primary model source`,value:k,options:[`session`,`fixed`,`fallback_profile`],onChange:e=>ae(e)}),k===`session`&&(0,U.jsxs)(`div`,{className:`rounded-md border bg-info/5 px-2 py-1.5 text-[11px] text-muted-foreground`,children:[`Uses the live session model: `,N?`${N}/`:``,ve||`not available`,`.`]}),k===`fixed`&&(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`span`,{className:`mb-1 block text-[11px] font-medium text-muted-foreground`,children:`Fixed provider / model`}),(0,U.jsx)(Ce,{value:re||void 0,provider:O||void 0,candidates:ge,placeholder:`Select exact provider / model…`,onPick:(e,t)=>{ie(e),te(t)}})]}),k===`fallback_profile`&&(0,U.jsx)(q,{label:`Fallback profile (first model is primary)`,value:A,options:Object.keys(M.fallbackProfiles),placeholder:`Select configured profile…`,onChange:oe}),(0,U.jsxs)(`div`,{children:[(0,U.jsx)(`span`,{className:`mb-1 block text-[11px] font-medium text-muted-foreground`,children:`Fallback models`}),(0,U.jsx)(W,{options:ge.map(e=>({value:`${e.provider}/${e.model}`,label:e.label,description:e.description,tag:e.provider})),selected:se,onChange:ce,placeholder:`Add fallback model…`,emptyLabel:`No models — add a provider in Settings`})]}),(0,U.jsx)(q,{label:`Role`,value:T,options:Yt,placeholder:`Select a role…`,onChange:D}),(0,U.jsxs)(`div`,{children:[(0,U.jsxs)(`span`,{className:`mb-1 block text-[11px] font-medium text-muted-foreground`,children:[`Agentic skills`,` `,(0,U.jsx)(`span`,{className:`text-muted-foreground/70`,children:`· force-loaded into the worker`})]}),(0,U.jsx)(W,{options:M.skills.map(e=>({value:e.name,label:e.name,description:e.description,tag:e.source})),selected:le,onChange:ue,placeholder:`Assign required skills…`,emptyLabel:`No skills registered`})]}),(0,U.jsxs)(`div`,{children:[(0,U.jsxs)(`span`,{className:`mb-1 block text-[11px] font-medium text-muted-foreground`,children:[`Tools`,` `,(0,U.jsx)(`span`,{className:`text-muted-foreground/70`,children:`· blank = full default toolset`})]}),(0,U.jsx)(W,{options:M.tools.map(e=>({value:e.name,label:e.name,description:e.description})),selected:de,onChange:fe,placeholder:`Restrict to specific tools…`,emptyLabel:`Tool list unavailable on this server`})]}),(0,U.jsxs)(`div`,{className:`rounded-md border bg-background/60`,children:[(0,U.jsxs)(`button`,{type:`button`,onClick:()=>xe(e=>!e),className:`flex w-full items-center justify-between px-2 py-1.5 text-[11px] font-medium text-muted-foreground hover:text-foreground`,children:[`Advanced`,(0,U.jsx)(x,{size:13,className:P(`transition-transform`,be&&`rotate-180`)})]}),be&&(0,U.jsxs)(`div`,{className:`space-y-3 border-t p-2`,children:[(0,U.jsx)(K,{label:`Agent name (optional)`,value:b,onChange:C}),(0,U.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,U.jsx)(q,{label:`Retry policy`,value:Ze,options:[`off`,`incremental`,`exponential`],onChange:e=>Qe(e)}),(0,U.jsx)(K,{label:`Max attempts`,value:tt,onChange:nt}),(0,U.jsx)(K,{label:`Cost ceiling USD`,value:$e,onChange:et})]}),(0,U.jsxs)(`div`,{children:[(0,U.jsxs)(`span`,{className:`mb-1 block text-[11px] font-medium text-muted-foreground`,children:[`Capabilities`,` `,(0,U.jsx)(`span`,{className:`text-muted-foreground/70`,children:`· blank = safe defaults`})]}),(0,U.jsx)(W,{options:Xt,selected:pe,onChange:me,placeholder:`Grant a capability…`})]})]})]})]}),(0,U.jsxs)(`div`,{className:`mt-4 grid grid-cols-2 gap-2`,children:[(0,U.jsxs)(`button`,{type:`button`,onClick:()=>{!t||!n||(o(`kanban.task.assign`,_t(`assign`)),ht(``),window.setTimeout(()=>c(t.id),150))},className:`inline-flex h-9 items-center justify-center gap-2 rounded-md border text-sm hover:bg-muted`,children:[(0,U.jsx)(m,{size:15}),`Assign`]}),(0,U.jsxs)(`button`,{type:`button`,onClick:()=>{!t||!n||(o(`kanban.task.dispatch`,_t(`dispatch`)),ht(``),window.setTimeout(()=>c(t.id),200))},className:`inline-flex h-9 items-center justify-center gap-2 rounded-md bg-primary text-sm text-primary-foreground hover:bg-primary/90`,children:[(0,U.jsx)(ne,{size:15}),`Dispatch`]})]})]}),e.length>1&&!r?(0,U.jsxs)(`div`,{className:`mt-4 space-y-2 rounded-md border bg-background p-2`,children:[(0,U.jsxs)(`label`,{className:`block`,children:[(0,U.jsx)(`span`,{className:`mb-1 block text-[11px] font-medium text-muted-foreground`,children:`Target board`}),(0,U.jsx)(`select`,{value:j,onChange:e=>he(e.target.value),className:`h-8 w-full rounded-md border bg-background px-2 text-sm outline-none focus:border-primary`,children:e.filter(e=>e.id!==t?.id).map(e=>(0,U.jsx)(`option`,{value:e.id,children:e.title},e.id))})]}),(0,U.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,U.jsxs)(`button`,{type:`button`,onClick:()=>{!t||!n||!j||o(`kanban.task.copy`,{boardId:t.id,taskId:n.id,targetBoardId:j})},disabled:!j,className:`inline-flex h-9 items-center justify-center gap-2 rounded-md border text-sm hover:bg-muted disabled:opacity-50`,children:[(0,U.jsx)(_e,{size:15}),`Copy`]}),(0,U.jsxs)(`button`,{type:`button`,onClick:()=>{!t||!n||!j||o(`kanban.task.transfer`,{boardId:t.id,taskId:n.id,targetBoardId:j})},disabled:!j,className:`inline-flex h-9 items-center justify-center gap-2 rounded-md border text-sm hover:bg-muted disabled:opacity-50`,children:[(0,U.jsx)(d,{size:15}),`Transfer`]})]})]}):null,(0,U.jsx)(Jt,{board:t,task:n,newCheck:rt,onNewCheckChange:it,onAddCheck:()=>{!t||!n||!rt.trim()||(o(`kanban.task.check.add`,{boardId:t.id,taskId:n.id,description:rt.trim(),checkType:`manual`}),it(``))},sendKanban:o}),t&&(0,U.jsx)(Fn,{boardId:t.id,task:n,sendKanban:o}),t&&(0,U.jsx)(gt,{board:t,task:n,sendKanban:o,onSelectTask:a}),(0,U.jsx)(cn,{task:n,events:l,sessionId:h,loading:f,error:p,onRefresh:g}),(0,U.jsx)(qt,{activityKind:ut,activityOutcome:ft,note:at,details:ct,onActivityKindChange:dt,onActivityOutcomeChange:pt,onNoteChange:ot,onDetailsChange:lt,onRecordActivity:()=>{!t||!n||!at.trim()||(o(`kanban.task.activity.add`,{boardId:t.id,taskId:n.id,kind:ut,outcome:ft,summary:at.trim(),...ct.trim()?{details:ct.trim()}:{},actor:b.trim()||v.trim()||`webui-operator`}),ot(``),lt(``),window.setTimeout(g,150))}})]}):null]}):null}var Ln=[[`board`,`Board`],[`tree`,`Tree`],[`dashboard`,`Verification`]];function Rn({viewMode:e,onViewModeChange:t}){return(0,U.jsx)(`div`,{className:`flex shrink-0 items-center gap-1 border-b px-4 py-1.5`,children:Ln.map(([n,r])=>(0,U.jsx)(`button`,{type:`button`,onClick:()=>t(n),className:P(`rounded-md px-2.5 py-1 text-[11px] font-medium transition-colors`,e===n?`bg-primary/10 text-primary`:`text-muted-foreground hover:bg-muted`),children:r},n))})}function zn(){let[e,t]=(0,R.useState)([]);return(0,R.useEffect)(()=>{let e=!1,n=async()=>{try{let n=await fetch(`/api/sessions`);if(!n.ok)return;let r=await n.json();if(!Array.isArray(r)||e)return;let i=r.filter(e=>!!e&&typeof e==`object`&&typeof e.sessionId==`string`&&e.status!==`lost`).map(e=>e.sessionId).sort();t(e=>e.length===i.length&&e.every((e,t)=>e===i[t])?e:i)}catch{}};n();let r=window.setInterval(n,8e3);return()=>{e=!0,window.clearInterval(r)}},[]),e}var Bn=5e3,Vn=12;function Hn({onClose:e}){let t=be(e=>e.wsUrl),n=ye(e=>e.session?.id??null),r=F(e=>e.agents),{boards:i,boardTotal:a,activeBoardTotal:o,orphanedBoardTotal:s,activeBoardId:c,activeBoard:l,loading:u,error:d,queueHealth:p,supervisorSnapshot:m,setLoading:h,setActiveBoardId:g}=xe(),[_,v]=(0,R.useState)(``),[y,b]=(0,R.useState)(1),x=zn(),[S,C]=(0,R.useState)(``),w=(0,R.useRef)(null);De(w);let[T,ee]=(0,R.useState)(``),[D,O]=(0,R.useState)(null),[te,ne]=(0,R.useState)([]),[re,k]=(0,R.useState)(),[ae,A]=(0,R.useState)(!1),[oe,se]=(0,R.useState)(null),[ce,le]=(0,R.useState)(0),[ue,de]=(0,R.useState)(null),[fe,pe]=(0,R.useState)(`board`),me=(0,R.useRef)(null),j=(0,R.useMemo)(()=>ve(t),[t]),he=l?.tasks.find(e=>e.id===D)??null,ge=(0,R.useMemo)(()=>$e(r.values()),[r]),N=(0,R.useMemo)(()=>et({sessionId:n,registrySessionIds:x,agents:r.values()}),[r,x,n]),P=i.filter(e=>tt(e,N)),Se=i.filter(e=>!tt(e,N)),Ce=(0,R.useMemo)(()=>l?ke(l,{now:Date.now(),liveAgentIdentities:ge,requireDueDate:l.lifecycle?.mode===`managed`}):null,[l,ge]),we=(0,R.useMemo)(()=>nt(l),[l]),I=(e,t={})=>{h(!0),j.send({type:e,payload:t})},Te=(e,t={})=>{j.send({type:e,payload:t})},Ee=(0,R.useMemo)(()=>rt(l),[l]),L=(e=y)=>I(`kanban.list`,{page:e,pageSize:Vn,activeSessionIds:N}),z=(e=c)=>{e&&I(`kanban.get`,{boardId:e})};(0,R.useEffect)(()=>{L()},[]),(0,R.useEffect)(()=>{let e=n?i.find(e=>e.tags?.includes(`session:${n}`)):void 0,t=!!(n&&e)&&me.current!==n,r=t?e:c?void 0:i[0];r?.id&&(t&&(me.current=n),g(r.id),I(`kanban.get`,{boardId:r.id}))},[i,c,n,g]),(0,R.useEffect)(()=>{l&&D&&!l.tasks.some(e=>e.id===D)&&O(null)},[l,D]),(0,R.useEffect)(()=>{c&&(I(`kanban.health`,{boardId:c}),I(`kanban.supervisor.status`,{boardId:c}))},[c]),(0,R.useEffect)(()=>{if(!c)return;let e=setInterval(()=>{j.send({type:`kanban.get`,payload:{boardId:c}}),j.send({type:`kanban.health`,payload:{boardId:c}})},5e3);return()=>clearInterval(e)},[c,j]),(0,R.useEffect)(()=>{let e=setInterval(()=>{j.send({type:`kanban.list`,payload:{page:y,pageSize:Vn,activeSessionIds:N}})},8e3);return()=>clearInterval(e)},[N,y,j]);let Oe=e=>{b(e),g(null),L(e)};(0,R.useEffect)(()=>{k(void 0)},[c,D]),(0,R.useEffect)(()=>{if(!c||!D)return;let e=c,t=D;A(!0),se(null);let n=j.on(`kanban.task.activity`,n=>{let r=n.payload;if(r.success===!1){se(r.error??`Task activity could not be loaded.`),A(!1);return}r.data?.boardId!==e||r.data.taskId!==t||(ne(r.data.events??[]),k(r.data.presence??[]),A(!1))});return j.send({type:`kanban.task.activity`,payload:{boardId:e,taskId:t,limit:Bn}}),n},[c,D,he?.updatedAt,ce,j]),(0,R.useEffect)(()=>{if(!(!c||!D))return j.on.bind(j)(`kanban.task.activity.changed`,e=>{let t=e.payload;t.boardId===c&&t.taskId===D&&le(e=>e+1)})},[c,D,j]);let Ae=()=>{let e=_.trim();e&&(v(``),I(`kanban.create`,{title:e,lifecycle:{mode:`managed`,columns:{backlog:`backlog`,todo:`todo`,running:`in-progress`,review:`review`,done:`done`}}}))},je=()=>{if(!l)return;let e=S.trim();e&&(C(``),I(`kanban.task.add`,{boardId:l.id,title:e,columnId:l.columns[0]?.id??`backlog`,activityNote:`Task created manually in WebUI.`}),window.setTimeout(()=>z(l.id),150))},Me=()=>{if(!l)return;let e=T.trim();e&&(ee(``),I(`kanban.column.add`,{boardId:l.id,title:e}),window.setTimeout(()=>z(l.id),150))},Ne=()=>{l&&(I(`kanban.delete`,{boardId:l.id}),window.setTimeout(L,150))},Pe=()=>{l&&(I(`kanban.duplicate`,{boardId:l.id,title:`${l.title} Copy`}),window.setTimeout(L,150))},Fe=e=>{l&&(I(`kanban.task.remove`,{boardId:l.id,taskId:e.id}),window.setTimeout(()=>z(l.id),150))},Ie=(e,t)=>{if(!l)return;let n=l.tasks.find(t=>t.id===e),r=l.columns.find(e=>e.id===n?.columnId)?.title,i=l.columns.find(e=>e.id===t)?.title??t;I(`kanban.task.move`,{boardId:l.id,taskId:e,columnId:t,activityNote:`Moved in WebUI${r?` from ${r}`:``} to ${i}.`}),window.setTimeout(()=>z(l.id),150)};return(0,U.jsxs)(`div`,{className:`flex h-full min-h-0 min-w-0 flex-col bg-background text-foreground md:flex-row`,children:[(0,U.jsx)(it,{boardTotal:a,activeBoardTotal:o,orphanedBoardTotal:s,activeBoardId:c,activeBoards:P,orphanedBoards:Se,boardPage:y,boardPageSize:Vn,loading:u,newBoardTitle:_,onClose:e,onRefresh:()=>L(),onNewBoardTitleChange:v,onCreateBoard:Ae,onBoardSelect:e=>{g(e),I(`kanban.get`,{boardId:e})},onBoardPageChange:Oe}),(0,U.jsxs)(`main`,{className:`flex min-h-0 min-w-0 flex-1 flex-col`,children:[(0,U.jsxs)(`header`,{className:`flex min-h-12 shrink-0 flex-wrap items-center gap-2 border-b px-3 py-2 sm:px-4`,children:[(0,U.jsxs)(`div`,{className:`w-full min-w-0 sm:w-auto sm:flex-1`,children:[(0,U.jsx)(`div`,{className:`truncate text-sm font-semibold`,children:l?.title??`No board selected`}),(0,U.jsx)(`div`,{className:`truncate text-[11px] text-muted-foreground`,children:l?`${l.columns.length} columns / ${l.tasks.length} tasks`:`Create or select a board`})]}),l&&(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`input`,{value:S,onChange:e=>C(e.target.value),onKeyDown:e=>{e.key===`Enter`&&je()},placeholder:`New task`,className:`h-8 w-[calc(100%-2.5rem)] min-w-0 flex-none rounded-md border bg-background px-2 text-sm outline-none focus:border-primary sm:w-56`}),(0,U.jsx)(`button`,{type:`button`,title:`Add task`,onClick:je,className:`flex h-8 w-8 items-center justify-center rounded-md bg-primary text-primary-foreground hover:bg-primary/90`,children:(0,U.jsx)(M,{size:16})}),(0,U.jsx)(`input`,{value:T,onChange:e=>ee(e.target.value),onKeyDown:e=>{e.key===`Enter`&&Me()},placeholder:`New column`,className:`h-8 w-[calc(100%-2.5rem)] min-w-0 flex-none rounded-md border bg-background px-2 text-sm outline-none focus:border-primary sm:w-44`}),(0,U.jsx)(`button`,{type:`button`,title:`Add column`,onClick:Me,className:`hidden h-8 w-8 items-center justify-center rounded-md border text-muted-foreground hover:bg-muted hover:text-foreground sm:flex`,children:(0,U.jsx)(f,{size:16})}),(0,U.jsx)(`button`,{type:`button`,title:`Duplicate board`,onClick:Pe,className:`flex h-8 w-8 items-center justify-center rounded-md border text-muted-foreground hover:bg-muted hover:text-foreground`,children:(0,U.jsx)(_e,{size:16})}),(0,U.jsx)(`button`,{type:`button`,title:`Delete board`,onClick:Ne,className:`hidden h-8 w-8 items-center justify-center rounded-md border text-muted-foreground hover:bg-destructive/10 hover:text-destructive sm:flex`,children:(0,U.jsx)(ie,{size:16})})]})]}),l&&(0,U.jsx)(Xe,{presence:l.presence}),l&&(0,U.jsx)(`div`,{className:`shrink-0 border-b px-3 py-2 sm:px-4`,children:(0,U.jsx)(st,{title:`Board boundary`,value:l.boundary,onSave:e=>{I(`kanban.update`,{boardId:l.id,boundary:e}),window.setTimeout(()=>z(l.id),150)}})}),l&&Ee&&(0,U.jsx)(Ft,{runLink:Ee,sendRaw:Te}),l&&!Ee&&l.tasks.length>0&&(0,U.jsx)(It,{boardId:l.id,sendKanban:I}),l&&(0,U.jsx)(Ze,{board:l,snapshot:m,sendKanban:I}),Ce&&(0,U.jsx)(dt,{audit:Ce,onSelectTask:O}),l&&(0,U.jsx)(pt,{board:l,sendKanban:I,onSelectTask:O}),l&&(0,U.jsx)(Rn,{viewMode:fe,onViewModeChange:pe}),d&&(0,U.jsxs)(`div`,{className:`flex h-9 shrink-0 items-center gap-2 border-b border-destructive/30 bg-destructive/10 px-4 text-sm text-destructive`,children:[(0,U.jsx)(E,{size:15}),(0,U.jsx)(`span`,{className:`truncate`,children:d})]}),(0,U.jsx)(`div`,{ref:w,className:`kanban-scroll-area min-h-0 flex-1 overflow-x-auto overflow-y-hidden overscroll-contain`,children:l?(0,U.jsxs)(U.Fragment,{children:[p&&(0,U.jsx)(Pt,{queueHealth:p,runningCostTotal:we}),fe===`tree`?(0,U.jsx)(Bt,{board:l,selectedTaskId:D,onSelectTask:O}):fe===`dashboard`?(0,U.jsx)(Ut,{board:l,onSelectTask:O}):(0,U.jsx)(`div`,{className:`flex h-full min-w-max gap-3 p-4`,children:[...l.columns].sort((e,t)=>e.order-t.order).map(e=>(0,U.jsx)(Nt,{board:l,column:e,selectedTaskId:D,dragTaskId:ue,setDragTaskId:de,onSelectTask:O,onDeleteTask:Fe,onMoveTask:Ie},e.id))})]}):(0,U.jsx)(`div`,{className:`flex h-full items-center justify-center text-sm text-muted-foreground`,children:`No kanban board selected.`})})]}),(0,U.jsx)(In,{boards:i,board:l,task:he,runLink:Ee,onClose:()=>O(null),onSelectTask:O,sendKanban:I,sendRaw:Te,refreshBoard:z,activityEvents:te,activityPresence:re,activityLoading:ae,activityError:oe,activitySessionId:l?.tags?.find(e=>e.startsWith(`session:`))?.slice(8),refreshActivity:()=>le(e=>e+1)})]})}export{Hn as KanbanView};