@open-mercato/cezar 0.16.2 → 0.16.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api-origin.d.ts +6 -0
- package/dist/api-origin.js +32 -0
- package/dist/api-origin.js.map +1 -0
- package/dist/automations/schedule-runner.d.ts +1 -0
- package/dist/automations/schedule-runner.js +2 -2
- package/dist/automations/schedule-runner.js.map +1 -1
- package/dist/core/agent-errors.d.ts +5 -0
- package/dist/core/agent-errors.js +49 -0
- package/dist/core/agent-errors.js.map +1 -1
- package/dist/core/claude-cli-runner.d.ts +3 -0
- package/dist/core/claude-cli-runner.js +20 -4
- package/dist/core/claude-cli-runner.js.map +1 -1
- package/dist/core/codex-ui-mapper.js +4 -1
- package/dist/core/codex-ui-mapper.js.map +1 -1
- package/dist/core/copilot-acp-runner.d.ts +1 -1
- package/dist/core/copilot-acp-runner.js +26 -5
- package/dist/core/copilot-acp-runner.js.map +1 -1
- package/dist/core/model-presets.d.ts +11 -0
- package/dist/core/model-presets.js +35 -1
- package/dist/core/model-presets.js.map +1 -1
- package/dist/core/opencode-model-catalog.js +3 -0
- package/dist/core/opencode-model-catalog.js.map +1 -1
- package/dist/core/opencode-server-runner.d.ts +7 -0
- package/dist/core/opencode-server-runner.js +36 -1
- package/dist/core/opencode-server-runner.js.map +1 -1
- package/dist/core/pi-runner.js +2 -0
- package/dist/core/pi-runner.js.map +1 -1
- package/dist/core/provider-auth.d.ts +6 -0
- package/dist/core/provider-auth.js +59 -13
- package/dist/core/provider-auth.js.map +1 -1
- package/dist/core/usage-limit.js +8 -2
- package/dist/core/usage-limit.js.map +1 -1
- package/dist/index.js +3 -19
- package/dist/index.js.map +1 -1
- package/dist/release/bump.d.ts +1 -1
- package/dist/release/bump.js +1 -1
- package/dist/release/stable.d.ts +21 -4
- package/dist/release/stable.js +48 -15
- package/dist/release/stable.js.map +1 -1
- package/dist/runs/agent-error-telemetry.js +4 -2
- package/dist/runs/agent-error-telemetry.js.map +1 -1
- package/dist/runs/store.d.ts +1 -1
- package/dist/runs/store.js +31 -4
- package/dist/runs/store.js.map +1 -1
- package/dist/server/git-changes.d.ts +22 -0
- package/dist/server/git-changes.js +19 -1
- package/dist/server/git-changes.js.map +1 -1
- package/dist/server/open-in-app.js +14 -3
- package/dist/server/open-in-app.js.map +1 -1
- package/dist/server/preview/location-reporter.d.ts +12 -0
- package/dist/server/preview/location-reporter.js +45 -0
- package/dist/server/preview/location-reporter.js.map +1 -0
- package/dist/server/preview/picker-script.d.ts +0 -22
- package/dist/server/preview/picker-script.js +3 -1
- package/dist/server/preview/picker-script.js.map +1 -1
- package/dist/server/provider-telemetry.d.ts +3 -1
- package/dist/server/provider-telemetry.js +4 -2
- package/dist/server/provider-telemetry.js.map +1 -1
- package/dist/server/repo-sync.js +5 -10
- package/dist/server/repo-sync.js.map +1 -1
- package/dist/server/server.d.ts +1854 -1854
- package/dist/server/server.js +7 -2
- package/dist/server/server.js.map +1 -1
- package/dist/server/worktree-lifecycle.d.ts +8 -8
- package/dist/telemetry.js +3 -1
- package/dist/telemetry.js.map +1 -1
- package/dist/workflows/continuation-context.d.ts +3 -1
- package/dist/workflows/continuation-context.js +22 -3
- package/dist/workflows/continuation-context.js.map +1 -1
- package/dist/workflows/run.d.ts +20 -9
- package/dist/workflows/run.js +49 -11
- package/dist/workflows/run.js.map +1 -1
- package/package.json +3 -3
- package/scripts/mock-copilot-acp.mjs +4 -0
- package/web/dist/assets/{agent-task-pickers-DEW3Vgdv.js → agent-task-pickers-CNuwgeJL.js} +1 -1
- package/web/dist/assets/{automations-route-Cx7mzYhD.js → automations-route-Cs1tsu1W.js} +1 -1
- package/web/dist/assets/{commit-list-xMdmPYbz.js → commit-list-Ti2arrt8.js} +1 -1
- package/web/dist/assets/{compare-variants-B6ja1M4D.js → compare-variants-CdchlJMs.js} +1 -1
- package/web/dist/assets/{dashboard-ClEGBFFq.js → dashboard-wi0EQack.js} +2 -2
- package/web/dist/assets/{file-preview-iucr8WDo.js → file-preview-pS9i9ZDR.js} +1 -1
- package/web/dist/assets/git-tab-loading-BC6WP7W4.js +1 -0
- package/web/dist/assets/{git-toolbar-DU5Ca6RI.js → git-toolbar-Dra1QlHb.js} +1 -1
- package/web/dist/assets/github-DZcdhMzw.js +1 -0
- package/web/dist/assets/{host-usage-DjDYDU0A.js → host-usage-DnkXF0CT.js} +1 -1
- package/web/dist/assets/index-qeFtKZ4e.js +22 -0
- package/web/dist/assets/{layout-cards-Sur4EWtx.js → layout-cards-CXMlrDUf.js} +1 -1
- package/web/dist/assets/{project-router-DZsR9P9C.js → project-router-CZzr7lzN.js} +2 -2
- package/web/dist/assets/queries-Bn7zl9OU.js +1 -0
- package/web/dist/assets/{reference-chip-DnemrSPW.js → reference-chip-CScP5y_O.js} +1 -1
- package/web/dist/assets/repo-git-CV-yXaSx.js +1 -0
- package/web/dist/assets/{run-diff-BPZ85gAE.js → run-diff-GHEaeAio.js} +2 -2
- package/web/dist/assets/{skills-BgCN1gTp.js → skills-DuSNv5op.js} +1 -1
- package/web/dist/assets/{task-commits-W1ZZiEt4.js → task-commits-D_gLpFQo.js} +1 -1
- package/web/dist/assets/{task-graph-DI2fn5M8.js → task-graph-BgHk8Y3v.js} +1 -1
- package/web/dist/assets/{task-notes-lmvd1UM7.js → task-notes-BBp0rdzM.js} +1 -1
- package/web/dist/assets/task-workspace-Cr9AjTxP.js +27 -0
- package/web/dist/assets/{terminal-drawer-DAkquqSe.js → terminal-drawer-CcPOjWwP.js} +2 -2
- package/web/dist/assets/{tracker-Cqdpt9RN.js → tracker-BHwMGsDY.js} +2 -2
- package/web/dist/assets/use-automations-Dh3Wj-79.js +5 -0
- package/web/dist/assets/{use-now-pBdvhv13.js → use-now-BB7W0F--.js} +1 -1
- package/web/dist/assets/{workflow-graph-l7O50dsV.js → workflow-graph-CcOTCItr.js} +3 -3
- package/web/dist/assets/worktree-lifecycle-operation-vTgExKUM.js +18 -0
- package/web/dist/index.html +10 -10
- package/web/dist/assets/git-tab-loading-BfC2ir8N.js +0 -1
- package/web/dist/assets/github-CELdSmld.js +0 -1
- package/web/dist/assets/index-BBND6Sg3.js +0 -22
- package/web/dist/assets/queries-CI0EmEcH.js +0 -1
- package/web/dist/assets/repo-git-Bj0PBOjX.js +0 -1
- package/web/dist/assets/task-workspace-B8Fpho3e.js +0 -27
- package/web/dist/assets/use-automations-v77gHYDG.js +0 -5
- package/web/dist/assets/worktree-lifecycle-operation-DOTiqQFx.js +0 -18
|
@@ -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{$r as r,Ci as i,G as a,Ln as o,Qt as s,Sa as c,Xt as l,Yn as u,ba as d,ea as f,gn as p,ir as m,j as h,zn as g}from"./queries-CI0EmEcH.js";import{$ as _,F as v,Q as y,Z as b,et as x,it as S,nt as C,t as w,tt as T,vt as E}from"./button-Clwd6u4_.js";import{T as ee,m as D,x as te}from"./project-router-DZsR9P9C.js";import{S as ne,a as re,o as ie,r as ae,t as oe}from"./reference-chip-DnemrSPW.js";import{A as O,C as se,E as k,M as A,N as j,O as ce,P as le,T as ue,_ as de,b as fe,c as pe,d as me,f as he,g as ge,h as _e,i as ve,j as ye,m as be,p as xe,v as Se,w as Ce,x as we,y as Te}from"./use-automations-v77gHYDG.js";import{a as Ee,i as De,n as Oe,o as ke,s as Ae,t as je}from"./use-now-pBdvhv13.js";import{a as Me,f as M,p as Ne,r as Pe}from"./automation-format-BL4n19a2.js";import{f as Fe,i as Ie,n as Le,r as Re,t as ze}from"./tooltip-B628Gs7C.js";import{t as Be}from"./chevron-right-VbYrJ_st.js";import{t as Ve}from"./download-DOJ8Dqfh.js";import{i as N,r as P,t as He}from"./token-metrics-Dk2ZNHb_.js";import{t as Ue}from"./index-BBND6Sg3.js";var We=v(`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`}]]),Ge=v(`arrow-down-left`,[[`path`,{d:`M17 7 7 17`,key:`15tmo1`}],[`path`,{d:`M17 17H7V7`,key:`1org7z`}]]),Ke=v(`circle-alert`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`line`,{x1:`12`,x2:`12`,y1:`8`,y2:`12`,key:`1pkeuh`}],[`line`,{x1:`12`,x2:`12.01`,y1:`16`,y2:`16`,key:`4dfq90`}]]),qe=v(`circle-question-mark`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3`,key:`1u773s`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]]),Je=v(`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`}]]),Ye=v(`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`}]]),F=e(t(),1);function Xe(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 Ze(e){return e.flatMap(e=>(e.data?.automations??[]).filter(e=>e.enabled).map(t=>({project:e,automation:t,at:Xe(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 Qe(e){let t=a(),n=c(),r=t.data?.projects??[],i=t.data?.bootProject,o=i&&!r.some(e=>e.id===i)?[...r,{id:i,name:i,status:`ok`}]:r,l=d({queryKey:[...s.dashboard,`automations`,o.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<o.length&&!e.aborted;){let r=o[t++];if(r.status===`missing`){n.push({...r,error:`Project folder unavailable`});continue}try{let t=S.parse(await f(await m.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,F.useEffect)(()=>{if(e)return ce(e=>{e===`automation-change`&&n.invalidateQueries({queryKey:[...s.dashboard,`automations`]})})},[n,e]),{...l,registry:t,retry:()=>{t.refetch(),l.refetch()}}}var I=n();function L({rows:e}){return(0,I.jsx)(`span`,{hidden:!0,"data-dashboard-export":JSON.stringify(e)})}var R=`section-mark font-mono text-[11px] font-semibold uppercase tracking-[0.14em] text-muted-foreground`,z=`flex min-h-12 flex-wrap items-center justify-between gap-x-3 gap-y-2 border-b px-4 py-2.5`,$e=`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 B(){return(0,I.jsx)(Be,{"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 et=`flex items-center gap-2 text-xs text-muted-foreground`;function tt({className:e=``,...t}){return(0,I.jsxs)(`span`,{className:`relative inline-flex`,children:[(0,I.jsx)(`select`,{...t,className:`h-9 cursor-pointer appearance-none rounded-md border bg-card-2 pr-8 pl-3 font-mono text-xs text-foreground outline-none transition-colors hover:border-foreground/20 hover:bg-muted focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 no-hover:min-h-11 ${e}`}),(0,I.jsx)(Fe,{"aria-hidden":`true`,className:`pointer-events-none absolute top-1/2 right-2.5 size-3.5 -translate-y-1/2 text-soft-foreground`})]})}var nt=`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`,V={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 rt({label:e,value:t,icon:n,children:r}){return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`span`,{className:`flex w-full items-center justify-between gap-2`,children:[(0,I.jsx)(`span`,{className:`font-mono text-[11px] font-medium uppercase tracking-[0.12em] text-muted-foreground`,children:e}),(0,I.jsx)(`span`,{className:`text-soft-foreground`,"aria-hidden":`true`,children:n})]}),(0,I.jsx)(`span`,{className:`mt-4 block text-4xl font-semibold leading-none tracking-tight tabular-nums`,children:t}),(0,I.jsx)(`span`,{className:`mt-3 block text-xs text-soft-foreground`,children:r})]})}function it({at:e}){return(0,I.jsxs)(`time`,{dateTime:e,title:new Date(e).toLocaleString(),children:[`Updated `,P(e),` ago`]})}function at(){let e=ve(),t=Qe(e.known&&!e.off),n=je(3e4),[r,i]=(0,F.useState)(!1),a=Ze(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,I.jsxs)(M,{"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,I.jsxs)(`div`,{className:z,children:[(0,I.jsxs)(`h2`,{className:`flex items-center ${R}`,children:[`Automations`,(0,I.jsx)(Ne,{className:`ml-2 size-3.5 text-soft-foreground`,"aria-hidden":`true`})]}),!e.off&&t.data&&(0,I.jsxs)(`span`,{className:`font-mono text-[11px] text-soft-foreground`,children:[a.length,` enabled`,l?` · partial`:``]})]}),!e.off&&t.data&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(L,{rows:[{section:`automations`,metric:`enabled`,value:a.length,unit:`automations`,note:l?`Partial project coverage`:`Loaded projects`}]}),t.dataUpdatedAt>0&&(0,I.jsx)(`p`,{className:`px-4 pt-3 text-xs text-muted-foreground`,children:(0,I.jsx)(it,{at:new Date(t.dataUpdatedAt).toISOString()})})]}),e.off?(0,I.jsx)(`p`,{className:`p-4 text-sm text-muted-foreground`,children:`Automations are disabled in this workspace.`}):(0,I.jsxs)(I.Fragment,{children:[c&&(0,I.jsx)(`p`,{className:`p-4 text-sm text-muted-foreground`,children:`Loading automations…`}),l&&(0,I.jsxs)(`div`,{role:`alert`,className:`p-4 text-sm`,children:[(0,I.jsx)(`p`,{children:`Some automation data could not be refreshed. Available results are shown.`}),s.map(e=>(0,I.jsxs)(`p`,{children:[e.name,`: `,e.error]},e.id)),(0,I.jsx)(w,{variant:`ghost`,onClick:t.retry,children:`Retry automations`})]}),!c&&!l&&a.length===0&&(0,I.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`:Me(r,n),o=t.kind===`schedule`?`Next run`:`Next check`;return(0,I.jsxs)(`div`,{"data-export-row":!0,className:`border-b px-4 py-3 transition-colors last:border-0 hover:bg-muted/30`,children:[(0,I.jsx)(D,{className:`block min-h-11 text-sm font-medium hover:underline`,to:`/p/${encodeURIComponent(e.id)}/automations/${encodeURIComponent(t.id)}`,children:t.name}),(0,I.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[e.name,` · `,o,`: `,a]}),r!==null&&(0,I.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:(0,I.jsxs)(`time`,{dateTime:new Date(r).toISOString(),children:[Pe(r,e.data.timeZone),` · `,e.data.timeZone]})}),t.kind!==`schedule`&&(0,I.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:`Checks for matching events; a task may not be started.`}),i&&(0,I.jsx)(`p`,{className:`mt-1 text-xs text-warning`,children:i}),(0,I.jsx)(L,{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,I.jsx)(w,{variant:`ghost`,className:`m-2 min-h-11`,onClick:()=>i(!r),children:r?`Show fewer`:`Show all ${a.length} enabled`}),!c&&(0,I.jsxs)(`details`,{className:`border-t px-4 py-2 text-xs text-muted-foreground`,children:[(0,I.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,I.jsx)(B,{}),`Manage automations by project`]}),t.data?.map(e=>(0,I.jsx)(D,{className:`block min-h-11 py-3 hover:underline`,to:`/p/${encodeURIComponent(e.id)}/automations`,children:e.name},e.id))]})]})]})}function ot(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 st(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 ct=(0,F.createContext)(``),lt=(0,F.createContext)(!0),H=new Map;function ut(e,t,n=``,r=0,i){let a=(0,F.useContext)(ct),o=`${a}:${n}`,[s,c]=(0,F.useState)(()=>H.get(o)),[l,u]=(0,F.useState)(o),d=(0,F.useRef)(r),f=(0,F.useRef)(!1);l!==o&&(u(o),c(H.get(o)),d.current=r,f.current=!1),d.current!==r&&(d.current=r,f.current=!0),(0,F.useEffect)(()=>{e&&(!s||f.current)&&(c(e),f.current=!1)},[s,e]);let p=(0,F.useMemo)(()=>({current:s}),[o]);p.current=s,(0,F.useEffect)(()=>()=>{!a||!p.current||(H.delete(o),H.set(o,p.current),H.size>60&&H.delete(H.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:st(g,e??m,t),updates:e?ot(g,e,t).size:0,show:()=>c(e)}}var dt=new Map;function ft(e){return dt.get(e)}function pt(e,t){dt.delete(e),dt.set(e,t),dt.size>20&&dt.delete(dt.keys().next().value)}var U=new Map;function mt(e,t){return U.get(e)?.[t]}function ht(e,t,n){let r=U.get(e)??{};r[t]=n,U.delete(e),U.set(e,r),U.size>20&&U.delete(U.keys().next().value)}var W=e=>`${e.projectId}:${e.id}`;function gt({row:e,removed:t=!1,queue:n=!1,checking:r=!1,checkFailed:i=!1,kicker:a}){let s=(0,F.useContext)(lt)&&!r&&!i,c=le(e);t=t||c===null||n&&c?.archived===!0,c&&(e={...e,status:c.status,awaitingAnswerSince:c.awaitingAnswerSince});let l=o(e),u=n&&!g(e),d=t||u||!s;return(0,I.jsxs)(`div`,{"data-dashboard-row":W(e),className:`min-w-0 border-b px-4 py-3 transition-colors last:border-0 hover:bg-muted/30`,children:[(0,I.jsx)(L,{rows:[{section:`task`,entity:W(e),metric:`title`,value:e.titleSummary||e.title},{section:`task`,entity:W(e),metric:`status`,value:d?`Not currently actionable`:e.status},{section:`task`,entity:W(e),metric:`createdAt`,value:e.createdAt}]}),a&&(0,I.jsx)(`p`,{className:`mb-1 pl-[15px] font-mono text-[10.5px] uppercase tracking-[0.1em] text-soft-foreground`,children:a}),(0,I.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,I.jsx)(N,{tone:l.tone,className:`mt-[7px]`}),(0,I.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,I.jsx)(D,{tabIndex:d?-1:void 0,"aria-disabled":d||void 0,onClick:e=>{d&&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,I.jsxs)(`div`,{className:`mt-1 flex flex-wrap items-center gap-x-2 gap-y-1 text-xs text-muted-foreground`,children:[(0,I.jsx)(`span`,{className:`font-mono text-[11px] text-soft-foreground`,children:e.projectId}),(0,I.jsx)(`span`,{children:i?`Could not check current state`:s?t?n&&c!==null?`No longer needs you`:`Task removed`:u?`No longer needs you`:l.label:`Checking current state…`}),(0,I.jsx)(`span`,{children:P(e.createdAt)}),e.dispatch&&(0,I.jsx)(`span`,{children:`Subtask`}),!d&&p(e).map(t=>(0,I.jsx)(oe,{reference:t,taskTitle:e.title,projectId:e.projectId,className:`no-hover:min-h-11`},`${t.kind}:${t.number}`))]})]})]})]})}function G({coverage:e,count:t,retry:n}){let r=e.projects.filter(e=>e.state!==`complete`);return r.length?(0,I.jsxs)(`div`,{className:`rounded-lg border border-pending/40 bg-card-2 p-3 text-sm`,role:`status`,children:[(0,I.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,I.jsxs)(`details`,{className:`mt-2`,children:[(0,I.jsxs)(`summary`,{className:`${$e} min-h-11`,children:[(0,I.jsx)(B,{}),`View unavailable `,r.length===1?`project`:`projects`]}),r.map(e=>(0,I.jsxs)(`p`,{children:[e.projectId,`: `,e.reason??e.state,e.omittedRuns>0?` · ${e.omittedRuns} omitted tasks`:``]},e.projectId))]}),(0,I.jsx)(w,{variant:`outline`,onClick:n,className:`min-h-11`,children:`Retry`})]}):null}function _t(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 K(e){return e===null?`Unavailable`:e<1?`${Math.round(e*60)}m`:e<48?`${e.toFixed(1)}h`:`${(e/24).toFixed(1)}d`}function vt(e,t,n){let r=te(),i=r.state?.dashboardEntry??r.key,[a,o]=ee(),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 yt=e=>`Last ${e===`7d`?7:30} calendar days`,bt=`font-mono text-[11px] font-semibold uppercase tracking-[0.12em] text-muted-foreground`,xt=`min-w-0 rounded-lg border bg-card-2 p-4`,q=`whitespace-nowrap px-3 py-2 font-mono text-[11px] font-medium uppercase tracking-[0.1em] text-soft-foreground`;function St(){let e=a().data?.projects;return t=>e?.find(e=>e.id===t)?.name??t}var Ct=(e,t)=>`/p/${encodeURIComponent(e)}/tasks/${encodeURIComponent(t)}`;function wt({label:e,value:t,onChange:n}){return(0,I.jsxs)(`label`,{className:et,children:[e,(0,I.jsxs)(tt,{value:t,onChange:e=>n(e.target.value===`30d`?`30d`:`7d`),children:[(0,I.jsx)(`option`,{value:`7d`,children:`Last 7 days`}),(0,I.jsx)(`option`,{value:`30d`,children:`Last 30 days`})]})]})}function Tt({query:e}){return e.isPending?(0,I.jsx)(`p`,{role:`status`,className:`text-sm text-muted-foreground`,children:`Loading insights…`}):e.isError?(0,I.jsxs)(`p`,{role:`alert`,className:`text-sm`,children:[e.data?`Showing previous results. `:``,`Could not refresh insights.`,` `,(0,I.jsx)(w,{variant:`outline`,onClick:()=>void e.refetch(),children:`Retry insights`})]}):null}function Et({period:e,active:t}){let n=Ue(e,t),r=n.data;return(0,I.jsxs)(`div`,{className:`space-y-3`,children:[(0,I.jsx)(Tt,{query:n}),r&&(0,I.jsx)(G,{coverage:r.coverage,retry:()=>void n.refetch()}),r&&(0,I.jsxs)(`div`,{className:`grid gap-3 lg:grid-cols-2`,children:[(0,I.jsx)(Dt,{data:r}),(0,I.jsx)(Ot,{data:r})]})]})}function Dt({data:e}){let t=e.delivered,n=[{label:`PRs opened`,value:t.prsOpened,note:`${t.prsTouched} touched`},{label:`Lines`,value:(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`span`,{className:`text-success`,children:[`+`,t.additions.toLocaleString(`en-US`)]}),` `,(0,I.jsxs)(`span`,{className:`text-danger`,children:[`−`,t.deletions.toLocaleString(`en-US`)]})]})},{label:`Files`,value:t.files.toLocaleString(`en-US`)},{label:`Issues`,value:t.issues}];return(0,I.jsxs)(`section`,{className:xt,"aria-label":`Delivered`,children:[(0,I.jsx)(L,{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,I.jsx)(`h3`,{className:bt,children:`Delivered`}),(0,I.jsx)(`dl`,{className:`mt-3 grid grid-cols-2 gap-x-4 gap-y-3 sm:grid-cols-4`,children:n.map(e=>(0,I.jsxs)(`div`,{className:`min-w-0`,children:[(0,I.jsx)(`dt`,{className:`text-xs text-soft-foreground`,children:e.label}),(0,I.jsx)(`dd`,{className:`mt-1 truncate text-xl font-semibold tracking-tight tabular-nums`,children:e.value}),e.note&&(0,I.jsx)(`dd`,{className:`text-xs text-soft-foreground`,children:e.note})]},e.label))}),(0,I.jsxs)(`span`,{className:`mt-3 block text-xs text-soft-foreground`,children:[`From `,t.completedTasks,` completed `,t.completedTasks===1?`task`:`tasks`,` ·`,` `,t.measuredTasks,` with a stored diff`]})]})}function Ot({data:e}){let t=St(),{total:n,reasons:r}=e.failures;return(0,I.jsxs)(`section`,{className:xt,"aria-label":`Why tasks failed`,children:[(0,I.jsx)(L,{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,I.jsxs)(`div`,{className:`flex items-baseline justify-between gap-2`,children:[(0,I.jsx)(`h3`,{className:bt,children:`Why tasks failed`}),n>0&&(0,I.jsxs)(`span`,{className:`font-mono text-[11px] text-soft-foreground`,children:[n,` failed`]})]}),n===0?(0,I.jsxs)(`span`,{className:`mt-4 flex items-center gap-2.5 text-sm text-muted-foreground`,children:[(0,I.jsx)(N,{tone:`success`}),`No failed outcomes in this period`]}):(0,I.jsx)(`ul`,{className:`mt-3 space-y-3`,children:r.map(e=>(0,I.jsx)(kt,{reason:e,total:n,projectName:t},`${e.category}:${e.label}`))})]})}function kt({reason:e,total:t,projectName:n}){let{latest:r}=e;return(0,I.jsxs)(`li`,{className:`min-w-0`,children:[(0,I.jsxs)(`div`,{className:`flex items-baseline justify-between gap-3 text-sm`,children:[(0,I.jsx)(`span`,{className:`min-w-0 truncate font-medium`,title:e.label,children:e.label}),(0,I.jsx)(`span`,{className:`font-mono text-xs tabular-nums text-muted-foreground`,children:e.count})]}),(0,I.jsx)(`div`,{className:`mt-1.5 h-1 overflow-hidden rounded-full bg-muted`,"aria-hidden":`true`,children:(0,I.jsx)(`div`,{className:`h-full rounded-full bg-danger/70`,style:{width:`${e.count/t*100}%`}})}),(0,I.jsxs)(`span`,{className:`mt-1.5 block truncate text-xs text-soft-foreground`,title:r.message,children:[`Latest:`,` `,(0,I.jsx)(D,{className:`text-muted-foreground hover:text-foreground hover:underline`,to:Ct(r.projectId,r.id),children:r.title}),` `,`· `,n(r.projectId),r.step?` · ${r.step}`:``,` · `,P(r.at),` ago`]})]})}var At={claude:`Claude Code`,codex:`Codex`,opencode:`OpenCode`,cursor:`Cursor`,pi:`Pi`,unknown:`Unknown backend`,mixed:`Mixed backends`},jt=e=>At[e]??e,Mt=(e,t)=>t?Math.round(e/t*100):0;function Nt(){let[e,t]=vt(`backends`,[`7d`,`30d`],`7d`),n=Ue(e),r=n.data,i=r?.visibility.cost;return(0,I.jsx)(`section`,{"data-dashboard-module":`backends`,className:`min-w-0`,children:(0,I.jsxs)(M,{className:`gap-0 py-0`,"data-export-context":`Backends: ${yt(e)}; finished tasks`,children:[(0,I.jsxs)(`div`,{className:z,children:[(0,I.jsx)(`h2`,{className:R,children:`Backends & models`}),(0,I.jsx)(wt,{label:`Finished`,value:e,onChange:t})]}),(0,I.jsxs)(`div`,{className:`space-y-3 p-4`,children:[(0,I.jsx)(Tt,{query:n}),r&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`p`,{className:`text-xs text-muted-foreground`,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,I.jsx)(G,{coverage:r.coverage,retry:()=>void n.refetch()}),r.backends.length?(0,I.jsx)(`div`,{className:`overflow-x-auto`,role:`region`,"aria-label":`Backend comparison`,tabIndex:0,children:(0,I.jsxs)(`table`,{className:`w-full text-left text-sm`,children:[(0,I.jsx)(`thead`,{children:(0,I.jsxs)(`tr`,{children:[(0,I.jsx)(`th`,{className:q,children:`Backend`}),(0,I.jsx)(`th`,{className:`${q} text-right`,children:`Finished`}),(0,I.jsx)(`th`,{className:q,children:`Success`}),(0,I.jsx)(`th`,{className:`${q} text-right`,children:`Median cycle`}),i&&(0,I.jsx)(`th`,{className:`${q} text-right`,children:`Reported USD`}),i&&(0,I.jsx)(`th`,{className:`${q} text-right`,children:`Per completed`})]})}),(0,I.jsx)(`tbody`,{children:r.backends.map(e=>(0,I.jsx)(Pt,{stat:e,cost:!!i},`${e.backend}:${e.model??``}`))})]})}):(0,I.jsx)(`p`,{className:`py-4 text-sm text-muted-foreground`,children:`No finished tasks in this period.`}),(0,I.jsx)(`span`,{className:`block font-mono text-[11px] text-soft-foreground`,children:(0,I.jsx)(it,{at:r.asOf})}),(0,I.jsx)(L,{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 Pt({stat:e,cost:t}){let n=Mt(e.done,e.finished),r=e.costUsd?.value;return(0,I.jsxs)(`tr`,{className:`border-t transition-colors hover:bg-muted/30`,children:[(0,I.jsxs)(`td`,{className:`px-3 py-2.5`,children:[(0,I.jsx)(`span`,{className:`block font-medium`,children:jt(e.backend)}),(0,I.jsx)(`span`,{className:`block font-mono text-[11px] text-soft-foreground`,children:e.backend===`mixed`?`steps ran on different backends`:e.model??`default model`})]}),(0,I.jsx)(`td`,{className:`px-3 py-2.5 text-right tabular-nums`,children:e.finished}),(0,I.jsxs)(`td`,{className:`min-w-40 px-3 py-2.5`,children:[(0,I.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,I.jsx)(`span`,{className:`h-1.5 flex-1 overflow-hidden rounded-full bg-danger/40`,"aria-hidden":`true`,children:(0,I.jsx)(`span`,{className:`block h-full rounded-full bg-success`,style:{width:`${n}%`}})}),(0,I.jsxs)(`span`,{className:`w-10 text-right font-mono text-xs tabular-nums`,children:[n,`%`]})]}),(0,I.jsxs)(`span`,{className:`block text-xs text-soft-foreground`,children:[e.done,` done · `,e.failed,` failed`]})]}),(0,I.jsx)(`td`,{className:`px-3 py-2.5 text-right tabular-nums`,children:e.timedTasks?K(e.medianCycleHours):`—`}),t&&(0,I.jsxs)(`td`,{className:`px-3 py-2.5 text-right tabular-nums`,children:[r==null?`—`:_t(r,!0),(0,I.jsxs)(`span`,{className:`block text-xs text-soft-foreground`,children:[e.costUsd?.reportedTasks??0,`/`,e.finished,` reported`]})]}),t&&(0,I.jsx)(`td`,{className:`px-3 py-2.5 text-right tabular-nums`,children:r==null||!e.done?`—`:_t(r/e.done,!0)})]})}function Ft(){let[e,t]=vt(`automations`,[`7d`,`30d`],`7d`),n=ve(),r=Ue(e),i=Qe(n.known&&!n.off),a=St(),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,I.jsx)(`section`,{"data-dashboard-module":`automation-outcomes`,className:`min-w-0`,children:(0,I.jsxs)(M,{className:`gap-0 py-0`,"data-export-context":`Automation outcomes: tasks created in ${yt(e)}`,children:[(0,I.jsxs)(`div`,{className:z,children:[(0,I.jsx)(`h2`,{className:R,children:`Automation outcomes`}),(0,I.jsx)(wt,{label:`Launched`,value:e,onChange:t})]}),(0,I.jsx)(`div`,{className:`space-y-3 p-4`,children:n.off?(0,I.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Automations are disabled in this workspace.`}):(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(Tt,{query:r}),o&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`p`,{className:`text-xs text-muted-foreground`,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,I.jsx)(G,{coverage:o.coverage,retry:()=>void r.refetch()}),u&&(0,I.jsxs)(`p`,{role:`alert`,className:`text-sm`,children:[`Some automation details could not be loaded. Their outcomes are shown by id.`,` `,(0,I.jsx)(w,{variant:`ghost`,onClick:i.retry,children:`Retry automations`})]}),d.length?(0,I.jsx)(`div`,{className:`overflow-x-auto`,role:`region`,"aria-label":`Automation outcomes`,tabIndex:0,children:(0,I.jsxs)(`table`,{className:`w-full text-left text-sm`,children:[(0,I.jsx)(`thead`,{children:(0,I.jsxs)(`tr`,{children:[(0,I.jsx)(`th`,{className:q,children:`Automation`}),(0,I.jsx)(`th`,{className:`${q} text-right`,children:`Tasks`}),(0,I.jsx)(`th`,{className:`${q} text-right`,children:`Done`}),(0,I.jsx)(`th`,{className:`${q} text-right`,children:`Failed`}),(0,I.jsx)(`th`,{className:`${q} text-right`,children:`Active`}),(0,I.jsx)(`th`,{className:q,children:`Last run`}),s&&(0,I.jsx)(`th`,{className:`${q} text-right`,children:`Reported USD`})]})}),(0,I.jsx)(`tbody`,{children:d.map(e=>(0,I.jsx)(It,{row:e,cost:!!s,projectName:a},`${e.projectId}:${e.automationId}`))})]})}):(0,I.jsx)(`p`,{className:`py-4 text-sm text-muted-foreground`,children:`No automations yet. Create one in a project's Automations page.`}),(0,I.jsx)(`span`,{className:`block font-mono text-[11px] text-soft-foreground`,children:(0,I.jsx)(it,{at:o.asOf})}),(0,I.jsx)(L,{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 It({row:e,cost:t,projectName:n}){let r=e.stat,i=`px-3 py-2.5 text-right tabular-nums`,a=e=>e||(0,I.jsx)(`span`,{className:`text-soft-foreground`,children:`0`});return(0,I.jsxs)(`tr`,{className:`border-t transition-colors hover:bg-muted/30`,children:[(0,I.jsxs)(`td`,{className:`px-3 py-2.5`,children:[e.definition===`removed`?(0,I.jsx)(`span`,{className:`block font-medium`,children:e.name}):(0,I.jsx)(D,{className:`block font-medium hover:underline`,to:`/p/${encodeURIComponent(e.projectId)}/automations/${encodeURIComponent(e.automationId)}`,children:e.name}),(0,I.jsxs)(`span`,{className:`flex items-center gap-1.5 text-xs text-soft-foreground`,children:[(0,I.jsx)(N,{tone:e.enabled?`success`:`neutral`}),n(e.projectId),` ·`,` `,e.definition===`removed`?`Removed`:e.definition===`unknown`?`Details unavailable`:e.enabled?`Enabled`:`Disabled`]})]}),(0,I.jsx)(`td`,{className:i,children:a(r?.tasks)}),(0,I.jsx)(`td`,{className:i,children:a(r?.done)}),(0,I.jsx)(`td`,{className:`${i} ${r?.failed?`text-danger`:``}`,children:a(r?.failed)}),(0,I.jsx)(`td`,{className:i,children:a(r?.active)}),(0,I.jsx)(`td`,{className:`whitespace-nowrap px-3 py-2.5 text-xs text-muted-foreground`,children:r?.lastRunAt?(0,I.jsxs)(`time`,{dateTime:r.lastRunAt,title:new Date(r.lastRunAt).toLocaleString(),children:[P(r.lastRunAt),` ago · `,r.lastStatus]}):`—`}),t&&(0,I.jsx)(`td`,{className:i,children:r?.costUsd?.value==null?`—`:_t(r.costUsd.value,!0)})]})}var Lt=0,Rt=()=>++Lt,J=new Map;function Y(e,t){let n=(0,F.useContext)(ct),r=()=>{let r=n?J.get(n):void 0;return r?.has(e)?r.get(e):typeof t==`function`?t():t},[i,a]=(0,F.useState)(r),o=`${n}:${e}`,[s,c]=(0,F.useState)(o);o!==s&&(c(o),a(()=>r()));let l=(0,F.useMemo)(()=>({value:i}),[n,e]);return l.value=i,(0,F.useEffect)(()=>()=>{if(!n)return;let t=J.get(n)??new Map;t.set(e,l.value),t.size>80&&t.delete(t.keys().next().value),J.delete(n),J.set(n,t),J.size>20&&J.delete(J.keys().next().value)},[n,e,l]),[i,a]}var zt=`a[href], button, select, input, [tabindex]`;function Bt(e){let[t]=Y(`${e}:position`,()=>({scroll:0})),n=(0,F.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,F.useMemo)(()=>({restore:()=>!1}),[t]);return{ref:(0,F.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 Vt(e,t){let n=(0,F.useRef)(null),[r,i]=Y(`${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 Ht(e,t=!0){return d({queryKey:[...s.dashboard,`overview`,e],enabled:t,staleTime:5e3,refetchInterval:t&&!e.snapshotId?15e3:!1,refetchIntervalInBackground:!1,retry:!1,queryFn:async({signal:t})=>b.parse(await f(await m.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 Ut={running:`Running now`,"needs-you":`Needs you`,completed:`Completed`,failed:`Failed outcomes`},Wt={"needs-you":V.violet,running:V.info,completed:V.success,failed:V.danger},Gt={"needs-you":qe,running:We,completed:k,failed:Ke};function Kt({active:e,children:t,onCurrent:n}){let[r,i]=vt(`period`,[`7d`,`30d`],`7d`),o=Vt(`outcome`,`[data-outcome-trigger]`),s=a().data?.projects,c=e=>s?.find(t=>t.id===e)?.name??e,l=Ht({period:r},e),[u,d]=Y(`outcome:selection`,null),f=Bt(`outcome:${u?.identity??`closed`}`),p=ye();if((0,F.useEffect)(()=>{e||d(null)},[e]),!e)return t({});let m=l.data,h=(e,t)=>{o.capture(),m&&d({identity:Rt(),snapshot:m,group:e,projectId:t})},g=m?.coverage.projects.every(e=>e.state===`complete`);return(0,I.jsxs)(I.Fragment,{children:[t({overview:(0,I.jsxs)(M,{className:`gap-0 py-0`,children:[(0,I.jsxs)(`div`,{className:z,children:[(0,I.jsx)(`h2`,{className:R,children:`Workspace overview`}),(0,I.jsxs)(`label`,{className:et,children:[`Outcomes period`,(0,I.jsxs)(tt,{value:r,onChange:e=>{i(e.target.value===`30d`?`30d`:`7d`),d(null)},children:[(0,I.jsx)(`option`,{value:`7d`,children:`Last 7 days`}),(0,I.jsx)(`option`,{value:`30d`,children:`Last 30 days`})]})]})]}),(0,I.jsxs)(`div`,{className:`space-y-4 p-4`,children:[l.isPending&&(0,I.jsx)(`p`,{role:`status`,className:`text-sm text-muted-foreground`,children:`Loading overview…`}),l.isError&&(0,I.jsxs)(`p`,{role:`alert`,children:[m?`Showing previous results. `:``,`Could not refresh overview.`,` `,(0,I.jsx)(w,{variant:`outline`,onClick:()=>void l.refetch(),children:`Retry overview`})]}),m&&(0,I.jsxs)(I.Fragment,{children:[(0,I.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,I.jsx)(G,{coverage:m.coverage,retry:()=>void l.refetch()}),(0,I.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],i=Gt[e];return(0,I.jsxs)(w,{"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?V.neutral:Wt[e]}`,onClick:t=>{n&&(e===`running`||e===`needs-you`)?n(e,t.currentTarget):h(e)},"aria-label":`${Ut[e]}: ${t}`,children:[(0,I.jsx)(rt,{label:Ut[e],value:t,icon:(0,I.jsx)(i,{className:`size-4`}),children:e===`running`||e===`needs-you`?`Current state`:`Last ${r===`7d`?7:30} calendar days`}),(0,I.jsxs)(`span`,{"data-export-exclude":!0,className:`mt-4 flex items-center gap-1 text-xs font-medium text-muted-foreground transition-colors group-hover/metric:text-foreground`,children:[`View tasks`,` `,(0,I.jsx)(Be,{className:`size-3 transition-transform group-hover/metric:translate-x-0.5 motion-reduce:transition-none`,"aria-hidden":`true`})]})]},e)})}),(0,I.jsx)(Et,{period:r,active:e}),(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-x-4 gap-y-1 border-t pt-3`,children:[(0,I.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Median cycle time`,` `,(0,I.jsx)(`strong`,{className:`font-mono font-semibold text-foreground`,children:K(m.metrics.medianCycleHours)}),` `,`· `,m.metrics.timedTasks,`/`,m.metrics.completed,` completed tasks have valid timings.`,` `,(0,I.jsx)(w,{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,I.jsx)(`p`,{className:`font-mono text-[11px] text-soft-foreground`,children:(0,I.jsxs)(`time`,{dateTime:m.asOf,title:new Date(m.asOf).toLocaleString(),children:[`Updated `,P(m.asOf),` ago`]})})]}),(0,I.jsxs)(`details`,{className:`text-xs text-muted-foreground`,children:[(0,I.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,I.jsx)(B,{}),`How these metrics work`]}),(0,I.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,I.jsx)(L,{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,I.jsx)(`div`,{children:(0,I.jsxs)(M,{className:`gap-0 py-0`,"data-export-context":`Outcomes: Last ${r===`7d`?7:30} calendar days; workload: current state`,children:[(0,I.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,I.jsx)(`h2`,{className:`section-mark font-mono text-[11px] font-semibold uppercase tracking-[0.14em] text-muted-foreground`,children:`Projects`})}),(0,I.jsx)(`p`,{className:`px-4 pt-3 text-xs text-muted-foreground`,children:`Current workload and outcomes for the selected period. Sorted by tasks needing you, then running tasks. Counts include subtasks.`}),(0,I.jsxs)(`div`,{className:`overflow-x-auto px-1 pb-2`,role:`region`,"aria-label":`Project outcomes`,tabIndex:0,children:[(0,I.jsxs)(`table`,{className:`w-full text-left text-sm`,children:[(0,I.jsx)(`thead`,{children:(0,I.jsx)(`tr`,{children:[`Project`,`Needs you`,`Running`,`Completed`,`Failed`,`Median cycle`].map(e=>(0,I.jsx)(`th`,{className:`whitespace-nowrap px-3 py-2 font-mono text-[11px] font-medium uppercase tracking-[0.1em] text-soft-foreground ${e===`Project`?``:`text-right`}`,children:e},e))})}),(0,I.jsx)(`tbody`,{children:m.projects.map(e=>{let t=m.coverage.projects.find(t=>t.projectId===e.projectId);return(0,I.jsxs)(`tr`,{className:`border-t transition-colors hover:bg-muted/30`,children:[(0,I.jsxs)(`td`,{className:`px-3 py-2`,children:[(0,I.jsx)(D,{className:`font-medium hover:underline`,to:`/p/${encodeURIComponent(e.projectId)}/tasks`,children:c(e.projectId)}),t?.state!==`complete`&&(0,I.jsx)(`span`,{className:`block text-xs text-muted-foreground`,children:`Incomplete data`})]}),[`needs-you`,`running`,`completed`,`failed`].map(n=>(0,I.jsx)(`td`,{className:`px-3 py-1 text-right`,children:(0,I.jsx)(w,{"data-export-keep":!0,variant:`ghost`,className:`min-h-11 tabular-nums`,"aria-label":`${c(e.projectId)}: ${Ut[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,I.jsxs)(`td`,{className:`px-3 py-2 text-right tabular-nums`,children:[K(e.medianCycleHours),(0,I.jsxs)(`span`,{className:`block text-xs text-muted-foreground`,children:[e.timedTasks,`/`,e.completed,` timed`]})]})]},e.projectId)})})]}),!m.projects.length&&(0,I.jsx)(`p`,{className:`py-4`,children:`No projects to compare yet.`})]}),(0,I.jsx)(L,{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,I.jsx)(Oe,{open:!!u,onOpenChange:e=>{e||d(null)},children:(0,I.jsxs)(De,{...f,className:`w-full overflow-y-auto sm:max-w-xl`,onCloseAutoFocus:e=>{e.preventDefault(),o.restore()},children:[(0,I.jsxs)(ke,{children:[(0,I.jsxs)(Ae,{children:[u?Ut[u.group]:`Tasks`,u?.projectId?` · ${u.projectId}`:``]}),(0,I.jsx)(Ee,{children:`Tasks behind the selected metric. Includes subtasks. Snapshot keeps counts and rows consistent.`})]}),u&&(0,I.jsx)(qt,{selection:u,projectName:c,refresh:()=>{d(null),l.refetch()}},u.identity)]})})]})}function qt({selection:e,refresh:t,projectName:n}){let[r,i]=Y(`outcome:${e.identity}:offset`,0),a=Ht({period:e.snapshot.period,snapshotId:e.snapshot.snapshotId,group:e.group,projectId:e.projectId,offset:r}),o=(0,F.useRef)(null),s=(0,F.useRef)(null);(0,F.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,I.jsxs)(`div`,{className:`space-y-3 p-4`,"data-sheet-loading":a.isFetching,children:[a.isPending&&(0,I.jsx)(`p`,{children:`Loading tasks…`}),a.isError&&(0,I.jsxs)(`p`,{role:`alert`,children:[`This snapshot may have expired or become unavailable.`,` `,(0,I.jsx)(w,{onClick:t,children:`Refresh overview`})]}),a.data&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`p`,{ref:o,tabIndex:-1,className:`text-xs text-muted-foreground`,children:[a.data.page.total,` tasks · Snapshot from`,` `,(0,I.jsxs)(`time`,{dateTime:a.data.asOf,title:new Date(a.data.asOf).toLocaleString(),children:[P(a.data.asOf),` ago`]})]}),a.data.page.rows.map(t=>(0,I.jsx)(Jt,{row:t,group:e.group,projectName:n},`${t.projectId}:${t.id}`)),!a.data.page.rows.length&&(0,I.jsx)(`p`,{children:`No tasks in this group.`})]}),(0,I.jsxs)(`div`,{className:`flex gap-2`,children:[(0,I.jsx)(w,{variant:`outline`,disabled:!r||a.isFetching,onClick:()=>c(Math.max(0,r-20)),children:`Previous`}),(0,I.jsx)(w,{variant:`outline`,disabled:!a.data||a.data.page.nextOffset===null||a.isFetching,onClick:()=>c(a.data.page.nextOffset),children:`Next`})]})]})}function Jt({row:e,group:t,projectName:n}){let r=le(e),i=t===`running`||t===`needs-you`;i&&r&&(e={...e,...r});let a=r===null,s=i&&(e.archived||(t===`running`?e.status!==`running`:!g(e))),c=a||s,l=o(e),u=i&&a?`Task removed`:s?t===`running`?`No longer running`:`No longer needs you`:l.label;return(0,I.jsxs)(`div`,{className:`border-b py-3`,children:[(0,I.jsx)(D,{"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,I.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[(0,I.jsx)(N,{tone:l.tone}),` `,n(e.projectId),` ·`,` `,u,` · `,e.archived?`Archived · `:``,(0,I.jsxs)(`time`,{dateTime:e.finishedAt??e.createdAt,title:new Date(e.finishedAt??e.createdAt).toLocaleString(),children:[e.finishedAt?`Finished`:`Created`,` `,P(e.finishedAt??e.createdAt),` ago`]})]})]})}var X={snapshot:[...s.dashboard,`snapshot`],feed:e=>[...s.dashboard,`feed`,e],telemetry:[...s.dashboard,`telemetry`]},Yt=new Map;async function Xt(e){let t=A(),n=x.parse(await f(await m.api.v1.workspace.dashboard.$get({},{init:{signal:e}}),`/workspace/dashboard`));return Yt.has(n.snapshotId)||Yt.set(n.snapshotId,t),Yt.size>60&&Yt.delete(Yt.keys().next().value),j(t,[...n.questions.rows,...n.reviews.rows]),n}async function Zt(e,t,n=0,r=20,i){let a=T.parse(await f(await m.api.v1.workspace.dashboard.tasks.$get({query:{snapshotId:e,group:t,offset:String(n),limit:String(r)}},{init:{signal:i}}),`/workspace/dashboard/tasks`)),o=Yt.get(e);return o!==void 0&&j(o,a.page.rows),a}function Qt(e){return d({queryKey:X.snapshot,queryFn:({signal:e})=>Xt(e),enabled:e,staleTime:5e3,refetchOnMount:`always`,refetchInterval:e?15e3:!1,refetchIntervalInBackground:!1,retry:!1})}function $t(e){return d({queryKey:X.telemetry,enabled:e,staleTime:0,queryFn:async({signal:e})=>{let t=C.parse(await f(await m.api.v1.workspace.dashboard.telemetry.$get({},{init:{signal:e}}),`/workspace/dashboard/telemetry`));return O.seed(t.samples,t.asOf),t}})}function en(e,t){let n=d({queryKey:X.feed(e),queryFn:async({signal:t})=>{let n=A(),r=_.parse(await f(await m.api.v1.workspace.dashboard.feed.$get({query:{filter:e}},{init:{signal:t}}),`/workspace/dashboard/feed`));return j(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,F.useRef)(!1);return(0,F.useEffect)(()=>{r.current=!1},[e,t]),(0,F.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 tn(e,t){let n=en(`tasks`,t&&e!==`github`),r=en(`github`,t&&e!==`tasks`),i=(0,F.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)=>nn(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 nn(e,t){return Date.parse(t.at)-Date.parse(e.at)||e.key.localeCompare(t.key)}var rn=[...s.dashboard,`costs`];function an(){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 un(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 on=new WeakMap;function sn(e){let t=on.get(e);return t||(t=an(),on.set(e,t)),t}function cn(){let e=sn(c());return(0,F.useSyncExternalStore)(e.subscribe,e.getSnapshot,e.getSnapshot)}var ln=new Map;async function un(e,t){let n=A(),r=y.parse(await f(await m.api.v1.workspace.dashboard.costs.$get({query:{...e,offset:String(e.offset??0),limit:`20`}},{init:{signal:t}}),`/workspace/dashboard/costs`));!e.snapshotId&&!ln.has(r.snapshotId)&&ln.set(r.snapshotId,n),ln.size>60&&ln.delete(ln.keys().next().value);let i=ln.get(r.snapshotId);return i!==void 0&&j(i,r.tasks.rows),r}function dn(e,t,n){let r=sn(c());return d({queryKey:[...rn,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 fn(e,t,n,r){let i=sn(c());return d({queryKey:[...rn,`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 u&&e.status===409)return s();throw e}}})}var pn={cost:{text:`text-primary`,fill:`bg-primary`,tint:V.primary,icon:ue},input:{text:`text-violet`,fill:`bg-violet`,tint:V.violet,icon:Ge},output:{text:`text-info`,fill:`bg-info`,tint:V.info,icon:ne}};function mn({metric:e,label:t,value:n,reported:r,total:i}){let a=pn[e],o=a.icon,s=i?Math.min(100,r/i*100):0;return(0,I.jsxs)(`div`,{className:`${nt} ${a.tint}`,children:[(0,I.jsxs)(rt,{label:t,value:n,icon:(0,I.jsx)(o,{className:`size-4 ${a.text}`}),children:[r,` of `,i,` tasks report this metric`]}),(0,I.jsx)(`div`,{className:`mt-2 h-1.5 overflow-hidden rounded-full bg-muted`,"aria-hidden":`true`,children:(0,I.jsx)(`div`,{className:`h-full rounded-full ${a.fill} transition-[width] duration-300 motion-reduce:transition-none`,style:{width:`${s}%`}})})]})}function hn({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=pn[n];return(0,I.jsxs)(Re,{delayDuration:150,children:[(0,I.jsxs)(`div`,{className:`space-y-1 rounded-xl border p-2`,"aria-label":`Projects ranked by ${i}`,children:[e.length===0&&(0,I.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,I.jsxs)(ze,{children:[(0,I.jsx)(Ie,{asChild:!0,children:(0,I.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,I.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,I.jsx)(`span`,{className:`w-4 shrink-0 text-xs tabular-nums text-muted-foreground`,"aria-hidden":`true`,children:n+1}),(0,I.jsx)(`span`,{className:`min-w-0 flex-1 break-words font-medium`,children:e.projectId}),(0,I.jsx)(`span`,{className:`shrink-0 font-semibold tabular-nums`,children:a(u)}),(0,I.jsx)(Be,{"data-export-exclude":!0,className:`size-4 shrink-0 text-muted-foreground`,"aria-hidden":`true`})]}),(0,I.jsx)(`div`,{className:`mt-2 ml-7 h-2 overflow-hidden rounded-full bg-muted`,"aria-hidden":`true`,children:(0,I.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,I.jsxs)(`p`,{className:`mt-1.5 ml-7 text-xs text-muted-foreground`,children:[l?.reportedTasks??0,` of `,e.tasks,` tasks report this metric`,f?``:` · No measured value`]})]})}),(0,I.jsxs)(Le,{className:`max-w-64`,children:[(0,I.jsxs)(`p`,{className:`font-medium`,children:[e.projectId,` · `,i,`: `,a(u)]}),(0,I.jsxs)(`p`,{children:[l?.reportedTasks??0,` of `,e.tasks,` tasks report this metric.`]}),(0,I.jsx)(`p`,{children:`Open project tasks`})]})]},e.projectId)})]}),e.length>0&&(0,I.jsxs)(`p`,{className:`mt-2 text-xs 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`},gn={cost:`Reported USD`,input:`Input tokens`,output:`Output tokens`};function _n(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 vn=(e,t)=>_t(e,t===`cost`);function Q(e){return[...e.cost?[`cost`]:[],...e.tokens?[`input`,`output`]:[]]}function yn({value:e,onChange:t,visibility:n}){return(0,I.jsxs)(`label`,{className:et,children:[`Sort by`,(0,I.jsx)(tt,{value:e,onChange:e=>t(e.target.value),children:Q(n).map(e=>(0,I.jsx)(`option`,{value:e,children:gn[e]},e))})]})}function bn(){return(0,I.jsx)(xn,{visibility:He(h().data)})}function xn({visibility:e}){return(0,I.jsxs)(M,{className:`gap-0 py-0`,children:[(0,I.jsx)(`div`,{className:z,children:(0,I.jsx)(`h2`,{className:R,children:`Usage & cost`})}),!e.cost&&!e.tokens?(0,I.jsx)(`p`,{className:`p-4 text-sm`,children:`Usage metrics are hidden by workspace settings`}):(0,I.jsx)(Sn,{visibility:e},`${e.cost}:${e.tokens}`)]})}function Sn({visibility:e}){let[t,n]=vt(`usagePeriod`,[`all`,`7d`,`30d`],`all`),[r,i]=vt(`usageSort`,Q(e),e.cost?`cost`:`input`);return(0,I.jsx)(Cn,{period:t,setPeriod:n,sort:r,setSort:i,visibility:e})}function Cn({period:e,setPeriod:t,sort:n,setSort:r,visibility:i}){let a=dn(e,n,`${i.cost}:${i.tokens}`),[o,s]=Y(`usage:accepted`,void 0),c=o??a.data,l=a.data??c,[u,d]=Y(`usage:panel`,null),[f,p]=(0,F.useState)(e);f!==e&&(p(e),s(void 0),d(null));let m=Bt(`usage:${u?.identity??`closed`}`),h=Vt(`usage`,`[data-usage-trigger]`),g=e=>{h.capture(),c&&d({identity:Rt(),projectId:e,snapshot:c,latestId:l?.snapshotId??c.snapshotId})},_=cn()??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&&_n(c,l),S=c?.coverage.projects.some(e=>e.state!==`complete`),C=l?.coverage.projects.some(e=>e.state!==`complete`),T=JSON.stringify(c?.coverage)!==JSON.stringify(l?.coverage),E=c?.totals.tasks===0&&!S&&!C;return(0,I.jsxs)(`div`,{className:`space-y-4 p-4 text-sm`,children:[c&&(0,I.jsx)(L,{rows:E?[]:[...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,I.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:(0,I.jsx)(it,{at:c.asOf})}),(0,I.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`h3`,{className:`font-medium`,children:`Lifetime totals of retained tasks`}),(0,I.jsxs)(`details`,{className:`mt-1 text-xs text-muted-foreground`,children:[(0,I.jsxs)(`summary`,{"data-export-heading":`Metric definitions`,className:`${$e} min-h-11`,children:[(0,I.jsx)(B,{}),`How these metrics work`]}),(0,I.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,I.jsxs)(`label`,{className:et,children:[`Tasks created`,(0,I.jsxs)(tt,{value:e,onChange:e=>t(e.target.value),children:[(0,I.jsx)(`option`,{value:`all`,children:`All time`}),(0,I.jsx)(`option`,{value:`7d`,children:`Last 7 days`}),(0,I.jsx)(`option`,{value:`30d`,children:`Last 30 days`})]})]})]}),e!==`all`&&(0,I.jsx)(`p`,{className:`text-muted-foreground`,children:`Lifetime usage of tasks created in this period — not spending during the period.`}),a.isPending&&(0,I.jsx)(`p`,{children:`Loading usage…`}),a.isError&&(0,I.jsxs)(`p`,{role:`alert`,children:[c?`Showing stale usage. Could not refresh.`:`Could not load usage.`,` `,(0,I.jsx)(w,{className:`min-h-11`,onClick:()=>void a.refetch(),children:`Retry`})]}),x&&(0,I.jsx)(`p`,{role:`status`,children:`Newer usage data is available; displayed values use the previous snapshot.`}),x&&(0,I.jsx)(w,{className:`min-h-11`,variant:`outline`,onClick:()=>s(l),children:`Updates available — Show`}),c&&S&&(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`p`,{className:`text-muted-foreground`,children:`Coverage of displayed usage:`}),(0,I.jsx)(G,{coverage:c.coverage,retry:()=>void a.refetch()})]}),l&&C&&T&&(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`p`,{className:`text-muted-foreground`,children:`Current source availability:`}),(0,I.jsx)(G,{coverage:l.coverage,retry:()=>void a.refetch()})]}),c&&(0,I.jsxs)(I.Fragment,{children:[!E&&(0,I.jsx)(`div`,{className:`report-cost-metrics grid gap-3 sm:grid-cols-[repeat(auto-fit,minmax(220px,1fr))]`,children:Q(v).map(e=>(0,I.jsx)(mn,{metric:e,label:gn[e],value:vn(c.totals[Z[e]]?.value,e),reported:c.totals[Z[e]]?.reportedTasks??0,total:c.totals.tasks},e))}),!v.cost&&!v.tokens&&(0,I.jsx)(`p`,{children:`Usage metrics are hidden by workspace settings`}),c.totals.tasks===0?(0,I.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,I.jsx)(`p`,{children:`No reports for the visible metrics in this cohort.`}),E&&(0,I.jsx)(`p`,{className:`text-muted-foreground`,children:`Usage appears when tasks report cost or tokens.`}),(0,I.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`}.`:``]}),!E&&(v.cost||v.tokens)&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`h3`,{className:`font-medium`,children:`Top projects`}),(0,I.jsx)(`p`,{className:`text-muted-foreground`,children:`Ranking uses reported metrics only.`})]}),(0,I.jsx)(yn,{value:y,onChange:r,visibility:v})]}),(0,I.jsx)(hn,{projects:b,metric:y,label:gn[y],field:Z[y],format:e=>vn(e,y),currentProjects:l?.projects??[],onSelect:g}),(0,I.jsx)(w,{"data-usage-trigger":!0,className:`min-h-11`,variant:`outline`,onClick:()=>g(``),children:`View tasks`})]})]}),(0,I.jsx)(Oe,{open:u!==null&&(v.cost||v.tokens),onOpenChange:e=>{e||d(null)},children:(0,I.jsxs)(De,{...m,className:`w-full overflow-y-auto sm:max-w-xl`,onCloseAutoFocus:e=>{e.preventDefault(),h.restore()},children:[(0,I.jsxs)(ke,{children:[(0,I.jsx)(Ae,{children:u?.projectId?`${u.projectId} tasks`:`All tasks`}),(0,I.jsx)(Ee,{children:`Lifetime usage of retained tasks. Missing reports are unavailable.`})]}),u!==null&&(0,I.jsx)(wn,{identity:`usage:${u.identity}`,snapshot:l&&l.snapshotId!==u.latestId?l:u.snapshot,projectId:u.projectId||void 0,visibility:v},u.identity)]})})]})}function wn({identity:e,snapshot:t,projectId:n,visibility:r}){let[i,a]=Y(`${e}:sort`,t.sort);return(0,I.jsx)(Tn,{identity:e,snapshot:t,projectId:n,visibility:r,sort:Q(r).includes(i)?i:Q(r)[0]??`cost`,setSort:a})}function Tn({identity:e,snapshot:t,projectId:n,visibility:r,sort:i,setSort:a}){let[o,s]=Y(`${e}:count`,20),[c,l]=Y(`${e}:paging`,void 0),[u,d]=(0,F.useState)(t.snapshotId);u!==t.snapshotId&&(d(t.snapshotId),l(void 0));let f=fn(c??t,n,i,o),p=cn()??r,m={cost:r.cost&&p.cost,tokens:r.tokens&&p.tokens},h=Q(m).includes(i)?i:Q(m)[0]??`cost`,[g,_]=Y(`${e}:accepted`,void 0),[v,y]=Y(`${e}:acceptedCount`,o),[b,x]=Y(`${e}:acceptedSort`,i),[S,C]=(0,F.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 T=g??f.data,E=f.data&&T&&_n(f.data,T),ee=T?.coverage.projects.some(e=>e.state!==`complete`),D=f.data?.coverage.projects.some(e=>e.state!==`complete`),te=JSON.stringify(T?.coverage)!==JSON.stringify(f.data?.coverage),ne=!n||t.projects.some(e=>e.projectId===n);return(0,I.jsxs)(`div`,{className:`space-y-3 p-4 text-sm`,"data-sheet-loading":f.isFetching,children:[(0,I.jsx)(yn,{value:h,onChange:a,visibility:m}),f.isPending&&(0,I.jsx)(`p`,{children:`Loading tasks…`}),f.isError&&(0,I.jsxs)(`p`,{role:`alert`,children:[`Could not refresh tasks. `,T?`Showing stale usage.`:``,` `,(0,I.jsx)(w,{className:`min-h-11`,onClick:()=>void f.refetch(),children:`Retry`})]}),E&&(0,I.jsx)(w,{className:`min-h-11`,onClick:()=>{_(f.data),y(o),x(i)},children:`Updates available — Show`}),T&&ee&&(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`p`,{className:`text-muted-foreground`,children:`Coverage of displayed tasks:`}),(0,I.jsx)(G,{coverage:T.coverage,retry:()=>void f.refetch()})]}),f.data&&D&&te&&(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`p`,{className:`text-muted-foreground`,children:`Current source availability:`}),(0,I.jsx)(G,{coverage:f.data.coverage,retry:()=>void f.refetch()})]}),T&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`p`,{className:`border-b pb-2 font-mono text-[11px] text-soft-foreground`,children:[T.tasks.rows.length,` of `,T.tasks.total,` retained tasks`]}),T.tasks.total===0&&(0,I.jsx)(`p`,{children:T.coverage.projects.some(e=>e.state!==`complete`)?`No tasks could be read from available sources.`:`No retained tasks in this cohort.`}),T.tasks.rows.map(e=>(0,I.jsx)(En,{row:e,sort:h,visibility:m,disabled:!ne||!f.data||!!(E&&!f.data?.tasks.rows.some(t=>t.id===e.id&&t.projectId===e.projectId))},`${e.projectId}:${e.id}`)),T.tasks.nextOffset!==null&&(0,I.jsx)(w,{className:`min-h-11`,disabled:f.isFetching,onClick:()=>{l(T),s(e=>e+20)},children:`Show 20 more tasks`})]})]})}function En({row:e,sort:t,visibility:n,disabled:r}){let i=le(e);r||=i===null;let a=o(i?{status:i.status,awaitingAnswerSince:i.awaitingAnswerSince}:e),s=Q(n).filter(e=>e!==t),c=t=>{let n=e[Z[t]];return n==null?`—`:vn(n,t)},l=t=>`${gn[t]}: ${vn(e[Z[t]],t)}`;return(0,I.jsxs)(`div`,{className:`grid grid-cols-[minmax(0,1fr)_auto] items-start gap-x-4 border-b py-3 last:border-0`,children:[(0,I.jsxs)(`div`,{className:`min-w-0`,children:[(0,I.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,I.jsx)(N,{tone:a.tone,pulse:a.pulse,className:`mt-[7px]`}),(0,I.jsx)(D,{className:`line-clamp-2 break-words font-medium leading-snug hover:underline no-hover:min-h-11`,title:e.title,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,I.jsxs)(`p`,{className:`mt-1 pl-[15px] font-mono text-[11px] text-soft-foreground`,children:[e.projectId,` · `,r?`Checking current state…`:i?.status??e.status,e.archived?` · Archived`:``,e.subtask?` · Subtask`:``]})]}),(0,I.jsxs)(`div`,{className:`text-right tabular-nums`,children:[(0,I.jsx)(`span`,{"aria-label":l(t),className:`block font-semibold ${e[Z[t]]==null?`text-soft-foreground`:``}`,children:c(t)}),s.length>0&&(0,I.jsx)(`span`,{className:`mt-1 flex justify-end gap-3 font-mono text-[11px] text-soft-foreground`,children:s.map(e=>(0,I.jsxs)(`span`,{"aria-label":l(e),children:[c(e),` `,e===`cost`?``:e===`input`?`in`:`out`]},e))})]})]})}var Dn={cost:`costUsd`,input:`inputTokens`,output:`outputTokens`},On={cost:`Reported USD`,input:`Input tokens`,output:`Output tokens`};function kn(e){return[...e.cost?[`cost`]:[],...e.tokens?[`input`,`output`]:[]]}var An=(e,t)=>_t(e,t===`cost`);function jn(e){return new Date(`${e}T00:00:00`).toLocaleDateString(void 0,{month:`short`,day:`numeric`})}function Mn({series:e,height:t,accent:n,renderTooltip:r,describe:i}){let a=Math.max(1,...e.map(t));return(0,I.jsxs)(Re,{delayDuration:150,children:[(0,I.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,I.jsxs)(ze,{children:[(0,I.jsx)(Ie,{asChild:!0,children:(0,I.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,I.jsx)(`span`,{style:{height:`${s}%`},className:`block w-full rounded-t-sm ${n}`})})}),(0,I.jsx)(Le,{children:r(e)})]},e.date)})}),(0,I.jsxs)(`div`,{className:`mt-1 flex justify-between text-xs text-muted-foreground`,children:[(0,I.jsx)(`span`,{children:jn(e[0].date)}),(0,I.jsx)(`span`,{children:jn(e.at(-1).date)})]})]})}function Nn({metrics:e,series:t}){return(0,I.jsxs)(`table`,{className:`w-full text-left text-xs`,children:[(0,I.jsx)(`thead`,{children:(0,I.jsxs)(`tr`,{className:`border-b`,children:[(0,I.jsx)(`th`,{className:`py-1 pr-2 font-medium`,children:`Date`}),e.map(e=>(0,I.jsx)(`th`,{className:`py-1 pr-2 text-right font-medium`,children:On[e]},e)),(0,I.jsx)(`th`,{className:`py-1 pr-2 text-right font-medium`,children:`Completed`}),(0,I.jsx)(`th`,{className:`py-1 text-right font-medium`,children:`Avg cycle`})]})}),(0,I.jsx)(`tbody`,{children:t.map(t=>(0,I.jsxs)(`tr`,{className:`border-b last:border-0`,children:[(0,I.jsx)(`td`,{className:`py-1 pr-2`,children:jn(t.date)}),e.map(e=>(0,I.jsx)(`td`,{className:`py-1 pr-2 text-right tabular-nums`,children:An(t[Dn[e]]?.value,e)},e)),(0,I.jsx)(`td`,{className:`py-1 pr-2 text-right tabular-nums`,children:t.completed}),(0,I.jsx)(`td`,{className:`py-1 text-right tabular-nums`,children:t.avgCycleHours===null?`—`:K(t.avgCycleHours)})]},t.date))})]})}function Pn({metric:e,series:t}){let n=pn[e],r=Dn[e],i=t.reduce((e,t)=>e+(t[r]?.reportedTasks??0),0);return(0,I.jsxs)(`div`,{className:`rounded-xl border p-3`,children:[(0,I.jsx)(`p`,{className:`text-xs font-medium ${n.text}`,children:On[e]}),(0,I.jsx)(`div`,{className:`mt-2`,children:(0,I.jsx)(Mn,{series:t,describe:t=>`${t.date}, ${On[e]}: ${An(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,I.jsxs)(`p`,{children:[jn(t.date),` · `,An(t[r]?.value,e),` ·`,` `,t[r]?.reportedTasks??0,`/`,t.tasks,` tasks reported`]})})}),i===0&&(0,I.jsx)(`p`,{className:`mt-2 text-xs text-muted-foreground`,children:`No reports in this period.`})]})}function Fn({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,I.jsxs)(`div`,{className:`rounded-xl border p-3`,children:[(0,I.jsxs)(`div`,{className:`flex flex-wrap items-baseline justify-between gap-2`,children:[(0,I.jsx)(`p`,{className:`text-xs font-medium text-success`,children:`Completed tasks`}),(0,I.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[t,` done · avg cycle`,` `,i===null?`unavailable`:K(i)]})]}),(0,I.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[r,`/`,t,` completed tasks have valid cycle times.`]}),(0,I.jsx)(`div`,{className:`mt-2`,children:(0,I.jsx)(Mn,{series:e,describe:e=>`${e.date}: ${e.completed} completed tasks, average cycle ${e.avgCycleHours==null?`Unavailable`:K(e.avgCycleHours)}`,height:e=>e.completed,accent:`bg-success`,renderTooltip:e=>(0,I.jsxs)(`div`,{children:[(0,I.jsxs)(`p`,{children:[jn(e.date),` · `,e.completed,` completed`]}),(0,I.jsxs)(`p`,{children:[`Avg cycle`,` `,e.avgCycleHours===null?`unavailable`:K(e.avgCycleHours),` · Median`,` `,e.medianCycleHours===null?`unavailable`:K(e.medianCycleHours)]})]})})}),t===0&&(0,I.jsx)(`p`,{className:`mt-2 text-xs text-muted-foreground`,children:`No tasks finished in this period.`})]})}function In(){return(0,I.jsx)(Ln,{visibility:He(h().data)})}function Ln({visibility:e}){let[t,n]=vt(`trendPeriod`,[`7d`,`30d`],`7d`),r=dn(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=kn({cost:e.cost&&i?.visibility.cost!==!1,tokens:e.tokens&&i?.visibility.tokens!==!1});return(0,I.jsxs)(M,{className:`gap-0 py-0`,children:[(0,I.jsxs)(`div`,{className:z,children:[(0,I.jsx)(`h2`,{className:R,children:`Trends`}),(0,I.jsxs)(`label`,{className:et,children:[`Period`,(0,I.jsxs)(tt,{value:t,onChange:e=>n(e.target.value),children:[(0,I.jsx)(`option`,{value:`7d`,children:`Last 7 days`}),(0,I.jsx)(`option`,{value:`30d`,children:`Last 30 days`})]})]})]}),(0,I.jsxs)(`div`,{className:`space-y-4 p-4 text-sm`,children:[i&&(0,I.jsx)(L,{rows:a?[]:i.series.flatMap(e=>[...o.map(t=>({section:`daily-creation-cohort`,entity:e.date,metric:Dn[t],value:e[Dn[t]]?.value??null,unit:t===`cost`?`USD`:`tokens`,reportedTasks:e[Dn[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,I.jsxs)(`details`,{className:`text-xs text-muted-foreground`,children:[(0,I.jsxs)(`summary`,{"data-export-heading":`Metric definitions`,className:`${$e} py-2`,children:[(0,I.jsx)(B,{}),`How these metrics work`]}),(0,I.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,I.jsx)(`p`,{children:`Loading trends…`}),r.isError&&(0,I.jsxs)(`p`,{role:`alert`,children:[i?`Showing stale trends. Could not refresh.`:`Could not load trends.`,` `,(0,I.jsx)(w,{className:`min-h-11`,onClick:()=>void r.refetch(),children:`Retry`})]}),i&&(0,I.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:(0,I.jsx)(it,{at:i.asOf})}),i&&(0,I.jsx)(G,{coverage:i.coverage,retry:()=>void r.refetch()}),i&&a&&(0,I.jsx)(`p`,{className:`text-muted-foreground`,children:`No retained tasks in this period yet.`}),i&&!a&&i.series.length>0&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`div`,{className:`space-y-4`,children:[o.length>0&&(0,I.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-[repeat(auto-fit,minmax(200px,1fr))]`,children:o.map(e=>(0,I.jsx)(Pn,{metric:e,series:i.series},e))}),(0,I.jsx)(Fn,{series:i.series})]}),(0,I.jsxs)(`details`,{className:`group rounded-lg border bg-muted/20 print:block`,children:[(0,I.jsxs)(`summary`,{"data-export-heading":`Daily data`,className:`flex min-h-11 cursor-pointer list-none items-center gap-2 px-3 text-xs font-medium text-muted-foreground hover:text-foreground [&::-webkit-details-marker]:hidden`,children:[(0,I.jsx)(Ye,{className:`size-4`,"aria-hidden":`true`}),` View data table`,(0,I.jsx)(Fe,{className:`ml-auto size-4 transition-transform group-open:rotate-180`,"aria-hidden":`true`})]}),(0,I.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,I.jsx)(Nn,{metrics:o,series:i.series})})]})]})]})]})}function Rn(e,t,n,r=!0){let i=c();return d({queryKey:[...X.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 Zt(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 u&&e.status===409){let e=await Xt(r);i.setQueryData(X.snapshot,e)}throw e}}})}function zn(e,t,n,r){let i=c(),a=t===`questions`||t===`reviews`?`needs-you`:t,o=a===`needs-you`?0:n,s=r.map(e=>`${e.projectId}:${e.id}`).sort();return d({queryKey:[...X.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 Zt(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 u&&e.status===409&&i.setQueryData(X.snapshot,await Xt(t)),e}}})}function Bn({snapshot:e,questions:t,reviews:n,more:r,healthy:i=!0}){let a=ye();return(0,I.jsxs)(M,{className:`min-w-0 gap-0 overflow-hidden py-0`,children:[(0,I.jsxs)(`div`,{className:z,children:[(0,I.jsxs)(`h2`,{id:`dashboard-needs-you`,tabIndex:-1,className:R,children:[`Needs you · `,e.counts.questions+e.counts.reviews]}),(0,I.jsxs)(`p`,{className:`font-mono text-[11px] text-soft-foreground`,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,I.jsxs)(`p`,{className:`flex items-center gap-2.5 px-4 py-8 text-sm text-muted-foreground`,children:[(0,I.jsx)(N,{tone:`success`}),`All caught up — no tasks need your input`]}):null,(0,I.jsx)(Vn,{snapshot:e,group:`questions`,count:t,more:r}),(0,I.jsx)(Vn,{snapshot:e,group:`reviews`,count:n,more:r})]})}function Vn({snapshot:e,group:t,count:n,more:r}){let i=e[t],a=Math.max(n,i.rows.length),o=Rn(e,t,a,a>i.rows.length),s=a>i.rows.length?o.data:i.rows,c=ut(s,W,t,n),l=zn(e,t,a,c.rows.filter(e=>e.removed).map(e=>e.row)),u=(0,F.useRef)(null);return!i.total&&!c.rows.length?null:(0,I.jsxs)(`section`,{children:[(0,I.jsxs)(`h3`,{ref:u,tabIndex:-1,className:`border-b bg-card-2 px-4 py-2 font-mono text-[11px] font-semibold uppercase tracking-[0.12em] text-muted-foreground`,children:[t===`questions`?`Questions`:`Reviews`,` · `,i.total]}),c.updates>0&&(0,I.jsxs)(w,{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,I.jsx)(gt,{row:l.data?.get(W(e))??e,removed:t&&!!l.data&&!l.data.has(W(e)),checking:s===void 0||t&&!l.data,checkFailed:s===void 0&&o.isError||t&&!l.data&&l.isError,queue:!0},W(e))),(o.isError||l.isError)&&(0,I.jsxs)(`p`,{role:`alert`,className:`p-4 text-sm`,children:[`Could not check current task state.`,` `,(0,I.jsx)(w,{variant:`ghost`,className:`min-h-11`,onClick:()=>{o.refetch(),l.refetch()},children:`Retry`})]}),a<i.total&&(0,I.jsxs)(w,{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 Hn(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 Un=e=>e.key;function Wn({filter:e,setFilter:t,count:n,more:r}){let i=tn(e,!0),a=ut(i.data?.rows,Un,`feed:${e}`,0,e=>e.kind===`task-result`),o=a.rows,s=a.updates,c=(0,F.useContext)(ct),l=(0,F.useRef)(null),u=`feed:${e}`,d=(0,F.useMemo)(()=>({scroll:mt(c,u)?.scroll??0,done:!1}),[c,u]);(0,F.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,F.useRef)(null),p=i.data?.sources.filter(e=>e.key.startsWith(`github:`))??[],m=p.flatMap(e=>e.fetchedAt?[e.fetchedAt]:[]).sort()[0],h=i.githubError,g=p.filter(e=>e.reason===`No GitHub remote`),_=p.some(e=>e.reason===`Still loading GitHub`),v=p.length>0&&g.length===p.length&&!h,y=p.filter(e=>e.state!==`ready`&&e.reason!==`No GitHub remote`&&e.reason!==`Still loading GitHub`),b=v&&e===`all`;return(0,I.jsxs)(M,{"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,I.jsxs)(`div`,{className:`space-y-2 border-b px-4 pt-2.5 pb-2`,children:[(0,I.jsxs)(`div`,{className:`flex min-h-9 flex-wrap items-center justify-between gap-2`,children:[(0,I.jsx)(`h2`,{ref:f,tabIndex:-1,className:R,children:b?`Recent results`:`Recent results & GitHub`}),(0,I.jsx)(`span`,{className:`font-mono text-[11px] text-soft-foreground`,children:`Last 7 days`})]}),!b&&(0,I.jsx)(pe,{slot:`dashboard-feed`,label:`Results source`,value:e,options:[{value:`all`,label:`All`},{value:`tasks`,label:`Tasks`},{value:`github`,label:`GitHub`}],onChange:t}),b&&(0,I.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Task results · No GitHub repositories configured`}),e!==`tasks`&&!b&&(0,I.jsxs)(`details`,{className:`text-xs text-muted-foreground`,open:y.length||h?!0:void 0,children:[(0,I.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,I.jsx)(B,{}),y.length||h?`GitHub needs attention`:_?`Checking GitHub…`:v?`GitHub not configured`:m?`GitHub checked ${P(m)} ago`:`GitHub source`]}),(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-x-3`,children:[(0,I.jsx)(`p`,{children:y.length||h?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.`:_?`Checking repository sources. Available results remain visible.`:v?`No GitHub repositories configured. Select Tasks to see task results.`:m?`GitHub checked ${P(m)} ago`:`GitHub snapshot`}),!v&&(0,I.jsx)(w,{variant:`ghost`,className:`min-h-11 px-0`,disabled:i.githubFetching,onClick:()=>{i.refetch()},children:i.githubFetching?`Refreshing…`:y.length||h?`Retry GitHub`:`Refresh GitHub`})]})]})]}),(0,I.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&&ht(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,I.jsxs)(`p`,{role:`alert`,className:`p-4 text-sm`,children:[`Could not load results.`,` `,(0,I.jsx)(w,{className:`min-h-11`,onClick:()=>{i.retryFailed()},children:`Retry`})]}),i.isPending&&(0,I.jsx)(`p`,{className:`p-4 text-sm`,children:`Loading results…`}),s>0&&(0,I.jsxs)(w,{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,I.jsx)(gt,{row:e.run,kicker:t?`Outside current results`:`Latest result: ${e.run.status===`failed`?`Failed`:`Completed`}`},e.key):(0,I.jsxs)(`div`,{className:`border-b px-4 py-3 transition-colors hover:bg-muted/30`,children:[(0,I.jsx)(L,{rows:[{section:`github`,entity:`${e.repo}#${e.number}`,metric:e.itemKind,value:e.title,asOf:e.at,note:e.url}]}),(0,I.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,I.jsxs)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:[e.repo,` · `,e.itemKind===`pr`?`PR`:`Issue`,` #`,e.number,` created ·`,` `,P(e.at)]})]},e.key)),i.data&&!i.data.rows.length&&!o.length&&!i.isFetching&&!i.isError&&!y.length&&!_&&i.data.coverage.projects.every(e=>e.state===`complete`)&&(0,I.jsx)(`p`,{className:`px-4 py-8 text-sm text-muted-foreground`,children:`No results in the last 7 days`}),n<o.length&&(0,I.jsxs)(w,{variant:`ghost`,className:`m-2 min-h-11`,onClick:r,children:[`Show `,Math.min(20,o.length-n),` more results`]}),i.data?.truncated&&(0,I.jsx)(`p`,{className:`p-4 text-xs`,children:`Showing the latest 60 results`}),i.data&&(0,I.jsx)(G,{coverage:i.data.coverage,retry:()=>{i.retryTasks()}}),!b&&i.data?.sources.some(e=>e.state!==`ready`||e.truncated)&&(0,I.jsxs)(`details`,{className:`p-4 text-xs`,children:[(0,I.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,I.jsx)(B,{}),`Source details`]}),i.data.sources.map(e=>(0,I.jsxs)(`p`,{className:`break-words py-1`,children:[Hn(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 ${P(e.fetchedAt)}`:``]},e.key))]})]})]})}var $=e=>e.replace(/[&<>"']/g,e=>({"&":`&`,"<":`<`,">":`>`,'"':`"`,"'":`'`})[e]),Gn=`Visible modules and loaded rows only. Filters and report availability apply. Retained task usage is not an invoice or a complete history.`,Kn=`Confidential — internal distribution only`,qn={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 Jn(e,t){return e==null?`Unavailable`:typeof e==`string`?e:_t(e,t)}function Yn(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=qn[e.metric];!i||t.has(e.metric)||(t.add(e.metric),n.push({label:i.label,value:Jn(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 Xn(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-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 Zn(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-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:Xn(e),rows:[...e.querySelectorAll(`[data-dashboard-export]`)].flatMap(e=>JSON.parse(e.dataset.dashboardExport))}})}}function Qn(e){let t=e==null?``:String(e);return typeof e==`string`&&/^[\s\uFEFF]*[=+@\-]/.test(t)&&(t=`'${t}`),`"${t.replaceAll(`"`,`""`)}"`}function $n(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`,Gn,``,``,``,``,``,[...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(Qn).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{$i as r,$r as i,Ci as a,G as o,Ln as s,Qt as c,Xt as l,Yn as u,gn as d,ir as f,j as p,xa as m,ya as h,zn as g}from"./queries-Bn7zl9OU.js";import{$ as _,F as v,Q as y,Z as b,et as x,it as S,nt as C,t as w,tt as T,vt as E}from"./button-Clwd6u4_.js";import{T as ee,m as D,x as te}from"./project-router-CZzr7lzN.js";import{S as ne,a as re,o as ie,r as ae,t as oe}from"./reference-chip-CScP5y_O.js";import{A as O,C as se,E as k,M as A,N as j,O as ce,P as le,T as ue,_ as de,b as fe,c as pe,d as me,f as he,g as ge,h as _e,i as ve,j as ye,m as be,p as xe,v as Se,w as Ce,x as we,y as Te}from"./use-automations-Dh3Wj-79.js";import{a as Ee,i as De,n as Oe,o as ke,s as Ae,t as je}from"./use-now-BB7W0F--.js";import{a as Me,f as M,p as Ne,r as Pe}from"./automation-format-BL4n19a2.js";import{f as Fe,i as Ie,n as Le,r as Re,t as ze}from"./tooltip-B628Gs7C.js";import{t as Be}from"./chevron-right-VbYrJ_st.js";import{t as Ve}from"./download-DOJ8Dqfh.js";import{i as N,r as P,t as He}from"./token-metrics-Dk2ZNHb_.js";import{t as Ue}from"./index-qeFtKZ4e.js";var We=v(`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`}]]),Ge=v(`arrow-down-left`,[[`path`,{d:`M17 7 7 17`,key:`15tmo1`}],[`path`,{d:`M17 17H7V7`,key:`1org7z`}]]),Ke=v(`circle-alert`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`line`,{x1:`12`,x2:`12`,y1:`8`,y2:`12`,key:`1pkeuh`}],[`line`,{x1:`12`,x2:`12.01`,y1:`16`,y2:`16`,key:`4dfq90`}]]),qe=v(`circle-question-mark`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3`,key:`1u773s`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]]),Je=v(`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`}]]),Ye=v(`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`}]]),F=e(t(),1);function Xe(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 Ze(e){return e.flatMap(e=>(e.data?.automations??[]).filter(e=>e.enabled).map(t=>({project:e,automation:t,at:Xe(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 Qe(e){let t=o(),n=m(),i=t.data?.projects??[],a=t.data?.bootProject,s=a&&!i.some(e=>e.id===a)?[...i,{id:a,name:a,status:`ok`}]:i,l=h({queryKey:[...c.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 i=s[t++];if(i.status===`missing`){n.push({...i,error:`Project folder unavailable`});continue}try{let t=S.parse(await r(await f.api.v1.workspace.dashboard.automations.$get({query:{projectId:i.id}},{init:{signal:e}}),`/workspace/dashboard/automations`));n.push({id:i.id,name:i.name,data:t})}catch{n.push({id:i.id,name:i.name,error:`Could not load automations`})}}})),n}});return(0,F.useEffect)(()=>{if(e)return ce(e=>{e===`automation-change`&&n.invalidateQueries({queryKey:[...c.dashboard,`automations`]})})},[n,e]),{...l,registry:t,retry:()=>{t.refetch(),l.refetch()}}}var I=n();function L({rows:e}){return(0,I.jsx)(`span`,{hidden:!0,"data-dashboard-export":JSON.stringify(e)})}var R=`section-mark font-mono text-[11px] font-semibold uppercase tracking-[0.14em] text-muted-foreground`,z=`flex min-h-12 flex-wrap items-center justify-between gap-x-3 gap-y-2 border-b px-4 py-2.5`,$e=`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 B(){return(0,I.jsx)(Be,{"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 et=`flex items-center gap-2 text-xs text-muted-foreground`;function tt({className:e=``,...t}){return(0,I.jsxs)(`span`,{className:`relative inline-flex`,children:[(0,I.jsx)(`select`,{...t,className:`h-9 cursor-pointer appearance-none rounded-md border bg-card-2 pr-8 pl-3 font-mono text-xs text-foreground outline-none transition-colors hover:border-foreground/20 hover:bg-muted focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 no-hover:min-h-11 ${e}`}),(0,I.jsx)(Fe,{"aria-hidden":`true`,className:`pointer-events-none absolute top-1/2 right-2.5 size-3.5 -translate-y-1/2 text-soft-foreground`})]})}var nt=`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`,V={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 rt({label:e,value:t,icon:n,children:r}){return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`span`,{className:`flex w-full items-center justify-between gap-2`,children:[(0,I.jsx)(`span`,{className:`font-mono text-[11px] font-medium uppercase tracking-[0.12em] text-muted-foreground`,children:e}),(0,I.jsx)(`span`,{className:`text-soft-foreground`,"aria-hidden":`true`,children:n})]}),(0,I.jsx)(`span`,{className:`mt-4 block text-4xl font-semibold leading-none tracking-tight tabular-nums`,children:t}),(0,I.jsx)(`span`,{className:`mt-3 block text-xs text-soft-foreground`,children:r})]})}function it({at:e}){return(0,I.jsxs)(`time`,{dateTime:e,title:new Date(e).toLocaleString(),children:[`Updated `,P(e),` ago`]})}function at(){let e=ve(),t=Qe(e.known&&!e.off),n=je(3e4),[r,i]=(0,F.useState)(!1),a=Ze(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,I.jsxs)(M,{"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,I.jsxs)(`div`,{className:z,children:[(0,I.jsxs)(`h2`,{className:`flex items-center ${R}`,children:[`Automations`,(0,I.jsx)(Ne,{className:`ml-2 size-3.5 text-soft-foreground`,"aria-hidden":`true`})]}),!e.off&&t.data&&(0,I.jsxs)(`span`,{className:`font-mono text-[11px] text-soft-foreground`,children:[a.length,` enabled`,l?` · partial`:``]})]}),!e.off&&t.data&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(L,{rows:[{section:`automations`,metric:`enabled`,value:a.length,unit:`automations`,note:l?`Partial project coverage`:`Loaded projects`}]}),t.dataUpdatedAt>0&&(0,I.jsx)(`p`,{className:`px-4 pt-3 text-xs text-muted-foreground`,children:(0,I.jsx)(it,{at:new Date(t.dataUpdatedAt).toISOString()})})]}),e.off?(0,I.jsx)(`p`,{className:`p-4 text-sm text-muted-foreground`,children:`Automations are disabled in this workspace.`}):(0,I.jsxs)(I.Fragment,{children:[c&&(0,I.jsx)(`p`,{className:`p-4 text-sm text-muted-foreground`,children:`Loading automations…`}),l&&(0,I.jsxs)(`div`,{role:`alert`,className:`p-4 text-sm`,children:[(0,I.jsx)(`p`,{children:`Some automation data could not be refreshed. Available results are shown.`}),s.map(e=>(0,I.jsxs)(`p`,{children:[e.name,`: `,e.error]},e.id)),(0,I.jsx)(w,{variant:`ghost`,onClick:t.retry,children:`Retry automations`})]}),!c&&!l&&a.length===0&&(0,I.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`:Me(r,n),o=t.kind===`schedule`?`Next run`:`Next check`;return(0,I.jsxs)(`div`,{"data-export-row":!0,className:`border-b px-4 py-3 transition-colors last:border-0 hover:bg-muted/30`,children:[(0,I.jsx)(D,{className:`block min-h-11 text-sm font-medium hover:underline`,to:`/p/${encodeURIComponent(e.id)}/automations/${encodeURIComponent(t.id)}`,children:t.name}),(0,I.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[e.name,` · `,o,`: `,a]}),r!==null&&(0,I.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:(0,I.jsxs)(`time`,{dateTime:new Date(r).toISOString(),children:[Pe(r,e.data.timeZone),` · `,e.data.timeZone]})}),t.kind!==`schedule`&&(0,I.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:`Checks for matching events; a task may not be started.`}),i&&(0,I.jsx)(`p`,{className:`mt-1 text-xs text-warning`,children:i}),(0,I.jsx)(L,{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,I.jsx)(w,{variant:`ghost`,className:`m-2 min-h-11`,onClick:()=>i(!r),children:r?`Show fewer`:`Show all ${a.length} enabled`}),!c&&(0,I.jsxs)(`details`,{className:`border-t px-4 py-2 text-xs text-muted-foreground`,children:[(0,I.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,I.jsx)(B,{}),`Manage automations by project`]}),t.data?.map(e=>(0,I.jsx)(D,{className:`block min-h-11 py-3 hover:underline`,to:`/p/${encodeURIComponent(e.id)}/automations`,children:e.name},e.id))]})]})]})}function ot(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 st(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 ct=(0,F.createContext)(``),lt=(0,F.createContext)(!0),H=new Map;function ut(e,t,n=``,r=0,i){let a=(0,F.useContext)(ct),o=`${a}:${n}`,[s,c]=(0,F.useState)(()=>H.get(o)),[l,u]=(0,F.useState)(o),d=(0,F.useRef)(r),f=(0,F.useRef)(!1);l!==o&&(u(o),c(H.get(o)),d.current=r,f.current=!1),d.current!==r&&(d.current=r,f.current=!0),(0,F.useEffect)(()=>{e&&(!s||f.current)&&(c(e),f.current=!1)},[s,e]);let p=(0,F.useMemo)(()=>({current:s}),[o]);p.current=s,(0,F.useEffect)(()=>()=>{!a||!p.current||(H.delete(o),H.set(o,p.current),H.size>60&&H.delete(H.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:st(g,e??m,t),updates:e?ot(g,e,t).size:0,show:()=>c(e)}}var dt=new Map;function ft(e){return dt.get(e)}function pt(e,t){dt.delete(e),dt.set(e,t),dt.size>20&&dt.delete(dt.keys().next().value)}var U=new Map;function mt(e,t){return U.get(e)?.[t]}function ht(e,t,n){let r=U.get(e)??{};r[t]=n,U.delete(e),U.set(e,r),U.size>20&&U.delete(U.keys().next().value)}var W=e=>`${e.projectId}:${e.id}`;function gt({row:e,removed:t=!1,queue:n=!1,checking:r=!1,checkFailed:i=!1,kicker:a}){let o=(0,F.useContext)(lt)&&!r&&!i,c=le(e);t=t||c===null||n&&c?.archived===!0,c&&(e={...e,status:c.status,awaitingAnswerSince:c.awaitingAnswerSince});let l=s(e),u=n&&!g(e),f=t||u||!o;return(0,I.jsxs)(`div`,{"data-dashboard-row":W(e),className:`min-w-0 border-b px-4 py-3 transition-colors last:border-0 hover:bg-muted/30`,children:[(0,I.jsx)(L,{rows:[{section:`task`,entity:W(e),metric:`title`,value:e.titleSummary||e.title},{section:`task`,entity:W(e),metric:`status`,value:f?`Not currently actionable`:e.status},{section:`task`,entity:W(e),metric:`createdAt`,value:e.createdAt}]}),a&&(0,I.jsx)(`p`,{className:`mb-1 pl-[15px] font-mono text-[10.5px] uppercase tracking-[0.1em] text-soft-foreground`,children:a}),(0,I.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,I.jsx)(N,{tone:l.tone,className:`mt-[7px]`}),(0,I.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,I.jsx)(D,{tabIndex:f?-1:void 0,"aria-disabled":f||void 0,onClick:e=>{f&&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,I.jsxs)(`div`,{className:`mt-1 flex flex-wrap items-center gap-x-2 gap-y-1 text-xs text-muted-foreground`,children:[(0,I.jsx)(`span`,{className:`font-mono text-[11px] text-soft-foreground`,children:e.projectId}),(0,I.jsx)(`span`,{children:i?`Could not check current state`:o?t?n&&c!==null?`No longer needs you`:`Task removed`:u?`No longer needs you`:l.label:`Checking current state…`}),(0,I.jsx)(`span`,{children:P(e.createdAt)}),e.dispatch&&(0,I.jsx)(`span`,{children:`Subtask`}),!f&&d(e).map(t=>(0,I.jsx)(oe,{reference:t,taskTitle:e.title,projectId:e.projectId,className:`no-hover:min-h-11`},`${t.kind}:${t.number}`))]})]})]})]})}function G({coverage:e,count:t,retry:n}){let r=e.projects.filter(e=>e.state!==`complete`);return r.length?(0,I.jsxs)(`div`,{className:`rounded-lg border border-pending/40 bg-card-2 p-3 text-sm`,role:`status`,children:[(0,I.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,I.jsxs)(`details`,{className:`mt-2`,children:[(0,I.jsxs)(`summary`,{className:`${$e} min-h-11`,children:[(0,I.jsx)(B,{}),`View unavailable `,r.length===1?`project`:`projects`]}),r.map(e=>(0,I.jsxs)(`p`,{children:[e.projectId,`: `,e.reason??e.state,e.omittedRuns>0?` · ${e.omittedRuns} omitted tasks`:``]},e.projectId))]}),(0,I.jsx)(w,{variant:`outline`,onClick:n,className:`min-h-11`,children:`Retry`})]}):null}function _t(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 K(e){return e===null?`Unavailable`:e<1?`${Math.round(e*60)}m`:e<48?`${e.toFixed(1)}h`:`${(e/24).toFixed(1)}d`}function vt(e,t,n){let r=te(),i=r.state?.dashboardEntry??r.key,[a,o]=ee(),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 yt=e=>`Last ${e===`7d`?7:30} calendar days`,bt=`font-mono text-[11px] font-semibold uppercase tracking-[0.12em] text-muted-foreground`,xt=`min-w-0 rounded-lg border bg-card-2 p-4`,q=`whitespace-nowrap px-3 py-2 font-mono text-[11px] font-medium uppercase tracking-[0.1em] text-soft-foreground`;function St(){let e=o().data?.projects;return t=>e?.find(e=>e.id===t)?.name??t}var Ct=(e,t)=>`/p/${encodeURIComponent(e)}/tasks/${encodeURIComponent(t)}`;function wt({label:e,value:t,onChange:n}){return(0,I.jsxs)(`label`,{className:et,children:[e,(0,I.jsxs)(tt,{value:t,onChange:e=>n(e.target.value===`30d`?`30d`:`7d`),children:[(0,I.jsx)(`option`,{value:`7d`,children:`Last 7 days`}),(0,I.jsx)(`option`,{value:`30d`,children:`Last 30 days`})]})]})}function Tt({query:e}){return e.isPending?(0,I.jsx)(`p`,{role:`status`,className:`text-sm text-muted-foreground`,children:`Loading insights…`}):e.isError?(0,I.jsxs)(`p`,{role:`alert`,className:`text-sm`,children:[e.data?`Showing previous results. `:``,`Could not refresh insights.`,` `,(0,I.jsx)(w,{variant:`outline`,onClick:()=>void e.refetch(),children:`Retry insights`})]}):null}function Et({period:e,active:t}){let n=Ue(e,t),r=n.data;return(0,I.jsxs)(`div`,{className:`space-y-3`,children:[(0,I.jsx)(Tt,{query:n}),r&&(0,I.jsx)(G,{coverage:r.coverage,retry:()=>void n.refetch()}),r&&(0,I.jsxs)(`div`,{className:`grid gap-3 lg:grid-cols-2`,children:[(0,I.jsx)(Dt,{data:r}),(0,I.jsx)(Ot,{data:r})]})]})}function Dt({data:e}){let t=e.delivered,n=[{label:`PRs opened`,value:t.prsOpened,note:`${t.prsTouched} touched`},{label:`Lines`,value:(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`span`,{className:`text-success`,children:[`+`,t.additions.toLocaleString(`en-US`)]}),` `,(0,I.jsxs)(`span`,{className:`text-danger`,children:[`−`,t.deletions.toLocaleString(`en-US`)]})]})},{label:`Files`,value:t.files.toLocaleString(`en-US`)},{label:`Issues`,value:t.issues}];return(0,I.jsxs)(`section`,{className:xt,"aria-label":`Delivered`,children:[(0,I.jsx)(L,{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,I.jsx)(`h3`,{className:bt,children:`Delivered`}),(0,I.jsx)(`dl`,{className:`mt-3 grid grid-cols-2 gap-x-4 gap-y-3 sm:grid-cols-4`,children:n.map(e=>(0,I.jsxs)(`div`,{className:`min-w-0`,children:[(0,I.jsx)(`dt`,{className:`text-xs text-soft-foreground`,children:e.label}),(0,I.jsx)(`dd`,{className:`mt-1 truncate text-xl font-semibold tracking-tight tabular-nums`,children:e.value}),e.note&&(0,I.jsx)(`dd`,{className:`text-xs text-soft-foreground`,children:e.note})]},e.label))}),(0,I.jsxs)(`span`,{className:`mt-3 block text-xs text-soft-foreground`,children:[`From `,t.completedTasks,` completed `,t.completedTasks===1?`task`:`tasks`,` ·`,` `,t.measuredTasks,` with a stored diff`]})]})}function Ot({data:e}){let t=St(),{total:n,reasons:r}=e.failures;return(0,I.jsxs)(`section`,{className:xt,"aria-label":`Why tasks failed`,children:[(0,I.jsx)(L,{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,I.jsxs)(`div`,{className:`flex items-baseline justify-between gap-2`,children:[(0,I.jsx)(`h3`,{className:bt,children:`Why tasks failed`}),n>0&&(0,I.jsxs)(`span`,{className:`font-mono text-[11px] text-soft-foreground`,children:[n,` failed`]})]}),n===0?(0,I.jsxs)(`span`,{className:`mt-4 flex items-center gap-2.5 text-sm text-muted-foreground`,children:[(0,I.jsx)(N,{tone:`success`}),`No failed outcomes in this period`]}):(0,I.jsx)(`ul`,{className:`mt-3 space-y-3`,children:r.map(e=>(0,I.jsx)(kt,{reason:e,total:n,projectName:t},`${e.category}:${e.label}`))})]})}function kt({reason:e,total:t,projectName:n}){let{latest:r}=e;return(0,I.jsxs)(`li`,{className:`min-w-0`,children:[(0,I.jsxs)(`div`,{className:`flex items-baseline justify-between gap-3 text-sm`,children:[(0,I.jsx)(`span`,{className:`min-w-0 truncate font-medium`,title:e.label,children:e.label}),(0,I.jsx)(`span`,{className:`font-mono text-xs tabular-nums text-muted-foreground`,children:e.count})]}),(0,I.jsx)(`div`,{className:`mt-1.5 h-1 overflow-hidden rounded-full bg-muted`,"aria-hidden":`true`,children:(0,I.jsx)(`div`,{className:`h-full rounded-full bg-danger/70`,style:{width:`${e.count/t*100}%`}})}),(0,I.jsxs)(`span`,{className:`mt-1.5 block truncate text-xs text-soft-foreground`,title:r.message,children:[`Latest:`,` `,(0,I.jsx)(D,{className:`text-muted-foreground hover:text-foreground hover:underline`,to:Ct(r.projectId,r.id),children:r.title}),` `,`· `,n(r.projectId),r.step?` · ${r.step}`:``,` · `,P(r.at),` ago`]})]})}var At={claude:`Claude Code`,codex:`Codex`,opencode:`OpenCode`,cursor:`Cursor`,pi:`Pi`,unknown:`Unknown backend`,mixed:`Mixed backends`},jt=e=>At[e]??e,Mt=(e,t)=>t?Math.round(e/t*100):0;function Nt(){let[e,t]=vt(`backends`,[`7d`,`30d`],`7d`),n=Ue(e),r=n.data,i=r?.visibility.cost;return(0,I.jsx)(`section`,{"data-dashboard-module":`backends`,className:`min-w-0`,children:(0,I.jsxs)(M,{className:`gap-0 py-0`,"data-export-context":`Backends: ${yt(e)}; finished tasks`,children:[(0,I.jsxs)(`div`,{className:z,children:[(0,I.jsx)(`h2`,{className:R,children:`Backends & models`}),(0,I.jsx)(wt,{label:`Finished`,value:e,onChange:t})]}),(0,I.jsxs)(`div`,{className:`space-y-3 p-4`,children:[(0,I.jsx)(Tt,{query:n}),r&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`p`,{className:`text-xs text-muted-foreground`,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,I.jsx)(G,{coverage:r.coverage,retry:()=>void n.refetch()}),r.backends.length?(0,I.jsx)(`div`,{className:`overflow-x-auto`,role:`region`,"aria-label":`Backend comparison`,tabIndex:0,children:(0,I.jsxs)(`table`,{className:`w-full text-left text-sm`,children:[(0,I.jsx)(`thead`,{children:(0,I.jsxs)(`tr`,{children:[(0,I.jsx)(`th`,{className:q,children:`Backend`}),(0,I.jsx)(`th`,{className:`${q} text-right`,children:`Finished`}),(0,I.jsx)(`th`,{className:q,children:`Success`}),(0,I.jsx)(`th`,{className:`${q} text-right`,children:`Median cycle`}),i&&(0,I.jsx)(`th`,{className:`${q} text-right`,children:`Reported USD`}),i&&(0,I.jsx)(`th`,{className:`${q} text-right`,children:`Per completed`})]})}),(0,I.jsx)(`tbody`,{children:r.backends.map(e=>(0,I.jsx)(Pt,{stat:e,cost:!!i},`${e.backend}:${e.model??``}`))})]})}):(0,I.jsx)(`p`,{className:`py-4 text-sm text-muted-foreground`,children:`No finished tasks in this period.`}),(0,I.jsx)(`span`,{className:`block font-mono text-[11px] text-soft-foreground`,children:(0,I.jsx)(it,{at:r.asOf})}),(0,I.jsx)(L,{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 Pt({stat:e,cost:t}){let n=Mt(e.done,e.finished),r=e.costUsd?.value;return(0,I.jsxs)(`tr`,{className:`border-t transition-colors hover:bg-muted/30`,children:[(0,I.jsxs)(`td`,{className:`px-3 py-2.5`,children:[(0,I.jsx)(`span`,{className:`block font-medium`,children:jt(e.backend)}),(0,I.jsx)(`span`,{className:`block font-mono text-[11px] text-soft-foreground`,children:e.backend===`mixed`?`steps ran on different backends`:e.model??`default model`})]}),(0,I.jsx)(`td`,{className:`px-3 py-2.5 text-right tabular-nums`,children:e.finished}),(0,I.jsxs)(`td`,{className:`min-w-40 px-3 py-2.5`,children:[(0,I.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,I.jsx)(`span`,{className:`h-1.5 flex-1 overflow-hidden rounded-full bg-danger/40`,"aria-hidden":`true`,children:(0,I.jsx)(`span`,{className:`block h-full rounded-full bg-success`,style:{width:`${n}%`}})}),(0,I.jsxs)(`span`,{className:`w-10 text-right font-mono text-xs tabular-nums`,children:[n,`%`]})]}),(0,I.jsxs)(`span`,{className:`block text-xs text-soft-foreground`,children:[e.done,` done · `,e.failed,` failed`]})]}),(0,I.jsx)(`td`,{className:`px-3 py-2.5 text-right tabular-nums`,children:e.timedTasks?K(e.medianCycleHours):`—`}),t&&(0,I.jsxs)(`td`,{className:`px-3 py-2.5 text-right tabular-nums`,children:[r==null?`—`:_t(r,!0),(0,I.jsxs)(`span`,{className:`block text-xs text-soft-foreground`,children:[e.costUsd?.reportedTasks??0,`/`,e.finished,` reported`]})]}),t&&(0,I.jsx)(`td`,{className:`px-3 py-2.5 text-right tabular-nums`,children:r==null||!e.done?`—`:_t(r/e.done,!0)})]})}function Ft(){let[e,t]=vt(`automations`,[`7d`,`30d`],`7d`),n=ve(),r=Ue(e),i=Qe(n.known&&!n.off),a=St(),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,I.jsx)(`section`,{"data-dashboard-module":`automation-outcomes`,className:`min-w-0`,children:(0,I.jsxs)(M,{className:`gap-0 py-0`,"data-export-context":`Automation outcomes: tasks created in ${yt(e)}`,children:[(0,I.jsxs)(`div`,{className:z,children:[(0,I.jsx)(`h2`,{className:R,children:`Automation outcomes`}),(0,I.jsx)(wt,{label:`Launched`,value:e,onChange:t})]}),(0,I.jsx)(`div`,{className:`space-y-3 p-4`,children:n.off?(0,I.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Automations are disabled in this workspace.`}):(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(Tt,{query:r}),o&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`p`,{className:`text-xs text-muted-foreground`,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,I.jsx)(G,{coverage:o.coverage,retry:()=>void r.refetch()}),u&&(0,I.jsxs)(`p`,{role:`alert`,className:`text-sm`,children:[`Some automation details could not be loaded. Their outcomes are shown by id.`,` `,(0,I.jsx)(w,{variant:`ghost`,onClick:i.retry,children:`Retry automations`})]}),d.length?(0,I.jsx)(`div`,{className:`overflow-x-auto`,role:`region`,"aria-label":`Automation outcomes`,tabIndex:0,children:(0,I.jsxs)(`table`,{className:`w-full text-left text-sm`,children:[(0,I.jsx)(`thead`,{children:(0,I.jsxs)(`tr`,{children:[(0,I.jsx)(`th`,{className:q,children:`Automation`}),(0,I.jsx)(`th`,{className:`${q} text-right`,children:`Tasks`}),(0,I.jsx)(`th`,{className:`${q} text-right`,children:`Done`}),(0,I.jsx)(`th`,{className:`${q} text-right`,children:`Failed`}),(0,I.jsx)(`th`,{className:`${q} text-right`,children:`Active`}),(0,I.jsx)(`th`,{className:q,children:`Last run`}),s&&(0,I.jsx)(`th`,{className:`${q} text-right`,children:`Reported USD`})]})}),(0,I.jsx)(`tbody`,{children:d.map(e=>(0,I.jsx)(It,{row:e,cost:!!s,projectName:a},`${e.projectId}:${e.automationId}`))})]})}):(0,I.jsx)(`p`,{className:`py-4 text-sm text-muted-foreground`,children:`No automations yet. Create one in a project's Automations page.`}),(0,I.jsx)(`span`,{className:`block font-mono text-[11px] text-soft-foreground`,children:(0,I.jsx)(it,{at:o.asOf})}),(0,I.jsx)(L,{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 It({row:e,cost:t,projectName:n}){let r=e.stat,i=`px-3 py-2.5 text-right tabular-nums`,a=e=>e||(0,I.jsx)(`span`,{className:`text-soft-foreground`,children:`0`});return(0,I.jsxs)(`tr`,{className:`border-t transition-colors hover:bg-muted/30`,children:[(0,I.jsxs)(`td`,{className:`px-3 py-2.5`,children:[e.definition===`removed`?(0,I.jsx)(`span`,{className:`block font-medium`,children:e.name}):(0,I.jsx)(D,{className:`block font-medium hover:underline`,to:`/p/${encodeURIComponent(e.projectId)}/automations/${encodeURIComponent(e.automationId)}`,children:e.name}),(0,I.jsxs)(`span`,{className:`flex items-center gap-1.5 text-xs text-soft-foreground`,children:[(0,I.jsx)(N,{tone:e.enabled?`success`:`neutral`}),n(e.projectId),` ·`,` `,e.definition===`removed`?`Removed`:e.definition===`unknown`?`Details unavailable`:e.enabled?`Enabled`:`Disabled`]})]}),(0,I.jsx)(`td`,{className:i,children:a(r?.tasks)}),(0,I.jsx)(`td`,{className:i,children:a(r?.done)}),(0,I.jsx)(`td`,{className:`${i} ${r?.failed?`text-danger`:``}`,children:a(r?.failed)}),(0,I.jsx)(`td`,{className:i,children:a(r?.active)}),(0,I.jsx)(`td`,{className:`whitespace-nowrap px-3 py-2.5 text-xs text-muted-foreground`,children:r?.lastRunAt?(0,I.jsxs)(`time`,{dateTime:r.lastRunAt,title:new Date(r.lastRunAt).toLocaleString(),children:[P(r.lastRunAt),` ago · `,r.lastStatus]}):`—`}),t&&(0,I.jsx)(`td`,{className:i,children:r?.costUsd?.value==null?`—`:_t(r.costUsd.value,!0)})]})}var Lt=0,Rt=()=>++Lt,J=new Map;function Y(e,t){let n=(0,F.useContext)(ct),r=()=>{let r=n?J.get(n):void 0;return r?.has(e)?r.get(e):typeof t==`function`?t():t},[i,a]=(0,F.useState)(r),o=`${n}:${e}`,[s,c]=(0,F.useState)(o);o!==s&&(c(o),a(()=>r()));let l=(0,F.useMemo)(()=>({value:i}),[n,e]);return l.value=i,(0,F.useEffect)(()=>()=>{if(!n)return;let t=J.get(n)??new Map;t.set(e,l.value),t.size>80&&t.delete(t.keys().next().value),J.delete(n),J.set(n,t),J.size>20&&J.delete(J.keys().next().value)},[n,e,l]),[i,a]}var zt=`a[href], button, select, input, [tabindex]`;function Bt(e){let[t]=Y(`${e}:position`,()=>({scroll:0})),n=(0,F.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,F.useMemo)(()=>({restore:()=>!1}),[t]);return{ref:(0,F.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 Vt(e,t){let n=(0,F.useRef)(null),[r,i]=Y(`${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 Ht(e,t=!0){return h({queryKey:[...c.dashboard,`overview`,e],enabled:t,staleTime:5e3,refetchInterval:t&&!e.snapshotId?15e3:!1,refetchIntervalInBackground:!1,retry:!1,queryFn:async({signal:t})=>b.parse(await r(await f.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 Ut={running:`Running now`,"needs-you":`Needs you`,completed:`Completed`,failed:`Failed outcomes`},Wt={"needs-you":V.violet,running:V.info,completed:V.success,failed:V.danger},Gt={"needs-you":qe,running:We,completed:k,failed:Ke};function Kt({active:e,children:t,onCurrent:n}){let[r,i]=vt(`period`,[`7d`,`30d`],`7d`),a=Vt(`outcome`,`[data-outcome-trigger]`),s=o().data?.projects,c=e=>s?.find(t=>t.id===e)?.name??e,l=Ht({period:r},e),[u,d]=Y(`outcome:selection`,null),f=Bt(`outcome:${u?.identity??`closed`}`),p=ye();if((0,F.useEffect)(()=>{e||d(null)},[e]),!e)return t({});let m=l.data,h=(e,t)=>{a.capture(),m&&d({identity:Rt(),snapshot:m,group:e,projectId:t})},g=m?.coverage.projects.every(e=>e.state===`complete`);return(0,I.jsxs)(I.Fragment,{children:[t({overview:(0,I.jsxs)(M,{className:`gap-0 py-0`,children:[(0,I.jsxs)(`div`,{className:z,children:[(0,I.jsx)(`h2`,{className:R,children:`Workspace overview`}),(0,I.jsxs)(`label`,{className:et,children:[`Outcomes period`,(0,I.jsxs)(tt,{value:r,onChange:e=>{i(e.target.value===`30d`?`30d`:`7d`),d(null)},children:[(0,I.jsx)(`option`,{value:`7d`,children:`Last 7 days`}),(0,I.jsx)(`option`,{value:`30d`,children:`Last 30 days`})]})]})]}),(0,I.jsxs)(`div`,{className:`space-y-4 p-4`,children:[l.isPending&&(0,I.jsx)(`p`,{role:`status`,className:`text-sm text-muted-foreground`,children:`Loading overview…`}),l.isError&&(0,I.jsxs)(`p`,{role:`alert`,children:[m?`Showing previous results. `:``,`Could not refresh overview.`,` `,(0,I.jsx)(w,{variant:`outline`,onClick:()=>void l.refetch(),children:`Retry overview`})]}),m&&(0,I.jsxs)(I.Fragment,{children:[(0,I.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,I.jsx)(G,{coverage:m.coverage,retry:()=>void l.refetch()}),(0,I.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],i=Gt[e];return(0,I.jsxs)(w,{"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?V.neutral:Wt[e]}`,onClick:t=>{n&&(e===`running`||e===`needs-you`)?n(e,t.currentTarget):h(e)},"aria-label":`${Ut[e]}: ${t}`,children:[(0,I.jsx)(rt,{label:Ut[e],value:t,icon:(0,I.jsx)(i,{className:`size-4`}),children:e===`running`||e===`needs-you`?`Current state`:`Last ${r===`7d`?7:30} calendar days`}),(0,I.jsxs)(`span`,{"data-export-exclude":!0,className:`mt-4 flex items-center gap-1 text-xs font-medium text-muted-foreground transition-colors group-hover/metric:text-foreground`,children:[`View tasks`,` `,(0,I.jsx)(Be,{className:`size-3 transition-transform group-hover/metric:translate-x-0.5 motion-reduce:transition-none`,"aria-hidden":`true`})]})]},e)})}),(0,I.jsx)(Et,{period:r,active:e}),(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-x-4 gap-y-1 border-t pt-3`,children:[(0,I.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Median cycle time`,` `,(0,I.jsx)(`strong`,{className:`font-mono font-semibold text-foreground`,children:K(m.metrics.medianCycleHours)}),` `,`· `,m.metrics.timedTasks,`/`,m.metrics.completed,` completed tasks have valid timings.`,` `,(0,I.jsx)(w,{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,I.jsx)(`p`,{className:`font-mono text-[11px] text-soft-foreground`,children:(0,I.jsxs)(`time`,{dateTime:m.asOf,title:new Date(m.asOf).toLocaleString(),children:[`Updated `,P(m.asOf),` ago`]})})]}),(0,I.jsxs)(`details`,{className:`text-xs text-muted-foreground`,children:[(0,I.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,I.jsx)(B,{}),`How these metrics work`]}),(0,I.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,I.jsx)(L,{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,I.jsx)(`div`,{children:(0,I.jsxs)(M,{className:`gap-0 py-0`,"data-export-context":`Outcomes: Last ${r===`7d`?7:30} calendar days; workload: current state`,children:[(0,I.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,I.jsx)(`h2`,{className:`section-mark font-mono text-[11px] font-semibold uppercase tracking-[0.14em] text-muted-foreground`,children:`Projects`})}),(0,I.jsx)(`p`,{className:`px-4 pt-3 text-xs text-muted-foreground`,children:`Current workload and outcomes for the selected period. Sorted by tasks needing you, then running tasks. Counts include subtasks.`}),(0,I.jsxs)(`div`,{className:`overflow-x-auto px-1 pb-2`,role:`region`,"aria-label":`Project outcomes`,tabIndex:0,children:[(0,I.jsxs)(`table`,{className:`w-full text-left text-sm`,children:[(0,I.jsx)(`thead`,{children:(0,I.jsx)(`tr`,{children:[`Project`,`Needs you`,`Running`,`Completed`,`Failed`,`Median cycle`].map(e=>(0,I.jsx)(`th`,{className:`whitespace-nowrap px-3 py-2 font-mono text-[11px] font-medium uppercase tracking-[0.1em] text-soft-foreground ${e===`Project`?``:`text-right`}`,children:e},e))})}),(0,I.jsx)(`tbody`,{children:m.projects.map(e=>{let t=m.coverage.projects.find(t=>t.projectId===e.projectId);return(0,I.jsxs)(`tr`,{className:`border-t transition-colors hover:bg-muted/30`,children:[(0,I.jsxs)(`td`,{className:`px-3 py-2`,children:[(0,I.jsx)(D,{className:`font-medium hover:underline`,to:`/p/${encodeURIComponent(e.projectId)}/tasks`,children:c(e.projectId)}),t?.state!==`complete`&&(0,I.jsx)(`span`,{className:`block text-xs text-muted-foreground`,children:`Incomplete data`})]}),[`needs-you`,`running`,`completed`,`failed`].map(n=>(0,I.jsx)(`td`,{className:`px-3 py-1 text-right`,children:(0,I.jsx)(w,{"data-export-keep":!0,variant:`ghost`,className:`min-h-11 tabular-nums`,"aria-label":`${c(e.projectId)}: ${Ut[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,I.jsxs)(`td`,{className:`px-3 py-2 text-right tabular-nums`,children:[K(e.medianCycleHours),(0,I.jsxs)(`span`,{className:`block text-xs text-muted-foreground`,children:[e.timedTasks,`/`,e.completed,` timed`]})]})]},e.projectId)})})]}),!m.projects.length&&(0,I.jsx)(`p`,{className:`py-4`,children:`No projects to compare yet.`})]}),(0,I.jsx)(L,{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,I.jsx)(Oe,{open:!!u,onOpenChange:e=>{e||d(null)},children:(0,I.jsxs)(De,{...f,className:`w-full overflow-y-auto sm:max-w-xl`,onCloseAutoFocus:e=>{e.preventDefault(),a.restore()},children:[(0,I.jsxs)(ke,{children:[(0,I.jsxs)(Ae,{children:[u?Ut[u.group]:`Tasks`,u?.projectId?` · ${u.projectId}`:``]}),(0,I.jsx)(Ee,{children:`Tasks behind the selected metric. Includes subtasks. Snapshot keeps counts and rows consistent.`})]}),u&&(0,I.jsx)(qt,{selection:u,projectName:c,refresh:()=>{d(null),l.refetch()}},u.identity)]})})]})}function qt({selection:e,refresh:t,projectName:n}){let[r,i]=Y(`outcome:${e.identity}:offset`,0),a=Ht({period:e.snapshot.period,snapshotId:e.snapshot.snapshotId,group:e.group,projectId:e.projectId,offset:r}),o=(0,F.useRef)(null),s=(0,F.useRef)(null);(0,F.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,I.jsxs)(`div`,{className:`space-y-3 p-4`,"data-sheet-loading":a.isFetching,children:[a.isPending&&(0,I.jsx)(`p`,{children:`Loading tasks…`}),a.isError&&(0,I.jsxs)(`p`,{role:`alert`,children:[`This snapshot may have expired or become unavailable.`,` `,(0,I.jsx)(w,{onClick:t,children:`Refresh overview`})]}),a.data&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`p`,{ref:o,tabIndex:-1,className:`text-xs text-muted-foreground`,children:[a.data.page.total,` tasks · Snapshot from`,` `,(0,I.jsxs)(`time`,{dateTime:a.data.asOf,title:new Date(a.data.asOf).toLocaleString(),children:[P(a.data.asOf),` ago`]})]}),a.data.page.rows.map(t=>(0,I.jsx)(Jt,{row:t,group:e.group,projectName:n},`${t.projectId}:${t.id}`)),!a.data.page.rows.length&&(0,I.jsx)(`p`,{children:`No tasks in this group.`})]}),(0,I.jsxs)(`div`,{className:`flex gap-2`,children:[(0,I.jsx)(w,{variant:`outline`,disabled:!r||a.isFetching,onClick:()=>c(Math.max(0,r-20)),children:`Previous`}),(0,I.jsx)(w,{variant:`outline`,disabled:!a.data||a.data.page.nextOffset===null||a.isFetching,onClick:()=>c(a.data.page.nextOffset),children:`Next`})]})]})}function Jt({row:e,group:t,projectName:n}){let r=le(e),i=t===`running`||t===`needs-you`;i&&r&&(e={...e,...r});let a=r===null,o=i&&(e.archived||(t===`running`?e.status!==`running`:!g(e))),c=a||o,l=s(e),u=i&&a?`Task removed`:o?t===`running`?`No longer running`:`No longer needs you`:l.label;return(0,I.jsxs)(`div`,{className:`border-b py-3`,children:[(0,I.jsx)(D,{"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,I.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[(0,I.jsx)(N,{tone:l.tone}),` `,n(e.projectId),` ·`,` `,u,` · `,e.archived?`Archived · `:``,(0,I.jsxs)(`time`,{dateTime:e.finishedAt??e.createdAt,title:new Date(e.finishedAt??e.createdAt).toLocaleString(),children:[e.finishedAt?`Finished`:`Created`,` `,P(e.finishedAt??e.createdAt),` ago`]})]})]})}var X={snapshot:[...c.dashboard,`snapshot`],feed:e=>[...c.dashboard,`feed`,e],telemetry:[...c.dashboard,`telemetry`]},Yt=new Map;async function Xt(e){let t=A(),n=x.parse(await r(await f.api.v1.workspace.dashboard.$get({},{init:{signal:e}}),`/workspace/dashboard`));return Yt.has(n.snapshotId)||Yt.set(n.snapshotId,t),Yt.size>60&&Yt.delete(Yt.keys().next().value),j(t,[...n.questions.rows,...n.reviews.rows]),n}async function Zt(e,t,n=0,i=20,a){let o=T.parse(await r(await f.api.v1.workspace.dashboard.tasks.$get({query:{snapshotId:e,group:t,offset:String(n),limit:String(i)}},{init:{signal:a}}),`/workspace/dashboard/tasks`)),s=Yt.get(e);return s!==void 0&&j(s,o.page.rows),o}function Qt(e){return h({queryKey:X.snapshot,queryFn:({signal:e})=>Xt(e),enabled:e,staleTime:5e3,refetchOnMount:`always`,refetchInterval:e?15e3:!1,refetchIntervalInBackground:!1,retry:!1})}function $t(e){return h({queryKey:X.telemetry,enabled:e,staleTime:0,queryFn:async({signal:e})=>{let t=C.parse(await r(await f.api.v1.workspace.dashboard.telemetry.$get({},{init:{signal:e}}),`/workspace/dashboard/telemetry`));return O.seed(t.samples,t.asOf),t}})}function en(e,t){let n=h({queryKey:X.feed(e),queryFn:async({signal:t})=>{let n=A(),i=_.parse(await r(await f.api.v1.workspace.dashboard.feed.$get({query:{filter:e}},{init:{signal:t}}),`/workspace/dashboard/feed`));return j(n,i.rows.flatMap(e=>e.kind===`task-result`?[e.run]:[])),i},enabled:t,staleTime:15e3,refetchInterval:t&&e!==`github`?15e3:!1,retry:!1}),i=(0,F.useRef)(!1);return(0,F.useEffect)(()=>{i.current=!1},[e,t]),(0,F.useEffect)(()=>{if(!t||i.current||!n.data?.sources.some(e=>e.reason===`Still loading GitHub`))return;let e=setTimeout(()=>{document.visibilityState!==`hidden`&&(i.current=!0,n.refetch())},5e3);return()=>clearTimeout(e)},[t,n.data,n.refetch]),n}function tn(e,t){let n=en(`tasks`,t&&e!==`github`),r=en(`github`,t&&e!==`tasks`),i=(0,F.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)=>nn(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 nn(e,t){return Date.parse(t.at)-Date.parse(e.at)||e.key.localeCompare(t.key)}var rn=[...c.dashboard,`costs`];function an(){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 un(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 on=new WeakMap;function sn(e){let t=on.get(e);return t||(t=an(),on.set(e,t)),t}function cn(){let e=sn(m());return(0,F.useSyncExternalStore)(e.subscribe,e.getSnapshot,e.getSnapshot)}var ln=new Map;async function un(e,t){let n=A(),i=y.parse(await r(await f.api.v1.workspace.dashboard.costs.$get({query:{...e,offset:String(e.offset??0),limit:`20`}},{init:{signal:t}}),`/workspace/dashboard/costs`));!e.snapshotId&&!ln.has(i.snapshotId)&&ln.set(i.snapshotId,n),ln.size>60&&ln.delete(ln.keys().next().value);let a=ln.get(i.snapshotId);return a!==void 0&&j(a,i.tasks.rows),i}function dn(e,t,n){let r=sn(m());return h({queryKey:[...rn,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 fn(e,t,n,r){let i=sn(m());return h({queryKey:[...rn,`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 u&&e.status===409)return s();throw e}}})}var pn={cost:{text:`text-primary`,fill:`bg-primary`,tint:V.primary,icon:ue},input:{text:`text-violet`,fill:`bg-violet`,tint:V.violet,icon:Ge},output:{text:`text-info`,fill:`bg-info`,tint:V.info,icon:ne}};function mn({metric:e,label:t,value:n,reported:r,total:i}){let a=pn[e],o=a.icon,s=i?Math.min(100,r/i*100):0;return(0,I.jsxs)(`div`,{className:`${nt} ${a.tint}`,children:[(0,I.jsxs)(rt,{label:t,value:n,icon:(0,I.jsx)(o,{className:`size-4 ${a.text}`}),children:[r,` of `,i,` tasks report this metric`]}),(0,I.jsx)(`div`,{className:`mt-2 h-1.5 overflow-hidden rounded-full bg-muted`,"aria-hidden":`true`,children:(0,I.jsx)(`div`,{className:`h-full rounded-full ${a.fill} transition-[width] duration-300 motion-reduce:transition-none`,style:{width:`${s}%`}})})]})}function hn({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=pn[n];return(0,I.jsxs)(Re,{delayDuration:150,children:[(0,I.jsxs)(`div`,{className:`space-y-1 rounded-xl border p-2`,"aria-label":`Projects ranked by ${i}`,children:[e.length===0&&(0,I.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,I.jsxs)(ze,{children:[(0,I.jsx)(Ie,{asChild:!0,children:(0,I.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,I.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,I.jsx)(`span`,{className:`w-4 shrink-0 text-xs tabular-nums text-muted-foreground`,"aria-hidden":`true`,children:n+1}),(0,I.jsx)(`span`,{className:`min-w-0 flex-1 break-words font-medium`,children:e.projectId}),(0,I.jsx)(`span`,{className:`shrink-0 font-semibold tabular-nums`,children:a(u)}),(0,I.jsx)(Be,{"data-export-exclude":!0,className:`size-4 shrink-0 text-muted-foreground`,"aria-hidden":`true`})]}),(0,I.jsx)(`div`,{className:`mt-2 ml-7 h-2 overflow-hidden rounded-full bg-muted`,"aria-hidden":`true`,children:(0,I.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,I.jsxs)(`p`,{className:`mt-1.5 ml-7 text-xs text-muted-foreground`,children:[l?.reportedTasks??0,` of `,e.tasks,` tasks report this metric`,f?``:` · No measured value`]})]})}),(0,I.jsxs)(Le,{className:`max-w-64`,children:[(0,I.jsxs)(`p`,{className:`font-medium`,children:[e.projectId,` · `,i,`: `,a(u)]}),(0,I.jsxs)(`p`,{children:[l?.reportedTasks??0,` of `,e.tasks,` tasks report this metric.`]}),(0,I.jsx)(`p`,{children:`Open project tasks`})]})]},e.projectId)})]}),e.length>0&&(0,I.jsxs)(`p`,{className:`mt-2 text-xs 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`},gn={cost:`Reported USD`,input:`Input tokens`,output:`Output tokens`};function _n(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 vn=(e,t)=>_t(e,t===`cost`);function Q(e){return[...e.cost?[`cost`]:[],...e.tokens?[`input`,`output`]:[]]}function yn({value:e,onChange:t,visibility:n}){return(0,I.jsxs)(`label`,{className:et,children:[`Sort by`,(0,I.jsx)(tt,{value:e,onChange:e=>t(e.target.value),children:Q(n).map(e=>(0,I.jsx)(`option`,{value:e,children:gn[e]},e))})]})}function bn(){return(0,I.jsx)(xn,{visibility:He(p().data)})}function xn({visibility:e}){return(0,I.jsxs)(M,{className:`gap-0 py-0`,children:[(0,I.jsx)(`div`,{className:z,children:(0,I.jsx)(`h2`,{className:R,children:`Usage & cost`})}),!e.cost&&!e.tokens?(0,I.jsx)(`p`,{className:`p-4 text-sm`,children:`Usage metrics are hidden by workspace settings`}):(0,I.jsx)(Sn,{visibility:e},`${e.cost}:${e.tokens}`)]})}function Sn({visibility:e}){let[t,n]=vt(`usagePeriod`,[`all`,`7d`,`30d`],`all`),[r,i]=vt(`usageSort`,Q(e),e.cost?`cost`:`input`);return(0,I.jsx)(Cn,{period:t,setPeriod:n,sort:r,setSort:i,visibility:e})}function Cn({period:e,setPeriod:t,sort:n,setSort:r,visibility:i}){let a=dn(e,n,`${i.cost}:${i.tokens}`),[o,s]=Y(`usage:accepted`,void 0),c=o??a.data,l=a.data??c,[u,d]=Y(`usage:panel`,null),[f,p]=(0,F.useState)(e);f!==e&&(p(e),s(void 0),d(null));let m=Bt(`usage:${u?.identity??`closed`}`),h=Vt(`usage`,`[data-usage-trigger]`),g=e=>{h.capture(),c&&d({identity:Rt(),projectId:e,snapshot:c,latestId:l?.snapshotId??c.snapshotId})},_=cn()??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&&_n(c,l),S=c?.coverage.projects.some(e=>e.state!==`complete`),C=l?.coverage.projects.some(e=>e.state!==`complete`),T=JSON.stringify(c?.coverage)!==JSON.stringify(l?.coverage),E=c?.totals.tasks===0&&!S&&!C;return(0,I.jsxs)(`div`,{className:`space-y-4 p-4 text-sm`,children:[c&&(0,I.jsx)(L,{rows:E?[]:[...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,I.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:(0,I.jsx)(it,{at:c.asOf})}),(0,I.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`h3`,{className:`font-medium`,children:`Lifetime totals of retained tasks`}),(0,I.jsxs)(`details`,{className:`mt-1 text-xs text-muted-foreground`,children:[(0,I.jsxs)(`summary`,{"data-export-heading":`Metric definitions`,className:`${$e} min-h-11`,children:[(0,I.jsx)(B,{}),`How these metrics work`]}),(0,I.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,I.jsxs)(`label`,{className:et,children:[`Tasks created`,(0,I.jsxs)(tt,{value:e,onChange:e=>t(e.target.value),children:[(0,I.jsx)(`option`,{value:`all`,children:`All time`}),(0,I.jsx)(`option`,{value:`7d`,children:`Last 7 days`}),(0,I.jsx)(`option`,{value:`30d`,children:`Last 30 days`})]})]})]}),e!==`all`&&(0,I.jsx)(`p`,{className:`text-muted-foreground`,children:`Lifetime usage of tasks created in this period — not spending during the period.`}),a.isPending&&(0,I.jsx)(`p`,{children:`Loading usage…`}),a.isError&&(0,I.jsxs)(`p`,{role:`alert`,children:[c?`Showing stale usage. Could not refresh.`:`Could not load usage.`,` `,(0,I.jsx)(w,{className:`min-h-11`,onClick:()=>void a.refetch(),children:`Retry`})]}),x&&(0,I.jsx)(`p`,{role:`status`,children:`Newer usage data is available; displayed values use the previous snapshot.`}),x&&(0,I.jsx)(w,{className:`min-h-11`,variant:`outline`,onClick:()=>s(l),children:`Updates available — Show`}),c&&S&&(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`p`,{className:`text-muted-foreground`,children:`Coverage of displayed usage:`}),(0,I.jsx)(G,{coverage:c.coverage,retry:()=>void a.refetch()})]}),l&&C&&T&&(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`p`,{className:`text-muted-foreground`,children:`Current source availability:`}),(0,I.jsx)(G,{coverage:l.coverage,retry:()=>void a.refetch()})]}),c&&(0,I.jsxs)(I.Fragment,{children:[!E&&(0,I.jsx)(`div`,{className:`report-cost-metrics grid gap-3 sm:grid-cols-[repeat(auto-fit,minmax(220px,1fr))]`,children:Q(v).map(e=>(0,I.jsx)(mn,{metric:e,label:gn[e],value:vn(c.totals[Z[e]]?.value,e),reported:c.totals[Z[e]]?.reportedTasks??0,total:c.totals.tasks},e))}),!v.cost&&!v.tokens&&(0,I.jsx)(`p`,{children:`Usage metrics are hidden by workspace settings`}),c.totals.tasks===0?(0,I.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,I.jsx)(`p`,{children:`No reports for the visible metrics in this cohort.`}),E&&(0,I.jsx)(`p`,{className:`text-muted-foreground`,children:`Usage appears when tasks report cost or tokens.`}),(0,I.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`}.`:``]}),!E&&(v.cost||v.tokens)&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`h3`,{className:`font-medium`,children:`Top projects`}),(0,I.jsx)(`p`,{className:`text-muted-foreground`,children:`Ranking uses reported metrics only.`})]}),(0,I.jsx)(yn,{value:y,onChange:r,visibility:v})]}),(0,I.jsx)(hn,{projects:b,metric:y,label:gn[y],field:Z[y],format:e=>vn(e,y),currentProjects:l?.projects??[],onSelect:g}),(0,I.jsx)(w,{"data-usage-trigger":!0,className:`min-h-11`,variant:`outline`,onClick:()=>g(``),children:`View tasks`})]})]}),(0,I.jsx)(Oe,{open:u!==null&&(v.cost||v.tokens),onOpenChange:e=>{e||d(null)},children:(0,I.jsxs)(De,{...m,className:`w-full overflow-y-auto sm:max-w-xl`,onCloseAutoFocus:e=>{e.preventDefault(),h.restore()},children:[(0,I.jsxs)(ke,{children:[(0,I.jsx)(Ae,{children:u?.projectId?`${u.projectId} tasks`:`All tasks`}),(0,I.jsx)(Ee,{children:`Lifetime usage of retained tasks. Missing reports are unavailable.`})]}),u!==null&&(0,I.jsx)(wn,{identity:`usage:${u.identity}`,snapshot:l&&l.snapshotId!==u.latestId?l:u.snapshot,projectId:u.projectId||void 0,visibility:v},u.identity)]})})]})}function wn({identity:e,snapshot:t,projectId:n,visibility:r}){let[i,a]=Y(`${e}:sort`,t.sort);return(0,I.jsx)(Tn,{identity:e,snapshot:t,projectId:n,visibility:r,sort:Q(r).includes(i)?i:Q(r)[0]??`cost`,setSort:a})}function Tn({identity:e,snapshot:t,projectId:n,visibility:r,sort:i,setSort:a}){let[o,s]=Y(`${e}:count`,20),[c,l]=Y(`${e}:paging`,void 0),[u,d]=(0,F.useState)(t.snapshotId);u!==t.snapshotId&&(d(t.snapshotId),l(void 0));let f=fn(c??t,n,i,o),p=cn()??r,m={cost:r.cost&&p.cost,tokens:r.tokens&&p.tokens},h=Q(m).includes(i)?i:Q(m)[0]??`cost`,[g,_]=Y(`${e}:accepted`,void 0),[v,y]=Y(`${e}:acceptedCount`,o),[b,x]=Y(`${e}:acceptedSort`,i),[S,C]=(0,F.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 T=g??f.data,E=f.data&&T&&_n(f.data,T),ee=T?.coverage.projects.some(e=>e.state!==`complete`),D=f.data?.coverage.projects.some(e=>e.state!==`complete`),te=JSON.stringify(T?.coverage)!==JSON.stringify(f.data?.coverage),ne=!n||t.projects.some(e=>e.projectId===n);return(0,I.jsxs)(`div`,{className:`space-y-3 p-4 text-sm`,"data-sheet-loading":f.isFetching,children:[(0,I.jsx)(yn,{value:h,onChange:a,visibility:m}),f.isPending&&(0,I.jsx)(`p`,{children:`Loading tasks…`}),f.isError&&(0,I.jsxs)(`p`,{role:`alert`,children:[`Could not refresh tasks. `,T?`Showing stale usage.`:``,` `,(0,I.jsx)(w,{className:`min-h-11`,onClick:()=>void f.refetch(),children:`Retry`})]}),E&&(0,I.jsx)(w,{className:`min-h-11`,onClick:()=>{_(f.data),y(o),x(i)},children:`Updates available — Show`}),T&&ee&&(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`p`,{className:`text-muted-foreground`,children:`Coverage of displayed tasks:`}),(0,I.jsx)(G,{coverage:T.coverage,retry:()=>void f.refetch()})]}),f.data&&D&&te&&(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`p`,{className:`text-muted-foreground`,children:`Current source availability:`}),(0,I.jsx)(G,{coverage:f.data.coverage,retry:()=>void f.refetch()})]}),T&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`p`,{className:`border-b pb-2 font-mono text-[11px] text-soft-foreground`,children:[T.tasks.rows.length,` of `,T.tasks.total,` retained tasks`]}),T.tasks.total===0&&(0,I.jsx)(`p`,{children:T.coverage.projects.some(e=>e.state!==`complete`)?`No tasks could be read from available sources.`:`No retained tasks in this cohort.`}),T.tasks.rows.map(e=>(0,I.jsx)(En,{row:e,sort:h,visibility:m,disabled:!ne||!f.data||!!(E&&!f.data?.tasks.rows.some(t=>t.id===e.id&&t.projectId===e.projectId))},`${e.projectId}:${e.id}`)),T.tasks.nextOffset!==null&&(0,I.jsx)(w,{className:`min-h-11`,disabled:f.isFetching,onClick:()=>{l(T),s(e=>e+20)},children:`Show 20 more tasks`})]})]})}function En({row:e,sort:t,visibility:n,disabled:r}){let i=le(e);r||=i===null;let a=s(i?{status:i.status,awaitingAnswerSince:i.awaitingAnswerSince}:e),o=Q(n).filter(e=>e!==t),c=t=>{let n=e[Z[t]];return n==null?`—`:vn(n,t)},l=t=>`${gn[t]}: ${vn(e[Z[t]],t)}`;return(0,I.jsxs)(`div`,{className:`grid grid-cols-[minmax(0,1fr)_auto] items-start gap-x-4 border-b py-3 last:border-0`,children:[(0,I.jsxs)(`div`,{className:`min-w-0`,children:[(0,I.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,I.jsx)(N,{tone:a.tone,pulse:a.pulse,className:`mt-[7px]`}),(0,I.jsx)(D,{className:`line-clamp-2 break-words font-medium leading-snug hover:underline no-hover:min-h-11`,title:e.title,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,I.jsxs)(`p`,{className:`mt-1 pl-[15px] font-mono text-[11px] text-soft-foreground`,children:[e.projectId,` · `,r?`Checking current state…`:i?.status??e.status,e.archived?` · Archived`:``,e.subtask?` · Subtask`:``]})]}),(0,I.jsxs)(`div`,{className:`text-right tabular-nums`,children:[(0,I.jsx)(`span`,{"aria-label":l(t),className:`block font-semibold ${e[Z[t]]==null?`text-soft-foreground`:``}`,children:c(t)}),o.length>0&&(0,I.jsx)(`span`,{className:`mt-1 flex justify-end gap-3 font-mono text-[11px] text-soft-foreground`,children:o.map(e=>(0,I.jsxs)(`span`,{"aria-label":l(e),children:[c(e),` `,e===`cost`?``:e===`input`?`in`:`out`]},e))})]})]})}var Dn={cost:`costUsd`,input:`inputTokens`,output:`outputTokens`},On={cost:`Reported USD`,input:`Input tokens`,output:`Output tokens`};function kn(e){return[...e.cost?[`cost`]:[],...e.tokens?[`input`,`output`]:[]]}var An=(e,t)=>_t(e,t===`cost`);function jn(e){return new Date(`${e}T00:00:00`).toLocaleDateString(void 0,{month:`short`,day:`numeric`})}function Mn({series:e,height:t,accent:n,renderTooltip:r,describe:i}){let a=Math.max(1,...e.map(t));return(0,I.jsxs)(Re,{delayDuration:150,children:[(0,I.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,I.jsxs)(ze,{children:[(0,I.jsx)(Ie,{asChild:!0,children:(0,I.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,I.jsx)(`span`,{style:{height:`${s}%`},className:`block w-full rounded-t-sm ${n}`})})}),(0,I.jsx)(Le,{children:r(e)})]},e.date)})}),(0,I.jsxs)(`div`,{className:`mt-1 flex justify-between text-xs text-muted-foreground`,children:[(0,I.jsx)(`span`,{children:jn(e[0].date)}),(0,I.jsx)(`span`,{children:jn(e.at(-1).date)})]})]})}function Nn({metrics:e,series:t}){return(0,I.jsxs)(`table`,{className:`w-full text-left text-xs`,children:[(0,I.jsx)(`thead`,{children:(0,I.jsxs)(`tr`,{className:`border-b`,children:[(0,I.jsx)(`th`,{className:`py-1 pr-2 font-medium`,children:`Date`}),e.map(e=>(0,I.jsx)(`th`,{className:`py-1 pr-2 text-right font-medium`,children:On[e]},e)),(0,I.jsx)(`th`,{className:`py-1 pr-2 text-right font-medium`,children:`Completed`}),(0,I.jsx)(`th`,{className:`py-1 text-right font-medium`,children:`Avg cycle`})]})}),(0,I.jsx)(`tbody`,{children:t.map(t=>(0,I.jsxs)(`tr`,{className:`border-b last:border-0`,children:[(0,I.jsx)(`td`,{className:`py-1 pr-2`,children:jn(t.date)}),e.map(e=>(0,I.jsx)(`td`,{className:`py-1 pr-2 text-right tabular-nums`,children:An(t[Dn[e]]?.value,e)},e)),(0,I.jsx)(`td`,{className:`py-1 pr-2 text-right tabular-nums`,children:t.completed}),(0,I.jsx)(`td`,{className:`py-1 text-right tabular-nums`,children:t.avgCycleHours===null?`—`:K(t.avgCycleHours)})]},t.date))})]})}function Pn({metric:e,series:t}){let n=pn[e],r=Dn[e],i=t.reduce((e,t)=>e+(t[r]?.reportedTasks??0),0);return(0,I.jsxs)(`div`,{className:`rounded-xl border p-3`,children:[(0,I.jsx)(`p`,{className:`text-xs font-medium ${n.text}`,children:On[e]}),(0,I.jsx)(`div`,{className:`mt-2`,children:(0,I.jsx)(Mn,{series:t,describe:t=>`${t.date}, ${On[e]}: ${An(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,I.jsxs)(`p`,{children:[jn(t.date),` · `,An(t[r]?.value,e),` ·`,` `,t[r]?.reportedTasks??0,`/`,t.tasks,` tasks reported`]})})}),i===0&&(0,I.jsx)(`p`,{className:`mt-2 text-xs text-muted-foreground`,children:`No reports in this period.`})]})}function Fn({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,I.jsxs)(`div`,{className:`rounded-xl border p-3`,children:[(0,I.jsxs)(`div`,{className:`flex flex-wrap items-baseline justify-between gap-2`,children:[(0,I.jsx)(`p`,{className:`text-xs font-medium text-success`,children:`Completed tasks`}),(0,I.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[t,` done · avg cycle`,` `,i===null?`unavailable`:K(i)]})]}),(0,I.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[r,`/`,t,` completed tasks have valid cycle times.`]}),(0,I.jsx)(`div`,{className:`mt-2`,children:(0,I.jsx)(Mn,{series:e,describe:e=>`${e.date}: ${e.completed} completed tasks, average cycle ${e.avgCycleHours==null?`Unavailable`:K(e.avgCycleHours)}`,height:e=>e.completed,accent:`bg-success`,renderTooltip:e=>(0,I.jsxs)(`div`,{children:[(0,I.jsxs)(`p`,{children:[jn(e.date),` · `,e.completed,` completed`]}),(0,I.jsxs)(`p`,{children:[`Avg cycle`,` `,e.avgCycleHours===null?`unavailable`:K(e.avgCycleHours),` · Median`,` `,e.medianCycleHours===null?`unavailable`:K(e.medianCycleHours)]})]})})}),t===0&&(0,I.jsx)(`p`,{className:`mt-2 text-xs text-muted-foreground`,children:`No tasks finished in this period.`})]})}function In(){return(0,I.jsx)(Ln,{visibility:He(p().data)})}function Ln({visibility:e}){let[t,n]=vt(`trendPeriod`,[`7d`,`30d`],`7d`),r=dn(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=kn({cost:e.cost&&i?.visibility.cost!==!1,tokens:e.tokens&&i?.visibility.tokens!==!1});return(0,I.jsxs)(M,{className:`gap-0 py-0`,children:[(0,I.jsxs)(`div`,{className:z,children:[(0,I.jsx)(`h2`,{className:R,children:`Trends`}),(0,I.jsxs)(`label`,{className:et,children:[`Period`,(0,I.jsxs)(tt,{value:t,onChange:e=>n(e.target.value),children:[(0,I.jsx)(`option`,{value:`7d`,children:`Last 7 days`}),(0,I.jsx)(`option`,{value:`30d`,children:`Last 30 days`})]})]})]}),(0,I.jsxs)(`div`,{className:`space-y-4 p-4 text-sm`,children:[i&&(0,I.jsx)(L,{rows:a?[]:i.series.flatMap(e=>[...o.map(t=>({section:`daily-creation-cohort`,entity:e.date,metric:Dn[t],value:e[Dn[t]]?.value??null,unit:t===`cost`?`USD`:`tokens`,reportedTasks:e[Dn[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,I.jsxs)(`details`,{className:`text-xs text-muted-foreground`,children:[(0,I.jsxs)(`summary`,{"data-export-heading":`Metric definitions`,className:`${$e} py-2`,children:[(0,I.jsx)(B,{}),`How these metrics work`]}),(0,I.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,I.jsx)(`p`,{children:`Loading trends…`}),r.isError&&(0,I.jsxs)(`p`,{role:`alert`,children:[i?`Showing stale trends. Could not refresh.`:`Could not load trends.`,` `,(0,I.jsx)(w,{className:`min-h-11`,onClick:()=>void r.refetch(),children:`Retry`})]}),i&&(0,I.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:(0,I.jsx)(it,{at:i.asOf})}),i&&(0,I.jsx)(G,{coverage:i.coverage,retry:()=>void r.refetch()}),i&&a&&(0,I.jsx)(`p`,{className:`text-muted-foreground`,children:`No retained tasks in this period yet.`}),i&&!a&&i.series.length>0&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`div`,{className:`space-y-4`,children:[o.length>0&&(0,I.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-[repeat(auto-fit,minmax(200px,1fr))]`,children:o.map(e=>(0,I.jsx)(Pn,{metric:e,series:i.series},e))}),(0,I.jsx)(Fn,{series:i.series})]}),(0,I.jsxs)(`details`,{className:`group rounded-lg border bg-muted/20 print:block`,children:[(0,I.jsxs)(`summary`,{"data-export-heading":`Daily data`,className:`flex min-h-11 cursor-pointer list-none items-center gap-2 px-3 text-xs font-medium text-muted-foreground hover:text-foreground [&::-webkit-details-marker]:hidden`,children:[(0,I.jsx)(Ye,{className:`size-4`,"aria-hidden":`true`}),` View data table`,(0,I.jsx)(Fe,{className:`ml-auto size-4 transition-transform group-open:rotate-180`,"aria-hidden":`true`})]}),(0,I.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,I.jsx)(Nn,{metrics:o,series:i.series})})]})]})]})]})}function Rn(e,t,n,r=!0){let i=m();return h({queryKey:[...X.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 Zt(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 u&&e.status===409){let e=await Xt(r);i.setQueryData(X.snapshot,e)}throw e}}})}function zn(e,t,n,r){let i=m(),a=t===`questions`||t===`reviews`?`needs-you`:t,o=a===`needs-you`?0:n,s=r.map(e=>`${e.projectId}:${e.id}`).sort();return h({queryKey:[...X.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 Zt(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 u&&e.status===409&&i.setQueryData(X.snapshot,await Xt(t)),e}}})}function Bn({snapshot:e,questions:t,reviews:n,more:r,healthy:i=!0}){let a=ye();return(0,I.jsxs)(M,{className:`min-w-0 gap-0 overflow-hidden py-0`,children:[(0,I.jsxs)(`div`,{className:z,children:[(0,I.jsxs)(`h2`,{id:`dashboard-needs-you`,tabIndex:-1,className:R,children:[`Needs you · `,e.counts.questions+e.counts.reviews]}),(0,I.jsxs)(`p`,{className:`font-mono text-[11px] text-soft-foreground`,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,I.jsxs)(`p`,{className:`flex items-center gap-2.5 px-4 py-8 text-sm text-muted-foreground`,children:[(0,I.jsx)(N,{tone:`success`}),`All caught up — no tasks need your input`]}):null,(0,I.jsx)(Vn,{snapshot:e,group:`questions`,count:t,more:r}),(0,I.jsx)(Vn,{snapshot:e,group:`reviews`,count:n,more:r})]})}function Vn({snapshot:e,group:t,count:n,more:r}){let i=e[t],a=Math.max(n,i.rows.length),o=Rn(e,t,a,a>i.rows.length),s=a>i.rows.length?o.data:i.rows,c=ut(s,W,t,n),l=zn(e,t,a,c.rows.filter(e=>e.removed).map(e=>e.row)),u=(0,F.useRef)(null);return!i.total&&!c.rows.length?null:(0,I.jsxs)(`section`,{children:[(0,I.jsxs)(`h3`,{ref:u,tabIndex:-1,className:`border-b bg-card-2 px-4 py-2 font-mono text-[11px] font-semibold uppercase tracking-[0.12em] text-muted-foreground`,children:[t===`questions`?`Questions`:`Reviews`,` · `,i.total]}),c.updates>0&&(0,I.jsxs)(w,{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,I.jsx)(gt,{row:l.data?.get(W(e))??e,removed:t&&!!l.data&&!l.data.has(W(e)),checking:s===void 0||t&&!l.data,checkFailed:s===void 0&&o.isError||t&&!l.data&&l.isError,queue:!0},W(e))),(o.isError||l.isError)&&(0,I.jsxs)(`p`,{role:`alert`,className:`p-4 text-sm`,children:[`Could not check current task state.`,` `,(0,I.jsx)(w,{variant:`ghost`,className:`min-h-11`,onClick:()=>{o.refetch(),l.refetch()},children:`Retry`})]}),a<i.total&&(0,I.jsxs)(w,{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 Hn(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 Un=e=>e.key;function Wn({filter:e,setFilter:t,count:n,more:r}){let i=tn(e,!0),a=ut(i.data?.rows,Un,`feed:${e}`,0,e=>e.kind===`task-result`),o=a.rows,s=a.updates,c=(0,F.useContext)(ct),l=(0,F.useRef)(null),u=`feed:${e}`,d=(0,F.useMemo)(()=>({scroll:mt(c,u)?.scroll??0,done:!1}),[c,u]);(0,F.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,F.useRef)(null),p=i.data?.sources.filter(e=>e.key.startsWith(`github:`))??[],m=p.flatMap(e=>e.fetchedAt?[e.fetchedAt]:[]).sort()[0],h=i.githubError,g=p.filter(e=>e.reason===`No GitHub remote`),_=p.some(e=>e.reason===`Still loading GitHub`),v=p.length>0&&g.length===p.length&&!h,y=p.filter(e=>e.state!==`ready`&&e.reason!==`No GitHub remote`&&e.reason!==`Still loading GitHub`),b=v&&e===`all`;return(0,I.jsxs)(M,{"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,I.jsxs)(`div`,{className:`space-y-2 border-b px-4 pt-2.5 pb-2`,children:[(0,I.jsxs)(`div`,{className:`flex min-h-9 flex-wrap items-center justify-between gap-2`,children:[(0,I.jsx)(`h2`,{ref:f,tabIndex:-1,className:R,children:b?`Recent results`:`Recent results & GitHub`}),(0,I.jsx)(`span`,{className:`font-mono text-[11px] text-soft-foreground`,children:`Last 7 days`})]}),!b&&(0,I.jsx)(pe,{slot:`dashboard-feed`,label:`Results source`,value:e,options:[{value:`all`,label:`All`},{value:`tasks`,label:`Tasks`},{value:`github`,label:`GitHub`}],onChange:t}),b&&(0,I.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Task results · No GitHub repositories configured`}),e!==`tasks`&&!b&&(0,I.jsxs)(`details`,{className:`text-xs text-muted-foreground`,open:y.length||h?!0:void 0,children:[(0,I.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,I.jsx)(B,{}),y.length||h?`GitHub needs attention`:_?`Checking GitHub…`:v?`GitHub not configured`:m?`GitHub checked ${P(m)} ago`:`GitHub source`]}),(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-x-3`,children:[(0,I.jsx)(`p`,{children:y.length||h?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.`:_?`Checking repository sources. Available results remain visible.`:v?`No GitHub repositories configured. Select Tasks to see task results.`:m?`GitHub checked ${P(m)} ago`:`GitHub snapshot`}),!v&&(0,I.jsx)(w,{variant:`ghost`,className:`min-h-11 px-0`,disabled:i.githubFetching,onClick:()=>{i.refetch()},children:i.githubFetching?`Refreshing…`:y.length||h?`Retry GitHub`:`Refresh GitHub`})]})]})]}),(0,I.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&&ht(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,I.jsxs)(`p`,{role:`alert`,className:`p-4 text-sm`,children:[`Could not load results.`,` `,(0,I.jsx)(w,{className:`min-h-11`,onClick:()=>{i.retryFailed()},children:`Retry`})]}),i.isPending&&(0,I.jsx)(`p`,{className:`p-4 text-sm`,children:`Loading results…`}),s>0&&(0,I.jsxs)(w,{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,I.jsx)(gt,{row:e.run,kicker:t?`Outside current results`:`Latest result: ${e.run.status===`failed`?`Failed`:`Completed`}`},e.key):(0,I.jsxs)(`div`,{className:`border-b px-4 py-3 transition-colors hover:bg-muted/30`,children:[(0,I.jsx)(L,{rows:[{section:`github`,entity:`${e.repo}#${e.number}`,metric:e.itemKind,value:e.title,asOf:e.at,note:e.url}]}),(0,I.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,I.jsxs)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:[e.repo,` · `,e.itemKind===`pr`?`PR`:`Issue`,` #`,e.number,` created ·`,` `,P(e.at)]})]},e.key)),i.data&&!i.data.rows.length&&!o.length&&!i.isFetching&&!i.isError&&!y.length&&!_&&i.data.coverage.projects.every(e=>e.state===`complete`)&&(0,I.jsx)(`p`,{className:`px-4 py-8 text-sm text-muted-foreground`,children:`No results in the last 7 days`}),n<o.length&&(0,I.jsxs)(w,{variant:`ghost`,className:`m-2 min-h-11`,onClick:r,children:[`Show `,Math.min(20,o.length-n),` more results`]}),i.data?.truncated&&(0,I.jsx)(`p`,{className:`p-4 text-xs`,children:`Showing the latest 60 results`}),i.data&&(0,I.jsx)(G,{coverage:i.data.coverage,retry:()=>{i.retryTasks()}}),!b&&i.data?.sources.some(e=>e.state!==`ready`||e.truncated)&&(0,I.jsxs)(`details`,{className:`p-4 text-xs`,children:[(0,I.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,I.jsx)(B,{}),`Source details`]}),i.data.sources.map(e=>(0,I.jsxs)(`p`,{className:`break-words py-1`,children:[Hn(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 ${P(e.fetchedAt)}`:``]},e.key))]})]})]})}var $=e=>e.replace(/[&<>"']/g,e=>({"&":`&`,"<":`<`,">":`>`,'"':`"`,"'":`'`})[e]),Gn=`Visible modules and loaded rows only. Filters and report availability apply. Retained task usage is not an invoice or a complete history.`,Kn=`Confidential — internal distribution only`,qn={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 Jn(e,t){return e==null?`Unavailable`:typeof e==`string`?e:_t(e,t)}function Yn(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=qn[e.metric];!i||t.has(e.metric)||(t.add(e.metric),n.push({label:i.label,value:Jn(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 Xn(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-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 Zn(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-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:Xn(e),rows:[...e.querySelectorAll(`[data-dashboard-export]`)].flatMap(e=>JSON.parse(e.dataset.dashboardExport))}})}}function Qn(e){let t=e==null?``:String(e);return typeof e==`string`&&/^[\s\uFEFF]*[=+@\-]/.test(t)&&(t=`'${t}`),`"${t.replaceAll(`"`,`""`)}"`}function $n(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`,Gn,``,``,``,``,``,[...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(Qn).join(`,`)).join(`\r
|
|
2
2
|
`)+`\r
|
|
3
3
|
`}function er(e,t){let n=Yn(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 {
|
|
@@ -41,4 +41,4 @@ body { margin:0; font:12px/1.5 system-ui,sans-serif; }
|
|
|
41
41
|
.report-module [role=region] > div, .report-module [role=region] > p { break-inside:avoid; }
|
|
42
42
|
.report-module .sr-only { display:none!important; }
|
|
43
43
|
.report-context { font-size:11px; color:var(--muted-foreground); margin:0 0 8px; }
|
|
44
|
-
</style></head><body><header class="report-heading"><h1>${$(e.title||`Dashboard report`)}</h1><p>${$(e.generatedAt)} · ${$(e.source)}</p><span class="report-confidential">${Kn}</span><p>${$(Gn)}</p>${e.notices.map(e=>`<p>${$(e)}</p>`).join(``)}</header>${n.length?`<section class="report-summary"><h2>Executive summary</h2><div class="summary-grid">${n.map(e=>`<div class="summary-tile"><span class="summary-value">${$(e.value)}</span><span class="summary-label">${$(e.label)}</span>${e.note?`<span class="summary-note">${$(e.note)}</span>`:``}</div>`).join(``)}</div></section>`:``}${e.modules.map(e=>`<section class="report-module${e.id===`usage`?` report-module-usage`:e.id===`fleet`?` report-module-fleet`:``}"><p class="report-context">${$(e.filters)}</p>${e.html}</section>`).join(``)}</body></html>`}function tr({dashboard:e}){let[t,n]=(0,F.useState)(!1),[r,i]=(0,F.useState)(``),[a,o]=(0,F.useState)(!1),[s,c]=(0,F.useState)(``),l=t=>{i(``);try{if(!e.current)return;let r=Zn(e.current,new Date().toISOString(),location.origin,s.trim());if(!r.modules.length){i(`Show at least one dashboard module before exporting.`);return}if(t===`csv`){let e=URL.createObjectURL(new Blob([$n(r)],{type:`text/csv;charset=utf-8`})),t=document.createElement(`a`);t.href=e,t.download=`dashboard-${r.generatedAt.replaceAll(`:`,`-`)}.csv`,document.body.append(t),t.click(),t.remove(),setTimeout(()=>URL.revokeObjectURL(e),1e3),n(!1)}else{o(!0);let e=[...document.querySelectorAll(`link[rel="stylesheet"],style`)].flatMap(e=>{if(e.tagName===`STYLE`)return[e.outerHTML];let t=e.href;if(new URL(t).origin!==location.origin)return[];let n=document.createElement(`link`);return n.rel=`stylesheet`,n.href=t,[n.outerHTML]}),t=document.createElement(`iframe`);t.title=`Dashboard PDF report`,t.style.cssText=`position:fixed;width:1000px;height:1px;bottom:0;left:0;border:0;opacity:0;pointer-events:none`;let a,s=()=>{clearTimeout(a),t.remove(),o(!1)};t.onload=async()=>{try{let e=t.contentWindow;await e.document.fonts.ready,e.addEventListener(`afterprint`,s,{once:!0}),e.focus(),e.print(),n(!1),o(!1)}catch{s(),i(`Could not open the print dialog. Please try again.`)}},a=setTimeout(s,12e4),t.srcdoc=er(r,e),document.body.append(t)}}catch{o(!1),i(`Could not prepare the export. Please try again.`)}};return(0,I.jsxs)(ae,{open:t,onOpenChange:n,children:[(0,I.jsx)(ie,{asChild:!0,children:(0,I.jsxs)(w,{variant:`outline`,className:`min-h-11`,disabled:a,children:[(0,I.jsx)(Ve,{className:`size-4`}),a?`Preparing report…`:`Export`]})}),(0,I.jsxs)(re,{align:`end`,className:`max-w-[calc(100vw-2rem)] space-y-3`,children:[(0,I.jsx)(`p`,{className:`text-sm font-medium`,children:`Export current dashboard`}),(0,I.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Visible modules, current filters and loaded rows. Hidden metrics are excluded.`}),(0,I.jsxs)(`label`,{className:`block space-y-1 text-xs text-muted-foreground`,children:[`Report title (optional)`,(0,I.jsx)(`input`,{className:`min-h-11 w-full rounded-md border bg-background px-3 text-sm text-foreground`,placeholder:`e.g. Fleet review for leadership`,value:s,onChange:e=>c(e.target.value)})]}),(0,I.jsx)(w,{className:`min-h-11 w-full`,onClick:()=>l(`pdf`),children:`PDF report…`}),(0,I.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Choose Save as PDF in the print dialog.`}),(0,I.jsx)(w,{variant:`outline`,className:`min-h-11 w-full`,onClick:()=>l(`csv`),children:`Download CSV`}),r&&(0,I.jsx)(`p`,{role:`alert`,className:`text-sm`,children:r})]})]})}var nr={overview:`Workspace overview`,portfolio:`Projects`,automations:`Automations`,fleet:`Queue & scheduling`,needsYou:`Needs you`,recent:`Recent results & GitHub`,usage:`Usage & cost`,trends:`Trends`};function rr({id:e,children:t,wide:n}){let{attributes:r,listeners:i,setNodeRef:a,setActivatorNodeRef:o,transform:s,isDragging:c}=_e({id:e});return(0,I.jsxs)(`section`,{ref:a,"data-dashboard-module":e,className:`group/module relative min-w-0 ${n?`lg:col-span-2`:``} ${c?`z-20 opacity-80`:``}`,style:{transform:s?`translate3d(${s.x}px, ${s.y}px, 0)`:void 0},children:[(0,I.jsx)(w,{ref:o,variant:`ghost`,className:`absolute -top-[22px] left-1/2 z-10 min-h-11 min-w-11 -translate-x-1/2 cursor-grab touch-none p-0 opacity-0 transition-opacity hover:bg-transparent focus-visible:opacity-100 active:cursor-grabbing group-hover/module:opacity-100 no-hover:opacity-100`,...r,...i,"aria-label":`Move ${nr[e]}`,children:(0,I.jsx)(`span`,{className:`flex h-4 w-8 items-center justify-center rounded-full border bg-card text-muted-foreground shadow-xs`,children:(0,I.jsx)(Je,{className:`size-3.5`,"aria-hidden":`true`})})}),t]})}function ir({order:e,modules:t,onOrder:n}){let r=we(fe(Se,{activationConstraint:{distance:8}}),fe(de,{coordinateGetter:be})),i=e.filter(e=>t[e]),a=new Set([`overview`,`portfolio`,`usage`,`trends`]),o;for(let e of i)a.has(e)?(o&&a.add(o),o=void 0):o=o?void 0:e;o&&a.add(o);let s=e=>`${nr[e]}, position ${i.indexOf(e)+1} of ${i.length}`;return(0,I.jsx)(ge,{sensors:r,collisionDetection:Te,accessibility:{announcements:{onDragStart:({active:e})=>`Picked up ${s(e.id)}.`,onDragOver:({active:e,over:t})=>t?`${nr[e.id]} moved to position ${i.indexOf(t.id)+1} of ${i.length}.`:void 0,onDragEnd:({active:e,over:t})=>t?`${nr[e.id]} dropped at position ${i.indexOf(t.id)+1} of ${i.length}.`:`Order unchanged. ${s(e.id)}.`,onDragCancel:({active:e})=>`Reordering cancelled. ${s(e.id)}.`},screenReaderInstructions:{draggable:`Press Space to pick up a module, use arrow keys to move, Space to drop, or Escape to cancel.`}},onDragEnd:({active:t,over:r})=>{!r||t.id===r.id||n(he(e,e.indexOf(t.id),e.indexOf(r.id)))},children:(0,I.jsx)(me,{items:i,strategy:xe,children:(0,I.jsx)(`div`,{className:`grid items-start gap-5 lg:grid-cols-2`,children:i.map(e=>(0,I.jsx)(rr,{id:e,wide:a.has(e),children:t[e]},e))})})})}var ar=[`overview`,`needsYou`,`recent`,`fleet`,`automations`,`portfolio`,`usage`,`trends`],or=e=>ar.includes(e);function sr(e=[]){let t=e.filter(or);return(e=>t.length===e.length&&t.every((t,n)=>t===e[n]))(ar.filter(e=>e!==`automations`))?[...ar]:[...new Set([...t.includes(`overview`)?[]:[`overview`],...t,...ar])]}function cr(e=[],t){let n=0;return[...e.map(e=>or(e)?t[n++]:e),...t.slice(n)]}function lr(){let e=l(),t=c(),[n,a]=(0,F.useState)(),[o,u]=(0,F.useState)(!1),d=(0,F.useRef)(void 0),f=(0,F.useRef)(!1),p=E.parse(e.data?.dashboard??{}),m=(0,F.useRef)(p);m.current=p;let h=n?.tiles??{automations:p.tiles?.automations??!0,fleet:p.tiles?.fleet??!0,needsYou:p.tiles?.needsYou??!0,recent:p.tiles?.recent??!0,usage:p.tiles?.usage??!0,trends:p.tiles?.trends??!0},g=sr(n?.order??p.order),_=(0,F.useRef)({tiles:h,order:g});_.current=n??{tiles:h,order:g};let v=e=>{let t={..._.current,...e};_.current=t,a(t),d.current=t},y=async()=>{if(!(f.current||!d.current)){for(f.current=!0;d.current;){let n=d.current;d.current=void 0;try{e.data||(m.current=E.parse((await r()).dashboard??{}));let o=await i({dashboard:{...m.current,order:cr(m.current.order,n.order),tiles:{...m.current?.tiles,...n.tiles}}});t.setQueryData(s.uiState,o),m.current=E.parse(o.dashboard??{}),u(!1),a(e=>e===n?void 0:e)}catch{u(!0),d.current||=n;break}}f.current=!1}},b=(0,F.useRef)(y);return b.current=y,(0,F.useEffect)(()=>()=>{b.current()},[]),(0,F.useEffect)(()=>{if(!n)return;let e=setTimeout(()=>{y()},250);return()=>clearTimeout(e)},[n]),{tiles:h,order:g,setOrder:e=>v({order:sr(e)}),failed:o,ready:e.data!==void 0||e.isError,setTiles(e){v({tiles:e})},retry:()=>{y()}}}function ur(e,t){let n=ar.filter(e=>t.includes(e)),r=0;return e.map(e=>t.includes(e)?n[r++]:e)}var dr=[[`overview`,`Overview`],[`costs`,`Usage & cost`],[`automations`,`Automations`]];function fr(){let e=te(),t=e.state?.dashboardEntry??e.key;return(0,I.jsx)(pr,{entryKey:t},t)}function pr({entryKey:e}){let t=te(),[n,r]=ee(),i=(0,F.useRef)(ft(e)).current,[a,o]=(0,F.useState)(i?.questions??0),[s,c]=(0,F.useState)(i?.reviews??0),[l,u]=(0,F.useState)(i?.feed??6),d=(0,F.useRef)(null),f=(0,F.useRef)(null),[p,m]=(0,F.useState)(!1),h=lr(),[g,_]=(0,F.useState)(!1),v=n.get(`view`)===`costs`?`costs`:n.get(`view`)===`automations`?`automations`:`overview`,y=dr.find(([e])=>e===v)[1],b=v===`costs`?[`usage`,`trends`]:v===`automations`?[`automations`]:[`fleet`,`needsYou`,`recent`],x=v===`overview`?[`overview`,`portfolio`,...b]:[...b],S=ur(h.order,x),C=()=>h.setTiles({...h.tiles,...Object.fromEntries(b.map(e=>[e,!0]))}),T=h.tiles,E={...T,automations:v===`automations`&&T.automations,fleet:v===`overview`&&T.fleet,needsYou:v===`overview`&&T.needsYou,recent:v===`overview`&&T.recent,usage:v===`costs`&&T.usage,trends:v===`costs`&&T.trends},ne=n.get(`feed`)===`tasks`?`tasks`:n.get(`feed`)===`github`?`github`:`all`,oe=n.get(`panel`),O=oe&&[`running`,`queued`,`scheduled`,`needs-you`].includes(oe)?oe:null,k=E.fleet||E.needsYou||E.recent&&ne!==`github`||!!O,A=Qt(h.ready&&k),j=ye();$t(h.ready&&E.fleet&&g);let ce=(0,F.useRef)({questions:a,reviews:s,feed:l,scroll:i?.scroll??0,focus:i?.focus});ce.current={...ce.current,questions:a,reviews:s,feed:l},(0,F.useEffect)(()=>{let t=d.current?.closest(`main`)??d.current,n=()=>{ce.current.scroll=t?.scrollTop??0},r=()=>{ce.current.focus=document.activeElement?.closest(`[data-dashboard-row]`)?.getAttribute(`data-dashboard-row`)??void 0};return t?.addEventListener(`scroll`,n),document.addEventListener(`focusin`,r),()=>{pt(e,ce.current),t?.removeEventListener(`scroll`,n),document.removeEventListener(`focusin`,r)}},[e]);let le=(0,F.useRef)(!1),ue=h.ready&&(!k||!!A.data&&!A.isFetching);(0,F.useEffect)(()=>{if(!i||le.current||!ue)return;let e=!1,t=()=>{if(e)return!0;let t=d.current?.closest(`main`)??d.current;t&&(t.scrollTop=i.scroll);let n=!!t&&Math.abs(t.scrollTop-i.scroll)<1;if(!i.focus)return n;let r=document.querySelector(`[data-dashboard-row="${CSS.escape(i.focus)}"] a`);return r?(r.focus({preventScroll:!0}),n):(document.getElementById(`dashboard-needs-you`)?.focus({preventScroll:!0}),!1)},n=()=>{t()&&o()},r=new MutationObserver(n),a=typeof ResizeObserver>`u`?null:new ResizeObserver(n),o=()=>{e=!0,le.current=!0,r.disconnect(),a?.disconnect()},s=requestAnimationFrame(()=>{n(),e||(r.observe(document.body,{childList:!0,subtree:!0}),d.current&&a?.observe(d.current))}),c=setTimeout(o,5e3),l=[`pointerdown`,`keydown`,`wheel`,`touchstart`];for(let e of l)document.addEventListener(e,o,{once:!0});return()=>{cancelAnimationFrame(s),clearTimeout(c),e=!0,r.disconnect(),a?.disconnect();for(let e of l)document.removeEventListener(e,o)}},[i,ue]);let de=i=>{let a=new URLSearchParams(n);i?a.set(`panel`,i):a.delete(`panel`),r(a,{replace:!0,state:{...t.state,dashboardEntry:e}})},fe=(e,t)=>{f.current=t,de(e)},pe=A.data?A.data.counts.questions+A.data.counts.reviews:0;return(0,I.jsx)(ct.Provider,{value:e,children:(0,I.jsx)(lt.Provider,{value:!i||!A.isFetching&&!A.isError,children:(0,I.jsxs)(`div`,{ref:d,"data-route":`dashboard`,className:`mx-auto w-full max-w-[1440px] space-y-6 p-4 md:px-8 md:py-7`,children:[(0,I.jsxs)(`header`,{className:`flex flex-wrap items-end justify-between gap-4`,children:[(0,I.jsxs)(`div`,{className:`min-w-0`,children:[(0,I.jsx)(`h1`,{className:`text-2xl font-semibold tracking-tight`,children:`Dashboard`}),(0,I.jsxs)(`p`,{className:`mt-1 flex flex-wrap items-center gap-x-2 text-xs text-muted-foreground`,children:[`Across your workspace · Includes subtasks`,(0,I.jsxs)(`span`,{"data-export-exclude":!0,className:`inline-flex items-center gap-1.5 rounded-full border px-2 py-0.5 font-mono text-[10.5px] uppercase tracking-[0.1em]`,children:[(0,I.jsx)(N,{tone:j.connected?`success`:`neutral`,pulse:j.connected}),j.connected?`Live`:`Offline`]})]})]}),(0,I.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,I.jsx)(tr,{dashboard:d}),(0,I.jsxs)(ae,{open:p,onOpenChange:m,children:[(0,I.jsx)(ie,{asChild:!0,children:(0,I.jsxs)(w,{variant:`outline`,className:`min-h-11`,children:[(0,I.jsx)(se,{className:`size-4`}),`Customize`]})}),(0,I.jsxs)(re,{align:`end`,className:`max-h-[min(32rem,80dvh)] max-w-[calc(100vw-2rem)] overflow-y-auto`,children:[(0,I.jsx)(`p`,{className:`mb-3 text-sm font-medium`,children:`Optional modules in this view`}),b.map(e=>(0,I.jsxs)(`label`,{className:`flex min-h-11 items-center gap-3 text-sm`,children:[(0,I.jsx)(`input`,{type:`checkbox`,checked:T[e],disabled:!h.ready,onChange:t=>h.setTiles({...T,[e]:t.target.checked})}),{automations:`Automations`,fleet:`Queue & scheduling`,needsYou:`Needs you`,recent:`Recent results & GitHub`,usage:`Usage & cost`,trends:`Trends`}[e]]},e)),(0,I.jsx)(`p`,{className:`mt-3 text-xs text-muted-foreground`,children:`Drag a module by its handle. With keyboard: Space, arrow keys, Space. Escape cancels.`}),h.order.some((e,t)=>e!==S[t])&&(0,I.jsxs)(w,{variant:`ghost`,className:`min-h-11`,onClick:()=>h.setOrder(S),children:[`Reset `,y,` order`]}),(0,I.jsx)(`p`,{className:`my-3 text-xs text-muted-foreground`,children:`Shared across browsers using this workspace`}),b.some(e=>!T[e])&&(0,I.jsxs)(w,{variant:`outline`,className:`min-h-11`,disabled:!h.ready,onClick:()=>{C(),m(!1)},children:[`Show all in `,y]})]})]})]})]}),(0,I.jsx)(`nav`,{"aria-label":`Dashboard views`,className:`-mt-2 flex flex-wrap gap-5 border-b`,children:dr.map(([r,i])=>{let a=new URLSearchParams(n);return a.set(`view`,r),a.delete(`panel`),(0,I.jsx)(w,{asChild:!0,variant:`ghost`,className:`-mb-px min-h-11 rounded-none border-b-2 px-0.5 hover:bg-transparent ${v===r?`border-primary text-foreground`:`border-transparent`}`,children:(0,I.jsx)(D,{"aria-current":v===r?`page`:void 0,to:`?${a}`,replace:v===r,state:{...t.state,dashboardEntry:v===r?e:void 0},children:i})},r)})}),h.failed&&(0,I.jsxs)(`p`,{role:`alert`,className:`text-sm`,children:[`Layout changed for this session, but could not be saved.`,` `,(0,I.jsx)(w,{variant:`ghost`,className:`min-h-11`,onClick:h.retry,children:`Retry saving`})]}),k&&!j.connected&&A.data&&(0,I.jsxs)(`p`,{role:`status`,className:`text-xs text-muted-foreground`,children:[`Tasks disconnected · Last updated `,P(A.data.asOf),` ago`]}),k&&A.isError&&(0,I.jsxs)(`p`,{role:`alert`,className:`rounded-md border p-4 text-sm`,children:[`Could not refresh dashboard.`,` `,A.data?`Showing the last available task state.`:``,` `,(0,I.jsx)(w,{className:`min-h-11`,onClick:()=>{A.refetch()},children:`Retry`})]}),v===`costs`&&!Object.values(E).some(Boolean)?(0,I.jsxs)(`p`,{role:`status`,className:`flex flex-wrap items-center gap-2 text-sm text-muted-foreground`,children:[(0,I.jsx)(Ce,{className:`size-4`,"aria-hidden":`true`}),`Optional modules in this view are hidden.`,(0,I.jsxs)(w,{variant:`outline`,className:`min-h-11`,onClick:()=>C(),children:[`Show all in `,y]})]}):null,A.isPending&&(E.fleet||E.needsYou)&&(0,I.jsx)(`p`,{className:`text-sm`,children:`Loading dashboard…`}),k&&A.data&&(0,I.jsx)(G,{coverage:A.data.coverage,count:pe,retry:()=>void A.refetch()}),v===`automations`&&(0,I.jsx)(Ft,{}),(0,I.jsx)(Kt,{active:v===`overview`,onCurrent:fe,children:i=>h.ready&&(0,I.jsx)(ir,{order:h.order,onOrder:h.setOrder,modules:{...i,automations:E.automations?(0,I.jsx)(at,{}):null,fleet:E.fleet&&A.data?(0,I.jsxs)(M,{className:`gap-0 py-0`,children:[(0,I.jsx)(L,{rows:Object.entries({queued:A.data.counts.queued,scheduled:A.data.counts.scheduled,monitoring:A.data.counts.monitoring}).map(([e,t])=>({section:`fleet`,metric:e,value:t,unit:`tasks`,asOf:A.data.asOf}))}),(0,I.jsxs)(`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,I.jsx)(`h2`,{className:`section-mark font-mono text-[11px] font-semibold uppercase tracking-[0.14em] text-muted-foreground`,children:`Queue & scheduling`}),(0,I.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,I.jsx)(N,{tone:j.connected?`success`:`neutral`}),j.connected?`Tasks connected`:`Tasks disconnected`]})]}),(0,I.jsx)(`div`,{className:`grid grid-cols-2 divide-x`,children:[[`queued`,`Queued`,A.data.counts.queued],[`scheduled`,`Scheduled`,A.data.counts.scheduled]].map(([e,t,n])=>(0,I.jsxs)(`button`,{"data-export-keep":!0,"aria-label":`${t}: ${n}`,className:`min-h-24 p-4 text-left transition-colors hover:bg-muted/40 focus-visible:outline-ring`,onClick:t=>fe(e,t.currentTarget),children:[(0,I.jsx)(`span`,{className:`block font-mono text-[11px] uppercase tracking-[0.12em] text-muted-foreground`,children:t}),(0,I.jsx)(`span`,{className:`mt-3 block text-3xl font-semibold leading-none tracking-tight tabular-nums`,children:n})]},e))}),(0,I.jsxs)(`details`,{open:g,onToggle:e=>_(e.currentTarget.open),className:`border-t px-4 py-3 text-xs text-muted-foreground`,children:[(0,I.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-2`,children:[(0,I.jsx)(B,{}),`Technical details`]}),(0,I.jsxs)(`div`,{className:`flex flex-wrap gap-x-5 gap-y-2`,children:[(0,I.jsxs)(`span`,{children:[A.data.counts.monitoring,` monitoring (included in Running)`]}),(0,I.jsx)(`span`,{children:`Agent processes`}),g&&(0,I.jsx)(mr,{running:A.data.counts.running})]})]})]}):null,needsYou:E.needsYou&&A.data?(0,I.jsx)(Bn,{healthy:!A.isError,snapshot:A.data,questions:a,reviews:s,more:(e,t)=>e===`questions`?o(t):c(t)}):null,recent:E.recent?(0,I.jsx)(Wn,{filter:ne,setFilter:i=>{let a=new URLSearchParams(n);a.set(`feed`,i||`all`),r(a,{replace:!0,state:{...t.state,dashboardEntry:e}}),u(6)},count:l,more:()=>u(e=>Math.min(60,e+20))}):null,usage:E.usage?(0,I.jsx)(bn,{}):null,trends:E.trends?(0,I.jsx)(In,{}):null}})}),v===`costs`&&(0,I.jsx)(Nt,{}),(0,I.jsx)(Oe,{open:!!O,onOpenChange:e=>{e||de(null)},children:(0,I.jsxs)(De,{className:`w-full overflow-y-auto sm:max-w-lg`,onCloseAutoFocus:e=>{e.preventDefault(),f.current?.focus()},children:[(0,I.jsxs)(ke,{children:[(0,I.jsxs)(Ae,{children:[O===`needs-you`?`Needs you`:O?O[0].toUpperCase()+O.slice(1):`Tasks`,A.data&&O?` · ${O===`needs-you`?pe:A.data.counts[O]}`:``]}),(0,I.jsx)(Ee,{children:`Includes subtasks. Open a task to continue in its project.`})]}),!A.data&&A.isPending&&(0,I.jsx)(`p`,{className:`p-4`,role:`status`,children:`Loading tasks…`}),!A.data&&A.isError&&(0,I.jsxs)(`p`,{className:`p-4`,role:`alert`,children:[`Could not load tasks.`,` `,(0,I.jsx)(w,{className:`min-h-11`,onClick:()=>{A.refetch()},children:`Retry`})]}),O&&A.data&&(0,I.jsx)(hr,{snapshot:A.data,group:O},O)]})})]})})})}function mr({running:e}){let{connected:t,samples:n}=ye(),r=t?n:[],i=r.filter(e=>e.cpuPct!==null);return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(L,{rows:[{section:`telemetry`,metric:`cpuPct`,value:i.length?i.reduce((e,t)=>e+(t.cpuPct??0),0):null,unit:`%`,reportedTasks:i.length,totalTasks:e,note:`Sum of sampled processes; may exceed 100%`},{section:`telemetry`,metric:`rssBytes`,value:r.length?r.reduce((e,t)=>e+t.rssBytes,0):null,unit:`bytes`,reportedTasks:r.length,totalTasks:e}]}),(0,I.jsxs)(`span`,{children:[`CPU`,` `,i.length?`${Math.round(i.reduce((e,t)=>e+(t.cpuPct??0),0))}%`:`unavailable`,` `,`· `,i.length,`/`,e,` measured`]}),(0,I.jsxs)(`span`,{children:[`RSS`,` `,r.length?`${(r.reduce((e,t)=>e+t.rssBytes,0)/1024**3).toFixed(1)} GiB`:`unavailable`,` `,`· `,r.length,`/`,e,` measured`]}),(0,I.jsx)(`span`,{children:`RSS sums process resident memory; CPU may exceed 100%.`})]})}function hr({snapshot:e,group:t}){let n=(0,F.useContext)(ct),r=(0,F.useRef)(mt(n,t)).current,[i,a]=(0,F.useState)(r?.count??20),o=(0,F.useRef)(null),s=(0,F.useRef)({count:i,scroll:r?.scroll??0});s.current.count=i,(0,F.useEffect)(()=>{let e=o.current?.closest(`[data-slot="sheet-content"]`),r=()=>{s.current.scroll=e?.scrollTop??0};return e?.addEventListener(`scroll`,r),()=>{ht(n,t,s.current),e?.removeEventListener(`scroll`,r)}},[n,t]);let c=Rn(e,t,i),l=ut(c.data,W,`panel:${t}`,i),u=zn(e,t,i,l.rows.filter(e=>e.removed).map(e=>e.row)),d=(0,F.useRef)(null),f=(0,F.useRef)(!1);(0,F.useEffect)(()=>{if(!c.data||!r||f.current)return;f.current=!0;let e=o.current?.closest(`[data-slot="sheet-content"]`);e&&(e.scrollTop=r.scroll)},[c.data,r]);let p=t===`needs-you`?e.counts.questions+e.counts.reviews:e.counts[t];return(0,I.jsxs)(`div`,{ref:o,children:[(0,I.jsx)(`h3`,{ref:d,tabIndex:-1,className:`sr-only`,children:`Tasks`}),c.isPending&&(0,I.jsx)(`p`,{className:`p-4`,children:`Loading tasks…`}),(c.isError||u.isError)&&(0,I.jsxs)(`p`,{className:`p-4`,role:`alert`,children:[`Could not check current task state.`,` `,(0,I.jsx)(w,{className:`min-h-11`,onClick:()=>{c.refetch(),u.refetch()},children:`Retry`})]}),l.updates>0&&(0,I.jsxs)(w,{className:`m-4 min-h-11`,onClick:()=>{l.show(),d.current?.focus()},children:[l.updates,` updates — Show`]}),l.rows.map(({row:e,removed:n})=>(0,I.jsx)(gt,{row:u.data?.get(W(e))??e,removed:n&&!!u.data&&!u.data.has(W(e)),checking:!c.data||n&&!u.data,checkFailed:!c.data&&c.isError||n&&!u.data&&u.isError,queue:t===`needs-you`},W(e))),i<p&&(0,I.jsxs)(w,{className:`m-4 min-h-11`,disabled:c.isFetching,onClick:()=>a(e=>e+20),children:[`Show `,Math.min(20,p-i),` more tasks`]})]})}export{fr as DashboardRoute};
|
|
44
|
+
</style></head><body><header class="report-heading"><h1>${$(e.title||`Dashboard report`)}</h1><p>${$(e.generatedAt)} · ${$(e.source)}</p><span class="report-confidential">${Kn}</span><p>${$(Gn)}</p>${e.notices.map(e=>`<p>${$(e)}</p>`).join(``)}</header>${n.length?`<section class="report-summary"><h2>Executive summary</h2><div class="summary-grid">${n.map(e=>`<div class="summary-tile"><span class="summary-value">${$(e.value)}</span><span class="summary-label">${$(e.label)}</span>${e.note?`<span class="summary-note">${$(e.note)}</span>`:``}</div>`).join(``)}</div></section>`:``}${e.modules.map(e=>`<section class="report-module${e.id===`usage`?` report-module-usage`:e.id===`fleet`?` report-module-fleet`:``}"><p class="report-context">${$(e.filters)}</p>${e.html}</section>`).join(``)}</body></html>`}function tr({dashboard:e}){let[t,n]=(0,F.useState)(!1),[r,i]=(0,F.useState)(``),[a,o]=(0,F.useState)(!1),[s,c]=(0,F.useState)(``),l=t=>{i(``);try{if(!e.current)return;let r=Zn(e.current,new Date().toISOString(),location.origin,s.trim());if(!r.modules.length){i(`Show at least one dashboard module before exporting.`);return}if(t===`csv`){let e=URL.createObjectURL(new Blob([$n(r)],{type:`text/csv;charset=utf-8`})),t=document.createElement(`a`);t.href=e,t.download=`dashboard-${r.generatedAt.replaceAll(`:`,`-`)}.csv`,document.body.append(t),t.click(),t.remove(),setTimeout(()=>URL.revokeObjectURL(e),1e3),n(!1)}else{o(!0);let e=[...document.querySelectorAll(`link[rel="stylesheet"],style`)].flatMap(e=>{if(e.tagName===`STYLE`)return[e.outerHTML];let t=e.href;if(new URL(t).origin!==location.origin)return[];let n=document.createElement(`link`);return n.rel=`stylesheet`,n.href=t,[n.outerHTML]}),t=document.createElement(`iframe`);t.title=`Dashboard PDF report`,t.style.cssText=`position:fixed;width:1000px;height:1px;bottom:0;left:0;border:0;opacity:0;pointer-events:none`;let a,s=()=>{clearTimeout(a),t.remove(),o(!1)};t.onload=async()=>{try{let e=t.contentWindow;await e.document.fonts.ready,e.addEventListener(`afterprint`,s,{once:!0}),e.focus(),e.print(),n(!1),o(!1)}catch{s(),i(`Could not open the print dialog. Please try again.`)}},a=setTimeout(s,12e4),t.srcdoc=er(r,e),document.body.append(t)}}catch{o(!1),i(`Could not prepare the export. Please try again.`)}};return(0,I.jsxs)(ae,{open:t,onOpenChange:n,children:[(0,I.jsx)(ie,{asChild:!0,children:(0,I.jsxs)(w,{variant:`outline`,className:`min-h-11`,disabled:a,children:[(0,I.jsx)(Ve,{className:`size-4`}),a?`Preparing report…`:`Export`]})}),(0,I.jsxs)(re,{align:`end`,className:`max-w-[calc(100vw-2rem)] space-y-3`,children:[(0,I.jsx)(`p`,{className:`text-sm font-medium`,children:`Export current dashboard`}),(0,I.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Visible modules, current filters and loaded rows. Hidden metrics are excluded.`}),(0,I.jsxs)(`label`,{className:`block space-y-1 text-xs text-muted-foreground`,children:[`Report title (optional)`,(0,I.jsx)(`input`,{className:`min-h-11 w-full rounded-md border bg-background px-3 text-sm text-foreground`,placeholder:`e.g. Fleet review for leadership`,value:s,onChange:e=>c(e.target.value)})]}),(0,I.jsx)(w,{className:`min-h-11 w-full`,onClick:()=>l(`pdf`),children:`PDF report…`}),(0,I.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Choose Save as PDF in the print dialog.`}),(0,I.jsx)(w,{variant:`outline`,className:`min-h-11 w-full`,onClick:()=>l(`csv`),children:`Download CSV`}),r&&(0,I.jsx)(`p`,{role:`alert`,className:`text-sm`,children:r})]})]})}var nr={overview:`Workspace overview`,portfolio:`Projects`,automations:`Automations`,fleet:`Queue & scheduling`,needsYou:`Needs you`,recent:`Recent results & GitHub`,usage:`Usage & cost`,trends:`Trends`};function rr({id:e,children:t,wide:n}){let{attributes:r,listeners:i,setNodeRef:a,setActivatorNodeRef:o,transform:s,isDragging:c}=_e({id:e});return(0,I.jsxs)(`section`,{ref:a,"data-dashboard-module":e,className:`group/module relative min-w-0 ${n?`lg:col-span-2`:``} ${c?`z-20 opacity-80`:``}`,style:{transform:s?`translate3d(${s.x}px, ${s.y}px, 0)`:void 0},children:[(0,I.jsx)(w,{ref:o,variant:`ghost`,className:`absolute -top-[22px] left-1/2 z-10 min-h-11 min-w-11 -translate-x-1/2 cursor-grab touch-none p-0 opacity-0 transition-opacity hover:bg-transparent focus-visible:opacity-100 active:cursor-grabbing group-hover/module:opacity-100 no-hover:opacity-100`,...r,...i,"aria-label":`Move ${nr[e]}`,children:(0,I.jsx)(`span`,{className:`flex h-4 w-8 items-center justify-center rounded-full border bg-card text-muted-foreground shadow-xs`,children:(0,I.jsx)(Je,{className:`size-3.5`,"aria-hidden":`true`})})}),t]})}function ir({order:e,modules:t,onOrder:n}){let r=we(fe(Se,{activationConstraint:{distance:8}}),fe(de,{coordinateGetter:be})),i=e.filter(e=>t[e]),a=new Set([`overview`,`portfolio`,`usage`,`trends`]),o;for(let e of i)a.has(e)?(o&&a.add(o),o=void 0):o=o?void 0:e;o&&a.add(o);let s=e=>`${nr[e]}, position ${i.indexOf(e)+1} of ${i.length}`;return(0,I.jsx)(ge,{sensors:r,collisionDetection:Te,accessibility:{announcements:{onDragStart:({active:e})=>`Picked up ${s(e.id)}.`,onDragOver:({active:e,over:t})=>t?`${nr[e.id]} moved to position ${i.indexOf(t.id)+1} of ${i.length}.`:void 0,onDragEnd:({active:e,over:t})=>t?`${nr[e.id]} dropped at position ${i.indexOf(t.id)+1} of ${i.length}.`:`Order unchanged. ${s(e.id)}.`,onDragCancel:({active:e})=>`Reordering cancelled. ${s(e.id)}.`},screenReaderInstructions:{draggable:`Press Space to pick up a module, use arrow keys to move, Space to drop, or Escape to cancel.`}},onDragEnd:({active:t,over:r})=>{!r||t.id===r.id||n(he(e,e.indexOf(t.id),e.indexOf(r.id)))},children:(0,I.jsx)(me,{items:i,strategy:xe,children:(0,I.jsx)(`div`,{className:`grid items-start gap-5 lg:grid-cols-2`,children:i.map(e=>(0,I.jsx)(rr,{id:e,wide:a.has(e),children:t[e]},e))})})})}var ar=[`overview`,`needsYou`,`recent`,`fleet`,`automations`,`portfolio`,`usage`,`trends`],or=e=>ar.includes(e);function sr(e=[]){let t=e.filter(or);return(e=>t.length===e.length&&t.every((t,n)=>t===e[n]))(ar.filter(e=>e!==`automations`))?[...ar]:[...new Set([...t.includes(`overview`)?[]:[`overview`],...t,...ar])]}function cr(e=[],t){let n=0;return[...e.map(e=>or(e)?t[n++]:e),...t.slice(n)]}function lr(){let e=l(),t=m(),[n,r]=(0,F.useState)(),[o,s]=(0,F.useState)(!1),u=(0,F.useRef)(void 0),d=(0,F.useRef)(!1),f=E.parse(e.data?.dashboard??{}),p=(0,F.useRef)(f);p.current=f;let h=n?.tiles??{automations:f.tiles?.automations??!0,fleet:f.tiles?.fleet??!0,needsYou:f.tiles?.needsYou??!0,recent:f.tiles?.recent??!0,usage:f.tiles?.usage??!0,trends:f.tiles?.trends??!0},g=sr(n?.order??f.order),_=(0,F.useRef)({tiles:h,order:g});_.current=n??{tiles:h,order:g};let v=e=>{let t={..._.current,...e};_.current=t,r(t),u.current=t},y=async()=>{if(!(d.current||!u.current)){for(d.current=!0;u.current;){let n=u.current;u.current=void 0;try{e.data||(p.current=E.parse((await i()).dashboard??{}));let o=await a({dashboard:{...p.current,order:cr(p.current.order,n.order),tiles:{...p.current?.tiles,...n.tiles}}});t.setQueryData(c.uiState,o),p.current=E.parse(o.dashboard??{}),s(!1),r(e=>e===n?void 0:e)}catch{s(!0),u.current||=n;break}}d.current=!1}},b=(0,F.useRef)(y);return b.current=y,(0,F.useEffect)(()=>()=>{b.current()},[]),(0,F.useEffect)(()=>{if(!n)return;let e=setTimeout(()=>{y()},250);return()=>clearTimeout(e)},[n]),{tiles:h,order:g,setOrder:e=>v({order:sr(e)}),failed:o,ready:e.data!==void 0||e.isError,setTiles(e){v({tiles:e})},retry:()=>{y()}}}function ur(e,t){let n=ar.filter(e=>t.includes(e)),r=0;return e.map(e=>t.includes(e)?n[r++]:e)}var dr=[[`overview`,`Overview`],[`costs`,`Usage & cost`],[`automations`,`Automations`]];function fr(){let e=te(),t=e.state?.dashboardEntry??e.key;return(0,I.jsx)(pr,{entryKey:t},t)}function pr({entryKey:e}){let t=te(),[n,r]=ee(),i=(0,F.useRef)(ft(e)).current,[a,o]=(0,F.useState)(i?.questions??0),[s,c]=(0,F.useState)(i?.reviews??0),[l,u]=(0,F.useState)(i?.feed??6),d=(0,F.useRef)(null),f=(0,F.useRef)(null),[p,m]=(0,F.useState)(!1),h=lr(),[g,_]=(0,F.useState)(!1),v=n.get(`view`)===`costs`?`costs`:n.get(`view`)===`automations`?`automations`:`overview`,y=dr.find(([e])=>e===v)[1],b=v===`costs`?[`usage`,`trends`]:v===`automations`?[`automations`]:[`fleet`,`needsYou`,`recent`],x=v===`overview`?[`overview`,`portfolio`,...b]:[...b],S=ur(h.order,x),C=()=>h.setTiles({...h.tiles,...Object.fromEntries(b.map(e=>[e,!0]))}),T=h.tiles,E={...T,automations:v===`automations`&&T.automations,fleet:v===`overview`&&T.fleet,needsYou:v===`overview`&&T.needsYou,recent:v===`overview`&&T.recent,usage:v===`costs`&&T.usage,trends:v===`costs`&&T.trends},ne=n.get(`feed`)===`tasks`?`tasks`:n.get(`feed`)===`github`?`github`:`all`,oe=n.get(`panel`),O=oe&&[`running`,`queued`,`scheduled`,`needs-you`].includes(oe)?oe:null,k=E.fleet||E.needsYou||E.recent&&ne!==`github`||!!O,A=Qt(h.ready&&k),j=ye();$t(h.ready&&E.fleet&&g);let ce=(0,F.useRef)({questions:a,reviews:s,feed:l,scroll:i?.scroll??0,focus:i?.focus});ce.current={...ce.current,questions:a,reviews:s,feed:l},(0,F.useEffect)(()=>{let t=d.current?.closest(`main`)??d.current,n=()=>{ce.current.scroll=t?.scrollTop??0},r=()=>{ce.current.focus=document.activeElement?.closest(`[data-dashboard-row]`)?.getAttribute(`data-dashboard-row`)??void 0};return t?.addEventListener(`scroll`,n),document.addEventListener(`focusin`,r),()=>{pt(e,ce.current),t?.removeEventListener(`scroll`,n),document.removeEventListener(`focusin`,r)}},[e]);let le=(0,F.useRef)(!1),ue=h.ready&&(!k||!!A.data&&!A.isFetching);(0,F.useEffect)(()=>{if(!i||le.current||!ue)return;let e=!1,t=()=>{if(e)return!0;let t=d.current?.closest(`main`)??d.current;t&&(t.scrollTop=i.scroll);let n=!!t&&Math.abs(t.scrollTop-i.scroll)<1;if(!i.focus)return n;let r=document.querySelector(`[data-dashboard-row="${CSS.escape(i.focus)}"] a`);return r?(r.focus({preventScroll:!0}),n):(document.getElementById(`dashboard-needs-you`)?.focus({preventScroll:!0}),!1)},n=()=>{t()&&o()},r=new MutationObserver(n),a=typeof ResizeObserver>`u`?null:new ResizeObserver(n),o=()=>{e=!0,le.current=!0,r.disconnect(),a?.disconnect()},s=requestAnimationFrame(()=>{n(),e||(r.observe(document.body,{childList:!0,subtree:!0}),d.current&&a?.observe(d.current))}),c=setTimeout(o,5e3),l=[`pointerdown`,`keydown`,`wheel`,`touchstart`];for(let e of l)document.addEventListener(e,o,{once:!0});return()=>{cancelAnimationFrame(s),clearTimeout(c),e=!0,r.disconnect(),a?.disconnect();for(let e of l)document.removeEventListener(e,o)}},[i,ue]);let de=i=>{let a=new URLSearchParams(n);i?a.set(`panel`,i):a.delete(`panel`),r(a,{replace:!0,state:{...t.state,dashboardEntry:e}})},fe=(e,t)=>{f.current=t,de(e)},pe=A.data?A.data.counts.questions+A.data.counts.reviews:0;return(0,I.jsx)(ct.Provider,{value:e,children:(0,I.jsx)(lt.Provider,{value:!i||!A.isFetching&&!A.isError,children:(0,I.jsxs)(`div`,{ref:d,"data-route":`dashboard`,className:`mx-auto w-full max-w-[1440px] space-y-6 p-4 md:px-8 md:py-7`,children:[(0,I.jsxs)(`header`,{className:`flex flex-wrap items-end justify-between gap-4`,children:[(0,I.jsxs)(`div`,{className:`min-w-0`,children:[(0,I.jsx)(`h1`,{className:`text-2xl font-semibold tracking-tight`,children:`Dashboard`}),(0,I.jsxs)(`p`,{className:`mt-1 flex flex-wrap items-center gap-x-2 text-xs text-muted-foreground`,children:[`Across your workspace · Includes subtasks`,(0,I.jsxs)(`span`,{"data-export-exclude":!0,className:`inline-flex items-center gap-1.5 rounded-full border px-2 py-0.5 font-mono text-[10.5px] uppercase tracking-[0.1em]`,children:[(0,I.jsx)(N,{tone:j.connected?`success`:`neutral`,pulse:j.connected}),j.connected?`Live`:`Offline`]})]})]}),(0,I.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,I.jsx)(tr,{dashboard:d}),(0,I.jsxs)(ae,{open:p,onOpenChange:m,children:[(0,I.jsx)(ie,{asChild:!0,children:(0,I.jsxs)(w,{variant:`outline`,className:`min-h-11`,children:[(0,I.jsx)(se,{className:`size-4`}),`Customize`]})}),(0,I.jsxs)(re,{align:`end`,className:`max-h-[min(32rem,80dvh)] max-w-[calc(100vw-2rem)] overflow-y-auto`,children:[(0,I.jsx)(`p`,{className:`mb-3 text-sm font-medium`,children:`Optional modules in this view`}),b.map(e=>(0,I.jsxs)(`label`,{className:`flex min-h-11 items-center gap-3 text-sm`,children:[(0,I.jsx)(`input`,{type:`checkbox`,checked:T[e],disabled:!h.ready,onChange:t=>h.setTiles({...T,[e]:t.target.checked})}),{automations:`Automations`,fleet:`Queue & scheduling`,needsYou:`Needs you`,recent:`Recent results & GitHub`,usage:`Usage & cost`,trends:`Trends`}[e]]},e)),(0,I.jsx)(`p`,{className:`mt-3 text-xs text-muted-foreground`,children:`Drag a module by its handle. With keyboard: Space, arrow keys, Space. Escape cancels.`}),h.order.some((e,t)=>e!==S[t])&&(0,I.jsxs)(w,{variant:`ghost`,className:`min-h-11`,onClick:()=>h.setOrder(S),children:[`Reset `,y,` order`]}),(0,I.jsx)(`p`,{className:`my-3 text-xs text-muted-foreground`,children:`Shared across browsers using this workspace`}),b.some(e=>!T[e])&&(0,I.jsxs)(w,{variant:`outline`,className:`min-h-11`,disabled:!h.ready,onClick:()=>{C(),m(!1)},children:[`Show all in `,y]})]})]})]})]}),(0,I.jsx)(`nav`,{"aria-label":`Dashboard views`,className:`-mt-2 flex flex-wrap gap-5 border-b`,children:dr.map(([r,i])=>{let a=new URLSearchParams(n);return a.set(`view`,r),a.delete(`panel`),(0,I.jsx)(w,{asChild:!0,variant:`ghost`,className:`-mb-px min-h-11 rounded-none border-b-2 px-0.5 hover:bg-transparent ${v===r?`border-primary text-foreground`:`border-transparent`}`,children:(0,I.jsx)(D,{"aria-current":v===r?`page`:void 0,to:`?${a}`,replace:v===r,state:{...t.state,dashboardEntry:v===r?e:void 0},children:i})},r)})}),h.failed&&(0,I.jsxs)(`p`,{role:`alert`,className:`text-sm`,children:[`Layout changed for this session, but could not be saved.`,` `,(0,I.jsx)(w,{variant:`ghost`,className:`min-h-11`,onClick:h.retry,children:`Retry saving`})]}),k&&!j.connected&&A.data&&(0,I.jsxs)(`p`,{role:`status`,className:`text-xs text-muted-foreground`,children:[`Tasks disconnected · Last updated `,P(A.data.asOf),` ago`]}),k&&A.isError&&(0,I.jsxs)(`p`,{role:`alert`,className:`rounded-md border p-4 text-sm`,children:[`Could not refresh dashboard.`,` `,A.data?`Showing the last available task state.`:``,` `,(0,I.jsx)(w,{className:`min-h-11`,onClick:()=>{A.refetch()},children:`Retry`})]}),v===`costs`&&!Object.values(E).some(Boolean)?(0,I.jsxs)(`p`,{role:`status`,className:`flex flex-wrap items-center gap-2 text-sm text-muted-foreground`,children:[(0,I.jsx)(Ce,{className:`size-4`,"aria-hidden":`true`}),`Optional modules in this view are hidden.`,(0,I.jsxs)(w,{variant:`outline`,className:`min-h-11`,onClick:()=>C(),children:[`Show all in `,y]})]}):null,A.isPending&&(E.fleet||E.needsYou)&&(0,I.jsx)(`p`,{className:`text-sm`,children:`Loading dashboard…`}),k&&A.data&&(0,I.jsx)(G,{coverage:A.data.coverage,count:pe,retry:()=>void A.refetch()}),v===`automations`&&(0,I.jsx)(Ft,{}),(0,I.jsx)(Kt,{active:v===`overview`,onCurrent:fe,children:i=>h.ready&&(0,I.jsx)(ir,{order:h.order,onOrder:h.setOrder,modules:{...i,automations:E.automations?(0,I.jsx)(at,{}):null,fleet:E.fleet&&A.data?(0,I.jsxs)(M,{className:`gap-0 py-0`,children:[(0,I.jsx)(L,{rows:Object.entries({queued:A.data.counts.queued,scheduled:A.data.counts.scheduled,monitoring:A.data.counts.monitoring}).map(([e,t])=>({section:`fleet`,metric:e,value:t,unit:`tasks`,asOf:A.data.asOf}))}),(0,I.jsxs)(`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,I.jsx)(`h2`,{className:`section-mark font-mono text-[11px] font-semibold uppercase tracking-[0.14em] text-muted-foreground`,children:`Queue & scheduling`}),(0,I.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,I.jsx)(N,{tone:j.connected?`success`:`neutral`}),j.connected?`Tasks connected`:`Tasks disconnected`]})]}),(0,I.jsx)(`div`,{className:`grid grid-cols-2 divide-x`,children:[[`queued`,`Queued`,A.data.counts.queued],[`scheduled`,`Scheduled`,A.data.counts.scheduled]].map(([e,t,n])=>(0,I.jsxs)(`button`,{"data-export-keep":!0,"aria-label":`${t}: ${n}`,className:`min-h-24 p-4 text-left transition-colors hover:bg-muted/40 focus-visible:outline-ring`,onClick:t=>fe(e,t.currentTarget),children:[(0,I.jsx)(`span`,{className:`block font-mono text-[11px] uppercase tracking-[0.12em] text-muted-foreground`,children:t}),(0,I.jsx)(`span`,{className:`mt-3 block text-3xl font-semibold leading-none tracking-tight tabular-nums`,children:n})]},e))}),(0,I.jsxs)(`details`,{open:g,onToggle:e=>_(e.currentTarget.open),className:`border-t px-4 py-3 text-xs text-muted-foreground`,children:[(0,I.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-2`,children:[(0,I.jsx)(B,{}),`Technical details`]}),(0,I.jsxs)(`div`,{className:`flex flex-wrap gap-x-5 gap-y-2`,children:[(0,I.jsxs)(`span`,{children:[A.data.counts.monitoring,` monitoring (included in Running)`]}),(0,I.jsx)(`span`,{children:`Agent processes`}),g&&(0,I.jsx)(mr,{running:A.data.counts.running})]})]})]}):null,needsYou:E.needsYou&&A.data?(0,I.jsx)(Bn,{healthy:!A.isError,snapshot:A.data,questions:a,reviews:s,more:(e,t)=>e===`questions`?o(t):c(t)}):null,recent:E.recent?(0,I.jsx)(Wn,{filter:ne,setFilter:i=>{let a=new URLSearchParams(n);a.set(`feed`,i||`all`),r(a,{replace:!0,state:{...t.state,dashboardEntry:e}}),u(6)},count:l,more:()=>u(e=>Math.min(60,e+20))}):null,usage:E.usage?(0,I.jsx)(bn,{}):null,trends:E.trends?(0,I.jsx)(In,{}):null}})}),v===`costs`&&(0,I.jsx)(Nt,{}),(0,I.jsx)(Oe,{open:!!O,onOpenChange:e=>{e||de(null)},children:(0,I.jsxs)(De,{className:`w-full overflow-y-auto sm:max-w-lg`,onCloseAutoFocus:e=>{e.preventDefault(),f.current?.focus()},children:[(0,I.jsxs)(ke,{children:[(0,I.jsxs)(Ae,{children:[O===`needs-you`?`Needs you`:O?O[0].toUpperCase()+O.slice(1):`Tasks`,A.data&&O?` · ${O===`needs-you`?pe:A.data.counts[O]}`:``]}),(0,I.jsx)(Ee,{children:`Includes subtasks. Open a task to continue in its project.`})]}),!A.data&&A.isPending&&(0,I.jsx)(`p`,{className:`p-4`,role:`status`,children:`Loading tasks…`}),!A.data&&A.isError&&(0,I.jsxs)(`p`,{className:`p-4`,role:`alert`,children:[`Could not load tasks.`,` `,(0,I.jsx)(w,{className:`min-h-11`,onClick:()=>{A.refetch()},children:`Retry`})]}),O&&A.data&&(0,I.jsx)(hr,{snapshot:A.data,group:O},O)]})})]})})})}function mr({running:e}){let{connected:t,samples:n}=ye(),r=t?n:[],i=r.filter(e=>e.cpuPct!==null);return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(L,{rows:[{section:`telemetry`,metric:`cpuPct`,value:i.length?i.reduce((e,t)=>e+(t.cpuPct??0),0):null,unit:`%`,reportedTasks:i.length,totalTasks:e,note:`Sum of sampled processes; may exceed 100%`},{section:`telemetry`,metric:`rssBytes`,value:r.length?r.reduce((e,t)=>e+t.rssBytes,0):null,unit:`bytes`,reportedTasks:r.length,totalTasks:e}]}),(0,I.jsxs)(`span`,{children:[`CPU`,` `,i.length?`${Math.round(i.reduce((e,t)=>e+(t.cpuPct??0),0))}%`:`unavailable`,` `,`· `,i.length,`/`,e,` measured`]}),(0,I.jsxs)(`span`,{children:[`RSS`,` `,r.length?`${(r.reduce((e,t)=>e+t.rssBytes,0)/1024**3).toFixed(1)} GiB`:`unavailable`,` `,`· `,r.length,`/`,e,` measured`]}),(0,I.jsx)(`span`,{children:`RSS sums process resident memory; CPU may exceed 100%.`})]})}function hr({snapshot:e,group:t}){let n=(0,F.useContext)(ct),r=(0,F.useRef)(mt(n,t)).current,[i,a]=(0,F.useState)(r?.count??20),o=(0,F.useRef)(null),s=(0,F.useRef)({count:i,scroll:r?.scroll??0});s.current.count=i,(0,F.useEffect)(()=>{let e=o.current?.closest(`[data-slot="sheet-content"]`),r=()=>{s.current.scroll=e?.scrollTop??0};return e?.addEventListener(`scroll`,r),()=>{ht(n,t,s.current),e?.removeEventListener(`scroll`,r)}},[n,t]);let c=Rn(e,t,i),l=ut(c.data,W,`panel:${t}`,i),u=zn(e,t,i,l.rows.filter(e=>e.removed).map(e=>e.row)),d=(0,F.useRef)(null),f=(0,F.useRef)(!1);(0,F.useEffect)(()=>{if(!c.data||!r||f.current)return;f.current=!0;let e=o.current?.closest(`[data-slot="sheet-content"]`);e&&(e.scrollTop=r.scroll)},[c.data,r]);let p=t===`needs-you`?e.counts.questions+e.counts.reviews:e.counts[t];return(0,I.jsxs)(`div`,{ref:o,children:[(0,I.jsx)(`h3`,{ref:d,tabIndex:-1,className:`sr-only`,children:`Tasks`}),c.isPending&&(0,I.jsx)(`p`,{className:`p-4`,children:`Loading tasks…`}),(c.isError||u.isError)&&(0,I.jsxs)(`p`,{className:`p-4`,role:`alert`,children:[`Could not check current task state.`,` `,(0,I.jsx)(w,{className:`min-h-11`,onClick:()=>{c.refetch(),u.refetch()},children:`Retry`})]}),l.updates>0&&(0,I.jsxs)(w,{className:`m-4 min-h-11`,onClick:()=>{l.show(),d.current?.focus()},children:[l.updates,` updates — Show`]}),l.rows.map(({row:e,removed:n})=>(0,I.jsx)(gt,{row:u.data?.get(W(e))??e,removed:n&&!!u.data&&!u.data.has(W(e)),checking:!c.data||n&&!u.data,checkFailed:!c.data&&c.isError||n&&!u.data&&u.isError,queue:t===`needs-you`},W(e))),i<p&&(0,I.jsxs)(w,{className:`m-4 min-h-11`,disabled:c.isFetching,onClick:()=>a(e=>e+20),children:[`Show `,Math.min(20,p-i),` more tasks`]})]})}export{fr as DashboardRoute};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{Pi as r,Ri as i,Yn as a,st as o,vt as s}from"./queries-
|
|
1
|
+
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{Pi as r,Ri as i,Yn as a,st as o,vt as s}from"./queries-Bn7zl9OU.js";import{F as c,r as l}from"./button-Clwd6u4_.js";import{t as u}from"./file-1a6_DhLG.js";import{t as d}from"./chevron-right-VbYrJ_st.js";import{f}from"./git-toolbar-Dra1QlHb.js";import{t as p}from"./triangle-alert-BqI_9MkV.js";import{t as m}from"./centered-state-nM7v9xtl.js";import{a as h,i as g,o as _,t as v}from"./markdown-Rbaca31B.js";import{n as y}from"./markdown-BzqT8I8y.js";var b=c(`arrow-down`,[[`path`,{d:`M12 5v14`,key:`s699le`}],[`path`,{d:`m19 12-7 7-7-7`,key:`1idqje`}]]),x=c(`file-exclamation-point`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M12 9v4`,key:`juzpu7`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]]),S=c(`file-question-mark`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}],[`path`,{d:`M9.1 9a3 3 0 0 1 5.82 1c0 2-3 3-3 3`,key:`mhlwft`}]]),C=c(`file-x`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`m14.5 12.5-5 5`,key:`b62r18`}],[`path`,{d:`m9.5 12.5 5 5`,key:`1rk7el`}]]),w=c(`folder-tree`,[[`path`,{d:`M20 10a1 1 0 0 0 1-1V6a1 1 0 0 0-1-1h-2.5a1 1 0 0 1-.8-.4l-.9-1.2A1 1 0 0 0 15 3h-2a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z`,key:`hod4my`}],[`path`,{d:`M20 21a1 1 0 0 0 1-1v-3a1 1 0 0 0-1-1h-2.9a1 1 0 0 1-.88-.55l-.42-.85a1 1 0 0 0-.92-.6H13a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z`,key:`w4yl2u`}],[`path`,{d:`M3 5a2 2 0 0 0 2 2h3`,key:`f2jnh7`}],[`path`,{d:`M3 3v13a2 2 0 0 0 2 2h3`,key:`k8epm1`}]]),T=c(`image`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,ry:`2`,key:`1m3agn`}],[`circle`,{cx:`9`,cy:`9`,r:`2`,key:`af1f0g`}],[`path`,{d:`m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21`,key:`1xmnt7`}]]),E=c(`mouse-pointer-click`,[[`path`,{d:`M14 4.1 12 6`,key:`ita8i4`}],[`path`,{d:`m5.1 8-2.9-.8`,key:`1go3kf`}],[`path`,{d:`m6 12-1.9 2`,key:`mnht97`}],[`path`,{d:`M7.2 2.2 8 5.1`,key:`1cfko1`}],[`path`,{d:`M9.037 9.69a.498.498 0 0 1 .653-.653l11 4.5a.5.5 0 0 1-.074.949l-4.349 1.041a1 1 0 0 0-.74.739l-1.04 4.35a.5.5 0 0 1-.95.074z`,key:`s0h3yz`}]]),D=e(t(),1),O=n();function k({root:e,selected:t,onSelect:n,commentCounts:r=A}){return(0,O.jsx)(j.Provider,{value:r,children:(0,O.jsx)(`nav`,{"data-slot":`changes-tree`,"aria-label":`Changed files`,className:`min-w-0 text-[13px]`,children:(0,O.jsxs)(`ul`,{className:`flex flex-col gap-px`,children:[e.dirs.map(e=>(0,O.jsx)(P,{dir:e,depth:0,selected:t,onSelect:n},e.path)),e.files.map(e=>(0,O.jsx)(I,{file:e,depth:0,selected:t,onSelect:n},e.path))]})})})}var A=new Map,j=(0,D.createContext)(A);function M(e,t){let n=0;for(let r of e.files)n+=t.get(r.path)??0;for(let r of e.dirs)n+=M(r,t);return n}function N({adds:e,dels:t}){return(0,O.jsxs)(`span`,{className:`shrink-0 font-mono text-[11px] font-medium tabular-nums`,children:[e>0?(0,O.jsxs)(`span`,{className:`text-success`,children:[`+`,e]}):null,e>0&&t>0?` `:null,t>0?(0,O.jsxs)(`span`,{className:`text-danger`,children:[`−`,t]}):null]})}function P({dir:e,depth:t,selected:n,onSelect:r}){let[i,a]=(0,D.useState)(!0),o=(0,D.useContext)(j),s=i?0:M(e,o);return(0,O.jsxs)(`li`,{children:[(0,O.jsxs)(`button`,{type:`button`,"data-slot":`tree-dir`,"data-path":e.path,"data-state":i?`open`:`closed`,"aria-expanded":i,onClick:()=>a(e=>!e),className:`flex w-full min-w-0 items-center gap-1.5 rounded-sm px-1.5 py-1 text-left text-muted-foreground hover:bg-muted hover:text-foreground`,style:{paddingLeft:`${6+t*14}px`},children:[(0,O.jsx)(d,{"aria-hidden":`true`,className:l(`size-3.5 shrink-0 transition-transform`,i&&`rotate-90`)}),(0,O.jsx)(f,{"aria-hidden":`true`,className:`size-3.5 shrink-0`}),(0,O.jsx)(`span`,{className:`min-w-0 truncate font-medium`,children:e.name}),(0,O.jsxs)(`span`,{className:`ml-auto flex shrink-0 items-center gap-2 pl-2`,children:[(0,O.jsx)(y,{count:s}),(0,O.jsx)(N,{adds:e.adds,dels:e.dels})]})]}),i?(0,O.jsxs)(`ul`,{className:`flex flex-col gap-px`,children:[e.dirs.map(e=>(0,O.jsx)(P,{dir:e,depth:t+1,selected:n,onSelect:r},e.path)),e.files.map(e=>(0,O.jsx)(I,{file:e,depth:t+1,selected:n,onSelect:r},e.path))]}):null]})}var F={added:`text-success`,deleted:`text-danger`};function I({file:e,depth:t,selected:n,onSelect:r}){let i=n===e.path,a=(0,D.useContext)(j).get(e.path)??0;return(0,O.jsx)(`li`,{children:(0,O.jsxs)(`button`,{type:`button`,"data-slot":`tree-file`,"data-path":e.path,"aria-current":i?`true`:void 0,onClick:()=>r(e.path),className:l(`flex w-full min-w-0 items-center gap-1.5 rounded-sm px-1.5 py-1 text-left hover:bg-muted`,i?`bg-muted font-medium text-foreground`:`text-muted-foreground hover:text-foreground`),style:{paddingLeft:`${24+t*14}px`},children:[(0,O.jsx)(u,{"aria-hidden":`true`,className:l(`size-3.5 shrink-0`,F[e.status])}),(0,O.jsx)(`span`,{className:`min-w-0 truncate`,children:e.name}),(0,O.jsxs)(`span`,{className:`ml-auto flex shrink-0 items-center gap-2 pl-2`,children:[(0,O.jsx)(y,{count:a}),(0,O.jsx)(N,{adds:e.adds,dels:e.dels})]})]})})}var L=(e,t)=>e.name.localeCompare(t.name);function R(e){let t=e;for(;t.files.length===0&&t.dirs.length===1;){let e=t.dirs[0];t={...e,name:`${t.name}/${e.name}`}}return{...t,dirs:t.dirs.map(R)}}function z(e,t){let n=(e,t)=>({kind:`dir`,name:e,path:t,dirs:[],files:[]}),r=n(``,``),i=new Map([[``,r]]),a=e=>{let t=i.get(e);if(t)return t;let r=e.lastIndexOf(`/`),o=a(r===-1?``:e.slice(0,r)),s=n(r===-1?e:e.slice(r+1),e);return o.dirs.push(s),i.set(e,s),s};for(let n of e){let e=n.lastIndexOf(`/`);a(e===-1?``:n.slice(0,e)).files.push(t(n,e===-1?n:n.slice(e+1)))}let o=e=>{e.dirs.forEach(o),e.dirs.sort(L),e.files.sort(L)};return o(r),{...r,dirs:r.dirs.map(R)}}function B(e){let t=new Map(e.map(e=>[e.path,e])),n=z(e.map(e=>e.path),(e,n)=>{let r=t.get(e);return{kind:`file`,name:n,path:e,status:r.status,adds:r.adds,dels:r.dels,binary:r.binary}}),r=e=>{let t=e.dirs.map(r);return{...e,dirs:t,adds:e.files.reduce((e,t)=>e+t.adds,0)+t.reduce((e,t)=>e+t.adds,0),dels:e.files.reduce((e,t)=>e+t.dels,0)+t.reduce((e,t)=>e+t.dels,0),fileCount:e.files.length+t.reduce((e,t)=>e+t.fileCount,0)}};return r(n)}var V=new Set([`png`,`jpg`,`jpeg`,`gif`,`webp`,`svg`,`bmp`,`ico`,`avif`]);function H(e){let t=e.slice(e.lastIndexOf(`/`)+1),n=t.lastIndexOf(`.`);return n<=0?!1:V.has(t.slice(n+1).toLowerCase())}function U(e){return e.tooLarge?`too-large`:H(e.path)?`image`:e.binary?`binary`:`text`}function W(e){return e>=1024**2?`${(e/1024**2).toFixed(1)} MB`:e>=1024?`${(e/1024).toFixed(1)} kB`:`${e} B`}function G(e,t){let n=s(e.kind===`run`?e.runId:void 0,e.kind===`run`?t:void 0),r=o(e.kind===`repo`?t:void 0);return e.kind===`run`?n:r}function K(e,t){return e.kind===`run`?i(e.runId,t):r(t)}function q({source:e,path:t,className:n}){let r=G(e,t??void 0);if(t===null)return(0,O.jsx)(Z,{className:n,children:(0,O.jsx)(m,{icon:(0,O.jsx)(E,{}),tone:`neutral`,heading:`h2`,title:`Select a file`,subtitle:`Pick a file from the tree to preview it here.`})});if(r.isPending)return(0,O.jsx)(Z,{className:n,children:(0,O.jsxs)(`p`,{"data-slot":`file-preview-loading`,className:`px-4 py-6 text-center text-xs text-soft-foreground`,children:[`Loading `,t,`…`]})});if(r.isError){let e=r.error instanceof a&&r.error.status===409;return(0,O.jsx)(Z,{className:n,children:(0,O.jsx)(m,{icon:e?(0,O.jsx)(C,{}):(0,O.jsx)(p,{}),tone:e?`neutral`:`danger`,heading:`h2`,title:e?`Cannot preview this file`:`Could not load this file`,subtitle:r.error.message})})}return r.data.type===`file`?(0,O.jsx)(X,{source:e,entry:r.data,className:n}):null}function J(e){return/\.(md|markdown|mdx)$/i.test(e)}var Y=`rendered`;function X({source:e,entry:t,className:n}){let r=U(t),i=r===`text`&&J(t.path),[a,o]=(0,D.useState)(Y),s=e=>{Y=e,o(e)};return(0,O.jsxs)(Z,{className:n,children:[(0,O.jsxs)(`header`,{"data-slot":`file-preview-head`,className:`sticky top-0 z-10 flex items-center gap-2 border-b border-border bg-[color-mix(in_oklab,var(--muted)_40%,var(--card))] px-4 py-2 text-xs shadow-[0_-1px_0_color-mix(in_oklab,var(--muted)_40%,var(--card))]`,children:[(0,O.jsx)(`span`,{className:`min-w-0 truncate font-mono font-medium`,children:t.path}),i?(0,O.jsx)(`div`,{"data-slot":`markdown-view-toggle`,className:`ml-auto flex shrink-0 overflow-hidden rounded-sm border border-border`,children:[`rendered`,`source`].map(e=>(0,O.jsx)(`button`,{type:`button`,"data-mode":e,"aria-pressed":a===e,onClick:()=>s(e),className:l(`px-2 py-0.5 capitalize`,a===e?`bg-muted font-medium text-foreground`:`text-soft-foreground hover:bg-muted`),children:e},e))}):null,(0,O.jsx)(`span`,{className:l(`shrink-0 tabular-nums text-soft-foreground`,i?`pl-2`:`ml-auto`),children:W(t.size)})]}),r===`image`?(0,O.jsx)(`div`,{className:`flex justify-center p-4`,children:(0,O.jsx)(`img`,{"data-slot":`file-preview-image`,src:K(e,t.path),alt:t.path,className:`max-h-[70vh] max-w-full rounded-sm`})}):r===`too-large`?(0,O.jsx)(m,{icon:(0,O.jsx)(x,{}),tone:`neutral`,heading:`h2`,title:`Too large to preview`,subtitle:`${W(t.size)} — past the preview cap. Open it in your editor instead.`}):r===`binary`?(0,O.jsx)(m,{icon:(0,O.jsx)(S,{}),tone:`neutral`,heading:`h2`,title:`Binary file`,subtitle:`${W(t.size)} of binary data — no text preview.`}):i&&a===`rendered`?(0,O.jsx)(`div`,{"data-slot":`file-preview-markdown`,className:`px-4 py-3`,children:(0,O.jsx)(v,{children:t.content??``})}):(0,O.jsx)(ee,{path:t.path,text:t.content??``})]})}function Z({className:e,children:t}){return(0,O.jsx)(`section`,{"data-slot":`file-preview`,className:l(`overflow-clip rounded-lg border border-border bg-card`,e),children:t})}var Q=1500;function $(e,t){let n=(0,D.useMemo)(()=>t.split(`
|
|
2
2
|
`).map(e=>[{content:e}]),[t]),r=(0,D.useMemo)(()=>_(e),[e]),i=n.length>Q,[a,o]=(0,D.useState)(null);return(0,D.useEffect)(()=>{if(r===null||i)return;let n=!1;return g(t,r).then(r=>{n||o({key:`${e}\0${t}`,tokens:r.tokens})}),()=>{n=!0}},[e,t,r,i]),r===null||i?n:a?.key===`${e}\0${t}`?a.tokens:h(t,r)?.tokens??n}function ee({path:e,text:t}){let n=$(e,t);return(0,O.jsx)(`div`,{"data-slot":`file-preview-code`,"data-lang":_(e)??`plaintext`,className:`overflow-x-auto py-2 font-mono text-xs leading-[1.7]`,children:n.map((e,t)=>(0,O.jsxs)(`div`,{className:`flex px-4`,children:[(0,O.jsx)(`span`,{className:`w-10 shrink-0 select-none pr-3 text-right tabular-nums text-soft-foreground`,children:t+1}),(0,O.jsx)(`span`,{className:`min-w-0 flex-1 whitespace-pre pr-4`,children:e.map((e,t)=>(0,O.jsx)(`span`,{style:e.color===void 0?void 0:{color:e.color},children:e.content},t))})]},t))})}export{z as a,T as c,B as i,w as l,W as n,k as o,H as r,E as s,q as t,b as u};
|