@open-mercato/cezar 0.15.0 → 0.15.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/automations/github-poller.d.ts +8 -1
- package/dist/automations/github-poller.js +78 -13
- package/dist/automations/github-poller.js.map +1 -1
- package/dist/automations/pr-head.js +15 -1
- package/dist/automations/pr-head.js.map +1 -1
- package/dist/automations/prompts.js +2 -2
- package/dist/automations/types.d.ts +10 -0
- package/dist/automations/types.js +12 -1
- package/dist/automations/types.js.map +1 -1
- package/dist/config.d.ts +1 -0
- package/dist/config.js +6 -0
- package/dist/config.js.map +1 -1
- package/dist/contract/automations.d.ts +31 -1
- package/dist/contract/index.d.ts +1 -0
- package/dist/contract/index.js +161 -17
- package/dist/contract/projects.d.ts +46 -0
- package/dist/contract/runs.d.ts +15 -0
- package/dist/contract/skills.d.ts +1 -0
- package/dist/contract/telemetry.d.ts +124 -0
- package/dist/contract/workspace.d.ts +3 -0
- package/dist/core/cursor-agent-runner.d.ts +11 -0
- package/dist/core/cursor-agent-runner.js +48 -4
- package/dist/core/cursor-agent-runner.js.map +1 -1
- package/dist/core/disclaim-spawn.d.ts +10 -0
- package/dist/core/disclaim-spawn.js +105 -8
- package/dist/core/disclaim-spawn.js.map +1 -1
- package/dist/git-diff-base.js +26 -19
- package/dist/git-diff-base.js.map +1 -1
- package/dist/git-remotes.d.ts +43 -0
- package/dist/git-remotes.js +127 -0
- package/dist/git-remotes.js.map +1 -0
- package/dist/git-worktree.d.ts +43 -19
- package/dist/git-worktree.js +138 -54
- package/dist/git-worktree.js.map +1 -1
- package/dist/index.js +46 -6
- package/dist/index.js.map +1 -1
- package/dist/runs/auto-name.d.ts +17 -0
- package/dist/runs/auto-name.js +47 -2
- package/dist/runs/auto-name.js.map +1 -1
- package/dist/runs/event-history.d.ts +10 -2
- package/dist/runs/event-history.js +290 -120
- package/dist/runs/event-history.js.map +1 -1
- package/dist/runs/retention.js +1 -1
- package/dist/runs/retention.js.map +1 -1
- package/dist/runs/store.d.ts +16 -3
- package/dist/runs/store.js +89 -10
- package/dist/runs/store.js.map +1 -1
- package/dist/server/checkout.d.ts +4 -0
- package/dist/server/checkout.js +9 -5
- package/dist/server/checkout.js.map +1 -1
- package/dist/server/create-project.d.ts +77 -0
- package/dist/server/create-project.js +342 -0
- package/dist/server/create-project.js.map +1 -0
- package/dist/server/forge/github.d.ts +2 -0
- package/dist/server/forge/github.js +32 -10
- package/dist/server/forge/github.js.map +1 -1
- package/dist/server/forge/index.d.ts +1 -12
- package/dist/server/forge/index.js +7 -29
- package/dist/server/forge/index.js.map +1 -1
- package/dist/server/forge/types.d.ts +2 -0
- package/dist/server/git-changes.d.ts +15 -0
- package/dist/server/git-changes.js +51 -1
- package/dist/server/git-changes.js.map +1 -1
- package/dist/server/git.d.ts +3 -2
- package/dist/server/git.js +4 -3
- package/dist/server/git.js.map +1 -1
- package/dist/server/project-context.js +1 -1
- package/dist/server/project-context.js.map +1 -1
- package/dist/server/server.d.ts +609 -302
- package/dist/server/server.js +191 -12
- package/dist/server/server.js.map +1 -1
- package/dist/server/star-count.d.ts +27 -11
- package/dist/server/star-count.js +57 -28
- package/dist/server/star-count.js.map +1 -1
- package/dist/telemetry-cli.d.ts +10 -0
- package/dist/telemetry-cli.js +54 -0
- package/dist/telemetry-cli.js.map +1 -0
- package/dist/telemetry-service.json +1 -0
- package/dist/telemetry.d.ts +79 -0
- package/dist/telemetry.js +453 -0
- package/dist/telemetry.js.map +1 -0
- package/dist/workflows/run.d.ts +28 -0
- package/dist/workflows/run.js +111 -16
- package/dist/workflows/run.js.map +1 -1
- package/dist/workspace/config.d.ts +10 -0
- package/dist/workspace/config.js +16 -0
- package/dist/workspace/config.js.map +1 -1
- package/dist/workspace/projects-cli.js +3 -0
- package/dist/workspace/projects-cli.js.map +1 -1
- package/package.json +3 -3
- package/scripts/mock-claude.mjs +32 -17
- package/scripts/stamp-telemetry-service.mjs +20 -0
- package/web/dist/assets/agent-task-pickers-mJzYn0UB.js +1 -0
- package/web/dist/assets/{alert-dialog-CF_-dmQ1.js → alert-dialog-Dd1WPOaz.js} +1 -1
- package/web/dist/assets/arrow-left-fsST4JqT.js +1 -0
- package/web/dist/assets/{automation-format-D1nqk0ID.js → automation-format-BTIFWfjt.js} +1 -1
- package/web/dist/assets/automations-route-DJjhwqug.js +1 -0
- package/web/dist/assets/button-BNnH7COh.js +100 -0
- package/web/dist/assets/{centered-state-T0J7VmBb.js → centered-state-sEYB3bgq.js} +1 -1
- package/web/dist/assets/check-DA37PQLT.js +1 -0
- package/web/dist/assets/chevron-left-zbXV2Qbu.js +1 -0
- package/web/dist/assets/chevron-right-Beu1pd6H.js +1 -0
- package/web/dist/assets/{collapsible-RD4hkew7.js → collapsible-MuXfYnM8.js} +1 -1
- package/web/dist/assets/commit-list-Bps23fvP.js +1 -0
- package/web/dist/assets/compare-variants-CQskdfDW.js +1 -0
- package/web/dist/assets/composer-DKWLJeo9.js +18 -0
- package/web/dist/assets/dashboard-BCNe_6p7.js +44 -0
- package/web/dist/assets/diff-CrLUECGW.js +3 -0
- package/web/dist/assets/{diff-stat-CFoeFye2.js → diff-stat-SpfygteL.js} +1 -1
- package/web/dist/assets/diff-view-DP4Gw3QJ.js +13 -0
- package/web/dist/assets/{download-BFQEsJRY.js → download-CBwSbmy_.js} +1 -1
- package/web/dist/assets/dropdown-menu-CxPGHgWX.js +1 -0
- package/web/dist/assets/ellipsis-BmusVE8U.js +1 -0
- package/web/dist/assets/{file-Df5WtpM_.js → file-DkvcUwxT.js} +1 -1
- package/web/dist/assets/file-preview-DxFusXAO.js +2 -0
- package/web/dist/assets/file-text-DBeC0yKb.js +1 -0
- package/web/dist/assets/file-tree-BTJZXRkM.js +1 -0
- package/web/dist/assets/{git-commit-horizontal-DawNm4qg.js → git-commit-horizontal-BM9_nEW7.js} +1 -1
- package/web/dist/assets/git-toolbar-DXyPCDkQ.js +1 -0
- package/web/dist/assets/github-G5fU4gJd.js +1 -0
- package/web/dist/assets/index-BN3w52uE.js +21 -0
- package/web/dist/assets/index-CAvSSpvF.css +2 -0
- package/web/dist/assets/{markdown-Bmfy_1Ll.js → markdown-BpZ4p95p.js} +1 -1
- package/web/dist/assets/{markdown-B_O1ys3h.js → markdown-C5F95Rt-.js} +1 -1
- package/web/dist/assets/{message-square-BOO9s3qX.js → message-square-BFQln9c4.js} +1 -1
- package/web/dist/assets/{pill-bO5OcHuK.js → pill-BcIQGDbn.js} +1 -1
- package/web/dist/assets/project-router-CWMOKp_H.js +3 -0
- package/web/dist/assets/reference-chip-B7lU_Pyh.js +1 -0
- package/web/dist/assets/reference-overflow-ClRRXWez.js +1 -0
- package/web/dist/assets/{refresh-cw-BaFyjVUz.js → refresh-cw-BBEYC6z2.js} +1 -1
- package/web/dist/assets/repo-git-CgxxZ7cO.js +1 -0
- package/web/dist/assets/{run-diff-GZbNs8fA.js → run-diff-BTB7nBeD.js} +1 -1
- package/web/dist/assets/run-header-BPNBEaOy.js +1 -0
- package/web/dist/assets/{image-preview-4SVDrBvn.js → scroll-within-DRt7mAnQ.js} +1 -1
- package/web/dist/assets/{search-x-bpAfQtVY.js → search-x-6BavY3mg.js} +1 -1
- package/web/dist/assets/sheet-D9PeyyRZ.js +1 -0
- package/web/dist/assets/skills-SIMzpL0l.js +1 -0
- package/web/dist/assets/square-DsFAQaY9.js +1 -0
- package/web/dist/assets/tab-link-DEUSZU49.js +1 -0
- package/web/dist/assets/{tag-DLwUkUsN.js → tag-DvCVnA6I.js} +1 -1
- package/web/dist/assets/task-changes-D-aajoMU.js +1 -0
- package/web/dist/assets/task-commits-BYD1GVkS.js +1 -0
- package/web/dist/assets/task-composer-7bdNNMP_.js +12 -0
- package/web/dist/assets/task-files-BfIOz-eN.js +1 -0
- package/web/dist/assets/task-graph-B5-5_IPh.js +1 -0
- package/web/dist/assets/task-notes-CfkTBgo8.js +1 -0
- package/web/dist/assets/task-thread-eEkjTDxr.js +10 -0
- package/web/dist/assets/{terminal-CwrL1hAi.js → terminal-xRHwWarr.js} +1 -1
- package/web/dist/assets/textarea-rKUFh5lI.js +1 -0
- package/web/dist/assets/thread-loading-DLlbK51g.js +1 -0
- package/web/dist/assets/{token-metrics-C149OWmd.js → token-metrics-BcPjL36-.js} +1 -1
- package/web/dist/assets/tooltip-BVqBAGNb.js +1 -0
- package/web/dist/assets/tracker-2DfMzsIE.js +4 -0
- package/web/dist/assets/triangle-alert-CP3Xp0FU.js +1 -0
- package/web/dist/assets/upload-bwO_2kok.js +1 -0
- package/web/dist/assets/use-automations-PceYR6ss.js +5 -0
- package/web/dist/assets/use-now-BAKdIYLG.js +1 -0
- package/web/dist/assets/use-submit-shortcut-BA4NVpJl.js +1 -0
- package/web/dist/assets/workflow-graph-HopaWPea.js +13 -0
- package/web/dist/assets/x-HaVPcg_B.js +1 -0
- package/web/dist/index.html +28 -31
- package/web/dist/assets/agent-task-pickers-C3ydGatB.js +0 -1
- package/web/dist/assets/arrow-left-BxBdc5DC.js +0 -1
- package/web/dist/assets/automations-route-BsflncpV.js +0 -1
- package/web/dist/assets/button-CjSjKnkd.js +0 -100
- package/web/dist/assets/check-DAAMuI4o.js +0 -1
- package/web/dist/assets/chevron-left-CvcqxpQZ.js +0 -1
- package/web/dist/assets/chevron-right-DKiL3NWw.js +0 -1
- package/web/dist/assets/commit-list-BJac2uO6.js +0 -1
- package/web/dist/assets/compare-variants-CfqICvRy.js +0 -1
- package/web/dist/assets/composer-DZx3cwQW.js +0 -18
- package/web/dist/assets/dashboard-CpCDiZdE.js +0 -44
- package/web/dist/assets/diff-LG2cl0PE.js +0 -3
- package/web/dist/assets/diff-controls-QgdH-r3F.js +0 -1
- package/web/dist/assets/diff-view-BVwSaBb2.js +0 -13
- package/web/dist/assets/dropdown-menu-DkEK7m00.js +0 -1
- package/web/dist/assets/editable-title-CJSWyCcL.js +0 -1
- package/web/dist/assets/ellipsis-vertical-CB0adfr7.js +0 -1
- package/web/dist/assets/external-link-DPKRidDg.js +0 -1
- package/web/dist/assets/eye-CEHQ0c-s.js +0 -1
- package/web/dist/assets/file-preview-kYsqZiLU.js +0 -2
- package/web/dist/assets/file-text-m0tZu8sU.js +0 -1
- package/web/dist/assets/git-merge-B7oVXcKc.js +0 -1
- package/web/dist/assets/git-toolbar-B0K4Q5Zv.js +0 -1
- package/web/dist/assets/github-C4WaHPni.js +0 -1
- package/web/dist/assets/index-CiQrbvAq.js +0 -21
- package/web/dist/assets/index-WWaEax-B.css +0 -2
- package/web/dist/assets/pencil-CCR9uUZ1.js +0 -1
- package/web/dist/assets/reference-chip-Bx_mG9QG.js +0 -1
- package/web/dist/assets/repo-git-Mn3_jrGP.js +0 -1
- package/web/dist/assets/run-header-i1D5Lvfs.js +0 -1
- package/web/dist/assets/sheet-DCdZVHFk.js +0 -1
- package/web/dist/assets/skills-Dea5ynJK.js +0 -1
- package/web/dist/assets/tab-link-BVItTl_Y.js +0 -1
- package/web/dist/assets/task-changes-xNbBM7FO.js +0 -1
- package/web/dist/assets/task-commits-BYozE_X3.js +0 -1
- package/web/dist/assets/task-composer-Brx0sa7_.js +0 -12
- package/web/dist/assets/task-files-MAPO-efK.js +0 -1
- package/web/dist/assets/task-graph-BSLCUr1E.js +0 -1
- package/web/dist/assets/task-thread-CRVmwchQ.js +0 -9
- package/web/dist/assets/textarea-Bb0_Hz53.js +0 -1
- package/web/dist/assets/thread-loading-Bo6IOu3Y.js +0 -1
- package/web/dist/assets/toaster-Hj_czp_o.js +0 -3
- package/web/dist/assets/tooltip--PYfu68E.js +0 -1
- package/web/dist/assets/tracker-DM5WtYD0.js +0 -4
- package/web/dist/assets/trash-2-EdjdGvEo.js +0 -1
- package/web/dist/assets/triangle-alert-DpH3QFz6.js +0 -1
- package/web/dist/assets/use-automations-XKvBTPM-.js +0 -5
- package/web/dist/assets/use-now-CrM50BFB.js +0 -1
- package/web/dist/assets/use-submit-shortcut-BJ10ZshV.js +0 -1
- package/web/dist/assets/workflow-graph-Y2Pr7ubb.js +0 -13
- package/web/dist/assets/x-BkwTUDpG.js +0 -1
|
@@ -1,18 +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{Ft as r,Ji as i,Wr as a,Wt as o,dt as s,m as c,n as l,x as u}from"./toaster-Hj_czp_o.js";import{F as d,mt as f,r as p,t as m}from"./button-CjSjKnkd.js";import{a as h,i as ee,o as te,s as g}from"./editable-title-CJSWyCcL.js";import{a as ne,i as re,m as ie,r as ae}from"./reference-chip-Bx_mG9QG.js";import{t as oe}from"./check-DAAMuI4o.js";import{a as _,c as se,n as v,o as ce,r as le,t as y}from"./dropdown-menu-DkEK7m00.js";import{_ as b,c as ue,n as de,s as fe,t as x}from"./use-now-CrM50BFB.js";import{t as pe}from"./x-BkwTUDpG.js";import{t as me}from"./use-submit-shortcut-BJ10ZshV.js";var he=d(`arrow-up`,[[`path`,{d:`m5 12 7-7 7 7`,key:`hav0vg`}],[`path`,{d:`M12 19V5`,key:`x0mq9r`}]]),ge=d(`mic`,[[`path`,{d:`M12 19v3`,key:`npa21l`}],[`path`,{d:`M19 10v2a7 7 0 0 1-14 0v-2`,key:`1vc78b`}],[`rect`,{x:`9`,y:`2`,width:`6`,height:`13`,rx:`3`,key:`s6n7sd`}]]),_e=d(`paperclip`,[[`path`,{d:`m16 6-8.414 8.586a2 2 0 0 0 2.829 2.829l8.414-8.586a4 4 0 1 0-5.657-5.657l-8.379 8.551a6 6 0 1 0 8.485 8.485l8.379-8.551`,key:`1miecu`}]]),S=e(t(),1),C=n(),ve=new Set([`ai`,`cezar`,`agents`,`team`]);function w(e){return ve.has(e.source)}function ye(e){return[...e].sort((e,t)=>Number(!w(e))-Number(!w(t)))}var be=5;function T(e,t,{mostUsedLimit:n=be}={}){let r=e.map((e,n)=>({skill:e,index:n,count:D(t,e.name)})).filter(e=>e.count>0).sort((e,t)=>t.count-e.count||Number(!w(e.skill))-Number(!w(t.skill))||e.index-t.index).slice(0,n).map(e=>e.skill),i=new Set(r),a=e.filter(e=>!i.has(e));return{mostUsed:r,project:a.filter(w),global:a.filter(e=>!w(e))}}function E(e,t){let n=T(e,t);return[...n.mostUsed,...n.project,...n.global]}function D(e,t){if(!e||!Object.hasOwn(e,t))return 0;let n=e[t];return typeof n==`number`?n:0}function xe(e,t){return{...e,[t]:D(e,t)+1}}function Se(e,t){if(t===``)return!0;let n=e.toLowerCase(),r=t.toLowerCase(),i=0;for(let e of r){if(i=n.indexOf(e,i),i===-1)return!1;i+=1}return!0}function O(e,t){let n=[];for(let r of e)for(let e of r.steps??[])e.skill===t&&n.push(`${r.name} › ${e.name??e.id}`);return n}var k=/[\s\-/_.]/;function Ce(e,t){let n=0;for(let r=e.indexOf(t);r!==-1;r=e.indexOf(t,r+1)){let i=1,a=e[r-1];if(r===0||a!==void 0&&k.test(a)){let n=e[r+t.length];i=n===void 0||k.test(n)?3:2}if(i>n&&(n=i),n===3)break}return n}function A(e,t,n){let r=t.toLowerCase().split(/\s+/).filter(Boolean);if(r.length===0)return 1;let i=[e,...n??[]].join(` `).toLowerCase(),a=0;for(let e of r){let t=Ce(i,e);if(t===0)return 0;a+=t}return a/(r.length*3)}function j(e,t){if(t===``)return 1;let n=e.toLowerCase(),r=t.toLowerCase();if(n===r)return 6;if(n.startsWith(r))return 5;let i=n.indexOf(r);if(i>0){let e=n[i-1];return e!==void 0&&k.test(e)?4:3}return+!!Se(n,r)}function M(e,t){let n=e.split(`-`).filter(Boolean);return t?[...n,t]:n}var N=10;function P(e,t,n){let r=n.toLowerCase().split(/\s+/).filter(Boolean);if(r.length===0)return 1;let i=0;for(let n of r){let r=j(e,n),a=t?j(t,n):0;if(r===0&&a===0)return 0;i+=r>0?r+N:a}return i}var F=.5;function I(e,t,n){return t.trim()===``?[...e]:e.map((e,r)=>{let i=P(e.name,e.description,t),a=D(n,e.name),o=Math.min(a,be)*F;return{item:e,index:r,count:a,score:i>0?i+o:0}}).filter(e=>e.score>0).sort((e,t)=>t.score-e.score||t.count-e.count||e.index-t.index).map(e=>e.item)}function L(e,t,n){return I(e,t,n)}function we(e,t){return I(e,t)}function Te(e,t,n){return I(E(e,n),t,n)}function Ee(e){if(!(e instanceof HTMLElement))return!1;let t=e.tagName;return t===`INPUT`||t===`TEXTAREA`||t===`SELECT`||e.isContentEditable?!0:e.closest(`[contenteditable=""], [contenteditable="true"]`)!==null}function De(e){return e instanceof HTMLElement&&e.closest(`[cmdk-input]`)!==null}function Oe(e,t){return!(typeof e.key!=`string`||e.key.toLowerCase()!==t.toLowerCase()||!e.metaKey&&!e.ctrlKey||e.altKey||e.shiftKey||e.repeat||Ee(e.target)&&!De(e.target))}function ke(e,t){let n=S.useRef(t);S.useLayoutEffect(()=>{n.current=t}),S.useEffect(()=>{let t=t=>{Oe(t,e)&&(t.preventDefault(),n.current(t))};return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},[e])}function R(e,t){return!(typeof e.key!=`string`||e.key.toLowerCase()!==t.toLowerCase()||e.metaKey||e.ctrlKey||e.altKey||e.shiftKey||e.repeat||Ee(e.target))}function Ae(e,t=typeof navigator>`u`?``:navigator.platform){let n=e.toUpperCase();return/mac|iphone|ipad|ipod/i.test(t)?`⌘${n}`:`Ctrl+${n}`}function z(e,t){let n=S.useRef(t);S.useLayoutEffect(()=>{n.current=t}),S.useEffect(()=>{let t=t=>{R(t,e)&&n.current(t)};return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},[e])}function B(){let e=u(),t=s(),n=(e.data?.profiles??[]).map(e=>({provider:e.provider,id:e.id,label:e.label,configDir:e.configDir})),r=t.data?.info?.root;return{accounts:n,repoAccount:V(r?e.data?.selections?.[r]:void 0,e.data?.defaults)}}function V(e,t){let n={};for(let r of[t,e])for(let[e,t]of Object.entries(r??{}))t&&(n[e]=t);return Object.keys(n).length>0?n:void 0}function H(e,t){return e.filter(e=>e.provider===t).length>1}var U=`inline-flex h-[26px] 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 disabled:pointer-events-none disabled:opacity-55`,W=(0,C.jsx)(ie,{"aria-hidden":`true`,className:`size-2.5 shrink-0 text-soft-foreground`});function je({active:e=!1,skill:t=!1,dashed:n=!1,chevron:r=!1,icon:i,className:a,children:o,type:s=`button`,...c}){return(0,C.jsxs)(`button`,{type:s,"data-slot":`chip`,"data-active":e?`true`:void 0,"data-skill":t?`true`:void 0,className:p(U,e&&`border-foreground font-semibold text-foreground`,t&&`border-violet font-mono font-semibold text-foreground`,n&&`border-dashed`,a),...c,children:[i,o,r?W:null]})}function G({slot:e,ariaLabel:t,label:n,value:r,options:i,onPick:a,disabled:o=!1,readOnly:s=!1,hint:c,disabledHint:l,status:u,searchPlaceholder:d}){let[f,p]=(0,S.useState)(!1),[m,h]=(0,S.useState)(``),ee=(0,S.useRef)(null),te=(0,S.useRef)(null),g=d?i.filter(e=>e.label.toLowerCase().includes(m.trim().toLowerCase())):i;if((0,S.useEffect)(()=>{if(!f||!d)return;let e=window.setTimeout(()=>ee.current?.focus());return()=>window.clearTimeout(e)},[f,d]),s)return(0,C.jsx)(`span`,{"data-slot":e,"aria-label":t,title:l??c,className:`${U} cursor-default hover:bg-card hover:text-muted-foreground`,children:n});let ne=(0,C.jsxs)(`button`,{type:`button`,"data-slot":e,"aria-label":t,disabled:o,title:o?l:c,className:U,children:[n,W]});return o?(0,C.jsx)(`span`,{title:l,className:`inline-flex`,children:ne}):(0,C.jsxs)(y,{open:f,onOpenChange:e=>{p(e),e||h(``)},children:[(0,C.jsx)(se,{asChild:!0,children:ne}),(0,C.jsxs)(v,{ref:te,align:`start`,"data-testid":`${e}-menu`,children:[d?(0,C.jsxs)(`div`,{className:`mb-1 flex h-9 items-center gap-2 border-b border-border px-2`,children:[(0,C.jsx)(b,{"aria-hidden":`true`,className:`size-3.5 shrink-0 text-muted-foreground`}),(0,C.jsx)(`input`,{ref:ee,type:`search`,"aria-label":d,placeholder:d,value:m,onChange:e=>h(e.target.value),onKeyDown:e=>{if(e.key===`ArrowDown`||e.key===`ArrowUp`){e.preventDefault(),e.stopPropagation();let t=te.current?.querySelectorAll(`[role="menuitemradio"]:not([data-disabled])`);(e.key===`ArrowDown`?t?.[0]:t?.[t.length-1])?.focus()}else e.key!==`Escape`&&e.stopPropagation()},className:`h-full min-w-48 bg-transparent text-sm outline-none placeholder:text-muted-foreground`})]}):null,(0,C.jsx)(_,{value:r,onValueChange:a,children:g.map(e=>(0,C.jsx)(ce,{value:e.value,className:`gap-2.5`,children:(0,C.jsxs)(`span`,{className:`flex min-w-0 flex-col`,children:[(0,C.jsx)(`span`,{className:`text-[12.5px] font-medium`,children:e.label}),e.desc?(0,C.jsx)(`span`,{className:`max-w-[calc(100vw-3rem)] whitespace-normal break-words text-[11.5px] text-muted-foreground md:max-w-96`,children:e.desc}):null]})},e.value))}),d&&g.length===0?(0,C.jsx)(`p`,{className:`px-2 py-5 text-center text-xs text-muted-foreground`,children:`No branches found.`}):null,u?(0,C.jsx)(le,{disabled:!0,className:`border-t border-border text-[11.5px] text-muted-foreground`,children:u}):null]})]})}var K=(e,t)=>t===null?e:`${e}:${t}`;function q({runners:e,value:t,onPick:n,disabled:r=!1,accounts:i=[],account:a=null,repoAccount:o}){let s=g.filter(t=>e.includes(t.id)).flatMap(e=>{let t=i.filter(t=>t.provider===e.id);return t.length<2?[{value:K(e.id,null),label:e.id,desc:e.desc}]:t.map(t=>({value:K(e.id,t.id),label:`${e.id} · ${t.label}`,desc:t.configDir}))}),c=a??o?.[t]??`default`,l=s.some(e=>e.value===K(t,c))?K(t,c):K(t,null);return(0,C.jsx)(G,{slot:`runner-pill`,ariaLabel:`Runner`,label:s.find(e=>e.value===l)?.label??t,value:l,disabled:r,onPick:e=>{let[t,r]=e.split(`:`);n(t,r??null)},options:s})}var J=80,Y=f,X=50,Me=200,Ne=50,Z=[{id:`add-tests`,label:`Add tests`,text:`Also add or update tests covering this change.`},{id:`explain-change`,label:`Explain the change`,text:`Explain what changed and why before finishing.`},{id:`keep-minimal`,label:`Keep it minimal`,text:`Keep the change as small and targeted as possible — no unrelated refactors.`},{id:`update-docs`,label:`Update docs`,text:`Also update any relevant documentation or comments.`},{id:`check-edge-cases`,label:`Double-check edge cases`,text:`Double-check edge cases and error handling before finishing.`},{id:`review-open-prs`,label:`Review open PRs`,text:'Check this repository\'s open pull requests that still need a review (use `gh pr list --state open --json number,title,headRefName,isDraft,reviewDecision` and skip drafts and PRs already approved). For each one, dispatch a separate review task with `cez task create --kind review --review-of <headRefName> --title "Review PR #<number>" "Review pull request #<number> (<title>) on branch <headRefName>: read the diff, run the tests, and report a verdict with findings."`, at most 4 at a time. Then end your turn with CEZ:MONITORING and, when their reports arrive, summarise every verdict in one message. If `cez task create` is refused or unavailable, stop and report that dispatch is disabled on this cockpit — do not review the PRs yourself and do not use sub-agents instead.'},{id:`create-automation`,label:`Create an automation`,skills:[`create-cezar-automation`],text:`Create an automation for this repository.
|
|
2
|
-
Trigger: <when — e.g. every new pull request; every issue labelled \`needs-agent\`; every day at 04:00; weekdays at 07:30; every 6 hours>.
|
|
3
|
-
Task for each run: <what the launched task must do — e.g. review the diff, run the tests and post findings as a review comment>.
|
|
4
|
-
Leave it paused and, for a GitHub trigger, preview its matches so I can check the filter before enabling it.`}],Pe=new Set([`review-open-prs`]),Fe=new Set([`create-automation`]);function Q(e,t){return e.filter(e=>(t?.dispatch===!0||!Pe.has(e.id))&&(t?.automations===!0||!Fe.has(e.id)))}function $(e){return!!e&&typeof e==`object`}function Ie(e){if(e===void 0||!Array.isArray(e))return Z.map(e=>({...e}));let t=new Set,n=[];for(let r of e){if(!$(r))continue;let e=typeof r.id==`string`?r.id.trim():``,i=typeof r.label==`string`?r.label.trim():``,a=typeof r.text==`string`?r.text.trim():``;if(!e||!i||!a||t.has(e))continue;t.add(e);let o=Le(r.skills);if(n.push({id:e,label:i.slice(0,J),text:a.slice(0,Y),...o.length>0?{skills:o}:{}}),n.length>=X)break}return n}function Le(e){if(!Array.isArray(e))return[];let t=new Set;for(let n of e){if(typeof n!=`string`)continue;let e=n.trim();if(!(!e||t.has(e))&&(t.add(e.slice(0,Me)),t.size>=Ne))break}return[...t]}function Re(e,t){if(t.length===0)return[];let n=new Set(t);return e.filter(e=>e.skills?.some(e=>n.has(e)))}function ze(e,t){return Re(e,t).map(e=>e.text).join(`
|
|
5
|
-
|
|
6
|
-
`)}function Be(e,t,n,r=``){if(e===``||e===r||e===t){let e=r&&n?`${r}\n\n${n}`:r||n;return{text:e,applied:n?e:``}}return{text:e,applied:t}}function Ve(){return`tpl-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}`}function He(e,t,n){let r=Math.max(0,Math.min(t,e.length)),i=e.slice(0,r),a=e.slice(r),o=``;i.length>0&&(o=i.endsWith(`
|
|
7
|
-
|
|
8
|
-
`)?``:i.endsWith(`
|
|
9
|
-
`)?`
|
|
10
|
-
`:`
|
|
11
|
-
|
|
12
|
-
`);let s=a.replace(/^[ \t]+/,``),c=``;return s.length>0&&(c=s.startsWith(`
|
|
13
|
-
|
|
14
|
-
`)?``:s.startsWith(`
|
|
15
|
-
`)?`
|
|
16
|
-
`:`
|
|
17
|
-
|
|
18
|
-
`),{text:i+o+n+c+s,caret:i.length+o.length+n.length}}var Ue=new Set([`/`,`@`]);function We(e,t){for(let n=t-1;n>=0;--n){let r=e[n];if(/\s/.test(r))return null;if(Ue.has(r))return n>0&&!/\s/.test(e[n-1])?null:{trigger:r,start:n,query:e.slice(n+1,t)}}return null}function Ge(e,t,n,r){let i=`${t.trigger}${r} `;return{text:e.slice(0,t.start)+i+e.slice(n),caret:t.start+i.length}}function Ke(){let e=window;return e.SpeechRecognition??e.webkitSpeechRecognition}function qe(e,t){let n=e,r=``;for(let e=t.resultIndex;e<t.results.length;e+=1){let i=t.results[e],a=i[0]?.transcript??``;i.isFinal?n+=a:r+=a}return{finalText:n,interim:r}}function Je(e){let[t,n]=S.useState(null),r=S.useRef(null),i=S.useRef(``),[a]=S.useState(()=>Ke()!==void 0),o=S.useCallback(()=>{let e=r.current;r.current=null,i.current=``,n(null),e&&(e.onresult=null,e.onerror=null,e.onend=null,e.abort())},[]);return S.useEffect(()=>o,[o]),{supported:a,recording:t,start:S.useCallback(()=>{if(r.current)return;let t=Ke();if(!t)return;let a;try{a=new t,a.lang=navigator.language||`en-US`,a.continuous=!0,a.interimResults=!0;let s=Date.now();a.onresult=e=>{let t=qe(i.current,e);i.current=t.finalText,n({transcript:t.finalText+t.interim,startedAt:s})},a.onerror=t=>{e(`Dictation failed${t.error?` — ${t.error}`:``}`),o()},a.start(),r.current=a,n({transcript:``,startedAt:s})}catch{e(`Dictation failed — the microphone could not be started`),o()}},[e,o]),cancel:S.useCallback(()=>o(),[o]),finish:S.useCallback(()=>{let e=r.current,a=(i.current+``).trim()===``?``:i.current,o=t?.transcript??a;return e&&(e.onresult=null,e.onerror=null,e.onend=null,e.stop()),r.current=null,i.current=``,n(null),o.trim()},[t])}}function Ye(e,t){let n=Math.max(0,Math.floor((t-e)/1e3));return`${Math.floor(n/60)}:${String(n%60).padStart(2,`0`)}`}var Xe={KeyA:`Yes, approved.`,KeyC:`Continue.`};function Ze({onSubmit:e,value:t,onValueChange:n,images:s,onImagesChange:u,autoFocus:d=!1,draftItems:f,footerStart:g,footerEnd:ie,sendAriaLabel:oe=`Send`,disabled:_=!1,disabledReason:se=`Session closed — Continue to reopen.`,allowEmptySubmit:v=!1,placeholder:ce=`Reply — / for skills, @ for files…`,ariaLabel:le=`Reply to the agent`,autocompleteSkills:y=!0,quickReplies:b=!1,getMentionCandidates:x,ref:ve}){let[ye,be]=(0,S.useState)(``),T=t??ye,E=(0,S.useRef)(T);E.current=T;let D=(0,S.useRef)(n);D.current=n;let O=(0,S.useCallback)(e=>{let t=typeof e==`function`?e(E.current):e;be(t),D.current?.(t)},[]),[k,Ce]=(0,S.useState)([]),A=s??k,j=(0,S.useRef)(A);j.current=A;let M=(0,S.useRef)(u);M.current=u;let N=(0,S.useCallback)((e,t=`edit`)=>{let n=typeof e==`function`?e(j.current):e;j.current=n,Ce(n),M.current?.(n,t)},[]),[P,F]=(0,S.useState)(!1),[I,L]=(0,S.useState)(null),[we,De]=(0,S.useState)(``),[Oe,ke]=(0,S.useState)(!1),R=(0,S.useRef)(null),Ae=(0,S.useRef)(null),z=(0,S.useRef)(null),B=(0,S.useRef)(new Map),V=r(y&&Oe),H=o(),U=i(),W=Je(e=>l(e,{tone:`danger`}));(0,S.useEffect)(()=>{d&&R.current?.focus()},[]),(0,S.useImperativeHandle)(ve,()=>({insertAtCaret:e=>{let t=R.current,n=He(E.current,t?.selectionStart??E.current.length,e);O(n.text),z.current=n.caret,t?.focus()}}),[O]);let je=(0,S.useCallback)(()=>{let e=R.current;if(!e||_){L(null);return}let t=We(e.value,e.selectionStart??e.value.length);if(t?.trigger===`/`&&!y||t?.trigger===`@`&&x===void 0)return L(null);t?.trigger===`/`&&ke(!0),L(t)},[y,_,x]),G=(0,S.useMemo)(()=>I===null?[]:I.trigger===`/`?Te(V.data??[],I.query,H.data?.skillUsage).map(e=>({value:`${e.name} ${e.path}`,insert:e.name,label:e.name,description:e.description,emphasized:w(e)})):(x?.()??[]).filter(e=>Se(e,I.query)).map(e=>({value:e,insert:e,label:e,emphasized:!1})),[x,V.data,I,H.data?.skillUsage]),K=G.some(e=>e.value===we)?we:G[0]?.value,q=I!==null,J=(0,S.useCallback)(()=>L(null),[]),Y=e=>{let t=R.current;if(!t||I===null)return;let n=t.selectionStart??t.value.length,r=Ge(t.value,I,n,e.insert);I.trigger===`/`&&H.data!==void 0&&a({skillUsage:xe(H.data.skillUsage,e.insert)}).then(()=>U.invalidateQueries({queryKey:c.uiState})).catch(()=>{}),O(r.text),z.current=r.caret,L(null),t.focus()};(0,S.useEffect)(()=>{!q||K==null||B.current.get(K)?.scrollIntoView({block:`nearest`})},[K,q]),(0,S.useLayoutEffect)(()=>{let e=z.current,t=R.current;e!==null&&t&&(t.setSelectionRange(e,e),z.current=null)},[T]),(0,S.useLayoutEffect)(()=>{let e=R.current;e&&(e.style.height=`auto`,e.style.height=`${Math.min(e.scrollHeight,220)}px`)},[T]);let X=(0,S.useCallback)((e,t=`file`)=>{if(_)return;let n=h(e,j.current.length);for(let e of n.rejected)l(e,{tone:`danger`});for(let e of n.accepted)ee(e,t).then(e=>N(t=>t.length>=4?t:[...t,e]))},[_]),Me=e=>{let t=[...e.clipboardData?.items??[]].filter(e=>e.kind===`file`).map(e=>e.getAsFile()).filter(e=>e!==null);t.length!==0&&(e.preventDefault(),X(t,`clipboard`))},Ne=e=>{let t=[...e.dataTransfer?.files??[]];t.length!==0&&(e.preventDefault(),X(t))},Z=(0,S.useCallback)(async(t,n,r,i)=>{let a=t.trim();if(!(_||P)&&!(a===``&&n.length===0&&!v)){F(!0);try{let t=n.map(te);await(i?e(a,t,i):e(a,t))}catch(e){l(e instanceof Error?e.message:String(e),{tone:`danger`}),r&&(O(e=>e===``?t:`${t}\n${e}`),N(e=>[...n,...e].slice(0,4)))}finally{F(!1)}}},[v,P,_,e]),Pe=(0,S.useCallback)(()=>{if(T.trim()===``&&A.length===0&&!v)return;let e=T,t=A;O(``),N([],`submit`),L(null),Z(e,t,!0)},[v,A,Z,T]),Fe=e=>{if(q){if(e.key===`ArrowDown`||e.key===`ArrowUp`){if(e.preventDefault(),G.length===0)return;let t=G.findIndex(e=>e.value===K),n=e.key===`ArrowDown`?1:-1,r=G[(t+n+G.length)%G.length];De(r.value);return}if(e.key===`Escape`){e.preventDefault(),J();return}if((e.key===`Enter`||e.key===`Tab`)&&!e.shiftKey){let t=G.find(e=>e.value===K);if(t){e.preventDefault(),Y(t);return}J()}}me({key:e.key,shiftKey:e.shiftKey,metaKey:e.metaKey,ctrlKey:e.ctrlKey,altKey:e.altKey,repeat:e.repeat,isComposing:e.nativeEvent.isComposing})&&(e.preventDefault(),Pe())};(0,S.useEffect)(()=>{if(!b||_)return;let e=e=>{if(!e.altKey||e.metaKey||e.ctrlKey||e.repeat||Ee(e.target))return;let t=Xe[e.code];t!==void 0&&(e.preventDefault(),Z(t,[],!1,{quickReply:!0}))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[_,b,Z]);let Q=e=>{let t=W.finish();if(t===``)return;let n=T.trim()===``?t:`${T.replace(/\s*$/,``)} ${t}`;if(e){O(``),N([],`submit`),Z(n,A,!0);return}O(n),z.current=n.length,R.current?.focus()},$=W.recording;return(0,C.jsxs)(ae,{open:q,onOpenChange:e=>e?void 0:J(),children:[(0,C.jsx)(re,{asChild:!0,children:(0,C.jsxs)(`div`,{ref:Ae,"data-slot":`composer`,"data-disabled":_||void 0,onDrop:Ne,onDragOver:e=>e.preventDefault(),className:p(`rounded-xl border border-border bg-card shadow-xs transition-[border-color,box-shadow]`,`focus-within:border-ring focus-within:ring-[3px] focus-within:ring-ring/15`,_&&`opacity-80`),children:[A.length>0||f?(0,C.jsxs)(`div`,{"data-slot":`composer-thumbs`,className:`flex flex-wrap items-center gap-2 px-4 pt-3`,children:[f,A.map((e,t)=>(0,C.jsxs)(`button`,{type:`button`,"aria-label":`Remove ${e.name}`,title:`Click to remove`,className:p(`group relative overflow-hidden rounded-md border border-border`,e.isImage?`size-12`:`flex h-12 max-w-[200px] items-center gap-1.5 bg-muted/40 px-2.5 text-xs text-muted-foreground`),onClick:()=>N(e=>e.filter((e,n)=>n!==t)),children:[e.isImage?(0,C.jsx)(`img`,{src:e.preview,alt:``,className:`size-full object-cover`}):(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(_e,{"aria-hidden":`true`,className:`size-3.5 shrink-0`}),(0,C.jsx)(`span`,{className:`truncate`,children:e.name})]}),(0,C.jsx)(`span`,{className:`absolute inset-0 hidden items-center justify-center bg-background/70 group-hover:flex group-focus-visible:flex`,children:(0,C.jsx)(pe,{"aria-hidden":`true`,className:`size-4`})})]},`${e.name}-${t}`))]}):null,(0,C.jsx)(`textarea`,{ref:R,rows:1,value:T,disabled:_,"aria-label":le,placeholder:_?se:ce,className:`block max-h-[220px] min-h-11 w-full resize-none bg-transparent px-3 pt-2.5 pb-1 text-base leading-normal outline-none placeholder:text-muted-foreground disabled:cursor-not-allowed md:min-h-[54px] md:px-4 md:pt-3 md:text-sm`,onChange:e=>{O(e.target.value),je()},onKeyDown:Fe,onSelect:je,onPaste:Me}),$?(0,C.jsx)($e,{transcript:$.transcript,startedAt:$.startedAt,onCancel:W.cancel,onInsert:()=>Q(!1),onInsertAndSend:()=>Q(!0)}):(0,C.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1 gap-y-1 px-1.5 pt-1 pb-1.5 md:gap-y-1.5 md:px-2 md:pt-1.5 md:pb-2`,children:[(0,C.jsxs)(`div`,{"data-slot":`composer-footer-start`,className:`flex min-w-0 flex-wrap items-center gap-1`,children:[(0,C.jsx)(Qe,{disabled:_,onFiles:X}),g]}),(0,C.jsxs)(`div`,{className:`ml-auto flex items-center gap-1`,children:[W.supported?(0,C.jsxs)(m,{type:`button`,variant:`ghost`,size:`sm`,disabled:_,"aria-label":`Start dictation`,title:`Dictation`,className:`h-8 gap-1.5 px-2.5 text-xs font-medium text-muted-foreground`,onClick:W.start,children:[(0,C.jsx)(ge,{"aria-hidden":`true`,className:`size-3.5`}),`Dictation`]}):null,ie?(0,C.jsx)(`div`,{"data-slot":`composer-footer-end`,className:`flex items-center gap-1.5`,children:ie}):null,(0,C.jsx)(m,{type:`button`,size:`icon-sm`,"aria-label":oe,disabled:_||P||T.trim()===``&&A.length===0&&!v,className:`size-8`,onClick:Pe,children:(0,C.jsx)(he,{"aria-hidden":`true`})})]})]})]})}),(0,C.jsx)(ne,{side:`top`,align:`start`,sideOffset:8,className:`w-80 max-w-[calc(100vw-2rem)] p-0`,onOpenAutoFocus:e=>e.preventDefault(),onInteractOutside:e=>{Ae.current?.contains(e.target)&&e.preventDefault()},children:(0,C.jsx)(de,{shouldFilter:!1,value:K??``,onValueChange:De,children:(0,C.jsx)(ue,{"data-slot":`composer-menu`,"data-trigger":I?.trigger,className:`max-h-[min(16rem,var(--radix-popover-content-available-height))] p-1`,children:G.length===0?(0,C.jsx)(`p`,{className:`px-3 py-4 text-center text-xs text-muted-foreground`,children:I?.trigger===`@`?`No files seen in this session yet — full file search arrives with the Files tab.`:V.isPending?`Loading skills…`:`No matching skills.`}):G.map(e=>(0,C.jsxs)(fe,{ref:t=>{t?B.current.set(e.value,t):B.current.delete(e.value)},value:e.value,"data-slot":`composer-menu-item`,"data-emphasized":e.emphasized||void 0,onSelect:()=>Y(e),children:[(0,C.jsx)(`span`,{className:p(`shrink-0 truncate`,e.emphasized&&`font-semibold`,I?.trigger===`@`&&`font-mono text-xs`),children:e.label}),e.description?(0,C.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs text-soft-foreground`,children:e.description}):null]},e.value))})})})]})}function Qe({disabled:e,onFiles:t}){let n=(0,S.useRef)(null);return(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(m,{type:`button`,variant:`ghost`,size:`icon-sm`,"aria-label":`Attach files`,title:`Attach an image, PDF, TXT or MD file (or paste a screenshot)`,disabled:e,className:`size-8 text-muted-foreground`,onClick:()=>n.current?.click(),children:(0,C.jsx)(_e,{"aria-hidden":`true`,className:`size-[15px]`})}),(0,C.jsx)(`input`,{ref:n,type:`file`,accept:`image/*,application/pdf,text/plain,text/markdown,.pdf,.txt,.md,.markdown,.log`,multiple:!0,className:`hidden`,"aria-hidden":`true`,tabIndex:-1,onChange:e=>{t([...e.target.files??[]]),e.target.value=``}})]})}function $e({transcript:e,startedAt:t,onCancel:n,onInsert:r,onInsertAndSend:i}){let a=x(1e3);return(0,C.jsxs)(`div`,{"data-slot":`dictation-overlay`,role:`status`,"aria-label":`Dictation in progress`,className:`flex items-center gap-2.5 rounded-b-xl border-t border-border bg-muted/60 px-3 py-2`,children:[(0,C.jsx)(`span`,{"aria-hidden":`true`,className:`size-2 flex-none animate-pulse rounded-full bg-danger motion-reduce:animate-none`}),(0,C.jsx)(`span`,{"data-slot":`dictation-timer`,className:`text-xs font-medium text-muted-foreground tabular-nums`,children:Ye(t,a)}),(0,C.jsx)(`span`,{"data-slot":`dictation-transcript`,"aria-live":`polite`,className:`min-w-0 flex-1 truncate text-sm text-foreground`,children:e===``?(0,C.jsx)(`span`,{className:`text-muted-foreground`,children:`Listening…`}):e}),(0,C.jsx)(m,{type:`button`,variant:`ghost`,size:`icon-sm`,"aria-label":`Cancel dictation`,className:`size-8 text-muted-foreground`,onClick:n,children:(0,C.jsx)(pe,{"aria-hidden":`true`})}),(0,C.jsx)(m,{type:`button`,variant:`outline`,size:`icon-sm`,"aria-label":`Insert transcription`,className:`size-8`,onClick:r,children:(0,C.jsx)(oe,{"aria-hidden":`true`})}),(0,C.jsx)(m,{type:`button`,size:`icon-sm`,"aria-label":`Insert transcription and send`,className:`size-8`,onClick:i,children:(0,C.jsx)(he,{"aria-hidden":`true`})})]})}export{M as A,A as C,P as D,T as E,_e as M,L as O,w as S,E as T,Ae as _,Q as a,xe as b,Ie as c,q as d,je as f,B as g,H as h,ze as i,O as j,we as k,Be as l,U as m,Z as n,He as o,W as p,Y as r,Ve as s,Ze as t,G as u,ke as v,ye as w,Te as x,z as y};
|
|
@@ -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{$t as r,An as i,Bi as a,Gn as o,Ji as s,Ki as c,Kr as l,Mn as u,Ni as d,Or as f,Q as p,R as m,Rn as h,Ui as g,Zt as _,gi as v,gn as y}from"./toaster-Hj_czp_o.js";import{$ as b,F as x,J as S,Q as C,X as w,Y as T,Z as ee,ht as E,t as D,tt as O}from"./button-CjSjKnkd.js";import{A as te,C as ne,E as re,M as k,N as A,O as j,P as M,T as ie,_ as ae,b as oe,c as se,d as ce,f as le,g as ue,h as de,i as fe,j as pe,m as me,p as he,v as ge,w as _e,x as ve,y as ye}from"./use-automations-XKvBTPM-.js";import{a as be,i as xe,o as Se,r as Ce,t as we}from"./sheet-DCdZVHFk.js";import{a as Te,h as Ee,m as De,o as Oe,r as ke,t as Ae}from"./reference-chip-Bx_mG9QG.js";import{a as je,f as N,p as Me,r as Ne}from"./automation-format-D1nqk0ID.js";import{t as Pe}from"./chevron-right-DKiL3NWw.js";import{t as Fe}from"./download-BFQEsJRY.js";import{t as Ie}from"./use-now-CrM50BFB.js";import{i as Le,n as Re,r as ze,t as Be}from"./tooltip--PYfu68E.js";import{i as P,r as F,t as Ve}from"./token-metrics-C149OWmd.js";import{t as He}from"./index-CiQrbvAq.js";var Ue=x(`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`}]]),We=x(`arrow-down-left`,[[`path`,{d:`M17 7 7 17`,key:`15tmo1`}],[`path`,{d:`M17 17H7V7`,key:`1org7z`}]]),Ge=x(`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`}]]),Ke=x(`circle-question-mark`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3`,key:`1u773s`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]]),qe=x(`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`}]]),Je=x(`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`}]]),I=e(t(),1);function Ye(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 Xe(e){return e.flatMap(e=>(e.data?.automations??[]).filter(e=>e.enabled).map(t=>({project:e,automation:t,at:Ye(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 Ze(e){let t=p(),n=s(),i=t.data?.projects??[],a=t.data?.bootProject,l=a&&!i.some(e=>e.id===a)?[...i,{id:a,name:a,status:`ok`}]:i,u=c({queryKey:[...r.dashboard,`automations`,l.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<l.length&&!e.aborted;){let r=l[t++];if(r.status===`missing`){n.push({...r,error:`Project folder unavailable`});continue}try{let t=O.parse(await v(await o.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,I.useEffect)(()=>{if(e)return j(e=>{e===`automation-change`&&n.invalidateQueries({queryKey:[...r.dashboard,`automations`]})})},[n,e]),{...u,registry:t,retry:()=>{t.refetch(),u.refetch()}}}var L=n();function R({rows:e}){return(0,L.jsx)(`span`,{hidden:!0,"data-dashboard-export":JSON.stringify(e)})}var z=`section-mark font-mono text-[11px] font-semibold uppercase tracking-[0.14em] text-muted-foreground`,B=`flex min-h-12 flex-wrap items-center justify-between gap-x-3 gap-y-2 border-b px-4 py-2.5`,Qe=`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 V(){return(0,L.jsx)(Pe,{"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 $e=`flex items-center gap-2 text-xs text-muted-foreground`;function et({className:e=``,...t}){return(0,L.jsxs)(`span`,{className:`relative inline-flex`,children:[(0,L.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,L.jsx)(De,{"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 tt=`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`,H={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 nt({label:e,value:t,icon:n,children:r}){return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`span`,{className:`flex w-full items-center justify-between gap-2`,children:[(0,L.jsx)(`span`,{className:`font-mono text-[11px] font-medium uppercase tracking-[0.12em] text-muted-foreground`,children:e}),(0,L.jsx)(`span`,{className:`text-soft-foreground`,"aria-hidden":`true`,children:n})]}),(0,L.jsx)(`span`,{className:`mt-4 block text-4xl font-semibold leading-none tracking-tight tabular-nums`,children:t}),(0,L.jsx)(`span`,{className:`mt-3 block text-xs text-soft-foreground`,children:r})]})}function rt({at:e}){return(0,L.jsxs)(`time`,{dateTime:e,title:new Date(e).toLocaleString(),children:[`Updated `,F(e),` ago`]})}function it(){let e=fe(),t=Ze(e.known&&!e.off),n=Ie(3e4),[r,i]=(0,I.useState)(!1),a=Xe(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,L.jsxs)(N,{"data-export-context":`Enabled automations · showing ${o.length} of ${a.length} loaded · ${l?`partial coverage`:`available projects`}`,className:`min-w-0 gap-0 py-0`,children:[(0,L.jsxs)(`div`,{className:B,children:[(0,L.jsxs)(`h2`,{className:`flex items-center ${z}`,children:[`Automations`,(0,L.jsx)(Me,{className:`ml-2 size-3.5 text-soft-foreground`,"aria-hidden":`true`})]}),!e.off&&t.data&&(0,L.jsxs)(`span`,{className:`font-mono text-[11px] text-soft-foreground`,children:[a.length,` enabled`,l?` · partial`:``]})]}),!e.off&&t.data&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(R,{rows:[{section:`automations`,metric:`enabled`,value:a.length,unit:`automations`,note:l?`Partial project coverage`:`Loaded projects`}]}),t.dataUpdatedAt>0&&(0,L.jsx)(`p`,{className:`px-4 pt-3 text-xs text-muted-foreground`,children:(0,L.jsx)(rt,{at:new Date(t.dataUpdatedAt).toISOString()})})]}),e.off?(0,L.jsx)(`p`,{className:`p-4 text-sm text-muted-foreground`,children:`Automations are disabled in this workspace.`}):(0,L.jsxs)(L.Fragment,{children:[c&&(0,L.jsx)(`p`,{className:`p-4 text-sm text-muted-foreground`,children:`Loading automations…`}),l&&(0,L.jsxs)(`div`,{role:`alert`,className:`p-4 text-sm`,children:[(0,L.jsx)(`p`,{children:`Some automation data could not be refreshed. Available results are shown.`}),s.map(e=>(0,L.jsxs)(`p`,{children:[e.name,`: `,e.error]},e.id)),(0,L.jsx)(D,{variant:`ghost`,onClick:t.retry,children:`Retry automations`})]}),!c&&!l&&a.length===0&&(0,L.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`:je(r,n),o=t.kind===`schedule`?`Next run`:`Next check`;return(0,L.jsxs)(`div`,{"data-export-row":!0,className:`border-b px-4 py-3 transition-colors last:border-0 hover:bg-muted/30`,children:[(0,L.jsx)(d,{className:`block min-h-11 text-sm font-medium hover:underline`,to:`/p/${encodeURIComponent(e.id)}/automations/${encodeURIComponent(t.id)}`,children:t.name}),(0,L.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[e.name,` · `,o,`: `,a]}),r!==null&&(0,L.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:(0,L.jsxs)(`time`,{dateTime:new Date(r).toISOString(),children:[Ne(r,e.data.timeZone),` · `,e.data.timeZone]})}),t.kind!==`schedule`&&(0,L.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:`Checks for matching events; a task may not be started.`}),i&&(0,L.jsx)(`p`,{className:`mt-1 text-xs text-warning`,children:i}),(0,L.jsx)(R,{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,L.jsx)(D,{variant:`ghost`,className:`m-2 min-h-11`,onClick:()=>i(!r),children:r?`Show fewer`:`Show all ${a.length} enabled`}),!c&&(0,L.jsxs)(`details`,{className:`border-t px-4 py-2 text-xs text-muted-foreground`,children:[(0,L.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,L.jsx)(V,{}),`Manage automations by project`]}),t.data?.map(e=>(0,L.jsx)(d,{className:`block min-h-11 py-3 hover:underline`,to:`/p/${encodeURIComponent(e.id)}/automations`,children:e.name},e.id))]})]})]})}function at(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 ot(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 st=(0,I.createContext)(``),ct=(0,I.createContext)(!0),U=new Map;function lt(e,t,n=``,r=0,i){let a=(0,I.useContext)(st),o=`${a}:${n}`,[s,c]=(0,I.useState)(()=>U.get(o)),[l,u]=(0,I.useState)(o),d=(0,I.useRef)(r),f=(0,I.useRef)(!1);l!==o&&(u(o),c(U.get(o)),d.current=r,f.current=!1),d.current!==r&&(d.current=r,f.current=!0),(0,I.useEffect)(()=>{e&&(!s||f.current)&&(c(e),f.current=!1)},[s,e]);let p=(0,I.useMemo)(()=>({current:s}),[o]);p.current=s,(0,I.useEffect)(()=>()=>{!a||!p.current||(U.delete(o),U.set(o,p.current),U.size>60&&U.delete(U.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:ot(g,e??m,t),updates:e?at(g,e,t).size:0,show:()=>c(e)}}var ut=new Map;function dt(e){return ut.get(e)}function ft(e,t){ut.delete(e),ut.set(e,t),ut.size>20&&ut.delete(ut.keys().next().value)}var W=new Map;function pt(e,t){return W.get(e)?.[t]}function mt(e,t,n){let r=W.get(e)??{};r[t]=n,W.delete(e),W.set(e,r),W.size>20&&W.delete(W.keys().next().value)}var G=e=>`${e.projectId}:${e.id}`;function ht({row:e,removed:t=!1,queue:n=!1,checking:r=!1,checkFailed:a=!1,kicker:o}){let s=(0,I.useContext)(ct)&&!r&&!a,c=M(e);t=t||c===null||n&&c?.archived===!0,c&&(e={...e,status:c.status,awaitingAnswerSince:c.awaitingAnswerSince});let l=i(e),f=n&&!u(e),p=t||f||!s;return(0,L.jsxs)(`div`,{"data-dashboard-row":G(e),className:`min-w-0 border-b px-4 py-3 transition-colors last:border-0 hover:bg-muted/30`,children:[(0,L.jsx)(R,{rows:[{section:`task`,entity:G(e),metric:`title`,value:e.titleSummary||e.title},{section:`task`,entity:G(e),metric:`status`,value:p?`Not currently actionable`:e.status},{section:`task`,entity:G(e),metric:`createdAt`,value:e.createdAt}]}),o&&(0,L.jsx)(`p`,{className:`mb-1 pl-[15px] font-mono text-[10.5px] uppercase tracking-[0.1em] text-soft-foreground`,children:o}),(0,L.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,L.jsx)(P,{tone:l.tone,className:`mt-[7px]`}),(0,L.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,L.jsx)(d,{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,L.jsxs)(`div`,{className:`mt-1 flex flex-wrap items-center gap-x-2 gap-y-1 text-xs text-muted-foreground`,children:[(0,L.jsx)(`span`,{className:`font-mono text-[11px] text-soft-foreground`,children:e.projectId}),(0,L.jsx)(`span`,{children:a?`Could not check current state`:s?t?n&&c!==null?`No longer needs you`:`Task removed`:f?`No longer needs you`:l.label:`Checking current state…`}),(0,L.jsx)(`span`,{children:F(e.createdAt)}),e.dispatch&&(0,L.jsx)(`span`,{children:`Subtask`}),!p&&y(e).map(t=>(0,L.jsx)(Ae,{reference:t,taskTitle:e.title,projectId:e.projectId,className:`no-hover:min-h-11`},`${t.kind}:${t.number}`))]})]})]})]})}function K({coverage:e,count:t,retry:n}){let r=e.projects.filter(e=>e.state!==`complete`);return r.length?(0,L.jsxs)(`div`,{className:`rounded-lg border border-pending/40 bg-card-2 p-3 text-sm`,role:`status`,children:[(0,L.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,L.jsxs)(`details`,{className:`mt-2`,children:[(0,L.jsxs)(`summary`,{className:`${Qe} min-h-11`,children:[(0,L.jsx)(V,{}),`View unavailable `,r.length===1?`project`:`projects`]}),r.map(e=>(0,L.jsxs)(`p`,{children:[e.projectId,`: `,e.reason??e.state,e.omittedRuns>0?` · ${e.omittedRuns} omitted tasks`:``]},e.projectId))]}),(0,L.jsx)(D,{variant:`outline`,onClick:n,className:`min-h-11`,children:`Retry`})]}):null}function gt(e,t=!1){return e==null?`Unavailable`:t?`$${e.toFixed(e===0||e>=1?2:Math.min(20,Math.max(4,Math.ceil(-Math.log10(e))+1)))}`:e.toLocaleString(`en-US`)}function q(e){return e===null?`Unavailable`:e<1?`${Math.round(e*60)}m`:e<48?`${e.toFixed(1)}h`:`${(e/24).toFixed(1)}d`}function _t(e,t,n){let r=a(),i=r.state?.dashboardEntry??r.key,[o,s]=g(),c=o.get(e);return[c!==null&&t.includes(c)?c:n,t=>s(n=>{let r=new URLSearchParams(n);return r.set(e,t),r},{replace:!0,state:{...r.state,dashboardEntry:i}})]}var vt=e=>`Last ${e===`7d`?7:30} calendar days`,yt=`font-mono text-[11px] font-semibold uppercase tracking-[0.12em] text-muted-foreground`,bt=`min-w-0 rounded-lg border bg-card-2 p-4`,J=`whitespace-nowrap px-3 py-2 font-mono text-[11px] font-medium uppercase tracking-[0.1em] text-soft-foreground`;function xt(){let e=p().data?.projects;return t=>e?.find(e=>e.id===t)?.name??t}var St=(e,t)=>`/p/${encodeURIComponent(e)}/tasks/${encodeURIComponent(t)}`;function Ct({label:e,value:t,onChange:n}){return(0,L.jsxs)(`label`,{className:$e,children:[e,(0,L.jsxs)(et,{value:t,onChange:e=>n(e.target.value===`30d`?`30d`:`7d`),children:[(0,L.jsx)(`option`,{value:`7d`,children:`Last 7 days`}),(0,L.jsx)(`option`,{value:`30d`,children:`Last 30 days`})]})]})}function wt({query:e}){return e.isPending?(0,L.jsx)(`p`,{role:`status`,className:`text-sm text-muted-foreground`,children:`Loading insights…`}):e.isError?(0,L.jsxs)(`p`,{role:`alert`,className:`text-sm`,children:[e.data?`Showing previous results. `:``,`Could not refresh insights.`,` `,(0,L.jsx)(D,{variant:`outline`,onClick:()=>void e.refetch(),children:`Retry insights`})]}):null}function Tt({period:e,active:t}){let n=He(e,t),r=n.data;return(0,L.jsxs)(`div`,{className:`space-y-3`,children:[(0,L.jsx)(wt,{query:n}),r&&(0,L.jsx)(K,{coverage:r.coverage,retry:()=>void n.refetch()}),r&&(0,L.jsxs)(`div`,{className:`grid gap-3 lg:grid-cols-2`,children:[(0,L.jsx)(Et,{data:r}),(0,L.jsx)(Dt,{data:r})]})]})}function Et({data:e}){let t=e.delivered,n=[{label:`PRs opened`,value:t.prsOpened,note:`${t.prsTouched} touched`},{label:`Lines`,value:(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`span`,{className:`text-success`,children:[`+`,t.additions.toLocaleString(`en-US`)]}),` `,(0,L.jsxs)(`span`,{className:`text-danger`,children:[`−`,t.deletions.toLocaleString(`en-US`)]})]})},{label:`Files`,value:t.files.toLocaleString(`en-US`)},{label:`Issues`,value:t.issues}];return(0,L.jsxs)(`section`,{className:bt,"aria-label":`Delivered`,children:[(0,L.jsx)(R,{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,L.jsx)(`h3`,{className:yt,children:`Delivered`}),(0,L.jsx)(`dl`,{className:`mt-3 grid grid-cols-2 gap-x-4 gap-y-3 sm:grid-cols-4`,children:n.map(e=>(0,L.jsxs)(`div`,{className:`min-w-0`,children:[(0,L.jsx)(`dt`,{className:`text-xs text-soft-foreground`,children:e.label}),(0,L.jsx)(`dd`,{className:`mt-1 truncate text-xl font-semibold tracking-tight tabular-nums`,children:e.value}),e.note&&(0,L.jsx)(`dd`,{className:`text-xs text-soft-foreground`,children:e.note})]},e.label))}),(0,L.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 Dt({data:e}){let t=xt(),{total:n,reasons:r}=e.failures;return(0,L.jsxs)(`section`,{className:bt,"aria-label":`Why tasks failed`,children:[(0,L.jsx)(R,{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,L.jsxs)(`div`,{className:`flex items-baseline justify-between gap-2`,children:[(0,L.jsx)(`h3`,{className:yt,children:`Why tasks failed`}),n>0&&(0,L.jsxs)(`span`,{className:`font-mono text-[11px] text-soft-foreground`,children:[n,` failed`]})]}),n===0?(0,L.jsxs)(`span`,{className:`mt-4 flex items-center gap-2.5 text-sm text-muted-foreground`,children:[(0,L.jsx)(P,{tone:`success`}),`No failed outcomes in this period`]}):(0,L.jsx)(`ul`,{className:`mt-3 space-y-3`,children:r.map(e=>(0,L.jsx)(Ot,{reason:e,total:n,projectName:t},`${e.category}:${e.label}`))})]})}function Ot({reason:e,total:t,projectName:n}){let{latest:r}=e;return(0,L.jsxs)(`li`,{className:`min-w-0`,children:[(0,L.jsxs)(`div`,{className:`flex items-baseline justify-between gap-3 text-sm`,children:[(0,L.jsx)(`span`,{className:`min-w-0 truncate font-medium`,title:e.label,children:e.label}),(0,L.jsx)(`span`,{className:`font-mono text-xs tabular-nums text-muted-foreground`,children:e.count})]}),(0,L.jsx)(`div`,{className:`mt-1.5 h-1 overflow-hidden rounded-full bg-muted`,"aria-hidden":`true`,children:(0,L.jsx)(`div`,{className:`h-full rounded-full bg-danger/70`,style:{width:`${e.count/t*100}%`}})}),(0,L.jsxs)(`span`,{className:`mt-1.5 block truncate text-xs text-soft-foreground`,title:r.message,children:[`Latest:`,` `,(0,L.jsx)(d,{className:`text-muted-foreground hover:text-foreground hover:underline`,to:St(r.projectId,r.id),children:r.title}),` `,`· `,n(r.projectId),r.step?` · ${r.step}`:``,` · `,F(r.at),` ago`]})]})}var kt={claude:`Claude Code`,codex:`Codex`,opencode:`OpenCode`,cursor:`Cursor`,pi:`Pi`,unknown:`Unknown backend`,mixed:`Mixed backends`},At=e=>kt[e]??e,jt=(e,t)=>t?Math.round(e/t*100):0;function Mt(){let[e,t]=_t(`backends`,[`7d`,`30d`],`7d`),n=He(e),r=n.data,i=r?.visibility.cost;return(0,L.jsx)(`section`,{"data-dashboard-module":`backends`,className:`min-w-0`,children:(0,L.jsxs)(N,{className:`gap-0 py-0`,"data-export-context":`Backends: ${vt(e)}; finished tasks`,children:[(0,L.jsxs)(`div`,{className:B,children:[(0,L.jsx)(`h2`,{className:z,children:`Backends & models`}),(0,L.jsx)(Ct,{label:`Finished`,value:e,onChange:t})]}),(0,L.jsxs)(`div`,{className:`space-y-3 p-4`,children:[(0,L.jsx)(wt,{query:n}),r&&(0,L.jsxs)(L.Fragment,{children:[(0,L.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,L.jsx)(K,{coverage:r.coverage,retry:()=>void n.refetch()}),r.backends.length?(0,L.jsx)(`div`,{className:`overflow-x-auto`,role:`region`,"aria-label":`Backend comparison`,tabIndex:0,children:(0,L.jsxs)(`table`,{className:`w-full text-left text-sm`,children:[(0,L.jsx)(`thead`,{children:(0,L.jsxs)(`tr`,{children:[(0,L.jsx)(`th`,{className:J,children:`Backend`}),(0,L.jsx)(`th`,{className:`${J} text-right`,children:`Finished`}),(0,L.jsx)(`th`,{className:J,children:`Success`}),(0,L.jsx)(`th`,{className:`${J} text-right`,children:`Median cycle`}),i&&(0,L.jsx)(`th`,{className:`${J} text-right`,children:`Reported USD`}),i&&(0,L.jsx)(`th`,{className:`${J} text-right`,children:`Per completed`})]})}),(0,L.jsx)(`tbody`,{children:r.backends.map(e=>(0,L.jsx)(Nt,{stat:e,cost:!!i},`${e.backend}:${e.model??``}`))})]})}):(0,L.jsx)(`p`,{className:`py-4 text-sm text-muted-foreground`,children:`No finished tasks in this period.`}),(0,L.jsx)(`span`,{className:`block font-mono text-[11px] text-soft-foreground`,children:(0,L.jsx)(rt,{at:r.asOf})}),(0,L.jsx)(R,{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 Nt({stat:e,cost:t}){let n=jt(e.done,e.finished),r=e.costUsd?.value;return(0,L.jsxs)(`tr`,{className:`border-t transition-colors hover:bg-muted/30`,children:[(0,L.jsxs)(`td`,{className:`px-3 py-2.5`,children:[(0,L.jsx)(`span`,{className:`block font-medium`,children:At(e.backend)}),(0,L.jsx)(`span`,{className:`block font-mono text-[11px] text-soft-foreground`,children:e.backend===`mixed`?`steps ran on different backends`:e.model??`default model`})]}),(0,L.jsx)(`td`,{className:`px-3 py-2.5 text-right tabular-nums`,children:e.finished}),(0,L.jsxs)(`td`,{className:`min-w-40 px-3 py-2.5`,children:[(0,L.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,L.jsx)(`span`,{className:`h-1.5 flex-1 overflow-hidden rounded-full bg-danger/40`,"aria-hidden":`true`,children:(0,L.jsx)(`span`,{className:`block h-full rounded-full bg-success`,style:{width:`${n}%`}})}),(0,L.jsxs)(`span`,{className:`w-10 text-right font-mono text-xs tabular-nums`,children:[n,`%`]})]}),(0,L.jsxs)(`span`,{className:`block text-xs text-soft-foreground`,children:[e.done,` done · `,e.failed,` failed`]})]}),(0,L.jsx)(`td`,{className:`px-3 py-2.5 text-right tabular-nums`,children:e.timedTasks?q(e.medianCycleHours):`—`}),t&&(0,L.jsxs)(`td`,{className:`px-3 py-2.5 text-right tabular-nums`,children:[r==null?`—`:gt(r,!0),(0,L.jsxs)(`span`,{className:`block text-xs text-soft-foreground`,children:[e.costUsd?.reportedTasks??0,`/`,e.finished,` reported`]})]}),t&&(0,L.jsx)(`td`,{className:`px-3 py-2.5 text-right tabular-nums`,children:r==null||!e.done?`—`:gt(r/e.done,!0)})]})}function Pt(){let[e,t]=_t(`automations`,[`7d`,`30d`],`7d`),n=fe(),r=He(e),i=Ze(n.known&&!n.off),a=xt(),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,L.jsx)(`section`,{"data-dashboard-module":`automation-outcomes`,className:`min-w-0`,children:(0,L.jsxs)(N,{className:`gap-0 py-0`,"data-export-context":`Automation outcomes: tasks created in ${vt(e)}`,children:[(0,L.jsxs)(`div`,{className:B,children:[(0,L.jsx)(`h2`,{className:z,children:`Automation outcomes`}),(0,L.jsx)(Ct,{label:`Launched`,value:e,onChange:t})]}),(0,L.jsx)(`div`,{className:`space-y-3 p-4`,children:n.off?(0,L.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Automations are disabled in this workspace.`}):(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(wt,{query:r}),o&&(0,L.jsxs)(L.Fragment,{children:[(0,L.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,L.jsx)(K,{coverage:o.coverage,retry:()=>void r.refetch()}),u&&(0,L.jsxs)(`p`,{role:`alert`,className:`text-sm`,children:[`Some automation details could not be loaded. Their outcomes are shown by id.`,` `,(0,L.jsx)(D,{variant:`ghost`,onClick:i.retry,children:`Retry automations`})]}),d.length?(0,L.jsx)(`div`,{className:`overflow-x-auto`,role:`region`,"aria-label":`Automation outcomes`,tabIndex:0,children:(0,L.jsxs)(`table`,{className:`w-full text-left text-sm`,children:[(0,L.jsx)(`thead`,{children:(0,L.jsxs)(`tr`,{children:[(0,L.jsx)(`th`,{className:J,children:`Automation`}),(0,L.jsx)(`th`,{className:`${J} text-right`,children:`Tasks`}),(0,L.jsx)(`th`,{className:`${J} text-right`,children:`Done`}),(0,L.jsx)(`th`,{className:`${J} text-right`,children:`Failed`}),(0,L.jsx)(`th`,{className:`${J} text-right`,children:`Active`}),(0,L.jsx)(`th`,{className:J,children:`Last run`}),s&&(0,L.jsx)(`th`,{className:`${J} text-right`,children:`Reported USD`})]})}),(0,L.jsx)(`tbody`,{children:d.map(e=>(0,L.jsx)(Ft,{row:e,cost:!!s,projectName:a},`${e.projectId}:${e.automationId}`))})]})}):(0,L.jsx)(`p`,{className:`py-4 text-sm text-muted-foreground`,children:`No automations yet. Create one in a project's Automations page.`}),(0,L.jsx)(`span`,{className:`block font-mono text-[11px] text-soft-foreground`,children:(0,L.jsx)(rt,{at:o.asOf})}),(0,L.jsx)(R,{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 Ft({row:e,cost:t,projectName:n}){let r=e.stat,i=`px-3 py-2.5 text-right tabular-nums`,a=e=>e||(0,L.jsx)(`span`,{className:`text-soft-foreground`,children:`0`});return(0,L.jsxs)(`tr`,{className:`border-t transition-colors hover:bg-muted/30`,children:[(0,L.jsxs)(`td`,{className:`px-3 py-2.5`,children:[e.definition===`removed`?(0,L.jsx)(`span`,{className:`block font-medium`,children:e.name}):(0,L.jsx)(d,{className:`block font-medium hover:underline`,to:`/p/${encodeURIComponent(e.projectId)}/automations/${encodeURIComponent(e.automationId)}`,children:e.name}),(0,L.jsxs)(`span`,{className:`flex items-center gap-1.5 text-xs text-soft-foreground`,children:[(0,L.jsx)(P,{tone:e.enabled?`success`:`neutral`}),n(e.projectId),` ·`,` `,e.definition===`removed`?`Removed`:e.definition===`unknown`?`Details unavailable`:e.enabled?`Enabled`:`Disabled`]})]}),(0,L.jsx)(`td`,{className:i,children:a(r?.tasks)}),(0,L.jsx)(`td`,{className:i,children:a(r?.done)}),(0,L.jsx)(`td`,{className:`${i} ${r?.failed?`text-danger`:``}`,children:a(r?.failed)}),(0,L.jsx)(`td`,{className:i,children:a(r?.active)}),(0,L.jsx)(`td`,{className:`whitespace-nowrap px-3 py-2.5 text-xs text-muted-foreground`,children:r?.lastRunAt?(0,L.jsxs)(`time`,{dateTime:r.lastRunAt,title:new Date(r.lastRunAt).toLocaleString(),children:[F(r.lastRunAt),` ago · `,r.lastStatus]}):`—`}),t&&(0,L.jsx)(`td`,{className:i,children:r?.costUsd?.value==null?`—`:gt(r.costUsd.value,!0)})]})}var It=0,Lt=()=>++It,Y=new Map;function X(e,t){let n=(0,I.useContext)(st),r=()=>{let r=n?Y.get(n):void 0;return r?.has(e)?r.get(e):typeof t==`function`?t():t},[i,a]=(0,I.useState)(r),o=`${n}:${e}`,[s,c]=(0,I.useState)(o);o!==s&&(c(o),a(()=>r()));let l=(0,I.useMemo)(()=>({value:i}),[n,e]);return l.value=i,(0,I.useEffect)(()=>()=>{if(!n)return;let t=Y.get(n)??new Map;t.set(e,l.value),t.size>80&&t.delete(t.keys().next().value),Y.delete(n),Y.set(n,t),Y.size>20&&Y.delete(Y.keys().next().value)},[n,e,l]),[i,a]}var Rt=`a[href], button, select, input, [tabindex]`;function zt(e){let[t]=X(`${e}:position`,()=>({scroll:0})),n=(0,I.useCallback)(e=>{let n=[...e.querySelectorAll(Rt)],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,I.useMemo)(()=>({restore:()=>!1}),[t]);return{ref:(0,I.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(Rt)].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 Bt(e,t){let n=(0,I.useRef)(null),[r,i]=X(`${e}:trigger`,null);return{capture:()=>{let e=document.activeElement;n.current=e instanceof HTMLElement&&e!==document.body?e:null,i(n.current?{label:n.current.getAttribute(`aria-label`),text:n.current.textContent}:null)},restore:()=>{((n.current?.isConnected?n.current:r?[...document.querySelectorAll(`button`)].find(e=>!e.closest(`[role="dialog"]`)&&!e.hasAttribute(`disabled`)&&(r.label?e.getAttribute(`aria-label`)===r.label:e.textContent===r.text)):void 0)??document.querySelector(t))?.focus({preventScroll:!0})}}}function Vt(e,t=!0){return c({queryKey:[...r.dashboard,`overview`,e],enabled:t,staleTime:5e3,refetchInterval:t&&!e.snapshotId?15e3:!1,refetchIntervalInBackground:!1,retry:!1,queryFn:async({signal:t})=>S.parse(await v(await o.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 Ht={running:`Running now`,"needs-you":`Needs you`,completed:`Completed`,failed:`Failed outcomes`},Ut={"needs-you":H.violet,running:H.info,completed:H.success,failed:H.danger},Wt={"needs-you":Ke,running:Ue,completed:re,failed:Ge};function Gt({active:e,children:t,onCurrent:n}){let[r,i]=_t(`period`,[`7d`,`30d`],`7d`),a=Bt(`outcome`,`[data-outcome-trigger]`),o=p().data?.projects,s=e=>o?.find(t=>t.id===e)?.name??e,c=Vt({period:r},e),[l,u]=X(`outcome:selection`,null),f=zt(`outcome:${l?.identity??`closed`}`),m=pe();if((0,I.useEffect)(()=>{e||u(null)},[e]),!e)return t({});let h=c.data,g=(e,t)=>{a.capture(),h&&u({identity:Lt(),snapshot:h,group:e,projectId:t})},_=h?.coverage.projects.every(e=>e.state===`complete`);return(0,L.jsxs)(L.Fragment,{children:[t({overview:(0,L.jsxs)(N,{className:`gap-0 py-0`,children:[(0,L.jsxs)(`div`,{className:B,children:[(0,L.jsx)(`h2`,{className:z,children:`Workspace overview`}),(0,L.jsxs)(`label`,{className:$e,children:[`Outcomes period`,(0,L.jsxs)(et,{value:r,onChange:e=>{i(e.target.value===`30d`?`30d`:`7d`),u(null)},children:[(0,L.jsx)(`option`,{value:`7d`,children:`Last 7 days`}),(0,L.jsx)(`option`,{value:`30d`,children:`Last 30 days`})]})]})]}),(0,L.jsxs)(`div`,{className:`space-y-4 p-4`,children:[c.isPending&&(0,L.jsx)(`p`,{role:`status`,className:`text-sm text-muted-foreground`,children:`Loading overview…`}),c.isError&&(0,L.jsxs)(`p`,{role:`alert`,children:[h?`Showing previous results. `:``,`Could not refresh overview.`,` `,(0,L.jsx)(D,{variant:`outline`,onClick:()=>void c.refetch(),children:`Retry overview`})]}),h&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[h.metrics.needsYou?`${h.metrics.needsYou} tasks require your input or review.`:_&&m.connected&&!c.isError?`No tasks currently require your input or review.`:`No waiting tasks found in the available data.`,` `,h.metrics.failed,` failed `,h.metrics.failed===1?`outcome`:`outcomes`,` `,`in this period. Includes subtasks; completed does not mean accepted or deployed.`]}),(0,L.jsx)(K,{coverage:h.coverage,retry:()=>void c.refetch()}),(0,L.jsx)(`div`,{className:`grid grid-cols-2 gap-3 lg:grid-cols-4`,children:[`needs-you`,`running`,`completed`,`failed`].map(e=>{let t=h.metrics[e===`needs-you`?`needsYou`:e],i=Wt[e];return(0,L.jsxs)(D,{"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?H.neutral:Ut[e]}`,onClick:t=>{n&&(e===`running`||e===`needs-you`)?n(e,t.currentTarget):g(e)},"aria-label":`${Ht[e]}: ${t}`,children:[(0,L.jsx)(nt,{label:Ht[e],value:t,icon:(0,L.jsx)(i,{className:`size-4`}),children:e===`running`||e===`needs-you`?`Current state`:`Last ${r===`7d`?7:30} calendar days`}),(0,L.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,L.jsx)(Pe,{className:`size-3 transition-transform group-hover/metric:translate-x-0.5 motion-reduce:transition-none`,"aria-hidden":`true`})]})]},e)})}),(0,L.jsx)(Tt,{period:r,active:e}),(0,L.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-x-4 gap-y-1 border-t pt-3`,children:[(0,L.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Median cycle time`,` `,(0,L.jsx)(`strong`,{className:`font-mono font-semibold text-foreground`,children:q(h.metrics.medianCycleHours)}),` `,`· `,h.metrics.timedTasks,`/`,h.metrics.completed,` completed tasks have valid timings.`,` `,(0,L.jsx)(D,{variant:`ghost`,className:`h-auto px-1.5 py-1 text-sm text-foreground underline-offset-4 hover:underline`,onClick:()=>g(`completed`),children:`Inspect completed tasks`})]}),(0,L.jsx)(`p`,{className:`font-mono text-[11px] text-soft-foreground`,children:(0,L.jsxs)(`time`,{dateTime:h.asOf,title:new Date(h.asOf).toLocaleString(),children:[`Updated `,F(h.asOf),` ago`]})})]}),(0,L.jsxs)(`details`,{className:`text-xs text-muted-foreground`,children:[(0,L.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,L.jsx)(V,{}),`How these metrics work`]}),(0,L.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,L.jsx)(R,{rows:Object.entries(h.metrics).map(([e,t])=>({section:`overview`,metric:e,value:t,unit:e===`medianCycleHours`?`hours`:`tasks`,asOf:h.asOf,note:e===`running`||e===`needsYou`?`Current non-archived state`:`Finished since ${h.windowStart}`}))})]})]})]}),portfolio:h&&(0,L.jsx)(`div`,{children:(0,L.jsxs)(N,{className:`gap-0 py-0`,"data-export-context":`Outcomes: Last ${r===`7d`?7:30} calendar days; workload: current state`,children:[(0,L.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,L.jsx)(`h2`,{className:`section-mark font-mono text-[11px] font-semibold uppercase tracking-[0.14em] text-muted-foreground`,children:`Projects`})}),(0,L.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,L.jsxs)(`div`,{className:`overflow-x-auto px-1 pb-2`,role:`region`,"aria-label":`Project outcomes`,tabIndex:0,children:[(0,L.jsxs)(`table`,{className:`w-full text-left text-sm`,children:[(0,L.jsx)(`thead`,{children:(0,L.jsx)(`tr`,{children:[`Project`,`Needs you`,`Running`,`Completed`,`Failed`,`Median cycle`].map(e=>(0,L.jsx)(`th`,{className:`whitespace-nowrap px-3 py-2 font-mono text-[11px] font-medium uppercase tracking-[0.1em] text-soft-foreground ${e===`Project`?``:`text-right`}`,children:e},e))})}),(0,L.jsx)(`tbody`,{children:h.projects.map(e=>{let t=h.coverage.projects.find(t=>t.projectId===e.projectId);return(0,L.jsxs)(`tr`,{className:`border-t transition-colors hover:bg-muted/30`,children:[(0,L.jsxs)(`td`,{className:`px-3 py-2`,children:[(0,L.jsx)(d,{className:`font-medium hover:underline`,to:`/p/${encodeURIComponent(e.projectId)}/tasks`,children:s(e.projectId)}),t?.state!==`complete`&&(0,L.jsx)(`span`,{className:`block text-xs text-muted-foreground`,children:`Incomplete data`})]}),[`needs-you`,`running`,`completed`,`failed`].map(n=>(0,L.jsx)(`td`,{className:`px-3 py-1 text-right`,children:(0,L.jsx)(D,{"data-export-keep":!0,variant:`ghost`,className:`min-h-11 tabular-nums`,"aria-label":`${s(e.projectId)}: ${Ht[n]}: ${t?.state===`unavailable`?`Unavailable`:e[n===`needs-you`?`needsYou`:n]}`,disabled:t?.state===`unavailable`,onClick:()=>g(n,e.projectId),children:t?.state===`unavailable`?`Unavailable`:e[n===`needs-you`?`needsYou`:n]})},n)),(0,L.jsxs)(`td`,{className:`px-3 py-2 text-right tabular-nums`,children:[q(e.medianCycleHours),(0,L.jsxs)(`span`,{className:`block text-xs text-muted-foreground`,children:[e.timedTasks,`/`,e.completed,` timed`]})]})]},e.projectId)})})]}),!h.projects.length&&(0,L.jsx)(`p`,{className:`py-4`,children:`No projects to compare yet.`})]}),(0,L.jsx)(R,{rows:h.projects.flatMap(({projectId:e,...t})=>Object.entries(t).map(([t,n])=>({section:`portfolio`,entity:e,metric:t,value:h.coverage.projects.find(t=>t.projectId===e)?.state===`unavailable`?null:n,unit:t===`medianCycleHours`?`hours`:`tasks`,asOf:h.asOf,note:`Outcomes since ${h.windowStart}; running and needsYou are current state`})))})]})})}),(0,L.jsx)(we,{open:!!l,onOpenChange:e=>{e||u(null)},children:(0,L.jsxs)(Ce,{...f,className:`w-full overflow-y-auto sm:max-w-xl`,onCloseAutoFocus:e=>{e.preventDefault(),a.restore()},children:[(0,L.jsxs)(be,{children:[(0,L.jsxs)(Se,{children:[l?Ht[l.group]:`Tasks`,l?.projectId?` · ${l.projectId}`:``]}),(0,L.jsx)(xe,{children:`Tasks behind the selected metric. Includes subtasks. Snapshot keeps counts and rows consistent.`})]}),l&&(0,L.jsx)(Kt,{selection:l,projectName:s,refresh:()=>{u(null),c.refetch()}},l.identity)]})})]})}function Kt({selection:e,refresh:t,projectName:n}){let[r,i]=X(`outcome:${e.identity}:offset`,0),a=Vt({period:e.snapshot.period,snapshotId:e.snapshot.snapshotId,group:e.group,projectId:e.projectId,offset:r}),o=(0,I.useRef)(null),s=(0,I.useRef)(null);(0,I.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,L.jsxs)(`div`,{className:`space-y-3 p-4`,"data-sheet-loading":a.isFetching,children:[a.isPending&&(0,L.jsx)(`p`,{children:`Loading tasks…`}),a.isError&&(0,L.jsxs)(`p`,{role:`alert`,children:[`This snapshot may have expired or become unavailable.`,` `,(0,L.jsx)(D,{onClick:t,children:`Refresh overview`})]}),a.data&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`p`,{ref:o,tabIndex:-1,className:`text-xs text-muted-foreground`,children:[a.data.page.total,` tasks · Snapshot from`,` `,(0,L.jsxs)(`time`,{dateTime:a.data.asOf,title:new Date(a.data.asOf).toLocaleString(),children:[F(a.data.asOf),` ago`]})]}),a.data.page.rows.map(t=>(0,L.jsx)(qt,{row:t,group:e.group,projectName:n},`${t.projectId}:${t.id}`)),!a.data.page.rows.length&&(0,L.jsx)(`p`,{children:`No tasks in this group.`})]}),(0,L.jsxs)(`div`,{className:`flex gap-2`,children:[(0,L.jsx)(D,{variant:`outline`,disabled:!r||a.isFetching,onClick:()=>c(Math.max(0,r-20)),children:`Previous`}),(0,L.jsx)(D,{variant:`outline`,disabled:!a.data||a.data.page.nextOffset===null||a.isFetching,onClick:()=>c(a.data.page.nextOffset),children:`Next`})]})]})}function qt({row:e,group:t,projectName:n}){let r=M(e),a=t===`running`||t===`needs-you`;a&&r&&(e={...e,...r});let o=r===null,s=a&&(e.archived||(t===`running`?e.status!==`running`:!u(e))),c=o||s,l=i(e),f=a&&o?`Task removed`:s?t===`running`?`No longer running`:`No longer needs you`:l.label;return(0,L.jsxs)(`div`,{className:`border-b py-3`,children:[(0,L.jsx)(d,{"aria-disabled":c||void 0,tabIndex:c?-1:void 0,onClick:e=>{c&&e.preventDefault()},className:`block min-h-11 font-medium hover:underline`,to:`/p/${encodeURIComponent(e.projectId)}/tasks/${encodeURIComponent(e.id)}`,children:e.titleSummary||e.title}),(0,L.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[(0,L.jsx)(P,{tone:l.tone}),` `,n(e.projectId),` ·`,` `,f,` · `,e.archived?`Archived · `:``,(0,L.jsxs)(`time`,{dateTime:e.finishedAt??e.createdAt,title:new Date(e.finishedAt??e.createdAt).toLocaleString(),children:[e.finishedAt?`Finished`:`Created`,` `,F(e.finishedAt??e.createdAt),` ago`]})]})]})}var Jt={snapshot:[...r.dashboard,`snapshot`],feed:e=>[...r.dashboard,`feed`,e],telemetry:[...r.dashboard,`telemetry`]},Yt=new Map;async function Xt(e){let t=k(),n=ee.parse(await v(await o.api.v1.workspace.dashboard.$get({},{init:{signal:e}}),`/workspace/dashboard`));return Yt.has(n.snapshotId)||Yt.set(n.snapshotId,t),Yt.size>60&&Yt.delete(Yt.keys().next().value),A(t,[...n.questions.rows,...n.reviews.rows]),n}async function Zt(e,t,n=0,r=20,i){let a=C.parse(await v(await o.api.v1.workspace.dashboard.tasks.$get({query:{snapshotId:e,group:t,offset:String(n),limit:String(r)}},{init:{signal:i}}),`/workspace/dashboard/tasks`)),s=Yt.get(e);return s!==void 0&&A(s,a.page.rows),a}function Qt(e){return c({queryKey:Jt.snapshot,queryFn:({signal:e})=>Xt(e),enabled:e,staleTime:5e3,refetchOnMount:`always`,refetchInterval:e?15e3:!1,refetchIntervalInBackground:!1,retry:!1})}function $t(e){return c({queryKey:Jt.telemetry,enabled:e,staleTime:0,queryFn:async({signal:e})=>{let t=b.parse(await v(await o.api.v1.workspace.dashboard.telemetry.$get({},{init:{signal:e}}),`/workspace/dashboard/telemetry`));return te.seed(t.samples,t.asOf),t}})}function en(e,t){let n=c({queryKey:Jt.feed(e),queryFn:async({signal:t})=>{let n=k(),r=w.parse(await v(await o.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,I.useRef)(!1);return(0,I.useEffect)(()=>{r.current=!1},[e,t]),(0,I.useEffect)(()=>{if(!t||r.current||!n.data?.sources.some(e=>e.reason===`Still loading GitHub`))return;let e=setTimeout(()=>{document.visibilityState!==`hidden`&&(r.current=!0,n.refetch())},5e3);return()=>clearTimeout(e)},[t,n.data,n.refetch]),n}function tn(e,t){let n=en(`tasks`,t&&e!==`github`),r=en(`github`,t&&e!==`tasks`),i=(0,I.useMemo)(()=>{if(e===`tasks`)return n.data;if(e===`github`)return r.data;let t=n.data,i=r.data;if(!t&&!i)return;let a=t??i,o=new Date(Math.max(Date.parse(t?.asOf??a.asOf),Date.parse(i?.asOf??a.asOf))).toISOString(),s=new Date(Date.parse(o)-10080*60*1e3).toISOString(),c=[...t?.rows??[],...i?.rows??[]].filter(e=>Date.parse(e.at)>=Date.parse(s)&&Date.parse(e.at)<=Date.parse(o)).sort((e,t)=>nn(e,t)),l=new Set(c.slice(60).map(e=>e.kind===`task-result`?`tasks:${e.run.projectId}`:e.key.slice(0,e.key.lastIndexOf(`:`)))),u=[...t?.sources??[],...i?.sources??[]].map(e=>l.has(e.key)?{...e,truncated:!0}:e);return{...a,asOf:o,windowStart:s,filter:`all`,rows:c.slice(0,60),sources:u,coverage:t?.coverage??a.coverage,truncated:c.length>60||!!t?.truncated||!!i?.truncated}},[e,n.data,r.data]),a=e===`github`?r:n;return{...a,data:i,githubError:r.isError,githubFetching:r.isFetching,retryTasks:()=>n.refetch(),retryFailed:()=>e===`github`?r.refetch():e===`tasks`?n.refetch():Promise.all([...n.isError?[n.refetch()]:[],...r.isError?[r.refetch()]:[]]),isPending:!i&&a.isPending,isError:a.isError||e===`all`&&r.isError,isFetching:a.isFetching||e===`all`&&r.isFetching,refetch:()=>e===`tasks`?n.refetch():r.refetch()}}function nn(e,t){return Date.parse(t.at)-Date.parse(e.at)||e.key.localeCompare(t.key)}var rn=[...r.dashboard,`costs`];function an(){let e=0,t=0,n,r=new Set;return{subscribe:e=>(r.add(e),()=>{r.delete(e)}),getSnapshot:()=>n,async read(i,a){let o=++e,s=await un(i,a);return!a?.aborted&&o>t&&(t=o,(n?.cost!==s.visibility.cost||n?.tokens!==s.visibility.tokens)&&(n=s.visibility,r.forEach(e=>e()))),s}}}var on=new WeakMap;function sn(e){let t=on.get(e);return t||(t=an(),on.set(e,t)),t}function cn(){let e=sn(s());return(0,I.useSyncExternalStore)(e.subscribe,e.getSnapshot,e.getSnapshot)}var ln=new Map;async function un(e,t){let n=k(),r=T.parse(await v(await o.api.v1.workspace.dashboard.costs.$get({query:{...e,offset:String(e.offset??0),limit:`20`}},{init:{signal:t}}),`/workspace/dashboard/costs`));!e.snapshotId&&!ln.has(r.snapshotId)&&ln.set(r.snapshotId,n),ln.size>60&&ln.delete(ln.keys().next().value);let i=ln.get(r.snapshotId);return i!==void 0&&A(i,r.tasks.rows),r}function dn(e,t,n){let r=sn(s());return c({queryKey:[...rn,e,t,n],queryFn:({signal:n})=>r.read({period:e,sort:t,tzOffsetMinutes:new Date().getTimezoneOffset()},n),staleTime:5e3,refetchOnMount:`always`,refetchInterval:15e3,refetchIntervalInBackground:!1,retry:!1})}function fn(e,t,n,r){let i=sn(s());return c({queryKey:[...rn,`tasks`,e.snapshotId,t,n,r,e.visibility],retry:!1,queryFn:async({signal:a})=>{let o=e.tzOffsetMinutes??new Date().getTimezoneOffset(),s=async s=>{let c=await i.read({period:e.period,sort:n,snapshotId:s,projectId:t,tzOffsetMinutes:o},a),l=[...c.tasks.rows];for(;c.tasks.nextOffset!==null&&l.length<r;)c=await i.read({period:e.period,sort:n,snapshotId:c.snapshotId,projectId:t,offset:c.tasks.nextOffset},a),l.push(...c.tasks.rows);return{...c,tasks:{...c.tasks,rows:l}}};try{return await s(e.snapshotId)}catch(e){if(e instanceof h&&e.status===409)return s();throw e}}})}var pn={cost:{text:`text-primary`,fill:`bg-primary`,tint:H.primary,icon:ie},input:{text:`text-violet`,fill:`bg-violet`,tint:H.violet,icon:We},output:{text:`text-info`,fill:`bg-info`,tint:H.info,icon:Ee}};function mn({metric:e,label:t,value:n,reported:r,total:i}){let a=pn[e],o=a.icon,s=i?Math.min(100,r/i*100):0;return(0,L.jsxs)(`div`,{className:`${tt} ${a.tint}`,children:[(0,L.jsxs)(nt,{label:t,value:n,icon:(0,L.jsx)(o,{className:`size-4 ${a.text}`}),children:[r,` of `,i,` tasks report this metric`]}),(0,L.jsx)(`div`,{className:`mt-2 h-1.5 overflow-hidden rounded-full bg-muted`,"aria-hidden":`true`,children:(0,L.jsx)(`div`,{className:`h-full rounded-full ${a.fill} transition-[width] duration-300 motion-reduce:transition-none`,style:{width:`${s}%`}})})]})}function hn({projects:e,currentProjects:t,metric:n,field:r,label:i,format:a,onSelect:o}){let s=e.reduce((e,t)=>Math.max(e,t[r]?.value??0),0),c=pn[n];return(0,L.jsxs)(ze,{delayDuration:150,children:[(0,L.jsxs)(`div`,{className:`space-y-1 rounded-xl border p-2`,"aria-label":`Projects ranked by ${i}`,children:[e.length===0&&(0,L.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,L.jsxs)(Be,{children:[(0,L.jsx)(Le,{asChild:!0,children:(0,L.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,L.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,L.jsx)(`span`,{className:`w-4 shrink-0 text-xs tabular-nums text-muted-foreground`,"aria-hidden":`true`,children:n+1}),(0,L.jsx)(`span`,{className:`min-w-0 flex-1 break-words font-medium`,children:e.projectId}),(0,L.jsx)(`span`,{className:`shrink-0 font-semibold tabular-nums`,children:a(u)}),(0,L.jsx)(Pe,{"data-export-exclude":!0,className:`size-4 shrink-0 text-muted-foreground`,"aria-hidden":`true`})]}),(0,L.jsx)(`div`,{className:`mt-2 ml-7 h-2 overflow-hidden rounded-full bg-muted`,"aria-hidden":`true`,children:(0,L.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,L.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,L.jsxs)(Re,{className:`max-w-64`,children:[(0,L.jsxs)(`p`,{className:`font-medium`,children:[e.projectId,` · `,i,`: `,a(u)]}),(0,L.jsxs)(`p`,{children:[l?.reportedTasks??0,` of `,e.tasks,` tasks report this metric.`]}),(0,L.jsx)(`p`,{children:`Open project tasks`})]})]},e.projectId)})]}),e.length>0&&(0,L.jsxs)(`p`,{className:`mt-2 text-xs text-muted-foreground`,children:[e.length>5?`Top 5 of ${e.length} projects. `:``,`Bar lengths compare reported values; the largest is the reference.`]})]})}var Z={cost:`costUsd`,input:`inputTokens`,output:`outputTokens`},gn={cost:`Reported USD`,input:`Input tokens`,output:`Output tokens`};function _n(e,t){return JSON.stringify([e.totals,e.projects,e.tasks,e.visibility,e.coverage,e.invalidDateTasks])!==JSON.stringify([t.totals,t.projects,t.tasks,t.visibility,t.coverage,t.invalidDateTasks])}var vn=(e,t)=>gt(e,t===`cost`);function Q(e){return[...e.cost?[`cost`]:[],...e.tokens?[`input`,`output`]:[]]}function yn({value:e,onChange:t,visibility:n}){return(0,L.jsxs)(`label`,{className:$e,children:[`Sort by`,(0,L.jsx)(et,{value:e,onChange:e=>t(e.target.value),children:Q(n).map(e=>(0,L.jsx)(`option`,{value:e,children:gn[e]},e))})]})}function bn(){return(0,L.jsx)(xn,{visibility:Ve(m().data)})}function xn({visibility:e}){return(0,L.jsxs)(N,{className:`gap-0 py-0`,children:[(0,L.jsx)(`div`,{className:B,children:(0,L.jsx)(`h2`,{className:z,children:`Usage & cost`})}),!e.cost&&!e.tokens?(0,L.jsx)(`p`,{className:`p-4 text-sm`,children:`Usage metrics are hidden by workspace settings`}):(0,L.jsx)(Sn,{visibility:e},`${e.cost}:${e.tokens}`)]})}function Sn({visibility:e}){let[t,n]=_t(`usagePeriod`,[`all`,`7d`,`30d`],`all`),[r,i]=_t(`usageSort`,Q(e),e.cost?`cost`:`input`);return(0,L.jsx)(Cn,{period:t,setPeriod:n,sort:r,setSort:i,visibility:e})}function Cn({period:e,setPeriod:t,sort:n,setSort:r,visibility:i}){let a=dn(e,n,`${i.cost}:${i.tokens}`),[o,s]=X(`usage:accepted`,void 0),c=o??a.data,l=a.data??c,[u,d]=X(`usage:panel`,null),[f,p]=(0,I.useState)(e);f!==e&&(p(e),s(void 0),d(null));let m=zt(`usage:${u?.identity??`closed`}`),h=Bt(`usage`,`[data-usage-trigger]`),g=e=>{h.capture(),c&&d({identity:Lt(),projectId:e,snapshot:c,latestId:l?.snapshotId??c.snapshotId})},_=cn()??i,v={cost:i.cost&&_.cost,tokens:i.tokens&&_.tokens},y=Q(v).includes(n)?n:Q(v)[0]??`cost`,b=[...c?.projects??[]].sort((e,t)=>{let n=e[Z[y]]?.value,r=t[Z[y]]?.value;return(n==null?r==null?0:1:r==null?-1:r-n)||e.projectId.localeCompare(t.projectId)});!o&&a.data&&s(a.data);let x=c&&l&&_n(c,l),S=c?.coverage.projects.some(e=>e.state!==`complete`),C=l?.coverage.projects.some(e=>e.state!==`complete`),w=JSON.stringify(c?.coverage)!==JSON.stringify(l?.coverage),T=c?.totals.tasks===0&&!S&&!C;return(0,L.jsxs)(`div`,{className:`space-y-4 p-4 text-sm`,children:[c&&(0,L.jsx)(R,{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,L.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:(0,L.jsx)(rt,{at:c.asOf})}),(0,L.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`h3`,{className:`font-medium`,children:`Lifetime totals of retained tasks`}),(0,L.jsxs)(`details`,{className:`mt-1 text-xs text-muted-foreground`,children:[(0,L.jsxs)(`summary`,{"data-export-heading":`Metric definitions`,className:`${Qe} min-h-11`,children:[(0,L.jsx)(V,{}),`How these metrics work`]}),(0,L.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,L.jsxs)(`label`,{className:$e,children:[`Tasks created`,(0,L.jsxs)(et,{value:e,onChange:e=>t(e.target.value),children:[(0,L.jsx)(`option`,{value:`all`,children:`All time`}),(0,L.jsx)(`option`,{value:`7d`,children:`Last 7 days`}),(0,L.jsx)(`option`,{value:`30d`,children:`Last 30 days`})]})]})]}),e!==`all`&&(0,L.jsx)(`p`,{className:`text-muted-foreground`,children:`Lifetime usage of tasks created in this period — not spending during the period.`}),a.isPending&&(0,L.jsx)(`p`,{children:`Loading usage…`}),a.isError&&(0,L.jsxs)(`p`,{role:`alert`,children:[c?`Showing stale usage. Could not refresh.`:`Could not load usage.`,` `,(0,L.jsx)(D,{className:`min-h-11`,onClick:()=>void a.refetch(),children:`Retry`})]}),x&&(0,L.jsx)(`p`,{role:`status`,children:`Newer usage data is available; displayed values use the previous snapshot.`}),x&&(0,L.jsx)(D,{className:`min-h-11`,variant:`outline`,onClick:()=>s(l),children:`Updates available — Show`}),c&&S&&(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`p`,{className:`text-muted-foreground`,children:`Coverage of displayed usage:`}),(0,L.jsx)(K,{coverage:c.coverage,retry:()=>void a.refetch()})]}),l&&C&&w&&(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`p`,{className:`text-muted-foreground`,children:`Current source availability:`}),(0,L.jsx)(K,{coverage:l.coverage,retry:()=>void a.refetch()})]}),c&&(0,L.jsxs)(L.Fragment,{children:[!T&&(0,L.jsx)(`div`,{className:`report-cost-metrics grid gap-3 sm:grid-cols-[repeat(auto-fit,minmax(220px,1fr))]`,children:Q(v).map(e=>(0,L.jsx)(mn,{metric:e,label:gn[e],value:vn(c.totals[Z[e]]?.value,e),reported:c.totals[Z[e]]?.reportedTasks??0,total:c.totals.tasks},e))}),!v.cost&&!v.tokens&&(0,L.jsx)(`p`,{children:`Usage metrics are hidden by workspace settings`}),c.totals.tasks===0?(0,L.jsx)(`p`,{children:S||C?`No retained tasks could be read from available sources.`:`No retained tasks in this cohort.`}):Q(v).every(e=>!c.totals[Z[e]]?.reportedTasks)&&(0,L.jsx)(`p`,{children:`No reports for the visible metrics in this cohort.`}),T&&(0,L.jsx)(`p`,{className:`text-muted-foreground`,children:`Usage appears when tasks report cost or tokens.`}),(0,L.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,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`h3`,{className:`font-medium`,children:`Top projects`}),(0,L.jsx)(`p`,{className:`text-muted-foreground`,children:`Ranking uses reported metrics only.`})]}),(0,L.jsx)(yn,{value:y,onChange:r,visibility:v})]}),(0,L.jsx)(hn,{projects:b,metric:y,label:gn[y],field:Z[y],format:e=>vn(e,y),currentProjects:l?.projects??[],onSelect:g}),(0,L.jsx)(D,{"data-usage-trigger":!0,className:`min-h-11`,variant:`outline`,onClick:()=>g(``),children:`View tasks`})]})]}),(0,L.jsx)(we,{open:u!==null&&(v.cost||v.tokens),onOpenChange:e=>{e||d(null)},children:(0,L.jsxs)(Ce,{...m,className:`w-full overflow-y-auto sm:max-w-xl`,onCloseAutoFocus:e=>{e.preventDefault(),h.restore()},children:[(0,L.jsxs)(be,{children:[(0,L.jsx)(Se,{children:u?.projectId?`${u.projectId} tasks`:`All tasks`}),(0,L.jsx)(xe,{children:`Lifetime usage of retained tasks. Missing reports are unavailable.`})]}),u!==null&&(0,L.jsx)(wn,{identity:`usage:${u.identity}`,snapshot:l&&l.snapshotId!==u.latestId?l:u.snapshot,projectId:u.projectId||void 0,visibility:v},u.identity)]})})]})}function wn({identity:e,snapshot:t,projectId:n,visibility:r}){let[i,a]=X(`${e}:sort`,t.sort);return(0,L.jsx)(Tn,{identity:e,snapshot:t,projectId:n,visibility:r,sort:Q(r).includes(i)?i:Q(r)[0]??`cost`,setSort:a})}function Tn({identity:e,snapshot:t,projectId:n,visibility:r,sort:i,setSort:a}){let[o,s]=X(`${e}:count`,20),[c,l]=X(`${e}:paging`,void 0),[u,d]=(0,I.useState)(t.snapshotId);u!==t.snapshotId&&(d(t.snapshotId),l(void 0));let f=fn(c??t,n,i,o),p=cn()??r,m={cost:r.cost&&p.cost,tokens:r.tokens&&p.tokens},h=Q(m).includes(i)?i:Q(m)[0]??`cost`,[g,_]=X(`${e}:accepted`,void 0),[v,y]=X(`${e}:acceptedCount`,o),[b,x]=X(`${e}:acceptedSort`,i),[S,C]=(0,I.useState)(i);S!==i&&(C(i),s(20),l(g??c??t)),f.data&&(!g||(v!==o||b!==i)&&g.snapshotId===f.data.snapshotId)&&(_(f.data),y(o),x(i));let w=g??f.data,T=f.data&&w&&_n(f.data,w),ee=w?.coverage.projects.some(e=>e.state!==`complete`),E=f.data?.coverage.projects.some(e=>e.state!==`complete`),O=JSON.stringify(w?.coverage)!==JSON.stringify(f.data?.coverage),te=!n||t.projects.some(e=>e.projectId===n);return(0,L.jsxs)(`div`,{className:`space-y-3 p-4 text-sm`,"data-sheet-loading":f.isFetching,children:[(0,L.jsx)(yn,{value:h,onChange:a,visibility:m}),f.isPending&&(0,L.jsx)(`p`,{children:`Loading tasks…`}),f.isError&&(0,L.jsxs)(`p`,{role:`alert`,children:[`Could not refresh tasks. `,w?`Showing stale usage.`:``,` `,(0,L.jsx)(D,{className:`min-h-11`,onClick:()=>void f.refetch(),children:`Retry`})]}),T&&(0,L.jsx)(D,{className:`min-h-11`,onClick:()=>{_(f.data),y(o),x(i)},children:`Updates available — Show`}),w&&ee&&(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`p`,{className:`text-muted-foreground`,children:`Coverage of displayed tasks:`}),(0,L.jsx)(K,{coverage:w.coverage,retry:()=>void f.refetch()})]}),f.data&&E&&O&&(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`p`,{className:`text-muted-foreground`,children:`Current source availability:`}),(0,L.jsx)(K,{coverage:f.data.coverage,retry:()=>void f.refetch()})]}),w&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`p`,{className:`border-b pb-2 font-mono text-[11px] text-soft-foreground`,children:[w.tasks.rows.length,` of `,w.tasks.total,` retained tasks`]}),w.tasks.total===0&&(0,L.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,L.jsx)(En,{row:e,sort:h,visibility:m,disabled:!te||!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,L.jsx)(D,{className:`min-h-11`,disabled:f.isFetching,onClick:()=>{l(w),s(e=>e+20)},children:`Show 20 more tasks`})]})]})}function En({row:e,sort:t,visibility:n,disabled:r}){let a=M(e);r||=a===null;let o=i(a?{status:a.status,awaitingAnswerSince:a.awaitingAnswerSince}:e),s=Q(n).filter(e=>e!==t),c=t=>{let n=e[Z[t]];return n==null?`—`:vn(n,t)},l=t=>`${gn[t]}: ${vn(e[Z[t]],t)}`;return(0,L.jsxs)(`div`,{className:`grid grid-cols-[minmax(0,1fr)_auto] items-start gap-x-4 border-b py-3 last:border-0`,children:[(0,L.jsxs)(`div`,{className:`min-w-0`,children:[(0,L.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,L.jsx)(P,{tone:o.tone,pulse:o.pulse,className:`mt-[7px]`}),(0,L.jsx)(d,{className:`line-clamp-2 break-words font-medium leading-snug hover:underline no-hover:min-h-11`,title:e.title,to:`/p/${encodeURIComponent(e.projectId)}/tasks/${encodeURIComponent(e.id)}`,"aria-disabled":r||void 0,tabIndex:r?-1:void 0,onClick:e=>{r&&e.preventDefault()},children:e.title})]}),(0,L.jsxs)(`p`,{className:`mt-1 pl-[15px] font-mono text-[11px] text-soft-foreground`,children:[e.projectId,` · `,r?`Checking current state…`:a?.status??e.status,e.archived?` · Archived`:``,e.subtask?` · Subtask`:``]})]}),(0,L.jsxs)(`div`,{className:`text-right tabular-nums`,children:[(0,L.jsx)(`span`,{"aria-label":l(t),className:`block font-semibold ${e[Z[t]]==null?`text-soft-foreground`:``}`,children:c(t)}),s.length>0&&(0,L.jsx)(`span`,{className:`mt-1 flex justify-end gap-3 font-mono text-[11px] text-soft-foreground`,children:s.map(e=>(0,L.jsxs)(`span`,{"aria-label":l(e),children:[c(e),` `,e===`cost`?``:e===`input`?`in`:`out`]},e))})]})]})}var Dn={cost:`costUsd`,input:`inputTokens`,output:`outputTokens`},On={cost:`Reported USD`,input:`Input tokens`,output:`Output tokens`};function kn(e){return[...e.cost?[`cost`]:[],...e.tokens?[`input`,`output`]:[]]}var An=(e,t)=>gt(e,t===`cost`);function jn(e){return new Date(`${e}T00:00:00`).toLocaleDateString(void 0,{month:`short`,day:`numeric`})}function Mn({series:e,height:t,accent:n,renderTooltip:r,describe:i}){let a=Math.max(1,...e.map(t));return(0,L.jsxs)(ze,{delayDuration:150,children:[(0,L.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,L.jsxs)(Be,{children:[(0,L.jsx)(Le,{asChild:!0,children:(0,L.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,L.jsx)(`span`,{style:{height:`${s}%`},className:`block w-full rounded-t-sm ${n}`})})}),(0,L.jsx)(Re,{children:r(e)})]},e.date)})}),(0,L.jsxs)(`div`,{className:`mt-1 flex justify-between text-xs text-muted-foreground`,children:[(0,L.jsx)(`span`,{children:jn(e[0].date)}),(0,L.jsx)(`span`,{children:jn(e.at(-1).date)})]})]})}function Nn({metrics:e,series:t}){return(0,L.jsxs)(`table`,{className:`w-full text-left text-xs`,children:[(0,L.jsx)(`thead`,{children:(0,L.jsxs)(`tr`,{className:`border-b`,children:[(0,L.jsx)(`th`,{className:`py-1 pr-2 font-medium`,children:`Date`}),e.map(e=>(0,L.jsx)(`th`,{className:`py-1 pr-2 text-right font-medium`,children:On[e]},e)),(0,L.jsx)(`th`,{className:`py-1 pr-2 text-right font-medium`,children:`Completed`}),(0,L.jsx)(`th`,{className:`py-1 text-right font-medium`,children:`Avg cycle`})]})}),(0,L.jsx)(`tbody`,{children:t.map(t=>(0,L.jsxs)(`tr`,{className:`border-b last:border-0`,children:[(0,L.jsx)(`td`,{className:`py-1 pr-2`,children:jn(t.date)}),e.map(e=>(0,L.jsx)(`td`,{className:`py-1 pr-2 text-right tabular-nums`,children:An(t[Dn[e]]?.value,e)},e)),(0,L.jsx)(`td`,{className:`py-1 pr-2 text-right tabular-nums`,children:t.completed}),(0,L.jsx)(`td`,{className:`py-1 text-right tabular-nums`,children:t.avgCycleHours===null?`—`:q(t.avgCycleHours)})]},t.date))})]})}function Pn({metric:e,series:t}){let n=pn[e],r=Dn[e],i=t.reduce((e,t)=>e+(t[r]?.reportedTasks??0),0);return(0,L.jsxs)(`div`,{className:`rounded-xl border p-3`,children:[(0,L.jsx)(`p`,{className:`text-xs font-medium ${n.text}`,children:On[e]}),(0,L.jsx)(`div`,{className:`mt-2`,children:(0,L.jsx)(Mn,{series:t,describe:t=>`${t.date}, ${On[e]}: ${An(t[r]?.value,e)}, ${t[r]?.reportedTasks??0} of ${t.tasks} tasks reported`,height:e=>e[r]?.value??0,accent:n.fill,renderTooltip:t=>(0,L.jsxs)(`p`,{children:[jn(t.date),` · `,An(t[r]?.value,e),` ·`,` `,t[r]?.reportedTasks??0,`/`,t.tasks,` tasks reported`]})})}),i===0&&(0,L.jsx)(`p`,{className:`mt-2 text-xs text-muted-foreground`,children:`No reports in this period.`})]})}function Fn({series:e}){let t=e.reduce((e,t)=>e+t.completed,0),n=e.reduce((e,t)=>e+(t.avgCycleHours??0)*(t.cycleReportedTasks??t.completed),0),r=e.reduce((e,t)=>e+(t.cycleReportedTasks??t.completed),0),i=r?n/r:null;return(0,L.jsxs)(`div`,{className:`rounded-xl border p-3`,children:[(0,L.jsxs)(`div`,{className:`flex flex-wrap items-baseline justify-between gap-2`,children:[(0,L.jsx)(`p`,{className:`text-xs font-medium text-success`,children:`Completed tasks`}),(0,L.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[t,` done · avg cycle`,` `,i===null?`unavailable`:q(i)]})]}),(0,L.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[r,`/`,t,` completed tasks have valid cycle times.`]}),(0,L.jsx)(`div`,{className:`mt-2`,children:(0,L.jsx)(Mn,{series:e,describe:e=>`${e.date}: ${e.completed} completed tasks, average cycle ${e.avgCycleHours==null?`Unavailable`:q(e.avgCycleHours)}`,height:e=>e.completed,accent:`bg-success`,renderTooltip:e=>(0,L.jsxs)(`div`,{children:[(0,L.jsxs)(`p`,{children:[jn(e.date),` · `,e.completed,` completed`]}),(0,L.jsxs)(`p`,{children:[`Avg cycle`,` `,e.avgCycleHours===null?`unavailable`:q(e.avgCycleHours),` · Median`,` `,e.medianCycleHours===null?`unavailable`:q(e.medianCycleHours)]})]})})}),t===0&&(0,L.jsx)(`p`,{className:`mt-2 text-xs text-muted-foreground`,children:`No tasks finished in this period.`})]})}function In(){return(0,L.jsx)(Ln,{visibility:Ve(m().data)})}function Ln({visibility:e}){let[t,n]=_t(`trendPeriod`,[`7d`,`30d`],`7d`),r=dn(t,e.cost?`cost`:`input`,`${e.cost}:${e.tokens}`),i=r.data,a=i&&i.totals.tasks===0&&i.coverage.projects.every(e=>e.state===`complete`)&&i.series.every(e=>e.tasks===0&&e.completed===0),o=kn({cost:e.cost&&i?.visibility.cost!==!1,tokens:e.tokens&&i?.visibility.tokens!==!1});return(0,L.jsxs)(N,{className:`gap-0 py-0`,children:[(0,L.jsxs)(`div`,{className:B,children:[(0,L.jsx)(`h2`,{className:z,children:`Trends`}),(0,L.jsxs)(`label`,{className:$e,children:[`Period`,(0,L.jsxs)(et,{value:t,onChange:e=>n(e.target.value),children:[(0,L.jsx)(`option`,{value:`7d`,children:`Last 7 days`}),(0,L.jsx)(`option`,{value:`30d`,children:`Last 30 days`})]})]})]}),(0,L.jsxs)(`div`,{className:`space-y-4 p-4 text-sm`,children:[i&&(0,L.jsx)(R,{rows:a?[]:i.series.flatMap(e=>[...o.map(t=>({section:`daily-creation-cohort`,entity:e.date,metric:Dn[t],value:e[Dn[t]]?.value??null,unit:t===`cost`?`USD`:`tokens`,reportedTasks:e[Dn[t]]?.reportedTasks??0,totalTasks:e.tasks,asOf:i.asOf,note:`Lifetime usage grouped by task creation date; not daily spend`})),{section:`daily-completions`,entity:e.date,metric:`completed`,value:e.completed,unit:`tasks`,asOf:i.asOf},{section:`daily-completions`,entity:e.date,metric:`avgCycleHours`,value:e.avgCycleHours,reportedTasks:e.cycleReportedTasks??e.completed,totalTasks:e.completed,unit:`hours`,asOf:i.asOf},{section:`daily-completions`,entity:e.date,metric:`medianCycleHours`,value:e.medianCycleHours,unit:`hours`,asOf:i.asOf}])}),(0,L.jsxs)(`details`,{className:`text-xs text-muted-foreground`,children:[(0,L.jsxs)(`summary`,{"data-export-heading":`Metric definitions`,className:`${Qe} py-2`,children:[(0,L.jsx)(V,{}),`How these metrics work`]}),(0,L.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,L.jsx)(`p`,{children:`Loading trends…`}),r.isError&&(0,L.jsxs)(`p`,{role:`alert`,children:[i?`Showing stale trends. Could not refresh.`:`Could not load trends.`,` `,(0,L.jsx)(D,{className:`min-h-11`,onClick:()=>void r.refetch(),children:`Retry`})]}),i&&(0,L.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:(0,L.jsx)(rt,{at:i.asOf})}),i&&(0,L.jsx)(K,{coverage:i.coverage,retry:()=>void r.refetch()}),i&&a&&(0,L.jsx)(`p`,{className:`text-muted-foreground`,children:`No retained tasks in this period yet.`}),i&&!a&&i.series.length>0&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsxs)(`div`,{className:`space-y-4`,children:[o.length>0&&(0,L.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-[repeat(auto-fit,minmax(200px,1fr))]`,children:o.map(e=>(0,L.jsx)(Pn,{metric:e,series:i.series},e))}),(0,L.jsx)(Fn,{series:i.series})]}),(0,L.jsxs)(`details`,{className:`group rounded-lg border bg-muted/20 print:block`,children:[(0,L.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,L.jsx)(Je,{className:`size-4`,"aria-hidden":`true`}),` View data table`,(0,L.jsx)(De,{className:`ml-auto size-4 transition-transform group-open:rotate-180`,"aria-hidden":`true`})]}),(0,L.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,L.jsx)(Nn,{metrics:o,series:i.series})})]})]})]})]})}function Rn(e,t,n,r=!0){let i=s();return c({queryKey:[...Jt.snapshot,e?.snapshotId,t,n],enabled:r&&!!e,retry:!1,queryFn:async({signal:r})=>{if(!e)throw Error(`Dashboard not loaded`);let a=[];try{for(let i=0;i<n;){let o=await Zt(e.snapshotId,t,i,Math.min(20,n-i),r);if(a.push(...o.page.rows),o.page.nextOffset===null)break;i=o.page.nextOffset}return a}catch(e){if(e instanceof h&&e.status===409){let e=await Xt(r);i.setQueryData(Jt.snapshot,e)}throw e}}})}function zn(e,t,n,r){let i=s(),a=t===`questions`||t===`reviews`?`needs-you`:t,o=a===`needs-you`?0:n,l=r.map(e=>`${e.projectId}:${e.id}`).sort();return c({queryKey:[...Jt.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=o;i!==null&&n.size;){let o=await Zt(e.snapshotId,a,i,20,t);for(let e of o.page.rows){let t=`${e.projectId}:${e.id}`;n.delete(t)&&r.set(t,e)}i=o.page.nextOffset}return r}catch(e){throw e instanceof h&&e.status===409&&i.setQueryData(Jt.snapshot,await Xt(t)),e}}})}function Bn({snapshot:e,questions:t,reviews:n,more:r,healthy:i=!0}){let a=pe();return(0,L.jsxs)(N,{className:`min-w-0 gap-0 overflow-hidden py-0`,children:[(0,L.jsxs)(`div`,{className:B,children:[(0,L.jsxs)(`h2`,{id:`dashboard-needs-you`,tabIndex:-1,className:z,children:[`Needs you · `,e.counts.questions+e.counts.reviews]}),(0,L.jsxs)(`p`,{className:`font-mono text-[11px] text-soft-foreground`,children:[e.counts.questions,` questions · `,e.counts.reviews,` reviews`]})]}),i&&a.connected&&e.counts.questions+e.counts.reviews===0&&e.coverage.projects.every(e=>e.state===`complete`)?(0,L.jsxs)(`p`,{className:`flex items-center gap-2.5 px-4 py-8 text-sm text-muted-foreground`,children:[(0,L.jsx)(P,{tone:`success`}),`All caught up — no tasks need your input`]}):null,(0,L.jsx)(Vn,{snapshot:e,group:`questions`,count:t,more:r}),(0,L.jsx)(Vn,{snapshot:e,group:`reviews`,count:n,more:r})]})}function Vn({snapshot:e,group:t,count:n,more:r}){let i=e[t],a=Math.max(n,i.rows.length),o=Rn(e,t,a,a>i.rows.length),s=a>i.rows.length?o.data:i.rows,c=lt(s,G,t,n),l=zn(e,t,a,c.rows.filter(e=>e.removed).map(e=>e.row)),u=(0,I.useRef)(null);return!i.total&&!c.rows.length?null:(0,L.jsxs)(`section`,{children:[(0,L.jsxs)(`h3`,{ref:u,tabIndex:-1,className:`border-b bg-card-2 px-4 py-2 font-mono text-[11px] font-semibold uppercase tracking-[0.12em] text-muted-foreground`,children:[t===`questions`?`Questions`:`Reviews`,` · `,i.total]}),c.updates>0&&(0,L.jsxs)(D,{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,L.jsx)(ht,{row:l.data?.get(G(e))??e,removed:t&&!!l.data&&!l.data.has(G(e)),checking:s===void 0||t&&!l.data,checkFailed:s===void 0&&o.isError||t&&!l.data&&l.isError,queue:!0},G(e))),(o.isError||l.isError)&&(0,L.jsxs)(`p`,{role:`alert`,className:`p-4 text-sm`,children:[`Could not check current task state.`,` `,(0,L.jsx)(D,{variant:`ghost`,className:`min-h-11`,onClick:()=>{o.refetch(),l.refetch()},children:`Retry`})]}),a<i.total&&(0,L.jsxs)(D,{variant:`ghost`,className:`m-2 min-h-11`,disabled:o.isFetching,onClick:()=>r(t,a+Math.min(20,i.total-a)),children:[`Show `,Math.min(20,i.total-a),` more `,t]})]})}function Hn(e){if(!e.startsWith(`github:`))return e===`tasks`?`Task results`:e;let t=e.slice(7).split(`:`),n=t.pop()===`pr`?`Pull requests`:`Issues`;return`${t.join(`:`).replace(/^project:/,`Project `).replace(/^github.com\//,``)} · ${n}`}var Un=e=>e.key;function Wn({filter:e,setFilter:t,count:n,more:r}){let i=tn(e,!0),a=lt(i.data?.rows,Un,`feed:${e}`,0,e=>e.kind===`task-result`),o=a.rows,s=a.updates,c=(0,I.useContext)(st),l=(0,I.useRef)(null),u=`feed:${e}`,d=(0,I.useMemo)(()=>({scroll:pt(c,u)?.scroll??0,done:!1}),[c,u]);(0,I.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,I.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,L.jsxs)(N,{"data-export-context":`Results source: ${e}; Last 7 days; loaded ${Math.min(n,o.length)} rows`,className:`min-w-0 gap-0 overflow-hidden py-0`,children:[(0,L.jsxs)(`div`,{className:`space-y-2 border-b px-4 pt-2.5 pb-2`,children:[(0,L.jsxs)(`div`,{className:`flex min-h-9 flex-wrap items-center justify-between gap-2`,children:[(0,L.jsx)(`h2`,{ref:f,tabIndex:-1,className:z,children:b?`Recent results`:`Recent results & GitHub`}),(0,L.jsx)(`span`,{className:`font-mono text-[11px] text-soft-foreground`,children:`Last 7 days`})]}),!b&&(0,L.jsx)(se,{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,L.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Task results · No GitHub repositories configured`}),e!==`tasks`&&!b&&(0,L.jsxs)(`details`,{className:`text-xs text-muted-foreground`,open:y.length||h?!0:void 0,children:[(0,L.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,L.jsx)(V,{}),y.length||h?`GitHub needs attention`:_?`Checking GitHub…`:v?`GitHub not configured`:m?`GitHub checked ${F(m)} ago`:`GitHub source`]}),(0,L.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-x-3`,children:[(0,L.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 ${F(m)} ago`:`GitHub snapshot`}),!v&&(0,L.jsx)(D,{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,L.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&&mt(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,L.jsxs)(`p`,{role:`alert`,className:`p-4 text-sm`,children:[`Could not load results.`,` `,(0,L.jsx)(D,{className:`min-h-11`,onClick:()=>{i.retryFailed()},children:`Retry`})]}),i.isPending&&(0,L.jsx)(`p`,{className:`p-4 text-sm`,children:`Loading results…`}),s>0&&(0,L.jsxs)(D,{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,L.jsx)(ht,{row:e.run,kicker:t?`Outside current results`:`Latest result: ${e.run.status===`failed`?`Failed`:`Completed`}`},e.key):(0,L.jsxs)(`div`,{className:`border-b px-4 py-3 transition-colors hover:bg-muted/30`,children:[(0,L.jsx)(R,{rows:[{section:`github`,entity:`${e.repo}#${e.number}`,metric:e.itemKind,value:e.title,asOf:e.at,note:e.url}]}),(0,L.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,L.jsxs)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:[e.repo,` · `,e.itemKind===`pr`?`PR`:`Issue`,` #`,e.number,` created ·`,` `,F(e.at)]})]},e.key)),i.data&&!i.data.rows.length&&!o.length&&!i.isFetching&&!i.isError&&!y.length&&!_&&i.data.coverage.projects.every(e=>e.state===`complete`)&&(0,L.jsx)(`p`,{className:`px-4 py-8 text-sm text-muted-foreground`,children:`No results in the last 7 days`}),n<o.length&&(0,L.jsxs)(D,{variant:`ghost`,className:`m-2 min-h-11`,onClick:r,children:[`Show `,Math.min(20,o.length-n),` more results`]}),i.data?.truncated&&(0,L.jsx)(`p`,{className:`p-4 text-xs`,children:`Showing the latest 60 results`}),i.data&&(0,L.jsx)(K,{coverage:i.data.coverage,retry:()=>{i.retryTasks()}}),!b&&i.data?.sources.some(e=>e.state!==`ready`||e.truncated)&&(0,L.jsxs)(`details`,{className:`p-4 text-xs`,children:[(0,L.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,L.jsx)(V,{}),`Source details`]}),i.data.sources.map(e=>(0,L.jsxs)(`p`,{className:`break-words py-1`,children:[Hn(e.key),`:`,` `,e.reason===`No GitHub remote`?`Not configured`:e.reason===`Still loading GitHub`?`Checking…`:e.reason??(e.state===`ready`?`Up to date`:e.state),e.truncated?` · capped`:``,e.fetchedAt?` · checked ${F(e.fetchedAt)}`:``]},e.key))]})]})]})}var $=e=>e.replace(/[&<>"']/g,e=>({"&":`&`,"<":`<`,">":`>`,'"':`"`,"'":`'`})[e]),Gn=`Visible modules and loaded rows only. Filters and report availability apply. Retained task usage is not an invoice or a complete history.`,Kn=`Confidential — internal distribution only`,qn={costUsd:{label:`Reported cost`,usd:!0},inputTokens:{label:`Input tokens`},outputTokens:{label:`Output tokens`},needsYou:{label:`Needs you`},running:{label:`Running now`},completed:{label:`Completed in period`},failed:{label:`Failed outcomes in period`},medianCycleHours:{label:`Median cycle (hours)`}};function Jn(e,t){return e==null?`Unavailable`:typeof e==`string`?e:gt(e,t)}function Yn(e){let t=new Set,n=[];for(let r of e.modules)for(let e of r.rows){if(e.section!==`totals`&&e.section!==`fleet`&&e.section!==`overview`)continue;let i=qn[e.metric];!i||t.has(e.metric)||(t.add(e.metric),n.push({label:i.label,value:Jn(e.value,i.usd),note:[e.metric===`needsYou`||e.metric===`running`?e.note||`Current non-archived state`:r.filters,e.asOf?`Data as of ${e.asOf}`:``,e.reportedTasks==null?``:`${e.reportedTasks} of ${e.totalTasks} tasks reported`].filter(Boolean).join(` · `)}))}return n}function Xn(e){let t=e.cloneNode(!0);t.querySelectorAll(`script,style,link,img,iframe,object,embed,input,[hidden],[data-dashboard-export],[data-export-exclude]`).forEach(e=>e.remove()),t.querySelectorAll(`select`).forEach((t,n)=>{let r=e.querySelectorAll(`select`)[n];t.replaceWith(document.createTextNode(`: `+(r?.selectedOptions[0]?.textContent??``)))}),t.querySelectorAll(`[data-export-row],[data-dashboard-row]`).forEach(e=>e.classList.add(`report-row`)),t.querySelectorAll(`summary`).forEach(e=>{let t=document.createElement(`h3`);t.textContent=e.getAttribute(`data-export-heading`)||e.textContent,e.replaceWith(t)}),t.querySelectorAll(`button`).forEach(e=>{if(e.hasAttribute(`data-export-keep`)){let t=document.createElement(`div`);for(let n of[...e.attributes])[`class`,`style`,`title`].includes(n.name)&&t.setAttribute(n.name,n.value);t.append(...e.childNodes),e.replaceWith(t)}else e.remove()}),t.querySelectorAll(`details`).forEach(e=>{let t=document.createElement(`div`);t.className=e.className,t.append(...e.childNodes),e.replaceWith(t)});for(let e of[t,...t.querySelectorAll(`*`)])for(let t of[...e.attributes])(t.name.startsWith(`on`)||[`href`,`src`,`srcset`,`action`,`formaction`,`tabindex`].includes(t.name)||t.name.startsWith(`data-`))&&e.removeAttribute(t.name);return t.removeAttribute(`style`),t.innerHTML}function Zn(e,t,n,r){return{generatedAt:t,source:n,title:r||void 0,notices:[...e.querySelectorAll(`[role=alert],[role=status]`)].filter(e=>!e.closest(`[data-dashboard-module]`)).map(e=>e.textContent?.trim()??``).filter(Boolean),modules:[...e.querySelectorAll(`[data-dashboard-module]`)].map(e=>{let t=[...e.querySelectorAll(`select`)].map(e=>`${e.closest(`label`)?.childNodes[0]?.textContent?.trim()??`Filter`}: ${e.selectedOptions[0]?.textContent}`).concat([...e.querySelectorAll(`[data-export-context]`)].map(e=>e.dataset.exportContext)).join(`; `),n=[...new Set([...e.querySelectorAll(`p,[role="alert"],[role="status"]`)].filter(e=>!e.closest(`table,[data-export-exclude]`)&&!e.querySelector(`p,[role="alert"],[role="status"]`)).map(e=>{let t=e.cloneNode(!0);return t.querySelectorAll(`table,button,select,summary,[data-export-exclude]`).forEach(e=>e.remove()),t.textContent?.trim()}).filter(Boolean))].join(` | `);return{id:e.dataset.dashboardModule,title:e.querySelector(`h2`)?.textContent??e.dataset.dashboardModule,filters:t,notes:n,html:Xn(e),rows:[...e.querySelectorAll(`[data-dashboard-export]`)].flatMap(e=>JSON.parse(e.dataset.dashboardExport))}})}}function Qn(e){let t=e==null?``:String(e);return typeof e==`string`&&/^[\s\uFEFF]*[=+@\-]/.test(t)&&(t=`'${t}`),`"${t.replaceAll(`"`,`""`)}"`}function $n(e){let t=[[`generated_at`,`source`,`module`,`filters`,`section`,`entity`,`metric`,`value`,`unit`,`availability`,`reported_tasks`,`total_tasks`,`as_of`,`notes`]];for(let n of e.modules){t.push([e.generatedAt,e.source,n.title,n.filters,`context`,``,`scope`,Gn,``,``,``,``,``,[...e.title?[`Report title: ${e.title}`]:[],...e.notices,n.notes].join(` | `)]);for(let r of n.rows)t.push([e.generatedAt,e.source,n.title,n.filters,r.section,r.entity,r.metric,r.value,r.unit,r.value===null?`unavailable`:typeof r.value==`number`?`measured`:`reported`,r.reportedTasks,r.totalTasks,r.asOf,r.note])}return``+t.map(e=>e.map(Qn).join(`,`)).join(`\r
|
|
2
|
-
`)+`\r
|
|
3
|
-
`}function er(e,t){let n=Yn(e);return`<!doctype html><html class="light"><head><meta charset="utf-8"><title>${$(e.title||`Dashboard`)} ${$(e.generatedAt.slice(0,10))}</title>${t.join(``)}<style>
|
|
4
|
-
@page {
|
|
5
|
-
size:A4; margin:14mm 14mm 18mm;
|
|
6
|
-
@bottom-left { content:"${Kn}"; 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">${Kn}</span><p>${$(Gn)}</p>${e.notices.map(e=>`<p>${$(e)}</p>`).join(``)}</header>${n.length?`<section class="report-summary"><h2>Executive summary</h2><div class="summary-grid">${n.map(e=>`<div class="summary-tile"><span class="summary-value">${$(e.value)}</span><span class="summary-label">${$(e.label)}</span>${e.note?`<span class="summary-note">${$(e.note)}</span>`:``}</div>`).join(``)}</div></section>`:``}${e.modules.map(e=>`<section class="report-module${e.id===`usage`?` report-module-usage`:e.id===`fleet`?` report-module-fleet`:``}"><p class="report-context">${$(e.filters)}</p>${e.html}</section>`).join(``)}</body></html>`}function tr({dashboard:e}){let[t,n]=(0,I.useState)(!1),[r,i]=(0,I.useState)(``),[a,o]=(0,I.useState)(!1),[s,c]=(0,I.useState)(``),l=t=>{i(``);try{if(!e.current)return;let r=Zn(e.current,new Date().toISOString(),location.origin,s.trim());if(!r.modules.length){i(`Show at least one dashboard module before exporting.`);return}if(t===`csv`){let e=URL.createObjectURL(new Blob([$n(r)],{type:`text/csv;charset=utf-8`})),t=document.createElement(`a`);t.href=e,t.download=`dashboard-${r.generatedAt.replaceAll(`:`,`-`)}.csv`,document.body.append(t),t.click(),t.remove(),setTimeout(()=>URL.revokeObjectURL(e),1e3),n(!1)}else{o(!0);let e=[...document.querySelectorAll(`link[rel="stylesheet"],style`)].flatMap(e=>{if(e.tagName===`STYLE`)return[e.outerHTML];let t=e.href;if(new URL(t).origin!==location.origin)return[];let n=document.createElement(`link`);return n.rel=`stylesheet`,n.href=t,[n.outerHTML]}),t=document.createElement(`iframe`);t.title=`Dashboard PDF report`,t.style.cssText=`position:fixed;width:1000px;height:1px;bottom:0;left:0;border:0;opacity:0;pointer-events:none`;let a,s=()=>{clearTimeout(a),t.remove(),o(!1)};t.onload=async()=>{try{let e=t.contentWindow;await e.document.fonts.ready,e.addEventListener(`afterprint`,s,{once:!0}),e.focus(),e.print(),n(!1),o(!1)}catch{s(),i(`Could not open the print dialog. Please try again.`)}},a=setTimeout(s,12e4),t.srcdoc=er(r,e),document.body.append(t)}}catch{o(!1),i(`Could not prepare the export. Please try again.`)}};return(0,L.jsxs)(ke,{open:t,onOpenChange:n,children:[(0,L.jsx)(Oe,{asChild:!0,children:(0,L.jsxs)(D,{variant:`outline`,className:`min-h-11`,disabled:a,children:[(0,L.jsx)(Fe,{className:`size-4`}),a?`Preparing report…`:`Export`]})}),(0,L.jsxs)(Te,{align:`end`,className:`max-w-[calc(100vw-2rem)] space-y-3`,children:[(0,L.jsx)(`p`,{className:`text-sm font-medium`,children:`Export current dashboard`}),(0,L.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Visible modules, current filters and loaded rows. Hidden metrics are excluded.`}),(0,L.jsxs)(`label`,{className:`block space-y-1 text-xs text-muted-foreground`,children:[`Report title (optional)`,(0,L.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,L.jsx)(D,{className:`min-h-11 w-full`,onClick:()=>l(`pdf`),children:`PDF report…`}),(0,L.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Choose Save as PDF in the print dialog.`}),(0,L.jsx)(D,{variant:`outline`,className:`min-h-11 w-full`,onClick:()=>l(`csv`),children:`Download CSV`}),r&&(0,L.jsx)(`p`,{role:`alert`,className:`text-sm`,children:r})]})]})}var nr={overview:`Workspace overview`,portfolio:`Projects`,automations:`Automations`,fleet:`Queue & scheduling`,needsYou:`Needs you`,recent:`Recent results & GitHub`,usage:`Usage & cost`,trends:`Trends`};function rr({id:e,children:t,wide:n}){let{attributes:r,listeners:i,setNodeRef:a,setActivatorNodeRef:o,transform:s,isDragging:c}=de({id:e});return(0,L.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,L.jsx)(D,{ref:o,variant:`ghost`,className:`absolute -top-[22px] left-1/2 z-10 min-h-11 min-w-11 -translate-x-1/2 cursor-grab touch-none p-0 opacity-0 transition-opacity hover:bg-transparent focus-visible:opacity-100 active:cursor-grabbing group-hover/module:opacity-100 no-hover:opacity-100`,...r,...i,"aria-label":`Move ${nr[e]}`,children:(0,L.jsx)(`span`,{className:`flex h-4 w-8 items-center justify-center rounded-full border bg-card text-muted-foreground shadow-xs`,children:(0,L.jsx)(qe,{className:`size-3.5`,"aria-hidden":`true`})})}),t]})}function ir({order:e,modules:t,onOrder:n}){let r=ve(oe(ge,{activationConstraint:{distance:8}}),oe(ae,{coordinateGetter:me})),i=e.filter(e=>t[e]),a=new Set([`overview`,`portfolio`,`usage`,`trends`]),o;for(let e of i)a.has(e)?(o&&a.add(o),o=void 0):o=o?void 0:e;o&&a.add(o);let s=e=>`${nr[e]}, position ${i.indexOf(e)+1} of ${i.length}`;return(0,L.jsx)(ue,{sensors:r,collisionDetection:ye,accessibility:{announcements:{onDragStart:({active:e})=>`Picked up ${s(e.id)}.`,onDragOver:({active:e,over:t})=>t?`${nr[e.id]} moved to position ${i.indexOf(t.id)+1} of ${i.length}.`:void 0,onDragEnd:({active:e,over:t})=>t?`${nr[e.id]} dropped at position ${i.indexOf(t.id)+1} of ${i.length}.`:`Order unchanged. ${s(e.id)}.`,onDragCancel:({active:e})=>`Reordering cancelled. ${s(e.id)}.`},screenReaderInstructions:{draggable:`Press Space to pick up a module, use arrow keys to move, Space to drop, or Escape to cancel.`}},onDragEnd:({active:t,over:r})=>{!r||t.id===r.id||n(le(e,e.indexOf(t.id),e.indexOf(r.id)))},children:(0,L.jsx)(ce,{items:i,strategy:he,children:(0,L.jsx)(`div`,{className:`grid items-start gap-5 lg:grid-cols-2`,children:i.map(e=>(0,L.jsx)(rr,{id:e,wide:a.has(e),children:t[e]},e))})})})}var ar=[`overview`,`needsYou`,`recent`,`fleet`,`automations`,`portfolio`,`usage`,`trends`],or=e=>ar.includes(e);function sr(e=[]){let t=e.filter(or);return(e=>t.length===e.length&&t.every((t,n)=>t===e[n]))(ar.filter(e=>e!==`automations`))?[...ar]:[...new Set([...t.includes(`overview`)?[]:[`overview`],...t,...ar])]}function cr(e=[],t){let n=0;return[...e.map(e=>or(e)?t[n++]:e),...t.slice(n)]}function lr(){let e=_(),t=s(),[n,i]=(0,I.useState)(),[a,o]=(0,I.useState)(!1),c=(0,I.useRef)(void 0),u=(0,I.useRef)(!1),d=E.parse(e.data?.dashboard??{}),p=(0,I.useRef)(d);p.current=d;let m=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},h=sr(n?.order??d.order),g=(0,I.useRef)({tiles:m,order:h});g.current=n??{tiles:m,order:h};let v=e=>{let t={...g.current,...e};g.current=t,i(t),c.current=t},y=async()=>{if(!(u.current||!c.current)){for(u.current=!0;c.current;){let n=c.current;c.current=void 0;try{e.data||(p.current=E.parse((await f()).dashboard??{}));let a=await l({dashboard:{...p.current,order:cr(p.current.order,n.order),tiles:{...p.current?.tiles,...n.tiles}}});t.setQueryData(r.uiState,a),p.current=E.parse(a.dashboard??{}),o(!1),i(e=>e===n?void 0:e)}catch{o(!0),c.current||=n;break}}u.current=!1}},b=(0,I.useRef)(y);return b.current=y,(0,I.useEffect)(()=>()=>{b.current()},[]),(0,I.useEffect)(()=>{if(!n)return;let e=setTimeout(()=>{y()},250);return()=>clearTimeout(e)},[n]),{tiles:m,order:h,setOrder:e=>v({order:sr(e)}),failed:a,ready:e.data!==void 0||e.isError,setTiles(e){v({tiles:e})},retry:()=>{y()}}}function ur(e,t){let n=ar.filter(e=>t.includes(e)),r=0;return e.map(e=>t.includes(e)?n[r++]:e)}var dr=[[`overview`,`Overview`],[`costs`,`Usage & cost`],[`automations`,`Automations`]];function fr(){let e=a(),t=e.state?.dashboardEntry??e.key;return(0,L.jsx)(pr,{entryKey:t},t)}function pr({entryKey:e}){let t=a(),[n,r]=g(),i=(0,I.useRef)(dt(e)).current,[o,s]=(0,I.useState)(i?.questions??0),[c,l]=(0,I.useState)(i?.reviews??0),[u,f]=(0,I.useState)(i?.feed??6),p=(0,I.useRef)(null),m=(0,I.useRef)(null),[h,_]=(0,I.useState)(!1),v=lr(),[y,b]=(0,I.useState)(!1),x=n.get(`view`)===`costs`?`costs`:n.get(`view`)===`automations`?`automations`:`overview`,S=dr.find(([e])=>e===x)[1],C=x===`costs`?[`usage`,`trends`]:x===`automations`?[`automations`]:[`fleet`,`needsYou`,`recent`],w=x===`overview`?[`overview`,`portfolio`,...C]:[...C],T=ur(v.order,w),ee=()=>v.setTiles({...v.tiles,...Object.fromEntries(C.map(e=>[e,!0]))}),E=v.tiles,O={...E,automations:x===`automations`&&E.automations,fleet:x===`overview`&&E.fleet,needsYou:x===`overview`&&E.needsYou,recent:x===`overview`&&E.recent,usage:x===`costs`&&E.usage,trends:x===`costs`&&E.trends},te=n.get(`feed`)===`tasks`?`tasks`:n.get(`feed`)===`github`?`github`:`all`,re=n.get(`panel`),k=re&&[`running`,`queued`,`scheduled`,`needs-you`].includes(re)?re:null,A=O.fleet||O.needsYou||O.recent&&te!==`github`||!!k,j=Qt(v.ready&&A),M=pe();$t(v.ready&&O.fleet&&y);let ie=(0,I.useRef)({questions:o,reviews:c,feed:u,scroll:i?.scroll??0,focus:i?.focus});ie.current={...ie.current,questions:o,reviews:c,feed:u},(0,I.useEffect)(()=>{let t=p.current?.closest(`main`)??p.current,n=()=>{ie.current.scroll=t?.scrollTop??0},r=()=>{ie.current.focus=document.activeElement?.closest(`[data-dashboard-row]`)?.getAttribute(`data-dashboard-row`)??void 0};return t?.addEventListener(`scroll`,n),document.addEventListener(`focusin`,r),()=>{ft(e,ie.current),t?.removeEventListener(`scroll`,n),document.removeEventListener(`focusin`,r)}},[e]);let ae=(0,I.useRef)(!1),oe=v.ready&&(!A||!!j.data&&!j.isFetching);(0,I.useEffect)(()=>{if(!i||ae.current||!oe)return;let e=!1,t=()=>{if(e)return!0;let t=p.current?.closest(`main`)??p.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,ae.current=!0,r.disconnect(),a?.disconnect()},s=requestAnimationFrame(()=>{n(),e||(r.observe(document.body,{childList:!0,subtree:!0}),p.current&&a?.observe(p.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,oe]);let se=i=>{let a=new URLSearchParams(n);i?a.set(`panel`,i):a.delete(`panel`),r(a,{replace:!0,state:{...t.state,dashboardEntry:e}})},ce=(e,t)=>{m.current=t,se(e)},le=j.data?j.data.counts.questions+j.data.counts.reviews:0;return(0,L.jsx)(st.Provider,{value:e,children:(0,L.jsx)(ct.Provider,{value:!i||!j.isFetching&&!j.isError,children:(0,L.jsxs)(`div`,{ref:p,"data-route":`dashboard`,className:`mx-auto w-full max-w-[1440px] space-y-6 p-4 md:px-8 md:py-7`,children:[(0,L.jsxs)(`header`,{className:`flex flex-wrap items-end justify-between gap-4`,children:[(0,L.jsxs)(`div`,{className:`min-w-0`,children:[(0,L.jsx)(`h1`,{className:`text-2xl font-semibold tracking-tight`,children:`Dashboard`}),(0,L.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,L.jsxs)(`span`,{"data-export-exclude":!0,className:`inline-flex items-center gap-1.5 rounded-full border px-2 py-0.5 font-mono text-[10.5px] uppercase tracking-[0.1em]`,children:[(0,L.jsx)(P,{tone:M.connected?`success`:`neutral`,pulse:M.connected}),M.connected?`Live`:`Offline`]})]})]}),(0,L.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,L.jsx)(tr,{dashboard:p}),(0,L.jsxs)(ke,{open:h,onOpenChange:_,children:[(0,L.jsx)(Oe,{asChild:!0,children:(0,L.jsxs)(D,{variant:`outline`,className:`min-h-11`,children:[(0,L.jsx)(ne,{className:`size-4`}),`Customize`]})}),(0,L.jsxs)(Te,{align:`end`,className:`max-h-[min(32rem,80dvh)] max-w-[calc(100vw-2rem)] overflow-y-auto`,children:[(0,L.jsx)(`p`,{className:`mb-3 text-sm font-medium`,children:`Optional modules in this view`}),C.map(e=>(0,L.jsxs)(`label`,{className:`flex min-h-11 items-center gap-3 text-sm`,children:[(0,L.jsx)(`input`,{type:`checkbox`,checked:E[e],disabled:!v.ready,onChange:t=>v.setTiles({...E,[e]:t.target.checked})}),{automations:`Automations`,fleet:`Queue & scheduling`,needsYou:`Needs you`,recent:`Recent results & GitHub`,usage:`Usage & cost`,trends:`Trends`}[e]]},e)),(0,L.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.`}),v.order.some((e,t)=>e!==T[t])&&(0,L.jsxs)(D,{variant:`ghost`,className:`min-h-11`,onClick:()=>v.setOrder(T),children:[`Reset `,S,` order`]}),(0,L.jsx)(`p`,{className:`my-3 text-xs text-muted-foreground`,children:`Shared across browsers using this workspace`}),C.some(e=>!E[e])&&(0,L.jsxs)(D,{variant:`outline`,className:`min-h-11`,disabled:!v.ready,onClick:()=>{ee(),_(!1)},children:[`Show all in `,S]})]})]})]})]}),(0,L.jsx)(`nav`,{"aria-label":`Dashboard views`,className:`-mt-2 flex flex-wrap gap-5 border-b`,children:dr.map(([r,i])=>{let a=new URLSearchParams(n);return a.set(`view`,r),a.delete(`panel`),(0,L.jsx)(D,{asChild:!0,variant:`ghost`,className:`-mb-px min-h-11 rounded-none border-b-2 px-0.5 hover:bg-transparent ${x===r?`border-primary text-foreground`:`border-transparent`}`,children:(0,L.jsx)(d,{"aria-current":x===r?`page`:void 0,to:`?${a}`,replace:x===r,state:{...t.state,dashboardEntry:x===r?e:void 0},children:i})},r)})}),v.failed&&(0,L.jsxs)(`p`,{role:`alert`,className:`text-sm`,children:[`Layout changed for this session, but could not be saved.`,` `,(0,L.jsx)(D,{variant:`ghost`,className:`min-h-11`,onClick:v.retry,children:`Retry saving`})]}),A&&!M.connected&&j.data&&(0,L.jsxs)(`p`,{role:`status`,className:`text-xs text-muted-foreground`,children:[`Tasks disconnected · Last updated `,F(j.data.asOf),` ago`]}),A&&j.isError&&(0,L.jsxs)(`p`,{role:`alert`,className:`rounded-md border p-4 text-sm`,children:[`Could not refresh dashboard.`,` `,j.data?`Showing the last available task state.`:``,` `,(0,L.jsx)(D,{className:`min-h-11`,onClick:()=>{j.refetch()},children:`Retry`})]}),x===`costs`&&!Object.values(O).some(Boolean)?(0,L.jsxs)(`p`,{role:`status`,className:`flex flex-wrap items-center gap-2 text-sm text-muted-foreground`,children:[(0,L.jsx)(_e,{className:`size-4`,"aria-hidden":`true`}),`Optional modules in this view are hidden.`,(0,L.jsxs)(D,{variant:`outline`,className:`min-h-11`,onClick:()=>ee(),children:[`Show all in `,S]})]}):null,j.isPending&&(O.fleet||O.needsYou)&&(0,L.jsx)(`p`,{className:`text-sm`,children:`Loading dashboard…`}),A&&j.data&&(0,L.jsx)(K,{coverage:j.data.coverage,count:le,retry:()=>void j.refetch()}),x===`automations`&&(0,L.jsx)(Pt,{}),(0,L.jsx)(Gt,{active:x===`overview`,onCurrent:ce,children:i=>v.ready&&(0,L.jsx)(ir,{order:v.order,onOrder:v.setOrder,modules:{...i,automations:O.automations?(0,L.jsx)(it,{}):null,fleet:O.fleet&&j.data?(0,L.jsxs)(N,{className:`gap-0 py-0`,children:[(0,L.jsx)(R,{rows:Object.entries({queued:j.data.counts.queued,scheduled:j.data.counts.scheduled,monitoring:j.data.counts.monitoring}).map(([e,t])=>({section:`fleet`,metric:e,value:t,unit:`tasks`,asOf:j.data.asOf}))}),(0,L.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,L.jsx)(`h2`,{className:`section-mark font-mono text-[11px] font-semibold uppercase tracking-[0.14em] text-muted-foreground`,children:`Queue & scheduling`}),(0,L.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,L.jsx)(P,{tone:M.connected?`success`:`neutral`}),M.connected?`Tasks connected`:`Tasks disconnected`]})]}),(0,L.jsx)(`div`,{className:`grid grid-cols-2 divide-x`,children:[[`queued`,`Queued`,j.data.counts.queued],[`scheduled`,`Scheduled`,j.data.counts.scheduled]].map(([e,t,n])=>(0,L.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=>ce(e,t.currentTarget),children:[(0,L.jsx)(`span`,{className:`block font-mono text-[11px] uppercase tracking-[0.12em] text-muted-foreground`,children:t}),(0,L.jsx)(`span`,{className:`mt-3 block text-3xl font-semibold leading-none tracking-tight tabular-nums`,children:n})]},e))}),(0,L.jsxs)(`details`,{open:y,onToggle:e=>b(e.currentTarget.open),className:`border-t px-4 py-3 text-xs text-muted-foreground`,children:[(0,L.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,L.jsx)(V,{}),`Technical details`]}),(0,L.jsxs)(`div`,{className:`flex flex-wrap gap-x-5 gap-y-2`,children:[(0,L.jsxs)(`span`,{children:[j.data.counts.monitoring,` monitoring (included in Running)`]}),(0,L.jsx)(`span`,{children:`Agent processes`}),y&&(0,L.jsx)(mr,{running:j.data.counts.running})]})]})]}):null,needsYou:O.needsYou&&j.data?(0,L.jsx)(Bn,{healthy:!j.isError,snapshot:j.data,questions:o,reviews:c,more:(e,t)=>e===`questions`?s(t):l(t)}):null,recent:O.recent?(0,L.jsx)(Wn,{filter:te,setFilter:i=>{let a=new URLSearchParams(n);a.set(`feed`,i||`all`),r(a,{replace:!0,state:{...t.state,dashboardEntry:e}}),f(6)},count:u,more:()=>f(e=>Math.min(60,e+20))}):null,usage:O.usage?(0,L.jsx)(bn,{}):null,trends:O.trends?(0,L.jsx)(In,{}):null}})}),x===`costs`&&(0,L.jsx)(Mt,{}),(0,L.jsx)(we,{open:!!k,onOpenChange:e=>{e||se(null)},children:(0,L.jsxs)(Ce,{className:`w-full overflow-y-auto sm:max-w-lg`,onCloseAutoFocus:e=>{e.preventDefault(),m.current?.focus()},children:[(0,L.jsxs)(be,{children:[(0,L.jsxs)(Se,{children:[k===`needs-you`?`Needs you`:k?k[0].toUpperCase()+k.slice(1):`Tasks`,j.data&&k?` · ${k===`needs-you`?le:j.data.counts[k]}`:``]}),(0,L.jsx)(xe,{children:`Includes subtasks. Open a task to continue in its project.`})]}),!j.data&&j.isPending&&(0,L.jsx)(`p`,{className:`p-4`,role:`status`,children:`Loading tasks…`}),!j.data&&j.isError&&(0,L.jsxs)(`p`,{className:`p-4`,role:`alert`,children:[`Could not load tasks.`,` `,(0,L.jsx)(D,{className:`min-h-11`,onClick:()=>{j.refetch()},children:`Retry`})]}),k&&j.data&&(0,L.jsx)(hr,{snapshot:j.data,group:k},k)]})})]})})})}function mr({running:e}){let{connected:t,samples:n}=pe(),r=t?n:[],i=r.filter(e=>e.cpuPct!==null);return(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(R,{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,L.jsxs)(`span`,{children:[`CPU`,` `,i.length?`${Math.round(i.reduce((e,t)=>e+(t.cpuPct??0),0))}%`:`unavailable`,` `,`· `,i.length,`/`,e,` measured`]}),(0,L.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,L.jsx)(`span`,{children:`RSS sums process resident memory; CPU may exceed 100%.`})]})}function hr({snapshot:e,group:t}){let n=(0,I.useContext)(st),r=(0,I.useRef)(pt(n,t)).current,[i,a]=(0,I.useState)(r?.count??20),o=(0,I.useRef)(null),s=(0,I.useRef)({count:i,scroll:r?.scroll??0});s.current.count=i,(0,I.useEffect)(()=>{let e=o.current?.closest(`[data-slot="sheet-content"]`),r=()=>{s.current.scroll=e?.scrollTop??0};return e?.addEventListener(`scroll`,r),()=>{mt(n,t,s.current),e?.removeEventListener(`scroll`,r)}},[n,t]);let c=Rn(e,t,i),l=lt(c.data,G,`panel:${t}`,i),u=zn(e,t,i,l.rows.filter(e=>e.removed).map(e=>e.row)),d=(0,I.useRef)(null),f=(0,I.useRef)(!1);(0,I.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,L.jsxs)(`div`,{ref:o,children:[(0,L.jsx)(`h3`,{ref:d,tabIndex:-1,className:`sr-only`,children:`Tasks`}),c.isPending&&(0,L.jsx)(`p`,{className:`p-4`,children:`Loading tasks…`}),(c.isError||u.isError)&&(0,L.jsxs)(`p`,{className:`p-4`,role:`alert`,children:[`Could not check current task state.`,` `,(0,L.jsx)(D,{className:`min-h-11`,onClick:()=>{c.refetch(),u.refetch()},children:`Retry`})]}),l.updates>0&&(0,L.jsxs)(D,{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,L.jsx)(ht,{row:u.data?.get(G(e))??e,removed:n&&!!u.data&&!u.data.has(G(e)),checking:!c.data||n&&!u.data,checkFailed:!c.data&&c.isError||n&&!u.data&&u.isError,queue:t===`needs-you`},G(e))),i<p&&(0,L.jsxs)(D,{className:`m-4 min-h-11`,disabled:c.isFetching,onClick:()=>a(e=>e+20),children:[`Show `,Math.min(20,p-i),` more tasks`]})]})}export{fr as DashboardRoute};
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/diff-view-BVwSaBb2.js","assets/rolldown-runtime-QTnfLwEv.js","assets/react-runtime-CCIEwYL0.js","assets/button-CjSjKnkd.js","assets/bundle-mjs-BT31bpU6.js","assets/chevron-right-DKiL3NWw.js","assets/pencil-CCR9uUZ1.js","assets/diff-stat-CFoeFye2.js","assets/use-submit-shortcut-BJ10ZshV.js","assets/chunk-BO2N2NFS-MDrqQfMl.js","assets/lib-BxQXEXDF.js","assets/markdown-Bmfy_1Ll.js","assets/alert-dialog-CF_-dmQ1.js","assets/index-CiQrbvAq.js","assets/toaster-Hj_czp_o.js","assets/use-automations-XKvBTPM-.js","assets/sheet-DCdZVHFk.js","assets/x-BkwTUDpG.js","assets/reference-chip-Bx_mG9QG.js","assets/git-merge-B7oVXcKc.js","assets/triangle-alert-DpH3QFz6.js","assets/tooltip--PYfu68E.js","assets/token-metrics-C149OWmd.js","assets/check-DAAMuI4o.js","assets/use-now-CrM50BFB.js","assets/editable-title-CJSWyCcL.js","assets/trash-2-EdjdGvEo.js","assets/dropdown-menu-DkEK7m00.js","assets/external-link-DPKRidDg.js","assets/composer-DZx3cwQW.js","assets/eye-CEHQ0c-s.js","assets/centered-state-T0J7VmBb.js","assets/search-x-bpAfQtVY.js","assets/pill-bO5OcHuK.js","assets/textarea-Bb0_Hz53.js","assets/thread-loading-Bo6IOu3Y.js","assets/index-WWaEax-B.css","assets/lib-BQXq3kEf.js","assets/markdown-B_O1ys3h.js","assets/message-square-BOO9s3qX.js","assets/image-preview-4SVDrBvn.js","assets/types-BTlmexWF.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{r}from"./button-CjSjKnkd.js";import{i}from"./bundle-mjs-BT31bpU6.js";import{t as a}from"./diff-stat-CFoeFye2.js";import{n as o,t as s}from"./image-preview-4SVDrBvn.js";var c=e(t(),1),l=n();function u(e){let[t,n]=(0,c.useState)(null);return(0,c.useEffect)(()=>{let e=!1;return i(()=>import(`./diff-view-BVwSaBb2.js`).then(t=>{e||n({View:t.DiffView})},()=>{e||n(`failed`)}),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41])),()=>{e=!0}},[]),e.files.length===0?(0,l.jsx)(`p`,{"data-slot":`diff-empty`,className:r(`px-1 text-xs text-soft-foreground`,e.className),children:`No changes.`}):t===`failed`?(0,l.jsx)(d,{...e}):t===null?(0,l.jsx)(`p`,{"data-slot":`diff-loading`,className:r(`px-1 text-xs text-soft-foreground`,e.className),children:`Loading diff…`}):(0,l.jsx)(t.View,{...e})}function d({files:e,wrap:t=!1,imageSrc:n,onOpenInApp:i,viewRef:o,className:s}){let u={adds:e.reduce((e,t)=>e+t.adds,0),dels:e.reduce((e,t)=>e+t.dels,0),files:e.length},d=(0,c.useRef)(null);return(0,c.useImperativeHandle)(o,()=>({scrollToPath:e=>{for(let t of d.current?.querySelectorAll(`[data-slot="diff-file"]`)??[])if(t.dataset.path===e){t.scrollIntoView({block:`start`,behavior:`smooth`});return}}})),(0,l.jsxs)(`div`,{ref:d,"data-slot":`diff`,"data-fallback":`true`,className:r(`flex min-w-0 flex-col gap-3`,s),children:[(0,l.jsxs)(`p`,{"data-slot":`diff-totals`,className:`flex items-center gap-2 px-1 text-xs text-muted-foreground`,children:[(0,l.jsxs)(`span`,{children:[u.files,` `,u.files===1?`file`:`files`,` changed`]}),(0,l.jsx)(a,{stat:u})]}),e.map(e=>(0,l.jsx)(f,{file:e,wrap:t,imageSrc:n,onOpenInApp:i},`${e.oldPath??``}→${e.path}`))]})}function f({file:e,wrap:t,imageSrc:n,onOpenInApp:i}){return(0,l.jsxs)(`section`,{"data-slot":`diff-file`,"data-path":e.path,className:`min-w-0 overflow-clip rounded-md border border-border bg-card`,children:[(0,l.jsxs)(`header`,{className:`flex items-center gap-2 border-b border-border/50 px-3 py-2`,children:[(0,l.jsx)(`span`,{"data-slot":`diff-file-path`,className:`min-w-0 truncate font-mono text-xs font-medium`,children:e.oldPath?`${e.oldPath} → ${e.path}`:e.path}),(0,l.jsx)(`span`,{className:`ml-auto shrink-0`,children:(0,l.jsx)(a,{stat:{adds:e.adds,dels:e.dels,files:1},className:`text-[11px]`})})]}),o(e)?(0,l.jsx)(s,{file:e,imageSrc:n,onOpenInApp:i}):e.binary?(0,l.jsx)(`p`,{className:`px-4 py-2.5 text-xs text-soft-foreground`,children:`Binary file — no text diff.`}):e.patch===``?(0,l.jsx)(`p`,{className:`px-4 py-2.5 text-xs text-soft-foreground`,children:`No content changes (metadata only).`}):(0,l.jsx)(`pre`,{className:r(`py-2 font-mono text-xs leading-[1.7]`,t?`break-words whitespace-pre-wrap`:`overflow-x-auto whitespace-pre`),children:e.patch.split(`
|
|
3
|
-
`).map((e,t)=>(0,l.jsxs)(`span`,{className:r(`block px-4`,e.startsWith(`+`)&&!e.startsWith(`+++`)&&`bg-diff-add`,e.startsWith(`-`)&&!e.startsWith(`---`)&&`bg-diff-del`,e.startsWith(`@@`)&&`text-soft-foreground`),children:[e,e===``?` `:``]},t))})]})}export{u as t};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{t as e}from"./react-runtime-CCIEwYL0.js";import{F as t,r as n,t as r}from"./button-CjSjKnkd.js";import{t as i}from"./eye-CEHQ0c-s.js";import{i as a,n as o,r as s,t as c}from"./tooltip--PYfu68E.js";import{B as l}from"./index-CiQrbvAq.js";var u=t(`text-wrap`,[[`path`,{d:`m16 16-3 3 3 3`,key:`117b85`}],[`path`,{d:`M3 12h14.5a1 1 0 0 1 0 7H13`,key:`18xa6z`}],[`path`,{d:`M3 19h6`,key:`1ygdsz`}],[`path`,{d:`M3 5h18`,key:`1u36vt`}]]),d=e();function f({mode:e,wrap:t,preview:l=!1,onModeChange:f,onWrapChange:m,onPreviewChange:h}){return(0,d.jsxs)(d.Fragment,{children:[(0,d.jsxs)(`span`,{"data-slot":`diff-mode-toggle`,role:`group`,"aria-label":`Diff layout`,className:`flex items-center rounded-md border border-border p-0.5`,children:[(0,d.jsx)(p,{current:e,value:`unified`,onModeChange:f}),(0,d.jsx)(p,{current:e,value:`split`,onModeChange:f})]}),h?(0,d.jsx)(s,{delayDuration:300,children:(0,d.jsxs)(c,{children:[(0,d.jsx)(a,{asChild:!0,children:(0,d.jsx)(r,{variant:`ghost`,size:`icon-sm`,"data-slot":`markdown-preview-toggle`,"aria-pressed":l,"aria-label":`Preview Markdown`,className:n(l&&`bg-muted text-foreground`),onClick:()=>h(!l),children:(0,d.jsx)(i,{"aria-hidden":`true`})})}),(0,d.jsx)(o,{side:`bottom`,sideOffset:6,"data-slot":`markdown-preview-tooltip`,children:l?`Show Markdown as a diff`:`Preview Markdown`})]})}):null,(0,d.jsx)(r,{variant:`ghost`,size:`icon-sm`,"data-slot":`wrap-toggle`,"aria-pressed":t,"aria-label":`Wrap long lines`,title:`Wrap long lines`,className:n(t&&`bg-muted text-foreground`),onClick:()=>m(!t),children:(0,d.jsx)(u,{"aria-hidden":`true`})})]})}function p({current:e,value:t,onModeChange:r}){let i=e===t;return(0,d.jsx)(`button`,{type:`button`,"data-mode":t,"aria-pressed":i,onClick:()=>r(t),className:n(`rounded-[5px] px-2 py-0.5 text-[11px] font-medium capitalize`,i?`bg-muted text-foreground`:`text-muted-foreground hover:text-foreground`),children:t})}function m({branch:e}){return(0,d.jsxs)(`span`,{"data-slot":`branch-chip`,className:`flex min-w-0 items-center gap-1 rounded-sm border border-border bg-card px-1.5 py-px font-mono text-[11px] font-medium`,children:[(0,d.jsx)(l,{"aria-hidden":`true`,className:`size-3 shrink-0`}),(0,d.jsx)(`span`,{className:`truncate`,children:e})]})}export{f as n,m as t};
|
|
@@ -1,13 +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{F as r,r as i,t as a}from"./button-CjSjKnkd.js";import{t as o}from"./chevron-right-DKiL3NWw.js";import{t as s}from"./pencil-CCR9uUZ1.js";import{t as c}from"./diff-stat-CFoeFye2.js";import{t as l}from"./use-submit-shortcut-BJ10ZshV.js";import{o as u}from"./chunk-BO2N2NFS-MDrqQfMl.js";import{a as d,i as f,r as p,t as m}from"./markdown-Bmfy_1Ll.js";import{z as h}from"./index-CiQrbvAq.js";import{t as g}from"./lib-BQXq3kEf.js";import{n as _,t as v}from"./markdown-B_O1ys3h.js";import{n as ee,t as te}from"./image-preview-4SVDrBvn.js";import{n as y,t as b}from"./types-BTlmexWF.js";var x=r(`message-square-off`,[[`path`,{d:`M19 19H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.7.7 0 0 1 2 21.286V5a2 2 0 0 1 1.184-1.826`,key:`1wyg69`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}],[`path`,{d:`M8.656 3H20a2 2 0 0 1 2 2v11.344`,key:`mhl4k6`}]]),S=e(t(),1),C=44;function w(e){if(e.binary===!0||e.patch===``)return 1;let t=e.patch.split(`
|
|
2
|
-
`),n=t.findIndex(e=>e.startsWith(`@@`));return n===-1?t.length:t.length-n}function ne(e){return w(e)*20+C}function re(e){return e.reduce((e,t)=>e+w(t),0)}function ie(e,t){let n=new URLSearchParams(e).get(`diff`);return n===`flat`||n===`virtual`?n:t>1500?`virtual`:`flat`}function T(e){return`${e.oldPath??``}→${e.path}`}function E(e){let t=0;for(let n of e.split(`
|
|
3
|
-
`))n.length>t&&(t=n.length);return t}var D=/[A-Za-z0-9_]+|\s+|[^\sA-Za-z0-9_]+/g,O=300,k=.3;function A(e,t){if(e===t)return null;let n=e.match(D)??[],r=t.match(D)??[];if(n.length===0||r.length===0||n.length>O||r.length>O)return null;let i=r.length+1,a=new Uint16Array((n.length+1)*i);for(let e=1;e<=n.length;e++)for(let t=1;t<=r.length;t++)a[e*i+t]=n[e-1]===r[t-1]?(a[(e-1)*i+(t-1)]??0)+1:Math.max(a[(e-1)*i+t]??0,a[e*i+(t-1)]??0);if((a[n.length*i+r.length]??0)/Math.max(n.length,r.length)<k)return null;let o=Array(n.length).fill(!1),s=Array(r.length).fill(!1),c=n.length,l=r.length;for(;c>0&&l>0;)n[c-1]===r[l-1]?(o[c-1]=!0,s[l-1]=!0,c--,l--):(a[(c-1)*i+l]??0)>=(a[c*i+(l-1)]??0)?c--:l--;return{del:j(n,o),add:j(r,s)}}function j(e,t){let n=[];return e.forEach((e,r)=>{let i=!(t[r]??!1),a=n[n.length-1];a&&a.changed===i?a.text+=e:n.push({text:e,changed:i})}),n}function M(e,t,n){if(!t||t.length===0)return e?e.map(e=>({text:e.content,color:e.color,changed:!1})):n===``?[]:[{text:n,changed:!1}];if(!e||e.length===0)return t.map(e=>({text:e.text,changed:e.changed}));let r=[],i=0,a=0,o=0,s=0;for(;i<e.length&&o<t.length;){let n=e[i],c=t[o],l=n.content.length-a,u=c.text.length-s,d=Math.min(l,u);d>0&&(r.push({text:n.content.slice(a,a+d),color:n.color,changed:c.changed}),a+=d,s+=d),n.content.length-a<=0&&(i++,a=0),c.text.length-s<=0&&(o++,s=0)}for(;i<e.length;){let t=e[i],n=t.content.slice(a);n!==``&&r.push({text:n,color:t.color,changed:!1}),i++,a=0}return r}var N=/^@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@/,P=`… (patch truncated)`;function F(e){let t=[],n=!1,r=null,i=0,a=0,o=e.split(`
|
|
4
|
-
`);o.at(-1)===``&&o.pop();for(let e of o){let o=N.exec(e);if(o){r={header:e,oldStart:Number(o[1]),oldCount:o[2]===void 0?1:Number(o[2]),newStart:Number(o[3]),newCount:o[4]===void 0?1:Number(o[4]),lines:[]},i=r.oldStart,a=r.newStart,t.push(r);continue}if(e.includes(P)){n=!0,r=null;continue}r&&(e.startsWith(`+`)?r.lines.push({kind:`add`,text:e.slice(1),newLine:a++}):e.startsWith(`-`)?r.lines.push({kind:`del`,text:e.slice(1),oldLine:i++}):e.startsWith(`\\`)||r.lines.push({kind:`context`,text:e.slice(1),oldLine:i++,newLine:a++}))}return{hunks:t,truncated:n}}function I(e,t=!1){let n=[],r=e[0];if(!r)return n;r.newStart>1&&n.push({beforeHunk:0,count:r.newStart-1,oldStart:1,newStart:1});for(let t=1;t<e.length;t++){let r=e[t-1],i=e[t],a=r.oldStart+r.oldCount,o=r.newStart+r.newCount,s=i.newStart-o;s>0&&n.push({beforeHunk:t,count:s,oldStart:a,newStart:o})}if(t){let t=e[e.length-1];n.push({beforeHunk:e.length,oldStart:t.oldStart+t.oldCount,newStart:t.newStart+t.newCount})}return n}function ae(e,t){let n=e.count===void 0?t.length:e.newStart+e.count-1,r=e.oldStart-e.newStart,i=[];for(let a=e.newStart;a<=Math.min(n,t.length);a++)i.push({kind:`context`,text:t[a-1]??``,oldLine:a+r,newLine:a});return i}function L(e,t){let n=Array(e.length),r=Array(t.length),i=Math.min(e.length,t.length);for(let a=0;a<i;a++){let i=A(e[a].text,t[a].text);i&&(n[a]=i.del,r[a]=i.add)}return{dels:e,adds:t,delSpans:n,addSpans:r}}function R(e,t,n){let r=0;for(;r<e.lines.length;){let i=e.lines[r];if(i.kind===`del`||i.kind===`add`){let t=[],i=[];for(;r<e.lines.length&&e.lines[r].kind===`del`;)t.push(e.lines[r++]);for(;r<e.lines.length&&e.lines[r].kind===`add`;)i.push(e.lines[r++]);n(L(t,i))}else t(i),r++}}function z(e,t=[],n){let r=new Map(t.map(e=>[e.beforeHunk,e])),i=[],a=e=>{let t=r.get(e);if(!t)return;let a=n?.get(e);if(a)for(let e of a)i.push({type:`line`,cell:{line:e}});else i.push({type:`gap`,gap:t})};return e.forEach((e,t)=>{a(t),i.push({type:`hunk`,hunk:e}),R(e,e=>i.push({type:`line`,cell:{line:e}}),e=>{e.dels.forEach((t,n)=>i.push({type:`line`,cell:{line:t,spans:e.delSpans[n]}})),e.adds.forEach((t,n)=>i.push({type:`line`,cell:{line:t,spans:e.addSpans[n]}}))})}),a(e.length),i}function B(e,t=[],n){let r=new Map(t.map(e=>[e.beforeHunk,e])),i=[],a=e=>{let t=r.get(e);if(!t)return;let a=n?.get(e);if(a)for(let e of a)i.push({type:`pair`,left:{line:e},right:{line:e}});else i.push({type:`gap`,gap:t})};return e.forEach((e,t)=>{a(t),i.push({type:`hunk`,hunk:e}),R(e,e=>i.push({type:`pair`,left:{line:e},right:{line:e}}),e=>{let t=Math.max(e.dels.length,e.adds.length);for(let n=0;n<t;n++){let t=e.dels[n],r=e.adds[n];i.push({type:`pair`,...t?{left:{line:t,spans:e.delSpans[n]}}:{},...r?{right:{line:r,spans:e.addSpans[n]}}:{}})}})}),a(e.length),i}var V=n();function H({file:e,loadFileText:t,imageSrc:n}){let r=(0,S.useMemo)(()=>oe(e),[e]),i=(0,S.useRef)(t);i.current=t;let a=t!==void 0,[o,s]=(0,S.useState)(null);(0,S.useEffect)(()=>{let t=i.current;if(!t)return;let n=!1;return t(e.path).then(t=>!n&&s({path:e.path,text:t}),()=>!n&&s({path:e.path,text:null})),()=>{n=!0}},[e.path,e.patch,a]);let c=(0,S.useRef)(n);c.current=n;let l=(0,S.useMemo)(()=>U(e.path,e=>c.current?.(e)),[e.path]),u=o?.path===e.path?o:null;if(a&&u===null)return(0,V.jsx)(`p`,{className:`px-4 py-2.5 text-xs text-soft-foreground`,children:`Loading preview…`});let d=u?.text??null;return(0,V.jsxs)(`div`,{"data-slot":`diff-markdown-preview`,className:`px-6 py-6`,children:[d===null&&!r.complete?(0,V.jsx)(`p`,{className:`mx-auto mb-4 max-w-[72ch] text-xs text-soft-foreground`,children:`Showing the changed sections only.`}):null,(0,V.jsx)(m,{variant:`document`,urlTransform:l,children:d??r.text})]})}function oe(e){let t=F(e.patch);return{text:t.hunks.map(e=>e.lines.filter(e=>e.kind!==`del`).map(e=>e.text).join(`
|
|
5
|
-
`)).join(`
|
|
6
|
-
|
|
7
|
-
---
|
|
8
|
-
|
|
9
|
-
`),complete:e.status===`added`&&!t.truncated}}var se=/^(?:[a-z][a-z\d+.-]*:|\/\/)/i;function U(e,t){return(n,r,i)=>{if(n.startsWith(`#`)||se.test(n))return u(n,r,i);let a=W(e,n);return a===null||r!==`src`?null:t(a)??null}}function W(e,t){let n=t.split(/[?#]/,1)[0]??``;if(n===``)return null;let r=n.startsWith(`/`)?[]:e.split(`/`).slice(0,-1);for(let e of n.split(`/`))if(!(e===``||e===`.`))if(e===`..`){if(r.pop()===void 0)return null}else r.push(G(e));return r.length>0?r.join(`/`):null}function G(e){try{return decodeURIComponent(e)}catch{return e}}function K(e,t){return t.kind===`del`?t.oldLine===void 0?void 0:{path:e,side:`old`,line:t.oldLine}:t.newLine===void 0?void 0:{path:e,side:`new`,line:t.newLine}}function q(e){return`${e.side}:${e.line}\u0000${e.path}`}function ce(e,t,n,r){let i=Math.max(0,Math.min(n,r)),a=Math.min(t.length-1,Math.max(n,r)),o=t[a],s=o?K(e,o):void 0;if(!s)return;let c=t.slice(i,a+1);if(i===a)return{anchor:s,excerpt:o.text};let l=K(e,t[i]);return{anchor:s,...l?{start:{side:l.side,line:l.line}}:{},excerpt:J(c)}}function J(e){let t=[],n,r;for(let i of e){if(i.newLine!==void 0&&r!==void 0&&i.newLine>r+1||i.oldLine!==void 0&&n!==void 0&&i.oldLine>n+1){let e=i.newLine!==void 0&&r!==void 0?i.newLine-r-1:i.oldLine-n-1;t.push(`⋯ ${e} unchanged ${e===1?`line`:`lines`} not shown`)}t.push(i.text),i.oldLine!==void 0&&(n=i.oldLine),i.newLine!==void 0&&(r=i.newLine)}return t.join(`
|
|
10
|
-
`)}var Y=(0,S.createContext)(null);function le(e){if(e===`selected`)return`relative before:pointer-events-none before:absolute before:inset-0 before:bg-primary/15`;if(e===`commented`)return`shadow-[inset_3px_0_0_0_var(--color-primary)]`}var ue=(0,S.createContext)(null);function X(){return(0,S.useContext)(ue)}function de(){return typeof window<`u`&&typeof window.matchMedia==`function`&&window.matchMedia(`(hover: none)`).matches}function fe(e,t,n){if(!(!e?.canAdd||t===void 0))return{onClick:r=>{de()&&(r.target.closest(`button, a, textarea, input`)||(window.getSelection?.()?.toString()??``)===``&&e.open(t,n))}}}function pe({anchor:e,excerpt:t,line:n}){let r=X(),a=(0,S.useContext)(Y);if(!r?.canAdd||e===void 0)return null;let o=a?.orderOf.get(n),s=r.editing,c=s!==null&&s.commentId===void 0&&s.anchor.path===e.path&&a!==null;return(0,V.jsx)(`button`,{type:`button`,"data-slot":`diff-add-comment`,"aria-label":`Comment on ${e.path.split(`/`).at(-1)} ${e.side===`old`?`removed `:``}line ${e.line}`,title:`Add a comment for the agent — drag to cover several lines, or shift-click to extend`,onMouseDown:t=>{t.button===0&&(t.preventDefault(),!(t.shiftKey&&c)&&a&&o!==void 0&&r.beginSelect(e.path,o,a.lines))},onClick:n=>{if(n.shiftKey&&c&&o!==void 0&&s){let t=s.start??s.anchor,n=me(a,e.path,t)??o,i=ce(e.path,a.lines,n,o);i&&r.open(i.anchor,i.excerpt,i.start,!0);return}n.detail===0&&r.open(e,t)},className:i(`absolute top-1/2 left-0 z-[1] flex size-4 -translate-y-1/2 items-center justify-center rounded-sm`,`bg-primary text-primary-foreground opacity-0 shadow-xs transition-opacity`,`group-hover/line:opacity-100 focus-visible:opacity-100 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`),children:(0,V.jsx)(h,{"aria-hidden":`true`,className:`size-2.5`,strokeWidth:3})})}function me(e,t,n){let r=q({path:t,side:n.side,line:n.line});for(let[n,i]of e.orderOf){let e=K(t,n);if(e&&q(e)===r)return i}}function he({anchors:e}){let t=X(),n=(0,S.useContext)(Y);if(!t)return null;let r=[...new Set(e.filter(e=>e!==void 0).map(q))],i=r.flatMap(e=>t.byKey.get(e)??[]),a=t.editing!==null&&r.includes(t.editing.threadKey)?t.editing:null;if(i.length===0&&a===null)return null;let o=a?.commentId;return(0,V.jsx)(`div`,{"data-slot":`diff-line-comments`,className:`border-y border-primary/25 bg-primary/5 py-2.5 font-sans`,children:(0,V.jsxs)(`div`,{className:`sticky left-0 flex w-full max-w-2xl flex-col gap-2 px-3 md:pl-24`,children:[i.map(e=>e.id===o&&a?(0,V.jsx)(ve,{editing:a,api:t},a.key):(0,V.jsx)(_e,{comment:e,outdated:ge(e,n),onEdit:t.edit,onRemove:t.remove},e.id)),a&&o===void 0?(0,V.jsx)(ve,{editing:a,api:t},a.key):null]})})}function ge(e,t){if(!t||!e.excerpt||e.excerpt.endsWith(`…`))return!1;let n=q(e),r=t.lines.find(t=>{let r=K(e.path,t);return r!==void 0&&q(r)===n});return r?(e.excerpt.split(`
|
|
11
|
-
`).at(-1)??``).trimEnd()!==r.text.trimEnd():!1}function _e({comment:e,outdated:t=!1,onEdit:n,onRemove:r}){return(0,V.jsxs)(`div`,{"data-slot":`diff-line-comment`,"data-comment-id":e.id,role:`group`,"aria-label":`Comment on ${y(e,e.start)}`,className:`flex flex-col gap-1.5 rounded-md border border-primary/40 bg-card px-3 py-2.5 text-[13px] leading-normal shadow-sm transition-shadow duration-500 data-[flash=true]:ring-2 data-[flash=true]:ring-primary`,children:[t?(0,V.jsxs)(`div`,{"data-slot":`diff-line-comment-outdated`,className:`flex flex-col gap-1`,children:[(0,V.jsx)(`p`,{className:`text-[11px] font-medium text-pending-strong`,children:`Outdated — the code here changed since this comment`}),(0,V.jsx)(`pre`,{className:`max-h-32 overflow-auto rounded-sm border border-border/60 bg-muted/40 px-2 py-1 font-mono text-[12px] whitespace-pre text-muted-foreground`,children:e.excerpt})]}):null,(0,V.jsx)(`p`,{className:`break-words whitespace-pre-wrap text-foreground`,children:e.body}),n||r?(0,V.jsxs)(`div`,{className:`flex items-center justify-end gap-1.5`,children:[n?(0,V.jsxs)(a,{type:`button`,variant:`ghost`,size:`sm`,onClick:()=>n(e),children:[(0,V.jsx)(s,{"aria-hidden":`true`,className:`size-3.5`}),`Edit`]}):null,r?(0,V.jsxs)(a,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>r(e.id),children:[(0,V.jsx)(x,{"aria-hidden":`true`,className:`size-3.5`}),`Remove from chat`]}):null]}):null]})}function ve({editing:e,api:t}){let[n,r]=(0,S.useState)(()=>t.pendingText.get(e.key)??e.initial??``),i=(0,S.useRef)(null);(0,S.useEffect)(()=>{let n=i.current;!n||t.focusRequest.current!==e.key||(t.focusRequest.current=null,n.focus({preventScroll:!0}),n.setSelectionRange(n.value.length,n.value.length),n.closest(`[data-slot="diff-comment-editor"]`)?.scrollIntoView?.({block:`nearest`}))},[]);let o=n.trim(),s=()=>{o!==``&&(e.commentId===void 0?t.submit({...e.anchor,...e.start?{start:e.start}:{},...e.oldPath?{oldPath:e.oldPath}:{},excerpt:e.excerpt,body:o}):t.update(e.commentId,o))&&t.pendingText.delete(e.key)},c=()=>{t.pendingText.delete(e.key),t.cancel()};return(0,V.jsxs)(`div`,{"data-slot":`diff-comment-editor`,className:`flex flex-col gap-2`,children:[(0,V.jsx)(`textarea`,{ref:i,rows:3,maxLength:b,value:n,"aria-label":`Comment on ${y(e.anchor,e.start)}`,placeholder:`Add a comment for the AI`,onChange:n=>{r(n.target.value),t.pendingText.set(e.key,n.target.value)},onKeyDown:e=>{if(e.key===`Escape`){e.preventDefault(),c();return}l({key:e.key,shiftKey:e.shiftKey,metaKey:e.metaKey,ctrlKey:e.ctrlKey,altKey:e.altKey,repeat:e.repeat,isComposing:e.nativeEvent.isComposing})&&(e.preventDefault(),s())},className:`block w-full resize-y rounded-md border border-ring/60 bg-background px-3 py-2 text-base leading-normal outline-none placeholder:text-muted-foreground focus:border-ring focus:ring-[3px] focus:ring-ring/15 md:text-sm`}),(0,V.jsxs)(`div`,{className:`flex items-center justify-end gap-1.5`,children:[(0,V.jsx)(a,{type:`button`,variant:`ghost`,size:`sm`,onClick:c,children:`Cancel`}),(0,V.jsxs)(a,{type:`button`,size:`sm`,disabled:o===``,onClick:s,children:[e.commentId===void 0?`Comment`:`Save`,` `,(0,V.jsx)(`span`,{"aria-hidden":`true`,children:`↵`})]})]})]})}var ye=1500,be=new Map;function xe(e,t){if(e){for(let n of e.querySelectorAll(`[data-slot="diff-file"]`))if(n.dataset.path===t)return n}}function Se(e,t){let n=xe(e,t.path);if(!n)return;if(t.commentId!==void 0){for(let e of n.querySelectorAll(`[data-slot="diff-line-comment"]`))if(e.dataset.commentId===t.commentId)return e}if(t.line===void 0)return;let r=String(t.line);for(let e of n.querySelectorAll(`[data-slot="diff-line"], [data-slot="diff-cell"]`))if((t.side===`old`?e.dataset.oldLine:e.dataset.newLine)===r)return e}function Ce(e){e.dataset.flash=`true`,setTimeout(()=>{delete e.dataset.flash},1600)}function we({files:e,mode:t=`unified`,wrap:n=!1,preview:r=!1,loadFileText:a,imageSrc:o,onOpenInApp:s,viewRef:l,comments:u,onAddComment:d,onEditComment:f,onRemoveComment:p,className:m}){let h=(0,S.useMemo)(()=>({adds:e.reduce((e,t)=>e+t.adds,0),dels:e.reduce((e,t)=>e+t.dels,0),files:e.length}),[e]),[g,_]=(0,S.useState)(()=>new Set),[ee,te]=(0,S.useState)(()=>new Map),y=(0,S.useCallback)(e=>{_(t=>{let n=new Set(t);return n.delete(e)||n.add(e),n})},[]),b=(0,S.useCallback)(async(e,t)=>{if(!a)return;let n=await a(e.path);if(n===null)return;let r=ae(t,n.split(`
|
|
12
|
-
`));te(n=>{let i=T(e);return new Map(n).set(i,new Map(n.get(i)??be).set(t.beforeHunk,r))})},[a]),[x,C]=(0,S.useState)(null),w=(0,S.useRef)(new Map).current,E=(0,S.useRef)(null),[D,O]=(0,S.useState)(null),k=(0,S.useRef)(null),A=(0,S.useRef)([]),j=D!==null,M=(0,S.useRef)(x);M.current=x;let N=(0,S.useRef)({element:null}),P=(0,S.useRef)(null),F=(0,S.useRef)(null),[I,L]=(0,S.useState)(0),R=e=>{let t=document.activeElement;N.current={element:t instanceof HTMLElement&&P.current?.contains(t)?t:null,...e?{commentId:e}:{}}},z=()=>{let{element:e,commentId:t}=N.current;N.current={element:null},setTimeout(()=>{if(e?.isConnected){e.focus({preventScroll:!0});return}if(t!==void 0){for(let e of P.current?.querySelectorAll(`[data-slot="diff-line-comment"]`)??[])if(e.dataset.commentId===t){e.querySelector(`button`)?.focus({preventScroll:!0});return}}},0)},B=(0,S.useRef)({captureOpener:R,restoreFocus:z});B.current={captureOpener:R,restoreFocus:z};let H=(0,S.useCallback)((t,n,r,i=!1)=>{let a=q(t),o=r?`${a}\u0000${r.side}:${r.line}`:a,s=M.current;if(i&&s&&s.commentId===void 0&&s.key!==o){let e=w.get(s.key);e!==void 0&&(w.set(o,e),w.delete(s.key))}let c=t.side===`old`||r?.side===`old`?e.find(e=>e.path===t.path)?.oldPath:void 0;E.current=o,i||B.current.captureOpener(),C({key:o,threadKey:a,anchor:t,excerpt:n,...r?{start:r}:{},...c?{oldPath:c}:{}})},[e,w]);(0,S.useEffect)(()=>{if(!j)return;let e=()=>{let e=k.current;if(k.current=null,O(null),!e)return;let t=ce(e.path,A.current,e.from,e.to);t&&H(t.anchor,t.excerpt,t.start)};return window.addEventListener(`mouseup`,e),()=>window.removeEventListener(`mouseup`,e)},[H,j]);let oe=(0,S.useMemo)(()=>{if(!d&&(u?.length??0)===0)return null;let e=new Map;for(let t of u??[]){let n=q(t);e.set(n,[...e.get(n)??[],t])}return{comments:u??[],byKey:e,editing:x,selection:D,canAdd:d!==void 0,open:H,beginSelect:(e,t,n)=>{A.current=n,k.current={path:e,from:t,to:t},O(k.current)},extendSelect:(e,t)=>{let n=k.current;n===null||n.path!==e||n.to===t||(k.current={...n,to:t},O(k.current))},edit:f?e=>{E.current=`edit:${e.id}`,B.current.captureOpener(e.id),C({key:`edit:${e.id}`,threadKey:q(e),anchor:e,...e.start?{start:e.start}:{},excerpt:``,commentId:e.id,initial:e.body})}:void 0,cancel:()=>{C(null),B.current.restoreFocus()},submit:e=>d?.(e)===!1?!1:(C(null),B.current.restoreFocus(),!0),update:(e,t)=>f?.(e,t)===!1?!1:(C(null),B.current.restoreFocus(),!0),remove:p,pendingText:w,focusRequest:E}},[u,x,d,f,p,H,w,D]),se=(0,S.useMemo)(()=>re(e),[e]),[U]=(0,S.useState)(()=>typeof window>`u`?``:window.location.search),W=ie(U,se),G=(0,S.useRef)(null),K=(0,S.useRef)(null),J=(0,S.useRef)(null);(0,S.useImperativeHandle)(l,()=>{let t=t=>{let n=e.findIndex(e=>e.path===t);if(n===-1)return;let r=K.current,i=J.current,a=i&&Number.parseFloat(getComputedStyle(i).scrollMarginTop)||0;r?r.scrollToIndex(n,{align:`start`,offset:-a}):xe(i,t)?.scrollIntoView?.({block:`start`,behavior:`instant`})};return{scrollToPath:e=>t(e),reveal:n=>{let r=e.find(e=>e.path===n.path);if(!r)return;_(e=>{if(!e.has(T(r)))return e;let t=new Set(e);return t.delete(T(r)),t}),t(n.path);let i=0,a=()=>{let e=Se(J.current,n);if(e){let t=G.current,n=K.current;if(t&&n){let r=e.getBoundingClientRect(),i=Number.parseFloat(getComputedStyle(e).scrollMarginBottom)||0;n.scrollTo(t.scrollTop+r.top-t.getBoundingClientRect().top-(t.clientHeight-i-r.height)/2)}else e.scrollIntoView?.({block:`center`,behavior:`instant`});Ce(e);return}++i<30&&requestAnimationFrame(a)};requestAnimationFrame(a)}}},[e]);let Y=e=>{let i=T(e);return(0,V.jsx)(Oe,{file:e,open:!g.has(i),onToggle:()=>y(i),expanded:ee.get(i)??be,onExpand:t=>void b(e,t),mode:t,wrap:n,preview:r&&v(e),loadFileText:a,canExpand:a!==void 0,imageSrc:o,onOpenInApp:s})};return(0,V.jsx)(ue.Provider,{value:oe,children:(0,V.jsxs)(`div`,{ref:e=>{if(J.current=e,P.current=e,!e)return;let t=Te(e);G.current=t,F.current&&F.current!==t&&L(e=>e+1),F.current=t},"data-slot":`diff`,"data-mode":t,className:i(`flex min-w-0 flex-col scroll-mt-[var(--diff-sticky-top,0px)]`,m),children:[(0,V.jsxs)(`p`,{"data-slot":`diff-totals`,className:`flex items-center gap-2 px-1 pb-3 text-xs text-muted-foreground`,children:[(0,V.jsxs)(`span`,{children:[h.files,` `,h.files===1?`file`:`files`,` changed`]}),(0,V.jsx)(c,{stat:h})]}),W===`virtual`?(0,V.jsx)(Ee,{files:e,handleRef:K,scrollElRef:G,card:Y},I):(0,V.jsx)(`div`,{"data-slot":`diff-files`,"data-virtualized":`false`,children:e.map(e=>(0,V.jsx)(`div`,{"data-slot":`diff-file-slot`,style:{containIntrinsicBlockSize:`auto ${ne(e)}px`},className:`pb-3 [content-visibility:auto]`,children:Y(e)},T(e)))})]})})}function Te(e){return e.closest(`[data-diff-scroller], [data-slot="main"]`)}function Ee({files:e,handleRef:t,scrollElRef:n,card:r}){let i=(0,S.useRef)(null),[a,o]=(0,S.useState)(0);return(0,S.useLayoutEffect)(()=>{let e=()=>{let e=i.current,t=n.current;!e||!t||o(Math.max(0,Math.round(e.getBoundingClientRect().top-t.getBoundingClientRect().top+t.scrollTop)))};return e(),window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[n]),(0,V.jsx)(`div`,{ref:e=>{i.current=e,e&&(n.current=Te(e))},"data-slot":`diff-files`,"data-virtualized":`true`,children:(0,V.jsx)(g,{ref:t,scrollRef:n,startMargin:a,children:e.map(e=>(0,V.jsx)(`div`,{"data-slot":`diff-file-slot`,className:`pb-3`,children:r(e)},T(e)))})})}var De={added:`added`,deleted:`deleted`,renamed:`renamed`,copied:`copied`};function Oe({file:e,open:t,onToggle:n,expanded:r,onExpand:a,mode:s,wrap:l,preview:u,loadFileText:d,canExpand:f,imageSrc:p,onOpenInApp:m}){let h=De[e.status],g=X()?.comments.filter(t=>t.path===e.path).length??0;return(0,V.jsxs)(`section`,{"data-slot":`diff-file`,"data-path":e.path,className:`min-w-0 scroll-mt-[var(--diff-sticky-top,0px)] overflow-clip rounded-md border border-border bg-card`,children:[(0,V.jsx)(`header`,{className:`sticky top-[var(--diff-sticky-top,0px)] z-10 border-b border-[color-mix(in_oklab,var(--border)_50%,var(--card))] bg-card shadow-[0_-1px_0_var(--card)]`,children:(0,V.jsxs)(`button`,{type:`button`,"data-slot":`diff-file-header`,"aria-expanded":t,onClick:n,className:`flex w-full items-center gap-2 px-3 py-2 text-left hover:bg-muted/50`,children:[(0,V.jsx)(o,{className:i(`size-3.5 shrink-0 text-soft-foreground transition-transform`,t&&`rotate-90`),"aria-hidden":`true`}),(0,V.jsx)(`span`,{"data-slot":`diff-file-path`,className:`min-w-0 truncate font-mono text-xs font-medium`,children:e.oldPath?(0,V.jsxs)(V.Fragment,{children:[(0,V.jsxs)(`span`,{className:`text-soft-foreground`,children:[e.oldPath,` → `]}),e.path]}):e.path}),h?(0,V.jsx)(`span`,{className:`shrink-0 rounded-sm bg-muted px-1.5 py-px text-[10px] font-medium text-muted-foreground`,children:h}):null,e.image?(0,V.jsx)(`span`,{className:`shrink-0 rounded-sm bg-muted px-1.5 py-px text-[10px] font-medium text-muted-foreground`,children:`image`}):e.binary?(0,V.jsx)(`span`,{className:`shrink-0 rounded-sm bg-muted px-1.5 py-px text-[10px] font-medium text-muted-foreground`,children:`binary`}):null,u?(0,V.jsx)(`span`,{className:`shrink-0 rounded-sm bg-muted px-1.5 py-px text-[10px] font-medium text-muted-foreground`,children:`preview`}):null,(0,V.jsxs)(`span`,{className:`ml-auto flex shrink-0 items-center gap-2`,children:[(0,V.jsx)(_,{count:g}),(0,V.jsx)(c,{stat:{adds:e.adds,dels:e.dels,files:1},className:`text-[11px]`})]})]})}),t&&u?(0,V.jsx)(H,{file:e,loadFileText:d,imageSrc:p}):t?(0,V.jsx)(ke,{file:e,expanded:r,onExpand:a,mode:s,wrap:l,canExpand:f,imageSrc:p,onOpenInApp:m}):null]})}function ke({file:e,expanded:t,onExpand:n,mode:r,wrap:a,canExpand:o,imageSrc:s,onOpenInApp:c}){let l=(0,S.useMemo)(()=>F(e.patch),[e.patch]),u=o&&e.status!==`added`&&e.status!==`deleted`,d=(0,S.useMemo)(()=>I(l.hunks,u),[l.hunks,u]),f=(0,S.useMemo)(()=>{let e=[];l.hunks.forEach((n,r)=>{let i=t.get(r);i&&e.push(...i),e.push(...n.lines)});let n=t.get(l.hunks.length);return n&&e.push(...n),e},[l.hunks,t]),p=(0,S.useMemo)(()=>new Map(f.map((e,t)=>[e,t])),[f]),m=Ae(e.path,f),h=X(),g=(0,S.useMemo)(()=>{if(!h)return null;let t=new Map;f.forEach((n,r)=>{let i=K(e.path,n);i&&t.set(q(i),r)});let n=n=>t.get(q({path:e.path,side:n.side,line:n.line})),r=new Map,i=(e,t,n)=>{for(let i=Math.min(e,t);i<=Math.max(e,t);i++)(n===`selected`||!r.has(i))&&r.set(i,n)},a=(e,t,r)=>{let a=n(e);a!==void 0&&i(t?n(t)??a:a,a,r)};for(let t of h.comments)t.path===e.path&&a(t,t.start,`commented`);let{editing:o,selection:s}=h;return o&&o.anchor.path===e.path&&a(o.anchor,o.start,`selected`),s&&s.path===e.path&&i(s.from,s.to,`selected`),{path:e.path,lines:f,orderOf:p,markAt:e=>r.get(e)}},[h,e.path,f,p]),_=(0,S.useMemo)(()=>r===`unified`?z(l.hunks,d,t):null,[r,l.hunks,d,t]),v=(0,S.useMemo)(()=>r===`split`?B(l.hunks,d,t):null,[r,l.hunks,d,t]),y=(0,S.useMemo)(()=>r===`unified`&&!a?{minInlineSize:`calc(${E(e.patch)}ch + 7rem)`}:void 0,[r,a,e.patch]);if(ee(e))return(0,V.jsx)(te,{file:e,imageSrc:s,onOpenInApp:c});if(e.binary)return(0,V.jsx)(Z,{children:`Binary file — no text diff.`});if(l.hunks.length===0)return(0,V.jsx)(Z,{children:l.truncated?`Patch truncated by the server.`:`No content changes (metadata only).`});let b=e=>{if(!m)return null;let t=p.get(e);return t===void 0?null:m[t]??null};return(0,V.jsxs)(`div`,{"data-slot":`diff-file-body`,"data-wrap":a||void 0,className:i(`py-1 font-mono text-xs leading-[1.7]`,!a&&`overflow-x-auto`),children:[(0,V.jsx)(Y.Provider,{value:g,children:(0,V.jsxs)(`div`,{"data-slot":`diff-rows`,style:y,className:`[&>*]:[contain-intrinsic-block-size:auto_20px] [&>*]:[content-visibility:auto]`,children:[_?_.map((t,r)=>(0,V.jsx)(Ie,{path:e.path,row:t,wrap:a,tokensFor:b,onExpand:u?n:void 0},r)):null,v?v.map((t,r)=>(0,V.jsx)(Le,{path:e.path,row:t,wrap:a,tokensFor:b,onExpand:u?n:void 0},r)):null]})}),l.truncated?(0,V.jsx)(Z,{children:`Patch truncated by the server — counts above remain exact.`}):null]})}function Ae(e,t){let n=(0,S.useMemo)(()=>t.length>ye?null:t.map(e=>e.text).join(`
|
|
13
|
-
`),[t]),r=(0,S.useMemo)(()=>d(e),[e]),[i,a]=(0,S.useState)(null);return(0,S.useEffect)(()=>{if(n===null||r===null)return;let e=!1;return p(n,r).then(t=>{e||a({text:n,tokens:t.tokens})}),()=>{e=!0}},[n,r]),n===null||r===null?null:i?.text===n?i.tokens:f(n,r)?.tokens??null}function Z({children:e}){return(0,V.jsx)(`p`,{className:`px-4 py-2.5 text-xs text-soft-foreground`,children:e})}var Q={add:`bg-diff-add`,del:`bg-diff-del`,context:void 0},je={add:`+`,del:`−`,context:` `},Me=`transition-shadow duration-500 data-[flash=true]:ring-2 data-[flash=true]:ring-inset data-[flash=true]:ring-primary`;function Ne({hunk:e}){return(0,V.jsx)(`div`,{"data-slot":`diff-hunk`,className:`bg-muted/40 px-4 py-0.5 whitespace-pre text-soft-foreground`,children:e.header})}function Pe({gap:e,onExpand:t}){let n=e.count===void 0?`⋯ unchanged lines to end of file`:`⋯ ${e.count} unchanged ${e.count===1?`line`:`lines`}`;return t?(0,V.jsxs)(`button`,{type:`button`,"data-slot":`diff-gap`,onClick:()=>t(e),className:`block w-full border-y border-border/40 bg-muted/20 px-4 py-0.5 text-left text-[11px] text-soft-foreground hover:bg-muted/50 hover:text-foreground`,children:[n,` — expand`]}):(0,V.jsx)(`div`,{"data-slot":`diff-gap`,className:`border-y border-border/40 bg-muted/20 px-4 py-0.5 text-[11px] text-soft-foreground`,children:n})}function Fe({cell:e,tokens:t,wrap:n}){let r=M(t,e.spans,e.line.text),a=e.line.kind===`add`?`bg-diff-add-strong`:`bg-diff-del-strong`;return(0,V.jsxs)(`span`,{className:i(`min-w-0 flex-1 pr-4`,n?`break-words whitespace-pre-wrap`:`whitespace-pre`),children:[r.map((t,n)=>(0,V.jsx)(`span`,{"data-word":t.changed?e.line.kind:void 0,style:t.color===void 0?void 0:{color:t.color},className:t.changed?i(`rounded-[2px]`,a):void 0,children:t.text},n)),e.line.text===``?` `:``]})}function $({value:e}){return(0,V.jsx)(`span`,{className:`w-10 shrink-0 pr-2 text-right text-soft-foreground/70 tabular-nums select-none`,children:e??``})}function Ie({path:e,row:t,wrap:n,tokensFor:r,onExpand:a}){let o=X(),s=(0,S.useContext)(Y);if(t.type===`hunk`)return(0,V.jsx)(Ne,{hunk:t.hunk});if(t.type===`gap`)return(0,V.jsx)(Pe,{gap:t.gap,onExpand:a});let{line:c}=t.cell,l=K(e,c),u=fe(o,l,c.text),d=s?.orderOf.get(c),f=d===void 0?void 0:s?.markAt(d);return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsxs)(`div`,{"data-slot":`diff-line`,"data-line":c.kind,"data-old-line":c.oldLine,"data-new-line":c.newLine,"data-mark":f,...u,onMouseEnter:o?.selection&&d!==void 0?()=>o.extendSelect(e,d):void 0,className:i(`group/line flex`,Q[c.kind],le(f),Me),children:[(0,V.jsx)($,{value:c.oldLine}),(0,V.jsx)($,{value:c.newLine}),(0,V.jsxs)(`span`,{className:`relative w-4 shrink-0 text-soft-foreground select-none`,children:[je[c.kind],(0,V.jsx)(pe,{anchor:l,excerpt:c.text,line:c})]}),(0,V.jsx)(Fe,{cell:t.cell,tokens:r(c),wrap:n})]}),(0,V.jsx)(he,{anchors:[l]})]})}function Le({path:e,row:t,wrap:n,tokensFor:r,onExpand:i}){if(t.type===`hunk`)return(0,V.jsx)(Ne,{hunk:t.hunk});if(t.type===`gap`)return(0,V.jsx)(Pe,{gap:t.gap,onExpand:i});let a=t.left?K(e,t.left.line):void 0,o=t.right?K(e,t.right.line):void 0;return(0,V.jsxs)(V.Fragment,{children:[(0,V.jsxs)(`div`,{"data-slot":`diff-pair`,className:`grid grid-cols-2`,children:[(0,V.jsx)(Re,{cell:t.left,anchor:a,side:`old`,tokensFor:r,wrap:n}),(0,V.jsx)(Re,{cell:t.right,anchor:o,side:`new`,tokensFor:r,wrap:n})]}),(0,V.jsx)(he,{anchors:[a,o]})]})}function Re({cell:e,anchor:t,side:n,tokensFor:r,wrap:a}){let o=X(),s=(0,S.useContext)(Y);if(!e)return(0,V.jsx)(`div`,{"data-slot":`diff-cell-empty`,className:i(`bg-muted/20`,n===`new`&&`border-l border-border/40`)});let{line:c}=e,l=s?.orderOf.get(c),u=l===void 0?void 0:s?.markAt(l);return(0,V.jsxs)(`div`,{"data-slot":`diff-cell`,"data-line":c.kind,"data-old-line":c.oldLine,"data-new-line":c.newLine,"data-mark":u,...fe(o,t,c.text),onMouseEnter:o?.selection&&l!==void 0&&t?()=>o.extendSelect(t.path,l):void 0,className:i(`group/line flex min-w-0 overflow-x-auto`,Q[c.kind],n===`new`&&`border-l border-border/40`,le(u),Me),children:[(0,V.jsx)($,{value:n===`old`?c.oldLine:c.newLine}),(0,V.jsxs)(`span`,{className:`relative w-4 shrink-0 text-soft-foreground select-none`,children:[je[c.kind],(0,V.jsx)(pe,{anchor:t,excerpt:c.text,line:c})]}),(0,V.jsx)(Fe,{cell:e,tokens:r(c),wrap:a})]})}export{we as DiffView};
|
|
@@ -1 +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{A as r,C as i,D as a,E as o,F as s,N as c,O as l,S as u,T as d,_ as f,b as p,g as m,h,m as g,r as _,v,w as y,x as b,y as x}from"./button-CjSjKnkd.js";import{a as S,c as C,l as w,o as T,s as E}from"./tooltip--PYfu68E.js";var D=s(`circle`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),O=s(`folder`,[[`path`,{d:`M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z`,key:`1kt360`}]]),k=s(`square-terminal`,[[`path`,{d:`m7 11 2-2-2-2`,key:`1lz0vl`}],[`path`,{d:`M11 13h4`,key:`1p7l4v`}],[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,ry:`2`,key:`1m3agn`}]]),A=e(t(),1),j=n();function M(e){let t=e+`CollectionProvider`,[n,i]=o(t),[a,s]=n(t,{collectionRef:{current:null},itemMap:new Map}),l=e=>{let{scope:t,children:n}=e,r=A.useRef(null),i=A.useRef(new Map).current;return(0,j.jsx)(a,{scope:t,itemMap:i,collectionRef:r,children:n})};l.displayName=t;let u=e+`CollectionSlot`,d=r(u),f=A.forwardRef((e,t)=>{let{scope:n,children:r}=e,i=c(t,s(u,n).collectionRef);return(0,j.jsx)(d,{ref:i,children:r})});f.displayName=u;let p=e+`CollectionItemSlot`,m=`data-radix-collection-item`,h=r(p),g=A.forwardRef((e,t)=>{let{scope:n,children:r,...i}=e,a=A.useRef(null),o=c(t,a),l=s(p,n);return A.useEffect(()=>(l.itemMap.set(a,{ref:a,...i}),()=>void l.itemMap.delete(a))),(0,j.jsx)(h,{[m]:``,ref:o,children:r})});g.displayName=p;function _(t){let n=s(e+`CollectionConsumer`,t);return A.useCallback(()=>{let e=n.collectionRef.current;if(!e)return[];let t=Array.from(e.querySelectorAll(`[${m}]`));return Array.from(n.itemMap.values()).sort((e,n)=>t.indexOf(e.ref.current)-t.indexOf(n.ref.current))},[n.collectionRef,n.itemMap])}return[{Provider:l,Slot:f,ItemSlot:g},_,i]}var ee=A.createContext(void 0);function N(e){let t=A.useContext(ee);return e||t||`ltr`}var P=!1;function te(){let[e,t]=A.useState(P);return A.useEffect(()=>{P||(P=!0,t(!0))},[]),e}var F=A.useSyncExternalStore;function I(){return()=>{}}function L(){return F(I,()=>!0,()=>!1)}var ne=typeof F==`function`?L:te,R=`rovingFocusGroup.onEntryFocus`,re={bubbles:!1,cancelable:!0},z=`RovingFocusGroup`,[ie,ae,oe]=M(z),[se,ce]=o(z,[oe]),[le,ue]=se(z),de=A.forwardRef((e,t)=>(0,j.jsx)(ie.Provider,{scope:e.__scopeRovingFocusGroup,children:(0,j.jsx)(ie.Slot,{scope:e.__scopeRovingFocusGroup,children:(0,j.jsx)(fe,{...e,ref:t})})}));de.displayName=z;var fe=A.forwardRef((e,t)=>{let{__scopeRovingFocusGroup:n,orientation:r,loop:o=!1,dir:s,currentTabStopId:l,defaultCurrentTabStopId:u,onCurrentTabStopIdChange:f,onEntryFocus:m,preventScrollOnEntryFocus:h=!1,...g}=e,_=A.useRef(null),v=c(t,_),y=N(s),[b,x]=i({prop:l,defaultProp:u??null,onChange:f,caller:z}),[S,C]=A.useState(!1),w=p(m),T=ae(n),E=A.useRef(!1),[D,O]=A.useState(0);return A.useEffect(()=>{let e=_.current;if(e)return e.addEventListener(R,w),()=>e.removeEventListener(R,w)},[w]),(0,j.jsx)(le,{scope:n,orientation:r,dir:y,loop:o,currentTabStopId:b,onItemFocus:A.useCallback(e=>x(e),[x]),onItemShiftTab:A.useCallback(()=>C(!0),[]),onFocusableItemAdd:A.useCallback(()=>O(e=>e+1),[]),onFocusableItemRemove:A.useCallback(()=>O(e=>e-1),[]),children:(0,j.jsx)(a.div,{tabIndex:S||D===0?-1:0,"data-orientation":r,...g,ref:v,style:{outline:`none`,...e.style},onMouseDown:d(e.onMouseDown,()=>{E.current=!0}),onFocus:d(e.onFocus,e=>{let t=!E.current;if(e.target===e.currentTarget&&t&&!S){let t=new CustomEvent(R,re);if(e.currentTarget.dispatchEvent(t),!t.defaultPrevented){let e=T().filter(e=>e.focusable);ve([e.find(e=>e.active),e.find(e=>e.id===b),...e].filter(Boolean).map(e=>e.ref.current),h)}}E.current=!1}),onBlur:d(e.onBlur,()=>C(!1))})})}),pe=`RovingFocusGroupItem`,me=A.forwardRef((e,t)=>{let{__scopeRovingFocusGroup:n,focusable:r=!0,active:i=!1,tabStopId:o,children:s,...c}=e,l=b(),u=o||l,f=ue(pe,n),p=f.currentTabStopId===u,m=ae(n),{onFocusableItemAdd:h,onFocusableItemRemove:g,currentTabStopId:_}=f,v=ne();return y(()=>{if(!(!v||!r))return h(),()=>g()},[v,r,h,g]),A.useEffect(()=>{if(!(v||!r))return h(),()=>g()},[v,r,h,g]),(0,j.jsx)(ie.ItemSlot,{scope:n,id:u,focusable:r,active:i,children:(0,j.jsx)(a.span,{tabIndex:p?0:-1,"data-orientation":f.orientation,...c,ref:t,onMouseDown:d(e.onMouseDown,e=>{r?f.onItemFocus(u):e.preventDefault()}),onFocus:d(e.onFocus,()=>f.onItemFocus(u)),onKeyDown:d(e.onKeyDown,e=>{if(e.key===`Tab`&&e.shiftKey){f.onItemShiftTab();return}if(e.target!==e.currentTarget)return;let t=_e(e,f.orientation,f.dir);if(t!==void 0){if(e.metaKey||e.ctrlKey||e.altKey||e.shiftKey)return;e.preventDefault();let n=m().filter(e=>e.focusable).map(e=>e.ref.current);if(t===`last`)n.reverse();else if(t===`prev`||t===`next`){t===`prev`&&n.reverse();let r=n.indexOf(e.currentTarget);n=f.loop?ye(n,r+1):n.slice(r+1)}setTimeout(()=>ve(n))}}),children:typeof s==`function`?s({isCurrentTabStop:p,hasTabStop:_!=null}):s})})});me.displayName=pe;var he={ArrowLeft:`prev`,ArrowUp:`prev`,ArrowRight:`next`,ArrowDown:`next`,PageUp:`first`,Home:`first`,PageDown:`last`,End:`last`};function ge(e,t){return t===`rtl`?e===`ArrowLeft`?`ArrowRight`:e===`ArrowRight`?`ArrowLeft`:e:e}function _e(e,t,n){let r=ge(e.key,n);if(!(t===`vertical`&&[`ArrowLeft`,`ArrowRight`].includes(r))&&!(t===`horizontal`&&[`ArrowUp`,`ArrowDown`].includes(r)))return he[r]}function ve(e,t=!1){let n=document.activeElement;for(let r of e)if(r===n||(r.focus({preventScroll:t}),document.activeElement!==n))return}function ye(e,t){return e.map((n,r)=>e[(t+r)%e.length])}var be=de,xe=me,Se=[`Enter`,` `],Ce=[`ArrowDown`,`PageUp`,`Home`],we=[`ArrowUp`,`PageDown`,`End`],Te=[...Ce,...we],Ee={ltr:[...Se,`ArrowRight`],rtl:[...Se,`ArrowLeft`]},De={ltr:[`ArrowLeft`],rtl:[`ArrowRight`]},B=`Menu`,[V,Oe,ke]=M(B),[H,Ae]=o(B,[ke,w,ce]),U=w(),je=ce(),[Me,W]=H(B),[Ne,G]=H(B),Pe=e=>{let{__scopeMenu:t,open:n=!1,children:r,dir:i,onOpenChange:a,modal:o=!0}=e,s=U(t),[c,l]=A.useState(null),u=A.useRef(!1),d=p(a),f=N(i);return A.useEffect(()=>{let e=()=>{u.current=!0,document.addEventListener(`pointerdown`,t,{capture:!0,once:!0}),document.addEventListener(`pointermove`,t,{capture:!0,once:!0})},t=()=>u.current=!1;return document.addEventListener(`keydown`,e,{capture:!0}),()=>{document.removeEventListener(`keydown`,e,{capture:!0}),document.removeEventListener(`pointerdown`,t,{capture:!0}),document.removeEventListener(`pointermove`,t,{capture:!0})}},[]),A.useEffect(()=>{if(!n)return;let e=()=>d(!1);return window.addEventListener(`blur`,e),()=>window.removeEventListener(`blur`,e)},[n,d]),(0,j.jsx)(C,{...s,children:(0,j.jsx)(Me,{scope:t,open:n,onOpenChange:d,content:c,onContentChange:l,children:(0,j.jsx)(Ne,{scope:t,onClose:A.useCallback(()=>d(!1),[d]),isUsingKeyboardRef:u,dir:f,modal:o,children:r})})})};Pe.displayName=B;var Fe=`MenuAnchor`,Ie=A.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e,i=U(n);return(0,j.jsx)(S,{...i,...r,ref:t})});Ie.displayName=Fe;var Le=`MenuPortal`,[Re,ze]=H(Le,{forceMount:void 0}),Be=e=>{let{__scopeMenu:t,forceMount:n,children:r,container:i}=e,a=W(Le,t);return(0,j.jsx)(Re,{scope:t,forceMount:n,children:(0,j.jsx)(u,{present:n||a.open,children:(0,j.jsx)(f,{asChild:!0,container:i,children:r})})})};Be.displayName=Le;var K=`MenuContent`,[Ve,He]=H(K),Ue=A.forwardRef((e,t)=>{let n=ze(K,e.__scopeMenu),{forceMount:r=n.forceMount,...i}=e,a=W(K,e.__scopeMenu),o=G(K,e.__scopeMenu);return(0,j.jsx)(V.Provider,{scope:e.__scopeMenu,children:(0,j.jsx)(u,{present:r||a.open,children:(0,j.jsx)(V.Slot,{scope:e.__scopeMenu,children:o.modal?(0,j.jsx)(We,{...i,ref:t}):(0,j.jsx)(Ge,{...i,ref:t})})})})}),We=A.forwardRef((e,t)=>{let n=W(K,e.__scopeMenu),r=A.useRef(null),i=c(t,r);return A.useEffect(()=>{let e=r.current;if(e)return g(e)},[]),(0,j.jsx)(qe,{...e,ref:i,trapFocus:n.open,disableOutsidePointerEvents:n.open,disableOutsideScroll:!0,onFocusOutside:d(e.onFocusOutside,e=>e.preventDefault(),{checkForDefaultPrevented:!1}),onDismiss:()=>n.onOpenChange(!1)})}),Ge=A.forwardRef((e,t)=>{let n=W(K,e.__scopeMenu);return(0,j.jsx)(qe,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,onDismiss:()=>n.onOpenChange(!1)})}),Ke=r(`MenuContent.ScrollLock`),qe=A.forwardRef((e,t)=>{let{__scopeMenu:n,loop:r=!1,trapFocus:i,onOpenAutoFocus:a,onCloseAutoFocus:o,disableOutsidePointerEvents:s,onEntryFocus:l,onEscapeKeyDown:u,onPointerDownOutside:f,onFocusOutside:p,onInteractOutside:g,onDismiss:_,disableOutsideScroll:y,...b}=e,S=W(K,n),C=G(K,n),w=U(n),T=je(n),D=Oe(n),[O,k]=A.useState(null),M=A.useRef(null),ee=c(t,M,S.onContentChange),N=A.useRef(0),P=A.useRef(``),te=A.useRef(0),F=A.useRef(null),I=A.useRef(`right`),L=A.useRef(0),ne=y?h:A.Fragment,R=y?{as:Ke,allowPinchZoom:!0}:void 0,re=e=>{let t=P.current+e,n=D().filter(e=>!e.disabled),r=document.activeElement,i=n.find(e=>e.ref.current===r)?.textValue,a=Dt(n.map(e=>e.textValue),t,i),o=n.find(e=>e.textValue===a)?.ref.current;(function e(t){P.current=t,window.clearTimeout(N.current),t!==``&&(N.current=window.setTimeout(()=>e(``),1e3))})(t),o&&setTimeout(()=>o.focus())};A.useEffect(()=>()=>window.clearTimeout(N.current),[]),m();let z=A.useCallback(e=>I.current===F.current?.side&&kt(e,F.current?.area),[]);return(0,j.jsx)(Ve,{scope:n,searchRef:P,onItemEnter:A.useCallback(e=>{z(e)&&e.preventDefault()},[z]),onItemLeave:A.useCallback(e=>{z(e)||(M.current?.focus(),k(null))},[z]),onTriggerLeave:A.useCallback(e=>{z(e)&&e.preventDefault()},[z]),pointerGraceTimerRef:te,onPointerGraceIntentChange:A.useCallback(e=>{F.current=e},[]),children:(0,j.jsx)(ne,{...R,children:(0,j.jsx)(v,{asChild:!0,trapped:i,onMountAutoFocus:d(a,e=>{e.preventDefault(),M.current?.focus({preventScroll:!0})}),onUnmountAutoFocus:o,children:(0,j.jsx)(x,{asChild:!0,disableOutsidePointerEvents:s,onEscapeKeyDown:u,onPointerDownOutside:f,onFocusOutside:p,onInteractOutside:g,onDismiss:_,children:(0,j.jsx)(be,{asChild:!0,...T,dir:C.dir,orientation:`vertical`,loop:r,currentTabStopId:O,onCurrentTabStopIdChange:k,onEntryFocus:d(l,e=>{C.isUsingKeyboardRef.current||e.preventDefault()}),preventScrollOnEntryFocus:!0,children:(0,j.jsx)(E,{role:`menu`,"aria-orientation":`vertical`,"data-state":Ct(S.open),"data-radix-menu-content":``,dir:C.dir,...w,...b,ref:ee,style:{outline:`none`,...b.style},onKeyDown:d(b.onKeyDown,e=>{let t=e.target.closest(`[data-radix-menu-content]`)===e.currentTarget,n=e.ctrlKey||e.altKey||e.metaKey,r=e.key.length===1;t&&(e.key===`Tab`&&e.preventDefault(),!n&&r&&re(e.key));let i=M.current;if(e.target!==i||!Te.includes(e.key))return;e.preventDefault();let a=D().filter(e=>!e.disabled).map(e=>e.ref.current);we.includes(e.key)&&a.reverse(),Tt(a)}),onBlur:d(e.onBlur,e=>{e.currentTarget.contains(e.target)||(window.clearTimeout(N.current),P.current=``)}),onPointerMove:d(e.onPointerMove,Z(e=>{let t=e.target,n=L.current!==e.clientX;if(e.currentTarget.contains(t)&&n){let t=e.clientX>L.current?`right`:`left`;I.current=t,L.current=e.clientX}}))})})})})})})});Ue.displayName=K;var Je=`MenuGroup`,Ye=A.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e;return(0,j.jsx)(a.div,{role:`group`,...r,ref:t})});Ye.displayName=Je;var Xe=`MenuLabel`,Ze=A.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e;return(0,j.jsx)(a.div,{...r,ref:t})});Ze.displayName=Xe;var q=`MenuItem`,Qe=`menu.itemSelect`,J=A.forwardRef((e,t)=>{let{disabled:n=!1,onSelect:r,...i}=e,a=A.useRef(null),o=G(q,e.__scopeMenu),s=He(q,e.__scopeMenu),u=c(t,a),f=A.useRef(!1),p=()=>{let e=a.current;if(!n&&e){let t=new CustomEvent(Qe,{bubbles:!0,cancelable:!0});e.addEventListener(Qe,e=>r?.(e),{once:!0}),l(e,t),t.defaultPrevented?f.current=!1:o.onClose()}};return(0,j.jsx)($e,{...i,ref:u,disabled:n,onClick:d(e.onClick,p),onPointerDown:t=>{e.onPointerDown?.(t),f.current=!0},onPointerUp:d(e.onPointerUp,e=>{f.current||e.currentTarget?.click()}),onKeyDown:d(e.onKeyDown,e=>{n||e.target!==e.currentTarget||s.searchRef.current!==``&&e.key===` `||Se.includes(e.key)&&(e.currentTarget.click(),e.preventDefault())})})});J.displayName=q;var $e=A.forwardRef((e,t)=>{let{__scopeMenu:n,disabled:r=!1,textValue:i,...o}=e,s=He(q,n),l=je(n),u=A.useRef(null),f=c(t,u),[p,m]=A.useState(!1),[h,g]=A.useState(``);return A.useEffect(()=>{let e=u.current;e&&g((e.textContent??``).trim())},[o.children]),(0,j.jsx)(V.ItemSlot,{scope:n,disabled:r,textValue:i??h,children:(0,j.jsx)(xe,{asChild:!0,...l,focusable:!r,children:(0,j.jsx)(a.div,{role:`menuitem`,"data-highlighted":p?``:void 0,"aria-disabled":r||void 0,"data-disabled":r?``:void 0,...o,ref:f,onPointerMove:d(e.onPointerMove,Z(e=>{r?s.onItemLeave(e):(s.onItemEnter(e),e.defaultPrevented||e.currentTarget.focus({preventScroll:!0}))})),onPointerLeave:d(e.onPointerLeave,Z(e=>s.onItemLeave(e))),onFocus:d(e.onFocus,()=>m(!0)),onBlur:d(e.onBlur,()=>m(!1))})})})}),et=`MenuCheckboxItem`,tt=A.forwardRef((e,t)=>{let{checked:n=!1,onCheckedChange:r,...i}=e;return(0,j.jsx)(lt,{scope:e.__scopeMenu,checked:n,children:(0,j.jsx)(J,{role:`menuitemcheckbox`,"aria-checked":X(n)?`mixed`:n,...i,ref:t,"data-state":wt(n),onSelect:d(i.onSelect,()=>r?.(X(n)?!0:!n),{checkForDefaultPrevented:!1})})})});tt.displayName=et;var nt=`MenuRadioGroup`,[rt,it]=H(nt,{value:void 0,onValueChange:()=>{}}),at=A.forwardRef((e,t)=>{let{value:n,onValueChange:r,...i}=e,a=p(r);return(0,j.jsx)(rt,{scope:e.__scopeMenu,value:n,onValueChange:a,children:(0,j.jsx)(Ye,{...i,ref:t})})});at.displayName=nt;var ot=`MenuRadioItem`,st=A.forwardRef((e,t)=>{let{value:n,...r}=e,i=it(ot,e.__scopeMenu),a=n===i.value;return(0,j.jsx)(lt,{scope:e.__scopeMenu,checked:a,children:(0,j.jsx)(J,{role:`menuitemradio`,"aria-checked":a,...r,ref:t,"data-state":wt(a),onSelect:d(r.onSelect,()=>i.onValueChange?.(n),{checkForDefaultPrevented:!1})})})});st.displayName=ot;var ct=`MenuItemIndicator`,[lt,ut]=H(ct,{checked:!1}),dt=A.forwardRef((e,t)=>{let{__scopeMenu:n,forceMount:r,...i}=e,o=ut(ct,n);return(0,j.jsx)(u,{present:r||X(o.checked)||o.checked===!0,children:(0,j.jsx)(a.span,{...i,ref:t,"data-state":wt(o.checked)})})});dt.displayName=ct;var ft=`MenuSeparator`,pt=A.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e;return(0,j.jsx)(a.div,{role:`separator`,"aria-orientation":`horizontal`,...r,ref:t})});pt.displayName=ft;var mt=`MenuArrow`,ht=A.forwardRef((e,t)=>{let{__scopeMenu:n,...r}=e,i=U(n);return(0,j.jsx)(T,{...i,...r,ref:t})});ht.displayName=mt;var gt=`MenuSub`,[_t,vt]=H(gt),yt=e=>{let{__scopeMenu:t,children:n,open:r=!1,onOpenChange:i}=e,a=W(gt,t),o=U(t),[s,c]=A.useState(null),[l,u]=A.useState(null),d=p(i);return A.useEffect(()=>(a.open===!1&&d(!1),()=>d(!1)),[a.open,d]),(0,j.jsx)(C,{...o,children:(0,j.jsx)(Me,{scope:t,open:r,onOpenChange:d,content:l,onContentChange:u,children:(0,j.jsx)(_t,{scope:t,contentId:b(),triggerId:b(),trigger:s,onTriggerChange:c,children:n})})})};yt.displayName=gt;var Y=`MenuSubTrigger`,bt=A.forwardRef((e,t)=>{let n=W(Y,e.__scopeMenu),r=G(Y,e.__scopeMenu),i=vt(Y,e.__scopeMenu),a=He(Y,e.__scopeMenu),o=A.useRef(null),{pointerGraceTimerRef:s,onPointerGraceIntentChange:l}=a,u={__scopeMenu:e.__scopeMenu},f=A.useCallback(()=>{o.current&&window.clearTimeout(o.current),o.current=null},[]);A.useEffect(()=>f,[f]),A.useEffect(()=>{let e=s.current;return()=>{window.clearTimeout(e),l(null)}},[s,l]);let p=c(t,i.onTriggerChange);return(0,j.jsx)(Ie,{asChild:!0,...u,children:(0,j.jsx)($e,{id:i.triggerId,"aria-haspopup":`menu`,"aria-expanded":n.open,"aria-controls":n.open?i.contentId:void 0,"data-state":Ct(n.open),...e,ref:p,onClick:t=>{e.onClick?.(t),!(e.disabled||t.defaultPrevented)&&(t.currentTarget.focus(),n.open||n.onOpenChange(!0))},onPointerMove:d(e.onPointerMove,Z(t=>{a.onItemEnter(t),!t.defaultPrevented&&!e.disabled&&!n.open&&!o.current&&(a.onPointerGraceIntentChange(null),o.current=window.setTimeout(()=>{n.onOpenChange(!0),f()},100))})),onPointerLeave:d(e.onPointerLeave,Z(e=>{f();let t=n.content?.getBoundingClientRect();if(t){let r=n.content?.dataset.side,i=r===`right`,o=i?-5:5,c=t[i?`left`:`right`],l=t[i?`right`:`left`];a.onPointerGraceIntentChange({area:[{x:e.clientX+o,y:e.clientY},{x:c,y:t.top},{x:l,y:t.top},{x:l,y:t.bottom},{x:c,y:t.bottom}],side:r}),window.clearTimeout(s.current),s.current=window.setTimeout(()=>a.onPointerGraceIntentChange(null),300)}else{if(a.onTriggerLeave(e),e.defaultPrevented)return;a.onPointerGraceIntentChange(null)}})),onKeyDown:d(e.onKeyDown,t=>{e.disabled||t.target!==t.currentTarget||a.searchRef.current!==``&&t.key===` `||Ee[r.dir].includes(t.key)&&(n.onOpenChange(!0),n.content?.focus(),t.preventDefault())})})})});bt.displayName=Y;var xt=`MenuSubContent`,St=A.forwardRef((e,t)=>{let n=ze(K,e.__scopeMenu),{forceMount:r=n.forceMount,align:i=`start`,...a}=e,o=W(K,e.__scopeMenu),s=G(K,e.__scopeMenu),l=vt(xt,e.__scopeMenu),f=A.useRef(null),p=c(t,f);return(0,j.jsx)(V.Provider,{scope:e.__scopeMenu,children:(0,j.jsx)(u,{present:r||o.open,children:(0,j.jsx)(V.Slot,{scope:e.__scopeMenu,children:(0,j.jsx)(qe,{id:l.contentId,"aria-labelledby":l.triggerId,...a,ref:p,align:i,side:s.dir===`rtl`?`left`:`right`,disableOutsidePointerEvents:!1,disableOutsideScroll:!1,trapFocus:!1,onOpenAutoFocus:e=>{s.isUsingKeyboardRef.current&&f.current?.focus(),e.preventDefault()},onCloseAutoFocus:e=>e.preventDefault(),onFocusOutside:d(e.onFocusOutside,e=>{e.target!==l.trigger&&o.onOpenChange(!1)}),onEscapeKeyDown:d(e.onEscapeKeyDown,e=>{s.onClose(),e.preventDefault()}),onKeyDown:d(e.onKeyDown,e=>{let t=e.currentTarget.contains(e.target),n=De[s.dir].includes(e.key);t&&n&&(o.onOpenChange(!1),l.trigger?.focus(),e.preventDefault())})})})})})});St.displayName=xt;function Ct(e){return e?`open`:`closed`}function X(e){return e===`indeterminate`}function wt(e){return X(e)?`indeterminate`:e?`checked`:`unchecked`}function Tt(e){let t=document.activeElement;for(let n of e)if(n===t||(n.focus(),document.activeElement!==t))return}function Et(e,t){return e.map((n,r)=>e[(t+r)%e.length])}function Dt(e,t,n){let r=t.length>1&&Array.from(t).every(e=>e===t[0])?t[0]:t,i=n?e.indexOf(n):-1,a=Et(e,Math.max(i,0));r.length===1&&(a=a.filter(e=>e!==n));let o=a.find(e=>e.toLowerCase().startsWith(r.toLowerCase()));return o===n?void 0:o}function Ot(e,t){let{x:n,y:r}=e,i=!1;for(let e=0,a=t.length-1;e<t.length;a=e++){let o=t[e],s=t[a],c=o.x,l=o.y,u=s.x,d=s.y;l>r!=d>r&&n<(u-c)*(r-l)/(d-l)+c&&(i=!i)}return i}function kt(e,t){return t?Ot({x:e.clientX,y:e.clientY},t):!1}function Z(e){return t=>t.pointerType===`mouse`?e(t):void 0}var At=Pe,jt=Ie,Mt=Be,Nt=Ue,Pt=Ye,Ft=Ze,It=J,Lt=tt,Rt=at,zt=st,Bt=dt,Vt=pt,Ht=ht,Ut=bt,Wt=St,Q=`DropdownMenu`,[Gt,Kt]=o(Q,[Ae]),$=Ae(),[qt,Jt]=Gt(Q),Yt=e=>{let{__scopeDropdownMenu:t,children:n,dir:r,open:a,defaultOpen:o,onOpenChange:s,modal:c=!0}=e,l=$(t),u=A.useRef(null),[d,f]=i({prop:a,defaultProp:o??!1,onChange:s,caller:Q});return(0,j.jsx)(qt,{scope:t,triggerId:b(),triggerRef:u,contentId:b(),open:d,onOpenChange:f,onOpenToggle:A.useCallback(()=>f(e=>!e),[f]),modal:c,children:(0,j.jsx)(At,{...l,open:d,onOpenChange:f,dir:r,modal:c,children:n})})};Yt.displayName=Q;var Xt=`DropdownMenuTrigger`,Zt=A.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,disabled:r=!1,...i}=e,o=Jt(Xt,n),s=$(n),l=c(t,o.triggerRef);return(0,j.jsx)(jt,{asChild:!0,...s,children:(0,j.jsx)(a.button,{type:`button`,id:o.triggerId,"aria-haspopup":`menu`,"aria-expanded":o.open,"aria-controls":o.open?o.contentId:void 0,"data-state":o.open?`open`:`closed`,"data-disabled":r?``:void 0,disabled:r,...i,ref:l,onPointerDown:d(e.onPointerDown,e=>{!r&&e.button===0&&e.ctrlKey===!1&&(o.onOpenToggle(),o.open||e.preventDefault())}),onKeyDown:d(e.onKeyDown,e=>{r||([`Enter`,` `].includes(e.key)&&o.onOpenToggle(),e.key===`ArrowDown`&&o.onOpenChange(!0),[`Enter`,` `,`ArrowDown`].includes(e.key)&&e.preventDefault())})})})});Zt.displayName=Xt;var Qt=`DropdownMenuPortal`,$t=e=>{let{__scopeDropdownMenu:t,...n}=e,r=$(t);return(0,j.jsx)(Mt,{...r,...n})};$t.displayName=Qt;var en=`DropdownMenuContent`,tn=A.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=Jt(en,n),a=$(n),o=A.useRef(!1);return(0,j.jsx)(Nt,{id:i.contentId,"aria-labelledby":i.triggerId,...a,...r,ref:t,onCloseAutoFocus:d(e.onCloseAutoFocus,e=>{o.current||i.triggerRef.current?.focus(),o.current=!1,e.preventDefault()}),onInteractOutside:d(e.onInteractOutside,e=>{let t=e.detail.originalEvent,n=t.button===0&&t.ctrlKey===!0,r=t.button===2||n;(!i.modal||r)&&(o.current=!0)}),style:{...e.style,"--radix-dropdown-menu-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-dropdown-menu-content-available-width":`var(--radix-popper-available-width)`,"--radix-dropdown-menu-content-available-height":`var(--radix-popper-available-height)`,"--radix-dropdown-menu-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-dropdown-menu-trigger-height":`var(--radix-popper-anchor-height)`}})});tn.displayName=en;var nn=`DropdownMenuGroup`,rn=A.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=$(n);return(0,j.jsx)(Pt,{...i,...r,ref:t})});rn.displayName=nn;var an=`DropdownMenuLabel`,on=A.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=$(n);return(0,j.jsx)(Ft,{...i,...r,ref:t})});on.displayName=an;var sn=`DropdownMenuItem`,cn=A.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=$(n);return(0,j.jsx)(It,{...i,...r,ref:t})});cn.displayName=sn;var ln=`DropdownMenuCheckboxItem`,un=A.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=$(n);return(0,j.jsx)(Lt,{...i,...r,ref:t})});un.displayName=ln;var dn=`DropdownMenuRadioGroup`,fn=A.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=$(n);return(0,j.jsx)(Rt,{...i,...r,ref:t})});fn.displayName=dn;var pn=`DropdownMenuRadioItem`,mn=A.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=$(n);return(0,j.jsx)(zt,{...i,...r,ref:t})});mn.displayName=pn;var hn=`DropdownMenuItemIndicator`,gn=A.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=$(n);return(0,j.jsx)(Bt,{...i,...r,ref:t})});gn.displayName=hn;var _n=`DropdownMenuSeparator`,vn=A.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=$(n);return(0,j.jsx)(Vt,{...i,...r,ref:t})});vn.displayName=_n;var yn=`DropdownMenuArrow`,bn=A.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=$(n);return(0,j.jsx)(Ht,{...i,...r,ref:t})});bn.displayName=yn;var xn=`DropdownMenuSubTrigger`,Sn=A.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=$(n);return(0,j.jsx)(Ut,{...i,...r,ref:t})});Sn.displayName=xn;var Cn=`DropdownMenuSubContent`,wn=A.forwardRef((e,t)=>{let{__scopeDropdownMenu:n,...r}=e,i=$(n);return(0,j.jsx)(Wt,{...i,...r,ref:t,style:{...e.style,"--radix-dropdown-menu-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-dropdown-menu-content-available-width":`var(--radix-popper-available-width)`,"--radix-dropdown-menu-content-available-height":`var(--radix-popper-available-height)`,"--radix-dropdown-menu-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-dropdown-menu-trigger-height":`var(--radix-popper-anchor-height)`}})});wn.displayName=Cn;var Tn=Yt,En=Zt,Dn=$t,On=tn,kn=on,An=cn,jn=fn,Mn=mn,Nn=gn,Pn=vn;function Fn({...e}){return(0,j.jsx)(Tn,{"data-slot":`dropdown-menu`,...e})}function In({...e}){return(0,j.jsx)(En,{"data-slot":`dropdown-menu-trigger`,...e})}function Ln({className:e,sideOffset:t=4,...n}){return(0,j.jsx)(Dn,{children:(0,j.jsx)(On,{"data-slot":`dropdown-menu-content`,sideOffset:t,className:_(`z-50 max-h-(--radix-dropdown-menu-content-available-height) min-w-[8rem] origin-(--radix-dropdown-menu-content-transform-origin) overflow-x-hidden overflow-y-auto rounded-md border bg-popover p-1 text-popover-foreground shadow-md data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95`,e),...n})})}function Rn({className:e,inset:t,variant:n=`default`,...r}){return(0,j.jsx)(An,{"data-slot":`dropdown-menu-item`,"data-inset":t,"data-variant":n,className:_(`relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 data-[inset]:pl-8 data-[variant=destructive]:text-destructive data-[variant=destructive]:focus:bg-destructive/10 data-[variant=destructive]:focus:text-destructive [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='text-'])]:text-muted-foreground data-[variant=destructive]:*:[svg]:text-destructive!`,e),...r})}function zn({...e}){return(0,j.jsx)(jn,{"data-slot":`dropdown-menu-radio-group`,...e})}function Bn({className:e,children:t,...n}){return(0,j.jsxs)(Mn,{"data-slot":`dropdown-menu-radio-item`,className:_(`relative flex cursor-default items-center gap-2 rounded-sm py-1.5 pr-2 pl-8 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,e),...n,children:[(0,j.jsx)(`span`,{className:`pointer-events-none absolute left-2 flex size-3.5 items-center justify-center`,children:(0,j.jsx)(Nn,{children:(0,j.jsx)(D,{className:`size-2 fill-current`})})}),t]})}function Vn({className:e,inset:t,...n}){return(0,j.jsx)(kn,{"data-slot":`dropdown-menu-label`,"data-inset":t,className:_(`px-2 py-1.5 text-sm font-medium data-[inset]:pl-8`,e),...n})}function Hn({className:e,...t}){return(0,j.jsx)(Pn,{"data-slot":`dropdown-menu-separator`,className:_(`-mx-1 my-1 h-px bg-border`,e),...t})}export{zn as a,In as c,ce as d,N as f,D as g,O as h,Vn as i,xe as l,k as m,Ln as n,Bn as o,M as p,Rn as r,Hn as s,Fn as t,be as u};
|
|
@@ -1 +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{$ as r,Ai as i,E as a,Nt as o,Rn as s,Tn as c,Y as l,dn as u,gn as d,n as f}from"./toaster-Hj_czp_o.js";import{F as p,St as m,bt as h,gt as g,jt as _,r as v,t as y,yt as ee}from"./button-CjSjKnkd.js";import{n as te,t as ne,u as re}from"./reference-chip-Bx_mG9QG.js";import{r as b}from"./trash-2-EdjdGvEo.js";import{c as ie,h as ae,m as x,n as oe,r as se,s as ce,t as le}from"./dropdown-menu-DkEK7m00.js";import{t as S}from"./external-link-DPKRidDg.js";var ue=p(`archive-restore`,[[`rect`,{width:`20`,height:`5`,x:`2`,y:`3`,rx:`1`,key:`1wp1u1`}],[`path`,{d:`M4 8v11a2 2 0 0 0 2 2h2`,key:`tvwodi`}],[`path`,{d:`M20 8v11a2 2 0 0 1-2 2h-2`,key:`1gkqxj`}],[`path`,{d:`m9 15 3-3 3 3`,key:`1pd0qc`}],[`path`,{d:`M12 12v9`,key:`192myk`}]]),de=p(`archive`,[[`rect`,{width:`20`,height:`5`,x:`2`,y:`3`,rx:`1`,key:`1wp1u1`}],[`path`,{d:`M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8`,key:`1s80jp`}],[`path`,{d:`M10 12h4`,key:`a56b0p`}]]),fe=p(`boxes`,[[`path`,{d:`M2.97 12.92A2 2 0 0 0 2 14.63v3.24a2 2 0 0 0 .97 1.71l3 1.8a2 2 0 0 0 2.06 0L12 19v-5.5l-5-3-4.03 2.42Z`,key:`lc1i9w`}],[`path`,{d:`m7 16.5-4.74-2.85`,key:`1o9zyk`}],[`path`,{d:`m7 16.5 5-3`,key:`va8pkn`}],[`path`,{d:`M7 16.5v5.17`,key:`jnp8gn`}],[`path`,{d:`M12 13.5V19l3.97 2.38a2 2 0 0 0 2.06 0l3-1.8a2 2 0 0 0 .97-1.71v-3.24a2 2 0 0 0-.97-1.71L17 10.5l-5 3Z`,key:`8zsnat`}],[`path`,{d:`m17 16.5-5-3`,key:`8arw3v`}],[`path`,{d:`m17 16.5 4.74-2.85`,key:`8rfmw`}],[`path`,{d:`M17 16.5v5.17`,key:`k6z78m`}],[`path`,{d:`M7.97 4.42A2 2 0 0 0 7 6.13v4.37l5 3 5-3V6.13a2 2 0 0 0-.97-1.71l-3-1.8a2 2 0 0 0-2.06 0l-3 1.8Z`,key:`1xygjf`}],[`path`,{d:`M12 8 7.26 5.15`,key:`1vbdud`}],[`path`,{d:`m12 8 4.74-2.85`,key:`3rx089`}],[`path`,{d:`M12 13.5V8`,key:`1io7kd`}]]),pe=p(`braces`,[[`path`,{d:`M8 3H7a2 2 0 0 0-2 2v5a2 2 0 0 1-2 2 2 2 0 0 1 2 2v5c0 1.1.9 2 2 2h1`,key:`ezmyqa`}],[`path`,{d:`M16 21h1a2 2 0 0 0 2-2v-5c0-1.1.9-2 2-2a2 2 0 0 1-2-2V5a2 2 0 0 0-2-2h-1`,key:`e1hn23`}]]),me=p(`code`,[[`path`,{d:`m16 18 6-6-6-6`,key:`eg8j8`}],[`path`,{d:`m8 6-6 6 6 6`,key:`ppft3o`}]]),C=p(`cpu`,[[`path`,{d:`M12 20v2`,key:`1lh1kg`}],[`path`,{d:`M12 2v2`,key:`tus03m`}],[`path`,{d:`M17 20v2`,key:`1rnc9c`}],[`path`,{d:`M17 2v2`,key:`11trls`}],[`path`,{d:`M2 12h2`,key:`1t8f8n`}],[`path`,{d:`M2 17h2`,key:`7oei6x`}],[`path`,{d:`M2 7h2`,key:`asdhe0`}],[`path`,{d:`M20 12h2`,key:`1q8mjw`}],[`path`,{d:`M20 17h2`,key:`1fpfkl`}],[`path`,{d:`M20 7h2`,key:`1o8tra`}],[`path`,{d:`M7 20v2`,key:`4gnj0m`}],[`path`,{d:`M7 2v2`,key:`1i4yhu`}],[`rect`,{x:`4`,y:`4`,width:`16`,height:`16`,rx:`2`,key:`1vbyd7`}],[`rect`,{x:`8`,y:`8`,width:`8`,height:`8`,rx:`1`,key:`z9xiuo`}]]),he=p(`diamond`,[[`path`,{d:`M2.7 10.3a2.41 2.41 0 0 0 0 3.41l7.59 7.59a2.41 2.41 0 0 0 3.41 0l7.59-7.59a2.41 2.41 0 0 0 0-3.41l-7.59-7.59a2.41 2.41 0 0 0-3.41 0Z`,key:`1f1r0c`}]]),ge=p(`feather`,[[`path`,{d:`M12.67 19a2 2 0 0 0 1.416-.588l6.154-6.172a6 6 0 0 0-8.49-8.49L5.586 9.914A2 2 0 0 0 5 11.328V18a1 1 0 0 0 1 1z`,key:`18jl4k`}],[`path`,{d:`M16 8 2 22`,key:`vp34q`}],[`path`,{d:`M17.5 15H9`,key:`1oz8nu`}]]),_e=p(`gem`,[[`path`,{d:`M10.5 3 8 9l4 13 4-13-2.5-6`,key:`b3dvk1`}],[`path`,{d:`M17 3a2 2 0 0 1 1.6.8l3 4a2 2 0 0 1 .013 2.382l-7.99 10.986a2 2 0 0 1-3.247 0l-7.99-10.986A2 2 0 0 1 2.4 7.8l2.998-3.997A2 2 0 0 1 7 3z`,key:`7w4byz`}],[`path`,{d:`M2 9h20`,key:`16fsjt`}]]),w=p(`globe`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20`,key:`13o1zl`}],[`path`,{d:`M2 12h20`,key:`9i4pu4`}]]),ve=p(`hammer`,[[`path`,{d:`m15 12-9.373 9.373a1 1 0 0 1-3.001-3L12 9`,key:`1hayfq`}],[`path`,{d:`m18 15 4-4`,key:`16gjal`}],[`path`,{d:`m21.5 11.5-1.914-1.914A2 2 0 0 1 19 8.172v-.344a2 2 0 0 0-.586-1.414l-1.657-1.657A6 6 0 0 0 12.516 3H9l1.243 1.243A6 6 0 0 1 12 8.485V10l2 2h1.172a2 2 0 0 1 1.414.586L18.5 14.5`,key:`15ts47`}]]),ye=p(`hexagon`,[[`path`,{d:`M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z`,key:`yt0hxn`}]]),be=p(`mouse-pointer-2`,[[`path`,{d:`M4.037 4.688a.495.495 0 0 1 .651-.651l16 6.5a.5.5 0 0 1-.063.947l-6.124 1.58a2 2 0 0 0-1.438 1.435l-1.579 6.126a.5.5 0 0 1-.947.063z`,key:`edeuup`}]]),xe=p(`pin`,[[`path`,{d:`M12 17v5`,key:`bb1du9`}],[`path`,{d:`M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H8a2 2 0 0 0 0 4 1 1 0 0 1 1 1z`,key:`1nkz8b`}]]),Se=p(`rocket`,[[`path`,{d:`M12 15v5s3.03-.55 4-2c1.08-1.62 0-5 0-5`,key:`qeys4`}],[`path`,{d:`M4.5 16.5c-1.5 1.26-2 5-2 5s3.74-.5 5-2c.71-.84.7-2.13-.09-2.91a2.18 2.18 0 0 0-2.91-.09`,key:`u4xsad`}],[`path`,{d:`M9 12a22 22 0 0 1 2-3.95A12.88 12.88 0 0 1 22 2c0 2.72-.78 7.5-6 11a22.4 22.4 0 0 1-4 2z`,key:`676m9`}],[`path`,{d:`M9 12H4s.55-3.03 2-4c1.62-1.08 5 .05 5 .05`,key:`92ym6u`}]]),Ce=p(`shapes`,[[`path`,{d:`M8.3 10a.7.7 0 0 1-.626-1.079L11.4 3a.7.7 0 0 1 1.198-.043L16.3 8.9a.7.7 0 0 1-.572 1.1Z`,key:`1bo67w`}],[`rect`,{x:`3`,y:`14`,width:`7`,height:`7`,rx:`1`,key:`1bkyp8`}],[`circle`,{cx:`17.5`,cy:`17.5`,r:`3.5`,key:`w3z12y`}]]),we=p(`smartphone`,[[`rect`,{width:`14`,height:`20`,x:`5`,y:`2`,rx:`2`,ry:`2`,key:`1yt0o3`}],[`path`,{d:`M12 18h.01`,key:`mhygvu`}]]),T=p(`sparkles`,[[`path`,{d:`M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z`,key:`1s2grr`}],[`path`,{d:`M20 2v4`,key:`1rf3ol`}],[`path`,{d:`M22 4h-4`,key:`gwowj6`}],[`circle`,{cx:`4`,cy:`20`,r:`2`,key:`6kqj1y`}]]),Te=p(`waves-horizontal`,[[`path`,{d:`M2 12q2.5 2 5 0t5 0 5 0 5 0`,key:`8ddzzs`}],[`path`,{d:`M2 19q2.5 2 5 0t5 0 5 0 5 0`,key:`1wj4st`}],[`path`,{d:`M2 5q2.5 2 5 0t5 0 5 0 5 0`,key:`69x50u`}]]),E=p(`zap`,[[`path`,{d:`M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z`,key:`1xq2db`}]]),D=e(t(),1),O=n(),Ee=[`done`,`failed`,`cancelled`],De=[`done`,`failed`];function k(e){return e.status===`failed`&&e.autoResumeAt!==void 0}function A(e){return e.status===`failed`&&e.awaitingAnswerSince!==void 0}function Oe(e){return Ee.includes(e)}function j(e){return e.archived||k(e)||A(e)||!De.includes(e.status)?!1:e.finishedAt!==void 0}function M(e){let t=e.finishedAt;return t===void 0||!j(e)?!1:e.seenAt===void 0||e.seenAt<t}function ke(e){return k(e)||A(e)?!1:Oe(e.status)&&!M(e)}function Ae(e){return e.reduce((e,t)=>M(t)?e+1:e,0)}var N={claude:`Claude Code`,codex:`Codex`,junie:`Junie`,opencode:`OpenCode`,cursor:`Cursor`,pi:`pi`,copilot:`GitHub Copilot CLI`};function P(e){let t=e.currentStepId?e.steps.find(t=>t.id===e.currentStepId):void 0;if(t?.backend)return t.backend;if(e.runner)return e.runner;for(let t=e.steps.length-1;t>=0;--t){let n=e.steps[t]?.backend;if(n)return n}return`claude`}function F(e){return e.runner??`claude`}function I(e,t){let n=i(t,e);return n?.enabled===!1?{provider:e,usable:!1,reason:`${N[e]} is disabled. Enable it in Settings → Agents → Providers.`}:n?.status===`connected`?{provider:e,usable:!0}:{provider:e,usable:!1,reason:`${N[e]} credentials are unavailable. Authorize it in Settings → Agents → Providers.`}}function je(e,t){return I(P(e),t)}function Me(e,t){return I(F(e),t)}function L(e){let t=r(),n=P(e);return t.isSuccess&&t.data?je(e,t.data):{provider:n,usable:!0}}function Ne(e){let t=r(),n=F(e);return t.isSuccess&&t.data?Me(e,t.data):t.isError?{provider:n,usable:!1,reason:`Provider authentication could not be verified.`}:{provider:n,usable:!1,reason:`Checking agent providers…`}}var Pe={folder:ae,terminal:x,vscode:me,cursor:be,zed:E,windsurf:Te,sublime:ge,idea:he,pycharm:ye,webstorm:w,goland:Ce,rubymine:_e,phpstorm:pe,clion:C,rider:fe,"android-studio":we,xcode:ve,warp:Se,claude:b,codex:T,junie:b,opencode:b,pi:b,copilot:b};function Fe(e){return e.icon&&Pe[e.icon]||S}var Ie=RegExp(`^cli:(${_.options.map(e=>e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)).join(`|`)})$`);function R(e){let t=Ie.exec(e);return t?t[1]:void 0}function Le({choices:e,onPick:t,label:n=`Open in…`,title:r,triggerVariant:i=`ghost`,disabled:a=!1,leading:o,trailing:s,slot:c}){return(0,O.jsxs)(le,{children:[(0,O.jsx)(ie,{asChild:!0,children:(0,O.jsxs)(y,{variant:i,size:`sm`,title:r,disabled:a,"data-slot":c,children:[(0,O.jsx)(S,{"aria-hidden":`true`}),n]})}),(0,O.jsxs)(oe,{align:`end`,children:[o,o&&e.length>0?(0,O.jsx)(ce,{}):null,e.map(({target:e,suffix:n,title:r})=>{let i=Fe(e);return(0,O.jsxs)(se,{"data-target":e.id,title:r,onSelect:()=>t(e.id),children:[(0,O.jsx)(i,{"aria-hidden":`true`}),e.label,n??``]},e.id)}),s]})]})}function z(e){return e===`running`||e===`queued`||e===`waiting`}function B(e){return[...e.steps].reverse().find(e=>e.sessionId)?.sessionId}var Re=/^[A-Za-z0-9._][A-Za-z0-9._-]{0,199}$/,V={claude:`claude --resume`,codex:`codex resume`,opencode:`opencode --session`,cursor:`agent --resume`,junie:`junie --resume`,pi:`pi --session`,copilot:`copilot --resume`};function ze(e,t){if(Re.test(t))return e===`junie`?`${V.junie} --session-id=${t}`:`${V[e??`claude`]} ${t}`}function Be(e){if(z(e.status))return;let t=B(e);if(t===void 0)return;let n=ze(e.runner,t);if(n!==void 0)return e.worktreePath?`cd ${e.worktreePath} && ${n}`:n}function Ve(e,t){let n=R(t);return!n||z(e.status)?!1:n===(e.runner??`claude`)&&B(e)!==void 0}function H(e){let t=z(e.status),n=B(e)!==void 0;return{finish:e.status===`waiting`||e.status===`review`,continueRun:!t&&n,terminal:!t&&n,notes:!0,archive:!t,pin:!e.archived,markUnread:j(e)&&!M(e),cancel:t,deleteRun:!t}}function He(e){return`Merge head branch and resolve conflicts in ${e?`PR number ${e}`:`this pull request`}`}function Ue(e){return e===`review`?`Accept the changes without a PR`:`Close the session`}function We(e,t){let n=e.filter(e=>!e.archived&&e.status===`queued`).sort((e,t)=>e.createdAt.localeCompare(t.createdAt)).findIndex(e=>e.id===t);return n>=0?n+1:void 0}var Ge=[50,100,200,400,800,1e3,1e3,1e3,1e3],Ke=e=>new Promise(t=>setTimeout(t,e));function qe(e){return e instanceof s&&e.status===409&&e.message===`run is still active`}async function U(e,t=Ke){for(let n=0;;n+=1)try{return await e()}catch(e){let r=Ge[n];if(!qe(e)||r===void 0)throw e;await t(r)}}function Je(e){return z(e.status)?`live`:H(e).continueRun?`resume`:`unavailable`}function W(e,t){let n=o(e.id,t),r=a(e.id,t),i=L(e),c=Ne(e),[l,u]=(0,D.useState)(void 0),[d,f]=(0,D.useState)(!1),p=(0,D.useRef)(!1),m=Je(e),h=m===`resume`?!c.usable:m===`live`&&!i.usable,g=m===`unavailable`?`no-session`:h?`provider`:void 0,_=g===`no-session`?`This session has ended and no agent session was recorded, so the answer cannot be delivered.`:g===`provider`?m===`resume`?c.reason:i.reason:void 0,v=e=>c.usable?r.mutateAsync({text:e}):Promise.reject(Error(c.reason??`The run provider is unavailable.`));return{mode:m,blockedBy:g,reason:_,isPending:d||n.isPending||r.isPending,error:l,send:async t=>{if(g||p.current)return _;p.current=!0,f(!0),u(void 0);try{if(m===`resume`){await U(()=>v(t));return}try{await n.mutateAsync({text:t})}catch(n){if(n instanceof s&&n.status===409&&B(e)!==void 0){await U(()=>v(t));return}throw n}return}catch(e){let t=e instanceof Error?e.message:String(e);return u(t),t}finally{p.current=!1,f(!1)}}}}function G({run:e,projectId:t,prNumber:n}){let r=W(e,t),i=te(),[a,o]=(0,D.useState)(!1),s=a||r.isPending,c=!!r.blockedBy,l=async()=>{if(s||c)return;let e=r.mode===`resume`;o(!0);try{let t=await r.send(He(n));t?f(t,{tone:`danger`}):(f(`${e?`Task reopened`:`Sent to the task`} — resolving conflicts${n?` in PR #${n}`:``}`),i())}finally{o(!1)}};return(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(y,{type:`button`,size:`sm`,"data-slot":`reference-conflict-action`,disabled:c||s,onClick:()=>void l(),className:`h-7 w-full text-xs`,children:s?`Sending…`:`Resolve conflicts`}),c&&r.reason?(0,O.jsx)(`span`,{className:`block opacity-70`,children:r.reason}):null]})}function Ye({projectId:e,runId:t,prNumber:n}){let r=l(e,t);return r.data?(0,O.jsx)(G,{run:r.data,projectId:e,prNumber:n}):(0,O.jsx)(y,{type:`button`,size:`sm`,disabled:!0,className:`h-7 w-full text-xs`,children:r.isError?`Unavailable`:`Loading…`})}function Xe({run:e,reference:t,className:n,compact:r=!1}){let{lookup:i,projectId:a}=re(),o=t.kind===`PR`?d(e).filter(e=>e.kind===`PR`&&(e.number!==t.number||!!e.url&&!!t.url&&e.url!==t.url)):[];return(0,O.jsx)(O.Fragment,{children:(t.number===void 0?[t,...o]:u([{...t,number:t.number},...o],e=>a?i({projectId:a,kind:e.kind,number:e.number}).status:void 0)).map((t,i)=>(0,O.jsx)(D.Fragment,{children:(0,O.jsx)(ne,{reference:t,taskTitle:c(e),conflictAction:(0,O.jsx)(G,{run:e,prNumber:t.number}),className:n,compact:r})},`${t.kind}-${t.number??`unknown`}-${t.url??i}`))})}var Ze=`quick-task`;function Qe(e,t,n=24){return[t,...(e??[]).filter(e=>!(e.source===t.source&&e.ref===t.ref))].slice(0,n)}var K=[{id:`claude`,label:`claude`,desc:`Claude Code CLI`},{id:`codex`,label:`codex`,desc:`OpenAI Codex (app-server)`},{id:`junie`,label:`junie`,desc:`JetBrains Junie CLI`},{id:`opencode`,label:`opencode`,desc:`OpenCode (serve)`},{id:`cursor`,label:`cursor`,desc:`Cursor Agent CLI`},{id:`pi`,label:`pi`,desc:`pi CLI (provider/model)`},{id:`copilot`,label:`copilot`,desc:`GitHub Copilot CLI (ACP)`}],q={claude:[{id:``,label:`auto`,desc:`Pick the best model per step`},{id:`opus`,label:`opus`,desc:`Deep reasoning for hard tasks`},{id:`sonnet`,label:`sonnet`,desc:`Fast and cheap`},{id:`haiku`,label:`haiku`,desc:`Fastest — simple, scoped tasks`}],codex:[{id:``,label:`auto`,desc:`Use your Codex default model`}],opencode:[{id:``,label:`auto`,desc:`Use your OpenCode default model`}],junie:[{id:``,label:`auto`,desc:`Use your Junie default model`}],cursor:[{id:``,label:`auto`,desc:`Use your Cursor default model`}],pi:[{id:``,label:`auto`,desc:`Use your pi default model`},{id:`anthropic/claude-opus-4-8`,label:`claude-opus-4.8`,desc:`via Anthropic`},{id:`anthropic/claude-sonnet-5`,label:`claude-sonnet-5`,desc:`via Anthropic`},{id:`openai/gpt-5.1`,label:`gpt-5.1`,desc:`via OpenAI`}],copilot:[{id:``,label:`auto`,desc:`Let Copilot pick the model`}]},J={claude:/^claude[-.]/,codex:/^gpt[-.]/},$e=[`opencode`,`pi`];function Y(e,t){return!e||q[t].some(t=>t.id===e)||J[t]?.test(e)?!1:Object.entries(q).some(([n,r])=>n!==t&&!$e.includes(n)&&r.some(t=>t.id!==``&&t.id===e))||Object.entries(J).some(([n,r])=>n!==t&&r.test(e))}function X(e,t,n=[]){let r=q[e]??q.claude,i=g(e)?t?.models??[]:[],a=i.length>0?[et(r)]:[...r],o=new Set(a.map(e=>e.id));for(let e of i)!e.id||o.has(e.id)||(o.add(e.id),a.push({id:e.id,label:e.label||e.id,desc:e.description}));for(let t of n)!t||o.has(t)||Y(t,e)||(o.add(t),a.push({id:t,label:t,desc:`Custom or legacy model`}));return a}function et(e){return e.find(e=>e.id===``)??{id:``,label:`auto`,desc:``}}var tt={claude:`Claude`,codex:`Codex`,opencode:`OpenCode`,junie:`Junie`,cursor:`Cursor`};function nt(e,t,n=!1){if(!g(e))return;let r=tt[e];if(t?.stale)return`Using cached ${r} model list`;if(n||t?.source===`unavailable`)return`Latest ${r} models unavailable`}function rt(e){let t=K.map(e=>e.id).filter(t=>e.some(e=>e.name===t&&e.available));return t.length>0?t:[`claude`]}function it(e,t,n){return e!==null&&t.includes(e)?e:t.includes(n)?n:t[0]??`claude`}function Z(e,t,n=!1){return!n&&e===t?void 0:e}function at(e,t,n,r){let i=X(t,r,[e,n?.[t]]);if(e!==null&&i.some(t=>t.id===e))return e;let a=n?.[t];return a!==void 0&&i.some(e=>e.id===a)?a:``}function ot(e,t,n){return e.source===`skill`?t.some(t=>t.name===e.ref):n.some(t=>t.name===e.ref)}function st(e,t,n){return e&&ot(e,t,n)?e:null}function ct(e){let{task:t,source:n,model:r,modelsLocked:i,runner:a,runnerExplicit:o,defaultRunner:s,agentProfile:c,variants:l,images:u,worktree:d,autonomous:f,generateFollowups:p,todoId:m,dispatch:h}=e;return{task:t,...n?.source===`skill`?{steps:[{id:`task`,name:n.ref,skill:n.ref,prompt:`{{task}}`}]}:{workflow:n?.ref??`quick-task`},model:i?void 0:r||void 0,runner:Z(a,s,o),agentProfile:c||void 0,variants:l>1?l:void 0,images:u.length>0?[...u]:void 0,worktree:d===!1&&l<=1?!1:void 0,autonomous:f===!0||void 0,generateFollowups:p!==!1&&void 0,todoId:m||void 0,dispatch:h??void 0}}function lt(e){let t=`runs`in e?e.runs[0]:e;return t?`/tasks/${t.id}`:`/`}var ut={md:`text/markdown`,markdown:`text/markdown`,txt:`text/plain`,log:`text/plain`,pdf:`application/pdf`};function Q(e){return h(e.type)?e.type:ut[e.name.split(`.`).pop()?.toLowerCase()??``]??null}function $(e,t){return t?`pasted image`:`pasted.${ee(e)}`}async function dt(e,t=`file`){let n=new Uint8Array(await e.arrayBuffer()),r=``;for(let e=0;e<n.length;e+=32768)r+=String.fromCharCode(...n.subarray(e,e+32768));let i=btoa(r),a=Q(e)??`application/octet-stream`,o=m(a),s=t===`clipboard`&&o?void 0:e.name;return{mediaType:a,data:i,...o?{preview:`data:${a};base64,${i}`}:{},name:s||$(a,o),...s?{originalName:s}:{},isImage:o}}function ft({mediaType:e,data:t,originalName:n}){return{mediaType:e,data:t,...n?{name:n}:{}}}function pt(e,t){let n=[],r=[],i=t;for(let t of e){let e=t.name||`attachment`;if(Q(t)===null){r.push(`${e} is not a supported attachment (images, PDF and plain-text files such as TXT or MD)`);continue}if(t.size>5242880){r.push(`${e} is too large (max 5 MB)`);continue}if(i>=4){r.push(`${e} skipped — max 4 attachments per message`);continue}n.push(t),i+=1}return{accepted:n,rejected:r}}function mt(e,t){let[n,r]=(0,D.useState)(!1),[i,a]=(0,D.useState)(``),o=(0,D.useRef)(!1),[s,c]=(0,D.useState)(!0),l=e=>{a(e),c(!0)},u=e=>{a(e),c(!1),o.current=!1,r(!0)};return{editing:n,draft:i,setDraft:l,begin:()=>{u(e),c(!0)},beginWith:u,commitOnBlur:s,commit:()=>{if(o.current)return;o.current=!0,r(!1);let n=i.trim();n.length===0||n===e||t(n)},cancel:()=>{o.current=!0,r(!1)}}}function ht({editor:e,className:t}){return(0,O.jsx)(`input`,{"data-slot":`title-input`,"aria-label":`Task title`,autoFocus:!0,value:e.draft,onChange:t=>e.setDraft(t.target.value),onBlur:()=>{e.commitOnBlur&&e.commit()},onKeyDown:t=>{t.key===`Enter`?(t.preventDefault(),e.commit()):t.key===`Escape`&&(t.preventDefault(),e.cancel())},className:v(`w-full min-w-0 rounded-sm border border-border bg-card px-1.5 py-0.5 outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50`,t)})}export{H as A,xe as B,W as C,B as D,z as E,ke as F,C as H,M as I,Ae as L,R as M,L as N,We as O,j as P,E as R,Xe as S,Ue as T,de as U,w as V,ue as W,Z as _,pt as a,G as b,rt as c,Y as d,X as f,st as g,it as h,dt as i,Le as j,Be as k,ct as l,at as m,mt as n,ft as o,Qe as p,$ as r,K as s,ht as t,nt as u,lt as v,Ve as w,Ye as x,Ze as y,T as z};
|