@open-mercato/cezar 0.20.0-pr2192.5251 → 0.20.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 (94) hide show
  1. package/dist/server/agent-setup-routes.d.ts +14 -14
  2. package/dist/server/dashboard.d.ts +54 -54
  3. package/dist/server/server.d.ts +68 -68
  4. package/dist/server/worktree-lifecycle.d.ts +90 -90
  5. package/dist/telemetry-service.json +1 -0
  6. package/dist/workflows/run-env-keys.d.ts +8 -0
  7. package/dist/workflows/run-env-keys.js +14 -0
  8. package/dist/workflows/run-env-keys.js.map +1 -0
  9. package/package.json +5 -5
  10. package/web/dist/assets/{active-forge-KyXM3uG9.js → active-forge-CkAcQPDz.js} +1 -1
  11. package/web/dist/assets/{agent-task-pickers-UkVtTCna.js → agent-task-pickers-BXCIulS3.js} +1 -1
  12. package/web/dist/assets/{alert-dialog-DT465VL4.js → alert-dialog-B2Vi6MQZ.js} +1 -1
  13. package/web/dist/assets/{ask-card-DVv8mY_R.js → ask-card-DPIjQSs8.js} +1 -1
  14. package/web/dist/assets/{assets-view-D22vr-oN.js → assets-view-CsFjfV2n.js} +1 -1
  15. package/web/dist/assets/{automation-format-KxcnBz7L.js → automation-format-CMG-6CYi.js} +1 -1
  16. package/web/dist/assets/{automations-route-3gfbxDq2.js → automations-route-Dd7F6b4F.js} +1 -1
  17. package/web/dist/assets/{button-CEskWahs.js → button-CJXK1JqU.js} +1 -1
  18. package/web/dist/assets/{centered-state-Cpzaj75Y.js → centered-state-DE6sgEMs.js} +1 -1
  19. package/web/dist/assets/{chip-CEZRGBV7.js → chip-DTCkrr8F.js} +1 -1
  20. package/web/dist/assets/{collapsible-ZLdkcdMa.js → collapsible-DHALizq-.js} +1 -1
  21. package/web/dist/assets/{command-CcbuBum7.js → command-CwP_dLx3.js} +1 -1
  22. package/web/dist/assets/{commit-list-BSjLQA6p.js → commit-list-BJeaIEp4.js} +1 -1
  23. package/web/dist/assets/{compare-variants-C9soYpuE.js → compare-variants-CYv97XSw.js} +1 -1
  24. package/web/dist/assets/{composer-Bz8ZfbHr.js → composer-C-aBJhY0.js} +1 -1
  25. package/web/dist/assets/{composer-attachments-BD2enHFJ.js → composer-attachments-ChelZhq4.js} +1 -1
  26. package/web/dist/assets/{dashboard-Bl6qWW8i.js → dashboard-Dh65_Yi7.js} +1 -1
  27. package/web/dist/assets/{dialog-nn9sCNvn.js → dialog-DVZE8yAO.js} +1 -1
  28. package/web/dist/assets/{diff-FrEDv09S.js → diff-aKT-mpn8.js} +2 -2
  29. package/web/dist/assets/{diff-stat-zisAayZW.js → diff-stat-DPetRUXO.js} +1 -1
  30. package/web/dist/assets/{diff-view-BeoeZVcx.js → diff-view-m4TvXu0y.js} +1 -1
  31. package/web/dist/assets/{dist-B_KqW6o6.js → dist-Bsi6zLdE.js} +1 -1
  32. package/web/dist/assets/{dropdown-menu-ayNafd3n.js → dropdown-menu-BKvUsb5Y.js} +1 -1
  33. package/web/dist/assets/{file-preview-Dzc3RFUx.js → file-preview-C2EkjhOh.js} +1 -1
  34. package/web/dist/assets/{follow-up-engine-Dul_3U9s.js → follow-up-engine-BnRCTyQ4.js} +1 -1
  35. package/web/dist/assets/{git-tab-loading-DG4p-eF4.js → git-tab-loading-DpG2D8Vl.js} +1 -1
  36. package/web/dist/assets/{github-DvZE0hDJ.js → github-CWRtsamJ.js} +1 -1
  37. package/web/dist/assets/{host-usage-GTjB03IM.js → host-usage-B8ohHYHR.js} +1 -1
  38. package/web/dist/assets/{icon-tooltip-DRhwcic2.js → icon-tooltip-DYk5cjLx.js} +1 -1
  39. package/web/dist/assets/{impact-control-CTdtyfcn.js → impact-control-ClslFBBA.js} +1 -1
  40. package/web/dist/assets/{impact-model-CpNcUgTV.js → impact-model-DCDyRxcf.js} +1 -1
  41. package/web/dist/assets/{index-BMA7ZpLG.js → index-BfbbA0lF.js} +4 -4
  42. package/web/dist/assets/{input-BtDLUR9Q.js → input-DofKzJZl.js} +1 -1
  43. package/web/dist/assets/{loading-state-BTvZxCb2.js → loading-state-NiNQtJ5H.js} +1 -1
  44. package/web/dist/assets/{manager-avatar-Ct1uVuvZ.js → manager-avatar-CKfqcoJQ.js} +1 -1
  45. package/web/dist/assets/{manager-chat-BfxPyXv3.js → manager-chat-BdigDKYZ.js} +1 -1
  46. package/web/dist/assets/{manager-index-CeMdRtKd.js → manager-index-D0TOmxr6.js} +1 -1
  47. package/web/dist/assets/{manager-new-Bs8_CMUR.js → manager-new-CCet_7u8.js} +1 -1
  48. package/web/dist/assets/{manager-settings-Bv2EqZvs.js → manager-settings-I1AeATjr.js} +1 -1
  49. package/web/dist/assets/{managers-DDPXJoKR.js → managers-Dr63u21Y.js} +1 -1
  50. package/web/dist/assets/{markdown-3rt1rOmI.js → markdown-CXJIKz2i.js} +1 -1
  51. package/web/dist/assets/{markdown-LlPZylt7.js → markdown-YSf01kqC.js} +1 -1
  52. package/web/dist/assets/{mascot-picker-BuGxdrpW.js → mascot-picker-C4s7n9Fc.js} +1 -1
  53. package/web/dist/assets/{new-task-form-BoiK41PS.js → new-task-form-2p4cXcVQ.js} +1 -1
  54. package/web/dist/assets/{picker-pill-CzANlEqt.js → picker-pill-Dv9H0dRF.js} +1 -1
  55. package/web/dist/assets/{pill-C2wRS9lg.js → pill-CoDPUIcJ.js} +1 -1
  56. package/web/dist/assets/{popover-DPba6FvD.js → popover-DUg9gBOn.js} +1 -1
  57. package/web/dist/assets/{project-router-CnMbTz-a.js → project-router-B1Q3upIJ.js} +1 -1
  58. package/web/dist/assets/{project-terminal-sfYncenW.js → project-terminal-DbIohh5G.js} +2 -2
  59. package/web/dist/assets/{provider-auth-alert-DbNH_-XT.js → provider-auth-alert-GxIEkIvw.js} +1 -1
  60. package/web/dist/assets/{queries-DVZ1lYAo.js → queries-BQUz3Wnb.js} +1 -1
  61. package/web/dist/assets/{reasoning-effort-pill-al6bbPpw.js → reasoning-effort-pill-BOV3C0If.js} +1 -1
  62. package/web/dist/assets/{reference-chip-DdxKs2_A.js → reference-chip-BpbybBvl.js} +1 -1
  63. package/web/dist/assets/{reference-conflict-action-Ci4LDmIm.js → reference-conflict-action-ByDYwT-Y.js} +1 -1
  64. package/web/dist/assets/{repo-git-BcEGYBrc.js → repo-git-ikURCYEK.js} +1 -1
  65. package/web/dist/assets/{run-actions-CDKK-8MP.js → run-actions-ChUnbFA7.js} +1 -1
  66. package/web/dist/assets/{run-diff-JJOUeclX.js → run-diff-B08Fk7dR.js} +1 -1
  67. package/web/dist/assets/{scroll-within-CfS_Ia4E.js → scroll-within-DMA4ZbQV.js} +1 -1
  68. package/web/dist/assets/{segmented-Chb1Y4ie.js → segmented-DI7abdqX.js} +1 -1
  69. package/web/dist/assets/{select-DG3hFvx2.js → select-DL5E3ZAD.js} +1 -1
  70. package/web/dist/assets/{sheet-DirfZrZD.js → sheet-DPwaj6sk.js} +1 -1
  71. package/web/dist/assets/{skills-CxWFZgjH.js → skills-BNiKFlUw.js} +1 -1
  72. package/web/dist/assets/{spinner-CwKcijCN.js → spinner-hSpq0sPM.js} +1 -1
  73. package/web/dist/assets/{status-dot-CZAbXsOs.js → status-dot-AP_4obOJ.js} +1 -1
  74. package/web/dist/assets/{tabs-r4PCzkHp.js → tabs-DrhZb97I.js} +1 -1
  75. package/web/dist/assets/{task-commits-CHnonzuD.js → task-commits-Di0Mc8MX.js} +1 -1
  76. package/web/dist/assets/{task-graph-DZAjkdmH.js → task-graph-Bpi3lEER.js} +1 -1
  77. package/web/dist/assets/{task-notes-CHs_WZf5.js → task-notes-DCHLinAF.js} +1 -1
  78. package/web/dist/assets/{task-workspace-DWGBLHlR.js → task-workspace-DHl5akxu.js} +3 -3
  79. package/web/dist/assets/{telemetry-onLa6CTl.js → telemetry-3DhVDxf8.js} +1 -1
  80. package/web/dist/assets/{terminal-drawer-DV7kUP0D.js → terminal-drawer-CEktqC3z.js} +1 -1
  81. package/web/dist/assets/{terminal-pane-DQAHtCtb.js → terminal-pane-CmmTwiTX.js} +1 -1
  82. package/web/dist/assets/{terminal-scope-CEQdw5Tz.js → terminal-scope-okFE6qRP.js} +1 -1
  83. package/web/dist/assets/{textarea-BqeSvPOp.js → textarea-DDyYxCcO.js} +1 -1
  84. package/web/dist/assets/{thread-items-CNxMLcOo.js → thread-items-C-4IW5zi.js} +1 -1
  85. package/web/dist/assets/{toaster-4t61QM_C.js → toaster-BoJZiTRl.js} +1 -1
  86. package/web/dist/assets/{tracker-B7u8exjG.js → tracker-bQUG9SkJ.js} +1 -1
  87. package/web/dist/assets/{tree-pane-resize-XHzIJDtc.js → tree-pane-resize-xgVK7J9r.js} +1 -1
  88. package/web/dist/assets/utils-Dp6vCdiU.js +55 -0
  89. package/web/dist/assets/{workflow-graph-BaZd6m6v.js → workflow-graph-CGMeFErv.js} +1 -1
  90. package/web/dist/assets/{worktree-lifecycle-YFVatYLd.js → worktree-lifecycle-C18dBDW4.js} +1 -1
  91. package/web/dist/assets/{worktree-lifecycle-operation-CYHhFvQF.js → worktree-lifecycle-operation-_xqKBVKB.js} +1 -1
  92. package/web/dist/assets/{zoomable-image-D4B6jvp-.js → zoomable-image-BiM5LfTG.js} +1 -1
  93. package/web/dist/index.html +46 -46
  94. package/web/dist/assets/utils-DWwoYTjU.js +0 -60
