@open-mercato/cezar 0.18.0 → 0.19.0-pr1815.4229

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (122) hide show
  1. package/dist/automations/automation-cli.js +12 -6
  2. package/dist/automations/automation-cli.js.map +1 -1
  3. package/dist/automations/prompts.js +3 -1
  4. package/dist/automations/prompts.js.map +1 -1
  5. package/dist/automations/schedule-runner.js +18 -4
  6. package/dist/automations/schedule-runner.js.map +1 -1
  7. package/dist/automations/store.js +9 -2
  8. package/dist/automations/store.js.map +1 -1
  9. package/dist/automations/templates.js +1 -0
  10. package/dist/automations/templates.js.map +1 -1
  11. package/dist/automations/types.d.ts +28 -0
  12. package/dist/automations/types.js +6 -2
  13. package/dist/automations/types.js.map +1 -1
  14. package/dist/contract/automation-schedule.d.ts +28 -0
  15. package/dist/contract/automations.d.ts +126 -0
  16. package/dist/contract/github.d.ts +56 -0
  17. package/dist/contract/index.js +63 -0
  18. package/dist/contract/workspace.d.ts +18 -0
  19. package/dist/server/forge/github-issue-metadata.d.ts +6 -0
  20. package/dist/server/forge/github-issue-metadata.js +66 -0
  21. package/dist/server/forge/github-issue-metadata.js.map +1 -0
  22. package/dist/server/forge/github.d.ts +1 -1
  23. package/dist/server/forge/github.js +38 -4
  24. package/dist/server/forge/github.js.map +1 -1
  25. package/dist/server/forge/types.d.ts +2 -17
  26. package/dist/server/server.d.ts +320 -36
  27. package/dist/server/server.js +21 -20
  28. package/dist/server/server.js.map +1 -1
  29. package/dist/workflows/run.js +7 -0
  30. package/dist/workflows/run.js.map +1 -1
  31. package/package.json +3 -3
  32. package/web/dist/assets/{agent-task-pickers-DbNIzx20.js → agent-task-pickers-_i7QNEVz.js} +1 -1
  33. package/web/dist/assets/{alert-dialog-4Kna6Hd7.js → alert-dialog-BZU09BVw.js} +1 -1
  34. package/web/dist/assets/arrow-down-BQxdXW9w.js +1 -0
  35. package/web/dist/assets/arrow-left-CvmEanh8.js +1 -0
  36. package/web/dist/assets/automation-format-CEBKDGz8.js +1 -0
  37. package/web/dist/assets/automations-route-Cg1sWvtN.js +1 -0
  38. package/web/dist/assets/button-BvYDiOkd.js +100 -0
  39. package/web/dist/assets/{centered-state-D-wDs7Y1.js → centered-state-Bpq40Y_t.js} +1 -1
  40. package/web/dist/assets/check-DC3eAaS2.js +1 -0
  41. package/web/dist/assets/chevron-left-BW4WDtiS.js +1 -0
  42. package/web/dist/assets/chevron-right-DuM1UAhq.js +1 -0
  43. package/web/dist/assets/circle-check-DiPv45P_.js +1 -0
  44. package/web/dist/assets/{clipboard-DQGL_gUp.js → clipboard-7kWKIj7k.js} +1 -1
  45. package/web/dist/assets/{collapsible-D7qsttC5.js → collapsible-OE3rGS50.js} +1 -1
  46. package/web/dist/assets/{commit-list-DTMGEn0-.js → commit-list-DalU6p3i.js} +1 -1
  47. package/web/dist/assets/{compare-variants-DqlkpLFs.js → compare-variants-CuCfgtyG.js} +1 -1
  48. package/web/dist/assets/dashboard-BYBop-ZJ.js +44 -0
  49. package/web/dist/assets/{diff-DY-_mmb0.js → diff-DfTKq2z2.js} +2 -2
  50. package/web/dist/assets/{diff-view-oTEcZZ_O.js → diff-view-Du2463vL.js} +1 -1
  51. package/web/dist/assets/{download-BBtWFvsh.js → download-_KH0gJo8.js} +1 -1
  52. package/web/dist/assets/facet-filter-BSS2vFA8.js +5 -0
  53. package/web/dist/assets/{file-CbWEaOku.js → file-d2ABwdSR.js} +1 -1
  54. package/web/dist/assets/file-preview-BURiO97x.js +2 -0
  55. package/web/dist/assets/{git-pull-request-draft-Dwhm6Vhn.js → git-pull-request-draft-DIdbQZ0O.js} +1 -1
  56. package/web/dist/assets/git-tab-loading-8Y0ID8J2.js +1 -0
  57. package/web/dist/assets/{git-toolbar-C3vpZJaZ.js → git-toolbar-CSrf6Ux9.js} +1 -1
  58. package/web/dist/assets/github-DQ8J0EYw.js +1 -0
  59. package/web/dist/assets/{host-usage-CI_ZlJQu.js → host-usage-EK6T4fAW.js} +1 -1
  60. package/web/dist/assets/{icon-tooltip-CgAWLDxo.js → icon-tooltip-nRvCJxOH.js} +1 -1
  61. package/web/dist/assets/index-BVPhzJ3k.js +31 -0
  62. package/web/dist/assets/index-HmrjUHlJ.css +2 -0
  63. package/web/dist/assets/{input-Br4NQpZK.js → input-90eli0Uk.js} +1 -1
  64. package/web/dist/assets/{layout-cards-fdJa2H62.js → layout-cards-n-2Pwe6c.js} +1 -1
  65. package/web/dist/assets/{lib-w_5wfsBF.js → lib-C4vuyY62.js} +1 -1
  66. package/web/dist/assets/loader-circle-DAforPX2.js +1 -0
  67. package/web/dist/assets/{markdown-G3dvGJao.js → markdown-BBnagS_c.js} +1 -1
  68. package/web/dist/assets/{markdown-BfZORc0a.js → markdown-DLB6o6YD.js} +1 -1
  69. package/web/dist/assets/{message-square-Dl-ol3uz.js → message-square-WCEmfkiD.js} +1 -1
  70. package/web/dist/assets/plus-BJEPAJjW.js +1 -0
  71. package/web/dist/assets/{project-router-DgQSavhI.js → project-router-7DKoABD3.js} +1 -1
  72. package/web/dist/assets/queries-DsfjHsrp.js +1 -0
  73. package/web/dist/assets/{reference-chip-BxUGeHDa.js → reference-chip-frnxjI-K.js} +1 -1
  74. package/web/dist/assets/repo-git-DVREyQYa.js +1 -0
  75. package/web/dist/assets/{run-diff-CqXLVaDj.js → run-diff-CmqQmGTJ.js} +1 -1
  76. package/web/dist/assets/{save-ByUa-aAl.js → save-CCb1fwTJ.js} +1 -1
  77. package/web/dist/assets/{scroll-within-Dexi68h1.js → scroll-within-CNcaqKGp.js} +1 -1
  78. package/web/dist/assets/{search-x-CLuL49ms.js → search-x-Cm22V3TC.js} +1 -1
  79. package/web/dist/assets/{settings-2-BvalJGW-.js → settings-2-CWK1otJs.js} +1 -1
  80. package/web/dist/assets/skills-B0OolFqS.js +1 -0
  81. package/web/dist/assets/{square-FwRsgrg-.js → square-B-gfdc5r.js} +1 -1
  82. package/web/dist/assets/{tabs-nC1VLjcX.js → tabs-D3hCl7A6.js} +1 -1
  83. package/web/dist/assets/{tag-CteJEZQp.js → tag-C5TeSwBA.js} +1 -1
  84. package/web/dist/assets/{task-commits-CYcqwz-f.js → task-commits-DIrIWA6g.js} +1 -1
  85. package/web/dist/assets/{task-graph-CJfTnzUp.js → task-graph-Diq4xAP_.js} +1 -1
  86. package/web/dist/assets/{task-notes-DxH2q3Hr.js → task-notes-DnIcoZgS.js} +1 -1
  87. package/web/dist/assets/task-workspace-DhUBQLGl.js +29 -0
  88. package/web/dist/assets/{terminal-aoRx5eKS.js → terminal-BIKtPgmL.js} +1 -1
  89. package/web/dist/assets/{terminal-drawer-CuGVJS-l.js → terminal-drawer-f0Tw3yHw.js} +2 -2
  90. package/web/dist/assets/{textarea-X_NVmVlZ.js → textarea-D6BGJB7j.js} +1 -1
  91. package/web/dist/assets/{token-metrics-CdH7TbLP.js → token-metrics-CMdTXREP.js} +1 -1
  92. package/web/dist/assets/{tooltip-C2bzSwbQ.js → tooltip-Bb7ddw0_.js} +1 -1
  93. package/web/dist/assets/{tracker-BYs-vq6-.js → tracker-BDiIqG2R.js} +2 -2
  94. package/web/dist/assets/{triangle-alert-BdMPm9Jb.js → triangle-alert-BhQYv6Is.js} +1 -1
  95. package/web/dist/assets/{upload-DrvICo_K.js → upload-Crivm77f.js} +1 -1
  96. package/web/dist/assets/{use-now-Byfm730u.js → use-now-BW1HO2p_.js} +1 -1
  97. package/web/dist/assets/{use-submit-shortcut-B41NLqM4.js → use-submit-shortcut-oBvmLiAo.js} +1 -1
  98. package/web/dist/assets/{workflow-graph-ppdi5xyK.js → workflow-graph-DJLPSGD3.js} +3 -3
  99. package/web/dist/assets/{worktree-lifecycle-operation-CvU6xu3u.js → worktree-lifecycle-operation-DL-RTic4.js} +2 -2
  100. package/web/dist/index.html +39 -39
  101. package/dist/telemetry-service.json +0 -1
  102. package/web/dist/assets/arrow-left-B1Ed0tpu.js +0 -1
  103. package/web/dist/assets/automation-format-CXffJGqm.js +0 -1
  104. package/web/dist/assets/automations-route-ruFF7d59.js +0 -1
  105. package/web/dist/assets/button-wdWSPx_B.js +0 -100
  106. package/web/dist/assets/check-DvAMBXJe.js +0 -1
  107. package/web/dist/assets/chevron-left-Dqb1lvgZ.js +0 -1
  108. package/web/dist/assets/chevron-right-DDQuVTY1.js +0 -1
  109. package/web/dist/assets/circle-check-BiVc-j8x.js +0 -1
  110. package/web/dist/assets/dashboard-BX4228zB.js +0 -44
  111. package/web/dist/assets/facet-filter-B_AsFqFx.js +0 -5
  112. package/web/dist/assets/file-preview-DEKEA-Hk.js +0 -2
  113. package/web/dist/assets/git-tab-loading-w5Ne43J6.js +0 -1
  114. package/web/dist/assets/github-Hshin4wG.js +0 -1
  115. package/web/dist/assets/index-CQ1cB3qE.css +0 -2
  116. package/web/dist/assets/index-D-pGbO9R.js +0 -31
  117. package/web/dist/assets/loader-circle-CwT0JWiv.js +0 -1
  118. package/web/dist/assets/plus-BwQyZgNP.js +0 -1
  119. package/web/dist/assets/queries-BTgOLNTK.js +0 -1
  120. package/web/dist/assets/repo-git-B47L82oV.js +0 -1
  121. package/web/dist/assets/skills-Bu12y3Zp.js +0 -1
  122. package/web/dist/assets/task-workspace-7NHIdOyT.js +0 -29
@@ -1,44 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{Fa as r,M as i,Na as a,Pi as o,Un as s,Vn as c,bn as l,ci as u,da as d,en as f,er as p,nn as m,q as h,ur as g}from"./queries-BTgOLNTK.js";import{F as _,at as v,et as y,it as b,nt as ee,rt as x,st as S,t as C,tt as w,xt as T}from"./button-wdWSPx_B.js";import{T as te,m as E,x as ne}from"./project-router-DgQSavhI.js";import{S as re,a as ie,o as ae,r as oe,t as se}from"./reference-chip-BxUGeHDa.js";import{C as ce,E as D,F as le,I as ue,L as O,O as k,R as A,T as de,_ as fe,b as pe,c as me,d as he,f as ge,g as _e,h as ve,m as ye,n as be,p as xe,v as Se,w as Ce,x as we,y as Te,z as Ee}from"./facet-filter-B_AsFqFx.js";import{a as De,i as Oe,n as ke,o as Ae,s as je,t as Me}from"./use-now-Byfm730u.js";import{a as Ne,f as j,m as Pe,p as Fe,r as Ie}from"./automation-format-CXffJGqm.js";import{f as Le,i as Re,n as ze,r as Be,t as Ve}from"./tooltip-C2bzSwbQ.js";import{t as He}from"./chevron-right-DDQuVTY1.js";import{t as Ue}from"./download-BBtWFvsh.js";import{i as M,n as We,r as N,t as Ge}from"./token-metrics-CdH7TbLP.js";import{t as Ke}from"./index-D-pGbO9R.js";var qe=_(`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`}]]),Je=_(`arrow-down-left`,[[`path`,{d:`M17 7 7 17`,key:`15tmo1`}],[`path`,{d:`M17 17H7V7`,key:`1org7z`}]]),Ye=_(`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`}]]),Xe=_(`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`}]]),Ze=_(`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`}]]),P=e(t(),1);function Qe(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 $e(e){return e.flatMap(e=>(e.data?.automations??[]).filter(e=>e.enabled).map(t=>({project:e,automation:t,at:Qe(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 et(e){let t=h(),n=r(),i=t.data?.projects??[],o=t.data?.bootProject,s=o&&!i.some(e=>e.id===o)?[...i,{id:o,name:o,status:`ok`}]:i,c=a({queryKey:[...m.dashboard,`automations`,s.map(e=>[e.id,e.name,e.status])],enabled:e&&!!t.data,queryFn:async({signal:e})=>{let t=0,n=[];return await Promise.all([0,1].map(async()=>{for(;t<s.length&&!e.aborted;){let r=s[t++];if(r.status===`missing`){n.push({...r,error:`Project folder unavailable`});continue}try{let t=S.parse(await d(await g.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,P.useEffect)(()=>{if(e)return k(e=>{e===`automation-change`&&n.invalidateQueries({queryKey:[...m.dashboard,`automations`]})})},[n,e]),{...c,registry:t,retry:()=>{t.refetch(),c.refetch()}}}var F=n();function I({rows:e}){return(0,F.jsx)(`span`,{hidden:!0,"data-dashboard-export":JSON.stringify(e)})}var L=`section-mark eyebrow text-muted-foreground`,R=`flex min-h-12 flex-wrap items-center justify-between gap-x-3 gap-y-2 border-b px-4 py-2.5`,tt=`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 z(){return(0,F.jsx)(He,{"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 nt=`flex items-center gap-2 text-xs text-muted-foreground`;function rt({className:e=``,...t}){return(0,F.jsxs)(`span`,{className:`relative inline-flex`,children:[(0,F.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,F.jsx)(Le,{"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 it=`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`,B={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 at({label:e,value:t,icon:n,children:r}){return(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(`span`,{className:`flex w-full items-center justify-between gap-2`,children:[(0,F.jsx)(`span`,{className:`eyebrow text-muted-foreground`,children:e}),(0,F.jsx)(`span`,{className:`text-soft-foreground`,"aria-hidden":`true`,children:n})]}),(0,F.jsx)(`span`,{className:`mt-4 block text-4xl font-semibold leading-none tracking-tight tabular-nums`,children:t}),(0,F.jsx)(`span`,{className:`mt-3 block text-xs text-soft-foreground`,children:r})]})}function ot({at:e}){return(0,F.jsxs)(`time`,{dateTime:e,title:new Date(e).toLocaleString(),children:[`Updated `,N(e),` ago`]})}function st(){let e=me(),t=et(e.known&&!e.off),n=Me(3e4),[r,i]=(0,P.useState)(!1),a=$e(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,F.jsxs)(j,{"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,F.jsxs)(`div`,{className:R,children:[(0,F.jsxs)(`h2`,{className:`flex items-center ${L}`,children:[`Automations`,(0,F.jsx)(Pe,{className:`ml-2 size-3.5 text-soft-foreground`,"aria-hidden":`true`})]}),!e.off&&t.data&&(0,F.jsxs)(`span`,{className:`font-mono text-meta text-soft-foreground`,children:[a.length,` enabled`,l?` · partial`:``]})]}),!e.off&&t.data&&(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(I,{rows:[{section:`automations`,metric:`enabled`,value:a.length,unit:`automations`,note:l?`Partial project coverage`:`Loaded projects`}]}),t.dataUpdatedAt>0&&(0,F.jsx)(`p`,{className:`px-4 pt-3 text-xs text-muted-foreground`,children:(0,F.jsx)(ot,{at:new Date(t.dataUpdatedAt).toISOString()})})]}),e.off?(0,F.jsx)(`p`,{className:`p-4 text-sm text-muted-foreground`,children:`Automations are disabled in this workspace.`}):(0,F.jsxs)(F.Fragment,{children:[c&&(0,F.jsx)(`p`,{className:`p-4 text-sm text-muted-foreground`,children:`Loading automations…`}),l&&(0,F.jsxs)(`div`,{role:`alert`,className:`p-4 text-sm`,children:[(0,F.jsx)(`p`,{children:`Some automation data could not be refreshed. Available results are shown.`}),s.map(e=>(0,F.jsxs)(`p`,{children:[e.name,`: `,e.error]},e.id)),(0,F.jsx)(C,{variant:`ghost`,onClick:t.retry,children:`Retry automations`})]}),!c&&!l&&a.length===0&&(0,F.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`:Ne(r,n),o=t.kind===`schedule`?`Next run`:`Next check`;return(0,F.jsxs)(`div`,{"data-export-row":!0,className:`border-b px-4 py-3 transition-colors last:border-0 hover:bg-muted/30`,children:[(0,F.jsx)(E,{className:`block min-h-11 text-sm font-medium hover:underline`,to:`/p/${encodeURIComponent(e.id)}/automations/${encodeURIComponent(t.id)}`,children:t.name}),(0,F.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[e.name,` · `,o,`: `,a]}),r!==null&&(0,F.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:(0,F.jsxs)(`time`,{dateTime:new Date(r).toISOString(),children:[Ie(r,e.data.timeZone),` · `,e.data.timeZone]})}),t.kind!==`schedule`&&(0,F.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:`Checks for matching events; a task may not be started.`}),i&&(0,F.jsx)(`p`,{className:`mt-1 text-xs text-warning`,children:i}),(0,F.jsx)(I,{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,F.jsx)(C,{variant:`ghost`,className:`m-2 min-h-11`,onClick:()=>i(!r),children:r?`Show fewer`:`Show all ${a.length} enabled`}),!c&&(0,F.jsxs)(`details`,{className:`border-t px-4 py-2 text-xs text-muted-foreground`,children:[(0,F.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,F.jsx)(z,{}),`Manage automations by project`]}),t.data?.map(e=>(0,F.jsx)(E,{className:`block min-h-11 py-3 hover:underline`,to:`/p/${encodeURIComponent(e.id)}/automations`,children:e.name},e.id))]})]})]})}function ct(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 lt(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 ut=(0,P.createContext)(``),dt=(0,P.createContext)(!0),V=new Map;function ft(e,t,n=``,r=0,i){let a=(0,P.useContext)(ut),o=`${a}:${n}`,[s,c]=(0,P.useState)(()=>V.get(o)),[l,u]=(0,P.useState)(o),d=(0,P.useRef)(r),f=(0,P.useRef)(!1);l!==o&&(u(o),c(V.get(o)),d.current=r,f.current=!1),d.current!==r&&(d.current=r,f.current=!0),(0,P.useEffect)(()=>{e&&(!s||f.current)&&(c(e),f.current=!1)},[s,e]);let p=(0,P.useMemo)(()=>({current:s}),[o]);p.current=s,(0,P.useEffect)(()=>()=>{!a||!p.current||(V.delete(o),V.set(o,p.current),V.size>60&&V.delete(V.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:lt(g,e??m,t),updates:e?ct(g,e,t).size:0,show:()=>c(e)}}var pt=new Map;function mt(e){return pt.get(e)}function ht(e,t){pt.delete(e),pt.set(e,t),pt.size>20&&pt.delete(pt.keys().next().value)}var H=new Map;function gt(e,t){return H.get(e)?.[t]}function _t(e,t,n){let r=H.get(e)??{};r[t]=n,H.delete(e),H.set(e,r),H.size>20&&H.delete(H.keys().next().value)}var U=e=>`${e.projectId}:${e.id}`;function vt({row:e,removed:t=!1,queue:n=!1,checking:r=!1,checkFailed:i=!1,kicker:a}){let o=(0,P.useContext)(dt)&&!r&&!i,u=Ee(e);t=t||u===null||n&&u?.archived===!0,u&&(e={...e,status:u.status,awaitingAnswerSince:u.awaitingAnswerSince});let d=c(e),f=n&&!s(e),p=t||f||!o;return(0,F.jsxs)(`div`,{"data-dashboard-row":U(e),className:`min-w-0 border-b px-4 py-3 transition-colors last:border-0 hover:bg-muted/30`,children:[(0,F.jsx)(I,{rows:[{section:`task`,entity:U(e),metric:`title`,value:e.titleSummary||e.title},{section:`task`,entity:U(e),metric:`status`,value:p?`Not currently actionable`:e.status},{section:`task`,entity:U(e),metric:`createdAt`,value:e.createdAt}]}),a&&(0,F.jsx)(`p`,{className:`mb-1 pl-[15px] eyebrow text-soft-foreground`,children:a}),(0,F.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,F.jsx)(M,{tone:d.tone,className:`mt-[7px]`}),(0,F.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,F.jsx)(E,{tabIndex:p?-1:void 0,"aria-disabled":p||void 0,onClick:e=>{p&&e.preventDefault()},to:`/p/${encodeURIComponent(e.projectId)}/tasks/${encodeURIComponent(e.id)}`,className:`block break-words text-sm font-medium leading-relaxed hover:underline no-hover:min-h-11`,children:e.titleSummary||e.title}),(0,F.jsxs)(`div`,{className:`mt-1 flex flex-wrap items-center gap-x-2 gap-y-1 text-xs text-muted-foreground`,children:[(0,F.jsx)(`span`,{className:`font-mono text-meta text-soft-foreground`,children:e.projectId}),(0,F.jsx)(`span`,{children:i?`Could not check current state`:o?t?n&&u!==null?`No longer needs you`:`Task removed`:f?`No longer needs you`:d.label:`Checking current state…`}),(0,F.jsx)(`span`,{children:N(e.createdAt)}),e.dispatch&&(0,F.jsx)(`span`,{children:`Subtask`}),!p&&l(e).map(t=>(0,F.jsx)(se,{reference:t,taskTitle:e.title,projectId:e.projectId,className:`no-hover:min-h-11`},`${t.kind}:${t.number}`))]})]})]})]})}function W({coverage:e,count:t,retry:n}){let r=e.projects.filter(e=>e.state!==`complete`);return r.length?(0,F.jsxs)(`div`,{className:`rounded-lg border border-pending/40 bg-card-2 p-3 text-sm`,role:`status`,children:[(0,F.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,F.jsxs)(`details`,{className:`mt-2`,children:[(0,F.jsxs)(`summary`,{className:`${tt} min-h-11`,children:[(0,F.jsx)(z,{}),`View unavailable `,r.length===1?`project`:`projects`]}),r.map(e=>(0,F.jsxs)(`p`,{children:[e.projectId,`: `,e.reason??e.state,e.omittedRuns>0?` · ${e.omittedRuns} omitted tasks`:``]},e.projectId))]}),(0,F.jsx)(C,{variant:`outline`,onClick:n,className:`min-h-11`,children:`Retry`})]}):null}function yt(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 G(e){return e===null?`Unavailable`:e<1?`${Math.round(e*60)}m`:e<48?`${e.toFixed(1)}h`:`${(e/24).toFixed(1)}d`}function bt(e,t,n){let r=ne(),i=r.state?.dashboardEntry??r.key,[a,o]=te(),s=a.get(e);return[s!==null&&t.includes(s)?s:n,t=>o(n=>{let r=new URLSearchParams(n);return r.set(e,t),r},{replace:!0,state:{...r.state,dashboardEntry:i}})]}var xt=e=>`Last ${e===`7d`?7:30} calendar days`,St=`eyebrow text-muted-foreground`,Ct=`min-w-0 rounded-lg border bg-card-2 p-4`,K=`whitespace-nowrap px-3 py-2 eyebrow text-soft-foreground`;function wt(){let e=h().data?.projects;return t=>e?.find(e=>e.id===t)?.name??t}var Tt=(e,t)=>`/p/${encodeURIComponent(e)}/tasks/${encodeURIComponent(t)}`;function Et({label:e,value:t,onChange:n}){return(0,F.jsxs)(`label`,{className:nt,children:[e,(0,F.jsxs)(rt,{value:t,onChange:e=>n(e.target.value===`30d`?`30d`:`7d`),children:[(0,F.jsx)(`option`,{value:`7d`,children:`Last 7 days`}),(0,F.jsx)(`option`,{value:`30d`,children:`Last 30 days`})]})]})}function Dt({query:e}){return e.isPending?(0,F.jsx)(`p`,{role:`status`,className:`text-sm text-muted-foreground`,children:`Loading insights…`}):e.isError?(0,F.jsxs)(`p`,{role:`alert`,className:`text-sm`,children:[e.data?`Showing previous results. `:``,`Could not refresh insights.`,` `,(0,F.jsx)(C,{variant:`outline`,onClick:()=>void e.refetch(),children:`Retry insights`})]}):null}function Ot({period:e,active:t}){let n=Ke(e,t),r=n.data;return(0,F.jsxs)(`div`,{className:`space-y-3`,children:[(0,F.jsx)(Dt,{query:n}),r&&(0,F.jsx)(W,{coverage:r.coverage,retry:()=>void n.refetch()}),r&&(0,F.jsxs)(`div`,{className:`grid gap-3 lg:grid-cols-2`,children:[(0,F.jsx)(At,{data:r}),(0,F.jsx)(jt,{data:r})]})]})}function kt({value:e,prefix:t=``,className:n}){let r=`${t}${e.toLocaleString(`en-US`)}`;return e<1e4?(0,F.jsx)(`span`,{className:n,children:r}):(0,F.jsxs)(`span`,{className:n,title:r,children:[t,We(e)]})}function At({data:e}){let t=e.delivered,n=[{label:`PRs opened`,value:t.prsOpened,note:`${t.prsTouched} touched`},{label:`Lines`,value:(0,F.jsxs)(`span`,{className:`flex flex-wrap gap-x-1.5`,children:[(0,F.jsx)(kt,{value:t.additions,prefix:`+`,className:`text-success`}),(0,F.jsx)(kt,{value:t.deletions,prefix:`−`,className:`text-danger`})]})},{label:`Files`,value:(0,F.jsx)(kt,{value:t.files})},{label:`Issues`,value:(0,F.jsx)(kt,{value:t.issues})}];return(0,F.jsxs)(`section`,{className:Ct,"aria-label":`Delivered`,children:[(0,F.jsx)(I,{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,F.jsx)(`h3`,{className:St,children:`Delivered`}),(0,F.jsx)(`dl`,{className:`mt-3 grid grid-cols-2 gap-x-4 gap-y-3 sm:grid-cols-4`,children:n.map(e=>(0,F.jsxs)(`div`,{className:`min-w-0`,children:[(0,F.jsx)(`dt`,{className:`text-xs text-soft-foreground`,children:e.label}),(0,F.jsx)(`dd`,{className:`mt-1 truncate text-xl font-semibold tracking-tight tabular-nums`,children:e.value}),e.note&&(0,F.jsx)(`dd`,{className:`text-xs text-soft-foreground`,children:e.note})]},e.label))}),(0,F.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 jt({data:e}){let t=wt(),{total:n,reasons:r}=e.failures;return(0,F.jsxs)(`section`,{className:Ct,"aria-label":`Why tasks failed`,children:[(0,F.jsx)(I,{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,F.jsxs)(`div`,{className:`flex items-baseline justify-between gap-2`,children:[(0,F.jsx)(`h3`,{className:St,children:`Why tasks failed`}),n>0&&(0,F.jsxs)(`span`,{className:`font-mono text-meta text-soft-foreground`,children:[n,` failed`]})]}),n===0?(0,F.jsxs)(`span`,{className:`mt-4 flex items-center gap-2.5 text-sm text-muted-foreground`,children:[(0,F.jsx)(M,{tone:`success`}),`No failed outcomes in this period`]}):(0,F.jsx)(`ul`,{className:`mt-3 space-y-3`,children:r.map(e=>(0,F.jsx)(Mt,{reason:e,total:n,projectName:t},`${e.category}:${e.label}`))})]})}function Mt({reason:e,total:t,projectName:n}){let{latest:r}=e;return(0,F.jsxs)(`li`,{className:`min-w-0`,children:[(0,F.jsxs)(`div`,{className:`flex items-baseline justify-between gap-3 text-sm`,children:[(0,F.jsx)(`span`,{className:`min-w-0 truncate font-medium`,title:e.label,children:e.label}),(0,F.jsx)(`span`,{className:`font-mono text-xs tabular-nums text-muted-foreground`,children:e.count})]}),(0,F.jsx)(`div`,{className:`mt-1.5 h-1 overflow-hidden rounded-full bg-muted`,"aria-hidden":`true`,children:(0,F.jsx)(`div`,{className:`h-full rounded-full bg-danger/70`,style:{width:`${e.count/t*100}%`}})}),(0,F.jsxs)(`span`,{className:`mt-1.5 block truncate text-xs text-soft-foreground`,title:r.message,children:[`Latest:`,` `,(0,F.jsx)(E,{className:`text-muted-foreground hover:text-foreground hover:underline`,to:Tt(r.projectId,r.id),children:r.title}),` `,`· `,n(r.projectId),r.step?` · ${r.step}`:``,` · `,N(r.at),` ago`]})]})}var Nt={claude:`Claude Code`,codex:`Codex`,opencode:`OpenCode`,cursor:`Cursor`,pi:`Pi`,unknown:`Unknown backend`,mixed:`Mixed backends`},Pt=e=>Nt[e]??e,Ft=(e,t)=>t?Math.round(e/t*100):0;function It(){let[e,t]=bt(`backends`,[`7d`,`30d`],`7d`),n=Ke(e),r=n.data,i=r?.visibility.cost;return(0,F.jsx)(`section`,{"data-dashboard-module":`backends`,className:`min-w-0`,children:(0,F.jsxs)(j,{className:`gap-0 py-0`,"data-export-context":`Backends: ${xt(e)}; finished tasks`,children:[(0,F.jsxs)(`div`,{className:R,children:[(0,F.jsx)(`h2`,{className:L,children:`Backends & models`}),(0,F.jsx)(Et,{label:`Finished`,value:e,onChange:t})]}),(0,F.jsxs)(`div`,{className:`space-y-3 p-4`,children:[(0,F.jsx)(Dt,{query:n}),r&&(0,F.jsxs)(F.Fragment,{children:[(0,F.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,F.jsx)(W,{coverage:r.coverage,retry:()=>void n.refetch()}),r.backends.length?(0,F.jsx)(`div`,{className:`overflow-x-auto`,role:`region`,"aria-label":`Backend comparison`,tabIndex:0,children:(0,F.jsxs)(`table`,{className:`w-full text-left text-sm`,children:[(0,F.jsx)(`thead`,{children:(0,F.jsxs)(`tr`,{children:[(0,F.jsx)(`th`,{className:K,children:`Backend`}),(0,F.jsx)(`th`,{className:`${K} text-right`,children:`Finished`}),(0,F.jsx)(`th`,{className:K,children:`Success`}),(0,F.jsx)(`th`,{className:`${K} text-right`,children:`Median cycle`}),i&&(0,F.jsx)(`th`,{className:`${K} text-right`,children:`Reported USD`}),i&&(0,F.jsx)(`th`,{className:`${K} text-right`,children:`Per completed`})]})}),(0,F.jsx)(`tbody`,{children:r.backends.map(e=>(0,F.jsx)(Lt,{stat:e,cost:!!i},`${e.backend}:${e.model??``}`))})]})}):(0,F.jsx)(`p`,{className:`py-4 text-sm text-muted-foreground`,children:`No finished tasks in this period.`}),(0,F.jsx)(`span`,{className:`block font-mono text-meta text-soft-foreground`,children:(0,F.jsx)(ot,{at:r.asOf})}),(0,F.jsx)(I,{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 Lt({stat:e,cost:t}){let n=Ft(e.done,e.finished),r=e.costUsd?.value;return(0,F.jsxs)(`tr`,{className:`border-t transition-colors hover:bg-muted/30`,children:[(0,F.jsxs)(`td`,{className:`px-3 py-2.5`,children:[(0,F.jsx)(`span`,{className:`block font-medium`,children:Pt(e.backend)}),(0,F.jsx)(`span`,{className:`block font-mono text-meta text-soft-foreground`,children:e.backend===`mixed`?`steps ran on different backends`:e.model??`default model`})]}),(0,F.jsx)(`td`,{className:`px-3 py-2.5 text-right tabular-nums`,children:e.finished}),(0,F.jsxs)(`td`,{className:`min-w-40 px-3 py-2.5`,children:[(0,F.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,F.jsx)(`span`,{className:`h-1.5 flex-1 overflow-hidden rounded-full bg-danger/40`,"aria-hidden":`true`,children:(0,F.jsx)(`span`,{className:`block h-full rounded-full bg-success`,style:{width:`${n}%`}})}),(0,F.jsxs)(`span`,{className:`w-10 text-right font-mono text-xs tabular-nums`,children:[n,`%`]})]}),(0,F.jsxs)(`span`,{className:`block text-xs text-soft-foreground`,children:[e.done,` done · `,e.failed,` failed`]})]}),(0,F.jsx)(`td`,{className:`px-3 py-2.5 text-right tabular-nums`,children:e.timedTasks?G(e.medianCycleHours):`—`}),t&&(0,F.jsxs)(`td`,{className:`px-3 py-2.5 text-right tabular-nums`,children:[r==null?`—`:yt(r,!0),(0,F.jsxs)(`span`,{className:`block text-xs text-soft-foreground`,children:[e.costUsd?.reportedTasks??0,`/`,e.finished,` reported`]})]}),t&&(0,F.jsx)(`td`,{className:`px-3 py-2.5 text-right tabular-nums`,children:r==null||!e.done?`—`:yt(r/e.done,!0)})]})}function Rt(){let[e,t]=bt(`automations`,[`7d`,`30d`],`7d`),n=me(),r=Ke(e),i=et(n.known&&!n.off),a=wt(),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,F.jsx)(`section`,{"data-dashboard-module":`automation-outcomes`,className:`min-w-0`,children:(0,F.jsxs)(j,{className:`gap-0 py-0`,"data-export-context":`Automation outcomes: tasks created in ${xt(e)}`,children:[(0,F.jsxs)(`div`,{className:R,children:[(0,F.jsx)(`h2`,{className:L,children:`Automation outcomes`}),(0,F.jsx)(Et,{label:`Launched`,value:e,onChange:t})]}),(0,F.jsx)(`div`,{className:`space-y-3 p-4`,children:n.off?(0,F.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Automations are disabled in this workspace.`}):(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(Dt,{query:r}),o&&(0,F.jsxs)(F.Fragment,{children:[(0,F.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,F.jsx)(W,{coverage:o.coverage,retry:()=>void r.refetch()}),u&&(0,F.jsxs)(`p`,{role:`alert`,className:`text-sm`,children:[`Some automation details could not be loaded. Their outcomes are shown by id.`,` `,(0,F.jsx)(C,{variant:`ghost`,onClick:i.retry,children:`Retry automations`})]}),d.length?(0,F.jsx)(`div`,{className:`overflow-x-auto`,role:`region`,"aria-label":`Automation outcomes`,tabIndex:0,children:(0,F.jsxs)(`table`,{className:`w-full text-left text-sm`,children:[(0,F.jsx)(`thead`,{children:(0,F.jsxs)(`tr`,{children:[(0,F.jsx)(`th`,{className:K,children:`Automation`}),(0,F.jsx)(`th`,{className:`${K} text-right`,children:`Tasks`}),(0,F.jsx)(`th`,{className:`${K} text-right`,children:`Done`}),(0,F.jsx)(`th`,{className:`${K} text-right`,children:`Failed`}),(0,F.jsx)(`th`,{className:`${K} text-right`,children:`Active`}),(0,F.jsx)(`th`,{className:K,children:`Last run`}),s&&(0,F.jsx)(`th`,{className:`${K} text-right`,children:`Reported USD`})]})}),(0,F.jsx)(`tbody`,{children:d.map(e=>(0,F.jsx)(zt,{row:e,cost:!!s,projectName:a},`${e.projectId}:${e.automationId}`))})]})}):(0,F.jsx)(`p`,{className:`py-4 text-sm text-muted-foreground`,children:`No automations yet. Create one in a project's Automations page.`}),(0,F.jsx)(`span`,{className:`block font-mono text-meta text-soft-foreground`,children:(0,F.jsx)(ot,{at:o.asOf})}),(0,F.jsx)(I,{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 zt({row:e,cost:t,projectName:n}){let r=e.stat,i=`px-3 py-2.5 text-right tabular-nums`,a=e=>e||(0,F.jsx)(`span`,{className:`text-soft-foreground`,children:`0`});return(0,F.jsxs)(`tr`,{className:`border-t transition-colors hover:bg-muted/30`,children:[(0,F.jsxs)(`td`,{className:`px-3 py-2.5`,children:[e.definition===`removed`?(0,F.jsx)(`span`,{className:`block font-medium`,children:e.name}):(0,F.jsx)(E,{className:`block font-medium hover:underline`,to:`/p/${encodeURIComponent(e.projectId)}/automations/${encodeURIComponent(e.automationId)}`,children:e.name}),(0,F.jsxs)(`span`,{className:`flex items-center gap-1.5 text-xs text-soft-foreground`,children:[(0,F.jsx)(M,{tone:e.enabled?`success`:`neutral`}),n(e.projectId),` ·`,` `,e.definition===`removed`?`Removed`:e.definition===`unknown`?`Details unavailable`:e.enabled?`Enabled`:`Disabled`]})]}),(0,F.jsx)(`td`,{className:i,children:a(r?.tasks)}),(0,F.jsx)(`td`,{className:i,children:a(r?.done)}),(0,F.jsx)(`td`,{className:`${i} ${r?.failed?`text-danger`:``}`,children:a(r?.failed)}),(0,F.jsx)(`td`,{className:i,children:a(r?.active)}),(0,F.jsx)(`td`,{className:`whitespace-nowrap px-3 py-2.5 text-xs text-muted-foreground`,children:r?.lastRunAt?(0,F.jsxs)(`time`,{dateTime:r.lastRunAt,title:new Date(r.lastRunAt).toLocaleString(),children:[N(r.lastRunAt),` ago · `,r.lastStatus]}):`—`}),t&&(0,F.jsx)(`td`,{className:i,children:r?.costUsd?.value==null?`—`:yt(r.costUsd.value,!0)})]})}var Bt=0,Vt=()=>++Bt,q=new Map;function J(e,t){let n=(0,P.useContext)(ut),r=()=>{let r=n?q.get(n):void 0;return r?.has(e)?r.get(e):typeof t==`function`?t():t},[i,a]=(0,P.useState)(r),o=`${n}:${e}`,[s,c]=(0,P.useState)(o);o!==s&&(c(o),a(()=>r()));let l=(0,P.useMemo)(()=>({value:i}),[n,e]);return l.value=i,(0,P.useEffect)(()=>()=>{if(!n)return;let t=q.get(n)??new Map;t.set(e,l.value),t.size>80&&t.delete(t.keys().next().value),q.delete(n),q.set(n,t),q.size>20&&q.delete(q.keys().next().value)},[n,e,l]),[i,a]}var Ht=`a[href], button, select, input, [tabindex]`;function Ut(e){let[t]=J(`${e}:position`,()=>({scroll:0})),n=(0,P.useCallback)(e=>{let n=[...e.querySelectorAll(Ht)],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,P.useMemo)(()=>({restore:()=>!1}),[t]);return{ref:(0,P.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(Ht)].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 Wt(e,t){let n=(0,P.useRef)(null),[r,i]=J(`${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 Gt(e,t=!0){return a({queryKey:[...m.dashboard,`overview`,e],enabled:t,staleTime:5e3,refetchInterval:t&&!e.snapshotId?15e3:!1,refetchIntervalInBackground:!1,retry:!1,queryFn:async({signal:t})=>y.parse(await d(await g.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 Kt={running:`Running now`,"needs-you":`Needs you`,completed:`Completed`,failed:`Failed outcomes`},qt={"needs-you":B.violet,running:B.info,completed:B.success,failed:B.danger},Jt={"needs-you":Fe,running:qe,completed:D,failed:Ye};function Yt({active:e,children:t,onCurrent:n}){let[r,i]=bt(`period`,[`7d`,`30d`],`7d`),a=Wt(`outcome`,`[data-outcome-trigger]`),o=h().data?.projects,s=e=>o?.find(t=>t.id===e)?.name??e,c=Gt({period:r},e),[l,u]=J(`outcome:selection`,null),d=Ut(`outcome:${l?.identity??`closed`}`),f=ue();if((0,P.useEffect)(()=>{e||u(null)},[e]),!e)return t({});let p=c.data,m=(e,t)=>{a.capture(),p&&u({identity:Vt(),snapshot:p,group:e,projectId:t})},g=p?.coverage.projects.every(e=>e.state===`complete`);return(0,F.jsxs)(F.Fragment,{children:[t({overview:(0,F.jsxs)(j,{className:`gap-0 py-0`,children:[(0,F.jsxs)(`div`,{className:R,children:[(0,F.jsx)(`h2`,{className:L,children:`Workspace overview`}),(0,F.jsxs)(`label`,{className:nt,children:[`Outcomes period`,(0,F.jsxs)(rt,{value:r,onChange:e=>{i(e.target.value===`30d`?`30d`:`7d`),u(null)},children:[(0,F.jsx)(`option`,{value:`7d`,children:`Last 7 days`}),(0,F.jsx)(`option`,{value:`30d`,children:`Last 30 days`})]})]})]}),(0,F.jsxs)(`div`,{className:`space-y-4 p-4`,children:[c.isPending&&(0,F.jsx)(`p`,{role:`status`,className:`text-sm text-muted-foreground`,children:`Loading overview…`}),c.isError&&(0,F.jsxs)(`p`,{role:`alert`,children:[p?`Showing previous results. `:``,`Could not refresh overview.`,` `,(0,F.jsx)(C,{variant:`outline`,onClick:()=>void c.refetch(),children:`Retry overview`})]}),p&&(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[p.metrics.needsYou?`${p.metrics.needsYou} tasks require your input or review.`:g&&f.connected&&!c.isError?`No tasks currently require your input or review.`:`No waiting tasks found in the available data.`,` `,p.metrics.failed,` failed `,p.metrics.failed===1?`outcome`:`outcomes`,` `,`in this period. Includes subtasks; completed does not mean accepted or deployed.`]}),(0,F.jsx)(W,{coverage:p.coverage,retry:()=>void c.refetch()}),(0,F.jsx)(`div`,{className:`grid grid-cols-2 gap-3 lg:grid-cols-4`,children:[`needs-you`,`running`,`completed`,`failed`].map(e=>{let t=p.metrics[e===`needs-you`?`needsYou`:e],i=Jt[e];return(0,F.jsxs)(C,{"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?B.neutral:qt[e]}`,onClick:t=>{n&&(e===`running`||e===`needs-you`)?n(e,t.currentTarget):m(e)},"aria-label":`${Kt[e]}: ${t}`,children:[(0,F.jsx)(at,{label:Kt[e],value:t,icon:(0,F.jsx)(i,{className:`size-4`}),children:e===`running`||e===`needs-you`?`Current state`:`Last ${r===`7d`?7:30} calendar days`}),(0,F.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,F.jsx)(He,{className:`size-3 transition-transform group-hover/metric:translate-x-0.5 motion-reduce:transition-none`,"aria-hidden":`true`})]})]},e)})}),(0,F.jsx)(Ot,{period:r,active:e}),(0,F.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-x-4 gap-y-1 border-t pt-3`,children:[(0,F.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Median cycle time`,` `,(0,F.jsx)(`strong`,{className:`font-mono font-semibold text-foreground`,children:G(p.metrics.medianCycleHours)}),` `,`· `,p.metrics.timedTasks,`/`,p.metrics.completed,` completed tasks have valid timings.`,` `,(0,F.jsx)(C,{variant:`ghost`,className:`h-auto px-1.5 py-1 text-sm text-foreground underline-offset-4 hover:underline`,onClick:()=>m(`completed`),children:`Inspect completed tasks`})]}),(0,F.jsx)(`p`,{className:`font-mono text-meta text-soft-foreground`,children:(0,F.jsxs)(`time`,{dateTime:p.asOf,title:new Date(p.asOf).toLocaleString(),children:[`Updated `,N(p.asOf),` ago`]})})]}),(0,F.jsxs)(`details`,{className:`text-xs text-muted-foreground`,children:[(0,F.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,F.jsx)(z,{}),`How these metrics work`]}),(0,F.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,F.jsx)(I,{rows:Object.entries(p.metrics).map(([e,t])=>({section:`overview`,metric:e,value:t,unit:e===`medianCycleHours`?`hours`:`tasks`,asOf:p.asOf,note:e===`running`||e===`needsYou`?`Current non-archived state`:`Finished since ${p.windowStart}`}))})]})]})]}),portfolio:p&&(0,F.jsx)(`div`,{children:(0,F.jsxs)(j,{className:`gap-0 py-0`,"data-export-context":`Outcomes: Last ${r===`7d`?7:30} calendar days; workload: current state`,children:[(0,F.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,F.jsx)(`h2`,{className:`section-mark eyebrow text-muted-foreground`,children:`Projects`})}),(0,F.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,F.jsxs)(`div`,{className:`overflow-x-auto px-1 pb-2`,role:`region`,"aria-label":`Project outcomes`,tabIndex:0,children:[(0,F.jsxs)(`table`,{className:`w-full text-left text-sm`,children:[(0,F.jsx)(`thead`,{children:(0,F.jsx)(`tr`,{children:[`Project`,`Needs you`,`Running`,`Completed`,`Failed`,`Median cycle`].map(e=>(0,F.jsx)(`th`,{className:`whitespace-nowrap px-3 py-2 eyebrow text-soft-foreground ${e===`Project`?``:`text-right`}`,children:e},e))})}),(0,F.jsx)(`tbody`,{children:p.projects.map(e=>{let t=p.coverage.projects.find(t=>t.projectId===e.projectId);return(0,F.jsxs)(`tr`,{className:`border-t transition-colors hover:bg-muted/30`,children:[(0,F.jsxs)(`td`,{className:`px-3 py-2`,children:[(0,F.jsx)(E,{className:`font-medium hover:underline`,to:`/p/${encodeURIComponent(e.projectId)}`,children:s(e.projectId)}),t?.state!==`complete`&&(0,F.jsx)(`span`,{className:`block text-xs text-muted-foreground`,children:`Incomplete data`})]}),[`needs-you`,`running`,`completed`,`failed`].map(n=>(0,F.jsx)(`td`,{className:`px-3 py-1 text-right`,children:(0,F.jsx)(C,{"data-export-keep":!0,variant:`ghost`,className:`min-h-11 tabular-nums`,"aria-label":`${s(e.projectId)}: ${Kt[n]}: ${t?.state===`unavailable`?`Unavailable`:e[n===`needs-you`?`needsYou`:n]}`,disabled:t?.state===`unavailable`,onClick:()=>m(n,e.projectId),children:t?.state===`unavailable`?`Unavailable`:e[n===`needs-you`?`needsYou`:n]})},n)),(0,F.jsxs)(`td`,{className:`px-3 py-2 text-right tabular-nums`,children:[G(e.medianCycleHours),(0,F.jsxs)(`span`,{className:`block text-xs text-muted-foreground`,children:[e.timedTasks,`/`,e.completed,` timed`]})]})]},e.projectId)})})]}),!p.projects.length&&(0,F.jsx)(`p`,{className:`py-4`,children:`No projects to compare yet.`})]}),(0,F.jsx)(I,{rows:p.projects.flatMap(({projectId:e,...t})=>Object.entries(t).map(([t,n])=>({section:`portfolio`,entity:e,metric:t,value:p.coverage.projects.find(t=>t.projectId===e)?.state===`unavailable`?null:n,unit:t===`medianCycleHours`?`hours`:`tasks`,asOf:p.asOf,note:`Outcomes since ${p.windowStart}; running and needsYou are current state`})))})]})})}),(0,F.jsx)(ke,{open:!!l,onOpenChange:e=>{e||u(null)},children:(0,F.jsxs)(Oe,{...d,className:`w-full overflow-y-auto sm:max-w-xl`,onCloseAutoFocus:e=>{e.preventDefault(),a.restore()},children:[(0,F.jsxs)(Ae,{children:[(0,F.jsxs)(je,{children:[l?Kt[l.group]:`Tasks`,l?.projectId?` · ${l.projectId}`:``]}),(0,F.jsx)(De,{children:`Tasks behind the selected metric. Includes subtasks. Snapshot keeps counts and rows consistent.`})]}),l&&(0,F.jsx)(Xt,{selection:l,projectName:s,refresh:()=>{u(null),c.refetch()}},l.identity)]})})]})}function Xt({selection:e,refresh:t,projectName:n}){let[r,i]=J(`outcome:${e.identity}:offset`,0),a=Gt({period:e.snapshot.period,snapshotId:e.snapshot.snapshotId,group:e.group,projectId:e.projectId,offset:r}),o=(0,P.useRef)(null),s=(0,P.useRef)(null);(0,P.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,F.jsxs)(`div`,{className:`space-y-3 p-4`,"data-sheet-loading":a.isFetching,children:[a.isPending&&(0,F.jsx)(`p`,{children:`Loading tasks…`}),a.isError&&(0,F.jsxs)(`p`,{role:`alert`,children:[`This snapshot may have expired or become unavailable.`,` `,(0,F.jsx)(C,{onClick:t,children:`Refresh overview`})]}),a.data&&(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(`p`,{ref:o,tabIndex:-1,className:`text-xs text-muted-foreground`,children:[a.data.page.total,` tasks · Snapshot from`,` `,(0,F.jsxs)(`time`,{dateTime:a.data.asOf,title:new Date(a.data.asOf).toLocaleString(),children:[N(a.data.asOf),` ago`]})]}),a.data.page.rows.map(t=>(0,F.jsx)(Zt,{row:t,group:e.group,projectName:n},`${t.projectId}:${t.id}`)),!a.data.page.rows.length&&(0,F.jsx)(`p`,{children:`No tasks in this group.`})]}),(0,F.jsxs)(`div`,{className:`flex gap-2`,children:[(0,F.jsx)(C,{variant:`outline`,disabled:!r||a.isFetching,onClick:()=>c(Math.max(0,r-20)),children:`Previous`}),(0,F.jsx)(C,{variant:`outline`,disabled:!a.data||a.data.page.nextOffset===null||a.isFetching,onClick:()=>c(a.data.page.nextOffset),children:`Next`})]})]})}function Zt({row:e,group:t,projectName:n}){let r=Ee(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`:!s(e))),l=a||o,u=c(e),d=i&&a?`Task removed`:o?t===`running`?`No longer running`:`No longer needs you`:u.label;return(0,F.jsxs)(`div`,{className:`border-b py-3`,children:[(0,F.jsx)(E,{"aria-disabled":l||void 0,tabIndex:l?-1:void 0,onClick:e=>{l&&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,F.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[(0,F.jsx)(M,{tone:u.tone}),` `,n(e.projectId),` ·`,` `,d,` · `,e.archived?`Archived · `:``,(0,F.jsxs)(`time`,{dateTime:e.finishedAt??e.createdAt,title:new Date(e.finishedAt??e.createdAt).toLocaleString(),children:[e.finishedAt?`Finished`:`Created`,` `,N(e.finishedAt??e.createdAt),` ago`]})]})]})}var Y={snapshot:[...m.dashboard,`snapshot`],feed:e=>[...m.dashboard,`feed`,e],telemetry:[...m.dashboard,`telemetry`]},X=new Map;async function Qt(e){let t=O(),n=x.parse(await d(await g.api.v1.workspace.dashboard.$get({},{init:{signal:e}}),`/workspace/dashboard`));return X.has(n.snapshotId)||X.set(n.snapshotId,t),X.size>60&&X.delete(X.keys().next().value),A(t,[...n.questions.rows,...n.reviews.rows]),n}async function $t(e,t,n=0,r=20,i){let a=b.parse(await d(await g.api.v1.workspace.dashboard.tasks.$get({query:{snapshotId:e,group:t,offset:String(n),limit:String(r)}},{init:{signal:i}}),`/workspace/dashboard/tasks`)),o=X.get(e);return o!==void 0&&A(o,a.page.rows),a}function en(e){return a({queryKey:Y.snapshot,queryFn:({signal:e})=>Qt(e),enabled:e,staleTime:5e3,refetchOnMount:`always`,refetchInterval:e?15e3:!1,refetchIntervalInBackground:!1,retry:!1})}function tn(e){return a({queryKey:Y.telemetry,enabled:e,staleTime:0,queryFn:async({signal:e})=>{let t=v.parse(await d(await g.api.v1.workspace.dashboard.telemetry.$get({},{init:{signal:e}}),`/workspace/dashboard/telemetry`));return le.seed(t.samples,t.asOf),t}})}function nn(e,t){let n=a({queryKey:Y.feed(e),queryFn:async({signal:t})=>{let n=O(),r=ee.parse(await d(await g.api.v1.workspace.dashboard.feed.$get({query:{filter:e}},{init:{signal:t}}),`/workspace/dashboard/feed`));return A(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,P.useRef)(!1);return(0,P.useEffect)(()=>{r.current=!1},[e,t]),(0,P.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 rn(e,t){let n=nn(`tasks`,t&&e!==`github`),r=nn(`github`,t&&e!==`tasks`),i=(0,P.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)=>an(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 an(e,t){return Date.parse(t.at)-Date.parse(e.at)||e.key.localeCompare(t.key)}var on=[...m.dashboard,`costs`];function sn(){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 fn(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 cn=new WeakMap;function ln(e){let t=cn.get(e);return t||(t=sn(),cn.set(e,t)),t}function un(){let e=ln(r());return(0,P.useSyncExternalStore)(e.subscribe,e.getSnapshot,e.getSnapshot)}var dn=new Map;async function fn(e,t){let n=O(),r=w.parse(await d(await g.api.v1.workspace.dashboard.costs.$get({query:{...e,offset:String(e.offset??0),limit:`20`}},{init:{signal:t}}),`/workspace/dashboard/costs`));!e.snapshotId&&!dn.has(r.snapshotId)&&dn.set(r.snapshotId,n),dn.size>60&&dn.delete(dn.keys().next().value);let i=dn.get(r.snapshotId);return i!==void 0&&A(i,r.tasks.rows),r}function pn(e,t,n){let i=ln(r());return a({queryKey:[...on,e,t,n],queryFn:({signal:n})=>i.read({period:e,sort:t,tzOffsetMinutes:new Date().getTimezoneOffset()},n),staleTime:5e3,refetchOnMount:`always`,refetchInterval:15e3,refetchIntervalInBackground:!1,retry:!1})}function mn(e,t,n,i){let o=ln(r());return a({queryKey:[...on,`tasks`,e.snapshotId,t,n,i,e.visibility],retry:!1,queryFn:async({signal:r})=>{let a=e.tzOffsetMinutes??new Date().getTimezoneOffset(),s=async s=>{let c=await o.read({period:e.period,sort:n,snapshotId:s,projectId:t,tzOffsetMinutes:a},r),l=[...c.tasks.rows];for(;c.tasks.nextOffset!==null&&l.length<i;)c=await o.read({period:e.period,sort:n,snapshotId:c.snapshotId,projectId:t,offset:c.tasks.nextOffset},r),l.push(...c.tasks.rows);return{...c,tasks:{...c.tasks,rows:l}}};try{return await s(e.snapshotId)}catch(e){if(e instanceof p&&e.status===409)return s();throw e}}})}var hn={cost:{text:`text-primary`,fill:`bg-primary`,tint:B.primary,icon:de},input:{text:`text-violet`,fill:`bg-violet`,tint:B.violet,icon:Je},output:{text:`text-info`,fill:`bg-info`,tint:B.info,icon:re}};function gn({metric:e,label:t,value:n,reported:r,total:i}){let a=hn[e],o=a.icon,s=i?Math.min(100,r/i*100):0;return(0,F.jsxs)(`div`,{className:`${it} ${a.tint}`,children:[(0,F.jsxs)(at,{label:t,value:n,icon:(0,F.jsx)(o,{className:`size-4 ${a.text}`}),children:[r,` of `,i,` tasks report this metric`]}),(0,F.jsx)(`div`,{className:`mt-2 h-1.5 overflow-hidden rounded-full bg-muted`,"aria-hidden":`true`,children:(0,F.jsx)(`div`,{className:`h-full rounded-full ${a.fill} transition-[width] duration-300 motion-reduce:transition-none`,style:{width:`${s}%`}})})]})}function _n({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=hn[n];return(0,F.jsxs)(Be,{delayDuration:150,children:[(0,F.jsxs)(`div`,{className:`space-y-1 rounded-xl border p-2`,"aria-label":`Projects ranked by ${i}`,children:[e.length===0&&(0,F.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,F.jsxs)(Ve,{children:[(0,F.jsx)(Re,{asChild:!0,children:(0,F.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,F.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,F.jsx)(`span`,{className:`w-4 shrink-0 text-xs tabular-nums text-muted-foreground`,"aria-hidden":`true`,children:n+1}),(0,F.jsx)(`span`,{className:`min-w-0 flex-1 break-words font-medium`,children:e.projectId}),(0,F.jsx)(`span`,{className:`shrink-0 font-semibold tabular-nums`,children:a(u)}),(0,F.jsx)(He,{"data-export-exclude":!0,className:`size-4 shrink-0 text-muted-foreground`,"aria-hidden":`true`})]}),(0,F.jsx)(`div`,{className:`mt-2 ml-7 h-2 overflow-hidden rounded-full bg-muted`,"aria-hidden":`true`,children:(0,F.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,F.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,F.jsxs)(ze,{className:`max-w-64`,children:[(0,F.jsxs)(`p`,{className:`font-medium`,children:[e.projectId,` · `,i,`: `,a(u)]}),(0,F.jsxs)(`p`,{children:[l?.reportedTasks??0,` of `,e.tasks,` tasks report this metric.`]}),(0,F.jsx)(`p`,{children:`Open project tasks`})]})]},e.projectId)})]}),e.length>0&&(0,F.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`},vn={cost:`Reported USD`,input:`Input tokens`,output:`Output tokens`};function yn(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 bn=(e,t)=>yt(e,t===`cost`);function Q(e){return[...e.cost?[`cost`]:[],...e.tokens?[`input`,`output`]:[]]}function xn({value:e,onChange:t,visibility:n}){return(0,F.jsxs)(`label`,{className:nt,children:[`Sort by`,(0,F.jsx)(rt,{value:e,onChange:e=>t(e.target.value),children:Q(n).map(e=>(0,F.jsx)(`option`,{value:e,children:vn[e]},e))})]})}function Sn(){return(0,F.jsx)(Cn,{visibility:Ge(i().data)})}function Cn({visibility:e}){return(0,F.jsxs)(j,{className:`gap-0 py-0`,children:[(0,F.jsx)(`div`,{className:R,children:(0,F.jsx)(`h2`,{className:L,children:`Usage & cost`})}),!e.cost&&!e.tokens?(0,F.jsx)(`p`,{className:`p-4 text-sm`,children:`Usage metrics are hidden by workspace settings`}):(0,F.jsx)(wn,{visibility:e},`${e.cost}:${e.tokens}`)]})}function wn({visibility:e}){let[t,n]=bt(`usagePeriod`,[`all`,`7d`,`30d`],`all`),[r,i]=bt(`usageSort`,Q(e),e.cost?`cost`:`input`);return(0,F.jsx)(Tn,{period:t,setPeriod:n,sort:r,setSort:i,visibility:e})}function Tn({period:e,setPeriod:t,sort:n,setSort:r,visibility:i}){let a=pn(e,n,`${i.cost}:${i.tokens}`),[o,s]=J(`usage:accepted`,void 0),c=o??a.data,l=a.data??c,[u,d]=J(`usage:panel`,null),[f,p]=(0,P.useState)(e);f!==e&&(p(e),s(void 0),d(null));let m=Ut(`usage:${u?.identity??`closed`}`),h=Wt(`usage`,`[data-usage-trigger]`),g=e=>{h.capture(),c&&d({identity:Vt(),projectId:e,snapshot:c,latestId:l?.snapshotId??c.snapshotId})},_=un()??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 ee=c&&l&&yn(c,l),x=c?.coverage.projects.some(e=>e.state!==`complete`),S=l?.coverage.projects.some(e=>e.state!==`complete`),w=JSON.stringify(c?.coverage)!==JSON.stringify(l?.coverage),T=c?.totals.tasks===0&&!x&&!S;return(0,F.jsxs)(`div`,{className:`space-y-4 p-4 text-sm`,children:[c&&(0,F.jsx)(I,{rows:T?[]:[...Q(v).map(e=>({section:`totals`,metric:Z[e],value:c.totals[Z[e]]?.value??null,unit:e===`cost`?`USD`:`tokens`,reportedTasks:c.totals[Z[e]]?.reportedTasks??0,totalTasks:c.totals.tasks,asOf:c.asOf})),...(v.cost||v.tokens?b.slice(0,5):[]).map(e=>({section:`project`,entity:e.projectId,metric:Z[y],value:e[Z[y]]?.value??null,unit:y===`cost`?`USD`:`tokens`,reportedTasks:e[Z[y]]?.reportedTasks??0,totalTasks:e.tasks,asOf:c.asOf}))]}),c&&(0,F.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:(0,F.jsx)(ot,{at:c.asOf})}),(0,F.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`h3`,{className:`font-medium`,children:`Lifetime totals of retained tasks`}),(0,F.jsxs)(`details`,{className:`mt-1 text-xs text-muted-foreground`,children:[(0,F.jsxs)(`summary`,{"data-export-heading":`Metric definitions`,className:`${tt} min-h-11`,children:[(0,F.jsx)(z,{}),`How these metrics work`]}),(0,F.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,F.jsxs)(`label`,{className:nt,children:[`Tasks created`,(0,F.jsxs)(rt,{value:e,onChange:e=>t(e.target.value),children:[(0,F.jsx)(`option`,{value:`all`,children:`All time`}),(0,F.jsx)(`option`,{value:`7d`,children:`Last 7 days`}),(0,F.jsx)(`option`,{value:`30d`,children:`Last 30 days`})]})]})]}),e!==`all`&&(0,F.jsx)(`p`,{className:`text-muted-foreground`,children:`Lifetime usage of tasks created in this period — not spending during the period.`}),a.isPending&&(0,F.jsx)(`p`,{children:`Loading usage…`}),a.isError&&(0,F.jsxs)(`p`,{role:`alert`,children:[c?`Showing stale usage. Could not refresh.`:`Could not load usage.`,` `,(0,F.jsx)(C,{className:`min-h-11`,onClick:()=>void a.refetch(),children:`Retry`})]}),ee&&(0,F.jsx)(`p`,{role:`status`,children:`Newer usage data is available; displayed values use the previous snapshot.`}),ee&&(0,F.jsx)(C,{className:`min-h-11`,variant:`outline`,onClick:()=>s(l),children:`Updates available — Show`}),c&&x&&(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`p`,{className:`text-muted-foreground`,children:`Coverage of displayed usage:`}),(0,F.jsx)(W,{coverage:c.coverage,retry:()=>void a.refetch()})]}),l&&S&&w&&(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`p`,{className:`text-muted-foreground`,children:`Current source availability:`}),(0,F.jsx)(W,{coverage:l.coverage,retry:()=>void a.refetch()})]}),c&&(0,F.jsxs)(F.Fragment,{children:[!T&&(0,F.jsx)(`div`,{className:`report-cost-metrics grid gap-3 sm:grid-cols-[repeat(auto-fit,minmax(220px,1fr))]`,children:Q(v).map(e=>(0,F.jsx)(gn,{metric:e,label:vn[e],value:bn(c.totals[Z[e]]?.value,e),reported:c.totals[Z[e]]?.reportedTasks??0,total:c.totals.tasks},e))}),!v.cost&&!v.tokens&&(0,F.jsx)(`p`,{children:`Usage metrics are hidden by workspace settings`}),c.totals.tasks===0?(0,F.jsx)(`p`,{children:x||S?`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,F.jsx)(`p`,{children:`No reports for the visible metrics in this cohort.`}),T&&(0,F.jsx)(`p`,{className:`text-muted-foreground`,children:`Usage appears when tasks report cost or tokens.`}),(0,F.jsxs)(`p`,{className:`text-muted-foreground`,children:[`Deleted tasks are excluded from retained history.`,c.invalidDateTasks?` ${c.invalidDateTasks} tasks have missing or invalid creation dates${e===`all`?`; included in All time`:`; excluded from this period`}.`:``]}),!T&&(v.cost||v.tokens)&&(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`h3`,{className:`font-medium`,children:`Top projects`}),(0,F.jsx)(`p`,{className:`text-muted-foreground`,children:`Ranking uses reported metrics only.`})]}),(0,F.jsx)(xn,{value:y,onChange:r,visibility:v})]}),(0,F.jsx)(_n,{projects:b,metric:y,label:vn[y],field:Z[y],format:e=>bn(e,y),currentProjects:l?.projects??[],onSelect:g}),(0,F.jsx)(C,{"data-usage-trigger":!0,className:`min-h-11`,variant:`outline`,onClick:()=>g(``),children:`View tasks`})]})]}),(0,F.jsx)(ke,{open:u!==null&&(v.cost||v.tokens),onOpenChange:e=>{e||d(null)},children:(0,F.jsxs)(Oe,{...m,className:`w-full overflow-y-auto sm:max-w-xl`,onCloseAutoFocus:e=>{e.preventDefault(),h.restore()},children:[(0,F.jsxs)(Ae,{children:[(0,F.jsx)(je,{children:u?.projectId?`${u.projectId} tasks`:`All tasks`}),(0,F.jsx)(De,{children:`Lifetime usage of retained tasks. Missing reports are unavailable.`})]}),u!==null&&(0,F.jsx)(En,{identity:`usage:${u.identity}`,snapshot:l&&l.snapshotId!==u.latestId?l:u.snapshot,projectId:u.projectId||void 0,visibility:v},u.identity)]})})]})}function En({identity:e,snapshot:t,projectId:n,visibility:r}){let[i,a]=J(`${e}:sort`,t.sort);return(0,F.jsx)(Dn,{identity:e,snapshot:t,projectId:n,visibility:r,sort:Q(r).includes(i)?i:Q(r)[0]??`cost`,setSort:a})}function Dn({identity:e,snapshot:t,projectId:n,visibility:r,sort:i,setSort:a}){let[o,s]=J(`${e}:count`,20),[c,l]=J(`${e}:paging`,void 0),[u,d]=(0,P.useState)(t.snapshotId);u!==t.snapshotId&&(d(t.snapshotId),l(void 0));let f=mn(c??t,n,i,o),p=un()??r,m={cost:r.cost&&p.cost,tokens:r.tokens&&p.tokens},h=Q(m).includes(i)?i:Q(m)[0]??`cost`,[g,_]=J(`${e}:accepted`,void 0),[v,y]=J(`${e}:acceptedCount`,o),[b,ee]=J(`${e}:acceptedSort`,i),[x,S]=(0,P.useState)(i);x!==i&&(S(i),s(20),l(g??c??t)),f.data&&(!g||(v!==o||b!==i)&&g.snapshotId===f.data.snapshotId)&&(_(f.data),y(o),ee(i));let w=g??f.data,T=f.data&&w&&yn(f.data,w),te=w?.coverage.projects.some(e=>e.state!==`complete`),E=f.data?.coverage.projects.some(e=>e.state!==`complete`),ne=JSON.stringify(w?.coverage)!==JSON.stringify(f.data?.coverage),re=!n||t.projects.some(e=>e.projectId===n);return(0,F.jsxs)(`div`,{className:`space-y-3 p-4 text-sm`,"data-sheet-loading":f.isFetching,children:[(0,F.jsx)(xn,{value:h,onChange:a,visibility:m}),f.isPending&&(0,F.jsx)(`p`,{children:`Loading tasks…`}),f.isError&&(0,F.jsxs)(`p`,{role:`alert`,children:[`Could not refresh tasks. `,w?`Showing stale usage.`:``,` `,(0,F.jsx)(C,{className:`min-h-11`,onClick:()=>void f.refetch(),children:`Retry`})]}),T&&(0,F.jsx)(C,{className:`min-h-11`,onClick:()=>{_(f.data),y(o),ee(i)},children:`Updates available — Show`}),w&&te&&(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`p`,{className:`text-muted-foreground`,children:`Coverage of displayed tasks:`}),(0,F.jsx)(W,{coverage:w.coverage,retry:()=>void f.refetch()})]}),f.data&&E&&ne&&(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`p`,{className:`text-muted-foreground`,children:`Current source availability:`}),(0,F.jsx)(W,{coverage:f.data.coverage,retry:()=>void f.refetch()})]}),w&&(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(`p`,{className:`border-b pb-2 font-mono text-meta text-soft-foreground`,children:[w.tasks.rows.length,` of `,w.tasks.total,` retained tasks`]}),w.tasks.total===0&&(0,F.jsx)(`p`,{children:w.coverage.projects.some(e=>e.state!==`complete`)?`No tasks could be read from available sources.`:`No retained tasks in this cohort.`}),w.tasks.rows.map(e=>(0,F.jsx)(On,{row:e,sort:h,visibility:m,disabled:!re||!f.data||!!(T&&!f.data?.tasks.rows.some(t=>t.id===e.id&&t.projectId===e.projectId))},`${e.projectId}:${e.id}`)),w.tasks.nextOffset!==null&&(0,F.jsx)(C,{className:`min-h-11`,disabled:f.isFetching,onClick:()=>{l(w),s(e=>e+20)},children:`Show 20 more tasks`})]})]})}function On({row:e,sort:t,visibility:n,disabled:r}){let i=Ee(e);r||=i===null;let a=c(i?{status:i.status,awaitingAnswerSince:i.awaitingAnswerSince}:e),o=Q(n).filter(e=>e!==t),s=t=>{let n=e[Z[t]];return n==null?`—`:bn(n,t)},l=t=>`${vn[t]}: ${bn(e[Z[t]],t)}`;return(0,F.jsxs)(`div`,{className:`grid grid-cols-[minmax(0,1fr)_auto] items-start gap-x-4 border-b py-3 last:border-0`,children:[(0,F.jsxs)(`div`,{className:`min-w-0`,children:[(0,F.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,F.jsx)(M,{tone:a.tone,pulse:a.pulse,className:`mt-[7px]`}),(0,F.jsx)(E,{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,F.jsxs)(`p`,{className:`mt-1 pl-[15px] font-mono text-meta text-soft-foreground`,children:[e.projectId,` · `,r?`Checking current state…`:i?.status??e.status,e.archived?` · Archived`:``,e.subtask?` · Subtask`:``]})]}),(0,F.jsxs)(`div`,{className:`text-right tabular-nums`,children:[(0,F.jsx)(`span`,{"aria-label":l(t),className:`block font-semibold ${e[Z[t]]==null?`text-soft-foreground`:``}`,children:s(t)}),o.length>0&&(0,F.jsx)(`span`,{className:`mt-1 flex justify-end gap-3 font-mono text-meta text-soft-foreground`,children:o.map(e=>(0,F.jsxs)(`span`,{"aria-label":l(e),children:[s(e),` `,e===`cost`?``:e===`input`?`in`:`out`]},e))})]})]})}var kn={cost:`costUsd`,input:`inputTokens`,output:`outputTokens`},An={cost:`Reported USD`,input:`Input tokens`,output:`Output tokens`};function jn(e){return[...e.cost?[`cost`]:[],...e.tokens?[`input`,`output`]:[]]}var Mn=(e,t)=>yt(e,t===`cost`);function Nn(e){return new Date(`${e}T00:00:00`).toLocaleDateString(void 0,{month:`short`,day:`numeric`})}function Pn({series:e,height:t,accent:n,renderTooltip:r,describe:i}){let a=Math.max(1,...e.map(t));return(0,F.jsxs)(Be,{delayDuration:150,children:[(0,F.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,F.jsxs)(Ve,{children:[(0,F.jsx)(Re,{asChild:!0,children:(0,F.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,F.jsx)(`span`,{style:{height:`${s}%`},className:`block w-full rounded-t-sm ${n}`})})}),(0,F.jsx)(ze,{children:r(e)})]},e.date)})}),(0,F.jsxs)(`div`,{className:`mt-1 flex justify-between text-xs text-muted-foreground`,children:[(0,F.jsx)(`span`,{children:Nn(e[0].date)}),(0,F.jsx)(`span`,{children:Nn(e.at(-1).date)})]})]})}function Fn({metrics:e,series:t}){return(0,F.jsxs)(`table`,{className:`w-full text-left text-xs`,children:[(0,F.jsx)(`thead`,{children:(0,F.jsxs)(`tr`,{className:`border-b`,children:[(0,F.jsx)(`th`,{className:`py-1 pr-2 font-medium`,children:`Date`}),e.map(e=>(0,F.jsx)(`th`,{className:`py-1 pr-2 text-right font-medium`,children:An[e]},e)),(0,F.jsx)(`th`,{className:`py-1 pr-2 text-right font-medium`,children:`Completed`}),(0,F.jsx)(`th`,{className:`py-1 text-right font-medium`,children:`Avg cycle`})]})}),(0,F.jsx)(`tbody`,{children:t.map(t=>(0,F.jsxs)(`tr`,{className:`border-b last:border-0`,children:[(0,F.jsx)(`td`,{className:`py-1 pr-2`,children:Nn(t.date)}),e.map(e=>(0,F.jsx)(`td`,{className:`py-1 pr-2 text-right tabular-nums`,children:Mn(t[kn[e]]?.value,e)},e)),(0,F.jsx)(`td`,{className:`py-1 pr-2 text-right tabular-nums`,children:t.completed}),(0,F.jsx)(`td`,{className:`py-1 text-right tabular-nums`,children:t.avgCycleHours===null?`—`:G(t.avgCycleHours)})]},t.date))})]})}function In({metric:e,series:t}){let n=hn[e],r=kn[e],i=t.reduce((e,t)=>e+(t[r]?.reportedTasks??0),0);return(0,F.jsxs)(`div`,{className:`rounded-xl border p-3`,children:[(0,F.jsx)(`p`,{className:`text-xs font-medium ${n.text}`,children:An[e]}),(0,F.jsx)(`div`,{className:`mt-2`,children:(0,F.jsx)(Pn,{series:t,describe:t=>`${t.date}, ${An[e]}: ${Mn(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,F.jsxs)(`p`,{children:[Nn(t.date),` · `,Mn(t[r]?.value,e),` ·`,` `,t[r]?.reportedTasks??0,`/`,t.tasks,` tasks reported`]})})}),i===0&&(0,F.jsx)(`p`,{className:`mt-2 text-xs text-muted-foreground`,children:`No reports in this period.`})]})}function Ln({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,F.jsxs)(`div`,{className:`rounded-xl border p-3`,children:[(0,F.jsxs)(`div`,{className:`flex flex-wrap items-baseline justify-between gap-2`,children:[(0,F.jsx)(`p`,{className:`text-xs font-medium text-success`,children:`Completed tasks`}),(0,F.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[t,` done · avg cycle`,` `,i===null?`unavailable`:G(i)]})]}),(0,F.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[r,`/`,t,` completed tasks have valid cycle times.`]}),(0,F.jsx)(`div`,{className:`mt-2`,children:(0,F.jsx)(Pn,{series:e,describe:e=>`${e.date}: ${e.completed} completed tasks, average cycle ${e.avgCycleHours==null?`Unavailable`:G(e.avgCycleHours)}`,height:e=>e.completed,accent:`bg-success`,renderTooltip:e=>(0,F.jsxs)(`div`,{children:[(0,F.jsxs)(`p`,{children:[Nn(e.date),` · `,e.completed,` completed`]}),(0,F.jsxs)(`p`,{children:[`Avg cycle`,` `,e.avgCycleHours===null?`unavailable`:G(e.avgCycleHours),` · Median`,` `,e.medianCycleHours===null?`unavailable`:G(e.medianCycleHours)]})]})})}),t===0&&(0,F.jsx)(`p`,{className:`mt-2 text-xs text-muted-foreground`,children:`No tasks finished in this period.`})]})}function Rn(){return(0,F.jsx)(zn,{visibility:Ge(i().data)})}function zn({visibility:e}){let[t,n]=bt(`trendPeriod`,[`7d`,`30d`],`7d`),r=pn(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=jn({cost:e.cost&&i?.visibility.cost!==!1,tokens:e.tokens&&i?.visibility.tokens!==!1});return(0,F.jsxs)(j,{className:`gap-0 py-0`,children:[(0,F.jsxs)(`div`,{className:R,children:[(0,F.jsx)(`h2`,{className:L,children:`Trends`}),(0,F.jsxs)(`label`,{className:nt,children:[`Period`,(0,F.jsxs)(rt,{value:t,onChange:e=>n(e.target.value),children:[(0,F.jsx)(`option`,{value:`7d`,children:`Last 7 days`}),(0,F.jsx)(`option`,{value:`30d`,children:`Last 30 days`})]})]})]}),(0,F.jsxs)(`div`,{className:`space-y-4 p-4 text-sm`,children:[i&&(0,F.jsx)(I,{rows:a?[]:i.series.flatMap(e=>[...o.map(t=>({section:`daily-creation-cohort`,entity:e.date,metric:kn[t],value:e[kn[t]]?.value??null,unit:t===`cost`?`USD`:`tokens`,reportedTasks:e[kn[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,F.jsxs)(`details`,{className:`text-xs text-muted-foreground`,children:[(0,F.jsxs)(`summary`,{"data-export-heading":`Metric definitions`,className:`${tt} py-2`,children:[(0,F.jsx)(z,{}),`How these metrics work`]}),(0,F.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,F.jsx)(`p`,{children:`Loading trends…`}),r.isError&&(0,F.jsxs)(`p`,{role:`alert`,children:[i?`Showing stale trends. Could not refresh.`:`Could not load trends.`,` `,(0,F.jsx)(C,{className:`min-h-11`,onClick:()=>void r.refetch(),children:`Retry`})]}),i&&(0,F.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:(0,F.jsx)(ot,{at:i.asOf})}),i&&(0,F.jsx)(W,{coverage:i.coverage,retry:()=>void r.refetch()}),i&&a&&(0,F.jsx)(`p`,{className:`text-muted-foreground`,children:`No retained tasks in this period yet.`}),i&&!a&&i.series.length>0&&(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(`div`,{className:`space-y-4`,children:[o.length>0&&(0,F.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-[repeat(auto-fit,minmax(200px,1fr))]`,children:o.map(e=>(0,F.jsx)(In,{metric:e,series:i.series},e))}),(0,F.jsx)(Ln,{series:i.series})]}),(0,F.jsxs)(`details`,{className:`group rounded-lg border bg-muted/20 print:block`,children:[(0,F.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,F.jsx)(Ze,{className:`size-4`,"aria-hidden":`true`}),` View data table`,(0,F.jsx)(Le,{className:`ml-auto size-4 transition-transform group-open:rotate-180`,"aria-hidden":`true`})]}),(0,F.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,F.jsx)(Fn,{metrics:o,series:i.series})})]})]})]})]})}function Bn(e,t,n,i=!0){let o=r();return a({queryKey:[...Y.snapshot,e?.snapshotId,t,n],enabled:i&&!!e,retry:!1,queryFn:async({signal:r})=>{if(!e)throw Error(`Dashboard not loaded`);let i=[];try{for(let a=0;a<n;){let o=await $t(e.snapshotId,t,a,Math.min(20,n-a),r);if(i.push(...o.page.rows),o.page.nextOffset===null)break;a=o.page.nextOffset}return i}catch(e){if(e instanceof p&&e.status===409){let e=await Qt(r);o.setQueryData(Y.snapshot,e)}throw e}}})}function Vn(e,t,n,i){let o=r(),s=t===`questions`||t===`reviews`?`needs-you`:t,c=s===`needs-you`?0:n,l=i.map(e=>`${e.projectId}:${e.id}`).sort();return a({queryKey:[...Y.snapshot,e.snapshotId,t,`displaced`,...l],enabled:l.length>0,retry:!1,queryFn:async({signal:t})=>{let n=new Set(l),r=new Map;try{for(let i=c;i!==null&&n.size;){let a=await $t(e.snapshotId,s,i,20,t);for(let e of a.page.rows){let t=`${e.projectId}:${e.id}`;n.delete(t)&&r.set(t,e)}i=a.page.nextOffset}return r}catch(e){throw e instanceof p&&e.status===409&&o.setQueryData(Y.snapshot,await Qt(t)),e}}})}function Hn({snapshot:e,questions:t,reviews:n,more:r,healthy:i=!0}){let a=ue();return(0,F.jsxs)(j,{className:`min-w-0 gap-0 overflow-hidden py-0`,children:[(0,F.jsxs)(`div`,{className:R,children:[(0,F.jsxs)(`h2`,{id:`dashboard-needs-you`,tabIndex:-1,className:L,children:[`Needs you · `,e.counts.questions+e.counts.reviews]}),(0,F.jsxs)(`p`,{className:`font-mono text-meta 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,F.jsxs)(`p`,{className:`flex items-center gap-2.5 px-4 py-8 text-sm text-muted-foreground`,children:[(0,F.jsx)(M,{tone:`success`}),`All caught up — no tasks need your input`]}):null,(0,F.jsx)(Un,{snapshot:e,group:`questions`,count:t,more:r}),(0,F.jsx)(Un,{snapshot:e,group:`reviews`,count:n,more:r})]})}function Un({snapshot:e,group:t,count:n,more:r}){let i=e[t],a=Math.max(n,i.rows.length),o=Bn(e,t,a,a>i.rows.length),s=a>i.rows.length?o.data:i.rows,c=ft(s,U,t,n),l=Vn(e,t,a,c.rows.filter(e=>e.removed).map(e=>e.row)),u=(0,P.useRef)(null);return!i.total&&!c.rows.length?null:(0,F.jsxs)(`section`,{children:[(0,F.jsxs)(`h3`,{ref:u,tabIndex:-1,className:`border-b bg-card-2 px-4 py-2 eyebrow text-muted-foreground`,children:[t===`questions`?`Questions`:`Reviews`,` · `,i.total]}),c.updates>0&&(0,F.jsxs)(C,{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,F.jsx)(vt,{row:l.data?.get(U(e))??e,removed:t&&!!l.data&&!l.data.has(U(e)),checking:s===void 0||t&&!l.data,checkFailed:s===void 0&&o.isError||t&&!l.data&&l.isError,queue:!0},U(e))),(o.isError||l.isError)&&(0,F.jsxs)(`p`,{role:`alert`,className:`p-4 text-sm`,children:[`Could not check current task state.`,` `,(0,F.jsx)(C,{variant:`ghost`,className:`min-h-11`,onClick:()=>{o.refetch(),l.refetch()},children:`Retry`})]}),a<i.total&&(0,F.jsxs)(C,{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 Wn(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 Gn=e=>e.key;function Kn({filter:e,setFilter:t,count:n,more:r}){let i=rn(e,!0),a=ft(i.data?.rows,Gn,`feed:${e}`,0,e=>e.kind===`task-result`),o=a.rows,s=a.updates,c=(0,P.useContext)(ut),l=(0,P.useRef)(null),u=`feed:${e}`,d=(0,P.useMemo)(()=>({scroll:gt(c,u)?.scroll??0,done:!1}),[c,u]);(0,P.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,P.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,F.jsxs)(j,{"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,F.jsxs)(`div`,{className:`space-y-2 border-b px-4 pt-2.5 pb-2`,children:[(0,F.jsxs)(`div`,{className:`flex min-h-9 flex-wrap items-center justify-between gap-2`,children:[(0,F.jsx)(`h2`,{ref:f,tabIndex:-1,className:L,children:b?`Recent results`:`Recent results & GitHub`}),(0,F.jsx)(`span`,{className:`font-mono text-meta text-soft-foreground`,children:`Last 7 days`})]}),!b&&(0,F.jsx)(be,{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,F.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Task results · No GitHub repositories configured`}),e!==`tasks`&&!b&&(0,F.jsxs)(`details`,{className:`text-xs text-muted-foreground`,open:y.length||h?!0:void 0,children:[(0,F.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,F.jsx)(z,{}),y.length||h?`GitHub needs attention`:_?`Checking GitHub…`:v?`GitHub not configured`:m?`GitHub checked ${N(m)} ago`:`GitHub source`]}),(0,F.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-x-3`,children:[(0,F.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 ${N(m)} ago`:`GitHub snapshot`}),!v&&(0,F.jsx)(C,{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,F.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&&_t(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,F.jsxs)(`p`,{role:`alert`,className:`p-4 text-sm`,children:[`Could not load results.`,` `,(0,F.jsx)(C,{className:`min-h-11`,onClick:()=>{i.retryFailed()},children:`Retry`})]}),i.isPending&&(0,F.jsx)(`p`,{className:`p-4 text-sm`,children:`Loading results…`}),s>0&&(0,F.jsxs)(C,{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,F.jsx)(vt,{row:e.run,kicker:t?`Outside current results`:`Latest result: ${e.run.status===`failed`?`Failed`:`Completed`}`},e.key):(0,F.jsxs)(`div`,{className:`border-b px-4 py-3 transition-colors hover:bg-muted/30`,children:[(0,F.jsx)(I,{rows:[{section:`github`,entity:`${e.repo}#${e.number}`,metric:e.itemKind,value:e.title,asOf:e.at,note:e.url}]}),(0,F.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,F.jsxs)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:[e.repo,` · `,e.itemKind===`pr`?`PR`:`Issue`,` #`,e.number,` created ·`,` `,N(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,F.jsx)(`p`,{className:`px-4 py-8 text-sm text-muted-foreground`,children:`No results in the last 7 days`}),n<o.length&&(0,F.jsxs)(C,{variant:`ghost`,className:`m-2 min-h-11`,onClick:r,children:[`Show `,Math.min(20,o.length-n),` more results`]}),i.data?.truncated&&(0,F.jsx)(`p`,{className:`p-4 text-xs`,children:`Showing the latest 60 results`}),i.data&&(0,F.jsx)(W,{coverage:i.data.coverage,retry:()=>{i.retryTasks()}}),!b&&i.data?.sources.some(e=>e.state!==`ready`||e.truncated)&&(0,F.jsxs)(`details`,{className:`p-4 text-xs`,children:[(0,F.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,F.jsx)(z,{}),`Source details`]}),i.data.sources.map(e=>(0,F.jsxs)(`p`,{className:`break-words py-1`,children:[Wn(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 ${N(e.fetchedAt)}`:``]},e.key))]})]})]})}var $=e=>e.replace(/[&<>"']/g,e=>({"&":`&amp;`,"<":`&lt;`,">":`&gt;`,'"':`&quot;`,"'":`&#39;`})[e]),qn=`Visible modules and loaded rows only. Filters and report availability apply. Retained task usage is not an invoice or a complete history.`,Jn=`Confidential — internal distribution only`,Yn={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 Xn(e,t){return e==null?`Unavailable`:typeof e==`string`?e:yt(e,t)}function Zn(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=Yn[e.metric];!i||t.has(e.metric)||(t.add(e.metric),n.push({label:i.label,value:Xn(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 Qn(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 $n(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:Qn(e),rows:[...e.querySelectorAll(`[data-dashboard-export]`)].flatMap(e=>JSON.parse(e.dataset.dashboardExport))}})}}function er(e){let t=e==null?``:String(e);return typeof e==`string`&&/^[\s\uFEFF]*[=+@\-]/.test(t)&&(t=`'${t}`),`"${t.replaceAll(`"`,`""`)}"`}function tr(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`,qn,``,``,``,``,``,[...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(er).join(`,`)).join(`\r
2
- `)+`\r
3
- `}function nr(e,t){let n=Zn(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
- @page {
5
- size:A4; margin:14mm 14mm 18mm;
6
- @bottom-left { content:"${Jn}"; font-family:system-ui,sans-serif; font-size:9px; color:var(--muted-foreground); }
7
- @bottom-right { content:"Page " counter(page) " of " counter(pages); font-family:system-ui,sans-serif; font-size:9px; color:var(--muted-foreground); }
8
- }
9
- html,body { height:auto!important; overflow:visible!important; background:var(--background)!important; color:var(--foreground)!important; }
10
- * { -webkit-print-color-adjust:exact; print-color-adjust:exact; }
11
- body { margin:0; font:12px/1.5 system-ui,sans-serif; }
12
- .report-heading { border-bottom:2px solid var(--violet); padding-bottom:16px; margin-bottom:20px; }
13
- .report-heading h1 { font-size:26px; margin:0 0 8px; }
14
- .report-heading p { margin:4px 0; color:var(--muted-foreground); }
15
- .report-confidential { display:inline-block; margin:6px 0; padding:2px 8px; border:1px solid var(--destructive); border-radius:4px; color:var(--destructive); font-size:11px; font-weight:600; letter-spacing:.03em; text-transform:uppercase; }
16
- .report-summary { margin:0 0 24px; }
17
- .report-summary h2 { font-size:12px; margin:0 0 10px; text-transform:uppercase; letter-spacing:.04em; color:var(--muted-foreground); }
18
- .summary-grid { display:flex; flex-wrap:wrap; gap:12px; }
19
- .summary-tile { flex:1 1 140px; border:1px solid var(--border); border-radius:8px; padding:12px 14px; break-inside:avoid; }
20
- .summary-value { display:block; font-size:22px; font-weight:600; }
21
- .summary-label { display:block; font-size:11px; color:var(--muted-foreground); margin-top:2px; }
22
- .summary-note { display:block; font-size:10px; color:var(--soft-foreground); margin-top:4px; }
23
- .report-module { margin:0 0 20px; break-before:auto; }
24
- .report-module h2,.report-module h3 { break-after:avoid; }
25
- .report-module-usage, .report-module-fleet { break-inside:avoid; }
26
- .report-module-usage label { min-height:0!important; }
27
- .report-module-usage .space-y-4 > :not(:last-child) { margin-block-end:8px!important; }
28
- .report-module-usage .report-row { padding-top:5px!important; padding-bottom:5px!important; }
29
- .report-cost-metrics { grid-template-columns:repeat(3,minmax(0,1fr))!important; }
30
- .report-cost-metrics > div { padding:12px!important; break-inside:avoid; }
31
- .report-cost-metrics .text-3xl { font-size:22px!important; }
32
- .report-module > :first-child, .report-module header, .report-context { break-after:avoid; }
33
- .report-module .report-row, .report-module tr { break-inside:avoid; }
34
- .report-module thead { display:table-header-group; }
35
- .report-module .report-row { padding-top:8px!important; padding-bottom:8px!important; }
36
- .report-module a { min-height:0!important; }
37
- .report-module > div { padding-top:12px!important; padding-bottom:12px!important; }
38
- .report-module * { overflow:visible !important; max-height: none !important; animation:none!important; transition:none!important; box-shadow:none!important; }
39
- .report-module a { color:inherit; text-decoration:none; }
40
- .report-module svg { max-width:24px; }
41
- .report-module [role=region] > div, .report-module [role=region] > p { break-inside:avoid; }
42
- .report-module .sr-only { display:none!important; }
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">${Jn}</span><p>${$(qn)}</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 rr({dashboard:e}){let[t,n]=(0,P.useState)(!1),[r,i]=(0,P.useState)(``),[a,o]=(0,P.useState)(!1),[s,c]=(0,P.useState)(``),l=t=>{i(``);try{if(!e.current)return;let r=$n(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([tr(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=nr(r,e),document.body.append(t)}}catch{o(!1),i(`Could not prepare the export. Please try again.`)}};return(0,F.jsxs)(oe,{open:t,onOpenChange:n,children:[(0,F.jsx)(ae,{asChild:!0,children:(0,F.jsxs)(C,{variant:`outline`,className:`min-h-11`,disabled:a,children:[(0,F.jsx)(Ue,{className:`size-4`}),a?`Preparing report…`:`Export`]})}),(0,F.jsxs)(ie,{align:`end`,className:`max-w-[calc(100vw-2rem)] space-y-3`,children:[(0,F.jsx)(`p`,{className:`text-sm font-medium`,children:`Export current dashboard`}),(0,F.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Visible modules, current filters and loaded rows. Hidden metrics are excluded.`}),(0,F.jsxs)(`label`,{className:`block space-y-1 text-xs text-muted-foreground`,children:[`Report title (optional)`,(0,F.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,F.jsx)(C,{className:`min-h-11 w-full`,onClick:()=>l(`pdf`),children:`PDF report…`}),(0,F.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Choose Save as PDF in the print dialog.`}),(0,F.jsx)(C,{variant:`outline`,className:`min-h-11 w-full`,onClick:()=>l(`csv`),children:`Download CSV`}),r&&(0,F.jsx)(`p`,{role:`alert`,className:`text-sm`,children:r})]})]})}var ir={overview:`Workspace overview`,portfolio:`Projects`,automations:`Automations`,fleet:`Queue & scheduling`,needsYou:`Needs you`,recent:`Recent results & GitHub`,usage:`Usage & cost`,trends:`Trends`};function ar({id:e,children:t,wide:n}){let{attributes:r,listeners:i,setNodeRef:a,setActivatorNodeRef:o,transform:s,isDragging:c}=ve({id:e});return(0,F.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,F.jsx)(C,{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 ${ir[e]}`,children:(0,F.jsx)(`span`,{className:`flex h-4 w-8 items-center justify-center rounded-full border bg-card text-muted-foreground shadow-xs`,children:(0,F.jsx)(Xe,{className:`size-3.5`,"aria-hidden":`true`})})}),t]})}function or({order:e,modules:t,onOrder:n}){let r=we(pe(Se,{activationConstraint:{distance:8}}),pe(fe,{coordinateGetter:ye})),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=>`${ir[e]}, position ${i.indexOf(e)+1} of ${i.length}`;return(0,F.jsx)(_e,{sensors:r,collisionDetection:Te,accessibility:{announcements:{onDragStart:({active:e})=>`Picked up ${s(e.id)}.`,onDragOver:({active:e,over:t})=>t?`${ir[e.id]} moved to position ${i.indexOf(t.id)+1} of ${i.length}.`:void 0,onDragEnd:({active:e,over:t})=>t?`${ir[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(ge(e,e.indexOf(t.id),e.indexOf(r.id)))},children:(0,F.jsx)(he,{items:i,strategy:xe,children:(0,F.jsx)(`div`,{className:`grid items-start gap-5 lg:grid-cols-2`,children:i.map(e=>(0,F.jsx)(ar,{id:e,wide:a.has(e),children:t[e]},e))})})})}var sr=[`overview`,`needsYou`,`recent`,`fleet`,`automations`,`portfolio`,`usage`,`trends`],cr=e=>sr.includes(e);function lr(e=[]){let t=e.filter(cr);return(e=>t.length===e.length&&t.every((t,n)=>t===e[n]))(sr.filter(e=>e!==`automations`))?[...sr]:[...new Set([...t.includes(`overview`)?[]:[`overview`],...t,...sr])]}function ur(e=[],t){let n=0;return[...e.map(e=>cr(e)?t[n++]:e),...t.slice(n)]}function dr(){let e=f(),t=r(),[n,i]=(0,P.useState)(),[a,s]=(0,P.useState)(!1),c=(0,P.useRef)(void 0),l=(0,P.useRef)(!1),d=T.parse(e.data?.dashboard??{}),p=(0,P.useRef)(d);p.current=d;let h=n?.tiles??{automations:d.tiles?.automations??!0,fleet:d.tiles?.fleet??!0,needsYou:d.tiles?.needsYou??!0,recent:d.tiles?.recent??!0,usage:d.tiles?.usage??!0,trends:d.tiles?.trends??!0},g=lr(n?.order??d.order),_=(0,P.useRef)({tiles:h,order:g});_.current=n??{tiles:h,order:g};let v=e=>{let t={..._.current,...e};_.current=t,i(t),c.current=t},y=async()=>{if(!(l.current||!c.current)){for(l.current=!0;c.current;){let n=c.current;c.current=void 0;try{e.data||(p.current=T.parse((await u()).dashboard??{}));let r=await o({dashboard:{...p.current,order:ur(p.current.order,n.order),tiles:{...p.current?.tiles,...n.tiles}}});t.setQueryData(m.uiState,r),p.current=T.parse(r.dashboard??{}),s(!1),i(e=>e===n?void 0:e)}catch{s(!0),c.current||=n;break}}l.current=!1}},b=(0,P.useRef)(y);return b.current=y,(0,P.useEffect)(()=>()=>{b.current()},[]),(0,P.useEffect)(()=>{if(!n)return;let e=setTimeout(()=>{y()},250);return()=>clearTimeout(e)},[n]),{tiles:h,order:g,setOrder:e=>v({order:lr(e)}),failed:a,ready:e.data!==void 0||e.isError,setTiles(e){v({tiles:e})},retry:()=>{y()}}}function fr(e,t){let n=sr.filter(e=>t.includes(e)),r=0;return e.map(e=>t.includes(e)?n[r++]:e)}var pr=[[`overview`,`Overview`],[`costs`,`Usage & cost`],[`automations`,`Automations`]];function mr(){let e=ne(),t=e.state?.dashboardEntry??e.key;return(0,F.jsx)(hr,{entryKey:t},t)}function hr({entryKey:e}){let t=ne(),[n,r]=te(),i=(0,P.useRef)(mt(e)).current,[a,o]=(0,P.useState)(i?.questions??0),[s,c]=(0,P.useState)(i?.reviews??0),[l,u]=(0,P.useState)(i?.feed??6),d=(0,P.useRef)(null),f=(0,P.useRef)(null),[p,m]=(0,P.useState)(!1),h=dr(),[g,_]=(0,P.useState)(!1),v=n.get(`view`)===`costs`?`costs`:n.get(`view`)===`automations`?`automations`:`overview`,y=pr.find(([e])=>e===v)[1],b=v===`costs`?[`usage`,`trends`]:v===`automations`?[`automations`]:[`fleet`,`needsYou`,`recent`],ee=v===`overview`?[`overview`,`portfolio`,...b]:[...b],x=fr(h.order,ee),S=()=>h.setTiles({...h.tiles,...Object.fromEntries(b.map(e=>[e,!0]))}),w=h.tiles,T={...w,automations:v===`automations`&&w.automations,fleet:v===`overview`&&w.fleet,needsYou:v===`overview`&&w.needsYou,recent:v===`overview`&&w.recent,usage:v===`costs`&&w.usage,trends:v===`costs`&&w.trends},re=n.get(`feed`)===`tasks`?`tasks`:n.get(`feed`)===`github`?`github`:`all`,se=n.get(`panel`),D=se&&[`running`,`queued`,`scheduled`,`needs-you`].includes(se)?se:null,le=T.fleet||T.needsYou||T.recent&&re!==`github`||!!D,O=en(h.ready&&le),k=ue();tn(h.ready&&T.fleet&&g);let A=(0,P.useRef)({questions:a,reviews:s,feed:l,scroll:i?.scroll??0,focus:i?.focus});A.current={...A.current,questions:a,reviews:s,feed:l},(0,P.useEffect)(()=>{let t=d.current?.closest(`main`)??d.current,n=()=>{A.current.scroll=t?.scrollTop??0},r=()=>{A.current.focus=document.activeElement?.closest(`[data-dashboard-row]`)?.getAttribute(`data-dashboard-row`)??void 0};return t?.addEventListener(`scroll`,n),document.addEventListener(`focusin`,r),()=>{ht(e,A.current),t?.removeEventListener(`scroll`,n),document.removeEventListener(`focusin`,r)}},[e]);let de=(0,P.useRef)(!1),fe=h.ready&&(!le||!!O.data&&!O.isFetching);(0,P.useEffect)(()=>{if(!i||de.current||!fe)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,de.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,fe]);let pe=i=>{let a=new URLSearchParams(n);i?a.set(`panel`,i):a.delete(`panel`),r(a,{replace:!0,state:{...t.state,dashboardEntry:e}})},me=(e,t)=>{f.current=t,pe(e)},he=O.data?O.data.counts.questions+O.data.counts.reviews:0;return(0,F.jsx)(ut.Provider,{value:e,children:(0,F.jsx)(dt.Provider,{value:!i||!O.isFetching&&!O.isError,children:(0,F.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,F.jsxs)(`header`,{className:`flex flex-wrap items-end justify-between gap-4`,children:[(0,F.jsxs)(`div`,{className:`min-w-0`,children:[(0,F.jsx)(`h1`,{className:`text-2xl font-semibold tracking-tight`,children:`Dashboard`}),(0,F.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,F.jsxs)(`span`,{"data-export-exclude":!0,className:`inline-flex items-center gap-1.5 rounded-full border px-2 py-0.5 eyebrow`,children:[(0,F.jsx)(M,{tone:k.connected?`success`:`neutral`,pulse:k.connected}),k.connected?`Live`:`Offline`]})]})]}),(0,F.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,F.jsx)(rr,{dashboard:d}),(0,F.jsxs)(oe,{open:p,onOpenChange:m,children:[(0,F.jsx)(ae,{asChild:!0,children:(0,F.jsxs)(C,{variant:`outline`,className:`min-h-11`,children:[(0,F.jsx)(ce,{className:`size-4`}),`Customize`]})}),(0,F.jsxs)(ie,{align:`end`,className:`max-h-[min(32rem,80dvh)] max-w-[calc(100vw-2rem)] overflow-y-auto`,children:[(0,F.jsx)(`p`,{className:`mb-3 text-sm font-medium`,children:`Optional modules in this view`}),b.map(e=>(0,F.jsxs)(`label`,{className:`flex min-h-11 items-center gap-3 text-sm`,children:[(0,F.jsx)(`input`,{type:`checkbox`,checked:w[e],disabled:!h.ready,onChange:t=>h.setTiles({...w,[e]:t.target.checked})}),{automations:`Automations`,fleet:`Queue & scheduling`,needsYou:`Needs you`,recent:`Recent results & GitHub`,usage:`Usage & cost`,trends:`Trends`}[e]]},e)),(0,F.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!==x[t])&&(0,F.jsxs)(C,{variant:`ghost`,className:`min-h-11`,onClick:()=>h.setOrder(x),children:[`Reset `,y,` order`]}),(0,F.jsx)(`p`,{className:`my-3 text-xs text-muted-foreground`,children:`Shared across browsers using this workspace`}),b.some(e=>!w[e])&&(0,F.jsxs)(C,{variant:`outline`,className:`min-h-11`,disabled:!h.ready,onClick:()=>{S(),m(!1)},children:[`Show all in `,y]})]})]})]})]}),(0,F.jsx)(`nav`,{"aria-label":`Dashboard views`,className:`-mt-2 flex flex-wrap gap-5 border-b`,children:pr.map(([r,i])=>{let a=new URLSearchParams(n);return a.set(`view`,r),a.delete(`panel`),(0,F.jsx)(C,{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,F.jsx)(E,{"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,F.jsxs)(`p`,{role:`alert`,className:`text-sm`,children:[`Layout changed for this session, but could not be saved.`,` `,(0,F.jsx)(C,{variant:`ghost`,className:`min-h-11`,onClick:h.retry,children:`Retry saving`})]}),le&&!k.connected&&O.data&&(0,F.jsxs)(`p`,{role:`status`,className:`text-xs text-muted-foreground`,children:[`Tasks disconnected · Last updated `,N(O.data.asOf),` ago`]}),le&&O.isError&&(0,F.jsxs)(`p`,{role:`alert`,className:`rounded-md border p-4 text-sm`,children:[`Could not refresh dashboard.`,` `,O.data?`Showing the last available task state.`:``,` `,(0,F.jsx)(C,{className:`min-h-11`,onClick:()=>{O.refetch()},children:`Retry`})]}),v===`costs`&&!Object.values(T).some(Boolean)?(0,F.jsxs)(`p`,{role:`status`,className:`flex flex-wrap items-center gap-2 text-sm text-muted-foreground`,children:[(0,F.jsx)(Ce,{className:`size-4`,"aria-hidden":`true`}),`Optional modules in this view are hidden.`,(0,F.jsxs)(C,{variant:`outline`,className:`min-h-11`,onClick:()=>S(),children:[`Show all in `,y]})]}):null,O.isPending&&(T.fleet||T.needsYou)&&(0,F.jsx)(`p`,{className:`text-sm`,children:`Loading dashboard…`}),le&&O.data&&(0,F.jsx)(W,{coverage:O.data.coverage,count:he,retry:()=>void O.refetch()}),v===`automations`&&(0,F.jsx)(Rt,{}),(0,F.jsx)(Yt,{active:v===`overview`,onCurrent:me,children:i=>h.ready&&(0,F.jsx)(or,{order:h.order,onOrder:h.setOrder,modules:{...i,automations:T.automations?(0,F.jsx)(st,{}):null,fleet:T.fleet&&O.data?(0,F.jsxs)(j,{className:`gap-0 py-0`,children:[(0,F.jsx)(I,{rows:Object.entries({queued:O.data.counts.queued,scheduled:O.data.counts.scheduled,monitoring:O.data.counts.monitoring}).map(([e,t])=>({section:`fleet`,metric:e,value:t,unit:`tasks`,asOf:O.data.asOf}))}),(0,F.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,F.jsx)(`h2`,{className:`section-mark eyebrow text-muted-foreground`,children:`Queue & scheduling`}),(0,F.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,F.jsx)(M,{tone:k.connected?`success`:`neutral`}),k.connected?`Tasks connected`:`Tasks disconnected`]})]}),(0,F.jsx)(`div`,{className:`grid grid-cols-2 divide-x`,children:[[`queued`,`Queued`,O.data.counts.queued],[`scheduled`,`Scheduled`,O.data.counts.scheduled]].map(([e,t,n])=>(0,F.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=>me(e,t.currentTarget),children:[(0,F.jsx)(`span`,{className:`block eyebrow text-muted-foreground`,children:t}),(0,F.jsx)(`span`,{className:`mt-3 block text-3xl font-semibold leading-none tracking-tight tabular-nums`,children:n})]},e))}),(0,F.jsxs)(`details`,{open:g,onToggle:e=>_(e.currentTarget.open),className:`border-t px-4 py-3 text-xs text-muted-foreground`,children:[(0,F.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,F.jsx)(z,{}),`Technical details`]}),(0,F.jsxs)(`div`,{className:`flex flex-wrap gap-x-5 gap-y-2`,children:[(0,F.jsxs)(`span`,{children:[O.data.counts.monitoring,` monitoring (included in Running)`]}),(0,F.jsx)(`span`,{children:`Agent processes`}),g&&(0,F.jsx)(gr,{running:O.data.counts.running})]})]})]}):null,needsYou:T.needsYou&&O.data?(0,F.jsx)(Hn,{healthy:!O.isError,snapshot:O.data,questions:a,reviews:s,more:(e,t)=>e===`questions`?o(t):c(t)}):null,recent:T.recent?(0,F.jsx)(Kn,{filter:re,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:T.usage?(0,F.jsx)(Sn,{}):null,trends:T.trends?(0,F.jsx)(Rn,{}):null}})}),v===`costs`&&(0,F.jsx)(It,{}),(0,F.jsx)(ke,{open:!!D,onOpenChange:e=>{e||pe(null)},children:(0,F.jsxs)(Oe,{className:`w-full overflow-y-auto sm:max-w-lg`,onCloseAutoFocus:e=>{e.preventDefault(),f.current?.focus()},children:[(0,F.jsxs)(Ae,{children:[(0,F.jsxs)(je,{children:[D===`needs-you`?`Needs you`:D?D[0].toUpperCase()+D.slice(1):`Tasks`,O.data&&D?` · ${D===`needs-you`?he:O.data.counts[D]}`:``]}),(0,F.jsx)(De,{children:`Includes subtasks. Open a task to continue in its project.`})]}),!O.data&&O.isPending&&(0,F.jsx)(`p`,{className:`p-4`,role:`status`,children:`Loading tasks…`}),!O.data&&O.isError&&(0,F.jsxs)(`p`,{className:`p-4`,role:`alert`,children:[`Could not load tasks.`,` `,(0,F.jsx)(C,{className:`min-h-11`,onClick:()=>{O.refetch()},children:`Retry`})]}),D&&O.data&&(0,F.jsx)(_r,{snapshot:O.data,group:D},D)]})})]})})})}function gr({running:e}){let{connected:t,samples:n}=ue(),r=t?n:[],i=r.filter(e=>e.cpuPct!==null);return(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(I,{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,F.jsxs)(`span`,{children:[`CPU`,` `,i.length?`${Math.round(i.reduce((e,t)=>e+(t.cpuPct??0),0))}%`:`unavailable`,` `,`· `,i.length,`/`,e,` measured`]}),(0,F.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,F.jsx)(`span`,{children:`RSS sums process resident memory; CPU may exceed 100%.`})]})}function _r({snapshot:e,group:t}){let n=(0,P.useContext)(ut),r=(0,P.useRef)(gt(n,t)).current,[i,a]=(0,P.useState)(r?.count??20),o=(0,P.useRef)(null),s=(0,P.useRef)({count:i,scroll:r?.scroll??0});s.current.count=i,(0,P.useEffect)(()=>{let e=o.current?.closest(`[data-slot="sheet-content"]`),r=()=>{s.current.scroll=e?.scrollTop??0};return e?.addEventListener(`scroll`,r),()=>{_t(n,t,s.current),e?.removeEventListener(`scroll`,r)}},[n,t]);let c=Bn(e,t,i),l=ft(c.data,U,`panel:${t}`,i),u=Vn(e,t,i,l.rows.filter(e=>e.removed).map(e=>e.row)),d=(0,P.useRef)(null),f=(0,P.useRef)(!1);(0,P.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,F.jsxs)(`div`,{ref:o,children:[(0,F.jsx)(`h3`,{ref:d,tabIndex:-1,className:`sr-only`,children:`Tasks`}),c.isPending&&(0,F.jsx)(`p`,{className:`p-4`,children:`Loading tasks…`}),(c.isError||u.isError)&&(0,F.jsxs)(`p`,{className:`p-4`,role:`alert`,children:[`Could not check current task state.`,` `,(0,F.jsx)(C,{className:`min-h-11`,onClick:()=>{c.refetch(),u.refetch()},children:`Retry`})]}),l.updates>0&&(0,F.jsxs)(C,{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,F.jsx)(vt,{row:u.data?.get(U(e))??e,removed:n&&!!u.data&&!u.data.has(U(e)),checking:!c.data||n&&!u.data,checkFailed:!c.data&&c.isError||n&&!u.data&&u.isError,queue:t===`needs-you`},U(e))),i<p&&(0,F.jsxs)(C,{className:`m-4 min-h-11`,disabled:c.isFetching,onClick:()=>a(e=>e+20),children:[`Show `,Math.min(20,p-i),` more tasks`]})]})}export{mr as DashboardRoute};
@@ -1,5 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,r as n,t as r}from"./react-runtime-CCIEwYL0.js";import{$n as i,Fa as a,Gr as o,Ji as s,Jn as c,M as l,Ma as u,N as d,Na as f,Pr as p,Qn as m,Ta as h,Vn as g,Wn as _,Xn as v,Yn as y,Zn as b,_r as x,dr as S,er as C,nn as w,qn as T,r as E,ta as D,wa as ee,wr as O}from"./queries-BTgOLNTK.js";import{B as te,F as k,Kt as ne,Lt as A,R as j,V as re,dt as M,ot as ie,pt as N,r as P,ut as F}from"./button-wdWSPx_B.js";import{f as I,s as L}from"./project-router-DgQSavhI.js";import{C as ae,a as R,o as oe,r as z}from"./reference-chip-BxUGeHDa.js";import{d as se,f as ce,h as le,l as B,m as ue,p as de,v as fe}from"./use-now-Byfm730u.js";import{t as pe}from"./check-DvAMBXJe.js";import{f as me}from"./tooltip-C2bzSwbQ.js";import{t as he}from"./clipboard-DQGL_gUp.js";var ge=e(n()),V=e(t(),1),H=new Map,_e=e=>({status:e.status,archived:e.archived,awaitingAnswerSince:e.awaitingAnswerSince}),U=new Map,ve=new Set,W=0;function ye(e,t){t?U.set(e,W+1):U.delete(e),W++,ve.forEach(e=>e())}function be(e,t){let n=`${e}:${typeof t==`string`?t:t.id}`;H.delete(n),H.set(n,{value:typeof t==`string`?null:_e(t),revision:W+1}),H.size>2e3&&H.delete(H.keys().next().value),W++,ve.forEach(e=>e())}function xe(e){return(0,V.useSyncExternalStore)(e=>(ve.add(e),()=>{ve.delete(e)}),()=>W),Ce(e.projectId,e.id)}var Se=()=>W,Ce=(e,t)=>U.has(e)?null:H.get(`${e}:${t}`)?.value;function we(e,t=[]){let n=new Map(t.map(e=>[`${e.projectId}:${e.id}`,e])),r=!1;for(let n of t){let t=U.get(n.projectId);t!==void 0&&t<=e&&(U.delete(n.projectId),r=!0)}for(let[t,i]of H){let a=n.get(t);i.revision>e||!a||(a.status!==void 0&&a.archived!==void 0?(H.set(t,{value:_e({status:a.status,archived:a.archived,awaitingAnswerSince:a.awaitingAnswerSince}),revision:W+1}),r=!0):i.value===null&&(H.delete(t),r=!0))}r&&(W++,ve.forEach(e=>e()))}function Te(e=()=>performance.now()){let t=new Map,n=new Set,r,i={connected:!1,samples:[]},a=()=>{i={...i,samples:[...t.values()].map(e=>e.sample)},n.forEach(e=>e())},o=()=>{let n=!1;for(let[r,i]of t)i.deadline<=e()&&(t.delete(r),n=!0);n&&a()};return{getSnapshot:()=>i,subscribe(e){return n.add(e),r||=setInterval(o,1e3),o(),()=>{n.delete(e),n.size||(clearInterval(r),r=void 0)}},expire:o,connected(e){i.connected!==e&&(i={...i,connected:e},a())},replace(n,r,i){for(let[e,r]of t)r.sample.projectId===n&&t.delete(e);let o=i?Date.parse(i):NaN;for(let i of r){let r=Math.max(0,o-Date.parse(i.sampledAt));Number.isFinite(r)&&r<1e4&&i.projectId===n&&t.set(`${n}:${i.runId}`,{sample:i,deadline:e()+1e4-r})}a()},seed(n,r){for(let[e,n]of t)Date.parse(n.sample.sampledAt)<=Date.parse(r)&&t.delete(e);for(let i of n){let n=Math.max(0,Date.parse(r)-Date.parse(i.sampledAt));Number.isFinite(n)&&n<1e4&&!t.has(`${i.projectId}:${i.runId}`)&&t.set(`${i.projectId}:${i.runId}`,{sample:i,deadline:e()+1e4-n})}a()},remove(e,n){for(let[r,i]of t)i.sample.projectId===e&&(!n||i.sample.runId===n)&&t.delete(r);a()}}}var G=Te(),Ee=()=>(0,V.useSyncExternalStore)(G.subscribe,G.getSnapshot);function De(e){return{enabled:(e&&typeof e==`object`?e:{}).enabled===!0}}function Oe(){let e=globalThis.Notification;if(typeof e!=`function`)return`unsupported`;let t=e.permission;return t===`granted`||t===`denied`?t:`default`}function ke(e,t){let n=new Map,r=[];for(let i of t??[]){n.set(i.id,i.status);let t=e.get(i.id);t===void 0||t===i.status||_(i)&&r.push(i)}return{entering:r,statuses:n}}function Ae(e){return e.enabled&&e.hidden&&e.permission===`granted`}function je(e){let t=g(e).label;return{title:e.titleSummary??e.title,body:`Task ${t}`,tag:`cezar-run-${e.id}`}}function Me(e){return Oe()===`granted`&&Ne(e)?!0:De(e.getQueryData(w.uiState)?.notifications).enabled&&Oe()===`granted`}function Ne(e){return Oe()===`granted`&&e.getQueryData(w.uiState)===void 0}var K=r(),Pe=`${j(`/workspace/events`)}?slim=1`,Fe=2,Ie=3e3,Le=[`run`,`run-deleted`,`todos`,`usage`,`ping`],Re=[`project-added`,`project-removed`,`checkout-progress`,`automation-change`,`tracker-changed`],ze=new Set;function Be(e){return ze.add(e),()=>{ze.delete(e)}}var Ve=400,He=15e3;function Ue(e){let t;return{onEvent(n){n.type!==`run`&&n.type!==`run-deleted`||t===void 0&&(t=setTimeout(()=>{t=void 0,e.invalidateQueries({queryKey:w.runsIndex})},Ve))},cancel(){clearTimeout(t),t=void 0}}}var We=[500,1500];function Ge(e){let t=new Set,n=new Map,r=new Set,i=!1,a=e=>{t.delete(e),n.delete(e)},s=(t,r,i)=>{let o=n.get(t);if(a(t),o?.kind===`deleted`){e.setQueryData(r,e=>c(e,i.id));return}e.setQueryData(r,e=>{let t=e!==void 0&&e.some(e=>e.id===i.id)?e:y(e,i);return o?.kind===`run`?y(t,o.frame):t})},l=(t,n,c,u,d)=>{o(c,u).then(e=>{i||s(t,n,e)}).catch(o=>{if(i)return;let s=We[d],f=o instanceof C&&o.status>=400&&o.status<500;if(s===void 0||f){a(t),s===void 0&&e.invalidateQueries({queryKey:n,refetchType:`active`});return}let p=setTimeout(()=>{r.delete(p),i||l(t,n,c,u,d+1)},s);r.add(p)})};return{run(e,r){if(i)return;let a=re(),o=`${a}\0${e}`;if(t.has(o)){n.set(o,{kind:`run`,frame:r});return}t.add(o),l(o,[a,`runs`,`list`],a,e,0)},deleted(e){if(i)return;let r=`${re()}\0${e}`;t.has(r)&&n.set(r,{kind:`deleted`})},cancel(){i=!0;for(let e of r)clearTimeout(e);r.clear(),t.clear(),n.clear()}}}function Ke(e,t){let n;for(let t of e.getQueryCache().getAll()){if(t.queryKey[1]!==`health`)continue;let e=t.state.data?.bootProject;if(typeof e==`string`){n=e;break}}let r=new Set([t]);return n===t&&r.add(`default`),[...r]}function qe(e){return[[`run-history`,e],[`run-history-context`,e],[`run-history-tail`,e]]}function Je(e){return[[e,`runs`],[e,`todos`],[e,`worktrees`],...qe(e)]}function Ye(e){if(e[0]!==`workspace`)return e[0]===`run-history`||e[0]===`run-history-context`||e[0]===`run-history-tail`?typeof e[1]==`string`?e[1]:void 0:typeof e[0]==`string`?e[0]:void 0}function Xe(e){return[...new Set(e.getQueryCache().getAll().map(({queryKey:e})=>Ye(e)).filter(e=>e!==void 0))]}function Ze(e){let t,n=new Set;return{onEvent(r){if(!(t!==void 0&&n.has(r))){for(let t of Ke(e,r))n.add(t);t===void 0&&(t=setTimeout(()=>{t=void 0;let r=n;n=new Set;let i=re();for(let t of r)for(let n of Je(t))e.invalidateQueries({queryKey:n,refetchType:t===i?`active`:`none`})},Ve))}},cancel(){clearTimeout(t),t=void 0,n.clear()}}}function Qe(e,t,n,r){let i=new Map,a,o=0,s=()=>{if(clearTimeout(a),a=void 0,o>0)return;let s=et(e),c=i;i=new Map;for(let i of c.values())i.project===s?tt(e,t,i.event,r):n(i.project)},c=()=>{a===void 0&&(a=setTimeout(s,50))};return{onEvent(e,t){let n=e.type===`run`?e.run.id:e.id;i.set(`${t}:${n}`,{event:e,project:t}),c()},beginReconcile(){s(),o+=1},endReconcile(){o!==0&&(--o,o===0&&s())},cancel(){clearTimeout(a),a=void 0,i.clear(),o=0}}}async function $e(e){let t=re(),n=[E.runs.all,w.runsIndex,w.dashboard,E.todos,E.health,E.worktrees,ae.all(),w.providerStatus,w.hostUsage,w.skillsUpdateAll,[`run-history`,t],[`run-history-context`,t]],r=Promise.allSettled([Promise.all([e.cancelQueries({queryKey:[`tracker`],predicate:e=>e.queryKey[2]!==`items`||e.getObserversCount()===0}),e.cancelQueries({queryKey:w.projects})]).then(()=>Promise.all([e.invalidateQueries({queryKey:[`tracker`],predicate:e=>e.queryKey[2]!==`items`||e.getObserversCount()===0}),e.invalidateQueries({queryKey:w.projects})])),e.invalidateQueries({queryKey:[`worktree-lifecycle`],refetchType:`none`}),...Xe(e).filter(e=>e!==t).flatMap(t=>Je(t).map(t=>e.invalidateQueries({queryKey:t,refetchType:`none`}))),...n.map(t=>e.invalidateQueries({queryKey:t}))]),i=!1,a;try{await Promise.race([r.then(()=>{i=!0}),new Promise(e=>{a=setTimeout(e,He)})])}finally{clearTimeout(a)}i||await Promise.allSettled(n.map(t=>e.cancelQueries({queryKey:t})))}function et(e){return te()??e.getQueryData(E.health)?.bootProject}function tt(e,t,n,r){switch(n.type){case`run`:{let t=E.runs.list(),i=e.getQueryData(t);i&&!b(n.run)&&!i.some(e=>e.id===n.run.id)?r.run(n.run.id,n.run):e.setQueryData(t,e=>y(e,n.run));let a=E.runs.detail(n.run.id);e.getQueryData(a)!==void 0&&e.setQueryData(a,e=>e===void 0?e:m(e,n.run));let o=E.runs.changes(n.run.id);e.getQueryData(o)!==void 0&&e.invalidateQueries({queryKey:o}),e.invalidateQueries({queryKey:E.worktrees});return}case`run-deleted`:r.deleted(n.id),e.setQueryData(E.runs.list(),e=>c(e,n.id)),e.removeQueries({queryKey:E.runs.detail(n.id)}),e.removeQueries({queryKey:E.runs.diff(n.id)}),e.invalidateQueries({queryKey:E.worktrees});return;case`todos`:e.setQueryData(E.todos,n.items);return;case`usage`:t.set(n.usage);return;case`ping`:return}}function nt(e,t=Pe){let n=a();(0,V.useEffect)(()=>{let r=globalThis.EventSource;if(typeof r!=`function`)return;let a=null,o,s,c=new Set,l=()=>{clearTimeout(o),clearTimeout(s),o=void 0,s=void 0;let e=et(n);for(let t of c){let r=t===e?re():t;n.invalidateQueries({queryKey:ae.all(r),refetchType:t===e?`active`:`none`}),t===e&&n.invalidateQueries({queryKey:E.worktrees})}c.clear()},u,d,f=()=>{clearTimeout(u),clearTimeout(d),u=void 0,d=void 0,n.invalidateQueries({queryKey:w.dashboard,refetchType:document.visibilityState===`hidden`?`none`:`active`,predicate:e=>e.queryKey[2]!==`telemetry`&&e.queryKey[2]!==`automations`&&!(e.queryKey[2]===`feed`&&e.queryKey[3]===`github`)})},p=()=>{clearTimeout(u),u=setTimeout(f,250),d??=setTimeout(f,1e3)},m=Ue(n),g=Ge(n),_=Ze(n),v=Qe(n,e,_.onEvent,g),y,b=!1,x=!1,S,C=!1,T=Date.now(),D,O=!1,te=!1,k=0,j=new Set,M=[],N=()=>{O=!0,te=!1;let e=w.providerStatus;n.cancelQueries({queryKey:e,exact:!0}).then(()=>n.invalidateQueries({queryKey:e,exact:!0,refetchType:`active`})).finally(()=>{if(C||!te){O=!1;return}N()})},P=e=>{let t=w.providerStatus,r=ee(n.getQueryData(t),e);if(r!==void 0){n.setQueryData(t,r);return}if(O){te=!0;return}N()},F=()=>{k+=1,v.beginReconcile(),$e(n).finally(()=>{--k,k===0&&(C?(j.clear(),M=[]):I()),v.endReconcile()})},I=()=>{let e=j,t=M;j=new Set,M=[];let r=et(n);for(let t of e)t===r?n.invalidateQueries({queryKey:E.todos}):_.onEvent(t);for(let e of t)P(e)},L=()=>{C||y!==void 0||(y=setTimeout(()=>{y=void 0,C||R()},Ie))},R=()=>{G.connected(!1),a?.close(),T=Date.now();let u=new r(t,{withCredentials:!0});a=u,u.addEventListener(`open`,()=>{C||a!==u||(T=Date.now(),clearTimeout(S),S=void 0,(b||x)&&F(),G.connected(!0),b=!0,x=!1)});for(let t of Le)u.addEventListener(t,r=>{if(C||a!==u)return;T=Date.now();let o=i(t,r.data);if(o){if(m.onEvent(o.event),(o.event.type===`run`||o.event.type===`run-deleted`)&&(p(),o.project&&be(o.project,o.event.type===`run-deleted`?o.event.id:o.event.run),o.project&&(o.event.type===`run-deleted`||o.event.run.status!==`running`)&&G.remove(o.project,o.event.type===`run-deleted`?o.event.id:o.event.run.id)),t===`usage`)try{let e=ie.safeParse(JSON.parse(r.data));e.success&&G.replace(e.data.project,e.data.samples??[],e.data.sentAt)}catch{}if(o.project!==null&&o.project!==et(n)){_.onEvent(o.project);return}o.event.type===`run`||o.event.type===`run-deleted`?o.project!==null&&v.onEvent(o.event,o.project):o.event.type===`todos`&&k>0?o.project!==null&&j.add(o.project):tt(n,e,o.event,g)}});u.addEventListener(`worktree-lifecycle`,e=>{if(C||a!==u)return;T=Date.now();let t;try{t=JSON.parse(e.data)}catch{return}let n=ne.safeParse(t);n.success&&(c.add(n.data.projectId),clearTimeout(o),o=setTimeout(l,100),s??=setTimeout(l,1e3))});for(let e of Re)u.addEventListener(e,t=>{if(C||a!==u)return;T=Date.now();let r;try{r=JSON.parse(t.data)}catch{return}if(e===`tracker-changed`){if(!A.safeParse(r).success)return;Promise.all([n.cancelQueries({queryKey:[`tracker`]}),n.cancelQueries({queryKey:w.projects})]).then(()=>Promise.all([n.invalidateQueries({queryKey:[`tracker`]}),n.invalidateQueries({queryKey:w.projects})]))}e!==`checkout-progress`&&e!==`automation-change`&&e!==`tracker-changed`&&(r&&typeof r==`object`&&(e===`project-removed`&&`id`in r&&typeof r.id==`string`?(ye(r.id,!0),G.remove(r.id)):e===`project-added`&&`project`in r&&r.project&&typeof r.project==`object`&&`id`in r.project&&typeof r.project.id==`string`&&ye(r.project.id,!1)),n.invalidateQueries({queryKey:w.projects}),n.invalidateQueries({queryKey:w.dashboard,refetchType:document.visibilityState===`hidden`?`none`:`active`}));for(let t of[...ze])t(e,r)});u.addEventListener(`provider-status`,e=>{if(C||a!==u)return;T=Date.now();let t;try{t=JSON.parse(e.data)}catch{return}let n=h(t);if(n){if(k>0){M.push(n);return}P(n)}}),u.addEventListener(`error`,()=>{C||a!==u||(G.connected(!1),u.readyState===Fe&&L())})},oe=()=>{x=!0,clearTimeout(S),S=setTimeout(()=>{S=void 0,!(C||!x)&&(x=!1,F())},He)},z,se=()=>{if(z=void 0,C||document.visibilityState!==`hidden`)return;if(Me(n)){Ne(n)&&(z=setTimeout(se,fe));return}clearTimeout(y),y=void 0;let e=a;a=null,G.connected(!1),e?.close()},ce=()=>{document.visibilityState===`hidden`&&(z??=setTimeout(se,fe))},le=()=>{if(document.visibilityState===`hidden`){ce();return}if(clearTimeout(z),z=void 0,!a||a.readyState===Fe){clearTimeout(y),y=void 0,oe(),R();return}F()},B=()=>{clearTimeout(y),y=void 0;let e=a;a=null,G.connected(!1),e?.close()},ue=e=>{e.persisted&&(oe(),R(),ce())};return D=setInterval(()=>{C||document.visibilityState!==`visible`||Date.now()-T<=4e4||(clearTimeout(y),y=void 0,R())},1e4),document.addEventListener(`visibilitychange`,le),window.addEventListener(`pagehide`,B),window.addEventListener(`pageshow`,ue),R(),ce(),()=>{C=!0,clearTimeout(y),clearTimeout(S),clearInterval(D),clearTimeout(z),G.connected(!1),clearTimeout(u),clearTimeout(d),clearTimeout(o),clearTimeout(s),c.clear(),m.cancel(),g.cancel(),_.cancel(),v.cancel(),j.clear(),M=[],document.removeEventListener(`visibilitychange`,le),window.removeEventListener(`pagehide`,B),window.removeEventListener(`pageshow`,ue);let e=a;a=null,G.connected(!1),e?.close()}},[n,e,t])}var rt=(0,V.createContext)(null);function it({children:e}){let[t]=(0,V.useState)(v);return nt(t),d(),(0,K.jsx)(rt.Provider,{value:t,children:e})}function at(e){let t=(0,V.useContext)(rt),n=t?t.get:st;return(0,V.useSyncExternalStore)(t?t.subscribe:ot,()=>e?n()[e]:void 0,()=>void 0)}var ot=()=>()=>void 0,st=()=>T,ct=k(`check-check`,[[`path`,{d:`M18 6 7 17l-5-5`,key:`116fxf`}],[`path`,{d:`m22 10-7.5 7.5L13 16`,key:`ke71qq`}]]),lt=k(`dollar-sign`,[[`line`,{x1:`12`,x2:`12`,y1:`2`,y2:`22`,key:`7eqyqh`}],[`path`,{d:`M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6`,key:`1b0p4s`}]]),ut=k(`layout-dashboard`,[[`rect`,{width:`7`,height:`9`,x:`3`,y:`3`,rx:`1`,key:`10lvy0`}],[`rect`,{width:`7`,height:`5`,x:`14`,y:`3`,rx:`1`,key:`16une8`}],[`rect`,{width:`7`,height:`9`,x:`14`,y:`12`,rx:`1`,key:`1hutg5`}],[`rect`,{width:`7`,height:`5`,x:`3`,y:`16`,rx:`1`,key:`ldoo1y`}]]),dt=k(`sliders-horizontal`,[[`path`,{d:`M10 5H3`,key:`1qgfaw`}],[`path`,{d:`M12 19H3`,key:`yhmn1j`}],[`path`,{d:`M14 3v4`,key:`1sua03`}],[`path`,{d:`M16 17v4`,key:`1q0r14`}],[`path`,{d:`M21 12h-9`,key:`1o4lsq`}],[`path`,{d:`M21 19h-5`,key:`1rlt1p`}],[`path`,{d:`M21 5h-7`,key:`1oszz2`}],[`path`,{d:`M8 10v4`,key:`tgpxqk`}],[`path`,{d:`M8 12H3`,key:`a7s4jb`}]]);function ft(){var e=[...arguments];return(0,V.useMemo)(()=>t=>{e.forEach(e=>e(t))},e)}var pt=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0;function mt(e){let t=Object.prototype.toString.call(e);return t===`[object Window]`||t===`[object global]`}function ht(e){return`nodeType`in e}function q(e){return e?mt(e)?e:ht(e)?e.ownerDocument?.defaultView??window:window:window}function gt(e){let{Document:t}=q(e);return e instanceof t}function _t(e){return!mt(e)&&e instanceof q(e).HTMLElement}function vt(e){return e instanceof q(e).SVGElement}function yt(e){return e?mt(e)?e.document:ht(e)?gt(e)?e:_t(e)||vt(e)?e.ownerDocument:document:document:document}var J=pt?V.useLayoutEffect:V.useEffect;function bt(e){let t=(0,V.useRef)(e);return J(()=>{t.current=e}),(0,V.useCallback)(function(){var e=[...arguments];return t.current==null?void 0:t.current(...e)},[])}function xt(){let e=(0,V.useRef)(null);return[(0,V.useCallback)((t,n)=>{e.current=setInterval(t,n)},[]),(0,V.useCallback)(()=>{e.current!==null&&(clearInterval(e.current),e.current=null)},[])]}function St(e,t){t===void 0&&(t=[e]);let n=(0,V.useRef)(e);return J(()=>{n.current!==e&&(n.current=e)},t),n}function Ct(e,t){let n=(0,V.useRef)();return(0,V.useMemo)(()=>{let t=e(n.current);return n.current=t,t},[...t])}function wt(e){let t=bt(e),n=(0,V.useRef)(null);return[n,(0,V.useCallback)(e=>{e!==n.current&&t?.(e,n.current),n.current=e},[])]}function Tt(e){let t=(0,V.useRef)();return(0,V.useEffect)(()=>{t.current=e},[e]),t.current}var Et={};function Dt(e,t){return(0,V.useMemo)(()=>{if(t)return t;let n=Et[e]==null?0:Et[e]+1;return Et[e]=n,e+`-`+n},[e,t])}function Ot(e){return function(t){return[...arguments].slice(1).reduce((t,n)=>{let r=Object.entries(n);for(let[n,i]of r){let r=t[n];r!=null&&(t[n]=r+e*i)}return t},{...t})}}var kt=Ot(1),At=Ot(-1);function jt(e){return`clientX`in e&&`clientY`in e}function Mt(e){if(!e)return!1;let{KeyboardEvent:t}=q(e.target);return t&&e instanceof t}function Nt(e){if(!e)return!1;let{TouchEvent:t}=q(e.target);return t&&e instanceof t}function Pt(e){if(Nt(e)){if(e.touches&&e.touches.length){let{clientX:t,clientY:n}=e.touches[0];return{x:t,y:n}}else if(e.changedTouches&&e.changedTouches.length){let{clientX:t,clientY:n}=e.changedTouches[0];return{x:t,y:n}}}return jt(e)?{x:e.clientX,y:e.clientY}:null}var Ft=Object.freeze({Translate:{toString(e){if(!e)return;let{x:t,y:n}=e;return`translate3d(`+(t?Math.round(t):0)+`px, `+(n?Math.round(n):0)+`px, 0)`}},Scale:{toString(e){if(!e)return;let{scaleX:t,scaleY:n}=e;return`scaleX(`+t+`) scaleY(`+n+`)`}},Transform:{toString(e){if(e)return[Ft.Translate.toString(e),Ft.Scale.toString(e)].join(` `)}},Transition:{toString(e){let{property:t,duration:n,easing:r}=e;return t+` `+n+`ms `+r}}}),It=`a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]`;function Lt(e){return e.matches(It)?e:e.querySelector(It)}var Rt={display:`none`};function zt(e){let{id:t,value:n}=e;return V.createElement(`div`,{id:t,style:Rt},n)}function Bt(e){let{id:t,announcement:n,ariaLiveType:r=`assertive`}=e;return V.createElement(`div`,{id:t,style:{position:`fixed`,top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:`hidden`,clip:`rect(0 0 0 0)`,clipPath:`inset(100%)`,whiteSpace:`nowrap`},role:`status`,"aria-live":r,"aria-atomic":!0},n)}function Vt(){let[e,t]=(0,V.useState)(``);return{announce:(0,V.useCallback)(e=>{e!=null&&t(e)},[]),announcement:e}}var Ht=(0,V.createContext)(null);function Ut(e){let t=(0,V.useContext)(Ht);(0,V.useEffect)(()=>{if(!t)throw Error(`useDndMonitor must be used within a children of <DndContext>`);return t(e)},[e,t])}function Wt(){let[e]=(0,V.useState)(()=>new Set),t=(0,V.useCallback)(t=>(e.add(t),()=>e.delete(t)),[e]);return[(0,V.useCallback)(t=>{let{type:n,event:r}=t;e.forEach(e=>e[n]?.call(e,r))},[e]),t]}var Gt={draggable:`
2
- To pick up a draggable item, press the space bar.
3
- While dragging, use the arrow keys to move the item.
4
- Press space again to drop the item in its new position, or press escape to cancel.
5
- `},Kt={onDragStart(e){let{active:t}=e;return`Picked up draggable item `+t.id+`.`},onDragOver(e){let{active:t,over:n}=e;return n?`Draggable item `+t.id+` was moved over droppable area `+n.id+`.`:`Draggable item `+t.id+` is no longer over a droppable area.`},onDragEnd(e){let{active:t,over:n}=e;return n?`Draggable item `+t.id+` was dropped over droppable area `+n.id:`Draggable item `+t.id+` was dropped.`},onDragCancel(e){let{active:t}=e;return`Dragging was cancelled. Draggable item `+t.id+` was dropped.`}};function qt(e){let{announcements:t=Kt,container:n,hiddenTextDescribedById:r,screenReaderInstructions:i=Gt}=e,{announce:a,announcement:o}=Vt(),s=Dt(`DndLiveRegion`),[c,l]=(0,V.useState)(!1);if((0,V.useEffect)(()=>{l(!0)},[]),Ut((0,V.useMemo)(()=>({onDragStart(e){let{active:n}=e;a(t.onDragStart({active:n}))},onDragMove(e){let{active:n,over:r}=e;t.onDragMove&&a(t.onDragMove({active:n,over:r}))},onDragOver(e){let{active:n,over:r}=e;a(t.onDragOver({active:n,over:r}))},onDragEnd(e){let{active:n,over:r}=e;a(t.onDragEnd({active:n,over:r}))},onDragCancel(e){let{active:n,over:r}=e;a(t.onDragCancel({active:n,over:r}))}}),[a,t])),!c)return null;let u=V.createElement(V.Fragment,null,V.createElement(zt,{id:r,value:i.draggable}),V.createElement(Bt,{id:s,announcement:o}));return n?(0,ge.createPortal)(u,n):u}var Y;(function(e){e.DragStart=`dragStart`,e.DragMove=`dragMove`,e.DragEnd=`dragEnd`,e.DragCancel=`dragCancel`,e.DragOver=`dragOver`,e.RegisterDroppable=`registerDroppable`,e.SetDroppableDisabled=`setDroppableDisabled`,e.UnregisterDroppable=`unregisterDroppable`})(Y||={});function Jt(){}function Yt(e,t){return(0,V.useMemo)(()=>({sensor:e,options:t??{}}),[e,t])}function Xt(){var e=[...arguments];return(0,V.useMemo)(()=>[...e].filter(e=>e!=null),[...e])}var X=Object.freeze({x:0,y:0});function Zt(e,t){return Math.sqrt((e.x-t.x)**2+(e.y-t.y)**2)}function Qt(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return n-r}function $t(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return r-n}function en(e){let{left:t,top:n,height:r,width:i}=e;return[{x:t,y:n},{x:t+i,y:n},{x:t,y:n+r},{x:t+i,y:n+r}]}function tn(e,t){if(!e||e.length===0)return null;let[n]=e;return t?n[t]:n}function nn(e,t,n){return t===void 0&&(t=e.left),n===void 0&&(n=e.top),{x:t+e.width*.5,y:n+e.height*.5}}var rn=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e,i=nn(t,t.left,t.top),a=[];for(let e of r){let{id:t}=e,r=n.get(t);if(r){let n=Zt(nn(r),i);a.push({id:t,data:{droppableContainer:e,value:n}})}}return a.sort(Qt)},an=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e,i=en(t),a=[];for(let e of r){let{id:t}=e,r=n.get(t);if(r){let n=en(r),o=i.reduce((e,t,r)=>e+Zt(n[r],t),0),s=Number((o/4).toFixed(4));a.push({id:t,data:{droppableContainer:e,value:s}})}}return a.sort(Qt)};function on(e,t){let n=Math.max(t.top,e.top),r=Math.max(t.left,e.left),i=Math.min(t.left+t.width,e.left+e.width),a=Math.min(t.top+t.height,e.top+e.height),o=i-r,s=a-n;if(r<i&&n<a){let n=t.width*t.height,r=e.width*e.height,i=o*s,a=i/(n+r-i);return Number(a.toFixed(4))}return 0}var sn=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e,i=[];for(let e of r){let{id:r}=e,a=n.get(r);if(a){let n=on(a,t);n>0&&i.push({id:r,data:{droppableContainer:e,value:n}})}}return i.sort($t)};function cn(e,t,n){return{...e,scaleX:t&&n?t.width/n.width:1,scaleY:t&&n?t.height/n.height:1}}function ln(e,t){return e&&t?{x:e.left-t.left,y:e.top-t.top}:X}function un(e){return function(t){return[...arguments].slice(1).reduce((t,n)=>({...t,top:t.top+e*n.y,bottom:t.bottom+e*n.y,left:t.left+e*n.x,right:t.right+e*n.x}),{...t})}}var dn=un(1);function fn(e){if(e.startsWith(`matrix3d(`)){let t=e.slice(9,-1).split(/, /);return{x:+t[12],y:+t[13],scaleX:+t[0],scaleY:+t[5]}}else if(e.startsWith(`matrix(`)){let t=e.slice(7,-1).split(/, /);return{x:+t[4],y:+t[5],scaleX:+t[0],scaleY:+t[3]}}return null}function pn(e,t,n){let r=fn(t);if(!r)return e;let{scaleX:i,scaleY:a,x:o,y:s}=r,c=e.left-o-(1-i)*parseFloat(n),l=e.top-s-(1-a)*parseFloat(n.slice(n.indexOf(` `)+1)),u=i?e.width/i:e.width,d=a?e.height/a:e.height;return{width:u,height:d,top:l,right:c+u,bottom:l+d,left:c}}var mn={ignoreTransform:!1};function hn(e,t){t===void 0&&(t=mn);let n=e.getBoundingClientRect();if(t.ignoreTransform){let{transform:t,transformOrigin:r}=q(e).getComputedStyle(e);t&&(n=pn(n,t,r))}let{top:r,left:i,width:a,height:o,bottom:s,right:c}=n;return{top:r,left:i,width:a,height:o,bottom:s,right:c}}function gn(e){return hn(e,{ignoreTransform:!0})}function _n(e){let t=e.innerWidth,n=e.innerHeight;return{top:0,left:0,right:t,bottom:n,width:t,height:n}}function vn(e,t){return t===void 0&&(t=q(e).getComputedStyle(e)),t.position===`fixed`}function yn(e,t){t===void 0&&(t=q(e).getComputedStyle(e));let n=/(auto|scroll|overlay)/;return[`overflow`,`overflowX`,`overflowY`].some(e=>{let r=t[e];return typeof r==`string`&&n.test(r)})}function bn(e,t){let n=[];function r(i){if(t!=null&&n.length>=t||!i)return n;if(gt(i)&&i.scrollingElement!=null&&!n.includes(i.scrollingElement))return n.push(i.scrollingElement),n;if(!_t(i)||vt(i)||n.includes(i))return n;let a=q(e).getComputedStyle(i);return i!==e&&yn(i,a)&&n.push(i),vn(i,a)?n:r(i.parentNode)}return e?r(e):n}function xn(e){let[t]=bn(e,1);return t??null}function Sn(e){return!pt||!e?null:mt(e)?e:ht(e)?gt(e)||e===yt(e).scrollingElement?window:_t(e)?e:null:null}function Cn(e){return mt(e)?e.scrollX:e.scrollLeft}function wn(e){return mt(e)?e.scrollY:e.scrollTop}function Tn(e){return{x:Cn(e),y:wn(e)}}var Z;(function(e){e[e.Forward=1]=`Forward`,e[e.Backward=-1]=`Backward`})(Z||={});function En(e){return!pt||!e?!1:e===document.scrollingElement}function Dn(e){let t={x:0,y:0},n=En(e)?{height:window.innerHeight,width:window.innerWidth}:{height:e.clientHeight,width:e.clientWidth},r={x:e.scrollWidth-n.width,y:e.scrollHeight-n.height};return{isTop:e.scrollTop<=t.y,isLeft:e.scrollLeft<=t.x,isBottom:e.scrollTop>=r.y,isRight:e.scrollLeft>=r.x,maxScroll:r,minScroll:t}}var On={x:.2,y:.2};function kn(e,t,n,r,i){let{top:a,left:o,right:s,bottom:c}=n;r===void 0&&(r=10),i===void 0&&(i=On);let{isTop:l,isBottom:u,isLeft:d,isRight:f}=Dn(e),p={x:0,y:0},m={x:0,y:0},h={height:t.height*i.y,width:t.width*i.x};return!l&&a<=t.top+h.height?(p.y=Z.Backward,m.y=r*Math.abs((t.top+h.height-a)/h.height)):!u&&c>=t.bottom-h.height&&(p.y=Z.Forward,m.y=r*Math.abs((t.bottom-h.height-c)/h.height)),!f&&s>=t.right-h.width?(p.x=Z.Forward,m.x=r*Math.abs((t.right-h.width-s)/h.width)):!d&&o<=t.left+h.width&&(p.x=Z.Backward,m.x=r*Math.abs((t.left+h.width-o)/h.width)),{direction:p,speed:m}}function An(e){if(e===document.scrollingElement){let{innerWidth:e,innerHeight:t}=window;return{top:0,left:0,right:e,bottom:t,width:e,height:t}}let{top:t,left:n,right:r,bottom:i}=e.getBoundingClientRect();return{top:t,left:n,right:r,bottom:i,width:e.clientWidth,height:e.clientHeight}}function jn(e){return e.reduce((e,t)=>kt(e,Tn(t)),X)}function Mn(e){return e.reduce((e,t)=>e+Cn(t),0)}function Nn(e){return e.reduce((e,t)=>e+wn(t),0)}function Pn(e,t){if(t===void 0&&(t=hn),!e)return;let{top:n,left:r,bottom:i,right:a}=t(e);xn(e)&&(i<=0||a<=0||n>=window.innerHeight||r>=window.innerWidth)&&e.scrollIntoView({block:`center`,inline:`center`})}var Fn=[[`x`,[`left`,`right`],Mn],[`y`,[`top`,`bottom`],Nn]],In=class{constructor(e,t){this.rect=void 0,this.width=void 0,this.height=void 0,this.top=void 0,this.bottom=void 0,this.right=void 0,this.left=void 0;let n=bn(t),r=jn(n);this.rect={...e},this.width=e.width,this.height=e.height;for(let[e,t,i]of Fn)for(let a of t)Object.defineProperty(this,a,{get:()=>{let t=i(n),o=r[e]-t;return this.rect[a]+o},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}},Ln=class{constructor(e){this.target=void 0,this.listeners=[],this.removeAll=()=>{this.listeners.forEach(e=>this.target?.removeEventListener(...e))},this.target=e}add(e,t,n){var r;(r=this.target)==null||r.addEventListener(e,t,n),this.listeners.push([e,t,n])}};function Rn(e){let{EventTarget:t}=q(e);return e instanceof t?e:yt(e)}function zn(e,t){let n=Math.abs(e.x),r=Math.abs(e.y);return typeof t==`number`?Math.sqrt(n**2+r**2)>t:`x`in t&&`y`in t?n>t.x&&r>t.y:`x`in t?n>t.x:`y`in t&&r>t.y}var Q;(function(e){e.Click=`click`,e.DragStart=`dragstart`,e.Keydown=`keydown`,e.ContextMenu=`contextmenu`,e.Resize=`resize`,e.SelectionChange=`selectionchange`,e.VisibilityChange=`visibilitychange`})(Q||={});function Bn(e){e.preventDefault()}function Vn(e){e.stopPropagation()}var $;(function(e){e.Space=`Space`,e.Down=`ArrowDown`,e.Right=`ArrowRight`,e.Left=`ArrowLeft`,e.Up=`ArrowUp`,e.Esc=`Escape`,e.Enter=`Enter`,e.Tab=`Tab`})($||={});var Hn={start:[$.Space,$.Enter],cancel:[$.Esc],end:[$.Space,$.Enter,$.Tab]},Un=(e,t)=>{let{currentCoordinates:n}=t;switch(e.code){case $.Right:return{...n,x:n.x+25};case $.Left:return{...n,x:n.x-25};case $.Down:return{...n,y:n.y+25};case $.Up:return{...n,y:n.y-25}}},Wn=class{constructor(e){this.props=void 0,this.autoScrollEnabled=!1,this.referenceCoordinates=void 0,this.listeners=void 0,this.windowListeners=void 0,this.props=e;let{event:{target:t}}=e;this.props=e,this.listeners=new Ln(yt(t)),this.windowListeners=new Ln(q(t)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(Q.Resize,this.handleCancel),this.windowListeners.add(Q.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(Q.Keydown,this.handleKeyDown))}handleStart(){let{activeNode:e,onStart:t}=this.props,n=e.node.current;n&&Pn(n),t(X)}handleKeyDown(e){if(Mt(e)){let{active:t,context:n,options:r}=this.props,{keyboardCodes:i=Hn,coordinateGetter:a=Un,scrollBehavior:o=`smooth`}=r,{code:s}=e;if(i.end.includes(s)){this.handleEnd(e);return}if(i.cancel.includes(s)){this.handleCancel(e);return}let{collisionRect:c}=n.current,l=c?{x:c.left,y:c.top}:X;this.referenceCoordinates||=l;let u=a(e,{active:t,context:n.current,currentCoordinates:l});if(u){let t=At(u,l),r={x:0,y:0},{scrollableAncestors:i}=n.current;for(let n of i){let i=e.code,{isTop:a,isRight:s,isLeft:c,isBottom:l,maxScroll:d,minScroll:f}=Dn(n),p=An(n),m={x:Math.min(i===$.Right?p.right-p.width/2:p.right,Math.max(i===$.Right?p.left:p.left+p.width/2,u.x)),y:Math.min(i===$.Down?p.bottom-p.height/2:p.bottom,Math.max(i===$.Down?p.top:p.top+p.height/2,u.y))},h=i===$.Right&&!s||i===$.Left&&!c,g=i===$.Down&&!l||i===$.Up&&!a;if(h&&m.x!==u.x){let e=n.scrollLeft+t.x,a=i===$.Right&&e<=d.x||i===$.Left&&e>=f.x;if(a&&!t.y){n.scrollTo({left:e,behavior:o});return}a?r.x=n.scrollLeft-e:r.x=i===$.Right?n.scrollLeft-d.x:n.scrollLeft-f.x,r.x&&n.scrollBy({left:-r.x,behavior:o});break}else if(g&&m.y!==u.y){let e=n.scrollTop+t.y,a=i===$.Down&&e<=d.y||i===$.Up&&e>=f.y;if(a&&!t.x){n.scrollTo({top:e,behavior:o});return}a?r.y=n.scrollTop-e:r.y=i===$.Down?n.scrollTop-d.y:n.scrollTop-f.y,r.y&&n.scrollBy({top:-r.y,behavior:o});break}}this.handleMove(e,kt(At(u,this.referenceCoordinates),r))}}}handleMove(e,t){let{onMove:n}=this.props;e.preventDefault(),n(t)}handleEnd(e){let{onEnd:t}=this.props;e.preventDefault(),this.detach(),t()}handleCancel(e){let{onCancel:t}=this.props;e.preventDefault(),this.detach(),t()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}};Wn.activators=[{eventName:`onKeyDown`,handler:(e,t,n)=>{let{keyboardCodes:r=Hn,onActivation:i}=t,{active:a}=n,{code:o}=e.nativeEvent;if(r.start.includes(o)){let t=a.activatorNode.current;return t&&e.target!==t?!1:(e.preventDefault(),i?.({event:e.nativeEvent}),!0)}return!1}}];function Gn(e){return!!(e&&`distance`in e)}function Kn(e){return!!(e&&`delay`in e)}var qn=class{constructor(e,t,n){n===void 0&&(n=Rn(e.event.target)),this.props=void 0,this.events=void 0,this.autoScrollEnabled=!0,this.document=void 0,this.activated=!1,this.initialCoordinates=void 0,this.timeoutId=null,this.listeners=void 0,this.documentListeners=void 0,this.windowListeners=void 0,this.props=e,this.events=t;let{event:r}=e,{target:i}=r;this.props=e,this.events=t,this.document=yt(i),this.documentListeners=new Ln(this.document),this.listeners=new Ln(n),this.windowListeners=new Ln(q(i)),this.initialCoordinates=Pt(r)??X,this.handleStart=this.handleStart.bind(this),this.handleMove=this.handleMove.bind(this),this.handleEnd=this.handleEnd.bind(this),this.handleCancel=this.handleCancel.bind(this),this.handleKeydown=this.handleKeydown.bind(this),this.removeTextSelection=this.removeTextSelection.bind(this),this.attach()}attach(){let{events:e,props:{options:{activationConstraint:t,bypassActivationConstraint:n}}}=this;if(this.listeners.add(e.move.name,this.handleMove,{passive:!1}),this.listeners.add(e.end.name,this.handleEnd),e.cancel&&this.listeners.add(e.cancel.name,this.handleCancel),this.windowListeners.add(Q.Resize,this.handleCancel),this.windowListeners.add(Q.DragStart,Bn),this.windowListeners.add(Q.VisibilityChange,this.handleCancel),this.windowListeners.add(Q.ContextMenu,Bn),this.documentListeners.add(Q.Keydown,this.handleKeydown),t){if(n!=null&&n({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(Kn(t)){this.timeoutId=setTimeout(this.handleStart,t.delay),this.handlePending(t);return}if(Gn(t)){this.handlePending(t);return}}this.handleStart()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll(),setTimeout(this.documentListeners.removeAll,50),this.timeoutId!==null&&(clearTimeout(this.timeoutId),this.timeoutId=null)}handlePending(e,t){let{active:n,onPending:r}=this.props;r(n,e,this.initialCoordinates,t)}handleStart(){let{initialCoordinates:e}=this,{onStart:t}=this.props;e&&(this.activated=!0,this.documentListeners.add(Q.Click,Vn,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(Q.SelectionChange,this.removeTextSelection),t(e))}handleMove(e){let{activated:t,initialCoordinates:n,props:r}=this,{onMove:i,options:{activationConstraint:a}}=r;if(!n)return;let o=Pt(e)??X,s=At(n,o);if(!t&&a){if(Gn(a)){if(a.tolerance!=null&&zn(s,a.tolerance))return this.handleCancel();if(zn(s,a.distance))return this.handleStart()}if(Kn(a)&&zn(s,a.tolerance))return this.handleCancel();this.handlePending(a,s);return}e.cancelable&&e.preventDefault(),i(o)}handleEnd(){let{onAbort:e,onEnd:t}=this.props;this.detach(),this.activated||e(this.props.active),t()}handleCancel(){let{onAbort:e,onCancel:t}=this.props;this.detach(),this.activated||e(this.props.active),t()}handleKeydown(e){e.code===$.Esc&&this.handleCancel()}removeTextSelection(){var e;(e=this.document.getSelection())==null||e.removeAllRanges()}},Jn={cancel:{name:`pointercancel`},move:{name:`pointermove`},end:{name:`pointerup`}},Yn=class extends qn{constructor(e){let{event:t}=e,n=yt(t.target);super(e,Jn,n)}};Yn.activators=[{eventName:`onPointerDown`,handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return!n.isPrimary||n.button!==0?!1:(r?.({event:n}),!0)}}];var Xn={move:{name:`mousemove`},end:{name:`mouseup`}},Zn;(function(e){e[e.RightClick=2]=`RightClick`})(Zn||={});var Qn=class extends qn{constructor(e){super(e,Xn,yt(e.event.target))}};Qn.activators=[{eventName:`onMouseDown`,handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return n.button===Zn.RightClick?!1:(r?.({event:n}),!0)}}];var $n={cancel:{name:`touchcancel`},move:{name:`touchmove`},end:{name:`touchend`}},er=class extends qn{constructor(e){super(e,$n)}static setup(){return window.addEventListener($n.move.name,e,{capture:!1,passive:!1}),function(){window.removeEventListener($n.move.name,e)};function e(){}}};er.activators=[{eventName:`onTouchStart`,handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t,{touches:i}=n;return i.length>1?!1:(r?.({event:n}),!0)}}];var tr;(function(e){e[e.Pointer=0]=`Pointer`,e[e.DraggableRect=1]=`DraggableRect`})(tr||={});var nr;(function(e){e[e.TreeOrder=0]=`TreeOrder`,e[e.ReversedTreeOrder=1]=`ReversedTreeOrder`})(nr||={});function rr(e){let{acceleration:t,activator:n=tr.Pointer,canScroll:r,draggingRect:i,enabled:a,interval:o=5,order:s=nr.TreeOrder,pointerCoordinates:c,scrollableAncestors:l,scrollableAncestorRects:u,delta:d,threshold:f}=e,p=ar({delta:d,disabled:!a}),[m,h]=xt(),g=(0,V.useRef)({x:0,y:0}),_=(0,V.useRef)({x:0,y:0}),v=(0,V.useMemo)(()=>{switch(n){case tr.Pointer:return c?{top:c.y,bottom:c.y,left:c.x,right:c.x}:null;case tr.DraggableRect:return i}},[n,i,c]),y=(0,V.useRef)(null),b=(0,V.useCallback)(()=>{let e=y.current;if(!e)return;let t=g.current.x*_.current.x,n=g.current.y*_.current.y;e.scrollBy(t,n)},[]),x=(0,V.useMemo)(()=>s===nr.TreeOrder?[...l].reverse():l,[s,l]);(0,V.useEffect)(()=>{if(!a||!l.length||!v){h();return}for(let e of x){if(r?.(e)===!1)continue;let n=l.indexOf(e),i=u[n];if(!i)continue;let{direction:a,speed:s}=kn(e,i,v,t,f);for(let e of[`x`,`y`])p[e][a[e]]||(s[e]=0,a[e]=0);if(s.x>0||s.y>0){h(),y.current=e,m(b,o),g.current=s,_.current=a;return}}g.current={x:0,y:0},_.current={x:0,y:0},h()},[t,b,r,h,a,o,JSON.stringify(v),JSON.stringify(p),m,l,x,u,JSON.stringify(f)])}var ir={x:{[Z.Backward]:!1,[Z.Forward]:!1},y:{[Z.Backward]:!1,[Z.Forward]:!1}};function ar(e){let{delta:t,disabled:n}=e,r=Tt(t);return Ct(e=>{if(n||!r||!e)return ir;let i={x:Math.sign(t.x-r.x),y:Math.sign(t.y-r.y)};return{x:{[Z.Backward]:e.x[Z.Backward]||i.x===-1,[Z.Forward]:e.x[Z.Forward]||i.x===1},y:{[Z.Backward]:e.y[Z.Backward]||i.y===-1,[Z.Forward]:e.y[Z.Forward]||i.y===1}}},[n,t,r])}function or(e,t){let n=t==null?void 0:e.get(t),r=n?n.node.current:null;return Ct(e=>t==null?null:r??e??null,[r,t])}function sr(e,t){return(0,V.useMemo)(()=>e.reduce((e,n)=>{let{sensor:r}=n,i=r.activators.map(e=>({eventName:e.eventName,handler:t(e.handler,n)}));return[...e,...i]},[]),[e,t])}var cr;(function(e){e[e.Always=0]=`Always`,e[e.BeforeDragging=1]=`BeforeDragging`,e[e.WhileDragging=2]=`WhileDragging`})(cr||={});var lr;(function(e){e.Optimized=`optimized`})(lr||={});var ur=new Map;function dr(e,t){let{dragging:n,dependencies:r,config:i}=t,[a,o]=(0,V.useState)(null),{frequency:s,measure:c,strategy:l}=i,u=(0,V.useRef)(e),d=g(),f=St(d),p=(0,V.useCallback)(function(e){e===void 0&&(e=[]),!f.current&&o(t=>t===null?e:t.concat(e.filter(e=>!t.includes(e))))},[f]),m=(0,V.useRef)(null),h=Ct(t=>{if(d&&!n)return ur;if(!t||t===ur||u.current!==e||a!=null){let t=new Map;for(let n of e){if(!n)continue;if(a&&a.length>0&&!a.includes(n.id)&&n.rect.current){t.set(n.id,n.rect.current);continue}let e=n.node.current,r=e?new In(c(e),e):null;n.rect.current=r,r&&t.set(n.id,r)}return t}return t},[e,a,n,d,c]);return(0,V.useEffect)(()=>{u.current=e},[e]),(0,V.useEffect)(()=>{d||p()},[n,d]),(0,V.useEffect)(()=>{a&&a.length>0&&o(null)},[JSON.stringify(a)]),(0,V.useEffect)(()=>{d||typeof s!=`number`||m.current!==null||(m.current=setTimeout(()=>{p(),m.current=null},s))},[s,d,p,...r]),{droppableRects:h,measureDroppableContainers:p,measuringScheduled:a!=null};function g(){switch(l){case cr.Always:return!1;case cr.BeforeDragging:return n;default:return!n}}}function fr(e,t){return Ct(n=>e?n||(typeof t==`function`?t(e):e):null,[t,e])}function pr(e,t){return fr(e,t)}function mr(e){let{callback:t,disabled:n}=e,r=bt(t),i=(0,V.useMemo)(()=>{if(n||typeof window>`u`||window.MutationObserver===void 0)return;let{MutationObserver:e}=window;return new e(r)},[r,n]);return(0,V.useEffect)(()=>()=>i?.disconnect(),[i]),i}function hr(e){let{callback:t,disabled:n}=e,r=bt(t),i=(0,V.useMemo)(()=>{if(n||typeof window>`u`||window.ResizeObserver===void 0)return;let{ResizeObserver:e}=window;return new e(r)},[n]);return(0,V.useEffect)(()=>()=>i?.disconnect(),[i]),i}function gr(e){return new In(hn(e),e)}function _r(e,t,n){t===void 0&&(t=gr);let[r,i]=(0,V.useState)(null);function a(){i(r=>{if(!e)return null;if(e.isConnected===!1)return r??n??null;let i=t(e);return JSON.stringify(r)===JSON.stringify(i)?r:i})}let o=mr({callback(t){if(e)for(let n of t){let{type:t,target:r}=n;if(t===`childList`&&r instanceof HTMLElement&&r.contains(e)){a();break}}}}),s=hr({callback:a});return J(()=>{a(),e?(s?.observe(e),o?.observe(document.body,{childList:!0,subtree:!0})):(s?.disconnect(),o?.disconnect())},[e]),r}function vr(e){return ln(e,fr(e))}var yr=[];function br(e){let t=(0,V.useRef)(e),n=Ct(n=>e?n&&n!==yr&&e&&t.current&&e.parentNode===t.current.parentNode?n:bn(e):yr,[e]);return(0,V.useEffect)(()=>{t.current=e},[e]),n}function xr(e){let[t,n]=(0,V.useState)(null),r=(0,V.useRef)(e),i=(0,V.useCallback)(e=>{let t=Sn(e.target);t&&n(e=>e?(e.set(t,Tn(t)),new Map(e)):null)},[]);return(0,V.useEffect)(()=>{let t=r.current;if(e!==t){a(t);let o=e.map(e=>{let t=Sn(e);return t?(t.addEventListener(`scroll`,i,{passive:!0}),[t,Tn(t)]):null}).filter(e=>e!=null);n(o.length?new Map(o):null),r.current=e}return()=>{a(e),a(t)};function a(e){e.forEach(e=>{Sn(e)?.removeEventListener(`scroll`,i)})}},[i,e]),(0,V.useMemo)(()=>e.length?t?Array.from(t.values()).reduce((e,t)=>kt(e,t),X):jn(e):X,[e,t])}function Sr(e,t){t===void 0&&(t=[]);let n=(0,V.useRef)(null);return(0,V.useEffect)(()=>{n.current=null},t),(0,V.useEffect)(()=>{let t=e!==X;t&&!n.current&&(n.current=e),!t&&n.current&&(n.current=null)},[e]),n.current?At(e,n.current):X}function Cr(e){(0,V.useEffect)(()=>{if(!pt)return;let t=e.map(e=>{let{sensor:t}=e;return t.setup==null?void 0:t.setup()});return()=>{for(let e of t)e?.()}},e.map(e=>{let{sensor:t}=e;return t}))}function wr(e,t){return(0,V.useMemo)(()=>e.reduce((e,n)=>{let{eventName:r,handler:i}=n;return e[r]=e=>{i(e,t)},e},{}),[e,t])}function Tr(e){return(0,V.useMemo)(()=>e?_n(e):null,[e])}var Er=[];function Dr(e,t){t===void 0&&(t=hn);let[n]=e,r=Tr(n?q(n):null),[i,a]=(0,V.useState)(Er);function o(){a(()=>e.length?e.map(e=>En(e)?r:new In(t(e),e)):Er)}let s=hr({callback:o});return J(()=>{s?.disconnect(),o(),e.forEach(e=>s?.observe(e))},[e]),i}function Or(e){if(!e)return null;if(e.children.length>1)return e;let t=e.children[0];return _t(t)?t:e}function kr(e){let{measure:t}=e,[n,r]=(0,V.useState)(null),i=hr({callback:(0,V.useCallback)(e=>{for(let{target:n}of e)if(_t(n)){r(e=>{let r=t(n);return e?{...e,width:r.width,height:r.height}:r});break}},[t])}),[a,o]=wt((0,V.useCallback)(e=>{let n=Or(e);i?.disconnect(),n&&i?.observe(n),r(n?t(n):null)},[t,i]));return(0,V.useMemo)(()=>({nodeRef:a,rect:n,setRef:o}),[n,a,o])}var Ar=[{sensor:Yn,options:{}},{sensor:Wn,options:{}}],jr={current:{}},Mr={draggable:{measure:gn},droppable:{measure:gn,strategy:cr.WhileDragging,frequency:lr.Optimized},dragOverlay:{measure:hn}},Nr=class extends Map{get(e){return e==null?void 0:super.get(e)??void 0}toArray(){return Array.from(this.values())}getEnabled(){return this.toArray().filter(e=>{let{disabled:t}=e;return!t})}getNodeFor(e){return this.get(e)?.node.current??void 0}},Pr={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new Nr,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:Jt},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:Mr,measureDroppableContainers:Jt,windowRect:null,measuringScheduled:!1},Fr={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:``},dispatch:Jt,draggableNodes:new Map,over:null,measureDroppableContainers:Jt},Ir=(0,V.createContext)(Fr),Lr=(0,V.createContext)(Pr);function Rr(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new Nr}}}function zr(e,t){switch(t.type){case Y.DragStart:return{...e,draggable:{...e.draggable,initialCoordinates:t.initialCoordinates,active:t.active}};case Y.DragMove:return e.draggable.active==null?e:{...e,draggable:{...e.draggable,translate:{x:t.coordinates.x-e.draggable.initialCoordinates.x,y:t.coordinates.y-e.draggable.initialCoordinates.y}}};case Y.DragEnd:case Y.DragCancel:return{...e,draggable:{...e.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case Y.RegisterDroppable:{let{element:n}=t,{id:r}=n,i=new Nr(e.droppable.containers);return i.set(r,n),{...e,droppable:{...e.droppable,containers:i}}}case Y.SetDroppableDisabled:{let{id:n,key:r,disabled:i}=t,a=e.droppable.containers.get(n);if(!a||r!==a.key)return e;let o=new Nr(e.droppable.containers);return o.set(n,{...a,disabled:i}),{...e,droppable:{...e.droppable,containers:o}}}case Y.UnregisterDroppable:{let{id:n,key:r}=t,i=e.droppable.containers.get(n);if(!i||r!==i.key)return e;let a=new Nr(e.droppable.containers);return a.delete(n),{...e,droppable:{...e.droppable,containers:a}}}default:return e}}function Br(e){let{disabled:t}=e,{active:n,activatorEvent:r,draggableNodes:i}=(0,V.useContext)(Ir),a=Tt(r),o=Tt(n?.id);return(0,V.useEffect)(()=>{if(!t&&!r&&a&&o!=null){if(!Mt(a)||document.activeElement===a.target)return;let e=i.get(o);if(!e)return;let{activatorNode:t,node:n}=e;if(!t.current&&!n.current)return;requestAnimationFrame(()=>{for(let e of[t.current,n.current]){if(!e)continue;let t=Lt(e);if(t){t.focus();break}}})}},[r,t,i,o,a]),null}function Vr(e,t){let{transform:n,...r}=t;return e!=null&&e.length?e.reduce((e,t)=>t({transform:e,...r}),n):n}function Hr(e){return(0,V.useMemo)(()=>({draggable:{...Mr.draggable,...e?.draggable},droppable:{...Mr.droppable,...e?.droppable},dragOverlay:{...Mr.dragOverlay,...e?.dragOverlay}}),[e?.draggable,e?.droppable,e?.dragOverlay])}function Ur(e){let{activeNode:t,measure:n,initialRect:r,config:i=!0}=e,a=(0,V.useRef)(!1),{x:o,y:s}=typeof i==`boolean`?{x:i,y:i}:i;J(()=>{if(!o&&!s||!t){a.current=!1;return}if(a.current||!r)return;let e=t?.node.current;if(!e||e.isConnected===!1)return;let i=ln(n(e),r);if(o||(i.x=0),s||(i.y=0),a.current=!0,Math.abs(i.x)>0||Math.abs(i.y)>0){let t=xn(e);t&&t.scrollBy({top:i.y,left:i.x})}},[t,o,s,r,n])}var Wr=(0,V.createContext)({...X,scaleX:1,scaleY:1}),Gr;(function(e){e[e.Uninitialized=0]=`Uninitialized`,e[e.Initializing=1]=`Initializing`,e[e.Initialized=2]=`Initialized`})(Gr||={});var Kr=(0,V.memo)(function(e){let{id:t,accessibility:n,autoScroll:r=!0,children:i,sensors:a=Ar,collisionDetection:o=sn,measuring:s,modifiers:c,...l}=e,[u,d]=(0,V.useReducer)(zr,void 0,Rr),[f,p]=Wt(),[m,h]=(0,V.useState)(Gr.Uninitialized),g=m===Gr.Initialized,{draggable:{active:_,nodes:v,translate:y},droppable:{containers:b}}=u,x=_==null?null:v.get(_),S=(0,V.useRef)({initial:null,translated:null}),C=(0,V.useMemo)(()=>_==null?null:{id:_,data:x?.data??jr,rect:S},[_,x]),w=(0,V.useRef)(null),[T,E]=(0,V.useState)(null),[D,ee]=(0,V.useState)(null),O=St(l,Object.values(l)),te=Dt(`DndDescribedBy`,t),k=(0,V.useMemo)(()=>b.getEnabled(),[b]),ne=Hr(s),{droppableRects:A,measureDroppableContainers:j,measuringScheduled:re}=dr(k,{dragging:g,dependencies:[y.x,y.y],config:ne.droppable}),M=or(v,_),ie=(0,V.useMemo)(()=>D?Pt(D):null,[D]),N=G(),P=pr(M,ne.draggable.measure);Ur({activeNode:_==null?null:v.get(_),config:N.layoutShiftCompensation,initialRect:P,measure:ne.draggable.measure});let F=_r(M,ne.draggable.measure,P),I=_r(M?M.parentElement:null),L=(0,V.useRef)({activatorEvent:null,active:null,activeNode:M,collisionRect:null,collisions:null,droppableRects:A,draggableNodes:v,draggingNode:null,draggingNodeRect:null,droppableContainers:b,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),ae=b.getNodeFor(L.current.over?.id),R=kr({measure:ne.dragOverlay.measure}),oe=R.nodeRef.current??M,z=g?R.rect??F:null,se=!!(R.nodeRef.current&&R.rect),ce=vr(se?null:F),le=Tr(oe?q(oe):null),B=br(g?ae??M:null),ue=Dr(B),de=Vr(c,{transform:{x:y.x-ce.x,y:y.y-ce.y,scaleX:1,scaleY:1},activatorEvent:D,active:C,activeNodeRect:F,containerNodeRect:I,draggingNodeRect:z,over:L.current.over,overlayNodeRect:R.rect,scrollableAncestors:B,scrollableAncestorRects:ue,windowRect:le}),fe=ie?kt(ie,y):null,pe=xr(B),me=Sr(pe),he=Sr(pe,[F]),H=kt(de,me),_e=z?dn(z,de):null,U=C&&_e?o({active:C,collisionRect:_e,droppableRects:A,droppableContainers:k,pointerCoordinates:fe}):null,ve=tn(U,`id`),[W,ye]=(0,V.useState)(null),be=cn(se?de:kt(de,he),W?.rect??null,F),xe=(0,V.useRef)(null),Se=(0,V.useCallback)((e,t)=>{let{sensor:n,options:r}=t;if(w.current==null)return;let i=v.get(w.current);if(!i)return;let a=e.nativeEvent,o=new n({active:w.current,activeNode:i,event:a,options:r,context:L,onAbort(e){if(!v.get(e))return;let{onDragAbort:t}=O.current,n={id:e};t?.(n),f({type:`onDragAbort`,event:n})},onPending(e,t,n,r){if(!v.get(e))return;let{onDragPending:i}=O.current,a={id:e,constraint:t,initialCoordinates:n,offset:r};i?.(a),f({type:`onDragPending`,event:a})},onStart(e){let t=w.current;if(t==null)return;let n=v.get(t);if(!n)return;let{onDragStart:r}=O.current,i={activatorEvent:a,active:{id:t,data:n.data,rect:S}};(0,ge.unstable_batchedUpdates)(()=>{r?.(i),h(Gr.Initializing),d({type:Y.DragStart,initialCoordinates:e,active:t}),f({type:`onDragStart`,event:i}),E(xe.current),ee(a)})},onMove(e){d({type:Y.DragMove,coordinates:e})},onEnd:s(Y.DragEnd),onCancel:s(Y.DragCancel)});xe.current=o;function s(e){return async function(){let{active:t,collisions:n,over:r,scrollAdjustedTranslate:i}=L.current,o=null;if(t&&i){let{cancelDrop:s}=O.current;o={activatorEvent:a,active:t,collisions:n,delta:i,over:r},e===Y.DragEnd&&typeof s==`function`&&await Promise.resolve(s(o))&&(e=Y.DragCancel)}w.current=null,(0,ge.unstable_batchedUpdates)(()=>{d({type:e}),h(Gr.Uninitialized),ye(null),E(null),ee(null),xe.current=null;let t=e===Y.DragEnd?`onDragEnd`:`onDragCancel`;if(o){let e=O.current[t];e?.(o),f({type:t,event:o})}})}}},[v]),Ce=sr(a,(0,V.useCallback)((e,t)=>(n,r)=>{let i=n.nativeEvent,a=v.get(r);if(w.current!==null||!a||i.dndKit||i.defaultPrevented)return;let o={active:a};e(n,t.options,o)===!0&&(i.dndKit={capturedBy:t.sensor},w.current=r,Se(n,t))},[v,Se]));Cr(a),J(()=>{F&&m===Gr.Initializing&&h(Gr.Initialized)},[F,m]),(0,V.useEffect)(()=>{let{onDragMove:e}=O.current,{active:t,activatorEvent:n,collisions:r,over:i}=L.current;if(!t||!n)return;let a={active:t,activatorEvent:n,collisions:r,delta:{x:H.x,y:H.y},over:i};(0,ge.unstable_batchedUpdates)(()=>{e?.(a),f({type:`onDragMove`,event:a})})},[H.x,H.y]),(0,V.useEffect)(()=>{let{active:e,activatorEvent:t,collisions:n,droppableContainers:r,scrollAdjustedTranslate:i}=L.current;if(!e||w.current==null||!t||!i)return;let{onDragOver:a}=O.current,o=r.get(ve),s=o&&o.rect.current?{id:o.id,rect:o.rect.current,data:o.data,disabled:o.disabled}:null,c={active:e,activatorEvent:t,collisions:n,delta:{x:i.x,y:i.y},over:s};(0,ge.unstable_batchedUpdates)(()=>{ye(s),a?.(c),f({type:`onDragOver`,event:c})})},[ve]),J(()=>{L.current={activatorEvent:D,active:C,activeNode:M,collisionRect:_e,collisions:U,droppableRects:A,draggableNodes:v,draggingNode:oe,draggingNodeRect:z,droppableContainers:b,over:W,scrollableAncestors:B,scrollAdjustedTranslate:H},S.current={initial:z,translated:_e}},[C,M,U,_e,v,oe,z,A,b,W,B,H]),rr({...N,delta:y,draggingRect:_e,pointerCoordinates:fe,scrollableAncestors:B,scrollableAncestorRects:ue});let we=(0,V.useMemo)(()=>({active:C,activeNode:M,activeNodeRect:F,activatorEvent:D,collisions:U,containerNodeRect:I,dragOverlay:R,draggableNodes:v,droppableContainers:b,droppableRects:A,over:W,measureDroppableContainers:j,scrollableAncestors:B,scrollableAncestorRects:ue,measuringConfiguration:ne,measuringScheduled:re,windowRect:le}),[C,M,F,D,U,I,R,v,b,A,W,j,B,ue,ne,re,le]),Te=(0,V.useMemo)(()=>({activatorEvent:D,activators:Ce,active:C,activeNodeRect:F,ariaDescribedById:{draggable:te},dispatch:d,draggableNodes:v,over:W,measureDroppableContainers:j}),[D,Ce,C,F,d,te,v,W,j]);return V.createElement(Ht.Provider,{value:p},V.createElement(Ir.Provider,{value:Te},V.createElement(Lr.Provider,{value:we},V.createElement(Wr.Provider,{value:be},i)),V.createElement(Br,{disabled:n?.restoreFocus===!1})),V.createElement(qt,{...n,hiddenTextDescribedById:te}));function G(){let e=T?.autoScrollEnabled===!1,t=typeof r==`object`?r.enabled===!1:r===!1,n=g&&!e&&!t;return typeof r==`object`?{...r,enabled:n}:{enabled:n}}}),qr=(0,V.createContext)(null),Jr=`button`,Yr=`Draggable`;function Xr(e){let{id:t,data:n,disabled:r=!1,attributes:i}=e,a=Dt(Yr),{activators:o,activatorEvent:s,active:c,activeNodeRect:l,ariaDescribedById:u,draggableNodes:d,over:f}=(0,V.useContext)(Ir),{role:p=Jr,roleDescription:m=`draggable`,tabIndex:h=0}=i??{},g=c?.id===t,_=(0,V.useContext)(g?Wr:qr),[v,y]=wt(),[b,x]=wt(),S=wr(o,t),C=St(n);return J(()=>(d.set(t,{id:t,key:a,node:v,activatorNode:b,data:C}),()=>{let e=d.get(t);e&&e.key===a&&d.delete(t)}),[d,t]),{active:c,activatorEvent:s,activeNodeRect:l,attributes:(0,V.useMemo)(()=>({role:p,tabIndex:h,"aria-disabled":r,"aria-pressed":g&&p===Jr?!0:void 0,"aria-roledescription":m,"aria-describedby":u.draggable}),[r,p,h,g,m,u.draggable]),isDragging:g,listeners:r?void 0:S,node:v,over:f,setNodeRef:y,setActivatorNodeRef:x,transform:_}}function Zr(){return(0,V.useContext)(Lr)}var Qr=`Droppable`,$r={timeout:25};function ei(e){let{data:t,disabled:n=!1,id:r,resizeObserverConfig:i}=e,a=Dt(Qr),{active:o,dispatch:s,over:c,measureDroppableContainers:l}=(0,V.useContext)(Ir),u=(0,V.useRef)({disabled:n}),d=(0,V.useRef)(!1),f=(0,V.useRef)(null),p=(0,V.useRef)(null),{disabled:m,updateMeasurementsFor:h,timeout:g}={...$r,...i},_=St(h??r),v=hr({callback:(0,V.useCallback)(()=>{if(!d.current){d.current=!0;return}p.current!=null&&clearTimeout(p.current),p.current=setTimeout(()=>{l(Array.isArray(_.current)?_.current:[_.current]),p.current=null},g)},[g]),disabled:m||!o}),[y,b]=wt((0,V.useCallback)((e,t)=>{v&&(t&&(v.unobserve(t),d.current=!1),e&&v.observe(e))},[v])),x=St(t);return(0,V.useEffect)(()=>{!v||!y.current||(v.disconnect(),d.current=!1,v.observe(y.current))},[y,v]),(0,V.useEffect)(()=>(s({type:Y.RegisterDroppable,element:{id:r,key:a,disabled:n,node:y,rect:f,data:x}}),()=>s({type:Y.UnregisterDroppable,key:a,id:r})),[r]),(0,V.useEffect)(()=>{n!==u.current.disabled&&(s({type:Y.SetDroppableDisabled,id:r,key:a,disabled:n}),u.current.disabled=n)},[r,a,n,s]),{active:o,rect:f,isOver:c?.id===r,node:y,over:c,setNodeRef:b}}function ti(e,t,n){let r=e.slice();return r.splice(n<0?r.length+n:n,0,r.splice(t,1)[0]),r}function ni(e,t){return e.reduce((e,n,r)=>{let i=t.get(n);return i&&(e[r]=i),e},Array(e.length))}function ri(e){return e!==null&&e>=0}function ii(e,t){if(e===t)return!0;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function ai(e){return typeof e==`boolean`?{draggable:e,droppable:e}:e}var oi=e=>{let{rects:t,activeIndex:n,overIndex:r,index:i}=e,a=ti(t,r,n),o=t[i],s=a[i];return!s||!o?null:{x:s.left-o.left,y:s.top-o.top,scaleX:s.width/o.width,scaleY:s.height/o.height}},si=`Sortable`,ci=V.createContext({activeIndex:-1,containerId:si,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:oi,disabled:{draggable:!1,droppable:!1}});function li(e){let{children:t,id:n,items:r,strategy:i=oi,disabled:a=!1}=e,{active:o,dragOverlay:s,droppableRects:c,over:l,measureDroppableContainers:u}=Zr(),d=Dt(si,n),f=s.rect!==null,p=(0,V.useMemo)(()=>r.map(e=>typeof e==`object`&&`id`in e?e.id:e),[r]),m=o!=null,h=o?p.indexOf(o.id):-1,g=l?p.indexOf(l.id):-1,_=(0,V.useRef)(p),v=!ii(p,_.current),y=g!==-1&&h===-1||v,b=ai(a);J(()=>{v&&m&&u(p)},[v,p,m,u]),(0,V.useEffect)(()=>{_.current=p},[p]);let x=(0,V.useMemo)(()=>({activeIndex:h,containerId:d,disabled:b,disableTransforms:y,items:p,overIndex:g,useDragOverlay:f,sortedRects:ni(p,c),strategy:i}),[h,d,b.draggable,b.droppable,y,p,g,c,f,i]);return V.createElement(ci.Provider,{value:x},t)}var ui=e=>{let{id:t,items:n,activeIndex:r,overIndex:i}=e;return ti(n,r,i).indexOf(t)},di=e=>{let{containerId:t,isSorting:n,wasDragging:r,index:i,items:a,newIndex:o,previousItems:s,previousContainerId:c,transition:l}=e;return!l||!r||s!==a&&i===o?!1:n?!0:o!==i&&t===c},fi={duration:200,easing:`ease`},pi=`transform`,mi=Ft.Transition.toString({property:pi,duration:0,easing:`linear`}),hi={roleDescription:`sortable`};function gi(e){let{disabled:t,index:n,node:r,rect:i}=e,[a,o]=(0,V.useState)(null),s=(0,V.useRef)(n);return J(()=>{if(!t&&n!==s.current&&r.current){let e=i.current;if(e){let t=hn(r.current,{ignoreTransform:!0}),n={x:e.left-t.left,y:e.top-t.top,scaleX:e.width/t.width,scaleY:e.height/t.height};(n.x||n.y)&&o(n)}}n!==s.current&&(s.current=n)},[t,n,r,i]),(0,V.useEffect)(()=>{a&&o(null)},[a]),a}function _i(e){let{animateLayoutChanges:t=di,attributes:n,disabled:r,data:i,getNewIndex:a=ui,id:o,strategy:s,resizeObserverConfig:c,transition:l=fi}=e,{items:u,containerId:d,activeIndex:f,disabled:p,disableTransforms:m,sortedRects:h,overIndex:g,useDragOverlay:_,strategy:v}=(0,V.useContext)(ci),y=vi(r,p),b=u.indexOf(o),x=(0,V.useMemo)(()=>({sortable:{containerId:d,index:b,items:u},...i}),[d,i,b,u]),S=(0,V.useMemo)(()=>u.slice(u.indexOf(o)),[u,o]),{rect:C,node:w,isOver:T,setNodeRef:E}=ei({id:o,data:x,disabled:y.droppable,resizeObserverConfig:{updateMeasurementsFor:S,...c}}),{active:D,activatorEvent:ee,activeNodeRect:O,attributes:te,setNodeRef:k,listeners:ne,isDragging:A,over:j,setActivatorNodeRef:re,transform:M}=Xr({id:o,data:x,attributes:{...hi,...n},disabled:y.draggable}),ie=ft(E,k),N=!!D,P=N&&!m&&ri(f)&&ri(g),F=!_&&A,I=P?(F&&P?M:null)??(s??v)({rects:h,activeNodeRect:O,activeIndex:f,overIndex:g,index:b}):null,L=ri(f)&&ri(g)?a({id:o,items:u,activeIndex:f,overIndex:g}):b,ae=D?.id,R=(0,V.useRef)({activeId:ae,items:u,newIndex:L,containerId:d}),oe=u!==R.current.items,z=t({active:D,containerId:d,isDragging:A,isSorting:N,id:o,index:b,items:u,newIndex:R.current.newIndex,previousItems:R.current.items,previousContainerId:R.current.containerId,transition:l,wasDragging:R.current.activeId!=null}),se=gi({disabled:!z,index:b,node:w,rect:C});return(0,V.useEffect)(()=>{N&&R.current.newIndex!==L&&(R.current.newIndex=L),d!==R.current.containerId&&(R.current.containerId=d),u!==R.current.items&&(R.current.items=u)},[N,L,d,u]),(0,V.useEffect)(()=>{if(ae===R.current.activeId)return;if(ae!=null&&R.current.activeId==null){R.current.activeId=ae;return}let e=setTimeout(()=>{R.current.activeId=ae},50);return()=>clearTimeout(e)},[ae]),{active:D,activeIndex:f,attributes:te,data:x,rect:C,index:b,newIndex:L,items:u,isOver:T,isSorting:N,isDragging:A,listeners:ne,node:w,overIndex:g,over:j,setNodeRef:ie,setActivatorNodeRef:re,setDroppableNodeRef:E,setDraggableNodeRef:k,transform:se??I,transition:ce()};function ce(){if(se||oe&&R.current.newIndex===b)return mi;if(!(F&&!Mt(ee)||!l)&&(N||z))return Ft.Transition.toString({...l,property:pi})}}function vi(e,t){return typeof e==`boolean`?{draggable:e,droppable:!1}:{draggable:e?.draggable??t.draggable,droppable:e?.droppable??t.droppable}}function yi(e){if(!e)return!1;let t=e.data.current;return!!(t&&`sortable`in t&&typeof t.sortable==`object`&&`containerId`in t.sortable&&`items`in t.sortable&&`index`in t.sortable)}var bi=[$.Down,$.Right,$.Up,$.Left],xi=(e,t)=>{let{context:{active:n,collisionRect:r,droppableRects:i,droppableContainers:a,over:o,scrollableAncestors:s}}=t;if(bi.includes(e.code)){if(e.preventDefault(),!n||!r)return;let t=[];a.getEnabled().forEach(n=>{if(!n||n!=null&&n.disabled)return;let a=i.get(n.id);if(a)switch(e.code){case $.Down:r.top<a.top&&t.push(n);break;case $.Up:r.top>a.top&&t.push(n);break;case $.Left:r.left>a.left&&t.push(n);break;case $.Right:r.left<a.left&&t.push(n);break}});let c=an({active:n,collisionRect:r,droppableRects:i,droppableContainers:t,pointerCoordinates:null}),l=tn(c,`id`);if(l===o?.id&&c.length>1&&(l=c[1].id),l!=null){let e=a.get(n.id),t=a.get(l),o=t?i.get(t.id):null,c=t?.node.current;if(c&&o&&e&&t){let n=bn(c).some((e,t)=>s[t]!==e),i=Si(e,t),a=Ci(e,t),l=n||!i?{x:0,y:0}:{x:a?r.width-o.width:0,y:a?r.height-o.height:0},u={x:o.left,y:o.top};return l.x&&l.y?u:At(u,l)}}}};function Si(e,t){return!yi(e)||!yi(t)?!1:e.data.current.sortable.containerId===t.data.current.sortable.containerId}function Ci(e,t){return!yi(e)||!yi(t)||!Si(e,t)?!1:e.data.current.sortable.index<t.data.current.sortable.index}var wi=e=>`"${e.replace(/(["\\$`!])/g,`\\$1`)}"`;function Ti(e){return e%3600==0?`${e/3600}h`:e%60==0?`${e/60}m`:`${e}s`}function Ei(e){if(e.kind===`tracker`)return!1;if(e.kind===`schedule`)return!!e.schedule&&(e.schedule.type!==`once`||!!e.schedule.date);if(!e.events?.length)return!1;let t=e.filters??{};return!([`assignees`,`allLabels`,`excludeLabels`,`changedLabels`].some(e=>(t[e]?.length??0)>0)||t.lookbackDays!==void 0&&t.lookbackDays!==7||t.maxRecords!==void 0&&t.maxRecords!==25)}function Di(e){let t=[`cez automation add`,`--name ${wi(e.name||`untitled`)}`];if(e.kind===`schedule`&&e.schedule?.type===`once`){let n=N(e.schedule);t.push(`--at ${wi(`${n.date} ${M(n.hour,n.minute)}`)}`)}else if(e.kind===`schedule`&&e.schedule)t.push(`--cron ${wi(F(e.schedule))}`);else{t.push(`--on ${(e.events??[]).join(`,`)}`),t.push(`--every ${Ti(e.intervalSeconds??300)}`);for(let n of e.filters?.anyLabels??[])t.push(`--label ${wi(n)}`);for(let n of e.filters?.authors??[])t.push(`--author ${wi(n)}`)}let{task:n}=e;return n.workflow&&t.push(`--workflow ${wi(n.workflow)}`),n.runner&&t.push(`--runner ${wi(n.runner)}`),n.model&&t.push(`--model ${wi(n.model)}`),n.autonomous===!1?t.push(`--no-autonomous`):n.autonomous&&t.push(`--autonomous`),n.dispatch&&(t.push(`--dispatch`),n.dispatch.maxSubtasks!==void 0&&t.push(`--max-subtasks ${n.dispatch.maxSubtasks}`),n.dispatch.reviewChild&&t.push(`--review-child`)),e.enable&&t.push(`--enable`),t.push(`--prompt ${wi(n.prompt||`…`)}`),t.join(` `)}function Oi(e){let t={name:e.name||`untitled`,kind:e.kind,...e.kind===`schedule`?{schedule:e.schedule}:e.kind===`tracker`?{trackerTrigger:e.trackerTrigger,intervalSeconds:e.intervalSeconds??1800,filters:{lookbackDays:7,maxRecords:25,...e.filters}}:{events:e.events,intervalSeconds:e.intervalSeconds??300,filters:{lookbackDays:7,maxRecords:25,...e.filters}},task:e.task,...e.enable?{enable:!0}:{}};return`cez automation create --json '${JSON.stringify(t).replace(/'/g,`'\\''`)}'`}function ki(e){return Ei(e)?Di(e):Oi(e)}var Ai=()=>[re(),`automations`];function ji(){let e=l(),t=e.data!==void 0;return{known:t,off:t&&e.data?.capabilities?.automations!==!0}}function Mi(e){let t=a(),n=L(),r=f({queryKey:Ai(),queryFn:({signal:e})=>p({signal:e}),enabled:e});return(0,V.useEffect)(()=>Be((e,r)=>{if(e!==`automation-change`)return;let i=r;typeof i.project==`string`&&(n===null||i.project===n)&&t.invalidateQueries({queryKey:Ai()})}),[n,t]),r}function Ni(e){let t=a(),n=()=>t.invalidateQueries({queryKey:Ai()}),r=e=>I(e instanceof Error?e.message:String(e),{tone:`danger`}),i=u({mutationFn:async e=>{e.kind===`schedule`?(await s(e.id),I(`Started "${e.name}" — the task is queued.`)):(await S(e.id,`execute`),I(`Checking events for "${e.name}" now.`))},onSuccess:()=>void n(),onError:r}),o=u({mutationFn:async e=>{await S(e.id,`preview`),I(`Preview queued for "${e.name}" — no tasks will launch. See the execution log for results.`)},onSuccess:()=>void n(),onError:r}),c=u({mutationFn:e=>D(e.id,!e.enabled),onSuccess:()=>void n(),onError:r}),l=u({mutationFn:e=>x({name:`${e.name} (copy)`,...e.description?{description:e.description}:{},kind:e.kind,...e.kind===`schedule`?{schedule:e.schedule}:e.kind===`tracker`?{trackerTrigger:e.trackerTrigger,intervalSeconds:e.intervalSeconds,filters:e.filters}:{events:e.events,intervalSeconds:e.intervalSeconds,filters:e.filters},task:e.task}),onSuccess:e=>{I(`Duplicated as "${e.automation.name}", paused.`),n()},onError:r}),d=u({mutationFn:e=>O(e.id),onSuccess:()=>void n(),onError:r});return{preview:e=>o.mutateAsync(e).then(()=>void 0,()=>void 0),runNow:e=>i.mutateAsync(e).then(()=>void 0,()=>void 0),toggleEnabled:e=>c.mutateAsync(e).then(()=>void 0,()=>void 0),duplicate:e=>l.mutateAsync(e).then(()=>void 0,()=>void 0),remove:e=>d.mutateAsync(e).then(()=>void 0,()=>void 0),copyCli:async e=>{await Pi(ki({name:e.name,kind:e.kind,trackerTrigger:e.trackerTrigger,schedule:e.schedule,events:e.events,intervalSeconds:e.intervalSeconds,filters:e.filters,task:e.task}))},busy:o.isPending||i.isPending||c.isPending||l.isPending||d.isPending}}async function Pi(e){try{await he(e),I(`Copied to the clipboard.`)}catch{I(`Copy failed — select the text to copy it.`,{tone:`danger`})}}function Fi({slot:e,label:t,value:n,options:r,onChange:i,full:a=!1,allowRelease:o=!1,className:s}){return(0,K.jsx)(`div`,{"data-slot":e,"data-full":a?`true`:void 0,role:`group`,"aria-label":t,className:P(`inline-flex gap-0.5 rounded-md bg-muted p-[3px]`,a&&`flex w-full`,s),children:r.map(e=>{let t=e.value===n;return(0,K.jsxs)(`button`,{type:`button`,"data-value":e.value,"aria-pressed":t,onClick:()=>{t&&!o||i(e.value)},className:P(`flex h-7 items-center justify-center gap-1.5 rounded-[7px] px-3 text-label font-medium whitespace-nowrap text-muted-foreground transition-colors hover:text-foreground`,a&&`flex-1`,t&&`bg-card font-semibold text-foreground shadow-xs`),children:[e.label,e.count===void 0?null:(0,K.jsx)(`small`,{className:`font-mono text-meta font-normal tabular-nums`,children:e.count})]},e.value)})})}function Ii({slot:e,label:t,options:n,selected:r,onToggle:i,onClear:a,searchPlaceholder:o,emptyLabel:s=`Nothing to filter by`}){let[c,l]=V.useState(!1),u=r.length>0,d=r.length===1?n.find(e=>e.value===r[0])?.label??r[0]:`${r.length} selected`;return(0,K.jsxs)(z,{open:c,onOpenChange:l,children:[(0,K.jsx)(oe,{asChild:!0,children:(0,K.jsxs)(`button`,{type:`button`,"data-slot":`facet-${e}`,"data-active":u?`true`:void 0,"aria-label":`Filter by ${t.toLowerCase()}`,className:P(`inline-flex h-7 items-center gap-1.5 rounded-full border border-border bg-card px-2.5 text-xs font-medium text-muted-foreground transition-colors hover:bg-muted hover:text-foreground`,u&&`border-violet/40 bg-violet/10 text-foreground`),children:[(0,K.jsx)(`span`,{className:P(u&&`text-soft-foreground`),children:t}),u?(0,K.jsx)(`span`,{className:`max-w-[140px] truncate font-semibold`,children:d}):null,(0,K.jsx)(me,{"aria-hidden":`true`,className:`size-2.5 shrink-0 text-soft-foreground`})]})}),(0,K.jsxs)(R,{align:`start`,className:`w-64 p-0`,"data-testid":`facet-${e}-menu`,children:[(0,K.jsxs)(B,{children:[(0,K.jsx)(de,{placeholder:o??`Search ${t.toLowerCase()}…`}),(0,K.jsxs)(le,{children:[(0,K.jsx)(se,{children:s}),(0,K.jsx)(ce,{children:n.map(e=>{let t=r.includes(e.value);return(0,K.jsxs)(ue,{value:e.label,onSelect:()=>i(e.value),"data-slot":`facet-option`,"data-value":e.value,"aria-checked":t,role:`option`,children:[(0,K.jsx)(`span`,{"aria-hidden":`true`,className:P(`flex size-4 shrink-0 items-center justify-center rounded-[4px] border`,t?`border-violet bg-violet text-violet-foreground`:`border-input`),children:t?(0,K.jsx)(pe,{className:`size-3`}):null}),(0,K.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.label}),e.count===void 0?null:(0,K.jsx)(`span`,{className:`shrink-0 font-mono text-meta text-soft-foreground tabular-nums`,children:e.count})]},e.value)})})]})]}),u?(0,K.jsx)(`div`,{className:`border-t border-border p-1`,children:(0,K.jsxs)(`button`,{type:`button`,"data-action":`facet-${e}-clear`,onClick:()=>a(),className:`w-full rounded-sm px-2 py-1.5 text-left text-xs font-medium text-muted-foreground hover:bg-muted hover:text-foreground`,children:[`Clear `,t.toLowerCase()]})}):null]})]})}function Li({label:e,count:t,selected:n,onToggle:r,slot:i,tone:a=`neutral`}){return(0,K.jsxs)(`button`,{type:`button`,"data-slot":i,"data-selected":n?`true`:void 0,"aria-pressed":n,onClick:r,className:P(`inline-flex h-7 items-center gap-1.5 rounded-full border px-2.5 text-xs font-medium transition-colors`,a===`tag`?`border-violet/25 bg-violet/10 text-violet hover:bg-violet/20`:`border-border bg-card text-muted-foreground hover:bg-muted hover:text-foreground`,n&&`border-violet bg-violet text-violet-foreground hover:bg-violet`),children:[e,t===void 0?null:(0,K.jsx)(`span`,{className:P(`font-mono text-meta tabular-nums`,!n&&`text-soft-foreground`),children:t})]})}function Ri({slot:e,label:t,value:n,options:r,onChange:i}){return(0,K.jsx)(Fi,{slot:e,label:t,value:n,options:r,onChange:i,allowRelease:!0})}export{je as A,dt as C,it as D,ct as E,G as F,Ee as I,Se as L,De as M,Oe as N,Be as O,Ae as P,we as R,Ft as S,lt as T,Wn as _,Ai as a,Yt as b,ji as c,li as d,ti as f,Kr as g,_i as h,Fi as i,ke as j,at as k,Mi as l,xi as m,Ri as n,Pi as o,oi as p,Li as r,Ni as s,Ii as t,ki as u,Yn as v,ut as w,Xt as x,rn as y,xe as z};
@@ -1,2 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{Gi as r,St as i,Yi as a,er as o,ut as s}from"./queries-BTgOLNTK.js";import{F as c,r as l}from"./button-wdWSPx_B.js";import{t as u}from"./file-CbWEaOku.js";import{t as d}from"./chevron-right-DDQuVTY1.js";import{p as f}from"./git-toolbar-C3vpZJaZ.js";import{t as p}from"./triangle-alert-BdMPm9Jb.js";import{t as m}from"./centered-state-D-wDs7Y1.js";import{a as ee,i as te,o as h,t as g}from"./markdown-G3dvGJao.js";import{n as _}from"./markdown-BfZORc0a.js";var ne=c(`arrow-down`,[[`path`,{d:`M12 5v14`,key:`s699le`}],[`path`,{d:`m19 12-7 7-7-7`,key:`1idqje`}]]),re=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`}]]),v=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`}]]),y=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`}]]),b=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`}]]),x=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`}]]),S=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`}]]),C=e(t(),1),w=n();function T({root:e,selected:t,onSelect:n,commentCounts:r=E}){return(0,w.jsx)(D.Provider,{value:r,children:(0,w.jsx)(`nav`,{"data-slot":`changes-tree`,"aria-label":`Changed files`,className:`min-w-0 text-ui`,children:(0,w.jsxs)(`ul`,{className:`flex flex-col gap-px`,children:[e.dirs.map(e=>(0,w.jsx)(A,{dir:e,depth:0,selected:t,onSelect:n},e.path)),e.files.map(e=>(0,w.jsx)(M,{file:e,depth:0,selected:t,onSelect:n},e.path))]})})})}var E=new Map,D=(0,C.createContext)(E);function O(e,t){let n=0;for(let r of e.files)n+=t.get(r.path)??0;for(let r of e.dirs)n+=O(r,t);return n}function k({adds:e,dels:t}){return(0,w.jsxs)(`span`,{className:`shrink-0 font-mono text-meta font-medium tabular-nums`,children:[e>0?(0,w.jsxs)(`span`,{className:`text-success`,children:[`+`,e]}):null,e>0&&t>0?` `:null,t>0?(0,w.jsxs)(`span`,{className:`text-danger`,children:[`−`,t]}):null]})}function A({dir:e,depth:t,selected:n,onSelect:r}){let[i,a]=(0,C.useState)(!0),o=(0,C.useContext)(D),s=i?0:O(e,o);return(0,w.jsxs)(`li`,{children:[(0,w.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,w.jsx)(d,{"aria-hidden":`true`,className:l(`size-3.5 shrink-0 transition-transform`,i&&`rotate-90`)}),(0,w.jsx)(f,{"aria-hidden":`true`,className:`size-3.5 shrink-0`}),(0,w.jsx)(`span`,{className:`min-w-0 truncate font-medium`,children:e.name}),(0,w.jsxs)(`span`,{className:`ml-auto flex shrink-0 items-center gap-2 pl-2`,children:[(0,w.jsx)(_,{count:s}),(0,w.jsx)(k,{adds:e.adds,dels:e.dels})]})]}),i?(0,w.jsxs)(`ul`,{className:`flex flex-col gap-px`,children:[e.dirs.map(e=>(0,w.jsx)(A,{dir:e,depth:t+1,selected:n,onSelect:r},e.path)),e.files.map(e=>(0,w.jsx)(M,{file:e,depth:t+1,selected:n,onSelect:r},e.path))]}):null]})}var j={added:`text-success`,deleted:`text-danger`};function M({file:e,depth:t,selected:n,onSelect:r}){let i=n===e.path,a=(0,C.useContext)(D).get(e.path)??0;return(0,w.jsx)(`li`,{children:(0,w.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,w.jsx)(u,{"aria-hidden":`true`,className:l(`size-3.5 shrink-0`,j[e.status])}),(0,w.jsx)(`span`,{className:`min-w-0 truncate`,children:e.name}),(0,w.jsxs)(`span`,{className:`ml-auto flex shrink-0 items-center gap-2 pl-2`,children:[(0,w.jsx)(_,{count:a}),(0,w.jsx)(k,{adds:e.adds,dels:e.dels})]})]})})}var N=`cez-tree-pane-width`,P=.6;function F(e,t=1/0){if(e==null||e===``)return null;let n=typeof e==`number`?e:Number(e);if(!Number.isFinite(n))return null;let r=Math.max(160,Math.min(720,t*P));return Math.min(r,Math.max(160,Math.round(n)))}function I(){try{return F(localStorage.getItem(N))}catch{return null}}function L(e){try{let t=F(e);t===null?localStorage.removeItem(N):localStorage.setItem(N,String(t))}catch{}}var R=new Set,z;function B(e){R.add(e);let t=t=>{t.key!==null&&t.key!==`cez-tree-pane-width`||(z=void 0,e())};return window.addEventListener(`storage`,t),()=>{R.delete(e),window.removeEventListener(`storage`,t)}}function V(){return z===void 0?I():z}function H(e){L(e),z=I()===e?void 0:e;for(let e of R)e()}function U(){return[C.useSyncExternalStore(B,V,V),H]}function W(e){return e===null?{}:{style:{"--tree-pane-width":`${e}px`},className:`md:w-(--tree-pane-width)!`}}function G({paneRef:e,width:t,onWidthChange:n,className:r}){let i=C.useRef(null),a=()=>t??Math.round(e.current?.getBoundingClientRect().width??0),o=t=>F(t,e.current?.parentElement?.clientWidth||1/0),s=e=>{e.button===0&&(i.current={x:e.clientX,width:a()},e.currentTarget.setPointerCapture(e.pointerId),e.preventDefault(),e.currentTarget.focus())},c=e=>{let t=i.current;t&&n(o(t.width+(e.clientX-t.x)))},u=e=>{i.current&&(i.current=null,e.currentTarget.hasPointerCapture(e.pointerId)&&e.currentTarget.releasePointerCapture(e.pointerId))};return(0,w.jsx)(`div`,{"data-slot":`tree-pane-resize`,className:l(`relative -mr-5 w-0 shrink-0`,r),children:(0,w.jsx)(`div`,{"data-slot":`tree-pane-resize-handle`,role:`separator`,"aria-orientation":`vertical`,"aria-label":`Resize the file tree`,"aria-valuenow":t??void 0,"aria-valuemin":160,"aria-valuemax":720,tabIndex:0,onPointerDown:s,onPointerMove:c,onPointerUp:u,onPointerCancel:u,onKeyDown:e=>{let t=e.key===`ArrowLeft`?a()-16:e.key===`ArrowRight`?a()+16:e.key===`Home`?160:e.key===`End`?720:null;t!==null&&(e.preventDefault(),n(o(t)))},onDoubleClick:()=>n(null),title:`Drag to resize the file tree — double-click to reset`,className:`absolute inset-y-0 -left-[14px] z-10 w-2 cursor-col-resize touch-none rounded-full bg-transparent transition-colors hover:bg-violet/40 focus-visible:bg-violet/60 focus-visible:outline-none`})})}var K=(e,t)=>e.name.localeCompare(t.name);function q(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(q)}}function J(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(K),e.files.sort(K)};return o(r),{...r,dirs:r.dirs.map(q)}}function Y(e){let t=new Map(e.map(e=>[e.path,e])),n=J(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 ie=new Set([`png`,`jpg`,`jpeg`,`gif`,`webp`,`svg`,`bmp`,`ico`,`avif`]);function X(e){let t=e.slice(e.lastIndexOf(`/`)+1),n=t.lastIndexOf(`.`);return n<=0?!1:ie.has(t.slice(n+1).toLowerCase())}function ae(e){return e.tooLarge?`too-large`:X(e.path)?`image`:e.binary?`binary`:`text`}function Z(e){return e>=1024**2?`${(e/1024**2).toFixed(1)} MB`:e>=1024?`${(e/1024).toFixed(1)} kB`:`${e} B`}function oe(e,t){let n=i(e.kind===`run`?e.runId:void 0,e.kind===`run`?t:void 0),r=s(e.kind===`repo`?t:void 0);return e.kind===`run`?n:r}function se(e,t){return e.kind===`run`?a(e.runId,t):r(t)}function ce({source:e,path:t,className:n}){let r=oe(e,t??void 0);if(t===null)return(0,w.jsx)($,{className:n,children:(0,w.jsx)(m,{icon:(0,w.jsx)(S,{}),tone:`neutral`,heading:`h2`,title:`Select a file`,subtitle:`Pick a file from the tree to preview it here.`})});if(r.isPending)return(0,w.jsx)($,{className:n,children:(0,w.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 o&&r.error.status===409;return(0,w.jsx)($,{className:n,children:(0,w.jsx)(m,{icon:e?(0,w.jsx)(y,{}):(0,w.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,w.jsx)(ue,{source:e,entry:r.data,className:n}):null}function le(e){return/\.(md|markdown|mdx)$/i.test(e)}var Q=`rendered`;function ue({source:e,entry:t,className:n}){let r=ae(t),i=r===`text`&&le(t.path),[a,o]=(0,C.useState)(Q),s=e=>{Q=e,o(e)};return(0,w.jsxs)($,{className:n,children:[(0,w.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,w.jsx)(`span`,{className:`min-w-0 truncate font-mono font-medium`,children:t.path}),i?(0,w.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,w.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,w.jsx)(`span`,{className:l(`shrink-0 tabular-nums text-soft-foreground`,i?`pl-2`:`ml-auto`),children:Z(t.size)})]}),r===`image`?(0,w.jsx)(`div`,{className:`flex justify-center p-4`,children:(0,w.jsx)(`img`,{"data-slot":`file-preview-image`,src:se(e,t.path),alt:t.path,className:`max-h-[70vh] max-w-full rounded-sm`})}):r===`too-large`?(0,w.jsx)(m,{icon:(0,w.jsx)(re,{}),tone:`neutral`,heading:`h2`,title:`Too large to preview`,subtitle:`${Z(t.size)} — past the preview cap. Open it in your editor instead.`}):r===`binary`?(0,w.jsx)(m,{icon:(0,w.jsx)(v,{}),tone:`neutral`,heading:`h2`,title:`Binary file`,subtitle:`${Z(t.size)} of binary data — no text preview.`}):i&&a===`rendered`?(0,w.jsx)(`div`,{"data-slot":`file-preview-markdown`,className:`px-4 py-3`,children:(0,w.jsx)(g,{children:t.content??``})}):(0,w.jsx)(pe,{path:t.path,text:t.content??``})]})}function $({className:e,children:t}){return(0,w.jsx)(`section`,{"data-slot":`file-preview`,className:l(`overflow-clip rounded-lg border border-border bg-card`,e),children:t})}var de=1500;function fe(e,t){let n=(0,C.useMemo)(()=>t.split(`
2
- `).map(e=>[{content:e}]),[t]),r=(0,C.useMemo)(()=>h(e),[e]),i=n.length>de,[a,o]=(0,C.useState)(null);return(0,C.useEffect)(()=>{if(r===null||i)return;let n=!1;return te(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:ee(t,r)?.tokens??n}function pe({path:e,text:t}){let n=fe(e,t);return(0,w.jsx)(`div`,{"data-slot":`file-preview-code`,"data-lang":h(e)??`plaintext`,className:`overflow-x-auto py-2 font-mono text-xs leading-[1.7]`,children:n.map((e,t)=>(0,w.jsxs)(`div`,{className:`flex px-4`,children:[(0,w.jsx)(`span`,{className:`w-10 shrink-0 select-none pr-3 text-right tabular-nums text-soft-foreground`,children:t+1}),(0,w.jsx)(`span`,{className:`min-w-0 flex-1 whitespace-pre pr-4`,children:e.map((e,t)=>(0,w.jsx)(`span`,{style:e.color===void 0?void 0:{color:e.color},children:e.content},t))})]},t))})}export{J as a,U as c,x as d,b as f,Y as i,T as l,Z as n,G as o,ne as p,X as r,W as s,ce as t,S as u};