@@ -1,4 +1,4 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{$ as r,$n as i,Er as a,F as o,Ni as s,Nn as c,dn as l,la as u,mr as d,nr as f,pn as p,qa as m,tr as h,xo as g,yo as _}from"./queries-DVZ1lYAo.js";import{A as v,D as y,M as b,O as x,P as S,Z as C,j as w,k as T,t as ee}from"./utils-DWwoYTjU.js";import{C as te,f as E,y as ne}from"./project-router-CnMbTz-a.js";import{_ as D,a as O,g as k,h as re,m as A,n as ie,r as j,v as M}from"./segmented-Chb1Y4ie.js";import{a as ae,i as oe,o as se,r as ce,t as le}from"./sheet-DirfZrZD.js";import{t as ue}from"./createLucideIcon-BHp8sXmF.js";import{t as de,u as fe}from"./reference-chip-DdxKs2_A.js";import{a as pe,d as me,r as he,u as N}from"./automation-format-KxcnBz7L.js";import{V as ge,t as P}from"./button-CEskWahs.js";import{r as _e}from"./dist-B_KqW6o6.js";import{i as ve,n as ye,o as be,s as xe,t as Se}from"./select-DG3hFvx2.js";import{t as Ce}from"./circle-alert-ClwRNTQt.js";import{t as we}from"./circle-question-mark-X2pmbDJg.js";import{t as Te}from"./download-CfgyYHf7.js";import{i as Ee,r as De,t as Oe}from"./popover-DPba6FvD.js";import{a as ke,c as Ae,d as je,f as Me,i as Ne,l as Pe,n as Fe,r as Ie,s as Le,t as Re,u as ze}from"./sortable.esm-B7aanBL9.js";import{a as Be,i as Ve,n as He,r as Ue,t as We}from"./icon-tooltip-DRhwcic2.js";import{r as F,t as Ge}from"./format-BUbPQpzw.js";import{t as I}from"./status-dot-CZAbXsOs.js";import{t as Ke}from"./token-metrics-DXeuToH8.js";import{t as qe}from"./use-now-C8dG5uIP.js";import{J as Je,ht as Ye,lt as Xe,n as Ze,t as Qe}from"./index-BMA7ZpLG.js";var $e=ue(`activity`,[[`path`,{d:`M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2`,key:`169zse`}]]),et=ue(`arrow-down-left`,[[`path`,{d:`M17 7 7 17`,key:`15tmo1`}],[`path`,{d:`M17 17H7V7`,key:`1org7z`}]]),tt=ue(`grip-horizontal`,[[`circle`,{cx:`12`,cy:`9`,r:`1`,key:`124mty`}],[`circle`,{cx:`19`,cy:`9`,r:`1`,key:`1ruzo2`}],[`circle`,{cx:`5`,cy:`9`,r:`1`,key:`1a8b28`}],[`circle`,{cx:`12`,cy:`15`,r:`1`,key:`1e56xg`}],[`circle`,{cx:`19`,cy:`15`,r:`1`,key:`1a92ep`}],[`circle`,{cx:`5`,cy:`15`,r:`1`,key:`5r1jwy`}]]),nt=ue(`table-2`,[[`path`,{d:`M9 3H5a2 2 0 0 0-2 2v4m6-6h10a2 2 0 0 1 2 2v4M9 3v18m0 0h10a2 2 0 0 0 2-2V9M9 21H5a2 2 0 0 1-2-2V9m0 0h18`,key:`gugj83`}]]),L=e(t(),1);function rt(e){let t=Date.parse(e.nextRunAt??``),n=Date.parse(e.state?.backoffUntil??``);return Number.isFinite(t)?Math.max(t,Number.isFinite(n)?n:t):null}function it(e){return e.flatMap(e=>(e.data?.automations??[]).filter(e=>e.enabled).map(t=>({project:e,automation:t,at:rt(t)}))).sort((e,t)=>(e.at??1/0)-(t.at??1/0)||e.project.id.localeCompare(t.project.id)||e.automation.id.localeCompare(t.automation.id))}function at(e){let t=r(),n=g(),i=t.data?.projects??[],o=t.data?.bootProject,s=o&&!i.some(e=>e.id===o)?[...i,{id:o,name:o,status:`ok`}]:i,c=_({queryKey:[...p.dashboard,`automations`,s.map(e=>[e.id,e.name,e.status])],enabled:e&&!!t.data,queryFn:async({signal:e})=>{let t=0,n=[];return await Promise.all([0,1].map(async()=>{for(;t<s.length&&!e.aborted;){let r=s[t++];if(r.status===`missing`){n.push({...r,error:`Project folder unavailable`});continue}try{let t=S.parse(await m(await a.api.v1.workspace.dashboard.automations.$get({query:{projectId:r.id}},{init:{signal:e}}),`/workspace/dashboard/automations`));n.push({id:r.id,name:r.name,data:t})}catch{n.push({id:r.id,name:r.name,error:`Could not load automations`})}}})),n}});return(0,L.useEffect)(()=>{if(e)return O(e=>{e===`automation-change`&&n.invalidateQueries({queryKey:[...p.dashboard,`automations`]})})},[n,e]),{...c,registry:t,retry:()=>{t.refetch(),c.refetch()}}}var R=n();function z({rows:e}){return(0,R.jsx)(`span`,{hidden:!0,"data-dashboard-export":JSON.stringify(e)})}var B=`section-mark eyebrow text-muted-foreground`,V=`flex min-h-12 flex-wrap items-center justify-between gap-x-3 gap-y-2 border-b px-4 py-2.5`,ot=`flex w-fit cursor-pointer list-none items-center gap-1.5 rounded-sm text-muted-foreground transition-colors select-none hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/50 [&::-webkit-details-marker]:hidden`;function H(){return(0,R.jsx)(ge,{"aria-hidden":`true`,className:`size-3.5 shrink-0 text-soft-foreground transition-transform duration-150 motion-reduce:transition-none [details[open]>summary>&]:rotate-90`})}var st=`flex items-center gap-2 text-label text-muted-foreground`;function ct({label:e,value:t,onValueChange:n,options:r}){let i=r.find(e=>e.value===t);return(0,R.jsxs)(`span`,{className:st,"data-export-filter":e,"data-export-value":i?.label??``,children:[e,(0,R.jsxs)(Se,{value:t,onValueChange:e=>n(e),children:[(0,R.jsx)(be,{"aria-label":e,size:`sm`,className:`bg-card-2 font-mono text-xs no-hover:min-h-11`,children:(0,R.jsx)(xe,{})}),(0,R.jsx)(ye,{children:r.map(e=>(0,R.jsx)(ve,{value:e.value,children:e.label},e.value))})]})]})}var lt=[{value:`7d`,label:`Last 7 days`},{value:`30d`,label:`Last 30 days`}],ut=`relative min-w-0 overflow-hidden rounded-lg border bg-card-2 p-4 transition-colors before:absolute before:inset-x-0 before:top-0 before:h-px before:opacity-80 hover:border-foreground/20 hover:bg-muted/40 sm:p-5`,U={violet:`before:bg-violet`,info:`before:bg-info`,success:`before:bg-success`,danger:`before:bg-danger`,primary:`before:bg-primary`,neutral:`before:bg-border`};function dt({label:e,value:t,icon:n,children:r}){return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`span`,{className:`flex w-full items-center justify-between gap-2`,children:[(0,R.jsx)(`span`,{className:`eyebrow text-muted-foreground`,children:e}),(0,R.jsx)(`span`,{className:`text-soft-foreground`,"aria-hidden":`true`,children:n})]}),(0,R.jsx)(`span`,{className:`mt-4 block text-4xl font-semibold leading-none tracking-tight tabular-nums`,children:t}),(0,R.jsx)(`span`,{className:`mt-3 block text-label text-muted-foreground`,children:r})]})}function ft({at:e,children:t}){return(0,R.jsx)(We,{label:new Date(e).toLocaleString(),children:(0,R.jsx)(`time`,{dateTime:e,children:t})})}function pt({at:e}){return(0,R.jsxs)(ft,{at:e,children:[`Updated `,F(e),` ago`]})}function mt(){let e=Je(),t=at(e.known&&!e.off),n=qe(3e4),[r,i]=(0,L.useState)(!1),a=it(t.data??[]),o=r?a:a.slice(0,3),s=t.data?.filter(e=>e.error)??[],c=!e.known||!t.registry.isError&&(t.registry.isPending||t.isPending),l=t.isError||t.registry.isError||s.length>0;return(0,R.jsxs)(N,{"data-export-context":`Enabled automations · showing ${o.length} of ${a.length} loaded · ${l?`partial coverage`:`available projects`}`,className:`min-w-0 gap-0 py-0`,children:[(0,R.jsxs)(`div`,{className:V,children:[(0,R.jsxs)(`h2`,{className:`flex items-center ${B}`,children:[`Automations`,(0,R.jsx)(me,{className:`ml-2 size-3.5 text-soft-foreground`,"aria-hidden":`true`})]}),!e.off&&t.data&&(0,R.jsxs)(`span`,{className:`text-label text-muted-foreground tabular-nums`,children:[a.length,` enabled`,l?` · partial`:``]})]}),!e.off&&t.data&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(z,{rows:[{section:`automations`,metric:`enabled`,value:a.length,unit:`automations`,note:l?`Partial project coverage`:`Loaded projects`}]}),t.dataUpdatedAt>0&&(0,R.jsx)(`p`,{className:`px-4 pt-3 text-label text-muted-foreground`,children:(0,R.jsx)(pt,{at:new Date(t.dataUpdatedAt).toISOString()})})]}),e.off?(0,R.jsx)(`p`,{className:`p-4 text-sm text-muted-foreground`,children:`Automations are disabled in this workspace.`}):(0,R.jsxs)(R.Fragment,{children:[c&&(0,R.jsx)(`p`,{className:`p-4 text-sm text-muted-foreground`,children:`Loading automations…`}),l&&(0,R.jsxs)(`div`,{role:`alert`,className:`p-4 text-sm`,children:[(0,R.jsx)(`p`,{children:`Some automation data could not be refreshed. Available results are shown.`}),s.map(e=>(0,R.jsxs)(`p`,{children:[e.name,`: `,e.error]},e.id)),(0,R.jsx)(P,{variant:`ghost`,onClick:t.retry,children:`Retry automations`})]}),!c&&!l&&a.length===0&&(0,R.jsx)(`p`,{className:`p-4 text-sm text-muted-foreground`,children:`No enabled automations. Enable one in a project's Automations page.`}),o.map(({project:e,automation:t,at:r})=>{let i=(t.state?.consecutiveFailures??0)>0?`Recent checks failed`:void 0,a=r===null?`Next time not available`:r<=n?`Due — awaiting scheduler`:pe(r,n),o=t.kind===`schedule`?`Next run`:`Next check`;return(0,R.jsxs)(`div`,{"data-export-row":!0,className:`border-b px-4 py-3 transition-colors last:border-0 hover:bg-muted/30`,children:[(0,R.jsx)(E,{className:`block min-h-11 text-sm font-medium hover:underline`,to:`/p/${encodeURIComponent(e.id)}/automations/${encodeURIComponent(t.id)}`,children:t.name}),(0,R.jsxs)(`p`,{className:`text-label text-muted-foreground`,children:[e.name,` · `,o,`: `,a]}),r!==null&&(0,R.jsx)(`p`,{className:`mt-1 text-label text-muted-foreground`,children:(0,R.jsxs)(`time`,{dateTime:new Date(r).toISOString(),children:[he(r,e.data.timeZone),` · `,e.data.timeZone]})}),t.kind!==`schedule`&&(0,R.jsx)(`p`,{className:`mt-1 text-label text-muted-foreground`,children:`Checks for matching events; a task may not be started.`}),i&&(0,R.jsx)(`p`,{className:`mt-1 text-label text-warning`,children:i}),(0,R.jsx)(z,{rows:[{section:`automation`,entity:`${e.id}:${t.id}`,metric:`name`,value:t.name},{section:`automation`,entity:`${e.id}:${t.id}`,metric:t.kind===`schedule`?`nextRunAt`:`nextCheckAt`,value:r===null?null:new Date(r).toISOString(),note:[a,i].filter(Boolean).join(` · `)}]})]},`${e.id}:${t.id}`)}),a.length>3&&(0,R.jsx)(P,{variant:`ghost`,className:`m-2 min-h-11`,onClick:()=>i(!r),children:r?`Show fewer`:`Show all ${a.length} enabled`}),!c&&(0,R.jsxs)(`details`,{className:`border-t px-4 py-2 text-label text-muted-foreground`,children:[(0,R.jsxs)(`summary`,{className:`flex w-fit cursor-pointer list-none items-center gap-1.5 rounded-sm text-muted-foreground transition-colors select-none hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/50 [&::-webkit-details-marker]:hidden min-h-11`,"data-export-heading":`Project automations`,children:[(0,R.jsx)(H,{}),`Manage automations by project`]}),t.data?.map(e=>(0,R.jsx)(E,{className:`block min-h-11 py-3 hover:underline`,to:`/p/${encodeURIComponent(e.id)}/automations`,children:e.name},e.id))]})]})]})}function ht(e,t,n){let r=new Set,i=new Map(e.map((e,t)=>[n(e),{r:e,i:t}]));return t.forEach((e,t)=>{let a=i.get(n(e));(!a||a.i!==t||JSON.stringify(a.r)!==JSON.stringify(e))&&r.add(n(e)),i.delete(n(e))}),i.forEach((e,t)=>r.add(t)),r}function gt(e,t,n){let r=new Map(t.map(e=>[n(e),e]));return e.map(e=>({row:r.get(n(e))??e,removed:!r.has(n(e))}))}var _t=(0,L.createContext)(``),vt=(0,L.createContext)(!0),W=new Map;function yt(e,t,n=``,r=0,i){let a=(0,L.useContext)(_t),o=`${a}:${n}`,[s,c]=(0,L.useState)(()=>W.get(o)),[l,u]=(0,L.useState)(o),d=(0,L.useRef)(r),f=(0,L.useRef)(!1);l!==o&&(u(o),c(W.get(o)),d.current=r,f.current=!1),d.current!==r&&(d.current=r,f.current=!0),(0,L.useEffect)(()=>{e&&(!s||f.current)&&(c(e),f.current=!1)},[s,e]);let p=(0,L.useMemo)(()=>({current:s}),[o]);p.current=s,(0,L.useEffect)(()=>()=>{!a||!p.current||(W.delete(o),W.set(o,p.current),W.size>60&&W.delete(W.keys().next().value))},[a,o,p]);let m=s??e??[],h=new Set((e??m).map(t)),g=i?m.filter(e=>h.has(t(e))||i(e)):m;return{rows:gt(g,e??m,t),updates:e?ht(g,e,t).size:0,show:()=>c(e)}}var bt=new Map;function xt(e){return bt.get(e)}function St(e,t){bt.delete(e),bt.set(e,t),bt.size>20&&bt.delete(bt.keys().next().value)}var Ct=new Map;function wt(e,t){return Ct.get(e)?.[t]}function Tt(e,t,n){let r=Ct.get(e)??{};r[t]=n,Ct.delete(e),Ct.set(e,r),Ct.size>20&&Ct.delete(Ct.keys().next().value)}var G=e=>`${e.projectId}:${e.id}`;function Et({row:e,removed:t=!1,queue:n=!1,checking:r=!1,checkFailed:a=!1,kicker:o}){let s=(0,L.useContext)(vt)&&!r&&!a,l=M(e);t=t||l===null||n&&l?.archived===!0,l&&(e={...e,status:l.status,awaitingAnswerSince:l.awaitingAnswerSince,idleClosedAt:l.idleClosedAt});let u=i(e),d=n&&!f(e),p=t||d||!s;return(0,R.jsxs)(`div`,{"data-dashboard-row":G(e),className:`min-w-0 border-b px-4 py-3 transition-colors last:border-0 hover:bg-muted/30`,children:[(0,R.jsx)(z,{rows:[{section:`task`,entity:G(e),metric:`title`,value:e.titleSummary||e.title},{section:`task`,entity:G(e),metric:`status`,value:p?`Not currently actionable`:e.status},{section:`task`,entity:G(e),metric:`createdAt`,value:e.createdAt}]}),o&&(0,R.jsx)(`p`,{className:`mb-1 pl-[15px] eyebrow text-soft-foreground`,children:o}),(0,R.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,R.jsx)(I,{tone:u.tone,pulse:u.pulse&&!p,className:`mt-[7px]`}),(0,R.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,R.jsx)(E,{tabIndex:p?-1:void 0,"aria-disabled":p||void 0,onClick:e=>{p&&e.preventDefault()},to:`/p/${encodeURIComponent(e.projectId)}/tasks/${encodeURIComponent(e.id)}`,className:`block break-words text-sm font-medium leading-relaxed hover:underline no-hover:min-h-11`,children:e.titleSummary||e.title}),(0,R.jsxs)(`div`,{className:`mt-1 flex flex-wrap items-center gap-x-2 gap-y-1 text-label text-muted-foreground`,children:[(0,R.jsx)(`span`,{className:`font-mono text-meta`,children:e.projectId}),(0,R.jsx)(`span`,{children:a?`Could not check current state`:s?t?n&&l!==null?`No longer needs you`:`Task removed`:d?`No longer needs you`:u.label:`Checking current state…`}),(0,R.jsx)(`span`,{children:F(e.createdAt)}),e.dispatch&&(0,R.jsx)(`span`,{children:`Subtask`}),!p&&c(e).map(t=>(0,R.jsx)(de,{reference:t,taskTitle:e.title,projectId:e.projectId,className:`no-hover:min-h-11`},`${t.kind}:${t.number}`))]})]})]})]})}function K({coverage:e,count:t,retry:n}){let r=e.projects.filter(e=>e.state!==`complete`);return r.length?(0,R.jsxs)(`div`,{className:`rounded-lg border border-pending/40 bg-card-2 p-3 text-sm`,role:`status`,children:[(0,R.jsxs)(`p`,{children:[t===void 0?``:`${t} tasks need you in the available data. Complete coverage: ${e.projects.length-r.length} of ${e.projects.length} projects. `,r.length===1?r[0].state===`unavailable`?`One project is unavailable.`:`One project has incomplete coverage.`:`${r.length} projects have incomplete coverage.`]}),(0,R.jsxs)(`details`,{className:`mt-2`,children:[(0,R.jsxs)(`summary`,{className:`${ot} min-h-11`,children:[(0,R.jsx)(H,{}),`View unavailable `,r.length===1?`project`:`projects`]}),r.map(e=>(0,R.jsxs)(`p`,{children:[e.projectId,`: `,e.reason??e.state,e.omittedRuns>0?` · ${e.omittedRuns} omitted tasks`:``]},e.projectId))]}),(0,R.jsx)(P,{variant:`outline`,onClick:n,className:`min-h-11`,children:`Retry`})]}):null}function Dt(e,t=!1){return e==null?`Unavailable`:t?`$${e.toFixed(e===0||e>=1?2:Math.min(20,Math.max(4,Math.ceil(-Math.log10(e))+1)))}`:e.toLocaleString(`en-US`)}function q(e){return e===null?`Unavailable`:e<1?`${Math.round(e*60)}m`:e<48?`${e.toFixed(1)}h`:`${(e/24).toFixed(1)}d`}function Ot(e,t,n){let r=ne(),i=r.state?.dashboardEntry??r.key,[a,o]=te(),s=a.get(e);return[s!==null&&t.includes(s)?s:n,t=>o(n=>{let r=new URLSearchParams(n);return r.set(e,t),r},{replace:!0,state:{...r.state,dashboardEntry:i}})]}var kt=e=>`Last ${e===`7d`?7:30} calendar days`,At=`eyebrow text-muted-foreground`,jt=`min-w-0 rounded-lg border bg-card-2 p-4`,J=`whitespace-nowrap px-3 py-2 eyebrow text-soft-foreground`,Y=`text-label text-muted-foreground`;function Mt(){let e=r().data?.projects;return t=>e?.find(e=>e.id===t)?.name??t}var Nt=(e,t)=>`/p/${encodeURIComponent(e)}/tasks/${encodeURIComponent(t)}`;function Pt({label:e,value:t,onChange:n}){return(0,R.jsx)(ct,{label:e,value:t,onValueChange:n,options:lt})}function Ft({query:e}){return e.isPending?(0,R.jsx)(`p`,{role:`status`,className:`text-sm text-muted-foreground`,children:`Loading insights…`}):e.isError?(0,R.jsxs)(`p`,{role:`alert`,className:`text-sm`,children:[e.data?`Showing previous results. `:``,`Could not refresh insights.`,` `,(0,R.jsx)(P,{variant:`outline`,onClick:()=>void e.refetch(),children:`Retry insights`})]}):null}function It({period:e,active:t}){let n=Qe(e,t),r=n.data;return(0,R.jsxs)(`div`,{className:`space-y-3`,children:[(0,R.jsx)(Ft,{query:n}),r&&(0,R.jsx)(K,{coverage:r.coverage,retry:()=>void n.refetch()}),r&&(0,R.jsxs)(`div`,{className:`grid gap-3 lg:grid-cols-2`,children:[(0,R.jsx)(Rt,{data:r}),(0,R.jsx)(zt,{data:r})]})]})}function Lt({value:e,prefix:t=``,className:n}){let r=`${t}${e.toLocaleString(`en-US`)}`;return e<1e4?(0,R.jsx)(`span`,{className:n,children:r}):(0,R.jsx)(We,{label:r,children:(0,R.jsxs)(`span`,{className:n,"aria-label":r,children:[t,Ge(e)]})})}function Rt({data:e}){let t=e.delivered,n=[{label:`PRs opened`,value:t.prsOpened,note:`${t.prsTouched} touched`},{label:`Lines`,value:(0,R.jsxs)(`span`,{className:`flex flex-wrap gap-x-1.5`,children:[(0,R.jsx)(Lt,{value:t.additions,prefix:`+`,className:`text-success`}),(0,R.jsx)(Lt,{value:t.deletions,prefix:`−`,className:`text-danger`})]})},{label:`Files`,value:(0,R.jsx)(Lt,{value:t.files})},{label:`Issues`,value:(0,R.jsx)(Lt,{value:t.issues})}];return(0,R.jsxs)(`section`,{className:jt,"aria-label":`Delivered`,children:[(0,R.jsx)(z,{rows:Object.entries(t).map(([t,n])=>({section:`delivered`,metric:t,value:n,unit:[`additions`,`deletions`].includes(t)?`lines`:t===`files`?`files`:`count`,asOf:e.asOf,note:`Completed since ${e.windowStart}`}))}),(0,R.jsx)(`h3`,{className:At,children:`Delivered`}),(0,R.jsx)(`dl`,{className:`mt-3 grid grid-cols-2 gap-x-4 gap-y-3 sm:grid-cols-4`,children:n.map(e=>(0,R.jsxs)(`div`,{className:`min-w-0`,children:[(0,R.jsx)(`dt`,{className:Y,children:e.label}),(0,R.jsx)(`dd`,{className:`mt-1 truncate text-xl font-semibold tracking-tight tabular-nums`,children:e.value}),e.note&&(0,R.jsx)(`dd`,{className:Y,children:e.note})]},e.label))}),(0,R.jsxs)(`span`,{className:`mt-3 block ${Y}`,children:[`From `,t.completedTasks,` completed `,t.completedTasks===1?`task`:`tasks`,` ·`,` `,t.measuredTasks,` with a stored diff`]})]})}function zt({data:e}){let t=Mt(),{total:n,reasons:r}=e.failures;return(0,R.jsxs)(`section`,{className:jt,"aria-label":`Why tasks failed`,children:[(0,R.jsx)(z,{rows:r.map(t=>({section:`failures`,entity:t.label,metric:t.category,value:t.count,unit:`tasks`,asOf:e.asOf,note:t.latest.message}))}),(0,R.jsxs)(`div`,{className:`flex items-baseline justify-between gap-2`,children:[(0,R.jsx)(`h3`,{className:At,children:`Why tasks failed`}),n>0&&(0,R.jsxs)(`span`,{className:`${Y} tabular-nums`,children:[n,` failed`]})]}),n===0?(0,R.jsxs)(`span`,{className:`mt-4 flex items-center gap-2.5 text-sm text-muted-foreground`,children:[(0,R.jsx)(I,{tone:`success`}),`No failed outcomes in this period`]}):(0,R.jsx)(`ul`,{className:`mt-3 space-y-3`,children:r.map(e=>(0,R.jsx)(Bt,{reason:e,total:n,projectName:t},`${e.category}:${e.label}`))})]})}function Bt({reason:e,total:t,projectName:n}){let{latest:r}=e;return(0,R.jsxs)(`li`,{className:`min-w-0`,children:[(0,R.jsxs)(`div`,{className:`flex items-baseline justify-between gap-3 text-sm`,children:[(0,R.jsx)(`span`,{className:`min-w-0 truncate font-medium`,children:e.label}),(0,R.jsx)(`span`,{className:`text-label tabular-nums text-muted-foreground`,children:e.count})]}),(0,R.jsx)(`div`,{className:`mt-1.5 h-1 overflow-hidden rounded-full bg-muted`,"aria-hidden":`true`,children:(0,R.jsx)(`div`,{className:`h-full rounded-full bg-danger/70`,style:{width:`${e.count/t*100}%`}})}),(0,R.jsx)(We,{label:r.message,children:(0,R.jsxs)(`span`,{className:`mt-1.5 block truncate ${Y}`,children:[`Latest:`,` `,(0,R.jsx)(E,{className:`hover:text-foreground hover:underline`,to:Nt(r.projectId,r.id),children:r.title}),` `,`· `,n(r.projectId),r.step?` · ${r.step}`:``,` · `,F(r.at),` ago`]})})]})}var Vt={claude:`Claude Code`,codex:`Codex`,opencode:`OpenCode`,cursor:`Cursor`,pi:`Pi`,unknown:`Unknown backend`,mixed:`Mixed backends`},Ht=e=>Vt[e]??e,Ut=(e,t)=>t?Math.round(e/t*100):0;function Wt(){let[e,t]=Ot(`backends`,[`7d`,`30d`],`7d`),n=Qe(e),r=n.data,i=r?.visibility.cost;return(0,R.jsx)(`section`,{"data-dashboard-module":`backends`,className:`min-w-0`,children:(0,R.jsxs)(N,{className:`gap-0 py-0`,"data-export-context":`Backends: ${kt(e)}; finished tasks`,children:[(0,R.jsxs)(`div`,{className:V,children:[(0,R.jsx)(`h2`,{className:B,children:`Backends & models`}),(0,R.jsx)(Pt,{label:`Finished`,value:e,onChange:t})]}),(0,R.jsxs)(`div`,{className:`space-y-3 p-4`,children:[(0,R.jsx)(Ft,{query:n}),r&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`p`,{className:Y,children:`Tasks that finished done or failed in the period, by the backend and model their steps ran on. Includes subtasks. Cost is reported USD only.`}),(0,R.jsx)(K,{coverage:r.coverage,retry:()=>void n.refetch()}),r.backends.length?(0,R.jsx)(`div`,{className:`overflow-x-auto`,role:`region`,"aria-label":`Backend comparison`,tabIndex:0,children:(0,R.jsxs)(`table`,{className:`w-full text-left text-sm`,children:[(0,R.jsx)(`thead`,{children:(0,R.jsxs)(`tr`,{children:[(0,R.jsx)(`th`,{className:J,children:`Backend`}),(0,R.jsx)(`th`,{className:`${J} text-right`,children:`Finished`}),(0,R.jsx)(`th`,{className:J,children:`Success`}),(0,R.jsx)(`th`,{className:`${J} text-right`,children:`Median cycle`}),i&&(0,R.jsx)(`th`,{className:`${J} text-right`,children:`Reported USD`}),i&&(0,R.jsx)(`th`,{className:`${J} text-right`,children:`Per completed`})]})}),(0,R.jsx)(`tbody`,{children:r.backends.map(e=>(0,R.jsx)(Gt,{stat:e,cost:!!i},`${e.backend}:${e.model??``}`))})]})}):(0,R.jsx)(`p`,{className:`py-4 text-sm text-muted-foreground`,children:`No finished tasks in this period.`}),(0,R.jsx)(`span`,{className:`block ${Y}`,children:(0,R.jsx)(pt,{at:r.asOf})}),(0,R.jsx)(z,{rows:r.backends.flatMap(e=>[`finished`,`done`,`failed`,`medianCycleHours`].map(t=>({section:`backends`,entity:`${e.backend}${e.model?`:${e.model}`:``}`,metric:t,value:e[t],unit:t===`medianCycleHours`?`hours`:`tasks`,asOf:r.asOf})))})]})]})]})})}function Gt({stat:e,cost:t}){let n=Ut(e.done,e.finished),r=e.costUsd?.value;return(0,R.jsxs)(`tr`,{className:`border-t transition-colors hover:bg-muted/30`,children:[(0,R.jsxs)(`td`,{className:`px-3 py-2.5`,children:[(0,R.jsx)(`span`,{className:`block font-medium`,children:Ht(e.backend)}),(0,R.jsx)(`span`,{className:ee(`block`,Y,e.backend!==`mixed`&&e.model?`font-mono text-meta`:``),children:e.backend===`mixed`?`steps ran on different backends`:e.model??`default model`})]}),(0,R.jsx)(`td`,{className:`px-3 py-2.5 text-right tabular-nums`,children:e.finished}),(0,R.jsxs)(`td`,{className:`min-w-40 px-3 py-2.5`,children:[(0,R.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,R.jsx)(`span`,{className:`h-1.5 flex-1 overflow-hidden rounded-full bg-danger/40`,"aria-hidden":`true`,children:(0,R.jsx)(`span`,{className:`block h-full rounded-full bg-success`,style:{width:`${n}%`}})}),(0,R.jsxs)(`span`,{className:`w-10 text-right text-label tabular-nums`,children:[n,`%`]})]}),(0,R.jsxs)(`span`,{className:`block ${Y}`,children:[e.done,` done · `,e.failed,` failed`]})]}),(0,R.jsx)(`td`,{className:`px-3 py-2.5 text-right tabular-nums`,children:e.timedTasks?q(e.medianCycleHours):`—`}),t&&(0,R.jsxs)(`td`,{className:`px-3 py-2.5 text-right tabular-nums`,children:[r==null?`—`:Dt(r,!0),(0,R.jsxs)(`span`,{className:`block ${Y}`,children:[e.costUsd?.reportedTasks??0,`/`,e.finished,` reported`]})]}),t&&(0,R.jsx)(`td`,{className:`px-3 py-2.5 text-right tabular-nums`,children:r==null||!e.done?`—`:Dt(r/e.done,!0)})]})}function Kt(){let[e,t]=Ot(`automations`,[`7d`,`30d`],`7d`),n=Je(),r=Qe(e),i=at(n.known&&!n.off),a=Mt(),o=r.data,s=o?.visibility.cost,c=new Map;for(let e of i.data??[])for(let t of e.data?.automations??[])c.set(`${e.id}\u0000${t.id}`,{projectId:e.id,automationId:t.id,name:t.name,enabled:t.enabled,definition:`known`});let l=new Set((i.data??[]).flatMap(e=>e.data&&!e.error?[e.id]:[])),u=i.isError||i.registry.isError||(i.data??[]).some(e=>e.error);for(let e of o?.automations??[]){let t=`${e.projectId}\u0000${e.automationId}`,n=c.get(t);c.set(t,n?{...n,stat:e}:{...e,name:e.automationId,definition:l.has(e.projectId)?`removed`:`unknown`,stat:e})}let d=[...c.values()].sort((e,t)=>(t.stat?.tasks??0)-(e.stat?.tasks??0)||Number(t.enabled??!1)-Number(e.enabled??!1)||e.name.localeCompare(t.name));return(0,R.jsx)(`section`,{"data-dashboard-module":`automation-outcomes`,className:`min-w-0`,children:(0,R.jsxs)(N,{className:`gap-0 py-0`,"data-export-context":`Automation outcomes: tasks created in ${kt(e)}`,children:[(0,R.jsxs)(`div`,{className:V,children:[(0,R.jsx)(`h2`,{className:B,children:`Automation outcomes`}),(0,R.jsx)(Pt,{label:`Launched`,value:e,onChange:t})]}),(0,R.jsx)(`div`,{className:`space-y-3 p-4`,children:n.off?(0,R.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Automations are disabled in this workspace.`}):(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(Ft,{query:r}),o&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`p`,{className:Y,children:`Tasks each automation created in the period and how they ended. Active means still running, queued, waiting on you, or waiting to resume after a usage limit.`}),(0,R.jsx)(K,{coverage:o.coverage,retry:()=>void r.refetch()}),u&&(0,R.jsxs)(`p`,{role:`alert`,className:`text-sm`,children:[`Some automation details could not be loaded. Their outcomes are shown by id.`,` `,(0,R.jsx)(P,{variant:`ghost`,onClick:i.retry,children:`Retry automations`})]}),d.length?(0,R.jsx)(`div`,{className:`overflow-x-auto`,role:`region`,"aria-label":`Automation outcomes`,tabIndex:0,children:(0,R.jsxs)(`table`,{className:`w-full text-left text-sm`,children:[(0,R.jsx)(`thead`,{children:(0,R.jsxs)(`tr`,{children:[(0,R.jsx)(`th`,{className:J,children:`Automation`}),(0,R.jsx)(`th`,{className:`${J} text-right`,children:`Tasks`}),(0,R.jsx)(`th`,{className:`${J} text-right`,children:`Done`}),(0,R.jsx)(`th`,{className:`${J} text-right`,children:`Failed`}),(0,R.jsx)(`th`,{className:`${J} text-right`,children:`Active`}),(0,R.jsx)(`th`,{className:J,children:`Last run`}),s&&(0,R.jsx)(`th`,{className:`${J} text-right`,children:`Reported USD`})]})}),(0,R.jsx)(`tbody`,{children:d.map(e=>(0,R.jsx)(qt,{row:e,cost:!!s,projectName:a},`${e.projectId}:${e.automationId}`))})]})}):(0,R.jsx)(`p`,{className:`py-4 text-sm text-muted-foreground`,children:`No automations yet. Create one in a project's Automations page.`}),(0,R.jsx)(`span`,{className:`block ${Y}`,children:(0,R.jsx)(pt,{at:o.asOf})}),(0,R.jsx)(z,{rows:d.flatMap(e=>[`tasks`,`done`,`failed`,`active`].map(t=>({section:`automation-outcomes`,entity:`${e.projectId}:${e.automationId}`,metric:t,value:e.stat?.[t]??0,unit:`tasks`,asOf:o.asOf,note:e.name})))})]})]})})]})})}function qt({row:e,cost:t,projectName:n}){let r=e.stat,i=`px-3 py-2.5 text-right tabular-nums`,a=e=>e||(0,R.jsx)(`span`,{className:`text-soft-foreground`,children:`0`});return(0,R.jsxs)(`tr`,{className:`border-t transition-colors hover:bg-muted/30`,children:[(0,R.jsxs)(`td`,{className:`px-3 py-2.5`,children:[e.definition===`removed`?(0,R.jsx)(`span`,{className:`block font-medium`,children:e.name}):(0,R.jsx)(E,{className:`block font-medium hover:underline`,to:`/p/${encodeURIComponent(e.projectId)}/automations/${encodeURIComponent(e.automationId)}`,children:e.name}),(0,R.jsxs)(`span`,{className:`flex items-center gap-1.5 ${Y}`,children:[(0,R.jsx)(I,{tone:e.enabled?`violet`:`neutral`}),n(e.projectId),` ·`,` `,e.definition===`removed`?`Removed`:e.definition===`unknown`?`Details unavailable`:e.enabled?`Enabled`:`Disabled`]})]}),(0,R.jsx)(`td`,{className:i,children:a(r?.tasks)}),(0,R.jsx)(`td`,{className:i,children:a(r?.done)}),(0,R.jsx)(`td`,{className:`${i} ${r?.failed?`text-danger`:``}`,children:a(r?.failed)}),(0,R.jsx)(`td`,{className:i,children:a(r?.active)}),(0,R.jsx)(`td`,{className:`whitespace-nowrap px-3 py-2.5 ${Y}`,children:r?.lastRunAt?(0,R.jsxs)(ft,{at:r.lastRunAt,children:[F(r.lastRunAt),` ago · `,r.lastStatus]}):`—`}),t&&(0,R.jsx)(`td`,{className:i,children:r?.costUsd?.value==null?`—`:Dt(r.costUsd.value,!0)})]})}var Jt=0,Yt=()=>++Jt,Xt=new Map;function X(e,t){let n=(0,L.useContext)(_t),r=()=>{let r=n?Xt.get(n):void 0;return r?.has(e)?r.get(e):typeof t==`function`?t():t},[i,a]=(0,L.useState)(r),o=`${n}:${e}`,[s,c]=(0,L.useState)(o);o!==s&&(c(o),a(()=>r()));let l=(0,L.useMemo)(()=>({value:i}),[n,e]);return l.value=i,(0,L.useEffect)(()=>()=>{if(!n)return;let t=Xt.get(n)??new Map;t.set(e,l.value),t.size>80&&t.delete(t.keys().next().value),Xt.delete(n),Xt.set(n,t),Xt.size>20&&Xt.delete(Xt.keys().next().value)},[n,e,l]),[i,a]}var Zt=`a[href], button, select, input, [tabindex]`;function Qt(e){let[t]=X(`${e}:position`,()=>({scroll:0})),n=(0,L.useCallback)(e=>{let n=[...e.querySelectorAll(Zt)],r=t.href?n.find(e=>e.getAttribute(`href`)===t.href):t.index===void 0?void 0:n[t.index];return r&&r.getAttribute(`aria-disabled`)!==`true`&&r.focus({preventScroll:!0}),e.scrollTop=t.scroll,!!r&&r.getAttribute(`aria-disabled`)!==`true`},[t]),r=(0,L.useMemo)(()=>({restore:()=>!1}),[t]);return{ref:(0,L.useCallback)(e=>{if(!e)return;let i=t.href!==void 0||t.index!==void 0,a=()=>{if(!i)return!1;let r=n(e);return r?(i=!1,o.disconnect()):e.querySelector(`[data-sheet-loading="false"]`)&&(i=!1,o.disconnect(),e.querySelector(`button:not([disabled]), select, [tabindex="0"]`)?.focus({preventScroll:!0}),e.scrollTop=t.scroll),r};r.restore=a;let o=new MutationObserver(a);i&&o.observe(e,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[`data-sheet-loading`]});let s=()=>{i=!1,o.disconnect()},c=()=>{i||(t.scroll=e.scrollTop)},l=n=>{i||!(n.target instanceof HTMLElement)||(t.href=n.target.getAttribute(`href`)??void 0,t.index=[...e.querySelectorAll(Zt)].indexOf(n.target))};return e.addEventListener(`pointerdown`,s),e.addEventListener(`keydown`,s),e.addEventListener(`wheel`,s,{passive:!0}),e.addEventListener(`scroll`,c),e.addEventListener(`focusin`,l),()=>{o.disconnect(),e.removeEventListener(`pointerdown`,s),e.removeEventListener(`keydown`,s),e.removeEventListener(`wheel`,s),e.removeEventListener(`scroll`,c),e.removeEventListener(`focusin`,l)}},[t,n,r]),onOpenAutoFocus:e=>{(t.href!==void 0||t.index!==void 0)&&(e.preventDefault(),r.restore())}}}function $t(e,t){let n=(0,L.useRef)(null),[r,i]=X(`${e}:trigger`,null);return{capture:()=>{let e=document.activeElement;n.current=e instanceof HTMLElement&&e!==document.body?e:null,i(n.current?{label:n.current.getAttribute(`aria-label`),text:n.current.textContent}:null)},restore:()=>{((n.current?.isConnected?n.current:r?[...document.querySelectorAll(`button`)].find(e=>!e.closest(`[role="dialog"]`)&&!e.hasAttribute(`disabled`)&&(r.label?e.getAttribute(`aria-label`)===r.label:e.textContent===r.text)):void 0)??document.querySelector(t))?.focus({preventScroll:!0})}}}function en(e,t=!0){return _({queryKey:[...p.dashboard,`overview`,e],enabled:t,staleTime:5e3,refetchInterval:t&&!e.snapshotId?15e3:!1,refetchIntervalInBackground:!1,retry:!1,queryFn:async({signal:t})=>y.parse(await m(await a.api.v1.workspace.dashboard.overview.$get({query:{period:e.period??`7d`,group:e.group??`completed`,tzOffsetMinutes:String(e.tzOffsetMinutes??new Date().getTimezoneOffset()),...e.snapshotId?{snapshotId:e.snapshotId}:{},...e.projectId?{projectId:e.projectId}:{},offset:String(e.offset??0),limit:`20`}},{init:{signal:t}}),`/workspace/dashboard/overview`))})}var tn={running:`Running now`,"needs-you":`Needs you`,completed:`Completed`,failed:`Failed outcomes`},nn={"needs-you":U.info,running:U.violet,completed:U.success,failed:U.danger},rn={"needs-you":we,running:$e,completed:j,failed:Ce};function an({active:e,children:t,onCurrent:n}){let[i,a]=Ot(`period`,[`7d`,`30d`],`7d`),o=$t(`outcome`,`[data-outcome-trigger]`),s=r().data?.projects,c=e=>s?.find(t=>t.id===e)?.name??e,l=en({period:i},e),[u,d]=X(`outcome:selection`,null),f=Qt(`outcome:${u?.identity??`closed`}`),p=re();if((0,L.useEffect)(()=>{e||d(null)},[e]),!e)return t({});let m=l.data,h=(e,t)=>{o.capture(),m&&d({identity:Yt(),snapshot:m,group:e,projectId:t})},g=m?.coverage.projects.every(e=>e.state===`complete`);return(0,R.jsxs)(R.Fragment,{children:[t({overview:(0,R.jsxs)(N,{className:`gap-0 py-0`,children:[(0,R.jsxs)(`div`,{className:V,children:[(0,R.jsx)(`h2`,{className:B,children:`Workspace overview`}),(0,R.jsx)(ct,{label:`Outcomes period`,value:i,onValueChange:e=>{a(e),d(null)},options:lt})]}),(0,R.jsxs)(`div`,{className:`space-y-4 p-4`,children:[l.isPending&&(0,R.jsx)(`p`,{role:`status`,className:`text-sm text-muted-foreground`,children:`Loading overview…`}),l.isError&&(0,R.jsxs)(`p`,{role:`alert`,children:[m?`Showing previous results. `:``,`Could not refresh overview.`,` `,(0,R.jsx)(P,{variant:`outline`,onClick:()=>void l.refetch(),children:`Retry overview`})]}),m&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[m.metrics.needsYou?`${m.metrics.needsYou} tasks require your input or review.`:g&&p.connected&&!l.isError?`No tasks currently require your input or review.`:`No waiting tasks found in the available data.`,` `,m.metrics.failed,` failed `,m.metrics.failed===1?`outcome`:`outcomes`,` `,`in this period. Includes subtasks; completed does not mean accepted or deployed.`]}),(0,R.jsx)(K,{coverage:m.coverage,retry:()=>void l.refetch()}),(0,R.jsx)(`div`,{className:`grid grid-cols-2 gap-3 lg:grid-cols-4`,children:[`needs-you`,`running`,`completed`,`failed`].map(e=>{let t=m.metrics[e===`needs-you`?`needsYou`:e],r=rn[e];return(0,R.jsxs)(P,{"data-outcome-trigger":!0,"data-export-keep":!0,variant:`outline`,className:`relative min-w-0 overflow-hidden rounded-lg border bg-card-2 p-4 transition-colors before:absolute before:inset-x-0 before:top-0 before:h-px before:opacity-80 hover:border-foreground/20 hover:bg-muted/40 sm:p-5 group/metric h-auto min-h-24 flex-col items-start gap-0 whitespace-normal text-left font-normal ${t===0?U.neutral:nn[e]}`,onClick:t=>{n&&(e===`running`||e===`needs-you`)?n(e,t.currentTarget):h(e)},"aria-label":`${tn[e]}: ${t}`,children:[(0,R.jsx)(dt,{label:tn[e],value:t,icon:(0,R.jsx)(r,{className:`size-4`}),children:e===`running`||e===`needs-you`?`Current state`:`Last ${i===`7d`?7:30} calendar days`}),(0,R.jsxs)(`span`,{"data-export-exclude":!0,className:`mt-4 flex items-center gap-1 text-label font-medium text-muted-foreground transition-colors group-hover/metric:text-foreground`,children:[`View tasks`,` `,(0,R.jsx)(ge,{className:`size-3 transition-transform group-hover/metric:translate-x-0.5 motion-reduce:transition-none`,"aria-hidden":`true`})]})]},e)})}),(0,R.jsx)(It,{period:i,active:e}),(0,R.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-x-4 gap-y-1 border-t pt-3`,children:[(0,R.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Median cycle time`,` `,(0,R.jsx)(`strong`,{className:`font-mono font-semibold text-foreground`,children:q(m.metrics.medianCycleHours)}),` `,`· `,m.metrics.timedTasks,`/`,m.metrics.completed,` completed tasks have valid timings.`,` `,(0,R.jsx)(P,{variant:`ghost`,className:`h-auto px-1.5 py-1 text-sm text-foreground underline-offset-4 hover:underline`,onClick:()=>h(`completed`),children:`Inspect completed tasks`})]}),(0,R.jsx)(`p`,{className:`text-label text-muted-foreground`,children:(0,R.jsxs)(ft,{at:m.asOf,children:[`Updated `,F(m.asOf),` ago`]})})]}),(0,R.jsxs)(`details`,{className:`text-label text-muted-foreground`,children:[(0,R.jsxs)(`summary`,{"data-export-heading":`Metric definitions`,className:`flex w-fit cursor-pointer list-none items-center gap-1.5 rounded-sm text-muted-foreground transition-colors select-none hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/50 [&::-webkit-details-marker]:hidden py-1`,children:[(0,R.jsx)(H,{}),`How these metrics work`]}),(0,R.jsx)(`p`,{className:`mt-1 max-w-prose pl-5 leading-relaxed`,children:`Outcomes use finish dates, including archived tasks. Scheduled retries are excluded from failed outcomes. Period includes today at your current fixed UTC offset.`})]}),(0,R.jsx)(z,{rows:Object.entries(m.metrics).map(([e,t])=>({section:`overview`,metric:e,value:t,unit:e===`medianCycleHours`?`hours`:`tasks`,asOf:m.asOf,note:e===`running`||e===`needsYou`?`Current non-archived state`:`Finished since ${m.windowStart}`}))})]})]})]}),portfolio:m&&(0,R.jsx)(`div`,{children:(0,R.jsxs)(N,{className:`gap-0 py-0`,"data-export-context":`Outcomes: Last ${i===`7d`?7:30} calendar days; workload: current state`,children:[(0,R.jsx)(`div`,{className:`flex min-h-12 flex-wrap items-center justify-between gap-x-3 gap-y-2 border-b px-4 py-2.5`,children:(0,R.jsx)(`h2`,{className:`section-mark eyebrow text-muted-foreground`,children:`Projects`})}),(0,R.jsx)(`p`,{className:`px-4 pt-3 text-label text-muted-foreground`,children:`Current workload and outcomes for the selected period. Sorted by tasks needing you, then running tasks. Counts include subtasks.`}),(0,R.jsxs)(`div`,{className:`overflow-x-auto px-1 pb-2`,role:`region`,"aria-label":`Project outcomes`,tabIndex:0,children:[(0,R.jsxs)(`table`,{className:`w-full text-left text-sm`,children:[(0,R.jsx)(`thead`,{children:(0,R.jsx)(`tr`,{children:[`Project`,`Needs you`,`Running`,`Completed`,`Failed`,`Median cycle`].map(e=>(0,R.jsx)(`th`,{className:`whitespace-nowrap px-3 py-2 eyebrow text-soft-foreground ${e===`Project`?``:`text-right`}`,children:e},e))})}),(0,R.jsx)(`tbody`,{children:m.projects.map(e=>{let t=m.coverage.projects.find(t=>t.projectId===e.projectId);return(0,R.jsxs)(`tr`,{className:`border-t transition-colors hover:bg-muted/30`,children:[(0,R.jsxs)(`td`,{className:`px-3 py-2`,children:[(0,R.jsx)(E,{className:`font-medium hover:underline`,to:`/p/${encodeURIComponent(e.projectId)}`,children:c(e.projectId)}),t?.state!==`complete`&&(0,R.jsx)(`span`,{className:`block text-label text-muted-foreground`,children:`Incomplete data`})]}),[`needs-you`,`running`,`completed`,`failed`].map(n=>(0,R.jsx)(`td`,{className:`px-3 py-1 text-right`,children:(0,R.jsx)(P,{"data-export-keep":!0,variant:`ghost`,className:`min-h-11 tabular-nums`,"aria-label":`${c(e.projectId)}: ${tn[n]}: ${t?.state===`unavailable`?`Unavailable`:e[n===`needs-you`?`needsYou`:n]}`,disabled:t?.state===`unavailable`,onClick:()=>h(n,e.projectId),children:t?.state===`unavailable`?`Unavailable`:e[n===`needs-you`?`needsYou`:n]})},n)),(0,R.jsxs)(`td`,{className:`px-3 py-2 text-right tabular-nums`,children:[q(e.medianCycleHours),(0,R.jsxs)(`span`,{className:`block text-label text-muted-foreground`,children:[e.timedTasks,`/`,e.completed,` timed`]})]})]},e.projectId)})})]}),!m.projects.length&&(0,R.jsx)(`p`,{className:`py-4`,children:`No projects to compare yet.`})]}),(0,R.jsx)(z,{rows:m.projects.flatMap(({projectId:e,...t})=>Object.entries(t).map(([t,n])=>({section:`portfolio`,entity:e,metric:t,value:m.coverage.projects.find(t=>t.projectId===e)?.state===`unavailable`?null:n,unit:t===`medianCycleHours`?`hours`:`tasks`,asOf:m.asOf,note:`Outcomes since ${m.windowStart}; running and needsYou are current state`})))})]})})}),(0,R.jsx)(le,{open:!!u,onOpenChange:e=>{e||d(null)},children:(0,R.jsxs)(ce,{...f,className:`w-full overflow-y-auto sm:max-w-xl`,onCloseAutoFocus:e=>{e.preventDefault(),o.restore()},children:[(0,R.jsxs)(ae,{children:[(0,R.jsxs)(se,{children:[u?tn[u.group]:`Tasks`,u?.projectId?` · ${u.projectId}`:``]}),(0,R.jsx)(oe,{children:`Tasks behind the selected metric. Includes subtasks. Snapshot keeps counts and rows consistent.`})]}),u&&(0,R.jsx)(on,{selection:u,projectName:c,refresh:()=>{d(null),l.refetch()}},u.identity)]})})]})}function on({selection:e,refresh:t,projectName:n}){let[r,i]=X(`outcome:${e.identity}:offset`,0),a=en({period:e.snapshot.period,snapshotId:e.snapshot.snapshotId,group:e.group,projectId:e.projectId,offset:r}),o=(0,L.useRef)(null),s=(0,L.useRef)(null);(0,L.useEffect)(()=>{a.data&&s.current===r&&(o.current?.focus(),s.current=null)},[a.data,r]);let c=e=>{s.current=e,i(e)};return(0,R.jsxs)(`div`,{className:`space-y-3 p-4`,"data-sheet-loading":a.isFetching,children:[a.isPending&&(0,R.jsx)(`p`,{children:`Loading tasks…`}),a.isError&&(0,R.jsxs)(`p`,{role:`alert`,children:[`This snapshot may have expired or become unavailable.`,` `,(0,R.jsx)(P,{onClick:t,children:`Refresh overview`})]}),a.data&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`p`,{ref:o,tabIndex:-1,className:`text-label text-muted-foreground`,children:[a.data.page.total,` tasks · Snapshot from`,` `,(0,R.jsxs)(ft,{at:a.data.asOf,children:[F(a.data.asOf),` ago`]})]}),a.data.page.rows.map(t=>(0,R.jsx)(sn,{row:t,group:e.group,projectName:n},`${t.projectId}:${t.id}`)),!a.data.page.rows.length&&(0,R.jsx)(`p`,{children:`No tasks in this group.`})]}),(0,R.jsxs)(`div`,{className:`flex gap-2`,children:[(0,R.jsx)(P,{variant:`outline`,disabled:!r||a.isFetching,onClick:()=>c(Math.max(0,r-20)),children:`Previous`}),(0,R.jsx)(P,{variant:`outline`,disabled:!a.data||a.data.page.nextOffset===null||a.isFetching,onClick:()=>c(a.data.page.nextOffset),children:`Next`})]})]})}function sn({row:e,group:t,projectName:n}){let r=M(e),a=t===`running`||t===`needs-you`;a&&r&&(e={...e,...r});let o=r===null,s=a&&(e.archived||(t===`running`?e.status!==`running`:!f(e))),c=o||s,l=i(e),u=a&&o?`Task removed`:s?t===`running`?`No longer running`:`No longer needs you`:l.label;return(0,R.jsxs)(`div`,{className:`border-b py-3`,children:[(0,R.jsx)(E,{"aria-disabled":c||void 0,tabIndex:c?-1:void 0,onClick:e=>{c&&e.preventDefault()},className:`block min-h-11 font-medium hover:underline`,to:`/p/${encodeURIComponent(e.projectId)}/tasks/${encodeURIComponent(e.id)}`,children:e.titleSummary||e.title}),(0,R.jsxs)(`p`,{className:`text-label text-muted-foreground`,children:[(0,R.jsx)(I,{tone:l.tone,pulse:l.pulse}),` `,n(e.projectId),` ·`,` `,u,` · `,e.archived?`Archived · `:``,(0,R.jsxs)(ft,{at:e.finishedAt??e.createdAt,children:[e.finishedAt?`Finished`:`Created`,` `,F(e.finishedAt??e.createdAt),` ago`]})]})]})}var cn={snapshot:[...p.dashboard,`snapshot`],feed:e=>[...p.dashboard,`feed`,e],telemetry:[...p.dashboard,`telemetry`]},ln=new Map;async function un(e){let t=k(),n=v.parse(await m(await a.api.v1.workspace.dashboard.$get({},{init:{signal:e}}),`/workspace/dashboard`));return ln.has(n.snapshotId)||ln.set(n.snapshotId,t),ln.size>60&&ln.delete(ln.keys().next().value),D(t,[...n.questions.rows,...n.reviews.rows]),n}async function dn(e,t,n=0,r=20,i){let o=w.parse(await m(await a.api.v1.workspace.dashboard.tasks.$get({query:{snapshotId:e,group:t,offset:String(n),limit:String(r)}},{init:{signal:i}}),`/workspace/dashboard/tasks`)),s=ln.get(e);return s!==void 0&&D(s,o.page.rows),o}function fn(e){return _({queryKey:cn.snapshot,queryFn:({signal:e})=>un(e),enabled:e,staleTime:5e3,refetchOnMount:`always`,refetchInterval:e?15e3:!1,refetchIntervalInBackground:!1,retry:!1})}function pn(e){return _({queryKey:cn.telemetry,enabled:e,staleTime:0,queryFn:async({signal:e})=>{let t=b.parse(await m(await a.api.v1.workspace.dashboard.telemetry.$get({},{init:{signal:e}}),`/workspace/dashboard/telemetry`));return A.seed(t.samples,t.asOf),t}})}function mn(e,t){let n=_({queryKey:cn.feed(e),queryFn:async({signal:t})=>{let n=k(),r=T.parse(await m(await a.api.v1.workspace.dashboard.feed.$get({query:{filter:e}},{init:{signal:t}}),`/workspace/dashboard/feed`));return D(n,r.rows.flatMap(e=>e.kind===`task-result`?[e.run]:[])),r},enabled:t,staleTime:15e3,refetchInterval:t&&e!==`github`?15e3:!1,retry:!1}),r=(0,L.useRef)(!1);return(0,L.useEffect)(()=>{r.current=!1},[e,t]),(0,L.useEffect)(()=>{if(!t||r.current||!n.data?.sources.some(e=>e.reason===`Still loading GitHub`))return;let e=setTimeout(()=>{document.visibilityState!==`hidden`&&(r.current=!0,n.refetch())},5e3);return()=>clearTimeout(e)},[t,n.data,n.refetch]),n}function hn(e,t){let n=mn(`tasks`,t&&e!==`github`),r=mn(`github`,t&&e!==`tasks`),i=(0,L.useMemo)(()=>{if(e===`tasks`)return n.data;if(e===`github`)return r.data;let t=n.data,i=r.data;if(!t&&!i)return;let a=t??i,o=new Date(Math.max(Date.parse(t?.asOf??a.asOf),Date.parse(i?.asOf??a.asOf))).toISOString(),s=new Date(Date.parse(o)-10080*60*1e3).toISOString(),c=[...t?.rows??[],...i?.rows??[]].filter(e=>Date.parse(e.at)>=Date.parse(s)&&Date.parse(e.at)<=Date.parse(o)).sort((e,t)=>gn(e,t)),l=new Set(c.slice(60).map(e=>e.kind===`task-result`?`tasks:${e.run.projectId}`:e.key.slice(0,e.key.lastIndexOf(`:`)))),u=[...t?.sources??[],...i?.sources??[]].map(e=>l.has(e.key)?{...e,truncated:!0}:e);return{...a,asOf:o,windowStart:s,filter:`all`,rows:c.slice(0,60),sources:u,coverage:t?.coverage??a.coverage,truncated:c.length>60||!!t?.truncated||!!i?.truncated}},[e,n.data,r.data]),a=e===`github`?r:n;return{...a,data:i,githubError:r.isError,githubFetching:r.isFetching,retryTasks:()=>n.refetch(),retryFailed:()=>e===`github`?r.refetch():e===`tasks`?n.refetch():Promise.all([...n.isError?[n.refetch()]:[],...r.isError?[r.refetch()]:[]]),isPending:!i&&a.isPending,isError:a.isError||e===`all`&&r.isError,isFetching:a.isFetching||e===`all`&&r.isFetching,refetch:()=>e===`tasks`?n.refetch():r.refetch()}}function gn(e,t){return Date.parse(t.at)-Date.parse(e.at)||e.key.localeCompare(t.key)}var _n=[...p.dashboard,`costs`];function vn(){let e=0,t=0,n,r=new Set;return{subscribe:e=>(r.add(e),()=>{r.delete(e)}),getSnapshot:()=>n,async read(i,a){let o=++e,s=await Cn(i,a);return!a?.aborted&&o>t&&(t=o,(n?.cost!==s.visibility.cost||n?.tokens!==s.visibility.tokens)&&(n=s.visibility,r.forEach(e=>e()))),s}}}var yn=new WeakMap;function bn(e){let t=yn.get(e);return t||(t=vn(),yn.set(e,t)),t}function xn(){let e=bn(g());return(0,L.useSyncExternalStore)(e.subscribe,e.getSnapshot,e.getSnapshot)}var Sn=new Map;async function Cn(e,t){let n=k(),r=x.parse(await m(await a.api.v1.workspace.dashboard.costs.$get({query:{...e,offset:String(e.offset??0),limit:`20`}},{init:{signal:t}}),`/workspace/dashboard/costs`));!e.snapshotId&&!Sn.has(r.snapshotId)&&Sn.set(r.snapshotId,n),Sn.size>60&&Sn.delete(Sn.keys().next().value);let i=Sn.get(r.snapshotId);return i!==void 0&&D(i,r.tasks.rows),r}function wn(e,t,n){let r=bn(g());return _({queryKey:[..._n,e,t,n],queryFn:({signal:n})=>r.read({period:e,sort:t,tzOffsetMinutes:new Date().getTimezoneOffset()},n),staleTime:5e3,refetchOnMount:`always`,refetchInterval:15e3,refetchIntervalInBackground:!1,retry:!1})}function Tn(e,t,n,r){let i=bn(g());return _({queryKey:[..._n,`tasks`,e.snapshotId,t,n,r,e.visibility],retry:!1,queryFn:async({signal:a})=>{let o=e.tzOffsetMinutes??new Date().getTimezoneOffset(),s=async s=>{let c=await i.read({period:e.period,sort:n,snapshotId:s,projectId:t,tzOffsetMinutes:o},a),l=[...c.tasks.rows];for(;c.tasks.nextOffset!==null&&l.length<r;)c=await i.read({period:e.period,sort:n,snapshotId:c.snapshotId,projectId:t,offset:c.tasks.nextOffset},a),l.push(...c.tasks.rows);return{...c,tasks:{...c.tasks,rows:l}}};try{return await s(e.snapshotId)}catch(e){if(e instanceof d&&e.status===409)return s();throw e}}})}var En={cost:{text:`text-violet`,fill:`bg-violet`,tint:U.violet,icon:Ye},input:{text:`text-violet`,fill:`bg-violet/70`,tint:U.violet,icon:et},output:{text:`text-violet`,fill:`bg-violet/40`,tint:U.violet,icon:fe}};function Dn({metric:e,label:t,value:n,reported:r,total:i}){let a=En[e],o=a.icon,s=i?Math.min(100,r/i*100):0;return(0,R.jsxs)(`div`,{className:`${ut} ${a.tint}`,children:[(0,R.jsxs)(dt,{label:t,value:n,icon:(0,R.jsx)(o,{className:`size-4 ${a.text}`}),children:[r,` of `,i,` tasks report this metric`]}),(0,R.jsx)(`div`,{className:`mt-2 h-1.5 overflow-hidden rounded-full bg-muted`,"aria-hidden":`true`,children:(0,R.jsx)(`div`,{className:`h-full rounded-full ${a.fill} transition-[width] duration-300 motion-reduce:transition-none`,style:{width:`${s}%`}})})]})}function On({projects:e,currentProjects:t,metric:n,field:r,label:i,format:a,onSelect:o}){let s=e.reduce((e,t)=>Math.max(e,t[r]?.value??0),0),c=En[n];return(0,R.jsxs)(Ve,{delayDuration:150,children:[(0,R.jsxs)(`div`,{className:`space-y-1 rounded-xl border p-2`,"aria-label":`Projects ranked by ${i}`,children:[e.length===0&&(0,R.jsx)(`p`,{className:`px-3 py-4 text-muted-foreground`,children:`No projects to compare in this cohort.`}),e.slice(0,5).map((e,n)=>{let l=e[r],u=l?.value,d=u==null||s===0?0:u/s*100,f=u!=null;return(0,R.jsxs)(He,{children:[(0,R.jsx)(Be,{asChild:!0,children:(0,R.jsxs)(`button`,{"data-export-row":!0,"data-export-keep":!0,className:`group w-full rounded-lg px-3 py-3 text-left transition-colors hover:bg-muted/60 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:opacity-50 motion-reduce:transition-none`,disabled:!t.some(t=>t.projectId===e.projectId),onClick:()=>o(e.projectId),children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,R.jsx)(`span`,{className:`w-4 shrink-0 text-label tabular-nums text-muted-foreground`,"aria-hidden":`true`,children:n+1}),(0,R.jsx)(`span`,{className:`min-w-0 flex-1 break-words font-medium`,children:e.projectId}),(0,R.jsx)(`span`,{className:`shrink-0 font-semibold tabular-nums`,children:a(u)}),(0,R.jsx)(ge,{"data-export-exclude":!0,className:`size-4 shrink-0 text-muted-foreground`,"aria-hidden":`true`})]}),(0,R.jsx)(`div`,{className:`mt-2 ml-7 h-2 overflow-hidden rounded-full bg-muted`,"aria-hidden":`true`,children:(0,R.jsx)(`div`,{"data-project-bar":e.projectId,className:`h-full rounded-full ${c.fill} transition-[width] duration-300 motion-reduce:transition-none`,style:{width:`${d}%`}})}),(0,R.jsxs)(`p`,{className:`mt-1.5 ml-7 text-label text-muted-foreground`,children:[l?.reportedTasks??0,` of `,e.tasks,` tasks report this metric`,f?``:` · No measured value`]})]})}),(0,R.jsxs)(Ue,{className:`max-w-64`,children:[(0,R.jsxs)(`p`,{className:`font-medium`,children:[e.projectId,` · `,i,`: `,a(u)]}),(0,R.jsxs)(`p`,{children:[l?.reportedTasks??0,` of `,e.tasks,` tasks report this metric.`]}),(0,R.jsx)(`p`,{children:`Open project tasks`})]})]},e.projectId)})]}),e.length>0&&(0,R.jsxs)(`p`,{className:`mt-2 text-label text-muted-foreground`,children:[e.length>5?`Top 5 of ${e.length} projects. `:``,`Bar lengths compare reported values; the largest is the reference.`]})]})}var Z={cost:`costUsd`,input:`inputTokens`,output:`outputTokens`},kn={cost:`Reported USD`,input:`Input tokens`,output:`Output tokens`};function An(e,t){return JSON.stringify([e.totals,e.projects,e.tasks,e.visibility,e.coverage,e.invalidDateTasks])!==JSON.stringify([t.totals,t.projects,t.tasks,t.visibility,t.coverage,t.invalidDateTasks])}var jn=(e,t)=>Dt(e,t===`cost`);function Q(e){return[...e.cost?[`cost`]:[],...e.tokens?[`input`,`output`]:[]]}function Mn({value:e,onChange:t,visibility:n}){return(0,R.jsx)(ct,{label:`Sort by`,value:e,onValueChange:t,options:Q(n).map(e=>({value:e,label:kn[e]}))})}var Nn=[{value:`all`,label:`All time`},{value:`7d`,label:`Last 7 days`},{value:`30d`,label:`Last 30 days`}];function Pn(){return(0,R.jsx)(Fn,{visibility:Ke(o().data)})}function Fn({visibility:e}){return(0,R.jsxs)(N,{className:`gap-0 py-0`,children:[(0,R.jsx)(`div`,{className:V,children:(0,R.jsx)(`h2`,{className:B,children:`Usage & cost`})}),!e.cost&&!e.tokens?(0,R.jsx)(`p`,{className:`p-4 text-sm`,children:`Usage metrics are hidden by workspace settings`}):(0,R.jsx)(In,{visibility:e},`${e.cost}:${e.tokens}`)]})}function In({visibility:e}){let[t,n]=Ot(`usagePeriod`,[`all`,`7d`,`30d`],`all`),[r,i]=Ot(`usageSort`,Q(e),e.cost?`cost`:`input`);return(0,R.jsx)(Ln,{period:t,setPeriod:n,sort:r,setSort:i,visibility:e})}function Ln({period:e,setPeriod:t,sort:n,setSort:r,visibility:i}){let a=wn(e,n,`${i.cost}:${i.tokens}`),[o,s]=X(`usage:accepted`,void 0),c=o??a.data,l=a.data??c,[u,d]=X(`usage:panel`,null),[f,p]=(0,L.useState)(e);f!==e&&(p(e),s(void 0),d(null));let m=Qt(`usage:${u?.identity??`closed`}`),h=$t(`usage`,`[data-usage-trigger]`),g=e=>{h.capture(),c&&d({identity:Yt(),projectId:e,snapshot:c,latestId:l?.snapshotId??c.snapshotId})},_=xn()??i,v={cost:i.cost&&_.cost,tokens:i.tokens&&_.tokens},y=Q(v).includes(n)?n:Q(v)[0]??`cost`,b=[...c?.projects??[]].sort((e,t)=>{let n=e[Z[y]]?.value,r=t[Z[y]]?.value;return(n==null?r==null?0:1:r==null?-1:r-n)||e.projectId.localeCompare(t.projectId)});!o&&a.data&&s(a.data);let x=c&&l&&An(c,l),S=c?.coverage.projects.some(e=>e.state!==`complete`),C=l?.coverage.projects.some(e=>e.state!==`complete`),w=JSON.stringify(c?.coverage)!==JSON.stringify(l?.coverage),T=c?.totals.tasks===0&&!S&&!C;return(0,R.jsxs)(`div`,{className:`space-y-4 p-4 text-sm`,children:[c&&(0,R.jsx)(z,{rows:T?[]:[...Q(v).map(e=>({section:`totals`,metric:Z[e],value:c.totals[Z[e]]?.value??null,unit:e===`cost`?`USD`:`tokens`,reportedTasks:c.totals[Z[e]]?.reportedTasks??0,totalTasks:c.totals.tasks,asOf:c.asOf})),...(v.cost||v.tokens?b.slice(0,5):[]).map(e=>({section:`project`,entity:e.projectId,metric:Z[y],value:e[Z[y]]?.value??null,unit:y===`cost`?`USD`:`tokens`,reportedTasks:e[Z[y]]?.reportedTasks??0,totalTasks:e.tasks,asOf:c.asOf}))]}),c&&(0,R.jsx)(`p`,{className:`text-label text-muted-foreground`,children:(0,R.jsx)(pt,{at:c.asOf})}),(0,R.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`h3`,{className:`font-medium`,children:`Lifetime totals of retained tasks`}),(0,R.jsxs)(`details`,{className:`mt-1 text-label text-muted-foreground`,children:[(0,R.jsxs)(`summary`,{"data-export-heading":`Metric definitions`,className:`${ot} min-h-11`,children:[(0,R.jsx)(H,{}),`How these metrics work`]}),(0,R.jsxs)(`p`,{children:[`Includes archived tasks and subtasks.`,` `,v.cost&&`Reported USD is not an invoice. `,`Missing reports are excluded, not treated as zero. Calendar days use your current UTC offset, including today.`]})]})]}),(0,R.jsx)(ct,{label:`Tasks created`,value:e,onValueChange:t,options:Nn})]}),e!==`all`&&(0,R.jsx)(`p`,{className:`text-muted-foreground`,children:`Lifetime usage of tasks created in this period — not spending during the period.`}),a.isPending&&(0,R.jsx)(`p`,{children:`Loading usage…`}),a.isError&&(0,R.jsxs)(`p`,{role:`alert`,children:[c?`Showing stale usage. Could not refresh.`:`Could not load usage.`,` `,(0,R.jsx)(P,{className:`min-h-11`,onClick:()=>void a.refetch(),children:`Retry`})]}),x&&(0,R.jsx)(`p`,{role:`status`,children:`Newer usage data is available; displayed values use the previous snapshot.`}),x&&(0,R.jsx)(P,{className:`min-h-11`,variant:`outline`,onClick:()=>s(l),children:`Updates available — Show`}),c&&S&&(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`p`,{className:`text-muted-foreground`,children:`Coverage of displayed usage:`}),(0,R.jsx)(K,{coverage:c.coverage,retry:()=>void a.refetch()})]}),l&&C&&w&&(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`p`,{className:`text-muted-foreground`,children:`Current source availability:`}),(0,R.jsx)(K,{coverage:l.coverage,retry:()=>void a.refetch()})]}),c&&(0,R.jsxs)(R.Fragment,{children:[!T&&(0,R.jsx)(`div`,{className:`report-cost-metrics grid gap-3 sm:grid-cols-[repeat(auto-fit,minmax(220px,1fr))]`,children:Q(v).map(e=>(0,R.jsx)(Dn,{metric:e,label:kn[e],value:jn(c.totals[Z[e]]?.value,e),reported:c.totals[Z[e]]?.reportedTasks??0,total:c.totals.tasks},e))}),!v.cost&&!v.tokens&&(0,R.jsx)(`p`,{children:`Usage metrics are hidden by workspace settings`}),c.totals.tasks===0?(0,R.jsx)(`p`,{children:S||C?`No retained tasks could be read from available sources.`:`No retained tasks in this cohort.`}):Q(v).every(e=>!c.totals[Z[e]]?.reportedTasks)&&(0,R.jsx)(`p`,{children:`No reports for the visible metrics in this cohort.`}),T&&(0,R.jsx)(`p`,{className:`text-muted-foreground`,children:`Usage appears when tasks report cost or tokens.`}),(0,R.jsxs)(`p`,{className:`text-muted-foreground`,children:[`Deleted tasks are excluded from retained history.`,c.invalidDateTasks?` ${c.invalidDateTasks} tasks have missing or invalid creation dates${e===`all`?`; included in All time`:`; excluded from this period`}.`:``]}),!T&&(v.cost||v.tokens)&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`h3`,{className:`font-medium`,children:`Top projects`}),(0,R.jsx)(`p`,{className:`text-muted-foreground`,children:`Ranking uses reported metrics only.`})]}),(0,R.jsx)(Mn,{value:y,onChange:r,visibility:v})]}),(0,R.jsx)(On,{projects:b,metric:y,label:kn[y],field:Z[y],format:e=>jn(e,y),currentProjects:l?.projects??[],onSelect:g}),(0,R.jsx)(P,{"data-usage-trigger":!0,className:`min-h-11`,variant:`outline`,onClick:()=>g(``),children:`View tasks`})]})]}),(0,R.jsx)(le,{open:u!==null&&(v.cost||v.tokens),onOpenChange:e=>{e||d(null)},children:(0,R.jsxs)(ce,{...m,className:`w-full overflow-y-auto sm:max-w-xl`,onCloseAutoFocus:e=>{e.preventDefault(),h.restore()},children:[(0,R.jsxs)(ae,{children:[(0,R.jsx)(se,{children:u?.projectId?`${u.projectId} tasks`:`All tasks`}),(0,R.jsx)(oe,{children:`Lifetime usage of retained tasks. Missing reports are unavailable.`})]}),u!==null&&(0,R.jsx)(Rn,{identity:`usage:${u.identity}`,snapshot:l&&l.snapshotId!==u.latestId?l:u.snapshot,projectId:u.projectId||void 0,visibility:v},u.identity)]})})]})}function Rn({identity:e,snapshot:t,projectId:n,visibility:r}){let[i,a]=X(`${e}:sort`,t.sort);return(0,R.jsx)(zn,{identity:e,snapshot:t,projectId:n,visibility:r,sort:Q(r).includes(i)?i:Q(r)[0]??`cost`,setSort:a})}function zn({identity:e,snapshot:t,projectId:n,visibility:r,sort:i,setSort:a}){let[o,s]=X(`${e}:count`,20),[c,l]=X(`${e}:paging`,void 0),[u,d]=(0,L.useState)(t.snapshotId);u!==t.snapshotId&&(d(t.snapshotId),l(void 0));let f=Tn(c??t,n,i,o),p=xn()??r,m={cost:r.cost&&p.cost,tokens:r.tokens&&p.tokens},h=Q(m).includes(i)?i:Q(m)[0]??`cost`,[g,_]=X(`${e}:accepted`,void 0),[v,y]=X(`${e}:acceptedCount`,o),[b,x]=X(`${e}:acceptedSort`,i),[S,C]=(0,L.useState)(i);S!==i&&(C(i),s(20),l(g??c??t)),f.data&&(!g||(v!==o||b!==i)&&g.snapshotId===f.data.snapshotId)&&(_(f.data),y(o),x(i));let w=g??f.data,T=f.data&&w&&An(f.data,w),ee=w?.coverage.projects.some(e=>e.state!==`complete`),te=f.data?.coverage.projects.some(e=>e.state!==`complete`),E=JSON.stringify(w?.coverage)!==JSON.stringify(f.data?.coverage),ne=!n||t.projects.some(e=>e.projectId===n);return(0,R.jsxs)(`div`,{className:`space-y-3 p-4 text-sm`,"data-sheet-loading":f.isFetching,children:[(0,R.jsx)(Mn,{value:h,onChange:a,visibility:m}),f.isPending&&(0,R.jsx)(`p`,{children:`Loading tasks…`}),f.isError&&(0,R.jsxs)(`p`,{role:`alert`,children:[`Could not refresh tasks. `,w?`Showing stale usage.`:``,` `,(0,R.jsx)(P,{className:`min-h-11`,onClick:()=>void f.refetch(),children:`Retry`})]}),T&&(0,R.jsx)(P,{className:`min-h-11`,onClick:()=>{_(f.data),y(o),x(i)},children:`Updates available — Show`}),w&&ee&&(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`p`,{className:`text-muted-foreground`,children:`Coverage of displayed tasks:`}),(0,R.jsx)(K,{coverage:w.coverage,retry:()=>void f.refetch()})]}),f.data&&te&&E&&(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`p`,{className:`text-muted-foreground`,children:`Current source availability:`}),(0,R.jsx)(K,{coverage:f.data.coverage,retry:()=>void f.refetch()})]}),w&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`p`,{className:`border-b pb-2 text-label text-muted-foreground tabular-nums`,children:[w.tasks.rows.length,` of `,w.tasks.total,` retained tasks`]}),w.tasks.total===0&&(0,R.jsx)(`p`,{children:w.coverage.projects.some(e=>e.state!==`complete`)?`No tasks could be read from available sources.`:`No retained tasks in this cohort.`}),w.tasks.rows.map(e=>(0,R.jsx)(Bn,{row:e,sort:h,visibility:m,disabled:!ne||!f.data||!!(T&&!f.data?.tasks.rows.some(t=>t.id===e.id&&t.projectId===e.projectId))},`${e.projectId}:${e.id}`)),w.tasks.nextOffset!==null&&(0,R.jsx)(P,{className:`min-h-11`,disabled:f.isFetching,onClick:()=>{l(w),s(e=>e+20)},children:`Show 20 more tasks`})]})]})}function Bn({row:e,sort:t,visibility:n,disabled:r}){let a=M(e);r||=a===null;let o=i(a?{status:a.status,awaitingAnswerSince:a.awaitingAnswerSince,idleClosedAt:a.idleClosedAt}:e),s=Q(n).filter(e=>e!==t),c=t=>{let n=e[Z[t]];return n==null?`—`:jn(n,t)},l=t=>`${kn[t]}: ${jn(e[Z[t]],t)}`;return(0,R.jsxs)(`div`,{className:`grid grid-cols-[minmax(0,1fr)_auto] items-start gap-x-4 border-b py-3 last:border-0`,children:[(0,R.jsxs)(`div`,{className:`min-w-0`,children:[(0,R.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,R.jsx)(I,{tone:o.tone,pulse:o.pulse,className:`mt-[7px]`}),(0,R.jsx)(We,{label:e.title,children:(0,R.jsx)(E,{className:`line-clamp-2 break-words font-medium leading-snug hover:underline no-hover:min-h-11`,to:`/p/${encodeURIComponent(e.projectId)}/tasks/${encodeURIComponent(e.id)}`,"aria-disabled":r||void 0,tabIndex:r?-1:void 0,onClick:e=>{r&&e.preventDefault()},children:e.title})})]}),(0,R.jsxs)(`p`,{className:`mt-1 pl-[15px] text-label text-muted-foreground`,children:[(0,R.jsx)(`span`,{className:`font-mono text-meta`,children:e.projectId}),` ·`,` `,r?`Checking current state…`:o.label,e.archived?` · Archived`:``,e.subtask?` · Subtask`:``]})]}),(0,R.jsxs)(`div`,{className:`text-right tabular-nums`,children:[(0,R.jsx)(`span`,{"aria-label":l(t),className:`block font-semibold ${e[Z[t]]==null?`text-soft-foreground`:``}`,children:c(t)}),s.length>0&&(0,R.jsx)(`span`,{className:`mt-1 flex justify-end gap-3 text-label text-muted-foreground tabular-nums`,children:s.map(e=>(0,R.jsxs)(`span`,{"aria-label":l(e),children:[c(e),` `,e===`cost`?``:e===`input`?`in`:`out`]},e))})]})]})}var Vn={cost:`costUsd`,input:`inputTokens`,output:`outputTokens`},Hn={cost:`Reported USD`,input:`Input tokens`,output:`Output tokens`};function Un(e){return[...e.cost?[`cost`]:[],...e.tokens?[`input`,`output`]:[]]}var Wn=(e,t)=>Dt(e,t===`cost`);function Gn(e){return new Date(`${e}T00:00:00`).toLocaleDateString(void 0,{month:`short`,day:`numeric`})}function Kn({series:e,height:t,accent:n,renderTooltip:r,describe:i}){let a=Math.max(1,...e.map(t));return(0,R.jsxs)(Ve,{delayDuration:150,children:[(0,R.jsx)(`div`,{className:`flex h-20 items-end gap-0.5`,role:`group`,"aria-label":`Daily trend`,children:e.map(e=>{let o=t(e),s=Math.max(o>0?4:0,o/a*100);return(0,R.jsxs)(He,{children:[(0,R.jsx)(Be,{asChild:!0,children:(0,R.jsx)(`button`,{"data-export-keep":!0,"aria-label":i(e),type:`button`,className:`min-w-0 flex-1 rounded-t-sm transition-opacity hover:opacity-80 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`,style:{height:`100%`,display:`flex`,alignItems:`end`},children:(0,R.jsx)(`span`,{style:{height:`${s}%`},className:`block w-full rounded-t-sm ${n}`})})}),(0,R.jsx)(Ue,{children:r(e)})]},e.date)})}),(0,R.jsxs)(`div`,{className:`mt-1 flex justify-between text-label text-muted-foreground`,children:[(0,R.jsx)(`span`,{children:Gn(e[0].date)}),(0,R.jsx)(`span`,{children:Gn(e.at(-1).date)})]})]})}function qn({metrics:e,series:t}){return(0,R.jsxs)(`table`,{className:`w-full text-left text-xs`,children:[(0,R.jsx)(`thead`,{children:(0,R.jsxs)(`tr`,{className:`border-b`,children:[(0,R.jsx)(`th`,{className:`py-1 pr-2 font-medium`,children:`Date`}),e.map(e=>(0,R.jsx)(`th`,{className:`py-1 pr-2 text-right font-medium`,children:Hn[e]},e)),(0,R.jsx)(`th`,{className:`py-1 pr-2 text-right font-medium`,children:`Completed`}),(0,R.jsx)(`th`,{className:`py-1 text-right font-medium`,children:`Avg cycle`})]})}),(0,R.jsx)(`tbody`,{children:t.map(t=>(0,R.jsxs)(`tr`,{className:`border-b last:border-0`,children:[(0,R.jsx)(`td`,{className:`py-1 pr-2`,children:Gn(t.date)}),e.map(e=>(0,R.jsx)(`td`,{className:`py-1 pr-2 text-right tabular-nums`,children:Wn(t[Vn[e]]?.value,e)},e)),(0,R.jsx)(`td`,{className:`py-1 pr-2 text-right tabular-nums`,children:t.completed}),(0,R.jsx)(`td`,{className:`py-1 text-right tabular-nums`,children:t.avgCycleHours===null?`—`:q(t.avgCycleHours)})]},t.date))})]})}function Jn({metric:e,series:t}){let n=En[e],r=Vn[e],i=t.reduce((e,t)=>e+(t[r]?.reportedTasks??0),0);return(0,R.jsxs)(`div`,{className:`rounded-xl border p-3`,children:[(0,R.jsx)(`p`,{className:`text-label font-medium ${n.text}`,children:Hn[e]}),(0,R.jsx)(`div`,{className:`mt-2`,children:(0,R.jsx)(Kn,{series:t,describe:t=>`${t.date}, ${Hn[e]}: ${Wn(t[r]?.value,e)}, ${t[r]?.reportedTasks??0} of ${t.tasks} tasks reported`,height:e=>e[r]?.value??0,accent:n.fill,renderTooltip:t=>(0,R.jsxs)(`p`,{children:[Gn(t.date),` · `,Wn(t[r]?.value,e),` ·`,` `,t[r]?.reportedTasks??0,`/`,t.tasks,` tasks reported`]})})}),i===0&&(0,R.jsx)(`p`,{className:`mt-2 text-label text-muted-foreground`,children:`No reports in this period.`})]})}function Yn({series:e}){let t=e.reduce((e,t)=>e+t.completed,0),n=e.reduce((e,t)=>e+(t.avgCycleHours??0)*(t.cycleReportedTasks??t.completed),0),r=e.reduce((e,t)=>e+(t.cycleReportedTasks??t.completed),0),i=r?n/r:null;return(0,R.jsxs)(`div`,{className:`rounded-xl border p-3`,children:[(0,R.jsxs)(`div`,{className:`flex flex-wrap items-baseline justify-between gap-2`,children:[(0,R.jsx)(`p`,{className:`text-label font-medium text-success`,children:`Completed tasks`}),(0,R.jsxs)(`p`,{className:`text-label text-muted-foreground`,children:[t,` done · avg cycle`,` `,i===null?`unavailable`:q(i)]})]}),(0,R.jsxs)(`p`,{className:`text-label text-muted-foreground`,children:[r,`/`,t,` completed tasks have valid cycle times.`]}),(0,R.jsx)(`div`,{className:`mt-2`,children:(0,R.jsx)(Kn,{series:e,describe:e=>`${e.date}: ${e.completed} completed tasks, average cycle ${e.avgCycleHours==null?`Unavailable`:q(e.avgCycleHours)}`,height:e=>e.completed,accent:`bg-success`,renderTooltip:e=>(0,R.jsxs)(`div`,{children:[(0,R.jsxs)(`p`,{children:[Gn(e.date),` · `,e.completed,` completed`]}),(0,R.jsxs)(`p`,{children:[`Avg cycle`,` `,e.avgCycleHours===null?`unavailable`:q(e.avgCycleHours),` · Median`,` `,e.medianCycleHours===null?`unavailable`:q(e.medianCycleHours)]})]})})}),t===0&&(0,R.jsx)(`p`,{className:`mt-2 text-label text-muted-foreground`,children:`No tasks finished in this period.`})]})}function Xn(){return(0,R.jsx)(Zn,{visibility:Ke(o().data)})}function Zn({visibility:e}){let[t,n]=Ot(`trendPeriod`,[`7d`,`30d`],`7d`),r=wn(t,e.cost?`cost`:`input`,`${e.cost}:${e.tokens}`),i=r.data,a=i&&i.totals.tasks===0&&i.coverage.projects.every(e=>e.state===`complete`)&&i.series.every(e=>e.tasks===0&&e.completed===0),o=Un({cost:e.cost&&i?.visibility.cost!==!1,tokens:e.tokens&&i?.visibility.tokens!==!1});return(0,R.jsxs)(N,{className:`gap-0 py-0`,children:[(0,R.jsxs)(`div`,{className:V,children:[(0,R.jsx)(`h2`,{className:B,children:`Trends`}),(0,R.jsx)(ct,{label:`Period`,value:t,onValueChange:n,options:lt})]}),(0,R.jsxs)(`div`,{className:`space-y-4 p-4 text-sm`,children:[i&&(0,R.jsx)(z,{rows:a?[]:i.series.flatMap(e=>[...o.map(t=>({section:`daily-creation-cohort`,entity:e.date,metric:Vn[t],value:e[Vn[t]]?.value??null,unit:t===`cost`?`USD`:`tokens`,reportedTasks:e[Vn[t]]?.reportedTasks??0,totalTasks:e.tasks,asOf:i.asOf,note:`Lifetime usage grouped by task creation date; not daily spend`})),{section:`daily-completions`,entity:e.date,metric:`completed`,value:e.completed,unit:`tasks`,asOf:i.asOf},{section:`daily-completions`,entity:e.date,metric:`avgCycleHours`,value:e.avgCycleHours,reportedTasks:e.cycleReportedTasks??e.completed,totalTasks:e.completed,unit:`hours`,asOf:i.asOf},{section:`daily-completions`,entity:e.date,metric:`medianCycleHours`,value:e.medianCycleHours,unit:`hours`,asOf:i.asOf}])}),(0,R.jsxs)(`details`,{className:`text-label text-muted-foreground`,children:[(0,R.jsxs)(`summary`,{"data-export-heading":`Metric definitions`,className:`${ot} py-2`,children:[(0,R.jsx)(H,{}),`How these metrics work`]}),(0,R.jsx)(`p`,{children:`Usage is grouped by creation date, not spending date. Completed tasks are grouped by finish date. Calendar days use your current UTC offset (fixed across the period), including today.`})]}),r.isPending&&(0,R.jsx)(`p`,{children:`Loading trends…`}),r.isError&&(0,R.jsxs)(`p`,{role:`alert`,children:[i?`Showing stale trends. Could not refresh.`:`Could not load trends.`,` `,(0,R.jsx)(P,{className:`min-h-11`,onClick:()=>void r.refetch(),children:`Retry`})]}),i&&(0,R.jsx)(`p`,{className:`text-label text-muted-foreground`,children:(0,R.jsx)(pt,{at:i.asOf})}),i&&(0,R.jsx)(K,{coverage:i.coverage,retry:()=>void r.refetch()}),i&&a&&(0,R.jsx)(`p`,{className:`text-muted-foreground`,children:`No retained tasks in this period yet.`}),i&&!a&&i.series.length>0&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`div`,{className:`space-y-4`,children:[o.length>0&&(0,R.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-[repeat(auto-fit,minmax(200px,1fr))]`,children:o.map(e=>(0,R.jsx)(Jn,{metric:e,series:i.series},e))}),(0,R.jsx)(Yn,{series:i.series})]}),(0,R.jsxs)(`details`,{className:`group rounded-lg border bg-muted/20 print:block`,children:[(0,R.jsxs)(`summary`,{"data-export-heading":`Daily data`,className:`flex min-h-11 cursor-pointer list-none items-center gap-2 px-3 text-label font-medium text-muted-foreground hover:text-foreground [&::-webkit-details-marker]:hidden`,children:[(0,R.jsx)(nt,{className:`size-4`,"aria-hidden":`true`}),` View data table`,(0,R.jsx)(_e,{className:`ml-auto size-4 transition-transform group-open:rotate-180`,"aria-hidden":`true`})]}),(0,R.jsx)(`div`,{className:`max-h-80 overflow-auto border-t p-3 print:max-h-none print:overflow-visible`,role:`region`,"aria-label":`Daily trend values`,tabIndex:0,children:(0,R.jsx)(qn,{metrics:o,series:i.series})})]})]})]})]})}function Qn(e,t,n,r=!0){let i=g();return _({queryKey:[...cn.snapshot,e?.snapshotId,t,n],enabled:r&&!!e,retry:!1,queryFn:async({signal:r})=>{if(!e)throw Error(`Dashboard not loaded`);let a=[];try{for(let i=0;i<n;){let o=await dn(e.snapshotId,t,i,Math.min(20,n-i),r);if(a.push(...o.page.rows),o.page.nextOffset===null)break;i=o.page.nextOffset}return a}catch(e){if(e instanceof d&&e.status===409){let e=await un(r);i.setQueryData(cn.snapshot,e)}throw e}}})}function $n(e,t,n,r){let i=g(),a=t===`questions`||t===`reviews`?`needs-you`:t,o=a===`needs-you`?0:n,s=r.map(e=>`${e.projectId}:${e.id}`).sort();return _({queryKey:[...cn.snapshot,e.snapshotId,t,`displaced`,...s],enabled:s.length>0,retry:!1,queryFn:async({signal:t})=>{let n=new Set(s),r=new Map;try{for(let i=o;i!==null&&n.size;){let o=await dn(e.snapshotId,a,i,20,t);for(let e of o.page.rows){let t=`${e.projectId}:${e.id}`;n.delete(t)&&r.set(t,e)}i=o.page.nextOffset}return r}catch(e){throw e instanceof d&&e.status===409&&i.setQueryData(cn.snapshot,await un(t)),e}}})}function er({snapshot:e,questions:t,reviews:n,more:r,healthy:i=!0}){let a=re();return(0,R.jsxs)(N,{className:`min-w-0 gap-0 overflow-hidden py-0`,children:[(0,R.jsxs)(`div`,{className:V,children:[(0,R.jsxs)(`h2`,{id:`dashboard-needs-you`,tabIndex:-1,className:B,children:[`Needs you · `,e.counts.questions+e.counts.reviews]}),(0,R.jsxs)(`p`,{className:`text-label text-muted-foreground tabular-nums`,children:[e.counts.questions,` questions · `,e.counts.reviews,` reviews`]})]}),i&&a.connected&&e.counts.questions+e.counts.reviews===0&&e.coverage.projects.every(e=>e.state===`complete`)?(0,R.jsxs)(`p`,{className:`flex items-center gap-2.5 px-4 py-8 text-sm text-muted-foreground`,children:[(0,R.jsx)(I,{tone:`success`}),`All caught up — no tasks need your input`]}):null,(0,R.jsx)(tr,{snapshot:e,group:`questions`,count:t,more:r}),(0,R.jsx)(tr,{snapshot:e,group:`reviews`,count:n,more:r})]})}function tr({snapshot:e,group:t,count:n,more:r}){let i=e[t],a=Math.max(n,i.rows.length),o=Qn(e,t,a,a>i.rows.length),s=a>i.rows.length?o.data:i.rows,c=yt(s,G,t,n),l=$n(e,t,a,c.rows.filter(e=>e.removed).map(e=>e.row)),u=(0,L.useRef)(null);return!i.total&&!c.rows.length?null:(0,R.jsxs)(`section`,{children:[(0,R.jsxs)(`h3`,{ref:u,tabIndex:-1,className:`border-b bg-card-2 px-4 py-2 eyebrow text-muted-foreground`,children:[t===`questions`?`Questions`:`Reviews`,` · `,i.total]}),c.updates>0&&(0,R.jsxs)(P,{variant:`ghost`,className:`m-2 min-h-11`,onClick:()=>{c.show(),u.current?.focus()},children:[c.updates,` updates — Show`]}),c.rows.map(({row:e,removed:t})=>(0,R.jsx)(Et,{row:l.data?.get(G(e))??e,removed:t&&!!l.data&&!l.data.has(G(e)),checking:s===void 0||t&&!l.data,checkFailed:s===void 0&&o.isError||t&&!l.data&&l.isError,queue:!0},G(e))),(o.isError||l.isError)&&(0,R.jsxs)(`p`,{role:`alert`,className:`p-4 text-sm`,children:[`Could not check current task state.`,` `,(0,R.jsx)(P,{variant:`ghost`,className:`min-h-11`,onClick:()=>{o.refetch(),l.refetch()},children:`Retry`})]}),a<i.total&&(0,R.jsxs)(P,{variant:`ghost`,className:`m-2 min-h-11`,disabled:o.isFetching,onClick:()=>r(t,a+Math.min(20,i.total-a)),children:[`Show `,Math.min(20,i.total-a),` more `,t]})]})}function nr(e){if(!e.startsWith(`github:`))return e===`tasks`?`Task results`:e;let t=e.slice(7).split(`:`),n=t.pop()===`pr`?`Pull requests`:`Issues`;return`${t.join(`:`).replace(/^project:/,`Project `).replace(/^github.com\//,``)} · ${n}`}var rr=e=>e.key;function ir({filter:e,setFilter:t,count:n,more:r}){let i=hn(e,!0),a=yt(i.data?.rows,rr,`feed:${e}`,0,e=>e.kind===`task-result`),o=a.rows,s=a.updates,c=(0,L.useContext)(_t),l=(0,L.useRef)(null),u=`feed:${e}`,d=(0,L.useMemo)(()=>({scroll:wt(c,u)?.scroll??0,done:!1}),[c,u]);(0,L.useLayoutEffect)(()=>{!l.current||d.done||(l.current.scrollTop=d.scroll,d.done=Math.abs(l.current.scrollTop-d.scroll)<1||!!i.data&&!i.isPending&&!i.isFetching)},[d,o.length,n,i.data,i.isPending,i.isFetching]);let f=(0,L.useRef)(null),p=i.data?.sources.filter(e=>e.key.startsWith(`github:`))??[],m=p.flatMap(e=>e.fetchedAt?[e.fetchedAt]:[]).sort()[0],g=i.githubError,_=p.filter(e=>e.reason===`No GitHub remote`),v=p.some(e=>e.reason===`Still loading GitHub`),y=p.length>0&&_.length===p.length&&!g,b=p.filter(e=>e.state!==`ready`&&e.reason!==`No GitHub remote`&&e.reason!==`Still loading GitHub`),x=y&&e===`all`;return(0,R.jsxs)(N,{"data-export-context":`Results source: ${e}; Last 7 days; loaded ${Math.min(n,o.length)} rows`,className:`min-w-0 gap-0 overflow-hidden py-0`,children:[(0,R.jsxs)(`div`,{className:`space-y-2 border-b px-4 pt-2.5 pb-2`,children:[(0,R.jsxs)(`div`,{className:`flex min-h-9 flex-wrap items-center justify-between gap-2`,children:[(0,R.jsx)(`h2`,{ref:f,tabIndex:-1,className:B,children:x?`Recent results`:`Recent results & GitHub`}),(0,R.jsx)(`span`,{className:`text-label text-muted-foreground`,children:`Last 7 days`})]}),!x&&(0,R.jsx)(Ze,{slot:`dashboard-feed`,label:`Results source`,value:e,options:[{value:`all`,label:`All`},{value:`tasks`,label:`Tasks`},{value:`github`,label:`GitHub`}],onChange:t}),x&&(0,R.jsx)(`p`,{className:`text-label text-muted-foreground`,children:`Task results · No GitHub repositories configured`}),e!==`tasks`&&!x&&(0,R.jsxs)(`details`,{className:`text-label text-muted-foreground`,open:b.length||g?!0:void 0,children:[(0,R.jsxs)(`summary`,{className:`flex w-fit cursor-pointer list-none items-center gap-1.5 rounded-sm text-muted-foreground transition-colors select-none hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/50 [&::-webkit-details-marker]:hidden py-1.5`,children:[(0,R.jsx)(H,{}),b.length||g?`GitHub needs attention`:v?`Checking GitHub…`:y?`GitHub not configured`:m?`GitHub checked ${F(m)} ago`:`GitHub source`]}),(0,R.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-x-3`,children:[(0,R.jsx)(`p`,{children:b.length||g?m?`Could not refresh GitHub. Showing results from ${new Date(m).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`})}.`:`Could not load one or more GitHub sources.`:v?`Checking repository sources. Available results remain visible.`:y?`No GitHub repositories configured. Select Tasks to see task results.`:m?`GitHub checked ${F(m)} ago`:`GitHub snapshot`}),!y&&(0,R.jsx)(P,{variant:`ghost`,className:`min-h-11 px-0`,disabled:i.githubFetching,onClick:()=>{i.refetch()},children:i.githubFetching?`Refreshing…`:b.length||g?`Retry GitHub`:`Refresh GitHub`})]})]})]}),(0,R.jsxs)(`div`,{role:`region`,"aria-label":`Recent results list`,ref:l,onWheel:()=>{d.done=!0},onTouchStart:()=>{d.done=!0},onKeyDown:()=>{d.done=!0},onScroll:e=>{c&&d.done&&Tt(c,u,{count:n,scroll:e.currentTarget.scrollTop})},tabIndex:0,className:`max-h-80 overflow-y-auto overscroll-contain focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring`,children:[i.isError&&(0,R.jsxs)(`p`,{role:`alert`,className:`p-4 text-sm`,children:[`Could not load results.`,` `,(0,R.jsx)(P,{className:`min-h-11`,onClick:()=>{i.retryFailed()},children:`Retry`})]}),i.isPending&&(0,R.jsx)(`p`,{className:`p-4 text-sm`,children:`Loading results…`}),s>0&&(0,R.jsxs)(P,{variant:`ghost`,className:`m-2 min-h-11`,onClick:()=>{a.show(),f.current?.focus()},children:[s,` updates — Show`]}),o.slice(0,n).map(({row:e,removed:t})=>e.kind===`task-result`?(0,R.jsx)(Et,{row:e.run,kicker:t?`Outside current results`:`Latest result: ${h(e.run)?`Closed after inactivity`:e.run.status===`failed`?`Failed`:`Completed`}`},e.key):(0,R.jsxs)(`div`,{className:`border-b px-4 py-3 transition-colors hover:bg-muted/30`,children:[(0,R.jsx)(z,{rows:[{section:`github`,entity:`${e.repo}#${e.number}`,metric:e.itemKind,value:e.title,asOf:e.at,note:e.url}]}),(0,R.jsx)(`a`,{className:`block break-words text-sm font-medium hover:underline no-hover:min-h-11`,href:e.url,target:`_blank`,rel:`noreferrer`,children:e.title}),(0,R.jsxs)(`p`,{className:`mt-1 text-label text-muted-foreground`,children:[e.repo,` · `,e.itemKind===`pr`?`PR`:`Issue`,` #`,e.number,` created ·`,` `,F(e.at)]})]},e.key)),i.data&&!i.data.rows.length&&!o.length&&!i.isFetching&&!i.isError&&!b.length&&!v&&i.data.coverage.projects.every(e=>e.state===`complete`)&&(0,R.jsx)(`p`,{className:`px-4 py-8 text-sm text-muted-foreground`,children:`No results in the last 7 days`}),n<o.length&&(0,R.jsxs)(P,{variant:`ghost`,className:`m-2 min-h-11`,onClick:r,children:[`Show `,Math.min(20,o.length-n),` more results`]}),i.data?.truncated&&(0,R.jsx)(`p`,{className:`p-4 text-label text-muted-foreground`,children:`Showing the latest 60 results`}),i.data&&(0,R.jsx)(K,{coverage:i.data.coverage,retry:()=>{i.retryTasks()}}),!x&&i.data?.sources.some(e=>e.state!==`ready`||e.truncated)&&(0,R.jsxs)(`details`,{className:`p-4 text-label`,children:[(0,R.jsxs)(`summary`,{className:`flex w-fit cursor-pointer list-none items-center gap-1.5 rounded-sm text-muted-foreground transition-colors select-none hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/50 [&::-webkit-details-marker]:hidden min-h-11`,children:[(0,R.jsx)(H,{}),`Source details`]}),i.data.sources.map(e=>(0,R.jsxs)(`p`,{className:`break-words py-1`,children:[nr(e.key),`:`,` `,e.reason===`No GitHub remote`?`Not configured`:e.reason===`Still loading GitHub`?`Checking…`:e.reason??(e.state===`ready`?`Up to date`:e.state),e.truncated?` · capped`:``,e.fetchedAt?` · checked ${F(e.fetchedAt)}`:``]},e.key))]})]})]})}var $=e=>e.replace(/[&<>"']/g,e=>({"&":`&amp;`,"<":`&lt;`,">":`&gt;`,'"':`&quot;`,"'":`&#39;`})[e]),ar=`Visible modules and loaded rows only. Filters and report availability apply. Retained task usage is not an invoice or a complete history.`,or=`Confidential — internal distribution only`,sr={costUsd:{label:`Reported cost`,usd:!0},inputTokens:{label:`Input tokens`},outputTokens:{label:`Output tokens`},needsYou:{label:`Needs you`},running:{label:`Running now`},completed:{label:`Completed in period`},failed:{label:`Failed outcomes in period`},medianCycleHours:{label:`Median cycle (hours)`}};function cr(e,t){return e==null?`Unavailable`:typeof e==`string`?e:Dt(e,t)}function lr(e){let t=new Set,n=[];for(let r of e.modules)for(let e of r.rows){if(e.section!==`totals`&&e.section!==`fleet`&&e.section!==`overview`)continue;let i=sr[e.metric];!i||t.has(e.metric)||(t.add(e.metric),n.push({label:i.label,value:cr(e.value,i.usd),note:[e.metric===`needsYou`||e.metric===`running`?e.note||`Current non-archived state`:r.filters,e.asOf?`Data as of ${e.asOf}`:``,e.reportedTasks==null?``:`${e.reportedTasks} of ${e.totalTasks} tasks reported`].filter(Boolean).join(` · `)}))}return n}function ur(e){let t=e.cloneNode(!0);t.querySelectorAll(`script,style,link,img,iframe,object,embed,input,[hidden],[data-dashboard-export],[data-export-exclude]`).forEach(e=>e.remove()),t.querySelectorAll(`select`).forEach((t,n)=>{let r=e.querySelectorAll(`select`)[n];t.replaceWith(document.createTextNode(`: `+(r?.selectedOptions[0]?.textContent??``)))}),t.querySelectorAll(`[data-export-filter]`).forEach(e=>{e.replaceWith(document.createTextNode(`${e.dataset.exportFilter}: ${e.dataset.exportValue??``}`))}),t.querySelectorAll(`[data-export-row],[data-dashboard-row]`).forEach(e=>e.classList.add(`report-row`)),t.querySelectorAll(`summary`).forEach(e=>{let t=document.createElement(`h3`);t.textContent=e.getAttribute(`data-export-heading`)||e.textContent,e.replaceWith(t)}),t.querySelectorAll(`button`).forEach(e=>{if(e.hasAttribute(`data-export-keep`)){let t=document.createElement(`div`);for(let n of[...e.attributes])[`class`,`style`,`title`].includes(n.name)&&t.setAttribute(n.name,n.value);t.append(...e.childNodes),e.replaceWith(t)}else e.remove()}),t.querySelectorAll(`details`).forEach(e=>{let t=document.createElement(`div`);t.className=e.className,t.append(...e.childNodes),e.replaceWith(t)});for(let e of[t,...t.querySelectorAll(`*`)])for(let t of[...e.attributes])(t.name.startsWith(`on`)||[`href`,`src`,`srcset`,`action`,`formaction`,`tabindex`].includes(t.name)||t.name.startsWith(`data-`))&&e.removeAttribute(t.name);return t.removeAttribute(`style`),t.innerHTML}function dr(e,t,n,r){return{generatedAt:t,source:n,title:r||void 0,notices:[...e.querySelectorAll(`[role=alert],[role=status]`)].filter(e=>!e.closest(`[data-dashboard-module]`)).map(e=>e.textContent?.trim()??``).filter(Boolean),modules:[...e.querySelectorAll(`[data-dashboard-module]`)].map(e=>{let t=[...e.querySelectorAll(`select`)].map(e=>`${e.closest(`label`)?.childNodes[0]?.textContent?.trim()??`Filter`}: ${e.selectedOptions[0]?.textContent}`).concat([...e.querySelectorAll(`[data-export-filter]`)].map(e=>`${e.dataset.exportFilter}: ${e.dataset.exportValue??``}`)).concat([...e.querySelectorAll(`[data-export-context]`)].map(e=>e.dataset.exportContext)).join(`; `),n=[...new Set([...e.querySelectorAll(`p,[role="alert"],[role="status"]`)].filter(e=>!e.closest(`table,[data-export-exclude]`)&&!e.querySelector(`p,[role="alert"],[role="status"]`)).map(e=>{let t=e.cloneNode(!0);return t.querySelectorAll(`table,button,select,summary,[data-export-exclude]`).forEach(e=>e.remove()),t.textContent?.trim()}).filter(Boolean))].join(` | `);return{id:e.dataset.dashboardModule,title:e.querySelector(`h2`)?.textContent??e.dataset.dashboardModule,filters:t,notes:n,html:ur(e),rows:[...e.querySelectorAll(`[data-dashboard-export]`)].flatMap(e=>JSON.parse(e.dataset.dashboardExport))}})}}function fr(e){let t=e==null?``:String(e);return typeof e==`string`&&/^[\s\uFEFF]*[=+@\-]/.test(t)&&(t=`'${t}`),`"${t.replaceAll(`"`,`""`)}"`}function pr(e){let t=[[`generated_at`,`source`,`module`,`filters`,`section`,`entity`,`metric`,`value`,`unit`,`availability`,`reported_tasks`,`total_tasks`,`as_of`,`notes`]];for(let n of e.modules){t.push([e.generatedAt,e.source,n.title,n.filters,`context`,``,`scope`,ar,``,``,``,``,``,[...e.title?[`Report title: ${e.title}`]:[],...e.notices,n.notes].join(` | `)]);for(let r of n.rows)t.push([e.generatedAt,e.source,n.title,n.filters,r.section,r.entity,r.metric,r.value,r.unit,r.value===null?`unavailable`:typeof r.value==`number`?`measured`:`reported`,r.reportedTasks,r.totalTasks,r.asOf,r.note])}return``+t.map(e=>e.map(fr).join(`,`)).join(`\r
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{$ as r,$n as i,Er as a,F as o,Ni as s,Nn as c,dn as l,la as u,mr as d,nr as f,pn as p,qa as m,tr as h,xo as g,yo as _}from"./queries-BQUz3Wnb.js";import{A as v,D as y,M as b,O as x,P as S,Z as C,j as w,k as T,t as ee}from"./utils-Dp6vCdiU.js";import{C as te,f as E,y as ne}from"./project-router-B1Q3upIJ.js";import{_ as D,a as O,g as k,h as re,m as A,n as ie,r as j,v as M}from"./segmented-DI7abdqX.js";import{a as ae,i as oe,o as se,r as ce,t as le}from"./sheet-DPwaj6sk.js";import{t as ue}from"./createLucideIcon-BHp8sXmF.js";import{t as de,u as fe}from"./reference-chip-BpbybBvl.js";import{a as pe,d as me,r as he,u as N}from"./automation-format-CMG-6CYi.js";import{V as ge,t as P}from"./button-CJXK1JqU.js";import{r as _e}from"./dist-Bsi6zLdE.js";import{i as ve,n as ye,o as be,s as xe,t as Se}from"./select-DL5E3ZAD.js";import{t as Ce}from"./circle-alert-ClwRNTQt.js";import{t as we}from"./circle-question-mark-X2pmbDJg.js";import{t as Te}from"./download-CfgyYHf7.js";import{i as Ee,r as De,t as Oe}from"./popover-DUg9gBOn.js";import{a as ke,c as Ae,d as je,f as Me,i as Ne,l as Pe,n as Fe,r as Ie,s as Le,t as Re,u as ze}from"./sortable.esm-B7aanBL9.js";import{a as Be,i as Ve,n as He,r as Ue,t as We}from"./icon-tooltip-DYk5cjLx.js";import{r as F,t as Ge}from"./format-BUbPQpzw.js";import{t as I}from"./status-dot-AP_4obOJ.js";import{t as Ke}from"./token-metrics-DXeuToH8.js";import{t as qe}from"./use-now-C8dG5uIP.js";import{J as Je,ht as Ye,lt as Xe,n as Ze,t as Qe}from"./index-BfbbA0lF.js";var $e=ue(`activity`,[[`path`,{d:`M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2`,key:`169zse`}]]),et=ue(`arrow-down-left`,[[`path`,{d:`M17 7 7 17`,key:`15tmo1`}],[`path`,{d:`M17 17H7V7`,key:`1org7z`}]]),tt=ue(`grip-horizontal`,[[`circle`,{cx:`12`,cy:`9`,r:`1`,key:`124mty`}],[`circle`,{cx:`19`,cy:`9`,r:`1`,key:`1ruzo2`}],[`circle`,{cx:`5`,cy:`9`,r:`1`,key:`1a8b28`}],[`circle`,{cx:`12`,cy:`15`,r:`1`,key:`1e56xg`}],[`circle`,{cx:`19`,cy:`15`,r:`1`,key:`1a92ep`}],[`circle`,{cx:`5`,cy:`15`,r:`1`,key:`5r1jwy`}]]),nt=ue(`table-2`,[[`path`,{d:`M9 3H5a2 2 0 0 0-2 2v4m6-6h10a2 2 0 0 1 2 2v4M9 3v18m0 0h10a2 2 0 0 0 2-2V9M9 21H5a2 2 0 0 1-2-2V9m0 0h18`,key:`gugj83`}]]),L=e(t(),1);function rt(e){let t=Date.parse(e.nextRunAt??``),n=Date.parse(e.state?.backoffUntil??``);return Number.isFinite(t)?Math.max(t,Number.isFinite(n)?n:t):null}function it(e){return e.flatMap(e=>(e.data?.automations??[]).filter(e=>e.enabled).map(t=>({project:e,automation:t,at:rt(t)}))).sort((e,t)=>(e.at??1/0)-(t.at??1/0)||e.project.id.localeCompare(t.project.id)||e.automation.id.localeCompare(t.automation.id))}function at(e){let t=r(),n=g(),i=t.data?.projects??[],o=t.data?.bootProject,s=o&&!i.some(e=>e.id===o)?[...i,{id:o,name:o,status:`ok`}]:i,c=_({queryKey:[...p.dashboard,`automations`,s.map(e=>[e.id,e.name,e.status])],enabled:e&&!!t.data,queryFn:async({signal:e})=>{let t=0,n=[];return await Promise.all([0,1].map(async()=>{for(;t<s.length&&!e.aborted;){let r=s[t++];if(r.status===`missing`){n.push({...r,error:`Project folder unavailable`});continue}try{let t=S.parse(await m(await a.api.v1.workspace.dashboard.automations.$get({query:{projectId:r.id}},{init:{signal:e}}),`/workspace/dashboard/automations`));n.push({id:r.id,name:r.name,data:t})}catch{n.push({id:r.id,name:r.name,error:`Could not load automations`})}}})),n}});return(0,L.useEffect)(()=>{if(e)return O(e=>{e===`automation-change`&&n.invalidateQueries({queryKey:[...p.dashboard,`automations`]})})},[n,e]),{...c,registry:t,retry:()=>{t.refetch(),c.refetch()}}}var R=n();function z({rows:e}){return(0,R.jsx)(`span`,{hidden:!0,"data-dashboard-export":JSON.stringify(e)})}var B=`section-mark eyebrow text-muted-foreground`,V=`flex min-h-12 flex-wrap items-center justify-between gap-x-3 gap-y-2 border-b px-4 py-2.5`,ot=`flex w-fit cursor-pointer list-none items-center gap-1.5 rounded-sm text-muted-foreground transition-colors select-none hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/50 [&::-webkit-details-marker]:hidden`;function H(){return(0,R.jsx)(ge,{"aria-hidden":`true`,className:`size-3.5 shrink-0 text-soft-foreground transition-transform duration-150 motion-reduce:transition-none [details[open]>summary>&]:rotate-90`})}var st=`flex items-center gap-2 text-label text-muted-foreground`;function ct({label:e,value:t,onValueChange:n,options:r}){let i=r.find(e=>e.value===t);return(0,R.jsxs)(`span`,{className:st,"data-export-filter":e,"data-export-value":i?.label??``,children:[e,(0,R.jsxs)(Se,{value:t,onValueChange:e=>n(e),children:[(0,R.jsx)(be,{"aria-label":e,size:`sm`,className:`bg-card-2 font-mono text-xs no-hover:min-h-11`,children:(0,R.jsx)(xe,{})}),(0,R.jsx)(ye,{children:r.map(e=>(0,R.jsx)(ve,{value:e.value,children:e.label},e.value))})]})]})}var lt=[{value:`7d`,label:`Last 7 days`},{value:`30d`,label:`Last 30 days`}],ut=`relative min-w-0 overflow-hidden rounded-lg border bg-card-2 p-4 transition-colors before:absolute before:inset-x-0 before:top-0 before:h-px before:opacity-80 hover:border-foreground/20 hover:bg-muted/40 sm:p-5`,U={violet:`before:bg-violet`,info:`before:bg-info`,success:`before:bg-success`,danger:`before:bg-danger`,primary:`before:bg-primary`,neutral:`before:bg-border`};function dt({label:e,value:t,icon:n,children:r}){return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`span`,{className:`flex w-full items-center justify-between gap-2`,children:[(0,R.jsx)(`span`,{className:`eyebrow text-muted-foreground`,children:e}),(0,R.jsx)(`span`,{className:`text-soft-foreground`,"aria-hidden":`true`,children:n})]}),(0,R.jsx)(`span`,{className:`mt-4 block text-4xl font-semibold leading-none tracking-tight tabular-nums`,children:t}),(0,R.jsx)(`span`,{className:`mt-3 block text-label text-muted-foreground`,children:r})]})}function ft({at:e,children:t}){return(0,R.jsx)(We,{label:new Date(e).toLocaleString(),children:(0,R.jsx)(`time`,{dateTime:e,children:t})})}function pt({at:e}){return(0,R.jsxs)(ft,{at:e,children:[`Updated `,F(e),` ago`]})}function mt(){let e=Je(),t=at(e.known&&!e.off),n=qe(3e4),[r,i]=(0,L.useState)(!1),a=it(t.data??[]),o=r?a:a.slice(0,3),s=t.data?.filter(e=>e.error)??[],c=!e.known||!t.registry.isError&&(t.registry.isPending||t.isPending),l=t.isError||t.registry.isError||s.length>0;return(0,R.jsxs)(N,{"data-export-context":`Enabled automations · showing ${o.length} of ${a.length} loaded · ${l?`partial coverage`:`available projects`}`,className:`min-w-0 gap-0 py-0`,children:[(0,R.jsxs)(`div`,{className:V,children:[(0,R.jsxs)(`h2`,{className:`flex items-center ${B}`,children:[`Automations`,(0,R.jsx)(me,{className:`ml-2 size-3.5 text-soft-foreground`,"aria-hidden":`true`})]}),!e.off&&t.data&&(0,R.jsxs)(`span`,{className:`text-label text-muted-foreground tabular-nums`,children:[a.length,` enabled`,l?` · partial`:``]})]}),!e.off&&t.data&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(z,{rows:[{section:`automations`,metric:`enabled`,value:a.length,unit:`automations`,note:l?`Partial project coverage`:`Loaded projects`}]}),t.dataUpdatedAt>0&&(0,R.jsx)(`p`,{className:`px-4 pt-3 text-label text-muted-foreground`,children:(0,R.jsx)(pt,{at:new Date(t.dataUpdatedAt).toISOString()})})]}),e.off?(0,R.jsx)(`p`,{className:`p-4 text-sm text-muted-foreground`,children:`Automations are disabled in this workspace.`}):(0,R.jsxs)(R.Fragment,{children:[c&&(0,R.jsx)(`p`,{className:`p-4 text-sm text-muted-foreground`,children:`Loading automations…`}),l&&(0,R.jsxs)(`div`,{role:`alert`,className:`p-4 text-sm`,children:[(0,R.jsx)(`p`,{children:`Some automation data could not be refreshed. Available results are shown.`}),s.map(e=>(0,R.jsxs)(`p`,{children:[e.name,`: `,e.error]},e.id)),(0,R.jsx)(P,{variant:`ghost`,onClick:t.retry,children:`Retry automations`})]}),!c&&!l&&a.length===0&&(0,R.jsx)(`p`,{className:`p-4 text-sm text-muted-foreground`,children:`No enabled automations. Enable one in a project's Automations page.`}),o.map(({project:e,automation:t,at:r})=>{let i=(t.state?.consecutiveFailures??0)>0?`Recent checks failed`:void 0,a=r===null?`Next time not available`:r<=n?`Due — awaiting scheduler`:pe(r,n),o=t.kind===`schedule`?`Next run`:`Next check`;return(0,R.jsxs)(`div`,{"data-export-row":!0,className:`border-b px-4 py-3 transition-colors last:border-0 hover:bg-muted/30`,children:[(0,R.jsx)(E,{className:`block min-h-11 text-sm font-medium hover:underline`,to:`/p/${encodeURIComponent(e.id)}/automations/${encodeURIComponent(t.id)}`,children:t.name}),(0,R.jsxs)(`p`,{className:`text-label text-muted-foreground`,children:[e.name,` · `,o,`: `,a]}),r!==null&&(0,R.jsx)(`p`,{className:`mt-1 text-label text-muted-foreground`,children:(0,R.jsxs)(`time`,{dateTime:new Date(r).toISOString(),children:[he(r,e.data.timeZone),` · `,e.data.timeZone]})}),t.kind!==`schedule`&&(0,R.jsx)(`p`,{className:`mt-1 text-label text-muted-foreground`,children:`Checks for matching events; a task may not be started.`}),i&&(0,R.jsx)(`p`,{className:`mt-1 text-label text-warning`,children:i}),(0,R.jsx)(z,{rows:[{section:`automation`,entity:`${e.id}:${t.id}`,metric:`name`,value:t.name},{section:`automation`,entity:`${e.id}:${t.id}`,metric:t.kind===`schedule`?`nextRunAt`:`nextCheckAt`,value:r===null?null:new Date(r).toISOString(),note:[a,i].filter(Boolean).join(` · `)}]})]},`${e.id}:${t.id}`)}),a.length>3&&(0,R.jsx)(P,{variant:`ghost`,className:`m-2 min-h-11`,onClick:()=>i(!r),children:r?`Show fewer`:`Show all ${a.length} enabled`}),!c&&(0,R.jsxs)(`details`,{className:`border-t px-4 py-2 text-label text-muted-foreground`,children:[(0,R.jsxs)(`summary`,{className:`flex w-fit cursor-pointer list-none items-center gap-1.5 rounded-sm text-muted-foreground transition-colors select-none hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/50 [&::-webkit-details-marker]:hidden min-h-11`,"data-export-heading":`Project automations`,children:[(0,R.jsx)(H,{}),`Manage automations by project`]}),t.data?.map(e=>(0,R.jsx)(E,{className:`block min-h-11 py-3 hover:underline`,to:`/p/${encodeURIComponent(e.id)}/automations`,children:e.name},e.id))]})]})]})}function ht(e,t,n){let r=new Set,i=new Map(e.map((e,t)=>[n(e),{r:e,i:t}]));return t.forEach((e,t)=>{let a=i.get(n(e));(!a||a.i!==t||JSON.stringify(a.r)!==JSON.stringify(e))&&r.add(n(e)),i.delete(n(e))}),i.forEach((e,t)=>r.add(t)),r}function gt(e,t,n){let r=new Map(t.map(e=>[n(e),e]));return e.map(e=>({row:r.get(n(e))??e,removed:!r.has(n(e))}))}var _t=(0,L.createContext)(``),vt=(0,L.createContext)(!0),W=new Map;function yt(e,t,n=``,r=0,i){let a=(0,L.useContext)(_t),o=`${a}:${n}`,[s,c]=(0,L.useState)(()=>W.get(o)),[l,u]=(0,L.useState)(o),d=(0,L.useRef)(r),f=(0,L.useRef)(!1);l!==o&&(u(o),c(W.get(o)),d.current=r,f.current=!1),d.current!==r&&(d.current=r,f.current=!0),(0,L.useEffect)(()=>{e&&(!s||f.current)&&(c(e),f.current=!1)},[s,e]);let p=(0,L.useMemo)(()=>({current:s}),[o]);p.current=s,(0,L.useEffect)(()=>()=>{!a||!p.current||(W.delete(o),W.set(o,p.current),W.size>60&&W.delete(W.keys().next().value))},[a,o,p]);let m=s??e??[],h=new Set((e??m).map(t)),g=i?m.filter(e=>h.has(t(e))||i(e)):m;return{rows:gt(g,e??m,t),updates:e?ht(g,e,t).size:0,show:()=>c(e)}}var bt=new Map;function xt(e){return bt.get(e)}function St(e,t){bt.delete(e),bt.set(e,t),bt.size>20&&bt.delete(bt.keys().next().value)}var Ct=new Map;function wt(e,t){return Ct.get(e)?.[t]}function Tt(e,t,n){let r=Ct.get(e)??{};r[t]=n,Ct.delete(e),Ct.set(e,r),Ct.size>20&&Ct.delete(Ct.keys().next().value)}var G=e=>`${e.projectId}:${e.id}`;function Et({row:e,removed:t=!1,queue:n=!1,checking:r=!1,checkFailed:a=!1,kicker:o}){let s=(0,L.useContext)(vt)&&!r&&!a,l=M(e);t=t||l===null||n&&l?.archived===!0,l&&(e={...e,status:l.status,awaitingAnswerSince:l.awaitingAnswerSince,idleClosedAt:l.idleClosedAt});let u=i(e),d=n&&!f(e),p=t||d||!s;return(0,R.jsxs)(`div`,{"data-dashboard-row":G(e),className:`min-w-0 border-b px-4 py-3 transition-colors last:border-0 hover:bg-muted/30`,children:[(0,R.jsx)(z,{rows:[{section:`task`,entity:G(e),metric:`title`,value:e.titleSummary||e.title},{section:`task`,entity:G(e),metric:`status`,value:p?`Not currently actionable`:e.status},{section:`task`,entity:G(e),metric:`createdAt`,value:e.createdAt}]}),o&&(0,R.jsx)(`p`,{className:`mb-1 pl-[15px] eyebrow text-soft-foreground`,children:o}),(0,R.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,R.jsx)(I,{tone:u.tone,pulse:u.pulse&&!p,className:`mt-[7px]`}),(0,R.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,R.jsx)(E,{tabIndex:p?-1:void 0,"aria-disabled":p||void 0,onClick:e=>{p&&e.preventDefault()},to:`/p/${encodeURIComponent(e.projectId)}/tasks/${encodeURIComponent(e.id)}`,className:`block break-words text-sm font-medium leading-relaxed hover:underline no-hover:min-h-11`,children:e.titleSummary||e.title}),(0,R.jsxs)(`div`,{className:`mt-1 flex flex-wrap items-center gap-x-2 gap-y-1 text-label text-muted-foreground`,children:[(0,R.jsx)(`span`,{className:`font-mono text-meta`,children:e.projectId}),(0,R.jsx)(`span`,{children:a?`Could not check current state`:s?t?n&&l!==null?`No longer needs you`:`Task removed`:d?`No longer needs you`:u.label:`Checking current state…`}),(0,R.jsx)(`span`,{children:F(e.createdAt)}),e.dispatch&&(0,R.jsx)(`span`,{children:`Subtask`}),!p&&c(e).map(t=>(0,R.jsx)(de,{reference:t,taskTitle:e.title,projectId:e.projectId,className:`no-hover:min-h-11`},`${t.kind}:${t.number}`))]})]})]})]})}function K({coverage:e,count:t,retry:n}){let r=e.projects.filter(e=>e.state!==`complete`);return r.length?(0,R.jsxs)(`div`,{className:`rounded-lg border border-pending/40 bg-card-2 p-3 text-sm`,role:`status`,children:[(0,R.jsxs)(`p`,{children:[t===void 0?``:`${t} tasks need you in the available data. Complete coverage: ${e.projects.length-r.length} of ${e.projects.length} projects. `,r.length===1?r[0].state===`unavailable`?`One project is unavailable.`:`One project has incomplete coverage.`:`${r.length} projects have incomplete coverage.`]}),(0,R.jsxs)(`details`,{className:`mt-2`,children:[(0,R.jsxs)(`summary`,{className:`${ot} min-h-11`,children:[(0,R.jsx)(H,{}),`View unavailable `,r.length===1?`project`:`projects`]}),r.map(e=>(0,R.jsxs)(`p`,{children:[e.projectId,`: `,e.reason??e.state,e.omittedRuns>0?` · ${e.omittedRuns} omitted tasks`:``]},e.projectId))]}),(0,R.jsx)(P,{variant:`outline`,onClick:n,className:`min-h-11`,children:`Retry`})]}):null}function Dt(e,t=!1){return e==null?`Unavailable`:t?`$${e.toFixed(e===0||e>=1?2:Math.min(20,Math.max(4,Math.ceil(-Math.log10(e))+1)))}`:e.toLocaleString(`en-US`)}function q(e){return e===null?`Unavailable`:e<1?`${Math.round(e*60)}m`:e<48?`${e.toFixed(1)}h`:`${(e/24).toFixed(1)}d`}function Ot(e,t,n){let r=ne(),i=r.state?.dashboardEntry??r.key,[a,o]=te(),s=a.get(e);return[s!==null&&t.includes(s)?s:n,t=>o(n=>{let r=new URLSearchParams(n);return r.set(e,t),r},{replace:!0,state:{...r.state,dashboardEntry:i}})]}var kt=e=>`Last ${e===`7d`?7:30} calendar days`,At=`eyebrow text-muted-foreground`,jt=`min-w-0 rounded-lg border bg-card-2 p-4`,J=`whitespace-nowrap px-3 py-2 eyebrow text-soft-foreground`,Y=`text-label text-muted-foreground`;function Mt(){let e=r().data?.projects;return t=>e?.find(e=>e.id===t)?.name??t}var Nt=(e,t)=>`/p/${encodeURIComponent(e)}/tasks/${encodeURIComponent(t)}`;function Pt({label:e,value:t,onChange:n}){return(0,R.jsx)(ct,{label:e,value:t,onValueChange:n,options:lt})}function Ft({query:e}){return e.isPending?(0,R.jsx)(`p`,{role:`status`,className:`text-sm text-muted-foreground`,children:`Loading insights…`}):e.isError?(0,R.jsxs)(`p`,{role:`alert`,className:`text-sm`,children:[e.data?`Showing previous results. `:``,`Could not refresh insights.`,` `,(0,R.jsx)(P,{variant:`outline`,onClick:()=>void e.refetch(),children:`Retry insights`})]}):null}function It({period:e,active:t}){let n=Qe(e,t),r=n.data;return(0,R.jsxs)(`div`,{className:`space-y-3`,children:[(0,R.jsx)(Ft,{query:n}),r&&(0,R.jsx)(K,{coverage:r.coverage,retry:()=>void n.refetch()}),r&&(0,R.jsxs)(`div`,{className:`grid gap-3 lg:grid-cols-2`,children:[(0,R.jsx)(Rt,{data:r}),(0,R.jsx)(zt,{data:r})]})]})}function Lt({value:e,prefix:t=``,className:n}){let r=`${t}${e.toLocaleString(`en-US`)}`;return e<1e4?(0,R.jsx)(`span`,{className:n,children:r}):(0,R.jsx)(We,{label:r,children:(0,R.jsxs)(`span`,{className:n,"aria-label":r,children:[t,Ge(e)]})})}function Rt({data:e}){let t=e.delivered,n=[{label:`PRs opened`,value:t.prsOpened,note:`${t.prsTouched} touched`},{label:`Lines`,value:(0,R.jsxs)(`span`,{className:`flex flex-wrap gap-x-1.5`,children:[(0,R.jsx)(Lt,{value:t.additions,prefix:`+`,className:`text-success`}),(0,R.jsx)(Lt,{value:t.deletions,prefix:`−`,className:`text-danger`})]})},{label:`Files`,value:(0,R.jsx)(Lt,{value:t.files})},{label:`Issues`,value:(0,R.jsx)(Lt,{value:t.issues})}];return(0,R.jsxs)(`section`,{className:jt,"aria-label":`Delivered`,children:[(0,R.jsx)(z,{rows:Object.entries(t).map(([t,n])=>({section:`delivered`,metric:t,value:n,unit:[`additions`,`deletions`].includes(t)?`lines`:t===`files`?`files`:`count`,asOf:e.asOf,note:`Completed since ${e.windowStart}`}))}),(0,R.jsx)(`h3`,{className:At,children:`Delivered`}),(0,R.jsx)(`dl`,{className:`mt-3 grid grid-cols-2 gap-x-4 gap-y-3 sm:grid-cols-4`,children:n.map(e=>(0,R.jsxs)(`div`,{className:`min-w-0`,children:[(0,R.jsx)(`dt`,{className:Y,children:e.label}),(0,R.jsx)(`dd`,{className:`mt-1 truncate text-xl font-semibold tracking-tight tabular-nums`,children:e.value}),e.note&&(0,R.jsx)(`dd`,{className:Y,children:e.note})]},e.label))}),(0,R.jsxs)(`span`,{className:`mt-3 block ${Y}`,children:[`From `,t.completedTasks,` completed `,t.completedTasks===1?`task`:`tasks`,` ·`,` `,t.measuredTasks,` with a stored diff`]})]})}function zt({data:e}){let t=Mt(),{total:n,reasons:r}=e.failures;return(0,R.jsxs)(`section`,{className:jt,"aria-label":`Why tasks failed`,children:[(0,R.jsx)(z,{rows:r.map(t=>({section:`failures`,entity:t.label,metric:t.category,value:t.count,unit:`tasks`,asOf:e.asOf,note:t.latest.message}))}),(0,R.jsxs)(`div`,{className:`flex items-baseline justify-between gap-2`,children:[(0,R.jsx)(`h3`,{className:At,children:`Why tasks failed`}),n>0&&(0,R.jsxs)(`span`,{className:`${Y} tabular-nums`,children:[n,` failed`]})]}),n===0?(0,R.jsxs)(`span`,{className:`mt-4 flex items-center gap-2.5 text-sm text-muted-foreground`,children:[(0,R.jsx)(I,{tone:`success`}),`No failed outcomes in this period`]}):(0,R.jsx)(`ul`,{className:`mt-3 space-y-3`,children:r.map(e=>(0,R.jsx)(Bt,{reason:e,total:n,projectName:t},`${e.category}:${e.label}`))})]})}function Bt({reason:e,total:t,projectName:n}){let{latest:r}=e;return(0,R.jsxs)(`li`,{className:`min-w-0`,children:[(0,R.jsxs)(`div`,{className:`flex items-baseline justify-between gap-3 text-sm`,children:[(0,R.jsx)(`span`,{className:`min-w-0 truncate font-medium`,children:e.label}),(0,R.jsx)(`span`,{className:`text-label tabular-nums text-muted-foreground`,children:e.count})]}),(0,R.jsx)(`div`,{className:`mt-1.5 h-1 overflow-hidden rounded-full bg-muted`,"aria-hidden":`true`,children:(0,R.jsx)(`div`,{className:`h-full rounded-full bg-danger/70`,style:{width:`${e.count/t*100}%`}})}),(0,R.jsx)(We,{label:r.message,children:(0,R.jsxs)(`span`,{className:`mt-1.5 block truncate ${Y}`,children:[`Latest:`,` `,(0,R.jsx)(E,{className:`hover:text-foreground hover:underline`,to:Nt(r.projectId,r.id),children:r.title}),` `,`· `,n(r.projectId),r.step?` · ${r.step}`:``,` · `,F(r.at),` ago`]})})]})}var Vt={claude:`Claude Code`,codex:`Codex`,opencode:`OpenCode`,cursor:`Cursor`,pi:`Pi`,unknown:`Unknown backend`,mixed:`Mixed backends`},Ht=e=>Vt[e]??e,Ut=(e,t)=>t?Math.round(e/t*100):0;function Wt(){let[e,t]=Ot(`backends`,[`7d`,`30d`],`7d`),n=Qe(e),r=n.data,i=r?.visibility.cost;return(0,R.jsx)(`section`,{"data-dashboard-module":`backends`,className:`min-w-0`,children:(0,R.jsxs)(N,{className:`gap-0 py-0`,"data-export-context":`Backends: ${kt(e)}; finished tasks`,children:[(0,R.jsxs)(`div`,{className:V,children:[(0,R.jsx)(`h2`,{className:B,children:`Backends & models`}),(0,R.jsx)(Pt,{label:`Finished`,value:e,onChange:t})]}),(0,R.jsxs)(`div`,{className:`space-y-3 p-4`,children:[(0,R.jsx)(Ft,{query:n}),r&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`p`,{className:Y,children:`Tasks that finished done or failed in the period, by the backend and model their steps ran on. Includes subtasks. Cost is reported USD only.`}),(0,R.jsx)(K,{coverage:r.coverage,retry:()=>void n.refetch()}),r.backends.length?(0,R.jsx)(`div`,{className:`overflow-x-auto`,role:`region`,"aria-label":`Backend comparison`,tabIndex:0,children:(0,R.jsxs)(`table`,{className:`w-full text-left text-sm`,children:[(0,R.jsx)(`thead`,{children:(0,R.jsxs)(`tr`,{children:[(0,R.jsx)(`th`,{className:J,children:`Backend`}),(0,R.jsx)(`th`,{className:`${J} text-right`,children:`Finished`}),(0,R.jsx)(`th`,{className:J,children:`Success`}),(0,R.jsx)(`th`,{className:`${J} text-right`,children:`Median cycle`}),i&&(0,R.jsx)(`th`,{className:`${J} text-right`,children:`Reported USD`}),i&&(0,R.jsx)(`th`,{className:`${J} text-right`,children:`Per completed`})]})}),(0,R.jsx)(`tbody`,{children:r.backends.map(e=>(0,R.jsx)(Gt,{stat:e,cost:!!i},`${e.backend}:${e.model??``}`))})]})}):(0,R.jsx)(`p`,{className:`py-4 text-sm text-muted-foreground`,children:`No finished tasks in this period.`}),(0,R.jsx)(`span`,{className:`block ${Y}`,children:(0,R.jsx)(pt,{at:r.asOf})}),(0,R.jsx)(z,{rows:r.backends.flatMap(e=>[`finished`,`done`,`failed`,`medianCycleHours`].map(t=>({section:`backends`,entity:`${e.backend}${e.model?`:${e.model}`:``}`,metric:t,value:e[t],unit:t===`medianCycleHours`?`hours`:`tasks`,asOf:r.asOf})))})]})]})]})})}function Gt({stat:e,cost:t}){let n=Ut(e.done,e.finished),r=e.costUsd?.value;return(0,R.jsxs)(`tr`,{className:`border-t transition-colors hover:bg-muted/30`,children:[(0,R.jsxs)(`td`,{className:`px-3 py-2.5`,children:[(0,R.jsx)(`span`,{className:`block font-medium`,children:Ht(e.backend)}),(0,R.jsx)(`span`,{className:ee(`block`,Y,e.backend!==`mixed`&&e.model?`font-mono text-meta`:``),children:e.backend===`mixed`?`steps ran on different backends`:e.model??`default model`})]}),(0,R.jsx)(`td`,{className:`px-3 py-2.5 text-right tabular-nums`,children:e.finished}),(0,R.jsxs)(`td`,{className:`min-w-40 px-3 py-2.5`,children:[(0,R.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,R.jsx)(`span`,{className:`h-1.5 flex-1 overflow-hidden rounded-full bg-danger/40`,"aria-hidden":`true`,children:(0,R.jsx)(`span`,{className:`block h-full rounded-full bg-success`,style:{width:`${n}%`}})}),(0,R.jsxs)(`span`,{className:`w-10 text-right text-label tabular-nums`,children:[n,`%`]})]}),(0,R.jsxs)(`span`,{className:`block ${Y}`,children:[e.done,` done · `,e.failed,` failed`]})]}),(0,R.jsx)(`td`,{className:`px-3 py-2.5 text-right tabular-nums`,children:e.timedTasks?q(e.medianCycleHours):`—`}),t&&(0,R.jsxs)(`td`,{className:`px-3 py-2.5 text-right tabular-nums`,children:[r==null?`—`:Dt(r,!0),(0,R.jsxs)(`span`,{className:`block ${Y}`,children:[e.costUsd?.reportedTasks??0,`/`,e.finished,` reported`]})]}),t&&(0,R.jsx)(`td`,{className:`px-3 py-2.5 text-right tabular-nums`,children:r==null||!e.done?`—`:Dt(r/e.done,!0)})]})}function Kt(){let[e,t]=Ot(`automations`,[`7d`,`30d`],`7d`),n=Je(),r=Qe(e),i=at(n.known&&!n.off),a=Mt(),o=r.data,s=o?.visibility.cost,c=new Map;for(let e of i.data??[])for(let t of e.data?.automations??[])c.set(`${e.id}\u0000${t.id}`,{projectId:e.id,automationId:t.id,name:t.name,enabled:t.enabled,definition:`known`});let l=new Set((i.data??[]).flatMap(e=>e.data&&!e.error?[e.id]:[])),u=i.isError||i.registry.isError||(i.data??[]).some(e=>e.error);for(let e of o?.automations??[]){let t=`${e.projectId}\u0000${e.automationId}`,n=c.get(t);c.set(t,n?{...n,stat:e}:{...e,name:e.automationId,definition:l.has(e.projectId)?`removed`:`unknown`,stat:e})}let d=[...c.values()].sort((e,t)=>(t.stat?.tasks??0)-(e.stat?.tasks??0)||Number(t.enabled??!1)-Number(e.enabled??!1)||e.name.localeCompare(t.name));return(0,R.jsx)(`section`,{"data-dashboard-module":`automation-outcomes`,className:`min-w-0`,children:(0,R.jsxs)(N,{className:`gap-0 py-0`,"data-export-context":`Automation outcomes: tasks created in ${kt(e)}`,children:[(0,R.jsxs)(`div`,{className:V,children:[(0,R.jsx)(`h2`,{className:B,children:`Automation outcomes`}),(0,R.jsx)(Pt,{label:`Launched`,value:e,onChange:t})]}),(0,R.jsx)(`div`,{className:`space-y-3 p-4`,children:n.off?(0,R.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Automations are disabled in this workspace.`}):(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(Ft,{query:r}),o&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`p`,{className:Y,children:`Tasks each automation created in the period and how they ended. Active means still running, queued, waiting on you, or waiting to resume after a usage limit.`}),(0,R.jsx)(K,{coverage:o.coverage,retry:()=>void r.refetch()}),u&&(0,R.jsxs)(`p`,{role:`alert`,className:`text-sm`,children:[`Some automation details could not be loaded. Their outcomes are shown by id.`,` `,(0,R.jsx)(P,{variant:`ghost`,onClick:i.retry,children:`Retry automations`})]}),d.length?(0,R.jsx)(`div`,{className:`overflow-x-auto`,role:`region`,"aria-label":`Automation outcomes`,tabIndex:0,children:(0,R.jsxs)(`table`,{className:`w-full text-left text-sm`,children:[(0,R.jsx)(`thead`,{children:(0,R.jsxs)(`tr`,{children:[(0,R.jsx)(`th`,{className:J,children:`Automation`}),(0,R.jsx)(`th`,{className:`${J} text-right`,children:`Tasks`}),(0,R.jsx)(`th`,{className:`${J} text-right`,children:`Done`}),(0,R.jsx)(`th`,{className:`${J} text-right`,children:`Failed`}),(0,R.jsx)(`th`,{className:`${J} text-right`,children:`Active`}),(0,R.jsx)(`th`,{className:J,children:`Last run`}),s&&(0,R.jsx)(`th`,{className:`${J} text-right`,children:`Reported USD`})]})}),(0,R.jsx)(`tbody`,{children:d.map(e=>(0,R.jsx)(qt,{row:e,cost:!!s,projectName:a},`${e.projectId}:${e.automationId}`))})]})}):(0,R.jsx)(`p`,{className:`py-4 text-sm text-muted-foreground`,children:`No automations yet. Create one in a project's Automations page.`}),(0,R.jsx)(`span`,{className:`block ${Y}`,children:(0,R.jsx)(pt,{at:o.asOf})}),(0,R.jsx)(z,{rows:d.flatMap(e=>[`tasks`,`done`,`failed`,`active`].map(t=>({section:`automation-outcomes`,entity:`${e.projectId}:${e.automationId}`,metric:t,value:e.stat?.[t]??0,unit:`tasks`,asOf:o.asOf,note:e.name})))})]})]})})]})})}function qt({row:e,cost:t,projectName:n}){let r=e.stat,i=`px-3 py-2.5 text-right tabular-nums`,a=e=>e||(0,R.jsx)(`span`,{className:`text-soft-foreground`,children:`0`});return(0,R.jsxs)(`tr`,{className:`border-t transition-colors hover:bg-muted/30`,children:[(0,R.jsxs)(`td`,{className:`px-3 py-2.5`,children:[e.definition===`removed`?(0,R.jsx)(`span`,{className:`block font-medium`,children:e.name}):(0,R.jsx)(E,{className:`block font-medium hover:underline`,to:`/p/${encodeURIComponent(e.projectId)}/automations/${encodeURIComponent(e.automationId)}`,children:e.name}),(0,R.jsxs)(`span`,{className:`flex items-center gap-1.5 ${Y}`,children:[(0,R.jsx)(I,{tone:e.enabled?`violet`:`neutral`}),n(e.projectId),` ·`,` `,e.definition===`removed`?`Removed`:e.definition===`unknown`?`Details unavailable`:e.enabled?`Enabled`:`Disabled`]})]}),(0,R.jsx)(`td`,{className:i,children:a(r?.tasks)}),(0,R.jsx)(`td`,{className:i,children:a(r?.done)}),(0,R.jsx)(`td`,{className:`${i} ${r?.failed?`text-danger`:``}`,children:a(r?.failed)}),(0,R.jsx)(`td`,{className:i,children:a(r?.active)}),(0,R.jsx)(`td`,{className:`whitespace-nowrap px-3 py-2.5 ${Y}`,children:r?.lastRunAt?(0,R.jsxs)(ft,{at:r.lastRunAt,children:[F(r.lastRunAt),` ago · `,r.lastStatus]}):`—`}),t&&(0,R.jsx)(`td`,{className:i,children:r?.costUsd?.value==null?`—`:Dt(r.costUsd.value,!0)})]})}var Jt=0,Yt=()=>++Jt,Xt=new Map;function X(e,t){let n=(0,L.useContext)(_t),r=()=>{let r=n?Xt.get(n):void 0;return r?.has(e)?r.get(e):typeof t==`function`?t():t},[i,a]=(0,L.useState)(r),o=`${n}:${e}`,[s,c]=(0,L.useState)(o);o!==s&&(c(o),a(()=>r()));let l=(0,L.useMemo)(()=>({value:i}),[n,e]);return l.value=i,(0,L.useEffect)(()=>()=>{if(!n)return;let t=Xt.get(n)??new Map;t.set(e,l.value),t.size>80&&t.delete(t.keys().next().value),Xt.delete(n),Xt.set(n,t),Xt.size>20&&Xt.delete(Xt.keys().next().value)},[n,e,l]),[i,a]}var Zt=`a[href], button, select, input, [tabindex]`;function Qt(e){let[t]=X(`${e}:position`,()=>({scroll:0})),n=(0,L.useCallback)(e=>{let n=[...e.querySelectorAll(Zt)],r=t.href?n.find(e=>e.getAttribute(`href`)===t.href):t.index===void 0?void 0:n[t.index];return r&&r.getAttribute(`aria-disabled`)!==`true`&&r.focus({preventScroll:!0}),e.scrollTop=t.scroll,!!r&&r.getAttribute(`aria-disabled`)!==`true`},[t]),r=(0,L.useMemo)(()=>({restore:()=>!1}),[t]);return{ref:(0,L.useCallback)(e=>{if(!e)return;let i=t.href!==void 0||t.index!==void 0,a=()=>{if(!i)return!1;let r=n(e);return r?(i=!1,o.disconnect()):e.querySelector(`[data-sheet-loading="false"]`)&&(i=!1,o.disconnect(),e.querySelector(`button:not([disabled]), select, [tabindex="0"]`)?.focus({preventScroll:!0}),e.scrollTop=t.scroll),r};r.restore=a;let o=new MutationObserver(a);i&&o.observe(e,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[`data-sheet-loading`]});let s=()=>{i=!1,o.disconnect()},c=()=>{i||(t.scroll=e.scrollTop)},l=n=>{i||!(n.target instanceof HTMLElement)||(t.href=n.target.getAttribute(`href`)??void 0,t.index=[...e.querySelectorAll(Zt)].indexOf(n.target))};return e.addEventListener(`pointerdown`,s),e.addEventListener(`keydown`,s),e.addEventListener(`wheel`,s,{passive:!0}),e.addEventListener(`scroll`,c),e.addEventListener(`focusin`,l),()=>{o.disconnect(),e.removeEventListener(`pointerdown`,s),e.removeEventListener(`keydown`,s),e.removeEventListener(`wheel`,s),e.removeEventListener(`scroll`,c),e.removeEventListener(`focusin`,l)}},[t,n,r]),onOpenAutoFocus:e=>{(t.href!==void 0||t.index!==void 0)&&(e.preventDefault(),r.restore())}}}function $t(e,t){let n=(0,L.useRef)(null),[r,i]=X(`${e}:trigger`,null);return{capture:()=>{let e=document.activeElement;n.current=e instanceof HTMLElement&&e!==document.body?e:null,i(n.current?{label:n.current.getAttribute(`aria-label`),text:n.current.textContent}:null)},restore:()=>{((n.current?.isConnected?n.current:r?[...document.querySelectorAll(`button`)].find(e=>!e.closest(`[role="dialog"]`)&&!e.hasAttribute(`disabled`)&&(r.label?e.getAttribute(`aria-label`)===r.label:e.textContent===r.text)):void 0)??document.querySelector(t))?.focus({preventScroll:!0})}}}function en(e,t=!0){return _({queryKey:[...p.dashboard,`overview`,e],enabled:t,staleTime:5e3,refetchInterval:t&&!e.snapshotId?15e3:!1,refetchIntervalInBackground:!1,retry:!1,queryFn:async({signal:t})=>y.parse(await m(await a.api.v1.workspace.dashboard.overview.$get({query:{period:e.period??`7d`,group:e.group??`completed`,tzOffsetMinutes:String(e.tzOffsetMinutes??new Date().getTimezoneOffset()),...e.snapshotId?{snapshotId:e.snapshotId}:{},...e.projectId?{projectId:e.projectId}:{},offset:String(e.offset??0),limit:`20`}},{init:{signal:t}}),`/workspace/dashboard/overview`))})}var tn={running:`Running now`,"needs-you":`Needs you`,completed:`Completed`,failed:`Failed outcomes`},nn={"needs-you":U.info,running:U.violet,completed:U.success,failed:U.danger},rn={"needs-you":we,running:$e,completed:j,failed:Ce};function an({active:e,children:t,onCurrent:n}){let[i,a]=Ot(`period`,[`7d`,`30d`],`7d`),o=$t(`outcome`,`[data-outcome-trigger]`),s=r().data?.projects,c=e=>s?.find(t=>t.id===e)?.name??e,l=en({period:i},e),[u,d]=X(`outcome:selection`,null),f=Qt(`outcome:${u?.identity??`closed`}`),p=re();if((0,L.useEffect)(()=>{e||d(null)},[e]),!e)return t({});let m=l.data,h=(e,t)=>{o.capture(),m&&d({identity:Yt(),snapshot:m,group:e,projectId:t})},g=m?.coverage.projects.every(e=>e.state===`complete`);return(0,R.jsxs)(R.Fragment,{children:[t({overview:(0,R.jsxs)(N,{className:`gap-0 py-0`,children:[(0,R.jsxs)(`div`,{className:V,children:[(0,R.jsx)(`h2`,{className:B,children:`Workspace overview`}),(0,R.jsx)(ct,{label:`Outcomes period`,value:i,onValueChange:e=>{a(e),d(null)},options:lt})]}),(0,R.jsxs)(`div`,{className:`space-y-4 p-4`,children:[l.isPending&&(0,R.jsx)(`p`,{role:`status`,className:`text-sm text-muted-foreground`,children:`Loading overview…`}),l.isError&&(0,R.jsxs)(`p`,{role:`alert`,children:[m?`Showing previous results. `:``,`Could not refresh overview.`,` `,(0,R.jsx)(P,{variant:`outline`,onClick:()=>void l.refetch(),children:`Retry overview`})]}),m&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[m.metrics.needsYou?`${m.metrics.needsYou} tasks require your input or review.`:g&&p.connected&&!l.isError?`No tasks currently require your input or review.`:`No waiting tasks found in the available data.`,` `,m.metrics.failed,` failed `,m.metrics.failed===1?`outcome`:`outcomes`,` `,`in this period. Includes subtasks; completed does not mean accepted or deployed.`]}),(0,R.jsx)(K,{coverage:m.coverage,retry:()=>void l.refetch()}),(0,R.jsx)(`div`,{className:`grid grid-cols-2 gap-3 lg:grid-cols-4`,children:[`needs-you`,`running`,`completed`,`failed`].map(e=>{let t=m.metrics[e===`needs-you`?`needsYou`:e],r=rn[e];return(0,R.jsxs)(P,{"data-outcome-trigger":!0,"data-export-keep":!0,variant:`outline`,className:`relative min-w-0 overflow-hidden rounded-lg border bg-card-2 p-4 transition-colors before:absolute before:inset-x-0 before:top-0 before:h-px before:opacity-80 hover:border-foreground/20 hover:bg-muted/40 sm:p-5 group/metric h-auto min-h-24 flex-col items-start gap-0 whitespace-normal text-left font-normal ${t===0?U.neutral:nn[e]}`,onClick:t=>{n&&(e===`running`||e===`needs-you`)?n(e,t.currentTarget):h(e)},"aria-label":`${tn[e]}: ${t}`,children:[(0,R.jsx)(dt,{label:tn[e],value:t,icon:(0,R.jsx)(r,{className:`size-4`}),children:e===`running`||e===`needs-you`?`Current state`:`Last ${i===`7d`?7:30} calendar days`}),(0,R.jsxs)(`span`,{"data-export-exclude":!0,className:`mt-4 flex items-center gap-1 text-label font-medium text-muted-foreground transition-colors group-hover/metric:text-foreground`,children:[`View tasks`,` `,(0,R.jsx)(ge,{className:`size-3 transition-transform group-hover/metric:translate-x-0.5 motion-reduce:transition-none`,"aria-hidden":`true`})]})]},e)})}),(0,R.jsx)(It,{period:i,active:e}),(0,R.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-x-4 gap-y-1 border-t pt-3`,children:[(0,R.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Median cycle time`,` `,(0,R.jsx)(`strong`,{className:`font-mono font-semibold text-foreground`,children:q(m.metrics.medianCycleHours)}),` `,`· `,m.metrics.timedTasks,`/`,m.metrics.completed,` completed tasks have valid timings.`,` `,(0,R.jsx)(P,{variant:`ghost`,className:`h-auto px-1.5 py-1 text-sm text-foreground underline-offset-4 hover:underline`,onClick:()=>h(`completed`),children:`Inspect completed tasks`})]}),(0,R.jsx)(`p`,{className:`text-label text-muted-foreground`,children:(0,R.jsxs)(ft,{at:m.asOf,children:[`Updated `,F(m.asOf),` ago`]})})]}),(0,R.jsxs)(`details`,{className:`text-label text-muted-foreground`,children:[(0,R.jsxs)(`summary`,{"data-export-heading":`Metric definitions`,className:`flex w-fit cursor-pointer list-none items-center gap-1.5 rounded-sm text-muted-foreground transition-colors select-none hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/50 [&::-webkit-details-marker]:hidden py-1`,children:[(0,R.jsx)(H,{}),`How these metrics work`]}),(0,R.jsx)(`p`,{className:`mt-1 max-w-prose pl-5 leading-relaxed`,children:`Outcomes use finish dates, including archived tasks. Scheduled retries are excluded from failed outcomes. Period includes today at your current fixed UTC offset.`})]}),(0,R.jsx)(z,{rows:Object.entries(m.metrics).map(([e,t])=>({section:`overview`,metric:e,value:t,unit:e===`medianCycleHours`?`hours`:`tasks`,asOf:m.asOf,note:e===`running`||e===`needsYou`?`Current non-archived state`:`Finished since ${m.windowStart}`}))})]})]})]}),portfolio:m&&(0,R.jsx)(`div`,{children:(0,R.jsxs)(N,{className:`gap-0 py-0`,"data-export-context":`Outcomes: Last ${i===`7d`?7:30} calendar days; workload: current state`,children:[(0,R.jsx)(`div`,{className:`flex min-h-12 flex-wrap items-center justify-between gap-x-3 gap-y-2 border-b px-4 py-2.5`,children:(0,R.jsx)(`h2`,{className:`section-mark eyebrow text-muted-foreground`,children:`Projects`})}),(0,R.jsx)(`p`,{className:`px-4 pt-3 text-label text-muted-foreground`,children:`Current workload and outcomes for the selected period. Sorted by tasks needing you, then running tasks. Counts include subtasks.`}),(0,R.jsxs)(`div`,{className:`overflow-x-auto px-1 pb-2`,role:`region`,"aria-label":`Project outcomes`,tabIndex:0,children:[(0,R.jsxs)(`table`,{className:`w-full text-left text-sm`,children:[(0,R.jsx)(`thead`,{children:(0,R.jsx)(`tr`,{children:[`Project`,`Needs you`,`Running`,`Completed`,`Failed`,`Median cycle`].map(e=>(0,R.jsx)(`th`,{className:`whitespace-nowrap px-3 py-2 eyebrow text-soft-foreground ${e===`Project`?``:`text-right`}`,children:e},e))})}),(0,R.jsx)(`tbody`,{children:m.projects.map(e=>{let t=m.coverage.projects.find(t=>t.projectId===e.projectId);return(0,R.jsxs)(`tr`,{className:`border-t transition-colors hover:bg-muted/30`,children:[(0,R.jsxs)(`td`,{className:`px-3 py-2`,children:[(0,R.jsx)(E,{className:`font-medium hover:underline`,to:`/p/${encodeURIComponent(e.projectId)}`,children:c(e.projectId)}),t?.state!==`complete`&&(0,R.jsx)(`span`,{className:`block text-label text-muted-foreground`,children:`Incomplete data`})]}),[`needs-you`,`running`,`completed`,`failed`].map(n=>(0,R.jsx)(`td`,{className:`px-3 py-1 text-right`,children:(0,R.jsx)(P,{"data-export-keep":!0,variant:`ghost`,className:`min-h-11 tabular-nums`,"aria-label":`${c(e.projectId)}: ${tn[n]}: ${t?.state===`unavailable`?`Unavailable`:e[n===`needs-you`?`needsYou`:n]}`,disabled:t?.state===`unavailable`,onClick:()=>h(n,e.projectId),children:t?.state===`unavailable`?`Unavailable`:e[n===`needs-you`?`needsYou`:n]})},n)),(0,R.jsxs)(`td`,{className:`px-3 py-2 text-right tabular-nums`,children:[q(e.medianCycleHours),(0,R.jsxs)(`span`,{className:`block text-label text-muted-foreground`,children:[e.timedTasks,`/`,e.completed,` timed`]})]})]},e.projectId)})})]}),!m.projects.length&&(0,R.jsx)(`p`,{className:`py-4`,children:`No projects to compare yet.`})]}),(0,R.jsx)(z,{rows:m.projects.flatMap(({projectId:e,...t})=>Object.entries(t).map(([t,n])=>({section:`portfolio`,entity:e,metric:t,value:m.coverage.projects.find(t=>t.projectId===e)?.state===`unavailable`?null:n,unit:t===`medianCycleHours`?`hours`:`tasks`,asOf:m.asOf,note:`Outcomes since ${m.windowStart}; running and needsYou are current state`})))})]})})}),(0,R.jsx)(le,{open:!!u,onOpenChange:e=>{e||d(null)},children:(0,R.jsxs)(ce,{...f,className:`w-full overflow-y-auto sm:max-w-xl`,onCloseAutoFocus:e=>{e.preventDefault(),o.restore()},children:[(0,R.jsxs)(ae,{children:[(0,R.jsxs)(se,{children:[u?tn[u.group]:`Tasks`,u?.projectId?` · ${u.projectId}`:``]}),(0,R.jsx)(oe,{children:`Tasks behind the selected metric. Includes subtasks. Snapshot keeps counts and rows consistent.`})]}),u&&(0,R.jsx)(on,{selection:u,projectName:c,refresh:()=>{d(null),l.refetch()}},u.identity)]})})]})}function on({selection:e,refresh:t,projectName:n}){let[r,i]=X(`outcome:${e.identity}:offset`,0),a=en({period:e.snapshot.period,snapshotId:e.snapshot.snapshotId,group:e.group,projectId:e.projectId,offset:r}),o=(0,L.useRef)(null),s=(0,L.useRef)(null);(0,L.useEffect)(()=>{a.data&&s.current===r&&(o.current?.focus(),s.current=null)},[a.data,r]);let c=e=>{s.current=e,i(e)};return(0,R.jsxs)(`div`,{className:`space-y-3 p-4`,"data-sheet-loading":a.isFetching,children:[a.isPending&&(0,R.jsx)(`p`,{children:`Loading tasks…`}),a.isError&&(0,R.jsxs)(`p`,{role:`alert`,children:[`This snapshot may have expired or become unavailable.`,` `,(0,R.jsx)(P,{onClick:t,children:`Refresh overview`})]}),a.data&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`p`,{ref:o,tabIndex:-1,className:`text-label text-muted-foreground`,children:[a.data.page.total,` tasks · Snapshot from`,` `,(0,R.jsxs)(ft,{at:a.data.asOf,children:[F(a.data.asOf),` ago`]})]}),a.data.page.rows.map(t=>(0,R.jsx)(sn,{row:t,group:e.group,projectName:n},`${t.projectId}:${t.id}`)),!a.data.page.rows.length&&(0,R.jsx)(`p`,{children:`No tasks in this group.`})]}),(0,R.jsxs)(`div`,{className:`flex gap-2`,children:[(0,R.jsx)(P,{variant:`outline`,disabled:!r||a.isFetching,onClick:()=>c(Math.max(0,r-20)),children:`Previous`}),(0,R.jsx)(P,{variant:`outline`,disabled:!a.data||a.data.page.nextOffset===null||a.isFetching,onClick:()=>c(a.data.page.nextOffset),children:`Next`})]})]})}function sn({row:e,group:t,projectName:n}){let r=M(e),a=t===`running`||t===`needs-you`;a&&r&&(e={...e,...r});let o=r===null,s=a&&(e.archived||(t===`running`?e.status!==`running`:!f(e))),c=o||s,l=i(e),u=a&&o?`Task removed`:s?t===`running`?`No longer running`:`No longer needs you`:l.label;return(0,R.jsxs)(`div`,{className:`border-b py-3`,children:[(0,R.jsx)(E,{"aria-disabled":c||void 0,tabIndex:c?-1:void 0,onClick:e=>{c&&e.preventDefault()},className:`block min-h-11 font-medium hover:underline`,to:`/p/${encodeURIComponent(e.projectId)}/tasks/${encodeURIComponent(e.id)}`,children:e.titleSummary||e.title}),(0,R.jsxs)(`p`,{className:`text-label text-muted-foreground`,children:[(0,R.jsx)(I,{tone:l.tone,pulse:l.pulse}),` `,n(e.projectId),` ·`,` `,u,` · `,e.archived?`Archived · `:``,(0,R.jsxs)(ft,{at:e.finishedAt??e.createdAt,children:[e.finishedAt?`Finished`:`Created`,` `,F(e.finishedAt??e.createdAt),` ago`]})]})]})}var cn={snapshot:[...p.dashboard,`snapshot`],feed:e=>[...p.dashboard,`feed`,e],telemetry:[...p.dashboard,`telemetry`]},ln=new Map;async function un(e){let t=k(),n=v.parse(await m(await a.api.v1.workspace.dashboard.$get({},{init:{signal:e}}),`/workspace/dashboard`));return ln.has(n.snapshotId)||ln.set(n.snapshotId,t),ln.size>60&&ln.delete(ln.keys().next().value),D(t,[...n.questions.rows,...n.reviews.rows]),n}async function dn(e,t,n=0,r=20,i){let o=w.parse(await m(await a.api.v1.workspace.dashboard.tasks.$get({query:{snapshotId:e,group:t,offset:String(n),limit:String(r)}},{init:{signal:i}}),`/workspace/dashboard/tasks`)),s=ln.get(e);return s!==void 0&&D(s,o.page.rows),o}function fn(e){return _({queryKey:cn.snapshot,queryFn:({signal:e})=>un(e),enabled:e,staleTime:5e3,refetchOnMount:`always`,refetchInterval:e?15e3:!1,refetchIntervalInBackground:!1,retry:!1})}function pn(e){return _({queryKey:cn.telemetry,enabled:e,staleTime:0,queryFn:async({signal:e})=>{let t=b.parse(await m(await a.api.v1.workspace.dashboard.telemetry.$get({},{init:{signal:e}}),`/workspace/dashboard/telemetry`));return A.seed(t.samples,t.asOf),t}})}function mn(e,t){let n=_({queryKey:cn.feed(e),queryFn:async({signal:t})=>{let n=k(),r=T.parse(await m(await a.api.v1.workspace.dashboard.feed.$get({query:{filter:e}},{init:{signal:t}}),`/workspace/dashboard/feed`));return D(n,r.rows.flatMap(e=>e.kind===`task-result`?[e.run]:[])),r},enabled:t,staleTime:15e3,refetchInterval:t&&e!==`github`?15e3:!1,retry:!1}),r=(0,L.useRef)(!1);return(0,L.useEffect)(()=>{r.current=!1},[e,t]),(0,L.useEffect)(()=>{if(!t||r.current||!n.data?.sources.some(e=>e.reason===`Still loading GitHub`))return;let e=setTimeout(()=>{document.visibilityState!==`hidden`&&(r.current=!0,n.refetch())},5e3);return()=>clearTimeout(e)},[t,n.data,n.refetch]),n}function hn(e,t){let n=mn(`tasks`,t&&e!==`github`),r=mn(`github`,t&&e!==`tasks`),i=(0,L.useMemo)(()=>{if(e===`tasks`)return n.data;if(e===`github`)return r.data;let t=n.data,i=r.data;if(!t&&!i)return;let a=t??i,o=new Date(Math.max(Date.parse(t?.asOf??a.asOf),Date.parse(i?.asOf??a.asOf))).toISOString(),s=new Date(Date.parse(o)-10080*60*1e3).toISOString(),c=[...t?.rows??[],...i?.rows??[]].filter(e=>Date.parse(e.at)>=Date.parse(s)&&Date.parse(e.at)<=Date.parse(o)).sort((e,t)=>gn(e,t)),l=new Set(c.slice(60).map(e=>e.kind===`task-result`?`tasks:${e.run.projectId}`:e.key.slice(0,e.key.lastIndexOf(`:`)))),u=[...t?.sources??[],...i?.sources??[]].map(e=>l.has(e.key)?{...e,truncated:!0}:e);return{...a,asOf:o,windowStart:s,filter:`all`,rows:c.slice(0,60),sources:u,coverage:t?.coverage??a.coverage,truncated:c.length>60||!!t?.truncated||!!i?.truncated}},[e,n.data,r.data]),a=e===`github`?r:n;return{...a,data:i,githubError:r.isError,githubFetching:r.isFetching,retryTasks:()=>n.refetch(),retryFailed:()=>e===`github`?r.refetch():e===`tasks`?n.refetch():Promise.all([...n.isError?[n.refetch()]:[],...r.isError?[r.refetch()]:[]]),isPending:!i&&a.isPending,isError:a.isError||e===`all`&&r.isError,isFetching:a.isFetching||e===`all`&&r.isFetching,refetch:()=>e===`tasks`?n.refetch():r.refetch()}}function gn(e,t){return Date.parse(t.at)-Date.parse(e.at)||e.key.localeCompare(t.key)}var _n=[...p.dashboard,`costs`];function vn(){let e=0,t=0,n,r=new Set;return{subscribe:e=>(r.add(e),()=>{r.delete(e)}),getSnapshot:()=>n,async read(i,a){let o=++e,s=await Cn(i,a);return!a?.aborted&&o>t&&(t=o,(n?.cost!==s.visibility.cost||n?.tokens!==s.visibility.tokens)&&(n=s.visibility,r.forEach(e=>e()))),s}}}var yn=new WeakMap;function bn(e){let t=yn.get(e);return t||(t=vn(),yn.set(e,t)),t}function xn(){let e=bn(g());return(0,L.useSyncExternalStore)(e.subscribe,e.getSnapshot,e.getSnapshot)}var Sn=new Map;async function Cn(e,t){let n=k(),r=x.parse(await m(await a.api.v1.workspace.dashboard.costs.$get({query:{...e,offset:String(e.offset??0),limit:`20`}},{init:{signal:t}}),`/workspace/dashboard/costs`));!e.snapshotId&&!Sn.has(r.snapshotId)&&Sn.set(r.snapshotId,n),Sn.size>60&&Sn.delete(Sn.keys().next().value);let i=Sn.get(r.snapshotId);return i!==void 0&&D(i,r.tasks.rows),r}function wn(e,t,n){let r=bn(g());return _({queryKey:[..._n,e,t,n],queryFn:({signal:n})=>r.read({period:e,sort:t,tzOffsetMinutes:new Date().getTimezoneOffset()},n),staleTime:5e3,refetchOnMount:`always`,refetchInterval:15e3,refetchIntervalInBackground:!1,retry:!1})}function Tn(e,t,n,r){let i=bn(g());return _({queryKey:[..._n,`tasks`,e.snapshotId,t,n,r,e.visibility],retry:!1,queryFn:async({signal:a})=>{let o=e.tzOffsetMinutes??new Date().getTimezoneOffset(),s=async s=>{let c=await i.read({period:e.period,sort:n,snapshotId:s,projectId:t,tzOffsetMinutes:o},a),l=[...c.tasks.rows];for(;c.tasks.nextOffset!==null&&l.length<r;)c=await i.read({period:e.period,sort:n,snapshotId:c.snapshotId,projectId:t,offset:c.tasks.nextOffset},a),l.push(...c.tasks.rows);return{...c,tasks:{...c.tasks,rows:l}}};try{return await s(e.snapshotId)}catch(e){if(e instanceof d&&e.status===409)return s();throw e}}})}var En={cost:{text:`text-violet`,fill:`bg-violet`,tint:U.violet,icon:Ye},input:{text:`text-violet`,fill:`bg-violet/70`,tint:U.violet,icon:et},output:{text:`text-violet`,fill:`bg-violet/40`,tint:U.violet,icon:fe}};function Dn({metric:e,label:t,value:n,reported:r,total:i}){let a=En[e],o=a.icon,s=i?Math.min(100,r/i*100):0;return(0,R.jsxs)(`div`,{className:`${ut} ${a.tint}`,children:[(0,R.jsxs)(dt,{label:t,value:n,icon:(0,R.jsx)(o,{className:`size-4 ${a.text}`}),children:[r,` of `,i,` tasks report this metric`]}),(0,R.jsx)(`div`,{className:`mt-2 h-1.5 overflow-hidden rounded-full bg-muted`,"aria-hidden":`true`,children:(0,R.jsx)(`div`,{className:`h-full rounded-full ${a.fill} transition-[width] duration-300 motion-reduce:transition-none`,style:{width:`${s}%`}})})]})}function On({projects:e,currentProjects:t,metric:n,field:r,label:i,format:a,onSelect:o}){let s=e.reduce((e,t)=>Math.max(e,t[r]?.value??0),0),c=En[n];return(0,R.jsxs)(Ve,{delayDuration:150,children:[(0,R.jsxs)(`div`,{className:`space-y-1 rounded-xl border p-2`,"aria-label":`Projects ranked by ${i}`,children:[e.length===0&&(0,R.jsx)(`p`,{className:`px-3 py-4 text-muted-foreground`,children:`No projects to compare in this cohort.`}),e.slice(0,5).map((e,n)=>{let l=e[r],u=l?.value,d=u==null||s===0?0:u/s*100,f=u!=null;return(0,R.jsxs)(He,{children:[(0,R.jsx)(Be,{asChild:!0,children:(0,R.jsxs)(`button`,{"data-export-row":!0,"data-export-keep":!0,className:`group w-full rounded-lg px-3 py-3 text-left transition-colors hover:bg-muted/60 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:opacity-50 motion-reduce:transition-none`,disabled:!t.some(t=>t.projectId===e.projectId),onClick:()=>o(e.projectId),children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,R.jsx)(`span`,{className:`w-4 shrink-0 text-label tabular-nums text-muted-foreground`,"aria-hidden":`true`,children:n+1}),(0,R.jsx)(`span`,{className:`min-w-0 flex-1 break-words font-medium`,children:e.projectId}),(0,R.jsx)(`span`,{className:`shrink-0 font-semibold tabular-nums`,children:a(u)}),(0,R.jsx)(ge,{"data-export-exclude":!0,className:`size-4 shrink-0 text-muted-foreground`,"aria-hidden":`true`})]}),(0,R.jsx)(`div`,{className:`mt-2 ml-7 h-2 overflow-hidden rounded-full bg-muted`,"aria-hidden":`true`,children:(0,R.jsx)(`div`,{"data-project-bar":e.projectId,className:`h-full rounded-full ${c.fill} transition-[width] duration-300 motion-reduce:transition-none`,style:{width:`${d}%`}})}),(0,R.jsxs)(`p`,{className:`mt-1.5 ml-7 text-label text-muted-foreground`,children:[l?.reportedTasks??0,` of `,e.tasks,` tasks report this metric`,f?``:` · No measured value`]})]})}),(0,R.jsxs)(Ue,{className:`max-w-64`,children:[(0,R.jsxs)(`p`,{className:`font-medium`,children:[e.projectId,` · `,i,`: `,a(u)]}),(0,R.jsxs)(`p`,{children:[l?.reportedTasks??0,` of `,e.tasks,` tasks report this metric.`]}),(0,R.jsx)(`p`,{children:`Open project tasks`})]})]},e.projectId)})]}),e.length>0&&(0,R.jsxs)(`p`,{className:`mt-2 text-label text-muted-foreground`,children:[e.length>5?`Top 5 of ${e.length} projects. `:``,`Bar lengths compare reported values; the largest is the reference.`]})]})}var Z={cost:`costUsd`,input:`inputTokens`,output:`outputTokens`},kn={cost:`Reported USD`,input:`Input tokens`,output:`Output tokens`};function An(e,t){return JSON.stringify([e.totals,e.projects,e.tasks,e.visibility,e.coverage,e.invalidDateTasks])!==JSON.stringify([t.totals,t.projects,t.tasks,t.visibility,t.coverage,t.invalidDateTasks])}var jn=(e,t)=>Dt(e,t===`cost`);function Q(e){return[...e.cost?[`cost`]:[],...e.tokens?[`input`,`output`]:[]]}function Mn({value:e,onChange:t,visibility:n}){return(0,R.jsx)(ct,{label:`Sort by`,value:e,onValueChange:t,options:Q(n).map(e=>({value:e,label:kn[e]}))})}var Nn=[{value:`all`,label:`All time`},{value:`7d`,label:`Last 7 days`},{value:`30d`,label:`Last 30 days`}];function Pn(){return(0,R.jsx)(Fn,{visibility:Ke(o().data)})}function Fn({visibility:e}){return(0,R.jsxs)(N,{className:`gap-0 py-0`,children:[(0,R.jsx)(`div`,{className:V,children:(0,R.jsx)(`h2`,{className:B,children:`Usage & cost`})}),!e.cost&&!e.tokens?(0,R.jsx)(`p`,{className:`p-4 text-sm`,children:`Usage metrics are hidden by workspace settings`}):(0,R.jsx)(In,{visibility:e},`${e.cost}:${e.tokens}`)]})}function In({visibility:e}){let[t,n]=Ot(`usagePeriod`,[`all`,`7d`,`30d`],`all`),[r,i]=Ot(`usageSort`,Q(e),e.cost?`cost`:`input`);return(0,R.jsx)(Ln,{period:t,setPeriod:n,sort:r,setSort:i,visibility:e})}function Ln({period:e,setPeriod:t,sort:n,setSort:r,visibility:i}){let a=wn(e,n,`${i.cost}:${i.tokens}`),[o,s]=X(`usage:accepted`,void 0),c=o??a.data,l=a.data??c,[u,d]=X(`usage:panel`,null),[f,p]=(0,L.useState)(e);f!==e&&(p(e),s(void 0),d(null));let m=Qt(`usage:${u?.identity??`closed`}`),h=$t(`usage`,`[data-usage-trigger]`),g=e=>{h.capture(),c&&d({identity:Yt(),projectId:e,snapshot:c,latestId:l?.snapshotId??c.snapshotId})},_=xn()??i,v={cost:i.cost&&_.cost,tokens:i.tokens&&_.tokens},y=Q(v).includes(n)?n:Q(v)[0]??`cost`,b=[...c?.projects??[]].sort((e,t)=>{let n=e[Z[y]]?.value,r=t[Z[y]]?.value;return(n==null?r==null?0:1:r==null?-1:r-n)||e.projectId.localeCompare(t.projectId)});!o&&a.data&&s(a.data);let x=c&&l&&An(c,l),S=c?.coverage.projects.some(e=>e.state!==`complete`),C=l?.coverage.projects.some(e=>e.state!==`complete`),w=JSON.stringify(c?.coverage)!==JSON.stringify(l?.coverage),T=c?.totals.tasks===0&&!S&&!C;return(0,R.jsxs)(`div`,{className:`space-y-4 p-4 text-sm`,children:[c&&(0,R.jsx)(z,{rows:T?[]:[...Q(v).map(e=>({section:`totals`,metric:Z[e],value:c.totals[Z[e]]?.value??null,unit:e===`cost`?`USD`:`tokens`,reportedTasks:c.totals[Z[e]]?.reportedTasks??0,totalTasks:c.totals.tasks,asOf:c.asOf})),...(v.cost||v.tokens?b.slice(0,5):[]).map(e=>({section:`project`,entity:e.projectId,metric:Z[y],value:e[Z[y]]?.value??null,unit:y===`cost`?`USD`:`tokens`,reportedTasks:e[Z[y]]?.reportedTasks??0,totalTasks:e.tasks,asOf:c.asOf}))]}),c&&(0,R.jsx)(`p`,{className:`text-label text-muted-foreground`,children:(0,R.jsx)(pt,{at:c.asOf})}),(0,R.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`h3`,{className:`font-medium`,children:`Lifetime totals of retained tasks`}),(0,R.jsxs)(`details`,{className:`mt-1 text-label text-muted-foreground`,children:[(0,R.jsxs)(`summary`,{"data-export-heading":`Metric definitions`,className:`${ot} min-h-11`,children:[(0,R.jsx)(H,{}),`How these metrics work`]}),(0,R.jsxs)(`p`,{children:[`Includes archived tasks and subtasks.`,` `,v.cost&&`Reported USD is not an invoice. `,`Missing reports are excluded, not treated as zero. Calendar days use your current UTC offset, including today.`]})]})]}),(0,R.jsx)(ct,{label:`Tasks created`,value:e,onValueChange:t,options:Nn})]}),e!==`all`&&(0,R.jsx)(`p`,{className:`text-muted-foreground`,children:`Lifetime usage of tasks created in this period — not spending during the period.`}),a.isPending&&(0,R.jsx)(`p`,{children:`Loading usage…`}),a.isError&&(0,R.jsxs)(`p`,{role:`alert`,children:[c?`Showing stale usage. Could not refresh.`:`Could not load usage.`,` `,(0,R.jsx)(P,{className:`min-h-11`,onClick:()=>void a.refetch(),children:`Retry`})]}),x&&(0,R.jsx)(`p`,{role:`status`,children:`Newer usage data is available; displayed values use the previous snapshot.`}),x&&(0,R.jsx)(P,{className:`min-h-11`,variant:`outline`,onClick:()=>s(l),children:`Updates available — Show`}),c&&S&&(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`p`,{className:`text-muted-foreground`,children:`Coverage of displayed usage:`}),(0,R.jsx)(K,{coverage:c.coverage,retry:()=>void a.refetch()})]}),l&&C&&w&&(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`p`,{className:`text-muted-foreground`,children:`Current source availability:`}),(0,R.jsx)(K,{coverage:l.coverage,retry:()=>void a.refetch()})]}),c&&(0,R.jsxs)(R.Fragment,{children:[!T&&(0,R.jsx)(`div`,{className:`report-cost-metrics grid gap-3 sm:grid-cols-[repeat(auto-fit,minmax(220px,1fr))]`,children:Q(v).map(e=>(0,R.jsx)(Dn,{metric:e,label:kn[e],value:jn(c.totals[Z[e]]?.value,e),reported:c.totals[Z[e]]?.reportedTasks??0,total:c.totals.tasks},e))}),!v.cost&&!v.tokens&&(0,R.jsx)(`p`,{children:`Usage metrics are hidden by workspace settings`}),c.totals.tasks===0?(0,R.jsx)(`p`,{children:S||C?`No retained tasks could be read from available sources.`:`No retained tasks in this cohort.`}):Q(v).every(e=>!c.totals[Z[e]]?.reportedTasks)&&(0,R.jsx)(`p`,{children:`No reports for the visible metrics in this cohort.`}),T&&(0,R.jsx)(`p`,{className:`text-muted-foreground`,children:`Usage appears when tasks report cost or tokens.`}),(0,R.jsxs)(`p`,{className:`text-muted-foreground`,children:[`Deleted tasks are excluded from retained history.`,c.invalidDateTasks?` ${c.invalidDateTasks} tasks have missing or invalid creation dates${e===`all`?`; included in All time`:`; excluded from this period`}.`:``]}),!T&&(v.cost||v.tokens)&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`h3`,{className:`font-medium`,children:`Top projects`}),(0,R.jsx)(`p`,{className:`text-muted-foreground`,children:`Ranking uses reported metrics only.`})]}),(0,R.jsx)(Mn,{value:y,onChange:r,visibility:v})]}),(0,R.jsx)(On,{projects:b,metric:y,label:kn[y],field:Z[y],format:e=>jn(e,y),currentProjects:l?.projects??[],onSelect:g}),(0,R.jsx)(P,{"data-usage-trigger":!0,className:`min-h-11`,variant:`outline`,onClick:()=>g(``),children:`View tasks`})]})]}),(0,R.jsx)(le,{open:u!==null&&(v.cost||v.tokens),onOpenChange:e=>{e||d(null)},children:(0,R.jsxs)(ce,{...m,className:`w-full overflow-y-auto sm:max-w-xl`,onCloseAutoFocus:e=>{e.preventDefault(),h.restore()},children:[(0,R.jsxs)(ae,{children:[(0,R.jsx)(se,{children:u?.projectId?`${u.projectId} tasks`:`All tasks`}),(0,R.jsx)(oe,{children:`Lifetime usage of retained tasks. Missing reports are unavailable.`})]}),u!==null&&(0,R.jsx)(Rn,{identity:`usage:${u.identity}`,snapshot:l&&l.snapshotId!==u.latestId?l:u.snapshot,projectId:u.projectId||void 0,visibility:v},u.identity)]})})]})}function Rn({identity:e,snapshot:t,projectId:n,visibility:r}){let[i,a]=X(`${e}:sort`,t.sort);return(0,R.jsx)(zn,{identity:e,snapshot:t,projectId:n,visibility:r,sort:Q(r).includes(i)?i:Q(r)[0]??`cost`,setSort:a})}function zn({identity:e,snapshot:t,projectId:n,visibility:r,sort:i,setSort:a}){let[o,s]=X(`${e}:count`,20),[c,l]=X(`${e}:paging`,void 0),[u,d]=(0,L.useState)(t.snapshotId);u!==t.snapshotId&&(d(t.snapshotId),l(void 0));let f=Tn(c??t,n,i,o),p=xn()??r,m={cost:r.cost&&p.cost,tokens:r.tokens&&p.tokens},h=Q(m).includes(i)?i:Q(m)[0]??`cost`,[g,_]=X(`${e}:accepted`,void 0),[v,y]=X(`${e}:acceptedCount`,o),[b,x]=X(`${e}:acceptedSort`,i),[S,C]=(0,L.useState)(i);S!==i&&(C(i),s(20),l(g??c??t)),f.data&&(!g||(v!==o||b!==i)&&g.snapshotId===f.data.snapshotId)&&(_(f.data),y(o),x(i));let w=g??f.data,T=f.data&&w&&An(f.data,w),ee=w?.coverage.projects.some(e=>e.state!==`complete`),te=f.data?.coverage.projects.some(e=>e.state!==`complete`),E=JSON.stringify(w?.coverage)!==JSON.stringify(f.data?.coverage),ne=!n||t.projects.some(e=>e.projectId===n);return(0,R.jsxs)(`div`,{className:`space-y-3 p-4 text-sm`,"data-sheet-loading":f.isFetching,children:[(0,R.jsx)(Mn,{value:h,onChange:a,visibility:m}),f.isPending&&(0,R.jsx)(`p`,{children:`Loading tasks…`}),f.isError&&(0,R.jsxs)(`p`,{role:`alert`,children:[`Could not refresh tasks. `,w?`Showing stale usage.`:``,` `,(0,R.jsx)(P,{className:`min-h-11`,onClick:()=>void f.refetch(),children:`Retry`})]}),T&&(0,R.jsx)(P,{className:`min-h-11`,onClick:()=>{_(f.data),y(o),x(i)},children:`Updates available — Show`}),w&&ee&&(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`p`,{className:`text-muted-foreground`,children:`Coverage of displayed tasks:`}),(0,R.jsx)(K,{coverage:w.coverage,retry:()=>void f.refetch()})]}),f.data&&te&&E&&(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`p`,{className:`text-muted-foreground`,children:`Current source availability:`}),(0,R.jsx)(K,{coverage:f.data.coverage,retry:()=>void f.refetch()})]}),w&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`p`,{className:`border-b pb-2 text-label text-muted-foreground tabular-nums`,children:[w.tasks.rows.length,` of `,w.tasks.total,` retained tasks`]}),w.tasks.total===0&&(0,R.jsx)(`p`,{children:w.coverage.projects.some(e=>e.state!==`complete`)?`No tasks could be read from available sources.`:`No retained tasks in this cohort.`}),w.tasks.rows.map(e=>(0,R.jsx)(Bn,{row:e,sort:h,visibility:m,disabled:!ne||!f.data||!!(T&&!f.data?.tasks.rows.some(t=>t.id===e.id&&t.projectId===e.projectId))},`${e.projectId}:${e.id}`)),w.tasks.nextOffset!==null&&(0,R.jsx)(P,{className:`min-h-11`,disabled:f.isFetching,onClick:()=>{l(w),s(e=>e+20)},children:`Show 20 more tasks`})]})]})}function Bn({row:e,sort:t,visibility:n,disabled:r}){let a=M(e);r||=a===null;let o=i(a?{status:a.status,awaitingAnswerSince:a.awaitingAnswerSince,idleClosedAt:a.idleClosedAt}:e),s=Q(n).filter(e=>e!==t),c=t=>{let n=e[Z[t]];return n==null?`—`:jn(n,t)},l=t=>`${kn[t]}: ${jn(e[Z[t]],t)}`;return(0,R.jsxs)(`div`,{className:`grid grid-cols-[minmax(0,1fr)_auto] items-start gap-x-4 border-b py-3 last:border-0`,children:[(0,R.jsxs)(`div`,{className:`min-w-0`,children:[(0,R.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,R.jsx)(I,{tone:o.tone,pulse:o.pulse,className:`mt-[7px]`}),(0,R.jsx)(We,{label:e.title,children:(0,R.jsx)(E,{className:`line-clamp-2 break-words font-medium leading-snug hover:underline no-hover:min-h-11`,to:`/p/${encodeURIComponent(e.projectId)}/tasks/${encodeURIComponent(e.id)}`,"aria-disabled":r||void 0,tabIndex:r?-1:void 0,onClick:e=>{r&&e.preventDefault()},children:e.title})})]}),(0,R.jsxs)(`p`,{className:`mt-1 pl-[15px] text-label text-muted-foreground`,children:[(0,R.jsx)(`span`,{className:`font-mono text-meta`,children:e.projectId}),` ·`,` `,r?`Checking current state…`:o.label,e.archived?` · Archived`:``,e.subtask?` · Subtask`:``]})]}),(0,R.jsxs)(`div`,{className:`text-right tabular-nums`,children:[(0,R.jsx)(`span`,{"aria-label":l(t),className:`block font-semibold ${e[Z[t]]==null?`text-soft-foreground`:``}`,children:c(t)}),s.length>0&&(0,R.jsx)(`span`,{className:`mt-1 flex justify-end gap-3 text-label text-muted-foreground tabular-nums`,children:s.map(e=>(0,R.jsxs)(`span`,{"aria-label":l(e),children:[c(e),` `,e===`cost`?``:e===`input`?`in`:`out`]},e))})]})]})}var Vn={cost:`costUsd`,input:`inputTokens`,output:`outputTokens`},Hn={cost:`Reported USD`,input:`Input tokens`,output:`Output tokens`};function Un(e){return[...e.cost?[`cost`]:[],...e.tokens?[`input`,`output`]:[]]}var Wn=(e,t)=>Dt(e,t===`cost`);function Gn(e){return new Date(`${e}T00:00:00`).toLocaleDateString(void 0,{month:`short`,day:`numeric`})}function Kn({series:e,height:t,accent:n,renderTooltip:r,describe:i}){let a=Math.max(1,...e.map(t));return(0,R.jsxs)(Ve,{delayDuration:150,children:[(0,R.jsx)(`div`,{className:`flex h-20 items-end gap-0.5`,role:`group`,"aria-label":`Daily trend`,children:e.map(e=>{let o=t(e),s=Math.max(o>0?4:0,o/a*100);return(0,R.jsxs)(He,{children:[(0,R.jsx)(Be,{asChild:!0,children:(0,R.jsx)(`button`,{"data-export-keep":!0,"aria-label":i(e),type:`button`,className:`min-w-0 flex-1 rounded-t-sm transition-opacity hover:opacity-80 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`,style:{height:`100%`,display:`flex`,alignItems:`end`},children:(0,R.jsx)(`span`,{style:{height:`${s}%`},className:`block w-full rounded-t-sm ${n}`})})}),(0,R.jsx)(Ue,{children:r(e)})]},e.date)})}),(0,R.jsxs)(`div`,{className:`mt-1 flex justify-between text-label text-muted-foreground`,children:[(0,R.jsx)(`span`,{children:Gn(e[0].date)}),(0,R.jsx)(`span`,{children:Gn(e.at(-1).date)})]})]})}function qn({metrics:e,series:t}){return(0,R.jsxs)(`table`,{className:`w-full text-left text-xs`,children:[(0,R.jsx)(`thead`,{children:(0,R.jsxs)(`tr`,{className:`border-b`,children:[(0,R.jsx)(`th`,{className:`py-1 pr-2 font-medium`,children:`Date`}),e.map(e=>(0,R.jsx)(`th`,{className:`py-1 pr-2 text-right font-medium`,children:Hn[e]},e)),(0,R.jsx)(`th`,{className:`py-1 pr-2 text-right font-medium`,children:`Completed`}),(0,R.jsx)(`th`,{className:`py-1 text-right font-medium`,children:`Avg cycle`})]})}),(0,R.jsx)(`tbody`,{children:t.map(t=>(0,R.jsxs)(`tr`,{className:`border-b last:border-0`,children:[(0,R.jsx)(`td`,{className:`py-1 pr-2`,children:Gn(t.date)}),e.map(e=>(0,R.jsx)(`td`,{className:`py-1 pr-2 text-right tabular-nums`,children:Wn(t[Vn[e]]?.value,e)},e)),(0,R.jsx)(`td`,{className:`py-1 pr-2 text-right tabular-nums`,children:t.completed}),(0,R.jsx)(`td`,{className:`py-1 text-right tabular-nums`,children:t.avgCycleHours===null?`—`:q(t.avgCycleHours)})]},t.date))})]})}function Jn({metric:e,series:t}){let n=En[e],r=Vn[e],i=t.reduce((e,t)=>e+(t[r]?.reportedTasks??0),0);return(0,R.jsxs)(`div`,{className:`rounded-xl border p-3`,children:[(0,R.jsx)(`p`,{className:`text-label font-medium ${n.text}`,children:Hn[e]}),(0,R.jsx)(`div`,{className:`mt-2`,children:(0,R.jsx)(Kn,{series:t,describe:t=>`${t.date}, ${Hn[e]}: ${Wn(t[r]?.value,e)}, ${t[r]?.reportedTasks??0} of ${t.tasks} tasks reported`,height:e=>e[r]?.value??0,accent:n.fill,renderTooltip:t=>(0,R.jsxs)(`p`,{children:[Gn(t.date),` · `,Wn(t[r]?.value,e),` ·`,` `,t[r]?.reportedTasks??0,`/`,t.tasks,` tasks reported`]})})}),i===0&&(0,R.jsx)(`p`,{className:`mt-2 text-label text-muted-foreground`,children:`No reports in this period.`})]})}function Yn({series:e}){let t=e.reduce((e,t)=>e+t.completed,0),n=e.reduce((e,t)=>e+(t.avgCycleHours??0)*(t.cycleReportedTasks??t.completed),0),r=e.reduce((e,t)=>e+(t.cycleReportedTasks??t.completed),0),i=r?n/r:null;return(0,R.jsxs)(`div`,{className:`rounded-xl border p-3`,children:[(0,R.jsxs)(`div`,{className:`flex flex-wrap items-baseline justify-between gap-2`,children:[(0,R.jsx)(`p`,{className:`text-label font-medium text-success`,children:`Completed tasks`}),(0,R.jsxs)(`p`,{className:`text-label text-muted-foreground`,children:[t,` done · avg cycle`,` `,i===null?`unavailable`:q(i)]})]}),(0,R.jsxs)(`p`,{className:`text-label text-muted-foreground`,children:[r,`/`,t,` completed tasks have valid cycle times.`]}),(0,R.jsx)(`div`,{className:`mt-2`,children:(0,R.jsx)(Kn,{series:e,describe:e=>`${e.date}: ${e.completed} completed tasks, average cycle ${e.avgCycleHours==null?`Unavailable`:q(e.avgCycleHours)}`,height:e=>e.completed,accent:`bg-success`,renderTooltip:e=>(0,R.jsxs)(`div`,{children:[(0,R.jsxs)(`p`,{children:[Gn(e.date),` · `,e.completed,` completed`]}),(0,R.jsxs)(`p`,{children:[`Avg cycle`,` `,e.avgCycleHours===null?`unavailable`:q(e.avgCycleHours),` · Median`,` `,e.medianCycleHours===null?`unavailable`:q(e.medianCycleHours)]})]})})}),t===0&&(0,R.jsx)(`p`,{className:`mt-2 text-label text-muted-foreground`,children:`No tasks finished in this period.`})]})}function Xn(){return(0,R.jsx)(Zn,{visibility:Ke(o().data)})}function Zn({visibility:e}){let[t,n]=Ot(`trendPeriod`,[`7d`,`30d`],`7d`),r=wn(t,e.cost?`cost`:`input`,`${e.cost}:${e.tokens}`),i=r.data,a=i&&i.totals.tasks===0&&i.coverage.projects.every(e=>e.state===`complete`)&&i.series.every(e=>e.tasks===0&&e.completed===0),o=Un({cost:e.cost&&i?.visibility.cost!==!1,tokens:e.tokens&&i?.visibility.tokens!==!1});return(0,R.jsxs)(N,{className:`gap-0 py-0`,children:[(0,R.jsxs)(`div`,{className:V,children:[(0,R.jsx)(`h2`,{className:B,children:`Trends`}),(0,R.jsx)(ct,{label:`Period`,value:t,onValueChange:n,options:lt})]}),(0,R.jsxs)(`div`,{className:`space-y-4 p-4 text-sm`,children:[i&&(0,R.jsx)(z,{rows:a?[]:i.series.flatMap(e=>[...o.map(t=>({section:`daily-creation-cohort`,entity:e.date,metric:Vn[t],value:e[Vn[t]]?.value??null,unit:t===`cost`?`USD`:`tokens`,reportedTasks:e[Vn[t]]?.reportedTasks??0,totalTasks:e.tasks,asOf:i.asOf,note:`Lifetime usage grouped by task creation date; not daily spend`})),{section:`daily-completions`,entity:e.date,metric:`completed`,value:e.completed,unit:`tasks`,asOf:i.asOf},{section:`daily-completions`,entity:e.date,metric:`avgCycleHours`,value:e.avgCycleHours,reportedTasks:e.cycleReportedTasks??e.completed,totalTasks:e.completed,unit:`hours`,asOf:i.asOf},{section:`daily-completions`,entity:e.date,metric:`medianCycleHours`,value:e.medianCycleHours,unit:`hours`,asOf:i.asOf}])}),(0,R.jsxs)(`details`,{className:`text-label text-muted-foreground`,children:[(0,R.jsxs)(`summary`,{"data-export-heading":`Metric definitions`,className:`${ot} py-2`,children:[(0,R.jsx)(H,{}),`How these metrics work`]}),(0,R.jsx)(`p`,{children:`Usage is grouped by creation date, not spending date. Completed tasks are grouped by finish date. Calendar days use your current UTC offset (fixed across the period), including today.`})]}),r.isPending&&(0,R.jsx)(`p`,{children:`Loading trends…`}),r.isError&&(0,R.jsxs)(`p`,{role:`alert`,children:[i?`Showing stale trends. Could not refresh.`:`Could not load trends.`,` `,(0,R.jsx)(P,{className:`min-h-11`,onClick:()=>void r.refetch(),children:`Retry`})]}),i&&(0,R.jsx)(`p`,{className:`text-label text-muted-foreground`,children:(0,R.jsx)(pt,{at:i.asOf})}),i&&(0,R.jsx)(K,{coverage:i.coverage,retry:()=>void r.refetch()}),i&&a&&(0,R.jsx)(`p`,{className:`text-muted-foreground`,children:`No retained tasks in this period yet.`}),i&&!a&&i.series.length>0&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`div`,{className:`space-y-4`,children:[o.length>0&&(0,R.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-[repeat(auto-fit,minmax(200px,1fr))]`,children:o.map(e=>(0,R.jsx)(Jn,{metric:e,series:i.series},e))}),(0,R.jsx)(Yn,{series:i.series})]}),(0,R.jsxs)(`details`,{className:`group rounded-lg border bg-muted/20 print:block`,children:[(0,R.jsxs)(`summary`,{"data-export-heading":`Daily data`,className:`flex min-h-11 cursor-pointer list-none items-center gap-2 px-3 text-label font-medium text-muted-foreground hover:text-foreground [&::-webkit-details-marker]:hidden`,children:[(0,R.jsx)(nt,{className:`size-4`,"aria-hidden":`true`}),` View data table`,(0,R.jsx)(_e,{className:`ml-auto size-4 transition-transform group-open:rotate-180`,"aria-hidden":`true`})]}),(0,R.jsx)(`div`,{className:`max-h-80 overflow-auto border-t p-3 print:max-h-none print:overflow-visible`,role:`region`,"aria-label":`Daily trend values`,tabIndex:0,children:(0,R.jsx)(qn,{metrics:o,series:i.series})})]})]})]})]})}function Qn(e,t,n,r=!0){let i=g();return _({queryKey:[...cn.snapshot,e?.snapshotId,t,n],enabled:r&&!!e,retry:!1,queryFn:async({signal:r})=>{if(!e)throw Error(`Dashboard not loaded`);let a=[];try{for(let i=0;i<n;){let o=await dn(e.snapshotId,t,i,Math.min(20,n-i),r);if(a.push(...o.page.rows),o.page.nextOffset===null)break;i=o.page.nextOffset}return a}catch(e){if(e instanceof d&&e.status===409){let e=await un(r);i.setQueryData(cn.snapshot,e)}throw e}}})}function $n(e,t,n,r){let i=g(),a=t===`questions`||t===`reviews`?`needs-you`:t,o=a===`needs-you`?0:n,s=r.map(e=>`${e.projectId}:${e.id}`).sort();return _({queryKey:[...cn.snapshot,e.snapshotId,t,`displaced`,...s],enabled:s.length>0,retry:!1,queryFn:async({signal:t})=>{let n=new Set(s),r=new Map;try{for(let i=o;i!==null&&n.size;){let o=await dn(e.snapshotId,a,i,20,t);for(let e of o.page.rows){let t=`${e.projectId}:${e.id}`;n.delete(t)&&r.set(t,e)}i=o.page.nextOffset}return r}catch(e){throw e instanceof d&&e.status===409&&i.setQueryData(cn.snapshot,await un(t)),e}}})}function er({snapshot:e,questions:t,reviews:n,more:r,healthy:i=!0}){let a=re();return(0,R.jsxs)(N,{className:`min-w-0 gap-0 overflow-hidden py-0`,children:[(0,R.jsxs)(`div`,{className:V,children:[(0,R.jsxs)(`h2`,{id:`dashboard-needs-you`,tabIndex:-1,className:B,children:[`Needs you · `,e.counts.questions+e.counts.reviews]}),(0,R.jsxs)(`p`,{className:`text-label text-muted-foreground tabular-nums`,children:[e.counts.questions,` questions · `,e.counts.reviews,` reviews`]})]}),i&&a.connected&&e.counts.questions+e.counts.reviews===0&&e.coverage.projects.every(e=>e.state===`complete`)?(0,R.jsxs)(`p`,{className:`flex items-center gap-2.5 px-4 py-8 text-sm text-muted-foreground`,children:[(0,R.jsx)(I,{tone:`success`}),`All caught up — no tasks need your input`]}):null,(0,R.jsx)(tr,{snapshot:e,group:`questions`,count:t,more:r}),(0,R.jsx)(tr,{snapshot:e,group:`reviews`,count:n,more:r})]})}function tr({snapshot:e,group:t,count:n,more:r}){let i=e[t],a=Math.max(n,i.rows.length),o=Qn(e,t,a,a>i.rows.length),s=a>i.rows.length?o.data:i.rows,c=yt(s,G,t,n),l=$n(e,t,a,c.rows.filter(e=>e.removed).map(e=>e.row)),u=(0,L.useRef)(null);return!i.total&&!c.rows.length?null:(0,R.jsxs)(`section`,{children:[(0,R.jsxs)(`h3`,{ref:u,tabIndex:-1,className:`border-b bg-card-2 px-4 py-2 eyebrow text-muted-foreground`,children:[t===`questions`?`Questions`:`Reviews`,` · `,i.total]}),c.updates>0&&(0,R.jsxs)(P,{variant:`ghost`,className:`m-2 min-h-11`,onClick:()=>{c.show(),u.current?.focus()},children:[c.updates,` updates — Show`]}),c.rows.map(({row:e,removed:t})=>(0,R.jsx)(Et,{row:l.data?.get(G(e))??e,removed:t&&!!l.data&&!l.data.has(G(e)),checking:s===void 0||t&&!l.data,checkFailed:s===void 0&&o.isError||t&&!l.data&&l.isError,queue:!0},G(e))),(o.isError||l.isError)&&(0,R.jsxs)(`p`,{role:`alert`,className:`p-4 text-sm`,children:[`Could not check current task state.`,` `,(0,R.jsx)(P,{variant:`ghost`,className:`min-h-11`,onClick:()=>{o.refetch(),l.refetch()},children:`Retry`})]}),a<i.total&&(0,R.jsxs)(P,{variant:`ghost`,className:`m-2 min-h-11`,disabled:o.isFetching,onClick:()=>r(t,a+Math.min(20,i.total-a)),children:[`Show `,Math.min(20,i.total-a),` more `,t]})]})}function nr(e){if(!e.startsWith(`github:`))return e===`tasks`?`Task results`:e;let t=e.slice(7).split(`:`),n=t.pop()===`pr`?`Pull requests`:`Issues`;return`${t.join(`:`).replace(/^project:/,`Project `).replace(/^github.com\//,``)} · ${n}`}var rr=e=>e.key;function ir({filter:e,setFilter:t,count:n,more:r}){let i=hn(e,!0),a=yt(i.data?.rows,rr,`feed:${e}`,0,e=>e.kind===`task-result`),o=a.rows,s=a.updates,c=(0,L.useContext)(_t),l=(0,L.useRef)(null),u=`feed:${e}`,d=(0,L.useMemo)(()=>({scroll:wt(c,u)?.scroll??0,done:!1}),[c,u]);(0,L.useLayoutEffect)(()=>{!l.current||d.done||(l.current.scrollTop=d.scroll,d.done=Math.abs(l.current.scrollTop-d.scroll)<1||!!i.data&&!i.isPending&&!i.isFetching)},[d,o.length,n,i.data,i.isPending,i.isFetching]);let f=(0,L.useRef)(null),p=i.data?.sources.filter(e=>e.key.startsWith(`github:`))??[],m=p.flatMap(e=>e.fetchedAt?[e.fetchedAt]:[]).sort()[0],g=i.githubError,_=p.filter(e=>e.reason===`No GitHub remote`),v=p.some(e=>e.reason===`Still loading GitHub`),y=p.length>0&&_.length===p.length&&!g,b=p.filter(e=>e.state!==`ready`&&e.reason!==`No GitHub remote`&&e.reason!==`Still loading GitHub`),x=y&&e===`all`;return(0,R.jsxs)(N,{"data-export-context":`Results source: ${e}; Last 7 days; loaded ${Math.min(n,o.length)} rows`,className:`min-w-0 gap-0 overflow-hidden py-0`,children:[(0,R.jsxs)(`div`,{className:`space-y-2 border-b px-4 pt-2.5 pb-2`,children:[(0,R.jsxs)(`div`,{className:`flex min-h-9 flex-wrap items-center justify-between gap-2`,children:[(0,R.jsx)(`h2`,{ref:f,tabIndex:-1,className:B,children:x?`Recent results`:`Recent results & GitHub`}),(0,R.jsx)(`span`,{className:`text-label text-muted-foreground`,children:`Last 7 days`})]}),!x&&(0,R.jsx)(Ze,{slot:`dashboard-feed`,label:`Results source`,value:e,options:[{value:`all`,label:`All`},{value:`tasks`,label:`Tasks`},{value:`github`,label:`GitHub`}],onChange:t}),x&&(0,R.jsx)(`p`,{className:`text-label text-muted-foreground`,children:`Task results · No GitHub repositories configured`}),e!==`tasks`&&!x&&(0,R.jsxs)(`details`,{className:`text-label text-muted-foreground`,open:b.length||g?!0:void 0,children:[(0,R.jsxs)(`summary`,{className:`flex w-fit cursor-pointer list-none items-center gap-1.5 rounded-sm text-muted-foreground transition-colors select-none hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/50 [&::-webkit-details-marker]:hidden py-1.5`,children:[(0,R.jsx)(H,{}),b.length||g?`GitHub needs attention`:v?`Checking GitHub…`:y?`GitHub not configured`:m?`GitHub checked ${F(m)} ago`:`GitHub source`]}),(0,R.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-x-3`,children:[(0,R.jsx)(`p`,{children:b.length||g?m?`Could not refresh GitHub. Showing results from ${new Date(m).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`})}.`:`Could not load one or more GitHub sources.`:v?`Checking repository sources. Available results remain visible.`:y?`No GitHub repositories configured. Select Tasks to see task results.`:m?`GitHub checked ${F(m)} ago`:`GitHub snapshot`}),!y&&(0,R.jsx)(P,{variant:`ghost`,className:`min-h-11 px-0`,disabled:i.githubFetching,onClick:()=>{i.refetch()},children:i.githubFetching?`Refreshing…`:b.length||g?`Retry GitHub`:`Refresh GitHub`})]})]})]}),(0,R.jsxs)(`div`,{role:`region`,"aria-label":`Recent results list`,ref:l,onWheel:()=>{d.done=!0},onTouchStart:()=>{d.done=!0},onKeyDown:()=>{d.done=!0},onScroll:e=>{c&&d.done&&Tt(c,u,{count:n,scroll:e.currentTarget.scrollTop})},tabIndex:0,className:`max-h-80 overflow-y-auto overscroll-contain focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring`,children:[i.isError&&(0,R.jsxs)(`p`,{role:`alert`,className:`p-4 text-sm`,children:[`Could not load results.`,` `,(0,R.jsx)(P,{className:`min-h-11`,onClick:()=>{i.retryFailed()},children:`Retry`})]}),i.isPending&&(0,R.jsx)(`p`,{className:`p-4 text-sm`,children:`Loading results…`}),s>0&&(0,R.jsxs)(P,{variant:`ghost`,className:`m-2 min-h-11`,onClick:()=>{a.show(),f.current?.focus()},children:[s,` updates — Show`]}),o.slice(0,n).map(({row:e,removed:t})=>e.kind===`task-result`?(0,R.jsx)(Et,{row:e.run,kicker:t?`Outside current results`:`Latest result: ${h(e.run)?`Closed after inactivity`:e.run.status===`failed`?`Failed`:`Completed`}`},e.key):(0,R.jsxs)(`div`,{className:`border-b px-4 py-3 transition-colors hover:bg-muted/30`,children:[(0,R.jsx)(z,{rows:[{section:`github`,entity:`${e.repo}#${e.number}`,metric:e.itemKind,value:e.title,asOf:e.at,note:e.url}]}),(0,R.jsx)(`a`,{className:`block break-words text-sm font-medium hover:underline no-hover:min-h-11`,href:e.url,target:`_blank`,rel:`noreferrer`,children:e.title}),(0,R.jsxs)(`p`,{className:`mt-1 text-label text-muted-foreground`,children:[e.repo,` · `,e.itemKind===`pr`?`PR`:`Issue`,` #`,e.number,` created ·`,` `,F(e.at)]})]},e.key)),i.data&&!i.data.rows.length&&!o.length&&!i.isFetching&&!i.isError&&!b.length&&!v&&i.data.coverage.projects.every(e=>e.state===`complete`)&&(0,R.jsx)(`p`,{className:`px-4 py-8 text-sm text-muted-foreground`,children:`No results in the last 7 days`}),n<o.length&&(0,R.jsxs)(P,{variant:`ghost`,className:`m-2 min-h-11`,onClick:r,children:[`Show `,Math.min(20,o.length-n),` more results`]}),i.data?.truncated&&(0,R.jsx)(`p`,{className:`p-4 text-label text-muted-foreground`,children:`Showing the latest 60 results`}),i.data&&(0,R.jsx)(K,{coverage:i.data.coverage,retry:()=>{i.retryTasks()}}),!x&&i.data?.sources.some(e=>e.state!==`ready`||e.truncated)&&(0,R.jsxs)(`details`,{className:`p-4 text-label`,children:[(0,R.jsxs)(`summary`,{className:`flex w-fit cursor-pointer list-none items-center gap-1.5 rounded-sm text-muted-foreground transition-colors select-none hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/50 [&::-webkit-details-marker]:hidden min-h-11`,children:[(0,R.jsx)(H,{}),`Source details`]}),i.data.sources.map(e=>(0,R.jsxs)(`p`,{className:`break-words py-1`,children:[nr(e.key),`:`,` `,e.reason===`No GitHub remote`?`Not configured`:e.reason===`Still loading GitHub`?`Checking…`:e.reason??(e.state===`ready`?`Up to date`:e.state),e.truncated?` · capped`:``,e.fetchedAt?` · checked ${F(e.fetchedAt)}`:``]},e.key))]})]})]})}var $=e=>e.replace(/[&<>"']/g,e=>({"&":`&amp;`,"<":`&lt;`,">":`&gt;`,'"':`&quot;`,"'":`&#39;`})[e]),ar=`Visible modules and loaded rows only. Filters and report availability apply. Retained task usage is not an invoice or a complete history.`,or=`Confidential — internal distribution only`,sr={costUsd:{label:`Reported cost`,usd:!0},inputTokens:{label:`Input tokens`},outputTokens:{label:`Output tokens`},needsYou:{label:`Needs you`},running:{label:`Running now`},completed:{label:`Completed in period`},failed:{label:`Failed outcomes in period`},medianCycleHours:{label:`Median cycle (hours)`}};function cr(e,t){return e==null?`Unavailable`:typeof e==`string`?e:Dt(e,t)}function lr(e){let t=new Set,n=[];for(let r of e.modules)for(let e of r.rows){if(e.section!==`totals`&&e.section!==`fleet`&&e.section!==`overview`)continue;let i=sr[e.metric];!i||t.has(e.metric)||(t.add(e.metric),n.push({label:i.label,value:cr(e.value,i.usd),note:[e.metric===`needsYou`||e.metric===`running`?e.note||`Current non-archived state`:r.filters,e.asOf?`Data as of ${e.asOf}`:``,e.reportedTasks==null?``:`${e.reportedTasks} of ${e.totalTasks} tasks reported`].filter(Boolean).join(` · `)}))}return n}function ur(e){let t=e.cloneNode(!0);t.querySelectorAll(`script,style,link,img,iframe,object,embed,input,[hidden],[data-dashboard-export],[data-export-exclude]`).forEach(e=>e.remove()),t.querySelectorAll(`select`).forEach((t,n)=>{let r=e.querySelectorAll(`select`)[n];t.replaceWith(document.createTextNode(`: `+(r?.selectedOptions[0]?.textContent??``)))}),t.querySelectorAll(`[data-export-filter]`).forEach(e=>{e.replaceWith(document.createTextNode(`${e.dataset.exportFilter}: ${e.dataset.exportValue??``}`))}),t.querySelectorAll(`[data-export-row],[data-dashboard-row]`).forEach(e=>e.classList.add(`report-row`)),t.querySelectorAll(`summary`).forEach(e=>{let t=document.createElement(`h3`);t.textContent=e.getAttribute(`data-export-heading`)||e.textContent,e.replaceWith(t)}),t.querySelectorAll(`button`).forEach(e=>{if(e.hasAttribute(`data-export-keep`)){let t=document.createElement(`div`);for(let n of[...e.attributes])[`class`,`style`,`title`].includes(n.name)&&t.setAttribute(n.name,n.value);t.append(...e.childNodes),e.replaceWith(t)}else e.remove()}),t.querySelectorAll(`details`).forEach(e=>{let t=document.createElement(`div`);t.className=e.className,t.append(...e.childNodes),e.replaceWith(t)});for(let e of[t,...t.querySelectorAll(`*`)])for(let t of[...e.attributes])(t.name.startsWith(`on`)||[`href`,`src`,`srcset`,`action`,`formaction`,`tabindex`].includes(t.name)||t.name.startsWith(`data-`))&&e.removeAttribute(t.name);return t.removeAttribute(`style`),t.innerHTML}function dr(e,t,n,r){return{generatedAt:t,source:n,title:r||void 0,notices:[...e.querySelectorAll(`[role=alert],[role=status]`)].filter(e=>!e.closest(`[data-dashboard-module]`)).map(e=>e.textContent?.trim()??``).filter(Boolean),modules:[...e.querySelectorAll(`[data-dashboard-module]`)].map(e=>{let t=[...e.querySelectorAll(`select`)].map(e=>`${e.closest(`label`)?.childNodes[0]?.textContent?.trim()??`Filter`}: ${e.selectedOptions[0]?.textContent}`).concat([...e.querySelectorAll(`[data-export-filter]`)].map(e=>`${e.dataset.exportFilter}: ${e.dataset.exportValue??``}`)).concat([...e.querySelectorAll(`[data-export-context]`)].map(e=>e.dataset.exportContext)).join(`; `),n=[...new Set([...e.querySelectorAll(`p,[role="alert"],[role="status"]`)].filter(e=>!e.closest(`table,[data-export-exclude]`)&&!e.querySelector(`p,[role="alert"],[role="status"]`)).map(e=>{let t=e.cloneNode(!0);return t.querySelectorAll(`table,button,select,summary,[data-export-exclude]`).forEach(e=>e.remove()),t.textContent?.trim()}).filter(Boolean))].join(` | `);return{id:e.dataset.dashboardModule,title:e.querySelector(`h2`)?.textContent??e.dataset.dashboardModule,filters:t,notes:n,html:ur(e),rows:[...e.querySelectorAll(`[data-dashboard-export]`)].flatMap(e=>JSON.parse(e.dataset.dashboardExport))}})}}function fr(e){let t=e==null?``:String(e);return typeof e==`string`&&/^[\s\uFEFF]*[=+@\-]/.test(t)&&(t=`'${t}`),`"${t.replaceAll(`"`,`""`)}"`}function pr(e){let t=[[`generated_at`,`source`,`module`,`filters`,`section`,`entity`,`metric`,`value`,`unit`,`availability`,`reported_tasks`,`total_tasks`,`as_of`,`notes`]];for(let n of e.modules){t.push([e.generatedAt,e.source,n.title,n.filters,`context`,``,`scope`,ar,``,``,``,``,``,[...e.title?[`Report title: ${e.title}`]:[],...e.notices,n.notes].join(` | `)]);for(let r of n.rows)t.push([e.generatedAt,e.source,n.title,n.filters,r.section,r.entity,r.metric,r.value,r.unit,r.value===null?`unavailable`:typeof r.value==`number`?`measured`:`reported`,r.reportedTasks,r.totalTasks,r.asOf,r.note])}return``+t.map(e=>e.map(fr).join(`,`)).join(`\r
2
2
  `)+`\r
3
3
  `}function mr(e,t){let n=lr(e);return`<!doctype html><html class="light"><head><meta charset="utf-8"><title>${$(e.title||`Dashboard`)} ${$(e.generatedAt.slice(0,10))}</title>${t.join(``)}<style>
4
4
  @page {
@@ -1 +1 @@
1
- import"./rolldown-runtime-QTnfLwEv.js";import{i as e,t}from"./react-runtime-CCIEwYL0.js";import{t as n}from"./utils-DWwoYTjU.js";import{d as r,f as i,h as a,l as o,m as s,p as c,t as l,u}from"./button-CEskWahs.js";import{t as d}from"./x-BqECUykl.js";e();var f=t();function p({...e}){return(0,f.jsx)(o,{"data-slot":`dialog`,...e})}function m({...e}){return(0,f.jsx)(s,{"data-slot":`dialog-portal`,...e})}function h({className:e,...t}){return(0,f.jsx)(c,{"data-slot":`dialog-overlay`,className:n(`fixed inset-0 z-50 bg-black/50 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:animate-in data-[state=open]:fade-in-0`,e),...t})}function g({className:e,children:t,showCloseButton:i=!0,...a}){return(0,f.jsxs)(m,{"data-slot":`dialog-portal`,children:[(0,f.jsx)(h,{}),(0,f.jsxs)(r,{"data-slot":`dialog-content`,className:n(`fixed top-[50%] left-[50%] z-50 grid w-full grid-cols-1 max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border bg-card p-6 shadow-modal duration-200 outline-none data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95 sm:max-w-lg`,e),...a,children:[t,i&&(0,f.jsxs)(u,{"data-slot":`dialog-close`,className:`absolute top-4 right-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:ring-2 focus:ring-ring focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,children:[(0,f.jsx)(d,{}),(0,f.jsx)(`span`,{className:`sr-only`,children:`Close`})]})]})]})}function _({className:e,...t}){return(0,f.jsx)(`div`,{"data-slot":`dialog-header`,className:n(`flex flex-col gap-2 text-center sm:text-left`,e),...t})}function v({className:e,showCloseButton:t=!1,children:r,...i}){return(0,f.jsxs)(`div`,{"data-slot":`dialog-footer`,className:n(`flex flex-col-reverse gap-2 sm:flex-row sm:justify-end`,e),...i,children:[r,t&&(0,f.jsx)(u,{asChild:!0,children:(0,f.jsx)(l,{variant:`outline`,children:`Close`})})]})}function y({className:e,...t}){return(0,f.jsx)(a,{"data-slot":`dialog-title`,className:n(`text-lg leading-none font-semibold`,e),...t})}function b({className:e,...t}){return(0,f.jsx)(i,{"data-slot":`dialog-description`,className:n(`text-sm text-muted-foreground`,e),...t})}export{_ as a,v as i,g as n,y as o,b as r,p as t};
1
+ import"./rolldown-runtime-QTnfLwEv.js";import{i as e,t}from"./react-runtime-CCIEwYL0.js";import{t as n}from"./utils-Dp6vCdiU.js";import{d as r,f as i,h as a,l as o,m as s,p as c,t as l,u}from"./button-CJXK1JqU.js";import{t as d}from"./x-BqECUykl.js";e();var f=t();function p({...e}){return(0,f.jsx)(o,{"data-slot":`dialog`,...e})}function m({...e}){return(0,f.jsx)(s,{"data-slot":`dialog-portal`,...e})}function h({className:e,...t}){return(0,f.jsx)(c,{"data-slot":`dialog-overlay`,className:n(`fixed inset-0 z-50 bg-black/50 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:animate-in data-[state=open]:fade-in-0`,e),...t})}function g({className:e,children:t,showCloseButton:i=!0,...a}){return(0,f.jsxs)(m,{"data-slot":`dialog-portal`,children:[(0,f.jsx)(h,{}),(0,f.jsxs)(r,{"data-slot":`dialog-content`,className:n(`fixed top-[50%] left-[50%] z-50 grid w-full grid-cols-1 max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border bg-card p-6 shadow-modal duration-200 outline-none data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95 sm:max-w-lg`,e),...a,children:[t,i&&(0,f.jsxs)(u,{"data-slot":`dialog-close`,className:`absolute top-4 right-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:ring-2 focus:ring-ring focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,children:[(0,f.jsx)(d,{}),(0,f.jsx)(`span`,{className:`sr-only`,children:`Close`})]})]})]})}function _({className:e,...t}){return(0,f.jsx)(`div`,{"data-slot":`dialog-header`,className:n(`flex flex-col gap-2 text-center sm:text-left`,e),...t})}function v({className:e,showCloseButton:t=!1,children:r,...i}){return(0,f.jsxs)(`div`,{"data-slot":`dialog-footer`,className:n(`flex flex-col-reverse gap-2 sm:flex-row sm:justify-end`,e),...i,children:[r,t&&(0,f.jsx)(u,{asChild:!0,children:(0,f.jsx)(l,{variant:`outline`,children:`Close`})})]})}function y({className:e,...t}){return(0,f.jsx)(a,{"data-slot":`dialog-title`,className:n(`text-lg leading-none font-semibold`,e),...t})}function b({className:e,...t}){return(0,f.jsx)(i,{"data-slot":`dialog-description`,className:n(`text-sm text-muted-foreground`,e),...t})}export{_ as a,v as i,g as n,y as o,b as r,p as t};
@@ -1,3 +1,3 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/diff-view-BeoeZVcx.js","assets/rolldown-runtime-QTnfLwEv.js","assets/react-runtime-CCIEwYL0.js","assets/utils-DWwoYTjU.js","assets/bundle-mjs-rHxsej31.js","assets/createLucideIcon-BHp8sXmF.js","assets/button-CEskWahs.js","assets/pencil-BWoe1EL-.js","assets/plus-CxRU2X8C.js","assets/icon-tooltip-DRhwcic2.js","assets/loading-state-BTvZxCb2.js","assets/spinner-CwKcijCN.js","assets/loader-circle-CPBhhDbB.js","assets/toaster-4t61QM_C.js","assets/status-dot-CZAbXsOs.js","assets/use-submit-shortcut-Cfam5eE7.js","assets/diff-stat-zisAayZW.js","assets/clipboard-DvCUPLwM.js","assets/lib-BQXq3kEf.js","assets/chunk-BO2N2NFS-BueWQOks.js","assets/preload-helper-Czpn1I53.js","assets/lib-BxQXEXDF.js","assets/markdown-LlPZylt7.js","assets/alert-dialog-DT465VL4.js","assets/markdown-3rt1rOmI.js","assets/message-square-B-MD-8rD.js","assets/scroll-within-CfS_Ia4E.js","assets/zoomable-image-D4B6jvp-.js","assets/types-BTlmexWF.js"])))=>i.map(i=>d[i]);
2
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{t as r}from"./utils-DWwoYTjU.js";import{t as i}from"./preload-helper-Czpn1I53.js";import{t as a}from"./diff-stat-zisAayZW.js";import{i as o,n as s,r as c,t as l}from"./scroll-within-CfS_Ia4E.js";var u=e(t(),1),d=n(),f=null,p=null;function m(){return p??=i(()=>import(`./diff-view-BeoeZVcx.js`).then(e=>f={View:e.DiffView},()=>(p=null,`failed`)),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28])),p}function h(e){let[t,n]=(0,u.useState)(f);return(0,u.useEffect)(()=>{if(f)return;let e=!1;return m().then(t=>{e||n(t)}),()=>{e=!0}},[]),e.files.length===0?(0,d.jsx)(`p`,{"data-slot":`diff-empty`,className:r(`px-1 text-label text-muted-foreground`,e.className),children:`No changes.`}):t===`failed`?(0,d.jsx)(g,{...e}):t===null?(0,d.jsx)(`p`,{"data-slot":`diff-loading`,className:r(`px-1 text-label text-soft-foreground`,e.className),children:`Loading diff…`}):(0,d.jsx)(t.View,{...e})}function g({files:e,wrap:t=!1,imageSrc:n,oldImageSrc:i,onOpenInApp:o,viewRef:c,className:f}){let p={adds:e.reduce((e,t)=>e+t.adds,0),dels:e.reduce((e,t)=>e+t.dels,0),files:e.length},m=(0,u.useRef)(null);return(0,u.useImperativeHandle)(c,()=>({scrollToPath:e=>{for(let t of m.current?.querySelectorAll(`[data-slot="diff-file"]`)??[])if(t.dataset.path===e){let e=l(t);e&&s(e,t,Number.parseFloat(getComputedStyle(t).scrollMarginTop)||0);return}}})),(0,d.jsxs)(`div`,{ref:m,"data-slot":`diff`,"data-fallback":`true`,className:r(`flex min-w-0 flex-col gap-3`,f),children:[(0,d.jsxs)(`p`,{"data-slot":`diff-totals`,className:`flex items-center gap-2 px-1 text-xs text-muted-foreground`,children:[(0,d.jsxs)(`span`,{children:[p.files,` `,p.files===1?`file`:`files`,` changed`]}),(0,d.jsx)(a,{stat:p})]}),e.map(e=>(0,d.jsx)(_,{file:e,wrap:t,imageSrc:n,onOpenInApp:o,oldImageSrc:i},`${e.oldPath??``}→${e.path}`))]})}function _({file:e,wrap:t,imageSrc:n,onOpenInApp:i,oldImageSrc:s}){return(0,d.jsxs)(`section`,{"data-slot":`diff-file`,"data-path":e.path,className:`min-w-0 scroll-mt-[var(--diff-sticky-top,0px)] overflow-clip rounded-md border border-border bg-card`,children:[(0,d.jsxs)(`header`,{className:`flex items-center gap-2 border-b border-border/50 px-3 py-2`,children:[(0,d.jsx)(`span`,{"data-slot":`diff-file-path`,className:`min-w-0 truncate font-mono text-xs font-medium`,children:e.oldPath?`${e.oldPath} → ${e.path}`:e.path}),(0,d.jsx)(`span`,{className:`ml-auto shrink-0`,children:(0,d.jsx)(a,{stat:{adds:e.adds,dels:e.dels,files:1},className:`text-meta`})})]}),o(e)?(0,d.jsx)(c,{file:e,imageSrc:n,oldImageSrc:s,onOpenInApp:i}):e.binary?(0,d.jsx)(`p`,{className:`px-4 py-2.5 text-label text-muted-foreground`,children:`Binary file — no text diff.`}):e.patch===``?(0,d.jsx)(`p`,{className:`px-4 py-2.5 text-label text-muted-foreground`,children:`No content changes (metadata only).`}):(0,d.jsx)(`pre`,{className:r(`py-2 font-mono text-xs leading-[1.7]`,t?`break-words whitespace-pre-wrap`:`overflow-x-auto whitespace-pre`),children:e.patch.split(`
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/diff-view-m4TvXu0y.js","assets/rolldown-runtime-QTnfLwEv.js","assets/react-runtime-CCIEwYL0.js","assets/utils-Dp6vCdiU.js","assets/bundle-mjs-rHxsej31.js","assets/createLucideIcon-BHp8sXmF.js","assets/button-CJXK1JqU.js","assets/pencil-BWoe1EL-.js","assets/plus-CxRU2X8C.js","assets/icon-tooltip-DYk5cjLx.js","assets/loading-state-NiNQtJ5H.js","assets/spinner-hSpq0sPM.js","assets/loader-circle-CPBhhDbB.js","assets/toaster-BoJZiTRl.js","assets/status-dot-AP_4obOJ.js","assets/use-submit-shortcut-Cfam5eE7.js","assets/diff-stat-DPetRUXO.js","assets/clipboard-DvCUPLwM.js","assets/lib-BQXq3kEf.js","assets/chunk-BO2N2NFS-BueWQOks.js","assets/preload-helper-Czpn1I53.js","assets/lib-BxQXEXDF.js","assets/markdown-YSf01kqC.js","assets/alert-dialog-B2Vi6MQZ.js","assets/markdown-CXJIKz2i.js","assets/message-square-B-MD-8rD.js","assets/scroll-within-DMA4ZbQV.js","assets/zoomable-image-BiM5LfTG.js","assets/types-BTlmexWF.js"])))=>i.map(i=>d[i]);
2
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{t as r}from"./utils-Dp6vCdiU.js";import{t as i}from"./preload-helper-Czpn1I53.js";import{t as a}from"./diff-stat-DPetRUXO.js";import{i as o,n as s,r as c,t as l}from"./scroll-within-DMA4ZbQV.js";var u=e(t(),1),d=n(),f=null,p=null;function m(){return p??=i(()=>import(`./diff-view-m4TvXu0y.js`).then(e=>f={View:e.DiffView},()=>(p=null,`failed`)),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28])),p}function h(e){let[t,n]=(0,u.useState)(f);return(0,u.useEffect)(()=>{if(f)return;let e=!1;return m().then(t=>{e||n(t)}),()=>{e=!0}},[]),e.files.length===0?(0,d.jsx)(`p`,{"data-slot":`diff-empty`,className:r(`px-1 text-label text-muted-foreground`,e.className),children:`No changes.`}):t===`failed`?(0,d.jsx)(g,{...e}):t===null?(0,d.jsx)(`p`,{"data-slot":`diff-loading`,className:r(`px-1 text-label text-soft-foreground`,e.className),children:`Loading diff…`}):(0,d.jsx)(t.View,{...e})}function g({files:e,wrap:t=!1,imageSrc:n,oldImageSrc:i,onOpenInApp:o,viewRef:c,className:f}){let p={adds:e.reduce((e,t)=>e+t.adds,0),dels:e.reduce((e,t)=>e+t.dels,0),files:e.length},m=(0,u.useRef)(null);return(0,u.useImperativeHandle)(c,()=>({scrollToPath:e=>{for(let t of m.current?.querySelectorAll(`[data-slot="diff-file"]`)??[])if(t.dataset.path===e){let e=l(t);e&&s(e,t,Number.parseFloat(getComputedStyle(t).scrollMarginTop)||0);return}}})),(0,d.jsxs)(`div`,{ref:m,"data-slot":`diff`,"data-fallback":`true`,className:r(`flex min-w-0 flex-col gap-3`,f),children:[(0,d.jsxs)(`p`,{"data-slot":`diff-totals`,className:`flex items-center gap-2 px-1 text-xs text-muted-foreground`,children:[(0,d.jsxs)(`span`,{children:[p.files,` `,p.files===1?`file`:`files`,` changed`]}),(0,d.jsx)(a,{stat:p})]}),e.map(e=>(0,d.jsx)(_,{file:e,wrap:t,imageSrc:n,onOpenInApp:o,oldImageSrc:i},`${e.oldPath??``}→${e.path}`))]})}function _({file:e,wrap:t,imageSrc:n,onOpenInApp:i,oldImageSrc:s}){return(0,d.jsxs)(`section`,{"data-slot":`diff-file`,"data-path":e.path,className:`min-w-0 scroll-mt-[var(--diff-sticky-top,0px)] overflow-clip rounded-md border border-border bg-card`,children:[(0,d.jsxs)(`header`,{className:`flex items-center gap-2 border-b border-border/50 px-3 py-2`,children:[(0,d.jsx)(`span`,{"data-slot":`diff-file-path`,className:`min-w-0 truncate font-mono text-xs font-medium`,children:e.oldPath?`${e.oldPath} → ${e.path}`:e.path}),(0,d.jsx)(`span`,{className:`ml-auto shrink-0`,children:(0,d.jsx)(a,{stat:{adds:e.adds,dels:e.dels,files:1},className:`text-meta`})})]}),o(e)?(0,d.jsx)(c,{file:e,imageSrc:n,oldImageSrc:s,onOpenInApp:i}):e.binary?(0,d.jsx)(`p`,{className:`px-4 py-2.5 text-label text-muted-foreground`,children:`Binary file — no text diff.`}):e.patch===``?(0,d.jsx)(`p`,{className:`px-4 py-2.5 text-label text-muted-foreground`,children:`No content changes (metadata only).`}):(0,d.jsx)(`pre`,{className:r(`py-2 font-mono text-xs leading-[1.7]`,t?`break-words whitespace-pre-wrap`:`overflow-x-auto whitespace-pre`),children:e.patch.split(`
3
3
  `).map((e,t)=>(0,d.jsxs)(`span`,{className:r(`block px-4`,e.startsWith(`+`)&&!e.startsWith(`+++`)&&`bg-diff-add`,e.startsWith(`-`)&&!e.startsWith(`---`)&&`bg-diff-del`,e.startsWith(`@@`)&&`text-soft-foreground`),children:[e,e===``?` `:``]},t))})]})}export{h as t};
@@ -1 +1 @@
1
- import{t as e}from"./react-runtime-CCIEwYL0.js";import{t}from"./utils-DWwoYTjU.js";var n=e();function r({stat:e,className:r}){let i=`+${e.adds} −${e.dels} across ${e.files} ${e.files===1?`file`:`files`}`,a=e.repointed?`${i} — measured against another branch checked out in this task's worktree, as this task found it`:void 0;return(0,n.jsx)(`span`,{"data-slot":`diff-stat`,...a?{"data-repointed":`true`,"aria-label":a}:{},title:a??i,className:t(`font-mono text-xs font-semibold tabular-nums`,e.repointed&&`cursor-help underline decoration-dotted underline-offset-2`,r),children:e.adds===0&&e.dels===0?(0,n.jsx)(`span`,{"data-slot":`diff-stat-empty`,className:`text-soft-foreground`,children:`—`}):(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)(`span`,{className:`text-success`,children:[`+`,e.adds]}),` `,(0,n.jsxs)(`span`,{className:`text-danger`,children:[`−`,e.dels]})]})})}export{r as t};
1
+ import{t as e}from"./react-runtime-CCIEwYL0.js";import{t}from"./utils-Dp6vCdiU.js";var n=e();function r({stat:e,className:r}){let i=`+${e.adds} −${e.dels} across ${e.files} ${e.files===1?`file`:`files`}`,a=e.repointed?`${i} — measured against another branch checked out in this task's worktree, as this task found it`:void 0;return(0,n.jsx)(`span`,{"data-slot":`diff-stat`,...a?{"data-repointed":`true`,"aria-label":a}:{},title:a??i,className:t(`font-mono text-xs font-semibold tabular-nums`,e.repointed&&`cursor-help underline decoration-dotted underline-offset-2`,r),children:e.adds===0&&e.dels===0?(0,n.jsx)(`span`,{"data-slot":`diff-stat-empty`,className:`text-soft-foreground`,children:`—`}):(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)(`span`,{className:`text-success`,children:[`+`,e.adds]}),` `,(0,n.jsxs)(`span`,{className:`text-danger`,children:[`−`,e.dels]})]})})}export{r as t};
@@ -1,4 +1,4 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{t as r}from"./utils-DWwoYTjU.js";import{t as i}from"./createLucideIcon-BHp8sXmF.js";import{H as a,V as o,t as s}from"./button-CEskWahs.js";import{n as c,t as l}from"./pencil-BWoe1EL-.js";import{t as u}from"./plus-CxRU2X8C.js";import{t as d}from"./icon-tooltip-DRhwcic2.js";import{i as f,n as p}from"./loading-state-BTvZxCb2.js";import{r as m}from"./toaster-4t61QM_C.js";import{t as h}from"./status-dot-CZAbXsOs.js";import{t as g}from"./use-submit-shortcut-Cfam5eE7.js";import{t as ee}from"./diff-stat-zisAayZW.js";import{t as _}from"./clipboard-DvCUPLwM.js";import{t as v}from"./lib-BQXq3kEf.js";import{s as te}from"./chunk-BO2N2NFS-BueWQOks.js";import{i as y,o as b,s as x,t as S}from"./markdown-LlPZylt7.js";import{n as ne,t as re}from"./markdown-3rt1rOmI.js";import{i as C,n as ie,r as w,t as ae}from"./scroll-within-CfS_Ia4E.js";import{n as T,t as E}from"./types-BTlmexWF.js";var D=i(`message-square-off`,[[`path`,{d:`M19 19H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.7.7 0 0 1 2 21.286V5a2 2 0 0 1 1.184-1.826`,key:`1wyg69`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}],[`path`,{d:`M8.656 3H20a2 2 0 0 1 2 2v11.344`,key:`mhl4k6`}]]),O=e(t(),1),k=20.4,A=44;function j(e){if(e.binary===!0||e.patch===``)return 1;let t=e.patch.split(`
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{t as r}from"./utils-Dp6vCdiU.js";import{t as i}from"./createLucideIcon-BHp8sXmF.js";import{H as a,V as o,t as s}from"./button-CJXK1JqU.js";import{n as c,t as l}from"./pencil-BWoe1EL-.js";import{t as u}from"./plus-CxRU2X8C.js";import{t as d}from"./icon-tooltip-DYk5cjLx.js";import{i as f,n as p}from"./loading-state-NiNQtJ5H.js";import{r as m}from"./toaster-BoJZiTRl.js";import{t as h}from"./status-dot-AP_4obOJ.js";import{t as g}from"./use-submit-shortcut-Cfam5eE7.js";import{t as ee}from"./diff-stat-DPetRUXO.js";import{t as _}from"./clipboard-DvCUPLwM.js";import{t as v}from"./lib-BQXq3kEf.js";import{s as te}from"./chunk-BO2N2NFS-BueWQOks.js";import{i as y,o as b,s as x,t as S}from"./markdown-YSf01kqC.js";import{n as ne,t as re}from"./markdown-CXJIKz2i.js";import{i as C,n as ie,r as w,t as ae}from"./scroll-within-DMA4ZbQV.js";import{n as T,t as E}from"./types-BTlmexWF.js";var D=i(`message-square-off`,[[`path`,{d:`M19 19H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.7.7 0 0 1 2 21.286V5a2 2 0 0 1 1.184-1.826`,key:`1wyg69`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}],[`path`,{d:`M8.656 3H20a2 2 0 0 1 2 2v11.344`,key:`mhl4k6`}]]),O=e(t(),1),k=20.4,A=44;function j(e){if(e.binary===!0||e.patch===``)return 1;let t=e.patch.split(`
2
2
  `),n=t.findIndex(e=>e.startsWith(`@@`));return n===-1?t.length:t.length-n}function oe(e,t=!0){return Math.round((t?j(e):1)*k)+A}function se(e){return e.reduce((e,t)=>e+j(t),0)}var M=/(^|\/)(package-lock\.json|npm-shrinkwrap\.json|yarn\.lock|pnpm-lock\.yaml|bun\.lockb?|Cargo\.lock|poetry\.lock|uv\.lock|composer\.lock|Gemfile\.lock|go\.sum)$|\.min\.(js|css)$|\.map$/;function ce(e){return e.binary===!0||e.image===!0?!1:e.adds+e.dels>400||M.test(e.path)}function le(e,t){let n=new URLSearchParams(e).get(`diff`);return n===`flat`||n===`virtual`?n:t>1500?`virtual`:`flat`}function N(e){return`${e.oldPath??``}→${e.path}`}function ue(e){let t=0;for(let n of e.split(`
3
3
  `))n.length>t&&(t=n.length);return t}function P(e,t){let n=Array(e.length);for(let r of pe(e)){let i=[e=>e.kind!==`add`,e=>e.kind!==`del`];for(let a of i){let i=r.filter(t=>a(e[t]));if(i.length===0)continue;let o=t(i.map(t=>e[t].text).join(`
4
4
  `));if(!o)return null;i.forEach((t,r)=>{n[t]=o.tokens[r]??[{content:e[t].text}]})}}return n}var F=2e6,I=new Map,L=0;function de(e,t){let n=e;for(let e of t)n+=`\n${e.kind[0]}${e.oldLine??``},${e.newLine??``}\t${e.text}`;return n}function R(e){let t=I.get(e);return t!==void 0&&(I.delete(e),I.set(e,t)),t}function z(e,t){if(!(e.length>F/4||I.has(e))){I.set(e,t),L+=e.length;for(let e of I.keys()){if(L<=F)break;L-=e.length,I.delete(e)}}}var B=8,V=[],H=!1;function U(){let e=performance.now();for(;V.length>0&&performance.now()-e<B;){let e=V.shift();e.cancelled||e.run()}V.length>0?setTimeout(U,0):H=!1}function fe(e){let t={run:e,cancelled:!1};return V.push(t),H||(H=!0,setTimeout(U,0)),()=>{t.cancelled=!0}}function pe(e){let t=[],n=[],r,i;return e.forEach((e,a)=>{!(n.length>0&&(e.oldLine===void 0||r===void 0||e.oldLine===r+1)&&(e.newLine===void 0||i===void 0||e.newLine===i+1))&&n.length>0&&(t.push(n),n=[],r=void 0,i=void 0),n.push(a),e.oldLine!==void 0&&(r=e.oldLine),e.newLine!==void 0&&(i=e.newLine)}),n.length>0&&t.push(n),t}var W=/[A-Za-z0-9_]+|\s+|[^\sA-Za-z0-9_]+/g,G=300,K=.3;function q(e,t){if(e===t)return null;let n=e.match(W)??[],r=t.match(W)??[];if(n.length===0||r.length===0||n.length>G||r.length>G)return null;let i=r.length+1,a=new Uint16Array((n.length+1)*i);for(let e=1;e<=n.length;e++)for(let t=1;t<=r.length;t++)a[e*i+t]=n[e-1]===r[t-1]?(a[(e-1)*i+(t-1)]??0)+1:Math.max(a[(e-1)*i+t]??0,a[e*i+(t-1)]??0);if((a[n.length*i+r.length]??0)/Math.max(n.length,r.length)<K)return null;let o=Array(n.length).fill(!1),s=Array(r.length).fill(!1),c=n.length,l=r.length;for(;c>0&&l>0;)n[c-1]===r[l-1]?(o[c-1]=!0,s[l-1]=!0,c--,l--):(a[(c-1)*i+l]??0)>=(a[c*i+(l-1)]??0)?c--:l--;return{del:J(n,o),add:J(r,s)}}function J(e,t){let n=[];return e.forEach((e,r)=>{let i=!(t[r]??!1),a=n[n.length-1];a&&a.changed===i?a.text+=e:n.push({text:e,changed:i})}),n}function me(e,t,n){if(!t||t.length===0)return e?e.map(e=>({text:e.content,color:e.color,changed:!1})):n===``?[]:[{text:n,changed:!1}];if(!e||e.length===0)return t.map(e=>({text:e.text,changed:e.changed}));let r=[],i=0,a=0,o=0,s=0;for(;i<e.length&&o<t.length;){let n=e[i],c=t[o],l=n.content.length-a,u=c.text.length-s,d=Math.min(l,u);d>0&&(r.push({text:n.content.slice(a,a+d),color:n.color,changed:c.changed}),a+=d,s+=d),n.content.length-a<=0&&(i++,a=0),c.text.length-s<=0&&(o++,s=0)}for(;i<e.length;){let t=e[i],n=t.content.slice(a);n!==``&&r.push({text:n,color:t.color,changed:!1}),i++,a=0}return r}var he=/^@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@/,ge=`… (patch truncated)`;function _e(e){let t=[],n=!1,r=null,i=0,a=0,o=e.split(`
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{t as r}from"./createLucideIcon-BHp8sXmF.js";import{A as i,I as a,z as o}from"./button-CEskWahs.js";var s=r(`chevron-down`,[[`path`,{d:`m6 9 6 6 6-6`,key:`qrunsl`}]]),c=e(t(),1),l=n();function u(e){let t=e+`CollectionProvider`,[n,r]=i(t),[s,u]=n(t,{collectionRef:{current:null},itemMap:new Map}),d=e=>{let{scope:t,children:n}=e,r=c.useRef(null),i=c.useRef(new Map).current;return(0,l.jsx)(s,{scope:t,itemMap:i,collectionRef:r,children:n})};d.displayName=t;let f=e+`CollectionSlot`,p=a(f),m=c.forwardRef((e,t)=>{let{scope:n,children:r}=e,i=o(t,u(f,n).collectionRef);return(0,l.jsx)(p,{ref:i,children:r})});m.displayName=f;let h=e+`CollectionItemSlot`,g=`data-radix-collection-item`,_=a(h),v=c.forwardRef((e,t)=>{let{scope:n,children:r,...i}=e,a=c.useRef(null),s=o(t,a),d=u(h,n);return c.useEffect(()=>(d.itemMap.set(a,{ref:a,...i}),()=>void d.itemMap.delete(a))),(0,l.jsx)(_,{[g]:``,ref:s,children:r})});v.displayName=h;function y(t){let n=u(e+`CollectionConsumer`,t);return c.useCallback(()=>{let e=n.collectionRef.current;if(!e)return[];let t=Array.from(e.querySelectorAll(`[${g}]`));return Array.from(n.itemMap.values()).sort((e,n)=>t.indexOf(e.ref.current)-t.indexOf(n.ref.current))},[n.collectionRef,n.itemMap])}return[{Provider:d,Slot:m,ItemSlot:v},y,r]}var d=c.createContext(void 0);function f(e){let t=c.useContext(d);return e||t||`ltr`}export{u as n,s as r,f as t};
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{t as r}from"./createLucideIcon-BHp8sXmF.js";import{A as i,I as a,z as o}from"./button-CJXK1JqU.js";var s=r(`chevron-down`,[[`path`,{d:`m6 9 6 6 6-6`,key:`qrunsl`}]]),c=e(t(),1),l=n();function u(e){let t=e+`CollectionProvider`,[n,r]=i(t),[s,u]=n(t,{collectionRef:{current:null},itemMap:new Map}),d=e=>{let{scope:t,children:n}=e,r=c.useRef(null),i=c.useRef(new Map).current;return(0,l.jsx)(s,{scope:t,itemMap:i,collectionRef:r,children:n})};d.displayName=t;let f=e+`CollectionSlot`,p=a(f),m=c.forwardRef((e,t)=>{let{scope:n,children:r}=e,i=o(t,u(f,n).collectionRef);return(0,l.jsx)(p,{ref:i,children:r})});m.displayName=f;let h=e+`CollectionItemSlot`,g=`data-radix-collection-item`,_=a(h),v=c.forwardRef((e,t)=>{let{scope:n,children:r,...i}=e,a=c.useRef(null),s=o(t,a),d=u(h,n);return c.useEffect(()=>(d.itemMap.set(a,{ref:a,...i}),()=>void d.itemMap.delete(a))),(0,l.jsx)(_,{[g]:``,ref:s,children:r})});v.displayName=h;function y(t){let n=u(e+`CollectionConsumer`,t);return c.useCallback(()=>{let e=n.collectionRef.current;if(!e)return[];let t=Array.from(e.querySelectorAll(`[${g}]`));return Array.from(n.itemMap.values()).sort((e,n)=>t.indexOf(e.ref.current)-t.indexOf(n.ref.current))},[n.collectionRef,n.itemMap])}return[{Provider:d,Slot:m,ItemSlot:v},y,r]}var d=c.createContext(void 0);function f(e){let t=c.useContext(d);return e||t||`ltr`}export{u as n,s as r,f as t};