@hearsay-tools/squawk 0.19.0-dev.9308 → 0.19.0-dev.9310
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/server/server.d.ts +58 -58
- package/package.json +4 -4
- package/web/dist/assets/{accounts-section-B8X63Wvk.js → accounts-section-DJ_M9Wt5.js} +1 -1
- package/web/dist/assets/{activity-motion-BX7w9uwa.js → activity-motion-CeNmzIIs.js} +1 -1
- package/web/dist/assets/{activity-route-D6OhCzkJ.js → activity-route-CYn-qQq2.js} +1 -1
- package/web/dist/assets/{agent-config-section-RluVjTDv.js → agent-config-section-C89KQhYI.js} +1 -1
- package/web/dist/assets/{agent-defaults-section-Bl67Iurg.js → agent-defaults-section-CsIHvRnd.js} +1 -1
- package/web/dist/assets/{appearance-ChGEz79A.js → appearance-xdlVXLZN.js} +1 -1
- package/web/dist/assets/{archive-on-merge-field-DtMYAmPH.js → archive-on-merge-field-vYZF1Wln.js} +1 -1
- package/web/dist/assets/{ask-card-Bk87kXMi.js → ask-card-CTkwopg6.js} +1 -1
- package/web/dist/assets/{automations-route-DpEqMGRx.js → automations-route-DhkRC_XY.js} +1 -1
- package/web/dist/assets/{commit-list-DGLW8f7_.js → commit-list-B3px5blI.js} +1 -1
- package/web/dist/assets/{diff-BQIvq2Ar.js → diff-4OKh2896.js} +2 -2
- package/web/dist/assets/{diff-controls-CcYIa7pJ.js → diff-controls-CQuYWKK_.js} +1 -1
- package/web/dist/assets/{diff-view-BSYPKJkF.js → diff-view-BZi9U7Rt.js} +6 -6
- package/web/dist/assets/{discard-changes-dialog-CEeuND_i.js → discard-changes-dialog-DRLVQrRX.js} +1 -1
- package/web/dist/assets/{file-preview-BPSpXZ6G.js → file-preview-DwDnEbjs.js} +1 -1
- package/web/dist/assets/{git-toolbar-D3O7S7vw.js → git-toolbar-CnbRMfPP.js} +1 -1
- package/web/dist/assets/{github-b6pU4RVM.js → github-BFdjku0b.js} +1 -1
- package/web/dist/assets/{global-activity-route-sTvejVUG.js → global-activity-route-CYV5tNqR.js} +1 -1
- package/web/dist/assets/{index-CIyGnGfm.js → index-BlqAIDwd.js} +4 -4
- package/web/dist/assets/index-DrL3MqE4.css +1 -0
- package/web/dist/assets/{markdown-DnBvknF9.js → markdown-BA-2Hv-H.js} +1 -1
- package/web/dist/assets/{option-select-HC8juekO.js → option-select-Bz-6fs6-.js} +1 -1
- package/web/dist/assets/{preferences-section-DuV8JFqQ.js → preferences-section-CGPTMvPb.js} +1 -1
- package/web/dist/assets/{preview-pane-connected-E8n0RgYL.js → preview-pane-connected-Km1_yTQu.js} +1 -1
- package/web/dist/assets/{project-location-bPiIsStE.js → project-location-DgWnz24i.js} +1 -1
- package/web/dist/assets/{projects-section-0eQ2TVqw.js → projects-section-C5Lm9E1X.js} +1 -1
- package/web/dist/assets/{prompt-templates-section-CVNw5v0w.js → prompt-templates-section-BSqqmMzn.js} +1 -1
- package/web/dist/assets/{remote-settings-notice-tNcad9fA.js → remote-settings-notice-CPMHtuyk.js} +1 -1
- package/web/dist/assets/{repo-git-DA66978k.js → repo-git-Dr-LPs33.js} +1 -1
- package/web/dist/assets/{report-reader-DHB5teJQ.js → report-reader-BXPtT3jw.js} +1 -1
- package/web/dist/assets/{reports-Oxg0v5bR.js → reports-BztUxdF1.js} +1 -1
- package/web/dist/assets/{resources-section-BAj-A1Ou.js → resources-section-CKxYxZlu.js} +1 -1
- package/web/dist/assets/{review-notes-drafts-agZQaBcF.js → review-notes-drafts-B7QtBlMK.js} +1 -1
- package/web/dist/assets/{review-panel-858YvYOc.js → review-panel-WjhjBT-O.js} +1 -1
- package/web/dist/assets/review-strip-lK-KV-Bh.js +1 -0
- package/web/dist/assets/{run-diff-BDFptONx.js → run-diff-BzL5y9aa.js} +1 -1
- package/web/dist/assets/{run-header-CEIKmo_0.js → run-header-D_I9i1FK.js} +2 -2
- package/web/dist/assets/{select-C4s2-ztq.js → select-C3I9ZinR.js} +1 -1
- package/web/dist/assets/{session-context-section-CihFGtUL.js → session-context-section-Bko3JFzB.js} +1 -1
- package/web/dist/assets/{settings-agent-picker-B-LnnccN.js → settings-agent-picker-CA5KEY0b.js} +1 -1
- package/web/dist/assets/{settings-save-bar-l5vO-fT3.js → settings-save-bar-DXlarWtq.js} +1 -1
- package/web/dist/assets/{settings-shell-B_o8TQYi.js → settings-shell-BvkTyfyu.js} +1 -1
- package/web/dist/assets/{sidebar-section-BTjJD2PF.js → sidebar-section-BWGMQzwD.js} +1 -1
- package/web/dist/assets/{skills-C-PLlLf0.js → skills-khuz63Be.js} +1 -1
- package/web/dist/assets/task-changes-BZiv3oW9.js +5 -0
- package/web/dist/assets/task-commits-C319iu69.js +1 -0
- package/web/dist/assets/{task-file-scope-npOd7AhM.js → task-file-scope-CVzNnBlI.js} +1 -1
- package/web/dist/assets/{task-files--54CdvAw.js → task-files-BwWE5iwD.js} +1 -1
- package/web/dist/assets/{task-github-item-QzP9IPGg.js → task-github-item--JaIohoc.js} +1 -1
- package/web/dist/assets/{task-thread-BgxYbzJU.js → task-thread-D_Yc4SUV.js} +1 -1
- package/web/dist/assets/{thread-state-CfmY7F3h.js → thread-state-DAlHXYiH.js} +1 -1
- package/web/dist/assets/{unified-diff-DdU6bcRV.js → unified-diff-C46MIUZz.js} +1 -1
- package/web/dist/assets/{use-finish-run-Bv7_Ezz_.js → use-finish-run-0YNEOl4g.js} +1 -1
- package/web/dist/assets/{use-hand-to-agent-state-dHej93ZU.js → use-hand-to-agent-state-CkqtX66f.js} +1 -1
- package/web/dist/assets/use-path-bases-Dpl3ksiL.js +1 -0
- package/web/dist/assets/{workflows-CeUWNdYH.js → workflows-D5gUtDwQ.js} +1 -1
- package/web/dist/assets/{workspace-tools-BwMECWWr.js → workspace-tools-CCQ42oji.js} +1 -1
- package/web/dist/assets/{worktrees-section-CytHZvmT.js → worktrees-section-B_8wVdPI.js} +1 -1
- package/web/dist/index.html +2 -2
- package/web/dist/assets/index-BToDejlf.css +0 -1
- package/web/dist/assets/review-strip-tiqQt7qS.js +0 -1
- package/web/dist/assets/task-changes-BZ7Hlj9q.js +0 -5
- package/web/dist/assets/task-commits-Jf35_1k0.js +0 -1
- package/web/dist/assets/use-path-bases-B6yYqrmU.js +0 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/project-rail-sortable-BmVI4_-T.js","assets/rolldown-runtime-QTnfLwEv.js","assets/react-runtime-CCIEwYL0.js","assets/project-order-AcHI4Dcl.js","assets/sortable.esm-CAVTYaA3.js","assets/accounts-section-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/project-rail-sortable-BmVI4_-T.js","assets/rolldown-runtime-QTnfLwEv.js","assets/react-runtime-CCIEwYL0.js","assets/project-order-AcHI4Dcl.js","assets/sortable.esm-CAVTYaA3.js","assets/accounts-section-DJ_M9Wt5.js","assets/queries-CPNrCEon.js","assets/host-context-KsSKxKbI.js","assets/project-scope-context-_6sNMsAf.js","assets/live-protocol-CNUmr-VT.js","assets/dist-CCX8mhHc.js","assets/bundle-mjs-rHxsej31.js","assets/host-storage-BHtMSWBL.js","assets/chunk-KS7C4IRE-BdLLx37K.js","assets/preload-helper-Czpn1I53.js","assets/design-icons-QbNMZniQ.js","assets/createLucideIcon-BHp8sXmF.js","assets/folder-browser-CHTNDBIU.js","assets/chevron-right-BENZ-1ZN.js","assets/folder-o-AvL3y3.js","assets/button-BV_AiLj2.js","assets/badge-DAnkqD7i.js","assets/dialog-DKr-j9S6.js","assets/dist-CyFJ-9Ex.js","assets/es2015-BHonSvOU.js","assets/status-dot-Dvy-rnDJ.js","assets/bot-TkDIw4y-.js","assets/agents-settings-path-7X6_cvUg.js","assets/centered-state-N8vWM_Hw.js","assets/option-select-Bz-6fs6-.js","assets/select-C3I9ZinR.js","assets/dist-B2_vvox1.js","assets/dist-Czz3Y5qH.js","assets/dist-Du6flkGD.js","assets/dist-ClMNSUvT.js","assets/settings-agent-picker-CA5KEY0b.js","assets/remote-settings-notice-CPMHtuyk.js","assets/save-cue-CpHgT93o.js","assets/use-path-bases-Dpl3ksiL.js","assets/project-location-DgWnz24i.js","assets/open-in-menu-D07DgRwh.js","assets/external-link-BE6y205O.js","assets/smartphone-Lr8Ug2z_.js","assets/square-terminal-B6RYYieR.js","assets/dropdown-menu-NJZfnQCU.js","assets/own-lookup-DS54wXvD.js","assets/project-router-l_pJCK5X.js","assets/settings-field-AyinSFR_.js","assets/use-workspace-config-save-M2ethek2.js","assets/agent-config-section-C89KQhYI.js","assets/code-editor-DZMD1guX.js","assets/highlighter-Crq-WTmN.js","assets/discard-changes-dialog-DRLVQrRX.js","assets/settings-save-bar-DXlarWtq.js","assets/agent-defaults-section-CsIHvRnd.js","assets/switch-B9OfOEzC.js","assets/agent-accounts-BC78GKYv.js","assets/textarea-BGp28xFr.js","assets/saved-draft-BwzBc-_Y.js","assets/appearance-xdlVXLZN.js","assets/moon-CRE9nU5R.js","assets/projects-section-C5Lm9E1X.js","assets/popover-BQolmvDR.js","assets/settings-list-detail-BlEEuyae.js","assets/page-shell-BdjH5hyc.js","assets/page-shell-CEIoW56O.css","assets/prompt-templates-section-BSqqmMzn.js","assets/command-4D8sPZJy.js","assets/skills-pM_PouEs.js","assets/resources-section-CKxYxZlu.js","assets/session-context-section-Bko3JFzB.js","assets/plus-CxRU2X8C.js","assets/sidebar-section-BWGMQzwD.js","assets/worktrees-section-B_8wVdPI.js","assets/preferences-section-CGPTMvPb.js","assets/archive-on-merge-field-vYZF1Wln.js","assets/preview-pane-connected-Km1_yTQu.js","assets/arrow-right-Dh_Lx3um.js","assets/check-OP-CVgZG.js","assets/chevron-down-CHGyCDBH.js","assets/circle-x-7nTlobAF.js","assets/info-DA1x_4bz.js","assets/loader-circle-CPBhhDbB.js","assets/play-CmVAj_fu.js","assets/tool-display-CTbToGmi.js","assets/preview-7NPVVq1D.js","assets/thread-state-DAlHXYiH.js","assets/app-window-CSHwDX9N.js","assets/format-BU7D3IfE.js","assets/report-reader-BXPtT3jw.js","assets/file-preview-DwDnEbjs.js","assets/diff-controls-CQuYWKK_.js","assets/html-report-BX3msvci.js","assets/markdown-BA-2Hv-H.js","assets/chunk-BO2N2NFS-DQrpGzb-.js","assets/lib-DrPFkMXk.js","assets/html-report-frame-Bk6UkqKa.js","assets/review-strip-lK-KV-Bh.js","assets/eye-B8okNWXU.js","assets/use-finish-run-0YNEOl4g.js","assets/task-groups-Bc_WNTMe.js","assets/attention-C33sN0aA.js","assets/review-notes-drafts-B7QtBlMK.js","assets/review-panel-WjhjBT-O.js","assets/run-diff-BzL5y9aa.js","assets/collapsible-D5i3hm2L.js","assets/unified-diff-C46MIUZz.js","assets/task-changes-BZiv3oW9.js","assets/run-header-D_I9i1FK.js","assets/reference-chip-B32qTHb5.js","assets/message-square-B-MD-8rD.js","assets/task-file-scope-CVzNnBlI.js","assets/tab-link-BPkGPOYd.js","assets/run-header-Ytho20Wt.css","assets/git-toolbar-CnbRMfPP.js","assets/diff-stat-DCO_BkZB.js","assets/middle-truncated-name-jUQS2QzL.js","assets/markdown-BBDDg-4t.js","assets/diff-4OKh2896.js","assets/image-preview-CvcSCCBU.js","assets/zoomable-image-Dv85Vr4A.js","assets/code-workbench-B0GIezrD.js","assets/file-text-nGpo7MVd.js","assets/selected-file-CfBWFB6p.js","assets/automations-route-DhkRC_XY.js","assets/label-Qj4HjGeN.js","assets/cez-idle-C0drOeLs.js","assets/hosts-BDfuQnus.js","assets/run-detail-refresh-CZ7VyCgP.js","assets/automation-format-jKMOXcHS.js","assets/automations-route-mn5aFSDU.css","assets/workspace-tools-CCQ42oji.js","assets/settings-shell-BvkTyfyu.js","assets/settings-shell-Bvje3VDf.css","assets/task-thread-D_Yc4SUV.js","assets/ask-card-CTkwopg6.js","assets/report-selection-DCC-F7i6.js","assets/use-search-params-writer-DD5PEEZw.js","assets/report-title-D4Mbu2Er.js","assets/search-x-I9Q8pgUa.js","assets/read-state-BXLUf0Xi.js","assets/task-thread-BObu0KsD.css","assets/task-files-BwWE5iwD.js","assets/task-commits-C319iu69.js","assets/change-counts-BLLRvt46.js","assets/commit-list-B3px5blI.js","assets/task-github-item--JaIohoc.js","assets/use-hand-to-agent-state-CkqtX66f.js","assets/use-hand-to-agent-state-BSM9EGsW.css","assets/repo-git-Dr-LPs33.js","assets/nav-row-styles-CIedRn3A.js","assets/control-locations-kCPVEtOM.js","assets/repo-git-DFbTe7cL.css","assets/github-BFdjku0b.js","assets/reports-BztUxdF1.js","assets/arrow-up-right-DKGzsMqY.js","assets/reports-CgbU2SrW.css","assets/workflows-D5gUtDwQ.js","assets/workflows-D7bXUmGa.css","assets/activity-route-CYn-qQq2.js","assets/activity-motion-CeNmzIIs.js","assets/activity-motion-DcKVM8fM.css","assets/global-activity-route-CYV5tNqR.js","assets/skills-khuz63Be.js"])))=>i.map(i=>d[i]);
|
|
2
2
|
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,n,r,t as i}from"./react-runtime-CCIEwYL0.js";import{$t as a,An as o,At as s,B as c,Bt as l,Ct as u,Et as d,Fn as f,Ft as p,H as m,Hn as h,I as g,In as _,Ln as v,M as y,Mn as b,N as x,Nn as S,O as C,Pn as w,Qt as T,Rn as E,Rt as D,S as O,Tn as k,U as A,Ut as j,Vn as M,Vt as N,W as ee,_ as P,_t as F,at as I,bt as L,ct as R,d as te,dn as ne,dt as re,en as z,ft as ie,g as ae,gt as oe,ht as B,in as se,it as ce,jt as le,k as ue,kn as de,l as fe,ln as pe,mt as me,nn as he,on as ge,ot as _e,p as ve,pt as ye,q as be,rt as xe,sn as V,t as Se,tn as Ce,u as we,un as Te,v as Ee,wt as De,y as Oe,yt as ke,z as Ae,zn as je}from"./queries-CPNrCEon.js";import{a as Me,c as Ne,d as Pe,f as Fe,g as Ie,i as Le,l as Re,m as ze,n as Be,o as Ve,s as He,u as Ue}from"./host-context-KsSKxKbI.js";import{$r as We,Aa as Ge,Ai as Ke,Bi as qe,C as Je,Ca as Ye,Cr as Xe,Da as Ze,Di as Qe,Dn as $e,Ea as et,Ei as tt,En as nt,Er as rt,Fa as it,Gi as at,Ht as ot,I as st,It as ct,Ji as lt,M as ut,Mn as dt,Mr as ft,Mt as pt,Na as mt,Nr as ht,Oa as gt,On as _t,Or as vt,P as yt,Pa as bt,Qr as xt,R as St,Rn as Ct,Rt as wt,Sa as Tt,Sr as Et,St as Dt,Ta as Ot,Tn as kt,Tr as At,Un as jt,Ut as Mt,Vi as Nt,Wr as Pt,Xr as Ft,Y as It,Yt as Lt,_a as Rt,a as H,ba as zt,br as Bt,dr as Vt,fn as Ht,ga as Ut,gr as Wt,ha as U,hi as Gt,hr as Kt,i as qt,ia as Jt,ii as Yt,in as Xt,k as Zt,ka as Qt,ki as $t,l as en,lr as tn,lt as nn,ma as rn,mi as an,mr as on,n as sn,ni as cn,nt as ln,on as un,pr as dn,qi as fn,r as pn,ri as mn,rr as hn,rt as gn,si as _n,t as vn,ti as yn,u as bn,ur as xn,v as Sn,vr as Cn,vt as wn,wn as Tn,wt as En,xa as Dn,zi as On,zn as kn}from"./project-scope-context-_6sNMsAf.js";import{B as An,F as jn,I as Mn,N as Nn,P as Pn,V as Fn,W as In,Y as Ln,Z as Rn}from"./live-protocol-CNUmr-VT.js";import{t as W}from"./preload-helper-Czpn1I53.js";import{_ as zn,a as Bn,c as Vn,g as Hn,h as Un,i as Wn,l as Gn,m as Kn,n as G,o as K,p as qn,r as Jn,s as Yn,t as Xn,u as Zn}from"./chunk-KS7C4IRE-BdLLx37K.js";import{A as Qn,B as $n,C as er,D as tr,E as nr,F as rr,I as ir,L as ar,M as or,N as sr,O as cr,P as lr,R as ur,S as dr,T as fr,V as pr,_ as mr,a as hr,b as gr,d as _r,f as vr,g as yr,i as br,j as xr,k as Sr,l as Cr,m as wr,p as Tr,r as Er,s as Dr,t as Or,u as kr,v as Ar,y as jr,z as Mr}from"./reference-chip-B32qTHb5.js";import{i as Nr,n as Pr,r as Fr,t as Ir}from"./label-Qj4HjGeN.js";import{t as Lr}from"./cez-idle-C0drOeLs.js";import{a as Rr,c as zr,o as q,r as Br}from"./dist-CCX8mhHc.js";import{a as Vr,c as Hr,d as Ur,f as Wr,i as Gr,l as Kr,o as qr,p as Jr,s as Yr,t as Xr,u as Zr}from"./hosts-BDfuQnus.js";import{n as Qr,r as $r,t as ei}from"./host-storage-BHtMSWBL.js";import{$ as ti,A as ni,B as ri,D as ii,E as ai,G as oi,H as si,I as ci,J as li,K as ui,L as di,M as fi,O as pi,Q as mi,R as hi,S as gi,V as _i,X as vi,_ as yi,a as bi,at as xi,b as Si,c as Ci,ct as wi,d as Ti,et as Ei,ft as Di,g as Oi,ht as ki,it as Ai,j as ji,k as Mi,l as Ni,m as Pi,mt as Fi,n as Ii,nt as Li,ot as Ri,pt as zi,q as Bi,r as Vi,rt as Hi,s as Ui,t as Wi,tt as Gi,u as Ki,ut as qi,w as Ji,y as Yi,z as Xi}from"./design-icons-QbNMZniQ.js";import{t as J}from"./createLucideIcon-BHp8sXmF.js";import{i as Zi,n as Qi,r as $i}from"./open-in-menu-D07DgRwh.js";import{t as ea}from"./check-OP-CVgZG.js";import{t as ta}from"./chevron-down-CHGyCDBH.js";import{_ as na,a as ra,c as ia,d as aa,f as oa,h as sa,i as ca,l as la,m as ua,n as da,o as fa,p as pa,r as ma,s as ha,u as ga}from"./nav-row-styles-CIedRn3A.js";import{n as _a,t as va}from"./folder-browser-CHTNDBIU.js";import{t as ya}from"./external-link-BE6y205O.js";import{t as ba}from"./eye-B8okNWXU.js";import{t as xa}from"./loader-circle-CPBhhDbB.js";import{t as Sa}from"./play-CmVAj_fu.js";import{t as Ca}from"./search-x-I9Q8pgUa.js";import{n as wa,r as Ta,t as Ea}from"./preview-7NPVVq1D.js";import{n as Da,t as Y}from"./button-BV_AiLj2.js";import{d as Oa,h as ka,i as Aa,l as ja,m as Ma,o as Na,p as Pa,u as Fa}from"./es2015-BHonSvOU.js";import{a as Ia,c as La,i as Ra,l as za,n as Ba,o as Va,r as Ha,s as Ua,t as Wa}from"./dist-CyFJ-9Ex.js";import{a as Ga,i as Ka,n as qa,r as Ja,t as Ya}from"./dist-Du6flkGD.js";import{a as Xa,c as Za,d as Qa,f as $a,i as eo,l as to,o as no,p as ro,r as io,s as ao,t as oo,u as so}from"./dropdown-menu-NJZfnQCU.js";import{i as co,n as lo,r as uo,s as fo,t as po}from"./popover-BQolmvDR.js";import{t as mo}from"./switch-B9OfOEzC.js";import{t as ho}from"./badge-DAnkqD7i.js";import{a as go,i as _o,n as vo,o as yo,r as bo,s as xo,t as So}from"./dialog-DKr-j9S6.js";import{t as Co}from"./own-lookup-DS54wXvD.js";import{a as wo,c as To,i as Eo,l as Do,o as Oo,r as ko,s as Ao,t as X}from"./project-router-l_pJCK5X.js";import{_ as jo,a as Mo,c as No,d as Po,g as Fo,h as Io,l as Lo,m as Ro,n as zo,p as Bo,r as Vo,s as Ho,t as Uo,u as Wo,v as Go,x as Ko,y as qo}from"./task-groups-Bc_WNTMe.js";import{t as Jo}from"./attention-C33sN0aA.js";import{n as Yo,r as Xo,t as Zo}from"./read-state-BXLUf0Xi.js";import{t as Qo}from"./status-dot-Dvy-rnDJ.js";import{a as $o,i as es,l as ts,n as ns,o as rs,r as is,t as as,u as os}from"./report-selection-DCC-F7i6.js";import{a as ss,c as cs,d as ls,f as us,l as ds,m as fs,n as ps,o as ms,p as hs,t as gs,u as _s}from"./page-shell-BdjH5hyc.js";import{t as vs}from"./diff-stat-DCO_BkZB.js";import{a as ys,i as bs,n as xs,o as Ss,r as Cs,t as ws}from"./format-BU7D3IfE.js";import{a as Ts,c as Es,i as Ds,l as Os,n as ks,o as As,r as js,s as Ms,t as Ns}from"./command-4D8sPZJy.js";import{i as Ps,r as Fs,t as Is}from"./project-order-AcHI4Dcl.js";import{a as Ls,c as Rs,d as zs,f as Bs,i as Vs,n as Hs,o as Us,p as Ws,r as Gs,t as Ks,u as qs}from"./skills-pM_PouEs.js";import{a as Js,i as Ys,r as Xs,t as Zs}from"./agent-accounts-BC78GKYv.js";import{t as Qs}from"./control-locations-kCPVEtOM.js";import{r as $s,t as ec}from"./agents-settings-path-7X6_cvUg.js";import{t as tc}from"./centered-state-N8vWM_Hw.js";import{r as nc}from"./html-report-BX3msvci.js";import{t as rc}from"./use-search-params-writer-DD5PEEZw.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),e.crossOrigin===`use-credentials`?t.credentials=`include`:e.crossOrigin===`anonymous`?t.credentials=`omit`:t.credentials=`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var ic=class extends it{constructor(e={}){super(),this.config=e,this.#e=new Set,this.#t=new Map,this.#n=0}#e;#t;#n;build(e,t,n){let r=new M({client:e,mutationCache:this,mutationId:++this.#n,options:e.defaultMutationOptions(t),state:n});return this.add(r),r}add(e){this.#e.add(e);let t=ac(e);if(typeof t==`string`){let n=this.#t.get(t);n?n.push(e):this.#t.set(t,[e])}this.notify({type:`added`,mutation:e})}remove(e){if(this.#e.delete(e)){let t=ac(e);if(typeof t==`string`){let n=this.#t.get(t);if(n)if(n.length>1){let t=n.indexOf(e);t!==-1&&n.splice(t,1)}else n[0]===e&&this.#t.delete(t)}}this.notify({type:`removed`,mutation:e})}canRun(e){let t=ac(e);if(typeof t==`string`){let n=this.#t.get(t)?.find(e=>e.state.status===`pending`);return!n||n===e}else return!0}runNext(e){let t=ac(e);return typeof t==`string`?(this.#t.get(t)?.find(t=>t!==e&&t.state.isPaused))?.continue()??Promise.resolve():Promise.resolve()}clear(){Rn.batch(()=>{this.#e.forEach(e=>{this.notify({type:`removed`,mutation:e})}),this.#e.clear(),this.#t.clear()})}getAll(){return Array.from(this.#e)}find(e){let t={exact:!0,...e};return this.getAll().find(e=>Ot(t,e))}findAll(e={}){return this.getAll().filter(t=>Ot(e,t))}notify(e){Rn.batch(()=>{this.listeners.forEach(t=>{t(e)})})}resumePausedMutations(){let e=this.getAll().filter(e=>e.state.isPaused);return Rn.batch(()=>Promise.all(e.map(e=>e.continue().catch(Ze))))}};function ac(e){return e.options.scope?.id}var oc=class extends it{constructor(e={}){super(),this.config=e,this.#e=new Map}#e;build(e,t,n){let r=t.queryKey,i=t.queryHash??Ye(r,t),a=this.get(i);return a||(a=new Rt({client:e,queryKey:r,queryHash:i,options:e.defaultQueryOptions(t),state:n,defaultOptions:e.getQueryDefaults(r)}),this.add(a)),a}add(e){this.#e.has(e.queryHash)||(this.#e.set(e.queryHash,e),this.notify({type:`added`,query:e}))}remove(e){let t=this.#e.get(e.queryHash);t&&(e.destroy(),t===e&&this.#e.delete(e.queryHash),this.notify({type:`removed`,query:e}))}clear(){Rn.batch(()=>{this.getAll().forEach(e=>{this.remove(e)})})}get(e){return this.#e.get(e)}getAll(){return[...this.#e.values()]}find(e){let t={exact:!0,...e};return this.getAll().find(e=>et(t,e))}findAll(e={}){let t=this.getAll();return Object.keys(e).length>0?t.filter(t=>et(e,t)):t}notify(e){Rn.batch(()=>{this.listeners.forEach(t=>{t(e)})})}onFocus(){Rn.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){Rn.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}},sc=class{#e;#t;#n;#r;#i;#a;#o;#s;constructor(e={}){this.#e=e.queryCache||new oc,this.#t=e.mutationCache||new ic,this.#n=e.defaultOptions||{},this.#r=new Map,this.#i=new Map,this.#a=0}mount(){this.#a++,this.#a===1&&(this.#o=bt.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onFocus())}),this.#s=zt.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#e.onOnline())}))}unmount(){this.#a--,this.#a===0&&(this.#o?.(),this.#o=void 0,this.#s?.(),this.#s=void 0)}isFetching(e){return this.#e.findAll({...e,fetchStatus:`fetching`}).length}isMutating(e){return this.#t.findAll({...e,status:`pending`}).length}getQueryData(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state.data}ensureQueryData(e){let t=this.defaultQueryOptions(e),n=this.#e.build(this,t),r=n.state.data;return r===void 0?this.fetchQuery(e):(e.revalidateIfStale&&n.isStaleByTime(Ge(t.staleTime,n))&&this.prefetchQuery(t),Promise.resolve(r))}getQueriesData(e){return this.#e.findAll(e).map(({queryKey:e,state:t})=>[e,t.data])}setQueryData(e,t,n){let r=this.defaultQueryOptions({queryKey:e}),i=this.#e.get(r.queryHash)?.state.data,a=Dn(t,i);if(a!==void 0)return this.#e.build(this,r).setData(a,{...n,manual:!0})}setQueriesData(e,t,n){return Rn.batch(()=>this.#e.findAll(e).map(({queryKey:e})=>[e,this.setQueryData(e,t,n)]))}getQueryState(e){let t=this.defaultQueryOptions({queryKey:e});return this.#e.get(t.queryHash)?.state}removeQueries(e){let t=this.#e;Rn.batch(()=>{t.findAll(e).forEach(e=>{t.remove(e)})})}resetQueries(e,t){let n=this.#e;return Rn.batch(()=>(n.findAll(e).forEach(e=>{e.reset()}),this.refetchQueries({type:`active`,...e},t)))}cancelQueries(e,t={}){let n={revert:!0,...t},r=Rn.batch(()=>this.#e.findAll(e).map(e=>e.cancel(n)));return Promise.all(r).then(Ze).catch(Ze)}invalidateQueries(e,t={}){return Rn.batch(()=>(this.#e.findAll(e).forEach(e=>{e.invalidate()}),e?.refetchType===`none`?Promise.resolve():this.refetchQueries({...e,type:e?.refetchType??e?.type??`active`},t)))}refetchQueries(e,t={}){let n={...t,cancelRefetch:t.cancelRefetch??!0},r=Rn.batch(()=>this.#e.findAll(e).filter(e=>!e.isDisabled()&&!e.isStatic()).map(e=>{let t=e.fetch(void 0,n);return n.throwOnError||(t=t.catch(Ze)),e.state.fetchStatus===`paused`?Promise.resolve():t}));return Promise.all(r).then(Ze)}fetchQuery(e){let t=this.defaultQueryOptions(e);t.retry===void 0&&(t.retry=!1);let n=this.#e.build(this,t);return n.isStaleByTime(Ge(t.staleTime,n))?n.fetch(t):Promise.resolve(n.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(Ze).catch(Ze)}fetchInfiniteQuery(e){return e._type=`infinite`,this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(Ze).catch(Ze)}ensureInfiniteQueryData(e){return e._type=`infinite`,this.ensureQueryData(e)}resumePausedMutations(){return zt.isOnline()?this.#t.resumePausedMutations():Promise.resolve()}getQueryCache(){return this.#e}getMutationCache(){return this.#t}getDefaultOptions(){return this.#n}setDefaultOptions(e){this.#n=e}setQueryDefaults(e,t){this.#r.set(Tt(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){let t=[...this.#r.values()],n={};return t.forEach(t=>{gt(e,t.queryKey)&&Object.assign(n,t.defaultOptions)}),n}setMutationDefaults(e,t){this.#i.set(Tt(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){let t=[...this.#i.values()],n={};return t.forEach(t=>{gt(e,t.mutationKey)&&Object.assign(n,t.defaultOptions)}),n}defaultQueryOptions(e){if(e._defaulted)return e;let t={...this.#n.queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||=Ye(t.queryKey,t),t.refetchOnReconnect===void 0&&(t.refetchOnReconnect=t.networkMode!==`always`),t.throwOnError===void 0&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode=`offlineFirst`),t.queryFn===mt&&(t.enabled=!1),t}defaultMutationOptions(e){return e?._defaulted?e:{...this.#n.mutations,...e?.mutationKey&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){this.#e.clear(),this.#t.clear()}},Z=e(t(),1);function cc(e,t){let n=U(t);return uc({filters:{...e,status:`pending`}},n).length}function lc(e,t){return e.findAll(t.filters).map(e=>t.select?t.select(e):e.state)}function uc(e={},t){let n=U(t).getMutationCache(),r=Z.useRef(e),i=Z.useRef(null);return i.current===null&&(i.current=lc(n,e)),Z.useEffect(()=>{r.current=e}),Z.useSyncExternalStore(Z.useCallback(e=>n.subscribe(()=>{let t=Qt(i.current,lc(n,r.current));i.current!==t&&(i.current=t,Rn.schedule(e))}),[n]),()=>i.current,()=>i.current)}var dc=n(),fc=In().regex(/^(?:(?:config\.json(?:\.bak)?|agent-accounts\.json|hosts\.json|ui-state\.json|server\.json|server\.install\.lock)|(?:remote-settings|server-instances)\/[a-zA-Z0-9-]+\.(?:json|install\.lock)|mcp-tokens\/[a-zA-Z0-9-]+\.json)$/),pc=An({file:fc,detectedAt:Ln(),canRestore:Pn()}),mc=[`reset`,`outside-write`,`legacy-change`],hc=An({files:Nn(jn(`reason`,[pc.extend({reason:Mn(`reset`)}),pc.extend({reason:Mn(`outside-write`)}),pc.extend({reason:Mn(`legacy-change`),canImport:Pn()})]))});function gc(e,t){return!e||typeof e!=`object`||!(`files`in e)||!Array.isArray(e.files)?e:{...e,files:e.files.filter(e=>!(e&&typeof e==`object`&&`reason`in e&&typeof e.reason==`string`&&!t.includes(e.reason)))}}var _c=Fn(e=>gc(e,mc),hc);An({file:fc,detectedAt:Ln()}).strict();async function vc(e,t,n){n.throwIfAborted();let r=new Ut(e,{queryKey:t.queryKey,queryFn:t.queryFn,retry:!1,enabled:!1}).subscribe(()=>void 0);n.addEventListener(`abort`,r,{once:!0});try{return await e.fetchQuery({...t,retry:!1})}finally{n.removeEventListener(`abort`,r),r()}}var yc=[`workspace`,`home-recovery`];function bc(e){let t=_c.safeParse(e);if(!t.success)throw new Tn(200,`the Squawk server answered /home/recovery with an unexpected body`);return t.data}async function xc(e){return bc(await dt(await kt.api.v1.home.recovery.$get({},_t(e)),`/home/recovery`))}function Sc(){return Jt({queryKey:yc,queryFn:({signal:e})=>xc({signal:e}),enabled:Vt(),staleTime:1/0,retry:!1})}function Cc(){let e=U();(0,Z.useEffect)(()=>{let t=!0,n=new AbortController,r,i=async t=>{tn()&&await vc(e,{queryKey:yc,queryFn:({signal:e})=>xc({signal:e}),staleTime:0},t?AbortSignal.any([n.signal,t]):n.signal)},a=n=>{let r;try{r=bc(n)}catch{i().catch(()=>{});return}e.cancelQueries({queryKey:yc,exact:!0}).then(()=>{t&&tn()&&e.setQueryData(yc,r)})},o=()=>{tn()&&!r?r=I(`home:recovery`,a):!tn()&&r&&(r(),r=void 0)};o();let s=xn(t=>{o(),t?i().catch(()=>{}):e.cancelQueries({queryKey:yc,exact:!0})}),c=hn(e=>i(e));return()=>{t=!1,n.abort(),c(),s(),r?.()}},[e])}function wc(e,t){let n=t===`config.json`?[V.projects,V.config,V.runsIndex]:t===`agent-accounts.json`?[V.agentProfiles,V.providerStatus]:t===`ui-state.json`?[V.uiState]:[];for(let t of n)e.invalidateQueries({queryKey:t})}function Tc(e){let t=U();return je({mutationFn:async t=>bc(await dt(await kt.api.v1.home.recovery[e].$post({json:t}),`/home/recovery/${e}`)),onSuccess:async(e,n)=>{await t.cancelQueries({queryKey:yc,exact:!0}),t.setQueryData(yc,e),wc(t,n.file)}})}var Ec=()=>Tc(`restore`),Dc=()=>Tc(`accept`),Oc=()=>Tc(`import`);function kc(){return Cc(),null}function Ac(){on();let e=new sc({mutationCache:new ic({onError(t){!Pe()&&t instanceof Tn&&t.hostId&&pe(e).reconcileHosts([t.hostId],{hold:!0})}}),defaultOptions:{queries:{refetchInterval:!1,staleTime:5*6e4,gcTime:30*6e4,refetchOnWindowFocus:!1,refetchOnReconnect:!1,retry:(e,t)=>t instanceof Tn&&t.status>=400&&t.status<500?!1:e<1},mutations:{...Pe()?{networkMode:`always`}:{},retry:!1}}}),t=e.mount.bind(e),n=e.unmount.bind(e),r=0,i=null;return e.mount=()=>{if(t(),r+=1,r!==1)return;let n=dn().offline;i=Cn(()=>{let{hostId:t,offline:r}=dn();if(t===null){n=!1;return}if(!n&&r)for(let t of e.getQueryCache().getAll())t.options.networkMode!==`always`&&(t.state.fetchStatus===`fetching`?t.cancel({revert:!0}):t.state.status===`error`&&t.state.data!==void 0&&Wt(t.state.error)&&t.setState({status:`success`,error:null,fetchStatus:`idle`}));else n&&!r&&e.invalidateQueries({predicate:e=>e.options.networkMode!==`always`},{cancelRefetch:!1});n=r})},e.unmount=()=>{r=Math.max(0,r-1),r===0&&(i?.(),i=null),n()},e}var jc=Z.createContext(null),Q=i(),Mc=class extends Z.Component{state={error:null};static getDerivedStateFromError(e){return{error:e instanceof Error?e:Error(String(e))}}componentDidCatch(e,t){console.error(`Squawk cockpit: uncaught render error`,e,t.componentStack)}render(){let{error:e}=this.state;return e?(0,Q.jsxs)(`div`,{"data-slot":`app-error`,role:`alert`,style:{display:`flex`,minHeight:`100dvh`,flexDirection:`column`,alignItems:`center`,justifyContent:`center`,gap:`12px`,padding:`24px`,textAlign:`center`,font:`14px/1.5 system-ui, sans-serif`},children:[(0,Q.jsx)(`h1`,{style:{fontSize:`20px`,fontWeight:600,margin:0},children:`The cockpit hit an error`}),(0,Q.jsxs)(`p`,{style:{margin:0,maxWidth:`52ch`},children:[`Reload to carry on. Nothing on disk changed — Squawk’s state lives in`,` `,(0,Q.jsx)(`code`,{children:`.ai/cezar/`}),`, and this page never wrote to it.`]}),(0,Q.jsx)(`pre`,{"data-slot":`app-error-detail`,style:{margin:0,maxWidth:`100%`,overflowX:`auto`,textAlign:`left`,opacity:.75},children:e.message}),(0,Q.jsx)(`button`,{type:`button`,onClick:()=>location.reload(),style:{padding:`6px 14px`,cursor:`pointer`},children:`Reload`})]}):this.props.children}},Nc=J(`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`}]]),Pc=J(`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`}]]),Fc=J(`brush`,[[`path`,{d:`m11 10 3 3`,key:`fzmg1i`}],[`path`,{d:`M6.5 21A3.5 3.5 0 1 0 3 17.5a2.62 2.62 0 0 1-.708 1.792A1 1 0 0 0 3 21z`,key:`p4q2r7`}],[`path`,{d:`M9.969 17.031 21.378 5.624a1 1 0 0 0-3.002-3.002L6.967 14.031`,key:`wy6l02`}]]),Ic=J(`check-check`,[[`path`,{d:`M18 6 7 17l-5-5`,key:`116fxf`}],[`path`,{d:`m22 10-7.5 7.5L13 16`,key:`ke71qq`}]]),Lc=J(`chevron-left`,[[`path`,{d:`m15 18-6-6 6-6`,key:`1wnfg3`}]]),Rc=J(`chevrons-left`,[[`path`,{d:`m11 17-5-5 5-5`,key:`13zhaf`}],[`path`,{d:`m18 17-5-5 5-5`,key:`h8a8et`}]]),zc=J(`chevrons-right`,[[`path`,{d:`m6 17 5-5-5-5`,key:`xnjwq`}],[`path`,{d:`m13 17 5-5-5-5`,key:`17xmmf`}]]),Bc=J(`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`}]]),Vc=J(`clock-3`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 6v6h4`,key:`135r8i`}]]),Hc=J(`coins`,[[`path`,{d:`M13.744 17.736a6 6 0 1 1-7.48-7.48`,key:`bq4yh3`}],[`path`,{d:`M15 6h1v4`,key:`11y1tn`}],[`path`,{d:`m6.134 14.768.866-.5 2 3.464`,key:`17snzx`}],[`circle`,{cx:`16`,cy:`8`,r:`6`,key:`14bfc9`}]]),Uc=J(`compass`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m16.24 7.76-1.804 5.411a2 2 0 0 1-1.265 1.265L7.76 16.24l1.804-5.411a2 2 0 0 1 1.265-1.265z`,key:`9ktpf1`}]]),Wc=J(`copy`,[[`rect`,{width:`14`,height:`14`,x:`8`,y:`8`,rx:`2`,ry:`2`,key:`17jyea`}],[`path`,{d:`M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2`,key:`zix9uf`}]]),Gc=J(`dollar-sign`,[[`line`,{x1:`12`,x2:`12`,y1:`2`,y2:`22`,key:`7eqyqh`}],[`path`,{d:`M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6`,key:`1b0p4s`}]]),Kc=J(`ellipsis`,[[`circle`,{cx:`12`,cy:`12`,r:`1`,key:`41hilf`}],[`circle`,{cx:`19`,cy:`12`,r:`1`,key:`1wjl8i`}],[`circle`,{cx:`5`,cy:`12`,r:`1`,key:`1pcz8c`}]]),qc=J(`eye-off`,[[`path`,{d:`M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49`,key:`ct8e1f`}],[`path`,{d:`M14.084 14.158a3 3 0 0 1-4.242-4.242`,key:`151rxh`}],[`path`,{d:`M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143`,key:`13bj9a`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]),Jc=J(`file-cog`,[[`path`,{d:`M15 8a1 1 0 0 1-1-1V2a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8z`,key:`1ckgky`}],[`path`,{d:`M20 8v12a2 2 0 0 1-2 2h-4.182`,key:`1726p0`}],[`path`,{d:`m3.305 19.53.923-.382`,key:`ao1pio`}],[`path`,{d:`M4 10.592V4a2 2 0 0 1 2-2h8`,key:`1foop0`}],[`path`,{d:`m4.228 16.852-.924-.383`,key:`1fv9zy`}],[`path`,{d:`m5.852 15.228-.383-.923`,key:`1a9hc2`}],[`path`,{d:`m5.852 20.772-.383.924`,key:`1sh9ke`}],[`path`,{d:`m8.148 15.228.383-.923`,key:`4yu6lf`}],[`path`,{d:`m8.53 21.696-.382-.924`,key:`18b0s9`}],[`path`,{d:`m9.773 16.852.922-.383`,key:`ti6xop`}],[`path`,{d:`m9.773 19.148.922.383`,key:`rws47d`}],[`circle`,{cx:`7`,cy:`18`,r:`3`,key:`lvkj7j`}]]),Yc=J(`file-stack`,[[`path`,{d:`M11 21a1 1 0 0 1-1 1H4a1 1 0 0 1-1-1v-8a1 1 0 0 1 1-1`,key:`likhh7`}],[`path`,{d:`M16 16a1 1 0 0 1-1 1H9a1 1 0 0 1-1-1V8a1 1 0 0 1 1-1`,key:`17ky3x`}],[`path`,{d:`M21 6a2 2 0 0 0-.586-1.414l-2-2A2 2 0 0 0 17 2h-3a1 1 0 0 0-1 1v8a1 1 0 0 0 1 1h6a1 1 0 0 0 1-1z`,key:`1hyeo0`}]]),Xc=J(`file-text`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M10 9H8`,key:`b1mrlr`}],[`path`,{d:`M16 13H8`,key:`t4e002`}],[`path`,{d:`M16 17H8`,key:`z1uh3a`}]]),Zc=J(`folder-git-2`,[[`path`,{d:`M18 19a5 5 0 0 1-5-5v8`,key:`sz5oeg`}],[`path`,{d:`M9 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v5`,key:`1w6njk`}],[`circle`,{cx:`13`,cy:`12`,r:`2`,key:`1j92g6`}],[`circle`,{cx:`20`,cy:`19`,r:`2`,key:`1obnsp`}]]),Qc=J(`folder-search`,[[`path`,{d:`M10.7 20H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v4.1`,key:`1bw5m7`}],[`path`,{d:`m21 21-1.9-1.9`,key:`1g2n9r`}],[`circle`,{cx:`17`,cy:`17`,r:`3`,key:`18b49y`}]]),$c=J(`git-pull-request-arrow`,[[`circle`,{cx:`5`,cy:`6`,r:`3`,key:`1qnov2`}],[`path`,{d:`M5 9v12`,key:`ih889a`}],[`circle`,{cx:`19`,cy:`18`,r:`3`,key:`1qljk2`}],[`path`,{d:`m15 9-3-3 3-3`,key:`1lwv8l`}],[`path`,{d:`M12 6h5a2 2 0 0 1 2 2v7`,key:`1yj91y`}]]),el=J(`grip-vertical`,[[`circle`,{cx:`9`,cy:`12`,r:`1`,key:`1vctgf`}],[`circle`,{cx:`9`,cy:`5`,r:`1`,key:`hp0tcf`}],[`circle`,{cx:`9`,cy:`19`,r:`1`,key:`fkjjf6`}],[`circle`,{cx:`15`,cy:`12`,r:`1`,key:`1tmaij`}],[`circle`,{cx:`15`,cy:`5`,r:`1`,key:`19l28e`}],[`circle`,{cx:`15`,cy:`19`,r:`1`,key:`f4zoj3`}]]),tl=J(`link`,[[`path`,{d:`M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71`,key:`1cjeqo`}],[`path`,{d:`M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71`,key:`19qd67`}]]),nl=J(`list-checks`,[[`path`,{d:`M13 5h8`,key:`a7qcls`}],[`path`,{d:`M13 12h8`,key:`h98zly`}],[`path`,{d:`M13 19h8`,key:`c3s6r1`}],[`path`,{d:`m3 17 2 2 4-4`,key:`1jhpwq`}],[`path`,{d:`m3 7 2 2 4-4`,key:`1obspn`}]]),rl=J(`memory-stick`,[[`path`,{d:`M12 12v-2`,key:`fwoke6`}],[`path`,{d:`M12 18v-2`,key:`qj6yno`}],[`path`,{d:`M16 12v-2`,key:`heuere`}],[`path`,{d:`M16 18v-2`,key:`s1ct0w`}],[`path`,{d:`M2 11h1.5`,key:`15p63e`}],[`path`,{d:`M20 18v-2`,key:`12ehxp`}],[`path`,{d:`M20.5 11H22`,key:`khsy7a`}],[`path`,{d:`M4 18v-2`,key:`1c3oqr`}],[`path`,{d:`M8 12v-2`,key:`1mwtfd`}],[`path`,{d:`M8 18v-2`,key:`qcmpov`}],[`rect`,{x:`2`,y:`6`,width:`20`,height:`10`,rx:`2`,key:`1qcswk`}]]),il=J(`panel-left-close`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M9 3v18`,key:`fh3hqa`}],[`path`,{d:`m16 15-3-3 3-3`,key:`14y99z`}]]),al=J(`panel-left-open`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M9 3v18`,key:`fh3hqa`}],[`path`,{d:`m14 9 3 3-3 3`,key:`8010ee`}]]),ol=J(`pencil`,[[`path`,{d:`M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z`,key:`1a8usu`}],[`path`,{d:`m15 5 4 4`,key:`1mk7zo`}]]),sl=J(`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`}]]),cl=J(`send`,[[`path`,{d:`M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z`,key:`1ffxy3`}],[`path`,{d:`m21.854 2.147-10.94 10.939`,key:`12cjpa`}]]),ll=J(`server-off`,[[`path`,{d:`M7 2h13a2 2 0 0 1 2 2v4a2 2 0 0 1-2 2h-5`,key:`bt2siv`}],[`path`,{d:`M10 10 2.5 2.5C2 2 2 2.5 2 5v3a2 2 0 0 0 2 2h6z`,key:`1hjrv1`}],[`path`,{d:`M22 17v-1a2 2 0 0 0-2-2h-1`,key:`1iynyr`}],[`path`,{d:`M4 14a2 2 0 0 0-2 2v4a2 2 0 0 0 2 2h16.5l1-.5.5.5-8-8H4z`,key:`161ggg`}],[`path`,{d:`M6 18h.01`,key:`uhywen`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]),ul=J(`settings`,[[`path`,{d:`M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915`,key:`1i5ecw`}],[`circle`,{cx:`12`,cy:`12`,r:`3`,key:`1v7zrd`}]]),dl=J(`x`,[[`path`,{d:`M18 6 6 18`,key:`1bl5f8`}],[`path`,{d:`m6 6 12 12`,key:`d8bk6v`}]]),fl=`cezar:open-command-palette`;function pl(){window.dispatchEvent(new Event(fl))}var ml=`cez-sidebar-width`;function hl(e){let t=typeof e==`number`?e:Number(e);return Number.isFinite(t)?Math.min(420,Math.max(264,Math.round(t))):264}function gl(){try{let e=localStorage.getItem(ml);return e===null?264:hl(e)}catch{return 264}}function _l(e){try{localStorage.setItem(ml,String(hl(e)))}catch{}}var vl=Z.createContext(264),yl=Z.createContext(void 0);function bl(){return Z.useContext(yl)}var xl=Object.freeze({position:`absolute`,border:0,width:1,height:1,padding:0,margin:-1,overflow:`hidden`,clip:`rect(0, 0, 0, 0)`,whiteSpace:`nowrap`,wordWrap:`normal`}),Sl=`VisuallyHidden`,Cl=Z.forwardRef((e,t)=>(0,Q.jsx)(ka.span,{...e,ref:t,style:{...xl,...e.style}}));Cl.displayName=Sl;var wl=Cl,Tl=`AlertDialog`,[El,Dl]=Ma(Tl,[za]),Ol=za(),kl=e=>{let{__scopeAlertDialog:t,...n}=e,r=Ol(t);return(0,Q.jsx)(Wa,{...r,...n,modal:!0})};kl.displayName=Tl;var Al=`AlertDialogTrigger`,jl=Z.forwardRef((e,t)=>{let{__scopeAlertDialog:n,...r}=e,i=Ol(n);return(0,Q.jsx)(La,{...i,...r,ref:t})});jl.displayName=Al;var Ml=`AlertDialogPortal`,Nl=e=>{let{__scopeAlertDialog:t,...n}=e,r=Ol(t);return(0,Q.jsx)(Va,{...r,...n})};Nl.displayName=Ml;var Pl=`AlertDialogOverlay`,Fl=Z.forwardRef((e,t)=>{let{__scopeAlertDialog:n,...r}=e,i=Ol(n);return(0,Q.jsx)(Ia,{...i,...r,ref:t})});Fl.displayName=Pl;var Il=`AlertDialogContent`,[Ll,Rl]=El(Il),zl=Z.forwardRef((e,t)=>{let{__scopeAlertDialog:n,children:r,...i}=e,a=Ol(n),o=Rr(t,Z.useRef(null)),s=Z.useRef(null);return(0,Q.jsx)(Ll,{scope:n,cancelRef:s,children:(0,Q.jsx)(Ha,{role:`alertdialog`,...a,...i,ref:o,onOpenAutoFocus:Pa(i.onOpenAutoFocus,e=>{e.preventDefault(),s.current?.focus({preventScroll:!0})}),onPointerDownOutside:e=>e.preventDefault(),onInteractOutside:e=>e.preventDefault(),children:r})})});zl.displayName=Il;var Bl=`AlertDialogTitle`,Vl=Z.forwardRef((e,t)=>{let{__scopeAlertDialog:n,...r}=e,i=Ol(n);return(0,Q.jsx)(Ua,{...i,...r,ref:t})});Vl.displayName=Bl;var Hl=`AlertDialogDescription`,Ul=Z.forwardRef((e,t)=>{let{__scopeAlertDialog:n,...r}=e,i=Ol(n);return(0,Q.jsx)(Ra,{...i,...r,ref:t})});Ul.displayName=Hl;var Wl=`AlertDialogAction`,Gl=Z.forwardRef((e,t)=>{let{__scopeAlertDialog:n,...r}=e,i=Ol(n);return(0,Q.jsx)(Ba,{...i,...r,ref:t})});Gl.displayName=Wl;var Kl=`AlertDialogCancel`,ql=Z.forwardRef((e,t)=>{let{__scopeAlertDialog:n,...r}=e,{cancelRef:i}=Rl(Kl,n),a=Ol(n),o=Rr(t,i);return(0,Q.jsx)(Ba,{...a,...r,ref:o})});ql.displayName=Kl;var Jl=kl,Yl=Nl,Xl=Fl,Zl=zl,Ql=Gl,$l=ql,eu=Vl,tu=Ul,[nu,ru]=Ma(`Tooltip`,[Ga]),iu=Ga(),au=`TooltipProvider`,ou=700,su=`tooltip.open`,[cu,lu]=nu(au),uu=e=>{let{__scopeTooltip:t,delayDuration:n=ou,skipDelayDuration:r=300,disableHoverableContent:i=!1,children:a}=e,o=Z.useRef(!0),s=Z.useRef(!1),c=Z.useRef(0);return Z.useEffect(()=>{let e=c.current;return()=>window.clearTimeout(e)},[]),(0,Q.jsx)(cu,{scope:t,isOpenDelayedRef:o,delayDuration:n,onOpen:Z.useCallback(()=>{r<=0||(window.clearTimeout(c.current),o.current=!1)},[r]),onClose:Z.useCallback(()=>{r<=0||(window.clearTimeout(c.current),c.current=window.setTimeout(()=>o.current=!0,r))},[r]),isPointerInTransitRef:s,onPointerInTransitChange:Z.useCallback(e=>{s.current=e},[]),disableHoverableContent:i,children:a})};uu.displayName=au;var du=`Tooltip`,[fu,pu]=nu(du),mu=e=>{let{__scopeTooltip:t,children:n,open:r,defaultOpen:i,onOpenChange:a,disableHoverableContent:o,delayDuration:s}=e,c=lu(du,e.__scopeTooltip),l=iu(t),[u,d]=Z.useState(null),f=ja(),p=Z.useRef(0),m=o??c.disableHoverableContent,h=s??c.delayDuration,g=Z.useRef(!1),[_,v]=Oa({prop:r,defaultProp:i??!1,onChange:e=>{e?(c.onOpen(),document.dispatchEvent(new CustomEvent(su))):c.onClose(),a?.(e)},caller:du}),y=Z.useMemo(()=>_?g.current?`delayed-open`:`instant-open`:`closed`,[_]),b=Z.useCallback(()=>{window.clearTimeout(p.current),p.current=0,g.current=!1,v(!0)},[v]),x=Z.useCallback(()=>{window.clearTimeout(p.current),p.current=0,v(!1)},[v]),S=Z.useCallback(()=>{window.clearTimeout(p.current),p.current=window.setTimeout(()=>{g.current=!0,v(!0),p.current=0},h)},[h,v]);return Z.useEffect(()=>()=>{p.current&&=(window.clearTimeout(p.current),0)},[]),(0,Q.jsx)(Ka,{...l,children:(0,Q.jsx)(fu,{scope:t,contentId:f,open:_,stateAttribute:y,trigger:u,onTriggerChange:d,onTriggerEnter:Z.useCallback(()=>{c.isOpenDelayedRef.current?S():b()},[c.isOpenDelayedRef,S,b]),onTriggerLeave:Z.useCallback(()=>{m?x():(window.clearTimeout(p.current),p.current=0)},[x,m]),onOpen:b,onClose:x,disableHoverableContent:m,children:n})})};mu.displayName=du;var hu=`TooltipTrigger`,gu=Z.forwardRef((e,t)=>{let{__scopeTooltip:n,...r}=e,i=pu(hu,n),a=lu(hu,n),o=iu(n),s=Rr(t,Z.useRef(null),i.onTriggerChange),c=Z.useRef(!1),l=Z.useRef(!1),u=Z.useCallback(()=>c.current=!1,[]);return Z.useEffect(()=>()=>document.removeEventListener(`pointerup`,u),[u]),(0,Q.jsx)(Ya,{asChild:!0,...o,children:(0,Q.jsx)(ka.button,{"aria-describedby":i.open?i.contentId:void 0,"data-state":i.stateAttribute,...r,ref:s,onPointerMove:Pa(e.onPointerMove,e=>{e.pointerType!==`touch`&&!l.current&&!a.isPointerInTransitRef.current&&(i.onTriggerEnter(),l.current=!0)}),onPointerLeave:Pa(e.onPointerLeave,()=>{i.onTriggerLeave(),l.current=!1}),onPointerDown:Pa(e.onPointerDown,()=>{i.open&&i.onClose(),c.current=!0,document.addEventListener(`pointerup`,u,{once:!0})}),onFocus:Pa(e.onFocus,()=>{c.current||i.onOpen()}),onBlur:Pa(e.onBlur,i.onClose),onClick:Pa(e.onClick,i.onClose)})})});gu.displayName=hu;var _u=`TooltipPortal`,[vu,yu]=nu(_u,{forceMount:void 0}),bu=e=>{let{__scopeTooltip:t,forceMount:n,children:r,container:i}=e,a=pu(_u,t);return(0,Q.jsx)(vu,{scope:t,forceMount:n,children:(0,Q.jsx)(Fa,{present:n||a.open,children:(0,Q.jsx)(Aa,{asChild:!0,container:i,children:r})})})};bu.displayName=_u;var xu=`TooltipContent`,Su=Z.forwardRef((e,t)=>{let n=yu(xu,e.__scopeTooltip),{forceMount:r=n.forceMount,side:i=`top`,...a}=e,o=pu(xu,e.__scopeTooltip);return(0,Q.jsx)(Fa,{present:r||o.open,children:o.disableHoverableContent?(0,Q.jsx)(Du,{side:i,...a,ref:t}):(0,Q.jsx)(Cu,{side:i,...a,ref:t})})}),Cu=Z.forwardRef((e,t)=>{let n=pu(xu,e.__scopeTooltip),r=lu(xu,e.__scopeTooltip),i=Z.useRef(null),a=Rr(t,i),[o,s]=Z.useState(null),{trigger:c,onClose:l}=n,u=i.current,{onPointerInTransitChange:d}=r,f=Z.useCallback(()=>{s(null),d(!1)},[d]),p=Z.useCallback((e,t)=>{let n=e.currentTarget,r={x:e.clientX,y:e.clientY},i=ju(r,Au(r,n.getBoundingClientRect())),a=Mu(t.getBoundingClientRect()),o=Pu([...i,...a]);s(o),d(!0)},[d]);return Z.useEffect(()=>()=>f(),[f]),Z.useEffect(()=>{if(c&&u){let e=e=>p(e,u),t=e=>p(e,c);return c.addEventListener(`pointerleave`,e),u.addEventListener(`pointerleave`,t),()=>{c.removeEventListener(`pointerleave`,e),u.removeEventListener(`pointerleave`,t)}}},[c,u,p,f]),Z.useEffect(()=>{if(o){let e=e=>{let t=e.target,n={x:e.clientX,y:e.clientY},r=c?.contains(t)||u?.contains(t),i=!Nu(n,o);r?f():i&&(f(),l())};return document.addEventListener(`pointermove`,e),()=>document.removeEventListener(`pointermove`,e)}},[c,u,o,l,f]),(0,Q.jsx)(Du,{...e,ref:a})}),[wu,Tu]=nu(du,{isInside:!1}),Eu=Br(`TooltipContent`),Du=Z.forwardRef((e,t)=>{let{__scopeTooltip:n,children:r,"aria-label":i,onEscapeKeyDown:a,onPointerDownOutside:o,...s}=e,c=pu(xu,n),l=iu(n),{onClose:u}=c;return Z.useEffect(()=>(document.addEventListener(su,u),()=>document.removeEventListener(su,u)),[u]),Z.useEffect(()=>{if(c.trigger){let e=e=>{e.target instanceof Node&&e.target.contains(c.trigger)&&u()};return window.addEventListener(`scroll`,e,{capture:!0}),()=>window.removeEventListener(`scroll`,e,{capture:!0})}},[c.trigger,u]),(0,Q.jsx)(Na,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:a,onPointerDownOutside:o,onFocusOutside:e=>e.preventDefault(),onDismiss:u,children:(0,Q.jsxs)(Ja,{"data-state":c.stateAttribute,...l,...s,ref:t,style:{...s.style,"--radix-tooltip-content-transform-origin":`var(--radix-popper-transform-origin)`,"--radix-tooltip-content-available-width":`var(--radix-popper-available-width)`,"--radix-tooltip-content-available-height":`var(--radix-popper-available-height)`,"--radix-tooltip-trigger-width":`var(--radix-popper-anchor-width)`,"--radix-tooltip-trigger-height":`var(--radix-popper-anchor-height)`},children:[(0,Q.jsx)(Eu,{children:r}),(0,Q.jsx)(wu,{scope:n,isInside:!0,children:(0,Q.jsx)(wl,{id:c.contentId,role:`tooltip`,children:i||r})})]})})});Su.displayName=xu;var Ou=`TooltipArrow`,ku=Z.forwardRef((e,t)=>{let{__scopeTooltip:n,...r}=e,i=iu(n);return Tu(Ou,n).isInside?null:(0,Q.jsx)(qa,{...i,...r,ref:t})});ku.displayName=Ou;function Au(e,t){let n=Math.abs(t.top-e.y),r=Math.abs(t.bottom-e.y),i=Math.abs(t.right-e.x),a=Math.abs(t.left-e.x);switch(Math.min(n,r,i,a)){case a:return`left`;case i:return`right`;case n:return`top`;case r:return`bottom`;default:throw Error(`unreachable`)}}function ju(e,t,n=5){let r=[];switch(t){case`top`:r.push({x:e.x-n,y:e.y+n},{x:e.x+n,y:e.y+n});break;case`bottom`:r.push({x:e.x-n,y:e.y-n},{x:e.x+n,y:e.y-n});break;case`left`:r.push({x:e.x+n,y:e.y-n},{x:e.x+n,y:e.y+n});break;case`right`:r.push({x:e.x-n,y:e.y-n},{x:e.x-n,y:e.y+n});break}return r}function Mu(e){let{top:t,right:n,bottom:r,left:i}=e;return[{x:i,y:t},{x:n,y:t},{x:n,y:r},{x:i,y:r}]}function Nu(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 Pu(e){let t=e.slice();return t.sort((e,t)=>e.x<t.x?-1:e.x>t.x?1:e.y<t.y?-1:+(e.y>t.y)),Fu(t)}function Fu(e){if(e.length<=1)return e.slice();let t=[];for(let n=0;n<e.length;n++){let r=e[n];for(;t.length>=2;){let e=t[t.length-1],n=t[t.length-2];if((e.x-n.x)*(r.y-n.y)>=(e.y-n.y)*(r.x-n.x))t.pop();else break}t.push(r)}t.pop();let n=[];for(let t=e.length-1;t>=0;t--){let r=e[t];for(;n.length>=2;){let e=n[n.length-1],t=n[n.length-2];if((e.x-t.x)*(r.y-t.y)>=(e.y-t.y)*(r.x-t.x))n.pop();else break}n.push(r)}return n.pop(),t.length===1&&n.length===1&&t[0].x===n[0].x&&t[0].y===n[0].y?t:t.concat(n)}var Iu=uu,Lu=mu,Ru=gu,zu=bu,Bu=Su,Vu=ku;function Hu({open:e,onOpenChange:t}){let[n,r]=(0,Z.useState)(null),[i,a]=(0,Z.useState)(null),o=A(),s=be(),c=Kn(),l=new Set((o.data?.projects??[]).map(e=>e.root)),u=e=>{r(e),a(null),s.reset()},d=_a(n,i);return(0,Q.jsx)(So,{open:e,onOpenChange:t,children:(0,Q.jsxs)(bo,{"data-slot":`add-project-dialog`,className:`sm:max-w-lg`,children:[(0,Q.jsxs)(yo,{children:[(0,Q.jsx)(xo,{children:`Open local folder`}),(0,Q.jsx)(_o,{children:`Pick the folder Squawk should run in. Git repos are marked; any folder works.`})]}),(0,Q.jsxs)(vo,{className:`space-y-4`,children:[(0,Q.jsx)(va,{path:n,selected:i,onSelect:a,onEnter:u,emptyHint:`No subfolders here — “Add project” registers this folder.`,decorate:e=>(0,Q.jsxs)(Q.Fragment,{children:[e.isRepo?(0,Q.jsx)(ho,{variant:`outline`,className:`shrink-0 text-[12px]`,children:`git`}):null,l.has(e.path)?(0,Q.jsx)(ho,{variant:`ghost`,className:`shrink-0 text-[12px] text-muted-foreground`,children:`already added`}):null]})}),s.isError?(0,Q.jsx)(`p`,{"data-slot":`add-project-error`,className:`min-w-0 break-words text-[13px] text-danger`,children:s.error instanceof Error?s.error.message:`could not add that folder`}):null]}),(0,Q.jsxs)(go,{className:`min-w-0 sm:items-center sm:justify-between`,children:[(0,Q.jsx)(`span`,{"data-slot":`add-project-target`,className:`min-w-0 truncate font-mono text-xs text-muted-foreground`,title:d??void 0,children:d??``}),(0,Q.jsxs)(`span`,{className:`flex shrink-0 gap-2`,children:[(0,Q.jsx)(Y,{variant:`outline`,onClick:()=>t(!1),children:`Cancel`}),(0,Q.jsx)(Y,{"data-slot":`add-project-confirm`,disabled:d===null||s.isPending,onClick:()=>{d===null||s.isPending||s.mutate(d,{onSuccess:({project:e})=>{t(!1),c(`/p/${encodeURIComponent(e.id)}/`)}})},children:s.isPending?`Adding…`:`Add project`})]})]})]})})}function Uu(e,t){let[n,r]=(0,Z.useState)(null),i=(0,Z.useMemo)(()=>`${e}${Math.random().toString(36).slice(2)}-${Date.now().toString(36)}`,[]),a=(0,Z.useRef)(i);return a.current=i,(0,Z.useEffect)(()=>Fr((e,t)=>{if(e!==`checkout-progress`)return;let n=t;n?.checkoutId===a.current&&(n.phase===`cloning`&&n.line?r(n.line):n.phase!==`cloning`&&r(null))}),[]),(0,Z.useEffect)(()=>hn(async e=>{if(!t)return;let n=await Xt(i,{signal:e}).catch(()=>null);if(!n)return;let{progress:o}=n;e.aborted||o?.checkoutId!==a.current||r(o?.phase===`cloning`?o.line??null:null)}),[t,i]),{checkoutId:i,progress:n,setProgress:r}}function Wu({className:e,type:t,...n}){return(0,Q.jsx)(`input`,{type:t,"data-slot":`input`,className:q(`h-11 w-full min-w-0 rounded-md border border-control-border bg-[var(--task-brand-bg)] px-3 py-1 text-base shadow-none transition-[color,box-shadow] outline-hidden selection:bg-accent-strong selection:text-accent-strong-foreground file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-soft-foreground disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm`,`focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50`,`aria-invalid:border-destructive aria-invalid:ring-destructive/20`,e),...n})}function Gu(e){return e instanceof Error?e.message.match(/https:\/\/github\.com\/orgs\/[A-Za-z0-9._-]+\/sso\?authorization_request=[A-Za-z0-9._~-]+(?![^\s'"<>])/)?.[0]??null:null}function Ku({open:e,onOpenChange:t}){let[n,r]=(0,Z.useState)(``),[i,a]=(0,Z.useState)(``),[o,s]=(0,Z.useState)(!1),c=(0,Z.useRef)(!1),l=A(),u=x(),{mutate:d,isPending:f}=u,p=Kn(),m=Gu(u.error),{checkoutId:h,progress:g,setProgress:_}=Uu(`co-`,f),v=(0,Z.useMemo)(()=>{let e=n.trim().replace(/\/+$/,``).replace(/\.git$/,``).split(`/`).pop()??``;return e.includes(`:`)?e.split(`:`).pop()??``:e},[n]),y=i.trim()===``?v:i.trim(),b=l.data?.projectsDir??``,S=y===``?``:`${b.replace(/\/+$/,``)}/${y}`,C=(0,Z.useCallback)(()=>{n.trim()===``||f||(c.current=!1,s(!1),_(null),d({url:n.trim(),checkoutId:h,...i.trim()===``?{}:{name:i.trim()}},{onSuccess:({project:e})=>{t(!1),p(`/p/${encodeURIComponent(e.id)}/`)}}))},[d,f,h,i,p,t,n]);return(0,Z.useEffect)(()=>{if(!o)return;let e=()=>{c.current&&(c.current=!1,s(!1),C())},t=()=>{document.visibilityState===`visible`&&e()};return window.addEventListener(`focus`,e),document.addEventListener(`visibilitychange`,t),()=>{window.removeEventListener(`focus`,e),document.removeEventListener(`visibilitychange`,t)}},[o,C]),(0,Q.jsx)(So,{open:e,onOpenChange:e=>u.isPending?void 0:t(e),children:(0,Q.jsxs)(bo,{"data-slot":`clone-project-dialog`,className:`min-w-0 max-h-[calc(100dvh-2rem)] overflow-x-hidden overflow-y-auto sm:max-w-lg`,children:[(0,Q.jsxs)(yo,{children:[(0,Q.jsx)(xo,{children:`Clone from GitHub`}),(0,Q.jsxs)(_o,{children:[`Squawk clones with `,(0,Q.jsx)(`code`,{children:`gh`}),` into your checkout root and adds the result as a project.`]})]}),(0,Q.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,Q.jsx)(Ir,{htmlFor:`clone-url`,children:`Repository`}),(0,Q.jsx)(Wu,{id:`clone-url`,"data-slot":`clone-url`,autoFocus:!0,placeholder:`owner/repo or https://github.com/owner/repo`,value:n,disabled:u.isPending,onChange:e=>r(e.target.value),onKeyDown:e=>{e.key===`Enter`&&C()}})]}),(0,Q.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,Q.jsx)(Ir,{htmlFor:`clone-name`,children:`Folder name`}),(0,Q.jsx)(Wu,{id:`clone-name`,"data-slot":`clone-name`,placeholder:v===``?`repo`:v,value:i,disabled:u.isPending,onChange:e=>a(e.target.value)}),(0,Q.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1`,children:[(0,Q.jsx)(`p`,{"data-slot":`clone-target`,className:`min-w-0 flex-1 truncate font-mono text-xs text-soft-foreground`,title:S,children:S}),u.isPending?(0,Q.jsx)(Y,{"data-slot":`clone-root-settings`,variant:`ghost`,size:`icon-sm`,"aria-label":`Edit checkout root`,title:`Edit checkout root`,disabled:!0,children:(0,Q.jsx)(Ei,{className:`size-3.5`,"aria-hidden":`true`})}):(0,Q.jsx)(Y,{asChild:!0,variant:`ghost`,size:`icon-sm`,children:(0,Q.jsx)(G,{to:`/settings/global/projects`,"data-slot":`clone-root-settings`,"aria-label":`Edit checkout root`,title:`Edit checkout root`,children:(0,Q.jsx)(Ei,{className:`size-3.5`,"aria-hidden":`true`})})})]})]}),u.isPending?(0,Q.jsx)(`p`,{"data-slot":`clone-progress`,className:`truncate font-mono text-xs text-muted-foreground`,children:g??`Starting the clone…`}):null,u.isError?(0,Q.jsx)(`div`,{"data-slot":`clone-error`,className:`grid min-w-0 gap-1.5 text-[13px] text-danger`,children:m?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`p`,{children:`GitHub requires SAML authorization for this organization.`}),(0,Q.jsxs)(`p`,{children:[(0,Q.jsx)(`a`,{"data-slot":`clone-sso-link`,className:`inline-flex min-h-11 items-center font-medium underline underline-offset-2`,href:m,target:`_blank`,rel:`noreferrer`,onClick:()=>{c.current=!0,s(!0)},children:`Authorize this GitHub organization`}),o?` — return here after authorizing, or choose Retry clone.`:` — return to this tab to retry, or choose Retry clone.`]}),(0,Q.jsxs)(`details`,{className:`min-w-0`,children:[(0,Q.jsx)(`summary`,{className:`min-h-11 content-center`,children:`Error details`}),(0,Q.jsx)(`p`,{className:`whitespace-pre-wrap break-all`,children:u.error instanceof Error?u.error.message:null})]})]}):(0,Q.jsx)(`p`,{className:`min-w-0 whitespace-pre-wrap break-all`,children:u.error instanceof Error?u.error.message:`could not clone that repository`})}):null,(0,Q.jsxs)(go,{children:[(0,Q.jsx)(Y,{variant:`outline`,disabled:u.isPending,onClick:()=>t(!1),children:`Cancel`}),(0,Q.jsx)(Y,{"data-slot":`clone-confirm`,disabled:n.trim()===``||y===``||u.isPending,onClick:C,children:u.isPending?`Cloning…`:u.isError?`Retry clone`:`Clone`})]})]})})}var qu=[{slug:`github/codespaces-nextjs`,label:`Next.js`,description:`Minimal Next.js app (GitHub)`},{slug:`vercel/chatbot`,label:`Next.js AI chatbot`,description:`Full-featured AI chat app (Vercel)`},{slug:`vercel/nextjs-postgres-nextauth-tailwindcss-template`,label:`Next.js admin dashboard`,description:`Postgres, Auth.js and Tailwind (Vercel)`},{slug:`github/codespaces-react`,label:`React + Vite`,description:`React single-page app (GitHub)`},{slug:`antfu-collective/vitesse`,label:`Vue + Vite`,description:`Opinionated Vue starter (Vitesse)`},{slug:`nuxt-ui-templates/starter-vue`,label:`Vue + Nuxt UI`,description:`Vue + Vite with Nuxt UI (Nuxt)`},{slug:`mugnavo/cove`,label:`Vite+`,description:`TanStack Start on Vite+ (vp), Better Auth`},{slug:`w3cj/hono-open-api-starter`,label:`Hono`,description:`Type-safe JSON API with OpenAPI docs`},{slug:`github/codespaces-express`,label:`Express`,description:`Node.js web server (GitHub)`},{slug:`andrewmcodes/obsidian-beginner-vault-template`,label:`Obsidian vault`,description:`Your own knowledge base in Markdown`},{slug:`chibat/chrome-extension-typescript-starter`,label:`Chrome extension`,description:`TypeScript extension starter`},{slug:`actions/typescript-action`,label:`GitHub Action`,description:`TypeScript action with tests (GitHub)`},{slug:`microsoft/python-package-template`,label:`Python package`,description:`Packaging, tests and CI (Microsoft)`},{slug:`github/codespaces-flask`,label:`Flask`,description:`Python web app (GitHub)`},{slug:`github/codespaces-django`,label:`Django`,description:`Python web framework (GitHub)`},{slug:`github/codespaces-rails`,label:`Ruby on Rails`,description:`Rails app (GitHub)`},{slug:`github/codespaces-jupyter`,label:`Jupyter notebooks`,description:`Data science and ML (GitHub)`}];function Ju(e){let t=e.trim().toLowerCase();return t===``||qu.some(e=>e.slug.toLowerCase()===t)?qu:qu.filter(e=>[e.label,e.slug,e.description].some(e=>e.toLowerCase().includes(t)))}function Yu({value:e,onChange:t,disabled:n,id:r}){let i=(0,Z.useId)(),a=Ju(e),[o,s]=(0,Z.useState)(-1),c=(0,Z.useRef)(null);(0,Z.useEffect)(()=>s(-1),[e]),(0,Z.useEffect)(()=>{o<0||c.current?.querySelector(`[data-index="${o}"]`)?.scrollIntoView?.({block:`nearest`})},[o]);let l=e=>`${i}-option-${e}`;return(0,Q.jsxs)(`div`,{className:`grid min-w-0 gap-1.5`,children:[(0,Q.jsx)(Wu,{id:r,"data-slot":`create-project-template`,role:`combobox`,"aria-expanded":`true`,"aria-controls":i,"aria-autocomplete":`list`,"aria-activedescendant":o>=0?l(o):void 0,autoComplete:`off`,spellCheck:!1,placeholder:`owner/repo or https://github.com/owner/repo`,value:e,disabled:n,onChange:e=>t(e.target.value),onKeyDown:e=>{if(e.key===`ArrowDown`||e.key===`ArrowUp`){if(e.preventDefault(),a.length===0)return;let t=e.key===`ArrowDown`;s(e=>e<0?t?0:a.length-1:(e+(t?1:-1)+a.length)%a.length)}else if(e.key===`Enter`&&o>=0){e.preventDefault(),e.stopPropagation();let n=a[o];n&&t(n.slug)}}}),(0,Q.jsx)(`ul`,{ref:c,id:i,role:`listbox`,"aria-label":`Suggested templates`,"data-slot":`create-project-template-list`,className:`max-h-48 min-h-0 overflow-y-auto overscroll-contain rounded-md border border-border`,children:a.length===0?(0,Q.jsx)(`li`,{className:`px-3 py-2 text-xs text-muted-foreground`,role:`presentation`,children:`No suggestion matches — any GitHub template repository works.`}):a.map((r,i)=>{let a=r.slug.toLowerCase()===e.trim().toLowerCase();return(0,Q.jsxs)(`li`,{id:l(i),role:`option`,"aria-selected":a,"data-index":i,"data-value":r.slug,"data-slot":`create-project-template-option`,onMouseDown:e=>e.preventDefault(),onClick:()=>{n||t(r.slug)},className:q(`grid min-h-11 cursor-pointer content-center gap-0.5 px-3 py-1.5 text-start`,`pointer-hover:hover:bg-accent`,i===o&&`bg-accent`,a&&`font-medium`),children:[(0,Q.jsxs)(`span`,{className:`truncate text-[13px]`,children:[r.label,` `,(0,Q.jsx)(`span`,{className:`font-mono text-xs text-soft-foreground`,children:r.slug})]}),(0,Q.jsx)(`span`,{className:`truncate text-xs text-muted-foreground`,children:r.description})]},r.slug)})})]})}function Xu({className:e,...t}){return(0,Q.jsx)(`div`,{"data-slot":`skeleton`,className:q(`animate-pulse motion-reduce:animate-none rounded-md bg-accent`,e),...t})}function Zu(e){return{available:e.data?.available?e.data.owners:null,unavailableReason:e.isError?`GitHub is unavailable: ${e.error instanceof Error?e.error.message:`could not ask gh`}`:e.data&&!e.data.available?e.data.reason:null}}function Qu(e,t){return e&&t!==null&&t.length>0}function $u(e,t){return e??t?.[0]?.login??null}function ed(e){return(e.data?.projectsDir??``).replace(/\/+$/,``)}function td({nameValid:e,isPending:t,created:n,github:r,chosenOwner:i,effectiveStart:a,template:o}){return e&&!t&&n===null&&(!r||i!==null&&(a===`empty`||o.trim()!==``))}function nd({trimmed:e,checkoutId:t,github:n,chosenOwner:r,effectiveStart:i,template:a}){return{name:e,checkoutId:t,...n&&r?{github:{owner:r,...i===`template`?{template:a.trim()}:{}}}:{}}}function rd({created:e}){return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(wi,{"aria-hidden":`true`,className:`mbs-0.5 size-5 shrink-0 text-semantic-amber`}),(0,Q.jsxs)(`div`,{className:`grid min-w-0 gap-2`,children:[(0,Q.jsx)(`p`,{className:`font-medium`,children:`The project was created, but its GitHub repository is not finished.`}),(0,Q.jsx)(`p`,{className:`min-w-0 whitespace-pre-wrap break-words font-mono text-xs`,children:e.warning})]})]})}function id({fieldId:e,name:t,setName:n,trimmed:r,nameValid:i,projectsDir:a,isPending:o,create:s}){let c=`${e}-name-hint`;return(0,Q.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,Q.jsx)(Ir,{htmlFor:`${e}-name`,children:`Name`}),(0,Q.jsx)(Wu,{id:`${e}-name`,"data-slot":`create-project-name`,autoFocus:!0,autoComplete:`off`,spellCheck:!1,placeholder:`my-project`,value:t,disabled:o,"aria-invalid":r!==``&&!i,"aria-describedby":r!==``&&!i?c:void 0,onChange:e=>n(e.target.value.replace(/\s/g,`-`)),onKeyDown:e=>{e.key===`Enter`&&s()}}),r!==``&&!i?(0,Q.jsx)(`p`,{id:c,"data-slot":`create-project-name-hint`,className:`text-xs text-danger`,children:`Use letters, digits, “.”, “-” and “_” only, starting with a letter or digit — it names the folder and the repository.`}):null,(0,Q.jsx)(`p`,{"data-slot":`create-project-path`,className:`min-w-0 truncate font-mono text-xs text-soft-foreground`,title:`${a}/${r}`,children:r===``?`${a}/…`:`${a}/${r}`})]})}function ad({fieldId:e,github:t,setGithubOn:n,isPending:r,available:i}){return(0,Q.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,Q.jsx)(mo,{id:`${e}-github`,"data-slot":`create-project-github`,checked:t,disabled:r||i===null||i.length===0,onCheckedChange:n,className:`mbs-0.5`}),(0,Q.jsxs)(`div`,{className:`grid min-w-0 gap-0.5`,children:[(0,Q.jsx)(Ir,{htmlFor:`${e}-github`,children:`Also create a private GitHub repository`}),(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Under the account you choose. You can change its visibility on GitHub later.`})]})]})}function od({fieldId:e,effectiveStart:t,setStart:n,isPending:r,github:i,template:a,setTemplate:o}){return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`fieldset`,{className:`grid gap-2`,disabled:r,children:[(0,Q.jsx)(`legend`,{className:`mbe-2 text-sm font-medium`,children:`Start with`}),(0,Q.jsx)(ud,{slot:`create-project-start-empty`,name:`${e}-start`,checked:t===`empty`,disabled:r,onChange:()=>n(`empty`),title:`Empty repository`,detail:`One empty first commit, no files.`}),(0,Q.jsx)(ud,{slot:`create-project-start-template`,name:`${e}-start`,checked:t===`template`,disabled:r||!i,onChange:()=>n(`template`),title:`From a template`,detail:i?`GitHub generates the repository from a template.`:`Needs the GitHub repository.`})]}),t===`template`?(0,Q.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,Q.jsx)(Ir,{htmlFor:`${e}-template`,children:`Template`}),(0,Q.jsx)(Yu,{id:`${e}-template`,value:a,onChange:o,disabled:r})]}):null]})}function sd({isPending:e,progress:t,failed:n,error:r}){return(0,Q.jsxs)(Q.Fragment,{children:[e?(0,Q.jsx)(`p`,{"data-slot":`create-project-progress`,className:`flex-none truncate font-mono text-xs text-muted-foreground`,children:t??`Starting…`}):null,n?(0,Q.jsx)(`p`,{"data-slot":`create-project-error`,role:`alert`,className:`flex-none min-w-0 whitespace-pre-wrap break-words text-[13px] text-danger`,children:r instanceof Error?r.message:`could not create the project`}):null]})}function cd({created:e,goToProject:t,isPending:n,onCancel:r,ready:i,onCreate:a,failed:o}){return(0,Q.jsx)(go,{className:`flex-none`,children:e?(0,Q.jsx)(Y,{"data-slot":`create-project-open`,onClick:t,children:`Go to project`}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Y,{variant:`outline`,disabled:n,onClick:r,children:`Cancel`}),(0,Q.jsx)(Y,{"data-slot":`create-project-submit`,disabled:!i,onClick:a,children:n?`Creating…`:o?`Try again`:`Create project`})]})})}function ld({open:e,onOpenChange:t}){let[n,r]=(0,Z.useState)(``),[i,a]=(0,Z.useState)(!1),[o,s]=(0,Z.useState)(null),[c,l]=(0,Z.useState)(`empty`),[u,d]=(0,Z.useState)(``),[f,p]=(0,Z.useState)(null),m=A(),h=Ae({enabled:e}),_=g(),{mutate:v,isPending:y}=_,b=Kn(),x=(0,Z.useId)(),S=(0,Z.useRef)(!1),{checkoutId:C,progress:w,setProgress:T}=Uu(`np-`,y),{available:E,unavailableReason:D}=Zu(h),O=Qu(i,E),k=$u(o,E),j=O?c:`empty`,M=n.trim(),N=Pt.test(M),ee=ed(m),P=td({nameValid:N,isPending:y,created:f,github:O,chosenOwner:k,effectiveStart:j,template:u}),F=(0,Z.useCallback)(()=>{!P||S.current||(S.current=!0,T(null),v(nd({trimmed:M,checkoutId:C,github:O,chosenOwner:k,effectiveStart:j,template:u}),{onSettled:()=>{S.current=!1},onSuccess:({project:e,warning:n})=>{if(n){p({projectId:e.id,warning:n});return}t(!1),b(`/p/${encodeURIComponent(e.id)}/`)}}))},[P,v,M,C,O,k,j,u,t,b]);return(0,Q.jsx)(So,{open:e,onOpenChange:e=>y?void 0:t(e),children:(0,Q.jsxs)(bo,{"data-slot":`create-project-dialog`,className:`flex min-w-0 flex-col overflow-y-clip overflow-x-clip sm:max-w-2xl`,children:[(0,Q.jsxs)(yo,{className:`flex-none`,children:[(0,Q.jsx)(xo,{children:`New project`}),(0,Q.jsx)(_o,{children:`Squawk creates a git repository with one empty commit in your checkout root and adds it as a project.`})]}),f?(0,Q.jsx)(`div`,{"data-slot":`create-project-warning`,role:`status`,className:`flex min-h-0 flex-1 gap-3 overflow-y-auto overscroll-contain rounded-md border border-border bg-muted p-4 text-[13px]`,children:(0,Q.jsx)(rd,{created:f})}):(0,Q.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-wrap gap-6 overflow-y-auto overscroll-contain`,children:[(0,Q.jsxs)(`div`,{className:`grid min-w-[50%] grow-[999] basis-0 content-start gap-5`,children:[(0,Q.jsx)(id,{fieldId:x,name:n,setName:r,trimmed:M,nameValid:N,projectsDir:ee,isPending:y,create:F}),(0,Q.jsx)(ad,{fieldId:x,github:O,setGithubOn:a,isPending:y,available:E}),(0,Q.jsx)(od,{fieldId:x,effectiveStart:j,setStart:l,isPending:y,github:O,template:u,setTemplate:d})]}),(0,Q.jsx)(dd,{owners:E,unavailableReason:D,enabled:O&&!y,chosen:k,onChoose:s,groupName:`${x}-owner`})]}),(0,Q.jsx)(sd,{isPending:y,progress:w,failed:_.isError,error:_.error}),(0,Q.jsx)(cd,{created:f,goToProject:()=>{f&&(t(!1),b(`/p/${encodeURIComponent(f.projectId)}/`))},isPending:y,onCancel:()=>t(!1),ready:P,onCreate:F,failed:_.isError})]})})}function ud({slot:e,name:t,checked:n,disabled:r,onChange:i,title:a,detail:o}){return(0,Q.jsxs)(`label`,{className:q(`flex min-h-11 items-start gap-3 rounded-md border border-border p-3`,`has-[:checked]:border-accent-strong has-[:focus-visible]:outline-2 has-[:focus-visible]:outline-offset-2 has-[:focus-visible]:outline-ring`,r?`cursor-not-allowed opacity-60`:`cursor-pointer`),children:[(0,Q.jsx)(`input`,{type:`radio`,"data-slot":e,name:t,checked:n,disabled:r,onChange:i,className:`mbs-0.5 size-4 accent-[var(--color-accent-strong)]`}),(0,Q.jsxs)(`span`,{className:`grid min-w-0 gap-0.5`,children:[(0,Q.jsx)(`span`,{className:`text-[13px] font-medium`,children:a}),(0,Q.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:o})]})]})}function dd({owners:e,unavailableReason:t,enabled:n,chosen:r,onChoose:i,groupName:a}){return(0,Q.jsxs)(`fieldset`,{"data-slot":`create-project-owners`,disabled:!n,className:`grid min-w-0 grow basis-56 content-start gap-2`,children:[(0,Q.jsx)(`legend`,{className:`mbe-2 text-sm font-medium`,children:`Repository owner`}),t===null?e===null?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Xu,{className:`h-14 w-full`}),(0,Q.jsx)(Xu,{className:`h-14 w-full`})]}):e.map(e=>(0,Q.jsxs)(`label`,{"data-slot":`create-project-owner`,className:q(`flex min-h-11 min-w-0 items-center gap-3 rounded-md border border-border p-2.5`,`has-[:checked]:border-accent-strong has-[:checked]:bg-accent`,`has-[:focus-visible]:outline-2 has-[:focus-visible]:outline-offset-2 has-[:focus-visible]:outline-ring`,n?`cursor-pointer pointer-hover:hover:bg-accent`:`cursor-not-allowed opacity-60`),children:[(0,Q.jsx)(`input`,{type:`radio`,name:a,value:e.login,checked:r===e.login,disabled:!n,onChange:()=>i(e.login),className:`sr-only`}),e.avatarUrl?(0,Q.jsx)(`img`,{src:e.avatarUrl,alt:``,className:`size-8 shrink-0 rounded-full object-cover`}):(0,Q.jsx)(`span`,{"aria-hidden":`true`,className:`grid size-8 shrink-0 place-items-center rounded-full bg-muted text-xs font-medium uppercase`,children:e.login.slice(0,1)}),(0,Q.jsxs)(`span`,{className:`grid min-w-0`,children:[(0,Q.jsx)(`span`,{className:`truncate text-[13px] font-medium`,children:e.login}),(0,Q.jsx)(`span`,{className:`truncate text-xs text-muted-foreground`,children:e.personal?`Personal account`:e.description??`Organization`})]})]},e.login)):(0,Q.jsxs)(`p`,{"data-slot":`create-project-github-unavailable`,className:`rounded-md border border-border bg-muted p-3 text-xs text-muted-foreground break-words`,children:[t,`. Local projects still work.`]})]})}function fd({triggerClassName:e,icon:t=pi,iconClassName:n=`size-4`,side:r,origin:i,label:a,iconFrameClassName:o}={}){let[s,c]=Z.useState(!1),[l,u]=Z.useState(!1),[d,f]=Z.useState(!1),p=o?(0,Q.jsx)(`span`,{"aria-hidden":`true`,className:o,children:(0,Q.jsx)(t,{className:n,"aria-hidden":`true`})}):(0,Q.jsx)(t,{className:n,"aria-hidden":`true`});return(0,Q.jsxs)(oo,{children:[(0,Q.jsx)(ro,{asChild:!0,children:a?(0,Q.jsxs)(`button`,{type:`button`,"aria-label":`Add project`,title:`Add project`,"data-origin":i,className:q(`inline-flex shrink-0 items-center whitespace-nowrap outline-hidden`,e),children:[p,(0,Q.jsx)(`span`,{children:a})]}):(0,Q.jsxs)(Y,{variant:`ghost`,size:`icon`,"aria-label":`Add project`,title:`Add project`,"data-origin":i,className:q(`p-0 text-muted-foreground`,e),children:[p,(0,Q.jsx)(`span`,{className:`sr-only`,children:`Add project`})]})}),(0,Q.jsxs)(io,{align:`start`,...zr({side:r}),className:`w-56`,children:[(0,Q.jsx)(Xa,{className:`text-xs text-soft-foreground`,children:`Add project`}),(0,Q.jsxs)(eo,{"data-slot":`add-project-new`,onSelect:()=>f(!0),children:[(0,Q.jsx)(pi,{"aria-hidden":`true`}),`New project…`]}),(0,Q.jsxs)(eo,{"data-slot":`add-project-local`,onSelect:()=>c(!0),children:[(0,Q.jsx)(ai,{"aria-hidden":`true`}),`Open local folder…`]}),(0,Q.jsxs)(eo,{"data-slot":`add-project-clone`,onSelect:()=>u(!0),children:[(0,Q.jsx)(di,{"aria-hidden":`true`}),`Clone from GitHub…`]})]}),s?(0,Q.jsx)(Hu,{open:!0,onOpenChange:c}):null,l?(0,Q.jsx)(Ku,{open:!0,onOpenChange:u}):null,d?(0,Q.jsx)(ld,{open:!0,onOpenChange:f}):null]})}var pd=`w-[228px] rounded-[10px] border-border bg-sidebar p-[5px] text-foreground shadow-[0_10px_28px_#00000047] motion-reduce:animate-none`,md=`h-8 gap-2.5 rounded-[6px] px-[9px] py-0 text-[13px] focus:bg-sidebar-row-hover focus:text-foreground [&_svg]:size-[15px] [&_svg]:text-soft-foreground focus:[&_svg]:text-foreground max-md:min-h-11`;function hd(){let e=Ao(),t=c(),n=A(),r=n.data?.bootProject??t.data?.bootProject??null,i=e??r,a=n.data?.projects.find(e=>e.id===i),o=r!==null&&i===r?t.data?.repo:void 0,s=a?.root??o?.root;return{health:t,registry:n,projectId:i,project:a,root:s,name:a?.name??s?.split(/[\\/]/).filter(Boolean).at(-1),branch:o?.branch??a?.branch}}function gd({onNavigate:e}={}){let t=(0,Z.useRef)(null),n=(0,Z.useRef)(null),[r,i]=(0,Z.useState)(0),{health:a,registry:o,projectId:s,root:c,name:l,branch:u}=hd(),d=a.data?.capabilities.localHandoff===!0,f=l??(o.isPending?`Loading project…`:`Project unavailable`),p=[d?c:void 0,u].filter(Boolean).join(` · `);return(0,Q.jsxs)(`div`,{"data-slot":`project-header`,className:`flex min-w-0 items-center gap-2.5 px-[14px] pt-[14px] pb-2.5`,children:[(0,Q.jsx)(`span`,{ref:t,"aria-hidden":`true`,"data-slot":`project-header-mark`,className:`flex size-7 shrink-0 items-center justify-center rounded-[7px] border border-soft-foreground bg-sidebar-row-selected text-xs leading-none font-semibold text-foreground`,children:l?b(l):`…`}),(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-px`,children:[(0,Q.jsx)(`div`,{"data-slot":`project-header-name`,className:`truncate text-[14px] font-semibold text-foreground`,title:f,children:f}),(0,Q.jsx)(`div`,{"data-slot":`project-header-detail`,dir:`rtl`,className:`truncate text-left font-mono text-xs text-soft-foreground`,title:p||void 0,children:(0,Q.jsx)(`bdi`,{dir:`ltr`,children:p||(o.isPending?`Loading…`:`Branch unavailable`)})})]}),(0,Q.jsx)(xd,{projectId:s,onNavigate:e,triggerRef:n,triggerClassName:`size-7 max-md:size-11`,align:`start`,alignOffset:r,onOpenChange:e=>{e&&t.current&&n.current&&i(t.current.getBoundingClientRect().left-n.current.getBoundingClientRect().left)}})]})}function _d(e,t,n){let r=e.data?.bootProject??t.data?.bootProject??null,i=e.data?.projects.find(e=>e.id===n),a=r!==null&&n===r?t.data?.repo:void 0;return{bootId:r,project:i,root:i?.root??a?.root}}function vd({marking:e,runs:t,unread:n,projectId:r}){return e||t.isError||t.data===void 0||n.length===0||r===null}function yd({marking:e,runs:t,unread:n}){return e?`Marking…`:t.isError?`Unavailable`:t.data===void 0?`Loading…`:`${n.length} unread`}function bd(e,t){return!e||t?.status===`missing`}function xd({projectId:e,onNavigate:t,triggerRef:n,triggerClassName:r,align:i=`start`,alignOffset:a,side:o,onOpenChange:s}){let l=bl(),u=c(),d=A(),[f,m]=(0,Z.useState)(!1),{bootId:h,project:g,root:_}=_d(d,u,e),y=De(e??`default`,e!==null&&(e!=="default"||h!==null),h!==null&&e===h),b=p(v({projectId:e??`default`,boot:e===h})),x=(0,Z.useRef)(e);x.current=e;let S=u.data?.capabilities.localHandoff===!0,C=(y.data??[]).filter(e=>!No(e)&&mn(e));async function w(){m(!0);let t=0;try{for(let n of C){if(x.current!==e)break;try{await b.mutateAsync(n.id)}catch{t+=1}}t>0&&H(`Could not mark ${t} task${t===1?``:`s`} read. Try again.`,{tone:`danger`})}finally{m(!1)}}async function T(){if(_)try{await navigator.clipboard.writeText(_),H(`Project folder copied`)}catch{H(`Could not copy path: ${_}`,{tone:`danger`})}}return(0,Q.jsxs)(oo,{...zr({onOpenChange:s}),children:[(0,Q.jsx)(ro,{asChild:!0,children:(0,Q.jsx)(`button`,{"data-slot":`project-menu-trigger`,ref:n,type:`button`,"aria-label":`Project menu`,className:q(`flex shrink-0 items-center justify-center rounded-[6px] text-soft-foreground hover:bg-sidebar-row-hover hover:text-foreground focus-visible:outline-2 focus-visible:outline-ring data-[state=open]:bg-sidebar-row-selected data-[state=open]:text-foreground`,r),children:(0,Q.jsx)(Kc,{"aria-hidden":`true`,className:`size-[15px]`})})}),(0,Q.jsxs)(io,{align:i,...zr({alignOffset:a,side:o}),sideOffset:4,className:pd,children:[(0,Q.jsxs)(eo,{className:md,disabled:vd({marking:f,runs:y,unread:C,projectId:e}),onSelect:()=>{w()},children:[(0,Q.jsx)(Ic,{"aria-hidden":`true`}),` Mark all read`,(0,Q.jsx)(`span`,{className:`ml-auto text-xs text-soft-foreground`,children:yd({marking:f,runs:y,unread:C})})]}),(0,Q.jsx)(to,{className:`mx-0`}),S&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Sd,{projectId:e??`default`,disabled:bd(_,g)}),(0,Q.jsxs)(eo,{className:md,disabled:!_,onSelect:()=>{T()},children:[(0,Q.jsx)(Wc,{"aria-hidden":`true`}),` Copy path`]}),(0,Q.jsx)(to,{className:`mx-0`})]}),(0,Q.jsx)(eo,{asChild:!0,className:md,children:(0,Q.jsxs)(X,{to:`/settings`,onClick:t??l,children:[(0,Q.jsx)(ul,{"aria-hidden":`true`}),` Project settings`]})})]})]})}function Sd({disabled:e,projectId:t}){let n=D(),r=je({mutationFn:e=>wt(e,t),onError:e=>H(e.message,{tone:`danger`}),onSuccess:()=>H(`Opening project folder`)}),i=(n.data?.targets??[]).filter(e=>Qi(e.id)===void 0);return(0,Q.jsxs)(so,{children:[(0,Q.jsxs)($a,{className:md,disabled:e||r.isPending,children:[(0,Q.jsx)(ya,{"aria-hidden":`true`}),` Open in`]}),(0,Q.jsx)(no,{children:(0,Q.jsxs)(Qa,{className:pd,children:[i.map(e=>{let t=$i(e);return(0,Q.jsxs)(eo,{className:md,"data-target":e.id,onSelect:()=>r.mutate(e.id),children:[(0,Q.jsx)(t,{"aria-hidden":`true`}),e.label]},e.id)}),i.length===0&&(0,Q.jsx)(eo,{className:md,disabled:!0,children:n.isError?`Apps unavailable`:n.isPending?`Loading apps…`:`No apps available`})]})})]})}var Cd={amber:`text-semantic-amber`,red:`text-semantic-red`,violet:`text-semantic-violet`,green:`text-semantic-green`};function wd({signal:e,known:t,current:n,maxParts:r,slot:i,className:a}){let o=w(e).slice(0,r);return(0,Q.jsx)(`span`,{"data-slot":i,className:q(`flex min-w-0 items-center font-medium`,n?`text-muted-foreground`:`text-soft-foreground`,a),children:t?o.length===0?`idle`:o.map((e,t)=>(0,Q.jsxs)(`span`,{className:`flex items-center gap-x-[inherit]`,children:[t>0?(0,Q.jsx)(`span`,{"aria-hidden":`true`,children:`·`}):null,(0,Q.jsx)(`span`,{"data-tone":e.tone,className:Cd[e.tone],children:e.text})]},e.tone)):`activity unknown`})}function Td({className:e,dot:t,shape:n=`filled`,pulse:r=!1,children:i,...a}){return(0,Q.jsxs)(`span`,{"data-slot":`pill`,className:q(`inline-flex items-center gap-1.5 rounded-full bg-muted px-2.5 py-[3px] text-xs font-medium whitespace-nowrap text-muted-foreground`,e),...a,children:[t?(0,Q.jsx)(Qo,{tone:t,shape:n,pulse:r}):null,i]})}function Ed({state:e,className:t,...n}){let r=At(e);return(0,Q.jsx)(Td,{"data-slot":`host-state-pill`,"data-host-state":e,dot:r.dotTone,shape:r.dotShape,pulse:r.dotPulse,className:t,...n,children:r.label})}function Dd({label:e,hostId:t,className:n}){return(0,Q.jsxs)(Td,{"data-slot":`task-host`,"data-host-id":t,title:e,className:q(`h-[18px] max-w-[140px] shrink-0 gap-1 py-0 text-xs font-medium text-muted-foreground`,n),children:[(0,Q.jsx)(Ta,{className:`size-2.5 shrink-0`,"aria-hidden":`true`}),(0,Q.jsx)(`span`,{className:`truncate`,children:e})]})}function Od({label:e=`Stale`,title:t=`Not live — showing last known tasks`,className:n}){return(0,Q.jsx)(Td,{"data-slot":`host-stale-pill`,dot:`neutral`,shape:`ring`,title:t,className:q(`shrink-0 py-0.5 text-muted-foreground`,n),children:e})}var kd={amber:`bg-pending text-signal-ink-amber`,red:`bg-danger text-signal-ink`,violet:`bg-status-running text-signal-ink`,green:`bg-success text-signal-ink`};function Ad(e,t,n){return e>9&&!(n&&t>1)?24:t===1?20:16}function jd({position:e,segments:t,className:n,compact:r=!1}){let i=t.filter(e=>e.count>0);return i.length===0?null:(0,Q.jsx)(`span`,{"aria-hidden":`true`,"data-slot":`rail-pill-${e}`,className:q(`pointer-events-none absolute -right-[4px] box-border flex h-[19px] overflow-hidden rounded-[10px] border-2 border-background`,e===`top`?`-top-[6px]`:`top-[25px]`,n),children:i.map(({tone:e,count:t})=>(0,Q.jsx)(`span`,{"data-segment":e,"data-count":t,style:{width:Ad(t,i.length,r)},className:q(`flex items-center justify-center text-xs leading-[14px] font-bold tabular-nums`,kd[e]),children:t>9?`9+`:t},e))})}function Md(e){return{top:[{tone:`amber`,count:e?.needsYou??0},{tone:`red`,count:e?.failedUnread??0}],bottom:[{tone:`violet`,count:e?.inMotion??0},{tone:`green`,count:e?.finishedUnread??0}]}}var Nd=`motion-safe:rail-text-in`,Pd=`focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring`;function Fd(e,t,n){if(n===void 0)return{showSignal:!1,signal:void 0,known:!1};if(e===null){if(n===null)return{showSignal:!0,signal:void 0,known:!1};if(!n.local)return{showSignal:!1,signal:void 0,known:!1};let e=n.local.known;return{showSignal:!0,signal:e?n.local.byProject.get(t):void 0,known:e}}let r=n!==null&&n.knownHosts.has(e);return{showSignal:!0,signal:r?n.byHost.get(e)?.get(t):void 0,known:r}}function Id(e,t,n,r){let{showSignal:i,signal:a,known:o}=Fd(e,n.id,r),s=`${n.name} (${t})`;return{showSignal:i,signal:a,known:o,label:i?S(s,a,{unknown:!o}):s,href:Ne(e,n.id),initials:b(n.name),...Md(a)}}function Ld({hostId:e,hostLabel:t,project:n,expanded:r,hostSignals:i}){let{showSignal:a,signal:o,known:s,label:c,href:l,initials:u,top:d,bottom:f}=Id(e,t,n,i),p=`flex size-9 shrink-0 items-center justify-center rounded-[9px] border border-transparent bg-muted text-[12px] leading-none font-semibold text-muted-foreground`;return(0,Q.jsx)(`div`,{"data-slot":`rail-project`,"data-host-id":e??`local`,"data-project-id":n.id,className:r?`relative w-full shrink-0`:`relative flex h-[52px] w-full shrink-0 items-center justify-center`,children:r?(0,Q.jsxs)(`a`,{href:l,"aria-label":c,className:q(`group flex h-[52px] w-full items-center gap-[10px] rounded-[8px] px-[6px] hover:bg-sidebar-row-hover`,Pd),children:[(0,Q.jsxs)(`span`,{"aria-hidden":`true`,"data-slot":`rail-mark`,className:q(`relative`,p),children:[u,a?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(jd,{position:`top`,segments:d,className:`border-background group-hover:border-sidebar-row-hover`}),(0,Q.jsx)(jd,{position:`bottom`,segments:f,className:`border-background group-hover:border-sidebar-row-hover`})]}):null]}),(0,Q.jsxs)(`span`,{className:q(`flex min-w-0 flex-1 flex-col gap-px`,Nd),children:[(0,Q.jsx)(`span`,{"data-slot":`rail-project-name`,className:`truncate text-[13.5px] leading-[18px] font-semibold text-muted-foreground group-hover:text-foreground`,children:n.name}),a?(0,Q.jsx)(wd,{signal:o,known:s,current:!1,maxParts:2,slot:`rail-project-state`,className:`h-4 gap-x-[4px] overflow-hidden text-xs leading-4 whitespace-nowrap`}):null]})]}):(0,Q.jsxs)(`div`,{className:`relative size-9`,children:[(0,Q.jsx)(`a`,{href:l,"aria-label":c,title:c,className:q(p,`size-full hover:text-foreground`,Pd),children:u}),a?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(jd,{position:`top`,segments:d}),(0,Q.jsx)(jd,{position:`bottom`,segments:f})]}):null]})})}function Rd({hostId:e,label:t,active:n,host:r}){let i=r?At(r.state):null,a=r!==void 0&&r.state===`connected`&&r.projects===null,o=r?a?`${t} — Could not load projects`:`${t} — ${i.label}`:t,s=(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Ta,{className:`size-3.5 shrink-0`,"aria-hidden":`true`}),i?(0,Q.jsx)(Qo,{tone:i.dotTone,shape:i.dotShape,pulse:i.dotPulse,className:`absolute right-1 bottom-1 ring-[1.5px] ring-background`}):null,a?(0,Q.jsx)(Bc,{"aria-hidden":`true`,"data-slot":`rail-host-projects-error-icon`,className:`absolute top-0.5 right-0.5 size-3 text-muted-foreground`}):null]}),c=q(`relative flex size-9 shrink-0 items-center justify-center rounded-[8px] border text-soft-foreground hover:bg-sidebar-row-hover hover:text-foreground`,n?`border-soft-foreground bg-sidebar-row-selected text-foreground`:`border-transparent`,Pd);return n?(0,Q.jsx)(G,{to:`/`,"data-slot":`rail-host-header`,"data-host-id":e??`local`,"data-host-state":r?.state,"data-projects-error":a?`true`:void 0,"aria-label":o,title:o,className:c,children:s}):(0,Q.jsx)(`a`,{href:Me(e),"data-slot":`rail-host-header`,"data-host-id":e??`local`,"data-host-state":r?.state,"data-projects-error":a?`true`:void 0,"aria-label":o,title:o,className:c,children:s})}function zd({hostId:e,label:t,active:n,host:r}){let i=(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`span`,{className:q(`min-w-0 flex-1 truncate text-xs font-medium`,n?`text-foreground`:`text-soft-foreground group-hover:text-foreground`),children:t}),r?(0,Q.jsx)(Ed,{state:r.state,className:`shrink-0 px-2 py-px`}):null]}),a=q(`group flex min-h-8 w-full items-center gap-1.5 rounded-[7px] px-1.5 py-1 text-left hover:bg-sidebar-row-hover`,Pd,Nd);return n?(0,Q.jsx)(G,{to:`/`,"data-slot":`rail-host-header`,"data-host-id":e??`local`,"data-host-state":r?.state,className:a,children:i}):(0,Q.jsx)(`a`,{href:Me(e),"data-slot":`rail-host-header`,"data-host-id":e??`local`,"data-host-state":r?.state,className:a,children:i})}function Bd({host:e,expanded:t,hostSignals:n}){return e.state===`connected`?e.projects===null?t?(0,Q.jsx)(`p`,{"data-slot":`rail-host-projects-error`,"data-host-id":e.id,className:q(`px-1.5 py-1 text-xs text-muted-foreground`,Nd),children:`Could not load projects`}):null:e.projects.length===0?t?(0,Q.jsx)(`p`,{"data-slot":`rail-host-empty`,"data-host-id":e.id,className:q(`px-1.5 py-1 text-xs text-soft-foreground`,Nd),children:`No projects`}):null:(0,Q.jsx)(Q.Fragment,{children:e.projects.map(r=>(0,Q.jsx)(Ld,{hostId:e.id,hostLabel:e.label,project:r,expanded:t,hostSignals:n},r.id))}):null}function Vd({warning:e,expanded:t}){return e?t?(0,Q.jsx)(`p`,{"data-slot":`rail-hosts-warning`,role:`alert`,className:q(`mt-1 px-1.5 py-1 text-xs text-muted-foreground`,Nd),children:e}):(0,Q.jsx)(`span`,{"data-slot":`rail-hosts-warning`,role:`status`,"aria-label":e,title:e,className:`mt-1 flex size-9 shrink-0 items-center justify-center rounded-[8px] text-muted-foreground`,children:(0,Q.jsx)(Bc,{className:`size-4`,"aria-hidden":`true`})}):null}function Hd({warning:e}){return e?(0,Q.jsx)(`p`,{"data-slot":`drawer-hosts-warning`,role:`alert`,className:`px-[10px] py-1 text-xs text-muted-foreground`,children:e}):null}function Ud({hostsData:e,expanded:t,activeSection:n}){let r=Be(),i=rt(e.hosts),a=r===null;return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{"data-slot":`rail-host-group`,"data-host-id":`local`,className:q(`flex w-full shrink-0 flex-col gap-0.5`,t?`items-stretch`:`items-center`),children:[t?(0,Q.jsx)(zd,{hostId:null,label:`This server`,active:a}):(0,Q.jsx)(Rd,{hostId:null,label:`This server`,active:a}),a?n:e.localProjects.length>0?e.localProjects.map(n=>(0,Q.jsx)(Ld,{hostId:null,hostLabel:`This server`,project:n,expanded:t,hostSignals:e.hostSignals},n.id)):t?(0,Q.jsx)(`p`,{"data-slot":`rail-host-empty`,"data-host-id":`local`,className:q(`px-1.5 py-1 text-xs text-soft-foreground`,Nd),children:`No projects`}):null]}),i.map(i=>{let a=r===i.id;return(0,Q.jsxs)(`div`,{"data-slot":`rail-host-group`,"data-host-id":i.id,"data-host-state":i.state,className:q(`flex w-full shrink-0 flex-col gap-0.5`,t?`items-stretch`:`items-center`),children:[(0,Q.jsx)(`div`,{"aria-hidden":`true`,className:q(`my-1.5 h-px bg-border`,t?`w-full`:`w-6`)}),t?(0,Q.jsx)(zd,{hostId:i.id,label:i.label,active:a,host:i}):(0,Q.jsx)(Rd,{hostId:i.id,label:i.label,active:a,host:i}),a?n:(0,Q.jsx)(Bd,{host:i,expanded:t,hostSignals:e.hostSignals})]},i.id)}),(0,Q.jsx)(Vd,{warning:e.warning,expanded:t})]})}function Wd({hostId:e,hostLabel:t,project:n,hostSignals:r}){let{showSignal:i,signal:a,known:o,label:s,href:c,initials:l,top:u,bottom:d}=Id(e,t,n,r);return(0,Q.jsxs)(`a`,{href:c,"data-slot":`drawer-project`,"data-host-id":e??`local`,"data-project-id":n.id,"aria-label":s,className:q(`flex h-[64px] min-w-0 items-center gap-[12px] rounded-[10px] px-[10px] text-foreground hover:bg-sidebar-row-hover`,Pd),children:[(0,Q.jsxs)(`span`,{"aria-hidden":`true`,className:`relative flex size-[40px] shrink-0 items-center justify-center rounded-[10px] border border-transparent bg-muted text-[13px] leading-none font-semibold text-muted-foreground`,children:[l,i?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(jd,{position:`top`,segments:u,className:`right-[-4px] border-sidebar`}),(0,Q.jsx)(jd,{position:`bottom`,segments:d,className:`right-[-4px] border-sidebar top-[29px]`})]}):null]}),(0,Q.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-[2px]`,children:[(0,Q.jsx)(`span`,{className:`truncate text-[14.5px] leading-tight font-semibold`,children:n.name}),i?(0,Q.jsx)(wd,{signal:a,known:o,current:!1,slot:`drawer-project-state`,className:`flex-wrap gap-x-[6px] text-xs leading-tight`}):null]})]})}function Gd({hostId:e,label:t,active:n,host:r,onNavigate:i}){let a=(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[12px] font-medium text-soft-foreground`,children:t}),r?(0,Q.jsx)(Ed,{state:r.state,className:`shrink-0`}):null]}),o=q(`flex min-h-[44px] w-full items-center gap-2 rounded-[8px] px-[10px] hover:bg-sidebar-row-hover`,Pd);return n?(0,Q.jsx)(G,{to:`/`,onClick:i,"data-slot":`drawer-host-header`,"data-host-id":e??`local`,"data-host-state":r?.state,className:o,children:a}):(0,Q.jsx)(`a`,{href:Me(e),"data-slot":`drawer-host-header`,"data-host-id":e??`local`,"data-host-state":r?.state,className:o,children:a})}function Kd({hostsData:e,activeProjects:t,onNavigate:n}){let r=Be(),i=rt(e.hosts),a=r===null;return(0,Q.jsxs)(`div`,{"data-slot":`drawer-hosts`,className:`flex flex-col gap-1 px-[8px] pb-[8px]`,children:[(0,Q.jsxs)(`div`,{"data-slot":`drawer-host-group`,"data-host-id":`local`,className:`flex flex-col gap-[2px]`,children:[(0,Q.jsx)(Gd,{hostId:null,label:`This server`,active:a,onNavigate:n}),a?t:e.localProjects.length>0?e.localProjects.map(t=>(0,Q.jsx)(Wd,{hostId:null,hostLabel:`This server`,project:t,hostSignals:e.hostSignals},t.id)):(0,Q.jsx)(`p`,{"data-slot":`drawer-host-empty`,"data-host-id":`local`,className:`px-[10px] py-1 text-xs text-soft-foreground`,children:`No projects`})]}),i.map(i=>{let a=r===i.id;return(0,Q.jsxs)(`div`,{"data-slot":`drawer-host-group`,"data-host-id":i.id,"data-host-state":i.state,className:`flex flex-col gap-[2px] border-t border-border pt-1`,children:[(0,Q.jsx)(Gd,{hostId:i.id,label:i.label,active:a,host:i,onNavigate:n}),a?t:i.state===`connected`?i.projects===null?(0,Q.jsx)(`p`,{"data-slot":`drawer-host-projects-error`,"data-host-id":i.id,className:`px-[10px] py-1 text-xs text-muted-foreground`,children:`Could not load projects`}):i.projects.length===0?(0,Q.jsx)(`p`,{"data-slot":`drawer-host-empty`,"data-host-id":i.id,className:`px-[10px] py-1 text-xs text-soft-foreground`,children:`No projects`}):i.projects.map(t=>(0,Q.jsx)(Wd,{hostId:i.id,hostLabel:i.label,project:t,hostSignals:e.hostSignals},t.id)):null]},i.id)}),(0,Q.jsx)(Hd,{warning:e.warning})]})}function qd(e,t){let n=e=>e.split(`.`).slice(0,3).map(e=>Number.parseInt(e,10)||0),r=n(e),i=n(t);for(let e=0;e<3;e++){let t=(r[e]??0)-(i[e]??0);if(t!==0)return t>0}return!1}var Jd=`cez-theme`,Yd=`(prefers-color-scheme: light)`,Xd=`dark`;function Zd(e){return e===`light`||e===`dark`||e===`system`?e:Xd}function Qd(e,t){return e===`light`||e===`system`&&t?`light`:`dark`}function $d(){try{return Zd(localStorage.getItem(Jd))}catch{return Xd}}function ef(e){try{return localStorage.setItem(Jd,e),!0}catch{return!1}}function tf(){return typeof window<`u`&&typeof window.matchMedia==`function`&&window.matchMedia(Yd).matches}function nf(e,t){e.classList.toggle(`light`,t===`light`),e.style.colorScheme=t}function rf(e){return`/cezarion-mark-${e}.svg`}function af(e){let t=document.querySelector(`link[rel="icon"]`);t&&(t.href=rf(e))}function of(e){let t=document.querySelector(`meta[name="theme-color"]`),n=getComputedStyle(e).getPropertyValue(`--card`).trim();t&&n&&(t.content=n)}var sf=Z.createContext(null);function cf({children:e}){let[t,n]=Z.useState($d),[r,i]=Z.useState(tf);Z.useEffect(()=>{let e=window.matchMedia?.(Yd);if(!e)return;i(e.matches);let t=e=>i(e.matches);return e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[]);let a=Qd(t,r);Z.useLayoutEffect(()=>{nf(document.documentElement,a),af(a),of(document.documentElement)},[a]);let o=Z.useCallback(e=>(n(e),ef(e)),[]),s=Z.useMemo(()=>({theme:t,resolvedTheme:a,setTheme:o}),[t,a,o]);return(0,Q.jsx)(sf.Provider,{value:s,children:e})}function lf(){let e=Z.useContext(sf);if(!e)throw Error(`Squawk: useTheme() must be called inside <ThemeProvider>`);return e}var uf={light:`dark`,dark:`system`,system:`light`},df={light:`light`,dark:`dark`,system:`system`};function ff({className:e,showLabel:t=!1,labelClassName:n}){let{theme:r,setTheme:i}=lf(),a=uf[r],o=xi;return(0,Q.jsxs)(`button`,{type:`button`,className:e,"data-slot":`theme-toggle`,"data-theme-pref":r,title:`Theme: ${df[r]}`,"aria-label":`Theme: ${df[r]}. Switch to ${df[a]}.`,onClick:()=>i(a),children:[(0,Q.jsx)(o,{"aria-hidden":`true`}),t?(0,Q.jsxs)(`span`,{className:n,children:[`Theme · `,r.charAt(0).toUpperCase()+r.slice(1)]}):null]})}function pf(e,t){if(!e?.signals)return null;let n=e.signals,r=e.projects.filter(e=>e.id!==t).map(e=>n.get(e.id)),i=Be(),a=e.hostsData?.hostSignals;if(a){if(i!==null&&a.local?.known)for(let e of a.local.byProject.values())r.push(e);for(let t of e.hostsData?.hosts??[]){if(t.id===i||t.state!==`connected`||!a.knownHosts.has(t.id))continue;let e=a.byHost.get(t.id);if(e)for(let t of e.values())r.push(t)}}return _(r)}function mf(e){let t=w(e??void 0).map(e=>e.text);return t.length>0?`Open projects. Elsewhere: ${t.join(`, `)}`:`Open projects`}function hf({elsewhere:e}){if(!e)return null;let{top:t,bottom:n}=Md(e),r=`right-[2px] border-card`;return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(jd,{position:`top`,segments:t,compact:!0,className:q(r,`top-[3px]`)}),(0,Q.jsx)(jd,{position:`bottom`,segments:n,compact:!0,className:q(r,`top-[24px]`)})]})}function gf({version:e,latestVersion:t=null}){let{resolvedTheme:n}=lf(),r=!!(e&&t&&qd(t,e));return(0,Q.jsxs)(`div`,{"data-slot":`drawer-identity`,className:`flex shrink-0 items-center gap-[12px] border-b border-border pt-[env(safe-area-inset-top)] pr-[14px] pb-[14px] pl-[18px]`,children:[(0,Q.jsx)(`img`,{src:`/cezarion-mark-${n}.svg`,alt:``,"aria-hidden":`true`,className:`mt-[14px] size-[32px] rounded-lg`}),(0,Q.jsx)(`span`,{"data-slot":`drawer-wordmark`,className:`mt-[14px] text-[18px] leading-none font-bold tracking-[-0.02em] text-foreground`,children:`Squawk`}),e?(0,Q.jsxs)(`span`,{"data-slot":`drawer-version`,"data-update-available":r?`true`:void 0,title:r?`v${e} — update available: v${t}`:`v${e}`,className:`mt-[14px] min-w-0 truncate text-xs leading-none text-soft-foreground`,children:[r?(0,Q.jsx)(Qo,{tone:`pending`,className:`mr-1 inline-block size-[5px] align-middle`}):null,`v`,e]}):null,(0,Q.jsx)($o,{asChild:!0,children:(0,Q.jsx)(Y,{variant:`ghost`,size:`icon`,"aria-label":`Close menu`,className:`mt-[14px] ml-auto text-foreground`,children:(0,Q.jsx)(Fi,{className:`size-[19px]`,"aria-hidden":`true`})})})]})}function _f({project:e,signal:t,known:n,current:r,onNavigate:i}){let{top:a,bottom:o}=Md(t),s=r?`border-sidebar-row-selected`:`border-sidebar`,c=`right-[-4px]`,l=(0,Q.jsxs)(G,{to:wo(e.id,`/`),onClick:i,"data-slot":`drawer-project`,"data-project-id":e.id,"aria-current":r?`page`:void 0,className:q(`flex h-[64px] min-w-0 items-center gap-[12px] rounded-[10px] px-[10px] text-foreground hover:bg-sidebar-row-hover focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring`,r&&`flex-1 hover:bg-sidebar-row-selected`),children:[(0,Q.jsxs)(`span`,{"aria-hidden":`true`,className:q(`relative flex size-[40px] shrink-0 items-center justify-center rounded-[10px] border text-[13px] leading-none font-semibold`,r?`border-soft-foreground bg-sidebar text-foreground`:`border-transparent bg-muted text-muted-foreground`),children:[b(e.name),(0,Q.jsx)(jd,{position:`top`,segments:a,className:q(c,s)}),(0,Q.jsx)(jd,{position:`bottom`,segments:o,className:q(c,s,`top-[29px]`)})]}),(0,Q.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-[2px]`,children:[(0,Q.jsx)(`span`,{className:`truncate text-[14.5px] leading-tight font-semibold`,children:e.name}),(0,Q.jsx)(wd,{signal:t,known:n,current:r,slot:`drawer-project-state`,className:`flex-wrap gap-x-[6px] text-xs leading-tight`})]}),r?(0,Q.jsx)(Ni,{"aria-hidden":`true`,className:`size-[16px] shrink-0 text-foreground`}):null]});return r?(0,Q.jsxs)(`div`,{"data-slot":`drawer-project-current`,className:`flex items-center rounded-[10px] bg-sidebar-row-selected pr-[4px]`,children:[l,(0,Q.jsx)(xd,{projectId:e.id,onNavigate:i,triggerClassName:`size-[44px]`,align:`end`})]}):l}var vf=`flex h-[48px] w-full items-center gap-[12px] rounded-[10px] px-[10px] text-[14.5px] font-normal text-foreground hover:bg-sidebar-row-hover focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring [&_svg]:size-[18px] [&_svg]:shrink-0 [&_svg]:text-soft-foreground`;function yf({nav:e,currentProjectId:t,onNavigate:n}){let r=e.projects.map(r=>(0,Q.jsx)(_f,{project:r,signal:e.signals?.get(r.id),known:e.signals!==null,current:r.id===t,onNavigate:n},r.id)),i=e.hostsData!==void 0&&e.hostsData.hosts.length>0;return(0,Q.jsxs)(`div`,{"data-slot":`drawer-projects`,className:`shrink-0`,children:[(0,Q.jsx)(`div`,{className:`px-[18px] pt-[14px] pb-[6px] text-[12px] font-medium text-soft-foreground`,id:`drawer-projects-label`,children:`Projects`}),i?(0,Q.jsx)(`div`,{role:`group`,"data-slot":`drawer-projects-group`,"aria-labelledby":`drawer-projects-label`,children:(0,Q.jsx)(Kd,{hostsData:e.hostsData,activeProjects:r,onNavigate:n})}):(0,Q.jsxs)(`div`,{role:`group`,"data-slot":`drawer-projects-group`,"aria-labelledby":`drawer-projects-label`,className:`flex flex-col gap-[2px] px-[8px] pb-[8px]`,children:[r,(0,Q.jsx)(Hd,{warning:e.hostsData?.warning})]}),(0,Q.jsxs)(`div`,{"data-slot":`drawer-workspace`,className:`flex flex-col gap-[2px] border-t border-border px-[8px] py-[8px]`,children:[(0,Q.jsxs)(G,{to:`/tasks`,onClick:n,"data-slot":`drawer-all-projects`,className:vf,children:[(0,Q.jsx)(ri,{"aria-hidden":`true`}),`All projects · task overview`]}),(0,Q.jsx)(fd,{origin:`mobile`,icon:pi,iconClassName:`size-[18px]`,label:`Add project`,triggerClassName:q(vf,`h-[48px] justify-start p-0 px-[10px] text-foreground`)})]})]})}function bf({onNavigate:e,tools:t}){let{theme:n,setTheme:r}=lf(),i=uf[n],a=n.charAt(0).toUpperCase()+n.slice(1);return(0,Q.jsxs)(`div`,{"data-slot":`drawer-global`,className:`flex shrink-0 flex-col gap-[2px] border-t border-border px-[8px] pt-[8px] pb-[max(8px,env(safe-area-inset-bottom))]`,children:[t?(0,Q.jsxs)(G,{to:`/tools`,onClick:e,"data-slot":`drawer-tools`,"aria-label":t.blocked?`Tools, needs setup`:void 0,"aria-describedby":t.blocked&&t.note?`drawer-tools-note`:void 0,className:q(vf,t.note&&`h-auto min-h-[48px] py-[6px]`),children:[(0,Q.jsxs)(`span`,{className:`relative flex shrink-0`,children:[(0,Q.jsx)(zi,{"aria-hidden":`true`}),t.blocked?(0,Q.jsx)(Qo,{tone:`pending`,"data-slot":`drawer-tools-dot`,className:`absolute -top-[2px] -right-[3px] ring-[1.5px] ring-sidebar`}):null]}),(0,Q.jsxs)(`span`,{className:`flex min-w-0 flex-col`,children:[(0,Q.jsx)(`span`,{children:`Tools`}),t.note?(0,Q.jsx)(`span`,{id:`drawer-tools-note`,"data-slot":`drawer-tools-note`,className:`text-xs leading-tight text-soft-foreground`,children:t.note}):null]})]}):null,(0,Q.jsxs)(G,{to:`/settings/global/appearance`,onClick:e,"data-slot":`drawer-global-settings`,className:vf,children:[(0,Q.jsx)(ti,{"aria-hidden":`true`}),`Global settings`]}),(0,Q.jsxs)(`button`,{type:`button`,"data-slot":`theme-toggle`,"data-theme-pref":n,"aria-label":`Theme: ${n.toLowerCase()}. Switch to ${i}.`,onClick:()=>r(i),className:vf,children:[(0,Q.jsx)(xi,{"aria-hidden":`true`}),`Theme · `,a]})]})}function xf(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 Sf(e){return e instanceof HTMLElement&&e.closest(`[cmdk-input]`)!==null}function Cf(e,t){return!(typeof e.key!=`string`||e.key.toLowerCase()!==t.toLowerCase()||!e.metaKey&&!e.ctrlKey||e.altKey||e.shiftKey||e.repeat||xf(e.target)&&!Sf(e.target))}function wf(e,t){let n=Z.useRef(t);Z.useLayoutEffect(()=>{n.current=t}),Z.useEffect(()=>{let t=t=>{Cf(t,e)&&(t.preventDefault(),n.current(t))};return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},[e])}function Tf(e,t){return!(typeof e.key!=`string`||e.key.toLowerCase()!==t.toLowerCase()||e.metaKey||e.ctrlKey||e.altKey||e.shiftKey||e.repeat||xf(e.target))}function Ef(e,t=typeof navigator>`u`?``:navigator.platform){let n=e.toUpperCase();return/mac|iphone|ipad|ipod/i.test(t)?`⌘${n}`:`Ctrl+${n}`}function Df(e,t){let n=Z.useRef(t);Z.useLayoutEffect(()=>{n.current=t}),Z.useEffect(()=>{let t=t=>{Tf(t,e)&&n.current(t)};return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},[e])}var Of=e(r(),1),kf=Z.createContext(null);function Af(){return Z.useContext(kf)}function jf({slot:e,children:t}){return(0,Of.createPortal)(t,e)}var Mf=`(min-width: 768px)`;function Nf(){let[e,t]=Z.useState(()=>window.matchMedia?.(Mf).matches??!0);return Z.useEffect(()=>{let e=window.matchMedia?.(Mf);if(!e)return;let n=()=>t(e.matches);return n(),e.addEventListener(`change`,n),()=>e.removeEventListener(`change`,n)},[]),e}function Pf({delayDuration:e=0,...t}){return(0,Q.jsx)(Iu,{"data-slot":`tooltip-provider`,delayDuration:e,...t})}function Ff({...e}){return(0,Q.jsx)(Lu,{"data-slot":`tooltip`,...e})}function If({...e}){return(0,Q.jsx)(Ru,{"data-slot":`tooltip-trigger`,...e})}function Lf({className:e,sideOffset:t=0,children:n,...r}){return(0,Q.jsx)(zu,{children:(0,Q.jsxs)(Bu,{"data-slot":`tooltip-content`,sideOffset:t,className:q(`z-50 w-fit origin-(--radix-tooltip-content-transform-origin) motion-safe:animate-in rounded-md bg-contrast px-3 py-1.5 text-xs text-balance text-contrast-foreground fade-in-0 motion-safe:zoom-in-95 motion-safe:data-[side=bottom]:slide-in-from-top-2 motion-safe:data-[side=left]:slide-in-from-right-2 motion-safe:data-[side=right]:slide-in-from-left-2 motion-safe:data-[side=top]:slide-in-from-bottom-2 motion-safe:data-[state=closed]:animate-out data-[state=closed]:fade-out-0 motion-safe:data-[state=closed]:zoom-out-95`,e),...r,children:[n,(0,Q.jsx)(Vu,{className:`z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px] bg-contrast fill-contrast`})]})})}var Rf=[`/git`,`/automations`,`/workflows`,`/reports`];function zf({items:e,activeTo:t,needsYou:n=!1,onNavigate:r}){let[i,a]=(0,Z.useState)(!1),o=(0,Z.useRef)(null),s=e.filter(e=>Rf.includes(e.to)),c=e.filter(e=>!s.includes(e)),l=s.some(e=>e.to===t);return(0,Q.jsx)(Pf,{children:(0,Q.jsxs)(`nav`,{ref:o,"aria-label":`Main`,"data-slot":`view-tabs`,onKeyDown:e=>{if(![`ArrowLeft`,`ArrowRight`,`Home`,`End`].includes(e.key))return;let t=Array.from(o.current?.querySelectorAll(`[data-view-tab]`)??[]),n=t.indexOf(document.activeElement);n<0||(e.preventDefault(),t[e.key===`Home`?0:e.key===`End`?t.length-1:(n+(e.key===`ArrowRight`?1:-1)+t.length)%t.length]?.focus())},className:`flex shrink-0 items-center justify-between max-md:justify-start max-md:gap-1 max-md:overflow-x-auto border-b border-border px-3 pt-2.5 pb-2`,children:[c.map(e=>{let i=e.to===t,a=e.icon,o=e.to===`/`&&n&&!i;return(0,Q.jsxs)(Ff,{children:[(0,Q.jsx)(If,{asChild:!0,children:(0,Q.jsxs)(X,{to:e.to,onClick:r,"data-view-tab":!0,"aria-label":e.label,"aria-current":i?`page`:void 0,className:q(`relative flex h-[30px] min-w-0 items-center justify-center rounded-[7px] text-soft-foreground hover:bg-sidebar-row-hover hover:text-foreground focus-visible:outline-2 focus-visible:outline-ring max-md:min-h-11 max-md:min-w-11`,i?`shrink-0 gap-1.5 bg-sidebar-row-selected px-[9px] text-[12px] font-semibold text-foreground`:`w-7 shrink-0`),children:[(0,Q.jsxs)(`span`,{className:`relative`,children:[(0,Q.jsx)(a,{className:`size-[15px] shrink-0`,"aria-hidden":`true`}),o?(0,Q.jsx)(`span`,{"aria-label":`Tasks need you`,"data-slot":`nav-needs-you-dot`,className:`absolute -top-1 -right-1 size-[7px] rounded-full border-[1.5px] border-sidebar bg-pending-strong`}):null]}),i?(0,Q.jsx)(`span`,{className:`truncate`,children:e.label}):null]})}),(0,Q.jsx)(Lf,{side:`bottom`,sideOffset:6,style:{pointerEvents:`none`},children:e.label})]},e.to)}),s.length?(0,Q.jsxs)(oo,{open:i,onOpenChange:a,children:[(0,Q.jsxs)(Ff,{children:[(0,Q.jsx)(If,{asChild:!0,children:(0,Q.jsx)(ro,{asChild:!0,children:(0,Q.jsx)(`button`,{type:`button`,"data-view-tab":!0,"aria-label":`More views`,"data-active":l?`true`:void 0,className:q(`relative flex h-[30px] w-7 shrink-0 items-center justify-center rounded-[7px] text-soft-foreground hover:bg-sidebar-row-hover hover:text-foreground focus-visible:outline-2 focus-visible:outline-ring max-md:min-h-11 max-md:min-w-11`,(i||l)&&`bg-sidebar-row-selected text-foreground`),children:(0,Q.jsx)(Kc,{className:`size-[15px]`,"aria-hidden":`true`})})})}),(0,Q.jsx)(Lf,{side:`bottom`,sideOffset:6,style:{pointerEvents:`none`},children:`More views`})]}),(0,Q.jsx)(io,{align:`end`,sideOffset:4,className:`w-48 rounded-[10px] border-border bg-sidebar p-[5px] shadow-[0_10px_28px_#00000047]`,children:s.map(e=>{let n=e.icon,i=e.to===t;return(0,Q.jsx)(eo,{asChild:!0,className:q(`h-8 max-md:min-h-11 gap-2.5 rounded-md px-[9px] text-[13px] text-foreground focus:bg-sidebar-row-hover`,i&&`bg-sidebar-row-selected font-medium`),children:(0,Q.jsxs)(X,{to:e.to,onClick:r,"aria-current":i?`page`:void 0,children:[(0,Q.jsx)(n,{className:`size-[15px] text-soft-foreground`}),e.label]})},e.to)})})]}):null]})})}var Bf=[{to:`/`,label:`Tasks`,icon:_i,match:[`/`,`/tasks`],badge:`tasks-unread`},{to:`/activity`,label:`Activity`,icon:Nc,match:[`/activity`]},{to:`/git`,label:`Git`,icon:ji,match:[`/git`]},{to:`/github`,label:`GitHub`,icon:di,match:[`/github`],forge:!0},{to:`/automations`,label:`Automations`,icon:ki,match:[`/automations`],automations:!0},{to:`/skills`,label:`Skills`,icon:Hi,match:[`/skills`]},{to:`/workflows`,label:`Workflows`,icon:Di,match:[`/workflows`]},{to:`/reports`,label:`Reports`,icon:Xc,match:[`/reports`],reports:!0},{to:`/settings`,label:`Settings`,icon:Ei,match:[`/settings`]}];function Vf({forge:e=!1,automations:t=!1,reports:n=!0}={}){return Bf.filter(r=>(!r.forge||e)&&(!r.automations||t)&&(!r.reports||n))}function Hf(e,t){return t===`/`?e===`/`:e===t||e.startsWith(t+`/`)}function Uf(e){let t=null;for(let n of Bf)for(let r of n.match)Hf(e,r)&&(t===null||r.length>t.length)&&(t={to:n.to,length:r.length});return t?.to??null}function Wf(e){let t=Uf(e);return Bf.find(e=>e.to===t)??null}function Gf(e){return/^\/tasks\/[^/]+(?:\/|$)/.test(Oo(e))}function Kf(e,t){let n=Oo(e);return/^\/git\/?$/.test(n)?new URLSearchParams(t).get(`view`)===`repo`:n.startsWith(`/git/`)}var qf=[`/`,`/activity`,`/github`],Jf=[`/git`,`/skills`,`/workflows`,`/reports`,`/settings`,`/automations`];function Yf(e,t,n){let r=Oo(e),i=r===`/new`,a=Gf(e);return{activeTo:i?`/new`:Uf(r),current:Wf(r),currentProjectId:Eo(e),newTask:i,pushed:a,showTabBar:!a&&!Kf(e,t)&&!n,gitRepositoryView:r===`/git`&&new URLSearchParams(t).get(`view`)===`repo`}}var Xf=[{to:`/git`,label:`Git`},{to:`/skills`,label:`Skills`},{to:`/workflows`,label:`Workflows`},{to:`/reports`,label:`Reports`},{to:`/settings`,label:`Project settings`}],Zf=[`/automations`],Qf=`flex h-[50px] min-h-11 w-full items-center gap-[14px] rounded-[10px] px-[10px] text-[14.5px] text-foreground hover:bg-sidebar-row-hover focus-visible:outline-2 focus-visible:outline-ring [&_svg]:size-[18px] [&_svg]:shrink-0 [&_svg]:text-muted-foreground`;function $f({open:e,onOpenChange:t,onCloseAutoFocus:n,projectName:r,items:i,activeTo:a}){let o=new Map(i.map(e=>[e.to,e])),s=Xf.flatMap(({to:e,label:t})=>{let n=o.get(e);return n?[{to:e,label:t,icon:n.icon}]:[]}),c=Zf.flatMap(e=>{let t=o.get(e);return t?[{to:e,label:t.label,icon:t.icon}]:[]}),l=()=>t(!1),u=({to:e,label:t,icon:n})=>{let r=e===a;return(0,Q.jsxs)(X,{to:e,onClick:l,"data-slot":`more-row`,"data-more-row":e,"aria-current":r?`page`:void 0,className:q(Qf,r&&`bg-sidebar-row-selected hover:bg-sidebar-row-selected`),children:[(0,Q.jsx)(n,{"aria-hidden":`true`}),(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:t}),(0,Q.jsx)(Ti,{"aria-hidden":`true`,className:`!size-[15px]`})]},e)};return(0,Q.jsx)(es,{open:e,onOpenChange:t,children:(0,Q.jsxs)(rs,{side:`bottom`,"data-slot":`more-sheet`,showCloseButton:!1,onCloseAutoFocus:n,"aria-describedby":void 0,className:`gap-0 rounded-t-[20px] border-border bg-sidebar px-[14px] pt-[10px] pb-[max(14px,env(safe-area-inset-bottom))] md:hidden`,children:[(0,Q.jsx)(`div`,{"aria-hidden":`true`,className:`mx-auto mb-[14px] h-[5px] w-[36px] rounded-[3px] bg-border`}),(0,Q.jsxs)(`div`,{className:`flex items-baseline gap-[10px] px-[10px] pb-[6px]`,children:[(0,Q.jsx)(ts,{className:`text-[17px] leading-tight font-bold`,children:`More`}),r?(0,Q.jsx)(`span`,{"data-slot":`more-project`,className:`min-w-0 truncate text-[12.5px] text-soft-foreground`,children:r}):null]}),(0,Q.jsx)(`div`,{className:`flex flex-col gap-[2px]`,children:s.map(u)}),c.length>0?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{role:`separator`,className:`mx-[10px] mt-[8px] border-t border-border`}),(0,Q.jsx)(`div`,{className:`px-[10px] pt-[12px] pb-[4px] text-[12px] font-medium text-soft-foreground`,children:`Shown when their flag is on`}),(0,Q.jsx)(`div`,{className:`flex flex-col gap-[2px]`,children:c.map(u)})]}):null]})})}var ep=`(min-width: 768px)`;function tp({items:e,activeTo:t,signal:n,projectName:r}){let[i,a]=Z.useState(!1),o=Z.useRef(null),{pathname:s}=qn();Z.useEffect(()=>{a(!1)},[s]),Z.useEffect(()=>{let e=window.matchMedia?.(ep);if(!e)return;e.matches&&a(!1);let t=e=>{e.matches&&a(!1)};return e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[]);let c=e.filter(e=>qf.includes(e.to)),l=t!==null&&Jf.includes(t)&&e.some(e=>e.to===t),{top:u}=Md(n),d=u.some(e=>e.count>0),f=e=>q(`relative flex h-full min-h-11 min-w-11 flex-1 flex-col items-center justify-center gap-[3px] text-xs leading-none focus-visible:outline-2 focus-visible:outline-ring`,e?`font-semibold text-foreground`:`font-medium text-soft-foreground`);return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`nav`,{"aria-label":`Views`,"data-slot":`mobile-tab-bar`,className:`flex h-[54px] items-stretch`,children:[c.map(e=>{let n=e.to===t,r=e.icon,i=e.to===`/`&&d;return(0,Q.jsxs)(X,{to:e.to,"data-tab":e.to,"aria-current":n?`page`:void 0,className:f(n),children:[(0,Q.jsxs)(`span`,{className:`relative`,children:[(0,Q.jsx)(r,{"aria-hidden":`true`,className:`size-[21px]`}),i?(0,Q.jsx)(jd,{position:`top`,segments:u,className:`-top-[6px] -right-[10px] border-sidebar`}):null]}),e.label]},e.to)}),(0,Q.jsxs)(`button`,{ref:o,type:`button`,"data-tab":`more`,"aria-haspopup":`dialog`,"aria-expanded":i,"data-active":l?`true`:void 0,onClick:()=>a(!0),className:f(l),children:[(0,Q.jsx)(`span`,{className:`relative`,children:(0,Q.jsx)(gi,{"aria-hidden":`true`,className:`size-[21px]`})}),`More`]})]}),(0,Q.jsx)($f,{open:i,onOpenChange:a,onCloseAutoFocus:e=>{o.current?.isConnected&&(e.preventDefault(),o.current.focus())},projectName:r,items:e,activeTo:t})]})}var np=`(min-width: 768px)`;function rp(e){return Gn({path:`/tasks/:id`,end:!0},Oo(e))!==null}function ip(e,t){if(!t)return e;let n=e.replace(/\/commits\/[^/]+\/?$/,`/commits`);return n.endsWith(`/git/commits`)?n.slice(0,-8):n}function ap({children:e,breadcrumb:t,repo:n=null,version:r=null,latestVersion:i=null,sidebarList:a,taskQuickList:o,sessionScope:s,toolsMenu:c,forgeAvailable:l=!0,automationsAvailable:u=!0,reportsAvailable:d=!0,banner:f,mobileProjects:p,projectHeader:m,sidebarProjectId:h,hasProjects:g=!0,needsYou:_,projectRail:v,hostLive:y,toolsStatus:b}){let{pathname:x,search:S}=qn(),{activeTo:C,current:w,currentProjectId:T,pushed:E,showTabBar:D,gitRepositoryView:O}=Yf(x,S,fo()),[k,A]=Z.useState(!1),[j,M]=Z.useState(null),N=Z.useRef(null),ee=Z.useRef(null),P=rp(x),F=ip(x,fs());Z.useLayoutEffect(()=>{if(P)return;let e=ee.current;e&&(e.scrollTop=0)},[F,P,O]);let I=Un(),L=Z.useRef(x);Z.useEffect(()=>{let e=L.current;L.current=x,e!==x&&(I===`REPLACE`&&fp(e,x)||A(!1))},[x,I]),Z.useEffect(()=>{let e=window.matchMedia?.(np);if(!e)return;e.matches&&A(!1);let t=e=>{e.matches&&A(!1)};return e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[]);let R=Vf({forge:l,automations:u,reports:d}),te=w?.to===`/reports`&&!d?null:w,ne={version:r,latestVersion:i};return(0,Q.jsx)(es,{open:k,onOpenChange:A,children:(0,Q.jsxs)(`div`,{"data-slot":`app-shell`,"data-host-live":y,className:`flex h-dvh overflow-hidden bg-background text-foreground pl-[env(safe-area-inset-left)] pr-[env(safe-area-inset-right)]`,children:[(0,Q.jsx)(cp,{projectRail:v,activeTo:C,items:R,repo:n,release:ne,sidebarList:a,taskQuickList:o,sessionScope:s,toolsMenu:c,projectHeader:m,sidebarProjectId:h,hasProjects:g,needsYou:_}),(0,Q.jsx)(dp,{release:ne,taskQuickList:o,sidebarProjectId:h,mobileProjects:p,currentProjectId:T,toolsStatus:b,onNavigate:()=>A(!1),onCloseAutoFocus:e=>{N.current?.isConnected&&(e.preventDefault(),N.current.focus())}}),(0,Q.jsxs)(`div`,{className:`group/shell grid min-w-0 flex-1 grid-rows-[auto_auto_1fr_auto] overflow-hidden`,children:[(0,Q.jsx)(vp,{title:te?.label??`Squawk`,pushed:E?{onSlot:M}:null,repo:n,elsewhere:pf(p,T),onTrigger:e=>{N.current=e}}),(0,Q.jsx)(op,{breadcrumb:t,repo:T===null?null:n,label:te?.label}),f?(0,Q.jsx)(`div`,{"data-slot":`banner-slot`,className:`row-start-2`,children:f}):null,(0,Q.jsx)(`main`,{ref:ee,"data-slot":`main`,className:`row-start-3 min-h-0 overflow-y-auto overscroll-contain`,children:(0,Q.jsx)(kf.Provider,{value:E?j:null,children:e})}),(0,Q.jsx)(sp,{showTabBar:D&&g,items:R,activeTo:C,mobileProjects:p,currentProjectId:T,repo:n})]})]})})}function op({breadcrumb:e,repo:t,label:n}){let r=e?.project??t?.name,i=e?.branch??t?.branch;return(0,Q.jsxs)(`header`,{"data-slot":`desktop-breadcrumb`,className:`row-start-1 hidden h-16 min-w-0 items-center gap-3 border-b border-border px-9 text-[13px] text-muted-foreground md:flex`,children:[(0,Q.jsx)(ai,{"aria-hidden":`true`,className:`size-4 shrink-0`}),r?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`span`,{className:`truncate font-medium text-foreground`,children:r}),(0,Q.jsx)(`span`,{"aria-hidden":`true`,children:`/`})]}):null,(0,Q.jsx)(`span`,{className:`min-w-0 truncate`,children:e?.page??n??`Squawk`}),i?(0,Q.jsxs)(`span`,{className:`ml-auto flex shrink-0 items-center gap-2 text-xs`,children:[(0,Q.jsx)(Gi,{"aria-hidden":`true`,className:`size-4 text-accent-text`}),i]}):null]})}function sp({showTabBar:e,items:t,activeTo:n,mobileProjects:r,currentProjectId:i,repo:a}){let o=i===null?void 0:r?.signals?.get(i);return(0,Q.jsx)(`div`,{"data-slot":`composer`,className:q(`row-start-4 pb-[max(env(safe-area-inset-bottom),var(--kb,0px))]`,e&&`relative max-md:border-t max-md:border-border max-md:bg-sidebar`),children:e?(0,Q.jsx)(`div`,{className:`md:hidden`,children:(0,Q.jsx)(tp,{items:t,activeTo:n,signal:o,projectName:r?.projects.find(e=>e.id===i)?.name??a?.name??null})}):null})}function cp({projectRail:e,...t}){let[n,r]=Z.useState(gl),i=Z.useCallback(e=>{let t=hl(e);r(t),_l(t)},[]);return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(vl.Provider,{value:n,children:e}),(0,Q.jsx)(lp,{...t,width:n,onWidthChange:i})]})}function lp({width:e,onWidthChange:t,...n}){return(0,Q.jsxs)(`aside`,{"data-slot":`sidebar`,style:{width:e},className:`relative hidden shrink-0 flex-col border-r border-border bg-sidebar md:flex`,children:[(0,Q.jsx)(mp,{...n}),(0,Q.jsx)(up,{width:e,onWidthChange:t})]})}function up({width:e,onWidthChange:t}){let n=Z.useRef(null),r=t=>{t.button===0&&(n.current={x:t.clientX,width:e},t.currentTarget.setPointerCapture(t.pointerId),t.preventDefault(),t.currentTarget.focus())},i=e=>{let r=n.current;r&&t(hl(r.width+(e.clientX-r.x)))},a=e=>{n.current&&(n.current=null,e.currentTarget.hasPointerCapture(e.pointerId)&&e.currentTarget.releasePointerCapture(e.pointerId))};return(0,Q.jsx)(`div`,{"data-slot":`sidebar-resize-handle`,role:`separator`,"aria-orientation":`vertical`,"aria-label":`Resize the sidebar`,"aria-valuenow":e,"aria-valuemin":264,"aria-valuemax":420,tabIndex:0,onPointerDown:r,onPointerMove:i,onPointerUp:a,onPointerCancel:a,onKeyDown:n=>{let r=n.key===`ArrowLeft`?e-16:n.key===`ArrowRight`?e+16:n.key===`Home`?264:n.key===`End`?420:null;r!==null&&(n.preventDefault(),t(hl(r)))},onDoubleClick:()=>t(264),title:`Drag to resize the sidebar — double-click to reset`,className:`absolute inset-y-0 -right-[2px] z-20 w-[5px] cursor-col-resize touch-none bg-transparent transition-colors hover:bg-[var(--composer-border)] focus-visible:bg-[var(--composer-border)] focus-visible:outline-none`})}function dp({onNavigate:e,onCloseAutoFocus:t,mobileProjects:n,currentProjectId:r,toolsStatus:i,release:a,taskQuickList:o,sidebarProjectId:s}){return(0,Q.jsxs)(rs,{side:`left`,"data-slot":`mobile-nav-drawer`,onCloseAutoFocus:t,overlayClassName:`bg-[var(--nav-scrim)]`,showCloseButton:!1,className:`w-[calc(100%-68px)] max-w-[334px] gap-0 border-border bg-sidebar p-0 sm:max-w-[334px] md:hidden`,"aria-describedby":void 0,children:[(0,Q.jsx)(ts,{className:`sr-only`,children:`Navigation`}),(0,Q.jsx)(gf,{version:a.version,latestVersion:a.latestVersion}),(0,Q.jsxs)(`div`,{"data-slot":`drawer-scroll`,className:`flex min-h-0 flex-1 flex-col overflow-y-auto overscroll-contain`,children:[n?(0,Q.jsx)(yf,{nav:n,currentProjectId:r,onNavigate:e}):null,o?(0,Q.jsx)(pp,{projectId:s,onNavigate:e,children:(0,Q.jsx)(`div`,{"data-slot":`drawer-tasks`,className:`border-t border-border px-[8px] py-[8px]`,children:o})}):null]}),(0,Q.jsx)(bf,{onNavigate:e,tools:i})]})}function fp(e,t){return Eo(e)==="default"&&Eo(t)!==null&&Eo(t)!=="default"&&Oo(e)===Oo(t)}function pp({projectId:e,onNavigate:t,children:n}){let r=pn(),i=e===void 0?r:{projectId:e,apiBase:`${ze()}${Fe}/p/${encodeURIComponent(e)}`};return(0,Q.jsx)(vn.Provider,{value:i,children:(0,Q.jsx)(yl.Provider,{value:t,children:n})})}function mp({activeTo:e,items:t,repo:n,release:r,sidebarList:i,taskQuickList:a,sessionScope:o,toolsMenu:s,projectHeader:c,sidebarProjectId:l,hasProjects:u=!0,needsYou:d,onNavigate:f}){return(0,Q.jsx)(pp,{projectId:l,onNavigate:f,children:(0,Q.jsxs)(`div`,{"data-slot":`sidebar-content`,className:`@container/sidebar flex min-h-0 flex-1 flex-col pt-[env(safe-area-inset-top)] pb-[env(safe-area-inset-bottom)]`,children:[(0,Q.jsx)(`div`,{"data-slot":`sidebar-header`,className:`shrink-0`,children:c??(n?(0,Q.jsxs)(`div`,{className:`px-[14px] pt-[14px] pb-2.5`,children:[(0,Q.jsx)(`div`,{className:`truncate text-sm font-semibold`,children:n.name}),(0,Q.jsx)(`div`,{className:`truncate font-mono text-xs text-soft-foreground`,children:n.branch})]}):u?null:(0,Q.jsxs)(`div`,{className:`px-[14px] pt-[14px] pb-2.5`,children:[(0,Q.jsx)(`div`,{className:`truncate text-[14px] font-semibold text-foreground`,children:`Workspace`}),(0,Q.jsx)(`div`,{className:`truncate text-xs text-soft-foreground`,children:`No projects yet`})]}))}),(0,Q.jsxs)(`div`,{"data-slot":`sidebar-actions`,className:`flex flex-col gap-2 px-3`,children:[(0,Q.jsx)(gp,{}),u?(0,Q.jsx)(Y,{asChild:!0,variant:`ghost`,size:`sm`,className:q(`relative rounded-[7px] bg-muted w-full min-w-0 justify-start gap-2 px-2.5 text-[12.5px] font-medium text-foreground hover:bg-sidebar-row-hover hover:text-foreground`,e===`/new`&&`bg-sidebar-row-selected text-foreground font-medium hover:bg-sidebar-row-selected`),children:(0,Q.jsxs)(X,{to:`/new`,onClick:f,"data-sidebar-item":`new-task`,"aria-current":e===`/new`?`page`:void 0,children:[(0,Q.jsx)(vi,{className:`size-[15px]`,"aria-hidden":`true`}),`New task`,(0,Q.jsx)(`kbd`,{"aria-hidden":`true`,className:`sr-only`,children:`C`})]})}):null]}),o?(0,Q.jsx)(`div`,{className:`shrink-0 px-3 pt-2`,children:o}):null,u?(0,Q.jsx)(zf,{items:t,activeTo:e,needsYou:d,onNavigate:f}):null,(0,Q.jsx)(`div`,{"data-slot":`project-task-navigation`,className:`min-h-0 flex-1 overflow-y-auto overscroll-contain p-3`,children:(0,Q.jsx)(yl.Provider,{value:f,children:i??(u?(0,Q.jsx)(`div`,{"data-slot":`task-quick-list`,children:a}):(0,Q.jsx)(`div`,{"data-slot":`sidebar-empty-projects`,className:`px-2 py-4 text-xs text-soft-foreground`,children:`Add a repository from the main view or project rail to see its tasks here.`}))})}),(0,Q.jsx)(hp,{toolsMenu:s,release:r})]})})}function hp({toolsMenu:e,release:t}){return(0,Q.jsx)(`div`,{"data-slot":`sidebar-footer`,className:`shrink-0`,children:(0,Q.jsxs)(`div`,{"data-slot":`sidebar-footer-controls`,className:`flex h-11 items-center justify-between gap-1 border-t border-border px-3`,children:[(0,Q.jsx)(`div`,{"data-slot":`tools-menu`,className:`shrink-0`,children:e}),(0,Q.jsx)(`div`,{className:`flex min-w-0 items-center gap-1`,"data-slot":`version-action`,children:t.version?(0,Q.jsx)(_p,{version:t.version,latestVersion:t.latestVersion}):null})]})})}function gp(){return(0,Q.jsxs)(`button`,{type:`button`,"data-slot":`command-palette-hint`,title:`Search — command palette (⌘K / Ctrl+K)`,onClick:()=>pl(),className:`flex h-[32px] max-md:min-h-11 w-full items-center gap-2 rounded-[7px] border border-border bg-background px-2.5 text-left text-[12.5px] font-normal text-soft-foreground transition-colors hover:border-border hover:text-foreground`,children:[(0,Q.jsx)(mi,{className:`size-[14px] shrink-0`,"aria-hidden":`true`}),(0,Q.jsx)(`span`,{className:`truncate`,children:`Search…`}),(0,Q.jsx)(`kbd`,{"aria-hidden":`true`,className:`ml-auto shrink-0 font-sans text-xs font-normal text-soft-foreground`,children:Ef(`k`)})]})}function _p({version:e,latestVersion:t}){let n=!!(t&&qd(t,e));return(0,Q.jsxs)(`span`,{"data-slot":`version-chip`,"data-update-available":n?`true`:void 0,title:n?`v${e} — update available: v${t}`:`v${e}`,className:`flex min-w-0 items-center gap-1 font-mono text-xs text-soft-foreground`,children:[n?(0,Q.jsx)(Qo,{tone:`pending`,className:`size-[5px] shrink-0`}):null,(0,Q.jsxs)(`span`,{className:`truncate`,children:[`v`,e]})]})}function vp({title:e,pushed:t,repo:n,elsewhere:r,onTrigger:i}){return t?(0,Q.jsx)(yp,{onSlot:t.onSlot}):(0,Q.jsx)(`header`,{"data-slot":`mobile-top-bar`,className:`row-start-1 min-w-0 border-b border-border bg-card pt-[env(safe-area-inset-top)] md:hidden`,children:(0,Q.jsxs)(`div`,{className:`flex h-[56px] min-w-0 items-center gap-[8px] px-[8px]`,children:[(0,Q.jsx)(os,{asChild:!0,children:(0,Q.jsxs)(Y,{variant:`ghost`,"aria-label":mf(r),onClick:e=>i(e.currentTarget),className:`relative w-[64px] shrink-0 justify-start rounded-md p-0 pl-[10px] text-foreground`,children:[(0,Q.jsx)(si,{className:`size-[20px]`,"aria-hidden":`true`}),(0,Q.jsx)(hf,{elsewhere:r})]})}),n?(0,Q.jsx)(os,{asChild:!0,children:(0,Q.jsxs)(`button`,{type:`button`,"data-slot":`mobile-project-picker`,"aria-label":`Switch project: ${n.name}`,onClick:e=>i(e.currentTarget),className:`flex h-[44px] min-w-0 flex-1 items-center justify-start gap-[10px] rounded-md text-left focus-visible:outline-2 focus-visible:outline-ring`,children:[(0,Q.jsx)(`span`,{"aria-hidden":`true`,className:`flex size-[28px] shrink-0 items-center justify-center rounded-[8px] border border-soft-foreground bg-sidebar-row-selected text-xs leading-none font-semibold text-foreground`,children:b(n.name)}),(0,Q.jsxs)(`span`,{className:`flex min-w-0 flex-col`,children:[(0,Q.jsx)(`span`,{className:`truncate text-[15px] leading-tight font-semibold text-foreground`,children:n.name}),n.branch?(0,Q.jsx)(`span`,{className:`truncate font-mono text-xs leading-tight text-soft-foreground`,children:n.branch}):null]}),(0,Q.jsx)(Ki,{"aria-hidden":`true`,className:`size-3.5 shrink-0 text-soft-foreground`})]})}):null,e===`Squawk`?n?null:(0,Q.jsx)(`span`,{className:`flex-1`}):(0,Q.jsx)(`span`,{"data-slot":`mobile-route-title`,className:q(`truncate text-[15px] font-semibold text-foreground`,n?`sr-only`:`min-w-0 flex-1 pl-[8px]`),children:e}),(0,Q.jsx)(Y,{variant:`ghost`,"aria-label":`Search`,"data-slot":`mobile-search`,onClick:()=>pl(),size:`icon`,className:`ml-auto shrink-0 p-0 text-foreground`,children:(0,Q.jsx)(mi,{className:`size-[19px]`,"aria-hidden":`true`})})]})})}function yp({onSlot:e}){let t=To();return(0,Q.jsx)(`header`,{"data-slot":`mobile-top-bar`,"data-mode":`task`,className:`row-start-1 min-w-0 border-b border-border bg-card pt-[env(safe-area-inset-top)] md:hidden`,children:(0,Q.jsxs)(`div`,{className:`flex min-h-[56px] min-w-0 items-center gap-[4px] px-[8px] py-2`,children:[(0,Q.jsx)(Y,{variant:`ghost`,"aria-label":`Back`,"data-slot":`mobile-back`,onClick:()=>{let e=window.history.state?.idx;t(typeof e==`number`&&e>0?-1:`/`)},size:`icon`,className:`shrink-0 p-0 text-foreground`,children:(0,Q.jsx)(Lc,{className:`size-[22px]`,"aria-hidden":`true`})}),(0,Q.jsx)(`div`,{"data-slot":`mobile-run-bar`,ref:e,className:`flex min-w-0 flex-1 items-center gap-[4px]`})]})})}function bp(e,t){let n=typeof e==`string`?new URLSearchParams(e):e,r=n.get(`runner`),i=r!==null&&(t?.runners.some(e=>e.id===r)??!1),a=n.get(`skillPath`);return{skill:(n.get(`skill`)??``).trim(),...a?{skillPath:a}:{},...i?{runner:r}:{},...n.has(`account`)?{account:n.get(`account`)}:{},ref:(n.get(`ref`)??n.get(`task`)??``).trim()}}function xp(e){let t=new URLSearchParams;e.skill&&t.set(`skill`,e.skill),e.skillPath!==void 0&&t.set(`skillPath`,e.skillPath),e.runner&&t.set(`runner`,e.runner),e.account!==void 0&&t.set(`account`,e.account),e.ref&&t.set(`ref`,e.ref);let n=t.toString();return n?`/new?${n}`:`/new`}function Sp(e){return e.reason===`deadline`?`timed out`:e.reason===`error`?`search failed`:e.state===`connected`?`not connected`:e.state===`unreachable`?`offline`:e.state===`paused`?`paused`:e.state===`connecting`?`connecting`:e.state===`needs-node`?`needs Node.js`:At(e.state).label.toLowerCase()}function Cp(e,t=!1){return t?`Could not search remote hosts.`:e.length===0?null:`Not searched: ${[...e].sort((e,t)=>e.label.localeCompare(t.label,void 0,{sensitivity:`base`})||e.hostId.localeCompare(t.hostId)).map(e=>`${e.label} (${Sp(e)})`).join(`, `)}.`}function wp(e,t,n){let r=new Set,i=[];for(let a of e){let e=`${a.hostId}\u0000${a.projectId}`;if(r.has(e))continue;r.add(e);let o=n.get(a.hostId)?.find(e=>e.id===a.projectId)?.name??a.projectId,s=t.get(a.hostId)??a.hostId;i.push(`${o} (${s})`)}return i}function Tp(e,t,n=[]){if(e.length===0)return[];let r=new Set(t.map(e=>`${e.hostId}\u0000${e.projectId}\u0000${e.id}`)),i=n.length>0?new Set(n):null,a=new Set,o=[];for(let t of e){if(t.delegation?.role===`worker`||i&&!i.has(t.hostId))continue;let e=`${t.hostId}\u0000${t.projectId}\u0000${t.id}`;r.has(e)||a.has(e)||(a.add(e),o.push(t))}return o.sort((e,t)=>t.createdAt.localeCompare(e.createdAt)||e.hostId.localeCompare(t.hostId)||e.id.localeCompare(t.id))}function Ep(e){let{hasHosts:t,hostLabels:n,hostStates:r,projectsByHost:i}=Jr(Pe()),[a,o]=Z.useState(``);Z.useEffect(()=>{if(!t||e.trim().length<2){o(``);return}let n=setTimeout(()=>o(e),250);return()=>clearTimeout(n)},[t,e]);let s=e.trim(),c=t&&s.length>=2,l=Zr(c?a:``,c),u=c&&a.trim()===s&&!l.isPlaceholderData,d=u?l.data:void 0,f=c?l.data?.runs:void 0;return{hasHosts:t,remoteTasks:Z.useMemo(()=>{if(!f||f.length===0)return[];let e=new Set;return f.filter(t=>{if(No(t))return!1;let n=`${t.hostId}/${t.projectId}/${t.id}`;return e.has(n)?!1:(e.add(n),!0)}).sort((e,t)=>t.createdAt.localeCompare(e.createdAt)||e.hostId.localeCompare(t.hostId)||e.id.localeCompare(t.id)).map(e=>({...e,hostLabel:n.get(e.hostId)??e.hostId,hostStale:r.get(e.hostId)!==`connected`}))},[f,n,r]),remoteTruncated:Z.useMemo(()=>d?wp(d.truncated,n,i):[],[d,n,i]),remoteProjectName:Z.useCallback((e,t)=>i.get(e)?.find(e=>e.id===t)?.name??t,[i]),unanswered:d?.unanswered??[],searchError:u&&l.isError,searchWarning:d?.warning}}function Dp({unanswered:e,error:t=!1,warning:n,className:r}){let i=Cp(e,t)??n??null;return i?(0,Q.jsx)(`p`,{"data-slot":`host-search-unanswered`,role:`status`,className:q(`text-xs text-soft-foreground`,r),children:i}):null}var Op=`cez-last-location`;function kp(){try{let e=localStorage.getItem(Qr(Op));return e===null?null:JSON.parse(e)}catch{return null}}function Ap(e){try{localStorage.setItem(Qr(Op),JSON.stringify(e))}catch{}}var jp=new Set([`projectId`,`pathname`,`search`,`hash`]);function Mp(e){return typeof e!=`string`||e.length<1||e.length>64?null:e}function Np(e){return typeof e!=`string`||e.length<1||e.length>2048||!e.startsWith(`/p/`)?null:e}function Pp(e){return e!==void 0&&(typeof e!=`string`||e.length>4096||!e.startsWith(`?`))?null:e}function Fp(e){return e!==void 0&&(typeof e!=`string`||e.length>2048||!e.startsWith(`#`))?null:e}function Ip(e){if(typeof e!=`object`||!e||Array.isArray(e))return null;let t=e;if(Object.keys(t).some(e=>!jp.has(e)))return null;let n=Mp(t.projectId);if(n===null)return null;let r=Np(t.pathname);if(r===null)return null;let i=Pp(t.search);if(i===null)return null;let a=Fp(t.hash);if(a===null)return null;try{if(Eo(r)!==n)return null}catch{return null}return{projectId:n,pathname:r,...i===void 0?{}:{search:i},...a===void 0?{}:{hash:a}}}function Lp(e,t){let n=t.projects.find(t=>t.id===e);return n!==void 0&&n.status!==`missing`}function Rp(e,t){if(t===void 0)return null;let n;try{n=Eo(e.pathname)}catch{return null}return n===null||!Lp(n,t)?null:Ip({projectId:n,pathname:e.pathname,...e.search===``?{}:{search:e.search},...e.hash===``?{}:{hash:e.hash}})}function zp(e,t,n,r={}){let i=Ip(e);return i===null||!(t===void 0?n!==void 0&&i.projectId===n:Lp(i.projectId,t))&&!(r.preserveRemovedProject===!0&&t!==void 0&&!t.projects.some(e=>e.id===i.projectId))?null:`${i.pathname}${i.search??``}${i.hash??``}`}function Bp(e,t){let n=Ip(e);return n!==null&&n.projectId===t.projectId&&n.pathname===t.pathname&&(n.search??``)===(t.search??``)&&(n.hash??``)===(t.hash??``)}var Vp=`cez-project-locations`;function Hp(){try{let e=localStorage.getItem(Qr(Vp)),t=e===null?null:JSON.parse(e);return typeof t==`object`&&t&&!Array.isArray(t)?t:{}}catch{return{}}}function Up(e){let t=Hp()[e];return t===void 0?null:t}function Wp(e){try{localStorage.setItem(Qr(Vp),JSON.stringify({...Hp(),[e.projectId]:e}))}catch{}}function Gp(e,t,n){let r=Ip(t);return r===null||r.projectId!==e||n===void 0||!Lp(e,n)?null:`${r.pathname}${r.search??``}${r.hash??``}`}var Kp=2500,qp=e=>String(wo(e,`/`));function Jp(e,t,n){let r={href:qp(e),verify:!1},i=Gp(e,t,n.registry);if(i===null)return r;try{let e=i.replace(/[?#].*$/,``),t=n.matchRoute(e);return t===null?r:{href:i,verify:Object.keys(t.params).some(e=>e!==`projectId`)}}catch{return r}}var Yp=e=>Dt(E(e.params.id??``,{projectId:e.opts.projectId}),{signal:e.opts.signal});function Xp(e){let t=Number(e);return Number.isSafeInteger(t)&&t>=1?t:null}async function Zp(e,t,n){let r=await It(e,t,{},n.opts);return r.available?r.item!==null:null}var Qp=async e=>(await Yp(e),!0),$p=async e=>(await Yp(e),await En(e.params.id??``,e.params.sha??``,e.opts),!0);async function em(e,t){let n=await Yp(e),r=Xp(e.params.n);return r===null?!1:er(n,e.repoBase).some(e=>e.kind===t&&e.number===r)?Zp(t,r,e):e.repoBase===void 0&&null}var tm=async e=>(await Je(e.params.sha??``,e.opts),!0);async function nm(e,t){let n=Xp(e.params.n);return n!==null&&Zp(t,n,e)}var rm=[{matches:e=>e===`/tasks/:id/commits/:sha`,check:$p},{matches:e=>e===`/tasks/:id/issue/:n`,check:e=>em(e,`issue`)},{matches:e=>e===`/tasks/:id/pr/:n`,check:e=>em(e,`pr`)},{matches:e=>e.startsWith(`/tasks/:id`),check:Qp},{matches:e=>e===`/git/commits/:sha`,check:tm},{matches:e=>e===`/github/issues/:n`,check:e=>nm(e,`issue`)},{matches:e=>e.startsWith(`/github/prs/:n`),check:e=>nm(e,`pr`)},{matches:e=>e===`/workflows/:name`,check:async e=>{let{workflows:t,issues:n}=await Zt(e.opts);return t.some(t=>t.name===e.params.name)?!0:n.length>0&&null}},{matches:e=>e.startsWith(`/automations/:automationId`),check:async e=>{let t=await Sn(e.opts);return t.available?t.automations.some(t=>t.id===e.params.automationId):null}}];async function im(e,t,n,r,i){let a=``;try{let o=i(t);if(o===null)return!1;a=o.pattern;let s=rm.find(e=>e.matches(o.pattern));return s===void 0?null:await s.check({projectId:e,pattern:a,params:o.params,repoBase:r,opts:{projectId:e,signal:n}})}catch(e){return!om(e,a)&&null}}var am=/unknown revision|bad object|bad revision|unknown commit|not a commit hash|needed a single revision/i;function om(e,t){return e instanceof Tn?e.status===404||(t===`/git/commits/:sha`||t===`/tasks/:id/commits/:sha`)&&e.status===409&&am.test(e.message):!1}async function sm(e,t,n){let r=Jp(e,t,n);if(!r.verify)return r.href;let i=new AbortController,a=setTimeout(()=>i.abort(),Kp);try{return await im(e,r.href.replace(/[?#].*$/,``),i.signal,n.repoBaseOf?.(e),n.matchRoute)===!1?qp(e):r.href}finally{clearTimeout(a)}}var cm={key:``,navigate:null,ticket:0};function lm(e,t){e!==cm.key&&cm.ticket++,cm.key=e,cm.navigate=t}function um(){cm.ticket++}async function dm(e,t,n){let r=++cm.ticket,i=cm.key,a=await sm(e,t,n);r===cm.ticket&&i===cm.key&&cm.navigate?.(a)}function fm(){let e=Kn(),t=qn();Z.useLayoutEffect(()=>{lm(`${t.key}|${t.pathname}${t.search}${t.hash}`,e)},[e,t.key,t.pathname,t.search,t.hash])}function pm(){let e=Z.useContext(jc);if(e===null)throw Error(`useProjectSwitch needs a ProjectRouteMatcherContext provider (App provides matchProjectRoute)`);let t=A().data,n=c().data,r=Z.useCallback(e=>t?.projects.find(t=>t.id===e)?.repoUrl??(e===(n?.bootProject??t?.bootProject)?R(n?.repo?.remote):void 0),[t,n]);fm();let{pathname:i,search:a,hash:o}=qn(),s=Eo(i),l=`${i}${a}${o}`;return{target:Z.useCallback(n=>n===s?{href:l,verify:!1}:Jp(n,Up(n),{registry:t,matchRoute:e}),[t,e,s,l]),go:Z.useCallback(async n=>{if(n===s)return um();await dm(n,Up(n),{registry:t,repoBaseOf:r,matchRoute:e})},[t,r,e,s])}}function mm(e){return e?.capabilities?.automations===!0}function hm(){let e=c().data,t=(0,Z.useRef)(void 0);return(0,Z.useEffect)(()=>{e&&(t.current=e)},[e]),e??t.current}function gm(){let e=hm();if(!e)return`unknown`;let t=e.capabilities?.automations;return t===!0?`available`:t===!1?`disabled`:`absent`}function _m(){return gm()===`available`}function vm(e){return e?e.capabilities?.reports===!0?`available`:`absent`:`unknown`}function ym(){return vm(hm())}function bm(e){return e?e.capabilities?.webhooks===!0?`available`:`absent`:`unknown`}function xm(){return bm(hm())}function Sm(e){return!Pe()&&e?.capabilities?.preview===!0}var Cm={home:null,root:null};function wm(e,t){if(!t)return null;let n=t.includes(`\\`)&&!t.includes(`/`)?`\\`:`/`,r=t.endsWith(n)?t.slice(0,-1):t;return r===``||/^[A-Za-z]:$/.test(r)?null:e===r||e===`${r}${n}`?{rest:``,separator:n}:e.startsWith(`${r}${n}`)?{rest:e.slice(r.length+1),separator:n}:null}function Tm(e,t=Cm){let n=wm(e,t.root);if(n!==null)return n.rest===``?`.`:`.${n.separator}${n.rest}`;let r=wm(e,t.home);return r===null?e:r.rest===``?`~`:`~${r.separator}${r.rest}`}function Em(e){return e.slice(0,8)}function Dm(e){if(!e)return;let t=new Date(e);return Number.isNaN(t.getTime())?void 0:t.toLocaleString()}function Om({sha:e,variant:t=`chip`,prefix:n,className:r,...i}){let a=e.slice(0,8);return(0,Q.jsx)(`span`,{"data-slot":`sha`,title:e,className:q(`font-mono tabular-nums`,t===`chip`?`shrink-0 rounded-sm border border-border bg-card px-1.5 py-px text-xs text-muted-foreground`:`select-all`,r),...i,children:n?`${n}${a}`:a})}function km({stat:e,compact:t=!1,className:n}){return(0,Q.jsx)(vs,{stat:e,compact:t,className:n})}function Am({value:e,variant:t=`plain`,className:n,...r}){return(0,Q.jsx)(`span`,{"data-slot":`count`,className:q(`tabular-nums`,t===`badge`&&`rounded-full bg-muted px-1.5 text-xs leading-[18px] font-medium text-muted-foreground`,t===`accent`&&`rounded-full bg-accent-strong/20 px-1.5 text-xs leading-[18px] font-semibold`,n),...r,children:e})}function jm({iso:e,now:t,ago:n=!1,prefix:r,fallback:i=``,title:a,className:o,...s}){let c=ys(e,t),l=c?n?Ss(c):c:i;return l?(0,Q.jsx)(`time`,{"data-slot":`relative-time`,dateTime:e,title:a??Dm(e),className:q(`tabular-nums`,o),...s,children:r?`${r}${l}`:l}):null}function Mm({value:e,variant:t=`inline`,wrap:n=!1,bases:r,className:i,...a}){return(0,Q.jsx)(`span`,{"data-slot":`path`,title:e,className:q(`font-mono`,t===`chip`?`block max-w-full truncate rounded-[6px] bg-muted px-1.5 py-0.5 text-xs font-medium text-muted-foreground`:n?`break-all`:`block min-w-0 truncate`,i),...a,children:r?Tm(e,r):e})}var Nm={category:`archive`,label:`Archived`,tone:`neutral`,shape:`filled`,pulse:!1},Pm={category:`capability`,label:`Dry run`};function Fm(e){return e&&e.charAt(0).toUpperCase()+e.slice(1)}var Im={"needs-permission":`Needs permission`,failed:`Failed`,"needs-you":`Needs you`,"needs-review":`Needs review`,running:`Running`,"usage-limit":`Usage limit`,"waiting-on-workers":`Waiting for workers`,"waiting-on-subagents":`Waiting for subagents`,"waiting-for-ci":`Waiting for CI`,"waiting-for-merge":`Waiting for merge`,"waiting-for-command":`Waiting for command`,monitoring:`Monitoring`,"waiting-for-capacity":`Waiting for capacity`,queued:`Queued`,done:`Done`,cancelled:`Cancelled`,unseen:`Unseen`},Lm={"needs-permission":`attention`,"needs-you":`attention`,"needs-review":`review`,failed:`execution`,running:`execution`,"usage-limit":`execution`,"waiting-on-workers":`execution`,"waiting-on-subagents":`execution`,"waiting-for-ci":`execution`,"waiting-for-merge":`execution`,"waiting-for-command":`execution`,monitoring:`execution`,"waiting-for-capacity":`execution`,queued:`execution`,done:`execution`,cancelled:`execution`,unseen:`attention`};function Rm(e,t,n){return e===`usage-limit`&&n===`provider-error`?`Provider error`:e===`waiting-on-workers`&&t?Fm(t.replace(/^waiting on\b/i,`Waiting for`)):e===`waiting-on-subagents`&&t||e===`monitoring`&&t&&t.toLowerCase()!==`monitoring`?Fm(t):Im[e]}function zm(e,t){let n=t??qe(e);return{category:Lm[n.rung],label:Rm(n.rung,n.label,e.autoResumeReason),tone:n.tone,shape:n.shape,pulse:n.pulse}}function Bm(e,t){let n=On(e);return{category:Lm[e],label:Rm(e,t??n.label),tone:n.tone,shape:n.shape,pulse:n.pulse}}var Vm={waiting:{category:`execution`,label:`Waiting`,tone:`pending`,shape:`ring`,pulse:!1},review:Bm(`needs-review`),running:Bm(`running`),queued:Bm(`queued`),done:Bm(`done`),failed:Bm(`failed`),cancelled:Bm(`cancelled`)};function Hm(e){return Vm[e]}function Um(e){return Hm(e).label}var Wm={waiting:{category:`execution`,label:`Scheduled`,tone:`running`,shape:`ring`,pulse:!1},paused:{category:`execution`,label:`Paused`,tone:`neutral`,shape:`filled`,pulse:!1},failed:{category:`execution`,label:`Failed`,tone:`danger`,shape:`filled`,pulse:!1},missed:{category:`attention`,label:`Missed`,tone:`pending`,shape:`filled`,pulse:!1},archived:Nm};function Gm(e){return e.schedule?.type===`once`?Wm[e.onceStatus??(e.enabled?`waiting`:`paused`)]:e.enabled?{category:`execution`,label:`Enabled`,tone:`success`,shape:`filled`,pulse:!1}:{category:`execution`,label:`Paused`,tone:`neutral`,shape:`filled`,pulse:!1}}var Km=/DRY_RUN=1\b/;function qm(e){return e!==void 0&&Km.test(e)}var Jm=new Set([`git`]);function Ym(e){return qm(e.version)?{availability:{category:`capability`,label:`Simulated`,tone:`neutral`,shape:`ring`,pulse:!1},mode:Pm,rawVersion:e.version}:e.available?{availability:{category:`capability`,label:`Installed`,tone:`success`,shape:`filled`,pulse:!1},version:e.version,rawVersion:e.version}:{availability:{category:`capability`,label:`Not installed`,tone:Jm.has(e.name)?`danger`:`neutral`,shape:`filled`,pulse:!1},rawVersion:e.version}}var Xm={connected:{category:`capability`,label:`Connected`,tone:`success`,shape:`filled`,pulse:!1},disconnected:{category:`capability`,label:`Not connected`,tone:`pending`,shape:`filled`,pulse:!1},"not-installed":{category:`capability`,label:`Not installed`,tone:`neutral`,shape:`filled`,pulse:!1},unknown:{category:`capability`,label:`Could not verify`,tone:`danger`,shape:`filled`,pulse:!1}};function Zm(e){return Xm[e]}function Qm(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:{}}function $m(){let e=U(),t=ce(),n=Z.useRef(0),r=Z.useRef(Promise.resolve()),i=Z.useMemo(()=>Fs(t.data?.sidebar?.projectOrder),[t.data?.sidebar?.projectOrder]),a=Z.useCallback(t=>{let i=e.getQueryData(V.uiState);if(i===void 0)return;let{projectOrder:a,...o}=Qm(i.sidebar),s=t===null?o:{...o,projectOrder:t};e.setQueryData(V.uiState,{...i,sidebar:s});let c=++n.current,l=r.current.then(async()=>{let t=await Ht({sidebar:s},{keepalive:!0});c===n.current&&e.setQueryData(V.uiState,t)});r.current=l.catch(t=>{H(t instanceof Error?t.message:String(t),{tone:`danger`}),c===n.current&&e.invalidateQueries({queryKey:V.uiState})})},[e]),o=Z.useCallback(e=>{let t=Fs(e);t.length===0||!Is(e.length)||a(t)},[a]),s=Z.useCallback(()=>a(null),[a]);return{order:i,canReorder:t.data!==void 0,setOrder:o,reset:s}}function eh(e){return[...e].sort((e,t)=>Date.parse(t.createdAt)-Date.parse(e.createdAt))}function th(e,t,n){let r=t.trim().toLowerCase();if(r===``)return 1;let i=(n?.length?`${e} ${n.join(` `)}`:e).toLowerCase(),a=r.split(/\s+/),o=0;for(let e of a){let t=i.indexOf(e);if(t===-1)return 0;let n=t===0||!/[a-z0-9]/.test(i[t-1]??``);o+=(n?1:.5)/(1+t/48)}return o/a.length}function nh(e,t){if(t.trim()===``)return e;let n=e=>e.rows.reduce((e,n)=>Math.max(e,th(n.value,t,n.keywords)),0);return e.map(e=>({group:e,score:n(e)})).sort((e,t)=>t.score-e.score).map(({group:e})=>e)}function rh(e,t){return{value:`task ${Ro(e)} ${e.hostId?`${e.hostId} `:``}${e.projectId?`${e.projectId} `:``}${e.id}`,keywords:[...e.hostLabel?[e.hostLabel]:[],...t?[t]:[],...e.projectId&&e.projectId!==t?[e.projectId]:[],...uh(e),...[e.branch,e.workflow,e.workflowLabel,e.pullRequestUrl,e.referencedPullRequestUrl,e.referencedIssueUrl].filter(e=>!!e)]}}var ih=e=>({value:`view ${e}`}),ah=e=>({value:`project ${e.name} ${e.id}`,keywords:[e.root]}),oh=e=>({value:`skill ${e.id} ${e.name} ${e.path??``}`,...zr({keywords:e.description?[e.description]:void 0})}),sh={value:`action toggle theme`},ch=150;function lh(e,t,n,r=[]){let i=eh(e.filter(e=>!No(e))).map(e=>({...e,projectId:t})),a=new Set(i.map(dh)),o=[...n??[],...r].filter(e=>No(e)||a.has(dh(e))?!1:(a.add(dh(e)),!0)).sort((e,t)=>t.createdAt.localeCompare(e.createdAt));return[...i,...o]}function uh(e){let t=new Set;for(let n of[e.pullRequestUrl,e.referencedPullRequestUrl,e.referencedIssueUrl]){let e=n?/\/(\d+)\/?$/.exec(n):null;e&&t.add(Number(e[1]))}for(let n of[e.prNumber,e.issueNumber,e.markerRefs?.pr,e.markerRefs?.issue])typeof n==`number`&&Number.isInteger(n)&&n>0&&t.add(n);return[...t].flatMap(e=>[String(e),`#${e}`])}var dh=e=>e.hostId===void 0?`${e.projectId??``}/${e.id}`:`${e.hostId}/${e.projectId??``}/${e.id}`;function fh(e){let t=e.filter(e=>mn(e)).sort((e,t)=>(t.finishedAt??``).localeCompare(e.finishedAt??``)),n=new Set(t.map(dh));return{recentlyFinished:t,otherTasks:e.filter(e=>!n.has(dh(e)))}}function ph(e,t,n=[]){let r=Ps(e,n);return[...r.filter(e=>e.id!==t),...r.filter(e=>e.id===t)]}function mh({canCreateTask:e=!0,onNavigateHostHref:t=e=>window.location.assign(e)}={}){let[n,r]=Z.useState(!1),i=To();wf(`k`,()=>r(e=>!e));let a=Z.useCallback(()=>{e&&(r(!1),i(`/new`))},[e,i]);return wf(`n`,a),Df(`c`,a),Z.useEffect(()=>{let e=()=>r(!0);return window.addEventListener(fl,e),()=>window.removeEventListener(fl,e)},[]),(0,Q.jsx)(ks,{open:n,onOpenChange:r,title:`Command palette`,description:`Search projects, tasks, views, actions, and skills`,showCloseButton:!1,filter:th,className:`top-[10vh] translate-y-0 sm:max-w-2xl lg:max-w-3xl xl:max-w-4xl`,children:(0,Q.jsx)(Ch,{close:()=>r(!1),canCreateTask:e,onNavigateHostHref:t})})}function hh({heading:e,tasks:t,projectName:n,showProject:r,now:i,onSelect:a,onLinkClick:o}){return(0,Q.jsx)(Ds,{heading:e,children:t.map(e=>(0,Q.jsx)(gh,{task:e,projectName:n(e),showProject:r,now:i,onSelect:a,onLinkClick:o},dh(e)))})}function gh({task:e,projectName:t,showProject:n,now:r,onSelect:i,onLinkClick:a}){let o=zm(e,qe(e)),s=Ro(e),c=e.hostId!==void 0&&e.projectId!==null?Re(e.hostId,e.projectId,e.id):null,l=(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Qo,{tone:o.tone,shape:o.shape,pulse:o.pulse,"aria-label":o.label,role:`img`}),e.delegation?.role===`worker`?(0,Q.jsx)(`span`,{className:`shrink-0 text-xs text-muted-foreground`,children:`Worker`}):null,(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:s}),e.hostId===void 0?null:(0,Q.jsx)(Dd,{label:e.hostLabel??e.hostId,hostId:e.hostId,className:`[&_svg]:size-3!`}),e.hostStale?(0,Q.jsx)(Od,{}):null,(n||e.hostId!==void 0)&&t?(0,Q.jsx)(`span`,{"data-slot":`palette-task-project`,className:e.hostId===void 0?`shrink-0 truncate text-xs text-soft-foreground`:`shrink-0 truncate text-xs text-soft-foreground max-sm:hidden`,children:t}):null,(0,Q.jsx)(jm,{iso:e.finishedAt??e.createdAt,now:r,className:`shrink-0 text-xs text-soft-foreground`})]});return(0,Q.jsx)(As,{...rh(e,t),"data-slot":`palette-task`,"data-run-id":e.id,"data-host-id":e.hostId,"data-project-id":e.projectId??void 0,onSelect:()=>i(e),children:c?(0,Q.jsx)(`a`,{href:c,tabIndex:-1,"data-slot":`palette-host-task-link`,className:`-mx-2 -my-3 flex min-w-0 flex-1 items-center gap-2 px-2 py-3 text-inherit no-underline`,onClick:e=>{e.stopPropagation(),!e.metaKey&&!e.ctrlKey&&!e.shiftKey&&!e.altKey&&e.button===0&&a()},children:l}):l})}function _h({multiProject:e,hasProjectScope:t,health:n,reports:r}){return[...e?[{label:`All tasks`,to:`/tasks`,icon:ri,global:!0}]:[],...t?Vf({forge:n.data?.forge?.available===!0,automations:mm(n.data),reports:r}).map(e=>({label:e.label,to:e.to,icon:e.icon,global:!1})):[]]}function vh({views:e,go:t,goGlobal:n,orderedProjects:r,activeProjectId:i,goProject:a,otherTasks:o,searching:s,taskProjectName:c,showProjectOnTasks:l,now:u,selectTask:d,orderedSkills:f,skillRunner:p,theme:m,nextTheme:h,setTheme:g,close:_}){let v=[{rows:e.map(e=>ih(e.label)),node:(0,Q.jsx)(Ds,{heading:`Views`,children:e.map(e=>{let r=e.icon;return(0,Q.jsxs)(As,{...ih(e.label),"data-slot":`palette-view`,"data-nav-to":e.to,onSelect:()=>e.global?n(e.to):t(e.to),children:[(0,Q.jsx)(r,{"aria-hidden":`true`}),e.label]},e.to)})},`views`)}];return r.length>0&&v.push({rows:r.map(ah),node:(0,Q.jsx)(Ds,{heading:`Projects`,children:r.map(e=>{let t=e.id===i,n=e.status===`missing`;return(0,Q.jsxs)(As,{...ah(e),"data-slot":`palette-project`,"data-project-id":e.id,disabled:n,onSelect:()=>a(e.id),children:[(0,Q.jsx)(ii,{"aria-hidden":`true`}),(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.name}),n?(0,Q.jsx)(`span`,{className:`shrink-0 text-xs text-soft-foreground`,children:`folder not found`}):e.branch===void 0?null:(0,Q.jsx)(`span`,{className:`shrink-0 font-mono text-xs text-soft-foreground`,children:e.branch}),t?(0,Q.jsx)(Ni,{"aria-hidden":`true`,className:`size-3.5 shrink-0 text-link-foreground`}):null]},e.id)})},`projects`)}),o.length>0&&v.push({rows:s?o.map(e=>rh(e,c(e))):[],node:(0,Q.jsx)(hh,{heading:`Tasks`,tasks:o,projectName:c,showProject:l,now:u,onSelect:d,onLinkClick:_},`tasks`)}),v.push({rows:[sh],node:(0,Q.jsx)(Ds,{heading:`Actions`,children:(0,Q.jsxs)(As,{...sh,"data-slot":`palette-action`,"data-action":`toggle-theme`,onSelect:()=>{g(h),_()},children:[(0,Q.jsx)(xi,{"aria-hidden":`true`}),`Toggle theme`,(0,Q.jsxs)(Os,{className:`tracking-normal`,children:[m,` → `,h]})]})},`actions`)}),f.length>0&&v.push({rows:f.map(oh),node:(0,Q.jsx)(Ds,{heading:`Skills`,children:f.map(e=>(0,Q.jsxs)(As,{...oh(e),"data-slot":`palette-skill`,"data-skill":e.id,onSelect:()=>t(xp({skill:e.id,skillPath:e.path,runner:p})),children:[(0,Q.jsx)(`span`,{className:`shrink-0 font-medium`,children:e.name}),e.path?(0,Q.jsx)(`span`,{className:`min-w-0 truncate text-xs`,children:e.path}):null,e.description?(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs text-soft-foreground`,children:e.description}):null]},JSON.stringify([e.id,e.path])))},`skills`)}),v}function yh({search:e,setSearch:t}){return(0,Q.jsx)(Ts,{placeholder:`Search projects, tasks, views, actions, skills…`,value:e,onValueChange:t})}function bh({search:e,searching:t,recentlyFinished:n,groups:r,taskProjectName:i,showProjectOnTasks:a,now:o,selectTask:s,go:c,showNewTask:l,close:u}){return(0,Q.jsxs)(Ms,{className:`max-h-[55vh] min-h-[14rem] sm:max-h-[60vh] lg:max-h-[68vh]`,children:[(0,Q.jsx)(js,{children:`Nothing matches.`}),l?(0,Q.jsx)(Ds,{children:(0,Q.jsxs)(As,{value:`new task`,"data-slot":`palette-view`,"data-nav-to":`/new`,onSelect:()=>c(`/new`),children:[(0,Q.jsx)(vi,{"aria-hidden":`true`}),`New task`,(0,Q.jsx)(Os,{children:`C`})]})}):null,!t&&n.length>0?(0,Q.jsx)(hh,{heading:`Recently finished`,tasks:n,projectName:i,showProject:a,now:o,onSelect:s,onLinkClick:u}):null,nh(r,e).map(e=>e.node)]})}function xh({cappedProjects:e}){return e.length===0?null:(0,Q.jsxs)(`p`,{"data-slot":`palette-search-truncated`,role:`status`,className:`border-t border-border px-3 py-2 text-xs text-soft-foreground`,children:[`More matches in `,e.join(`, `),`. Type more to narrow them.`]})}function Sh(e,t,n,r,i){if(e!==null)return{fallbackProjectId:null,queryProjectId:void 0,fetchProjectQueries:!0,hasProjectScope:!0,runsProjectId:e};if(t!==void 0){if(t.bootProject!==null)return{fallbackProjectId:null,queryProjectId:void 0,fetchProjectQueries:!0,hasProjectScope:!0,runsProjectId:t.bootProject};let e=ph(t.projects,null,r).find(e=>e.status!==`missing`)?.id??null,n=e!==null;return{fallbackProjectId:e,queryProjectId:e??void 0,fetchProjectQueries:n,hasProjectScope:n,runsProjectId:e}}let a=n!==void 0&&n.bootProject!==null;return{fallbackProjectId:null,queryProjectId:void 0,fetchProjectQueries:a,hasProjectScope:n===void 0?i:a,runsProjectId:null}}function Ch({close:e,canCreateTask:t,onNavigateHostHref:n}){let r=To(),i=Kn(),[o,s]=Z.useState(``),l=o.trim()!==``,u=Ao(),{theme:d,setTheme:f}=lf(),p=A(),m=c(),h=p.data,{order:g}=$m(),{fallbackProjectId:_,queryProjectId:v,fetchProjectQueries:y,hasProjectScope:b,runsProjectId:x}=Sh(u,h,m.data,g,t),S=T(y,v),w=re(void 0,void 0,y,v),E=C(y,v),D=Date.now(),O=h!==void 0&&h.projects.length>1,k=a(O),j=Z.useMemo(()=>O?ph(h.projects,u,g):[],[O,h,u,g]),M=Z.useMemo(()=>new Map((h?.projects??[]).map(e=>[e.id,e.name])),[h]),[N,ee]=Z.useState(``);Z.useEffect(()=>{let e=setTimeout(()=>ee(o),ch);return()=>clearTimeout(e)},[o]);let P=z(N),F=Ep(o),I=l?P.data?.runs:void 0,L=[...l&&!P.isPlaceholderData?(P.data?.truncated??[]).map(e=>M.get(e)??e):[],...F.remoteTruncated],R=Z.useMemo(()=>lh(S.data??[],x,k.data?.runs,I),[S.data,x,k.data,I]),te=Z.useMemo(()=>l&&F.remoteTasks.length>0?[...R,...F.remoteTasks]:R,[R,l,F.remoteTasks]),ne=Z.useMemo(()=>fh(R),[R]),ie=l?[]:ne.recentlyFinished,ae=l?te:ne.otherTasks,oe=O,B=e=>e.projectId===null?null:e.hostId===void 0?M.get(e.projectId)??null:F.remoteProjectName(e.hostId,e.projectId),se=E.data?.skillUsage,ce=Z.useMemo(()=>Us(w.data??[],se),[w.data,se]),le=t=>{e(),r(_===null?t:wo(_,t))},ue=t=>{e(),i(t)},de=pm(),fe=t=>{e(),de.go(t)},pe=t=>{if(e(),t.hostId!==void 0&&t.projectId!==null){n(Re(t.hostId,t.projectId,t.id));return}r(t.projectId===null?`/tasks/${t.id}`:wo(t.projectId,`/tasks/${t.id}`))},me=uf[d],he=ym()!==`absent`,ge=vh({views:_h({multiProject:O||F.hasHosts,hasProjectScope:b,health:m,reports:he}),go:le,goGlobal:ue,orderedProjects:j,activeProjectId:u,goProject:fe,otherTasks:ae,searching:l,taskProjectName:B,showProjectOnTasks:oe,now:D,selectTask:pe,orderedSkills:ce,skillRunner:w.runner,theme:d,nextTheme:me,setTheme:f,close:e});return b&&(w.isError||w.list?.source===`unavailable`)&&l&&ge.push({rows:[{value:o.trim()}],node:(0,Q.jsx)(Ds,{heading:`Skills`,children:(0,Q.jsxs)(As,{value:o.trim(),onSelect:()=>le(xp({skill:o.trim(),runner:w.runner})),children:[`Use skill id “`,o.trim(),`” (unchecked)`]})},`unchecked-skill`)}),(0,Q.jsxs)(Q.Fragment,{children:[yh({search:o,setSearch:s}),bh({search:o,searching:l,recentlyFinished:ie,groups:ge,taskProjectName:B,showProjectOnTasks:oe,now:D,selectTask:pe,go:le,showNewTask:b,close:e}),xh({cappedProjects:L}),(0,Q.jsx)(Dp,{unanswered:F.unanswered,error:F.searchError,warning:F.searchWarning,className:`border-t border-border px-3 py-2`})]})}var wh=Z.createContext(null);function Th({children:e}){let[t,n]=Z.useState(`active`),r=_m(),i=r?t:`active`,a=Z.useMemo(()=>[i,n,r],[i,r]);return(0,Q.jsx)(wh.Provider,{value:a,children:e})}function Eh(){let e=Z.useContext(wh);if(!e)throw Error(`useListView must be used inside a <ListViewProvider>`);return e}function Dh(e){return e.toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`,second:`2-digit`})}function Oh(){let e=Gr(),t=U(),[n,r]=(0,Z.useState)(!1),[i,a]=(0,Z.useState)(null),o=!!e?.offline;if((0,Z.useEffect)(()=>{o||a(null)},[o]),!e||!e.offline||e.state===null)return null;let s=e.state,c=At(s),l=Xe({hostId:e.hostId,hostLabel:e.hostLabel,state:s}),u=async()=>{if(!n){r(!0);try{try{await un()}catch{}await t.refetchQueries({queryKey:Xr.hosts,exact:!0});let n=t.getQueryData(Xr.hosts)?.hosts.find(t=>t.id===e.hostId)?.state??s;if(n!==`connected`){let e=At(n).label,t=Dh(new Date);a(n=>({label:e,time:t,count:(n?.count??0)+1}))}else a(null)}finally{r(!1)}}};return(0,Q.jsxs)(`div`,{"data-slot":`host-offline-banner`,"data-host-id":e.hostId,"data-host-state":s,role:c.bannerTone===`danger`?`alert`:`status`,className:q(`flex min-h-9 flex-wrap items-center gap-x-3 gap-y-1.5 border-b border-border px-4 py-1.5 text-sm text-foreground`,c.bannerTone===`danger`?`bg-destructive/10`:`bg-muted/50`),children:[(0,Q.jsx)(Ed,{state:s,className:`shrink-0`}),(0,Q.jsxs)(`span`,{className:`min-w-0 flex-1 [overflow-wrap:break-word]`,children:[l,(0,Q.jsx)(`span`,{role:`status`,"aria-live":`polite`,"aria-atomic":`true`,"data-slot":`host-retry-feedback`,className:i?`ml-2 text-xs text-muted-foreground`:`sr-only`,children:i?(0,Q.jsxs)(`span`,{children:[`Still `,i.label,` (`,i.time,`).`]},i.count):null})]}),(0,Q.jsx)(Y,{type:`button`,size:`sm`,variant:`outline`,"data-action":`host-retry`,disabled:n,onClick:()=>void u(),className:`ml-auto shrink-0`,children:n?`Checking…`:`Retry`})]})}function kh(e,t){if(typeof e!=`object`||!e||Array.isArray(e))return{};let n=e,r={};for(let{id:e}of t?.runners??[]){let t=n[e];typeof t==`string`&&t.length>0&&t.length<=128&&(r[e]=t)}return r}function Ah(e,t,n){if(!e||!n)return[];let r=new Map(e.providers.map(e=>[e.provider,e]));return n.runners.flatMap(({id:e,displayName:n})=>{let i=r.get(e);return i?.status!==`disconnected`||!i.authFailureId||t[e]===i.authFailureId?[]:[{provider:e,label:n,authFailureId:i.authFailureId}]})}function jh(e,t){return{...e,...Object.fromEntries(t.map(({provider:e,authFailureId:t})=>[e,t]))}}function Mh({status:e,runners:t,pending:n,error:r,dismissals:i,onDismissAuthFailures:a,accounts:o=[]}){if(n||!e)return null;let s;try{s=Ct(e)}catch{return null}let c=Ah(s,i,t);if(c.length>0)return(0,Q.jsxs)(`div`,{"data-slot":`provider-banner`,role:`alert`,className:`flex min-h-9 items-center gap-2 border-b border-border bg-destructive/10 px-4 text-sm text-foreground`,children:[(0,Q.jsx)(Qo,{tone:`danger`}),(0,Q.jsxs)(`span`,{children:[`Provider authentication failed during a task:`,` `,c.map(({label:e})=>e).join(`, `),`.`]}),(0,Q.jsx)(X,{to:`/settings/agent-defaults#providers`,className:`ml-auto shrink-0 font-medium underline underline-offset-4 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`,children:`Open agent settings`}),(0,Q.jsx)(`button`,{type:`button`,"aria-label":`Dismiss provider authentication alert`,onClick:()=>a(c),className:`shrink-0 rounded-sm p-1 text-muted-foreground hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`,children:(0,Q.jsx)(dl,{className:`size-4`,"aria-hidden":`true`})})]});if(r||s.providers.some(e=>e.enabled&&jt(e,o)))return null;let l=s.providers.some(e=>jt(e,o)),u=s.providers.some(e=>e.status===`unknown`);return(0,Q.jsxs)(`div`,{"data-slot":`provider-banner`,role:`status`,className:`flex min-h-9 items-center gap-2 border-b border-border bg-muted/50 px-4 text-sm text-muted-foreground`,children:[(0,Q.jsx)(Qo,{tone:u?`danger`:`pending`}),(0,Q.jsx)(`span`,{children:l?`No agent provider is enabled.`:u?`No connected provider could be verified.`:`No agent provider credentials were found.`}),(0,Q.jsx)(X,{to:`/settings/agent-defaults#providers`,className:`ml-auto shrink-0 font-medium text-foreground underline underline-offset-4 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`,children:`Configure providers`})]})}function Nh(e){if(!(typeof e!=`object`||!e||Array.isArray(e)))return e}function Ph(){let e=ee(),t=L().data,n=Xs(),r=ce(),i=U(),a=(0,Z.useRef)(Promise.resolve()),o=(0,Z.useRef)(0),s=(0,Z.useRef)(0),c=(0,Z.useRef)(Nh(r.data));(0,Z.useEffect)(()=>{s.current===0&&(c.current=Nh(r.data))},[r.data]);let l=(0,Z.useCallback)(e=>{let n=V.uiState,r=Nh(i.getQueryData(n)),l=jh(kh(r?.dismissedProviderAuthFailures,t),e),u={...r,dismissedProviderAuthFailures:l};s.current+=1,i.setQueryData(n,u);let d=++o.current;a.current=a.current.then(async()=>{try{let e=await Ht({dismissedProviderAuthFailures:l});c.current=Nh(e),d===o.current&&i.setQueryData(n,e)}catch(e){d===o.current&&(c.current===void 0?i.removeQueries({queryKey:n,exact:!0}):i.setQueryData(n,c.current),i.invalidateQueries({queryKey:n}),H(e instanceof Error?e.message:String(e),{tone:`danger`}))}finally{--s.current}})},[i,t]);return(0,Q.jsx)(Mh,{status:e.data,runners:t,pending:e.isPending,error:e.isError,dismissals:kh(Nh(r.data)?.dismissedProviderAuthFailures,t),onDismissAuthFailures:l,accounts:n})}function Fh(e={displayName:`Squawk`,command:`hsq`,npx:`npx -p @hearsay-tools/squawk hsq`}){return e.command}function Ih(e){return e.reason===`legacy-change`?e.canImport?`${e.file} changed in the old home. Import keeps live-only changes. Old-home changes win when both homes changed the same key or entry.`:`${e.file} changed in the old home. Import is unavailable. Ignore keeps the live file and skips these old-home changes.`:e.reason===`outside-write`?`${e.file} changed outside Squawk. Restore the previous version or accept the file as found.`:e.file===`config.json`?`The project registry was reset. Restore the previous projects?`:`The account list was reset. Restore the previous accounts?`}function Lh({file:e,editable:t}){let n=Ec(),r=Dc(),i=Oc(),a=e.reason===`legacy-change`,o=n.isPending||r.isPending||i.isPending,s=n.error??r.error??i.error,c=t=>{n.reset(),r.reset(),i.reset();let a={file:e.file,detectedAt:e.detectedAt};t===`restore`?n.mutate(a):t===`accept`?r.mutate(a):i.mutate(a)};return(0,Q.jsxs)(`div`,{"data-slot":`home-recovery`,"data-home-file":e.file,role:`status`,"aria-live":`polite`,"aria-busy":o,className:`flex flex-wrap items-center gap-x-3 gap-y-2 border-b border-border bg-muted/50 p-3 text-sm text-foreground`,children:[(0,Q.jsx)(`span`,{className:`flex-[1_1_24rem] [min-inline-size:0] [overflow-wrap:break-word]`,children:Ih(e)}),t?(0,Q.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[a?e.canImport&&(0,Q.jsx)(Y,{type:`button`,"data-action":`import`,disabled:o,onClick:()=>c(`import`),children:`Import changes from the old home`}):(0,Q.jsx)(Y,{type:`button`,"data-action":`restore`,disabled:o||!e.canRestore,onClick:()=>c(`restore`),children:`Restore`}),(0,Q.jsx)(Y,{type:`button`,variant:`outline`,"data-action":`accept`,disabled:o,onClick:()=>c(`accept`),children:a?`Ignore`:`Accept as found`})]}):t===!1&&(0,Q.jsxs)(`p`,{className:`basis-full`,children:[a?e.canImport?`Only the host operator can import or ignore this file.`:`Only the host operator can ignore this file.`:`Only the host operator can restore or accept this file.`,e.file.startsWith(`remote-settings/`)&&(a?(0,Q.jsxs)(Q.Fragment,{children:[` `,e.canImport&&(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`code`,{children:[Fh(),` backup import `,e.file]}),` or `]}),(0,Q.jsxs)(`code`,{children:[Fh(),` backup ignore `,e.file]})]}):(0,Q.jsxs)(Q.Fragment,{children:[` `,(0,Q.jsxs)(`code`,{children:[Fh(),` backup restore `,e.file]})]}))]}),t&&s&&(0,Q.jsx)(`p`,{role:`alert`,className:`basis-full text-danger`,children:s.message})]})}function Rh(){let e=Sc(),t=c().data?.capabilities?.localHandoff;return(0,Q.jsx)(`div`,{"data-slot":`home-recovery-state`,"data-state":e.isSuccess?`ready`:e.isError?`error`:`pending`,children:e.data?.files.map(e=>(0,Q.jsx)(Lh,{file:e,editable:!e.file.startsWith(`remote-settings/`)&&t},e.file))})}var zh=`hsq:reloaded-for-version`,Bh=new WeakMap;function Vh(e,t){if(!t)return null;let n=Bh.get(e);return n===void 0?(Bh.set(e,t),null):t===n?null:t}function Hh(e,t=eg()){try{return t?.getItem(Qr(zh))===e}catch{return!1}}function Uh(e,t=()=>window.location.reload()){try{eg()?.setItem(Qr(zh),e)}catch{}t()}var Wh=[`textarea`,`input${[`search`,`checkbox`,`radio`,`hidden`,`button`,`submit`,`reset`,`image`,`file`,`range`,`color`].map(e=>`:not([type="${e}"])`).join(``)}`,`[contenteditable=""]`,`[contenteditable="true"]`].join(`, `),Gh=new WeakSet,Kh=new Set;function qh(){let e=Symbol(`unsent-draft`);return Kh.add(e),()=>{Kh.delete(e)}}function Jh(e){(0,Z.useEffect)(()=>e?qh():void 0,[e])}var Yh=new WeakMap;function Xh(e){return e instanceof HTMLTextAreaElement||e instanceof HTMLInputElement?e.value:e.textContent??``}function Zh(e=document){let t=e=>{let t=e.target;t instanceof Element&&t.matches(Wh)&&!Yh.has(t)&&Yh.set(t,Xh(t))},n=e=>{e.target&&Gh.add(e.target)};return e.addEventListener(`focusin`,t,!0),e.addEventListener(`input`,n,!0),()=>{e.removeEventListener(`focusin`,t,!0),e.removeEventListener(`input`,n,!0)}}function Qh(e){if(!Gh.has(e)||e.closest(`[data-persisted-draft], [data-slot="composer"], [data-reports-dirty]`)||(e instanceof HTMLTextAreaElement||e instanceof HTMLInputElement)&&(e.disabled||e.readOnly))return!1;let t=Xh(e).trim(),n=Yh.get(e);return n===void 0?t!==``:t!==n.trim()}function $h(e=document){return Kh.size>0||Array.from(e.querySelectorAll(Wh)).some(Qh)}function eg(){try{return typeof window>`u`?void 0:window.sessionStorage}catch{return}}var tg=2e3;function ng({reload:e}){let t=Pe(),n=c(),r=Yr(t),i=t?r.data?.version:n.data?.version,a=U(),[o,s]=(0,Z.useState)(null),[l,u]=(0,Z.useState)(`reloading`);return(0,Z.useEffect)(()=>Zh(),[]),(0,Z.useEffect)(()=>{let e=Vh(a,i);e!==null&&s(e)},[a,i]),(0,Z.useEffect)(()=>{if(o===null)return;if(Hh(o)){u(`manual`);return}let t=()=>$h()?(u(`waiting-for-input`),!1):(u(`reloading`),Uh(o,e),!0);if(t())return;let n=window.setInterval(()=>{t()&&window.clearInterval(n)},tg);return()=>window.clearInterval(n)},[o,e]),o===null?null:(0,Q.jsxs)(`div`,{"data-slot":`version-reload`,"data-phase":l,role:`status`,className:`flex min-h-9 flex-wrap items-center gap-x-3 gap-y-1 border-b border-border bg-muted/50 px-4 py-1 text-sm text-foreground`,children:[(0,Q.jsx)(`span`,{children:l===`reloading`?`Squawk was updated to ${o}. Reloading…`:l===`waiting-for-input`?`Squawk was updated to ${o}. It reloads once your unsent message is sent or cleared.`:`Squawk was updated to ${o}. Reload to use the new version.`}),l===`reloading`?null:(0,Q.jsx)(Y,{type:`button`,size:`sm`,variant:`outline`,className:`ml-auto`,"data-action":`version-reload`,onClick:()=>Uh(o,e),children:`Reload now`})]})}var rg=`cez-project-rail-expanded`;function ig(e,t){return e-232-t>=640}function ag(){try{return localStorage.getItem(rg)===`1`}catch{return!1}}function og(e){try{localStorage.setItem(rg,e?`1`:`0`)}catch{}}var sg=Z.lazy(()=>W(()=>import(`./project-rail-sortable-BmVI4_-T.js`),__vite__mapDeps([0,1,2,3,4])));function cg(e){if(e!==void 0)return e.isDragging?`relative z-10 opacity-40 [-webkit-touch-callout:none]`:`[-webkit-touch-callout:none]`}function lg({project:e,signal:t,known:n,current:r,target:i,onSwitchProject:a,onSelectProject:o,sort:s}){let c=S(e.name,t,{unknown:!n});return(0,Q.jsxs)(`div`,{ref:s?.setNodeRef,style:s?.style,...s?.listeners,"data-slot":`rail-project`,"data-project-id":e.id,"data-dragging":s?.isDragging?``:void 0,className:q(`relative flex h-[52px] w-full shrink-0 items-center justify-center`,cg(s)),children:[r?(0,Q.jsx)(`span`,{"aria-hidden":`true`,"data-slot":`rail-current-bar`,className:`absolute top-1/2 left-0 h-5 w-[3px] -translate-y-1/2 rounded-r-[2px] bg-foreground`}):null,(0,Q.jsxs)(`div`,{className:`relative size-9`,children:[(0,Q.jsx)(G,{ref:s?.setActivatorNodeRef,"aria-describedby":s?.attributes[`aria-describedby`],to:i.href,onClick:t=>{t.defaultPrevented||t.button!==0||t.metaKey||t.ctrlKey||t.shiftKey||t.altKey||(o?.(e.id),i.verify&&a&&(t.preventDefault(),a(e.id)))},"aria-label":c,title:c,"aria-current":r?`page`:void 0,className:q(`flex size-full items-center justify-center rounded-[9px] border text-[12px] leading-none font-semibold focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring`,r?`border-soft-foreground bg-sidebar-row-selected text-foreground`:`border-transparent bg-muted text-muted-foreground hover:text-foreground`),children:b(e.name)}),(0,Q.jsx)(jd,{position:`top`,segments:Md(t).top}),(0,Q.jsx)(jd,{position:`bottom`,segments:Md(t).bottom})]})]})}var ug=`motion-safe:rail-text-in`;function dg({project:e,signal:t,known:n,current:r,target:i,onSwitchProject:a,onSelectProject:o,sort:s}){let c=S(e.name,t,{unknown:!n}),{top:l,bottom:u}=Md(t),d=r?`border-sidebar-row-selected`:`border-background group-hover:border-sidebar-row-hover`;return(0,Q.jsxs)(`div`,{ref:s?.setNodeRef,style:s?.style,...s?.listeners,"data-slot":`rail-project`,"data-project-id":e.id,"data-dragging":s?.isDragging?``:void 0,className:q(`group/row relative w-full shrink-0`,cg(s)),children:[(0,Q.jsxs)(G,{to:i.href,onClick:t=>{t.defaultPrevented||t.button!==0||t.metaKey||t.ctrlKey||t.shiftKey||t.altKey||(o?.(e.id),i.verify&&a&&(t.preventDefault(),a(e.id)))},"aria-label":c,"aria-current":r?`page`:void 0,className:q(`group flex h-[52px] w-full items-center gap-[10px] rounded-[8px] px-[6px] pr-6 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring`,r?`bg-sidebar-row-selected`:`hover:bg-sidebar-row-hover`),children:[(0,Q.jsxs)(`span`,{"aria-hidden":`true`,"data-slot":`rail-mark`,className:q(`relative flex size-9 shrink-0 items-center justify-center rounded-[9px] border text-[12px] leading-none font-semibold`,r?`border-soft-foreground bg-sidebar text-foreground`:`border-transparent bg-muted text-muted-foreground`),children:[b(e.name),(0,Q.jsx)(jd,{position:`top`,segments:l,className:d}),(0,Q.jsx)(jd,{position:`bottom`,segments:u,className:d})]}),(0,Q.jsxs)(`span`,{className:q(`flex min-w-0 flex-1 flex-col gap-px`,ug),children:[(0,Q.jsx)(`span`,{"data-slot":`rail-project-name`,className:q(`truncate text-[13.5px] leading-[18px] font-semibold`,r?`text-foreground`:`text-muted-foreground`),children:e.name}),(0,Q.jsx)(wd,{signal:t,known:n,current:r,maxParts:2,slot:`rail-project-state`,className:`h-4 gap-x-[4px] overflow-hidden text-xs leading-4 whitespace-nowrap`})]})]}),s?(0,Q.jsx)(fg,{name:e.name,sort:s}):null]})}function fg({name:e,sort:t}){return(0,Q.jsx)(`button`,{type:`button`,ref:t.setActivatorNodeRef,"data-slot":`rail-project-grip`,...t.attributes,"aria-label":`Reorder ${e}, position ${t.position} of ${t.total}`,className:q(`absolute top-1/2 right-0.5 flex h-10 w-5 -translate-y-1/2 cursor-grab touch-none items-center justify-center rounded text-soft-foreground opacity-0 outline-none transition-opacity hover:text-foreground motion-reduce:transition-none`,`focus-visible:opacity-100 focus-visible:ring-[3px] focus-visible:ring-ring/50`,`group-hover/row:opacity-100 group-focus-within/row:opacity-100 [@media(hover:none)]:opacity-100`),children:(0,Q.jsx)(el,{"aria-hidden":`true`,className:`size-3.5`})})}function pg(e){return q(`flex shrink-0 items-center rounded-[8px] text-soft-foreground hover:bg-sidebar-row-hover hover:text-foreground focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring`,e?`size-auto h-9 w-full justify-start gap-3 px-2.5 text-[13px] font-normal`:`size-9 justify-center`)}var mg=q(`truncate text-muted-foreground group-hover:text-foreground`,ug);function hg({to:e,label:t,slot:n,active:r,expanded:i,children:a}){return(0,Q.jsxs)(G,{to:e,"data-slot":n,"aria-label":t,title:i?void 0:t,"aria-current":r?`page`:void 0,className:q(`group`,pg(i),r&&`bg-sidebar-row-selected text-foreground hover:bg-sidebar-row-selected`),children:[a,i?(0,Q.jsx)(`span`,{className:mg,children:t}):null]})}function gg(e){let[t,n]=Z.useState(()=>window.innerWidth);return Z.useEffect(()=>{let e=()=>n(window.innerWidth);return window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[]),ig(t,e)}function _g(){let e=gg(Z.useContext(vl));return(0,Q.jsx)(`div`,{"aria-hidden":`true`,"data-slot":`project-rail-placeholder`,style:{width:ag()&&e?232:60},className:`hidden shrink-0 border-r border-border bg-background md:block`})}var vg=e=>({href:String(wo(e,`/`)),verify:!1});function yg({expanded:e,resolvedTheme:t,version:n}){let r=n?`Squawk v${n}`:`Squawk`;return e?(0,Q.jsxs)(`div`,{"data-slot":`rail-identity`,className:`flex shrink-0 flex-col gap-0.5`,children:[(0,Q.jsxs)(`div`,{className:`flex h-[34px] items-center gap-[10px] px-0.5`,children:[(0,Q.jsx)(`img`,{src:`/cezarion-mark-${t}.svg`,alt:``,"aria-hidden":`true`,"data-slot":`rail-app-mark`,className:`size-[34px] shrink-0 rounded-[8px]`}),(0,Q.jsxs)(`span`,{className:q(`flex min-w-0 items-baseline gap-[10px] whitespace-nowrap`,ug),"aria-label":r,children:[(0,Q.jsx)(`span`,{className:`text-[15px] leading-none font-bold text-foreground`,children:`Squawk`}),n?(0,Q.jsxs)(`span`,{"data-slot":`rail-version`,title:`v${n}`,className:`min-w-0 truncate text-xs leading-none text-soft-foreground`,children:[`v`,n]}):null]})]}),(0,Q.jsx)(`div`,{"aria-hidden":`true`,className:`h-px w-full bg-border`}),(0,Q.jsx)(`div`,{className:q(`px-1 pt-2.5 pb-1 text-xs font-medium text-soft-foreground`,ug),children:`Projects`})]}):(0,Q.jsxs)(`div`,{className:`flex shrink-0 flex-col items-center gap-0.5`,children:[(0,Q.jsx)(`img`,{src:`/cezarion-mark-${t}.svg`,alt:r,title:r,"data-slot":`rail-app-mark`,className:`size-[34px] rounded-[9px]`}),(0,Q.jsx)(`div`,{"aria-hidden":`true`,className:`mt-0.5 mb-1.5 h-px w-6 bg-border`})]})}function bg({expanded:e}){return e?(0,Q.jsx)(fd,{origin:`rail`,icon:vi,iconClassName:`size-[15px] text-soft-foreground`,iconFrameClassName:`flex size-9 shrink-0 items-center justify-center rounded-[9px] border border-border`,label:`Add project`,side:`right`,triggerClassName:q(`h-[44px] w-full shrink-0 justify-start gap-[10px] rounded-[8px] px-[6px] text-[13px] font-normal text-muted-foreground hover:bg-sidebar-row-hover hover:text-foreground focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring motion-safe:[&>span:last-child]:rail-text-in`)}):(0,Q.jsx)(fd,{origin:`rail`,icon:vi,iconClassName:`size-[15px]`,side:`right`,triggerClassName:`shrink-0 rounded-[9px] border border-border text-soft-foreground hover:bg-muted hover:text-foreground focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring`})}function xg({roomToExpand:e,expanded:t,toggle:n,railId:r,allProjectsActive:i,settingsActive:a}){return(0,Q.jsxs)(`div`,{"data-slot":`rail-bottom`,className:q(`flex shrink-0 flex-col gap-0.5 pt-2`,t?`items-stretch`:`items-center`),children:[e?(0,Q.jsxs)(`button`,{type:`button`,"data-slot":`rail-expand-toggle`,"aria-expanded":t,"aria-controls":r,"aria-label":t?`Collapse projects`:`Expand projects`,title:t?void 0:`Expand projects`,onClick:n,className:q(`group`,pg(t)),children:[t?(0,Q.jsx)(il,{className:`size-4 shrink-0`,"aria-hidden":`true`}):(0,Q.jsx)(al,{className:`size-4 shrink-0`,"aria-hidden":`true`}),t?(0,Q.jsx)(`span`,{className:mg,children:`Collapse`}):null]}):null,(0,Q.jsx)(hg,{to:`/tasks`,label:`All projects`,slot:`rail-all-projects`,active:i,expanded:t,children:(0,Q.jsx)(ri,{className:`size-4 shrink-0`,"aria-hidden":`true`})}),(0,Q.jsx)(hg,{to:`/settings/global/appearance`,label:`Global settings`,slot:`rail-global-settings`,active:a,expanded:t,children:(0,Q.jsx)(ti,{className:`size-4 shrink-0`,"aria-hidden":`true`})}),(0,Q.jsx)(ff,{showLabel:t,labelClassName:mg,className:q(`group`,pg(t),`[&_svg]:size-4`)})]})}function Sg({children:e,rememberFocus:t,restoreFocus:n}){return Z.useLayoutEffect(()=>(n(),t),[t,n]),(0,Q.jsx)(Q.Fragment,{children:e})}function Cg({projects:e,signals:t,version:n,projectTarget:r=vg,onSwitchProject:i,onSelectProject:a,canReorder:o=!1,onReorder:s,hostsData:c}){let{pathname:l}=qn(),{resolvedTheme:u}=lf(),d=Z.useContext(vl),[f,p]=Z.useState(ag),m=gg(d),h=f&&m,g=()=>{let e=!h;p(e),og(e)},_=Eo(l),v=l===`/tasks`,y=l===`/settings/global`||l.startsWith(`/settings/global/`),b=Z.useId(),x=Z.useRef(null),S=Z.useRef(null),C=Z.useCallback(()=>{let e=document.activeElement;if(!(e instanceof HTMLAnchorElement)||!x.current?.contains(e))return;let t=e.closest(`[data-project-id]`)?.dataset.projectId;t&&(S.current={link:e,projectId:t})},[]),w=Z.useCallback(()=>{let e=S.current;if(S.current=null,!e||e.link.isConnected||document.activeElement!==document.body)return;let t=x.current?.querySelectorAll(`[data-project-id]`)??[];for(let n of t)if(n.dataset.projectId===e.projectId){n.querySelector(`a`)?.focus({preventScroll:!0});break}},[]),T=o&&s!==void 0&&e.length>1,E=(e,n)=>(0,Q.jsx)(h?dg:lg,{project:e,signal:t?.get(e.id),known:t!==null,current:e.id===_,target:r(e.id),onSwitchProject:i,onSelectProject:a,sort:n},e.id),D=(0,Q.jsx)(Sg,{rememberFocus:C,restoreFocus:w,children:e.map(e=>E(e))}),O=(0,Q.jsxs)(Q.Fragment,{children:[T?(0,Q.jsx)(Z.Suspense,{fallback:D,children:(0,Q.jsx)(sg,{projects:e,onReorder:s,renderProject:E,onReady:w})}):D,(0,Q.jsx)(bg,{expanded:h})]}),k=c!==void 0&&c.hosts.length>0;return(0,Q.jsxs)(`nav`,{id:b,"aria-label":`Projects`,"data-slot":`project-rail`,"data-expanded":h?`true`:`false`,style:{width:h?232:60},className:q(`hidden shrink-0 flex-col overflow-hidden border-r border-border bg-background pt-3 pb-3.5 transition-[width] duration-[160ms] ease-out motion-reduce:transition-none md:flex`,h?`items-stretch px-2.5`:`items-center`),children:[(0,Q.jsx)(yg,{expanded:h,resolvedTheme:u,version:n}),(0,Q.jsx)(`div`,{ref:x,"data-slot":`rail-projects`,className:q(`flex min-h-0 w-full flex-1 flex-col gap-0.5 overflow-y-auto overscroll-contain [scrollbar-width:none]`,h?`items-stretch`:`items-center`),children:k?(0,Q.jsx)(Ud,{hostsData:c,expanded:h,activeSection:O}):(0,Q.jsxs)(Q.Fragment,{children:[O,(0,Q.jsx)(Vd,{warning:c?.warning,expanded:h})]})}),(0,Q.jsx)(xg,{roomToExpand:m,expanded:h,toggle:g,railId:b,allProjectsActive:v,settingsActive:y})]})}function wg(){let e=U(),t=Pe(),n=A().data?.projects,{order:r,canReorder:i,setOrder:s}=$m(),c=i&&n!==void 0&&Is(n.length),l=Z.useMemo(()=>n?Ps(n,r):void 0,[n,r]),u=a(!0,void 0,Z.useMemo(()=>{let e;return t=>{let n=f(t.runs);return e&&e.size===n.size&&[...n].every(([t,n])=>Ft(e.get(t),n))?e:(e=n,n)}},[])).data??null,d=Kr({enabled:!t}),p=!t&&(d.data?.hosts.length??0)>0,m=qr(p,Z.useMemo(()=>{let e;return t=>{let n=de(t);return o(e,n)?e:(e=n,n)}},[])),h=Ur({enabled:t}),g=t?h.data??null:p?m.data??null:void 0,_=n?.map(e=>e.id).sort().join(`
|
|
3
3
|
`),v=Z.useRef(void 0);return Z.useEffect(()=>{if(_===void 0)return;let t=v.current;if(v.current=_,t===void 0||t===_)return;let n=new Set(t.split(`
|
|
4
4
|
`)),r=new Set(_.split(`
|
|
5
|
-
`)),i=Te(e);for(let e of n)r.has(e)||i.dropProject(e);let a=[...r].filter(e=>!n.has(e));for(let e of a)i.restoreProject(e);a.length>0&&i.reconcile({hold:!0})},[e,_]),Z.useMemo(()=>l?{projects:l,signals:u,...g===void 0?{}:{hostSignals:g},canReorder:c,onReorder:s}:null,[l,u,g,c,s])}var Tg=60;function Eg(e){return`title`in e?`Archived "${e.title.length>Tg?`${e.title.slice(0,Tg-1)}…`:e.title}"`:`Archived ${e.count} ${e.count===1?`task`:`tasks`}`}async function Dg(e,t,n){let r=new Set(n),i=(await Promise.allSettled(t.map(async t=>{await gn(E(t,{projectId:e}),!1),r.has(t)&&await Mt(E(t,{projectId:e}),!0)}))).find(e=>e.status===`rejected`);i&&H(i.reason instanceof Error?i.reason.message:`Could not undo the archive.`,{tone:`danger`})}function Og(){let e=document.activeElement;return!e||e===document.body||!e.isConnected}function kg(e,t){if(!e.isConnected)return t();let n=new MutationObserver(()=>{e.isConnected||(n.disconnect(),clearTimeout(r),t())}),r=setTimeout(()=>n.disconnect(),5e3);n.observe(document.body,{childList:!0,subtree:!0})}function Ag(e,t){if(!Og())return;let n=e?.isConnected?e:t?.isConnected?t:null;n instanceof HTMLElement&&(n.tabIndex<0&&!n.hasAttribute(`tabindex`)&&(n.tabIndex=-1),n.focus({preventScroll:!0}))}function jg(e,t,n){if(!e)return()=>{};let r=t(e);return()=>kg(e,()=>Ag(r,n))}function Mg(e){let t=document.activeElement?.closest(`[data-slot="task-row"]`);return t?.getAttribute(`data-run-id`)===e?t:Array.from(document.querySelectorAll(`[data-slot="task-row"]`)).find(t=>t.getAttribute(`data-run-id`)===e)??null}var Ng=e=>e?.querySelector(`a`)??null;function Pg(e,t){let n=e?.projectId,r=e?.cacheScope,i=se(),[a,o]=Z.useState(null),s=e=>i.invalidateAfter(`runs`,v({projectId:n,cacheScope:e})),c=(e,t,r,i)=>H(e,{action:{label:`Undo`,onAction:()=>void Dg(n,r,i).finally(()=>void s(t))}}),l=Z.useRef(new Map);return{archiveOne:e=>{let i=l.current.get(e.id);if(i)return i;let a=r??Ie(),o=!!e.pinned,u=Mg(e.id),d=jg(u,e=>{let t=Array.from(e.closest(`[data-slot="quick-list-bucket"]`)?.querySelectorAll(`[data-slot="task-row"]`)??[]),n=t.indexOf(e);return Ng(t[n+1]??t[n-1])},u?.closest(`[data-slot="quick-list-bucket"]`)?.parentElement??null),f=gn(E(e.id,{projectId:n}),!0).then(()=>(s(a),c(Eg({title:Ro(e)}),a,[e.id],o?[e.id]:[]),d(),t?.(),!0),e=>(H(e.message,{tone:`danger`}),!1)).finally(()=>l.current.delete(e.id));return l.current.set(e.id,f),f},sweep:(e,i)=>{let a=r??Ie();o(e);let l=document.activeElement,u=l?.matches(`[data-action="archive-group"]`)?l:null,d=jg(u,e=>Ng(e.closest(`[data-slot="quick-list-bucket"]`)?.nextElementSibling?.querySelector(`[data-slot="task-row"]`)??void 0),u?.closest(`[data-slot="quick-list-bucket"]`)?.parentElement??null);ln(v({projectId:n}),e,i).then(({ids:e,pinnedIds:n})=>{s(a),e.length>0&&c(Eg({count:e.length}),a,e,n),d(),e.length>0&&t?.()},e=>H(e.message,{tone:`danger`})).finally(()=>o(null))},sweeping:a}}var Fg=.6,Ig=300,Lg=100,Rg={offset:0,phase:`idle`,past:!1},zg=null;function Bg(e,t){zg&&zg.id!==e&&zg.close(),zg={id:e,close:t}}function Vg(e){zg?.id===e&&(zg=null)}function Hg(){if(!(typeof navigator>`u`||typeof navigator.vibrate!=`function`))try{navigator.vibrate(10)}catch{}}function Ug({id:e,enabled:t,onArchive:n}){let[r,i]=Z.useState(Rg),a=Z.useRef(null),o=Z.useRef(null),s=Z.useRef(!1),c=Z.useRef(!1),l=Z.useRef(void 0),u=()=>{c.current=!0,clearTimeout(l.current),l.current=void 0},d=()=>{c.current&&(clearTimeout(l.current),l.current=setTimeout(()=>{c.current=!1},Ig))};Z.useEffect(()=>()=>clearTimeout(l.current),[]);let f=Z.useRef(r);f.current=r;let p=Z.useRef(n);p.current=n;let m=Z.useCallback(()=>{o.current=null,s.current=!1,Vg(e),i(Rg)},[e]);Z.useEffect(()=>{!t&&f.current.phase!==`committing`&&m()},[t,m]),Z.useEffect(()=>()=>Vg(e),[e]);let h=r.phase===`open`;Z.useEffect(()=>{if(!h)return;let e=()=>m(),t=e=>{let t=a.current;t&&e.target instanceof Node&&t.contains(e.target)||m()};return document.addEventListener(`scroll`,e,{capture:!0,passive:!0}),document.addEventListener(`pointerdown`,t,!0),()=>{document.removeEventListener(`scroll`,e,{capture:!0}),document.removeEventListener(`pointerdown`,t,!0)}},[h,m]);let g=t=>{Vg(e),i({offset:-t,phase:`committing`,past:!0});let n=e=>{e===!1&&m()};try{let e=p.current();e&&typeof e.then==`function`&&e.then(n,m)}catch{m()}};return{offset:r.offset,phase:r.phase,past:r.past,surfaceRef:a,bind:{onPointerDown:e=>{if(c.current=!1,!t||f.current.phase===`committing`||e.pointerType===`mouse`&&e.button!==0)return;let n=(a.current??e.currentTarget).getBoundingClientRect();o.current={pointerId:e.pointerId,x0:e.clientX,y0:e.clientY,base:f.current.phase===`open`?-88:0,width:n.width>0?n.width:320,axis:null,wasOpen:f.current.phase===`open`,samples:[{x:e.clientX,t:Date.now()}]}},onPointerMove:t=>{let n=o.current;if(!n||t.pointerId!==n.pointerId)return;let r=t.clientX-n.x0,a=t.clientY-n.y0;if(n.axis===null){if(Math.max(Math.abs(r),Math.abs(a))<10||(n.axis=Math.abs(r)>Math.abs(a)?`x`:`y`,n.axis===`y`))return;try{t.currentTarget.setPointerCapture?.(t.pointerId)}catch{}Bg(e,m),u()}if(n.axis!==`x`)return;let c=Math.min(0,Math.max(-n.width,n.base+r)),l=-c>=Fg*n.width;l&&!s.current&&Hg(),s.current=l,n.samples.push({x:t.clientX,t:Date.now()}),n.samples.length>8&&n.samples.shift(),i({offset:c,phase:`dragging`,past:l})},onPointerUp:t=>{let n=o.current;if(!n||t.pointerId!==n.pointerId)return;if(o.current=null,n.axis!==`x`){n.axis===null&&n.wasOpen&&(u(),d(),m());return}d();let r=f.current.offset,a=Date.now(),c={x:t.clientX,t:a},l=n.samples.find(e=>a-e.t<=Lg&&e.t<a),p=l?(c.x-l.x)/(c.t-l.t):0;s.current=!1,f.current.past||p<=-1&&-r>=40?g(n.width):p<1&&-r>=40?(Bg(e,m),i({offset:-88,phase:`open`,past:!1})):m()},onPointerCancel:e=>{let t=o.current;!t||e.pointerId!==t.pointerId||(o.current=null,d(),t.axis===`x`&&m())},onClickCapture:e=>{c.current&&(c.current=!1,e.preventDefault(),e.stopPropagation())},onKeyDownCapture:()=>{c.current=!1}},close:m}}function Wg(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 Gg(e){return _n(e)?.runner??e.runner??`claude`}function Kg(e,t,n,r,i,a){return a?e.workflowDef?.steps.find(n=>n.command===void 0&&n.kind!==`plugin`&&(n.runner??e.runner??`claude`)===t)?.agentProfile??(t===n?e.agentProfile:void 0)??i?.[t]:t===r?_n(e)?.agentProfile:i?.[t]}function qg(e,t,n,r,i=!1){let a=r?.original??Gg(e),o=r?.target??a;if(e.delegation?.role===`worker`){let r=Kg(e,t,a,o,n,i);if(r!==void 0||i)return r}if(t!==o)return n?.[t];let s=Yt(e),c=s.profileId??`default`;return s.sessionId!==void 0&&s.backend===o&&(e.agentProfile??c)===c?c:(o===a?e.agentProfile:void 0)??n?.[t]}function Jg(e,t,n){let r=Yt(e),i=r.sessionId===void 0?{runner:e.runner??`claude`,account:e.agentProfile}:{runner:r.backend,account:r.profileId??e.agentProfile};return(i.runner===t?i.account:void 0)??n?.[t]}function Yg(e,t,n){let r=e.find(e=>e.provider===t&&e.id===n);return r?.isDefault?void 0:r}function Xg(e,t,n,r){return Yg(n,t,qg(e,t,r))}function Zg(e,t,n,r){let i=kn(t,e);return i?.enabled===!1?{provider:e,usable:!1,reason:`${ye(n,e)} is disabled. Enable it in ${Qs(`providers`)}.`}:r&&i?.authFailureId===void 0?r.status===void 0||r.status===`connected`?{provider:e,usable:!0}:{provider:e,usable:!1,reason:`${ye(n,e)} account "${r.label}" is not signed in. Sign in in ${Qs(`providers`)}.`}:i?.status===`connected`?{provider:e,usable:!0}:{provider:e,usable:!1,reason:`${ye(n,e)} credentials are unavailable. Authorize it in ${Qs(`providers`)}.`}}function Qg(e,t,n,r){return Zg(Wg(e),t,n,r)}function $g(e,t,n,r){return Zg(Gg(e),t,n,r)}function e_(e){let t=ee(),n=L().data,r=Wg(e),{accounts:i,repoAccount:a}=Ys(),o=Yg(i,r,Jg(e,r,a));return t.isSuccess&&t.data&&n?Qg(e,t.data,n,o):{provider:r,usable:!0}}function t_(e){let t=ee(),n=L(),r=Gg(e),{accounts:i,repoAccount:a}=Ys(),o=Xg(e,r,i,a);return t.isSuccess&&t.data&&n.data?$g(e,t.data,n.data,o):t.isError||n.isError?{provider:r,usable:!1,reason:`Provider authentication could not be verified.`}:{provider:r,usable:!1,reason:`Checking agent providers…`}}function n_(e){return Yt(e).sessionId}function r_(e){return Yt(e).backend}function i_(e){if(We(e)||e.cliHandoff===!1)return;let t=e.cliResumeCommand;if(t!==void 0)return e.worktreePath?`cd ${e.worktreePath} && ${t}`:t}function a_(e,t){let n=Qi(t);return!n||We(e)?!1:n===r_(e)&&n_(e)!==void 0}function o_(e){return(e.status===`failed`||lt(e))&&(e.waits?.length??0)>0}function s_(e,t){return t&&e.delegation?.role===`root`&&(e.status===`failed`||lt(e))}function c_(e){return e.status===`cancelled`&&e.startedAt===void 0&&e.workflowDef!==void 0&&e.steps.every(e=>e.status===`pending`&&e.startedAt===void 0&&!e.sessionId)}function l_(e){return yn(e)&&e.removedRunner===void 0}function u_(e,t=!1){let n=We(e),r=n_(e)!==void 0;return{finish:e.status===`waiting`&&n||e.status===`review`,continueRun:(!n||e.removedRunner!==void 0&&e.status!==`queued`)&&!e.stopping&&e.delegation?.role!==`invalid`&&!(e.delegation?.role===`worker`&&e.delegation.destroy)&&(r||c_(e)||e.removedRunner!==void 0),terminal:h_(e,n,r),notes:!0,archive:!n,pin:!e.archived&&!No(e),markUnread:xt(e)&&!mn(e),cancel:n||o_(e)||s_(e,t),deleteRun:!n}}function d_(e){return e.status===`waiting`&&e.finishBlocked===null&&qe(e).bucket===`waiting`}function f_(e){return`Merge head branch and resolve conflicts in ${e?`PR number ${e}`:`this pull request`}`}function p_(e){return e===`review`?`Accept the changes without a PR`:`Close the session`}function m_(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}function h_(e,t,n){return e.cliHandoff!==!1&&!t&&n}var g_=new Set(vt),__=[50,100,200,400,800,1e3,1e3,1e3,1e3],v_=e=>new Promise(t=>setTimeout(t,e));function y_(e){return e instanceof Tn&&e.status===409&&e.message===`run is still active`}async function b_(e,t=v_){for(let n=0;;n+=1)try{return await e()}catch(e){let r=__[n];if(!y_(e)||r===void 0)throw e;await t(r)}}function x_(e){return We(e)?`live`:u_(e).continueRun?`resume`:`unavailable`}function S_(e,t,n){let r=Ce(e.id,t,n),i=le(e.id,t,n),a=e_(e),o=t_(e),[s,c]=(0,Z.useState)(void 0),l=s?.message;Et(()=>{c(e=>e?.clearOnHostRecovery?void 0:e)});let[u,d]=(0,Z.useState)(!1),f=(0,Z.useRef)(!1),p=x_(e),m=n!==void 0,h=m?!1:p===`resume`?!o.usable:p===`live`&&!a.usable,g=p===`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`?p===`resume`?o.reason:a.reason:void 0,v=(e,t)=>!m&&!o.usable?Promise.reject(Error(o.reason??`The run provider is unavailable.`)):i.mutateAsync({text:e,...t===void 0?{}:{images:t}});return{mode:p,blockedBy:g,reason:_,isPending:u||r.isPending||i.isPending,error:l,send:async(t,n)=>{if(g)return _;if(f.current)return`An answer is already being sent.`;f.current=!0,d(!0),c(void 0);try{if(p===`resume`){await b_(()=>v(t,n));return}try{await r.mutateAsync({text:t,...n===void 0?{}:{images:n}})}catch(r){if(r instanceof Tn&&r.status===409&&(r.code===void 0||!g_.has(r.code))&&n_(e)!==void 0){try{await b_(()=>v(t,n))}catch(e){let t=nt(e);throw Error(`Session closed. Retry to reopen the session. ${t}`,{cause:e})}return}throw r}return}catch(e){let t=nt(e);return c({message:t,clearOnHostRecovery:Kt(e)}),t}finally{f.current=!1,d(!1)}}}}function C_({run:e,projectId:t,hostId:n,prNumber:r}){let i=S_(e,t,n),a=Er(),[o,s]=(0,Z.useState)(!1),c=o||i.isPending,l=!!i.blockedBy,u=async()=>{if(c||l)return;let e=i.mode===`resume`;s(!0);try{let t=await i.send(f_(r));t?H(t,{tone:`danger`}):(H(`${e?`Task reopened`:`Sent to the task`} — resolving conflicts${r?` in PR #${r}`:``}`),a())}finally{s(!1)}};return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Y,{type:`button`,size:`sm`,"data-slot":`reference-conflict-action`,disabled:l||c,onClick:()=>void u(),className:`w-full text-xs`,children:c?`Sending…`:`Resolve conflicts`}),l&&i.reason?(0,Q.jsx)(`span`,{className:`block text-muted-foreground`,children:i.reason}):null]})}function w_({projectId:e,hostId:t,runId:n,prNumber:r}){let i=N(e,n,!0,t===void 0?void 0:{hostId:t});return i.data?(0,Q.jsx)(C_,{run:i.data,projectId:e,hostId:t,prNumber:r}):(0,Q.jsx)(Y,{type:`button`,size:`sm`,disabled:!0,className:`w-full text-xs`,children:i.isError?`Unavailable`:`Loading…`})}function T_({runId:e,prNumber:t}){let{projectId:n}=Dr();return n===void 0?(0,Q.jsx)(E_,{runId:e,prNumber:t}):(0,Q.jsx)(w_,{projectId:n,runId:e,prNumber:t})}function E_({runId:e,prNumber:t}){let n=j(e);return n.data?(0,Q.jsx)(C_,{run:n.data,prNumber:t}):(0,Q.jsx)(Y,{type:`button`,size:`sm`,disabled:!0,className:`w-full text-xs`,children:n.isError?`Unavailable`:`Loading…`})}function D_({run:e,reference:t,className:n,compact:r=!1,plain:i=!1,inert:a=!1}){let{projectId:o,repoBase:s}=Dr(),c=o!==void 0&&t.number!==void 0?dr(o,e.id,{kind:t.kind,number:t.number,url:t.url},s):void 0;return(0,Q.jsx)(Or,{reference:t,taskTitle:Ro(e),to:c,conflictAction:Tr({...t,number:t.number??0},s)?(0,Q.jsx)(T_,{runId:e.id,prNumber:t.number}):void 0,className:n,compact:r,plain:i,inert:a})}var O_=220;function k_(e,t,n,r,i){if(e===void 0)return{to:void 0,fullPage:!1};let a=dr(e,t,n,r);return a?i===void 0?{to:a,fullPage:!1}:{to:He(i,a),fullPage:!0}:{to:void 0,fullPage:!1}}function A_({references:e,taskTitle:t,visibleCount:n,plain:r=!1,projectId:i,hostId:a,runId:o,repoBase:s}){let[c,l]=Z.useState(!1),u=Z.useRef(!1),d=Z.useRef(!1),f=Z.useRef(null),p=Z.useRef(void 0);Z.useEffect(()=>()=>clearTimeout(p.current),[]);let m=e=>e.pointerType!==`touch`,h=()=>clearTimeout(p.current),g=e=>{m(e)&&(h(),c||(u.current=!0),l(!0))},_=e=>{m(e)&&(h(),p.current=setTimeout(()=>l(!1),O_))},v=e.length-n,y=e.slice(n).map(t=>{let n=e.some(e=>e!==t&&e.kind===t.kind&&e.number===t.number)&&t.url?new URL(t.url).pathname.split(`/`).slice(1,3).join(`/`):``;return`${t.kind} #${t.number}${n?` (${n})`:``}`}).join(`, `);return v<=0?null:(0,Q.jsxs)(po,{open:c,onOpenChange:l,children:[(0,Q.jsx)(co,{asChild:!0,children:(0,Q.jsxs)(`button`,{type:`button`,"data-slot":`reference-overflow`,title:y,"aria-label":`Show all ${e.length} references for ${t}`,onPointerEnter:g,onPointerLeave:_,onPointerDown:e=>{e.stopPropagation(),d.current=c&&u.current,u.current=!1},onClick:e=>{e.stopPropagation(),c&&(d.current||u.current)&&(e.preventDefault(),h(),f.current?.focus()),d.current=!1,u.current=!1},className:`no-hover:min-h-[44px] no-hover:min-w-[44px] max-md:min-h-[44px] max-md:min-w-[44px] shrink-0 rounded-full px-1 text-xs font-medium text-soft-foreground transition-colors hover:bg-muted hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`,children:[`+`,v]})}),(0,Q.jsxs)(uo,{ref:f,align:`start`,collisionPadding:8,className:`w-auto min-w-40 max-h-(--radix-popover-content-available-height) overflow-y-auto overscroll-contain p-1.5`,"data-slot":`reference-overflow-list`,onClick:e=>e.stopPropagation(),onPointerDown:e=>e.stopPropagation(),onPointerEnter:g,onPointerLeave:_,onOpenAutoFocus:e=>{e.preventDefault(),!u.current&&e.target instanceof HTMLElement&&e.target.focus()},onKeyDownCapture:e=>{e.key===`Escape`&&(e.preventDefault(),u.current=!1,l(!1))},onCloseAutoFocus:e=>{u.current&&e.preventDefault()},children:[(0,Q.jsx)(`p`,{className:`px-1 pb-1.5 text-xs text-soft-foreground`,children:`References`}),(0,Q.jsx)(`span`,{className:`flex flex-col items-start gap-1`,children:e.map(e=>j_({reference:e,taskTitle:t,projectId:i,hostId:a,runId:o,repoBase:s,plain:r,className:`no-hover:min-h-[44px] max-md:min-h-[44px]`}))})]})]})}function j_({reference:e,taskTitle:t,projectId:n,hostId:r,runId:i,repoBase:a,plain:o,compact:s=!1,inert:c=!1,className:l}){let u=k_(n,i,e,a,r);return(0,Q.jsx)(Or,{reference:e,taskTitle:t,projectId:n,hostId:r,repoBase:a,to:u.to,fullPage:u.fullPage,plain:o,compact:s,inert:c,className:l,conflictAction:n&&Tr(e,a)?(0,Q.jsx)(w_,{projectId:n,hostId:r,runId:i,prNumber:e.number}):void 0},mr(e))}function M_({references:e,maxVisible:t,taskTitle:n,projectId:r,hostId:i,runId:a,repoBase:o,plain:s=!1,compact:c=!1,inertInline:l=!1,fitContainer:u=!1,overflowContainer:d}){let f=Z.useRef(null),[p,m]=Z.useState(t),h=Z.useRef(new Map),g=e.map(mr).join(`|`);Z.useLayoutEffect(()=>{let n=f.current;if(!u||!n?.parentElement){m(t);return}let r=n.parentElement,i=()=>{[...n.querySelectorAll(`:scope > [data-slot="pr-chip"], :scope > [data-slot="issue-chip"]`)].forEach((t,n)=>{let r=t.getBoundingClientRect().width;r&&h.current.set(mr(e[n]),r)});let i=r.getBoundingClientRect();if(!i.width)return;let a=Math.min(t,e.length);n.dataset.referenceWidth=String(e.slice(0,a).reduce((e,t)=>e+(h.current.get(mr(t))??48),0)+Math.max(0,a-1)*4);let o=0;for(let e=n.nextElementSibling;e;e=e.nextElementSibling){if(e.getAttribute(`data-slot`)===`task-row-age`||e.getAttribute(`aria-hidden`)===`true`&&e.nextElementSibling?.getAttribute(`data-slot`)===`task-row-age`)continue;let t=getComputedStyle(e);o+=e.getBoundingClientRect().width+(parseFloat(t.marginLeft)||0)+(parseFloat(t.marginRight)||0)}let s=i.right-n.getBoundingClientRect().left-o,c=n.querySelector(`[data-slot="reference-overflow"]`)?.getBoundingClientRect().width||(l?44:26),u=Math.min(t,e.length);for(;u>0;){let t=d===void 0&&u<e.length,n=(t?u:Math.max(0,u-1))*4;if(e.slice(0,u).reduce((e,t)=>e+(h.current.get(mr(t))??48),0)+n+(t?c:0)<=s+(u===e.length?d?.getBoundingClientRect().width??0:0))break;u--}m(u)};if(i(),typeof ResizeObserver>`u`)return;let a=new ResizeObserver(i);return a.observe(r),a.observe(n),()=>a.disconnect()},[u,t,g,l,e,d]);let _=Math.min(p,t,e.length),v=(0,Q.jsx)(A_,{references:e,visibleCount:_,taskTitle:n,projectId:r,hostId:i,runId:a,repoBase:o,plain:s});return(0,Q.jsxs)(`span`,{ref:f,"data-slot":`reference-list`,className:`inline-flex max-w-full flex-nowrap items-center gap-1 align-middle`,children:[e.slice(0,_).map(e=>j_({reference:e,taskTitle:n,projectId:r,hostId:i,runId:a,repoBase:o,plain:s,compact:c,inert:l,className:`shrink-0`})),d===void 0?v:d?(0,Of.createPortal)(v,d):null]})}function N_({pinned:e,onToggle:t,className:n}){return(0,Q.jsx)(`button`,{type:`button`,"data-slot":`pin-toggle`,"data-pinned":e?`true`:void 0,"aria-pressed":e,"aria-label":e?`Unpin task`:`Pin task`,title:e?`Unpin from the top of the list`:`Pin to the top of the list`,onClick:n=>{n.stopPropagation(),t(!e)},className:q(`inline-flex size-5 shrink-0 items-center justify-center rounded-sm text-soft-foreground transition-colors motion-reduce:transition-none hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`,n,`max-md:min-h-11 max-md:min-w-11 no-hover:min-h-11 no-hover:min-w-11`),children:(0,Q.jsx)(sl,{"data-slot":`pin-icon`,className:`size-[12px]`,fill:e?`currentColor`:`none`,"aria-hidden":`true`})})}var P_=`opacity-0 group-hover/task-row:opacity-100 focus-visible:opacity-100 group-has-[:focus-visible]/task-row:opacity-100 no-hover:opacity-100`,F_=`opacity-0 group-hover/task-row:opacity-100 focus-visible:opacity-100 group-has-[:focus-visible]/task-row:opacity-100`,I_=`transition-opacity motion-reduce:transition-none group-hover/task-row:opacity-0 group-has-[:focus-visible]/task-row:opacity-0 max-md:absolute max-md:top-1/2 max-md:left-0 max-md:-translate-y-1/2 max-md:opacity-100 no-hover:absolute no-hover:top-1/2 no-hover:left-0 no-hover:-translate-y-1/2 no-hover:opacity-100`;function L_({run:e,title:t,unread:n,inertReferences:r,onTogglePin:i,onArchiveRun:a}){return(0,Q.jsxs)(`span`,{"data-slot":`task-row-trailing`,className:`relative flex h-[19px] w-[16px] shrink-0 items-center justify-center max-md:h-auto max-md:w-11 max-md:self-stretch no-hover:h-auto no-hover:w-11 no-hover:self-stretch`,children:[n?(0,Q.jsx)(Qo,{tone:Xo(e),role:`img`,"aria-label":`unread`,title:`Unread — not opened since it finished`,"data-slot":`unread-marker`,className:i?I_:void 0}):null,i?(0,Q.jsx)(N_,{pinned:!!e.pinned,onToggle:t=>i(e,t),className:q(`absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2`,P_)}):null,a&&!r&&cn(e)?(0,Q.jsx)(`button`,{type:`button`,"data-action":`archive-run`,"aria-label":`Archive ${t}`,title:`Archive task`,onClick:t=>{t.stopPropagation(),a(e)},className:q(`absolute top-[19.5px] left-1/2 inline-flex size-5 -translate-x-1/2 items-center justify-center rounded-sm text-muted-foreground transition-colors hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none motion-reduce:transition-none`,F_),children:(0,Q.jsx)(Wi,{className:`size-[12px] -translate-y-[2.5px]`,"aria-hidden":`true`})}):null]})}function R_({inertReferences:e,swipeable:t,swipe:n,title:r,onArchive:i,children:a}){return e?(0,Q.jsxs)(`div`,{ref:n.surfaceRef,"data-slot":`task-row-swipe`,"data-swipe":t?`on`:void 0,"data-phase":t?n.phase:void 0,className:q(`relative rounded-[6px]`,t&&`touch-pan-y touch-pinch-zoom overflow-hidden`),children:[n.offset<0?(0,Q.jsx)(z_,{width:-n.offset,past:n.past,title:r,onArchive:i}):null,a]}):a}function z_({width:e,past:t,title:n,onArchive:r}){return(0,Q.jsx)(`div`,{"data-slot":`task-row-swipe-action`,"data-past":t?`true`:void 0,"aria-hidden":`true`,style:{width:e},className:q(`absolute inset-y-0 right-0 flex items-stretch justify-end overflow-hidden rounded-[6px]`,t?`bg-info text-signal-ink`:`bg-muted text-foreground`),children:t?(0,Q.jsxs)(`span`,{className:`flex w-full items-center justify-center gap-2 text-[12px] font-semibold whitespace-nowrap`,children:[(0,Q.jsx)(Wi,{className:`size-[16px] shrink-0`,"aria-hidden":`true`}),`Release to archive`]}):(0,Q.jsxs)(`button`,{type:`button`,tabIndex:-1,"aria-label":`Archive ${n}`,onClick:e=>{e.stopPropagation(),r()},className:`flex w-[88px] shrink-0 flex-col items-center justify-center gap-1 text-[12px] font-semibold`,children:[(0,Q.jsx)(Wi,{className:`size-[16px]`,"aria-hidden":`true`}),`Archive`]})})}var B_=`[&>[data-ellipsis-hidden]]:pointer-events-none`,V_=`data-ellipsis-hidden`,H_=new Map;function U_(e){let t=getComputedStyle(e),n=`${t.fontStyle} ${t.fontWeight} ${t.fontSize} ${t.fontFamily} ${t.letterSpacing}`,r=H_.get(n);if(r!==void 0)return r;let i=document.createElement(`span`);i.textContent=`…`,i.setAttribute(`aria-hidden`,`true`),Object.assign(i.style,{position:`absolute`,visibility:`hidden`,whiteSpace:`pre`,fontStyle:t.fontStyle,fontWeight:t.fontWeight,fontSize:t.fontSize,fontFamily:t.fontFamily,letterSpacing:t.letterSpacing}),document.body.appendChild(i);let a=i.getBoundingClientRect().width;i.remove();let o=a||parseFloat(t.fontSize)||12;return a&&(!document.fonts||document.fonts.status===`loaded`)&&H_.set(n,o),o}function W_(e,t){if(e.scrollWidth<=e.clientWidth)return[];let n=e.getBoundingClientRect(),r=parseFloat(getComputedStyle(e).paddingRight)||0,i=n.left+e.clientLeft+e.clientWidth-r-t+.5;return Array.from(e.children).filter(e=>e.getBoundingClientRect().right>i)}function G_(e,t,n){Z.useLayoutEffect(()=>{let n=e.current;if(!t||!n||typeof ResizeObserver>`u`)return;let r=!0,i=()=>{if(!r)return;let e=new Set(W_(n,U_(n)));for(let t of Array.from(n.children))t.hasAttribute(V_)!==e.has(t)&&t.toggleAttribute(V_,e.has(t))},a=new ResizeObserver(i),o=new Set,s=()=>{for(let e of Array.from(n.children))o.has(e)||(o.add(e),a.observe(e))};a.observe(n),s(),i();let c=typeof MutationObserver>`u`?null:new MutationObserver(()=>{s(),i()});return c?.observe(n,{childList:!0}),document.fonts&&document.fonts.status!==`loaded`&&document.fonts.ready.then(i),()=>{r=!1,a.disconnect(),c?.disconnect();for(let e of Array.from(n.children))e.removeAttribute(V_)}},[e,t,n])}var K_=`(hover: none)`;function q_(){let[e,t]=(0,Z.useState)(()=>typeof window.matchMedia==`function`&&window.matchMedia(K_).matches);return(0,Z.useEffect)(()=>{if(typeof window.matchMedia!=`function`)return;let e=window.matchMedia(K_);t(e.matches);let n=e=>t(e.matches);return e.addEventListener(`change`,n),()=>e.removeEventListener(`change`,n)},[]),e}var J_={"needs-permission":`label`,failed:`label`,"needs-you":`none`,"needs-review":`label`,running:`label`,"usage-limit":`resume`,"waiting-on-workers":`label`,"waiting-on-subagents":`label`,"waiting-for-ci":`label`,"waiting-for-merge":`label`,"waiting-for-command":`until`,monitoring:`next-check`,"waiting-for-capacity":`label`,queued:`queue-position`,done:`none`,cancelled:`none`,unseen:`label`};function Y_(e,t,n,r){let i=Rm(e.rung,e.label,n.autoResumeReason);switch(J_[e.rung]){case`none`:return;case`queue-position`:return t===null?i:`Queued #${t}`;case`resume`:{let e=bs(n.autoResumeAt,r);return e===`scheduled`?i:`${i}, ${e}`}case`next-check`:{let e=fn(n),t=e?.kind===`timer`?new Date(e.at):void 0;return t&&Number.isFinite(t.getTime())?`${i}, next check ${ws(t,new Date(r))}`:i}case`until`:{let e=fn(n),t=e?.kind===`process`?new Date(e.deadline):void 0;return t&&Number.isFinite(t.getTime())?`${i}, until ${ws(t,new Date(r))}`:i}case`label`:return i}}function X_({run:e,attention:t,queuePosition:n,inWorkingGroup:r,scope:i,now:a}){let o=nr(e,void 0,i??void 0),s=n===null?ys(e.finishedAt??e.createdAt,a):``,c=r&&t.rung===`running`?void 0:Y_(t,n,e,a);return{stateWord:c,references:o,age:s,key:`${s}|${c??``}|${o.map(e=>`${e.kind}-${e.number}-${e.url}`).join(`,`)}|${+!!e.notify}`}}function Z_(e){let t=Ro(e);return{title:t,displayTitle:Bo(t,fr(e)?.number)?qo(t).rest:t}}var Q_=`cez-sidebar-collapsed`,$_=`cez-sidebar-sections-collapsed`;function ev(e){if(typeof e!=`object`||!e||Array.isArray(e))return{};let t={};for(let[n,r]of Object.entries(e))typeof r==`boolean`&&(t[n]=r);return t}function tv(e=Q_){try{let t=localStorage.getItem(Qr(e));return t===null?{}:ev(JSON.parse(t))}catch{return{}}}function nv(e,t=Q_){try{localStorage.setItem(Qr(t),JSON.stringify(e))}catch{}}var rv=`cez-sidebar-sections-changed`;function iv(e){let[t,n]=(0,Z.useState)(()=>tv($_)),[r,i]=(0,Z.useState)({}),a=(0,Z.useRef)(t);(0,Z.useEffect)(()=>{let e=e=>{if(e instanceof StorageEvent&&e.key!==null&&e.key!==Qr(`cez-sidebar-sections-collapsed`))return;let t=e instanceof CustomEvent?e.detail:tv($_);a.current=t,n(t)};return window.addEventListener(`storage`,e),window.addEventListener(rv,e),()=>{window.removeEventListener(`storage`,e),window.removeEventListener(rv,e)}},[]),(0,Z.useEffect)(()=>{if(e===null||Object.keys(r).length===0)return;let t={...a.current};for(let[n,i]of Object.entries(r))t[JSON.stringify([e,n])]=i;i({}),a.current=t,n(t),nv(t,$_),window.dispatchEvent(new CustomEvent(rv,{detail:t}))},[e,r]);let o=t=>JSON.stringify([e,t]);return{isCollapsed:e=>e!==`Archived`&&(r[e]??t[o(e)])===!0,toggle:t=>{if(e===null){i(e=>({...e,[t]:e[t]!==!0}));return}let r=o(t),s={...a.current,[r]:a.current[r]!==!0};a.current=s,n(s),nv(s,$_),window.dispatchEvent(new CustomEvent(rv,{detail:s}))}}}function av({runs:e,view:t,automations:n,webhooks:r=!0,onViewChange:i,currentRunId:a=null,now:o=Date.now(),onTogglePin:s,onArchiveRun:c,onSweep:l,sweeping:u=null,showViewControls:d=!0,rowLimit:f,sidebarLimits:p,projectId:m=null}){let h=bl(),g=jo(e,n),_=Go(e,t,n),v=Ho(_,`active`),y=Mo(v,p??f??{overall:null}),b=l?ov(_):void 0;return(0,Q.jsxs)(`div`,{"data-slot":`quick-list`,children:[(0,Q.jsxs)(`div`,{"data-slot":`quick-list-header`,className:`flex min-h-11 items-center gap-1.5 pr-[6px] pl-[10px] md:min-h-[26px]`,children:[(0,Q.jsx)(`h2`,{className:`text-[13px] font-semibold text-foreground`,children:`Tasks`}),(0,Q.jsx)(`span`,{className:`text-xs text-soft-foreground`,children:g[t]}),(0,Q.jsxs)(X,{to:`/`,onClick:h,className:`ml-auto flex min-h-11 items-center gap-0.5 text-[12px] text-soft-foreground hover:text-foreground md:min-h-[26px]`,children:[`All`,(0,Q.jsx)(Ti,{className:`size-[13px]`,"aria-hidden":`true`})]})]}),d?(0,Q.jsx)(`div`,{className:`sticky top-0 z-10 bg-sidebar pt-2 pb-1`,children:(0,Q.jsx)(`div`,{className:`inline-flex w-full gap-0.5 rounded-md bg-muted p-[2px]`,children:(0,Q.jsx)(bv,{view:t,automations:n,onSelect:i,counts:g})})}):null,v.length===0?(0,Q.jsx)(`p`,{className:`px-3 py-3.5 text-xs text-soft-foreground`,children:t===`automations`?`No automation tasks.`:`No tasks yet — describe one.`}):(0,Q.jsx)(sv,{buckets:y,allBuckets:v,sectionProjectId:m,currentRunId:Fo(a,e),now:o,onTogglePin:s,onArchiveRun:c,onSweep:l,sweeping:u,sweepCounts:b,view:t,automations:n,webhooks:r})]})}function ov(e){return{unpinned:gr(e,`unpinned`),pinned:gr(e,`pinned`)}}function sv({buckets:e,currentRunId:t=null,now:n=Date.now(),scope:r=null,onTogglePin:i,onArchiveRun:a,onSweep:o,sweeping:s=null,sweepCounts:c,projectName:l,allBuckets:u=e,sectionProjectId:d=r,view:f=`active`,automations:p,webhooks:m=!0}){let h=Z.useId(),g=iv(d),_=Z.useRef(null),v=Z.useRef(null);Z.useLayoutEffect(()=>{let e=v.current;if(!e||e.element.isConnected||(v.current=null,document.activeElement!==document.body))return;let t=u.find(t=>t.rows.some(t=>t.run.id===e.id));if(!t)return;let n=Array.from(_.current?.children??[]).find(e=>e.dataset.bucket===t.label);(Array.from(n?.querySelectorAll(`[data-slot="task-row"]`)??[]).find(t=>t.dataset.runId===e.id)?.querySelector(`a`)??n?.querySelector(`[data-slot="section-toggle"]`))?.focus({preventScroll:!0})});let y=(e,o=!1)=>(0,Q.jsx)(hv,{inWorkingGroup:o,run:e.run,queuePosition:e.queuePosition,currentRunId:t,now:n,scope:r,webhooks:m,onTogglePin:i,onArchiveRun:a});return(0,Q.jsx)(`div`,{ref:_,className:`flex flex-col gap-3`,onFocusCapture:e=>{let t=e.target.closest(`[data-slot="task-row"]`);v.current=t?.dataset.runId?{id:t.dataset.runId,element:e.target}:null},onBlurCapture:e=>{e.currentTarget.contains(e.relatedTarget)||(v.current=null)},children:u.map(t=>{let n=t.label===`Archived`,i=g.isCollapsed(t.label),a=e.find(({label:e})=>e===t.label)?.rows??[],u=t.rows.length,d=!n&&!i&&a.length<u,m=`${h}-${t.label.replaceAll(` `,`-`)}`;return(0,Q.jsxs)(`div`,{"data-slot":`quick-list-bucket`,"data-bucket":t.label,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-2 pr-[6px]`,children:[(0,Q.jsx)(lv,{id:m,bucket:t,collapsed:i,cut:d,onToggle:g.toggle}),d?(0,Q.jsx)(cv,{section:t.label,shown:a.length,total:u,scope:r,view:f,automations:p}):null,o&&c?(0,Q.jsx)(vv,{label:t.label,headingId:m,projectName:l,counts:c,onSweep:o,sweeping:s}):null]}),(0,Q.jsx)(`div`,{id:`${m}-rows`,hidden:i,children:!i&&a.map(e=>(0,Q.jsx)(`div`,{children:y(e,t.label===`Working`)},e.run.id))})]},t.label)})})}function cv({section:e,shown:t,total:n,scope:r,view:i,automations:a}){let o=bl();return(0,Q.jsxs)(X,{to:wo(r,Io(e,i,a)),onClick:o,"data-slot":`section-cut-link`,"aria-label":`${e}: showing ${t} of ${n}, see all`,title:`The sidebar shows ${t} of ${n} ${e} tasks. Click to see all of them. Change the limit in ${Qs(`sidebar`)}.`,className:`mr-auto -ml-1 flex min-h-[44px] min-w-[44px] shrink-0 items-center rounded-[4px] px-1 text-xs font-normal text-soft-foreground tabular-nums underline decoration-dotted underline-offset-[3px] hover:text-foreground focus-visible:outline-2 focus-visible:outline-link-foreground md:min-h-[26px] md:min-w-0 no-hover:min-h-[44px] no-hover:min-w-[44px]`,children:[t,` of `,n]})}function lv({id:e,bucket:t,collapsed:n,cut:r,onToggle:i}){let a=t.rows.length;if(t.label===`Archived`)return(0,Q.jsx)(`h2`,{id:e,className:`min-w-0 flex-1 text-xs font-medium text-soft-foreground`,children:(0,Q.jsxs)(`span`,{className:`px-[10px] pt-[2px] pb-[4px]`,children:[t.label,` `,a]})});let o=t.label,s=t.rows.map(e=>e.run),c=s.length?zm(Wo(s)):null,l=s.some(mn),u=n?Ti:Ki;return(0,Q.jsx)(`h2`,{id:e,className:q(`min-w-0 text-xs font-medium text-soft-foreground`,r?`shrink-0`:`flex-1`),children:(0,Q.jsxs)(`button`,{type:`button`,"data-slot":`section-toggle`,"aria-expanded":!n,"aria-controls":`${e}-rows`,"aria-label":`${o} ${a}`,onClick:()=>i(o),className:q(`flex min-h-[44px] items-center gap-1.5 rounded-[4px] px-[10px] text-left hover:bg-sidebar-row-hover hover:text-foreground focus-visible:outline-2 focus-visible:outline-link-foreground md:min-h-[26px] no-hover:min-h-[44px]`,r?`pr-[4px]`:`w-full`),children:[(0,Q.jsx)(u,{className:`size-[12px] shrink-0`,"aria-hidden":`true`}),(0,Q.jsx)(`span`,{children:o}),r?null:(0,Q.jsxs)(Q.Fragment,{children:[` `,(0,Q.jsx)(`span`,{className:`font-normal tabular-nums`,children:a})]}),c&&(o===`Needs you`||n)?(0,Q.jsx)(Qo,{tone:c.tone,shape:c.shape,pulse:c.pulse,role:`img`,"aria-label":c.label,title:c.label}):null,n&&l?(0,Q.jsx)(`span`,{role:`img`,"aria-label":`unread`,title:`Unread tasks`,className:`size-[5px] shrink-0 rounded-full bg-foreground`}):null]})})}function uv({view:e,current:t,onSelect:n,count:r,children:i}){let a=e===t;return(0,Q.jsxs)(`button`,{type:`button`,"data-slot":`view-tab`,"data-view":e,"aria-pressed":a,onClick:()=>n(e),className:q(`flex min-h-11 min-w-0 flex-1 items-center justify-center gap-1.5 rounded-[7px] text-xs font-medium text-muted-foreground md:min-h-[22px]`,a&&`bg-card font-semibold text-foreground shadow-xs`),children:[i,r>0?(0,Q.jsx)(`span`,{className:`font-mono text-xs tabular-nums`,children:r}):null]})}function dv(){let e=q_(),t=fs();return e||!t}function fv(e){let t=document.createRange();t.selectNodeContents(e);let n=t.getBoundingClientRect?.().width,r=e.querySelector(`[data-reference-width]`),i=r?Math.max(0,Number(r.dataset.referenceWidth)-r.getBoundingClientRect().width):0;return Math.ceil((n||e.scrollWidth)+i)}function pv(e,t,n){let[r,i]=Z.useState(!1),[a,o]=Z.useState(0),s=Z.useRef(!1),c=Z.useRef(!1),l=Z.useRef(null),u=Z.useCallback(e=>{s.current=e,i(e)},[]);return Z.useLayoutEffect(()=>{let r=e.current;if(!t||!r||typeof ResizeObserver>`u`){l.current=null,u(!1);return}let i=!0,a=()=>{if(i){if(l.current?.key!==n){if(s.current){u(!1),o(e=>e+1);return}l.current={key:n,width:fv(r)}}u(l.current.width>r.clientWidth)}};a();let d=new ResizeObserver(a);d.observe(r);let f=new WeakMap,p=new ResizeObserver(e=>{let t=!1;for(let n of e??[]){let e=n.borderBoxSize?.[0]?.inlineSize??n.contentRect.width,r=f.get(n.target);f.set(n.target,e),r!==void 0&&r!==e&&(t=!0)}!t||!i||(l.current=null,a())}),m=new Set,h=()=>{let e=!1;for(let t of[...r.children,...r.querySelectorAll(`[data-slot="reference-list"] [data-slot="pr-chip"], [data-slot="reference-list"] [data-slot="issue-chip"]`)]){let{slot:n}=t.dataset;n===`task-row-age`||t.getAttribute(`aria-hidden`)===`true`||m.has(t)||(m.add(t),f.set(t,t.getBoundingClientRect().width),p.observe(t),e=!0)}return e};h();let g=typeof MutationObserver>`u`?null:new MutationObserver(()=>{!h()||!i||(l.current=null,a())});return g?.observe(r,{childList:!0,subtree:!0}),document.fonts&&document.fonts.status!==`loaded`&&!c.current&&document.fonts.ready.then(()=>{c.current=!0,i&&(l.current=null,a())}),()=>{i=!1,d.disconnect(),p.disconnect(),g?.disconnect()}},[e,t,n,a,u]),t&&r}function mv(){return(0,Q.jsx)(`span`,{"aria-hidden":`true`,children:` · `})}function hv({run:e,queuePosition:t,currentRunId:n,now:r,scope:i,webhooks:a=!0,inWorkingGroup:o=!1,onTogglePin:s,onArchiveRun:c}){let l=To(),u=bl(),d=dv(),f=!!c&&d&&cn(e),p=Ug({id:e.id,enabled:f,onArchive:()=>c?.(e)}),m=wo(i,`/tasks/${e.id}`),h=qe(e),g=e.id===n,{title:_,displayTitle:v}=Z_(e),y=mn(e),b=X_({run:e,attention:h,queuePosition:t,inWorkingGroup:o,scope:i,now:r}),[x,S]=Z.useState(null);return(0,Q.jsx)(R_,{inertReferences:d,swipeable:f,swipe:p,title:_,onArchive:()=>void c?.(e),children:(0,Q.jsxs)(`div`,{"data-slot":`task-row`,"data-run-id":e.id,"data-active":g?`true`:void 0,onClick:e=>{e.currentTarget.contains(e.target)&&(e.target.closest(`a, button, input`)||(l(m),u?.()))},...f?p.bind:{},style:p.offset?{transform:`translateX(${p.offset}px)`}:void 0,className:q(`selection-row group/task-row flex cursor-pointer items-start gap-2.5 rounded-[6px] py-1.5 pr-2 pl-2.5 hover:bg-sidebar-row-hover`,f&&`select-none`,f&&p.phase!==`dragging`&&`motion-safe:transition-transform motion-safe:duration-200 motion-safe:ease-out`,g&&`bg-sidebar-row-selected hover:bg-sidebar-row-selected`),children:[(0,Q.jsx)(`span`,{"data-slot":`task-row-dot`,className:`flex h-[19px] w-[12px] shrink-0 items-center justify-center`,children:(0,Q.jsx)(Qo,{tone:h.tone,shape:h.shape,pulse:h.pulse,"aria-label":zm(e,h).label,title:zm(e,h).label,role:`img`})}),(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,Q.jsx)(gv,{run:e,to:m,title:_,displayTitle:v,isActive:g,unread:y,swipeable:f,onNavigate:u}),(0,Q.jsx)(_v,{run:e,meta:b,title:_,scope:i,isActive:g,inertReferences:d,overflowContainer:x,webhooks:a})]}),b.references.length?(0,Q.jsx)(`span`,{ref:S,"data-slot":`protected-reference-overflow`,className:q(`shrink-0 self-end empty:hidden`,d&&`-my-1.5 self-center`)}):null,e.delegation?.role===`worker`?(0,Q.jsxs)(`span`,{className:`sr-only`,children:[`Worker · `,zm(e,h).label]}):null,(0,Q.jsx)(L_,{run:e,title:_,unread:y,inertReferences:d,onTogglePin:s,onArchiveRun:c})]})})}function gv({run:e,to:t,title:n,displayTitle:r,isActive:i,unread:a,swipeable:o,onNavigate:s}){return(0,Q.jsxs)(X,{to:t,onClick:s,title:n,"aria-current":i?`page`:void 0,draggable:!o&&void 0,className:`flex h-[19px] min-w-0 items-center gap-2 rounded-[2px] focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-link-foreground`,children:[(0,Q.jsx)(`span`,{"data-slot":`task-row-title`,className:q(`min-w-[7rem] flex-1 truncate text-[13px] leading-[1.45] font-medium text-muted-foreground`,a&&`font-semibold text-foreground`,i&&`text-foreground`),children:r}),e.diffStat?(0,Q.jsx)(vs,{stat:e.diffStat,className:`hidden shrink-0 text-[12px] @min-[23rem]/sidebar:inline`}):null]})}function _v({run:e,meta:t,title:n,scope:r,isActive:i,inertReferences:a,overflowContainer:o,webhooks:s=!0}){let{stateWord:c,references:l,age:u,key:d}=t,f=s&&e.notify===!0,p=`${d}|${+!!f}`,m=Dr(),h=Z.useRef(null),g=pv(h,!!u,p);G_(h,!a&&l.length>0,`${p}|${+!!g}`);let _=[];return c&&_.push((0,Q.jsx)(`span`,{"data-slot":`task-row-state`,children:c},`state`)),l.length&&_.push((0,Q.jsx)(M_,{references:l,maxVisible:2,taskTitle:n,projectId:r??m.projectId,repoBase:m.repoBase,runId:e.id,plain:!0,compact:!0,inertInline:a,fitContainer:!0,overflowContainer:o},`references`)),u&&!g&&_.push((0,Q.jsx)(`span`,{"data-slot":`task-row-age`,className:`tabular-nums`,children:u},`age`)),(0,Q.jsxs)(`div`,{ref:h,"data-slot":`task-row-meta`,className:q(`h-[16px] min-w-0 truncate text-xs leading-[1.4] font-normal text-soft-foreground`,B_,i&&`text-muted-foreground`),children:[f?(0,Q.jsx)(`span`,{"data-slot":`task-row-notify`,role:`img`,"aria-label":`Notifying the task webhook`,title:`Notifying the task webhook`,className:`mr-[4px] inline-block shrink-0 align-[-1px]`,children:(0,Q.jsx)(cl,{"aria-hidden":`true`,className:`size-[10px]`})}):null,_.length?_.flatMap((e,t)=>t?[(0,Q.jsx)(mv,{},`sep-${t}`),e]:[e]):f?null:`\xA0`]})}function vv({label:e,headingId:t,projectName:n,counts:r,onSweep:i,sweeping:a}){let o=e===`Finished`?`unpinned`:null;if(!o||r[o]===0)return null;let s=a===o,c=`Archive all`;return(0,Q.jsxs)(`button`,{type:`button`,"data-action":`archive-group`,"data-scope":o,disabled:s,"aria-busy":s?`true`:void 0,"aria-label":n?`${c}, ${n}`:void 0,"aria-describedby":t,onClick:()=>i(o),className:`relative inline-flex shrink-0 items-center gap-1 rounded-[4px] px-1.5 py-0.5 font-sans text-xs leading-[1.4] text-muted-foreground hover:bg-sidebar-row-hover hover:text-foreground focus-visible:outline-2 focus-visible:outline-link-foreground disabled:opacity-60 max-md:before:absolute max-md:before:top-1/2 max-md:before:left-0 max-md:before:h-11 max-md:before:w-full max-md:before:-translate-y-1/2 max-md:before:content-[''] no-hover:before:absolute no-hover:before:top-1/2 no-hover:before:left-0 no-hover:before:h-11 no-hover:before:w-full no-hover:before:-translate-y-1/2 no-hover:before:content-['']`,children:[(0,Q.jsx)(Wi,{className:`size-[11px]`,"aria-hidden":`true`}),c]})}function yv({showViewControls:e=!0,projectId:t,boot:n=!1,enabled:r=!0}){let i=bl(),a=t??Ie(),o=De(a,r,n),s=Ee(a,r,n).data?.sidebarLimits??{},u=l(v({projectId:a,boot:n})),d=Pg(v({projectId:a,boot:n}),i),f=c(),p=xm()!==`absent`,[h,g,_]=Eh(),y=Do(`/tasks/:id/*`),b=Do(`/tasks/:id`),x=is(3e4),S=te(),C=t??S,w=m(C),T=Mo(Ho(Go(o.data??[],h,_),`active`),s),E=C===void 0?[]:T.flatMap(e=>e.rows.flatMap(({run:e})=>nr(e,w).filter(e=>Tr(e,w)).map(e=>({projectId:C,kind:e.kind,number:e.number}))));return o.data?(0,Q.jsx)(br,{projectId:C,repoBase:w,requests:E,children:(0,Q.jsx)(av,{showViewControls:e,sidebarLimits:s,projectId:C==="default"?f.data?.bootProject??null:C??null,runs:o.data,view:h,automations:_,webhooks:p,onViewChange:g,currentRunId:y?.params.id??b?.params.id??null,now:x,onTogglePin:(e,t)=>u.mutate({id:e.id,pinned:t}),onArchiveRun:d.archiveOne,onSweep:e=>d.sweep(e,_?h===`automations`:void 0),sweeping:d.sweeping})}):null}function bv({view:e,automations:t,onSelect:n,counts:r}){let i=(0,Q.jsx)(Qo,{tone:`pending`,pulse:!0,"data-slot":`waiting-dot`,"aria-label":`Needs you`});return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(uv,{view:`active`,current:e,onSelect:n,count:r.active,children:[`Active`,r.activeWaiting>0&&e!==`active`?i:null]}),t?(0,Q.jsxs)(uv,{view:`automations`,current:e,onSelect:n,count:r.automations,children:[`Automations`,r.automationsWaiting>0&&e!==`automations`?i:null]}):null]})}var xv=e=>e.available?null:e.hint??null,Sv={git:`https://git-scm.com/downloads`,gh:`https://cli.github.com/`};function Cv(e,t){if(e.available)return null;if(B(t,e.name))return{kind:`settings`,to:$s(e.name),label:`Set up`};let n=Sv[e.name];return n?{kind:`external`,href:n,label:`Install guide`}:null}var wv=(e,t)=>oe(t).includes(e.name);function Tv(e,t){let n=e.checks.filter(e=>wv(e,t));if(n.length&&!n.some(e=>e.available))return`no agent CLI found — install one to run tasks`;let r=n.find(t=>t.name===e.defaultRunner);return r&&!r.available?`default runner (${e.defaultRunner}) not found`:null}function Ev(e,t){let n=`Squawk v${e.version}`;if(t===void 0)return n;let r=Tv(e,t);if(r)return`${n} · ${r}`;let i=e.checks.filter(e=>!e.available).map(e=>e.name);return i.length?`${n} · optional: ${i.join(`, `)} not installed`:n}function Dv(e){return e.forge?.available?null:e.forge?`GitHub is unreachable — ${e.forge.reason??`unknown reason`}. The GitHub tab is hidden until it comes back.`:`No GitHub remote detected — the GitHub tab is hidden. Every plain-git feature still works.`}function Ov({health:e,runners:t,sessionScope:n}){if(!e)return null;let r=Tv(e,t);return(0,Q.jsxs)(oo,{children:[(0,Q.jsx)(ro,{asChild:!0,children:(0,Q.jsxs)(`button`,{type:`button`,"data-slot":`tools-menu-trigger`,"aria-label":`Tools`,title:Ev(e,t),className:`relative flex items-center gap-1.5 rounded-[6px] px-2 py-1.5 text-[12px] font-normal text-soft-foreground transition-colors hover:bg-sidebar-row-hover hover:text-foreground focus-visible:outline-2 focus-visible:outline-ring data-[state=open]:bg-sidebar-row-selected data-[state=open]:text-foreground`,children:[(0,Q.jsx)(zi,{className:`size-[15px]`,"aria-hidden":`true`}),r?(0,Q.jsx)(Qo,{tone:`pending`,className:`absolute top-1 left-5 size-1.5`}):null,`Tools`]})}),(0,Q.jsxs)(io,{side:`top`,align:`start`,"data-slot":`tools-menu-content`,className:`w-[240px]`,children:[n?(0,Q.jsx)(`div`,{className:`px-2 py-2`,children:n}):null,(0,Q.jsx)(Xa,{className:`text-xs font-semibold tracking-[.04em] text-soft-foreground uppercase`,children:`Installed tools`}),e.checks.map(e=>e.available?(0,Q.jsx)(kv,{check:e},e.name):(0,Q.jsx)(Av,{check:e,runners:t},e.name)),Dv(e)?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(to,{}),(0,Q.jsx)(`p`,{"data-slot":`forge-note`,className:`px-2 py-1.5 text-xs leading-snug text-muted-foreground`,children:Dv(e)})]}):null,(0,Q.jsx)(to,{}),(0,Q.jsx)(eo,{asChild:!0,children:(0,Q.jsx)(G,{to:`/tools`,children:`Tools diagnostics`})}),(0,Q.jsx)(eo,{asChild:!0,children:(0,Q.jsxs)(G,{to:ec,"data-slot":`tools-settings`,className:`gap-2 text-[13px] text-muted-foreground`,children:[(0,Q.jsx)(Ei,{className:`size-3.5`,"aria-hidden":`true`}),`Tool settings`]})})]})]})}function kv({check:e}){let t=Ym(e);return(0,Q.jsxs)(`div`,{"data-slot":`tool-row`,"data-tool":e.name,"data-available":`true`,className:`flex items-center gap-2 rounded-sm px-2 py-1.5`,children:[(0,Q.jsx)(Qo,{tone:t.availability.tone,shape:t.availability.shape}),(0,Q.jsx)(`span`,{className:`font-mono text-[13px] font-medium`,children:e.name}),t.mode?(0,Q.jsx)(`span`,{"data-slot":`tool-dry-run`,title:t.rawVersion,className:`ml-auto shrink-0 rounded-full border border-border bg-muted px-2 py-0.5 text-xs font-medium text-muted-foreground`,children:t.mode.label}):(0,Q.jsx)(`span`,{"data-slot":`tool-version`,className:`ml-auto font-mono text-xs font-medium text-muted-foreground tabular-nums`,children:t.version??t.availability.label})]})}function Av({check:e,runners:t}){let n=xv(e),r=Ym(e),i=Cv(e,t),a={"data-slot":`tool-row`,"data-tool":e.name,"data-available":`false`},o=(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(Qo,{tone:r.availability.tone,shape:r.availability.shape}),(0,Q.jsx)(`span`,{className:`font-mono text-[13px] font-medium`,children:e.name}),(0,Q.jsx)(`span`,{"data-slot":`tool-version`,className:`ml-auto text-xs font-medium text-muted-foreground`,children:r.availability.label})]}),(0,Q.jsxs)(`span`,{className:`flex items-end justify-between gap-3 pl-[15px]`,children:[n?(0,Q.jsx)(`span`,{"data-slot":`tool-hint`,className:`min-w-0 text-xs leading-snug text-muted-foreground`,children:n}):null,i?(0,Q.jsxs)(`span`,{"data-slot":`tool-setup`,className:`ml-auto shrink-0 text-xs font-semibold text-accent-text`,children:[i.label,` `,i.kind===`external`?`↗`:`→`]}):null]})]});return i?(0,Q.jsx)(eo,{asChild:!0,children:i.kind===`settings`?(0,Q.jsx)(G,{to:i.to,...a,className:`flex-col items-stretch gap-1`,children:o}):(0,Q.jsx)(`a`,{href:i.href,target:`_blank`,rel:`noreferrer`,...a,className:`flex-col items-stretch gap-1`,children:o})}):(0,Q.jsx)(`div`,{...a,className:`flex flex-col items-stretch gap-1 rounded-sm px-2 py-1.5 text-sm`,children:o})}function jv(e){return e?.trim()||null}function Mv({projectName:e,pageLabel:t}){let n=jv(e),r=jv(t);return n&&r?`${n} — ${r} · Squawk`:n?`${n} · Squawk`:r?`${r} · Squawk`:`Squawk`}function Nv(e){let t=Mv(e);(0,Z.useEffect)(()=>{document.title=t},[t])}function Pv({...e}){return(0,Q.jsx)(Jl,{"data-slot":`alert-dialog`,...e})}function Fv({...e}){return(0,Q.jsx)(Yl,{"data-slot":`alert-dialog-portal`,...e})}function Iv({className:e,...t}){return(0,Q.jsx)(Xl,{"data-slot":`alert-dialog-overlay`,className:q(`fixed inset-0 z-50 bg-black/50 motion-safe:data-[state=closed]:animate-out data-[state=closed]:fade-out-0 motion-safe:data-[state=open]:animate-in data-[state=open]:fade-in-0 motion-reduce:data-[state=open]:animate-none motion-reduce:data-[state=closed]:animate-none`,e),...t})}function Lv({className:e,...t}){return(0,Q.jsxs)(Fv,{children:[(0,Q.jsx)(Iv,{}),(0,Q.jsx)(Zl,{"data-slot":`alert-dialog-content`,className:q(`fixed inset-bs-[50%] start-[50%] z-50 grid max-h-[calc(100dvh-2rem)] overflow-y-auto overscroll-contain w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border bg-card p-6 shadow-modal duration-200 outline-hidden motion-safe:data-[state=closed]:animate-out data-[state=closed]:fade-out-0 motion-safe:data-[state=closed]:zoom-out-95 motion-safe:data-[state=open]:animate-in data-[state=open]:fade-in-0 motion-safe:data-[state=open]:zoom-in-95 motion-reduce:data-[state=open]:animate-none motion-reduce:data-[state=closed]:animate-none sm:max-w-md`,e),...t})]})}function Rv({className:e,...t}){return(0,Q.jsx)(`div`,{"data-slot":`alert-dialog-header`,className:q(`flex flex-col gap-2 text-center sm:text-start`,e),...t})}function zv({className:e,...t}){return(0,Q.jsx)(`div`,{"data-slot":`alert-dialog-footer`,className:q(`flex flex-col-reverse gap-2 sm:flex-row sm:justify-end`,e),...t})}function Bv({className:e,...t}){return(0,Q.jsx)(eu,{"data-slot":`alert-dialog-title`,className:q(`text-lg leading-none font-semibold`,e),...t})}function Vv({className:e,...t}){return(0,Q.jsx)(tu,{"data-slot":`alert-dialog-description`,className:q(`text-sm text-muted-foreground`,e),...t})}function Hv({className:e,...t}){return(0,Q.jsx)(Ql,{"data-slot":`alert-dialog-action`,className:q(Da({variant:`contrast`}),e),...t})}function Uv({className:e,...t}){return(0,Q.jsx)($l,{"data-slot":`alert-dialog-cancel`,className:q(Da({variant:`outline`}),e),...t})}function Wv(e){let t=Oo(e);return/^\/git\/branches(?:\/|$)/.test(t)?`branches`:/^\/git\/not-landed(?:\/|$)/.test(t)?`not-landed`:/^\/git\/cleanup(?:\/|$)/.test(t)?`cleanup`:/^\/git\/changes(?:\/|$)/.test(t)?`changes`:/^\/git(?:\/commits(?:\/[^/]+)?)?\/?$/.test(t)?`main`:null}var Gv={main:`/git`,"not-landed":`/git/not-landed`,cleanup:`/git/cleanup`,branches:`/git/branches`,changes:`/git/changes`},Kv=`/git?view=repo`,qv={second:1,minute:60,hour:3600,day:86400,week:7*86400,month:30*86400,year:365*86400};function Jv(e,t,n=Date.now()){let r=t?ys(t,n):``;if(r)return r;let i=/^(\d+) (second|minute|hour|day|week|month|year)s?(?:, (\d+) (second|minute|hour|day|week|month|year)s?)? ago$/.exec(e.trim());return i?xs(Number(i[1])*qv[i[2]]+(i[3]?Number(i[3])*qv[i[4]]:0)):e}function Yv(e,t){let n=t?Date.parse(t):NaN;return Number.isFinite(n)?new Date(n).toLocaleString():e}function Xv(e){let t=new Date(e);return t.setHours(0,0,0,0),t.getTime()}var Zv=new Intl.DateTimeFormat(`en-US`,{weekday:`short`,month:`short`,day:`numeric`}),Qv=new Intl.DateTimeFormat(`en-US`,{month:`short`,day:`numeric`,year:`numeric`});function $v(e,t){let n=Date.parse(e);if(Number.isNaN(n))return`Earlier`;let r=Xv(t);if(n>=r)return`Today`;if(n>=Xv(r-1))return`Yesterday`;let i=new Date(n);return(i.getFullYear()===new Date(t).getFullYear()?Zv:Qv).format(i)}function ey(e,t=Date.now()){let n=[];for(let r of e){let e=$v(r.at,t),i=n.at(-1);i?.label===e?i.commits.push(r):n.push({label:e,commits:[r]})}return n}function ty(e,t=Date.now()){return e.filter(e=>$v(e.at,t)===`Today`).length}function ny(e,t){return(e.baseBranch??t.branch)===t.branch?e.tracking:null}function ry(e,t=Date.now()){let n=e.fetchedAt?ys(e.fetchedAt,t):``;return n?`fetched ${Ss(n)}`:`never fetched`}function iy(e,t,n){return!e?.repo||e.bootProject===null||t!=="default"&&t!==e.bootProject?e:{...e,repo:{...e.repo,branch:n}}}function ay(e,t){return Promise.all([e.invalidateQueries({queryKey:[t,`repo`]}),e.invalidateQueries({queryKey:[t,`health`]}),e.invalidateQueries({queryKey:V.projects})])}var oy=e=>[e,`repo-branch-switch`];function sy(e){return cc({mutationKey:oy(e)})>0}function cy(e,t){let n=U();return je({mutationKey:oy(e),mutationFn:t=>en({name:t},e),onSuccess:async t=>{H(t.created?`Created and switched to ${t.branch}`:`Switched to ${t.branch}`),await ay(n,e),n.setQueryData([e,`repo`],e=>e?.info?{...e,info:{...e.info,branch:t.branch}}:e),n.setQueryData([e,`health`],n=>iy(n,e,t.branch))},...t?{onError:t}:{}})}function ly(e,t){let n=U(),r=[e,`repo`],[i,a]=(0,Z.useState)(null),o=e=>H(e.message,{tone:`danger`}),s=()=>ay(n,e),c=je({mutationFn:t=>yt(t,e)}),l=async(e=!1)=>{let n=i?.branch??t.branch;try{let t=await c.mutateAsync(e?{branch:n,confirm:!0}:{branch:n});if(`risks`in t){a(t);return}a(null),H(t.summary),await s()}catch(e){a(null),H(e instanceof Error?e.message:String(e),{tone:`danger`}),await s()}},u=cy(e,o),d=sy(e),f=je({mutationFn:t=>st({baseBranch:t},e),onSuccess:t=>{H(t.baseBranch?`New tasks now start from ${t.baseBranch}`:`New tasks now start from the checked-out branch`),n.invalidateQueries({queryKey:r}),n.invalidateQueries({queryKey:[e,`config`]})},onError:o});return{switching:d,hasRemote:!!t.remote,pull:l,pulling:c.isPending,confirmation:i,dismissConfirmation:()=>{c.isPending||a(null)},switchBranch:u,setBase:f}}var uy={sidebar:{card:`gap-[8px] rounded-[8px] p-[10px]`,branchRow:`gap-[6px]`,branchIcon:`size-[14px]`,branch:`text-[12.5px]`,chevron:`size-[12px]`,pull:`h-[24px] gap-[4px] rounded-[6px] px-[8px] text-xs [&>svg]:size-[12px]`,line:`text-xs`,lineChevron:`size-[11px]`,dirty:`gap-[6px] pt-[6px] text-xs [&>svg]:size-[12px]`},screen:{card:`gap-[10px] rounded-[10px] p-[12px]`,branchRow:`gap-[8px]`,branchIcon:`size-[16px]`,branch:`text-[14px]`,chevron:`size-[14px]`,pull:`h-[36px] gap-[6px] rounded-[8px] px-[14px] text-[13px] [&>svg]:size-[14px]`,line:`text-[12px]`,lineChevron:`size-[12px]`,dirty:`h-[40px] gap-[8px] pt-[4px] text-[13px] [&>svg:first-child]:size-[14px] [&>svg:last-child]:size-[15px]`}};function dy({scope:e,repo:t,info:n,variant:r,onNavigate:i}){let a=uy[r],o=ly(e,n),s=t.baseBranch??n.branch,c=t.status.length,l=ny(t,n),u=o.switching,d=(0,Z.useRef)(null);return(0,Q.jsxs)(`section`,{"aria-label":`Checkout`,"data-slot":`git-checkout`,"data-variant":r,className:q(`flex flex-col border border-border`,a.card),children:[(0,Q.jsxs)(`div`,{className:q(`flex min-w-0 items-center`,a.branchRow),children:[(0,Q.jsxs)(oo,{children:[(0,Q.jsxs)(ro,{"data-slot":`git-branch-menu`,"aria-label":`Branch ${n.branch}. Switch branch`,disabled:u,className:q(`group flex min-w-0 flex-1 items-center rounded-[4px] text-left outline-none focus-visible:outline-2 focus-visible:outline-ring disabled:opacity-60`,a.branchRow,r===`screen`&&`min-h-11`),children:[(0,Q.jsx)(ji,{"aria-hidden":`true`,className:q(`shrink-0 text-muted-foreground`,a.branchIcon)}),(0,Q.jsx)(`span`,{"data-slot":`git-checkout-branch`,className:q(`min-w-0 flex-1 truncate font-mono font-semibold text-foreground`,a.branch),children:n.branch}),(0,Q.jsx)(Ki,{"aria-hidden":`true`,className:q(`shrink-0 text-soft-foreground group-hover:text-foreground`,a.chevron)})]}),(0,Q.jsxs)(io,{align:`start`,className:`w-64`,children:[(0,Q.jsx)(Xa,{className:`text-xs text-soft-foreground`,children:`Switch branch`}),(0,Q.jsx)(ao,{value:n.branch,onValueChange:e=>{e!==n.branch&&o.switchBranch.mutate(e)},children:t.branches.map(e=>(0,Q.jsx)(Za,{value:e,"data-branch":e,className:`font-mono text-[12.5px]`,children:(0,Q.jsx)(`span`,{className:`truncate`,children:e})},e))}),(0,Q.jsx)(to,{}),(0,Q.jsx)(eo,{asChild:!0,children:(0,Q.jsx)(X,{to:Gv.branches,"data-slot":`git-branch-menu-all`,onClick:i,children:`Create or find a branch…`})})]})]}),(0,Q.jsxs)(`button`,{ref:d,type:`button`,"data-action":`repo-pull`,disabled:!o.hasRemote||o.pulling,title:o.hasRemote?`Pull ${n.branch}`:`No remote configured. Add a Git remote before pulling.`,onClick:()=>void o.pull(),className:q(`inline-flex shrink-0 items-center bg-muted font-medium text-foreground hover:brightness-110 focus-visible:outline-2 focus-visible:outline-ring disabled:opacity-50 disabled:hover:brightness-100`,a.pull),children:[o.pulling?(0,Q.jsx)(xa,{"aria-hidden":`true`,className:`motion-safe:animate-spin`}):(0,Q.jsx)(Ii,{"aria-hidden":`true`}),`Pull`]})]}),l?(0,Q.jsx)(fy,{tracking:l,className:a.line}):null,(0,Q.jsxs)(oo,{children:[(0,Q.jsxs)(ro,{"data-slot":`base-branch-picker`,"aria-label":`New tasks start from ${s}. Change the base branch`,disabled:o.setBase.isPending,className:q(`group flex min-w-0 items-center gap-[4px] self-start rounded-[4px] text-soft-foreground outline-none hover:text-foreground focus-visible:outline-2 focus-visible:outline-ring disabled:opacity-60`,a.line,r===`screen`&&`min-h-[32px]`),children:[(0,Q.jsx)(`span`,{className:`shrink-0`,children:`New tasks start from`}),(0,Q.jsx)(`span`,{"data-slot":`base-branch`,className:`min-w-0 truncate font-mono text-muted-foreground group-hover:text-foreground`,children:s}),(0,Q.jsx)(Ki,{"aria-hidden":`true`,className:q(`shrink-0`,a.lineChevron)})]}),(0,Q.jsxs)(io,{align:`start`,className:`w-64`,children:[(0,Q.jsx)(Xa,{className:`text-xs text-soft-foreground`,children:`New tasks start from`}),(0,Q.jsxs)(ao,{value:t.baseBranch??``,onValueChange:e=>o.setBase.mutate(e===``?null:e),children:[(0,Q.jsx)(Za,{value:``,"data-branch":``,className:`text-[12.5px]`,children:`The checked-out branch (default)`}),t.branches.map(e=>(0,Q.jsx)(Za,{value:e,"data-branch":e,className:`font-mono text-[12.5px]`,children:(0,Q.jsx)(`span`,{className:`truncate`,children:e})},e))]})]})]}),c>0?(0,Q.jsxs)(X,{to:Gv.changes,"data-slot":`git-uncommitted`,onClick:i,className:q(`flex min-w-0 items-center border-t border-border text-muted-foreground hover:text-foreground focus-visible:outline-2 focus-visible:outline-ring`,a.dirty),children:[(0,Q.jsx)(wi,{"aria-hidden":`true`,className:`shrink-0 text-inbox-count-foreground`}),(0,Q.jsxs)(`span`,{className:`min-w-0 flex-1 truncate`,children:[c,` uncommitted file`,c===1?``:`s`]}),(0,Q.jsx)(Ti,{"aria-hidden":`true`,className:`shrink-0 text-soft-foreground`})]}):null,(0,Q.jsx)(py,{checkout:o,returnFocus:d})]})}function fy({tracking:e,className:t}){let n=e.ref.split(`/`)[0]||e.ref,r=ry(e);return(0,Q.jsx)(`p`,{"data-slot":`git-freshness`,className:q(`flex min-w-0 items-center gap-[4px] text-soft-foreground`,t),children:e.behind>0?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`span`,{"data-slot":`git-behind`,className:`shrink-0 font-medium text-inbox-count-foreground`,children:[e.behind,` behind `,n]}),(0,Q.jsxs)(`span`,{className:`min-w-0 truncate`,children:[`· `,r]})]}):(0,Q.jsxs)(`span`,{className:`min-w-0 truncate`,children:[`up to date · `,r]})})}function py({checkout:e,returnFocus:t}){return(0,Q.jsx)(Pv,{open:e.confirmation!==null,onOpenChange:t=>!t&&e.dismissConfirmation(),children:(0,Q.jsxs)(Lv,{onCloseAutoFocus:e=>{e.preventDefault(),t.current?.focus()},children:[(0,Q.jsxs)(Rv,{children:[(0,Q.jsxs)(Bv,{children:[`Pull `,e.confirmation?.branch,` anyway?`]}),(0,Q.jsx)(Vv,{asChild:!0,children:(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[e.confirmation?.risks.includes(`active_runs`)?(0,Q.jsx)(`p`,{children:`An active session is using this repository. Pulling can change files while it works.`}):null,e.confirmation?.risks.includes(`dirty_tree`)?(0,Q.jsx)(`p`,{children:`The checkout has dirty files. Git may refuse the pull to protect them.`}):null]})})]}),(0,Q.jsxs)(zv,{children:[(0,Q.jsx)(Uv,{className:`h-11`,disabled:e.pulling,children:`Cancel`}),(0,Q.jsx)(Hv,{className:`h-11`,disabled:e.pulling||e.confirmation===null,onClick:t=>{t.preventDefault(),e.pull(!0)},children:e.pulling?`Pulling…`:`Pull anyway`})]})]})})}var my={main:fi,"not-landed":$c,cleanup:Fc,branches:ji};function hy(e,t){switch(e){case`main`:return t?`Recently on ${t}`:`Recent commits`;case`not-landed`:return`Not landed`;case`cleanup`:return`Cleanup`;case`branches`:return`All branches`;case`changes`:return`Uncommitted changes`}}var gy=[`main`,`not-landed`,`cleanup`,`branches`];function _y({branch:e,counts:t,variant:n,active:r,onNavigate:i}){let a=n===`screen`;return(0,Q.jsx)(`nav`,{"aria-label":`Git sections`,"data-slot":`git-sections`,className:a?ca:sa,children:gy.map(n=>{let o=my[n],s=!a&&r===n,c=t[n];return(0,Q.jsxs)(X,{to:a&&n===`main`?Kv:Gv[n],"data-git-section":n,"aria-current":s?`page`:void 0,onClick:i,className:q(a?ha:q(pa,`text-[12.5px]`),ua,s&&`bg-sidebar-row-selected text-foreground font-medium hover:bg-sidebar-row-selected`),children:[(0,Q.jsx)(o,{"aria-hidden":`true`,className:a?fa:oa}),(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:hy(n,e)}),c?(0,Q.jsx)(`span`,{"data-slot":`git-section-count`,className:a?ma:la,children:c}):null,a?(0,Q.jsx)(Ti,{"aria-hidden":`true`,className:da}):null]},n)})})}async function vy(e,t){return dt(await kt.api.v1.p[`:projectId`].repo.branches.counts.$get({param:{projectId:t??Ie()}},_t(e)),`/repo/branches/counts`)}function yy(e){return Jt({queryKey:[e,`repo`,`branches`,`counts`],queryFn:({signal:t})=>vy({signal:t},e)})}function by(e,t,n){let r=Oe(e),i=yy(e),a=r.data?.totalBytes??null,o=i.data?.counts??null,s=t&&n===`screen`?ty(t.log):0;return{main:s>0?`${s} today`:null,"not-landed":o?.notLanded?String(o.notLanded):null,cleanup:a?vr(a):r.data&&a===null&&o?.cleanup?String(o.cleanup):null,branches:t?String(i.data?.allBranches??t.branches.length):null}}function xy({scope:e}){let t=P(e),{pathname:n}=qn(),r=bl(),i=t.data?.info?t.data:null,a=by(e,i,`sidebar`);return(0,Q.jsxs)(`div`,{"data-slot":`git-sidebar`,role:`region`,"aria-label":`Git`,className:ia,children:[i?.info?(0,Q.jsx)(dy,{scope:e,repo:i,info:i.info,variant:`sidebar`,onNavigate:r},e):t.isPending?(0,Q.jsx)(`div`,{"data-slot":`git-checkout-placeholder`,"aria-hidden":`true`,className:`h-[94px] rounded-[8px] border border-border`}):null,t.isPending?null:(0,Q.jsx)(_y,{branch:i?.info?.branch??null,counts:a,variant:`sidebar`,active:Wv(n),onNavigate:r})]})}var Sy=[`assigned`,`no-task`,`has-task`,`all`],Cy=[`review`,`mine`,`failing`,`all`],wy=50,Ty=`is:open review-requested:@me`,Ey=`is:open status:failure`;function Dy(e,t){return e===`prs`&&(t===`review`||t===`failing`)}function Oy(e){return e===`review`?Ty:e===`failing`?Ey:null}function ky(e,t){return t===null?null:(e===`issues`?Sy:Cy).includes(t)?t:`all`}var Ay=[`q`,`label`,`assignee`,`board`];function jy(e){let t=new URLSearchParams;for(let n of Ay)for(let r of e.getAll(n))r!==``&&t.append(n,r);return t.toString()}function My(e,t,n,r=``,i=``){let a=`${n===void 0?e===`issues`?`/github`:`/github/prs`:`${e===`issues`?`/github/issues`:`/github/prs`}/${n}`}${r}`,o=[t===null?``:`filter=${encodeURIComponent(t)}`,i].filter(Boolean).join(`&`);return o===``?a:`${a}?${o}`}function Ny(e,t){let n=t??`all`;return n===`all`?e===`issues`?`all`:`all-prs`:n}function Py(e){return e===`all`?{view:`issues`,filter:`all`}:e===`all-prs`?{view:`prs`,filter:`all`}:{view:e===`review`||e===`mine`||e===`failing`?`prs`:`issues`,filter:e}}var Fy=[{id:`assigned`,label:`Assigned to me`},{id:`no-task`,label:`No task yet`},{id:`has-task`,label:`Has a task`},{id:`all`,label:`All open`}],Iy=[{id:`review`,label:`Review requested`},{id:`mine`,label:`Mine`},{id:`failing`,label:`Checks failing`},{id:`all-prs`,label:`All open`}],Ly=Object.fromEntries([...Fy,...Iy].map(e=>[e.id,e.label]));function Ry(e){return e===null?``:`${e.value}${e.bound===`atLeast`?`+`:``}`}function zy(e,t){if(t?.bound===`atLeast`)return e===`review`||e===`failing`?`At least ${t.value}: GitHub search returns at most ${wy} results.`:`At least ${t.value}: only the loaded pages are counted. Scroll to load more.`}var By=(e,t)=>e!==void 0&&t!==void 0&&e.toLowerCase()===t.toLowerCase();function Vy(e){try{let t=new URL(e).pathname.split(`/`).filter(Boolean);return t.length>=2?`${t[0]}/${t[1]}`.toLowerCase():null}catch{return null}}function Hy(e,t,n){return new Set(e.filter(e=>!e.archived).flatMap(e=>Uy(e,t,n)))}function Uy(e,t,n){let r=t?.toLowerCase();return nr(e,void 0,n).filter(e=>e.kind===`Issue`&&(!e.url||r!==void 0&&Vy(e.url)===r)).map(e=>e.number)}function Wy(e,t,n,r){let i=new Map;for(let a of e)!No(a)&&Uy(a,n,r).includes(t)&&i.set(a.id,a);return[...i.values()].sort((e,t)=>Date.parse(t.createdAt)-Date.parse(e.createdAt)||e.id.localeCompare(t.id))}function Gy(e,t,n){let r=new Map;for(let i of e)if(!(i.archived||No(i)))for(let e of Uy(i,t,n)){let t=r.get(e);(!t||Date.parse(i.createdAt)>Date.parse(t.createdAt))&&r.set(e,i)}return r}function Ky(e,t){let n=new Map(t.map(e=>[e.number,e]));return e.map(e=>n.get(e.number)??e)}function qy(e){return e?.available?{value:e.items.length,bound:e.truncated?`atLeast`:`exact`}:null}function Jy({gh:e,tasks:t,review:n,failing:r}){let i={assigned:null,"no-task":null,"has-task":null,all:null,review:qy(n),mine:null,failing:qy(r),"all-prs":null};if(!e?.available)return i;let a=!ve(e,`issues`),o=!ve(e,`prs`),s=(e,t)=>({value:e,bound:t?`atLeast`:`exact`}),c=t?e.issues.filter(e=>t.has(e.number)).length:null;return{...i,all:s(e.issuesTotal??e.issues.length,!1),"all-prs":s(e.prsTotal??e.prs.length,!1),assigned:e.viewerLogin?s(e.issues.filter(t=>t.assignees?.some(t=>By(t,e.viewerLogin))).length,a):null,mine:e.viewerLogin?s(e.prs.filter(t=>By(t.author,e.viewerLogin)).length,o):null,"has-task":c===null?null:s(c,a),"no-task":c===null?null:s(e.issues.length-c,a)}}var Yy={assigned:qi,"no-task":na,"has-task":Ci,all:Pi,review:ba,mine:ci,failing:yi,"all-prs":Pi};function Xy(e,t){return e===`assigned`||e===`mine`?t.identity:e===`no-task`||e===`has-task`?t.tasks:null}function Zy({model:e,variant:t,activeId:n,onNavigate:r,keep:i}){let a=t===`screen`;return(0,Q.jsx)(Q.Fragment,{children:[{key:`issues`,label:`Issues`,rows:Fy},{key:`prs`,label:`Pull requests`,rows:Iy}].map(t=>(0,Q.jsxs)(`nav`,{"aria-label":t.label,"data-slot":`github-filter-group`,"data-group":t.key,className:a?ca:q(ga,t.key===`prs`&&`pt-[6px]`),children:[(0,Q.jsx)(`h3`,{className:a?ra:aa,children:t.label}),t.rows.map(({id:t,label:o})=>{let s=Yy[t],c=n===t,l=Xy(t,e.blocked),u=e.counts[t],d=Ry(u),f=q(a?ha:q(pa,`text-[12.5px]`),l?`cursor-not-allowed opacity-60`:ua,c&&`bg-sidebar-row-selected text-foreground font-medium hover:bg-sidebar-row-selected`),p=(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(s,{"aria-hidden":`true`,className:a?fa:oa}),(0,Q.jsx)(`span`,{className:`truncate`,children:o}),d?(0,Q.jsx)(`span`,{"data-slot":`gh-filter-count`,title:zy(t,u),className:a?ma:la,children:d}):null,a?(0,Q.jsx)(Ti,{"aria-hidden":`true`,className:q(da,!d&&`ml-auto`)}):null]});if(l)return(0,Q.jsxs)(`div`,{"data-gh-filter":t,"aria-disabled":`true`,title:l,className:f,children:[p,(0,Q.jsx)(`span`,{className:`sr-only`,children:l})]},t);let{view:m,filter:h}=Py(t);return(0,Q.jsx)(X,{to:My(m,h,void 0,``,i?.view===m?i.narrows:``),"data-gh-filter":t,"aria-current":c?`page`:void 0,onClick:r,className:f,children:p},t)})]},t.key))})}function Qy(e){let t=fe(e,50).data,n=t?.available===!0,r=De(e,!0,e==="default"),i=we(e,`pr`,Ty,n),a=we(e,`pr`,Ey,n),o=(0,Z.useMemo)(()=>r.data?Hy(r.data,t?.repo,e):null,[r.data,t?.repo,e]);return{gh:t,counts:(0,Z.useMemo)(()=>Jy({gh:t,tasks:o,review:i.data,failing:a.data}),[t,o,i.data,a.data]),blocked:{identity:t?.available===!0&&!t.viewerLogin?`GitHub login unavailable.`:null,tasks:r.isError&&!r.data?`Task list unavailable.`:null}}}function $y(e){return/^\/github\/prs(?:\/|$)/.test(Oo(e))?`prs`:`issues`}function eb({scope:e}){let t=Qy(e),{pathname:n}=qn(),[r]=zn(),i=bl(),a=$y(n);return(0,Q.jsx)(`div`,{"data-slot":`github-sidebar`,role:`region`,"aria-label":`GitHub`,className:ia,children:(0,Q.jsx)(Zy,{model:t,variant:`sidebar`,activeId:Ny(a,ky(a,r.get(`filter`))),onNavigate:i,keep:{view:a,narrows:jy(r)}})})}var tb=(0,Z.lazy)(()=>W(()=>import(`./accounts-section-B8X63Wvk.js`).then(e=>({default:e.GlobalAgentsSection})),__vite__mapDeps([5,1,2,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,42,43,44,45,46,47,48]))),nb=(0,Z.lazy)(()=>W(()=>import(`./agent-config-section-RluVjTDv.js`).then(e=>({default:e.AgentConfigSection})),__vite__mapDeps([49,1,2,6,7,8,9,10,11,12,20,21,28,36,38,39,15,40,16,26,41,19,42,43,44,24,31,33,34,45,46,13,14,47,37,50,51,52,53]))),rb=(0,Z.lazy)(()=>W(()=>import(`./agent-defaults-section-Bl67Iurg.js`).then(e=>({default:e.AgentDefaultsSection})),__vite__mapDeps([54,1,2,6,7,8,9,10,11,12,15,20,55,24,32,34,25,26,16,56,28,57,29,30,31,33,35,22,23,37,47,53,58]))),ib=(0,Z.lazy)(()=>W(()=>import(`./appearance-ChGEz79A.js`).then(e=>({default:e.AppearanceSection})),__vite__mapDeps([59,2,1,6,7,8,9,10,11,12,16,60,20,37,47]))),ab=(0,Z.lazy)(()=>W(()=>import(`./projects-section-0eQ2TVqw.js`).then(e=>e.r).then(e=>({default:e.ProjectsSection})),__vite__mapDeps([61,1,2,6,7,8,9,10,11,12,13,14,15,20,62,24,33,34,28,29,30,31,32,37,47,38,39,40,16,26,41,19,42,43,44,45,46,53,58,63,64,65]))),ob=(0,Z.lazy)(()=>W(()=>import(`./prompt-templates-section-CVNw5v0w.js`).then(e=>({default:e.PromptTemplatesSection})),__vite__mapDeps([66,1,2,6,7,8,9,10,11,12,15,20,62,24,33,34,67,23,22,68,28,57,47,37,53,58,63,64,65]))),sb=(0,Z.lazy)(()=>W(()=>import(`./resources-section-BAj-A1Ou.js`).then(e=>({default:e.ResourcesSection})),__vite__mapDeps([69,2,1,6,7,8,9,10,11,12,13,14,15,55,24,32,34,28,29,30,31,33,37,47,48,53,20,58]))),cb=(0,Z.lazy)(()=>W(()=>import(`./session-context-section-CihFGtUL.js`).then(e=>({default:e.SessionContextSection})),__vite__mapDeps([70,1,2,6,7,8,9,10,11,12,71,16,20,21,28,50,51,14,45,53,37]))),lb=(0,Z.lazy)(()=>W(()=>import(`./sidebar-section-BTjJD2PF.js`).then(e=>({default:e.SidebarSection})),__vite__mapDeps([72,1,2,6,7,8,9,10,11,12,20,53,37]))),ub=(0,Z.lazy)(()=>W(()=>import(`./worktrees-section-CytHZvmT.js`).then(e=>({default:e.WorktreesSection})),__vite__mapDeps([73,1,2,6,7,8,9,10,11,12,15,46,13,14,28,36,47,37,39,40,16,26,41,19,42,43,20,44,24,31,33,34,45,53,58]))),db=(0,Z.lazy)(()=>W(()=>import(`./preferences-section-DuV8JFqQ.js`).then(e=>({default:e.PreferencesSection})),__vite__mapDeps([74,1,2,6,7,8,9,10,11,12,55,24,32,34,37,75,29,30,15,31,33]))),fb=[{id:`sidebar`,title:`Sidebar`,description:`Overall and per-section task limits for this project.`,icon:ni,component:lb,scope:`project`},{id:`agent-defaults`,title:`Agent defaults`,description:`Default runner, models and system prompt.`,icon:Ci,component:rb,scope:`project`},{id:`agent-config`,title:`Agent config`,description:`Edit the coding agents’ own config files, per scope.`,icon:Jc,component:nb,scope:`project`},{id:`session-context`,title:`Session context`,description:`Text Squawk puts at the start of every agent session it launches.`,icon:Yc,component:cb,scope:`project`},{id:`worktrees`,title:`Worktrees`,description:`How many finished task worktrees this project keeps on disk.`,icon:Zc,component:ub,scope:`project`},{id:`prompt-templates`,title:`Prompt templates`,description:`Reusable snippets for follow-up instructions.`,icon:Xc,component:ob,scope:`project`},{id:`appearance`,title:`Appearance`,description:`Theme, density and reading width.`,icon:Bi,component:ib,scope:`global`},{id:`preferences`,title:`Preferences`,description:`Browser notifications and task archiving after pull requests merge.`,icon:Ui,component:db,scope:`global`},{id:`resources`,title:`Resources`,description:`Parallel tasks and per-task memory limit, across every project.`,icon:ni,component:sb,scope:`global`},{id:`agents`,title:`Agents`,description:`Install, version and sign-in for each agent, and the agent and models a project uses when it has chosen none.`,icon:Xi,component:tb,scope:`global`},{id:`projects`,title:`Projects`,description:`The workspace registry and where GitHub checkouts land.`,icon:Mi,component:ab,scope:`global`}];function pb(e){return fb.filter(t=>t.scope===e)}function mb(e,t){return e===`global`?`/settings/global/${t}`:`/settings/${t}`}var hb=mb(`global`,`appearance`);function gb({projectId:e,projectName:t}){return(0,Q.jsx)(`div`,{"data-slot":`settings-sidebar`,className:ia,children:(e===null?[`global`]:[`project`,`global`]).map(n=>{let r=n===`project`?`This project${t?` · ${t}`:``}`:`Global · every project`,i=n===`project`&&e!==null?`/p/${encodeURIComponent(e)}/settings`:`/settings/global`,a=pb(n).map(e=>({id:e.id,title:e.title,icon:e.icon,to:`${i}/${e.id}`})),o=n===`project`?[{id:`general`,title:`General`,icon:Ei,to:i},...a]:a;return(0,Q.jsxs)(`nav`,{"aria-label":r,"data-slot":`settings-nav`,"data-scope":n,className:q(`flex flex-col gap-px`,n===`global`&&e!==null&&`pt-[6px]`),children:[(0,Q.jsx)(`h3`,{title:r,className:aa,children:r}),o.map(({id:e,title:t,icon:n,to:r})=>(0,Q.jsxs)(Jn,{to:r,end:!0,"data-section":e,className:({isActive:e})=>q(pa,ua,e&&`bg-sidebar-row-selected text-foreground font-medium hover:bg-sidebar-row-selected`),children:[(0,Q.jsx)(n,{"aria-hidden":`true`,className:oa}),(0,Q.jsx)(`span`,{className:`truncate`,children:t})]},e))]},n)})})}var _b=[{pattern:`/`,pageLabel:`Tasks`},{pattern:`/tasks`,pageLabel:`All tasks`},{pattern:`/tools`,pageLabel:`Workspace tools`},{pattern:`/new`,pageLabel:`New task`},{pattern:`/activity`,pageLabel:`Activity`},{pattern:`/git/not-landed`,pageLabel:`Git / Not landed`},{pattern:`/git/branches`,pageLabel:`Git / All branches`},{pattern:`/git/changes`,pageLabel:`Git / Uncommitted changes`},{pattern:`/git/cleanup`,pageLabel:`Git / Cleanup`},{pattern:`/git/*`,pageLabel:`Git`},{pattern:`/github/*`,pageLabel:`GitHub`},{pattern:`/automations/new`,pageLabel:`Automations / New automation`},{pattern:`/automations/:automationId`,pageLabel:`Automations / Edit automation`},{pattern:`/automations/*`,pageLabel:`Automations`},{pattern:`/skills`,pageLabel:`Skills`},{pattern:`/reports`,pageLabel:`Reports`},{pattern:`/workflows/*`,pageLabel:`Workflows`},{pattern:`/settings/*`,pageLabel:`Settings`}];function vb(e,t={}){let n=Oo(e),r=Gn({path:`/tasks/:id/*`,end:!0},n);if(r)return{pageLabel:null,taskId:r.params.id??null};let i=t.reports??!0;return{pageLabel:_b.find(({pattern:e})=>(e!==`/reports`||i)&&Gn({path:e,end:!0},n))?.pageLabel??null,taskId:null}}function yb(e){let t=e?.repo;if(!t)return null;let n=t.root.replace(/[\\/]+$/,``).split(/[\\/]/).pop();return n?{name:n,branch:t.branch}:null}var bb=e=>Lo(e).waiting>0;function xb(e,t){return e===void 0?t!==void 0&&t.bootProject===null?null:t?.bootProject??`default`:e.bootProject===null?e.projects.find(e=>e.status!==`missing`)?.id??e.projects[0]?.id??null:e.bootProject}function Sb(e,t,n){let r=t===void 0?n?.bootProject??null:t.bootProject,i=e??xb(t,n);return{bootProjectId:r,sidebarProjectId:i,sidebarBoot:i!==null&&i===r,isBootProject:e!==null&&e===r,activeProject:e===null?void 0:t?.projects.find(t=>t.id===e),sidebarProject:i===null?void 0:t?.projects.find(e=>e.id===i),projectQueriesEnabled:i!==null&&(e!==null||r!==null||t!==void 0)}}function Cb(e,t,n,r,i,a){let o=e===`/tools`||e===`/settings/global`||e.startsWith(`/settings/global/`);return{globalSettings:o,projectName:o?null:t?.name??(n?yb(r)?.name??null:null),titleRun:a,pageLabel:a?Ro(a):i.pageLabel}}function wb(e){return e?.forge===`github`}function Tb(e,t,n,r,i,a){if(/^\/settings(?:\/|$)/.test(e))return(0,Q.jsx)(gb,{projectId:n,projectName:n===null?null:i?.projects.find(e=>e.id===n)?.name??(r?yb(a)?.name??null:null)});if(n!==null)return/^\/github(?:\/|$)/.test(e)&&t?(0,Q.jsx)(eb,{scope:v({projectId:n,boot:r}).cacheScope}):/^\/git(?:\/|$)/.test(e)?(0,Q.jsx)(xy,{scope:v({projectId:n,boot:r}).cacheScope}):void 0}function Eb(e,t,n,r,i){return e===`/tools`?yb(i):t?null:n?{name:n.name,branch:n.id===r?i?.repo?.branch??``:``}:yb(i)}function Db(e,t,n,r,i,a){let o=Eo(e)===null,s=n?`Tasks / ${i}`:e===`/tools`?`Tools`:!a&&e===`/`?`Projects`:i??(r.taskId===null?`Not found`:`Tasks`);return{project:o?`Workspace`:t,page:s,branch:n?.worktreePath?`Isolated worktree`:void 0}}function Ob(e,t,n=!1,r){if(!e||e.hosts.length===0&&!e.warning)return;let i=t?e.hosts.map(e=>{if(e.id!==t.hostId)return e;let r=t.offline&&t.state!==null?t.state:!t.offline&&n?`connected`:e.state;return r===e.state?e:{...e,state:r}}):e.hosts;return{localProjects:e.local.projects,hosts:i,warning:e.warning,...r===void 0?{}:{hostSignals:r}}}function kb(e,t){let n=Pe()?t:e;return{version:n?.version??null,latestVersion:n?.latestVersion??null}}function Ab(e,t){return e?t?{...e,hostsData:t}:e:t?{projects:[],signals:null,hostsData:t}:null}function jb(e,t,n,r,i){return e?(0,Q.jsx)(Cg,{...e,hostsData:i,projectTarget:t.target,onSwitchProject:e=>void t.go(e),version:r}):i?(0,Q.jsx)(Cg,{projects:[],signals:null,hostsData:i,version:r}):n?(0,Q.jsx)(_g,{}):null}function Mb(e,t,n){return e===null?{hasProjects:!1,taskQuickList:void 0,projectHeader:void 0,sidebarProjectId:void 0}:{hasProjects:!0,taskQuickList:(0,Q.jsx)(yv,{projectId:e,boot:t,enabled:n}),projectHeader:(0,Q.jsx)(gd,{}),sidebarProjectId:e}}function Nb(e,t,n){return!e&&t===`/`?`Projects`:n}function Pb({children:e}){let{pathname:t}=qn(),n=Ao(),r=Pe(),i=c(),a=Yr(r),o=L(),s=(0,Z.useRef)(void 0);(0,Z.useEffect)(()=>{i.data&&(s.current=i.data)},[i.data]);let l=i.data??s.current,u=mm(l),d=vm(l)!==`absent`,f=A(),p=f.data,m=wg(),h=Bt(),g=Gr(),_=Ur({enabled:r}),v=m?.hostSignals??(r?_.data??null:void 0),y=Ob(Kr().data,g,h.reportedState===`connected`,v),b=Ab(m,y),x=pm(),S=vb(t,{reports:d}),{bootProjectId:C,sidebarProjectId:w,sidebarBoot:T,isBootProject:E,activeProject:D,sidebarProject:O,projectQueriesEnabled:k}=Sb(n,p,i.data),M=Mb(w,T,k),ee=De(w??``,k,T,bb).data??!1,P=(0,Z.useCallback)(e=>{let t=e.find(e=>e.id===S.taskId);return t?{title:t.title,titleSummary:t.titleSummary,titleOrigin:t.titleOrigin,worktreePath:t.worktreePath}:void 0},[S.taskId]),F=De(n??``,D!==void 0&&S.taskId!==null,E,P).data,I=F?void 0:S.taskId??void 0,R=j(n===null&&C!==null?I:void 0),te=N(n??void 0,I),ne=n===null?R.data:te.data,{globalSettings:re,projectName:z,titleRun:ie,pageLabel:ae}=Cb(t,D,E,i.data,S,F??ne);Nv({projectName:z,pageLabel:Nb(M.hasProjects,t,ae)});let oe=wb(O),B=Tb(Oo(t),oe,w,T,p,i.data),{version:se,latestVersion:ce}=kb(l,a.data),le=h.offline;return(0,Q.jsxs)(Th,{children:[(0,Q.jsx)(ap,{repo:Eb(t,re,D,C,i.data),breadcrumb:Db(t,z,ie,S,ae,M.hasProjects),version:se,latestVersion:ce,forgeAvailable:oe,automationsAvailable:u,reportsAvailable:d,hostLive:le?`false`:void 0,...M,banner:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Oh,{}),(0,Q.jsx)(ng,{}),(0,Q.jsx)(Rh,{}),(0,Q.jsx)(Ph,{})]}),sidebarList:B,mobileProjects:b,needsYou:ee,toolsMenu:(0,Q.jsx)(Ov,{health:i.data,runners:o.data}),toolsStatus:i.data?{blocked:Tv(i.data,o.data)!==null,note:Dv(i.data)}:null,projectRail:jb(m,x,f.isPending,se,y),children:e}),(0,Q.jsx)(mh,{canCreateTask:M.hasProjects})]})}var Fb=`cez-accent`,Ib=`cez-density`,Lb=`cez-width`,Rb=`cezarion`,zb=`comfortable`,Bb=`narrow`;function Vb(e){return Rb}function Hb(e){return e===`comfortable`||e===`compact`||e===`ultra`?e:zb}function Ub(e){return e===`narrow`||e===`wide`?e:Bb}function Wb(e){let t=e&&typeof e==`object`?e:{};return{accent:Vb(t.accent),density:Hb(t.density),width:Ub(t.width)}}function Gb(){try{return{accent:Vb(localStorage.getItem(Fb)),density:Hb(localStorage.getItem(Ib)),width:Ub(localStorage.getItem(Lb))}}catch{return{accent:Rb,density:zb,width:Bb}}}function Kb(e){try{localStorage.setItem(Fb,e.accent),localStorage.setItem(Ib,e.density),localStorage.setItem(Lb,e.width)}catch{}}function qb(e,t){t.accent===`cezarion`?delete e.dataset.accent:e.dataset.accent=t.accent,t.density===`comfortable`?delete e.dataset.density:e.dataset.density=t.density,t.width===`narrow`?delete e.dataset.width:e.dataset.width=t.width}var Jb=Z.createContext(null);function Yb({children:e}){let t=U(),n=Pe(),r=ce(!n),i=Wr(n),a=n?i:r,o=n?Xr.uiState:V.uiState,[s,c]=Z.useState(Gb),l=a.data;Z.useEffect(()=>{if(l===void 0)return;let e=Wb(l.appearance);c(e),Kb(e)},[l]),Z.useLayoutEffect(()=>{qb(document.documentElement,s)},[s]);let u=Z.useCallback(e=>(c(e),Kb(e),(n?k:Ht)({appearance:e}).then(e=>(t.setQueryData(o,e),!0)).catch(e=>(H(e instanceof Error?e.message:String(e),{tone:`danger`}),t.invalidateQueries({queryKey:o}),!1))),[n,t,o]),d=Z.useCallback(e=>u({...s,accent:e}),[u,s]),f=Z.useCallback(e=>u({...s,density:e}),[u,s]),p=Z.useCallback(e=>u({...s,width:e}),[u,s]),m=Z.useMemo(()=>({accent:s.accent,density:s.density,width:s.width,setAccent:d,setDensity:f,setWidth:p}),[s,d,f,p]);return(0,Q.jsx)(Jb.Provider,{value:m,children:e})}function Xb(){let e=Z.useContext(Jb);if(!e)throw Error(`Squawk: useAppearance() must be called inside <AppearanceProvider>`);return e}function Zb({hostId:e,hosts:t,warning:n}){let r=rt(t);return(0,Q.jsx)(ds,{route:`unknown-host`,density:`empty`,flushPadding:!0,children:(0,Q.jsxs)(tc,{icon:(0,Q.jsx)(ll,{}),tone:`neutral`,title:`“${e}” isn’t a saved host`,subtitle:r.length>0?`This Squawk doesn’t have a saved host by that id. Choose a saved host below, or open this server:`:n?`This Squawk could not load saved hosts.`:`This Squawk doesn’t have a saved host by that id, and no remote hosts are saved yet.`,children:[n?(0,Q.jsx)(`p`,{"data-slot":`unknown-host-warning`,role:`alert`,className:`mx-auto max-w-sm rounded-md border border-border bg-muted/50 px-3 py-2 text-xs text-muted-foreground`,children:n}):null,r.length>0?(0,Q.jsxs)(`div`,{className:`mx-auto flex w-full max-w-sm flex-col gap-3`,children:[(0,Q.jsx)(`ul`,{"data-slot":`saved-hosts`,className:`flex w-full flex-col gap-1.5 text-left`,children:r.map(e=>(0,Q.jsx)(`li`,{children:(0,Q.jsxs)(`a`,{href:Me(e.id),"data-slot":`saved-host-link`,"data-host-id":e.id,className:`flex min-h-11 items-center justify-between gap-2 rounded-md border border-border bg-card px-3 py-2 text-sm font-medium text-foreground shadow-xs transition-colors hover:bg-card-2 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring`,children:[(0,Q.jsxs)(`span`,{className:`flex min-w-0 flex-wrap items-baseline gap-x-2`,children:[(0,Q.jsx)(`span`,{className:`truncate`,children:e.label}),(0,Q.jsxs)(`span`,{className:`font-mono text-xs font-normal text-muted-foreground`,children:[`/h/`,e.id]})]}),(0,Q.jsx)(Ed,{state:e.state,className:`shrink-0`})]})},e.id))}),(0,Q.jsx)(`div`,{children:(0,Q.jsx)(Y,{asChild:!0,variant:`outline`,children:(0,Q.jsx)(`a`,{href:Me(null),"data-slot":`return-this-server`,children:`Open this server`})})})]}):(0,Q.jsx)(Y,{asChild:!0,variant:`primary`,children:(0,Q.jsx)(`a`,{href:Me(null),"data-slot":`return-this-server`,children:`Open this server`})})]})})}function Qb({hostId:e,children:t}){Vr();let n=Hr({enabled:e!==null,pollWhileOffline:!0}),r=(0,Z.useRef)(null),i=!!(e&&n.data?.hosts.some(t=>t.id===e));if((0,Z.useEffect)(()=>{i&&e?r.current=e:r.current===e?n.data&&!n.data.warning&&(r.current=null):r.current=null},[e,i,n.data]),e===null)return(0,Q.jsx)(Q.Fragment,{children:t});let a=ht.safeParse(e).success;if(n.isPending&&!n.data)return(0,Q.jsx)(`div`,{"data-route":`host-resolving`,className:`flex min-h-dvh flex-col bg-background text-foreground`,children:(0,Q.jsx)(`p`,{className:`px-4 py-6 text-center text-xs text-soft-foreground`,children:`Loading…`})});if(!a)return(0,Q.jsx)(`div`,{className:`grid min-h-dvh bg-background text-foreground`,children:(0,Q.jsx)(Zb,{hostId:e,hosts:n.data?.hosts??[],warning:n.data?.warning})});if(!n.data)return(0,Q.jsx)(`div`,{className:`grid min-h-dvh bg-background text-foreground`,children:(0,Q.jsx)(ds,{route:`host-lookup-error`,density:`empty`,flushPadding:!0,children:(0,Q.jsx)(tc,{icon:(0,Q.jsx)(wi,{size:16}),tone:`danger`,title:`Could not load saved hosts`,subtitle:`Could not reach this server to check saved hosts. Retry once the server is available.`,actions:(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center justify-center gap-2`,children:[(0,Q.jsx)(Y,{type:`button`,variant:`primary`,onClick:()=>void n.refetch(),children:`Retry`}),(0,Q.jsx)(Y,{asChild:!0,variant:`outline`,children:(0,Q.jsx)(`a`,{href:Me(null),"data-slot":`return-this-server`,children:`Open this server`})})]})})})});let o=!!n.data.warning&&r.current===e;return!i&&!o?(0,Q.jsx)(`div`,{className:`grid min-h-dvh bg-background text-foreground`,children:(0,Q.jsx)(Zb,{hostId:e,hosts:n.data.hosts,warning:n.data.warning})}):(0,Q.jsx)(Q.Fragment,{children:t})}function $b(){let e=qn(),t=A();return fm(),(0,Z.useEffect)(()=>{let n=Rp(e,t.data);n!==null&&(Bp(kp(),n)||Ap(n),Bp(Up(n.projectId),n)||Wp(n))},[e.hash,e.pathname,e.search,t.data]),null}function ex(e){return{enabled:(e&&typeof e==`object`?e:{}).enabled===!0}}function tx(){let e=globalThis.Notification;if(typeof e!=`function`)return`unsupported`;let t=e.permission;return t===`granted`||t===`denied`?t:`default`}function nx(e,t){let n=new Map,r=[];for(let i of t??[]){let t={status:i.status,wantsAttention:Jo(i)};n.set(i.id,t);let a=e.get(i.id);a!==void 0&&(a.status===t.status&&a.wantsAttention===t.wantsAttention||t.wantsAttention&&r.push(i))}return{entering:r,statuses:n}}function rx(e){return e.enabled&&e.hidden&&e.permission===`granted`}function ix(e){let t=qe(e).label;return{title:e.titleSummary??e.title,body:`Task ${t}`,tag:`cezar-run-${e.id}`}}function ax(){let e=U(),t=ex(ce().data?.notifications).enabled,n=(0,Z.useRef)(t);return n.current=t,(0,Z.useEffect)(()=>{let t=e.getQueryCache(),r=new Map,i=new Map,a=new Map,o=new Set,s=new Map,c=0,l=e=>e.length===3&&typeof e[0]==`string`&&e[1]===`runs`&&e[2]===`list`,u=()=>{let e=new Set([...r.values()].flatMap(e=>[...e.keys()]));for(let t of i.keys())e.has(t)||(i.delete(t),a.delete(t),o.delete(t))},d=(e,t,s=!1,l=1/0)=>{let d=r.get(e),{statuses:f}=nx(new Map,t),p=t.filter(e=>{if((a.get(e.id)??0)>l)return!1;let t=d?.get(e.id),n=f.get(e.id),r=l===1/0?t:i.get(e.id);return t!==void 0&&r!==void 0&&(r.status!==n.status||r.wantsAttention!==n.wantsAttention)}),{entering:m,statuses:h}=nx(i,p);for(let[e,t]of f)!d?.has(e)&&!o.has(e)&&(a.get(e)??0)<=l&&(i.set(e,t),a.set(e,++c));for(let[e,t]of h){let n=i.get(e);n?.status===t.status&&n.wantsAttention===t.wantsAttention||(i.set(e,t),a.set(e,++c),o.add(e))}if(r.set(e,f),u(),!s&&m.length!==0&&rx({enabled:n.current,hidden:document.visibilityState===`hidden`,permission:tx()}))for(let e of m)ox(e)};for(let e of t.getAll().sort((e,t)=>e.state.dataUpdatedAt-t.state.dataUpdatedAt))l(e.queryKey)&&Array.isArray(e.state.data)&&d(e.queryHash,e.state.data,!0);return t.subscribe(e=>{if(l(e.query.queryKey)){if(e.type===`removed`)r.delete(e.query.queryHash),s.delete(e.query.queryHash),u();else if(e.type===`updated`&&(e.action.type===`fetch`&&s.set(e.query.queryHash,c),e.action.type===`success`&&Array.isArray(e.query.state.data))){let t=e.action.manual?1/0:s.get(e.query.queryHash)??0;d(e.query.queryHash,e.query.state.data,!1,t),e.action.manual||s.delete(e.query.queryHash)}}})},[e]),null}function ox(e){let t=globalThis.Notification;if(typeof t!=`function`)return;let n=ix(e);try{new t(n.title,{body:n.body,tag:n.tag})}catch{}}function sx(){return(0,Q.jsx)(ss,{route:`activity`,density:`sparse`,rootProps:{"aria-busy":`true`},header:{title:`Activity`},children:(0,Q.jsx)(`p`,{"data-slot":`activity-loading`,role:`status`,className:`text-xs text-muted-foreground`,children:`Loading activity…`})})}function cx(){return(0,Q.jsx)(ls,{route:`github`,density:`sparse`,flushPadding:!0,children:(0,Q.jsx)(tc,{icon:(0,Q.jsx)(xa,{className:`motion-safe:animate-spin`}),tone:`neutral`,title:`Loading GitHub…`,subtitle:`Fetching open issues and pull requests.`})})}function lx({skill:e,emphasized:t}){return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`span`,{className:q(`shrink-0 font-mono text-xs`,t&&`font-semibold`),children:e.name}),e.description?(0,Q.jsx)(`span`,{title:e.description,className:`min-w-0 flex-[3] truncate text-xs text-soft-foreground`,children:e.description}):null,e.path?(0,Q.jsx)(`span`,{title:e.path,className:`min-w-0 truncate text-xs text-soft-foreground`,children:e.path}):null]})}var ux=80,dx=2e3,fx=50,px=200,mx=50,hx=[{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.`}];function gx(e){return!!e&&typeof e==`object`}function _x(e){if(e===void 0||!Array.isArray(e))return hx.map(e=>({...e}));let t=new Set,n=[];for(let r of e){if(!gx(r))continue;let e=typeof r.id==`string`?r.id.trim():``;if(e===`create-automation`)continue;let 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=vx(r.skills);if(n.push({id:e,label:i.slice(0,ux),text:a.slice(0,dx),...o.length>0?{skills:o}:{}}),n.length>=fx)break}return n}function vx(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,px)),t.size>=mx))break}return[...t]}function yx(e,t){if(t.length===0)return[];let n=new Set(t);return e.filter(e=>e.skills?.some(e=>n.has(e)))}function bx(e,t){return yx(e,t).map(e=>e.text).join(`
|
|
5
|
+
`)),i=Te(e);for(let e of n)r.has(e)||i.dropProject(e);let a=[...r].filter(e=>!n.has(e));for(let e of a)i.restoreProject(e);a.length>0&&i.reconcile({hold:!0})},[e,_]),Z.useMemo(()=>l?{projects:l,signals:u,...g===void 0?{}:{hostSignals:g},canReorder:c,onReorder:s}:null,[l,u,g,c,s])}var Tg=60;function Eg(e){return`title`in e?`Archived "${e.title.length>Tg?`${e.title.slice(0,Tg-1)}…`:e.title}"`:`Archived ${e.count} ${e.count===1?`task`:`tasks`}`}async function Dg(e,t,n){let r=new Set(n),i=(await Promise.allSettled(t.map(async t=>{await gn(E(t,{projectId:e}),!1),r.has(t)&&await Mt(E(t,{projectId:e}),!0)}))).find(e=>e.status===`rejected`);i&&H(i.reason instanceof Error?i.reason.message:`Could not undo the archive.`,{tone:`danger`})}function Og(){let e=document.activeElement;return!e||e===document.body||!e.isConnected}function kg(e,t){if(!e.isConnected)return t();let n=new MutationObserver(()=>{e.isConnected||(n.disconnect(),clearTimeout(r),t())}),r=setTimeout(()=>n.disconnect(),5e3);n.observe(document.body,{childList:!0,subtree:!0})}function Ag(e,t){if(!Og())return;let n=e?.isConnected?e:t?.isConnected?t:null;n instanceof HTMLElement&&(n.tabIndex<0&&!n.hasAttribute(`tabindex`)&&(n.tabIndex=-1),n.focus({preventScroll:!0}))}function jg(e,t,n){if(!e)return()=>{};let r=t(e);return()=>kg(e,()=>Ag(r,n))}function Mg(e){let t=document.activeElement?.closest(`[data-slot="task-row"]`);return t?.getAttribute(`data-run-id`)===e?t:Array.from(document.querySelectorAll(`[data-slot="task-row"]`)).find(t=>t.getAttribute(`data-run-id`)===e)??null}var Ng=e=>e?.querySelector(`a`)??null;function Pg(e,t){let n=e?.projectId,r=e?.cacheScope,i=se(),[a,o]=Z.useState(null),s=e=>i.invalidateAfter(`runs`,v({projectId:n,cacheScope:e})),c=(e,t,r,i)=>H(e,{action:{label:`Undo`,onAction:()=>void Dg(n,r,i).finally(()=>void s(t))}}),l=Z.useRef(new Map);return{archiveOne:e=>{let i=l.current.get(e.id);if(i)return i;let a=r??Ie(),o=!!e.pinned,u=Mg(e.id),d=jg(u,e=>{let t=Array.from(e.closest(`[data-slot="quick-list-bucket"]`)?.querySelectorAll(`[data-slot="task-row"]`)??[]),n=t.indexOf(e);return Ng(t[n+1]??t[n-1])},u?.closest(`[data-slot="quick-list-bucket"]`)?.parentElement??null),f=gn(E(e.id,{projectId:n}),!0).then(()=>(s(a),c(Eg({title:Ro(e)}),a,[e.id],o?[e.id]:[]),d(),t?.(),!0),e=>(H(e.message,{tone:`danger`}),!1)).finally(()=>l.current.delete(e.id));return l.current.set(e.id,f),f},sweep:(e,i)=>{let a=r??Ie();o(e);let l=document.activeElement,u=l?.matches(`[data-action="archive-group"]`)?l:null,d=jg(u,e=>Ng(e.closest(`[data-slot="quick-list-bucket"]`)?.nextElementSibling?.querySelector(`[data-slot="task-row"]`)??void 0),u?.closest(`[data-slot="quick-list-bucket"]`)?.parentElement??null);ln(v({projectId:n}),e,i).then(({ids:e,pinnedIds:n})=>{s(a),e.length>0&&c(Eg({count:e.length}),a,e,n),d(),e.length>0&&t?.()},e=>H(e.message,{tone:`danger`})).finally(()=>o(null))},sweeping:a}}var Fg=.6,Ig=300,Lg=100,Rg={offset:0,phase:`idle`,past:!1},zg=null;function Bg(e,t){zg&&zg.id!==e&&zg.close(),zg={id:e,close:t}}function Vg(e){zg?.id===e&&(zg=null)}function Hg(){if(!(typeof navigator>`u`||typeof navigator.vibrate!=`function`))try{navigator.vibrate(10)}catch{}}function Ug({id:e,enabled:t,onArchive:n}){let[r,i]=Z.useState(Rg),a=Z.useRef(null),o=Z.useRef(null),s=Z.useRef(!1),c=Z.useRef(!1),l=Z.useRef(void 0),u=()=>{c.current=!0,clearTimeout(l.current),l.current=void 0},d=()=>{c.current&&(clearTimeout(l.current),l.current=setTimeout(()=>{c.current=!1},Ig))};Z.useEffect(()=>()=>clearTimeout(l.current),[]);let f=Z.useRef(r);f.current=r;let p=Z.useRef(n);p.current=n;let m=Z.useCallback(()=>{o.current=null,s.current=!1,Vg(e),i(Rg)},[e]);Z.useEffect(()=>{!t&&f.current.phase!==`committing`&&m()},[t,m]),Z.useEffect(()=>()=>Vg(e),[e]);let h=r.phase===`open`;Z.useEffect(()=>{if(!h)return;let e=()=>m(),t=e=>{let t=a.current;t&&e.target instanceof Node&&t.contains(e.target)||m()};return document.addEventListener(`scroll`,e,{capture:!0,passive:!0}),document.addEventListener(`pointerdown`,t,!0),()=>{document.removeEventListener(`scroll`,e,{capture:!0}),document.removeEventListener(`pointerdown`,t,!0)}},[h,m]);let g=t=>{Vg(e),i({offset:-t,phase:`committing`,past:!0});let n=e=>{e===!1&&m()};try{let e=p.current();e&&typeof e.then==`function`&&e.then(n,m)}catch{m()}};return{offset:r.offset,phase:r.phase,past:r.past,surfaceRef:a,bind:{onPointerDown:e=>{if(c.current=!1,!t||f.current.phase===`committing`||e.pointerType===`mouse`&&e.button!==0)return;let n=(a.current??e.currentTarget).getBoundingClientRect();o.current={pointerId:e.pointerId,x0:e.clientX,y0:e.clientY,base:f.current.phase===`open`?-88:0,width:n.width>0?n.width:320,axis:null,wasOpen:f.current.phase===`open`,samples:[{x:e.clientX,t:Date.now()}]}},onPointerMove:t=>{let n=o.current;if(!n||t.pointerId!==n.pointerId)return;let r=t.clientX-n.x0,a=t.clientY-n.y0;if(n.axis===null){if(Math.max(Math.abs(r),Math.abs(a))<10||(n.axis=Math.abs(r)>Math.abs(a)?`x`:`y`,n.axis===`y`))return;try{t.currentTarget.setPointerCapture?.(t.pointerId)}catch{}Bg(e,m),u()}if(n.axis!==`x`)return;let c=Math.min(0,Math.max(-n.width,n.base+r)),l=-c>=Fg*n.width;l&&!s.current&&Hg(),s.current=l,n.samples.push({x:t.clientX,t:Date.now()}),n.samples.length>8&&n.samples.shift(),i({offset:c,phase:`dragging`,past:l})},onPointerUp:t=>{let n=o.current;if(!n||t.pointerId!==n.pointerId)return;if(o.current=null,n.axis!==`x`){n.axis===null&&n.wasOpen&&(u(),d(),m());return}d();let r=f.current.offset,a=Date.now(),c={x:t.clientX,t:a},l=n.samples.find(e=>a-e.t<=Lg&&e.t<a),p=l?(c.x-l.x)/(c.t-l.t):0;s.current=!1,f.current.past||p<=-1&&-r>=40?g(n.width):p<1&&-r>=40?(Bg(e,m),i({offset:-88,phase:`open`,past:!1})):m()},onPointerCancel:e=>{let t=o.current;!t||e.pointerId!==t.pointerId||(o.current=null,d(),t.axis===`x`&&m())},onClickCapture:e=>{c.current&&(c.current=!1,e.preventDefault(),e.stopPropagation())},onKeyDownCapture:()=>{c.current=!1}},close:m}}function Wg(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 Gg(e){return _n(e)?.runner??e.runner??`claude`}function Kg(e,t,n,r,i,a){return a?e.workflowDef?.steps.find(n=>n.command===void 0&&n.kind!==`plugin`&&(n.runner??e.runner??`claude`)===t)?.agentProfile??(t===n?e.agentProfile:void 0)??i?.[t]:t===r?_n(e)?.agentProfile:i?.[t]}function qg(e,t,n,r,i=!1){let a=r?.original??Gg(e),o=r?.target??a;if(e.delegation?.role===`worker`){let r=Kg(e,t,a,o,n,i);if(r!==void 0||i)return r}if(t!==o)return n?.[t];let s=Yt(e),c=s.profileId??`default`;return s.sessionId!==void 0&&s.backend===o&&(e.agentProfile??c)===c?c:(o===a?e.agentProfile:void 0)??n?.[t]}function Jg(e,t,n){let r=Yt(e),i=r.sessionId===void 0?{runner:e.runner??`claude`,account:e.agentProfile}:{runner:r.backend,account:r.profileId??e.agentProfile};return(i.runner===t?i.account:void 0)??n?.[t]}function Yg(e,t,n){let r=e.find(e=>e.provider===t&&e.id===n);return r?.isDefault?void 0:r}function Xg(e,t,n,r){return Yg(n,t,qg(e,t,r))}function Zg(e,t,n,r){let i=kn(t,e);return i?.enabled===!1?{provider:e,usable:!1,reason:`${ye(n,e)} is disabled. Enable it in ${Qs(`providers`)}.`}:r&&i?.authFailureId===void 0?r.status===void 0||r.status===`connected`?{provider:e,usable:!0}:{provider:e,usable:!1,reason:`${ye(n,e)} account "${r.label}" is not signed in. Sign in in ${Qs(`providers`)}.`}:i?.status===`connected`?{provider:e,usable:!0}:{provider:e,usable:!1,reason:`${ye(n,e)} credentials are unavailable. Authorize it in ${Qs(`providers`)}.`}}function Qg(e,t,n,r){return Zg(Wg(e),t,n,r)}function $g(e,t,n,r){return Zg(Gg(e),t,n,r)}function e_(e){let t=ee(),n=L().data,r=Wg(e),{accounts:i,repoAccount:a}=Ys(),o=Yg(i,r,Jg(e,r,a));return t.isSuccess&&t.data&&n?Qg(e,t.data,n,o):{provider:r,usable:!0}}function t_(e){let t=ee(),n=L(),r=Gg(e),{accounts:i,repoAccount:a}=Ys(),o=Xg(e,r,i,a);return t.isSuccess&&t.data&&n.data?$g(e,t.data,n.data,o):t.isError||n.isError?{provider:r,usable:!1,reason:`Provider authentication could not be verified.`}:{provider:r,usable:!1,reason:`Checking agent providers…`}}function n_(e){return Yt(e).sessionId}function r_(e){return Yt(e).backend}function i_(e){if(We(e)||e.cliHandoff===!1)return;let t=e.cliResumeCommand;if(t!==void 0)return e.worktreePath?`cd ${e.worktreePath} && ${t}`:t}function a_(e,t){let n=Qi(t);return!n||We(e)?!1:n===r_(e)&&n_(e)!==void 0}function o_(e){return(e.status===`failed`||lt(e))&&(e.waits?.length??0)>0}function s_(e,t){return t&&e.delegation?.role===`root`&&(e.status===`failed`||lt(e))}function c_(e){return e.status===`cancelled`&&e.startedAt===void 0&&e.workflowDef!==void 0&&e.steps.every(e=>e.status===`pending`&&e.startedAt===void 0&&!e.sessionId)}function l_(e){return yn(e)&&e.removedRunner===void 0}function u_(e,t=!1){let n=We(e),r=n_(e)!==void 0;return{finish:e.status===`waiting`&&n||e.status===`review`,continueRun:(!n||e.removedRunner!==void 0&&e.status!==`queued`)&&!e.stopping&&e.delegation?.role!==`invalid`&&!(e.delegation?.role===`worker`&&e.delegation.destroy)&&(r||c_(e)||e.removedRunner!==void 0),terminal:h_(e,n,r),notes:!0,archive:!n,pin:!e.archived&&!No(e),markUnread:xt(e)&&!mn(e),cancel:n||o_(e)||s_(e,t),deleteRun:!n}}function d_(e){return e.status===`waiting`&&e.finishBlocked===null&&qe(e).bucket===`waiting`}function f_(e){return`Merge head branch and resolve conflicts in ${e?`PR number ${e}`:`this pull request`}`}function p_(e){return e===`review`?`Accept the changes without a PR`:`Close the session`}function m_(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}function h_(e,t,n){return e.cliHandoff!==!1&&!t&&n}var g_=new Set(vt),__=[50,100,200,400,800,1e3,1e3,1e3,1e3],v_=e=>new Promise(t=>setTimeout(t,e));function y_(e){return e instanceof Tn&&e.status===409&&e.message===`run is still active`}async function b_(e,t=v_){for(let n=0;;n+=1)try{return await e()}catch(e){let r=__[n];if(!y_(e)||r===void 0)throw e;await t(r)}}function x_(e){return We(e)?`live`:u_(e).continueRun?`resume`:`unavailable`}function S_(e,t,n){let r=Ce(e.id,t,n),i=le(e.id,t,n),a=e_(e),o=t_(e),[s,c]=(0,Z.useState)(void 0),l=s?.message;Et(()=>{c(e=>e?.clearOnHostRecovery?void 0:e)});let[u,d]=(0,Z.useState)(!1),f=(0,Z.useRef)(!1),p=x_(e),m=n!==void 0,h=m?!1:p===`resume`?!o.usable:p===`live`&&!a.usable,g=p===`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`?p===`resume`?o.reason:a.reason:void 0,v=(e,t)=>!m&&!o.usable?Promise.reject(Error(o.reason??`The run provider is unavailable.`)):i.mutateAsync({text:e,...t===void 0?{}:{images:t}});return{mode:p,blockedBy:g,reason:_,isPending:u||r.isPending||i.isPending,error:l,send:async(t,n)=>{if(g)return _;if(f.current)return`An answer is already being sent.`;f.current=!0,d(!0),c(void 0);try{if(p===`resume`){await b_(()=>v(t,n));return}try{await r.mutateAsync({text:t,...n===void 0?{}:{images:n}})}catch(r){if(r instanceof Tn&&r.status===409&&(r.code===void 0||!g_.has(r.code))&&n_(e)!==void 0){try{await b_(()=>v(t,n))}catch(e){let t=nt(e);throw Error(`Session closed. Retry to reopen the session. ${t}`,{cause:e})}return}throw r}return}catch(e){let t=nt(e);return c({message:t,clearOnHostRecovery:Kt(e)}),t}finally{f.current=!1,d(!1)}}}}function C_({run:e,projectId:t,hostId:n,prNumber:r}){let i=S_(e,t,n),a=Er(),[o,s]=(0,Z.useState)(!1),c=o||i.isPending,l=!!i.blockedBy,u=async()=>{if(c||l)return;let e=i.mode===`resume`;s(!0);try{let t=await i.send(f_(r));t?H(t,{tone:`danger`}):(H(`${e?`Task reopened`:`Sent to the task`} — resolving conflicts${r?` in PR #${r}`:``}`),a())}finally{s(!1)}};return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Y,{type:`button`,size:`sm`,"data-slot":`reference-conflict-action`,disabled:l||c,onClick:()=>void u(),className:`w-full text-xs`,children:c?`Sending…`:`Resolve conflicts`}),l&&i.reason?(0,Q.jsx)(`span`,{className:`block text-muted-foreground`,children:i.reason}):null]})}function w_({projectId:e,hostId:t,runId:n,prNumber:r}){let i=N(e,n,!0,t===void 0?void 0:{hostId:t});return i.data?(0,Q.jsx)(C_,{run:i.data,projectId:e,hostId:t,prNumber:r}):(0,Q.jsx)(Y,{type:`button`,size:`sm`,disabled:!0,className:`w-full text-xs`,children:i.isError?`Unavailable`:`Loading…`})}function T_({runId:e,prNumber:t}){let{projectId:n}=Dr();return n===void 0?(0,Q.jsx)(E_,{runId:e,prNumber:t}):(0,Q.jsx)(w_,{projectId:n,runId:e,prNumber:t})}function E_({runId:e,prNumber:t}){let n=j(e);return n.data?(0,Q.jsx)(C_,{run:n.data,prNumber:t}):(0,Q.jsx)(Y,{type:`button`,size:`sm`,disabled:!0,className:`w-full text-xs`,children:n.isError?`Unavailable`:`Loading…`})}function D_({run:e,reference:t,className:n,compact:r=!1,plain:i=!1,inert:a=!1}){let{projectId:o,repoBase:s}=Dr(),c=o!==void 0&&t.number!==void 0?dr(o,e.id,{kind:t.kind,number:t.number,url:t.url},s):void 0;return(0,Q.jsx)(Or,{reference:t,taskTitle:Ro(e),to:c,conflictAction:Tr({...t,number:t.number??0},s)?(0,Q.jsx)(T_,{runId:e.id,prNumber:t.number}):void 0,className:n,compact:r,plain:i,inert:a})}var O_=220;function k_(e,t,n,r,i){if(e===void 0)return{to:void 0,fullPage:!1};let a=dr(e,t,n,r);return a?i===void 0?{to:a,fullPage:!1}:{to:He(i,a),fullPage:!0}:{to:void 0,fullPage:!1}}function A_({references:e,taskTitle:t,visibleCount:n,plain:r=!1,projectId:i,hostId:a,runId:o,repoBase:s}){let[c,l]=Z.useState(!1),u=Z.useRef(!1),d=Z.useRef(!1),f=Z.useRef(null),p=Z.useRef(void 0);Z.useEffect(()=>()=>clearTimeout(p.current),[]);let m=e=>e.pointerType!==`touch`,h=()=>clearTimeout(p.current),g=e=>{m(e)&&(h(),c||(u.current=!0),l(!0))},_=e=>{m(e)&&(h(),p.current=setTimeout(()=>l(!1),O_))},v=e.length-n,y=e.slice(n).map(t=>{let n=e.some(e=>e!==t&&e.kind===t.kind&&e.number===t.number)&&t.url?new URL(t.url).pathname.split(`/`).slice(1,3).join(`/`):``;return`${t.kind} #${t.number}${n?` (${n})`:``}`}).join(`, `);return v<=0?null:(0,Q.jsxs)(po,{open:c,onOpenChange:l,children:[(0,Q.jsx)(co,{asChild:!0,children:(0,Q.jsxs)(`button`,{type:`button`,"data-slot":`reference-overflow`,title:y,"aria-label":`Show all ${e.length} references for ${t}`,onPointerEnter:g,onPointerLeave:_,onPointerDown:e=>{e.stopPropagation(),d.current=c&&u.current,u.current=!1},onClick:e=>{e.stopPropagation(),c&&(d.current||u.current)&&(e.preventDefault(),h(),f.current?.focus()),d.current=!1,u.current=!1},className:`no-hover:min-h-[44px] no-hover:min-w-[44px] max-md:min-h-[44px] max-md:min-w-[44px] shrink-0 rounded-full px-1 text-xs font-medium text-soft-foreground transition-colors hover:bg-muted hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`,children:[`+`,v]})}),(0,Q.jsxs)(uo,{ref:f,align:`start`,collisionPadding:8,className:`w-auto min-w-40 max-h-(--radix-popover-content-available-height) overflow-y-auto overscroll-contain p-1.5`,"data-slot":`reference-overflow-list`,onClick:e=>e.stopPropagation(),onPointerDown:e=>e.stopPropagation(),onPointerEnter:g,onPointerLeave:_,onOpenAutoFocus:e=>{e.preventDefault(),!u.current&&e.target instanceof HTMLElement&&e.target.focus()},onKeyDownCapture:e=>{e.key===`Escape`&&(e.preventDefault(),u.current=!1,l(!1))},onCloseAutoFocus:e=>{u.current&&e.preventDefault()},children:[(0,Q.jsx)(`p`,{className:`px-1 pb-1.5 text-xs text-soft-foreground`,children:`References`}),(0,Q.jsx)(`span`,{className:`flex flex-col items-start gap-1`,children:e.map(e=>j_({reference:e,taskTitle:t,projectId:i,hostId:a,runId:o,repoBase:s,plain:r,className:`no-hover:min-h-[44px] max-md:min-h-[44px]`}))})]})]})}function j_({reference:e,taskTitle:t,projectId:n,hostId:r,runId:i,repoBase:a,plain:o,compact:s=!1,inert:c=!1,className:l}){let u=k_(n,i,e,a,r);return(0,Q.jsx)(Or,{reference:e,taskTitle:t,projectId:n,hostId:r,repoBase:a,to:u.to,fullPage:u.fullPage,plain:o,compact:s,inert:c,className:l,conflictAction:n&&Tr(e,a)?(0,Q.jsx)(w_,{projectId:n,hostId:r,runId:i,prNumber:e.number}):void 0},mr(e))}function M_({references:e,maxVisible:t,taskTitle:n,projectId:r,hostId:i,runId:a,repoBase:o,plain:s=!1,compact:c=!1,inertInline:l=!1,fitContainer:u=!1,overflowContainer:d}){let f=Z.useRef(null),[p,m]=Z.useState(t),h=Z.useRef(new Map),g=e.map(mr).join(`|`);Z.useLayoutEffect(()=>{let n=f.current;if(!u||!n?.parentElement){m(t);return}let r=n.parentElement,i=()=>{[...n.querySelectorAll(`:scope > [data-slot="pr-chip"], :scope > [data-slot="issue-chip"]`)].forEach((t,n)=>{let r=t.getBoundingClientRect().width;r&&h.current.set(mr(e[n]),r)});let i=r.getBoundingClientRect();if(!i.width)return;let a=Math.min(t,e.length);n.dataset.referenceWidth=String(e.slice(0,a).reduce((e,t)=>e+(h.current.get(mr(t))??48),0)+Math.max(0,a-1)*4);let o=0;for(let e=n.nextElementSibling;e;e=e.nextElementSibling){if(e.getAttribute(`data-slot`)===`task-row-age`||e.getAttribute(`aria-hidden`)===`true`&&e.nextElementSibling?.getAttribute(`data-slot`)===`task-row-age`)continue;let t=getComputedStyle(e);o+=e.getBoundingClientRect().width+(parseFloat(t.marginLeft)||0)+(parseFloat(t.marginRight)||0)}let s=i.right-n.getBoundingClientRect().left-o,c=n.querySelector(`[data-slot="reference-overflow"]`)?.getBoundingClientRect().width||(l?44:26),u=Math.min(t,e.length);for(;u>0;){let t=d===void 0&&u<e.length,n=(t?u:Math.max(0,u-1))*4;if(e.slice(0,u).reduce((e,t)=>e+(h.current.get(mr(t))??48),0)+n+(t?c:0)<=s+(u===e.length?d?.getBoundingClientRect().width??0:0))break;u--}m(u)};if(i(),typeof ResizeObserver>`u`)return;let a=new ResizeObserver(i);return a.observe(r),a.observe(n),()=>a.disconnect()},[u,t,g,l,e,d]);let _=Math.min(p,t,e.length),v=(0,Q.jsx)(A_,{references:e,visibleCount:_,taskTitle:n,projectId:r,hostId:i,runId:a,repoBase:o,plain:s});return(0,Q.jsxs)(`span`,{ref:f,"data-slot":`reference-list`,className:`inline-flex max-w-full flex-nowrap items-center gap-1 align-middle`,children:[e.slice(0,_).map(e=>j_({reference:e,taskTitle:n,projectId:r,hostId:i,runId:a,repoBase:o,plain:s,compact:c,inert:l,className:`shrink-0`})),d===void 0?v:d?(0,Of.createPortal)(v,d):null]})}function N_({pinned:e,onToggle:t,className:n}){return(0,Q.jsx)(`button`,{type:`button`,"data-slot":`pin-toggle`,"data-pinned":e?`true`:void 0,"aria-pressed":e,"aria-label":e?`Unpin task`:`Pin task`,title:e?`Unpin from the top of the list`:`Pin to the top of the list`,onClick:n=>{n.stopPropagation(),t(!e)},className:q(`inline-flex size-5 shrink-0 items-center justify-center rounded-sm text-soft-foreground transition-colors motion-reduce:transition-none hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`,n,`max-md:min-h-11 max-md:min-w-11 no-hover:min-h-11 no-hover:min-w-11`),children:(0,Q.jsx)(sl,{"data-slot":`pin-icon`,className:`size-[12px]`,fill:e?`currentColor`:`none`,"aria-hidden":`true`})})}var P_=`opacity-0 group-hover/task-row:opacity-100 focus-visible:opacity-100 group-has-[:focus-visible]/task-row:opacity-100 no-hover:opacity-100`,F_=`opacity-0 group-hover/task-row:opacity-100 focus-visible:opacity-100 group-has-[:focus-visible]/task-row:opacity-100`,I_=`transition-opacity motion-reduce:transition-none group-hover/task-row:opacity-0 group-has-[:focus-visible]/task-row:opacity-0 max-md:absolute max-md:top-1/2 max-md:left-0 max-md:-translate-y-1/2 max-md:opacity-100 no-hover:absolute no-hover:top-1/2 no-hover:left-0 no-hover:-translate-y-1/2 no-hover:opacity-100`;function L_({run:e,title:t,unread:n,inertReferences:r,onTogglePin:i,onArchiveRun:a}){return(0,Q.jsxs)(`span`,{"data-slot":`task-row-trailing`,className:`relative flex h-[19px] w-[16px] shrink-0 items-center justify-center max-md:h-auto max-md:w-11 max-md:self-stretch no-hover:h-auto no-hover:w-11 no-hover:self-stretch`,children:[n?(0,Q.jsx)(Qo,{tone:Xo(e),role:`img`,"aria-label":`unread`,title:`Unread — not opened since it finished`,"data-slot":`unread-marker`,className:i?I_:void 0}):null,i?(0,Q.jsx)(N_,{pinned:!!e.pinned,onToggle:t=>i(e,t),className:q(`absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2`,P_)}):null,a&&!r&&cn(e)?(0,Q.jsx)(`button`,{type:`button`,"data-action":`archive-run`,"aria-label":`Archive ${t}`,title:`Archive task`,onClick:t=>{t.stopPropagation(),a(e)},className:q(`absolute top-[19.5px] left-1/2 inline-flex size-5 -translate-x-1/2 items-center justify-center rounded-sm text-muted-foreground transition-colors hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none motion-reduce:transition-none`,F_),children:(0,Q.jsx)(Wi,{className:`size-[12px] -translate-y-[2.5px]`,"aria-hidden":`true`})}):null]})}function R_({inertReferences:e,swipeable:t,swipe:n,title:r,onArchive:i,children:a}){return e?(0,Q.jsxs)(`div`,{ref:n.surfaceRef,"data-slot":`task-row-swipe`,"data-swipe":t?`on`:void 0,"data-phase":t?n.phase:void 0,className:q(`relative rounded-[6px]`,t&&`touch-pan-y touch-pinch-zoom overflow-hidden`),children:[n.offset<0?(0,Q.jsx)(z_,{width:-n.offset,past:n.past,title:r,onArchive:i}):null,a]}):a}function z_({width:e,past:t,title:n,onArchive:r}){return(0,Q.jsx)(`div`,{"data-slot":`task-row-swipe-action`,"data-past":t?`true`:void 0,"aria-hidden":`true`,style:{width:e},className:q(`absolute inset-y-0 right-0 flex items-stretch justify-end overflow-hidden rounded-[6px]`,t?`bg-info text-signal-ink`:`bg-muted text-foreground`),children:t?(0,Q.jsxs)(`span`,{className:`flex w-full items-center justify-center gap-2 text-[12px] font-semibold whitespace-nowrap`,children:[(0,Q.jsx)(Wi,{className:`size-[16px] shrink-0`,"aria-hidden":`true`}),`Release to archive`]}):(0,Q.jsxs)(`button`,{type:`button`,tabIndex:-1,"aria-label":`Archive ${n}`,onClick:e=>{e.stopPropagation(),r()},className:`flex w-[88px] shrink-0 flex-col items-center justify-center gap-1 text-[12px] font-semibold`,children:[(0,Q.jsx)(Wi,{className:`size-[16px]`,"aria-hidden":`true`}),`Archive`]})})}var B_=`[&>[data-ellipsis-hidden]]:pointer-events-none`,V_=`data-ellipsis-hidden`,H_=new Map;function U_(e){let t=getComputedStyle(e),n=`${t.fontStyle} ${t.fontWeight} ${t.fontSize} ${t.fontFamily} ${t.letterSpacing}`,r=H_.get(n);if(r!==void 0)return r;let i=document.createElement(`span`);i.textContent=`…`,i.setAttribute(`aria-hidden`,`true`),Object.assign(i.style,{position:`absolute`,visibility:`hidden`,whiteSpace:`pre`,fontStyle:t.fontStyle,fontWeight:t.fontWeight,fontSize:t.fontSize,fontFamily:t.fontFamily,letterSpacing:t.letterSpacing}),document.body.appendChild(i);let a=i.getBoundingClientRect().width;i.remove();let o=a||parseFloat(t.fontSize)||12;return a&&(!document.fonts||document.fonts.status===`loaded`)&&H_.set(n,o),o}function W_(e,t){if(e.scrollWidth<=e.clientWidth)return[];let n=e.getBoundingClientRect(),r=parseFloat(getComputedStyle(e).paddingRight)||0,i=n.left+e.clientLeft+e.clientWidth-r-t+.5;return Array.from(e.children).filter(e=>e.getBoundingClientRect().right>i)}function G_(e,t,n){Z.useLayoutEffect(()=>{let n=e.current;if(!t||!n||typeof ResizeObserver>`u`)return;let r=!0,i=()=>{if(!r)return;let e=new Set(W_(n,U_(n)));for(let t of Array.from(n.children))t.hasAttribute(V_)!==e.has(t)&&t.toggleAttribute(V_,e.has(t))},a=new ResizeObserver(i),o=new Set,s=()=>{for(let e of Array.from(n.children))o.has(e)||(o.add(e),a.observe(e))};a.observe(n),s(),i();let c=typeof MutationObserver>`u`?null:new MutationObserver(()=>{s(),i()});return c?.observe(n,{childList:!0}),document.fonts&&document.fonts.status!==`loaded`&&document.fonts.ready.then(i),()=>{r=!1,a.disconnect(),c?.disconnect();for(let e of Array.from(n.children))e.removeAttribute(V_)}},[e,t,n])}var K_=`(hover: none)`;function q_(){let[e,t]=(0,Z.useState)(()=>typeof window.matchMedia==`function`&&window.matchMedia(K_).matches);return(0,Z.useEffect)(()=>{if(typeof window.matchMedia!=`function`)return;let e=window.matchMedia(K_);t(e.matches);let n=e=>t(e.matches);return e.addEventListener(`change`,n),()=>e.removeEventListener(`change`,n)},[]),e}var J_={"needs-permission":`label`,failed:`label`,"needs-you":`none`,"needs-review":`label`,running:`label`,"usage-limit":`resume`,"waiting-on-workers":`label`,"waiting-on-subagents":`label`,"waiting-for-ci":`label`,"waiting-for-merge":`label`,"waiting-for-command":`until`,monitoring:`next-check`,"waiting-for-capacity":`label`,queued:`queue-position`,done:`none`,cancelled:`none`,unseen:`label`};function Y_(e,t,n,r){let i=Rm(e.rung,e.label,n.autoResumeReason);switch(J_[e.rung]){case`none`:return;case`queue-position`:return t===null?i:`Queued #${t}`;case`resume`:{let e=bs(n.autoResumeAt,r);return e===`scheduled`?i:`${i}, ${e}`}case`next-check`:{let e=fn(n),t=e?.kind===`timer`?new Date(e.at):void 0;return t&&Number.isFinite(t.getTime())?`${i}, next check ${ws(t,new Date(r))}`:i}case`until`:{let e=fn(n),t=e?.kind===`process`?new Date(e.deadline):void 0;return t&&Number.isFinite(t.getTime())?`${i}, until ${ws(t,new Date(r))}`:i}case`label`:return i}}function X_({run:e,attention:t,queuePosition:n,inWorkingGroup:r,scope:i,now:a}){let o=nr(e,void 0,i??void 0),s=n===null?ys(e.finishedAt??e.createdAt,a):``,c=r&&t.rung===`running`?void 0:Y_(t,n,e,a);return{stateWord:c,references:o,age:s,key:`${s}|${c??``}|${o.map(e=>`${e.kind}-${e.number}-${e.url}`).join(`,`)}|${+!!e.notify}`}}function Z_(e){let t=Ro(e);return{title:t,displayTitle:Bo(t,fr(e)?.number)?qo(t).rest:t}}var Q_=`cez-sidebar-collapsed`,$_=`cez-sidebar-sections-collapsed`;function ev(e){if(typeof e!=`object`||!e||Array.isArray(e))return{};let t={};for(let[n,r]of Object.entries(e))typeof r==`boolean`&&(t[n]=r);return t}function tv(e=Q_){try{let t=localStorage.getItem(Qr(e));return t===null?{}:ev(JSON.parse(t))}catch{return{}}}function nv(e,t=Q_){try{localStorage.setItem(Qr(t),JSON.stringify(e))}catch{}}var rv=`cez-sidebar-sections-changed`;function iv(e){let[t,n]=(0,Z.useState)(()=>tv($_)),[r,i]=(0,Z.useState)({}),a=(0,Z.useRef)(t);(0,Z.useEffect)(()=>{let e=e=>{if(e instanceof StorageEvent&&e.key!==null&&e.key!==Qr(`cez-sidebar-sections-collapsed`))return;let t=e instanceof CustomEvent?e.detail:tv($_);a.current=t,n(t)};return window.addEventListener(`storage`,e),window.addEventListener(rv,e),()=>{window.removeEventListener(`storage`,e),window.removeEventListener(rv,e)}},[]),(0,Z.useEffect)(()=>{if(e===null||Object.keys(r).length===0)return;let t={...a.current};for(let[n,i]of Object.entries(r))t[JSON.stringify([e,n])]=i;i({}),a.current=t,n(t),nv(t,$_),window.dispatchEvent(new CustomEvent(rv,{detail:t}))},[e,r]);let o=t=>JSON.stringify([e,t]);return{isCollapsed:e=>e!==`Archived`&&(r[e]??t[o(e)])===!0,toggle:t=>{if(e===null){i(e=>({...e,[t]:e[t]!==!0}));return}let r=o(t),s={...a.current,[r]:a.current[r]!==!0};a.current=s,n(s),nv(s,$_),window.dispatchEvent(new CustomEvent(rv,{detail:s}))}}}function av({runs:e,view:t,automations:n,webhooks:r=!0,onViewChange:i,currentRunId:a=null,now:o=Date.now(),onTogglePin:s,onArchiveRun:c,onSweep:l,sweeping:u=null,showViewControls:d=!0,rowLimit:f,sidebarLimits:p,projectId:m=null}){let h=bl(),g=jo(e,n),_=Go(e,t,n),v=Ho(_,`active`),y=Mo(v,p??f??{overall:null}),b=l?ov(_):void 0;return(0,Q.jsxs)(`div`,{"data-slot":`quick-list`,children:[(0,Q.jsxs)(`div`,{"data-slot":`quick-list-header`,className:`flex min-h-11 items-center gap-1.5 pr-[6px] pl-[10px] md:min-h-[26px]`,children:[(0,Q.jsx)(`h2`,{className:`text-[13px] font-semibold text-foreground`,children:`Tasks`}),(0,Q.jsx)(`span`,{className:`text-xs text-soft-foreground`,children:g[t]}),(0,Q.jsxs)(X,{to:`/`,onClick:h,className:`ml-auto flex min-h-11 items-center gap-0.5 text-[12px] text-soft-foreground hover:text-foreground md:min-h-[26px]`,children:[`All`,(0,Q.jsx)(Ti,{className:`size-[13px]`,"aria-hidden":`true`})]})]}),d?(0,Q.jsx)(`div`,{className:`sticky top-0 z-10 bg-sidebar pt-2 pb-1`,children:(0,Q.jsx)(`div`,{className:`inline-flex w-full gap-0.5 rounded-md bg-muted p-[2px]`,children:(0,Q.jsx)(bv,{view:t,automations:n,onSelect:i,counts:g})})}):null,v.length===0?(0,Q.jsx)(`p`,{className:`px-3 py-3.5 text-xs text-soft-foreground`,children:t===`automations`?`No automation tasks.`:`No tasks yet — describe one.`}):(0,Q.jsx)(sv,{buckets:y,allBuckets:v,sectionProjectId:m,currentRunId:Fo(a,e),now:o,onTogglePin:s,onArchiveRun:c,onSweep:l,sweeping:u,sweepCounts:b,view:t,automations:n,webhooks:r})]})}function ov(e){return{unpinned:gr(e,`unpinned`),pinned:gr(e,`pinned`)}}function sv({buckets:e,currentRunId:t=null,now:n=Date.now(),scope:r=null,onTogglePin:i,onArchiveRun:a,onSweep:o,sweeping:s=null,sweepCounts:c,projectName:l,allBuckets:u=e,sectionProjectId:d=r,view:f=`active`,automations:p,webhooks:m=!0}){let h=Z.useId(),g=iv(d),_=Z.useRef(null),v=Z.useRef(null);Z.useLayoutEffect(()=>{let e=v.current;if(!e||e.element.isConnected||(v.current=null,document.activeElement!==document.body))return;let t=u.find(t=>t.rows.some(t=>t.run.id===e.id));if(!t)return;let n=Array.from(_.current?.children??[]).find(e=>e.dataset.bucket===t.label);(Array.from(n?.querySelectorAll(`[data-slot="task-row"]`)??[]).find(t=>t.dataset.runId===e.id)?.querySelector(`a`)??n?.querySelector(`[data-slot="section-toggle"]`))?.focus({preventScroll:!0})});let y=(e,o=!1)=>(0,Q.jsx)(hv,{inWorkingGroup:o,run:e.run,queuePosition:e.queuePosition,currentRunId:t,now:n,scope:r,webhooks:m,onTogglePin:i,onArchiveRun:a});return(0,Q.jsx)(`div`,{ref:_,className:`flex flex-col gap-3`,onFocusCapture:e=>{let t=e.target.closest(`[data-slot="task-row"]`);v.current=t?.dataset.runId?{id:t.dataset.runId,element:e.target}:null},onBlurCapture:e=>{e.currentTarget.contains(e.relatedTarget)||(v.current=null)},children:u.map(t=>{let n=t.label===`Archived`,i=g.isCollapsed(t.label),a=e.find(({label:e})=>e===t.label)?.rows??[],u=t.rows.length,d=!n&&!i&&a.length<u,m=`${h}-${t.label.replaceAll(` `,`-`)}`;return(0,Q.jsxs)(`div`,{"data-slot":`quick-list-bucket`,"data-bucket":t.label,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-2 pr-[6px]`,children:[(0,Q.jsx)(lv,{id:m,bucket:t,collapsed:i,cut:d,onToggle:g.toggle}),d?(0,Q.jsx)(cv,{section:t.label,shown:a.length,total:u,scope:r,view:f,automations:p}):null,o&&c?(0,Q.jsx)(vv,{label:t.label,headingId:m,projectName:l,counts:c,onSweep:o,sweeping:s}):null]}),(0,Q.jsx)(`div`,{id:`${m}-rows`,hidden:i,children:!i&&a.map(e=>(0,Q.jsx)(`div`,{children:y(e,t.label===`Working`)},e.run.id))})]},t.label)})})}function cv({section:e,shown:t,total:n,scope:r,view:i,automations:a}){let o=bl();return(0,Q.jsxs)(X,{to:wo(r,Io(e,i,a)),onClick:o,"data-slot":`section-cut-link`,"aria-label":`${e}: showing ${t} of ${n}, see all`,title:`The sidebar shows ${t} of ${n} ${e} tasks. Click to see all of them. Change the limit in ${Qs(`sidebar`)}.`,className:`mr-auto -ml-1 flex min-h-[44px] min-w-[44px] shrink-0 items-center rounded-[4px] px-1 text-xs font-normal text-soft-foreground tabular-nums underline decoration-dotted underline-offset-[3px] hover:text-foreground focus-visible:outline-2 focus-visible:outline-link-foreground md:min-h-[26px] md:min-w-0 no-hover:min-h-[44px] no-hover:min-w-[44px]`,children:[t,` of `,n]})}function lv({id:e,bucket:t,collapsed:n,cut:r,onToggle:i}){let a=t.rows.length;if(t.label===`Archived`)return(0,Q.jsx)(`h2`,{id:e,className:`min-w-0 flex-1 text-xs font-medium text-soft-foreground`,children:(0,Q.jsxs)(`span`,{className:`px-[10px] pt-[2px] pb-[4px]`,children:[t.label,` `,a]})});let o=t.label,s=t.rows.map(e=>e.run),c=s.length?zm(Wo(s)):null,l=s.some(mn),u=n?Ti:Ki;return(0,Q.jsx)(`h2`,{id:e,className:q(`min-w-0 text-xs font-medium text-soft-foreground`,r?`shrink-0`:`flex-1`),children:(0,Q.jsxs)(`button`,{type:`button`,"data-slot":`section-toggle`,"aria-expanded":!n,"aria-controls":`${e}-rows`,"aria-label":`${o} ${a}`,onClick:()=>i(o),className:q(`flex min-h-[44px] items-center gap-1.5 rounded-[4px] px-[10px] text-left hover:bg-sidebar-row-hover hover:text-foreground focus-visible:outline-2 focus-visible:outline-link-foreground md:min-h-[26px] no-hover:min-h-[44px]`,r?`pr-[4px]`:`w-full`),children:[(0,Q.jsx)(u,{className:`size-[12px] shrink-0`,"aria-hidden":`true`}),(0,Q.jsx)(`span`,{children:o}),r?null:(0,Q.jsxs)(Q.Fragment,{children:[` `,(0,Q.jsx)(`span`,{className:`font-normal tabular-nums`,children:a})]}),c&&(o===`Needs you`||n)?(0,Q.jsx)(Qo,{tone:c.tone,shape:c.shape,pulse:c.pulse,role:`img`,"aria-label":c.label,title:c.label}):null,n&&l?(0,Q.jsx)(`span`,{role:`img`,"aria-label":`unread`,title:`Unread tasks`,className:`size-[5px] shrink-0 rounded-full bg-foreground`}):null]})})}function uv({view:e,current:t,onSelect:n,count:r,children:i}){let a=e===t;return(0,Q.jsxs)(`button`,{type:`button`,"data-slot":`view-tab`,"data-view":e,"aria-pressed":a,onClick:()=>n(e),className:q(`flex min-h-11 min-w-0 flex-1 items-center justify-center gap-1.5 rounded-[7px] text-xs font-medium text-muted-foreground md:min-h-[22px]`,a&&`bg-card font-semibold text-foreground shadow-xs`),children:[i,r>0?(0,Q.jsx)(`span`,{className:`font-mono text-xs tabular-nums`,children:r}):null]})}function dv(){let e=q_(),t=fs();return e||!t}function fv(e){let t=document.createRange();t.selectNodeContents(e);let n=t.getBoundingClientRect?.().width,r=e.querySelector(`[data-reference-width]`),i=r?Math.max(0,Number(r.dataset.referenceWidth)-r.getBoundingClientRect().width):0;return Math.ceil((n||e.scrollWidth)+i)}function pv(e,t,n){let[r,i]=Z.useState(!1),[a,o]=Z.useState(0),s=Z.useRef(!1),c=Z.useRef(!1),l=Z.useRef(null),u=Z.useCallback(e=>{s.current=e,i(e)},[]);return Z.useLayoutEffect(()=>{let r=e.current;if(!t||!r||typeof ResizeObserver>`u`){l.current=null,u(!1);return}let i=!0,a=()=>{if(i){if(l.current?.key!==n){if(s.current){u(!1),o(e=>e+1);return}l.current={key:n,width:fv(r)}}u(l.current.width>r.clientWidth)}};a();let d=new ResizeObserver(a);d.observe(r);let f=new WeakMap,p=new ResizeObserver(e=>{let t=!1;for(let n of e??[]){let e=n.borderBoxSize?.[0]?.inlineSize??n.contentRect.width,r=f.get(n.target);f.set(n.target,e),r!==void 0&&r!==e&&(t=!0)}!t||!i||(l.current=null,a())}),m=new Set,h=()=>{let e=!1;for(let t of[...r.children,...r.querySelectorAll(`[data-slot="reference-list"] [data-slot="pr-chip"], [data-slot="reference-list"] [data-slot="issue-chip"]`)]){let{slot:n}=t.dataset;n===`task-row-age`||t.getAttribute(`aria-hidden`)===`true`||m.has(t)||(m.add(t),f.set(t,t.getBoundingClientRect().width),p.observe(t),e=!0)}return e};h();let g=typeof MutationObserver>`u`?null:new MutationObserver(()=>{!h()||!i||(l.current=null,a())});return g?.observe(r,{childList:!0,subtree:!0}),document.fonts&&document.fonts.status!==`loaded`&&!c.current&&document.fonts.ready.then(()=>{c.current=!0,i&&(l.current=null,a())}),()=>{i=!1,d.disconnect(),p.disconnect(),g?.disconnect()}},[e,t,n,a,u]),t&&r}function mv(){return(0,Q.jsx)(`span`,{"aria-hidden":`true`,children:` · `})}function hv({run:e,queuePosition:t,currentRunId:n,now:r,scope:i,webhooks:a=!0,inWorkingGroup:o=!1,onTogglePin:s,onArchiveRun:c}){let l=To(),u=bl(),d=dv(),f=!!c&&d&&cn(e),p=Ug({id:e.id,enabled:f,onArchive:()=>c?.(e)}),m=wo(i,`/tasks/${e.id}`),h=qe(e),g=e.id===n,{title:_,displayTitle:v}=Z_(e),y=mn(e),b=X_({run:e,attention:h,queuePosition:t,inWorkingGroup:o,scope:i,now:r}),[x,S]=Z.useState(null);return(0,Q.jsx)(R_,{inertReferences:d,swipeable:f,swipe:p,title:_,onArchive:()=>void c?.(e),children:(0,Q.jsxs)(`div`,{"data-slot":`task-row`,"data-run-id":e.id,"data-active":g?`true`:void 0,onClick:e=>{e.currentTarget.contains(e.target)&&(e.target.closest(`a, button, input`)||(l(m),u?.()))},...f?p.bind:{},style:p.offset?{transform:`translateX(${p.offset}px)`}:void 0,className:q(`selection-row group/task-row flex cursor-pointer items-start gap-2.5 rounded-[6px] py-1.5 pr-2 pl-2.5 hover:bg-sidebar-row-hover`,f&&`select-none`,f&&p.phase!==`dragging`&&`motion-safe:transition-transform motion-safe:duration-200 motion-safe:ease-out`,g&&`bg-sidebar-row-selected hover:bg-sidebar-row-selected`),children:[(0,Q.jsx)(`span`,{"data-slot":`task-row-dot`,className:`flex h-[19px] w-[12px] shrink-0 items-center justify-center`,children:(0,Q.jsx)(Qo,{tone:h.tone,shape:h.shape,pulse:h.pulse,"aria-label":zm(e,h).label,title:zm(e,h).label,role:`img`})}),(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,Q.jsx)(gv,{run:e,to:m,title:_,displayTitle:v,isActive:g,unread:y,swipeable:f,onNavigate:u}),(0,Q.jsx)(_v,{run:e,meta:b,title:_,scope:i,isActive:g,inertReferences:d,overflowContainer:x,webhooks:a})]}),b.references.length?(0,Q.jsx)(`span`,{ref:S,"data-slot":`protected-reference-overflow`,className:q(`shrink-0 self-end empty:hidden`,d&&`-my-1.5 self-center`)}):null,e.delegation?.role===`worker`?(0,Q.jsxs)(`span`,{className:`sr-only`,children:[`Worker · `,zm(e,h).label]}):null,(0,Q.jsx)(L_,{run:e,title:_,unread:y,inertReferences:d,onTogglePin:s,onArchiveRun:c})]})})}function gv({run:e,to:t,title:n,displayTitle:r,isActive:i,unread:a,swipeable:o,onNavigate:s}){return(0,Q.jsxs)(X,{to:t,onClick:s,title:n,"aria-current":i?`page`:void 0,draggable:!o&&void 0,className:`flex h-[19px] min-w-0 items-center gap-2 rounded-[2px] focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-link-foreground`,children:[(0,Q.jsx)(`span`,{"data-slot":`task-row-title`,className:q(`min-w-[7rem] flex-1 truncate text-[13px] leading-[1.45] font-medium text-muted-foreground`,a&&`font-semibold text-foreground`,i&&`text-foreground`),children:r}),e.diffStat?(0,Q.jsx)(vs,{stat:e.diffStat,className:`hidden shrink-0 text-[12px] @min-[23rem]/sidebar:inline`}):null]})}function _v({run:e,meta:t,title:n,scope:r,isActive:i,inertReferences:a,overflowContainer:o,webhooks:s=!0}){let{stateWord:c,references:l,age:u,key:d}=t,f=s&&e.notify===!0,p=`${d}|${+!!f}`,m=Dr(),h=Z.useRef(null),g=pv(h,!!u,p);G_(h,!a&&l.length>0,`${p}|${+!!g}`);let _=[];return c&&_.push((0,Q.jsx)(`span`,{"data-slot":`task-row-state`,children:c},`state`)),l.length&&_.push((0,Q.jsx)(M_,{references:l,maxVisible:2,taskTitle:n,projectId:r??m.projectId,repoBase:m.repoBase,runId:e.id,plain:!0,compact:!0,inertInline:a,fitContainer:!0,overflowContainer:o},`references`)),u&&!g&&_.push((0,Q.jsx)(`span`,{"data-slot":`task-row-age`,className:`tabular-nums`,children:u},`age`)),(0,Q.jsxs)(`div`,{ref:h,"data-slot":`task-row-meta`,className:q(`h-[16px] min-w-0 truncate text-xs leading-[1.4] font-normal text-soft-foreground`,B_,i&&`text-muted-foreground`),children:[f?(0,Q.jsx)(`span`,{"data-slot":`task-row-notify`,role:`img`,"aria-label":`Notifying the task webhook`,title:`Notifying the task webhook`,className:`mr-[4px] inline-block shrink-0 align-[-1px]`,children:(0,Q.jsx)(cl,{"aria-hidden":`true`,className:`size-[10px]`})}):null,_.length?_.flatMap((e,t)=>t?[(0,Q.jsx)(mv,{},`sep-${t}`),e]:[e]):f?null:`\xA0`]})}function vv({label:e,headingId:t,projectName:n,counts:r,onSweep:i,sweeping:a}){let o=e===`Finished`?`unpinned`:null;if(!o||r[o]===0)return null;let s=a===o,c=`Archive all`;return(0,Q.jsxs)(`button`,{type:`button`,"data-action":`archive-group`,"data-scope":o,disabled:s,"aria-busy":s?`true`:void 0,"aria-label":n?`${c}, ${n}`:void 0,"aria-describedby":t,onClick:()=>i(o),className:`relative inline-flex shrink-0 items-center gap-1 rounded-[4px] px-1.5 py-0.5 font-sans text-xs leading-[1.4] text-muted-foreground hover:bg-sidebar-row-hover hover:text-foreground focus-visible:outline-2 focus-visible:outline-link-foreground disabled:opacity-60 max-md:before:absolute max-md:before:top-1/2 max-md:before:left-0 max-md:before:h-11 max-md:before:w-full max-md:before:-translate-y-1/2 max-md:before:content-[''] no-hover:before:absolute no-hover:before:top-1/2 no-hover:before:left-0 no-hover:before:h-11 no-hover:before:w-full no-hover:before:-translate-y-1/2 no-hover:before:content-['']`,children:[(0,Q.jsx)(Wi,{className:`size-[11px]`,"aria-hidden":`true`}),c]})}function yv({showViewControls:e=!0,projectId:t,boot:n=!1,enabled:r=!0}){let i=bl(),a=t??Ie(),o=De(a,r,n),s=Ee(a,r,n).data?.sidebarLimits??{},u=l(v({projectId:a,boot:n})),d=Pg(v({projectId:a,boot:n}),i),f=c(),p=xm()!==`absent`,[h,g,_]=Eh(),y=Do(`/tasks/:id/*`),b=Do(`/tasks/:id`),x=is(3e4),S=te(),C=t??S,w=m(C),T=Mo(Ho(Go(o.data??[],h,_),`active`),s),E=C===void 0?[]:T.flatMap(e=>e.rows.flatMap(({run:e})=>nr(e,w).filter(e=>Tr(e,w)).map(e=>({projectId:C,kind:e.kind,number:e.number}))));return o.data?(0,Q.jsx)(br,{projectId:C,repoBase:w,requests:E,children:(0,Q.jsx)(av,{showViewControls:e,sidebarLimits:s,projectId:C==="default"?f.data?.bootProject??null:C??null,runs:o.data,view:h,automations:_,webhooks:p,onViewChange:g,currentRunId:y?.params.id??b?.params.id??null,now:x,onTogglePin:(e,t)=>u.mutate({id:e.id,pinned:t}),onArchiveRun:d.archiveOne,onSweep:e=>d.sweep(e,_?h===`automations`:void 0),sweeping:d.sweeping})}):null}function bv({view:e,automations:t,onSelect:n,counts:r}){let i=(0,Q.jsx)(Qo,{tone:`pending`,pulse:!0,"data-slot":`waiting-dot`,"aria-label":`Needs you`});return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(uv,{view:`active`,current:e,onSelect:n,count:r.active,children:[`Active`,r.activeWaiting>0&&e!==`active`?i:null]}),t?(0,Q.jsxs)(uv,{view:`automations`,current:e,onSelect:n,count:r.automations,children:[`Automations`,r.automationsWaiting>0&&e!==`automations`?i:null]}):null]})}var xv=e=>e.available?null:e.hint??null,Sv={git:`https://git-scm.com/downloads`,gh:`https://cli.github.com/`};function Cv(e,t){if(e.available)return null;if(B(t,e.name))return{kind:`settings`,to:$s(e.name),label:`Set up`};let n=Sv[e.name];return n?{kind:`external`,href:n,label:`Install guide`}:null}var wv=(e,t)=>oe(t).includes(e.name);function Tv(e,t){let n=e.checks.filter(e=>wv(e,t));if(n.length&&!n.some(e=>e.available))return`no agent CLI found — install one to run tasks`;let r=n.find(t=>t.name===e.defaultRunner);return r&&!r.available?`default runner (${e.defaultRunner}) not found`:null}function Ev(e,t){let n=`Squawk v${e.version}`;if(t===void 0)return n;let r=Tv(e,t);if(r)return`${n} · ${r}`;let i=e.checks.filter(e=>!e.available).map(e=>e.name);return i.length?`${n} · optional: ${i.join(`, `)} not installed`:n}function Dv(e){return e.forge?.available?null:e.forge?`GitHub is unreachable — ${e.forge.reason??`unknown reason`}. The GitHub tab is hidden until it comes back.`:`No GitHub remote detected — the GitHub tab is hidden. Every plain-git feature still works.`}function Ov({health:e,runners:t,sessionScope:n}){if(!e)return null;let r=Tv(e,t);return(0,Q.jsxs)(oo,{children:[(0,Q.jsx)(ro,{asChild:!0,children:(0,Q.jsxs)(`button`,{type:`button`,"data-slot":`tools-menu-trigger`,"aria-label":`Tools`,title:Ev(e,t),className:`relative flex items-center gap-1.5 rounded-[6px] px-2 py-1.5 text-[12px] font-normal text-soft-foreground transition-colors hover:bg-sidebar-row-hover hover:text-foreground focus-visible:outline-2 focus-visible:outline-ring data-[state=open]:bg-sidebar-row-selected data-[state=open]:text-foreground`,children:[(0,Q.jsx)(zi,{className:`size-[15px]`,"aria-hidden":`true`}),r?(0,Q.jsx)(Qo,{tone:`pending`,className:`absolute top-1 left-5 size-1.5`}):null,`Tools`]})}),(0,Q.jsxs)(io,{side:`top`,align:`start`,"data-slot":`tools-menu-content`,className:`w-[240px]`,children:[n?(0,Q.jsx)(`div`,{className:`px-2 py-2`,children:n}):null,(0,Q.jsx)(Xa,{className:`text-xs font-semibold tracking-[.04em] text-soft-foreground uppercase`,children:`Installed tools`}),e.checks.map(e=>e.available?(0,Q.jsx)(kv,{check:e},e.name):(0,Q.jsx)(Av,{check:e,runners:t},e.name)),Dv(e)?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(to,{}),(0,Q.jsx)(`p`,{"data-slot":`forge-note`,className:`px-2 py-1.5 text-xs leading-snug text-muted-foreground`,children:Dv(e)})]}):null,(0,Q.jsx)(to,{}),(0,Q.jsx)(eo,{asChild:!0,children:(0,Q.jsx)(G,{to:`/tools`,children:`Tools diagnostics`})}),(0,Q.jsx)(eo,{asChild:!0,children:(0,Q.jsxs)(G,{to:ec,"data-slot":`tools-settings`,className:`gap-2 text-[13px] text-muted-foreground`,children:[(0,Q.jsx)(Ei,{className:`size-3.5`,"aria-hidden":`true`}),`Tool settings`]})})]})]})}function kv({check:e}){let t=Ym(e);return(0,Q.jsxs)(`div`,{"data-slot":`tool-row`,"data-tool":e.name,"data-available":`true`,className:`flex items-center gap-2 rounded-sm px-2 py-1.5`,children:[(0,Q.jsx)(Qo,{tone:t.availability.tone,shape:t.availability.shape}),(0,Q.jsx)(`span`,{className:`font-mono text-[13px] font-medium`,children:e.name}),t.mode?(0,Q.jsx)(`span`,{"data-slot":`tool-dry-run`,title:t.rawVersion,className:`ml-auto shrink-0 rounded-full border border-border bg-muted px-2 py-0.5 text-xs font-medium text-muted-foreground`,children:t.mode.label}):(0,Q.jsx)(`span`,{"data-slot":`tool-version`,className:`ml-auto font-mono text-xs font-medium text-muted-foreground tabular-nums`,children:t.version??t.availability.label})]})}function Av({check:e,runners:t}){let n=xv(e),r=Ym(e),i=Cv(e,t),a={"data-slot":`tool-row`,"data-tool":e.name,"data-available":`false`},o=(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(Qo,{tone:r.availability.tone,shape:r.availability.shape}),(0,Q.jsx)(`span`,{className:`font-mono text-[13px] font-medium`,children:e.name}),(0,Q.jsx)(`span`,{"data-slot":`tool-version`,className:`ml-auto text-xs font-medium text-muted-foreground`,children:r.availability.label})]}),(0,Q.jsxs)(`span`,{className:`flex items-end justify-between gap-3 pl-[15px]`,children:[n?(0,Q.jsx)(`span`,{"data-slot":`tool-hint`,className:`min-w-0 text-xs leading-snug text-muted-foreground`,children:n}):null,i?(0,Q.jsxs)(`span`,{"data-slot":`tool-setup`,className:`ml-auto shrink-0 text-xs font-semibold text-accent-text`,children:[i.label,` `,i.kind===`external`?`↗`:`→`]}):null]})]});return i?(0,Q.jsx)(eo,{asChild:!0,children:i.kind===`settings`?(0,Q.jsx)(G,{to:i.to,...a,className:`flex-col items-stretch gap-1`,children:o}):(0,Q.jsx)(`a`,{href:i.href,target:`_blank`,rel:`noreferrer`,...a,className:`flex-col items-stretch gap-1`,children:o})}):(0,Q.jsx)(`div`,{...a,className:`flex flex-col items-stretch gap-1 rounded-sm px-2 py-1.5 text-sm`,children:o})}function jv(e){return e?.trim()||null}function Mv({projectName:e,pageLabel:t}){let n=jv(e),r=jv(t);return n&&r?`${n} — ${r} · Squawk`:n?`${n} · Squawk`:r?`${r} · Squawk`:`Squawk`}function Nv(e){let t=Mv(e);(0,Z.useEffect)(()=>{document.title=t},[t])}function Pv({...e}){return(0,Q.jsx)(Jl,{"data-slot":`alert-dialog`,...e})}function Fv({...e}){return(0,Q.jsx)(Yl,{"data-slot":`alert-dialog-portal`,...e})}function Iv({className:e,...t}){return(0,Q.jsx)(Xl,{"data-slot":`alert-dialog-overlay`,className:q(`fixed inset-0 z-50 bg-black/50 motion-safe:data-[state=closed]:animate-out data-[state=closed]:fade-out-0 motion-safe:data-[state=open]:animate-in data-[state=open]:fade-in-0 motion-reduce:data-[state=open]:animate-none motion-reduce:data-[state=closed]:animate-none`,e),...t})}function Lv({className:e,...t}){return(0,Q.jsxs)(Fv,{children:[(0,Q.jsx)(Iv,{}),(0,Q.jsx)(Zl,{"data-slot":`alert-dialog-content`,className:q(`fixed inset-bs-[50%] start-[50%] z-50 grid max-h-[calc(100dvh-2rem)] overflow-y-auto overscroll-contain w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border bg-card p-6 shadow-modal duration-200 outline-hidden motion-safe:data-[state=closed]:animate-out data-[state=closed]:fade-out-0 motion-safe:data-[state=closed]:zoom-out-95 motion-safe:data-[state=open]:animate-in data-[state=open]:fade-in-0 motion-safe:data-[state=open]:zoom-in-95 motion-reduce:data-[state=open]:animate-none motion-reduce:data-[state=closed]:animate-none sm:max-w-md`,e),...t})]})}function Rv({className:e,...t}){return(0,Q.jsx)(`div`,{"data-slot":`alert-dialog-header`,className:q(`flex flex-col gap-2 text-center sm:text-start`,e),...t})}function zv({className:e,...t}){return(0,Q.jsx)(`div`,{"data-slot":`alert-dialog-footer`,className:q(`flex flex-col-reverse gap-2 sm:flex-row sm:justify-end`,e),...t})}function Bv({className:e,...t}){return(0,Q.jsx)(eu,{"data-slot":`alert-dialog-title`,className:q(`text-lg leading-none font-semibold`,e),...t})}function Vv({className:e,...t}){return(0,Q.jsx)(tu,{"data-slot":`alert-dialog-description`,className:q(`text-sm text-muted-foreground`,e),...t})}function Hv({className:e,...t}){return(0,Q.jsx)(Ql,{"data-slot":`alert-dialog-action`,className:q(Da({variant:`contrast`}),e),...t})}function Uv({className:e,...t}){return(0,Q.jsx)($l,{"data-slot":`alert-dialog-cancel`,className:q(Da({variant:`outline`}),e),...t})}function Wv(e){let t=Oo(e);return/^\/git\/branches(?:\/|$)/.test(t)?`branches`:/^\/git\/not-landed(?:\/|$)/.test(t)?`not-landed`:/^\/git\/cleanup(?:\/|$)/.test(t)?`cleanup`:/^\/git\/changes(?:\/|$)/.test(t)?`changes`:/^\/git(?:\/commits(?:\/[^/]+)?)?\/?$/.test(t)?`main`:null}var Gv={main:`/git`,"not-landed":`/git/not-landed`,cleanup:`/git/cleanup`,branches:`/git/branches`,changes:`/git/changes`},Kv=`/git?view=repo`,qv={second:1,minute:60,hour:3600,day:86400,week:7*86400,month:30*86400,year:365*86400};function Jv(e,t,n=Date.now()){let r=t?ys(t,n):``;if(r)return r;let i=/^(\d+) (second|minute|hour|day|week|month|year)s?(?:, (\d+) (second|minute|hour|day|week|month|year)s?)? ago$/.exec(e.trim());return i?xs(Number(i[1])*qv[i[2]]+(i[3]?Number(i[3])*qv[i[4]]:0)):e}function Yv(e,t){let n=t?Date.parse(t):NaN;return Number.isFinite(n)?new Date(n).toLocaleString():e}function Xv(e){let t=new Date(e);return t.setHours(0,0,0,0),t.getTime()}var Zv=new Intl.DateTimeFormat(`en-US`,{weekday:`short`,month:`short`,day:`numeric`}),Qv=new Intl.DateTimeFormat(`en-US`,{month:`short`,day:`numeric`,year:`numeric`});function $v(e,t){let n=Date.parse(e);if(Number.isNaN(n))return`Earlier`;let r=Xv(t);if(n>=r)return`Today`;if(n>=Xv(r-1))return`Yesterday`;let i=new Date(n);return(i.getFullYear()===new Date(t).getFullYear()?Zv:Qv).format(i)}function ey(e,t=Date.now()){let n=[];for(let r of e){let e=$v(r.at,t),i=n.at(-1);i?.label===e?i.commits.push(r):n.push({label:e,commits:[r]})}return n}function ty(e,t=Date.now()){return e.filter(e=>$v(e.at,t)===`Today`).length}function ny(e,t){return(e.baseBranch??t.branch)===t.branch?e.tracking:null}function ry(e,t=Date.now()){let n=e.fetchedAt?ys(e.fetchedAt,t):``;return n?`fetched ${Ss(n)}`:`never fetched`}function iy(e,t,n){return!e?.repo||e.bootProject===null||t!=="default"&&t!==e.bootProject?e:{...e,repo:{...e.repo,branch:n}}}function ay(e,t){return Promise.all([e.invalidateQueries({queryKey:[t,`repo`]}),e.invalidateQueries({queryKey:[t,`health`]}),e.invalidateQueries({queryKey:V.projects})])}var oy=e=>[e,`repo-branch-switch`];function sy(e){return cc({mutationKey:oy(e)})>0}function cy(e,t){let n=U();return je({mutationKey:oy(e),mutationFn:t=>en({name:t},e),onSuccess:async t=>{H(t.created?`Created and switched to ${t.branch}`:`Switched to ${t.branch}`),await ay(n,e),n.setQueryData([e,`repo`],e=>e?.info?{...e,info:{...e.info,branch:t.branch}}:e),n.setQueryData([e,`health`],n=>iy(n,e,t.branch))},...t?{onError:t}:{}})}function ly(e,t){let n=U(),r=[e,`repo`],[i,a]=(0,Z.useState)(null),o=e=>H(e.message,{tone:`danger`}),s=()=>ay(n,e),c=je({mutationFn:t=>yt(t,e)}),l=async(e=!1)=>{let n=i?.branch??t.branch;try{let t=await c.mutateAsync(e?{branch:n,confirm:!0}:{branch:n});if(`risks`in t){a(t);return}a(null),H(t.summary),await s()}catch(e){a(null),H(e instanceof Error?e.message:String(e),{tone:`danger`}),await s()}},u=cy(e,o),d=sy(e),f=je({mutationFn:t=>st({baseBranch:t},e),onSuccess:t=>{H(t.baseBranch?`New tasks now start from ${t.baseBranch}`:`New tasks now start from the checked-out branch`),n.invalidateQueries({queryKey:r}),n.invalidateQueries({queryKey:[e,`config`]})},onError:o});return{switching:d,hasRemote:!!t.remote,pull:l,pulling:c.isPending,confirmation:i,dismissConfirmation:()=>{c.isPending||a(null)},switchBranch:u,setBase:f}}var uy={sidebar:{card:`gap-[8px] rounded-[8px] p-[10px]`,branchRow:`gap-[6px]`,branchIcon:`size-[14px]`,branch:`text-[12.5px]`,chevron:`size-[12px]`,pull:`h-[24px] gap-[4px] rounded-[6px] px-[8px] text-xs [&>svg]:size-[12px]`,line:`text-xs`,lineChevron:`size-[11px]`,dirty:`gap-[6px] pt-[6px] text-xs [&>svg]:size-[12px]`},screen:{card:`gap-[10px] rounded-[10px] p-[12px]`,branchRow:`gap-[8px]`,branchIcon:`size-[16px]`,branch:`text-[14px]`,chevron:`size-[14px]`,pull:`h-[36px] gap-[6px] rounded-[8px] px-[14px] text-[13px] [&>svg]:size-[14px]`,line:`text-[12px]`,lineChevron:`size-[12px]`,dirty:`h-[40px] gap-[8px] pt-[4px] text-[13px] [&>svg:first-child]:size-[14px] [&>svg:last-child]:size-[15px]`}};function dy({scope:e,repo:t,info:n,variant:r,onNavigate:i}){let a=uy[r],o=ly(e,n),s=t.baseBranch??n.branch,c=t.status.length,l=ny(t,n),u=o.switching,d=(0,Z.useRef)(null);return(0,Q.jsxs)(`section`,{"aria-label":`Checkout`,"data-slot":`git-checkout`,"data-variant":r,className:q(`flex flex-col border border-border`,a.card),children:[(0,Q.jsxs)(`div`,{className:q(`flex min-w-0 items-center`,a.branchRow),children:[(0,Q.jsxs)(oo,{children:[(0,Q.jsxs)(ro,{"data-slot":`git-branch-menu`,"aria-label":`Branch ${n.branch}. Switch branch`,disabled:u,className:q(`group flex min-w-0 flex-1 items-center rounded-[4px] text-left outline-none focus-visible:outline-2 focus-visible:outline-ring disabled:opacity-60`,a.branchRow,r===`screen`&&`min-h-11`),children:[(0,Q.jsx)(ji,{"aria-hidden":`true`,className:q(`shrink-0 text-muted-foreground`,a.branchIcon)}),(0,Q.jsx)(`span`,{"data-slot":`git-checkout-branch`,className:q(`min-w-0 flex-1 truncate font-mono font-semibold text-foreground`,a.branch),children:n.branch}),(0,Q.jsx)(Ki,{"aria-hidden":`true`,className:q(`shrink-0 text-soft-foreground group-hover:text-foreground`,a.chevron)})]}),(0,Q.jsxs)(io,{align:`start`,className:`w-64`,children:[(0,Q.jsx)(Xa,{className:`text-xs text-soft-foreground`,children:`Switch branch`}),(0,Q.jsx)(ao,{value:n.branch,onValueChange:e=>{e!==n.branch&&o.switchBranch.mutate(e)},children:t.branches.map(e=>(0,Q.jsx)(Za,{value:e,"data-branch":e,className:`font-mono text-[12.5px]`,children:(0,Q.jsx)(`span`,{className:`truncate`,children:e})},e))}),(0,Q.jsx)(to,{}),(0,Q.jsx)(eo,{asChild:!0,children:(0,Q.jsx)(X,{to:Gv.branches,"data-slot":`git-branch-menu-all`,onClick:i,children:`Create or find a branch…`})})]})]}),(0,Q.jsxs)(`button`,{ref:d,type:`button`,"data-action":`repo-pull`,disabled:!o.hasRemote||o.pulling,title:o.hasRemote?`Pull ${n.branch}`:`No remote configured. Add a Git remote before pulling.`,onClick:()=>void o.pull(),className:q(`inline-flex shrink-0 items-center bg-muted font-medium text-foreground hover:brightness-110 focus-visible:outline-2 focus-visible:outline-ring disabled:opacity-50 disabled:hover:brightness-100`,a.pull),children:[o.pulling?(0,Q.jsx)(xa,{"aria-hidden":`true`,className:`motion-safe:animate-spin`}):(0,Q.jsx)(Ii,{"aria-hidden":`true`}),`Pull`]})]}),l?(0,Q.jsx)(fy,{tracking:l,className:a.line}):null,(0,Q.jsxs)(oo,{children:[(0,Q.jsxs)(ro,{"data-slot":`base-branch-picker`,"aria-label":`New tasks start from ${s}. Change the base branch`,disabled:o.setBase.isPending,className:q(`group flex min-w-0 items-center gap-[4px] self-start rounded-[4px] text-soft-foreground outline-none hover:text-foreground focus-visible:outline-2 focus-visible:outline-ring disabled:opacity-60`,a.line,r===`screen`&&`min-h-[32px]`),children:[(0,Q.jsx)(`span`,{className:`shrink-0`,children:`New tasks start from`}),(0,Q.jsx)(`span`,{"data-slot":`base-branch`,className:`min-w-0 truncate font-mono text-muted-foreground group-hover:text-foreground`,children:s}),(0,Q.jsx)(Ki,{"aria-hidden":`true`,className:q(`shrink-0`,a.lineChevron)})]}),(0,Q.jsxs)(io,{align:`start`,className:`w-64`,children:[(0,Q.jsx)(Xa,{className:`text-xs text-soft-foreground`,children:`New tasks start from`}),(0,Q.jsxs)(ao,{value:t.baseBranch??``,onValueChange:e=>o.setBase.mutate(e===``?null:e),children:[(0,Q.jsx)(Za,{value:``,"data-branch":``,className:`text-[12.5px]`,children:`The checked-out branch (default)`}),t.branches.map(e=>(0,Q.jsx)(Za,{value:e,"data-branch":e,className:`font-mono text-[12.5px]`,children:(0,Q.jsx)(`span`,{className:`truncate`,children:e})},e))]})]})]}),c>0?(0,Q.jsxs)(X,{to:Gv.changes,"data-slot":`git-uncommitted`,onClick:i,className:q(`flex min-w-0 items-center border-t border-border text-muted-foreground hover:text-foreground focus-visible:outline-2 focus-visible:outline-ring`,a.dirty),children:[(0,Q.jsx)(wi,{"aria-hidden":`true`,className:`shrink-0 text-inbox-count-foreground`}),(0,Q.jsxs)(`span`,{className:`min-w-0 flex-1 truncate`,children:[c,` uncommitted file`,c===1?``:`s`]}),(0,Q.jsx)(Ti,{"aria-hidden":`true`,className:`shrink-0 text-soft-foreground`})]}):null,(0,Q.jsx)(py,{checkout:o,returnFocus:d})]})}function fy({tracking:e,className:t}){let n=e.ref.split(`/`)[0]||e.ref,r=ry(e);return(0,Q.jsx)(`p`,{"data-slot":`git-freshness`,className:q(`flex min-w-0 items-center gap-[4px] text-soft-foreground`,t),children:e.behind>0?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`span`,{"data-slot":`git-behind`,className:`shrink-0 font-medium text-inbox-count-foreground`,children:[e.behind,` behind `,n]}),(0,Q.jsxs)(`span`,{className:`min-w-0 truncate`,children:[`· `,r]})]}):(0,Q.jsxs)(`span`,{className:`min-w-0 truncate`,children:[`up to date · `,r]})})}function py({checkout:e,returnFocus:t}){return(0,Q.jsx)(Pv,{open:e.confirmation!==null,onOpenChange:t=>!t&&e.dismissConfirmation(),children:(0,Q.jsxs)(Lv,{onCloseAutoFocus:e=>{e.preventDefault(),t.current?.focus()},children:[(0,Q.jsxs)(Rv,{children:[(0,Q.jsxs)(Bv,{children:[`Pull `,e.confirmation?.branch,` anyway?`]}),(0,Q.jsx)(Vv,{asChild:!0,children:(0,Q.jsxs)(`div`,{className:`space-y-2`,children:[e.confirmation?.risks.includes(`active_runs`)?(0,Q.jsx)(`p`,{children:`An active session is using this repository. Pulling can change files while it works.`}):null,e.confirmation?.risks.includes(`dirty_tree`)?(0,Q.jsx)(`p`,{children:`The checkout has dirty files. Git may refuse the pull to protect them.`}):null]})})]}),(0,Q.jsxs)(zv,{children:[(0,Q.jsx)(Uv,{className:`h-11`,disabled:e.pulling,children:`Cancel`}),(0,Q.jsx)(Hv,{className:`h-11`,disabled:e.pulling||e.confirmation===null,onClick:t=>{t.preventDefault(),e.pull(!0)},children:e.pulling?`Pulling…`:`Pull anyway`})]})]})})}var my={main:fi,"not-landed":$c,cleanup:Fc,branches:ji};function hy(e,t){switch(e){case`main`:return t?`Recently on ${t}`:`Recent commits`;case`not-landed`:return`Not landed`;case`cleanup`:return`Cleanup`;case`branches`:return`All branches`;case`changes`:return`Uncommitted changes`}}var gy=[`main`,`not-landed`,`cleanup`,`branches`];function _y({branch:e,counts:t,variant:n,active:r,onNavigate:i}){let a=n===`screen`;return(0,Q.jsx)(`nav`,{"aria-label":`Git sections`,"data-slot":`git-sections`,className:a?ca:sa,children:gy.map(n=>{let o=my[n],s=!a&&r===n,c=t[n];return(0,Q.jsxs)(X,{to:a&&n===`main`?Kv:Gv[n],"data-git-section":n,"aria-current":s?`page`:void 0,onClick:i,className:q(a?ha:q(pa,`text-[12.5px]`),ua,s&&`bg-sidebar-row-selected text-foreground font-medium hover:bg-sidebar-row-selected`),children:[(0,Q.jsx)(o,{"aria-hidden":`true`,className:a?fa:oa}),(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:hy(n,e)}),c?(0,Q.jsx)(`span`,{"data-slot":`git-section-count`,className:a?ma:la,children:c}):null,a?(0,Q.jsx)(Ti,{"aria-hidden":`true`,className:da}):null]},n)})})}async function vy(e,t){return dt(await kt.api.v1.p[`:projectId`].repo.branches.counts.$get({param:{projectId:t??Ie()}},_t(e)),`/repo/branches/counts`)}function yy(e){return Jt({queryKey:[e,`repo`,`branches`,`counts`],queryFn:({signal:t})=>vy({signal:t},e)})}function by(e,t,n){let r=Oe(e),i=yy(e),a=r.data?.totalBytes??null,o=i.data?.counts??null,s=t&&n===`screen`?ty(t.log):0;return{main:s>0?`${s} today`:null,"not-landed":o?.notLanded?String(o.notLanded):null,cleanup:a?vr(a):r.data&&a===null&&o?.cleanup?String(o.cleanup):null,branches:t?String(i.data?.allBranches??t.branches.length):null}}function xy({scope:e}){let t=P(e),{pathname:n}=qn(),r=bl(),i=t.data?.info?t.data:null,a=by(e,i,`sidebar`);return(0,Q.jsxs)(`div`,{"data-slot":`git-sidebar`,role:`region`,"aria-label":`Git`,className:ia,children:[i?.info?(0,Q.jsx)(dy,{scope:e,repo:i,info:i.info,variant:`sidebar`,onNavigate:r},e):t.isPending?(0,Q.jsx)(`div`,{"data-slot":`git-checkout-placeholder`,"aria-hidden":`true`,className:`h-[94px] rounded-[8px] border border-border`}):null,t.isPending?null:(0,Q.jsx)(_y,{branch:i?.info?.branch??null,counts:a,variant:`sidebar`,active:Wv(n),onNavigate:r})]})}var Sy=[`assigned`,`no-task`,`has-task`,`all`],Cy=[`review`,`mine`,`failing`,`all`],wy=50,Ty=`is:open review-requested:@me`,Ey=`is:open status:failure`;function Dy(e,t){return e===`prs`&&(t===`review`||t===`failing`)}function Oy(e){return e===`review`?Ty:e===`failing`?Ey:null}function ky(e,t){return t===null?null:(e===`issues`?Sy:Cy).includes(t)?t:`all`}var Ay=[`q`,`label`,`assignee`,`board`];function jy(e){let t=new URLSearchParams;for(let n of Ay)for(let r of e.getAll(n))r!==``&&t.append(n,r);return t.toString()}function My(e,t,n,r=``,i=``){let a=`${n===void 0?e===`issues`?`/github`:`/github/prs`:`${e===`issues`?`/github/issues`:`/github/prs`}/${n}`}${r}`,o=[t===null?``:`filter=${encodeURIComponent(t)}`,i].filter(Boolean).join(`&`);return o===``?a:`${a}?${o}`}function Ny(e,t){let n=t??`all`;return n===`all`?e===`issues`?`all`:`all-prs`:n}function Py(e){return e===`all`?{view:`issues`,filter:`all`}:e===`all-prs`?{view:`prs`,filter:`all`}:{view:e===`review`||e===`mine`||e===`failing`?`prs`:`issues`,filter:e}}var Fy=[{id:`assigned`,label:`Assigned to me`},{id:`no-task`,label:`No task yet`},{id:`has-task`,label:`Has a task`},{id:`all`,label:`All open`}],Iy=[{id:`review`,label:`Review requested`},{id:`mine`,label:`Mine`},{id:`failing`,label:`Checks failing`},{id:`all-prs`,label:`All open`}],Ly=Object.fromEntries([...Fy,...Iy].map(e=>[e.id,e.label]));function Ry(e){return e===null?``:`${e.value}${e.bound===`atLeast`?`+`:``}`}function zy(e,t){if(t?.bound===`atLeast`)return e===`review`||e===`failing`?`At least ${t.value}: GitHub search returns at most ${wy} results.`:`At least ${t.value}: only the loaded pages are counted. Scroll to load more.`}var By=(e,t)=>e!==void 0&&t!==void 0&&e.toLowerCase()===t.toLowerCase();function Vy(e){try{let t=new URL(e).pathname.split(`/`).filter(Boolean);return t.length>=2?`${t[0]}/${t[1]}`.toLowerCase():null}catch{return null}}function Hy(e,t,n){return new Set(e.filter(e=>!e.archived).flatMap(e=>Uy(e,t,n)))}function Uy(e,t,n){let r=t?.toLowerCase();return nr(e,void 0,n).filter(e=>e.kind===`Issue`&&(!e.url||r!==void 0&&Vy(e.url)===r)).map(e=>e.number)}function Wy(e,t,n,r){let i=new Map;for(let a of e)!No(a)&&Uy(a,n,r).includes(t)&&i.set(a.id,a);return[...i.values()].sort((e,t)=>Date.parse(t.createdAt)-Date.parse(e.createdAt)||e.id.localeCompare(t.id))}function Gy(e,t,n){let r=new Map;for(let i of e)if(!(i.archived||No(i)))for(let e of Uy(i,t,n)){let t=r.get(e);(!t||Date.parse(i.createdAt)>Date.parse(t.createdAt))&&r.set(e,i)}return r}function Ky(e,t){let n=new Map(t.map(e=>[e.number,e]));return e.map(e=>n.get(e.number)??e)}function qy(e){return e?.available?{value:e.items.length,bound:e.truncated?`atLeast`:`exact`}:null}function Jy({gh:e,tasks:t,review:n,failing:r}){let i={assigned:null,"no-task":null,"has-task":null,all:null,review:qy(n),mine:null,failing:qy(r),"all-prs":null};if(!e?.available)return i;let a=!ve(e,`issues`),o=!ve(e,`prs`),s=(e,t)=>({value:e,bound:t?`atLeast`:`exact`}),c=t?e.issues.filter(e=>t.has(e.number)).length:null;return{...i,all:s(e.issuesTotal??e.issues.length,!1),"all-prs":s(e.prsTotal??e.prs.length,!1),assigned:e.viewerLogin?s(e.issues.filter(t=>t.assignees?.some(t=>By(t,e.viewerLogin))).length,a):null,mine:e.viewerLogin?s(e.prs.filter(t=>By(t.author,e.viewerLogin)).length,o):null,"has-task":c===null?null:s(c,a),"no-task":c===null?null:s(e.issues.length-c,a)}}var Yy={assigned:qi,"no-task":na,"has-task":Ci,all:Pi,review:ba,mine:ci,failing:yi,"all-prs":Pi};function Xy(e,t){return e===`assigned`||e===`mine`?t.identity:e===`no-task`||e===`has-task`?t.tasks:null}function Zy({model:e,variant:t,activeId:n,onNavigate:r,keep:i}){let a=t===`screen`;return(0,Q.jsx)(Q.Fragment,{children:[{key:`issues`,label:`Issues`,rows:Fy},{key:`prs`,label:`Pull requests`,rows:Iy}].map(t=>(0,Q.jsxs)(`nav`,{"aria-label":t.label,"data-slot":`github-filter-group`,"data-group":t.key,className:a?ca:q(ga,t.key===`prs`&&`pt-[6px]`),children:[(0,Q.jsx)(`h3`,{className:a?ra:aa,children:t.label}),t.rows.map(({id:t,label:o})=>{let s=Yy[t],c=n===t,l=Xy(t,e.blocked),u=e.counts[t],d=Ry(u),f=q(a?ha:q(pa,`text-[12.5px]`),l?`cursor-not-allowed opacity-60`:ua,c&&`bg-sidebar-row-selected text-foreground font-medium hover:bg-sidebar-row-selected`),p=(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(s,{"aria-hidden":`true`,className:a?fa:oa}),(0,Q.jsx)(`span`,{className:`truncate`,children:o}),d?(0,Q.jsx)(`span`,{"data-slot":`gh-filter-count`,title:zy(t,u),className:a?ma:la,children:d}):null,a?(0,Q.jsx)(Ti,{"aria-hidden":`true`,className:q(da,!d&&`ml-auto`)}):null]});if(l)return(0,Q.jsxs)(`div`,{"data-gh-filter":t,"aria-disabled":`true`,title:l,className:f,children:[p,(0,Q.jsx)(`span`,{className:`sr-only`,children:l})]},t);let{view:m,filter:h}=Py(t);return(0,Q.jsx)(X,{to:My(m,h,void 0,``,i?.view===m?i.narrows:``),"data-gh-filter":t,"aria-current":c?`page`:void 0,onClick:r,className:f,children:p},t)})]},t.key))})}function Qy(e){let t=fe(e,50).data,n=t?.available===!0,r=De(e,!0,e==="default"),i=we(e,`pr`,Ty,n),a=we(e,`pr`,Ey,n),o=(0,Z.useMemo)(()=>r.data?Hy(r.data,t?.repo,e):null,[r.data,t?.repo,e]);return{gh:t,counts:(0,Z.useMemo)(()=>Jy({gh:t,tasks:o,review:i.data,failing:a.data}),[t,o,i.data,a.data]),blocked:{identity:t?.available===!0&&!t.viewerLogin?`GitHub login unavailable.`:null,tasks:r.isError&&!r.data?`Task list unavailable.`:null}}}function $y(e){return/^\/github\/prs(?:\/|$)/.test(Oo(e))?`prs`:`issues`}function eb({scope:e}){let t=Qy(e),{pathname:n}=qn(),[r]=zn(),i=bl(),a=$y(n);return(0,Q.jsx)(`div`,{"data-slot":`github-sidebar`,role:`region`,"aria-label":`GitHub`,className:ia,children:(0,Q.jsx)(Zy,{model:t,variant:`sidebar`,activeId:Ny(a,ky(a,r.get(`filter`))),onNavigate:i,keep:{view:a,narrows:jy(r)}})})}var tb=(0,Z.lazy)(()=>W(()=>import(`./accounts-section-DJ_M9Wt5.js`).then(e=>({default:e.GlobalAgentsSection})),__vite__mapDeps([5,1,2,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,42,43,44,45,46,47,48]))),nb=(0,Z.lazy)(()=>W(()=>import(`./agent-config-section-C89KQhYI.js`).then(e=>({default:e.AgentConfigSection})),__vite__mapDeps([49,1,2,6,7,8,9,10,11,12,20,21,28,36,38,39,15,40,16,26,41,19,42,43,44,24,31,33,34,45,46,13,14,47,37,50,51,52,53]))),rb=(0,Z.lazy)(()=>W(()=>import(`./agent-defaults-section-CsIHvRnd.js`).then(e=>({default:e.AgentDefaultsSection})),__vite__mapDeps([54,1,2,6,7,8,9,10,11,12,15,20,55,24,32,34,25,26,16,56,28,57,29,30,31,33,35,22,23,37,47,53,58]))),ib=(0,Z.lazy)(()=>W(()=>import(`./appearance-xdlVXLZN.js`).then(e=>({default:e.AppearanceSection})),__vite__mapDeps([59,2,1,6,7,8,9,10,11,12,16,60,20,37,47]))),ab=(0,Z.lazy)(()=>W(()=>import(`./projects-section-C5Lm9E1X.js`).then(e=>e.r).then(e=>({default:e.ProjectsSection})),__vite__mapDeps([61,1,2,6,7,8,9,10,11,12,13,14,15,20,62,24,33,34,28,29,30,31,32,37,47,38,39,40,16,26,41,19,42,43,44,45,46,53,58,63,64,65]))),ob=(0,Z.lazy)(()=>W(()=>import(`./prompt-templates-section-BSqqmMzn.js`).then(e=>({default:e.PromptTemplatesSection})),__vite__mapDeps([66,1,2,6,7,8,9,10,11,12,15,20,62,24,33,34,67,23,22,68,28,57,47,37,53,58,63,64,65]))),sb=(0,Z.lazy)(()=>W(()=>import(`./resources-section-CKxYxZlu.js`).then(e=>({default:e.ResourcesSection})),__vite__mapDeps([69,2,1,6,7,8,9,10,11,12,13,14,15,55,24,32,34,28,29,30,31,33,37,47,48,53,20,58]))),cb=(0,Z.lazy)(()=>W(()=>import(`./session-context-section-Bko3JFzB.js`).then(e=>({default:e.SessionContextSection})),__vite__mapDeps([70,1,2,6,7,8,9,10,11,12,71,16,20,21,28,50,51,14,45,53,37]))),lb=(0,Z.lazy)(()=>W(()=>import(`./sidebar-section-BWGMQzwD.js`).then(e=>({default:e.SidebarSection})),__vite__mapDeps([72,1,2,6,7,8,9,10,11,12,20,53,37]))),ub=(0,Z.lazy)(()=>W(()=>import(`./worktrees-section-B_8wVdPI.js`).then(e=>({default:e.WorktreesSection})),__vite__mapDeps([73,1,2,6,7,8,9,10,11,12,15,46,13,14,28,36,47,37,39,40,16,26,41,19,42,43,20,44,24,31,33,34,45,53,58]))),db=(0,Z.lazy)(()=>W(()=>import(`./preferences-section-CGPTMvPb.js`).then(e=>({default:e.PreferencesSection})),__vite__mapDeps([74,1,2,6,7,8,9,10,11,12,55,24,32,34,37,75,29,30,15,31,33]))),fb=[{id:`sidebar`,title:`Sidebar`,description:`Overall and per-section task limits for this project.`,icon:ni,component:lb,scope:`project`},{id:`agent-defaults`,title:`Agent defaults`,description:`Default runner, models and system prompt.`,icon:Ci,component:rb,scope:`project`},{id:`agent-config`,title:`Agent config`,description:`Edit the coding agents’ own config files, per scope.`,icon:Jc,component:nb,scope:`project`},{id:`session-context`,title:`Session context`,description:`Text Squawk puts at the start of every agent session it launches.`,icon:Yc,component:cb,scope:`project`},{id:`worktrees`,title:`Worktrees`,description:`How many finished task worktrees this project keeps on disk.`,icon:Zc,component:ub,scope:`project`},{id:`prompt-templates`,title:`Prompt templates`,description:`Reusable snippets for follow-up instructions.`,icon:Xc,component:ob,scope:`project`},{id:`appearance`,title:`Appearance`,description:`Theme, density and reading width.`,icon:Bi,component:ib,scope:`global`},{id:`preferences`,title:`Preferences`,description:`Browser notifications and task archiving after pull requests merge.`,icon:Ui,component:db,scope:`global`},{id:`resources`,title:`Resources`,description:`Parallel tasks and per-task memory limit, across every project.`,icon:ni,component:sb,scope:`global`},{id:`agents`,title:`Agents`,description:`Install, version and sign-in for each agent, and the agent and models a project uses when it has chosen none.`,icon:Xi,component:tb,scope:`global`},{id:`projects`,title:`Projects`,description:`The workspace registry and where GitHub checkouts land.`,icon:Mi,component:ab,scope:`global`}];function pb(e){return fb.filter(t=>t.scope===e)}function mb(e,t){return e===`global`?`/settings/global/${t}`:`/settings/${t}`}var hb=mb(`global`,`appearance`);function gb({projectId:e,projectName:t}){return(0,Q.jsx)(`div`,{"data-slot":`settings-sidebar`,className:ia,children:(e===null?[`global`]:[`project`,`global`]).map(n=>{let r=n===`project`?`This project${t?` · ${t}`:``}`:`Global · every project`,i=n===`project`&&e!==null?`/p/${encodeURIComponent(e)}/settings`:`/settings/global`,a=pb(n).map(e=>({id:e.id,title:e.title,icon:e.icon,to:`${i}/${e.id}`})),o=n===`project`?[{id:`general`,title:`General`,icon:Ei,to:i},...a]:a;return(0,Q.jsxs)(`nav`,{"aria-label":r,"data-slot":`settings-nav`,"data-scope":n,className:q(`flex flex-col gap-px`,n===`global`&&e!==null&&`pt-[6px]`),children:[(0,Q.jsx)(`h3`,{title:r,className:aa,children:r}),o.map(({id:e,title:t,icon:n,to:r})=>(0,Q.jsxs)(Jn,{to:r,end:!0,"data-section":e,className:({isActive:e})=>q(pa,ua,e&&`bg-sidebar-row-selected text-foreground font-medium hover:bg-sidebar-row-selected`),children:[(0,Q.jsx)(n,{"aria-hidden":`true`,className:oa}),(0,Q.jsx)(`span`,{className:`truncate`,children:t})]},e))]},n)})})}var _b=[{pattern:`/`,pageLabel:`Tasks`},{pattern:`/tasks`,pageLabel:`All tasks`},{pattern:`/tools`,pageLabel:`Workspace tools`},{pattern:`/new`,pageLabel:`New task`},{pattern:`/activity`,pageLabel:`Activity`},{pattern:`/git/not-landed`,pageLabel:`Git / Not landed`},{pattern:`/git/branches`,pageLabel:`Git / All branches`},{pattern:`/git/changes`,pageLabel:`Git / Uncommitted changes`},{pattern:`/git/cleanup`,pageLabel:`Git / Cleanup`},{pattern:`/git/*`,pageLabel:`Git`},{pattern:`/github/*`,pageLabel:`GitHub`},{pattern:`/automations/new`,pageLabel:`Automations / New automation`},{pattern:`/automations/:automationId`,pageLabel:`Automations / Edit automation`},{pattern:`/automations/*`,pageLabel:`Automations`},{pattern:`/skills`,pageLabel:`Skills`},{pattern:`/reports`,pageLabel:`Reports`},{pattern:`/workflows/*`,pageLabel:`Workflows`},{pattern:`/settings/*`,pageLabel:`Settings`}];function vb(e,t={}){let n=Oo(e),r=Gn({path:`/tasks/:id/*`,end:!0},n);if(r)return{pageLabel:null,taskId:r.params.id??null};let i=t.reports??!0;return{pageLabel:_b.find(({pattern:e})=>(e!==`/reports`||i)&&Gn({path:e,end:!0},n))?.pageLabel??null,taskId:null}}function yb(e){let t=e?.repo;if(!t)return null;let n=t.root.replace(/[\\/]+$/,``).split(/[\\/]/).pop();return n?{name:n,branch:t.branch}:null}var bb=e=>Lo(e).waiting>0;function xb(e,t){return e===void 0?t!==void 0&&t.bootProject===null?null:t?.bootProject??`default`:e.bootProject===null?e.projects.find(e=>e.status!==`missing`)?.id??e.projects[0]?.id??null:e.bootProject}function Sb(e,t,n){let r=t===void 0?n?.bootProject??null:t.bootProject,i=e??xb(t,n);return{bootProjectId:r,sidebarProjectId:i,sidebarBoot:i!==null&&i===r,isBootProject:e!==null&&e===r,activeProject:e===null?void 0:t?.projects.find(t=>t.id===e),sidebarProject:i===null?void 0:t?.projects.find(e=>e.id===i),projectQueriesEnabled:i!==null&&(e!==null||r!==null||t!==void 0)}}function Cb(e,t,n,r,i,a){let o=e===`/tools`||e===`/settings/global`||e.startsWith(`/settings/global/`);return{globalSettings:o,projectName:o?null:t?.name??(n?yb(r)?.name??null:null),titleRun:a,pageLabel:a?Ro(a):i.pageLabel}}function wb(e){return e?.forge===`github`}function Tb(e,t,n,r,i,a){if(/^\/settings(?:\/|$)/.test(e))return(0,Q.jsx)(gb,{projectId:n,projectName:n===null?null:i?.projects.find(e=>e.id===n)?.name??(r?yb(a)?.name??null:null)});if(n!==null)return/^\/github(?:\/|$)/.test(e)&&t?(0,Q.jsx)(eb,{scope:v({projectId:n,boot:r}).cacheScope}):/^\/git(?:\/|$)/.test(e)?(0,Q.jsx)(xy,{scope:v({projectId:n,boot:r}).cacheScope}):void 0}function Eb(e,t,n,r,i){return e===`/tools`?yb(i):t?null:n?{name:n.name,branch:n.id===r?i?.repo?.branch??``:``}:yb(i)}function Db(e,t,n,r,i,a){let o=Eo(e)===null,s=n?`Tasks / ${i}`:e===`/tools`?`Tools`:!a&&e===`/`?`Projects`:i??(r.taskId===null?`Not found`:`Tasks`);return{project:o?`Workspace`:t,page:s,branch:n?.worktreePath?`Isolated worktree`:void 0}}function Ob(e,t,n=!1,r){if(!e||e.hosts.length===0&&!e.warning)return;let i=t?e.hosts.map(e=>{if(e.id!==t.hostId)return e;let r=t.offline&&t.state!==null?t.state:!t.offline&&n?`connected`:e.state;return r===e.state?e:{...e,state:r}}):e.hosts;return{localProjects:e.local.projects,hosts:i,warning:e.warning,...r===void 0?{}:{hostSignals:r}}}function kb(e,t){let n=Pe()?t:e;return{version:n?.version??null,latestVersion:n?.latestVersion??null}}function Ab(e,t){return e?t?{...e,hostsData:t}:e:t?{projects:[],signals:null,hostsData:t}:null}function jb(e,t,n,r,i){return e?(0,Q.jsx)(Cg,{...e,hostsData:i,projectTarget:t.target,onSwitchProject:e=>void t.go(e),version:r}):i?(0,Q.jsx)(Cg,{projects:[],signals:null,hostsData:i,version:r}):n?(0,Q.jsx)(_g,{}):null}function Mb(e,t,n){return e===null?{hasProjects:!1,taskQuickList:void 0,projectHeader:void 0,sidebarProjectId:void 0}:{hasProjects:!0,taskQuickList:(0,Q.jsx)(yv,{projectId:e,boot:t,enabled:n}),projectHeader:(0,Q.jsx)(gd,{}),sidebarProjectId:e}}function Nb(e,t,n){return!e&&t===`/`?`Projects`:n}function Pb({children:e}){let{pathname:t}=qn(),n=Ao(),r=Pe(),i=c(),a=Yr(r),o=L(),s=(0,Z.useRef)(void 0);(0,Z.useEffect)(()=>{i.data&&(s.current=i.data)},[i.data]);let l=i.data??s.current,u=mm(l),d=vm(l)!==`absent`,f=A(),p=f.data,m=wg(),h=Bt(),g=Gr(),_=Ur({enabled:r}),v=m?.hostSignals??(r?_.data??null:void 0),y=Ob(Kr().data,g,h.reportedState===`connected`,v),b=Ab(m,y),x=pm(),S=vb(t,{reports:d}),{bootProjectId:C,sidebarProjectId:w,sidebarBoot:T,isBootProject:E,activeProject:D,sidebarProject:O,projectQueriesEnabled:k}=Sb(n,p,i.data),M=Mb(w,T,k),ee=De(w??``,k,T,bb).data??!1,P=(0,Z.useCallback)(e=>{let t=e.find(e=>e.id===S.taskId);return t?{title:t.title,titleSummary:t.titleSummary,titleOrigin:t.titleOrigin,worktreePath:t.worktreePath}:void 0},[S.taskId]),F=De(n??``,D!==void 0&&S.taskId!==null,E,P).data,I=F?void 0:S.taskId??void 0,R=j(n===null&&C!==null?I:void 0),te=N(n??void 0,I),ne=n===null?R.data:te.data,{globalSettings:re,projectName:z,titleRun:ie,pageLabel:ae}=Cb(t,D,E,i.data,S,F??ne);Nv({projectName:z,pageLabel:Nb(M.hasProjects,t,ae)});let oe=wb(O),B=Tb(Oo(t),oe,w,T,p,i.data),{version:se,latestVersion:ce}=kb(l,a.data),le=h.offline;return(0,Q.jsxs)(Th,{children:[(0,Q.jsx)(ap,{repo:Eb(t,re,D,C,i.data),breadcrumb:Db(t,z,ie,S,ae,M.hasProjects),version:se,latestVersion:ce,forgeAvailable:oe,automationsAvailable:u,reportsAvailable:d,hostLive:le?`false`:void 0,...M,banner:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Oh,{}),(0,Q.jsx)(ng,{}),(0,Q.jsx)(Rh,{}),(0,Q.jsx)(Ph,{})]}),sidebarList:B,mobileProjects:b,needsYou:ee,toolsMenu:(0,Q.jsx)(Ov,{health:i.data,runners:o.data}),toolsStatus:i.data?{blocked:Tv(i.data,o.data)!==null,note:Dv(i.data)}:null,projectRail:jb(m,x,f.isPending,se,y),children:e}),(0,Q.jsx)(mh,{canCreateTask:M.hasProjects})]})}var Fb=`cez-accent`,Ib=`cez-density`,Lb=`cez-width`,Rb=`cezarion`,zb=`comfortable`,Bb=`narrow`;function Vb(e){return Rb}function Hb(e){return e===`comfortable`||e===`compact`||e===`ultra`?e:zb}function Ub(e){return e===`narrow`||e===`wide`?e:Bb}function Wb(e){let t=e&&typeof e==`object`?e:{};return{accent:Vb(t.accent),density:Hb(t.density),width:Ub(t.width)}}function Gb(){try{return{accent:Vb(localStorage.getItem(Fb)),density:Hb(localStorage.getItem(Ib)),width:Ub(localStorage.getItem(Lb))}}catch{return{accent:Rb,density:zb,width:Bb}}}function Kb(e){try{localStorage.setItem(Fb,e.accent),localStorage.setItem(Ib,e.density),localStorage.setItem(Lb,e.width)}catch{}}function qb(e,t){t.accent===`cezarion`?delete e.dataset.accent:e.dataset.accent=t.accent,t.density===`comfortable`?delete e.dataset.density:e.dataset.density=t.density,t.width===`narrow`?delete e.dataset.width:e.dataset.width=t.width}var Jb=Z.createContext(null);function Yb({children:e}){let t=U(),n=Pe(),r=ce(!n),i=Wr(n),a=n?i:r,o=n?Xr.uiState:V.uiState,[s,c]=Z.useState(Gb),l=a.data;Z.useEffect(()=>{if(l===void 0)return;let e=Wb(l.appearance);c(e),Kb(e)},[l]),Z.useLayoutEffect(()=>{qb(document.documentElement,s)},[s]);let u=Z.useCallback(e=>(c(e),Kb(e),(n?k:Ht)({appearance:e}).then(e=>(t.setQueryData(o,e),!0)).catch(e=>(H(e instanceof Error?e.message:String(e),{tone:`danger`}),t.invalidateQueries({queryKey:o}),!1))),[n,t,o]),d=Z.useCallback(e=>u({...s,accent:e}),[u,s]),f=Z.useCallback(e=>u({...s,density:e}),[u,s]),p=Z.useCallback(e=>u({...s,width:e}),[u,s]),m=Z.useMemo(()=>({accent:s.accent,density:s.density,width:s.width,setAccent:d,setDensity:f,setWidth:p}),[s,d,f,p]);return(0,Q.jsx)(Jb.Provider,{value:m,children:e})}function Xb(){let e=Z.useContext(Jb);if(!e)throw Error(`Squawk: useAppearance() must be called inside <AppearanceProvider>`);return e}function Zb({hostId:e,hosts:t,warning:n}){let r=rt(t);return(0,Q.jsx)(ds,{route:`unknown-host`,density:`empty`,flushPadding:!0,children:(0,Q.jsxs)(tc,{icon:(0,Q.jsx)(ll,{}),tone:`neutral`,title:`“${e}” isn’t a saved host`,subtitle:r.length>0?`This Squawk doesn’t have a saved host by that id. Choose a saved host below, or open this server:`:n?`This Squawk could not load saved hosts.`:`This Squawk doesn’t have a saved host by that id, and no remote hosts are saved yet.`,children:[n?(0,Q.jsx)(`p`,{"data-slot":`unknown-host-warning`,role:`alert`,className:`mx-auto max-w-sm rounded-md border border-border bg-muted/50 px-3 py-2 text-xs text-muted-foreground`,children:n}):null,r.length>0?(0,Q.jsxs)(`div`,{className:`mx-auto flex w-full max-w-sm flex-col gap-3`,children:[(0,Q.jsx)(`ul`,{"data-slot":`saved-hosts`,className:`flex w-full flex-col gap-1.5 text-left`,children:r.map(e=>(0,Q.jsx)(`li`,{children:(0,Q.jsxs)(`a`,{href:Me(e.id),"data-slot":`saved-host-link`,"data-host-id":e.id,className:`flex min-h-11 items-center justify-between gap-2 rounded-md border border-border bg-card px-3 py-2 text-sm font-medium text-foreground shadow-xs transition-colors hover:bg-card-2 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring`,children:[(0,Q.jsxs)(`span`,{className:`flex min-w-0 flex-wrap items-baseline gap-x-2`,children:[(0,Q.jsx)(`span`,{className:`truncate`,children:e.label}),(0,Q.jsxs)(`span`,{className:`font-mono text-xs font-normal text-muted-foreground`,children:[`/h/`,e.id]})]}),(0,Q.jsx)(Ed,{state:e.state,className:`shrink-0`})]})},e.id))}),(0,Q.jsx)(`div`,{children:(0,Q.jsx)(Y,{asChild:!0,variant:`outline`,children:(0,Q.jsx)(`a`,{href:Me(null),"data-slot":`return-this-server`,children:`Open this server`})})})]}):(0,Q.jsx)(Y,{asChild:!0,variant:`primary`,children:(0,Q.jsx)(`a`,{href:Me(null),"data-slot":`return-this-server`,children:`Open this server`})})]})})}function Qb({hostId:e,children:t}){Vr();let n=Hr({enabled:e!==null,pollWhileOffline:!0}),r=(0,Z.useRef)(null),i=!!(e&&n.data?.hosts.some(t=>t.id===e));if((0,Z.useEffect)(()=>{i&&e?r.current=e:r.current===e?n.data&&!n.data.warning&&(r.current=null):r.current=null},[e,i,n.data]),e===null)return(0,Q.jsx)(Q.Fragment,{children:t});let a=ht.safeParse(e).success;if(n.isPending&&!n.data)return(0,Q.jsx)(`div`,{"data-route":`host-resolving`,className:`flex min-h-dvh flex-col bg-background text-foreground`,children:(0,Q.jsx)(`p`,{className:`px-4 py-6 text-center text-xs text-soft-foreground`,children:`Loading…`})});if(!a)return(0,Q.jsx)(`div`,{className:`grid min-h-dvh bg-background text-foreground`,children:(0,Q.jsx)(Zb,{hostId:e,hosts:n.data?.hosts??[],warning:n.data?.warning})});if(!n.data)return(0,Q.jsx)(`div`,{className:`grid min-h-dvh bg-background text-foreground`,children:(0,Q.jsx)(ds,{route:`host-lookup-error`,density:`empty`,flushPadding:!0,children:(0,Q.jsx)(tc,{icon:(0,Q.jsx)(wi,{size:16}),tone:`danger`,title:`Could not load saved hosts`,subtitle:`Could not reach this server to check saved hosts. Retry once the server is available.`,actions:(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center justify-center gap-2`,children:[(0,Q.jsx)(Y,{type:`button`,variant:`primary`,onClick:()=>void n.refetch(),children:`Retry`}),(0,Q.jsx)(Y,{asChild:!0,variant:`outline`,children:(0,Q.jsx)(`a`,{href:Me(null),"data-slot":`return-this-server`,children:`Open this server`})})]})})})});let o=!!n.data.warning&&r.current===e;return!i&&!o?(0,Q.jsx)(`div`,{className:`grid min-h-dvh bg-background text-foreground`,children:(0,Q.jsx)(Zb,{hostId:e,hosts:n.data.hosts,warning:n.data.warning})}):(0,Q.jsx)(Q.Fragment,{children:t})}function $b(){let e=qn(),t=A();return fm(),(0,Z.useEffect)(()=>{let n=Rp(e,t.data);n!==null&&(Bp(kp(),n)||Ap(n),Bp(Up(n.projectId),n)||Wp(n))},[e.hash,e.pathname,e.search,t.data]),null}function ex(e){return{enabled:(e&&typeof e==`object`?e:{}).enabled===!0}}function tx(){let e=globalThis.Notification;if(typeof e!=`function`)return`unsupported`;let t=e.permission;return t===`granted`||t===`denied`?t:`default`}function nx(e,t){let n=new Map,r=[];for(let i of t??[]){let t={status:i.status,wantsAttention:Jo(i)};n.set(i.id,t);let a=e.get(i.id);a!==void 0&&(a.status===t.status&&a.wantsAttention===t.wantsAttention||t.wantsAttention&&r.push(i))}return{entering:r,statuses:n}}function rx(e){return e.enabled&&e.hidden&&e.permission===`granted`}function ix(e){let t=qe(e).label;return{title:e.titleSummary??e.title,body:`Task ${t}`,tag:`cezar-run-${e.id}`}}function ax(){let e=U(),t=ex(ce().data?.notifications).enabled,n=(0,Z.useRef)(t);return n.current=t,(0,Z.useEffect)(()=>{let t=e.getQueryCache(),r=new Map,i=new Map,a=new Map,o=new Set,s=new Map,c=0,l=e=>e.length===3&&typeof e[0]==`string`&&e[1]===`runs`&&e[2]===`list`,u=()=>{let e=new Set([...r.values()].flatMap(e=>[...e.keys()]));for(let t of i.keys())e.has(t)||(i.delete(t),a.delete(t),o.delete(t))},d=(e,t,s=!1,l=1/0)=>{let d=r.get(e),{statuses:f}=nx(new Map,t),p=t.filter(e=>{if((a.get(e.id)??0)>l)return!1;let t=d?.get(e.id),n=f.get(e.id),r=l===1/0?t:i.get(e.id);return t!==void 0&&r!==void 0&&(r.status!==n.status||r.wantsAttention!==n.wantsAttention)}),{entering:m,statuses:h}=nx(i,p);for(let[e,t]of f)!d?.has(e)&&!o.has(e)&&(a.get(e)??0)<=l&&(i.set(e,t),a.set(e,++c));for(let[e,t]of h){let n=i.get(e);n?.status===t.status&&n.wantsAttention===t.wantsAttention||(i.set(e,t),a.set(e,++c),o.add(e))}if(r.set(e,f),u(),!s&&m.length!==0&&rx({enabled:n.current,hidden:document.visibilityState===`hidden`,permission:tx()}))for(let e of m)ox(e)};for(let e of t.getAll().sort((e,t)=>e.state.dataUpdatedAt-t.state.dataUpdatedAt))l(e.queryKey)&&Array.isArray(e.state.data)&&d(e.queryHash,e.state.data,!0);return t.subscribe(e=>{if(l(e.query.queryKey)){if(e.type===`removed`)r.delete(e.query.queryHash),s.delete(e.query.queryHash),u();else if(e.type===`updated`&&(e.action.type===`fetch`&&s.set(e.query.queryHash,c),e.action.type===`success`&&Array.isArray(e.query.state.data))){let t=e.action.manual?1/0:s.get(e.query.queryHash)??0;d(e.query.queryHash,e.query.state.data,!1,t),e.action.manual||s.delete(e.query.queryHash)}}})},[e]),null}function ox(e){let t=globalThis.Notification;if(typeof t!=`function`)return;let n=ix(e);try{new t(n.title,{body:n.body,tag:n.tag})}catch{}}function sx(){return(0,Q.jsx)(ss,{route:`activity`,density:`sparse`,rootProps:{"aria-busy":`true`},header:{title:`Activity`},children:(0,Q.jsx)(`p`,{"data-slot":`activity-loading`,role:`status`,className:`text-xs text-muted-foreground`,children:`Loading activity…`})})}function cx(){return(0,Q.jsx)(ls,{route:`github`,density:`sparse`,flushPadding:!0,children:(0,Q.jsx)(tc,{icon:(0,Q.jsx)(xa,{className:`motion-safe:animate-spin`}),tone:`neutral`,title:`Loading GitHub…`,subtitle:`Fetching open issues and pull requests.`})})}function lx({skill:e,emphasized:t}){return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`span`,{className:q(`shrink-0 font-mono text-xs`,t&&`font-semibold`),children:e.name}),e.description?(0,Q.jsx)(`span`,{title:e.description,className:`min-w-0 flex-[3] truncate text-xs text-soft-foreground`,children:e.description}):null,e.path?(0,Q.jsx)(`span`,{title:e.path,className:`min-w-0 truncate text-xs text-soft-foreground`,children:e.path}):null]})}var ux=80,dx=2e3,fx=50,px=200,mx=50,hx=[{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.`}];function gx(e){return!!e&&typeof e==`object`}function _x(e){if(e===void 0||!Array.isArray(e))return hx.map(e=>({...e}));let t=new Set,n=[];for(let r of e){if(!gx(r))continue;let e=typeof r.id==`string`?r.id.trim():``;if(e===`create-automation`)continue;let 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=vx(r.skills);if(n.push({id:e,label:i.slice(0,ux),text:a.slice(0,dx),...o.length>0?{skills:o}:{}}),n.length>=fx)break}return n}function vx(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,px)),t.size>=mx))break}return[...t]}function yx(e,t){if(t.length===0)return[];let n=new Set(t);return e.filter(e=>e.skills?.some(e=>n.has(e)))}function bx(e,t){return yx(e,t).map(e=>e.text).join(`
|
|
6
6
|
|
|
7
7
|
`)}function xx(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 Sx(){return`tpl-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}`}function Cx(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(`
|
|
8
8
|
|
|
@@ -17,5 +17,5 @@ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,n,r,t as i}from
|
|
|
17
17
|
`:`
|
|
18
18
|
|
|
19
19
|
`),{text:i+o+n+c+s,caret:i.length+o.length+n.length}}function wx({prompt:e,base:t,selectionStart:n,focused:r,remembered:i}){return e===t?e.length:r&&n!=null||n!=null&&n>0?n:i??e.length}var Tx=`(hover: none) and (pointer: coarse)`;function Ex(){return typeof globalThis.matchMedia==`function`&&globalThis.matchMedia(Tx).matches}function Dx(e){return e.key!==`Enter`||e.shiftKey||e.altKey||e.repeat||e.isComposing?!1:e.metaKey||e.ctrlKey?!0:!Ex()}function Ox(e){let{nativeEvent:t,...n}=e;return Dx({...n,isComposing:t.isComposing})&&(e.metaKey||e.ctrlKey)}function kx(e=typeof navigator>`u`?``:navigator.platform){return/mac|iphone|ipad|ipod/i.test(e)?`⌘↵`:`Ctrl+↵`}var Ax={png:`image/png`,jpg:`image/jpeg`,jpeg:`image/jpeg`,gif:`image/gif`,webp:`image/webp`,svg:`image/svg+xml`,bmp:`image/bmp`,avif:`image/avif`,md:`text/markdown`,markdown:`text/markdown`,txt:`text/plain`,log:`text/plain`,pdf:`application/pdf`};function jx(e){return Qe(e.type)?e.type:Co(Ax,e.name.split(`.`).pop()?.toLowerCase()??``)??null}async function Mx(e){let t=new Uint8Array(await e.arrayBuffer()),n=``;for(let e=0;e<t.length;e+=32768)n+=String.fromCharCode(...t.subarray(e,e+32768));let r=btoa(n),i=jx(e)??`application/octet-stream`,a=$t(i);return{mediaType:i,data:r,...a?{preview:`data:${i};base64,${r}`}:{},name:e.name||(a?`pasted image`:`pasted.${tt(i)}`),isImage:a}}function Nx(e,t){let n=[],r=[],i=t;for(let t of e){let e=t.name||`attachment`;if(jx(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}}var Px=new Set([`/`,`@`]);function Fx(e,t){for(let n=t-1;n>=0;--n){let r=e[n];if(/\s/.test(r))return null;if(Px.has(r))return n>0&&!/\s/.test(e[n-1])?null:{trigger:r,start:n,query:e.slice(n+1,t)}}return null}function Ix(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}}var Lx=`[data-slot="composer-submit-row"], [data-slot="composer-dictation"], [data-folded]`,Rx=`[role="menu"], [role="listbox"], [role="dialog"]`,zx=(0,Z.createContext)(!1);function Bx(){return(0,Z.useContext)(zx)}function Vx(e){return e.closest(Lx)!==null}function Hx(e,t){if(!(t instanceof Element))return!1;if(e.contains(t))return!0;let n=t.closest(Rx);return n===null||n.id===``?!1:[...e.querySelectorAll(`[aria-controls]`)].some(e=>e.getAttribute(`aria-controls`)?.split(` `).includes(n.id))}function Ux(e,t){let[n,r]=(0,Z.useState)(!1),i=(0,Z.useRef)(!1);return(0,Z.useEffect)(()=>{if(!e)return;let n=e=>t.current!==null&&Hx(t.current,e),a=e=>{i.current=n(e.target),i.current||r(!1)},o=e=>{n(e.target)?Vx(e.target)||r(!0):r(!1)},s=e=>{t.current?.contains(e.target)&&e.relatedTarget===null&&!i.current&&r(!1)},c=()=>{i.current=!1},l=e=>{c(),n(e.target)&&!Vx(e.target)&&r(!0)},u=document.activeElement;return n(u)&&!Vx(u)&&r(!0),document.addEventListener(`pointerdown`,a,!0),document.addEventListener(`focusin`,o,!0),document.addEventListener(`focusout`,s,!0),document.addEventListener(`click`,l,!0),document.addEventListener(`pointercancel`,c,!0),()=>{r(!1),document.removeEventListener(`pointerdown`,a,!0),document.removeEventListener(`focusin`,o,!0),document.removeEventListener(`focusout`,s,!0),document.removeEventListener(`click`,l,!0),document.removeEventListener(`pointercancel`,c,!0)}},[e,t]),e&&n}function Wx(){let e=window;return e.SpeechRecognition??e.webkitSpeechRecognition}function Gx(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 Kx(e,t){switch(e){case`aborted`:return null;case`network`:case`service-not-allowed`:return{message:`Dictation couldn't reach this browser's speech service. Some Chromium builds, such as Helium, block it. Use your system dictation instead (macOS: press Fn/Globe twice), or open the cockpit in Chrome or Safari.`,retryable:e===`network`};case`not-allowed`:return{message:`Microphone access is blocked. Allow it in this site's browser settings, then try again.`,retryable:!0};case`audio-capture`:return{message:`No microphone was found. Connect one, then try again.`,retryable:!0};case`language-not-supported`:return{message:`This browser can't recognize speech in ${t}. Use your system dictation instead (macOS: press Fn/Globe twice).`,retryable:!1};case`no-speech`:return{message:`No speech was heard. Check the microphone, then try again.`,retryable:!0};default:return{message:`Dictation failed${e?` — ${e}`:``}`,retryable:!0}}}function qx(e){let[t,n]=Z.useState(null),r=Z.useRef(null),i=Z.useRef(``),a=Z.useRef(!1),o=Z.useRef(()=>{}),[s]=Z.useState(()=>Wx()!==void 0),c=Z.useCallback(()=>{let e=r.current;r.current=null,i.current=``,n(null),e&&(e.onresult=null,e.onerror=null,e.onend=null,e.abort())},[]);Z.useEffect(()=>(a.current=!0,()=>{a.current=!1,c()}),[c]);let l=Z.useCallback(()=>o.current(),[]),u=Z.useCallback(()=>{if(!a.current||r.current)return;let t=Wx();if(!t)return;let o;try{o=new t,o.lang=navigator.language||`en-US`,o.continuous=!0,o.interimResults=!0;let a=Date.now();o.onresult=e=>{let t=Gx(i.current,e);i.current=t.finalText,n({transcript:t.finalText+t.interim,startedAt:a})},o.onerror=t=>{console.warn(`[dictation] recognition error`,t.error,t.message);let n=Kx(t.error,o.lang);c(),n&&e(n.message,n.retryable?l:void 0)},o.start(),r.current=o,n({transcript:``,startedAt:a})}catch{e(`Dictation failed — the microphone could not be started`,l),c()}},[e,l,c]);return o.current=u,{supported:s,recording:t,start:u,cancel:Z.useCallback(()=>c(),[c]),finish:Z.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 Jx(e,t){let n=Math.max(0,Math.floor((t-e)/1e3));return`${Math.floor(n/60)}:${String(n%60).padStart(2,`0`)}`}function Yx(e,t){return e.trim()!==``||t>0}function Xx(e,t,n,r){return!e&&(t!==void 0&&n||r)}function Zx(e,t,n){return!e&&!t&&n!==void 0}function Qx(e,t,n,r){return e||t||!n&&r!==void 0}function $x(e,t,n){return!e&&t?t:n}function eS(e,t,n){return e||t&&n}function tS(e,t,n){return e||t&&n}function nS(e,t,n,r,i,a){return e||t||n||i.trim()===``&&a===0&&!r}function rS(e,t,n,r){return e&&!t&&!n&&!r}function iS(e){return e instanceof Error?e.message:String(e)}function aS(e,t){return e===``?t:`${t}\n${e}`}function oS(e){return`${e||`Attachment`} could not be read — try attaching it again`}function sS(e){return[...e??[]].filter(e=>e.kind===`file`).map(e=>e.getAsFile()).filter(e=>e!==null)}function cS(e){return[...e??[]]}function lS(e,t){return e.trim()===``?t:`${e.replace(/\s*$/,``)} ${t}`}function uS(e,t,n,r,i){return e||t||n&&(r||i)}function dS(e,t,n){return!e||t||n}function fS(e,t,n){return(e+t+n)%n}function pS(e,t){return e??t}function mS(){return typeof CSS<`u`&&CSS.supports(`field-sizing`,`content`)}function hS(e,t){return e!==t}function gS(e){return e||void 0}function _S(e,t){return e&&!t||void 0}function vS(e,t,n){return e?t??``:n}function yS(e,t){return e?`${t}-submission`:void 0}function bS(e,t,n,r){return e||t||n!==null||r!=null}function xS(e,t,n){return e||!!t||n}function SS(e,t){return!!e||t}function CS(e,t){return!e&&!t}function wS(e,t){return e===`@`?`No files seen in this session yet — full file search arrives with the Files tab.`:t?`Loading skills…`:`No matching skills.`}function TS(e,t){return q(`shrink-0 truncate`,e&&`font-semibold`,t&&`font-mono text-xs`)}function ES(e,t,n){return q(e&&`new-task-composer`,t&&`session-composer`,n&&`opacity-80`)}function DS(e){return q(`rounded-xl border border-[var(--composer-border)] bg-card shadow-none transition-[border-color,box-shadow] focus-within:border-ring focus-within:ring-[3px] focus-within:ring-ring/15`,e&&`new-task-editor`)}function OS(e){return q(`group relative shrink-0 overflow-hidden rounded-md border border-border`,e?`size-12`:`flex h-12 min-w-11 max-w-[200px] items-center gap-1.5 bg-muted/40 px-2.5 text-xs text-muted-foreground`)}function kS(e){return q(`block field-sizing-content min-h-11 max-h-[220px] w-full overflow-y-auto resize-none bg-transparent px-3 pbs-2.5 pbe-1 text-base leading-normal outline-hidden placeholder:text-muted-foreground disabled:cursor-not-allowed md:min-h-[54px] md:px-4 md:pbs-3 md:text-sm`,e&&`md:text-base`)}function AS(e,t){return e?`Task description`:t}function jS(e){return e?`hidden px-5 pbs-5 text-xs text-muted-foreground md:block`:`sr-only`}function MS(e){return q(`ms-auto flex min-w-0 flex-wrap items-center justify-end gap-1 md:flex-nowrap`,e&&`new-task-submission`)}function NS(e){return q(`flex min-w-0 flex-wrap items-center gap-1.5 md:flex-nowrap`,e.executionOptions&&`me-auto`)}function PS(e,t){return e.executionOptions||e.sessionControls||!e.hasContent&&t?`default`:`icon`}function FS(e,t){return q(e.executionOptions?`w-full gap-2 px-6`:e.sessionControls&&`gap-2 px-5`,!e.hasContent&&t&&`px-3`,`active:opacity-80`)}function IS(e,t){return q(`overflow-y-auto text-xs leading-5 text-muted-foreground`,e&&!t?`h-0`:`px-3 pbe-2 md:px-4`,e?t&&`min-h-6`:`h-24 md:h-20`)}function LS(e){return q(`active:opacity-80`,e&&`px-3`)}function RS(e){return q(`flex min-w-0 flex-wrap items-center gap-2`,e&&`w-full`)}var zS=`shrink-0 rounded-[9px] border border-border p-0 text-muted-foreground`;function BS(e){return e.disabled||e.busy||e.stopPending||!e.hasContent&&!e.allowEmptySubmit}function VS(e,t){return!e.sessionControls&&!e.hasContent&&!!t}function HS(e,t){return e.executionOptions||e.sessionControls||!e.hasContent&&!!t}function US(e,t){return e.sessionControls||e.hasContent||!t}function WS(e){return e?`Finishing…`:`Finish`}function GS({mode:e,onStart:t}){return(0,Q.jsx)(Y,{type:`button`,variant:`ghost`,size:`icon`,disabled:e.disabled||e.readOnly,"aria-label":`Start dictation`,title:`Dictation`,className:zS,onClick:t,children:(0,Q.jsx)(oi,{"aria-hidden":`true`,className:`size-4`})})}function KS({mode:e,onFinish:t}){return(0,Q.jsxs)(Y,{type:`button`,"data-slot":`composer-finish`,"aria-label":e.finishLabel,"aria-busy":e.finishing||void 0,title:e.finishTitle,disabled:e.busy||e.stopPending||e.finishing,className:`w-auto gap-[7px] px-5 active:opacity-80`,onClick:t,children:[(0,Q.jsx)(Ni,{"aria-hidden":`true`}),e.finishLabel]})}function qS({mode:e,onStop:t}){return(0,Q.jsxs)(Y,{type:`button`,variant:`outline`,size:e.labelledStop?`default`:`icon`,"aria-label":e.stopPending?`Stopping…`:`Stop`,"aria-busy":e.stopPending||void 0,title:e.stopPending?`Waiting for execution to stop`:`Stop execution; keep existing work`,disabled:e.busy||e.stopPending,className:LS(e.labelledStop),onClick:t,children:[(0,Q.jsx)(Ai,{"aria-hidden":`true`,className:`size-3 fill-current`}),e.labelledStop?(0,Q.jsx)(`span`,{"data-slot":`composer-stop-label`,children:e.stopPending?`Stopping…`:`Stop`}):null]})}function JS({shown:e,compactFeedback:t,hasCompactFeedback:n,textareaId:r,submissionError:i,externalError:a,stopPending:o,busy:s,pendingLabel:c,failureHint:l,idleFeedback:u}){if(!e)return null;let d=a||null,f=i??d;return(0,Q.jsx)(`div`,{"data-slot":`composer-status`,className:IS(t,n),children:(0,Q.jsx)(`div`,{id:`${r}-submission`,role:f===null?`status`:`alert`,"aria-atomic":`true`,tabIndex:f===null?void 0:0,className:`break-words`,children:o?`Stopping execution. Your draft is kept.`:s?c:i===null?d===null?u??null:(0,Q.jsx)(`p`,{className:`font-medium text-foreground`,children:d}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`p`,{className:`font-medium text-foreground`,children:i}),(0,Q.jsx)(`p`,{children:l})]})})})}function YS({mode:e,emptySubmitLabel:t,emptySubmitVariant:n,optionsId:r,footerEnd:i,stopControl:a,secondaryAction:o,finishControl:s,onSubmit:c}){return(0,Q.jsxs)(`div`,{"data-slot":`composer-submit-row`,className:MS(e.executionOptions),children:[i?(0,Q.jsx)(`div`,{id:r,"data-slot":`composer-footer-end`,className:NS(e),children:(0,Q.jsx)(`div`,{className:`contents`,inert:gS(e.readOnly),children:i})}):null,(0,Q.jsxs)(`div`,{className:`flex min-w-[100px] items-center justify-end gap-1`,"data-slot":`composer-actions`,children:[a??o,s,CS(e.primaryStop,e.primaryFinish)?(0,Q.jsxs)(Y,{type:`button`,size:PS(e,t),variant:e.hasContent?`primary`:n??`primary`,"aria-label":e.submitLabel,"aria-busy":_S(e.busy,e.stopPending),disabled:BS(e),className:FS(e,t),onClick:c,children:[VS(e,t)?(0,Q.jsx)(Sa,{"aria-hidden":`true`}):null,HS(e,t)?e.submitLabel:null,US(e,t)?(0,Q.jsx)(bi,{"aria-hidden":`true`}):null]}):null]})]})}function XS({images:e,readOnly:t,onRemove:n}){return e.length===0?null:(0,Q.jsx)(`div`,{"data-slot":`composer-thumbs`,className:`flex flex-nowrap items-center gap-2 overflow-x-auto px-4 pbs-3 md:flex-wrap md:overflow-visible`,children:e.map((e,r)=>(0,Q.jsxs)(`button`,{type:`button`,"aria-label":`Remove ${e.name}`,title:t?`Attachment submitted`:`Click to remove`,disabled:t,className:OS(e.isImage),onClick:()=>n(r),children:[e.isImage?(0,Q.jsx)(`img`,{src:e.preview,alt:``,className:`size-full object-cover`}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(li,{"aria-hidden":`true`,className:`size-3.5 shrink-0`}),(0,Q.jsx)(`span`,{className:`truncate`,children:e.name})]}),(0,Q.jsx)(`span`,{className:`absolute inset-0 hidden items-center justify-center bg-background/70 group-hover:flex group-focus-visible:flex`,children:(0,Q.jsx)(Fi,{"aria-hidden":`true`,className:`size-4`})})]},`${e.name}-${r}`))})}function ZS({menuListRef:e,trigger:t,activeValue:n,skillsPending:r,candidates:i,onValueChange:a,onPick:o}){return(0,Q.jsx)(Ns,{shouldFilter:!1,value:n??``,onValueChange:a,children:(0,Q.jsx)(Ms,{ref:e,"data-slot":`composer-menu`,"data-trigger":t,className:`max-h-[min(16rem,var(--radix-popover-content-available-height))] p-1`,children:i.length===0?(0,Q.jsx)(`p`,{className:`px-3 py-4 text-center text-xs text-muted-foreground`,children:wS(t,r)}):i.map(e=>(0,Q.jsxs)(As,{value:e.value,"data-slot":`composer-menu-item`,"data-emphasized":e.emphasized||void 0,onSelect:()=>o(e),children:[(0,Q.jsx)(`span`,{className:TS(e.emphasized,t===`@`),children:e.label}),e.description?(0,Q.jsx)(`span`,{title:e.description,className:`min-w-0 flex-1 truncate text-xs text-soft-foreground`,children:e.description}):null]},e.value))})})}function QS({recording:e,insertionDisabled:t,onCancel:n,onInsert:r,onInsertAndSend:i,now:a}){return(0,Q.jsxs)(`div`,{"data-slot":`dictation-overlay`,role:`status`,"aria-label":`Dictation in progress`,className:`flex items-center gap-2.5 rounded-b-xl border-bs border-border bg-muted/60 px-3 py-2`,children:[(0,Q.jsx)(`span`,{"aria-hidden":`true`,className:`size-2 flex-none animate-pulse rounded-full bg-danger motion-reduce:animate-none`}),(0,Q.jsx)(`span`,{"data-slot":`dictation-timer`,className:`text-xs font-medium text-muted-foreground tabular-nums`,children:Jx(e.startedAt,a)}),(0,Q.jsx)(`span`,{"data-slot":`dictation-transcript`,"aria-live":`polite`,className:`min-w-0 flex-1 truncate text-sm text-foreground`,children:e.transcript===``?(0,Q.jsx)(`span`,{className:`text-muted-foreground`,children:`Listening…`}):e.transcript}),(0,Q.jsx)(Y,{type:`button`,variant:`ghost`,size:`icon-sm`,"aria-label":`Cancel dictation`,className:`text-muted-foreground`,onClick:n,children:(0,Q.jsx)(Fi,{"aria-hidden":`true`})}),(0,Q.jsx)(Y,{type:`button`,variant:`outline`,size:`icon-sm`,disabled:t,"aria-label":`Insert transcription`,onClick:r,children:(0,Q.jsx)(Ni,{"aria-hidden":`true`})}),(0,Q.jsx)(Y,{type:`button`,size:`icon-sm`,disabled:t,"aria-label":`Insert transcription and send`,onClick:i,children:(0,Q.jsx)(bi,{"aria-hidden":`true`})})]})}function $S(){return(0,Q.jsxs)(`p`,{"data-slot":`composer-skill-hint`,className:`flex items-center gap-2 px-5 pbs-3 pbe-2 text-xs text-muted-foreground`,children:[(0,Q.jsx)(Ri,{"aria-hidden":`true`,className:`size-[15px] shrink-0`}),`Type / for a skill or workflow`]})}function eC({disabled:e,onFiles:t,inputRef:n}){return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Y,{type:`button`,variant:`ghost`,size:`icon`,"aria-label":`Attach files`,title:`Attach an image, PDF, TXT or MD file (or paste a screenshot)`,disabled:e,className:zS,onClick:()=>n.current?.click(),children:(0,Q.jsx)(li,{"aria-hidden":`true`,className:`size-[15px]`})}),(0,Q.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 tC({mode:e,executionOptions:t,sessionControls:n,images:r,onRemoveImage:i,textareaId:a,textareaRef:o,text:s,disabled:c,retainDraftUntilSuccess:l,ariaLabel:u,disabledReason:d,placeholder:f,onTextChange:p,onKeyDown:m,onSelect:h,onPaste:g,recording:_,onCancelDictation:v,onInsertTranscript:y,onInsertAndSend:b,stopControl:x,footerStart:S,attachInputRef:C,addFiles:w,dictationButton:T,submissionControls:E,feedback:D,agentOptions:O}){return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(`div`,{"data-slot":`composer-editor`,className:DS(t),children:[(0,Q.jsx)(XS,{images:r,readOnly:e.readOnly,onRemove:i}),(0,Q.jsx)(`label`,{htmlFor:a,className:jS(t),children:AS(t,u)}),(0,Q.jsx)(`textarea`,{ref:o,id:a,autoComplete:`off`,rows:1,value:s,disabled:c,readOnly:e.readOnly,"aria-busy":e.readOnly||void 0,"aria-describedby":yS(l,a),"aria-label":u,placeholder:vS(c,d,f),className:kS(t),onChange:e=>p(e.target.value),onKeyDown:m,onSelect:h,onPaste:g}),t?(0,Q.jsx)($S,{}):null,n&&_?(0,Q.jsx)(`div`,{"data-slot":`session-controls`,inert:gS(e.readOnly),children:n}):null,_?(0,Q.jsx)(nC,{recording:_,mode:e,onCancel:v,onInsert:y,onInsertAndSend:b,stopControl:x}):(0,Q.jsx)(rC,{mode:e,sessionControls:n,executionOptions:t,footerStart:S,attachInputRef:C,addFiles:w,disabled:c,dictationButton:T,submissionControls:E}),t?null:D]}),t?(0,Q.jsx)(iC,{mode:e,agentOptions:O,executionOptions:t,submissionControls:E,feedback:D}):null]})}function nC({recording:e,mode:t,onCancel:n,onInsert:r,onInsertAndSend:i,stopControl:a}){let o=is(1e3);return(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(QS,{recording:e,insertionDisabled:t.readOnly,onCancel:n,onInsert:r,onInsertAndSend:i,now:o}),a?(0,Q.jsx)(`div`,{className:`flex justify-end px-2 pbe-2`,children:a}):null]})}function rC(e){return(0,Q.jsxs)(`div`,{"data-slot":`composer-toolbar`,className:`flex flex-wrap items-center gap-1 gap-y-1 px-1.5 pbs-1 pbe-1.5 md:gap-y-1.5 md:px-2 md:pbs-1.5 md:pbe-2`,children:[e.sessionControls?(0,Q.jsx)(`div`,{"data-slot":`session-controls`,inert:gS(e.mode.readOnly),children:e.sessionControls}):null,(0,Q.jsxs)(`div`,{"data-slot":`composer-footer-start`,className:RS(e.executionOptions),children:[(0,Q.jsx)(eC,{disabled:e.disabled||e.mode.readOnly,onFiles:e.addFiles,inputRef:e.attachInputRef}),e.dictationButton?(0,Q.jsx)(`div`,{"data-slot":`composer-dictation`,className:`contents`,children:e.dictationButton}):null,(0,Q.jsx)(`div`,{className:`contents`,inert:gS(e.mode.readOnly),children:e.footerStart})]}),e.executionOptions?null:e.submissionControls]})}function iC({mode:e,agentOptions:t,executionOptions:n,submissionControls:r,feedback:i}){return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`div`,{"data-slot":`composer-agent-options`,inert:gS(e.readOnly),children:t}),(0,Q.jsx)(`div`,{"data-slot":`composer-execution-panel`,inert:gS(e.readOnly),children:n}),r,(0,Q.jsx)(`div`,{"data-slot":`composer-feedback`,children:i})]})}function aC({open:e,onClose:t,rootRef:n,disabled:r,atRest:i,onDrop:a,className:o,children:s,menu:c}){return(0,Q.jsxs)(po,{open:e,onOpenChange:e=>e?void 0:t(),children:[(0,Q.jsx)(lo,{asChild:!0,children:(0,Q.jsx)(`div`,{ref:n,"data-slot":`composer`,"data-disabled":r||void 0,"data-rest":i||void 0,onDrop:a,onDragOver:e=>e.preventDefault(),className:o,children:s})}),(0,Q.jsx)(uo,{side:`top`,align:`start`,sideOffset:8,className:`w-80 max-w-[calc(100vw-2rem)] p-0`,onOpenAutoFocus:e=>e.preventDefault(),onInteractOutside:e=>{n.current?.contains(e.target)&&e.preventDefault()},children:c})]})}var oC={KeyA:`Yes, approved.`,KeyC:`Continue.`},sC={retainDraftUntilSuccess:!1,finishing:!1,stopOnEmpty:!1,stopping:!1,compactFeedback:!1,pendingLabel:`Starting task…`,failureHint:`Could not confirm submission. Check Tasks before you retry. Your draft is kept.`,clearOnSuccess:!0,autoFocus:!1,phoneRest:!1,sendAriaLabel:`Send`,disabled:!1,disabledReason:`Session closed — Continue to reopen.`,allowEmptySubmit:!1,placeholder:`Reply — / for skills, @ for files…`,ariaLabel:`Reply to the agent`,autocompleteSkills:!0,quickReplies:!1};function cC(e,t){return e===void 0?t:e}function lC(e,t,n,r){return t>0||n||!r&&e.trim()!==``}function uC(e){return{...e,retainDraftUntilSuccess:cC(e.retainDraftUntilSuccess,sC.retainDraftUntilSuccess),finishing:cC(e.finishing,sC.finishing),stopOnEmpty:cC(e.stopOnEmpty,sC.stopOnEmpty),stopping:cC(e.stopping,sC.stopping),compactFeedback:cC(e.compactFeedback,sC.compactFeedback),pendingLabel:cC(e.pendingLabel,sC.pendingLabel),failureHint:cC(e.failureHint,sC.failureHint),clearOnSuccess:cC(e.clearOnSuccess,sC.clearOnSuccess),autoFocus:cC(e.autoFocus,sC.autoFocus),phoneRest:cC(e.phoneRest,sC.phoneRest),sendAriaLabel:cC(e.sendAriaLabel,sC.sendAriaLabel),disabled:cC(e.disabled,sC.disabled),disabledReason:cC(e.disabledReason,sC.disabledReason),allowEmptySubmit:cC(e.allowEmptySubmit,sC.allowEmptySubmit),placeholder:cC(e.placeholder,sC.placeholder),ariaLabel:cC(e.ariaLabel,sC.ariaLabel),autocompleteSkills:cC(e.autocompleteSkills,sC.autocompleteSkills),quickReplies:cC(e.quickReplies,sC.quickReplies)}}function dC(e,t,n,r){if(e===null)return[];if(e.trigger===`/`){let r=new Set;return Hs(t,e.query,n).filter(e=>r.has(e.id)?!1:(r.add(e.id),!0)).map(e=>({value:e.id,insert:e.id,label:e.name,description:fC(e,t),emphasized:Vs(e)}))}return(r?.()??[]).filter(t=>Gs(t,e.query)).map(e=>({value:e,insert:e,label:e,emphasized:!1}))}function fC(e,t){let n=t.filter(t=>t.id===e.id);return[e.description,...n.map(e=>e.path),n.length>1?`Runner scope picks the copy. Use the task skill picker to choose a specific copy.`:void 0].filter(Boolean).join(` · `)}function pC(e,t){return e.some(e=>e.value===t)?t:e[0]?.value}function mC(e,t,n,r,i,a,o){!e||!t||!n||(r&&a(),i&&o())}function hC(e,t,n,r,i,a,o,s){if(e){a(n);return}H(n,{tone:`danger`}),t&&(o(e=>aS(e,r)),s(e=>[...i,...e].slice(0,4)))}function gC(e,t){let[n,r]=(0,Z.useState)(``),i=e??n,a=(0,Z.useRef)(i);a.current=i;let o=(0,Z.useRef)(t);return o.current=t,{text:i,textRef:a,setText:(0,Z.useCallback)(e=>{let t=typeof e==`function`?e(a.current):e;r(t),o.current?.(t)},[])}}function _C(e){let{onSubmit:t,retainDraftUntilSuccess:n,onStop:r,onFinish:i,finishing:a,secondaryAction:o,stopOnEmpty:s,stopping:c,emptySubmitLabel:l,emptySubmitVariant:u,compactFeedback:d,idleFeedback:f,externalError:p,onAttachmentsChange:m,pendingLabel:h,failureHint:g,clearOnSuccess:_,onPendingChange:v,value:y,onValueChange:b,autoFocus:x,phoneRest:S,footerStart:w,footerEnd:T,sessionControls:E,executionOptions:D,agentOptions:O,sendAriaLabel:k,disabled:A,disabledReason:j,allowEmptySubmit:M,placeholder:N,ariaLabel:ee,autocompleteSkills:P,skillRunner:F,skillAccount:I,quickReplies:L,getMentionCandidates:R,ref:te,draftPersisted:ne}=uC(e),{text:z,textRef:ie,setText:ae}=gC(y,b),[oe,B]=(0,Z.useState)([]),se=(0,Z.useRef)(oe);se.current=oe;let ce=(0,Z.useRef)(m);ce.current=m,(0,Z.useEffect)(()=>{ce.current?.(oe.length)},[oe.length]);let[le,ue]=(0,Z.useState)(!1),de=c||le,fe=(0,Z.useRef)(de);fe.current=de;let[pe,me]=(0,Z.useState)(!1),he=(0,Z.useRef)(!1),_e=(0,Z.useRef)(0),ve=(0,Z.useRef)(!0);(0,Z.useEffect)(()=>(ve.current=!0,()=>{ve.current=!1}),[]);let[ye,be]=(0,Z.useState)(null),xe=ye?.message??null,V=(0,Z.useCallback)((e,t=!1)=>{be(e===null?null:{message:e,clearOnHostRecovery:t})},[]);Et(()=>{be(e=>e?.clearOnHostRecovery?null:e)});let Se=()=>tS(fe.current,n,he.current),[Ce,we]=(0,Z.useState)(null),[Te,Ee]=(0,Z.useState)(``),[De,Oe]=(0,Z.useState)(!1),ke=(0,Z.useRef)(null),Ae=(0,Z.useId)(),je=(0,Z.useId)(),Me=(0,Z.useRef)(null),Ne=(0,Z.useRef)(null),Pe=Ux(S,Ne),Fe=(0,Z.useRef)(null),Ie=(0,Z.useRef)(null),Le=re(F,I,P&&De),Re=C(),ze=U(),Be=(0,Z.useRef)(A);Be.current=A;let Ve=qx((e,t)=>H(e,{tone:`danger`,...t?{action:{label:`Try again`,onAction:()=>{!Be.current&&!Se()&&t()}}}:{}}));(0,Z.useEffect)(()=>{x&&ke.current?.focus()},[]);let He=(0,Z.useCallback)(()=>{let e=ke.current;if(!e||A||Se()){we(null);return}let t=Fx(e.value,pS(e.selectionStart,e.value.length));if(t?.trigger===`/`&&!P||t?.trigger===`@`&&R===void 0)return we(null);t?.trigger===`/`&&Oe(!0),we(t)},[P,A,R,n]),Ue=(0,Z.useMemo)(()=>dC(Ce,Le.data??[],Re.data?.skillUsage,R),[R,Le.data,Ce,Re.data?.skillUsage]),We=pC(Ue,Te),Ge=Ce!==null;(0,Z.useLayoutEffect)(()=>{!Ge||!We||[...Fe.current?.querySelectorAll(`[data-slot="composer-menu-item"]`)??[]].find(e=>e.getAttribute(`data-value`)===We)?.scrollIntoView({block:`nearest`})},[We,Ge]);let Ke=(0,Z.useCallback)(()=>we(null),[]),qe=e=>{let t=ke.current;if(!t||Ce===null||Se())return;let n=pS(t.selectionStart,t.value.length),r=Ix(t.value,Ce,n,e.insert);Ce.trigger===`/`&&Re.data!==void 0&&St({skillUsage:Ks(Re.data.skillUsage,e.insert)}).then(()=>ze.invalidateQueries({queryKey:ge.uiState})).catch(()=>{}),ae(r.text),Ie.current=r.caret,we(null),t.focus()};(0,Z.useLayoutEffect)(()=>{let e=Ie.current,t=ke.current;e!==null&&t&&(t.setSelectionRange(e,e),Ie.current=null)},[z]),(0,Z.useLayoutEffect)(()=>{let e=ke.current;if(!e||mS())return;let t=()=>{e.style.height=`auto`,e.style.height=`${Math.min(e.scrollHeight,220)}px`};t();let n=e.clientWidth,r=typeof ResizeObserver>`u`?null:new ResizeObserver(()=>{hS(e.clientWidth,n)&&(n=e.clientWidth,t())});r?.observe(e);let i=!1;return document.fonts?.ready.then(()=>{i||t()}),()=>{i=!0,r?.disconnect()}},[z]);let Je=(0,Z.useCallback)(e=>{if(A||Se())return;let t=_e.current,r=Nx(e,se.current.length);for(let e of r.rejected)H(e,{tone:`danger`});for(let e of r.accepted)Mx(e).then(e=>{!ve.current||n&&he.current&&!fe.current||t!==_e.current||B(t=>t.length>=4?t:[...t,e])},()=>H(oS(e.name),{tone:`danger`}))},[A,n]),Ye=e=>{let t=cS(e.dataTransfer?.files);t.length!==0&&(e.preventDefault(),Je(t))},Xe=(0,Z.useCallback)((e,t)=>nS(A,c,he.current,M,e,t.length),[A,c,M]),Ze=(0,Z.useCallback)(async(e,r,i)=>{let a=e.trim();if(!Xe(e,r)){he.current=!0,n&&(_e.current+=1),me(!0),V(null),v?.(!0),we(null),i&&!n&&(ae(``),B([]));try{await t(a,r.map(({mediaType:e,data:t})=>({mediaType:e,data:t}))),mC(ve.current,n,_,ie.current===e,se.current===r,()=>ae(``),()=>B([]))}catch(t){if(!ve.current&&n)return;let a=Kt(t);hC(n,i,iS(t),e,r,e=>V(e,a),ae,B)}finally{he.current=!1,ve.current&&(v?.(!1),me(!1))}}},[Xe,t,n,_,v,V,ae]),Qe=(0,Z.useCallback)(()=>Xe(ie.current,se.current)?!1:(Ze(ie.current,se.current,!0),!0),[Xe,Ze]);(0,Z.useImperativeHandle)(te,()=>({insertAtCaret:e=>{if(Se())return;let t=ke.current,n=pS(t?.selectionStart??null,ie.current.length),r=Cx(ie.current,n,e);ae(r.text),Ie.current=r.caret,t?.focus()}}),[ae,n]);let $e=async()=>{if(!dS(r,c,he.current)){he.current=!0,me(!0),ue(!0),V(null);try{await r?.()}catch(e){ve.current&&V(iS(e),Kt(e))}finally{he.current=!1,ve.current&&(me(!1),ue(!1))}}},et=e=>{Ge&&tt(e)||Dx({key:e.key,shiftKey:e.shiftKey,metaKey:e.metaKey,ctrlKey:e.ctrlKey,altKey:e.altKey,repeat:e.repeat,isComposing:e.nativeEvent.isComposing})&&(e.preventDefault(),Qe())},tt=e=>{if(e.key===`ArrowDown`||e.key===`ArrowUp`){if(e.preventDefault(),Ue.length===0)return!0;let t=Ue.findIndex(e=>e.value===We),n=e.key===`ArrowDown`?1:-1,r=Ue[fS(t,n,Ue.length)];return Ee(r.value),!0}if(e.key===`Escape`)return e.preventDefault(),Ke(),!0;if((e.key===`Enter`||e.key===`Tab`)&&!e.shiftKey){let t=Ue.find(e=>e.value===We);if(t)return e.preventDefault(),qe(t),!0;Ke()}return!1};(0,Z.useEffect)(()=>{if(!L||A)return;let e=e=>{if(!e.altKey||e.metaKey||e.ctrlKey||e.repeat||xf(e.target))return;let t=oC[e.code];t!==void 0&&(e.preventDefault(),Ze(t,[],!1))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[A,L,Ze]);let nt=e=>{if(uS(A,fe.current,he.current,e,n))return;let t=Ve.finish();if(t===``)return;let r=lS(z,t);if(e){n&&ae(r),Ze(r,oe,!0);return}ae(r),Ie.current=r.length,ke.current?.focus()},rt=Yx(z,oe.length),it=Xx(rt,r,s,de),at=Zx(rt,it,i),ot={hasContent:rt,primaryStop:it,primaryFinish:at,labelledStop:Qx(it,at,rt,l),submitLabel:$x(rt,l,k),busy:pe,stopPending:de,finishing:a,finishLabel:WS(a),finishTitle:`Close the session and mark this task done`,disabled:A,allowEmptySubmit:M,readOnly:eS(de,n,pe),executionOptions:!!D,sessionControls:!!E,showStop:SS(r,de)},st=Ve.recording,ct=bS(de,pe,xe??(p||null),f),lt=rS(S&&!Pe,z!==``||oe.length>0,st!==null,ct);Jh(lC(z,oe.length,st!==null,ne===!0));let ut=Ve.supported?(0,Q.jsx)(GS,{mode:ot,onStart:()=>{Se()||Ve.start()}}):null,dt=ot.primaryFinish?(0,Q.jsx)(KS,{mode:ot,onFinish:()=>void i?.()}):null,ft=ot.showStop?(0,Q.jsx)(qS,{mode:ot,onStop:()=>void $e()}):null,pt=(0,Q.jsx)(JS,{shown:xS(n,r,c),compactFeedback:d,hasCompactFeedback:ct,textareaId:Ae,submissionError:xe,externalError:p,stopPending:de,busy:pe,pendingLabel:h,failureHint:g,idleFeedback:f}),mt=(0,Q.jsx)(YS,{mode:ot,emptySubmitLabel:l,emptySubmitVariant:u,optionsId:je,footerEnd:T,stopControl:ft,secondaryAction:o,finishControl:dt,onSubmit:Qe});return(0,Q.jsx)(zx,{value:lt,children:(0,Q.jsx)(aC,{open:Ge,onClose:Ke,rootRef:Ne,disabled:A,atRest:lt,onDrop:Ye,className:ES(D,E,A),menu:(0,Q.jsx)(ZS,{menuListRef:Fe,trigger:Ce?.trigger,activeValue:We,skillsPending:Le.isPending,candidates:Ue,onValueChange:Ee,onPick:qe}),children:(0,Q.jsx)(tC,{mode:ot,executionOptions:D,sessionControls:E,images:oe,onRemoveImage:e=>{Se()||B(t=>t.filter((t,n)=>n!==e))},textareaId:Ae,textareaRef:ke,text:z,disabled:A,retainDraftUntilSuccess:n,ariaLabel:ee,disabledReason:j,placeholder:N,onTextChange:e=>{Se()||(ae(e),He())},onKeyDown:et,onSelect:He,onPaste:e=>{let t=sS(e.clipboardData?.items);t.length!==0&&(e.preventDefault(),Je(t))},recording:st,onCancelDictation:Ve.cancel,onInsertTranscript:()=>nt(!1),onInsertAndSend:()=>nt(!0),stopControl:ft,footerStart:w,attachInputRef:Me,addFiles:Je,dictationButton:ut,submissionControls:mt,feedback:pt,agentOptions:O})})})}var vC=`inline-flex h-[26px] min-w-0 max-w-full items-center gap-1.5 rounded-full border border-control-border bg-card px-2.5 text-xs font-medium text-muted-foreground transition-colors focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-link-foreground hover:bg-muted hover:text-foreground disabled:pointer-events-none disabled:border-dashed disabled:bg-muted`,yC=(0,Q.jsx)(Ki,{"aria-hidden":`true`,className:`size-2.5 shrink-0 text-supporting-foreground`}),bC=(0,Z.createContext)(null),xC=e=>Number.parseFloat(e)||0;function SC({pill:e,box:t,full:n}){let r=getComputedStyle(e),i=[...e.children].filter(e=>{if(e===t)return!1;let n=getComputedStyle(e);return n.display!==`none`&&n.position!==`absolute`});return i.reduce((e,t)=>e+t.getBoundingClientRect().width,0)+xC(r.columnGap)*i.length+n.getBoundingClientRect().width+xC(r.paddingLeft)+xC(r.paddingRight)+xC(r.borderLeftWidth)+xC(r.borderRightWidth)}function CC(e){for(let t=e.parentElement;t;t=t.parentElement){if(t.dataset.slot===`picker-pill-disabled-wrapper`)continue;let e=getComputedStyle(t).display;if(e===`grid`||e===`flex`)return t}return e.parentElement}function wC(e,t){let n=new Map;for(let t of e){let e=CC(t.pill),r=n.get(e)??new Map,i=Math.round(t.pill.getBoundingClientRect().top);r.set(i,[...r.get(i)??[],t]),n.set(e,r)}for(let[e,r]of n){let n=getComputedStyle(e),i=e.clientWidth-xC(n.paddingLeft)-xC(n.paddingRight);for(let e of r.values()){let r=e.map(SC);if((e.length>1&&e.some(e=>e.pill.dataset.slot===t)?Math.max(...r)*e.length:r.reduce((e,t)=>e+t,0))+xC(n.columnGap)*(e.length-1)>i+.5)return!1}}return!0}function TC({children:e,fill:t}){let n=(0,Z.useRef)(new Map),r=(0,Z.useRef)(null),[i,a]=(0,Z.useState)(!0),o=(0,Z.useRef)(t),s=(0,Z.useCallback)(()=>a(wC([...n.current.values()],o.current)),[]),c=(0,Z.useCallback)((e,t)=>{if(n.current.set(e,t),typeof ResizeObserver<`u`){r.current??=new ResizeObserver(s);for(let e of[t.box,t.full,CC(t.pill)])r.current.observe(e)}return s(),()=>{if(n.current.delete(e),typeof ResizeObserver<`u`)for(let e of[t.box,t.full])r.current?.unobserve(e);s()}},[s]);(0,Z.useLayoutEffect)(()=>{o.current!==t&&(o.current=t,s())},[t,s]),(0,Z.useLayoutEffect)(()=>()=>r.current?.disconnect(),[]);let l=(0,Z.useMemo)(()=>({register:c,showPrefixes:i}),[c,i]);return(0,Q.jsx)(bC.Provider,{value:l,children:e})}function EC({field:e,children:t}){let n=(0,Z.useRef)(null),r=(0,Z.useRef)(null),i=(0,Z.useContext)(bC),a=i?.register,o=(0,Z.useId)(),[s,c]=(0,Z.useState)(!0);(0,Z.useLayoutEffect)(()=>{let e=n.current,t=r.current;if(a){let n=e.closest(`[data-slot$="pill"]`);return n?a(o,{pill:n,box:e,full:t}):void 0}let i=()=>c(t.getBoundingClientRect().width<=e.getBoundingClientRect().width+.5);if(i(),typeof ResizeObserver>`u`)return;let s=new ResizeObserver(i);return s.observe(e),s.observe(t),()=>s.disconnect()},[e,t,o,a]);let l=i!==null,u=l?i.showPrefixes:s,d=l&&!u;return(0,Q.jsxs)(`span`,{ref:n,className:`relative min-w-0 overflow-hidden`,"aria-hidden":`true`,children:[(0,Q.jsxs)(`span`,{ref:r,className:q(`invisible w-max whitespace-nowrap`,d?`absolute left-0 top-0`:`block`),children:[e,` · `,t]}),(0,Q.jsxs)(`span`,{"data-slot":`picker-label`,className:q(`block truncate`,d?`relative`:`absolute inset-0`),children:[u?(0,Q.jsxs)(`span`,{className:`text-muted-foreground`,children:[e,` · `]}):null,t]})]})}function DC({fieldLabel:e,ariaLabel:t,label:n,options:r,value:i}){return e?`${t} · ${typeof n==`string`?n:r.find(e=>e.value===i)?.label??i}`:t}function OC({readOnly:e,disabled:t,hint:n,disabledHint:r}){return e?r??n:t?r:n}function kC({fieldLabel:e,fullLabel:t,explanation:n}){return e?[t,n].filter(Boolean).join(` — `):n}function AC({icon:e,fieldLabel:t,ariaLabel:n,label:r}){return(0,Q.jsxs)(Q.Fragment,{children:[e,t?(0,Q.jsx)(EC,{field:n,children:r}):(0,Q.jsx)(`span`,{className:`min-w-0 truncate`,title:typeof r==`string`?r:void 0,children:r})]})}function jC({slot:e,ariaLabel:t,label:n,value:r,options:i,onPick:a,disabled:o=!1,choicesDisabled:s=!1,readOnly:c=!1,hint:l,disabledHint:u,status:d,searchPlaceholder:f,icon:p,fieldLabel:m=!1,footer:h,onOpenChange:g}){let[_,v]=(0,Z.useState)(!1),[y,b]=(0,Z.useState)(``),x=(0,Z.useRef)(null),S=(0,Z.useRef)(null),C=f?i.filter(e=>e.label.toLowerCase().includes(y.trim().toLowerCase())):i;(0,Z.useEffect)(()=>{if(!_||!f)return;let e=window.setTimeout(()=>x.current?.focus());return()=>window.clearTimeout(e)},[_,f]);let w=e=>{x.current&&document.activeElement===x.current&&e.preventDefault()},T=p?` h-9 touch:h-11 gap-2 rounded-lg border-border px-3 text-foreground`:``,E=DC({fieldLabel:m,ariaLabel:t,label:n,options:i,value:r}),D=kC({fieldLabel:m,fullLabel:E,explanation:OC({readOnly:c,disabled:o,hint:l,disabledHint:u})}),O=AC({icon:p,fieldLabel:m,ariaLabel:t,label:n});if(c)return(0,Q.jsxs)(`span`,{"data-slot":e,"aria-label":E,title:D,className:q(vC,T,`cursor-default hover:bg-card hover:text-muted-foreground`),children:[O,m?(0,Q.jsx)(`span`,{className:`sr-only`,children:E}):null]});let k=(0,Q.jsxs)(`button`,{type:`button`,"data-slot":e,"aria-label":E,disabled:o,title:D,className:q(vC,T),children:[O,p?(0,Q.jsx)(Ki,{"aria-hidden":`true`,className:`size-[13px] shrink-0 text-muted-foreground`}):yC]});return o?(0,Q.jsx)(`span`,{"data-slot":`picker-pill-disabled-wrapper`,title:D,className:`inline-flex min-w-0 max-w-full`,children:k}):(0,Q.jsxs)(oo,{open:_,onOpenChange:e=>{v(e),e||b(``),g?.(e)},children:[(0,Q.jsx)(ro,{asChild:!0,children:k}),(0,Q.jsxs)(io,{ref:S,align:`start`,"data-testid":`${e}-menu`,children:[f?(0,Q.jsxs)(`div`,{"data-slot":`picker-search`,className:`mbe-1 flex min-h-11 min-w-56 items-center gap-2 border-b border-border px-2`,children:[(0,Q.jsx)(mi,{"aria-hidden":`true`,className:`size-3.5 shrink-0 text-muted-foreground`}),(0,Q.jsx)(`input`,{ref:x,type:`search`,"aria-label":f,placeholder:f,value:y,onChange:e=>b(e.target.value),onKeyDown:e=>{if(e.key===`ArrowDown`||e.key===`ArrowUp`){e.preventDefault(),e.stopPropagation();let t=S.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-11 w-0 min-w-0 flex-1 bg-transparent text-sm placeholder:text-muted-foreground`})]}):null,(0,Q.jsx)(ao,{value:r,onValueChange:a,children:C.map(e=>(0,Q.jsx)(Za,{value:e.value,disabled:s,className:q(`gap-2.5`,f&&`min-h-11`),onPointerMove:w,onPointerLeave:w,onKeyDown:t=>{x.current&&(t.key===`ArrowUp`&&e===C[0]||t.key===`Tab`&&t.shiftKey)&&(t.preventDefault(),t.stopPropagation(),x.current.focus())},children:(0,Q.jsxs)(`span`,{className:`flex min-w-0 flex-col`,children:[(0,Q.jsx)(`span`,{className:`text-[13px] font-medium`,children:e.label}),e.desc?(0,Q.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e.desc}):null]})},e.value))}),f&&C.length===0?(0,Q.jsx)(`p`,{role:`status`,className:`px-2 py-5 text-center text-xs text-muted-foreground`,children:`No matches found.`}):null,d?(0,Q.jsx)(eo,{disabled:!0,onPointerMove:w,onPointerLeave:w,className:`border-t border-border text-xs text-muted-foreground`,children:d}):null,h]})]})}var MC=(e,t)=>t===null?e:`${e}:${t}`;function NC({runners:e,value:t,onPick:n,disabled:r=!1,accounts:i=[],account:a=null,repoAccount:o,icon:s,fieldLabel:c,uninstalled:l=[],signedOut:u=[]}){let d=L().data,f=me(d).filter(t=>e.includes(t.id)).flatMap(e=>{let t=i.filter(t=>t.provider===e.id),n=e.displayName;return t.length<2?[{value:MC(e.id,null),label:n,desc:e.pickerDescription}]:t.map(t=>({value:MC(e.id,t.id),label:`${n} · ${t.label}`,...t.configDir?{desc:t.configDir}:{}}))}),p=r&&(l.length>0||u.length>0),m=a??o?.[t]??`default`,h=f.some(e=>e.value===MC(t,m))?MC(t,m):MC(t,null);return(0,Q.jsx)(jC,{icon:s,fieldLabel:c,slot:`runner-pill`,ariaLabel:`Runner`,label:f.find(e=>e.value===h)?.label??ye(d,t),value:h,disabled:r&&!p,choicesDisabled:p,onPick:e=>{let[t,r]=e.split(`:`);n(t,r??null)},options:f,footer:(0,Q.jsx)(PC,{uninstalled:l,signedOut:u})})}function PC({uninstalled:e,signedOut:t}){let n=L().data,r=me(n).flatMap(n=>{let r=n.displayName;return e.includes(n.id)?[{id:n.id,name:r,state:`Not installed`,action:`Install in Settings`}]:t.includes(n.id)?[{id:n.id,name:r,state:`Not connected`,action:`Sign in in Settings`}]:[]});return r.length===0?null:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(to,{}),r.map(e=>(0,Q.jsx)(eo,{asChild:!0,className:`gap-2.5 ps-8`,children:(0,Q.jsx)(G,{to:$s(e.id),"data-slot":`runner-install-link`,"data-runner":e.id,children:(0,Q.jsxs)(`span`,{className:`flex min-w-0 flex-col`,children:[(0,Q.jsx)(`span`,{className:`text-[13px] font-medium text-muted-foreground`,children:e.name}),(0,Q.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[e.state,` · `,(0,Q.jsx)(`span`,{className:`font-medium text-accent-text`,children:e.action})]})]})})},e.id))]})}function FC({templates:e,onInsert:t,triggerClassName:n,disabled:r,iconOnly:i=!1,label:a=`Template`}){let[o,s]=(0,Z.useState)(!1),c=(0,Z.useRef)(null),l=To();return e.length===0?null:(0,Q.jsxs)(po,{open:o,onOpenChange:s,children:[(0,Q.jsx)(co,{asChild:!0,children:(0,Q.jsxs)(`button`,{type:`button`,"data-slot":`prompt-template-trigger`,"aria-label":`Insert a prompt template`,title:`Insert a prompt template`,disabled:r,className:q(`inline-flex h-[26px] items-center gap-1.5 rounded-full border border-border bg-card text-xs font-medium text-muted-foreground transition-colors hover:bg-muted hover:text-foreground disabled:pointer-events-none disabled:opacity-50`,i?`w-[26px] justify-center px-0`:`h-9 touch:h-11 gap-2 rounded-lg px-3 text-foreground`,n),children:[(0,Q.jsx)(ui,{"aria-hidden":`true`,className:i?`size-3 shrink-0 text-accent-icon`:`size-[18px] shrink-0 text-muted-foreground`}),i?null:(0,Q.jsxs)(Q.Fragment,{children:[a,(0,Q.jsx)(Ki,{"aria-hidden":`true`,className:`size-[13px] shrink-0 text-soft-foreground`})]})]})}),(0,Q.jsx)(uo,{align:`start`,sideOffset:8,"data-slot":`prompt-template-menu`,className:`w-[336px] max-w-[calc(100vw-2rem)] p-0`,onCloseAutoFocus:e=>e.preventDefault(),children:(0,Q.jsxs)(Ns,{filter:Ls,children:[(0,Q.jsx)(Ts,{placeholder:`search templates…`,onInput:()=>c.current?.scrollTo(0,0)}),(0,Q.jsxs)(Ms,{ref:c,"data-slot":`prompt-template-list-menu`,className:`max-h-[min(16rem,calc(var(--radix-popover-content-available-height)-3rem))]`,children:[(0,Q.jsx)(js,{children:`Nothing matches.`}),(0,Q.jsx)(Ds,{heading:`Insert a template`,children:e.map(e=>(0,Q.jsxs)(As,{value:`template ${e.label} ${e.id}`,keywords:[e.text,...e.skills??[]],"data-slot":`prompt-template-option`,"data-template":e.id,title:e.text,className:`flex-col items-start gap-0.5`,onSelect:()=>{t(e.text),s(!1)},children:[(0,Q.jsxs)(`span`,{className:`flex w-full items-center gap-1.5`,children:[(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[13px] font-medium text-foreground`,children:e.label}),e.skills&&e.skills.length>0?(0,Q.jsx)(`span`,{"data-slot":`prompt-template-assigned`,title:`Applied automatically with: ${e.skills.join(`, `)}`,className:`shrink-0 text-[12px] font-medium text-accent-text`,children:e.skills.length===1?`1 skill`:`${e.skills.length} skills`}):null]}),(0,Q.jsx)(`span`,{className:`line-clamp-1 text-xs text-soft-foreground`,children:e.text})]},e.id))}),(0,Q.jsx)(Es,{}),(0,Q.jsx)(Ds,{children:(0,Q.jsx)(As,{value:`edit prompt templates settings`,"data-slot":`prompt-template-settings`,className:`text-[12px] text-muted-foreground`,onSelect:()=>{s(!1),l(`/settings/prompt-templates`)},children:`Edit templates…`})})]})]})})]})}var IC={repo:`Project`,user:`User`,system:`Built in`,other:null};function LC(e){return[e.scope?IC[e.scope]:null,e.plugin?`Plugin ${e.plugin}`:null].filter(Boolean).join(` · `)||null}function RC({skill:e,heading:t=`h2`,actions:n}){let r=LC(e);return(0,Q.jsxs)(`div`,{"data-slot":`skill-detail`,className:`grid min-w-0 gap-3 break-words`,children:[t?(0,Q.jsx)(t,{className:`text-xl font-semibold`,children:e.name}):null,e.description?(0,Q.jsx)(`p`,{"data-slot":`skill-description`,className:`max-w-[78ch] text-[13.5px] leading-relaxed`,children:e.description}):(0,Q.jsx)(`p`,{className:`text-xs text-soft-foreground`,children:`This runner reports no description.`}),(0,Q.jsxs)(`dl`,{className:`grid grid-cols-[max-content_minmax(0,1fr)] items-center gap-x-4 gap-y-1.5 text-[12.5px]`,children:[(0,Q.jsx)(zC,{label:`Id`,children:(0,Q.jsx)(BC,{value:e.id,label:`Copy id`})}),r?(0,Q.jsx)(zC,{label:`Source`,children:(0,Q.jsx)(`span`,{"data-slot":`skill-source`,children:r})}):null,e.path?(0,Q.jsx)(zC,{label:`File`,children:(0,Q.jsx)(BC,{value:e.path,label:`Copy path`,slot:`skill-path`})}):null]}),n?(0,Q.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:n}):null]})}function zC({label:e,children:t}){return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`dt`,{className:`text-soft-foreground`,children:e}),(0,Q.jsx)(`dd`,{className:`flex min-w-0 items-center gap-1`,children:t})]})}function BC({value:e,label:t,slot:n}){let r=()=>Promise.resolve().then(()=>navigator.clipboard.writeText(e)).then(()=>H(`Copied.`),e=>H(e instanceof Error?e.message:String(e),{tone:`danger`}));return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`code`,{"data-slot":n,title:e,className:`min-w-0 truncate rounded-sm border border-border bg-background px-1.5 py-px font-mono text-xs`,children:e}),(0,Q.jsx)(`button`,{type:`button`,"aria-label":t,onClick:()=>void r(),className:`inline-flex size-7 shrink-0 items-center justify-center rounded-sm text-soft-foreground focus-visible:outline-2 pointer-hover:bg-muted pointer-hover:text-foreground`,children:(0,Q.jsx)(Yi,{"aria-hidden":`true`,className:`size-3.5`})})]})}function VC({skill:e,onClose:t}){return(0,Q.jsx)(So,{open:e!==null,onOpenChange:e=>{e||t()},children:(0,Q.jsx)(bo,{"data-slot":`skill-preview`,className:`max-h-[80dvh] overflow-y-auto`,children:e?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(xo,{className:`sr-only`,children:e.name}),(0,Q.jsx)(_o,{className:`sr-only`,children:`Runner skill metadata`}),(0,Q.jsx)(RC,{skill:e,heading:`h3`})]}):null})})}function HC(e){try{let t=new URL(e),n=t.pathname===`/`?``:t.pathname.replace(/\/$/,``);return`${t.host}${n}`||e}catch{return e}}function UC(e){return e?e.webhooks?e.webhooks.filter(e=>e.tasks).map(({id:e,name:t,url:n})=>({id:e,name:t,url:n})):e.webhook?[{id:`task-webhook`,name:`Task webhook`,url:e.webhook.url}]:[]:[]}function WC(e){let t=e.map(e=>e.name);return t.length<=2?t.join(` and `):t.length===3?`${t[0]}, ${t[1]} and ${t[2]}`:`${t[0]}, ${t[1]} and ${t.length-2} more`}function GC(e,t){return e===``?{message:`Prefilled from link — review and press Start`,tone:`default`}:{message:t?`Unknown skill "${e}" — prefilled for quick-task; review and press Start`:`Unknown skill "${e}" — no skill selected; review before starting`,tone:`danger`}}function KC(e,t){return`Use the "${e}" skill on: ${t}`}function qC(e){let t=e.configuredAutonomous===`source-dependent`?e.source===`skill`:e.configuredAutonomous;return{autonomous:e.planFirst?!1:e.explicitAutonomous??t,worktree:e.hasGit?e.explicitWorktree??e.configuredWorktree:!1}}function JC(e){return e.worktree?`Runs in an isolated worktree — review everything before it lands.`:e.hasGit?`Runs in the repo working tree — your checkout is modified directly.`:`Runs in place — no git repository detected, so there is no worktree to isolate in.`}var YC={text:``,source:null,runner:null,agentProfile:null,model:null,effort:null,planFirst:!1,worktree:null,autonomous:null,archiveWhenDone:!1,autoMergePr:!1,allowWorkers:!0,allowMessaging:!0},XC=`cez-new-task-draft`,ZC=`cez-new-task-handoff`,QC=new Set;function $C(e,t){return ei(e,`${ZC}:${t}`)}function ew(e,t){QC.add($C(e,t))}function tw(e,t){return QC.has($C(e,t))}function nw(e){if(!e)return null;try{let t=JSON.parse(e);return!t||typeof t!=`object`||typeof t.text!=`string`||t.text.trim()===``||t.rootProjectId!==null&&typeof t.rootProjectId!=`string`||t.rootUrlProjectId!==null&&typeof t.rootUrlProjectId!=`string`?null:{text:t.text,rootProjectId:t.rootProjectId,rootUrlProjectId:t.rootUrlProjectId}}catch{return null}}function rw(e,t){let n=e!==null&&t!==void 0?$C(e,t):null;for(let e of QC)e!==n&&QC.delete(e);try{for(let e of Object.keys(sessionStorage))e!==n&&$r(e,ZC,!0)&&sessionStorage.removeItem(e)}catch{}}function iw(e,t,n){rw(e,t);let r=$C(e,t);QC.delete(r);try{sessionStorage.setItem(r,JSON.stringify(n));let e=nw(sessionStorage.getItem(r));return e!==null&&e.text===n.text&&e.rootProjectId===n.rootProjectId&&e.rootUrlProjectId===n.rootUrlProjectId?!0:(sessionStorage.removeItem(r),!1)}catch{try{sessionStorage.removeItem(r)}catch{}return!1}}function aw(e,t){try{return nw(sessionStorage.getItem($C(e,t)))}catch{return null}}function ow(e,t){let n=$C(e,t);QC.delete(n);try{sessionStorage.removeItem(n)}catch{}}function sw(e,t){let n=ei(null,e===null?XC:`${XC}:${e}`);try{let e=localStorage.getItem(n);if(!e)return;let r=lw(JSON.parse(e));if(r.text!==t)return;let i={...r,text:``};localStorage.setItem(n,JSON.stringify(i)),dw.has(n)&&dw.set(n,i)}catch{}}function cw(e){return Qr(e===null?XC:`${XC}:${e}`)}function lw(e){let t=e&&typeof e==`object`?e:{};return{text:typeof t.text==`string`?t.text:``,source:uw(t.source)?t.source:null,runner:typeof t.runner==`string`?t.runner:null,agentProfile:typeof t.agentProfile==`string`?t.agentProfile:null,model:typeof t.model==`string`?t.model:null,effort:typeof t.effort==`string`?t.effort:null,planFirst:t.planFirst===!0,worktree:typeof t.worktree==`boolean`?t.worktree:null,autonomous:typeof t.autonomous==`boolean`?t.autonomous:null,archiveWhenDone:t.archiveWhenDone===!0,autoMergePr:t.autoMergePr===!0,allowWorkers:t.allowWorkers!==!1,allowMessaging:t.allowMessaging!==!1}}function uw(e){return!!e&&typeof e==`object`&&(e.source===`skill`||e.source===`workflow`)&&typeof e.ref==`string`}var dw=new Map,fw=new Map,pw=new Map;function mw(e=null){return fw.get(cw(e))??0}function hw(e){try{let t=localStorage.getItem(e);return t?lw(JSON.parse(t)):{...YC}}catch{return{...YC}}}function gw(e=null){let t=cw(e),n=dw.get(t);if(n)return{...n};let r=hw(t);return dw.set(t,r),{...r}}function _w(e=null){let t=cw(e),n=dw.get(t);if(n&&pw.get(t)===!1)return{...n};let r=hw(t);return dw.set(t,r),{...r}}function vw(e,t=null){let n=cw(t);fw.set(n,mw(t)+1),dw.set(n,{...e});try{localStorage.setItem(n,JSON.stringify(e)),pw.set(n,!0)}catch{pw.set(n,!1)}}function yw(e,t=null){let n=cw(t);try{localStorage.setItem(n,JSON.stringify(e))}catch{return pw.set(n,!1),!1}return fw.set(n,mw(t)+1),dw.set(n,{...e}),pw.set(n,!0),!0}function bw(e=null){return pw.get(cw(e))??!1}function xw(e=null,t){t!==void 0&&mw(e)!==t||vw({...gw(e),text:``,source:null},e)}var Sw={connected:[],unavailable:[],visible:!1},Cw=e=>{window.location.assign(e)},ww=e=>{window.history.length>1?window.history.back():window.location.assign(e)};function Tw(e){Cw(e)}function Ew(e){ww(e)}function Dw(e,t){return`${encodeURIComponent(e)}:${encodeURIComponent(t)}`}function Ow(e,t){let n=e?.repoIdentity;if(!n||t.length===0)return Sw;let r=[],i=[];for(let e of rt(t)){if(e.state!==`connected`){i.push(e);continue}if(e.projects===null)continue;let t=e.projects.filter(e=>e.status!==`missing`&&e.repoIdentity===n);if(t.length===0)continue;let a=new Map;for(let e of t)a.set(e.name,(a.get(e.name)??0)+1);for(let n of t)r.push({value:Dw(e.id,n.id),hostId:e.id,hostLabel:e.label,project:n,multipleOnHost:t.length>1,duplicateNameOnHost:(a.get(n.name)??0)>1})}return r.length===0?Sw:{connected:r,unavailable:i,visible:!0}}function kw(e){if(e)return e.branch?`${e.name} · ${e.branch}`:e.name}function Aw(e){return e.multipleOnHost?e.duplicateNameOnHost?e.project.branch?`${e.project.id} · ${e.project.branch}`:e.project.id:e.project.branch:kw(e.project)}function jw(e){let t=Pe(),{savedHosts:n,mainHostsProjects:r}=Jr(t),[i,a]=(0,Z.useState)(null),[o,s]=(0,Z.useState)(null),c=(0,Z.useCallback)(()=>s(null),[]),l=e.urlProjectId??e.bootProject??r.data?.local.bootProject??void 0,u=e.localProjects.length>0?e.localProjects:r.data?.local.projects??[],d=(0,Z.useMemo)(()=>l?u.find(e=>e.id===l):void 0,[l,u]),f=(0,Z.useMemo)(()=>t?Sw:Ow(d,n),[t,d,n]),p=(0,Z.useRef)(e.draftText);p.current=e.draftText;let m=(0,Z.useRef)(f);m.current=f;let{draftProjectId:h,urlProjectId:g,submissionPending:_}=e,v=(0,Z.useCallback)(e=>{if(_.current)return;s(null);let t=p.current;if(t.trim()!==``&&!(yw({...gw(h),text:t},h)&&iw(e.hostId,e.project.id,{text:t,rootProjectId:h,rootUrlProjectId:g??null}))){s(`Could not move your draft to ${e.hostLabel} — browser storage is unavailable or full. Your draft was kept here.`);return}Tw(Ve(e.hostId,e.project.id))},[h,_,g]);return{currentProject:d,targets:f,pendingLeaveBehind:i,moveError:o,clearMoveError:c,selectHost:(0,Z.useCallback)(t=>{if(!_.current){if(e.attachmentCount>0||e.draftSource!==null){a({hostId:t.hostId,hostLabel:t.hostLabel,projectId:t.project.id,projectName:t.project.name});return}v(t)}},[v,e.attachmentCount,e.draftSource,_]),confirmLeaveBehind:(0,Z.useCallback)(()=>{if(!i)return;let e=i;if(a(null),_.current)return;let t=m.current.connected.find(t=>t.hostId===e.hostId&&t.project.id===e.projectId);if(!t){s(`Could not open ${e.hostLabel} — the host is no longer connected or no longer has a matching project.`);return}v(t)},[v,i,_]),cancelLeaveBehind:(0,Z.useCallback)(()=>{a(null)},[])}}function Mw({hosts:e}){return e.length===0?null:(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(to,{}),e.map(e=>(0,Q.jsxs)(eo,{disabled:!0,"data-slot":`run-on-host-unavailable`,"data-host-id":e.id,"data-host-state":e.state,className:`justify-between gap-2.5 ps-8 data-[disabled]:opacity-100`,children:[(0,Q.jsx)(`span`,{className:`min-w-0 truncate text-[13px] font-medium text-muted-foreground`,children:e.label}),(0,Q.jsx)(Ed,{state:e.state,className:`shrink-0`})]},e.id))]})}function Nw({targets:e,currentProject:t,disabled:n=!1,onSelectHost:r}){let[i,a]=(0,Z.useState)(!1);if(!e.visible&&!i)return null;let o=kw(t),s=[{value:`local`,label:`This server`,...o?{desc:o}:{}},...e.connected.map(e=>{let t=Aw(e);return{value:e.value,label:e.multipleOnHost?`${e.hostLabel} · ${e.project.name}`:e.hostLabel,...t?{desc:t}:{}}})];return(0,Q.jsx)(jC,{icon:(0,Q.jsx)(Ta,{"aria-hidden":`true`,className:`size-[18px] shrink-0 text-accent-text`}),fieldLabel:!0,slot:`run-on-pill`,ariaLabel:`Run on`,label:`This server`,value:`local`,disabled:n,options:s,onOpenChange:a,onPick:t=>{if(t===`local`)return;let n=e.connected.find(e=>e.value===t);n&&r(n)},footer:(0,Q.jsx)(Mw,{hosts:e.unavailable})})}function Pw(e,t,n){let r=t===1?`1 attached file does`:`${t} attached files do`;return t>0&&n!==null?`Only the text moves. ${r} not move and the chosen ${n.source} stays here; attach the files and choose the ${n.source} again on ${e}.`:t>0?`Only the text moves. ${r} not move and must be attached again on ${e}.`:`Only the text moves. The chosen ${n?.source??`skill or workflow`} stays here; choose it again on ${e}.`}function Fw({pending:e,draftText:t,attachmentCount:n,draftSource:r,onCancel:i,onConfirm:a}){if(!e)return null;let o=t.trim()!==``;return(0,Q.jsx)(Pv,{open:!0,onOpenChange:e=>{e||i()},children:(0,Q.jsxs)(Lv,{"data-slot":`run-on-leave-behind-dialog`,children:[(0,Q.jsxs)(Rv,{children:[(0,Q.jsx)(Bv,{children:o?`Move draft text to ${e.hostLabel}?`:`Open ${e.hostLabel}?`}),(0,Q.jsx)(Vv,{asChild:!0,children:(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2.5 text-sm text-muted-foreground`,children:[(0,Q.jsx)(`p`,{children:o?`Your draft text will move to ${e.hostLabel} (${e.projectName}).`:`Opening ${e.hostLabel} (${e.projectName}).`}),(0,Q.jsx)(`p`,{children:Pw(e.hostLabel,n,r)})]})})]}),(0,Q.jsxs)(zv,{children:[(0,Q.jsx)(Uv,{"data-slot":`run-on-cancel`,children:`Cancel`}),(0,Q.jsx)(Hv,{"data-slot":`run-on-move`,onClick:e=>{e.preventDefault(),a()},children:o?`Move draft`:`Open ${e.hostLabel}`})]})]})})}function Iw({pending:e,draftProjectId:t,projects:n,onCancel:r,onConfirm:i}){let a=Hr({enabled:e!==null});if(!e)return null;let o=a.data?.hosts.find(t=>t.id===e.hostId)?.label??$e(e.hostId),s=n.find(t=>t.id===e.projectId)?.name??e.projectId,c=_w(t).text;return(0,Q.jsx)(Pv,{open:!0,onOpenChange:e=>{e||r()},children:(0,Q.jsxs)(Lv,{"data-slot":`run-on-arrival-dialog`,children:[(0,Q.jsxs)(Rv,{children:[(0,Q.jsx)(Bv,{children:`Move draft to ${o}?`}),(0,Q.jsx)(Vv,{asChild:!0,children:(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2.5 text-sm text-muted-foreground`,children:[(0,Q.jsxs)(`p`,{children:[(0,Q.jsx)(`span`,{className:`font-medium text-foreground`,children:o}),` already has an unsent draft for `,(0,Q.jsx)(`span`,{className:`font-medium text-foreground`,children:s}),`.`]}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Q.jsx)(`p`,{className:`text-xs font-medium text-foreground`,children:`Draft on ${o}`}),(0,Q.jsx)(`blockquote`,{"data-slot":`run-on-existing-draft`,className:`max-h-24 overflow-y-auto rounded-md border border-border bg-muted/50 px-3 py-2 text-xs whitespace-pre-wrap break-words text-foreground`,children:c})]}),(0,Q.jsx)(`p`,{children:`Append keeps the host draft and its chosen skill or workflow. Replace replaces the draft text and clears its skill or workflow.`})]})})]}),(0,Q.jsxs)(zv,{children:[(0,Q.jsx)(Uv,{"data-slot":`run-on-cancel`,children:`Cancel`}),(0,Q.jsx)(Y,{type:`button`,variant:`outline`,"data-slot":`run-on-replace`,onClick:()=>i(`replace`),children:`Replace`}),(0,Q.jsx)(Hv,{"data-slot":`run-on-append`,onClick:e=>{e.preventDefault(),i(`append`)},children:`Append`})]})]})})}var Lw=`Runner default`,Rw=`quick-task`;function zw(e,t,n=24){return[t,...(e??[]).filter(e=>!(e.source===t.source&&e.ref===t.ref))].slice(0,n)}function Bw(e,t){return B(e,t)?.models.suggested}var Vw=[{value:``,label:Lw,desc:`Harness default`},{value:`low`,label:`low`,desc:`Less reasoning, faster replies`},{value:`medium`,label:`medium`,desc:`Balanced reasoning`},{value:`high`,label:`high`,desc:`More reasoning for hard tasks`},{value:`xhigh`,label:`xhigh`,desc:`Extra-high reasoning`},{value:`max`,label:`max`,desc:`Maximum reasoning`}];function Hw(e,t){let n=Vw,r=t?.models.find(t=>t.id===e)?.effortLevels;if(r===void 0)return n;let i=[Vw[0]],a=new Set;for(let e of r){if(a.has(e))continue;let t=Vw.find(t=>t.value===e);t&&(a.add(e),i.push(t))}return i}function Uw(e,t){let n=e??``;return t.some(e=>e.value===n)?n:``}function Ww(e,t,n){if(!e||Bw(n,t)?.some(t=>t.id===e))return!1;let r=(n?.runners??[]).filter(e=>e.id!==t);return r.some(t=>t.models.retired.includes(e))?!0:r.some(t=>t.modelIdScope!==`provider-spanning`&&t.models.suggested.some(t=>t.id!==``&&t.id===e))}function Gw(e,t,n,r=[]){let i=n?.runner===e?n.models:[],a=Bw(t,e)??Bw(t,`claude`)??[],o=(i.length?a.slice(0,1):a).map(e=>e.id===``?{...e,label:Lw}:e),s=new Set(o.map(e=>e.id));for(let e of i)!e.id||s.has(e.id)||(s.add(e.id),o.push({id:e.id,label:e.label||e.id,desc:e.description}));for(let n of r)!n||s.has(n)||Ww(n,e,t)||(s.add(n),o.push({id:n,label:n,desc:`Custom or legacy model`}));return o}function Kw(e,t,n,r=!1,i=!1){let a=F(t,e);if(a!==void 0){if(n?.stale)return`Using cached ${a} model list`;if(r||n?.source===`unavailable`){let e=n?.reason?.trim();return`${e?`Latest ${a} models unavailable: ${/[.!?]$/.test(e)?e:`${e}.`}`:`Latest ${a} models unavailable.`} Check ${a} status and sign-in in Settings → Agents.`}if(i&&!n)return`Loading ${a} models…`}}var qw=`__catalog-status`;function Jw(e,t,n){return Kw(e,t,n?.data,n?.isError,n?.isFetching)}function Yw(e,t){let n=oe(t).filter(t=>e.some(e=>e.name===t&&e.available));return n.length>0?n:[`claude`]}function Xw(e,t,n){return e!==null&&t.includes(e)?e:t.includes(n)?n:t[0]??`claude`}function Zw(e,t,n=!1){return!n&&e===t?void 0:e}function Qw(e,t,n,r,i){let a=Gw(t,n,i,[e,r?.[t]]);if(e!==null&&a.some(t=>t.id===e))return e;let o=r?.[t];return o!==void 0&&a.some(e=>e.id===o)?o:``}function $w(e,t,n){return e.source===`skill`?t.some(t=>t.id===e.ref&&(e.path===void 0||t.path===e.path)):n.some(t=>t.name===e.ref)}function eT(e,t,n,r=!1){return e?.source===`skill`&&(r||e.typed)||e&&$w(e,t,n)?e:null}function tT(e){let{task:t,source:n,model:r,modelsLocked:i,effort:a,runner:o,runnerExplicit:s,defaultRunner:c,agentProfile:l,images:u,worktree:d,autonomous:f,archiveWhenDone:p,autoMergePr:m,allowWorkers:h,allowMessaging:g}=e;return{task:t,...n?.source===`skill`?{steps:[{id:`task`,name:n.ref,skill:n.ref,...n.path===void 0?{}:{skillPath:n.path},prompt:`{{task}}`}]}:{workflow:n?.ref??`quick-task`},model:i?void 0:r||void 0,effort:i?void 0:a||void 0,runner:Zw(o,c,s),agentProfile:l||void 0,images:u.length>0?[...u]:void 0,worktree:d!==!1&&void 0,autonomous:f===!0||void 0,...nT({archiveWhenDone:p,autoMergePr:m,allowWorkers:h,allowMessaging:g})}}function nT(e){return{...e.archiveWhenDone?{archiveWhenDone:!0}:{},...e.autoMergePr?{autoMergePr:!0}:{},...e.allowWorkers===!1?{allowWorkers:!1}:{},...e.allowMessaging===!1?{allowMessaging:!1}:{}}}function rT(e,t){return t?{...e,notify:!0}:e}function iT(e){return`/tasks/${e.id}`}function aT(e,t,n){return{task:e,steps:[...n.steps],rationale:n.rationale,fallback:n.fallback,images:[...t]}}function oT(e,t){return!Number.isInteger(t)||t<0||t>=e.length?[...e]:e.filter((e,n)=>n!==t)}function sT(e,t,n){let r=[...e];if(!Number.isInteger(t)||t<0||t>=r.length)return r;let i=Math.max(0,Math.min(r.length-1,n));if(i===t)return r;let[a]=r.splice(t,1);return r.splice(i,0,a),r}function cT(e){return e.command??e.prompt??``}function lT(e,t=120){let n=e.split(`
|
|
20
|
-
`)[0]??``;return n.length>t?`${n.slice(0,t-1)}…`:n}function uT(e){let{task:t,steps:n,agentProfile:r,model:i,modelsLocked:a,effort:o,runner:s,runnerExplicit:c,defaultRunner:l,images:u,archiveWhenDone:d,autoMergePr:f,allowWorkers:p,allowMessaging:m}=e;return{task:t,steps:[...n],...r?{agentProfile:r}:{},model:a?void 0:i||void 0,effort:a?void 0:o||void 0,runner:Zw(s,l,c),images:u.length>0?[...u]:void 0,...nT({archiveWhenDone:d,autoMergePr:f,allowWorkers:p,allowMessaging:m})}}function dT(e,t,n){return{runner:e,agentProfile:t||null,...e===n?{}:{model:null,effort:null}}}var fT=`Could not save the moved draft in browser storage. Your draft is still kept on the main server.`;function pT(e,t,n){if(n===`append`){let n=e.text.trim()===``?t.text:`${e.text}\n\n${t.text}`;return{...e,text:n}}return{...e,text:t.text,source:null}}function mT(e){ow(e.hostId,e.projectId),sw(e.handoff.rootProjectId,e.handoff.text)}function hT(e){e!==null&&ow(e.hostId,e.projectId)}function gT(e,t,n){let r=Be(),i=r!==null&&t!==void 0?aw(r,t):null;if(!i||r===null||t===void 0)return{base:gw(e),autoTake:null,claimedArrival:null,pendingArrival:null,discardArrival:null};let a={hostId:r,projectId:t,handoff:i};if(n)return{base:gw(e),autoTake:null,claimedArrival:null,pendingArrival:null,discardArrival:a};if(tw(a.hostId,a.projectId))return{base:gw(e),autoTake:null,claimedArrival:a,pendingArrival:null,discardArrival:null};let o=_w(e);return o.text.trim()===``?{base:pT(o,i,`replace`),autoTake:a,claimedArrival:null,pendingArrival:null,discardArrival:null}:{base:o,autoTake:null,claimedArrival:null,pendingArrival:a,discardArrival:null}}function _T(e,t,n){let{base:r,autoTake:i,claimedArrival:a,pendingArrival:o,discardArrival:s}=gT(e,t,n.ref!==``);return{draft:{...r,...n.runner===void 0?{}:dT(n.runner,n.account,r.runner),...n.ref===``?{}:{text:n.ref},...n.skill===``?{}:{source:{source:`skill`,ref:n.skill,...n.skillPath===void 0?{}:{path:n.skillPath}}}},autoTake:i,claimedArrival:a,pendingArrival:o,discardArrival:s}}function vT(e,t,n,r){let[{draft:i,autoTake:a,claimedArrival:o,pendingArrival:s,discardArrival:c}]=(0,Z.useState)(()=>_T(e,r,t)),[l,u]=(0,Z.useState)(i),[d,f]=(0,Z.useState)(s),[p,m]=(0,Z.useState)(null),[h,g]=(0,Z.useState)(!1),_=(0,Z.useRef)(l),v=(0,Z.useRef)(!1),y=(0,Z.useRef)(o),b=(0,Z.useCallback)(()=>m(null),[]);(0,Z.useEffect)(()=>{if(rw(Be(),r),hT(c),a!==null){if(v.current)return;vw(_.current,e),bw(e)?(v.current=!0,y.current=null,mT(a),m(null)):(ew(a.hostId,a.projectId),y.current=a,m(fT));return}s===null&&(vw(_.current,e),y.current&&bw(e)&&(mT(y.current),y.current=null,v.current=!0,m(null)))},[a,c,e,s,r]);let x=(0,Z.useRef)(!1),S=(0,Z.useRef)(!0);(0,Z.useEffect)(()=>(S.current=!0,()=>{S.current=!1}),[]);let C=t=>{if(!S.current||x.current)return;let n={..._.current,...t};_.current=n,vw(n,e),y.current&&bw(e)&&(mT(y.current),y.current=null,v.current=!0,m(null)),u(n)},w=(0,Z.useRef)(t.runner===void 0);(0,Z.useEffect)(()=>{!w.current||n===void 0||(w.current=!1,C(dT(n,t.account,_.current.runner)))},[n]);let T=t=>{if(mw(e)!==t)return;y.current&&(mT(y.current),y.current=null,v.current=!0),xw(e,t);let n=gw(e);_.current=n,S.current&&u(n)},E=(0,Z.useCallback)(t=>{if(!d)return;let n=pT(_w(e),d.handoff,t);if(!yw(n,e)){f(null),m(fT);return}_.current=n,u(n),mT(d),f(null),m(null)},[e,d]),D=(0,Z.useCallback)(()=>{if(!d)return;let e=d.handoff.rootUrlProjectId?Ve(null,d.handoff.rootUrlProjectId):`/new`;ow(d.hostId,d.projectId),f(null),Ew(e)},[d]);return{draft:l,update:C,clearStarted:T,submissionPending:x,submittingDraft:h,onPendingChange:(0,Z.useCallback)(e=>{x.current=e,g(e),e&&m(null)},[]),mounted:S,pendingArrival:d,arrivalError:p,clearArrivalError:b,confirmArrival:E,cancelArrival:D}}function yT(e,t,n,r){let i=ue(),a=re(n,r),o=a.data,s=t.data?.skillUsage,c=(0,Z.useMemo)(()=>Us(o??[],s),[o,s]),l=i.data?.workflows??[],u=i.data!==void 0&&!t.isPending,d=eT(e,c,l,a.unchecked),f=d?.source===`skill`?c.find(e=>e.id===d.ref&&(d.path===void 0||e.path===d.path)):void 0;return{skillList:c,skillUsage:s,workflowList:l,sourcesReady:u,source:d,selectedSkill:f,skillsSettled:!a.isPending,listUnchecked:a.unchecked,unchecked:a.unchecked||d?.source===`skill`&&!f}}function bT(e){let{uiState:t,source:n,sourcesReady:r,draftText:i,submissionPending:a,update:o}=e,s=t.data?.promptTemplates,c=(0,Z.useMemo)(()=>_x(s),[s]),l=bx(c,n?.source===`skill`?[n.ref]:[]),u=(0,Z.useRef)(i);u.current=i;let d=(0,Z.useRef)(``);return(0,Z.useEffect)(()=>{if(!r||a.current)return;let e=xx(u.current,d.current,l);d.current=e.applied,e.text!==u.current&&o({text:e.text})},[l,r]),c}function xT(e,t){let n=ee(),r=L(),i=Js(),{runners:a,uninstalled:o,signedOut:s}=i,c=t.data?.defaultRunner,l=c??`claude`,d=a.length>0?Xw(e.runner,a,l):null,{runner:f,ready:p}=ke(d??l),m=n.isSuccess&&a.length>0,h={isPending:n.isPending||r.isPending,isError:n.isError||r.isError},g=i.accountFor(f,e.agentProfile)??i.repoAccount?.[f],_=ie(c,oe(r.data)),v=_===void 0?null:i.accountFor(_,d===_?e.agentProfile:null),y=u(f,p,g),b=t.data?.modelsLocked===!0,x=t.data?.defaultModels,S=d===null?[]:Gw(d,r.data,y.data,[e.model,x?.[d]]),C=d===null?``:Qw(b?null:e.model,d,r.data,x,y.data),w=Hw(C,y.data);return{providers:h,registered:r,runners:a,uninstalled:o,signedOut:s,defaultRunner:c,planAccount:v,runner:d,displayRunner:f,providersReady:m,catalog:y,modelsLocked:b,models:S,model:C,effortOptions:w,effort:b?``:Uw(e.effort,w)}}function ST(e,t){let n=y(),{accounts:r,repoAccount:i,accountFor:a}=Js();return{accountChoices:r,repoAccount:i,accountsSettled:!n.isPending,agentProfile:a(e,t)}}function CT(e){let t=(0,Z.useRef)(!1),n=(0,Z.useRef)(void 0);(0,Z.useEffect)(()=>{n.current===void 0&&(n.current=document.activeElement);let r=e&&!t.current;t.current=e,r&&(document.activeElement===document.body||document.activeElement===n.current)&&document.querySelector(`textarea[aria-label="Describe a task for the agent"]`)?.focus()},[e])}function wT(e){let t=e.workspaceConfig.data?.composerDefaults;return qC({hasGit:e.hasGit,planFirst:e.draft.planFirst,explicitAutonomous:e.draft.autonomous,explicitWorktree:e.draft.worktree,configuredAutonomous:t?.autonomous??t?.inheritedAutonomous??`source-dependent`,configuredWorktree:t?.worktree??t?.inheritedWorktree??!0,source:e.source?.source??`workflow`})}function TT(e){let t=A(),n=xm(),r=t.data?.projects??[],i=e??t.data?.bootProject,a=n===`absent`?[]:UC(r.find(e=>e.id===i)),[o,s]=(0,Z.useState)(!1);return{projectList:r,bootProject:t.data?.bootProject,webhookTargets:a,notifyOn:a.length>0&&o,setNotifyChoice:s}}function ET(e){let[t,n]=(0,Z.useState)(()=>typeof window<`u`&&window.innerWidth<=767);return(0,Z.useLayoutEffect)(()=>{let t=e.current;if(!t)return;let r=()=>n(window.innerWidth<=767||t.getBoundingClientRect().width<550);r();let i=typeof ResizeObserver>`u`?null:new ResizeObserver(r);return i?.observe(t),window.addEventListener(`resize`,r),()=>{i?.disconnect(),window.removeEventListener(`resize`,r)}},[]),t}function DT(e){let t=To(),[n,r]=(0,Z.useState)(()=>e.deepLink.ref!==``||e.deepLink.skillPath!==void 0);OT(e.search,t),kT({pending:n,setPending:r,deepLink:e.deepLink,sourcesReady:e.sourcesReady,listUnchecked:e.listUnchecked,skillList:e.skillList,update:e.update})}function OT(e,t){let n=(0,Z.useRef)(!1);(0,Z.useEffect)(()=>{n.current||(n.current=!0,e.toString()!==``&&t(`/new`,{replace:!0}))},[])}function kT(e){let{pending:t,sourcesReady:n,deepLink:r}=e;(0,Z.useEffect)(()=>{if(!t||!n)return;e.setPending(!1);let i=!e.listUnchecked&&r.skill!==``&&!$w({source:`skill`,ref:r.skill,...r.skillPath===void 0?{}:{path:r.skillPath}},e.skillList,[])?r.skill:``;i!==``&&r.ref!==``&&e.update({text:KC(r.skill,r.ref),source:null});let{message:a,tone:o}=GC(i,r.ref!==``);H(a,{tone:o}),document.querySelector(`[data-slot="composer"] button[aria-label="Start task"], [data-slot="composer"] button[aria-label="Plan task"]`)?.focus()},[t,n])}function AT(e){return e.isPending?`Checking agent providers…`:e.isError?`Provider authentication could not be verified.`:`Connect an agent provider before starting a task.`}function jT(e,t,n){St({lastTask:e?{source:e.source,ref:e.ref}:null,...e?{recentSources:zw(t.data?.recentSources,{source:e.source,ref:e.ref})}:{},...e?.source===`skill`&&t.data!==void 0?{skillUsage:Ks(t.data.skillUsage,e.ref)}:{}}).then(()=>n.invalidateQueries({queryKey:ge.uiState})).catch(()=>{})}function MT(e){let t=To(),n=U(),[r,i]=(0,Z.useState)(null),[a,o]=(0,Z.useState)(!1),[s,c]=(0,Z.useState)(!1),{draft:l,draftProjectId:u,engine:d,mounted:f}=e,{providers:p,providersReady:m,runner:h}=d,g=(r,i)=>{e.clearStarted(i),n.invalidateQueries({queryKey:ge.runs.all}),f.current&&t(iT(r))};return{plan:r,setPlan:i,planning:a,starting:s,submit:async(t,r)=>{let a=mw(u);if(!m||h===null)throw Error(AT(p));if(!e.sourcesReady)throw Error(`Still loading workflows and skills — try again in a second.`);if(l.agentProfile&&!e.accountsSettled)throw Error(`Still loading agent accounts — try again in a second.`);if(l.planFirst){o(!0);try{let e=await ut(t,d.planAccount);f.current&&i(aT(t,r,e))}finally{o(!1)}return}let s=await nn(rT(tT({task:t,source:e.source,model:d.model,modelsLocked:d.modelsLocked,effort:d.effort,runner:h,runnerExplicit:l.runner!==null,agentProfile:e.agentProfile,defaultRunner:d.defaultRunner,images:r,worktree:e.runMode.worktree,autonomous:e.runMode.autonomous,archiveWhenDone:l.archiveWhenDone,autoMergePr:l.autoMergePr,allowWorkers:l.allowWorkers,allowMessaging:l.allowMessaging}),e.notifyOn));jT(e.source,e.uiState,n),g(s,a)},startPlanned:async()=>{if(r===null||r.steps.length===0||s||!m||h===null||l.agentProfile&&!e.accountsSettled)return;let t=mw(u);c(!0);try{let n=await nn(rT(uT({task:r.task,steps:r.steps,agentProfile:e.agentProfile,model:d.model,modelsLocked:d.modelsLocked,effort:d.effort,runner:h,runnerExplicit:l.runner!==null,defaultRunner:d.defaultRunner,images:r.images,archiveWhenDone:l.archiveWhenDone,autoMergePr:l.autoMergePr,allowWorkers:l.allowWorkers,allowMessaging:l.allowMessaging}),e.notifyOn));i(null),g(n,t)}catch(e){H(e instanceof Error?e.message:String(e),{tone:`danger`})}finally{c(!1)}}}}function NT({archiveWhenDone:e,autoMergePr:t,onChange:n,disabled:r=!1,disabledReason:i=`Unavailable while saving these settings.`,embedded:a=!1}){let o=(0,Z.useId)(),s=r?i:void 0;return(0,Q.jsxs)(`fieldset`,{"data-slot":`completion-controls`,"data-embedded":a||void 0,className:`grid min-w-0 gap-3`,children:[(0,Q.jsx)(`legend`,{className:a?`sr-only`:`text-sm font-medium [margin-block-end:0.5rem]`,children:`After Done`}),(0,Q.jsxs)(`label`,{htmlFor:`${o}-archive`,className:`completion-control flex min-h-11 min-w-0 items-center justify-between gap-3 rounded-md text-sm`,children:[(0,Q.jsxs)(`span`,{className:`min-w-0 break-words`,children:[(0,Q.jsx)(`span`,{id:`${o}-archive-label`,children:`Archive when Done`}),a?(0,Q.jsx)(`span`,{id:`${o}-archive-help`,className:`completion-control-help`,children:s??`Move to Archived after Done, even without a PR. You can restore it later.`}):null]}),(0,Q.jsx)(mo,{id:`${o}-archive`,className:`completion-switch`,checked:e,disabled:r,"aria-labelledby":`${o}-archive-label`,"aria-describedby":`${o}-archive-help`,onCheckedChange:e=>n({archiveWhenDone:e})})]}),a?null:(0,Q.jsx)(`p`,{id:`${o}-archive-help`,className:`text-xs break-words text-muted-foreground`,children:s??`Move the task to Archived after it reaches Done. You can restore it later.`}),(0,Q.jsxs)(`label`,{htmlFor:`${o}-merge`,className:`completion-control flex min-h-11 min-w-0 items-center justify-between gap-3 rounded-md text-sm`,children:[(0,Q.jsxs)(`span`,{className:`min-w-0 break-words`,children:[(0,Q.jsx)(`span`,{id:`${o}-merge-label`,children:`Auto-merge PR`}),a?(0,Q.jsx)(`span`,{id:`${o}-merge-help`,className:`completion-control-help`,children:s??`After Done, mark the PR ready and merge when current-head CI and GitHub rules allow.`}):null]}),(0,Q.jsx)(mo,{id:`${o}-merge`,className:`completion-switch`,checked:t,disabled:r,"aria-labelledby":`${o}-merge-label`,"aria-describedby":`${o}-merge-help`,onCheckedChange:e=>n({autoMergePr:e})})]}),a?null:(0,Q.jsx)(`p`,{id:`${o}-merge-help`,className:`text-xs break-words text-muted-foreground`,children:s??`After Done, mark a draft PR ready and merge when current-head CI and GitHub rules allow it.`}),!a||e&&t?(0,Q.jsx)(`p`,{className:`completion-order-note text-xs break-words text-muted-foreground`,children:a?`Merge runs before archive when both are on.`:`When both are on, merge comes before archive. Without a PR, Archive when Done still archives the task.`}):null]})}var PT=[{key:`allowWorkers`,slot:`workers`,label:`Allow Squawk workers`,help:`Agents in this task can start Squawk workers. Each worker is a separate paid agent session. Worker limits cap resources, not spending.`},{key:`allowMessaging`,slot:`messaging`,label:`Allow task messaging`,help:`Agents in this task can message other tasks in this project.`}];function FT({allowWorkers:e,allowMessaging:t,onChange:n,disabled:r=!1,embedded:i=!1}){let a=(0,Z.useId)(),o={allowWorkers:e,allowMessaging:t};return(0,Q.jsxs)(`fieldset`,{"data-slot":`task-access-controls`,"data-embedded":i||void 0,className:`grid min-w-0 gap-3`,children:[(0,Q.jsx)(`legend`,{className:i?`sr-only`:`text-sm font-medium [margin-block-end:0.5rem]`,children:`Task access`}),PT.map(e=>(0,Q.jsxs)(Z.Fragment,{children:[(0,Q.jsxs)(`label`,{htmlFor:`${a}-${e.slot}`,"data-slot":`task-access-${e.slot}`,className:`completion-control flex min-h-11 min-w-0 items-center justify-between gap-3 rounded-md text-sm`,children:[(0,Q.jsxs)(`span`,{className:`min-w-0 break-words`,children:[(0,Q.jsx)(`span`,{id:`${a}-${e.slot}-label`,children:e.label}),i?(0,Q.jsx)(`span`,{id:`${a}-${e.slot}-help`,className:`completion-control-help`,children:e.help}):null]}),(0,Q.jsx)(mo,{id:`${a}-${e.slot}`,className:`completion-switch shrink-0`,checked:o[e.key],disabled:r,"aria-labelledby":`${a}-${e.slot}-label`,"aria-describedby":`${a}-${e.slot}-help`,onCheckedChange:t=>n({[e.key]:t})})]}),i?null:(0,Q.jsx)(`p`,{id:`${a}-${e.slot}-help`,className:`text-xs break-words text-muted-foreground`,children:e.help})]},e.key))]})}var IT=[{id:`fix-bug`,label:`Fix a bug`,body:`Investigate and fix the issue, adding a regression test that reproduces it first.`},{id:`add-tests`,label:`Add tests`,body:`Add focused unit tests covering the edge cases and verify the suite passes.`},{id:`review-changes`,label:`Review changes`,body:`Review the recent changes for bugs, edge cases, and missing test coverage.`}];function LT({templates:e,onInsert:t}){let n=e.length>0?e.slice(0,4).map(e=>({id:e.id,label:e.label,body:e.text})):IT,r=e.length>0?`Saved templates`:`Quick start prompts`;return(0,Q.jsxs)(`section`,{"data-slot":`new-task-quick-prompts`,"aria-label":r,className:`mt-5 flex flex-col gap-2.5 rounded-xl border border-border bg-card p-4`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-baseline justify-between gap-2`,children:[(0,Q.jsx)(`h2`,{className:`text-xs font-semibold text-foreground`,children:r}),(0,Q.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Insert a starting prompt into the composer`})]}),(0,Q.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:n.map(e=>(0,Q.jsx)(`button`,{type:`button`,"data-slot":`new-task-quick-prompt`,onClick:()=>t(e.body),className:`inline-flex min-h-9 max-md:min-h-11 no-hover:min-h-11 items-center rounded-lg border border-border bg-background px-3 py-1.5 text-left text-xs font-medium text-foreground transition-colors hover:bg-muted focus-visible:outline-2 focus-visible:outline-ring`,children:e.label},e.id))})]})}function RT({groupRef:e,compact:t,runOn:n,engine:r,accounts:i,draftEffort:a,update:o}){let s=r.runners.length>1||r.uninstalled.length>0||r.signedOut.length>0||r.runners.some(e=>Zs(i.accountChoices,e))?(0,Q.jsx)(zT,{engine:r,accounts:i,update:o},`runner`):null,c=(0,Q.jsx)(BT,{engine:r,draftEffort:a,update:o},`model`),l=(0,Q.jsx)(VT,{engine:r,update:o},`effort`);return(0,Q.jsx)(`div`,{ref:e,"data-slot":`agent-options`,role:`group`,"aria-label":`Agent settings`,className:`new-task-agent-options`,children:(0,Q.jsx)(TC,{children:t?[n,s,l,c]:[n,s,c,l]})})}function zT({engine:e,accounts:t,update:n}){return(0,Q.jsx)(NC,{icon:(0,Q.jsx)(Ri,{"aria-hidden":`true`,className:`size-[18px] shrink-0 text-accent-text`}),fieldLabel:!0,runners:e.runners,uninstalled:e.uninstalled,signedOut:e.signedOut,value:e.displayRunner,accounts:t.accountChoices,account:t.agentProfile,repoAccount:t.repoAccount,onPick:(t,r)=>n({runner:t,agentProfile:r,...t===e.displayRunner?{}:{model:null}}),disabled:!e.providersReady})}function BT({engine:e,draftEffort:t,update:n}){let{catalog:r,displayRunner:i}=e;return(0,Q.jsx)(jC,{icon:(0,Q.jsx)(Si,{"aria-hidden":`true`,className:`size-[18px] shrink-0 text-accent-text`}),fieldLabel:!0,slot:`model-pill`,ariaLabel:`Model`,label:e.models.find(t=>t.id===e.model)?.label??`Runner default`,value:e.model,disabled:!e.providersReady,readOnly:e.modelsLocked,disabledHint:e.modelsLocked?`Model selection is locked to native coding-agent settings.`:void 0,onPick:e=>{let i=Hw(e,r.data);n({model:e,effort:t===null?null:Uw(t,i)})},options:e.models.map(e=>({value:e.id,label:e.label,desc:e.desc})),status:Jw(i,e.registered.data,r)})}function VT({engine:e,update:t}){return(0,Q.jsx)(jC,{icon:(0,Q.jsx)(ni,{"aria-hidden":`true`,className:`size-[18px] shrink-0 text-accent-text`}),fieldLabel:!0,slot:`effort-pill`,ariaLabel:`Effort`,label:e.effortOptions.find(t=>t.value===e.effort)?.label??`Runner default`,value:e.effort,disabled:!e.providersReady,readOnly:e.modelsLocked,disabledHint:e.modelsLocked?`Effort selection is locked to native coding-agent settings.`:void 0,onPick:e=>t({effort:e}),options:e.effortOptions.map(e=>({value:e.value,label:e.label,desc:e.desc}))})}function HT({engine:e,draft:t,update:n,repo:r,hasGit:i,runMode:a,webhook:o,completionDisabled:s}){let{displayRunner:c}=e,l=L().data,u=fs(),[d,f]=(0,Z.useState)(),p=d??u;return(0,Q.jsxs)(`details`,{"data-slot":`execution-options`,open:p,onToggle:e=>{e.currentTarget.open!==p&&f(e.currentTarget.open)},className:`group rounded-xl border border-border bg-card xl:self-start`,children:[(0,Q.jsxs)(`summary`,{className:`flex min-h-[44px] cursor-pointer list-none flex-wrap items-center gap-x-2 gap-y-1 px-3 py-2 text-xs text-muted-foreground pointer-hover:bg-muted/50 active:bg-muted/50 focus-visible:outline-2 focus-visible:outline-offset-[-2px] focus-visible:outline-foreground [&::-webkit-details-marker]:hidden`,children:[(0,Q.jsx)(Li,{"aria-hidden":`true`,className:`size-[18px] shrink-0 text-accent-text`}),(0,Q.jsx)(`span`,{className:`font-medium text-foreground`,children:`Execution settings`}),(0,Q.jsxs)(`span`,{"data-slot":`execution-summary`,className:`min-w-0 basis-full truncate pl-5 xl:ml-auto xl:basis-auto xl:pl-0`,children:[ye(l,c),` · `,e.models.find(t=>t.id===e.model)?.label??`Runner default`,i&&!a.worktree?` · no worktree`:``,a.autonomous?` · autonomous`:``]}),(0,Q.jsx)(Ki,{"aria-hidden":`true`,className:`new-task-settings-chevron size-4 shrink-0`})]}),(0,Q.jsxs)(`div`,{className:`new-task-settings-body`,children:[(0,Q.jsx)(`p`,{className:`new-task-settings-description`,children:`Control this run and what happens after Done.`}),(0,Q.jsxs)(`div`,{role:`group`,"aria-label":`Run settings`,className:`new-task-run-settings`,children:[i?(0,Q.jsx)(GT,{on:a.worktree,onChange:e=>n({worktree:e})}):null,(0,Q.jsx)(JT,{repo:r,worktree:a.worktree||!i}),(0,Q.jsx)(KT,{on:a.autonomous,disabled:t.planFirst,onChange:e=>n({autonomous:e})}),o.targets.length>0?(0,Q.jsx)(qT,{on:o.on,targets:o.targets,onChange:o.onChange}):null]}),(0,Q.jsx)(NT,{embedded:!0,archiveWhenDone:t.archiveWhenDone,autoMergePr:t.autoMergePr,onChange:n,disabled:s,disabledReason:`Unavailable while starting the task or preparing its plan.`}),(0,Q.jsx)(FT,{embedded:!0,allowWorkers:t.allowWorkers,allowMessaging:t.allowMessaging,onChange:n,disabled:s})]})]})}function UT({showConfigureProviders:e,planFirst:t,planning:n,onModeChange:r}){return(0,Q.jsxs)(Q.Fragment,{children:[e?(0,Q.jsx)(X,{to:`/settings/agent-defaults#providers`,className:`text-xs font-medium text-foreground underline underline-offset-4`,children:`Configure providers`}):null,(0,Q.jsx)($T,{planFirst:t,planning:n,onModeChange:r}),(0,Q.jsx)(`kbd`,{"aria-hidden":`true`,className:`hidden rounded-[5px] border border-b-2 border-border bg-card px-[5px] py-px font-mono text-xs font-medium text-muted-foreground md:inline`,children:kx()})]})}function WT({slot:e,label:t,hint:n,title:r,on:i,disabled:a,onChange:o,hintSlot:s,truncateHint:c}){return(0,Q.jsxs)(`label`,{title:r,className:q(`flex min-h-11 items-center justify-between gap-3 px-0 py-3 text-left`,a?`cursor-not-allowed opacity-50`:`cursor-pointer`),children:[(0,Q.jsxs)(`span`,{className:`min-w-0`,children:[(0,Q.jsx)(`span`,{className:`block text-[13px] font-medium`,children:t}),(0,Q.jsx)(`span`,{"data-slot":s,className:q(`block text-[12px] text-muted-foreground`,c&&`truncate`),children:n})]}),(0,Q.jsx)(mo,{"data-slot":e,"aria-label":t,checked:i,disabled:a,onCheckedChange:o})]})}function GT({on:e,onChange:t}){return(0,Q.jsx)(WT,{slot:`worktree-toggle`,label:`Worktree`,hint:e?`Changes stay in a separate working copy.`:`Changes are made in the current working directory.`,title:e?`Runs in an isolated worktree — turn off to run in the repo working tree`:`Runs in the repo working tree — turn on to isolate in a worktree`,on:e,onChange:t})}function KT({on:e,disabled:t,onChange:n}){return(0,Q.jsx)(WT,{slot:`autonomous-toggle`,label:`Autonomous`,hint:`Let the agent proceed without prompts`,title:t?`Plan-first runs are interactive — autonomous is unavailable`:e?`Autonomous — the agent runs to completion without pausing for you`:`Runs interactively — turn on to let the agent finish without pausing for you`,on:e,disabled:t,onChange:n})}function qT({on:e,targets:t,onChange:n}){return(0,Q.jsx)(WT,{slot:`notify-webhook-toggle`,label:`Notify webhook`,hint:`Send status changes`,hintSlot:`notify-webhook-subtitle`,truncateHint:!0,title:`${e?`Status changes go to`:`Turn on to send this task's status changes to`} ${WC(t)} (${t.map(e=>HC(e.url)).join(`, `)})`,on:e,onChange:n})}function JT({repo:e,worktree:t}){return(0,Q.jsxs)(`div`,{"data-slot":`base-branch-row`,"data-inactive":t?void 0:``,className:q(`new-task-base-branch flex items-center justify-between gap-2 text-xs text-muted-foreground`,!t&&`opacity-60`),children:[(0,Q.jsxs)(`span`,{children:[`Base branch`,t?null:(0,Q.jsx)(`span`,{"data-slot":`base-branch-hint`,className:`block text-[12px]`,children:`Not used while Worktree is off.`})]}),e?(0,Q.jsx)(YT,{repo:e,disabled:!t}):null]})}function YT({repo:e,disabled:t}){let n=U(),r=je({mutationFn:e=>st({baseBranch:e}),onSuccess:e=>{n.invalidateQueries({queryKey:ge.repo}),H(e.baseBranch?`New tasks will branch off "${e.baseBranch}" (PRs target it too).`:`Base branch cleared — new tasks fork from the checked-out branch.`)},onError:e=>H(e.message,{tone:`danger`})});return e.info?(0,Q.jsx)(jC,{searchPlaceholder:`Search branches…`,slot:`base-pill`,ariaLabel:`Base branch`,disabled:t,label:(0,Q.jsx)(`span`,{className:`text-xs`,children:e.baseBranch??e.info.branch}),value:e.baseBranch??``,onPick:e=>r.mutate(e===``?null:e),options:[{value:``,label:`follow checked-out branch (${e.info.branch})`,desc:`New task worktrees fork from whatever branch is checked out`},...e.branches.map(e=>({value:e,label:e}))]}):null}var XT=`h-6 rounded-md px-3 text-xs font-medium transition-colors outline-hidden focus-visible:ring-2 focus-visible:ring-ring/50`,ZT=`bg-muted text-foreground`,QT=`text-muted-foreground pointer-hover:text-foreground`;function $T({planFirst:e,planning:t,onModeChange:n}){return(0,Q.jsxs)(`div`,{"data-slot":`mode-seg`,role:`radiogroup`,"aria-label":`Run mode`,className:`inline-flex items-center gap-0.5 rounded-lg border border-border bg-card p-0.5`,children:[(0,Q.jsx)(`button`,{type:`button`,role:`radio`,"aria-checked":!e,onClick:()=>n(!1),className:q(XT,e?QT:ZT),children:`Run now`}),(0,Q.jsx)(`button`,{type:`button`,role:`radio`,"aria-checked":e,"aria-busy":t||void 0,"data-slot":`mode-plan`,onClick:()=>n(!0),className:q(XT,e?ZT:QT,t&&`animate-pulse`),children:t?`Planning…`:`Plan first`})]})}function eE({plan:e,starting:t,startAvailable:n,startUnavailableReason:r,startUnavailableAction:i,onStepsChange:a,onStart:o,onDiscard:s}){let[c,l]=(0,Z.useState)(null),[u,d]=(0,Z.useState)(null),f=(0,Z.useRef)(null),p=(0,Z.useId)();(0,Z.useEffect)(()=>{f.current?.focus({preventScroll:!0});let e=f.current?.closest(`[data-slot="main"]`);e&&(e.scrollTop=0)},[]);let m=()=>{l(null),d(null)},h=(t,n)=>{t.preventDefault(),c!==null&&c!==n&&a(sT(e.steps,c,n)),m()},g=e.steps.length===0;return(0,Q.jsx)(`div`,{"data-slot":`plan-page`,children:(0,Q.jsx)(`div`,{"data-slot":`plan-canvas`,children:(0,Q.jsxs)(`section`,{ref:f,tabIndex:-1,"aria-labelledby":p,"data-slot":`plan-review`,className:`flex flex-col outline-none`,onKeyDown:e=>{e.key!==`Escape`||e.defaultPrevented||e.target.closest(`[role="dialog"], [role="alertdialog"]`)||(e.preventDefault(),s())},children:[(0,Q.jsxs)(`header`,{"data-slot":`dialog-header`,className:`flex flex-col gap-1 px-5 pt-4 pb-3.5 text-left`,children:[(0,Q.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,Q.jsx)(`h2`,{id:p,"data-slot":`dialog-title`,className:`text-xs font-semibold tracking-[0.08em] text-muted-foreground uppercase`,children:`Proposed chain`}),(0,Q.jsx)(`button`,{type:`button`,onClick:s,"aria-label":`Discard the plan`,className:`-mt-1 -mr-1 rounded-md p-1 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground`,children:(0,Q.jsx)(Fi,{"aria-hidden":`true`,className:`size-4`})})]}),(0,Q.jsx)(`p`,{"data-slot":`plan-task`,title:e.task,className:`text-[18px] font-medium text-foreground`,children:lT(e.task)}),e.fallback?(0,Q.jsx)(`p`,{"data-slot":`plan-fallback`,className:`text-xs text-soft-foreground italic`,children:`planner unavailable — single-step plan`}):e.rationale===``?null:(0,Q.jsx)(`p`,{"data-slot":`plan-rationale`,className:`text-xs text-muted-foreground`,children:e.rationale})]}),(0,Q.jsx)(`ol`,{"data-slot":`plan-steps`,className:`flex-1 space-y-2 overflow-y-auto px-5 py-4`,children:g?(0,Q.jsx)(`li`,{className:`py-6 text-center text-sm text-muted-foreground`,children:`(no steps left — discard and plan again)`}):e.steps.map((t,n)=>(0,Q.jsxs)(`li`,{"data-slot":`plan-step`,"data-step-id":t.id,draggable:!0,onDragStart:()=>l(n),onDragOver:e=>{e.preventDefault(),d(n)},onDragLeave:()=>d(e=>e===n?null:e),onDrop:e=>h(e,n),onDragEnd:m,className:q(`flex items-center gap-2.5 rounded-lg border border-border bg-card-2 px-3 py-2.5`,c===n&&`opacity-50`,u===n&&c!==null&&c!==n&&`border-ring`),children:[(0,Q.jsx)(hi,{"aria-hidden":`true`,className:`size-3.5 shrink-0 cursor-grab text-soft-foreground`}),(0,Q.jsx)(`span`,{className:`w-5 shrink-0 font-mono text-xs text-muted-foreground tabular-nums`,children:String(n+1).padStart(2,`0`)}),(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,Q.jsx)(`span`,{className:`text-[13px] font-medium`,children:t.name??t.id}),t.skill?(0,Q.jsx)(`span`,{"data-slot":`plan-badge-skill`,title:`skill`,className:`shrink-0 rounded-full bg-accent-strong/15 px-1.5 py-px font-mono text-xs font-medium text-accent-text`,children:t.skill}):null,t.command?(0,Q.jsx)(`span`,{"data-slot":`plan-badge-check`,className:`shrink-0 rounded-full bg-muted px-1.5 py-px text-xs font-medium text-muted-foreground`,children:`check`}):null]}),(0,Q.jsx)(`p`,{className:`mt-3 whitespace-pre-wrap break-words font-mono text-xs text-muted-foreground`,children:cT(t)})]}),(0,Q.jsxs)(`span`,{"data-slot":`plan-step-actions`,className:`flex flex-wrap items-center gap-2`,children:[(0,Q.jsx)(Y,{type:`button`,variant:`ghost`,size:`icon-sm`,"data-slot":`plan-step-up`,"aria-label":`Move step ${n+1} up`,disabled:n===0,className:`text-muted-foreground`,onClick:()=>a(sT(e.steps,n,n-1)),children:`Move up`}),(0,Q.jsx)(Y,{type:`button`,variant:`ghost`,size:`icon-sm`,"data-slot":`plan-step-down`,"aria-label":`Move step ${n+1} down`,disabled:n===e.steps.length-1,className:`text-muted-foreground`,onClick:()=>a(sT(e.steps,n,n+1)),children:`Move down`}),(0,Q.jsx)(Y,{type:`button`,variant:`ghost`,size:`icon-sm`,"data-slot":`plan-step-remove`,"aria-label":`Remove step ${n+1}`,className:`text-muted-foreground hover:text-semantic-red`,onClick:()=>a(oT(e.steps,n)),children:`Remove`})]})]},t.id))}),!n&&r?(0,Q.jsxs)(`p`,{id:`plan-start-guidance`,className:`flex flex-wrap items-center gap-1.5 border-t border-border px-5 pt-3 text-xs text-muted-foreground`,children:[(0,Q.jsx)(`span`,{children:r}),i]}):null,(0,Q.jsxs)(`div`,{"data-slot":`plan-actions`,className:`flex flex-wrap items-center gap-3 px-6 pt-3 pb-6`,children:[(0,Q.jsxs)(Y,{type:`button`,"data-slot":`plan-start`,disabled:g||t||!n,title:n?void 0:r,"aria-describedby":!n&&r?`plan-start-guidance`:void 0,onClick:o,children:[(0,Q.jsx)(Sa,{"aria-hidden":`true`,className:`size-3.5`}),t?`Starting…`:`Start`]}),(0,Q.jsx)(tE,{steps:e.steps,disabled:g}),(0,Q.jsx)(Y,{type:`button`,variant:`outline`,onClick:s,children:`Discard`})]}),(0,Q.jsx)(`p`,{className:`px-6 pb-6 text-xs text-muted-foreground`,children:`No steps left? Start is disabled. A planner failure shows a single-step fallback.`})]})})})}function tE({steps:e,disabled:t}){let n=U(),[r,i]=(0,Z.useState)(!1),[a,o]=(0,Z.useState)(``),[s,c]=(0,Z.useState)(!1),[l,u]=(0,Z.useState)(!1),d=async t=>{let r=a.trim();if(!(r===``||l)){u(!0);try{let a=await bn({name:r,steps:e,...t?{overwrite:!0}:{}});H(`Saved — ${a.path.split(`/`).pop()??a.path}`),n.invalidateQueries({queryKey:ge.workflows}),c(!1),i(!1),o(``)}catch(e){e instanceof Tn&&e.exists===!0?c(!0):H(e instanceof Error?e.message:String(e),{tone:`danger`})}finally{u(!1)}}};return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Y,{type:`button`,variant:`outline`,"data-slot":`plan-save`,disabled:t,onClick:()=>i(!0),children:`Save as chain`}),(0,Q.jsx)(So,{open:r,onOpenChange:e=>i(!!e),children:(0,Q.jsxs)(bo,{"data-slot":`plan-save-dialog`,className:`sm:max-w-sm`,showCloseButton:!1,children:[(0,Q.jsxs)(yo,{children:[(0,Q.jsx)(xo,{children:`Save as chain`}),(0,Q.jsx)(_o,{children:`Saves these steps as a reusable workflow — it joins the picker like any other chain.`})]}),(0,Q.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),d(!1)},children:[(0,Q.jsx)(`label`,{htmlFor:`plan-chain-name`,className:`mb-2 block text-xs text-muted-foreground`,children:`Chain name`}),(0,Q.jsx)(Wu,{id:`plan-chain-name`,value:a,onChange:e=>o(e.target.value),"aria-label":`Chain name`,placeholder:`e.g. fix-and-verify-v2`,maxLength:80,autoFocus:!0}),(0,Q.jsxs)(go,{className:`mt-4`,children:[(0,Q.jsx)(Y,{type:`button`,variant:`outline`,onClick:()=>i(!1),children:`Cancel`}),(0,Q.jsx)(Y,{type:`submit`,disabled:a.trim()===``||l,children:l?`Saving…`:`Save chain`})]})]})]})}),(0,Q.jsx)(Pv,{open:s,onOpenChange:e=>e?void 0:c(!1),children:(0,Q.jsxs)(Lv,{"data-slot":`plan-overwrite-dialog`,children:[(0,Q.jsxs)(Rv,{children:[(0,Q.jsxs)(Bv,{children:[`Overwrite “`,a.trim(),`”?`]}),(0,Q.jsx)(Vv,{children:`A chain with this name already exists. Overwriting replaces its steps with this plan.`})]}),(0,Q.jsxs)(zv,{children:[(0,Q.jsx)(Uv,{children:`Cancel`}),(0,Q.jsx)(Hv,{onClick:()=>void d(!0),children:`Overwrite chain`})]})]})})]})}var nE={start:{note:`Start immediately with the selected configuration.`,pendingLabel:`Starting task…`,failureHint:void 0,clearOnSuccess:!0,sendAriaLabel:`Start task`},plan:{note:`Review the plan before starting the task.`,pendingLabel:`Planning task…`,failureHint:`Could not create the plan. Your draft is kept. Please retry.`,clearOnSuccess:!1,sendAriaLabel:`Plan task`}};function rE(){let[e]=zn(),t=(0,Z.useRef)(null),n=(0,Z.useRef)(null),r=(0,Z.useRef)(null),{projectId:i}=Hn(),a=pn().projectId,o=L().data,[s]=(0,Z.useState)(()=>e.toString()),[c]=(0,Z.useState)(()=>bp(s,o)),l=bp(s,o).runner,u=O(),d=C(),f=ae(),p=xe(),{draft:m,update:h,clearStarted:g,submissionPending:_,submittingDraft:v,onPendingChange:y,mounted:b,pendingArrival:x,arrivalError:S,clearArrivalError:w,confirmArrival:T,cancelArrival:E}=vT(a,c,l,i),D=bw(a),[k,A]=(0,Z.useState)(0),j=xT(m,f),M=ST(j.displayRunner,m.agentProfile),N=yT(m.source,d,j.displayRunner,M.agentProfile),{source:ee,sourcesReady:P,skillList:F}=N,I=TT(i),R=jw({draftProjectId:a,urlProjectId:i,localProjects:I.projectList,bootProject:I.bootProject,draftText:m.text,draftSource:ee,attachmentCount:k,submissionPending:_}),te=bT({uiState:d,source:ee,sourcesReady:P,draftText:m.text,submissionPending:_,update:h});CT(j.providersReady);let ne=u.data===void 0||u.data.info!==null,re=wT({hasGit:ne,draft:m,selectedSkill:N.selectedSkill,workspaceConfig:p,source:ee}),{plan:z,setPlan:ie,planning:oe,starting:B,submit:se,startPlanned:ce}=MT({draft:m,draftProjectId:a,engine:j,agentProfile:M.agentProfile,accountsSettled:M.accountsSettled,sourcesReady:P,source:ee,runMode:re,notifyOn:I.notifyOn,uiState:d,mounted:b,clearStarted:g});DT({deepLink:c,search:e,sourcesReady:P&&N.skillsSettled&&!j.providers.isPending&&M.accountsSettled,listUnchecked:N.listUnchecked,skillList:F,update:h});let le=ET(t),{providers:ue,providersReady:de}=j,fe=m.planFirst?nE.plan:nE.start,pe=AT(ue),me=iE({plan:z,draftText:m.text,providersReady:de,starting:B,planning:oe,submittingDraft:v,arrivalError:S,moveError:R.moveError});return(0,Q.jsxs)(ms,{route:`new`,density:me.isSparseDraft?`sparse`:`full`,rootProps:{"data-plan-review":z===null?void 0:`true`},className:`relative isolate overflow-x-clip pb-16`,header:oE(z!==null),sparseFooter:sE(me.isSparseDraft,te,n),children:[(0,Q.jsx)(`div`,{"data-slot":`new-task-layout`,"data-persisted-draft":D||void 0,ref:r,style:z===null?void 0:{display:`none`},className:`relative z-[1] w-full`,children:(0,Q.jsx)(_C,{ref:n,onSubmit:se,retainDraftUntilSuccess:!0,idleFeedback:(0,Q.jsxs)(`div`,{"data-slot":`new-task-idle-feedback`,className:`flex flex-col gap-1`,children:[(0,Q.jsxs)(`div`,{"data-slot":`new-task-mode-note`,className:`flex items-center justify-between gap-3 text-xs text-muted-foreground`,children:[me.showStartHint?(0,Q.jsx)(`span`,{"data-slot":`new-task-start-hint`,children:`Describe a task above to start.`}):(0,Q.jsx)(`span`,{children:fe.note}),(0,Q.jsx)(`kbd`,{className:`hidden font-sans md:inline`,children:kx()})]}),(0,Q.jsx)(`p`,{"data-slot":`run-mode-note`,className:`text-xs text-muted-foreground`,children:JC({worktree:re.worktree,hasGit:ne})})]}),pendingLabel:fe.pendingLabel,failureHint:fe.failureHint,externalError:me.externalError,onAttachmentsChange:A,clearOnSuccess:fe.clearOnSuccess,onPendingChange:e=>{y(e),aE(e,R.clearMoveError)},value:m.text,onValueChange:e=>{w(),R.clearMoveError(),h({text:e})},draftPersisted:D,autoFocus:!0,placeholder:`Describe a task for the agent — / for skills…`,ariaLabel:`Describe a task for the agent`,sendAriaLabel:fe.sendAriaLabel,disabled:!de||B,disabledReason:pe,autocompleteSkills:!0,skillRunner:j.displayRunner,skillAccount:M.agentProfile,footerStart:(0,Q.jsx)(cE,{projects:I.projectList,urlProjectId:i,templates:te,onInsertTemplate:e=>n.current?.insertAtCaret(e),sources:N,onPickSource:e=>h({source:e})}),agentOptions:(0,Q.jsx)(RT,{groupRef:t,compact:le,runOn:(0,Q.jsx)(Nw,{targets:R.targets,currentProject:R.currentProject,disabled:me.submitting,onSelectHost:R.selectHost},`run-on`),engine:j,accounts:M,draftEffort:m.effort,update:h}),executionOptions:(0,Q.jsx)(HT,{engine:j,draft:m,update:h,repo:u.data,hasGit:ne,runMode:re,webhook:{targets:I.webhookTargets,on:I.notifyOn,onChange:I.setNotifyChoice},completionDisabled:B||oe}),footerEnd:(0,Q.jsx)(UT,{showConfigureProviders:!de&&!ue.isPending,planFirst:m.planFirst,planning:oe,onModeChange:e=>h({planFirst:e})})})}),z===null?null:(0,Q.jsx)(eE,{plan:z,starting:B,startAvailable:de,startUnavailableReason:pe,startUnavailableAction:ue.isPending?void 0:(0,Q.jsx)(X,{to:`/settings/agent-defaults#providers`,children:`Configure providers`}),onStepsChange:e=>ie(t=>t&&{...t,steps:e}),onStart:()=>void ce(),onDiscard:()=>{ie(null),requestAnimationFrame(()=>r.current?.querySelector(`textarea`)?.focus())}}),(0,Q.jsx)(Fw,{pending:R.pendingLeaveBehind,draftText:m.text,attachmentCount:k,draftSource:ee,onCancel:R.cancelLeaveBehind,onConfirm:R.confirmLeaveBehind}),(0,Q.jsx)(Iw,{pending:x,draftProjectId:a,projects:I.projectList,onCancel:E,onConfirm:T})]})}function iE(e){let t=e.draftText.trim()===``;return{isSparseDraft:e.plan===null&&t,showStartHint:e.providersReady&&!e.starting&&t,submitting:e.starting||e.planning||e.submittingDraft,externalError:e.arrivalError??e.moveError}}function aE(e,t){e&&t()}function oE(e){return e?{title:`New task / Plan first`,subtitle:`Review the proposed chain before launching.`,headerSlot:`plan-page-header`,hideSubtitleOnMobile:!0}:{title:`What should the agent work on?`,subtitle:`Describe the outcome, then configure the run.`,subtitleSlot:`page-description`,hideSubtitleOnMobile:!0}}function sE(e,t,n){if(e)return(0,Q.jsx)(LT,{templates:t,onInsert:e=>n.current?.insertAtCaret(e)})}function cE({projects:e,urlProjectId:t,templates:n,onInsertTemplate:r,sources:i,onPickSource:a}){let o=To();return(0,Q.jsxs)(Q.Fragment,{children:[e.length>1&&t!==void 0?(0,Q.jsx)(uE,{projects:e,projectId:t,onPick:e=>o(`/p/${encodeURIComponent(e)}/new`,{replace:!0})}):null,(0,Q.jsx)(FC,{label:`Template`,templates:n,onInsert:r}),(0,Q.jsx)(yE,{source:i.source,unchecked:i.unchecked,ready:i.sourcesReady,skillsLoading:!i.skillsSettled,skills:i.skillList,skillUsage:i.skillUsage,workflows:i.workflowList,onPick:a})]})}function lE(e,t){let n=t.trim().toLowerCase();if(n===``)return[...e];let r=e=>{let t=e.name.toLowerCase(),r=e.id.toLowerCase();return t.startsWith(n)||r.startsWith(n)?0:t.includes(n)||r.includes(n)?1:2};return e.map((e,t)=>({project:e,rank:r(e),index:t})).filter(e=>e.rank<2).sort((e,t)=>e.rank-t.rank||e.index-t.index).map(e=>e.project)}function uE({projects:e,projectId:t,onPick:n}){let[r,i]=(0,Z.useState)(!1),[a,o]=(0,Z.useState)(``),{order:s}=$m(),c=e.find(e=>e.id===t),l=lE(Ps(e,s),a);return(0,Q.jsxs)(po,{open:r,onOpenChange:e=>{i(e),e||o(``)},children:[(0,Q.jsx)(co,{asChild:!0,children:(0,Q.jsxs)(`button`,{type:`button`,"data-slot":`project-pill`,"aria-label":`Project`,title:`Which project this task runs in — its skills, workflows, settings and draft`,className:q(vC,`border-foreground/60 font-semibold text-foreground`),children:[(0,Q.jsx)(ii,{"aria-hidden":`true`,className:`size-3 shrink-0 text-soft-foreground`}),(0,Q.jsx)(`span`,{className:`max-w-40 truncate`,children:c?.name??t}),yC]})}),(0,Q.jsx)(uo,{align:`start`,sideOffset:8,className:`w-[300px] max-w-[calc(100vw-2rem)] p-0`,children:(0,Q.jsxs)(Ns,{shouldFilter:!1,children:[(0,Q.jsx)(Ts,{placeholder:`search projects…`,value:a,onValueChange:o}),(0,Q.jsxs)(Ms,{"data-slot":`project-menu`,className:`max-h-[min(18rem,calc(var(--radix-popover-content-available-height)-3rem))]`,children:[l.length===0?(0,Q.jsx)(js,{children:`Nothing matches.`}):null,l.map(e=>(0,Q.jsxs)(As,{value:e.id,keywords:[e.name],"data-slot":`project-option`,"data-project-id":e.id,disabled:e.status===`missing`,onSelect:()=>{n(e.id),i(!1)},children:[(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs font-medium`,children:e.name}),e.status===`missing`?(0,Q.jsx)(`span`,{className:`shrink-0 text-xs text-soft-foreground`,children:`folder not found`}):e.branch===void 0?null:(0,Q.jsx)(`span`,{className:`shrink-0 font-mono text-xs text-soft-foreground`,children:e.branch}),e.id===t?(0,Q.jsx)(Ni,{"aria-hidden":`true`,className:`size-3.5 shrink-0 text-link-foreground`}):null]},e.id))]}),(0,Q.jsx)(`p`,{className:`border-t border-border px-3 py-2 text-xs leading-snug text-soft-foreground`,children:`Skills, workflows, settings and the draft re-resolve against the selected project.`})]})})]})}function dE(e,t,n){return!e&&(t.ranked?t.ranked.length===0:t.mostUsed.length===0&&t.project.length===0&&t.global.length===0)&&n.length===0}function fE(e,t){return Rs(`no skill`,`none plain ${Rw} ${e?.description??``}`,t)>0}var pE={workflows:`Skill or workflow`,skills:`Skill`};function mE({source:e,ready:t,offersWorkflows:n,onPick:r,skillLabel:i}){let a=e===null||e.source===`skill`?Hi:Di;return(0,Q.jsxs)(`button`,{type:`button`,"data-slot":`source-pill`,"data-source-kind":e?.source??`none`,"aria-label":`Choose a skill or workflow`,title:e===null?`No skill — the task runs as one plain agent step. Pick a skill or workflow to change that.`:`Runs the ${e.source} "${e.ref}" — pick it again, or press ✕, to run without it`,disabled:!t,"aria-busy":!t||void 0,onKeyDown:t=>{e===null||t.metaKey||t.ctrlKey||t.altKey||t.key!==`Backspace`&&t.key!==`Delete`||(t.preventDefault(),r(null))},className:q(vC,e===null?`text-muted-foreground`:`rounded-r-none border-r-0 border-foreground/60 pr-1.5 font-semibold text-foreground`),children:[(0,Q.jsx)(a,{"aria-hidden":`true`,className:q(`size-3 shrink-0`,e===null?`text-muted-foreground`:`text-accent-icon`)}),e===null?(0,Q.jsx)(`span`,{"data-sizer":pE.workflows,className:`grid max-w-44 before:invisible before:whitespace-nowrap before:content-[attr(data-sizer)] before:[grid-area:1/1]`,children:(0,Q.jsx)(`span`,{className:`truncate text-start [grid-area:1/1]`,children:t?n?pE.workflows:pE.skills:`…`})}):(0,Q.jsx)(`span`,{className:`max-w-44 truncate`,children:t?i??e.ref:`…`}),yC]})}function hE({source:e,quickTask:t,onPick:n}){return(0,Q.jsx)(Ds,{children:(0,Q.jsxs)(As,{value:`none no-skill`,keywords:[`none`,`plain`,...Ws(Rw)],"data-slot":`source-option`,"data-source-kind":`none`,onSelect:()=>n(null),children:[(0,Q.jsx)(Oi,{"aria-hidden":`true`,className:`size-3.5 shrink-0 text-soft-foreground`}),(0,Q.jsx)(`span`,{className:`shrink-0 text-xs font-medium`,children:`No skill`}),(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs text-soft-foreground`,children:t?.description??`One agent run on your task — no ceremony.`}),e===null?(0,Q.jsx)(Ni,{"aria-hidden":`true`,className:`ml-auto size-3.5 shrink-0 text-link-foreground`}):null]})})}function gE({ranked:e,mostUsed:t,project:n,skillItem:r}){return(0,Q.jsx)(Q.Fragment,{children:e?e.length>0?(0,Q.jsx)(Ds,{children:e.map(e=>r(e,Vs(e)))}):null:(0,Q.jsxs)(Q.Fragment,{children:[t.length>0?(0,Q.jsx)(Ds,{heading:`Most used`,children:t.map(e=>r(e,Vs(e)))}):null,n.length>0?(0,Q.jsx)(Ds,{heading:`Project skills`,children:n.map(e=>r(e,!0))}):null]})})}function _E({source:e,matchedWorkflows:t,toggle:n}){return t.length>0?(0,Q.jsx)(Ds,{heading:`Workflows`,children:t.map(t=>{let r=e?.source===`workflow`&&e.ref===t.name;return(0,Q.jsxs)(As,{value:`workflow ${t.name}`,keywords:Ws(t.name,t.description),"data-slot":`source-option`,"data-source-kind":`workflow`,"data-source-ref":t.name,onSelect:()=>n({source:`workflow`,ref:t.name}),children:[(0,Q.jsx)(`span`,{className:`shrink-0 font-mono text-xs`,children:t.name}),t.description?(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs text-soft-foreground`,children:t.description}):null,r?(0,Q.jsx)(Ni,{"aria-hidden":`true`,className:`ml-auto size-3.5 shrink-0 text-link-foreground`}):null]},t.name)})}):null}function vE({global:e,skillItem:t}){return e.length>0?(0,Q.jsx)(Ds,{heading:`Global`,children:e.map(e=>t(e,!1))}):null}function yE({source:e,unchecked:t,ready:n,skillsLoading:r,skills:i,skillUsage:a,workflows:o,onPick:s}){let[c,l]=(0,Z.useState)(!1),[u,d]=(0,Z.useState)(``),[f,p]=(0,Z.useState)(null),m=(0,Z.useRef)(null),{mostUsed:h,project:g,global:_,ranked:v}=qs(i,u,a),y=o.find(e=>e.name===Rw),b=zs(o,u).filter(e=>e.name!==Rw),x=o.some(e=>e.name!==Rw),S=fE(y,u),C=dE(S,{ranked:v,mostUsed:h,project:g,global:_},b),w=e=>{s(e),l(!1)},T=t=>w(e?.source===t.source&&e.ref===t.ref&&(e.source!==`skill`||t.source!==`skill`||e.path===t.path)?null:t),E=(t,n)=>{let r=e?.source===`skill`&&e.ref===t.id&&e.path===t.path;return(0,Q.jsxs)(As,{value:Bs(t),keywords:Ws(t.name,t.description),"data-slot":`source-option`,"data-source-kind":`skill`,"data-source-ref":t.id,onSelect:()=>T({source:`skill`,ref:t.id,...t.path===void 0?{}:{path:t.path}}),children:[(0,Q.jsx)(lx,{skill:t,emphasized:n}),(0,Q.jsx)(`button`,{type:`button`,"data-slot":`source-skill-view`,"aria-label":`View skill ${t.name}`,title:`View skill`,onClick:e=>{e.preventDefault(),e.stopPropagation(),p(t)},className:`ml-auto shrink-0 rounded-sm p-0.5 text-soft-foreground transition-colors hover:text-foreground`,children:(0,Q.jsx)(ba,{"aria-hidden":`true`,className:`size-3.5`})}),r?(0,Q.jsx)(Ni,{"aria-hidden":`true`,className:`size-3.5 shrink-0 text-link-foreground`}):null]},Bs(t))},D=mE({source:e,ready:n,offersWorkflows:x,onPick:s,skillLabel:e?.source===`skill`?i.find(t=>t.id===e.ref&&(e.path===void 0||e.path===t.path))?.name:void 0});return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(VC,{skill:f,onClose:()=>p(null)}),(0,Q.jsxs)(po,{open:c,onOpenChange:e=>{l(e),e||d(``)},children:[(0,Q.jsxs)(`span`,{className:`inline-flex items-center`,children:[(0,Q.jsx)(co,{asChild:!0,children:D}),e?.source===`skill`&&t?(0,Q.jsx)(`span`,{role:`status`,children:`Unchecked`}):null,e!==null&&n?(0,Q.jsx)(`button`,{type:`button`,"data-slot":`source-pill-clear`,"aria-label":`Clear the ${e.source} ${e.ref}`,title:`Run without it`,onClick:()=>s(null),className:q(vC,`new-task-source-clear justify-center rounded-l-none border-foreground/60 px-2 text-soft-foreground hover:text-foreground`),children:(0,Q.jsx)(Fi,{"aria-hidden":`true`,className:`size-3`})}):null]}),(0,Q.jsx)(uo,{align:`start`,sideOffset:8,className:`w-[336px] max-w-[calc(100vw-2rem)] p-0`,children:(0,Q.jsxs)(Ns,{shouldFilter:!1,children:[(0,Q.jsx)(Ts,{placeholder:`search skills & workflows…`,value:u,onValueChange:d,onInput:()=>m.current?.scrollTo(0,0)}),(0,Q.jsxs)(Ms,{ref:m,"data-slot":`source-menu`,"aria-busy":r,className:`max-h-[min(18rem,calc(var(--radix-popover-content-available-height)-3rem))]`,children:[u.trim()&&!i.some(e=>e.id===u.trim())?(0,Q.jsx)(Ds,{children:(0,Q.jsxs)(As,{value:`typed-skill`,onSelect:()=>w({source:`skill`,ref:u.trim(),typed:!0}),children:[`Use skill id “`,u.trim(),`” (unchecked)`]})}):null,C&&!r?(0,Q.jsx)(js,{children:`Nothing matches.`}):null,S?(0,Q.jsx)(hE,{source:e,quickTask:y,onPick:w}):null,r?(0,Q.jsx)(`div`,{"data-slot":`source-skills-loading`,role:`status`,className:`px-2 py-1.5 text-xs text-muted-foreground`,children:`Loading skills…`}):null,(0,Q.jsx)(gE,{ranked:v,mostUsed:h,project:g,skillItem:E}),(0,Q.jsx)(_E,{source:e,matchedWorkflows:b,toggle:T}),(0,Q.jsx)(vE,{global:_,skillItem:E})]})]})})]})]})}function bE(){let[e,t]=Z.useState(!1),[n,r]=Z.useState(!1),[i,a]=Z.useState(!1);return(0,Q.jsxs)(ds,{route:`no-projects`,density:`empty`,children:[(0,Q.jsx)(tc,{icon:(0,Q.jsx)(pi,{}),tone:`neutral`,title:`No projects yet`,subtitle:`Open a local folder, clone a repository from GitHub, or create a new project to start running tasks.`,children:(0,Q.jsxs)(`div`,{"data-slot":`no-projects-actions`,className:`flex flex-wrap items-center justify-center gap-2`,children:[(0,Q.jsxs)(Y,{type:`button`,variant:`primary`,"data-action":`empty-open-local`,onClick:()=>t(!0),children:[(0,Q.jsx)(ai,{"aria-hidden":`true`}),`Open local folder…`]}),(0,Q.jsxs)(Y,{type:`button`,variant:`outline`,"data-action":`empty-clone-github`,onClick:()=>r(!0),children:[(0,Q.jsx)(di,{"aria-hidden":`true`}),`Clone from GitHub…`]}),(0,Q.jsxs)(Y,{type:`button`,variant:`outline`,"data-action":`empty-create-project`,onClick:()=>a(!0),children:[(0,Q.jsx)(pi,{"aria-hidden":`true`}),`New project…`]})]})}),e?(0,Q.jsx)(Hu,{open:!0,onOpenChange:t}):null,n?(0,Q.jsx)(Ku,{open:!0,onOpenChange:r}):null,i?(0,Q.jsx)(ld,{open:!0,onOpenChange:a}):null]})}function xE(){return(0,Q.jsx)(ds,{route:`not-found`,density:`empty`,header:{title:`Page not found`,subtitle:`Nothing lives at this address.`,primaryAction:(0,Q.jsx)(cs,{asChild:!0,variant:`outline`,children:(0,Q.jsx)(X,{to:`/`,children:`Back to tasks`})})},emptyState:(0,Q.jsx)(gs,{icon:(0,Q.jsx)(Uc,{className:`size-4`}),title:`Address not found`,description:`The link may be mistyped, or it points at something that is gone.`})})}function SE(){return(0,Q.jsx)(`div`,{className:`px-4 pt-2 md:hidden`,children:(0,Q.jsxs)(X,{to:`/git`,"data-slot":`git-back`,className:`inline-flex min-h-11 items-center gap-1.5 text-xs font-medium text-muted-foreground hover:text-foreground`,children:[(0,Q.jsx)(Vi,{size:16,"aria-hidden":`true`,className:`size-3.5`}),`Back to Git`]})})}function CE(){let{pathname:e,search:t}=qn();return(0,Q.jsxs)(_s,{route:`repo-git`,density:`sparse`,flushPadding:!0,children:[Oo(e)!==`/git`||new URLSearchParams(t).get(`view`)===`repo`?(0,Q.jsx)(SE,{}):null,(0,Q.jsx)(tc,{icon:(0,Q.jsx)(xa,{className:`motion-safe:animate-spin`}),tone:`neutral`,title:`Loading repository…`,subtitle:`Fetching the repo's git state.`})]})}function wE(){return(0,Q.jsxs)(ls,{route:`skills`,density:`sparse`,rootProps:{"aria-busy":`true`},header:{title:`Skills`,subtitle:`The skills each agent loads in this project, as its runner reports them.`},children:[(0,Q.jsx)(`p`,{"data-slot":`skills-loading`,role:`status`,className:`text-xs text-muted-foreground`,children:`Loading skills…`}),(0,Q.jsxs)(`div`,{"aria-hidden":`true`,className:`mt-4 flex flex-col gap-[22px] motion-safe:animate-pulse`,children:[(0,Q.jsx)(`div`,{className:`h-11 rounded-lg border border-border bg-card`}),(0,Q.jsx)(`div`,{className:`h-80 rounded-xl border border-border bg-card`})]})]})}function TE({projectId:e,registry:t}){let n=t.projects.length?t.projects:t.bootProject===null?[]:[{id:t.bootProject,name:t.bootProject}];return(0,Q.jsx)(ds,{route:`unknown-project`,density:`empty`,children:(0,Q.jsx)(tc,{icon:(0,Q.jsx)(Qc,{}),tone:`neutral`,title:`“${e}” isn’t registered here`,subtitle:n.length>0?`This Squawk doesn’t serve a project by that id. The link may come from another machine’s workspace — these are the projects registered on this one:`:`This Squawk doesn’t serve a project by that id, and no projects are registered on this server yet.`,children:n.length>0?(0,Q.jsx)(`ul`,{"data-slot":`registered-projects`,className:`mx-auto flex w-full max-w-xs flex-col gap-1.5 text-left`,children:n.map(e=>(0,Q.jsx)(`li`,{children:(0,Q.jsxs)(G,{to:`/p/${encodeURIComponent(e.id)}/`,className:`flex items-baseline gap-2 rounded-md border border-border bg-card px-3 py-2 text-sm font-medium text-foreground shadow-xs transition-colors hover:bg-card-2`,children:[e.name||e.id,(0,Q.jsxs)(`span`,{className:`font-mono text-xs font-normal text-muted-foreground`,children:[`/p/`,e.id]})]})},e.id))}):(0,Q.jsx)(Y,{asChild:!0,variant:`primary`,children:(0,Q.jsx)(G,{to:`/`,children:`Add a project`})})})})}function EE(){return(0,Q.jsxs)(_s,{route:`workflows`,density:`sparse`,rootProps:{"aria-busy":`true`},header:{title:`Workflows`,subtitle:`Portable skill chains. Steps run from top to bottom.`},children:[(0,Q.jsx)(`p`,{"data-slot":`workflows-loading`,role:`status`,className:`text-xs text-muted-foreground`,children:`Loading workflows…`}),(0,Q.jsxs)(`div`,{"aria-hidden":`true`,className:`mt-4 flex flex-col gap-[22px] motion-safe:animate-pulse`,children:[(0,Q.jsx)(`div`,{className:`h-11 rounded-lg border border-border bg-card`}),(0,Q.jsx)(`div`,{className:`h-80 rounded-xl border border-border bg-card`})]})]})}function DE({tab:e}){return(0,Q.jsx)(ds,{route:`task-${e}`,density:`sparse`,flushPadding:!0,children:(0,Q.jsx)(tc,{icon:(0,Q.jsx)(xa,{className:`motion-safe:animate-spin`}),tone:`neutral`,title:e===`changes`?`Loading changes…`:`Loading files…`,subtitle:`Fetching the run record.`})})}function OE({tab:e,error:t}){let n=t instanceof Tn&&t.status===404;return(0,Q.jsx)(ds,{route:`task-${e}`,density:`empty`,flushPadding:!0,children:(0,Q.jsx)(tc,{icon:n?(0,Q.jsx)(Ca,{}):(0,Q.jsx)(wi,{size:16}),tone:n?`neutral`:`danger`,title:n?`Task not found`:`Could not load this task`,subtitle:n?`No run has this id. It may have been deleted, or the link is from another machine.`:t.message,actions:(0,Q.jsx)(Y,{asChild:!0,variant:`outline`,children:(0,Q.jsx)(X,{to:`/`,children:`Back to tasks`})})})})}var kE={issue:`issue`,pr:`pull request`};function AE({kind:e,number:t,heading:n=`h1`}){let r=(0,Q.jsx)(`div`,{"data-slot":`task-github-loading`,className:`flex min-h-full flex-1 flex-col`,children:(0,Q.jsx)(tc,{icon:(0,Q.jsx)(xa,{className:`motion-safe:animate-spin`}),tone:`neutral`,heading:n,title:`Loading ${kE[e]}${t===void 0?``:` #${t}`}…`,subtitle:t===void 0?`Fetching the run record.`:`Asking GitHub.`})});return n===`h2`?r:(0,Q.jsx)(ds,{route:`task-github-item`,density:`sparse`,flushPadding:!0,children:r})}function jE(){return(0,Q.jsx)(ds,{route:`task-thread`,density:`sparse`,flushPadding:!0,children:(0,Q.jsx)(tc,{icon:(0,Q.jsx)(xa,{className:`motion-safe:animate-spin`}),tone:`neutral`,title:`Loading task…`,subtitle:`Fetching the run and its session transcript.`})})}var ME=(0,Z.createContext)(null),NE=/^[0-9a-f-]{36}$/i,PE=/^(\/p\/[^/?#]+\/tasks\/[^/?#]+)\/files\?(artifact=[^&#]*)$/;function FE(e){let t=new URLSearchParams(e);return[...t.keys()].length===1&&NE.test(t.get(`artifact`)??``)}function IE(e,t,n){if(e.startsWith(`${t}?artifact=`))return FE(e.slice(t.length+1))?n+e.slice(t.length):null;let r=PE.exec(e);return r&&FE(r[2])?`${r[1]}/report?${r[2]}`:void 0}var LE=/^\/(?:api|p|tasks|new|settings|skills|workflows|git|github|inbox|automations)(?:\/|[?#]|$)/;function RE(e,t){let n=/^[a-z]:[\\/]/i.test(e),r=/^file:/i.test(e);if(!n&&/^[a-z][a-z\d+.-]*:/i.test(e)&&!r)return null;let i=r?e:decodeURIComponent(e);if(/[\u0000-\u001f]/.test(i))return null;if(!t||i.startsWith(`/`)||n||r)return i;let a=t.replaceAll(`\\`,`/`);return a.slice(0,a.lastIndexOf(`/`)+1)+i}function zE(e,t){if(!e||/[\u0000-\u001f]/.test(e)||e.startsWith(`#`)||e.startsWith(`//`))return null;let n=e.indexOf(`#`),r=n<0?e:e.slice(0,n),i=n<0?``:e.slice(n),a=t.projectId?`/p/${encodeURIComponent(t.projectId)}`:``,o=`/tasks/${encodeURIComponent(t.runId)}/files`,s=`/tasks/${encodeURIComponent(t.runId)}/report`,c=IE(r,o,a+s);if(c!==void 0)return c===null?null:c+i;if(LE.test(r))return null;let l=RE(r,t.basePath);return l===null?null:`${a}${nc(l)?s:o}?path=${encodeURIComponent(l)}${i}`}function BE(e,t){let n=e.replace(/^\.\//,``);if(!t)return n;let r=`${t.replace(/\/+$/,``)}/`;return n.startsWith(r)?n.slice(r.length):n}function VE(e,t=!1){return e.status===`review`&&!t&&!at(e)}var HE=e=>`${e} ${e===1?`check`:`checks`}`;function UE(e){let t=e.steps.filter(e=>e.kind===`check`),n=t.filter(e=>e.status===`done`).length,r=t.filter(e=>e.status===`failed`).length,i=r>0?`${HE(r)} failed${n>0?`, ${n} passed`:``}`:n>0?`${HE(n)} passed`:void 0;return{...e.diffStat&&e.diffStat.files>0?{diff:e.diffStat}:{},...i===void 0?{}:{checks:{label:i,failed:r>0}}}}async function WE(e,t,n,r,i){try{return await vc(e,{queryKey:[t,`runs`,`artifact-metadata`,n,r],queryFn:({signal:e})=>wn(n,r,{signal:e})},i),!0}catch(e){if(e instanceof Tn&&e.status===404)return!1;throw e}}async function GE(e,t,n,r,i,a){if(await WE(e,t,n,r,i))return n;i.throwIfAborted();let o=await vc(e,{queryKey:[t,`runs`,`relationships`,n],queryFn:({signal:e})=>pt(n,{signal:e})},i),s=new Set(o.workers.map(e=>e.workerId));a&&s.add(a),s.delete(n);for(let n of s){if(i.aborted)throw i.reason;if(await WE(e,t,n,r,i))return n}throw new Tn(404,`Report missing or deleted`)}function KE(e,t,n){let r=U(),i=Ie();return Jt({queryKey:[i,`runs`,`report-source`,e,t,n],queryFn:({signal:a})=>GE(r,i,e,t,a,n),enabled:!!(e&&t),retry:!1})}var qE=`cez-preview-tasks`,JE=`cez.preview.pane-width`,YE=e=>Math.min(75,Math.max(30,Math.round(e)));function XE(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function ZE(e){if(!XE(e))return;let{port:t,agent:n,url:r}=e;if(typeof t==`number`&&Number.isInteger(t)&&t>=1&&t<=65535)return{port:t};if(n===!0)return{agent:!0};if(typeof r==`string`&&/^https?:\/\//i.test(r))return{url:r}}function QE(e){if(!XE(e))return;let t=ZE(e.target),n=typeof e.percent==`number`&&Number.isFinite(e.percent)?e.percent:void 0;return{open:e.open===!0,...t?{target:t}:{},...n===void 0?{}:{percent:n},at:typeof e.at==`number`?e.at:0}}function $E(){try{let e=localStorage.getItem(qE),t=e===null?null:JSON.parse(e);return XE(t)?t:{}}catch{return{}}}function eD(e){let t=QE($E()[e]);if(!t)return;let{at:n,...r}=t;return r}function tD(e,t,n=Date.now()){let r=$E(),i={open:!1,...QE(r[e]),...t,at:n};for(let e of Object.keys(i))i[e]===void 0&&delete i[e];r[e]=i;let a=Object.keys(r);if(a.length>100){let e=e=>QE(r[e])?.at??0;for(let t of a.sort((t,n)=>e(t)-e(n)).slice(0,a.length-100))delete r[t]}try{localStorage.setItem(qE,JSON.stringify(r))}catch{}}function nD(){try{let e=Number(localStorage.getItem(JE));return e>0?e:void 0}catch{return}}function rD(e){let t=(e===void 0?void 0:eD(e)?.percent)??nD();return t===void 0?58:YE(t)}function iD(e,t){try{localStorage.setItem(JE,String(t))}catch{}e!==void 0&&tD(e,{percent:t})}var aD=`cez-split-workbench`;function oD(){try{return localStorage.getItem(aD)===`on`}catch{return!1}}function sD(e){try{e?localStorage.setItem(aD,`on`):localStorage.removeItem(aD)}catch{}}var cD=`(min-width: 1180px)`,lD=`(min-width: 1280px)`,uD=`(max-width: 767px)`;function dD(e,t){let[n,r]=(0,Z.useState)(()=>window.matchMedia?.(e).matches??t);return(0,Z.useEffect)(()=>{let t=window.matchMedia?.(e);if(!t)return;let n=()=>r(t.matches);return n(),t.addEventListener(`change`,n),()=>t.removeEventListener(`change`,n)},[e]),n}function fD(e){if(!e.worktreePath||e.worktreeReclaimedAt)return!0;let t=e.delegation?.role===`worker`?e.delegation.destroy:void 0;return t!==void 0&&!t.remaining.includes(`worktree`)}function pD(e){let{state:t,server:n}=e,r=ys(e.stateAt);switch(t){case`registered`:return n.answeredAtRegistration?{tone:`neutral`,ring:!1,pulse:!1,text:`was running when registered`}:{tone:`neutral`,ring:!0,pulse:!1,text:`registered · not started`};case`adopted`:return{tone:`neutral`,ring:!1,pulse:!1,text:`was running when registered`};case`starting`:return{tone:`pending`,ring:!1,pulse:!0,text:`starting`};case`up`:return{tone:`success`,ring:!1,pulse:!1,text:r?`up · ${r}`:`up`};case`stalled`:return{tone:`pending`,ring:!1,pulse:!1,text:`stalled · port silent 2 min`};case`exited`:return{tone:`danger`,ring:!1,pulse:!1,text:e.exitCode===void 0?`exited`:`exited · code ${e.exitCode}`};case`stopped`:return{tone:`neutral`,ring:!0,pulse:!1,text:e.reason===`idle`?`stopped after 15 min idle`:`stopped`};case`unavailable`:return{tone:`neutral`,ring:!0,pulse:!1,text:`unavailable`}}}function mD(e){return{kind:`preview-server`,id:`preview-server:${e.port}`,server:e,state:`registered`,stateAt:e.registeredAt}}function hD(e,t){return t?.get(e.port)??mD(e)}function gD(e){return e.state===`registered`?e.server.answeredAtRegistration:e.state===`up`||e.state===`starting`||e.state===`adopted`}function _D(e){return e.split(` -- `)[0].trim()}var vD=(0,Z.createContext)(null);function yD(){return(0,Z.useContext)(vD)}function bD(e){return e.report?`report`:e.preview?`preview`:e.changes?`changes`:null}var xD=(0,Z.createContext)(null);function SD(){return(0,Z.useContext)(xD)}var CD=e=>e&&`port`in e?e.port:void 0;function wD(){return typeof window.matchMedia!=`function`||window.matchMedia(`(min-width: 1180px)`).matches}function TD(e){let t=e===void 0?void 0:eD(e),n=t?.open===!0,r=n?t.target:void 0;return{open:n,target:r,request:n?{...r,restored:!0}:void 0,session:n&&!wD(),percent:rD(e)}}function ED(e,t=!1){let[n]=(0,Z.useState)(()=>TD(e)),[r,i]=(0,Z.useState)(n.open),[a,o]=(0,Z.useState)(!1),[s,c]=(0,Z.useState)(n.target),[l,u]=(0,Z.useState)(n.session),[d,f]=(0,Z.useState)(n.request),[p,m]=(0,Z.useState)(n.percent),[h,g]=(0,Z.useState)(oD),[_,v]=(0,Z.useState)(e),y=(0,Z.useRef)(r);if(y.current=r,_!==e){let t=TD(e);v(e),i(t.open),o(!1),c(t.target),u(t.session),f(t.request),m(t.percent)}t&&r&&d?.restored&&(i(!1),c(void 0),f(void 0),u(!1));let b=(0,Z.useCallback)(t=>{e!==void 0&&tD(e,t)},[e]),x=(0,Z.useRef)(h);x.current=h;let S=(0,Z.useCallback)(e=>{g(e),sD(e)},[]),C=(0,Z.useCallback)(e=>{x.current&&S(!1),f({...e});let t=e.port===void 0?e.agent?{agent:!0}:void 0:{port:e.port};u(!1),i(!0),t?(c(t),b({open:!0,target:t})):y.current?b({open:!0}):(c(void 0),b({open:!0,target:void 0}))},[b,S]),w=(0,Z.useCallback)(()=>{i(!1),o(!1),u(!1),c(void 0),b({open:!1})},[b]),T=(0,Z.useCallback)(e=>{c(e),b({target:e})},[b]),E=(0,Z.useCallback)(t=>{m(t),iD(e,t)},[e]),D=(0,Z.useCallback)(()=>u(!0),[]),O=CD(s),k=(0,Z.useCallback)(e=>{e&&y.current&&w(),S(e)},[w,S]);return(0,Z.useMemo)(()=>({open:r,live:a,port:O,target:s,percent:p,request:d,session:l,changes:h,openPane:C,closePane:w,showSession:D,setLive:o,setTarget:T,setPercent:E,setChanges:k}),[r,a,O,s,p,d,l,h,C,w,D,T,E,k])}var DD=(0,Z.lazy)(()=>W(()=>import(`./preview-pane-connected-E8n0RgYL.js`).then(e=>({default:e.ConnectedPreviewPane})),__vite__mapDeps([76,1,2,7,8,9,10,11,16,77,78,79,80,42,81,82,60,83,84,85,20,43,44,15,24,31,33,34,46,13,14,25,26,86,87,88]))),OD=2,kD=(0,Z.createContext)(null);function AD(){return(0,Z.useContext)(kD)!==null}function jD(){return(0,Z.useContext)(kD)}function MD(e){let[t,n]=(0,Z.useState)(void 0);return(0,Z.useEffect)(()=>{let t=e.current?.closest(`[data-slot="main"]`);if(!t)return;let r=()=>n(t.clientHeight||void 0);if(r(),typeof ResizeObserver>`u`)return;let i=new ResizeObserver(r);return i.observe(t),()=>i.disconnect()},[e]),t}function ND({run:e,state:t,children:n,report:r,changes:i}){let a=dD(cD,!0),o=dD(uD,!1),s=(0,Z.useRef)(null),c=MD(s),{percent:l,setPercent:u}=t,d=bD({report:!!r,preview:t.open&&e!==void 0,changes:!!i}),f=d!==null,p=f&&!a,m=!r&&t.session,h=p&&!m,g=p&&m,_={"--preview-pane":`${l}%`,...c===void 0?{}:{"--preview-h":`${c}px`}};return(0,Q.jsxs)(`div`,{ref:s,"data-slot":`task-split`,"data-pane":f?`open`:`closed`,"data-takeover":h?``:void 0,className:`preview-split flex min-h-full w-full min-w-0`,style:_,children:[(0,Q.jsx)(`div`,{"data-slot":`task-main`,hidden:h&&o,"data-collapsed":h&&!o?``:void 0,className:`min-w-0 flex-1`,children:(0,Q.jsx)(kD.Provider,{value:d,children:n})}),f?(0,Q.jsxs)(Q.Fragment,{children:[a?(0,Q.jsx)(PD,{wrapper:s,percent:l,setPercent:u,label:d===`changes`?`Resize changes`:`Resize preview`}):null,(0,Q.jsxs)(`aside`,{"data-slot":`preview-pane`,"data-kind":d,"data-phone":o?``:void 0,hidden:g,className:`preview-pane`,children:[r,d===`changes`?i:null,(0,Q.jsx)(`div`,{hidden:d!==`preview`,className:`h-full`,children:t.open&&e?(0,Q.jsx)(FD,{run:e,state:t,inFront:h}):null})]})]}):null]})}function PD({wrapper:e,percent:t,setPercent:n,label:r}){let i=t=>{let r=e.current?.getBoundingClientRect();!r||r.width===0||n(YE((r.right-t)/r.width*100))};return(0,Q.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,"aria-label":r,"aria-valuemin":30,"aria-valuemax":75,"aria-valuenow":t,tabIndex:0,"data-slot":`preview-divider`,className:`preview-divider`,onPointerDown:e=>{e.currentTarget.setPointerCapture?.(e.pointerId)},onPointerMove:e=>{e.currentTarget.hasPointerCapture?.(e.pointerId)&&i(e.clientX)},onKeyDown:e=>{if(e.key===`ArrowLeft`)n(YE(t+OD));else if(e.key===`ArrowRight`)n(YE(t-OD));else return;e.preventDefault()}})}function FD({run:e,state:t,inFront:n}){return(0,Q.jsx)(wa,{onClose:t.closePane,children:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(`p`,{role:`status`,className:`p-6 text-sm text-muted-foreground`,children:`Opening the preview…`}),children:(0,Q.jsx)(DD,{run:e,servers:e.previewServers??[],request:t.request,onSession:n?t.showSession:void 0,onTarget:t.setTarget,onLive:t.setLive,onClose:t.closePane},e.id)})})}function ID(e){for(let t=e.length-1;t>=0;--t){let n=Ke.safeParse(e[t]);if(n.success)return n.data.state===`connected`}return!1}function LD(e){let{currentEvents:t}=Ea(e);return(0,Z.useMemo)(()=>ID(t),[t])}var RD=(0,Z.lazy)(()=>W(()=>import(`./report-reader-DHB5teJQ.js`).then(e=>({default:e.ReportReader})),__vite__mapDeps([89,1,2,6,7,8,9,10,11,12,13,14,15,90,16,91,20,44,24,31,33,34,28,92,51,45,93,94,95,96]))),zD=(0,Z.lazy)(()=>W(()=>import(`./review-strip-tiqQt7qS.js`).then(e=>e.n).then(e=>({default:e.ReviewStrip})),__vite__mapDeps([97,1,2,6,7,8,9,10,11,12,13,14,15,16,41,98,20,46,57,99,100,101,56,102]))),BD=(0,Z.lazy)(()=>W(()=>import(`./review-panel-858YvYOc.js`).then(e=>e.n).then(e=>({default:e.AcceptCelebration})),__vite__mapDeps([103,1,2,6,7,8,9,10,11,12,97,13,14,15,16,41,98,20,46,57,99,100,101,56,102,28,104,18,105,24,51,45,106,21]))),VD=(0,Z.lazy)(()=>W(()=>import(`./task-changes-BZ7Hlj9q.js`).then(e=>({default:e.ChangesPane})),__vite__mapDeps([107,1,2,6,7,8,9,10,11,12,13,14,15,108,109,62,24,33,34,100,101,16,87,40,26,41,19,42,43,20,44,31,45,81,110,22,23,46,25,88,56,57,93,94,95,51,111,112,113,114,91,115,116,64,65,28,117,106,21,102,118,119,120,121,122,123])));function HD(){let{id:e}=Hn(),t=j(e),n=qn(),r=Sm(c().data),i=t.data?fD(t.data):!1,a=ED(e,i),o=ns(e),s=KE(e,o.selection?.artifactId,o.sourceRunId),l=o.selection?(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(`p`,{role:`status`,children:`Loading report…`}),children:(0,Q.jsx)(RD,{runId:s.data??e??``,selection:{artifactId:o.selection.artifactId},fragment:n.hash,onBack:o.close,variant:`pane`,sourceLookup:s},`${e}:${o.selection.artifactId}`)}):void 0,{workbench:u,changes:d}=KD(t.data,a,o,{previewOpen:r&&a.open,reportOpen:l!==void 0}),f=r?(0,Q.jsx)(qD,{id:e,run:t.data,pane:a,removed:i,report:l,changes:d,children:(0,Q.jsx)(Bn,{})}):(0,Q.jsx)(ND,{run:t.data,state:{...a,open:!1},report:l,changes:d,children:(0,Q.jsx)(Bn,{})}),p=t.data&&VE(t.data)&&!UD.test(n.pathname)?t.data:void 0;return(0,Q.jsxs)(as.Provider,{value:o.registry,children:[(0,Q.jsx)(xD.Provider,{value:u,children:(0,Q.jsxs)(`div`,{"data-slot":`task-layout`,children:[f,p?(0,Q.jsx)(Z.Suspense,{fallback:null,children:(0,Q.jsx)(zD,{run:p},p.id)}):null]})}),t.data?(0,Q.jsx)(Z.Suspense,{fallback:null,children:(0,Q.jsx)(BD,{status:t.data.status},t.data.id)}):null]})}var UD=/\/report\/?$/,WD=/\/tasks\/[^/]+\/?$/,GD=/\/tasks\/[^/]+\/changes\/?$/;function KD(e,t,n,r){let i=qn(),a=Kn(),o=dD(lD,!1),s=(0,Z.useRef)(null),c=WD.test(i.pathname),l=o&&c&&t.changes?e:void 0,u=l!==void 0&&bD({report:r.reportOpen,preview:r.previewOpen,changes:!0})===`changes`,{setChanges:d}=t,f=n.close,p=(0,Z.useMemo)(()=>({available:o,showing:u,setOn:e=>{d(e),e&&(GD.test(i.pathname)?a(i.pathname.replace(/\/changes\/?$/,``)):r.reportOpen&&f())},revealChange:t=>u&&(s.current?.(BE(t,e?.worktreePath))??!1)}),[o,u,d,i.pathname,a,r.reportOpen,f,e?.worktreePath]);return{workbench:p,changes:l?(0,Q.jsxs)(`div`,{"data-slot":`changes-split-pane`,"data-scroll-root":!0,className:`h-full overflow-y-auto overscroll-contain`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-2 border-b border-border bg-background ps-4 pe-1 md:ps-9`,children:[(0,Q.jsx)(`h2`,{className:`text-xs font-semibold`,children:`Changes`}),(0,Q.jsx)(Y,{variant:`ghost`,size:`icon`,"aria-label":`Close split view`,onClick:()=>p.setOn(!1),children:(0,Q.jsx)(Fi,{"aria-hidden":`true`})})]}),(0,Q.jsx)(`div`,{className:`pt-4`,children:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(`p`,{role:`status`,className:`p-6 text-sm text-muted-foreground`,children:`Loading changes…`}),children:(0,Q.jsx)(VD,{run:l,revealRef:s},l.id)})})]}):void 0}}function qD({id:e,run:t,pane:n,removed:r,children:i,report:a,changes:o}){let s=LD(e),c=(0,Z.useMemo)(()=>({...n,worktreeRemoved:r,agentLive:s}),[n,r,s]);return(0,Q.jsx)(vD.Provider,{value:c,children:(0,Q.jsx)(ND,{run:t,state:n,report:a,changes:o,children:i})})}var JD=[`task`,`runner`,`workflow`,`branch`,`diff`,`reference`,`usage`,`started`],YD=[`status`,`task`,`workflow`,`branch`,`diff`,`reference`,`tokens`,`cost`,`cpu`,`memory`,`started`],XD=[{id:`status`,label:`Status`,canFold:!1,defaultExpanded:!0,align:`left`,width:`180px`},{id:`task`,label:`Task`,canFold:!1,defaultExpanded:!0,align:`left`,width:`320px`},{id:`runner`,label:`Runner`,canFold:!0,defaultExpanded:!1,align:`left`,width:`132px`,icon:`runner`},{id:`workflow`,label:`Workflow`,canFold:!0,defaultExpanded:!0,align:`left`,width:`108px`,icon:`workflow`},{id:`branch`,label:`Branch`,canFold:!0,defaultExpanded:!1,align:`left`,width:`76px`,icon:`branch`},{id:`diff`,label:`±`,summaryLabel:`Changes`,canFold:!0,defaultExpanded:!0,align:`left`,width:`80px`,resourceWidth:`70px`,icon:`diff`},{id:`reference`,label:`Ref`,summaryLabel:`Reference`,canFold:!0,defaultExpanded:!0,align:`left`,width:`76px`,icon:`reference`},{id:`usage`,label:`Usage`,canFold:!0,defaultExpanded:!0,align:`right`,width:`144px`,icon:`usage`},{id:`tokens`,label:`IN / OUT`,canFold:!0,defaultExpanded:!0,align:`right`,width:`96px`,icon:`tokens`,capability:`tokens`},{id:`cost`,label:`Cost`,canFold:!0,defaultExpanded:!0,align:`right`,width:`52px`,icon:`cost`,capability:`cost`},{id:`cpu`,label:`CPU`,canFold:!0,defaultExpanded:!0,align:`right`,width:`42px`,icon:`cpu`},{id:`memory`,label:`Mem`,canFold:!0,defaultExpanded:!0,align:`right`,width:`80px`,icon:`memory`},{id:`started`,label:`Started`,canFold:!0,defaultExpanded:!0,align:`right`,width:`64px`,resourceWidth:`42px`,icon:`started`}],ZD=new Map(XD.map(e=>[e.id,e]));function QD(e){return typeof e!=`object`||!e||Array.isArray(e)?{}:Object.fromEntries(Object.entries(e).filter(e=>typeof e[1]==`boolean`))}function $D(e){let t={};for(let[n,r]of Object.entries(QD(e))){let e=ZD.get(n);e?.canFold&&(t[e.id]=r)}return t}function eO(e,t){let n=ZD.get(e);return!n||!n.canFold?!0:t[e]??n.defaultExpanded}function tO(e,t){let n=QD(e);return ZD.get(t)?.canFold?{...n,[t]:!eO(t,$D(e))}:n}var nO=new Set(YD),rO=new Set(JD);function iO(){return XD.filter(e=>rO.has(e.id))}function aO(e){return XD.filter(t=>nO.has(t.id)&&(t.capability===void 0||e[t.capability]))}function oO(e,t){return t===`flat`?!1:t===`virtual`||e>=100}function sO(e,t){let n=t===null?-1:e.indexOf(t);return n<0?[]:[n-1,n,n+1].filter(t=>t>=0&&t<e.length)}function cO(e,t){let n=e.map(e=>eO(e.id,t)?Number.parseFloat(e.resourceWidth??e.width??`100`):42);return{"--task-columns":e.map((e,t)=>e.id===`task`?`minmax(220px, 1fr)`:`${n[t]}px`).join(` `),minInlineSize:n.reduce((t,n,r)=>t+(e[r]?.id===`task`?220:n),0)}}var lO=null,{min:uO,max:dO,abs:fO,floor:pO}=Math,mO=(e,t,n)=>uO(n,dO(t,e)),hO=e=>[...e].sort((e,t)=>e-t),gO=typeof queueMicrotask==`function`?queueMicrotask:e=>{Promise.resolve().then(e)},_O=()=>{let e;return[new Promise(t=>{e=t}),e]},vO=e=>{let t;return()=>(e&&=(t=e(),void 0),t)},yO=(e,t,n)=>{let r=n?`unshift`:`push`;for(let n=0;n<t;n++)e[r](-1);return e},bO=(e,t)=>{let n=e.t[t];return n===-1?e.o:n},xO=(e,t,n)=>{let r=e.t[t]===-1;return e.t[t]=n,e.i=uO(t,e.i),r},SO=(e,t)=>{if(!e.l)return 0;if(e.i>=t)return e.u[t];e.i<0&&(e.u[0]=0,e.i=0);let n=e.i,r=e.u[n];for(;n<t;)r+=bO(e,n),e.u[++n]=r;return e.i=t,r},CO=(e,t,n=0,r=e.l-1)=>{let i=n;for(;n<=r;){let a=pO((n+r)/2);SO(e,a)<=t?(i=a,n=a+1):r=a-1}return mO(i,0,e.l-1)},wO=(e,t,n)=>{let r=t-e.l;return e.i=n?-1:uO(t-1,e.i),e.l=t,r>0?(yO(e.u,r),yO(e.t,r,n),e.o*r):(e.u.splice(r),(n?e.t.splice(0,-r):e.t.splice(r)).reduce((t,n)=>t-(n===-1?e.o:n),0))},TO=typeof window<`u`,EO=e=>e.documentElement,DO=e=>e.ownerDocument,OO=e=>e.defaultView,kO=vO(()=>!!/iP(hone|od|ad)/.test(navigator.userAgent)||navigator.platform===`MacIntel`&&navigator.maxTouchPoints>0),AO=vO(()=>`scrollBehavior`in EO(document).style),jO=e=>dO(e.h(),e.p()),MO=(e,t=40,n=0,r,i=!1)=>{let a=!!n,o=1,s=0,c=0,l=0,u=0,d=0,f=0,p=0,m=0,h=lO,g=[0,a?dO(n-1,0):-1],_=0,v=!1,y=((e,t,n)=>({o:t,t:n?yO(n.slice(0,uO(e,n.length)),dO(0,e-n.length)):yO([],e),l:e,i:-1,u:yO([],e+1)}))(e,r?r[1]:t,r&&r[0]),b=new Set,x=()=>l-c,S=()=>x()+d+u,C=(e,t)=>((e,t,n,r)=>{if(r=uO(r,e.l-1),SO(e,r)<=t){let i=CO(e,n,r);return[CO(e,t,r,i),i]}{let i=CO(e,t,void 0,r);return[i,CO(e,n,i)]}})(y,e,t,g[0]),w=()=>SO(y,y.l),T=(e,t)=>{let n=SO(y,e)-d;return t?w()-n-E(e):n},E=e=>bO(y,e),D=(e,t=-1)=>y.t[e]===t,O=e=>{e&&(kO()&&p!==0||h&&m===1?d+=e:u+=e)};return{v:()=>{b.clear()},m:()=>o,_:()=>(e=>[e.t.slice(),e.o])(y),S:(e=200)=>{if(!v||a)return g;let t,n;if(f)[t,n]=g;else{let r=dO(0,S()),a=r+s;i||(e=dO(0,e),p!==1&&(r-=e),p!==2&&(a+=e)),[t,n]=g=C(dO(0,r),dO(0,a)),h&&(t=uO(t,h[0]),n=dO(n,h[1]))}return[dO(t,0),uO(n,y.l-1)]},$:e=>CO(y,e-c),I:D,k:T,R:E,T:()=>y.l,C:()=>l,M:()=>p!==0,p:()=>s,O:()=>c,h:w,H:()=>(f=u,u=0,[f,m===2]),W:(e,t)=>{let n=[e,t];return b.add(n),()=>{b.delete(n)}},B:(e,t)=>{let n,r,g=0;switch(e){case 1:{if(t===l&&m===0)break;let e=f;f=0;let n=t-l,i=fO(n);e&&i<fO(e)+1||m!==0||(p=n<0?2:1),a&&=!1,l=t,g=4;let o=x();o>=-s&&o<=w()&&(g+=1,r=i>s);break}case 2:g=8,p!==0&&(n=!0,g+=1),p=0,m=0,h=lO;break;case 3:{let e=t.filter(([e,t])=>!D(e,t));if(!e.length)break;O(e.reduce((e,[t,n])=>{let r;if(m===2)r=!0;else if(h&&m===1)r=t<h[0];else{let e=x(),n=T(t),i=E(t);r=p!==1&&m===0?n+i<=e:n<e&&n+i<e+s}return r&&(e+=n-E(t)),e},0));for(let[t,n]of e){let e=E(t),r=xO(y,t,n);i&&(_+=r?n:n-e)}i&&s&&_>s&&(O(((e,t)=>{let n=0,r=[];e.t.forEach((e,i)=>{e!==-1&&(r.push(e),i<t&&n++)}),e.i=-1;let i=hO(r),a=i.length,o=a/2|0,s=a%2==0?(i[o-1]+i[o])/2:i[o],c=e.o;return((e.o=s)-c)*dO(t-n,0)})(y,CO(y,S()))),i=!1),g=3,r=!0;break}case 4:s!==t&&(s||(v=r=!0),s=t,g=3);break;case 5:t[1]?(O(wO(y,t[0],!0)),m=2,g=1):(wO(y,t[0]),g=1);break;case 6:c=t;break;case 7:m=1;break;case 8:h=C(t,t+s),g=1}g&&(o=1+(2147483647&o),n&&d&&(u+=d,d=0),b.forEach(([e,t])=>{g&e&&t(r)}))}}},NO=setTimeout,PO=(e,t)=>t?-e:e,FO=(e,t,n,r,i,a)=>{let o=Date.now,s=0,c=!1,l=!1,u=!1,d=!1,f=(()=>{let t,n=()=>{t!=lO&&clearTimeout(t)},r=()=>{n(),t=NO(()=>{t=lO,(()=>{if(c||l)return c=!1,void f();u=!1,e.B(2)})()},150)};return r.J=n,r})(),p=()=>{s=o(),u&&(d=!0),a&&e.B(6,a()),e.B(1,r()),f()},m=t=>{if(c||!e.M()||t.ctrlKey)return;let r=o()-s;150>r&&50<r&&(n?t.deltaX:t.deltaY)&&(c=!0)},h=()=>{l=!0,u=d=!1},g=()=>{l=!1,kO()&&(u=!0)};return t.addEventListener(`scroll`,p),t.addEventListener(`wheel`,m,{passive:!0}),t.addEventListener(`touchstart`,h,{passive:!0}),t.addEventListener(`touchend`,g,{passive:!0}),{A:()=>{t.removeEventListener(`scroll`,p),t.removeEventListener(`wheel`,m),t.removeEventListener(`touchstart`,h),t.removeEventListener(`touchend`,g),f.J()},L:()=>{let[t,n]=e.H();t&&(i(t,n,d),d=!1,n&&e.p()>e.h()&&e.B(1,r()))}}},IO=(e,t,n)=>{let r;return[async(i,a)=>{if(!await t())return;r&&r();let o=()=>{let[t,n]=_O();return r=()=>{n(!1)},e.p()&&NO(r,150),[t,e.W(2,()=>{n(!0)})]};if(a&&AO())e.B(8,i()),gO(async()=>{for(;;){let t=!0;for(let[n,r]=e.S();n<=r;n++)if(e.I(n)){t=!1;break}if(t)break;let[n,r]=o();try{if(!await n)return}finally{r()}}e.B(7),n(i(),a)});else for(;;){let[t,r]=o();try{if(e.B(7),n(i()),!await t)return}finally{r()}}},()=>{r&&r()}]},LO=(e,t)=>{let n,r,i=_O(),a=!1,o=t?`scrollLeft`:`scrollTop`,s=t?`overflowX`:`overflowY`,[c,l]=IO(e,()=>i[0],(e,r)=>{e=PO(e,a),r?n.scrollTo({[t?`left`:`top`]:e,behavior:`smooth`}):n[o]=e});return{N(c,u){n=u,t&&(a=getComputedStyle(u).direction===`rtl`),r=FO(e,u,t,()=>PO(u[o],a),(t,n,r)=>{if(r){let e=u.style,t=e[s];e[s]=`hidden`,NO(()=>{e[s]=t})}u[o]=PO(e.C()+t,a),n&&l()}),i[1](!0)},v(){r&&r.A(),i[1](!1),i=_O()},P:()=>a,V(e){c(()=>e)},X(t){t+=e.C(),c(()=>t)},Y(t,{align:n,smooth:r,offset:i=0}={}){if(t=mO(t,0,e.T()-1),n===`nearest`){let r=e.k(t),i=e.C();if(r<i)n=`start`;else{if(!(r+e.R(t)>i+e.p()))return;n=`end`}}c(()=>i+e.O()+e.k(t)+(n===`end`?e.R(t)-e.p():n===`center`?(e.R(t)-e.p())/2:0),r)},q:()=>{r&&r.L()}}},RO=e=>{let t;return{j(n){(t||=new(OO(DO(n))).ResizeObserver(e)).observe(n)},D(e){t.unobserve(e)},A(){t&&t.disconnect()}}},zO=(e,t)=>{let n,r=t?`width`:`height`,i=new WeakMap,a=RO(t=>{let a=[];for(let{target:o,contentRect:s}of t)if(o.offsetParent)if(o===n)e.B(4,s[r]);else{let e=i.get(o);e!=lO&&a.push([e,s[r]])}a.length&&e.B(3,a)});return{G(e){a.j(n=e)},U:(e,t)=>(i.set(e,t),a.j(e),()=>{i.delete(e),a.D(e)}),v:a.A}},BO=TO?Z.useLayoutEffect:Z.useEffect,VO=`current`,HO=(e,t)=>{if(Array.isArray(e))for(let n of e)HO(n,t);else e==null||typeof e==`boolean`||t.push(e)},UO=(e,t)=>e.key??`_`+t,WO=e=>{let t=(0,Z.useRef)(null);return t[VO]||(t[VO]=e())},GO=e=>{let t=(0,Z.useRef)(e);return BO(()=>{t[VO]=e},[e]),t},KO=(0,Z.memo)(({Z:e,ee:t,te:n,oe:r,ne:i,re:a,se:o,ie:s})=>{let c=(0,Z.useRef)(null);BO(()=>t(c[VO],n),[n]);let l=(0,Z.useMemo)(()=>{let e={contain:`layout style`,position:i&&s?void 0:`absolute`,[o?`height`:`width`]:`100%`,[o?`top`:`left`]:0,[o?`left`:`top`]:r,visibility:!i||s?void 0:`hidden`};return o&&(e.display=`inline-flex`),e},[r,i,s,o]);return(0,Q.jsx)(a,typeof a==`string`?{ref:c,style:l,children:e}:{ref:c,style:l,index:n,children:e})}),qO=(e,t)=>(0,Z.useMemo)(()=>{if(typeof e==`function`)return[n=>e(t[n],n),t.length];let n=(e=>{let t=[];return HO(e,t),t})(e);return[e=>n[e],n.length]},[e,t]),JO=(0,Z.forwardRef)(({children:e,data:t,bufferSize:n,itemSize:r,shift:i,horizontal:a,keepMounted:o,cache:s,startMargin:c=0,ssrCount:l,as:u=`div`,item:d=`div`,scrollRef:f,onScroll:p,onScrollEnd:m},h)=>{let[g,_]=qO(e,t),v=(0,Z.useRef)(null),y=(0,Z.useRef)(!!l),b=GO(p),x=GO(m),[S,C,w,T]=WO(()=>{let e=!!a,t=MO(_,r,l,s,!r);return[t,zO(t,e),LO(t,e),e]});_!==S.T()&&S.B(5,[_,i]),c!==S.O()&&S.B(6,c);let[E,D]=(0,Z.useReducer)(S.m,void 0,S.m),O=S.M(),k=S.h(),A=w.P(),j=[],M=e=>{let t=g(e);return(0,Q.jsx)(KO,{ee:C.U,te:e,oe:S.k(e,A),ne:S.I(e),re:d,Z:t,se:T,ie:y[VO]},UO(t,e))};if(BO(()=>{y[VO]=!1,S.W(1,e=>{e?(0,Of.flushSync)(D):D()}),S.W(4,()=>{b[VO]&&b[VO](S.C())}),S.W(8,()=>{x[VO]&&x[VO]()});let e=v[VO],t=t=>{C.G(t),w.N(e,t)};return f?gO(()=>{f[VO]&&t(f[VO])}):t(e.parentElement),()=>{S.v(),C.v(),w.v()}},[]),BO(()=>{w.q()},[E]),(0,Z.useImperativeHandle)(h,()=>({get cache(){return S._()},get scrollOffset(){return S.C()},get scrollSize(){return jO(S)},get viewportSize(){return S.p()},findItemIndex:S.$,getItemOffset:S.k,getItemSize:S.R,scrollToIndex:w.Y,scrollTo:w.V,scrollBy:w.X}),[]),o){let e=new Set(o);for(let[t,r]=S.S(n);t<=r;t++)e.add(t);hO([...e]).forEach(e=>{j.push(M(e))})}else for(let[e,t]=S.S(n);e<=t;e++)j.push(M(e));return(0,Q.jsx)(u,{ref:v,style:{contain:`size style`,overflowAnchor:`none`,flex:`none`,position:`relative`,width:T?k:`100%`,height:T?`100%`:k,pointerEvents:O?`none`:void 0},children:j})});function YO(e,t){let[n,r]=(0,Z.useState)(!1),[i,a]=(0,Z.useState)(``),o=(0,Z.useRef)(!1);return{editing:n,draft:i,setDraft:a,begin:()=>{a(e),o.current=!1,r(!0)},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 XO({editor:e,className:t}){return(0,Q.jsx)(`input`,{"data-slot":`title-input`,"aria-label":`Task title`,autoFocus:!0,value:e.draft,onChange:t=>e.setDraft(t.target.value),onBlur:e.commit,onKeyDown:t=>{t.key===`Enter`?(t.preventDefault(),e.commit()):t.key===`Escape`&&(t.preventDefault(),e.cancel())},className:q(`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)})}function ZO(e){let t=new Map,n=new Set,r;return{begin:e,editingId:()=>r?.id??null,subscribeSelection(e){return n.add(e),()=>{n.delete(e)}},snapshot:e=>r?.id===e?r.editor:null,subscribe(e,n){let r=t.get(e);return r||(r=new Set,t.set(e,r)),r.add(n),()=>{r.delete(n),r.size||t.delete(e)}},publish(e,i){let a=r?.id;if(r=e&&i.editing?{id:e,editor:i}:void 0,a!==r?.id)for(let e of n)e();for(let e of new Set([a,r?.id]))if(e)for(let n of t.get(e)??[])n()}}}var QO=(0,Z.createContext)(null),$O={editing:!1,draft:``,begin(){},setDraft(){},commit(){},cancel(){}};function ek({children:e,runs:t,onRename:n}){let[r,i]=(0,Z.useState)(),[a]=(0,Z.useState)(()=>ZO(e=>i({run:e}))),o=t.find(e=>e.id===r?.run.id),s=YO(o?Ro(o):``,e=>{o&&n(o.id,e)});return(0,Z.useEffect)(()=>{r&&s.begin()},[r]),(0,Z.useEffect)(()=>{r&&!o&&(s.cancel(),i(void 0))},[r,o,s]),(0,Z.useLayoutEffect)(()=>{a.publish(o?.id,s)},[a,o?.id,s]),(0,Q.jsx)(QO,{value:a,children:e})}function tk(e){let t=(0,Z.useContext)(QO);if(!t)throw Error(`Task title editor needs its page provider`);return{...(0,Z.useSyncExternalStore)((0,Z.useCallback)(n=>t.subscribe(e.id,n),[t,e.id]),(0,Z.useCallback)(()=>t.snapshot(e.id),[t,e.id]))??$O,begin:()=>t.begin(e)}}var nk=()=>null;function rk(){return ik}function ik(){}function ak(){let e=(0,Z.useContext)(QO);return(0,Z.useSyncExternalStore)(e?.subscribeSelection??rk,e?.editingId??nk)}function ok(e,t,n){return n===void 0?e===void 0?t:`${e}/${t}`:`host:${n}/${e??``}/${t}`}var sk=new Set([`done`,`failed`,`cancelled`]);function ck(e,t=240){let n=e.replace(/\s+/g,` `).trim();return n.length<=t?n:`${n.slice(0,t-1).trimEnd()}…`}function lk(e,t){if(e.statePreview)return e.statePreview;if(!e.archived){if(e.hasPendingPermission)return{kind:`permission`,text:`Permission requested`};if(t.rung===`needs-you`)return{kind:`ask`,text:`Waiting for your reply`};if(e.status===`review`)return{kind:`review`,text:`Ready for review`}}if(e.status===`failed`&&!lt(e)&&e.error){let t=ck(e.error);if(t)return{kind:`error`,text:t}}}function uk(e,t){let n=e.runner?ye(t,e.runner):void 0,r=e.model?.trim()||void 0;return n&&r?`${n} · ${r}`:n??r}function dk(e,t){let n=[],r=t.showTokens&&(e.inputTokens!==void 0||e.outputTokens!==void 0)?(e.inputTokens??0)+(e.outputTokens??0):0;r>0&&n.push(Cs(r));let i=t.showCost?_r(e.costUsd):``;return i&&n.push(i),n}function fk(e,t,n){return e.inputTokens!==void 0||e.outputTokens!==void 0||e.costUsd!==void 0||!!(t||n||e.branch)}function pk(e,t,n){let r=dk(e,n),i=tr(e,t);return r.length<2&&i.cpu.kind===`live`&&i.cpu.text?r.push(i.cpu.text):r.length===0&&i.mem.text&&r.push(i.mem.text),{label:r.length>0?r.join(` · `):`Usage`,hasData:r.length>0||fk(e,i.cpu.text,i.mem.text)}}function mk({run:e,queuePosition:t=null,runners:n,automationName:r,repoBase:i,now:a,showTokens:o=!0,showCost:s=!0}){let c=qe(e),l=zm(e,c),u=Ar(e,a===void 0?void 0:new Date(a)),d=pk(e,e.usage,{showTokens:o,showCost:s}),f=e.automationId;return{key:e.id,runId:e.id,tags:[],run:e,href:`/tasks/${e.id}`,title:Ro(e),isWorker:No(e),unread:mn(e),readDone:Zo(e),canToggleRead:xt(e),unreadTone:Xo(e),attention:c,status:l,urgent:Nt(e),scheduled:u,pinned:!!e.pinned,queuePosition:t,automationBadge:f===void 0?void 0:{id:f,label:r?.(f)??f},runnerModel:uk(e,n),statePreview:lk(e,c),workflow:cr(e),branch:e.branch,diffStat:e.diffStat,references:nr(e,i),repoBase:i,startedAt:e.startedAt??e.createdAt,usageSummary:d.label,hasUsageData:d.hasData,snapshotUsage:e.usage,canArchive:e.archived||sk.has(e.status)}}function hk(e){return typeof e==`string`?e:e.pathname??``}var gk=new WeakMap;function _k(e){let t=new Date(e);return`${t.getFullYear()}-${t.getMonth()}-${t.getDate()}`}function vk(e,t){return!!(e&&e.queuePosition===t.queuePosition&&e.runners===t.runners&&e.autoLabel===t.autoLabel&&e.showTokens===t.showTokens&&e.showCost===t.showCost&&e.dayKey===t.dayKey)}function yk(e){return e.hostId===void 0?{}:{hostId:e.hostId,hostLabel:e.hostLabel??e.hostId,hostStale:!!e.hostStale,hostState:e.hostState,fullPageNav:!0}}function bk({task:e,queuePosition:t=null,runners:n,automationName:r,now:i,showTokens:a=!0,showCost:o=!0}){let s=e.run,c=s.automationId===void 0?void 0:r?.(e),l=lt(s)?i??Date.now():void 0,u={queuePosition:t,runners:n,autoLabel:c,showTokens:a,showCost:o,dayKey:l===void 0?``:_k(l)},d=gk.get(e);if(vk(d,u))return d.model;let f=mk({run:s,queuePosition:t,runners:n,automationName:c===void 0?void 0:()=>c,repoBase:e.project?.repoUrl,now:l,showTokens:a,showCost:o}),p=e.hostId!==void 0,m={...f,key:ok(s.projectId,s.id,e.hostId),...yk(e),projectId:s.projectId,projectName:e.projectName,projectHref:p?Ne(e.hostId,s.projectId):hk(wo(s.projectId,`/`)),tags:e.tags,href:p?Re(e.hostId,s.projectId,s.id):hk(wo(s.projectId,`/tasks/${s.id}`)),references:nr(s,e.project?.repoUrl,s.projectId)};return gk.set(e,{...u,model:m}),m}var xk=(0,Z.createContext)(null);function Sk(e,t,n=!1){let[r,i]=(0,Z.useState)(null),a=(0,Z.useRef)(new Map),o=(0,Z.useCallback)((e,t)=>{t?a.current.set(e,t):a.current.delete(e)},[]),s=(0,Z.useCallback)(e=>[...a.current.values()].some(t=>t.includes(e)),[]);return{props:Ck(e,t,i,n?s:void 0),value:(0,Z.useMemo)(()=>({focused:r,revision:t,registerList:n?o:void 0}),[r,t,o,n])}}function Ck(e,t,n,r){let i=(0,Z.useRef)(r);(0,Z.useLayoutEffect)(()=>{i.current=r});let a=(0,Z.useRef)(null),o=(0,Z.useRef)(null);return(0,Z.useLayoutEffect)(()=>{let e=o.current;if(!e||e.element.isConnected||document.activeElement!==document.body)return;let t=()=>{o.current===e&&(o.current=null,n?.(null))},r=()=>{let n=ok(e.project,e.runId,e.hostId);if(i.current&&!i.current(n)||document.activeElement!==document.body||e.element.isConnected)return t(),!0;let r=[...a.current?.querySelectorAll(`[data-run-id]`)??[]].filter(t=>t.dataset.runId===e.runId&&t.dataset.project===e.project&&t.dataset.hostId===e.hostId).flatMap(e=>[...e.querySelectorAll(`a,button,input`)]),o=r.find(t=>e.control?t.dataset.taskControl===e.control:t.tagName===e.tag&&t.getAttribute(`aria-label`)===e.label)??r.find(e=>e.tagName===`A`);return o?.focus({preventScroll:!0}),!!o&&document.activeElement===o};if(r()||!a.current)return;let s=()=>{l.disconnect(),document.removeEventListener(`pointerdown`,c,!0),document.removeEventListener(`keydown`,c,!0)},c=()=>{t(),s()},l=new MutationObserver(()=>{r()&&s()});return document.addEventListener(`pointerdown`,c,!0),document.addEventListener(`keydown`,c,!0),l.observe(a.current,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[`style`]}),s},[e,t]),{ref:a,onFocusCapture:e=>{let t=e.target,r=t.closest(`[data-run-id]`);o.current=r?{element:t,runId:r.dataset.runId,project:r.dataset.project,hostId:r.dataset.hostId,control:t.dataset.taskControl??null,label:t.getAttribute(`aria-label`),tag:t.tagName}:null,n?.(r?ok(r.dataset.project,r.dataset.runId,r.dataset.hostId):null)},onBlurCapture:e=>{let t=e.target,r=e.currentTarget;queueMicrotask(()=>{o.current?.element===t&&t.isConnected&&!r.contains(document.activeElement)&&(o.current=null,n?.(null))})}}}var wk=new WeakMap;function Tk({items:e,itemKey:t,children:n,itemSize:r}){let[i]=zn(),a=(0,Z.useRef)(null),o=(0,Z.useRef)(null),[s,c]=(0,Z.useState)({available:null,margin:0}),[l,u]=(0,Z.useState)(null),d=ak(),f=(0,Z.useContext)(xk),p=e.map(t),m=oO(e.length,i.get(`tasks`)),h=s.available===!0&&m,g=(0,Z.useRef)(Symbol(`task-list`)),_=(0,Z.useRef)(()=>{});(0,Z.useLayoutEffect)(()=>{f?.registerList?.(g.current,p);let e=y.current;return e&&wk.set(e,{keys:p,handle:o,measure:()=>_.current()}),()=>{f?.registerList?.(g.current,null),e&&wk.delete(e)}});let v=Ck(String(h),void 0,void 0,e=>p.includes(e)),y=v.ref;return(0,Z.useLayoutEffect)(()=>{let e=y.current,t=e?.closest(`[data-slot="main"]`);if(a.current=t??null,!e||!t){c(e=>e.available===!1?e:{available:!1,margin:0});return}let n=null,r=()=>{let r=Math.max(0,e.getBoundingClientRect().top-t.getBoundingClientRect().top+t.scrollTop);r!==n&&(n=r,c(e=>e.available===!0&&e.margin===r?e:{available:!0,margin:r}))};r(),_.current=r;let i=new ResizeObserver(r);for(let n=e;n&&n!==t;n=n.parentElement){i.observe(n);for(let e of n.parentElement?.children??[])i.observe(e)}return i.observe(t),()=>i.disconnect()},[]),(0,Q.jsx)(`div`,{ref:y,"data-slot":`task-list-items`,"data-virtualized":h,onFocusCapture:e=>{v.onFocusCapture(e),u(e.target.closest(`[data-task-item]`)?.dataset.taskItem??null)},onBlurCapture:e=>{v.onBlurCapture(e),e.relatedTarget&&!e.currentTarget.contains(e.relatedTarget)&&u(null)},children:h?(0,Q.jsx)(Dk,{itemSize:r,items:e,keys:p,handle:o,scroll:a,margin:s.margin,focused:f?.focused??l,editing:d,children:n}):(s.available===null&&m?[]:e).map((t,r)=>(0,Q.jsx)(`div`,{"data-task-item":p[r],"data-first":r===0,"data-last":r===e.length-1,className:`task-list-flat-item`,children:n(t,r)},p[r]))})}function Ek({layout:e,revision:t,visibilityRevision:n=``,children:r,...i}){let a=Sk(e,t,!0);return(0,Q.jsx)(xk,{value:a.value,children:(0,Q.jsx)(kk,{revision:t,visibilityRevision:`${e}:${n}`,children:(0,Q.jsx)(`div`,{...i,...a.props,children:r})})})}function Dk({items:e,keys:t,handle:n,scroll:r,margin:i,focused:a,editing:o,children:s,itemSize:c}){let[l,u]=(0,Z.useState)(!1),d=Ok(r);return(0,Z.useLayoutEffect)(()=>{let e=r.current;if(!e)return;let t=new ResizeObserver(e=>{e.some(e=>e.contentRect.height>0)&&(u(!0),t.disconnect())});return t.observe(e),()=>t.disconnect()},[r]),(0,Q.jsx)(JO,{ref:n,...c===void 0?{}:{itemSize:c},scrollRef:r,startMargin:i,keepMounted:[...new Set([...!l&&e.length?[0]:[],...sO(t,a),...sO(t,d),...sO(t,o)])],data:e,children:(n,r)=>(0,Q.jsx)(`div`,{"data-task-item":t[r],"data-first":r===0,"data-last":r===e.length-1,children:s(n,r)},t[r])})}function Ok(e){let[t,n]=(0,Z.useState)(null),r=(0,Z.useRef)(t);return(0,Z.useLayoutEffect)(()=>{let t=e.current;if(!t)return;let i=e=>{if(e.target!==t)return;let i=t.contains(document.activeElement)?document.activeElement.closest(`[data-task-item]`)?.dataset.taskItem??null:null;i!==r.current&&(r.current=i,(0,Of.flushSync)(()=>n(i)))};return document.addEventListener(`scroll`,i,{capture:!0,passive:!0}),()=>document.removeEventListener(`scroll`,i,{capture:!0})},[e]),t}var kk=class extends Z.Component{root={current:null};owner(){return this.root.current?.closest(`[data-slot="main"]`)??null}getSnapshotBeforeUpdate(e){if(e.revision===this.props.revision&&e.visibilityRevision===this.props.visibilityRevision)return null;let t=this.owner();if(!t||!this.root.current)return null;let n=t.getBoundingClientRect();for(let e of this.root.current.querySelectorAll(`[data-task-item]`)){let r=e.getBoundingClientRect();if(r.bottom>n.top&&r.top<n.bottom)return{key:e.dataset.taskItem,top:r.top,scrollTop:t.scrollTop}}return{key:null,top:0,scrollTop:t.scrollTop}}componentDidUpdate(e,t,n){let r=this.owner();if(!n||!r)return;let i=n.key===null?null:this.currentTop(n.key);i!==null&&Math.abs(i-n.top)>.5&&(r.scrollTop+=i-n.top),queueMicrotask(()=>{r.isConnected&&(0,Of.flushSync)(()=>{for(let e of this.root.current?.querySelectorAll(`[data-slot="task-list-items"]`)??[])wk.get(e)?.measure();r.scrollTop!==n.scrollTop&&r.dispatchEvent(new Event(`scroll`))})})}currentTop(e){for(let t of this.root.current?.querySelectorAll(`[data-task-item]`)??[])if(t.dataset.taskItem===e)return t.getBoundingClientRect().top;for(let t of this.root.current?.querySelectorAll(`[data-slot="task-list-items"]`)??[]){let n=wk.get(t),r=n?.keys.indexOf(e)??-1,i=n?.handle.current;if(r>=0&&i)return t.getBoundingClientRect().top+i.getItemOffset(r)}return null}render(){return(0,Q.jsx)(`div`,{ref:this.root,style:{display:`contents`},children:this.props.children})}},Ak=/^- \S+ — (?:(?:turn complete|step ".*" complete|step ".*" ended without done|session idle-closed) — |worktree setup (?:done in|failed —|skipped —) )/;function jk(e,t=3){let n=an(e,`## Progress log`);if(n<0)return[];let r=[];for(let i of e.slice(Gt(e,n)).split(`
|
|
21
|
-
`)){if(r.length>=t||i.startsWith(`## `))break;let e=i.trim();!e||Ak.test(e)||r.push(e.replace(/^[-*] /,``))}return r}function Mk({origin:e,counts:t,automations:n,onChange:r,compact:i=!1}){return(0,Q.jsx)(`div`,{role:`group`,"aria-label":`Task origin`,"data-slot":`origin-filter`,className:q(`flex flex-wrap items-center`,i?`inline-flex rounded-md border border-border bg-card p-0.5 gap-0.5`:`gap-1.5`),children:pr(n).map(n=>{let a=n.value===e;return(0,Q.jsxs)(`button`,{type:`button`,"data-origin":n.value,"aria-pressed":a,onClick:()=>r(n.value),className:q(i?`inline-flex min-h-11 items-center gap-1 rounded-sm px-2.5 text-xs font-medium text-muted-foreground hover:bg-muted hover:text-foreground focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-link-foreground md:min-h-0 md:h-8`:`inline-flex min-h-11 items-center gap-1.5 rounded-full border border-border px-3 text-[13px] font-medium text-muted-foreground hover:bg-muted hover:text-foreground focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-link-foreground`,a&&(i?`bg-accent-strong/15 text-accent-text`:`border-accent-strong bg-accent-strong/10 text-accent-text`)),children:[n.label,` `,(0,Q.jsx)(Am,{value:t[n.value]})]},n.value)})})}function Nk({onExpand:e,onCollapse:t,compact:n=!1,allCollapsed:r=!1}){return n?(0,Q.jsx)(`div`,{"data-slot":`group-fold-controls`,className:`hidden items-center md:flex`,children:r?(0,Q.jsx)(Y,{type:`button`,variant:`ghost`,size:`sm`,className:`px-2 text-xs text-muted-foreground`,"data-action":`expand-groups`,onClick:e,children:`Expand all`}):(0,Q.jsx)(Y,{type:`button`,variant:`ghost`,size:`sm`,className:`px-2 text-xs text-muted-foreground`,"data-action":`collapse-groups`,onClick:t,children:`Collapse all`})}):(0,Q.jsxs)(`div`,{"data-slot":`group-fold-controls`,className:`hidden flex-wrap items-center gap-1 md:ml-auto md:flex md:gap-2`,children:[(0,Q.jsx)(Y,{type:`button`,variant:`ghost`,size:`default`,"data-action":`expand-groups`,onClick:e,children:`Expand groups`}),(0,Q.jsx)(Y,{type:`button`,variant:`ghost`,size:`default`,"data-action":`collapse-groups`,onClick:t,children:`Collapse groups`})]})}function Pk(e,t){if(t===`danger`)return`contains failed tasks`;switch(e){case`Needs you`:return`needs you`;case`Working`:return`working`;case`Finished`:return`finished`;case`Archived`:return`archived`}}function Fk({id:e,label:t,count:n,tone:r,folded:i,collapsed:a,onToggle:o,children:s}){let c=a?Ti:Ki;return(0,Q.jsxs)(`section`,{"data-slot":`task-status-group`,"data-bucket":t,"data-folded":i,"data-tone":r,"aria-labelledby":`${e}-heading`,className:`flex flex-col gap-2.5`,children:[(0,Q.jsx)(`h2`,{id:`${e}-heading`,className:`text-[13px] font-semibold text-foreground`,children:(0,Q.jsxs)(`button`,{type:`button`,"data-slot":`status-group-toggle`,"aria-expanded":!a,"aria-controls":`${e}-rows`,"aria-label":`${t} ${n}${r===`danger`?`, contains failed tasks`:``}`,onClick:o,className:`inline-flex min-h-11 items-center gap-2 rounded-md pr-2 hover:text-foreground focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-link-foreground`,children:[(0,Q.jsx)(c,{className:`size-3.5 shrink-0 text-muted-foreground`,"aria-hidden":`true`}),(0,Q.jsx)(Qo,{tone:r,role:`img`,"aria-label":Pk(t,r),title:Pk(t,r)}),(0,Q.jsx)(`span`,{children:t}),` `,(0,Q.jsx)(Am,{value:n,className:`font-normal text-muted-foreground`})]})}),(0,Q.jsx)(`div`,{id:`${e}-rows`,hidden:a,children:a?null:s})]})}function Ik({projectId:e,hostId:t,runId:n,status:r,error:i,open:a,compact:o=!1}){let s=he(e,n,!0,t),c=s.data===void 0?[]:jk(s.data);return o?(0,Q.jsxs)(`div`,{"data-slot":`task-preview`,className:`flex flex-col gap-2 text-xs`,children:[i?(0,Q.jsx)(`p`,{"data-slot":`task-preview-error`,className:`break-words text-semantic-red`,children:i}):null,s.isPending?(0,Q.jsx)(`p`,{role:`status`,className:`text-muted-foreground`,children:`Loading latest progress…`}):s.isError?(0,Q.jsx)(`p`,{"data-slot":`task-preview-unavailable`,className:`text-muted-foreground`,children:`Latest progress is unavailable.`}):c.length>0?(0,Q.jsx)(`ul`,{"aria-label":`Latest progress`,className:`flex flex-col gap-1 text-muted-foreground`,children:c.map((e,t)=>(0,Q.jsx)(`li`,{className:`break-words`,children:e},t))}):null,(0,Q.jsx)(`div`,{children:a})]}):(0,Q.jsxs)(`div`,{"data-slot":`task-preview`,className:`flex flex-col gap-3 rounded-md bg-muted/50 p-4 text-xs`,children:[(0,Q.jsx)(`p`,{className:`font-medium text-foreground`,children:r}),i?(0,Q.jsx)(`p`,{"data-slot":`task-preview-error`,className:`break-words text-semantic-red`,children:i}):null,s.isPending?(0,Q.jsx)(`p`,{role:`status`,className:`text-muted-foreground`,children:`Loading latest progress…`}):s.isError?(0,Q.jsx)(`p`,{"data-slot":`task-preview-unavailable`,className:`text-muted-foreground`,children:`Latest progress is unavailable.`}):c.length===0?(0,Q.jsx)(`p`,{className:`text-muted-foreground`,children:`No progress recorded yet.`}):(0,Q.jsx)(`ul`,{"aria-label":`Latest progress`,className:`flex flex-col gap-1 text-muted-foreground`,children:c.map((e,t)=>(0,Q.jsx)(`li`,{className:`break-words`,children:e},t))}),(0,Q.jsx)(`div`,{children:a})]})}function Lk(e,t){return e===`Finished`?`neutral`:rr(e,t)}var Rk=`inline-flex min-h-11 max-md:min-w-11 max-md:-mb-px md:min-h-0 md:h-8 items-center justify-center gap-1.5 border-b-2 border-transparent px-1 text-[13px] text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring`,zk=`border-accent-text font-medium text-foreground`;function Bk({view:e,current:t,onSelect:n,count:r,children:i}){let a=e===t;return(0,Q.jsxs)(`button`,{type:`button`,"data-slot":`overview-tab`,"data-view":e,"aria-pressed":a,onClick:()=>n(e),className:q(Rk,a&&zk),children:[i,r===0?null:(0,Q.jsxs)(`span`,{className:`tabular-nums`,children:[` · `,(0,Q.jsx)(Am,{value:r})]})]})}function Vk({view:e,onSelect:t,activeCount:n,archivedCount:r,trailing:i}){return(0,Q.jsxs)(`div`,{"data-slot":`tasks-view-tabs`,className:`flex flex-wrap items-center gap-x-4 gap-y-1`,children:[(0,Q.jsx)(Bk,{view:`active`,current:e,onSelect:t,count:n,children:`Active`}),(0,Q.jsx)(Bk,{view:`archived`,current:e,onSelect:t,count:r,children:`Archived`}),i]})}function Hk(){return(0,Q.jsx)(`span`,{className:`text-xs text-soft-foreground`,children:`—`})}function Uk(e,t,n){return`${e} ${e===1?`task`:`tasks`}${t?` loaded`:``}${n?` matching “${n}”`:``}`}function Wk({count:e,incomplete:t,needle:n}){return(0,Q.jsx)(`span`,{"data-slot":`tasks-result-count`,className:q(`self-center truncate text-xs text-soft-foreground tabular-nums`,n===``&&!t&&`sr-only`),children:Uk(e,t,n)})}function Gk({branch:e}){return(0,Q.jsx)(Mm,{value:e,variant:`chip`})}function Kk({view:e,unread:t,finished:n,archivePending:r,markReadPending:i=!1,onMarkAllRead:a,onArchiveFinished:o,focusReturnRef:s,surface:c=`both`}){let l=Z.useRef(!1),[u,d]=Z.useState(!1),f=n>0||r,p=c!==`mobile`,m=c!==`desktop`;return Z.useEffect(()=>{let e=window.matchMedia?.(hs);if(!e)return;let t=()=>{e.matches&&d(!1)};return t(),e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[]),(0,Q.jsxs)(Q.Fragment,{children:[p&&t>0?(0,Q.jsxs)(Y,{type:`button`,variant:`outline`,"data-slot":`mark-all-read`,disabled:i,"aria-busy":i,className:`hidden md:inline-flex`,onClick:a,children:[(0,Q.jsx)(Ic,{className:`size-3.5`,"aria-hidden":`true`}),`Mark all read `,(0,Q.jsx)(Am,{value:t,className:`text-muted-foreground`})]}):null,p&&e===`active`&&n>0?(0,Q.jsxs)(Y,{type:`button`,variant:`outline`,"data-slot":`archive-finished`,className:`hidden md:inline-flex`,disabled:r,"aria-busy":r,onClick:o,children:[(0,Q.jsx)(Wi,{className:`size-3.5`,"aria-hidden":`true`}),`Archive finished `,(0,Q.jsx)(Am,{value:n,className:`text-muted-foreground`})]}):null,m&&e===`active`&&(f||t>0)?(0,Q.jsxs)(oo,{open:u,onOpenChange:d,children:[(0,Q.jsx)(ro,{asChild:!0,children:(0,Q.jsx)(Y,{type:`button`,variant:`outline`,size:`icon`,className:`md:hidden`,"aria-label":`Task actions`,"aria-busy":r||i,children:(0,Q.jsx)(Kc,{"aria-hidden":`true`})})}),(0,Q.jsxs)(io,{align:`end`,className:`md:hidden`,onCloseAutoFocus:e=>{(l.current||window.matchMedia?.(`(min-width: 48rem)`).matches)&&(e.preventDefault(),l.current=!1,(s?.current??document).querySelector(`[data-slot="overview-tab"][data-view="active"]`)?.focus())},children:[f?(0,Q.jsxs)(eo,{disabled:r||n===0,onSelect:()=>{l.current=!0,o()},children:[(0,Q.jsx)(Wi,{"aria-hidden":`true`}),r?`Archiving…`:`Archive finished (${n})`]}):null,t>0?(0,Q.jsxs)(eo,{disabled:i,onSelect:a,children:[(0,Q.jsx)(Ic,{"aria-hidden":`true`}),`Mark all read (${t})`]}):null]})]}):null]})}function qk(e){return e.id===`reference`?`Reference`:e.id===`memory`?`Memory`:e.summaryLabel??e.label}function Jk({columns:e,expandedColumns:t,columnsPending:n,onToggleColumn:r,detailedTable:i,onToggleDetailed:a,showReferences:o=!0}){return(0,Q.jsxs)(po,{children:[(0,Q.jsx)(co,{asChild:!0,children:(0,Q.jsx)(Y,{"data-slot":`task-columns-trigger`,variant:`outline`,className:`hidden md:inline-flex`,children:`Columns`})}),(0,Q.jsxs)(uo,{align:`end`,className:`w-72`,children:[(0,Q.jsx)(`h2`,{className:`mb-2 text-base font-medium`,children:`Visible columns`}),(0,Q.jsx)(`p`,{className:`mb-4 text-xs text-muted-foreground`,children:`Task · Always visible`}),(0,Q.jsx)(`div`,{className:`grid grid-cols-2 gap-3`,children:e.filter(e=>e.canFold).map(e=>(0,Q.jsxs)(`label`,{className:`flex items-center gap-2 text-xs`,children:[(0,Q.jsx)(`input`,{"data-column-toggle":e.id,type:`checkbox`,checked:eO(e.id,t)&&(e.id!==`reference`||o),disabled:n||e.id===`reference`&&!o,onChange:()=>r(e.id)}),qk(e),e.id===`reference`&&!o?(0,Q.jsx)(`span`,{className:`text-muted-foreground`,children:`(no references)`}):null]},e.id))}),(0,Q.jsx)(`p`,{className:`mt-4 text-xs text-muted-foreground`,children:`Saved automatically across task lists.`}),a?(0,Q.jsx)(Y,{variant:`outline`,className:`mt-4`,onClick:a,children:i?`Summary view`:`Resource columns`}):null]})]})}function Yk({query:e,onQueryChange:t,searchPlaceholder:n,searchLabel:r,origin:i,originCounts:a,automations:o,onOriginChange:s,columns:c,expandedColumns:l,columnsPending:u,onToggleColumn:d,detailedTable:f,onToggleDetailed:p,showReferences:m=!0,groupLabels:h,allGroupsCollapsed:g=!1,onSetAllFolds:_,extraControls:v,mobileOriginOpen:y,mobileActions:b}){let x=(0,Z.useRef)(null),[S,C]=Z.useState(i!==`all`),w=y===void 0&&(o||a.automations>0||i!==`all`),T=y??S;return(0,Q.jsxs)(`div`,{"data-slot":`tasks-toolbar`,className:`flex flex-wrap items-center gap-2`,children:[(0,Q.jsxs)(`div`,{className:`flex min-w-0 basis-full items-center gap-2 md:contents`,children:[(0,Q.jsxs)(`div`,{className:`relative min-w-0 flex-1 md:order-1 md:min-w-48`,children:[(0,Q.jsx)(mi,{className:`pointer-events-none absolute top-1/2 left-2.5 size-3.5 -translate-y-1/2 text-soft-foreground`,"aria-hidden":`true`}),(0,Q.jsx)(`input`,{type:`text`,value:e,onChange:e=>t(e.target.value),placeholder:n,"aria-label":r,ref:x,className:q(`h-11 w-full rounded-md border border-input bg-card pl-8 text-base text-foreground outline-none placeholder:text-soft-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 md:h-9 md:text-[13px]`,e?`pr-11 md:pr-9`:`pr-3`)}),e?(0,Q.jsx)(`button`,{type:`button`,"data-slot":`task-search-clear`,"aria-label":`Clear search`,onClick:()=>{t(``),x.current?.focus()},className:`absolute top-1/2 right-0 flex size-11 -translate-y-1/2 items-center justify-center rounded-md text-soft-foreground hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none md:size-9`,children:(0,Q.jsx)(dl,{className:`size-3.5`,"aria-hidden":`true`})}):null]}),v?(0,Q.jsx)(`div`,{className:`shrink-0 md:order-3`,children:v}):null,w?(0,Q.jsx)(Y,{type:`button`,variant:`outline`,size:`icon`,"data-slot":`origin-filter-toggle`,"data-active":S||i!==`all`,"aria-label":`Filter by origin`,"aria-expanded":S,onClick:()=>C(e=>!e),className:q(`shrink-0 md:hidden`,(S||i!==`all`)&&`border-accent-strong bg-accent-strong/10 text-accent-text hover:bg-accent-strong/15 hover:text-accent-text`),children:(0,Q.jsx)(Li,{"aria-hidden":`true`})}):null,b?(0,Q.jsx)(`div`,{className:`shrink-0 md:hidden`,children:b}):null]}),(0,Q.jsx)(`div`,{className:q(`md:order-2`,!T&&`max-md:hidden`),children:(0,Q.jsx)(Mk,{origin:i,counts:a,automations:o,onChange:s,compact:!0})}),(0,Q.jsx)(`div`,{className:`hidden md:order-4 md:block`,children:(0,Q.jsx)(Jk,{columns:c,showReferences:m,expandedColumns:l,columnsPending:u,onToggleColumn:d,detailedTable:f,onToggleDetailed:p})}),h.length>0?(0,Q.jsx)(`div`,{className:`hidden md:order-5 md:block`,children:(0,Q.jsx)(Nk,{onExpand:()=>_(h,!1),onCollapse:()=>_(h,!0),compact:!0,allCollapsed:g})}):null]})}var Xk=1e3;function Zk(e){return e.isPending&&e.failureCount===0}function Qk({scope:e,scopePending:t,children:n}){let[r,i]=Z.useState(!1);return Z.useEffect(()=>{if(!t||r)return;let e=setTimeout(()=>i(!0),Xk);return()=>clearTimeout(e)},[t,r]),t&&!r?(0,Q.jsx)(`div`,{"data-slot":`tasks-header-status`,"aria-busy":`true`,className:`min-h-11 md:min-h-8`}):(!e&&!r&&i(!0),(0,Q.jsxs)(`div`,{"data-slot":`tasks-header-status`,className:`flex flex-wrap items-center gap-x-3 gap-y-1`,children:[e&&!r?(0,Q.jsxs)(`span`,{className:`hidden items-center gap-1.5 whitespace-nowrap text-xs font-medium text-muted-foreground md:inline-flex`,children:[(0,Q.jsx)(`span`,{"data-slot":`tasks-project-scope`,children:e}),n?(0,Q.jsx)(`span`,{"aria-hidden":`true`,"data-slot":`tasks-scope-separator`,className:`text-soft-foreground`,children:`·`}):null]}):null,n]}))}function $k({projectName:e,projectScopePending:t,status:n,secondaryActions:r}){return{title:`Project tasks`,status:(0,Q.jsx)(Qk,{scope:e,scopePending:t,children:n}),secondaryActions:r,primaryAction:(0,Q.jsx)(cs,{asChild:!0,variant:`primary`,"data-slot":`new-task-inline`,children:(0,Q.jsxs)(X,{to:`/new`,children:[(0,Q.jsx)(vi,{"aria-hidden":`true`}),`New task`]})})}}function eA(e,t,n,r){if(!(!e||t<=0||r!==``))return(0,Q.jsx)(ps,{summary:`${t} ${n} ${t===1?`task`:`tasks`} in this project.`,actions:(0,Q.jsx)(Y,{variant:`outline`,size:`sm`,asChild:!0,children:(0,Q.jsx)(X,{to:`/new`,children:`Start another task`})})})}function tA(e,t){return e===void 0?`full`:us(t)}function nA(e){return{"data-presentation":e?`resources`:`summary`}}var rA=150;function iA(e,t){se();let n=U(),[r,i]=Z.useState(``),[a,o]=Z.useState(``);Z.useEffect(()=>{let e=setTimeout(()=>o(r),rA);return()=>clearTimeout(e)},[r]);let s=e!==void 0&&Lo(e).archived>=200,{data:c,isError:l,isPlaceholderData:u,hasNextPage:f,isFetchingNextPage:p,fetchNextPage:m,refetch:h}=d(a,t===`archived`&&(a!==``||s)),g=c?.pages,_=Z.useMemo(()=>g||l?{runs:(g??[]).flatMap(e=>e.runs),query:u?null:a,hasMore:f,loading:p,onLoadMore:()=>void(g?m():h()),failed:l}:void 0,[g,l,u,a,f,p,m,h]),v=a===``?g:n.getQueryData(ge.runs.archived(``))?.pages,y=v===void 0?void 0:v.at(-1)?.nextCursor!=null;return{pages:Z.useMemo(()=>_&&{..._,plainHasMore:y},[_,y]),total:v?.[0]?.total,search:i}}function aA({pages:e}){return e.failed?(0,Q.jsxs)(`p`,{role:`alert`,"data-slot":`archived-older-error`,className:`mt-3.5 flex items-center justify-center gap-2.5 text-[13px] text-muted-foreground`,children:[`Could not load older archived tasks.`,(0,Q.jsx)(Y,{variant:`outline`,onClick:e.onLoadMore,children:`Retry`})]}):e.hasMore?(0,Q.jsx)(Y,{"data-slot":`archived-older`,variant:`outline`,className:`mt-3.5 self-center`,disabled:e.loading,onClick:e.onLoadMore,children:e.loading?`Loading older archived…`:`Show older archived`}):null}function oA({error:e,onRetry:t}){return e?(0,Q.jsxs)(`div`,{role:`alert`,className:`rounded-xl border border-border bg-card p-6`,children:[(0,Q.jsx)(`h2`,{className:`text-lg`,children:`Could not load tasks`}),(0,Q.jsx)(`p`,{className:`mt-2 text-sm text-muted-foreground`,children:e}),(0,Q.jsx)(Y,{variant:`outline`,className:`mt-4`,onClick:t,children:`Retry`})]}):(0,Q.jsx)(`div`,{role:`status`,"aria-label":`Loading tasks`,className:`rounded-xl border border-border bg-card p-6 text-sm text-muted-foreground`,children:`Loading tasks…`})}function sA(e,t){return e.length>0&&e.every(t)}function cA(e,t){return n=>(t===null?n.delete(e):n.set(e,t),n)}function lA(e){return e===void 0?`unknown`:new Intl.NumberFormat().format(e)}function uA(e,t){return`Input tokens: ${lA(e)}; output tokens: ${lA(t)}`}function dA(e,t,n=`compact`){let r=e===void 0?`—`:Cs(e),i=t===void 0?`—`:Cs(t);return n===`table`?`${r} / ${i}`:`IN ${r} · OUT ${i}`}function fA({inputTokens:e,outputTokens:t,variant:n=`compact`,omitWhenUnknown:r=!0,className:i,title:a}){return r&&e===void 0&&t===void 0?null:(0,Q.jsx)(`span`,{"data-slot":`directional-usage`,"aria-label":uA(e,t),title:a,className:q(`font-mono tabular-nums`,i),children:dA(e,t,n)})}function pA({model:e,showTokens:t,showCost:n,liveUsageSource:r=`stream`,openLink:i,extraActions:a,className:o}){let[s,c]=Z.useState(!1);return(0,Q.jsxs)(po,{open:s,onOpenChange:c,children:[(0,Q.jsx)(co,{asChild:!0,children:(0,Q.jsxs)(`button`,{type:`button`,"data-slot":`task-usage-trigger`,"data-task-control":`usage`,"aria-expanded":s,"aria-label":`Usage and telemetry for ${e.title}`,className:q(`inline-flex h-7 max-w-full items-center gap-1 rounded-md border border-border bg-background px-2 font-mono text-xs text-muted-foreground tabular-nums transition-colors hover:border-control-border hover:bg-muted hover:text-foreground focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring max-md:min-h-11 max-md:px-2.5`,s&&`border-accent-strong bg-accent-strong/10 text-foreground`,o),children:[(0,Q.jsx)(`span`,{className:`min-w-0 truncate`,children:e.usageSummary}),(0,Q.jsx)(ta,{className:q(`size-3 shrink-0 opacity-70 transition-transform motion-reduce:transition-none`,s&&`rotate-180`),"aria-hidden":`true`})]})}),s?(0,Q.jsx)(uo,{align:`end`,collisionPadding:8,"data-slot":`task-telemetry-popover`,className:`max-h-(--radix-popover-content-available-height) w-80 max-w-[calc(100vw-16px)] overflow-y-auto overscroll-contain p-3.5`,children:(0,Q.jsx)(gA,{model:e,showTokens:t,showCost:n,liveUsageSource:r,openLink:i,extraActions:a})}):null]})}function mA({model:e,showTokens:t,showCost:n}){return(0,Q.jsx)(hA,{model:e,sample:Nr(e.runId),showTokens:t,showCost:n})}function hA({model:e,sample:t,showTokens:n,showCost:r}){let{run:i}=e,a=tr(i,t),o=a.cpu.kind===`live`||a.mem.kind===`live`;return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2.5`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,Q.jsx)(`span`,{className:`text-xs font-semibold tracking-[0.05em] text-accent-text uppercase`,children:`Task telemetry`}),(0,Q.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e.hostStale?`Stale`:o?`Live`:`Recorded`})]}),(0,Q.jsxs)(`dl`,{className:`grid grid-cols-2 gap-x-3 gap-y-2.5 text-xs`,children:[n?(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`dt`,{className:`text-xs text-muted-foreground`,children:`Tokens IN / OUT`}),(0,Q.jsx)(`dd`,{className:`mt-0.5 font-mono text-foreground`,children:(0,Q.jsx)(fA,{inputTokens:i.inputTokens,outputTokens:i.outputTokens,variant:`table`,omitWhenUnknown:!1,className:`whitespace-nowrap`})})]}):null,r?(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`dt`,{className:`text-xs text-muted-foreground`,children:`Cost`}),(0,Q.jsx)(`dd`,{className:`mt-0.5 font-mono text-foreground tabular-nums`,children:_r(i.costUsd)||`—`})]}):null,(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`dt`,{className:`text-xs text-muted-foreground`,children:`CPU`}),(0,Q.jsx)(`dd`,{"data-usage":`cpu`,"data-usage-kind":a.cpu.kind,title:a.cpu.title,className:`mt-0.5 font-mono text-foreground tabular-nums`,children:a.cpu.text||`—`})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`dt`,{className:`text-xs text-muted-foreground`,children:`Memory`}),(0,Q.jsx)(`dd`,{"data-usage":`mem`,"data-usage-kind":a.mem.kind,title:a.mem.title,className:`mt-0.5 font-mono text-foreground tabular-nums`,children:a.mem.text||`—`})]}),e.branch?(0,Q.jsxs)(`div`,{className:`col-span-2 border-t border-border pt-2`,children:[(0,Q.jsx)(`dt`,{className:`text-xs text-muted-foreground`,children:`Branch`}),(0,Q.jsx)(`dd`,{className:`mt-1`,children:(0,Q.jsx)(Mm,{value:e.branch,variant:`chip`})})]}):null]})]})}function gA({model:e,showTokens:t,showCost:n,liveUsageSource:r,openLink:i,extraActions:a}){return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[r===`stream`?(0,Q.jsx)(mA,{model:e,showTokens:t,showCost:n}):(0,Q.jsx)(hA,{model:e,sample:e.snapshotUsage,showTokens:t,showCost:n}),(0,Q.jsx)(`div`,{className:`border-t border-border pt-2.5`,children:(0,Q.jsx)(Ik,{compact:!0,projectId:e.projectId,hostId:e.hostId,runId:e.runId,status:e.status.label,error:e.run.error,open:(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[i,a]})})})]})}function _A({children:e}){return(0,Q.jsx)(Y,{asChild:!0,variant:`outline`,size:`sm`,children:e})}var vA=new Set(JD);function yA(e,t){return XD.filter(n=>vA.has(n.id)?n.id===`task`?!0:n.id===`reference`&&!t?!1:eO(n.id,e):!1)}var bA=240,xA=10,SA=32;function CA(e){return e.map(e=>e.id===`task`?`minmax(0, 1fr)`:e.width??`100px`).join(` `)}function wA(e){return e.reduce((e,t)=>e+(t.id===`task`?bA:Number.parseFloat(t.width??`100`)||100),0)+Math.max(0,e.length-1)*xA+SA}function TA(e,t,n){return q(n?`line-clamp-2 min-w-0 whitespace-normal rounded-sm text-[13.5px] leading-[1.35]`:`min-w-0 truncate rounded-sm text-[13px] leading-[18px]`,e?`font-semibold text-foreground`:t?`font-normal text-foreground`:`font-medium text-foreground`,`focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-link-foreground`)}var EA={ask:{label:`Ask`,tone:`text-semantic-amber`},permission:{label:`Permission`,tone:`text-semantic-amber`},review:{label:`Review`,tone:`text-accent-text`},error:{label:`Error`,tone:`text-semantic-red`}};function DA({preview:e}){if(!e)return null;let t=EA[e.kind];return(0,Q.jsxs)(`p`,{"data-slot":`task-state-preview`,"data-preview-kind":e.kind,title:e.text,className:`mt-1 flex min-w-0 items-baseline gap-1.5 text-xs leading-[1.35] text-muted-foreground`,children:[(0,Q.jsx)(`span`,{className:q(`shrink-0 text-xs font-semibold`,t.tone),children:t.label}),(0,Q.jsx)(`span`,{className:`min-w-0 truncate`,children:e.text})]})}function OA({badge:e}){return(0,Q.jsxs)(`span`,{"data-slot":`task-automation-badge`,"data-origin":`automation`,title:`Automation ${e.id}`,className:`inline-flex max-w-[180px] shrink-0 items-center gap-1 truncate rounded-full border border-info/30 bg-info/10 px-2 py-px text-xs font-medium text-semantic-info`,children:[(0,Q.jsx)(Zi,{className:`size-2.5 shrink-0`,"aria-hidden":`true`}),(0,Q.jsx)(`span`,{className:`truncate`,children:e.label})]})}function kA({name:e,href:t,fullPage:n=!1}){let r=`inline-flex h-[18px] max-w-[140px] shrink-0 items-center truncate rounded-md border border-border bg-muted px-1.5 font-mono text-xs leading-none font-medium text-foreground`;return t?n?(0,Q.jsx)(`a`,{href:t,"data-slot":`task-project`,title:e,className:q(r,`hover:border-control-border hover:bg-muted/80`),children:e}):(0,Q.jsx)(G,{to:t,"data-slot":`task-project`,title:e,className:q(r,`hover:border-control-border hover:bg-muted/80`),children:e}):(0,Q.jsx)(`span`,{"data-slot":`task-project`,className:r,title:e,children:e})}function AA({scoped:e,fullPage:t=!1,to:n,className:r,title:i,children:a,...o}){return t?(0,Q.jsx)(`a`,{href:n,title:i,className:r,...o,children:a}):e?(0,Q.jsx)(X,{to:n,title:i,className:r,...o,children:a}):(0,Q.jsx)(G,{to:n,title:i,className:r,...o,children:a})}function jA({run:e,to:t,title:n,unread:r,unreadTone:i,readDone:a,isWorker:o,pinned:s,automationBadge:c,scoped:l=!0,onTogglePin:u,lines:d=1,compact:f=!1}){let p=tk(e);if(p.editing)return(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,"data-slot":`table-title-editor`,children:[(0,Q.jsx)(XO,{editor:p,className:`basis-full text-[13px] font-medium`}),(0,Q.jsx)(Y,{size:`sm`,"aria-label":`Save title`,onMouseDown:e=>e.preventDefault(),onClick:p.commit,children:`Save`}),(0,Q.jsx)(Y,{size:`sm`,variant:`outline`,"aria-label":`Cancel rename`,onMouseDown:e=>e.preventDefault(),onClick:p.cancel,children:`Cancel`})]});let m=q(d===2?`line-clamp-2 min-w-0 whitespace-normal rounded-sm text-[13px] leading-[18px]`:`min-w-0 truncate rounded-sm text-[13px] leading-[18px]`,r?`font-semibold text-foreground`:a?`font-normal text-foreground`:`font-medium text-foreground`,`focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-link-foreground`);return(0,Q.jsxs)(`span`,{className:q(`flex min-w-0 items-center gap-1.5`,f||d===1?`h-[18px]`:`min-h-[18px]`),children:[o?(0,Q.jsx)(`span`,{className:`shrink-0 text-xs text-muted-foreground`,children:`Worker`}):null,(0,Q.jsx)(AA,{scoped:l,to:t,title:n,"data-task-control":`title`,className:m,children:n}),c?(0,Q.jsx)(OA,{badge:c}):null,r?(0,Q.jsx)(Qo,{tone:i,role:`img`,"aria-label":`unread`,title:`Unread — not opened since it finished`,className:`shrink-0`}):null,(0,Q.jsx)(`button`,{type:`button`,"data-slot":`row-rename`,"aria-label":`Rename task`,onClick:p.begin,className:`shrink-0 rounded-sm p-0.5 text-soft-foreground opacity-0 transition-opacity group-hover/row:opacity-100 hover:text-foreground focus-visible:opacity-100 focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`,children:(0,Q.jsx)(ol,{className:`size-3`,"aria-hidden":`true`})}),(0,Q.jsx)(`span`,{"aria-hidden":`true`,className:`flex-1`}),u?(0,Q.jsx)(N_,{pinned:s,onToggle:u,className:`size-[19px] opacity-0 group-hover/row:opacity-100 focus-visible:opacity-100 no-hover:opacity-100 data-[pinned=true]:text-semantic-amber data-[pinned=true]:opacity-100`}):null]})}function MA({model:e,scoped:t,onTogglePin:n,compact:r}){return(0,Q.jsx)(jA,{run:e.run,to:e.href,title:e.title,unread:e.unread,unreadTone:e.unreadTone,readDone:e.readDone,isWorker:e.isWorker,pinned:e.pinned,automationBadge:e.automationBadge,scoped:t,onTogglePin:n?t=>n(e,t):void 0,compact:r})}function NA({model:e,scoped:t,showProject:n,onTogglePin:r,clamp:i}){return(0,Q.jsxs)(`span`,{className:q(`flex min-w-0 items-center gap-1.5`,i?`items-start`:`min-h-[18px]`),children:[n&&e.hostLabel?(0,Q.jsx)(Dd,{label:e.hostLabel,hostId:e.hostId}):null,n&&e.projectName?(0,Q.jsx)(kA,{name:e.projectName,href:e.projectHref,fullPage:e.fullPageNav}):null,e.isWorker?(0,Q.jsx)(`span`,{className:`shrink-0 text-xs text-muted-foreground`,children:`Worker`}):null,(0,Q.jsx)(AA,{scoped:t,fullPage:e.fullPageNav,to:e.href,title:e.title,"data-task-control":`title`,className:q(TA(e.unread,e.readDone,i),i&&`flex-1`),children:e.title}),!i&&e.automationBadge?(0,Q.jsx)(OA,{badge:e.automationBadge}):null,e.unread?(0,Q.jsx)(Qo,{tone:e.unreadTone,role:`img`,"aria-label":`unread`,title:`Unread — not opened since it finished`,className:q(`shrink-0`,i&&`mt-1.5`)}):null,i?null:(0,Q.jsx)(`span`,{"aria-hidden":`true`,className:`flex-1`}),r?(0,Q.jsx)(N_,{pinned:e.pinned,onToggle:t=>r(e,t),className:i?`-mt-0.5 shrink-0 data-[pinned=true]:text-semantic-amber`:`size-[19px] opacity-0 group-hover/row:opacity-100 focus-visible:opacity-100 no-hover:opacity-100 data-[pinned=true]:text-semantic-amber data-[pinned=true]:opacity-100`}):null]})}function PA({model:e,showProject:t,showAutomationOnMeta:n,trailing:r}){let{status:i,scheduled:a,queuePosition:o,runnerModel:s,tags:c}=e;return(0,Q.jsxs)(`div`,{"data-slot":`task-meta-line`,className:`mt-1 flex min-w-0 flex-wrap items-center gap-x-1.5 gap-y-1 text-xs text-muted-foreground`,children:[(0,Q.jsxs)(Td,{dot:i.tone,shape:i.shape,pulse:!e.hostStale&&i.pulse,title:a?.title??i.label,className:`shrink-0 py-0.5`,children:[i.label,a?(0,Q.jsxs)(`span`,{className:`tabular-nums`,children:[` `,a.label]}):null]}),e.hostStale?(0,Q.jsx)(Od,{}):null,t&&e.hostLabel?(0,Q.jsx)(Dd,{label:e.hostLabel,hostId:e.hostId}):null,t&&e.projectName?(0,Q.jsx)(kA,{name:e.projectName,href:e.projectHref,fullPage:e.fullPageNav}):null,n&&e.automationBadge?(0,Q.jsx)(OA,{badge:e.automationBadge}):null,s?(0,Q.jsxs)(`span`,{className:`inline-flex min-w-0 items-center gap-1.5`,children:[(0,Q.jsx)(`span`,{"aria-hidden":`true`,className:`max-md:hidden`,children:`·`}),(0,Q.jsx)(`span`,{"data-slot":`task-runner-model`,className:`min-w-0 truncate`,children:s})]}):null,e.run.status===`queued`&&o!==null?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),(0,Q.jsxs)(`span`,{"data-slot":`queue-note`,className:`shrink-0 tabular-nums`,children:[`#`,o,` in queue`]})]}):null,c.map(e=>(0,Q.jsx)(`span`,{"data-slot":`task-tag`,className:`rounded bg-muted px-1.5 py-px text-xs text-soft-foreground`,children:e},e)),r]})}function FA({model:e,onSetRead:t,onArchive:n,busy:r}){return!t&&!n?null:(0,Q.jsxs)(Q.Fragment,{children:[t&&e.canToggleRead?(0,Q.jsxs)(Y,{type:`button`,variant:`outline`,size:`sm`,"data-action":e.unread?`mark-read`:`mark-unread`,"aria-label":e.unread?`Mark ${e.title} read`:`Mark ${e.title} unread`,disabled:r,onClick:()=>t(e,e.unread),children:[e.unread?(0,Q.jsx)(ba,{className:`size-3.5`,"aria-hidden":`true`}):(0,Q.jsx)(qc,{className:`size-3.5`,"aria-hidden":`true`}),e.unread?`Mark read`:`Mark unread`]}):null,n&&e.canArchive?(0,Q.jsxs)(Y,{type:`button`,variant:`outline`,size:`sm`,"data-action":e.run.archived?`unarchive-run`:`archive-run`,"aria-label":e.run.archived?`Restore ${e.title} to the active list`:`Archive ${e.title}`,disabled:r,onClick:()=>n(e,!e.run.archived),children:[e.run.archived?(0,Q.jsx)(Pc,{className:`size-3.5`,"aria-hidden":`true`}):(0,Q.jsx)(Wi,{className:`size-3.5`,"aria-hidden":`true`}),e.run.archived?`Unarchive`:`Archive`]}):null]})}function IA({model:e,scoped:t}){return e.references.length===0?(0,Q.jsx)(`span`,{className:`text-xs text-soft-foreground`,children:`—`}):t?(0,Q.jsx)(D_,{run:e.run,reference:e.references[0],compact:!0}):(0,Q.jsx)(M_,{references:e.references,maxVisible:1,taskTitle:e.title,projectId:e.projectId,hostId:e.hostId,runId:e.runId,repoBase:e.repoBase,compact:!0})}function LA({model:e,scoped:t,showTokens:n,showCost:r,liveUsageSource:i,onSetRead:a,onArchive:o,busy:s,className:c}){return(0,Q.jsx)(pA,{model:e,showTokens:n,showCost:r,liveUsageSource:i,className:c,openLink:(0,Q.jsx)(_A,{children:(0,Q.jsxs)(AA,{scoped:t,fullPage:e.fullPageNav,to:e.href,"data-task-control":`open`,children:[`Open task`,(0,Q.jsxs)(`span`,{className:`sr-only`,children:[`: `,e.title]})]})}),extraActions:(0,Q.jsx)(FA,{model:e,onSetRead:a,onArchive:o,busy:s})})}function RA({column:e,hasUsageColumn:t,...n}){let{model:r,now:i,scoped:a,showProject:o,allowRename:s,compact:c,onTogglePin:l}=n;switch(e.id){case`task`:return(0,Q.jsxs)(`div`,{role:`cell`,"data-column-id":`task`,className:q(`min-w-0 pr-1`,c?`py-1.5`:`py-2.5`),children:[s?(0,Q.jsx)(MA,{model:r,scoped:a,onTogglePin:l,compact:c}):(0,Q.jsx)(NA,{model:r,scoped:a,showProject:o,onTogglePin:l,clamp:!1}),(0,Q.jsx)(PA,{model:r,showProject:!1,showAutomationOnMeta:!1,trailing:t?null:(0,Q.jsx)(LA,{...n,className:`ml-auto h-6 px-1.5 text-xs`})}),(0,Q.jsx)(DA,{preview:r.statePreview})]});case`runner`:return(0,Q.jsx)(`div`,{role:`cell`,"data-column-id":`runner`,className:`min-w-0 truncate text-xs text-muted-foreground`,title:r.runnerModel,children:r.runnerModel??(0,Q.jsx)(`span`,{className:`text-soft-foreground`,children:`—`})});case`workflow`:return(0,Q.jsx)(`div`,{role:`cell`,"data-column-id":`workflow`,className:`min-w-0 truncate text-xs text-muted-foreground`,title:r.workflow,children:r.workflow});case`branch`:return(0,Q.jsx)(`div`,{role:`cell`,"data-column-id":`branch`,className:`min-w-0 overflow-hidden`,children:r.branch?(0,Q.jsx)(Mm,{value:r.branch,variant:`chip`}):(0,Q.jsx)(`span`,{className:`text-xs text-soft-foreground`,children:`—`})});case`diff`:return(0,Q.jsx)(`div`,{role:`cell`,"data-column-id":`diff`,className:`text-xs`,children:r.diffStat?(0,Q.jsx)(km,{stat:r.diffStat}):(0,Q.jsx)(`span`,{className:`text-soft-foreground`,children:`—`})});case`reference`:return(0,Q.jsx)(`div`,{role:`cell`,"data-column-id":`reference`,className:`min-w-0`,children:(0,Q.jsx)(IA,{model:r,scoped:a})});case`usage`:return(0,Q.jsx)(`div`,{role:`cell`,"data-column-id":`usage`,className:`flex justify-end`,children:(0,Q.jsx)(LA,{...n})});case`started`:return(0,Q.jsx)(`div`,{role:`cell`,"data-column-id":`started`,className:`text-right text-xs whitespace-nowrap text-muted-foreground tabular-nums`,children:(0,Q.jsx)(jm,{iso:r.startedAt,now:i})});default:return null}}function zA(e){return e instanceof Element&&!!e.closest(`a, button, input, [role="dialog"]`)}function BA(e,t){return e===t||e.run===t.run&&e.hostId===t.hostId&&e.hostLabel===t.hostLabel&&e.hostStale===t.hostStale&&e.href===t.href&&e.projectName===t.projectName&&e.projectHref===t.projectHref&&e.runnerModel===t.runnerModel&&e.usageSummary===t.usageSummary&&e.queuePosition===t.queuePosition&&e.automationBadge?.label===t.automationBadge?.label&&e.tags.length===t.tags.length&&e.tags.every((e,n)=>e===t.tags[n])}function VA(e,t){let{model:n,...r}=e,{model:i,...a}=t;return BA(n,i)&&Object.keys(r).every(e=>r[e]===a[e])}function HA(e){let t=To(),n=Kn();return(r,i)=>{if(i){window.location.assign(r);return}e?t(r):n(r)}}function UA(e,t){return{"data-slot":t,"data-task-row":`true`,"data-status":e.run.status,"data-urgent":e.urgent?`true`:void 0,"data-run-id":e.runId,"data-project":e.projectId,"data-host-id":e.hostId,"data-host-stale":e.hostStale?`true`:void 0,"data-host-live":e.hostId===void 0?void 0:String(!e.hostStale)}}var WA=Z.memo(function({rowIndex:e,columns:t,gridTemplate:n,rowSlot:r,...i}){let{model:a,scoped:o}=i,s=HA(o),c=t.some(e=>e.id===`usage`);return(0,Q.jsx)(`div`,{role:`row`,"aria-rowindex":e,...UA(a,r),style:{gridTemplateColumns:n},onClick:e=>{zA(e.target)||s(a.href,a.fullPageNav)},className:q(`group/row grid cursor-pointer items-center gap-x-2.5 border-b border-border px-4 transition-colors hover:bg-muted/70`,a.hostStale?`bg-muted/30 hover:bg-muted/50`:a.urgent&&`bg-pending/[0.07] hover:bg-pending/[0.11]`),children:t.map(e=>(0,Q.jsx)(RA,{column:e,hasUsageColumn:c,...i},e.id))})},VA),GA=Z.memo(function({model:e,now:t,scoped:n,showProject:r,showTokens:i,showCost:a,liveUsageSource:o,onTogglePin:s,onSetRead:c,onArchive:l,busy:u,cardSlot:d}){let f=HA(n);return(0,Q.jsxs)(`article`,{...UA(e,d),onClick:t=>{zA(t.target)||f(e.href,e.fullPageNav)},className:q(`flex cursor-pointer flex-col gap-1.5 border-b border-border px-3 py-2.5 transition-colors`,e.hostStale?`bg-muted/30`:e.urgent&&`bg-pending/[0.07]`),children:[(0,Q.jsx)(`div`,{"data-slot":`mobile-task-title-row`,children:(0,Q.jsx)(NA,{model:e,scoped:n,showProject:!1,onTogglePin:s,clamp:!0})}),(0,Q.jsx)(PA,{model:e,showProject:r,showAutomationOnMeta:!0,trailing:e.runnerModel?null:(0,Q.jsx)(`span`,{"data-slot":`mobile-task-workflow`,className:`min-w-0 truncate`,children:e.workflow})}),(0,Q.jsx)(DA,{preview:e.statePreview}),(0,Q.jsxs)(`div`,{"data-slot":`mobile-task-meta`,className:`-my-1 flex min-w-0 items-center justify-between gap-2 text-xs text-muted-foreground`,children:[(0,Q.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5 overflow-hidden`,children:[e.references.length>0?(0,Q.jsx)(IA,{model:e,scoped:n}):null,e.references.length>0&&(e.queuePosition!==null||e.diffStat)?(0,Q.jsx)(`span`,{"aria-hidden":`true`,className:`shrink-0 text-soft-foreground`,children:`·`}):null,e.queuePosition===null?e.diffStat?(0,Q.jsx)(km,{stat:e.diffStat}):e.references.length===0?(0,Q.jsx)(`span`,{"data-slot":`mobile-task-workflow`,className:`min-w-0 truncate`,children:e.workflow}):null:(0,Q.jsxs)(`span`,{"data-slot":`queue-note`,className:`shrink-0 tabular-nums`,children:[`#`,e.queuePosition,` in queue`]})]}),(0,Q.jsxs)(`span`,{className:`flex shrink-0 items-center gap-2`,children:[(0,Q.jsx)(pA,{model:e,showTokens:i,showCost:a,liveUsageSource:o,className:`max-md:px-2`,openLink:(0,Q.jsx)(_A,{children:(0,Q.jsxs)(AA,{scoped:n,fullPage:e.fullPageNav,to:e.href,"data-task-control":`open`,children:[`Open task`,(0,Q.jsxs)(`span`,{className:`sr-only`,children:[`: `,e.title]})]})}),extraActions:(0,Q.jsx)(FA,{model:e,onSetRead:c,onArchive:l,busy:u})}),(0,Q.jsx)(jm,{iso:e.startedAt,now:t})]})]})]})},VA);function KA({items:e,density:t,now:n,showHeader:r=!0,showProject:i=!1,showReferences:a=!0,expandedColumns:o=$D(void 0),showTokens:s=!0,showCost:c=!0,scopedLinks:l=!0,liveUsageSource:u=`stream`,allowRename:d=!1,onTogglePin:f,onArchive:p,onSetRead:m,busy:h=!1,tableSlot:g=`tasks-summary`,rowSlot:_=`task-summary-row`,cardSlot:v=`task-card`}){let y=Z.useMemo(()=>yA(o,a),[o,a]),b=Z.useMemo(()=>CA(y),[y]),x=Z.useMemo(()=>wA(y),[y]);if(t===`card`)return(0,Q.jsx)(Pf,{children:(0,Q.jsx)(`div`,{"data-slot":`task-cards`,"data-task-table":`true`,"data-density":`card`,className:`flex flex-col overflow-hidden rounded-lg border border-card-edge bg-card shadow-card`,children:(0,Q.jsx)(Tk,{itemSize:107,items:e,itemKey:e=>e.key,children:e=>(0,Q.jsx)(GA,{model:e,now:n,scoped:l,showProject:i,showTokens:s,showCost:c,liveUsageSource:u,onTogglePin:f,onSetRead:m,onArchive:p,busy:h,cardSlot:v},e.key)})})});let S=t===`compact`;return(0,Q.jsx)(Pf,{children:(0,Q.jsx)(`div`,{"data-slot":g,"data-task-table":`true`,"data-density":t,"data-head":r,"data-reference-column":a,className:`overflow-x-auto rounded-lg border border-card-edge bg-card shadow-card`,children:(0,Q.jsxs)(`div`,{role:`table`,"aria-rowcount":e.length+1,style:{minWidth:`${x}px`},className:`w-full`,children:[(0,Q.jsx)(`div`,{role:`row`,"aria-rowindex":1,"data-slot":`task-table-head`,style:{gridTemplateColumns:b},className:q(`grid items-center gap-x-2.5 border-b border-border px-4`,!r&&`sr-only`),children:y.map(e=>(0,Q.jsx)(`div`,{role:`columnheader`,"data-column-id":e.id,className:q(`flex h-8 items-center text-xs font-medium tracking-[0.04em] whitespace-nowrap text-muted-foreground uppercase`,e.align===`right`&&`justify-end text-right`),children:e.summaryLabel??e.label},e.id))}),(0,Q.jsx)(Tk,{itemSize:S?56:63,items:e,itemKey:e=>e.key,children:(e,t)=>(0,Q.jsx)(WA,{model:e,rowIndex:t+2,columns:y,gridTemplate:b,now:n,scoped:l,showProject:i,allowRename:d,showTokens:s,showCost:c,liveUsageSource:u,compact:S,onTogglePin:f,onSetRead:m,onArchive:p,busy:h,rowSlot:_},e.key)})]})})})}function qA(){let[e,t]=rc(),n=e.get(`archived`)===`1`?`archived`:`active`,r=Mr(e.get(`origin`)),[i,a]=Z.useState(n),[o,s]=Z.useState(r);Z.useEffect(()=>a(n),[n]),Z.useEffect(()=>s(r),[r]);let c=e.get(`q`)??``,l=Z.useRef(void 0);return Z.useEffect(()=>{let e=l;return()=>clearTimeout(e.current)},[]),{view:i,setView:e=>{a(e),t(cA(`archived`,e===`archived`?`1`:null))},origin:o,setOrigin:e=>{s(e),t(cA(`origin`,e===`all`?null:e))},urlQuery:c,writeQuery:Z.useCallback((e,n)=>{clearTimeout(l.current);let r=e.trim();l.current=setTimeout(()=>t(e=>{let t=e.get(`q`),i=cA(`q`,r===``?null:r)(e);return i.get(`q`)!==t&&n(r),i}),JA)},[t])}}var JA=250,YA=`cez-task-list-folds`,XA=`cez-task-list-folds-changed`;function ZA(e,t,n=new Set){let[r,i]=(0,Z.useState)(()=>tv(YA));(0,Z.useEffect)(()=>{let e=e=>{e instanceof StorageEvent&&e.key!==null&&e.key!==Qr(`cez-task-list-folds`)||i(e instanceof CustomEvent?e.detail:tv(YA))};return window.addEventListener(`storage`,e),window.addEventListener(XA,e),()=>{window.removeEventListener(`storage`,e),window.removeEventListener(XA,e)}},[]);let a=(0,Z.useCallback)(n=>JSON.stringify([e,t,n]),[e,t]),o=(0,Z.useCallback)(e=>{i(t=>{let n=e(t);return nv(n,YA),queueMicrotask(()=>window.dispatchEvent(new CustomEvent(XA,{detail:n}))),n})},[]),s=e=>r[a(e)]===!0;return{isFolded:s,isCollapsed:e=>s(e)&&!n.has(e),toggle:e=>o(t=>({...t,[a(e)]:t[a(e)]!==!0})),setAll:(e,t)=>o(n=>({...n,...Object.fromEntries(e.map(e=>[a(e),t]))})),only:(0,Z.useCallback)((e,t)=>o(n=>({...n,...Object.fromEntries(t.map(t=>[a(t),t!==e]))})),[o,a])}}function QA(e,t,n,r){let i=ZA(e,t,n),a=(0,Z.useRef)(r);a.current=r;let[o,s]=rc(),c=t===`active`?Po(o.get(zo)):null,{only:l}=i;return(0,Z.useEffect)(()=>{c!==null&&(l(c,Vo),a.current?.(),s(e=>(e.delete(zo),e)))},[c,l,s]),i}function $A(e){let t=e?.capabilities,n=t?.tokenMetrics!==!1;return{tokens:t?.tokenUsageMetrics??n,cost:t?.costMetrics??n}}function ej(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:{}}function tj(){let e=U(),t=ce(),n=Z.useRef(0),r=Z.useRef(0),i=Z.useRef(Promise.resolve()),a=Z.useMemo(()=>$D(t.data?.taskTable?.expandedColumns),[t.data?.taskTable?.expandedColumns]),o=Z.useCallback(t=>{if(!XD.find(e=>e.id===t)?.canFold)return;let a=e.getQueryData(V.uiState);if(a===void 0)return;let o=ej(a?.taskTable),s={...o,expandedColumns:tO(o.expandedColumns,t)};e.setQueryData(V.uiState,{...a,taskTable:s});let c=++n.current;r.current=c;let l=i.current.then(async()=>{let t=await Ht({taskTable:s},{keepalive:!0});c===r.current&&e.setQueryData(V.uiState,t)});i.current=l.catch(t=>{H(t instanceof Error?t.message:String(t),{tone:`danger`}),c===r.current&&e.invalidateQueries({queryKey:V.uiState})})},[e]);return{expandedColumns:a,isExpanded:Z.useCallback(e=>eO(e,a),[a]),toggleColumn:o,isPending:t.isPending}}var nj=()=>void 0;function rj({runs:e,view:t,onViewChange:n,onArchiveFinished:r,archivePending:i=!1,onMarkAllRead:a,onRename:o,onTogglePin:s,now:c=Date.now(),showTokens:l=!0,showCost:u=!0,expandedColumns:d=$D(void 0),onToggleColumn:f=()=>void 0,columnsPending:p=!1,projectName:m,projectScopePending:h,runners:g,error:_,onRetry:v,archivedPages:y,archivedTotal:b,onArchivedSearch:x,origin:S,onOriginChange:C,automations:w,urlQuery:T=``,onQueryChange:E,foldScope:D=`project`,automationName:O=nj}){let[k,A]=ij(T,E);Z.useEffect(()=>{x?.(k.trim())},[x,k]);let[j,M]=aj(S,C,w),[N,ee]=Z.useState(!1),P=fs(),F=Z.useMemo(()=>e??[],[e]),I=Z.useMemo(()=>oj({all:F,view:t,query:k,origin:j,archivedPages:y,archivedTotal:b,automationName:O}),[F,t,k,j,y,b,O]),{groups:L,needle:R}=I,te=Z.useMemo(()=>aO({tokens:l,cost:u}),[l,u]),ne=Z.useMemo(()=>iO(),[]),re=QA(D,t,new Set(R?L.map(e=>e.label):[]),()=>A(``)),z=t===`archived`?void 0:s,ie={view:t,unread:I.unread,finished:I.finished,archivePending:i,onMarkAllRead:()=>a(ar(j)),onArchiveFinished:()=>r(ar(j))};return(0,Q.jsx)(ek,{runs:y?[...F,...y.runs]:F,onRename:o,children:(0,Q.jsx)(ls,{route:`tasks`,density:tA(e,I.visibleCount),headerSpacing:`compact`,rootProps:nA(N),bodyClassName:`gap-3`,header:$k({projectName:m,projectScopePending:h,status:(0,Q.jsx)(Vk,{view:t,onSelect:n,activeCount:I.activeCount,archivedCount:I.archivedCount,trailing:e!==void 0&&L.length>0?(0,Q.jsx)(Wk,{count:I.visibleCount,incomplete:I.incomplete,needle:R}):null}),secondaryActions:(0,Q.jsx)(Kk,{surface:`desktop`,...ie})}),sparseFooter:eA(e!==void 0,I.visibleCount,t,R),children:(0,Q.jsxs)(Ek,{layout:`${P}:${N}`,revision:L,visibilityRevision:JSON.stringify([Uo.map(re.isCollapsed),t,d]),className:`flex min-w-0 flex-1 flex-col gap-3`,children:[(0,Q.jsx)(Yk,{query:k,onQueryChange:A,searchPlaceholder:`Search tasks or automations…`,searchLabel:`Search tasks`,origin:j,originCounts:I.originTotals,automations:w,onOriginChange:M,showReferences:yr(L,re.isCollapsed,N),columns:N?te:ne,expandedColumns:d,columnsPending:p,onToggleColumn:f,detailedTable:N,onToggleDetailed:()=>ee(e=>!e),groupLabels:L.map(e=>e.label),allGroupsCollapsed:sA(L.map(e=>e.label),re.isCollapsed),onSetAllFolds:re.setAll,mobileActions:(0,Q.jsx)(Kk,{surface:`mobile`,...ie})}),(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col`,children:[e===void 0?(0,Q.jsx)(oA,{error:_,onRetry:v}):(0,Q.jsx)(sj,{view:t,query:k,origin:j,onShowAll:()=>{A(``),M(`all`)},groups:L,folds:re,grouped:{desktop:P,detailedTable:N,columns:te,expandedColumns:d,onToggleColumn:f,columnsPending:p,onRename:o,onTogglePin:z,now:c,showTokens:l,showCost:u,runners:g,automationName:O}}),t===`archived`&&y?(0,Q.jsx)(aA,{pages:y}):null]})]})})})}function ij(e,t){let[n,r]=Z.useState(e),i=Z.useRef(e),a=Z.useRef(e),o=Z.useRef([]);return Z.useEffect(()=>{if(e===i.current)return;i.current=e;let t=o.current.indexOf(e);o.current=t===-1?[]:o.current.slice(t+1),t===-1&&e!==a.current&&r(e)},[e]),Z.useEffect(()=>{a.current=n.trim(),t?.(n,e=>{o.current.push(e)})},[t,n]),[n,r]}function aj(e,t,n){let[r,i]=Z.useState(`all`);return[xr(e??r,n),t??i]}function oj({all:e,view:t,query:n,origin:r,archivedPages:i,archivedTotal:a,automationName:o}){let s=n.trim(),c=e=>e.automationId===void 0?``:o(e.automationId)??e.automationId,l=i?.query===s,u=new Set(l?i.runs.map(e=>e.id):[]),d=Ko(e,l||s===``?i?.runs??[]:[]).slice(e.length),f=Cr(e,n,c),p=new Set(f.map(e=>e.id)),m=Cr(e.filter(e=>u.has(e.id)&&!p.has(e.id)),``),h=e=>ir(e,r),g=lr([...f,...m,...Cr(d,``)].filter(h),t,e),_=Ko(e,i?.query===``?i.runs:[]),v=Lo(e).archived>=200,y=e.filter(h);return{groups:g,needle:s,visibleCount:g.reduce((e,t)=>e+sr(t).length,0),originTotals:ur(_,t),activeCount:ur(e,`active`)[r],archivedCount:Qn(e,_,r,i?.plainHasMore,a),incomplete:t===`archived`&&v&&i?.hasMore!==!1,finished:kr(y),unread:Yo(y)}}function sj({view:e,query:t,origin:n,onShowAll:r,groups:i,folds:a,grouped:o}){if(i.length===0)return(0,Q.jsx)(cj,{view:e,query:t,origin:n,onShowAll:r});let s=i.filter(e=>!a.isCollapsed(e.label)),c=yr(i,a.isCollapsed);return(0,Q.jsx)(`div`,{className:`flex flex-col gap-3`,children:i.map(t=>{let n=sr(t);return(0,Q.jsx)(Fk,{id:`tasks-group-${e}-${t.label.replaceAll(` `,`-`)}`,label:t.label,count:n.length,tone:Lk(t.label,n),folded:a.isFolded(t.label),collapsed:a.isCollapsed(t.label),onToggle:()=>a.toggle(t.label),children:(0,Q.jsx)(lj,{group:t,showHeader:t===s[0],showReference:c,...o})},t.label)})})}function cj({view:e,query:t,origin:n=`all`,onShowAll:r}){let i=t.trim(),a=i||n!==`all`?`search-miss`:e===`archived`?`archive`:`no-tasks`;return(0,Q.jsx)(`div`,{"data-slot":`tasks-empty`,"data-empty-kind":a,className:`flex flex-1 flex-col`,children:a===`search-miss`?(0,Q.jsx)(tc,{heading:`h2`,icon:(0,Q.jsx)(Ca,{}),tone:`neutral`,title:`No matching tasks`,subtitle:i?`No tasks match “${i}”.`:n===`automations`?`No automation started a task here.`:`No task here was started directly.`,actions:r?(0,Q.jsx)(Y,{variant:`outline`,"data-action":`clear-task-filters`,onClick:r,children:`Show all tasks`}):void 0}):a===`archive`?(0,Q.jsx)(tc,{heading:`h2`,icon:(0,Q.jsx)(Wi,{}),tone:`neutral`,title:`Nothing archived yet`,subtitle:`Finished tasks you archive land here.`}):(0,Q.jsx)(tc,{heading:`h2`,icon:(0,Q.jsx)(nl,{}),tone:`primary`,backdrop:!0,title:`No tasks yet`,subtitle:`Describe a task to get started.`,actions:(0,Q.jsx)(Y,{asChild:!0,children:(0,Q.jsxs)(X,{to:`/new`,children:[(0,Q.jsx)(vi,{"aria-hidden":`true`}),`New task`]})})})})}function lj({showHeader:e,showReference:t,desktop:n,group:r,detailedTable:i,columns:a,expandedColumns:o,onToggleColumn:s,columnsPending:c,onRename:l,onTogglePin:u,now:d,showTokens:f,showCost:p,runners:m,automationName:h}){let g=Z.useMemo(()=>r.rows.flatMap(e=>$n(e).map(t=>({run:t,queuePosition:t.status===`queued`?e.queuePosition:null}))),[r.rows]),_=Z.useMemo(()=>g.map(({run:e,queuePosition:t})=>mk({run:e,queuePosition:t,runners:m,automationName:h,now:d,showTokens:f,showCost:p})),[g,m,h,d,f,p]),v=Z.useCallback((e,t)=>{u?.(e.run,t)},[u]);return n&&i?(0,Q.jsx)(`div`,{"data-slot":`tasks-table`,className:`overflow-x-auto rounded-lg border border-card-edge bg-card shadow-card`,children:(0,Q.jsx)(Pf,{children:(0,Q.jsxs)(`div`,{role:`table`,"aria-rowcount":g.length+1,className:`task-resource-grid`,style:cO(a,o),children:[(0,Q.jsx)(`div`,{role:`row`,"aria-rowindex":1,className:`task-resource-row`,children:a.map(e=>(0,Q.jsx)(dj,{column:e,expanded:eO(e.id,o),onToggle:s,disabled:c},e.id))}),(0,Q.jsx)(Tk,{itemSize:76,items:g,itemKey:({run:e})=>e.id,children:({run:e,queuePosition:t},n)=>(0,Q.jsx)(mj,{rowIndex:n+2,run:e,queuePosition:t,onRename:l,onTogglePin:u,now:d,columns:a,expandedColumns:o,automationName:h})})]})})}):(0,Q.jsx)(KA,{items:_,density:n?`table`:`card`,now:d,showHeader:e,showProject:!1,showReferences:t,expandedColumns:o,showTokens:f,showCost:p,scopedLinks:!0,liveUsageSource:`stream`,allowRename:n,onTogglePin:u?v:void 0})}function uj({children:e,right:t=!1,columnId:n,folded:r=!1}){return(0,Q.jsx)(`div`,{role:`columnheader`,"data-column-id":n,"data-folded":r||void 0,className:q(`h-[38px] border-b border-border px-2.5 text-left text-xs font-semibold tracking-[0.05em] whitespace-nowrap text-supporting-foreground uppercase first:pl-4 last:pr-4`,t&&`text-right`,r&&`px-0 first:pl-0 last:pr-0`),children:e})}function dj({column:e,expanded:t,onToggle:n,disabled:r}){if(!e.canFold)return(0,Q.jsx)(uj,{columnId:e.id,right:e.align===`right`,children:e.label});let i=t?`Fold`:`Expand`;return(0,Q.jsx)(uj,{columnId:e.id,right:e.align===`right`,folded:!t,children:(0,Q.jsxs)(Ff,{children:[(0,Q.jsx)(If,{asChild:!0,children:(0,Q.jsx)(`button`,{type:`button`,"aria-label":`${i} ${e.label} column`,"aria-pressed":t,disabled:r,onClick:()=>n(e.id),className:q(`inline-flex h-8 w-full items-center gap-1 rounded-sm px-0.5 text-inherit outline-none hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:cursor-wait disabled:opacity-60`,e.align===`right`?`justify-end`:`justify-start`,!t&&`justify-center px-0`),children:t?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`span`,{className:`min-w-0 truncate`,children:e.label}),(0,Q.jsx)(Rc,{className:`size-3 opacity-55`,"aria-hidden":`true`})]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(fj,{icon:e.icon}),(0,Q.jsx)(zc,{className:`size-3 opacity-70`,"aria-hidden":`true`})]})})}),(0,Q.jsxs)(Lf,{side:`top`,children:[e.label,` · `,i,` column`]})]})})}function fj({icon:e}){let t=`size-3.5`;switch(e){case`workflow`:return(0,Q.jsx)(Di,{className:t,"aria-hidden":`true`});case`branch`:return(0,Q.jsx)(ji,{className:t,"aria-hidden":`true`});case`diff`:return(0,Q.jsx)(Ji,{className:t,"aria-hidden":`true`});case`reference`:return(0,Q.jsx)(tl,{className:t,"aria-hidden":`true`});case`tokens`:return(0,Q.jsx)(Hc,{className:t,"aria-hidden":`true`});case`cost`:return(0,Q.jsx)(Gc,{className:t,"aria-hidden":`true`});case`cpu`:return(0,Q.jsx)(Si,{className:t,"aria-hidden":`true`});case`memory`:return(0,Q.jsx)(rl,{className:t,"aria-hidden":`true`});case`started`:return(0,Q.jsx)(Vc,{className:t,"aria-hidden":`true`});default:return null}}var pj=`h-[88px] border-b border-border px-2.5 whitespace-nowrap first:pl-4 last:pr-4`,mj=Z.memo(function({rowIndex:e,run:t,queuePosition:n,onRename:r,onTogglePin:i,now:a,columns:o,expandedColumns:s,automationName:c}){let l=To(),u=qe(t),d=Ar(t),f=`/tasks/${t.id}`,p=_r(t.costUsd),m=fr(t);return(0,Q.jsx)(`div`,{role:`row`,"aria-rowindex":e,"data-slot":`task-table-row`,"data-run-id":t.id,onClick:e=>{e.target.closest(`a, button, input`)||l(f)},className:`task-resource-row group/row cursor-pointer hover:bg-muted`,children:o.map(e=>{if(e.id===`memory`)return null;if(e.id===`cpu`){let r=eO(`cpu`,s),i=eO(`memory`,s);return n!==null&&(r||i)?(0,Q.jsxs)(`div`,{role:`cell`,"data-slot":`queue-note`,"data-column-id":`cpu-memory`,"aria-colspan":2,style:{gridColumn:`span 2`},className:q(pj,`text-right font-mono text-xs text-supporting-foreground`),children:[`#`,n,` in queue`]},e.id):(0,Q.jsx)(bj,{run:t,cpuExpanded:r,memoryExpanded:i},e.id)}return(0,Q.jsx)(_j,{column:e,expanded:eO(e.id,s),run:t,attention:u,scheduled:d,reference:m,cost:p,to:f,onRename:r,onTogglePin:i,now:a,automationName:c},e.id)})})});function hj({run:e,to:t,onRename:n,onTogglePin:r,automationName:i}){let a=e.automationId===void 0?void 0:i(e.automationId)??e.automationId;return(0,Q.jsxs)(`div`,{role:`cell`,"data-column-id":`task`,className:q(pj,`min-w-0 whitespace-normal`),children:[(0,Q.jsx)(yj,{lines:2,run:e,to:t,onRename:n,onTogglePin:r}),a?(0,Q.jsx)(`div`,{className:`mt-1`,children:(0,Q.jsxs)(`span`,{"data-slot":`task-automation-badge`,"data-origin":`automation`,className:`inline-flex max-w-[180px] items-center gap-1 truncate rounded-full border border-info/30 bg-info/10 px-2 py-px text-xs font-medium text-semantic-info`,children:[(0,Q.jsx)(Zi,{className:`size-2.5 shrink-0`,"aria-hidden":`true`}),(0,Q.jsx)(`span`,{className:`truncate`,children:a})]})}):null]})}function gj({run:e,attention:t,scheduled:n}){let r=zm(e,t);return(0,Q.jsx)(`div`,{role:`cell`,"data-column-id":`status`,className:q(pj,`overflow-hidden`),children:(0,Q.jsx)(Td,{dot:r.tone,shape:r.shape,pulse:r.pulse,title:n?.title??r.label,className:`w-full max-w-full overflow-hidden`,children:(0,Q.jsxs)(`span`,{className:`min-w-0 whitespace-normal`,children:[r.label,n?(0,Q.jsxs)(Q.Fragment,{children:[` `,(0,Q.jsx)(`span`,{className:`block tabular-nums`,children:n.label})]}):null]})})})}function _j({column:e,expanded:t,run:n,attention:r,scheduled:i,reference:a,cost:o,to:s,onRename:c,onTogglePin:l,now:u,automationName:d}){if(!t)return(0,Q.jsx)(vj,{column:e.id});switch(e.id){case`status`:return(0,Q.jsx)(gj,{run:n,attention:r,scheduled:i});case`task`:return(0,Q.jsx)(hj,{run:n,to:s,onRename:c,onTogglePin:l,automationName:d});case`workflow`:return(0,Q.jsx)(`div`,{role:`cell`,"data-column-id":e.id,className:q(pj,`max-w-0 truncate text-[13px] text-muted-foreground`),children:cr(n)});case`branch`:return(0,Q.jsx)(`div`,{role:`cell`,"data-column-id":e.id,className:q(pj,`max-w-0 overflow-hidden`),children:n.branch?(0,Q.jsx)(Gk,{branch:n.branch}):(0,Q.jsx)(Hk,{})});case`diff`:return(0,Q.jsx)(`div`,{role:`cell`,"data-column-id":e.id,className:q(pj,`overflow-hidden`),children:n.diffStat?(0,Q.jsx)(km,{stat:n.diffStat,compact:!0,className:`block max-w-full`}):(0,Q.jsx)(Hk,{})});case`reference`:return(0,Q.jsx)(`div`,{role:`cell`,"data-column-id":e.id,className:q(pj,`overflow-hidden`),children:a?(0,Q.jsx)(D_,{run:n,reference:a,compact:!0,className:`max-w-full overflow-hidden`}):(0,Q.jsx)(Hk,{})});case`tokens`:{let t=uA(n.inputTokens,n.outputTokens);return(0,Q.jsx)(`div`,{role:`cell`,"data-column-id":e.id,className:q(pj,`text-right text-xs text-muted-foreground`),children:(0,Q.jsx)(fA,{inputTokens:n.inputTokens,outputTokens:n.outputTokens,variant:`table`,omitWhenUnknown:!1,title:t,className:`block max-w-full overflow-hidden text-ellipsis`})})}case`cost`:return(0,Q.jsx)(`div`,{role:`cell`,"data-column-id":e.id,className:q(pj,`text-right font-mono text-xs text-muted-foreground tabular-nums`),children:o?(0,Q.jsx)(Sj,{text:o,accessibleText:`$${n.costUsd}`}):(0,Q.jsx)(Hk,{})});case`started`:return(0,Q.jsx)(`div`,{role:`cell`,"data-column-id":e.id,className:q(pj,`text-right text-xs text-supporting-foreground`),children:(0,Q.jsx)(jm,{iso:n.startedAt??n.createdAt,now:u})});default:return null}}function vj({column:e}){return(0,Q.jsx)(`div`,{role:`cell`,"aria-hidden":`true`,"data-column-id":e,"data-folded":`true`,className:q(pj,`px-0 first:pl-0 last:pr-0`)})}function yj({run:e,to:t,onTogglePin:n,lines:r=1}){return(0,Q.jsx)(jA,{run:e,to:t,title:Ro(e),unread:mn(e),unreadTone:Xo(e),readDone:Zo(e),isWorker:e.delegation?.role===`worker`,pinned:!!e.pinned,onTogglePin:n?t=>n(e,t):void 0,lines:r})}function bj({run:e,cpuExpanded:t,memoryExpanded:n}){let r=tr(e,Nr(e.id));return(0,Q.jsxs)(Q.Fragment,{children:[t?(0,Q.jsx)(xj,{column:`cpu`,cell:r.cpu}):(0,Q.jsx)(vj,{column:`cpu`}),n?(0,Q.jsx)(xj,{column:`memory`,cell:r.mem}):(0,Q.jsx)(vj,{column:`memory`})]})}function xj({column:e,cell:t}){let n=t.text&&t.title?`${t.text}; ${t.title}`:t.text;return(0,Q.jsx)(`div`,{role:`cell`,"data-usage":e===`memory`?`mem`:e,"data-column-id":e,"data-usage-kind":t.kind,className:q(pj,`overflow-hidden text-right font-mono tabular-nums`,t.kind===`live`&&`bg-accent-strong/5 text-xs font-medium text-foreground`,t.kind===`peak`&&`text-xs text-supporting-foreground`,t.kind===`none`&&`text-xs text-soft-foreground`),children:(0,Q.jsx)(Sj,{text:t.text||`—`,accessibleText:n||void 0})})}function Sj({text:e,accessibleText:t}){return(0,Q.jsx)(`span`,{"data-slot":`bounded-metric`,...t?{"aria-label":t,title:t}:{},className:`block max-w-full overflow-hidden text-ellipsis`,children:e})}function Cj(){let e=T(),t=L(),n=c(),r=$A(n.data),i=_m(),{view:a,setView:o,origin:u,setOrigin:d,urlQuery:f,writeQuery:p}=qA(),h=se(),g=U(),_=iA(e.data,a),y=je({mutationFn:e=>ln(v(),void 0,e),onSuccess:()=>h.invalidateAfter(`runs`,()=>v()),onError:e=>H(e.message,{tone:`danger`})}),b=je({mutationFn:e=>ct(e),onSuccess:()=>g.invalidateQueries({queryKey:ge.runs.all}),onError:e=>H(e.message,{tone:`danger`})}),x=je({mutationFn:({id:e,title:t})=>ot(e,{title:t}),onSuccess:()=>g.invalidateQueries({queryKey:ge.runs.all}),onError:e=>H(e.message,{tone:`danger`})}),S=l(),C=is(3e4),w=tj(),E=te(),D=m(void 0,{retryOnMount:!1}),O=A({retryOnMount:!1}),k=O.data?.projects?.find(e=>e.id===E)?.name,j=k===void 0&&(Zk(O)||E===void 0&&Zk(n)),M=[...e.data??[],..._.pages?.runs??[]].some(e=>e.automationId!==void 0),N=s([void 0],i&&M),ee=Z.useCallback(e=>N(void 0,e),[N]),P=Z.useMemo(()=>E===void 0?[]:(e.data??[]).flatMap(e=>{let t=fr(e);return t?[{projectId:E,kind:t.kind,number:t.number}]:[]}),[e.data,E]),F=Z.useCallback((e,t)=>x.mutate({id:e,title:t}),[x.mutate]),I=Z.useCallback((e,t)=>S.mutate({id:e.id,pinned:t}),[S.mutate]);return(0,Q.jsx)(br,{projectId:E,repoBase:D,requests:P,children:(0,Q.jsx)(rj,{runs:e.data,runners:t.data,projectName:k,projectScopePending:j,error:e.error?.message,onRetry:()=>void e.refetch(),view:a,onViewChange:o,origin:u,onOriginChange:d,automations:i,urlQuery:f,onQueryChange:p,foldScope:`project:${E??`default`}`,automationName:ee,onArchiveFinished:e=>{y.isPending||y.mutate(e)},archivePending:y.isPending,onMarkAllRead:e=>b.mutate(e),onRename:F,onTogglePin:I,now:C,showTokens:r.tokens,showCost:r.cost,expandedColumns:w.expandedColumns,onToggleColumn:w.toggleColumn,columnsPending:w.isPending,archivedPages:_.pages,archivedTotal:_.total,onArchivedSearch:_.search})})}function wj(e){return e.kind===`loading`?`Loading tasks from this host…`:e.kind===`stale`?e.state===`connected`?`Not live — showing last known tasks while syncing.`:`Not live — showing last known tasks.`:`No tasks loaded yet.`}function Tj({entries:e,excludedBulkHosts:t=[],searchUnanswered:n=[],searchTruncated:r=[],searchError:i=!1,searchWarning:a,error:o,onRetry:s}){let c=n.length>0||r.length>0||i||!!a;return e.length===0&&t.length===0&&!o&&!c?null:(0,Q.jsxs)(`div`,{"data-slot":`global-hosts-status`,className:`flex flex-col gap-1.5 rounded-lg border border-border bg-card px-3.5 py-2.5 text-xs text-muted-foreground`,children:[o?(0,Q.jsxs)(`div`,{role:`alert`,"data-slot":`global-hosts-error`,className:`flex flex-wrap items-center justify-between gap-2 text-semantic-red`,children:[(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,Q.jsx)(Bc,{className:`size-3.5 shrink-0`,"aria-hidden":`true`}),(0,Q.jsxs)(`span`,{children:[`Could not load tasks from remote hosts: `,o]})]}),s?(0,Q.jsx)(Y,{type:`button`,variant:`outline`,size:`sm`,onClick:s,children:`Retry`}):null]}):null,e.map(e=>(0,Q.jsxs)(`div`,{"data-slot":`global-host-status-row`,"data-host-id":e.id,"data-host-status":e.kind,className:`flex flex-wrap items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:`font-medium text-foreground`,children:e.label}),e.kind===`loading`?(0,Q.jsx)(Td,{"data-slot":`host-loading-pill`,dot:`pending`,pulse:!0,className:`py-0.5 text-muted-foreground`,children:`Loading`}):e.kind===`stale`?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Ed,{state:e.state}),(0,Q.jsx)(Od,{})]}):(0,Q.jsx)(Ed,{state:e.state}),(0,Q.jsx)(`span`,{children:wj(e)})]},e.id)),(0,Q.jsx)(Dp,{unanswered:n,error:i,warning:a,className:`text-muted-foreground`}),r.length>0?(0,Q.jsxs)(`p`,{"data-slot":`host-search-truncated`,role:`status`,className:`text-muted-foreground`,children:[`More matches in `,r.join(`, `),`. Type more to narrow them.`]}):null,t.length>0?(0,Q.jsxs)(`p`,{"data-slot":`global-bulk-excluded-hosts`,className:`text-muted-foreground`,children:[`Bulk actions skip hosts that are not live: `,t.join(`, `),`.`]}):null]})}function Ej({hits:e,now:t}){return e.length===0?null:(0,Q.jsxs)(`section`,{"data-slot":`host-search-more-matches`,"aria-labelledby":`host-search-more-matches-heading`,className:`rounded-lg border border-border bg-card p-4`,children:[(0,Q.jsx)(`h2`,{id:`host-search-more-matches-heading`,className:`text-sm font-semibold text-foreground`,children:`More matches on hosts`}),(0,Q.jsx)(`div`,{className:`mt-2 flex flex-col divide-y divide-border`,children:e.map(({run:e,hostLabel:n,projectName:r})=>{let i=zm(e,qe(e));return(0,Q.jsxs)(`a`,{href:Re(e.hostId,e.projectId,e.id),"data-slot":`host-search-extra-row`,"data-host-id":e.hostId,"data-project-id":e.projectId,"data-run-id":e.id,className:`flex min-h-11 items-center gap-2.5 py-2 text-sm text-foreground hover:text-accent-text`,children:[(0,Q.jsx)(Qo,{tone:i.tone,shape:i.shape,pulse:i.pulse,"aria-label":i.label,role:`img`}),(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-medium`,children:Ro(e)}),(0,Q.jsx)(Dd,{label:n,hostId:e.hostId}),(0,Q.jsx)(`span`,{className:`shrink-0 truncate text-xs text-soft-foreground max-sm:hidden`,children:r}),(0,Q.jsx)(jm,{iso:e.finishedAt??e.createdAt,now:t,className:`shrink-0 text-xs text-soft-foreground`})]},`${e.hostId}/${e.projectId}/${e.id}`)})})]})}function Dj({message:e,onDismiss:t}){return e?(0,Q.jsxs)(`div`,{role:`alert`,"data-slot":`global-bulk-error`,className:`flex items-center justify-between gap-2 rounded-lg border border-danger/35 bg-danger/10 py-1.5 pr-1.5 pl-3.5 text-xs text-semantic-red`,children:[(0,Q.jsxs)(`span`,{className:`inline-flex min-w-0 items-start gap-2`,children:[(0,Q.jsx)(Bc,{className:`mt-0.5 size-3.5 shrink-0`,"aria-hidden":`true`}),(0,Q.jsx)(`span`,{className:`min-w-0 break-words`,children:e})]}),(0,Q.jsx)(Y,{type:`button`,variant:`ghost`,size:`icon`,"aria-label":`Dismiss error`,onClick:t,className:`shrink-0 text-semantic-red/80 hover:bg-danger/15 hover:text-semantic-red`,children:(0,Q.jsx)(Fi,{className:`size-3.5`,"aria-hidden":`true`})})]}):null}function Oj({projects:e,perProjectLimit:t}){return e.length===0?null:(0,Q.jsxs)(`p`,{"data-slot":`global-tasks-truncated`,className:`text-xs text-soft-foreground`,children:[`Showing every active task and the newest `,t,` archived tasks per project — older archived tasks in`,` `,e.join(`, `),` are in that project’s own Tasks page.`]})}function kj({registry:e}){return e.length<=1?null:(0,Q.jsxs)(`section`,{"data-slot":`other-projects`,className:`rounded-lg border border-border bg-card p-5`,children:[(0,Q.jsx)(`h2`,{className:`text-base font-semibold`,children:`Other projects`}),(0,Q.jsx)(`div`,{className:`mt-3 flex flex-col divide-y divide-border`,children:e.map(e=>(0,Q.jsxs)(`div`,{className:`flex min-h-14 items-center justify-between gap-3`,children:[(0,Q.jsx)(`span`,{className:`min-w-0 truncate text-[13px]`,children:e.name}),(0,Q.jsxs)(G,{to:wo(e.id,`/`),className:`inline-flex min-h-11 shrink-0 items-center rounded-md px-3 text-xs text-accent-text hover:bg-accent-strong/10`,children:[`View tasks`,(0,Q.jsxs)(`span`,{className:`sr-only`,children:[` for `,e.name]})]})]},e.id))})]})}function Aj({view:e,filtered:t,unloadedHosts:n=[]}){if(t)return(0,Q.jsx)(tc,{heading:`h2`,icon:(0,Q.jsx)(Ca,{}),tone:`neutral`,title:`No matching tasks`,subtitle:`No task in any project matches these filters.`});let r=n.some(e=>e.kind===`loading`),i=n.some(e=>e.kind===`offline`);return r||i?(0,Q.jsx)(tc,{heading:`h2`,icon:(0,Q.jsx)(nl,{}),tone:`neutral`,title:r&&!i?`Loading remote host tasks…`:`No tasks available yet`,subtitle:r&&i?`Connected hosts are loading and offline hosts have no cached tasks.`:r?`No local tasks yet. Tasks from connected remote hosts are loading.`:`No local tasks yet. Offline hosts are not connected and have no cached tasks.`}):e===`archived`?(0,Q.jsx)(tc,{heading:`h2`,icon:(0,Q.jsx)(Wi,{}),tone:`neutral`,title:`Nothing archived yet`,subtitle:`Finished tasks you archive land here, from every project.`}):(0,Q.jsx)(tc,{heading:`h2`,icon:(0,Q.jsx)(nl,{}),tone:`neutral`,title:`No tasks yet`,subtitle:`Start a task in any project and it shows up here.`})}function jj({groupBy:e,filterDetailsOpen:t,message:n,onRetry:r}){return(0,Q.jsx)(ls,{route:`global-tasks`,density:`empty`,rootProps:{"data-presentation":e===`none`?`summary`:`cards`,"data-filter-details":String(t)},className:`pb-[calc(90px+env(safe-area-inset-bottom))]`,bodyClassName:`gap-[22px]`,children:(0,Q.jsx)(tc,{icon:(0,Q.jsx)(ri,{}),tone:`danger`,title:`Tasks across projects did not load`,subtitle:n,actions:(0,Q.jsx)(Y,{variant:`outline`,onClick:r,children:`Retry`})})})}function Mj({slot:e,label:t,options:n,selected:r,onToggle:i,onClear:a,searchPlaceholder:o,emptyLabel:s=`Nothing to filter by`}){let[c,l]=Z.useState(!1),u=r.length>0,d=r.length===1?n.find(e=>e.value===r[0])?.label??r[0]:`${r.length} selected`;return(0,Q.jsxs)(po,{open:c,onOpenChange:l,children:[(0,Q.jsx)(co,{asChild:!0,children:(0,Q.jsxs)(`button`,{type:`button`,"data-slot":`facet-${e}`,"data-active":u?`true`:void 0,"aria-label":`Filter by ${t.toLowerCase()}`,className:q(`inline-flex h-7 items-center gap-1.5 rounded-full border border-border bg-card px-2.5 text-xs font-medium text-muted-foreground transition-colors hover:bg-muted hover:text-foreground`,u&&`border-accent-strong/40 bg-accent-strong/10 text-foreground`),children:[(0,Q.jsx)(`span`,{className:q(u&&`text-soft-foreground`),children:t}),u?(0,Q.jsx)(`span`,{className:`max-w-[140px] truncate font-semibold`,children:d}):null,(0,Q.jsx)(ta,{"aria-hidden":`true`,className:`size-2.5 shrink-0 text-soft-foreground`})]})}),(0,Q.jsxs)(uo,{align:`start`,className:`w-64 p-0`,"data-testid":`facet-${e}-menu`,children:[(0,Q.jsxs)(Ns,{children:[(0,Q.jsx)(Ts,{placeholder:o??`Search ${t.toLowerCase()}…`}),(0,Q.jsxs)(Ms,{children:[(0,Q.jsx)(js,{children:s}),(0,Q.jsx)(Ds,{children:n.map(e=>{let t=r.includes(e.value);return(0,Q.jsxs)(As,{value:e.label,onSelect:()=>i(e.value),"data-slot":`facet-option`,"data-value":e.value,"aria-checked":t,role:`option`,children:[(0,Q.jsx)(`span`,{"aria-hidden":`true`,className:q(`flex size-4 shrink-0 items-center justify-center rounded-[4px] border`,t?`border-accent-strong bg-accent-strong text-accent-strong-foreground`:`border-input`),children:t?(0,Q.jsx)(ea,{className:`size-3`}):null}),(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.label}),e.count===void 0?null:(0,Q.jsx)(`span`,{className:`shrink-0 font-mono text-xs text-soft-foreground tabular-nums`,children:e.count})]},e.value)})})]})]}),u?(0,Q.jsx)(`div`,{className:`border-t border-border p-1`,children:(0,Q.jsxs)(`button`,{type:`button`,"data-action":`facet-${e}-clear`,onClick:()=>a(),className:`w-full rounded-sm px-2 py-1.5 text-left text-xs font-medium text-muted-foreground hover:bg-muted hover:text-foreground`,children:[`Clear `,t.toLowerCase()]})}):null]})]})}function Nj({label:e,count:t,selected:n,onToggle:r,slot:i,tone:a=`neutral`}){return(0,Q.jsxs)(`button`,{type:`button`,"data-slot":i,"data-selected":n?`true`:void 0,"aria-pressed":n,onClick:r,className:q(`inline-flex h-7 items-center gap-1.5 rounded-full border px-2.5 text-xs font-medium transition-colors`,a===`tag`?`border-accent-strong/25 bg-accent-strong/10 text-accent-text hover:bg-accent-strong/20`:`border-border bg-card text-muted-foreground hover:bg-muted hover:text-foreground`,n&&`border-accent-strong bg-accent-strong text-accent-strong-foreground hover:bg-accent-strong`),children:[e,t===void 0?null:(0,Q.jsx)(`span`,{className:q(`font-mono text-xs tabular-nums`,!n&&`text-soft-foreground`),children:t})]})}function Pj({slot:e,label:t,value:n,options:r,onChange:i,size:a=`compact`}){return(0,Q.jsx)(`div`,{"data-slot":e,role:`group`,"aria-label":t,className:`inline-flex gap-0.5 rounded-md bg-muted p-[3px]`,children:r.map(e=>{let t=e.value===n;return(0,Q.jsx)(`button`,{type:`button`,"data-value":e.value,"aria-pressed":t,disabled:e.disabled,title:e.title,onClick:()=>i(e.value),className:q(`flex h-6 items-center justify-center rounded-[6px] px-2.5 text-[12px] font-medium text-muted-foreground transition-colors hover:text-foreground disabled:pointer-events-none disabled:opacity-50`,a===`touch`&&`h-11 px-4 text-[13px]`,t&&`bg-card font-semibold text-foreground shadow-xs`),children:e.label},e.value)})})}var Fj=ft;function Ij(e){return e.hostId??Fj}function Lj(e,t){return t===void 0?e:`${t}/${e}`}var Rj=` untagged`,zj=[{value:`project`,label:`Project`},{value:`tag`,label:`Tag`},{value:`status`,label:`Status`},{value:`workflow`,label:`Workflow`}];function Bj(e,t){return e===t?`none`:t}var Vj={query:``,tags:[],statuses:[],workflows:[]};function Hj(e,t){let{origin:n,...r}=e;return t===`all`?r:{...r,origin:t}}function Uj(e,t){return e.includes(t)?e.filter(e=>e!==t):[...e,t]}function Wj(e){return(e.hosts?.length??0)+(e.projects?.length??0)+e.tags.length+e.statuses.length+e.workflows.length+(e.origin===void 0||e.origin===`all`?0:1)}function Gj(e){return e.query.trim()!==``||Wj(e)>0}function Kj(e){return Wj(e.filters)+(e.filters.query.trim()===``?0:1)}function qj(e){return Kj(e)>0||e.groupBy!==`none`}var Jj=new WeakMap;function Yj(e,t,n){let r=Jj.get(e);if(r&&r.project===t&&r.hostId===n?.id&&r.hostLabel===n?.label&&r.hostStale===n?.stale&&r.hostState===n?.state)return r.task;let i={run:e,...n?{hostId:n.id,hostLabel:n.label,hostStale:n.stale,hostState:n.state}:{},project:t,projectName:t?.name||e.projectId,tags:t?.tags??[]};return Jj.set(e,{project:t,hostId:n?.id,hostLabel:n?.label,hostStale:n?.stale,hostState:n?.state,task:i}),i}function Xj(e,t){if(t.length===0)return e;if(e.length===0)return t;let n=[],r=0,i=0;for(;r<e.length&&i<t.length;)(e[r].run.createdAt??``)>=t[i].run.createdAt?n.push(e[r++]):n.push(t[i++]);for(;r<e.length;)n.push(e[r++]);for(;i<t.length;)n.push(t[i++]);return n}function Zj(e,t,n){let r=new Map(t.map(e=>[e.id,e])),i=[];for(let t of e)No(t)||i.push(Yj(t,r.get(t.projectId)));if(!n||n.runs.length===0)return i;let a=new Map(n.hosts.map(e=>[e.id,e])),o=new Map;for(let[e,t]of n.projectsByHost)o.set(e,new Map(t.map(e=>[e.id,e])));let s=[];for(let e of n.runs){if(No(e))continue;let t=a.get(e.hostId),n=o.get(e.hostId)?.get(e.projectId);s.push(Yj(e,n,{id:e.hostId,label:t?.label??e.hostId,stale:t?.stale??!1,state:t?.state??`connected`}))}return Xj(i,s)}function Qj(e,t){let n=new Map;for(let r of e)for(let e of t(r))n.set(e,(n.get(e)??0)+1);return n}var $j=e=>e.tags.length===0?[Rj]:e.tags,eM=(e,t)=>e.length===0||t.some(t=>e.includes(t)),tM=(e,t)=>{if(t.length===0)return!0;let n=$j(e).map(e=>e.toLowerCase());return t.some(e=>n.includes(e.toLowerCase()))};function nM(e,t){return{displayTitle:Ro(e.run),projectName:e.hostLabel?`${e.projectName} ${e.hostLabel}`:e.projectName,tags:e.tags,automation:e.run.automationId===void 0?void 0:t(e)??e.run.automationId,references:()=>jr(e.run)}}function rM(e,t,n,r=()=>void 0){let i=t.query.trim()!==``,a=t.hosts??[],o=t.projects??[];return e.filter(e=>(n===`archived`?!e.run.archived:e.run.archived)||!ir(e.run,t.origin??`all`)||!eM(a,[Ij(e)])||!eM(o,[Lj(e.run.projectId,e.hostId)])||!eM(t.statuses,[e.run.status])||!eM(t.workflows,[e.run.workflow])||!tM(e,t.tags)?!1:!i||Sr(e.run,t.query,{scope:`shown`,extras:nM(e,r)}))}function iM(e,t,n,r,i){return rM(e,r===`origin`?{...t,origin:`all`}:{...t,[r]:[]},n,i)}function aM(e,t){if(t===`none`)return[{key:`all`,label:``,tasks:[...e]}];let n=new Map,r=(e,t,r,i)=>{let a=n.get(e);a?a.tasks.push(r):n.set(e,{key:e,label:t,...i,tasks:[r]})};for(let n of e)if(t===`project`)r(n.hostId===void 0?n.run.projectId:`host:${n.hostId}/${n.run.projectId}`,n.projectName,n,{projectId:n.run.projectId,...n.hostId===void 0?{}:{hostId:n.hostId,hostLabel:n.hostLabel}});else if(t===`status`)r(n.run.status,Um(n.run.status),n);else if(t===`workflow`)r(n.run.workflow,n.run.workflow,n);else if(n.tags.length===0)r(Rj,`Untagged`,n);else for(let e of n.tags)r(e.toLowerCase(),e,n);return[...n.values()].sort((e,t)=>e.key===` untagged`?1:t.key===` untagged`?-1:t.tasks.length-e.tasks.length||e.label.localeCompare(t.label))}function oM(e,t){let n=new Map(t.map(e=>[e.id,e.name]));return e.map(e=>n.get(e)||e)}var $={query:`q`,host:`host`,project:`project`,tag:`tag`,untagged:`untagged`,status:`status`,workflow:`workflow`,groupBy:`group`,archived:`archived`,origin:`origin`},sM=new Set(zj.map(e=>e.value));function cM(e){let t=new URLSearchParams,n=e.filters.query.trim();n!==``&&t.set($.query,n);for(let n of e.filters.tags)n===` untagged`?t.set($.untagged,`1`):t.append($.tag,n);for(let n of e.filters.hosts??[])t.append($.host,n);for(let n of e.filters.projects??[])t.append($.project,n);for(let n of e.filters.statuses)t.append($.status,n);for(let n of e.filters.workflows)t.append($.workflow,n);return e.groupBy!==`none`&&t.set($.groupBy,e.groupBy),e.view===`archived`&&t.set($.archived,`1`),e.filters.origin!==void 0&&e.filters.origin!==`all`&&t.set($.origin,e.filters.origin),t}function lM(e,t){let n=e.getAll($.tag).filter(e=>e!==``);e.get($.untagged)===`1`&&n.push(Rj);let r=e.get($.groupBy)??``,i=xr(Mr(e.get($.origin)),t);return{filters:{query:e.get($.query)??``,...e.has($.host)?{hosts:e.getAll($.host).filter(Boolean)}:{},...e.has($.project)?{projects:e.getAll($.project).filter(Boolean)}:{},tags:n,statuses:e.getAll($.status).filter(e=>e!==``),workflows:e.getAll($.workflow).filter(e=>e!==``),...i===`all`?{}:{origin:i}},groupBy:sM.has(r)?r:`none`,view:e.get($.archived)===`1`?`archived`:`active`}}function uM(e){return(e.hosts?.length??0)+(e.projects?.length??0)+e.tags.length+e.statuses.length+e.workflows.length}function dM(e,t){e.set(t,(e.get(t)??0)+1)}function fM(e,t,n){let r=new Map,i=new Map,a=new Map,o=new Map,s=new Map,c=n&&(!t.hosts||t.hosts.length===0),l=!t.projects||t.projects.length===0,u=t.tags.length===0,d=t.statuses.length===0,f=t.workflows.length===0;if(c||l||u||d||f)for(let t of e){if(c&&dM(r,Ij(t)),l&&dM(i,Lj(t.run.projectId,t.hostId)),u)for(let e of $j(t))dM(a,e);d&&dM(o,t.run.status),f&&dM(s,t.run.workflow)}return{hosts:r,projects:i,tags:a,statuses:o,workflows:s}}function pM(e,t){let n=new Map,r=new Set,i=new Set;for(let a of e){let e=Lj(a.run.projectId,a.hostId);n.has(e)||n.set(e,t&&a.hostLabel?`${a.projectName} · ${a.hostLabel}`:a.projectName),r.add(a.run.status),i.add(a.run.workflow)}return{projects:[...n.entries()],statuses:[...r].sort((e,t)=>e.localeCompare(t)),workflows:[...i].sort((e,t)=>e.localeCompare(t))}}function mM({filters:e,onToggle:t,onClearFacet:n,onClearAll:r,groupBy:i,onGroupByChange:a,projects:o,hosts:s=[],tasks:c,visible:l,view:u,automationName:d}){let f=Z.useMemo(()=>_e(o),[o]),p=s.length>0,m=Z.useMemo(()=>{let t=l===void 0?{hosts:new Map,projects:new Map,tags:new Map,statuses:new Map,workflows:new Map}:fM(l,e,p),n=(t,n,r,i)=>l!==void 0&&(!n||n.length===0)?i:Qj(iM(c,e,u,t,d),r);return{hosts:p?n(`hosts`,e.hosts,e=>[Ij(e)],t.hosts):t.hosts,projects:n(`projects`,e.projects,e=>[Lj(e.run.projectId,e.hostId)],t.projects),tags:n(`tags`,e.tags,$j,t.tags),statuses:n(`statuses`,e.statuses,e=>[e.run.status],t.statuses),workflows:n(`workflows`,e.workflows,e=>[e.run.workflow],t.workflows)}},[c,l,e,u,d,p]),h=Z.useMemo(()=>pM(c,p),[c,p]),g=Z.useMemo(()=>h.projects.map(([e,t])=>({value:e,label:t,count:m.projects.get(e)??0})),[h.projects,m.projects]),_=Z.useMemo(()=>p?[{value:Fj,label:`This server`,count:m.hosts.get(Fj)??0},...s.map(e=>({value:e.id,label:e.label,count:m.hosts.get(e.id)??0}))]:[],[p,s,m.hosts]),v=Z.useMemo(()=>h.statuses.map(e=>({value:e,label:Um(e),count:m.statuses.get(e)??0})),[h.statuses,m.statuses]),y=Z.useMemo(()=>h.workflows.map(e=>({value:e,label:e,count:m.workflows.get(e)??0})),[c,m.workflows]);return(0,Q.jsxs)(`div`,{id:`global-tasks-filters`,"data-slot":`global-tasks-filters`,className:`flex flex-col gap-2`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[p?(0,Q.jsx)(Mj,{slot:`host`,label:`Host`,selected:e.hosts??[],onToggle:e=>t(`hosts`,e),onClear:()=>n(`hosts`),options:_,emptyLabel:`No hosts`}):null,(0,Q.jsx)(Mj,{slot:`project`,label:`Project`,selected:e.projects??[],onToggle:e=>t(`projects`,e),onClear:()=>n(`projects`),options:g,emptyLabel:`No tasks to filter`}),(0,Q.jsx)(Mj,{slot:`status`,label:`Status`,selected:e.statuses,onToggle:e=>t(`statuses`,e),onClear:()=>n(`statuses`),options:v,emptyLabel:`No tasks to filter`}),(0,Q.jsx)(Mj,{slot:`workflow`,label:`Workflow`,selected:e.workflows,onToggle:e=>t(`workflows`,e),onClear:()=>n(`workflows`),options:y,emptyLabel:`No tasks to filter`}),(0,Q.jsxs)(`div`,{"data-slot":`group-controls`,className:`flex flex-wrap items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:`mx-1 h-5 w-px bg-border`,"aria-hidden":`true`}),(0,Q.jsx)(`span`,{className:`text-xs font-medium text-soft-foreground`,children:`Group by`}),(0,Q.jsx)(Pj,{slot:`group-by`,label:`Group tasks by`,value:i,options:zj,onChange:e=>a(Bj(i,e))})]}),qj({filters:e,groupBy:i})?(0,Q.jsxs)(`button`,{type:`button`,"data-action":`clear-filters`,onClick:r,className:`ml-auto inline-flex h-7 items-center gap-1 rounded-full px-2 text-xs font-medium text-muted-foreground hover:bg-muted hover:text-foreground`,children:[(0,Q.jsx)(Fi,{className:`size-3`,"aria-hidden":`true`}),`Clear`,Kj({filters:e,groupBy:i})>0?` (${Kj({filters:e,groupBy:i})})`:null]}):null]}),f.length>0?(0,Q.jsxs)(`div`,{"data-slot":`tag-filters`,className:`flex flex-wrap items-center gap-1.5`,children:[(0,Q.jsx)(`span`,{className:`text-xs font-medium text-soft-foreground`,children:`Tags`}),f.map(n=>(0,Q.jsx)(Nj,{slot:`tag-filter`,tone:`tag`,label:n,count:m.tags.get(n)??0,selected:e.tags.some(e=>e.toLowerCase()===n.toLowerCase()),onToggle:()=>t(`tags`,n)},n)),(0,Q.jsx)(Nj,{slot:`tag-filter`,label:`Untagged`,count:m.tags.get(` untagged`)??0,selected:e.tags.includes(Rj),onToggle:()=>t(`tags`,Rj)})]}):(0,Q.jsxs)(`p`,{"data-slot":`no-tags-hint`,className:`text-xs text-soft-foreground`,children:[`Tag connected repositories in`,` `,(0,Q.jsx)(G,{to:`/settings/global/projects`,className:`font-medium text-accent-text hover:underline`,children:Qs(`projects`)}),` `,`to group their tasks together here.`]})]})}var hM=new Set([`done`,`failed`,`cancelled`]);async function gM(e,t){if(e.length===0)return{succeeded:[],failures:[]};let n=await Promise.allSettled(e.map(e=>t(e))),r=[],i=[];return n.forEach((t,n)=>{let a=e[n];if(t.status===`fulfilled`)r.push(a);else{let e=t.reason instanceof Error?t.reason.message:String(t.reason);i.push({hostId:a.hostId,hostLabel:a.hostLabel,message:e})}}),{succeeded:r,failures:i}}function _M(e,t){let n=new Map;for(let e of t.failures)n.has(e.hostLabel)||n.set(e.hostLabel,e.message);return`${e} failed on ${[...n.entries()].map(([e,t])=>`${e} (${t})`).join(`, `)}.${t.succeeded.length>0?` Other hosts were updated.`:``}`}function vM(e,t,n){let r=n.hosts&&n.hosts.length>0?new Set(n.hosts):void 0,i=n.projects&&n.projects.length>0?new Set(n.projects):void 0,a=n.tags.length>0?new Set(n.tags.map(e=>e.toLowerCase())):void 0;return e.filter(e=>!(!ir(e.run,t)||r&&!r.has(Ij(e))||i&&!i.has(Lj(e.run.projectId,e.hostId))||a&&!$j(e).some(e=>a.has(e.toLowerCase()))))}function yM(e){let t=new Map;for(let n of e){let e=`${n.hostId??``}\u0000${n.run.projectId}`;t.has(e)||t.set(e,{...n.hostId===void 0?{}:{hostId:n.hostId},hostLabel:n.hostLabel??`This server`,projectId:n.run.projectId})}return[...t.values()]}var bM=e=>e.hostId===void 0||e.hostState===`connected`&&!e.hostStale;function xM({tasks:e,origin:t,filters:n}){let r=U(),[i,a]=Z.useState(null),o=Z.useMemo(()=>vM(e,t,n),[e,t,n]),s=Z.useMemo(()=>o.filter(bM),[o]),c=Z.useMemo(()=>{let e=new Set;for(let t of o)bM(t)||(mn(t.run)||!t.run.archived&&hM.has(t.run.status))&&e.add(t.hostLabel??t.hostId??`Remote host`);return[...e]},[o]),l=Z.useMemo(()=>s.map(e=>e.run),[s]),u=Z.useMemo(()=>Yo(l),[l]),d=Z.useMemo(()=>kr(l),[l]),f=Z.useCallback((e,t,n)=>{t.some(e=>e.hostId===void 0)&&(r.invalidateQueries({queryKey:V.runsIndex}),r.invalidateQueries({queryKey:ge.runs.all}));let i=[...new Set(t.map(e=>e.hostId).filter(e=>e!==void 0))];i.length>0&&pe(r).reconcileHosts(i),n.failures.length>0?a(_M(e,n)):a(null)},[r]),p=je({mutationFn:({targets:e,origin:t})=>gM(e,({projectId:e,hostId:n})=>ct(ar(t),v({projectId:e,hostId:n}))),onSuccess:(e,{targets:t})=>f(`Mark all read`,t,e),onError:e=>{a(nt(e))}}),m=je({mutationFn:({targets:e,origin:t})=>gM(e,({projectId:e,hostId:n})=>ln(v({projectId:e,hostId:n}),void 0,ar(t))),onSuccess:(e,{targets:t})=>f(`Archive finished`,t,e),onError:e=>{a(nt(e))}}),h=Z.useCallback(()=>{if(p.isPending)return;let e=yM(s.filter(e=>mn(e.run)));e.length>0&&p.mutate({targets:e,origin:t})},[s,p,t]),g=Z.useCallback(()=>{if(m.isPending)return;let e=yM(s.filter(e=>!e.run.archived&&hM.has(e.run.status)));e.length>0&&m.mutate({targets:e,origin:t})},[s,m,t]);return{unread:u,finished:d,archivePending:m.isPending,markReadPending:p.isPending,onMarkAllRead:h,onArchiveFinished:g,excludedBulkHosts:c,bulkError:i,dismissBulkError:Z.useCallback(()=>a(null),[])}}function SM(e,t,n){if(e.length===0)return[];let r=new Map((t??[]).map(e=>[e.id,e])),i=[];for(let t of e){let e=r.get(t.id),a=e?.state??t.state,o=e?.loaded??!1,s=e?.stale??a!==`connected`;o?s&&i.push({id:t.id,label:e?.label??t.label,state:a,kind:`stale`}):i.push({id:t.id,label:e?.label??t.label,state:a,kind:a===`connected`||n&&a===`connecting`?`loading`:`offline`})}return i}function CM(e,t){let n=[];for(let r of e??[])if(r.truncated.length!==0)for(let e of oM(r.truncated,t.get(r.id)??[]))n.push(`${e} (${r.label})`);return n}function wM(e,t,n){if(e)return{statusError:void 0,retryStatus:void 0};let r=t.data?.warning;return{statusError:t.error?.message??r??n.error?.message,retryStatus:t.isError||r?()=>{t.refetch()}:n.isError?()=>{n.refetch()}:void 0}}function TM(e,t,n,r){let i=e.hosts;if(!i||i.length===0)return e;if(t)return{...e,hosts:[]};if(!n)return e;if(r.length===0)return{...e,hosts:[]};let a=new Set([Fj,...r.map(e=>e.id)]),o=i.filter(e=>a.has(e));return o.length===i.length?e:{...e,hosts:o}}function EM(e,t,n,r,i,a,o){if(e.length===0)return[];let s=t.length===0?e:e.filter(e=>!ne(t,e.hostId,e.projectId,e.id));return s.length===0?[]:rM(Zj([],[],{runs:s,hosts:n,projectsByHost:i}),{...a,query:``},o).map(e=>{let t=e.run;return{run:t,hostLabel:r.get(t.hostId)??e.hostLabel??t.hostId,projectName:e.projectName}})}function DM(e,t,n=`active`){let r=U(),{mainHostsProjects:i,savedHosts:a,hasHosts:o,hostLabels:s,projectsByHost:c}=Jr(e),l=e||i.isSuccess,u=Z.useMemo(()=>TM(t,e,l,a),[t,e,l,a]),d=u.hosts??[],f=qr(o),p=d.length>0&&!d.some(e=>e!==Fj),m=u.query.trim(),h=!e&&o&&!p&&m.length>=2,g=Zr(m,h),_=h&&!g.isPlaceholderData?g.data:void 0,v=f.data?.hosts;Z.useEffect(()=>{if(v)for(let e of v)Se(e.referenceStatuses,e.id)},[v]);let y=Z.useMemo(()=>{if(!(!o||!f.data))return{runs:f.data.runs,hosts:f.data.hosts,projectsByHost:c}},[o,f.data,c]),b=f.data!==void 0||f.isError,x=Z.useMemo(()=>{if(!_||_.runs.length===0||!b)return[];let e=r.getQueryData(Xr.hostsRunsIndex)?.runs??[];return Tp(_.runs,e)},[_,b,r]),S=Z.useMemo(()=>x.length===0?[]:EM(x,f.data?.runs??[],f.data?.hosts??[],s,c,u,n),[x,f.data?.runs,f.data?.hosts,s,c,u,n]),C=Z.useMemo(()=>SM(a,f.data?.hosts,f.isPending),[a,f.data?.hosts,f.isPending]),w=Z.useMemo(()=>a.flatMap(e=>e.projects??[]),[a]),T=Z.useMemo(()=>CM(f.data?.hosts,c),[f.data?.hosts,c]),E=Z.useMemo(()=>_?wp(_.truncated,s,c):[],[_,s,c]),D=Z.useMemo(()=>{let e=_?.unanswered??[];if(d.length===0)return e;let t=new Set(d);return e.filter(e=>t.has(e.hostId))},[_,d]),O=Z.useMemo(()=>a.map(e=>({id:e.id,label:e.label})),[a]),{statusError:k,retryStatus:A}=wM(e,i,f);return{filters:u,hasHosts:o,hostsResolved:l,savedHosts:a,hostsIndex:f,remoteInput:y,extraSearchHits:S,hostStatusEntries:C,remoteProjectsFlat:w,remoteTruncated:T,searchTruncated:E,hostFilterOptions:O,statusError:k,retryStatus:A,searchUnanswered:D,searchError:h&&g.isError&&!g.isPlaceholderData,searchWarning:_?.warning}}var OM=15e3,kM=250;function AM(){return NM({request:({hostId:e,projectId:t,runId:n,archived:r})=>gn(E(n,{projectId:t,hostId:e}),r),patch:({archived:e})=>t=>({...t,archived:e})})}function jM(){return NM({request:({hostId:e,projectId:t,runId:n,read:r})=>Lt(E(n,{projectId:t,hostId:e}),r),patch:({read:e})=>t=>{if(e)return{...t,seenAt:new Date().toISOString()};let{seenAt:n,...r}=t;return r}})}function MM(){return NM({request:({hostId:e,projectId:t,runId:n,pinned:r})=>Mt(E(n,{projectId:t,hostId:e}),r),patch:({pinned:e})=>t=>({...t,pinned:e})})}function NM({request:e,patch:t}){let n=se();return je({mutationFn:e,onMutate:e=>n.patchIndex(E(e.runId,{projectId:e.projectId,hostId:e.hostId}),()=>t(e)),onError:(e,t,n)=>{n?.rollback(),H(nt(e),{tone:`danger`})},onSettled:(e,t,{hostId:r,projectId:i,runId:a},o)=>{o?o.settle():n.invalidateAfter(`indexed`,E(a,{projectId:i,hostId:r}))}})}function PM({projectCount:e,hostCount:t,projectsPending:n,newTaskProject:r,status:i,secondaryActions:a}){return{title:`All tasks`,status:(0,Q.jsx)(Qk,{scope:e>0||t>0?(0,Q.jsxs)(`span`,{className:`tabular-nums`,children:[e,` `,e===1?`project`:`projects`,t>0?` · ${t} ${t===1?`host`:`hosts`}`:``]}):null,scopePending:n,children:i}),secondaryActions:a,...r===null?{}:{primaryAction:(0,Q.jsx)(cs,{asChild:!0,variant:`primary`,"data-slot":`new-task-inline`,children:(0,Q.jsxs)(G,{to:wo(r??`default`,`/new`),children:[(0,Q.jsx)(vi,{"aria-hidden":`true`}),`New task`]})})}}}function FM({visible:e,total:t,filtered:n,truncated:r}){return(0,Q.jsxs)(`span`,{"data-slot":`global-tasks-count`,className:q(`self-center text-xs text-soft-foreground tabular-nums`,!n&&!r&&`sr-only`),children:[e,` of `,t,r?` loaded`:``]})}function IM(e){if(e!==void 0)return e.bootProject===null?e.projects.find(e=>e.status!==`missing`)?.id??e.projects[0]?.id??null:e.bootProject}function LM(e,t,n,r){if(!(!e||t<=0||n))return(0,Q.jsx)(ps,{summary:`Showing ${t} ${t===1?`task`:`tasks`} across registered projects.`,actions:r===null?void 0:(0,Q.jsx)(Y,{variant:`outline`,size:`sm`,asChild:!0,children:(0,Q.jsx)(G,{to:wo(r??`default`,`/new`),children:`Start a task`})})})}function RM(){let{mutate:e,isPending:t}=AM(),{mutate:n,isPending:r}=jM(),{mutate:i,isPending:a}=MM();return{onArchive:Z.useCallback((t,n)=>{t.projectId&&e({hostId:t.hostId,projectId:t.projectId,runId:t.runId,archived:n})},[e]),onSetRead:Z.useCallback((e,t)=>{e.projectId&&n({hostId:e.hostId,projectId:e.projectId,runId:e.runId,read:t})},[n]),onTogglePin:Z.useCallback((e,t)=>{e.projectId&&i({hostId:e.hostId,projectId:e.projectId,runId:e.runId,pinned:t})},[i]),busy:t||r||a}}function zM(){let e=fs(),t=Pe(),n=A(),r=L(),i=$A(c().data),o=a(!0,OM),s=tj(),l=Z.useMemo(()=>iO(),[]),[u,d]=rc(),f=_m(),{filters:p,groupBy:m,view:h}=Z.useMemo(()=>lM(u,f),[u,f]),g=DM(t,p,h),_=g.filters,v=is(3e4),y=e=>d(t=>{let n=cM(e(lM(t,!0))),r=t.get(`tasks`);return(r===`flat`||r===`virtual`)&&n.set(`tasks`,r),n}),b=e=>y(t=>({...t,filters:e(t.filters)})),x=e=>y(t=>({...t,groupBy:e})),S=e=>y(t=>({...t,view:e})),C=uM(_),[w,T]=Z.useState(C>0),[E,D]=HM(_.query,e=>b(t=>({...t,query:e}))),O=o.data?.referenceStatuses;Z.useEffect(()=>{O&&Se(O)},[O]);let k=Z.useMemo(()=>n.data?.projects??[],[n.data]),j=Z.useMemo(()=>g.remoteProjectsFlat.length===0?k:[...k,...g.remoteProjectsFlat],[k,g.remoteProjectsFlat]),M=Z.useMemo(()=>{if(g.savedHosts.length===0)return k.length;let e=new Set(k.map(e=>`\u0000${e.id}`));for(let t of g.savedHosts)for(let n of t.projects??[])e.add(`${t.id}\u0000${n.id}`);for(let t of g.remoteInput?.runs??[])e.add(`${t.hostId}\u0000${t.projectId}`);return e.size},[k,g.savedHosts,g.remoteInput]),N=Z.useMemo(()=>o.data?.runs??[],[o.data]),ee=Z.useMemo(()=>g.remoteInput?[...N,...g.remoteInput.runs]:N,[N,g.remoteInput]),P=Z.useMemo(()=>Zj(N,k,g.remoteInput),[N,k,g.remoteInput]),{nameOf:F,visible:I,originTotals:R,statusGroups:te,folds:ne}=UM({tasks:P,filters:_,view:h,groupBy:m,index:ee,automationsOn:f}),re=Z.useMemo(()=>aM(I,m),[I,m]),z=Z.useMemo(()=>m===`none`?te.some(e=>!ne.isCollapsed(e.label)&&e.rows.some(e=>$n(e).some(e=>nr(e.run,e.project?.repoUrl).length>0))):re.some(e=>e.tasks.some(e=>nr(e.run,e.project?.repoUrl).length>0)),[m,te,re,ne]),ie=_.origin??`all`,ae=Z.useMemo(()=>{let e=P.map(e=>e.run);return{active:ur(e,`active`)[ie],archived:ur(e,`archived`)[ie]}},[P,ie]),oe=e=>b(t=>Hj(t,e)),B=xM({tasks:P,origin:ie,filters:_}),se=RM(),ce=Z.useMemo(()=>{let e=new Set,t=[];for(let n of I){if(n.hostStale)continue;let r=wr(n.run,n.project?.repoUrl);for(let i of r){let r=`${n.hostId??``}\u0000${n.run.projectId}\u0000${i.kind}\u0000${i.number}`;e.has(r)||(e.add(r),t.push({...n.hostId===void 0?{}:{hostId:n.hostId},projectId:n.run.projectId,kind:i.kind,number:i.number}))}}return t},[I]),le=Z.useMemo(()=>[...oM(o.data?.truncated??[],k),...g.remoteTruncated],[o.data?.truncated,k,g.remoteTruncated]),ue=(e,t)=>b(n=>({...n,[e]:Uj(n[e]??[],t)})),de=e=>b(t=>({...t,[e]:[]})),fe=o.error??n.error;if(fe)return(0,Q.jsx)(jj,{groupBy:m,filterDetailsOpen:w,message:fe.message,onRetry:()=>{o.refetch(),n.refetch()}});let pe=o.data===void 0?`full`:us(I.length),me=(0,Q.jsxs)(Y,{variant:`outline`,"data-slot":`filters-toggle`,"data-active":w||C>0,className:q(`max-md:px-2.5`,(w||C>0)&&`border-accent-strong bg-accent-strong/10 text-accent-text hover:bg-accent-strong/15 hover:text-accent-text`),"aria-expanded":w,"aria-controls":`global-tasks-filters`,onClick:()=>T(e=>!e),children:[(0,Q.jsx)(Li,{"aria-hidden":`true`}),(0,Q.jsx)(`span`,{className:`max-md:sr-only`,children:`Filters`}),C>0?(0,Q.jsx)(Am,{variant:`accent`,"data-slot":`filters-count`,"aria-hidden":`true`,value:C}):null]}),he={view:h,unread:B.unread,finished:B.finished,archivePending:B.archivePending,markReadPending:B.markReadPending,onMarkAllRead:B.onMarkAllRead,onArchiveFinished:B.onArchiveFinished},ge=IM(n.data),_e=g.hostStatusEntries.filter(e=>e.kind!==`stale`);return(0,Q.jsx)(ls,{route:`global-tasks`,density:pe,headerSpacing:`compact`,rootProps:{"data-presentation":m===`none`?`summary`:`cards`,"data-filter-details":String(w)},bodyClassName:`gap-3`,header:PM({projectCount:M,hostCount:g.savedHosts.length,projectsPending:Zk(n),newTaskProject:ge,status:(0,Q.jsx)(Vk,{view:h,onSelect:S,activeCount:ae.active,archivedCount:ae.archived,trailing:(0,Q.jsx)(FM,{visible:I.length,total:P.length,filtered:Gj(_),truncated:le.length>0})}),secondaryActions:(0,Q.jsx)(Kk,{surface:`desktop`,...he})}),sparseFooter:LM(o.data!==void 0,I.length,Gj(_),ge),children:(0,Q.jsxs)(Ek,{layout:`${m}:${e}`,revision:re,visibilityRevision:JSON.stringify([Uo.map(ne.isCollapsed),h,s.expandedColumns]),className:`flex min-w-0 flex-1 flex-col gap-3`,children:[(0,Q.jsx)(Yk,{query:E,onQueryChange:D,searchPlaceholder:`Search every project…`,searchLabel:`Search tasks across projects`,origin:ie,originCounts:R,automations:f,onOriginChange:oe,columns:l,showReferences:z,expandedColumns:s.expandedColumns,columnsPending:s.isPending,onToggleColumn:s.toggleColumn,groupLabels:te.map(e=>e.label),allGroupsCollapsed:sA(te.map(e=>e.label),ne.isCollapsed),onSetAllFolds:ne.setAll,extraControls:me,mobileOriginOpen:w||ie!==`all`,mobileActions:(0,Q.jsx)(Kk,{surface:`mobile`,...he})}),(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-3`,children:[(0,Q.jsx)(mM,{filters:_,onToggle:ue,onClearFacet:de,onClearAll:()=>{D(``),y(e=>({...e,filters:Vj,groupBy:`none`}))},groupBy:m,onGroupByChange:x,projects:j,hosts:g.hostFilterOptions,tasks:P,visible:I,view:h,automationName:F}),(0,Q.jsx)(Dj,{message:B.bulkError,onDismiss:B.dismissBulkError}),(0,Q.jsx)(Tj,{entries:g.hostStatusEntries,excludedBulkHosts:B.excludedBulkHosts,searchUnanswered:g.searchUnanswered,searchTruncated:g.searchTruncated,searchError:g.searchError,searchWarning:g.searchWarning,error:g.statusError,onRetry:g.retryStatus}),(0,Q.jsx)(Oj,{projects:le,perProjectLimit:o.data?.perProjectLimit}),o.data===void 0?(0,Q.jsx)(`div`,{role:`status`,className:`rounded-xl border border-border bg-card p-6 text-sm text-muted-foreground`,children:`Loading tasks…`}):(0,Q.jsxs)(Q.Fragment,{children:[I.length===0&&g.extraSearchHits.length>0?null:(0,Q.jsx)(BM,{view:h,filtered:Gj(_),visibleCount:I.length,unloadedHosts:_e,referenceRequests:ce,lists:{desktop:e,groupBy:m,view:h,statusGroups:te,groups:re,folds:ne,showReferences:z,expandedColumns:s.expandedColumns,now:v,runners:r.data,showTokens:i.tokens,showCost:i.cost,automationName:F,onTogglePin:h===`archived`?void 0:se.onTogglePin,onArchive:se.onArchive,onSetRead:se.onSetRead,busy:se.busy}}),(0,Q.jsx)(Ej,{hits:g.extraSearchHits,now:v})]}),(0,Q.jsx)(kj,{registry:k})]})]})})}function BM({view:e,filtered:t,visibleCount:n,unloadedHosts:r,referenceRequests:i,lists:a}){return n===0?(0,Q.jsx)(Aj,{view:e,filtered:t,unloadedHosts:r}):(0,Q.jsx)(br,{requests:i,children:(0,Q.jsx)(VM,{...a})})}function VM({desktop:e,groupBy:t,view:n,statusGroups:r,groups:i,folds:a,expandedColumns:o,now:s,runners:c,showTokens:l,showCost:u,automationName:d,onTogglePin:f,onArchive:p,onSetRead:m,busy:h,showReferences:g}){let _=r.filter(e=>!a.isCollapsed(e.label)),v=e?`table`:`card`,y=e=>e.map(({task:e,queuePosition:t})=>bk({task:e,queuePosition:t,runners:c,automationName:d,now:s,showTokens:l,showCost:u})),b={density:v,now:s,showReferences:g,expandedColumns:o,showTokens:l,showCost:u,scopedLinks:!1,liveUsageSource:`snapshot`,onTogglePin:f,onArchive:p,onSetRead:m,busy:h,tableSlot:`global-tasks-table`,rowSlot:`global-task-row`,cardSlot:`global-task-row`};return(0,Q.jsx)(Q.Fragment,{children:t===`none`?r.map(e=>{let t=a.isCollapsed(e.label);return(0,Q.jsx)(Fk,{id:`global-group-${n}-${e.label.replaceAll(` `,`-`)}`,label:e.label,count:e.rows.length,tone:Lk(e.label,e.label===`Finished`?e.rows.map(e=>e.run.run):[]),folded:a.isFolded(e.label),collapsed:t,onToggle:()=>a.toggle(e.label),children:t?null:(0,Q.jsx)(KA,{...b,items:e.rows.map(e=>bk({task:e.run,queuePosition:e.run.run.status===`queued`?e.queuePosition:null,runners:c,automationName:d,now:s,showTokens:l,showCost:u})),showHeader:e===_[0],showProject:!0})},e.label)}):i.map((e,r)=>{let i=n===`archived`?e.tasks:[...e.tasks].sort((e,t)=>Number(!!t.run.pinned)-Number(!!e.run.pinned));return(0,Q.jsxs)(`section`,{"data-slot":`task-group`,"data-group-key":e.key,children:[(0,Q.jsxs)(`h2`,{className:`mb-1.5 flex items-center gap-2 text-[12px] font-semibold tracking-[0.04em] text-soft-foreground uppercase`,children:[t===`project`?e.hostId===void 0?(0,Q.jsx)(G,{to:wo(e.projectId??e.key,`/`),"data-slot":`group-project-link`,className:`hover:text-foreground hover:underline`,children:e.label}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`a`,{href:Ne(e.hostId,e.projectId??e.key),"data-slot":`group-project-link`,className:`hover:text-foreground hover:underline`,children:e.label}),(0,Q.jsx)(Dd,{label:e.hostLabel??e.hostId,hostId:e.hostId,className:`normal-case tracking-normal`})]}):e.label,(0,Q.jsx)(Am,{value:i.length,className:`font-mono text-xs font-medium`})]}),(0,Q.jsx)(KA,{...b,items:y(i.map(e=>({task:e,queuePosition:null}))),showHeader:r===0,showProject:t!==`project`})]},e.key)})})}function HM(e,t){let[n,r]=Z.useState(e),i=Z.useRef(e);return Z.useEffect(()=>{e!==i.current&&r(e),i.current=e},[e]),Z.useEffect(()=>{if(n===i.current)return;let e=setTimeout(()=>{i.current=n,t(n)},kM);return()=>clearTimeout(e)},[n]),[n,r]}function UM({tasks:e,filters:t,view:n,groupBy:r,index:i,automationsOn:a}){let o=Z.useMemo(()=>{let t=new Map;for(let n of e){if(n.run.automationId===void 0||n.hostStale)continue;let e=`${n.hostId??``}\u0000${n.run.projectId}`;t.has(e)||t.set(e,{projectId:n.run.projectId,...n.hostId===void 0?{}:{hostId:n.hostId}})}return[...t.values()]},[e]),c=s(o,a&&o.length>0),l=Z.useCallback(e=>e.run.automationId===void 0?void 0:c(e.run.projectId,e.run.automationId,e.hostId),[c]),u=Z.useMemo(()=>rM(e,t,n,l),[e,t,n,l]),d=Z.useMemo(()=>ur((t.origin===void 0||t.origin===`all`?u:iM(e,t,n,`origin`,l)).map(e=>e.run),n),[e,u,t,n,l]),f=Z.useMemo(()=>r===`none`?or(u,n,i):[],[r,u,n,i]);return{nameOf:l,visible:u,originTotals:d,statusGroups:f,folds:ZA(`global`,n,Z.useMemo(()=>new Set(t.query.trim()===``?[]:f.map(e=>e.label)),[t.query,f]))}}var WM=(0,Z.lazy)(()=>W(()=>import(`./automations-route-DpEqMGRx.js`).then(e=>({default:e.AutomationsRoute})),__vite__mapDeps([124,1,2,6,7,8,9,10,11,12,13,14,125,126,127,128,24,15,78,16,20,105,30,31,32,33,34,55,46,64,65,56,27,28,57,129,130]))),GM=(0,Z.lazy)(()=>W(()=>import(`./workspace-tools-BwMECWWr.js`).then(e=>({default:e.WorkspaceToolsRoute})),__vite__mapDeps([131,1,2,6,7,8,9,10,11,12,13,14,18,16,41,20,25,26,64,65,27]))),KM=(0,Z.lazy)(()=>W(()=>import(`./settings-shell-B_o8TQYi.js`).then(e=>({default:e.SettingsIndexRoute})),__vite__mapDeps([132,1,2,6,7,8,9,10,11,12,13,14,15,71,16,20,105,24,55,32,34,21,46,101,64,65,57,37,47,39,40,26,41,19,42,43,44,31,33,45,53,58,75,29,30,61,62,28,38,63,133]))),qM=(0,Z.lazy)(()=>W(()=>import(`./settings-shell-B_o8TQYi.js`).then(e=>({default:e.SettingsSectionRoute})),__vite__mapDeps([132,1,2,6,7,8,9,10,11,12,13,14,15,71,16,20,105,24,55,32,34,21,46,101,64,65,57,37,47,39,40,26,41,19,42,43,44,31,33,45,53,58,75,29,30,61,62,28,38,63,133]))),JM=(0,Z.lazy)(()=>W(()=>import(`./task-thread-BgxYbzJU.js`).then(e=>({default:e.TaskThreadRoute})),__vite__mapDeps([134,1,2,6,7,8,9,10,11,12,13,14,109,15,62,24,33,34,100,101,16,135,78,18,42,82,110,84,43,20,105,46,136,23,137,92,120,57,93,94,95,51,45,111,138,108,87,40,26,41,19,44,31,81,22,25,88,56,112,113,98,139,85,140,64,65,28,104,106,21,99,129,86,83,141]))),YM=(0,Z.lazy)(()=>W(()=>import(`./task-changes-BZ7Hlj9q.js`).then(e=>({default:e.TaskChangesRoute})),__vite__mapDeps([107,1,2,6,7,8,9,10,11,12,13,14,15,108,109,62,24,33,34,100,101,16,87,40,26,41,19,42,43,20,44,31,45,81,110,22,23,46,25,88,56,57,93,94,95,51,111,112,113,114,91,115,116,64,65,28,117,106,21,102,118,119,120,121,122,123]))),XM=(0,Z.lazy)(()=>W(()=>import(`./task-files--54CdvAw.js`).then(e=>({default:e.TaskFilesRoute})),__vite__mapDeps([142,1,2,6,7,8,9,10,11,12,13,14,15,16,108,109,62,24,33,34,100,101,87,40,26,41,19,42,43,20,44,31,45,81,110,22,23,46,25,88,56,57,93,94,95,51,111,112,113,90,91,28,92,96,64,65,137,121,116,123]))),ZM=(0,Z.lazy)(async()=>{let{TaskReportRoute:e}=await W(async()=>{let{TaskReportRoute:e}=await import(`./report-reader-DHB5teJQ.js`);return{TaskReportRoute:e}},__vite__mapDeps([89,1,2,6,7,8,9,10,11,12,13,14,15,90,16,91,20,44,24,31,33,34,28,92,51,45,93,94,95,96]));return{default:e}}),QM=(0,Z.lazy)(()=>W(()=>import(`./task-commits-Jf35_1k0.js`).then(e=>({default:e.TaskCommitsRoute})),__vite__mapDeps([143,2,1,6,7,8,9,10,11,12,13,14,15,108,109,62,24,33,34,100,101,16,87,40,26,41,19,42,43,20,44,31,45,81,110,22,23,46,25,88,56,57,93,94,95,51,111,112,113,64,65,28,144,121,122,145,91,139,118,115,119,120,123]))),$M=(0,Z.lazy)(()=>W(()=>import(`./task-github-item-QzP9IPGg.js`).then(e=>({default:e.TaskGithubItemRoute})),__vite__mapDeps([146,2,1,6,7,8,9,10,11,12,13,14,109,15,62,24,33,34,100,101,108,16,87,40,26,41,19,42,43,20,44,31,45,81,110,22,23,46,25,88,56,57,93,94,95,51,111,112,113,139,64,65,28,147,98,82,83,67,68,118,115,119,120,144,29,30,32,148]))),eN=(0,Z.lazy)(()=>W(()=>import(`./repo-git-DA66978k.js`).then(e=>({default:e.RepoGitRoute})),__vite__mapDeps([149,1,2,6,7,8,9,10,11,12,13,14,109,15,62,24,33,34,100,101,16,80,150,114,41,91,20,44,31,43,115,116,81,82,22,23,46,25,26,64,65,88,151,28,117,118,119,120,144,121,122,145,139,152]))),tN=(0,Z.lazy)(()=>W(()=>import(`./github-b6pU4RVM.js`).then(e=>({default:e.GithubRoute})),__vite__mapDeps([153,1,2,6,7,8,9,10,11,12,13,14,109,15,62,24,33,34,100,101,79,16,18,82,83,20,30,31,32,46,25,26,64,65,67,23,22,28,137,93,94,95,51,45,147,41,98,110,68,56,57,118,115,119,120,144,29,112,148]))),nN=(0,Z.lazy)(()=>W(()=>import(`./reports-Oxg0v5bR.js`).then(e=>({default:e.ReportsRoute})),__vite__mapDeps([154,1,2,6,7,8,9,10,11,12,13,14,15,155,16,18,98,20,46,64,65,137,138,96,92,156]))),rN=(0,Z.lazy)(()=>W(()=>import(`./workflows-CeUWNdYH.js`).then(e=>({default:e.WorkflowsRoute})),__vite__mapDeps([157,1,2,6,7,8,9,10,11,12,13,14,15,20,44,24,31,33,34,22,23,64,65,68,28,57,4,29,30,32,52,158]))),iN=(0,Z.lazy)(()=>W(()=>import(`./activity-route-D6OhCzkJ.js`).then(e=>({default:e.ProjectActivityRoute})),__vite__mapDeps([159,1,2,7,160,6,8,9,10,11,12,13,14,128,15,16,135,78,18,42,82,110,84,43,20,105,24,46,136,23,137,92,120,57,93,94,95,51,45,111,138,77,155,26,41,81,62,33,34,101,25,64,65,99,100,56,103,97,98,102,28,104,106,21,161]))),aN=(0,Z.lazy)(()=>W(()=>import(`./global-activity-route-sTvejVUG.js`).then(e=>({default:e.GlobalActivityRoute})),__vite__mapDeps([162,1,2,6,7,8,9,10,11,12,13,14,160,128,15,16,135,78,18,42,82,110,84,43,20,105,24,46,136,23,137,92,120,57,93,94,95,51,45,111,138,77,155,26,41,81,62,33,34,101,25,64,65,99,100,56,103,97,98,102,28,104,106,21,161,3]))),oN=(0,Z.lazy)(()=>W(()=>import(`./skills-C-PLlLf0.js`).then(e=>({default:e.SkillsRoute})),__vite__mapDeps([163,1,2,6,7,8,9,10,11,12,13,14,15,20,46,64,65,68,56,29,30,24,31,32,33,34])));function sN(){let e=qn();return(0,Q.jsx)(ko,{to:{pathname:`/skills`,search:e.search,hash:e.hash},replace:!0})}function cN({sectionId:e}){let t=qn();return(0,Q.jsx)(Wn,{to:{pathname:mb(`global`,e),search:t.search,hash:t.hash},replace:!0})}function lN(){return(0,Q.jsx)(`div`,{"data-route":`scope-resolving`,className:`flex min-h-full flex-col`,children:(0,Q.jsx)(`p`,{className:`px-4 py-6 text-center text-xs text-soft-foreground`,children:`Loading…`})})}function uN(e,t,n){let r=e.data===void 0?e.isError?t.data?.bootProject:void 0:e.data.bootProject;if(typeof r==`string`){let e=n.pathname.replace(/^\/p\/default(?=\/|$)/,``);return(0,Q.jsx)(Wn,{to:`/p/${encodeURIComponent(r)}${e||`/`}${n.search}${n.hash}`,replace:!0})}return r===null?e.data&&e.data.projects.length>0?(0,Q.jsx)(TE,{projectId:`default`,registry:e.data}):(0,Q.jsx)(bE,{}):e.isError?void 0:(0,Q.jsx)(lN,{})}function dN(){let{projectId:e=``}=Hn(),t=qn(),n=A(),r=c();if(e==="default"){let e=uN(n,r,t);if(e!==void 0)return e}if(n.data){if(!(n.data.bootProject!==null&&n.data.bootProject===e||n.data.projects.some(t=>t.id===e)))return(0,Q.jsx)(TE,{projectId:e,registry:n.data})}else if(!n.isError)return(0,Q.jsx)(lN,{});return(0,Q.jsx)(sn,{projectId:n.data?.bootProject!==null&&n.data?.bootProject===e?null:e,children:(0,Q.jsx)(Bn,{},e)})}function fN(){let{projectId:e=``}=Hn();return(0,Q.jsx)(rE,{},e)}var pN=/^\/tasks\/([0-9a-f-]{36})(?=\/|$)/i;function mN(e,t){let n=e.data===void 0?t.data===void 0?void 0:t.data.bootProject:e.data.bootProject;return{resolved:n,settled:(e.data!==void 0||e.isError)&&(t.data!==void 0||t.isError),boot:n===void 0?`default`:n}}function hN(e){let t=e.data?.projects??[];return t.find(e=>e.status!==`missing`)?.id??t[0]?.id??null}function gN(e,t,n){if(!(e.pathname===`/`&&e.search===``&&e.hash===``))return;if(t.data===void 0&&!t.isError)return(0,Q.jsx)(lN,{});let r=zp(kp(),t.data,n??void 0,{preserveRemovedProject:Pe()});if(r!==null)return(0,Q.jsx)(Wn,{to:r,replace:!0})}function _N(e,t,n,r,i,a){if(!n)return{state:`pending`};let o=i.data?.runs.find(t=>t.id===e)?.projectId;return o===void 0?r?a.data===void 0&&!a.isError?{state:`pending`}:{state:`resolved`,projectId:a.data?.runs.find(t=>t.id===e)?.projectId??t}:{state:`resolved`,projectId:t}:{state:`resolved`,projectId:o}}function vN(e,t){let n=t.pathname===`/p`||t.pathname===`/p/`?`/`:t.pathname;return(0,Q.jsx)(Wn,{to:`/p/${encodeURIComponent(e)}${n}${t.search}${t.hash}`,replace:!0})}function yN(){let e=qn(),t=c(),n=A(),r=pN.exec(e.pathname)?.[1]??null,i=a(r!==null),o=i.data!==void 0||i.isError,s=i.data!==void 0&&!i.data.runs.some(e=>e.id===r),l=z(r!==null&&s?r:``),{resolved:u,settled:d,boot:f}=mN(t,n);if(u===void 0&&!d)return(0,Q.jsx)(lN,{});let p=gN(e,n,u);if(p!==void 0)return p;if(f===null&&n.data===void 0&&!n.isError)return(0,Q.jsx)(lN,{});let m=f??hN(n),h=m;if(r!==null){let e=_N(r,m,o,s,i,l);if(e.state===`pending`)return(0,Q.jsx)(lN,{});h=e.projectId}return h===null?(0,Q.jsx)(bE,{}):vN(h,e)}function bN(){return(0,Q.jsxs)(K,{path:`/p/:projectId`,element:(0,Q.jsx)(dN,{}),children:[(0,Q.jsx)(K,{index:!0,element:(0,Q.jsx)(Cj,{})}),(0,Q.jsx)(K,{path:`new`,element:(0,Q.jsx)(fN,{})}),(0,Q.jsx)(K,{path:`activity`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(sx,{}),children:(0,Q.jsx)(iN,{})})}),(0,Q.jsxs)(K,{path:`tasks/:id`,element:(0,Q.jsx)(HD,{}),children:[(0,Q.jsx)(K,{index:!0,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(jE,{}),children:(0,Q.jsx)(JM,{})})}),(0,Q.jsx)(K,{path:`changes`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(DE,{tab:`changes`}),children:(0,Q.jsx)(YM,{})})}),(0,Q.jsx)(K,{path:`files`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(DE,{tab:`files`}),children:(0,Q.jsx)(XM,{})})}),(0,Q.jsx)(K,{path:`report`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(`div`,{"data-route":`task-report`,children:(0,Q.jsx)(`h1`,{className:`p-4 text-sm text-soft-foreground`,children:`Loading report…`})}),children:(0,Q.jsx)(ZM,{})})}),(0,Q.jsx)(K,{path:`commits`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(DE,{tab:`changes`}),children:(0,Q.jsx)(QM,{})})}),(0,Q.jsx)(K,{path:`commits/:sha`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(DE,{tab:`changes`}),children:(0,Q.jsx)(QM,{})})}),(0,Q.jsx)(K,{path:`issue/:n`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(AE,{kind:`issue`}),children:(0,Q.jsx)($M,{kind:`issue`})})}),(0,Q.jsx)(K,{path:`pr/:n`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(AE,{kind:`pr`}),children:(0,Q.jsx)($M,{kind:`pr`})})})]}),(0,Q.jsx)(K,{path:`git`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(CE,{}),children:(0,Q.jsx)(eN,{section:`main`,index:!0})})}),(0,Q.jsx)(K,{path:`git/commits`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(CE,{}),children:(0,Q.jsx)(eN,{section:`main`})})}),(0,Q.jsx)(K,{path:`git/commits/:sha`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(CE,{}),children:(0,Q.jsx)(eN,{section:`main`})})}),(0,Q.jsx)(K,{path:`git/not-landed`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(CE,{}),children:(0,Q.jsx)(eN,{section:`not-landed`})})}),(0,Q.jsx)(K,{path:`git/cleanup`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(CE,{}),children:(0,Q.jsx)(eN,{section:`cleanup`})})}),(0,Q.jsx)(K,{path:`git/branches`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(CE,{}),children:(0,Q.jsx)(eN,{section:`branches`})})}),(0,Q.jsx)(K,{path:`git/changes`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(CE,{}),children:(0,Q.jsx)(eN,{section:`changes`})})}),(0,Q.jsx)(K,{path:`github`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(cx,{}),children:(0,Q.jsx)(tN,{view:`issues`,index:!0})})}),(0,Q.jsx)(K,{path:`github/prs`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(cx,{}),children:(0,Q.jsx)(tN,{view:`prs`})})}),(0,Q.jsx)(K,{path:`github/issues/:n`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(cx,{}),children:(0,Q.jsx)(tN,{view:`issues`})})}),(0,Q.jsx)(K,{path:`github/prs/:n`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(cx,{}),children:(0,Q.jsx)(tN,{view:`prs`})})}),(0,Q.jsx)(K,{path:`github/prs/:n/changes`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(cx,{}),children:(0,Q.jsx)(tN,{view:`prs`,changes:!0})})}),(0,Q.jsx)(K,{path:`automations`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(`p`,{role:`status`,children:`Loading automations…`}),children:(0,Q.jsx)(WM,{})})}),(0,Q.jsx)(K,{path:`automations/new`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(`p`,{role:`status`,children:`Loading automations…`}),children:(0,Q.jsx)(WM,{mode:`new`})})}),(0,Q.jsx)(K,{path:`automations/:automationId`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(`p`,{role:`status`,children:`Loading automations…`}),children:(0,Q.jsx)(WM,{mode:`edit`})})}),(0,Q.jsx)(K,{path:`automations/:automationId/log`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(`p`,{role:`status`,children:`Loading automations…`}),children:(0,Q.jsx)(WM,{mode:`log`})})}),(0,Q.jsx)(K,{path:`skills`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(wE,{}),children:(0,Q.jsx)(oN,{})})}),(0,Q.jsx)(K,{path:`reports`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(`p`,{role:`status`,children:`Loading reports…`}),children:(0,Q.jsx)(nN,{})})}),(0,Q.jsx)(K,{path:`workflows`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(EE,{}),children:(0,Q.jsx)(rN,{})})}),(0,Q.jsx)(K,{path:`workflows/:name`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(EE,{}),children:(0,Q.jsx)(rN,{})})}),(0,Q.jsx)(K,{path:`settings`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(`p`,{role:`status`,children:`Loading settings…`}),children:(0,Q.jsx)(KM,{})})}),(0,Q.jsx)(K,{path:`settings/skills`,element:(0,Q.jsx)(sN,{})}),pb(`project`).map(e=>(0,Q.jsx)(K,{path:`settings/${e.id}`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(`p`,{role:`status`,children:`Loading settings…`}),children:(0,Q.jsx)(qM,{section:e,scope:`project`})})},e.id)),pb(`global`).map(e=>(0,Q.jsx)(K,{path:`settings/${e.id}`,element:(0,Q.jsx)(cN,{sectionId:e.id})},e.id)),(0,Q.jsx)(K,{path:`*`,element:(0,Q.jsx)(xE,{})})]})}function xN(e){let t=Zn(Vn(bN()),e),n=t?.at(-1);return!t||!n||n.route.path===`*`?null:{pattern:`/${t.slice(1).map(e=>e.route.path).filter(e=>e!==void 0).join(`/`)}`.replace(/\/$/,``)||`/`,params:n.params}}function SN(){return(0,Q.jsxs)(Yn,{children:[bN(),(0,Q.jsx)(K,{path:`/tasks`,element:(0,Q.jsx)(zM,{})}),(0,Q.jsx)(K,{path:`/tools`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(`p`,{role:`status`,children:`Loading workspace tools…`}),children:(0,Q.jsx)(GM,{})})}),(0,Q.jsx)(K,{path:`/activity`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(sx,{}),children:(0,Q.jsx)(aN,{})})}),(0,Q.jsx)(K,{path:`/settings/global`,element:(0,Q.jsx)(Wn,{to:hb,replace:!0})}),(0,Q.jsx)(K,{path:`/settings/global/skills`,element:(0,Q.jsx)(Wn,{to:`/skills`,replace:!0})}),pb(`global`).map(e=>(0,Q.jsx)(K,{path:mb(`global`,e.id),element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(`p`,{role:`status`,children:`Loading settings…`}),children:(0,Q.jsx)(qM,{section:e,scope:`global`})})},e.id)),(0,Q.jsx)(K,{path:`*`,element:(0,Q.jsx)(yN,{})})]})}function CN(){let[e]=(0,Z.useState)(Ac);(0,Z.useEffect)(()=>Lr(e),[e]);let t=Be(),n=Le();return(0,Q.jsx)(Mc,{children:(0,Q.jsx)(rn,{client:e,children:(0,Q.jsx)(cf,{children:(0,Q.jsx)(Yb,{children:(0,Q.jsx)(Qb,{hostId:t,children:(0,Q.jsxs)(Pr,{children:[(0,Q.jsx)(kc,{}),(0,Q.jsx)(ax,{}),(0,Q.jsxs)(Xn,{...n?{basename:n}:{},children:[(0,Q.jsx)($b,{}),(0,Q.jsx)(jc.Provider,{value:xN,children:(0,Q.jsx)(hr,{children:(0,Q.jsx)(Pb,{children:(0,Q.jsx)(SN,{})})})}),(0,Q.jsx)(qt,{})]})]})})})})})})}var wN=document.querySelector(`meta[name="cez-api-base"]`)?.getAttribute(`content`),TN=h(wN,void 0,void 0);Ue({pathname:window.location.pathname,mainApiBase:TN});var EN=document.getElementById(`root`);if(!EN)throw Error(`Squawk: #root container is missing from index.html`);(0,dc.createRoot)(EN).render((0,Q.jsx)(Z.StrictMode,{children:(0,Q.jsx)(CN,{})}));export{PC as $,If as $n,Pv as $t,SE as A,Rm as An,jy as At,Qw as B,Om as Bn,hy as Bt,BE as C,qh as Cn,Vc as Cr,Ly as Ct,DE as D,Nm as Dn,Iy as Dt,OE as E,$m as En,Pc as Er,Fy as Et,Yw as F,zm as Fn,ky as Ft,HC as G,gm as Gn,sy as Gt,Zw as H,Tm as Hn,py as Ht,Jw as I,Ym as In,Ky as It,VC as J,xm as Jn,ny as Jt,WC as K,_m as Kn,Kv as Kt,Hw as L,km as Ln,Oy as Lt,FT as M,Zm as Mn,Hy as Mt,NT as N,Um as Nn,Wy as Nt,EE as O,Pm as On,Ty as Ot,qw as P,Hm as Pn,Gy as Pt,NC as Q,Pf as Qn,ey as Qt,Gw as R,Mm as Rn,by as Rt,zE as S,e_ as Sn,Wc as Sr,Zy as St,AE as T,Fh as Tn,Fc as Tr,Ay as Tt,Lw as U,mm as Un,ly as Ut,Xw as V,Em as Vn,dy as Vt,UC as W,Sm as Wn,cy as Wt,jC as X,Ff as Xn,Jv as Xt,FC as Y,xp as Yn,ry as Yt,TC as Z,Lf as Zn,Yv as Zt,uD as _,d_ as _n,Zc as _r,Xb as _t,YO as a,Rv as an,hd as ar,hx as at,VE as b,u_ as bn,Jc as br,pb as bt,jD as c,Cv as cn,Ku as cr,Sx as ct,gD as d,a_ as dn,xl as dr,wx as dt,Hv as en,jf as er,vC as et,_D as f,p_ as fn,dl as fr,lx as ft,cD as g,n_ as gn,$c as gr,tx as gt,SD as h,r_ as hn,tl as hr,ex as ht,XO as i,zv as in,Td as ir,kx as it,xE as j,qm as jn,Dy as jt,CE as k,Gm as kn,My as kt,AD as l,C_ as ln,Wu as lr,_x as lt,yD as m,c_ as mn,ol as mr,sx as mt,$A as n,Lv as nn,Af as nr,Bx as nt,JO as o,Bv as on,ld as or,bx as ot,pD as p,l_ as pn,cl as pr,cx as pt,RC as q,ym as qn,Gv as qt,fA as r,Vv as rn,lf as rr,Ox as rt,LD as s,xv as sn,Xu as sr,Cx as st,Pj as t,Uv as tn,Nf as tr,_C as tt,hD as u,S_ as un,Hu as ur,xx as ut,dD as v,m_ as vn,Xc as vr,hb as vt,jE as w,Jh as wn,Lc as wr,Ey as wt,ME as x,qg as xn,Kc as xr,Qy as xt,UE as y,i_ as yn,Yc as yr,mb as yt,Uw as z,jm as zn,_y as zt};
|
|
20
|
+
`)[0]??``;return n.length>t?`${n.slice(0,t-1)}…`:n}function uT(e){let{task:t,steps:n,agentProfile:r,model:i,modelsLocked:a,effort:o,runner:s,runnerExplicit:c,defaultRunner:l,images:u,archiveWhenDone:d,autoMergePr:f,allowWorkers:p,allowMessaging:m}=e;return{task:t,steps:[...n],...r?{agentProfile:r}:{},model:a?void 0:i||void 0,effort:a?void 0:o||void 0,runner:Zw(s,l,c),images:u.length>0?[...u]:void 0,...nT({archiveWhenDone:d,autoMergePr:f,allowWorkers:p,allowMessaging:m})}}function dT(e,t,n){return{runner:e,agentProfile:t||null,...e===n?{}:{model:null,effort:null}}}var fT=`Could not save the moved draft in browser storage. Your draft is still kept on the main server.`;function pT(e,t,n){if(n===`append`){let n=e.text.trim()===``?t.text:`${e.text}\n\n${t.text}`;return{...e,text:n}}return{...e,text:t.text,source:null}}function mT(e){ow(e.hostId,e.projectId),sw(e.handoff.rootProjectId,e.handoff.text)}function hT(e){e!==null&&ow(e.hostId,e.projectId)}function gT(e,t,n){let r=Be(),i=r!==null&&t!==void 0?aw(r,t):null;if(!i||r===null||t===void 0)return{base:gw(e),autoTake:null,claimedArrival:null,pendingArrival:null,discardArrival:null};let a={hostId:r,projectId:t,handoff:i};if(n)return{base:gw(e),autoTake:null,claimedArrival:null,pendingArrival:null,discardArrival:a};if(tw(a.hostId,a.projectId))return{base:gw(e),autoTake:null,claimedArrival:a,pendingArrival:null,discardArrival:null};let o=_w(e);return o.text.trim()===``?{base:pT(o,i,`replace`),autoTake:a,claimedArrival:null,pendingArrival:null,discardArrival:null}:{base:o,autoTake:null,claimedArrival:null,pendingArrival:a,discardArrival:null}}function _T(e,t,n){let{base:r,autoTake:i,claimedArrival:a,pendingArrival:o,discardArrival:s}=gT(e,t,n.ref!==``);return{draft:{...r,...n.runner===void 0?{}:dT(n.runner,n.account,r.runner),...n.ref===``?{}:{text:n.ref},...n.skill===``?{}:{source:{source:`skill`,ref:n.skill,...n.skillPath===void 0?{}:{path:n.skillPath}}}},autoTake:i,claimedArrival:a,pendingArrival:o,discardArrival:s}}function vT(e,t,n,r){let[{draft:i,autoTake:a,claimedArrival:o,pendingArrival:s,discardArrival:c}]=(0,Z.useState)(()=>_T(e,r,t)),[l,u]=(0,Z.useState)(i),[d,f]=(0,Z.useState)(s),[p,m]=(0,Z.useState)(null),[h,g]=(0,Z.useState)(!1),_=(0,Z.useRef)(l),v=(0,Z.useRef)(!1),y=(0,Z.useRef)(o),b=(0,Z.useCallback)(()=>m(null),[]);(0,Z.useEffect)(()=>{if(rw(Be(),r),hT(c),a!==null){if(v.current)return;vw(_.current,e),bw(e)?(v.current=!0,y.current=null,mT(a),m(null)):(ew(a.hostId,a.projectId),y.current=a,m(fT));return}s===null&&(vw(_.current,e),y.current&&bw(e)&&(mT(y.current),y.current=null,v.current=!0,m(null)))},[a,c,e,s,r]);let x=(0,Z.useRef)(!1),S=(0,Z.useRef)(!0);(0,Z.useEffect)(()=>(S.current=!0,()=>{S.current=!1}),[]);let C=t=>{if(!S.current||x.current)return;let n={..._.current,...t};_.current=n,vw(n,e),y.current&&bw(e)&&(mT(y.current),y.current=null,v.current=!0,m(null)),u(n)},w=(0,Z.useRef)(t.runner===void 0);(0,Z.useEffect)(()=>{!w.current||n===void 0||(w.current=!1,C(dT(n,t.account,_.current.runner)))},[n]);let T=t=>{if(mw(e)!==t)return;y.current&&(mT(y.current),y.current=null,v.current=!0),xw(e,t);let n=gw(e);_.current=n,S.current&&u(n)},E=(0,Z.useCallback)(t=>{if(!d)return;let n=pT(_w(e),d.handoff,t);if(!yw(n,e)){f(null),m(fT);return}_.current=n,u(n),mT(d),f(null),m(null)},[e,d]),D=(0,Z.useCallback)(()=>{if(!d)return;let e=d.handoff.rootUrlProjectId?Ve(null,d.handoff.rootUrlProjectId):`/new`;ow(d.hostId,d.projectId),f(null),Ew(e)},[d]);return{draft:l,update:C,clearStarted:T,submissionPending:x,submittingDraft:h,onPendingChange:(0,Z.useCallback)(e=>{x.current=e,g(e),e&&m(null)},[]),mounted:S,pendingArrival:d,arrivalError:p,clearArrivalError:b,confirmArrival:E,cancelArrival:D}}function yT(e,t,n,r){let i=ue(),a=re(n,r),o=a.data,s=t.data?.skillUsage,c=(0,Z.useMemo)(()=>Us(o??[],s),[o,s]),l=i.data?.workflows??[],u=i.data!==void 0&&!t.isPending,d=eT(e,c,l,a.unchecked),f=d?.source===`skill`?c.find(e=>e.id===d.ref&&(d.path===void 0||e.path===d.path)):void 0;return{skillList:c,skillUsage:s,workflowList:l,sourcesReady:u,source:d,selectedSkill:f,skillsSettled:!a.isPending,listUnchecked:a.unchecked,unchecked:a.unchecked||d?.source===`skill`&&!f}}function bT(e){let{uiState:t,source:n,sourcesReady:r,draftText:i,submissionPending:a,update:o}=e,s=t.data?.promptTemplates,c=(0,Z.useMemo)(()=>_x(s),[s]),l=bx(c,n?.source===`skill`?[n.ref]:[]),u=(0,Z.useRef)(i);u.current=i;let d=(0,Z.useRef)(``);return(0,Z.useEffect)(()=>{if(!r||a.current)return;let e=xx(u.current,d.current,l);d.current=e.applied,e.text!==u.current&&o({text:e.text})},[l,r]),c}function xT(e,t){let n=ee(),r=L(),i=Js(),{runners:a,uninstalled:o,signedOut:s}=i,c=t.data?.defaultRunner,l=c??`claude`,d=a.length>0?Xw(e.runner,a,l):null,{runner:f,ready:p}=ke(d??l),m=n.isSuccess&&a.length>0,h={isPending:n.isPending||r.isPending,isError:n.isError||r.isError},g=i.accountFor(f,e.agentProfile)??i.repoAccount?.[f],_=ie(c,oe(r.data)),v=_===void 0?null:i.accountFor(_,d===_?e.agentProfile:null),y=u(f,p,g),b=t.data?.modelsLocked===!0,x=t.data?.defaultModels,S=d===null?[]:Gw(d,r.data,y.data,[e.model,x?.[d]]),C=d===null?``:Qw(b?null:e.model,d,r.data,x,y.data),w=Hw(C,y.data);return{providers:h,registered:r,runners:a,uninstalled:o,signedOut:s,defaultRunner:c,planAccount:v,runner:d,displayRunner:f,providersReady:m,catalog:y,modelsLocked:b,models:S,model:C,effortOptions:w,effort:b?``:Uw(e.effort,w)}}function ST(e,t){let n=y(),{accounts:r,repoAccount:i,accountFor:a}=Js();return{accountChoices:r,repoAccount:i,accountsSettled:!n.isPending,agentProfile:a(e,t)}}function CT(e){let t=(0,Z.useRef)(!1),n=(0,Z.useRef)(void 0);(0,Z.useEffect)(()=>{n.current===void 0&&(n.current=document.activeElement);let r=e&&!t.current;t.current=e,r&&(document.activeElement===document.body||document.activeElement===n.current)&&document.querySelector(`textarea[aria-label="Describe a task for the agent"]`)?.focus()},[e])}function wT(e){let t=e.workspaceConfig.data?.composerDefaults;return qC({hasGit:e.hasGit,planFirst:e.draft.planFirst,explicitAutonomous:e.draft.autonomous,explicitWorktree:e.draft.worktree,configuredAutonomous:t?.autonomous??t?.inheritedAutonomous??`source-dependent`,configuredWorktree:t?.worktree??t?.inheritedWorktree??!0,source:e.source?.source??`workflow`})}function TT(e){let t=A(),n=xm(),r=t.data?.projects??[],i=e??t.data?.bootProject,a=n===`absent`?[]:UC(r.find(e=>e.id===i)),[o,s]=(0,Z.useState)(!1);return{projectList:r,bootProject:t.data?.bootProject,webhookTargets:a,notifyOn:a.length>0&&o,setNotifyChoice:s}}function ET(e){let[t,n]=(0,Z.useState)(()=>typeof window<`u`&&window.innerWidth<=767);return(0,Z.useLayoutEffect)(()=>{let t=e.current;if(!t)return;let r=()=>n(window.innerWidth<=767||t.getBoundingClientRect().width<550);r();let i=typeof ResizeObserver>`u`?null:new ResizeObserver(r);return i?.observe(t),window.addEventListener(`resize`,r),()=>{i?.disconnect(),window.removeEventListener(`resize`,r)}},[]),t}function DT(e){let t=To(),[n,r]=(0,Z.useState)(()=>e.deepLink.ref!==``||e.deepLink.skillPath!==void 0);OT(e.search,t),kT({pending:n,setPending:r,deepLink:e.deepLink,sourcesReady:e.sourcesReady,listUnchecked:e.listUnchecked,skillList:e.skillList,update:e.update})}function OT(e,t){let n=(0,Z.useRef)(!1);(0,Z.useEffect)(()=>{n.current||(n.current=!0,e.toString()!==``&&t(`/new`,{replace:!0}))},[])}function kT(e){let{pending:t,sourcesReady:n,deepLink:r}=e;(0,Z.useEffect)(()=>{if(!t||!n)return;e.setPending(!1);let i=!e.listUnchecked&&r.skill!==``&&!$w({source:`skill`,ref:r.skill,...r.skillPath===void 0?{}:{path:r.skillPath}},e.skillList,[])?r.skill:``;i!==``&&r.ref!==``&&e.update({text:KC(r.skill,r.ref),source:null});let{message:a,tone:o}=GC(i,r.ref!==``);H(a,{tone:o}),document.querySelector(`[data-slot="composer"] button[aria-label="Start task"], [data-slot="composer"] button[aria-label="Plan task"]`)?.focus()},[t,n])}function AT(e){return e.isPending?`Checking agent providers…`:e.isError?`Provider authentication could not be verified.`:`Connect an agent provider before starting a task.`}function jT(e,t,n){St({lastTask:e?{source:e.source,ref:e.ref}:null,...e?{recentSources:zw(t.data?.recentSources,{source:e.source,ref:e.ref})}:{},...e?.source===`skill`&&t.data!==void 0?{skillUsage:Ks(t.data.skillUsage,e.ref)}:{}}).then(()=>n.invalidateQueries({queryKey:ge.uiState})).catch(()=>{})}function MT(e){let t=To(),n=U(),[r,i]=(0,Z.useState)(null),[a,o]=(0,Z.useState)(!1),[s,c]=(0,Z.useState)(!1),{draft:l,draftProjectId:u,engine:d,mounted:f}=e,{providers:p,providersReady:m,runner:h}=d,g=(r,i)=>{e.clearStarted(i),n.invalidateQueries({queryKey:ge.runs.all}),f.current&&t(iT(r))};return{plan:r,setPlan:i,planning:a,starting:s,submit:async(t,r)=>{let a=mw(u);if(!m||h===null)throw Error(AT(p));if(!e.sourcesReady)throw Error(`Still loading workflows and skills — try again in a second.`);if(l.agentProfile&&!e.accountsSettled)throw Error(`Still loading agent accounts — try again in a second.`);if(l.planFirst){o(!0);try{let e=await ut(t,d.planAccount);f.current&&i(aT(t,r,e))}finally{o(!1)}return}let s=await nn(rT(tT({task:t,source:e.source,model:d.model,modelsLocked:d.modelsLocked,effort:d.effort,runner:h,runnerExplicit:l.runner!==null,agentProfile:e.agentProfile,defaultRunner:d.defaultRunner,images:r,worktree:e.runMode.worktree,autonomous:e.runMode.autonomous,archiveWhenDone:l.archiveWhenDone,autoMergePr:l.autoMergePr,allowWorkers:l.allowWorkers,allowMessaging:l.allowMessaging}),e.notifyOn));jT(e.source,e.uiState,n),g(s,a)},startPlanned:async()=>{if(r===null||r.steps.length===0||s||!m||h===null||l.agentProfile&&!e.accountsSettled)return;let t=mw(u);c(!0);try{let n=await nn(rT(uT({task:r.task,steps:r.steps,agentProfile:e.agentProfile,model:d.model,modelsLocked:d.modelsLocked,effort:d.effort,runner:h,runnerExplicit:l.runner!==null,defaultRunner:d.defaultRunner,images:r.images,archiveWhenDone:l.archiveWhenDone,autoMergePr:l.autoMergePr,allowWorkers:l.allowWorkers,allowMessaging:l.allowMessaging}),e.notifyOn));i(null),g(n,t)}catch(e){H(e instanceof Error?e.message:String(e),{tone:`danger`})}finally{c(!1)}}}}function NT({archiveWhenDone:e,autoMergePr:t,onChange:n,disabled:r=!1,disabledReason:i=`Unavailable while saving these settings.`,embedded:a=!1}){let o=(0,Z.useId)(),s=r?i:void 0;return(0,Q.jsxs)(`fieldset`,{"data-slot":`completion-controls`,"data-embedded":a||void 0,className:`grid min-w-0 gap-3`,children:[(0,Q.jsx)(`legend`,{className:a?`sr-only`:`text-sm font-medium [margin-block-end:0.5rem]`,children:`After Done`}),(0,Q.jsxs)(`label`,{htmlFor:`${o}-archive`,className:`completion-control flex min-h-11 min-w-0 items-center justify-between gap-3 rounded-md text-sm`,children:[(0,Q.jsxs)(`span`,{className:`min-w-0 break-words`,children:[(0,Q.jsx)(`span`,{id:`${o}-archive-label`,children:`Archive when Done`}),a?(0,Q.jsx)(`span`,{id:`${o}-archive-help`,className:`completion-control-help`,children:s??`Move to Archived after Done, even without a PR. You can restore it later.`}):null]}),(0,Q.jsx)(mo,{id:`${o}-archive`,className:`completion-switch`,checked:e,disabled:r,"aria-labelledby":`${o}-archive-label`,"aria-describedby":`${o}-archive-help`,onCheckedChange:e=>n({archiveWhenDone:e})})]}),a?null:(0,Q.jsx)(`p`,{id:`${o}-archive-help`,className:`text-xs break-words text-muted-foreground`,children:s??`Move the task to Archived after it reaches Done. You can restore it later.`}),(0,Q.jsxs)(`label`,{htmlFor:`${o}-merge`,className:`completion-control flex min-h-11 min-w-0 items-center justify-between gap-3 rounded-md text-sm`,children:[(0,Q.jsxs)(`span`,{className:`min-w-0 break-words`,children:[(0,Q.jsx)(`span`,{id:`${o}-merge-label`,children:`Auto-merge PR`}),a?(0,Q.jsx)(`span`,{id:`${o}-merge-help`,className:`completion-control-help`,children:s??`After Done, mark the PR ready and merge when current-head CI and GitHub rules allow.`}):null]}),(0,Q.jsx)(mo,{id:`${o}-merge`,className:`completion-switch`,checked:t,disabled:r,"aria-labelledby":`${o}-merge-label`,"aria-describedby":`${o}-merge-help`,onCheckedChange:e=>n({autoMergePr:e})})]}),a?null:(0,Q.jsx)(`p`,{id:`${o}-merge-help`,className:`text-xs break-words text-muted-foreground`,children:s??`After Done, mark a draft PR ready and merge when current-head CI and GitHub rules allow it.`}),!a||e&&t?(0,Q.jsx)(`p`,{className:`completion-order-note text-xs break-words text-muted-foreground`,children:a?`Merge runs before archive when both are on.`:`When both are on, merge comes before archive. Without a PR, Archive when Done still archives the task.`}):null]})}var PT=[{key:`allowWorkers`,slot:`workers`,label:`Allow Squawk workers`,help:`Agents in this task can start Squawk workers. Each worker is a separate paid agent session. Worker limits cap resources, not spending.`},{key:`allowMessaging`,slot:`messaging`,label:`Allow task messaging`,help:`Agents in this task can message other tasks in this project.`}];function FT({allowWorkers:e,allowMessaging:t,onChange:n,disabled:r=!1,embedded:i=!1}){let a=(0,Z.useId)(),o={allowWorkers:e,allowMessaging:t};return(0,Q.jsxs)(`fieldset`,{"data-slot":`task-access-controls`,"data-embedded":i||void 0,className:`grid min-w-0 gap-3`,children:[(0,Q.jsx)(`legend`,{className:i?`sr-only`:`text-sm font-medium [margin-block-end:0.5rem]`,children:`Task access`}),PT.map(e=>(0,Q.jsxs)(Z.Fragment,{children:[(0,Q.jsxs)(`label`,{htmlFor:`${a}-${e.slot}`,"data-slot":`task-access-${e.slot}`,className:`completion-control flex min-h-11 min-w-0 items-center justify-between gap-3 rounded-md text-sm`,children:[(0,Q.jsxs)(`span`,{className:`min-w-0 break-words`,children:[(0,Q.jsx)(`span`,{id:`${a}-${e.slot}-label`,children:e.label}),i?(0,Q.jsx)(`span`,{id:`${a}-${e.slot}-help`,className:`completion-control-help`,children:e.help}):null]}),(0,Q.jsx)(mo,{id:`${a}-${e.slot}`,className:`completion-switch shrink-0`,checked:o[e.key],disabled:r,"aria-labelledby":`${a}-${e.slot}-label`,"aria-describedby":`${a}-${e.slot}-help`,onCheckedChange:t=>n({[e.key]:t})})]}),i?null:(0,Q.jsx)(`p`,{id:`${a}-${e.slot}-help`,className:`text-xs break-words text-muted-foreground`,children:e.help})]},e.key))]})}var IT=[{id:`fix-bug`,label:`Fix a bug`,body:`Investigate and fix the issue, adding a regression test that reproduces it first.`},{id:`add-tests`,label:`Add tests`,body:`Add focused unit tests covering the edge cases and verify the suite passes.`},{id:`review-changes`,label:`Review changes`,body:`Review the recent changes for bugs, edge cases, and missing test coverage.`}];function LT({templates:e,onInsert:t}){let n=e.length>0?e.slice(0,4).map(e=>({id:e.id,label:e.label,body:e.text})):IT,r=e.length>0?`Saved templates`:`Quick start prompts`;return(0,Q.jsxs)(`section`,{"data-slot":`new-task-quick-prompts`,"aria-label":r,className:`mt-5 flex flex-col gap-2.5 rounded-xl border border-border bg-card p-4`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-baseline justify-between gap-2`,children:[(0,Q.jsx)(`h2`,{className:`text-xs font-semibold text-foreground`,children:r}),(0,Q.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Insert a starting prompt into the composer`})]}),(0,Q.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:n.map(e=>(0,Q.jsx)(`button`,{type:`button`,"data-slot":`new-task-quick-prompt`,onClick:()=>t(e.body),className:`inline-flex min-h-9 max-md:min-h-11 no-hover:min-h-11 items-center rounded-lg border border-border bg-background px-3 py-1.5 text-left text-xs font-medium text-foreground transition-colors hover:bg-muted focus-visible:outline-2 focus-visible:outline-ring`,children:e.label},e.id))})]})}function RT({groupRef:e,compact:t,runOn:n,engine:r,accounts:i,draftEffort:a,update:o}){let s=r.runners.length>1||r.uninstalled.length>0||r.signedOut.length>0||r.runners.some(e=>Zs(i.accountChoices,e))?(0,Q.jsx)(zT,{engine:r,accounts:i,update:o},`runner`):null,c=(0,Q.jsx)(BT,{engine:r,draftEffort:a,update:o},`model`),l=(0,Q.jsx)(VT,{engine:r,update:o},`effort`);return(0,Q.jsx)(`div`,{ref:e,"data-slot":`agent-options`,role:`group`,"aria-label":`Agent settings`,className:`new-task-agent-options`,children:(0,Q.jsx)(TC,{children:t?[n,s,l,c]:[n,s,c,l]})})}function zT({engine:e,accounts:t,update:n}){return(0,Q.jsx)(NC,{icon:(0,Q.jsx)(Ri,{"aria-hidden":`true`,className:`size-[18px] shrink-0 text-accent-text`}),fieldLabel:!0,runners:e.runners,uninstalled:e.uninstalled,signedOut:e.signedOut,value:e.displayRunner,accounts:t.accountChoices,account:t.agentProfile,repoAccount:t.repoAccount,onPick:(t,r)=>n({runner:t,agentProfile:r,...t===e.displayRunner?{}:{model:null}}),disabled:!e.providersReady})}function BT({engine:e,draftEffort:t,update:n}){let{catalog:r,displayRunner:i}=e;return(0,Q.jsx)(jC,{icon:(0,Q.jsx)(Si,{"aria-hidden":`true`,className:`size-[18px] shrink-0 text-accent-text`}),fieldLabel:!0,slot:`model-pill`,ariaLabel:`Model`,label:e.models.find(t=>t.id===e.model)?.label??`Runner default`,value:e.model,disabled:!e.providersReady,readOnly:e.modelsLocked,disabledHint:e.modelsLocked?`Model selection is locked to native coding-agent settings.`:void 0,onPick:e=>{let i=Hw(e,r.data);n({model:e,effort:t===null?null:Uw(t,i)})},options:e.models.map(e=>({value:e.id,label:e.label,desc:e.desc})),status:Jw(i,e.registered.data,r)})}function VT({engine:e,update:t}){return(0,Q.jsx)(jC,{icon:(0,Q.jsx)(ni,{"aria-hidden":`true`,className:`size-[18px] shrink-0 text-accent-text`}),fieldLabel:!0,slot:`effort-pill`,ariaLabel:`Effort`,label:e.effortOptions.find(t=>t.value===e.effort)?.label??`Runner default`,value:e.effort,disabled:!e.providersReady,readOnly:e.modelsLocked,disabledHint:e.modelsLocked?`Effort selection is locked to native coding-agent settings.`:void 0,onPick:e=>t({effort:e}),options:e.effortOptions.map(e=>({value:e.value,label:e.label,desc:e.desc}))})}function HT({engine:e,draft:t,update:n,repo:r,hasGit:i,runMode:a,webhook:o,completionDisabled:s}){let{displayRunner:c}=e,l=L().data,u=fs(),[d,f]=(0,Z.useState)(),p=d??u;return(0,Q.jsxs)(`details`,{"data-slot":`execution-options`,open:p,onToggle:e=>{e.currentTarget.open!==p&&f(e.currentTarget.open)},className:`group rounded-xl border border-border bg-card xl:self-start`,children:[(0,Q.jsxs)(`summary`,{className:`flex min-h-[44px] cursor-pointer list-none flex-wrap items-center gap-x-2 gap-y-1 px-3 py-2 text-xs text-muted-foreground pointer-hover:bg-muted/50 active:bg-muted/50 focus-visible:outline-2 focus-visible:outline-offset-[-2px] focus-visible:outline-foreground [&::-webkit-details-marker]:hidden`,children:[(0,Q.jsx)(Li,{"aria-hidden":`true`,className:`size-[18px] shrink-0 text-accent-text`}),(0,Q.jsx)(`span`,{className:`font-medium text-foreground`,children:`Execution settings`}),(0,Q.jsxs)(`span`,{"data-slot":`execution-summary`,className:`min-w-0 basis-full truncate pl-5 xl:ml-auto xl:basis-auto xl:pl-0`,children:[ye(l,c),` · `,e.models.find(t=>t.id===e.model)?.label??`Runner default`,i&&!a.worktree?` · no worktree`:``,a.autonomous?` · autonomous`:``]}),(0,Q.jsx)(Ki,{"aria-hidden":`true`,className:`new-task-settings-chevron size-4 shrink-0`})]}),(0,Q.jsxs)(`div`,{className:`new-task-settings-body`,children:[(0,Q.jsx)(`p`,{className:`new-task-settings-description`,children:`Control this run and what happens after Done.`}),(0,Q.jsxs)(`div`,{role:`group`,"aria-label":`Run settings`,className:`new-task-run-settings`,children:[i?(0,Q.jsx)(GT,{on:a.worktree,onChange:e=>n({worktree:e})}):null,(0,Q.jsx)(JT,{repo:r,worktree:a.worktree||!i}),(0,Q.jsx)(KT,{on:a.autonomous,disabled:t.planFirst,onChange:e=>n({autonomous:e})}),o.targets.length>0?(0,Q.jsx)(qT,{on:o.on,targets:o.targets,onChange:o.onChange}):null]}),(0,Q.jsx)(NT,{embedded:!0,archiveWhenDone:t.archiveWhenDone,autoMergePr:t.autoMergePr,onChange:n,disabled:s,disabledReason:`Unavailable while starting the task or preparing its plan.`}),(0,Q.jsx)(FT,{embedded:!0,allowWorkers:t.allowWorkers,allowMessaging:t.allowMessaging,onChange:n,disabled:s})]})]})}function UT({showConfigureProviders:e,planFirst:t,planning:n,onModeChange:r}){return(0,Q.jsxs)(Q.Fragment,{children:[e?(0,Q.jsx)(X,{to:`/settings/agent-defaults#providers`,className:`text-xs font-medium text-foreground underline underline-offset-4`,children:`Configure providers`}):null,(0,Q.jsx)($T,{planFirst:t,planning:n,onModeChange:r}),(0,Q.jsx)(`kbd`,{"aria-hidden":`true`,className:`hidden rounded-[5px] border border-b-2 border-border bg-card px-[5px] py-px font-mono text-xs font-medium text-muted-foreground md:inline`,children:kx()})]})}function WT({slot:e,label:t,hint:n,title:r,on:i,disabled:a,onChange:o,hintSlot:s,truncateHint:c}){return(0,Q.jsxs)(`label`,{title:r,className:q(`flex min-h-11 items-center justify-between gap-3 px-0 py-3 text-left`,a?`cursor-not-allowed opacity-50`:`cursor-pointer`),children:[(0,Q.jsxs)(`span`,{className:`min-w-0`,children:[(0,Q.jsx)(`span`,{className:`block text-[13px] font-medium`,children:t}),(0,Q.jsx)(`span`,{"data-slot":s,className:q(`block text-[12px] text-muted-foreground`,c&&`truncate`),children:n})]}),(0,Q.jsx)(mo,{"data-slot":e,"aria-label":t,checked:i,disabled:a,onCheckedChange:o})]})}function GT({on:e,onChange:t}){return(0,Q.jsx)(WT,{slot:`worktree-toggle`,label:`Worktree`,hint:e?`Changes stay in a separate working copy.`:`Changes are made in the current working directory.`,title:e?`Runs in an isolated worktree — turn off to run in the repo working tree`:`Runs in the repo working tree — turn on to isolate in a worktree`,on:e,onChange:t})}function KT({on:e,disabled:t,onChange:n}){return(0,Q.jsx)(WT,{slot:`autonomous-toggle`,label:`Autonomous`,hint:`Let the agent proceed without prompts`,title:t?`Plan-first runs are interactive — autonomous is unavailable`:e?`Autonomous — the agent runs to completion without pausing for you`:`Runs interactively — turn on to let the agent finish without pausing for you`,on:e,disabled:t,onChange:n})}function qT({on:e,targets:t,onChange:n}){return(0,Q.jsx)(WT,{slot:`notify-webhook-toggle`,label:`Notify webhook`,hint:`Send status changes`,hintSlot:`notify-webhook-subtitle`,truncateHint:!0,title:`${e?`Status changes go to`:`Turn on to send this task's status changes to`} ${WC(t)} (${t.map(e=>HC(e.url)).join(`, `)})`,on:e,onChange:n})}function JT({repo:e,worktree:t}){return(0,Q.jsxs)(`div`,{"data-slot":`base-branch-row`,"data-inactive":t?void 0:``,className:q(`new-task-base-branch flex items-center justify-between gap-2 text-xs text-muted-foreground`,!t&&`opacity-60`),children:[(0,Q.jsxs)(`span`,{children:[`Base branch`,t?null:(0,Q.jsx)(`span`,{"data-slot":`base-branch-hint`,className:`block text-[12px]`,children:`Not used while Worktree is off.`})]}),e?(0,Q.jsx)(YT,{repo:e,disabled:!t}):null]})}function YT({repo:e,disabled:t}){let n=U(),r=je({mutationFn:e=>st({baseBranch:e}),onSuccess:e=>{n.invalidateQueries({queryKey:ge.repo}),H(e.baseBranch?`New tasks will branch off "${e.baseBranch}" (PRs target it too).`:`Base branch cleared — new tasks fork from the checked-out branch.`)},onError:e=>H(e.message,{tone:`danger`})});return e.info?(0,Q.jsx)(jC,{searchPlaceholder:`Search branches…`,slot:`base-pill`,ariaLabel:`Base branch`,disabled:t,label:(0,Q.jsx)(`span`,{className:`text-xs`,children:e.baseBranch??e.info.branch}),value:e.baseBranch??``,onPick:e=>r.mutate(e===``?null:e),options:[{value:``,label:`follow checked-out branch (${e.info.branch})`,desc:`New task worktrees fork from whatever branch is checked out`},...e.branches.map(e=>({value:e,label:e}))]}):null}var XT=`h-6 rounded-md px-3 text-xs font-medium transition-colors outline-hidden focus-visible:ring-2 focus-visible:ring-ring/50`,ZT=`bg-muted text-foreground`,QT=`text-muted-foreground pointer-hover:text-foreground`;function $T({planFirst:e,planning:t,onModeChange:n}){return(0,Q.jsxs)(`div`,{"data-slot":`mode-seg`,role:`radiogroup`,"aria-label":`Run mode`,className:`inline-flex items-center gap-0.5 rounded-lg border border-border bg-card p-0.5`,children:[(0,Q.jsx)(`button`,{type:`button`,role:`radio`,"aria-checked":!e,onClick:()=>n(!1),className:q(XT,e?QT:ZT),children:`Run now`}),(0,Q.jsx)(`button`,{type:`button`,role:`radio`,"aria-checked":e,"aria-busy":t||void 0,"data-slot":`mode-plan`,onClick:()=>n(!0),className:q(XT,e?ZT:QT,t&&`animate-pulse`),children:t?`Planning…`:`Plan first`})]})}function eE({plan:e,starting:t,startAvailable:n,startUnavailableReason:r,startUnavailableAction:i,onStepsChange:a,onStart:o,onDiscard:s}){let[c,l]=(0,Z.useState)(null),[u,d]=(0,Z.useState)(null),f=(0,Z.useRef)(null),p=(0,Z.useId)();(0,Z.useEffect)(()=>{f.current?.focus({preventScroll:!0});let e=f.current?.closest(`[data-slot="main"]`);e&&(e.scrollTop=0)},[]);let m=()=>{l(null),d(null)},h=(t,n)=>{t.preventDefault(),c!==null&&c!==n&&a(sT(e.steps,c,n)),m()},g=e.steps.length===0;return(0,Q.jsx)(`div`,{"data-slot":`plan-page`,children:(0,Q.jsx)(`div`,{"data-slot":`plan-canvas`,children:(0,Q.jsxs)(`section`,{ref:f,tabIndex:-1,"aria-labelledby":p,"data-slot":`plan-review`,className:`flex flex-col outline-none`,onKeyDown:e=>{e.key!==`Escape`||e.defaultPrevented||e.target.closest(`[role="dialog"], [role="alertdialog"]`)||(e.preventDefault(),s())},children:[(0,Q.jsxs)(`header`,{"data-slot":`dialog-header`,className:`flex flex-col gap-1 px-5 pt-4 pb-3.5 text-left`,children:[(0,Q.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,Q.jsx)(`h2`,{id:p,"data-slot":`dialog-title`,className:`text-xs font-semibold tracking-[0.08em] text-muted-foreground uppercase`,children:`Proposed chain`}),(0,Q.jsx)(`button`,{type:`button`,onClick:s,"aria-label":`Discard the plan`,className:`-mt-1 -mr-1 rounded-md p-1 text-muted-foreground transition-colors hover:bg-muted hover:text-foreground`,children:(0,Q.jsx)(Fi,{"aria-hidden":`true`,className:`size-4`})})]}),(0,Q.jsx)(`p`,{"data-slot":`plan-task`,title:e.task,className:`text-[18px] font-medium text-foreground`,children:lT(e.task)}),e.fallback?(0,Q.jsx)(`p`,{"data-slot":`plan-fallback`,className:`text-xs text-soft-foreground italic`,children:`planner unavailable — single-step plan`}):e.rationale===``?null:(0,Q.jsx)(`p`,{"data-slot":`plan-rationale`,className:`text-xs text-muted-foreground`,children:e.rationale})]}),(0,Q.jsx)(`ol`,{"data-slot":`plan-steps`,className:`flex-1 space-y-2 overflow-y-auto px-5 py-4`,children:g?(0,Q.jsx)(`li`,{className:`py-6 text-center text-sm text-muted-foreground`,children:`(no steps left — discard and plan again)`}):e.steps.map((t,n)=>(0,Q.jsxs)(`li`,{"data-slot":`plan-step`,"data-step-id":t.id,draggable:!0,onDragStart:()=>l(n),onDragOver:e=>{e.preventDefault(),d(n)},onDragLeave:()=>d(e=>e===n?null:e),onDrop:e=>h(e,n),onDragEnd:m,className:q(`flex items-center gap-2.5 rounded-lg border border-border bg-card-2 px-3 py-2.5`,c===n&&`opacity-50`,u===n&&c!==null&&c!==n&&`border-ring`),children:[(0,Q.jsx)(hi,{"aria-hidden":`true`,className:`size-3.5 shrink-0 cursor-grab text-soft-foreground`}),(0,Q.jsx)(`span`,{className:`w-5 shrink-0 font-mono text-xs text-muted-foreground tabular-nums`,children:String(n+1).padStart(2,`0`)}),(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,Q.jsx)(`span`,{className:`text-[13px] font-medium`,children:t.name??t.id}),t.skill?(0,Q.jsx)(`span`,{"data-slot":`plan-badge-skill`,title:`skill`,className:`shrink-0 rounded-full bg-accent-strong/15 px-1.5 py-px font-mono text-xs font-medium text-accent-text`,children:t.skill}):null,t.command?(0,Q.jsx)(`span`,{"data-slot":`plan-badge-check`,className:`shrink-0 rounded-full bg-muted px-1.5 py-px text-xs font-medium text-muted-foreground`,children:`check`}):null]}),(0,Q.jsx)(`p`,{className:`mt-3 whitespace-pre-wrap break-words font-mono text-xs text-muted-foreground`,children:cT(t)})]}),(0,Q.jsxs)(`span`,{"data-slot":`plan-step-actions`,className:`flex flex-wrap items-center gap-2`,children:[(0,Q.jsx)(Y,{type:`button`,variant:`ghost`,size:`icon-sm`,"data-slot":`plan-step-up`,"aria-label":`Move step ${n+1} up`,disabled:n===0,className:`text-muted-foreground`,onClick:()=>a(sT(e.steps,n,n-1)),children:`Move up`}),(0,Q.jsx)(Y,{type:`button`,variant:`ghost`,size:`icon-sm`,"data-slot":`plan-step-down`,"aria-label":`Move step ${n+1} down`,disabled:n===e.steps.length-1,className:`text-muted-foreground`,onClick:()=>a(sT(e.steps,n,n+1)),children:`Move down`}),(0,Q.jsx)(Y,{type:`button`,variant:`ghost`,size:`icon-sm`,"data-slot":`plan-step-remove`,"aria-label":`Remove step ${n+1}`,className:`text-muted-foreground hover:text-semantic-red`,onClick:()=>a(oT(e.steps,n)),children:`Remove`})]})]},t.id))}),!n&&r?(0,Q.jsxs)(`p`,{id:`plan-start-guidance`,className:`flex flex-wrap items-center gap-1.5 border-t border-border px-5 pt-3 text-xs text-muted-foreground`,children:[(0,Q.jsx)(`span`,{children:r}),i]}):null,(0,Q.jsxs)(`div`,{"data-slot":`plan-actions`,className:`flex flex-wrap items-center gap-3 px-6 pt-3 pb-6`,children:[(0,Q.jsxs)(Y,{type:`button`,"data-slot":`plan-start`,disabled:g||t||!n,title:n?void 0:r,"aria-describedby":!n&&r?`plan-start-guidance`:void 0,onClick:o,children:[(0,Q.jsx)(Sa,{"aria-hidden":`true`,className:`size-3.5`}),t?`Starting…`:`Start`]}),(0,Q.jsx)(tE,{steps:e.steps,disabled:g}),(0,Q.jsx)(Y,{type:`button`,variant:`outline`,onClick:s,children:`Discard`})]}),(0,Q.jsx)(`p`,{className:`px-6 pb-6 text-xs text-muted-foreground`,children:`No steps left? Start is disabled. A planner failure shows a single-step fallback.`})]})})})}function tE({steps:e,disabled:t}){let n=U(),[r,i]=(0,Z.useState)(!1),[a,o]=(0,Z.useState)(``),[s,c]=(0,Z.useState)(!1),[l,u]=(0,Z.useState)(!1),d=async t=>{let r=a.trim();if(!(r===``||l)){u(!0);try{let a=await bn({name:r,steps:e,...t?{overwrite:!0}:{}});H(`Saved — ${a.path.split(`/`).pop()??a.path}`),n.invalidateQueries({queryKey:ge.workflows}),c(!1),i(!1),o(``)}catch(e){e instanceof Tn&&e.exists===!0?c(!0):H(e instanceof Error?e.message:String(e),{tone:`danger`})}finally{u(!1)}}};return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Y,{type:`button`,variant:`outline`,"data-slot":`plan-save`,disabled:t,onClick:()=>i(!0),children:`Save as chain`}),(0,Q.jsx)(So,{open:r,onOpenChange:e=>i(!!e),children:(0,Q.jsxs)(bo,{"data-slot":`plan-save-dialog`,className:`sm:max-w-sm`,showCloseButton:!1,children:[(0,Q.jsxs)(yo,{children:[(0,Q.jsx)(xo,{children:`Save as chain`}),(0,Q.jsx)(_o,{children:`Saves these steps as a reusable workflow — it joins the picker like any other chain.`})]}),(0,Q.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),d(!1)},children:[(0,Q.jsx)(`label`,{htmlFor:`plan-chain-name`,className:`mb-2 block text-xs text-muted-foreground`,children:`Chain name`}),(0,Q.jsx)(Wu,{id:`plan-chain-name`,value:a,onChange:e=>o(e.target.value),"aria-label":`Chain name`,placeholder:`e.g. fix-and-verify-v2`,maxLength:80,autoFocus:!0}),(0,Q.jsxs)(go,{className:`mt-4`,children:[(0,Q.jsx)(Y,{type:`button`,variant:`outline`,onClick:()=>i(!1),children:`Cancel`}),(0,Q.jsx)(Y,{type:`submit`,disabled:a.trim()===``||l,children:l?`Saving…`:`Save chain`})]})]})]})}),(0,Q.jsx)(Pv,{open:s,onOpenChange:e=>e?void 0:c(!1),children:(0,Q.jsxs)(Lv,{"data-slot":`plan-overwrite-dialog`,children:[(0,Q.jsxs)(Rv,{children:[(0,Q.jsxs)(Bv,{children:[`Overwrite “`,a.trim(),`”?`]}),(0,Q.jsx)(Vv,{children:`A chain with this name already exists. Overwriting replaces its steps with this plan.`})]}),(0,Q.jsxs)(zv,{children:[(0,Q.jsx)(Uv,{children:`Cancel`}),(0,Q.jsx)(Hv,{onClick:()=>void d(!0),children:`Overwrite chain`})]})]})})]})}var nE={start:{note:`Start immediately with the selected configuration.`,pendingLabel:`Starting task…`,failureHint:void 0,clearOnSuccess:!0,sendAriaLabel:`Start task`},plan:{note:`Review the plan before starting the task.`,pendingLabel:`Planning task…`,failureHint:`Could not create the plan. Your draft is kept. Please retry.`,clearOnSuccess:!1,sendAriaLabel:`Plan task`}};function rE(){let[e]=zn(),t=(0,Z.useRef)(null),n=(0,Z.useRef)(null),r=(0,Z.useRef)(null),{projectId:i}=Hn(),a=pn().projectId,o=L().data,[s]=(0,Z.useState)(()=>e.toString()),[c]=(0,Z.useState)(()=>bp(s,o)),l=bp(s,o).runner,u=O(),d=C(),f=ae(),p=xe(),{draft:m,update:h,clearStarted:g,submissionPending:_,submittingDraft:v,onPendingChange:y,mounted:b,pendingArrival:x,arrivalError:S,clearArrivalError:w,confirmArrival:T,cancelArrival:E}=vT(a,c,l,i),D=bw(a),[k,A]=(0,Z.useState)(0),j=xT(m,f),M=ST(j.displayRunner,m.agentProfile),N=yT(m.source,d,j.displayRunner,M.agentProfile),{source:ee,sourcesReady:P,skillList:F}=N,I=TT(i),R=jw({draftProjectId:a,urlProjectId:i,localProjects:I.projectList,bootProject:I.bootProject,draftText:m.text,draftSource:ee,attachmentCount:k,submissionPending:_}),te=bT({uiState:d,source:ee,sourcesReady:P,draftText:m.text,submissionPending:_,update:h});CT(j.providersReady);let ne=u.data===void 0||u.data.info!==null,re=wT({hasGit:ne,draft:m,selectedSkill:N.selectedSkill,workspaceConfig:p,source:ee}),{plan:z,setPlan:ie,planning:oe,starting:B,submit:se,startPlanned:ce}=MT({draft:m,draftProjectId:a,engine:j,agentProfile:M.agentProfile,accountsSettled:M.accountsSettled,sourcesReady:P,source:ee,runMode:re,notifyOn:I.notifyOn,uiState:d,mounted:b,clearStarted:g});DT({deepLink:c,search:e,sourcesReady:P&&N.skillsSettled&&!j.providers.isPending&&M.accountsSettled,listUnchecked:N.listUnchecked,skillList:F,update:h});let le=ET(t),{providers:ue,providersReady:de}=j,fe=m.planFirst?nE.plan:nE.start,pe=AT(ue),me=iE({plan:z,draftText:m.text,providersReady:de,starting:B,planning:oe,submittingDraft:v,arrivalError:S,moveError:R.moveError});return(0,Q.jsxs)(ms,{route:`new`,density:me.isSparseDraft?`sparse`:`full`,rootProps:{"data-plan-review":z===null?void 0:`true`},className:`relative isolate overflow-x-clip pb-16`,header:oE(z!==null),sparseFooter:sE(me.isSparseDraft,te,n),children:[(0,Q.jsx)(`div`,{"data-slot":`new-task-layout`,"data-persisted-draft":D||void 0,ref:r,style:z===null?void 0:{display:`none`},className:`relative z-[1] w-full`,children:(0,Q.jsx)(_C,{ref:n,onSubmit:se,retainDraftUntilSuccess:!0,idleFeedback:(0,Q.jsxs)(`div`,{"data-slot":`new-task-idle-feedback`,className:`flex flex-col gap-1`,children:[(0,Q.jsxs)(`div`,{"data-slot":`new-task-mode-note`,className:`flex items-center justify-between gap-3 text-xs text-muted-foreground`,children:[me.showStartHint?(0,Q.jsx)(`span`,{"data-slot":`new-task-start-hint`,children:`Describe a task above to start.`}):(0,Q.jsx)(`span`,{children:fe.note}),(0,Q.jsx)(`kbd`,{className:`hidden font-sans md:inline`,children:kx()})]}),(0,Q.jsx)(`p`,{"data-slot":`run-mode-note`,className:`text-xs text-muted-foreground`,children:JC({worktree:re.worktree,hasGit:ne})})]}),pendingLabel:fe.pendingLabel,failureHint:fe.failureHint,externalError:me.externalError,onAttachmentsChange:A,clearOnSuccess:fe.clearOnSuccess,onPendingChange:e=>{y(e),aE(e,R.clearMoveError)},value:m.text,onValueChange:e=>{w(),R.clearMoveError(),h({text:e})},draftPersisted:D,autoFocus:!0,placeholder:`Describe a task for the agent — / for skills…`,ariaLabel:`Describe a task for the agent`,sendAriaLabel:fe.sendAriaLabel,disabled:!de||B,disabledReason:pe,autocompleteSkills:!0,skillRunner:j.displayRunner,skillAccount:M.agentProfile,footerStart:(0,Q.jsx)(cE,{projects:I.projectList,urlProjectId:i,templates:te,onInsertTemplate:e=>n.current?.insertAtCaret(e),sources:N,onPickSource:e=>h({source:e})}),agentOptions:(0,Q.jsx)(RT,{groupRef:t,compact:le,runOn:(0,Q.jsx)(Nw,{targets:R.targets,currentProject:R.currentProject,disabled:me.submitting,onSelectHost:R.selectHost},`run-on`),engine:j,accounts:M,draftEffort:m.effort,update:h}),executionOptions:(0,Q.jsx)(HT,{engine:j,draft:m,update:h,repo:u.data,hasGit:ne,runMode:re,webhook:{targets:I.webhookTargets,on:I.notifyOn,onChange:I.setNotifyChoice},completionDisabled:B||oe}),footerEnd:(0,Q.jsx)(UT,{showConfigureProviders:!de&&!ue.isPending,planFirst:m.planFirst,planning:oe,onModeChange:e=>h({planFirst:e})})})}),z===null?null:(0,Q.jsx)(eE,{plan:z,starting:B,startAvailable:de,startUnavailableReason:pe,startUnavailableAction:ue.isPending?void 0:(0,Q.jsx)(X,{to:`/settings/agent-defaults#providers`,children:`Configure providers`}),onStepsChange:e=>ie(t=>t&&{...t,steps:e}),onStart:()=>void ce(),onDiscard:()=>{ie(null),requestAnimationFrame(()=>r.current?.querySelector(`textarea`)?.focus())}}),(0,Q.jsx)(Fw,{pending:R.pendingLeaveBehind,draftText:m.text,attachmentCount:k,draftSource:ee,onCancel:R.cancelLeaveBehind,onConfirm:R.confirmLeaveBehind}),(0,Q.jsx)(Iw,{pending:x,draftProjectId:a,projects:I.projectList,onCancel:E,onConfirm:T})]})}function iE(e){let t=e.draftText.trim()===``;return{isSparseDraft:e.plan===null&&t,showStartHint:e.providersReady&&!e.starting&&t,submitting:e.starting||e.planning||e.submittingDraft,externalError:e.arrivalError??e.moveError}}function aE(e,t){e&&t()}function oE(e){return e?{title:`New task / Plan first`,subtitle:`Review the proposed chain before launching.`,headerSlot:`plan-page-header`,hideSubtitleOnMobile:!0}:{title:`What should the agent work on?`,subtitle:`Describe the outcome, then configure the run.`,subtitleSlot:`page-description`,hideSubtitleOnMobile:!0}}function sE(e,t,n){if(e)return(0,Q.jsx)(LT,{templates:t,onInsert:e=>n.current?.insertAtCaret(e)})}function cE({projects:e,urlProjectId:t,templates:n,onInsertTemplate:r,sources:i,onPickSource:a}){let o=To();return(0,Q.jsxs)(Q.Fragment,{children:[e.length>1&&t!==void 0?(0,Q.jsx)(uE,{projects:e,projectId:t,onPick:e=>o(`/p/${encodeURIComponent(e)}/new`,{replace:!0})}):null,(0,Q.jsx)(FC,{label:`Template`,templates:n,onInsert:r}),(0,Q.jsx)(yE,{source:i.source,unchecked:i.unchecked,ready:i.sourcesReady,skillsLoading:!i.skillsSettled,skills:i.skillList,skillUsage:i.skillUsage,workflows:i.workflowList,onPick:a})]})}function lE(e,t){let n=t.trim().toLowerCase();if(n===``)return[...e];let r=e=>{let t=e.name.toLowerCase(),r=e.id.toLowerCase();return t.startsWith(n)||r.startsWith(n)?0:t.includes(n)||r.includes(n)?1:2};return e.map((e,t)=>({project:e,rank:r(e),index:t})).filter(e=>e.rank<2).sort((e,t)=>e.rank-t.rank||e.index-t.index).map(e=>e.project)}function uE({projects:e,projectId:t,onPick:n}){let[r,i]=(0,Z.useState)(!1),[a,o]=(0,Z.useState)(``),{order:s}=$m(),c=e.find(e=>e.id===t),l=lE(Ps(e,s),a);return(0,Q.jsxs)(po,{open:r,onOpenChange:e=>{i(e),e||o(``)},children:[(0,Q.jsx)(co,{asChild:!0,children:(0,Q.jsxs)(`button`,{type:`button`,"data-slot":`project-pill`,"aria-label":`Project`,title:`Which project this task runs in — its skills, workflows, settings and draft`,className:q(vC,`border-foreground/60 font-semibold text-foreground`),children:[(0,Q.jsx)(ii,{"aria-hidden":`true`,className:`size-3 shrink-0 text-soft-foreground`}),(0,Q.jsx)(`span`,{className:`max-w-40 truncate`,children:c?.name??t}),yC]})}),(0,Q.jsx)(uo,{align:`start`,sideOffset:8,className:`w-[300px] max-w-[calc(100vw-2rem)] p-0`,children:(0,Q.jsxs)(Ns,{shouldFilter:!1,children:[(0,Q.jsx)(Ts,{placeholder:`search projects…`,value:a,onValueChange:o}),(0,Q.jsxs)(Ms,{"data-slot":`project-menu`,className:`max-h-[min(18rem,calc(var(--radix-popover-content-available-height)-3rem))]`,children:[l.length===0?(0,Q.jsx)(js,{children:`Nothing matches.`}):null,l.map(e=>(0,Q.jsxs)(As,{value:e.id,keywords:[e.name],"data-slot":`project-option`,"data-project-id":e.id,disabled:e.status===`missing`,onSelect:()=>{n(e.id),i(!1)},children:[(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs font-medium`,children:e.name}),e.status===`missing`?(0,Q.jsx)(`span`,{className:`shrink-0 text-xs text-soft-foreground`,children:`folder not found`}):e.branch===void 0?null:(0,Q.jsx)(`span`,{className:`shrink-0 font-mono text-xs text-soft-foreground`,children:e.branch}),e.id===t?(0,Q.jsx)(Ni,{"aria-hidden":`true`,className:`size-3.5 shrink-0 text-link-foreground`}):null]},e.id))]}),(0,Q.jsx)(`p`,{className:`border-t border-border px-3 py-2 text-xs leading-snug text-soft-foreground`,children:`Skills, workflows, settings and the draft re-resolve against the selected project.`})]})})]})}function dE(e,t,n){return!e&&(t.ranked?t.ranked.length===0:t.mostUsed.length===0&&t.project.length===0&&t.global.length===0)&&n.length===0}function fE(e,t){return Rs(`no skill`,`none plain ${Rw} ${e?.description??``}`,t)>0}var pE={workflows:`Skill or workflow`,skills:`Skill`};function mE({source:e,ready:t,offersWorkflows:n,onPick:r,skillLabel:i}){let a=e===null||e.source===`skill`?Hi:Di;return(0,Q.jsxs)(`button`,{type:`button`,"data-slot":`source-pill`,"data-source-kind":e?.source??`none`,"aria-label":`Choose a skill or workflow`,title:e===null?`No skill — the task runs as one plain agent step. Pick a skill or workflow to change that.`:`Runs the ${e.source} "${e.ref}" — pick it again, or press ✕, to run without it`,disabled:!t,"aria-busy":!t||void 0,onKeyDown:t=>{e===null||t.metaKey||t.ctrlKey||t.altKey||t.key!==`Backspace`&&t.key!==`Delete`||(t.preventDefault(),r(null))},className:q(vC,e===null?`text-muted-foreground`:`rounded-r-none border-r-0 border-foreground/60 pr-1.5 font-semibold text-foreground`),children:[(0,Q.jsx)(a,{"aria-hidden":`true`,className:q(`size-3 shrink-0`,e===null?`text-muted-foreground`:`text-accent-icon`)}),e===null?(0,Q.jsx)(`span`,{"data-sizer":pE.workflows,className:`grid max-w-44 before:invisible before:whitespace-nowrap before:content-[attr(data-sizer)] before:[grid-area:1/1]`,children:(0,Q.jsx)(`span`,{className:`truncate text-start [grid-area:1/1]`,children:t?n?pE.workflows:pE.skills:`…`})}):(0,Q.jsx)(`span`,{className:`max-w-44 truncate`,children:t?i??e.ref:`…`}),yC]})}function hE({source:e,quickTask:t,onPick:n}){return(0,Q.jsx)(Ds,{children:(0,Q.jsxs)(As,{value:`none no-skill`,keywords:[`none`,`plain`,...Ws(Rw)],"data-slot":`source-option`,"data-source-kind":`none`,onSelect:()=>n(null),children:[(0,Q.jsx)(Oi,{"aria-hidden":`true`,className:`size-3.5 shrink-0 text-soft-foreground`}),(0,Q.jsx)(`span`,{className:`shrink-0 text-xs font-medium`,children:`No skill`}),(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs text-soft-foreground`,children:t?.description??`One agent run on your task — no ceremony.`}),e===null?(0,Q.jsx)(Ni,{"aria-hidden":`true`,className:`ml-auto size-3.5 shrink-0 text-link-foreground`}):null]})})}function gE({ranked:e,mostUsed:t,project:n,skillItem:r}){return(0,Q.jsx)(Q.Fragment,{children:e?e.length>0?(0,Q.jsx)(Ds,{children:e.map(e=>r(e,Vs(e)))}):null:(0,Q.jsxs)(Q.Fragment,{children:[t.length>0?(0,Q.jsx)(Ds,{heading:`Most used`,children:t.map(e=>r(e,Vs(e)))}):null,n.length>0?(0,Q.jsx)(Ds,{heading:`Project skills`,children:n.map(e=>r(e,!0))}):null]})})}function _E({source:e,matchedWorkflows:t,toggle:n}){return t.length>0?(0,Q.jsx)(Ds,{heading:`Workflows`,children:t.map(t=>{let r=e?.source===`workflow`&&e.ref===t.name;return(0,Q.jsxs)(As,{value:`workflow ${t.name}`,keywords:Ws(t.name,t.description),"data-slot":`source-option`,"data-source-kind":`workflow`,"data-source-ref":t.name,onSelect:()=>n({source:`workflow`,ref:t.name}),children:[(0,Q.jsx)(`span`,{className:`shrink-0 font-mono text-xs`,children:t.name}),t.description?(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs text-soft-foreground`,children:t.description}):null,r?(0,Q.jsx)(Ni,{"aria-hidden":`true`,className:`ml-auto size-3.5 shrink-0 text-link-foreground`}):null]},t.name)})}):null}function vE({global:e,skillItem:t}){return e.length>0?(0,Q.jsx)(Ds,{heading:`Global`,children:e.map(e=>t(e,!1))}):null}function yE({source:e,unchecked:t,ready:n,skillsLoading:r,skills:i,skillUsage:a,workflows:o,onPick:s}){let[c,l]=(0,Z.useState)(!1),[u,d]=(0,Z.useState)(``),[f,p]=(0,Z.useState)(null),m=(0,Z.useRef)(null),{mostUsed:h,project:g,global:_,ranked:v}=qs(i,u,a),y=o.find(e=>e.name===Rw),b=zs(o,u).filter(e=>e.name!==Rw),x=o.some(e=>e.name!==Rw),S=fE(y,u),C=dE(S,{ranked:v,mostUsed:h,project:g,global:_},b),w=e=>{s(e),l(!1)},T=t=>w(e?.source===t.source&&e.ref===t.ref&&(e.source!==`skill`||t.source!==`skill`||e.path===t.path)?null:t),E=(t,n)=>{let r=e?.source===`skill`&&e.ref===t.id&&e.path===t.path;return(0,Q.jsxs)(As,{value:Bs(t),keywords:Ws(t.name,t.description),"data-slot":`source-option`,"data-source-kind":`skill`,"data-source-ref":t.id,onSelect:()=>T({source:`skill`,ref:t.id,...t.path===void 0?{}:{path:t.path}}),children:[(0,Q.jsx)(lx,{skill:t,emphasized:n}),(0,Q.jsx)(`button`,{type:`button`,"data-slot":`source-skill-view`,"aria-label":`View skill ${t.name}`,title:`View skill`,onClick:e=>{e.preventDefault(),e.stopPropagation(),p(t)},className:`ml-auto shrink-0 rounded-sm p-0.5 text-soft-foreground transition-colors hover:text-foreground`,children:(0,Q.jsx)(ba,{"aria-hidden":`true`,className:`size-3.5`})}),r?(0,Q.jsx)(Ni,{"aria-hidden":`true`,className:`size-3.5 shrink-0 text-link-foreground`}):null]},Bs(t))},D=mE({source:e,ready:n,offersWorkflows:x,onPick:s,skillLabel:e?.source===`skill`?i.find(t=>t.id===e.ref&&(e.path===void 0||e.path===t.path))?.name:void 0});return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(VC,{skill:f,onClose:()=>p(null)}),(0,Q.jsxs)(po,{open:c,onOpenChange:e=>{l(e),e||d(``)},children:[(0,Q.jsxs)(`span`,{className:`inline-flex items-center`,children:[(0,Q.jsx)(co,{asChild:!0,children:D}),e?.source===`skill`&&t?(0,Q.jsx)(`span`,{role:`status`,children:`Unchecked`}):null,e!==null&&n?(0,Q.jsx)(`button`,{type:`button`,"data-slot":`source-pill-clear`,"aria-label":`Clear the ${e.source} ${e.ref}`,title:`Run without it`,onClick:()=>s(null),className:q(vC,`new-task-source-clear justify-center rounded-l-none border-foreground/60 px-2 text-soft-foreground hover:text-foreground`),children:(0,Q.jsx)(Fi,{"aria-hidden":`true`,className:`size-3`})}):null]}),(0,Q.jsx)(uo,{align:`start`,sideOffset:8,className:`w-[336px] max-w-[calc(100vw-2rem)] p-0`,children:(0,Q.jsxs)(Ns,{shouldFilter:!1,children:[(0,Q.jsx)(Ts,{placeholder:`search skills & workflows…`,value:u,onValueChange:d,onInput:()=>m.current?.scrollTo(0,0)}),(0,Q.jsxs)(Ms,{ref:m,"data-slot":`source-menu`,"aria-busy":r,className:`max-h-[min(18rem,calc(var(--radix-popover-content-available-height)-3rem))]`,children:[u.trim()&&!i.some(e=>e.id===u.trim())?(0,Q.jsx)(Ds,{children:(0,Q.jsxs)(As,{value:`typed-skill`,onSelect:()=>w({source:`skill`,ref:u.trim(),typed:!0}),children:[`Use skill id “`,u.trim(),`” (unchecked)`]})}):null,C&&!r?(0,Q.jsx)(js,{children:`Nothing matches.`}):null,S?(0,Q.jsx)(hE,{source:e,quickTask:y,onPick:w}):null,r?(0,Q.jsx)(`div`,{"data-slot":`source-skills-loading`,role:`status`,className:`px-2 py-1.5 text-xs text-muted-foreground`,children:`Loading skills…`}):null,(0,Q.jsx)(gE,{ranked:v,mostUsed:h,project:g,skillItem:E}),(0,Q.jsx)(_E,{source:e,matchedWorkflows:b,toggle:T}),(0,Q.jsx)(vE,{global:_,skillItem:E})]})]})})]})]})}function bE(){let[e,t]=Z.useState(!1),[n,r]=Z.useState(!1),[i,a]=Z.useState(!1);return(0,Q.jsxs)(ds,{route:`no-projects`,density:`empty`,children:[(0,Q.jsx)(tc,{icon:(0,Q.jsx)(pi,{}),tone:`neutral`,title:`No projects yet`,subtitle:`Open a local folder, clone a repository from GitHub, or create a new project to start running tasks.`,children:(0,Q.jsxs)(`div`,{"data-slot":`no-projects-actions`,className:`flex flex-wrap items-center justify-center gap-2`,children:[(0,Q.jsxs)(Y,{type:`button`,variant:`primary`,"data-action":`empty-open-local`,onClick:()=>t(!0),children:[(0,Q.jsx)(ai,{"aria-hidden":`true`}),`Open local folder…`]}),(0,Q.jsxs)(Y,{type:`button`,variant:`outline`,"data-action":`empty-clone-github`,onClick:()=>r(!0),children:[(0,Q.jsx)(di,{"aria-hidden":`true`}),`Clone from GitHub…`]}),(0,Q.jsxs)(Y,{type:`button`,variant:`outline`,"data-action":`empty-create-project`,onClick:()=>a(!0),children:[(0,Q.jsx)(pi,{"aria-hidden":`true`}),`New project…`]})]})}),e?(0,Q.jsx)(Hu,{open:!0,onOpenChange:t}):null,n?(0,Q.jsx)(Ku,{open:!0,onOpenChange:r}):null,i?(0,Q.jsx)(ld,{open:!0,onOpenChange:a}):null]})}function xE(){return(0,Q.jsx)(ds,{route:`not-found`,density:`empty`,header:{title:`Page not found`,subtitle:`Nothing lives at this address.`,primaryAction:(0,Q.jsx)(cs,{asChild:!0,variant:`outline`,children:(0,Q.jsx)(X,{to:`/`,children:`Back to tasks`})})},emptyState:(0,Q.jsx)(gs,{icon:(0,Q.jsx)(Uc,{className:`size-4`}),title:`Address not found`,description:`The link may be mistyped, or it points at something that is gone.`})})}function SE(){return(0,Q.jsx)(`div`,{className:`px-4 pt-2 md:hidden`,children:(0,Q.jsxs)(X,{to:`/git`,"data-slot":`git-back`,className:`inline-flex min-h-11 items-center gap-1.5 text-xs font-medium text-muted-foreground hover:text-foreground`,children:[(0,Q.jsx)(Vi,{size:16,"aria-hidden":`true`,className:`size-3.5`}),`Back to Git`]})})}function CE(){let{pathname:e,search:t}=qn();return(0,Q.jsxs)(_s,{route:`repo-git`,density:`sparse`,flushPadding:!0,children:[Oo(e)!==`/git`||new URLSearchParams(t).get(`view`)===`repo`?(0,Q.jsx)(SE,{}):null,(0,Q.jsx)(tc,{icon:(0,Q.jsx)(xa,{className:`motion-safe:animate-spin`}),tone:`neutral`,title:`Loading repository…`,subtitle:`Fetching the repo's git state.`})]})}function wE(){return(0,Q.jsxs)(ls,{route:`skills`,density:`sparse`,rootProps:{"aria-busy":`true`},header:{title:`Skills`,subtitle:`The skills each agent loads in this project, as its runner reports them.`},children:[(0,Q.jsx)(`p`,{"data-slot":`skills-loading`,role:`status`,className:`text-xs text-muted-foreground`,children:`Loading skills…`}),(0,Q.jsxs)(`div`,{"aria-hidden":`true`,className:`mt-4 flex flex-col gap-[22px] motion-safe:animate-pulse`,children:[(0,Q.jsx)(`div`,{className:`h-11 rounded-lg border border-border bg-card`}),(0,Q.jsx)(`div`,{className:`h-80 rounded-xl border border-border bg-card`})]})]})}function TE({projectId:e,registry:t}){let n=t.projects.length?t.projects:t.bootProject===null?[]:[{id:t.bootProject,name:t.bootProject}];return(0,Q.jsx)(ds,{route:`unknown-project`,density:`empty`,children:(0,Q.jsx)(tc,{icon:(0,Q.jsx)(Qc,{}),tone:`neutral`,title:`“${e}” isn’t registered here`,subtitle:n.length>0?`This Squawk doesn’t serve a project by that id. The link may come from another machine’s workspace — these are the projects registered on this one:`:`This Squawk doesn’t serve a project by that id, and no projects are registered on this server yet.`,children:n.length>0?(0,Q.jsx)(`ul`,{"data-slot":`registered-projects`,className:`mx-auto flex w-full max-w-xs flex-col gap-1.5 text-left`,children:n.map(e=>(0,Q.jsx)(`li`,{children:(0,Q.jsxs)(G,{to:`/p/${encodeURIComponent(e.id)}/`,className:`flex items-baseline gap-2 rounded-md border border-border bg-card px-3 py-2 text-sm font-medium text-foreground shadow-xs transition-colors hover:bg-card-2`,children:[e.name||e.id,(0,Q.jsxs)(`span`,{className:`font-mono text-xs font-normal text-muted-foreground`,children:[`/p/`,e.id]})]})},e.id))}):(0,Q.jsx)(Y,{asChild:!0,variant:`primary`,children:(0,Q.jsx)(G,{to:`/`,children:`Add a project`})})})})}function EE(){return(0,Q.jsxs)(_s,{route:`workflows`,density:`sparse`,rootProps:{"aria-busy":`true`},header:{title:`Workflows`,subtitle:`Portable skill chains. Steps run from top to bottom.`},children:[(0,Q.jsx)(`p`,{"data-slot":`workflows-loading`,role:`status`,className:`text-xs text-muted-foreground`,children:`Loading workflows…`}),(0,Q.jsxs)(`div`,{"aria-hidden":`true`,className:`mt-4 flex flex-col gap-[22px] motion-safe:animate-pulse`,children:[(0,Q.jsx)(`div`,{className:`h-11 rounded-lg border border-border bg-card`}),(0,Q.jsx)(`div`,{className:`h-80 rounded-xl border border-border bg-card`})]})]})}function DE({tab:e}){return(0,Q.jsx)(ds,{route:`task-${e}`,density:`sparse`,flushPadding:!0,children:(0,Q.jsx)(tc,{icon:(0,Q.jsx)(xa,{className:`motion-safe:animate-spin`}),tone:`neutral`,title:e===`changes`?`Loading changes…`:`Loading files…`,subtitle:`Fetching the run record.`})})}function OE({tab:e,error:t}){let n=t instanceof Tn&&t.status===404;return(0,Q.jsx)(ds,{route:`task-${e}`,density:`empty`,flushPadding:!0,children:(0,Q.jsx)(tc,{icon:n?(0,Q.jsx)(Ca,{}):(0,Q.jsx)(wi,{size:16}),tone:n?`neutral`:`danger`,title:n?`Task not found`:`Could not load this task`,subtitle:n?`No run has this id. It may have been deleted, or the link is from another machine.`:t.message,actions:(0,Q.jsx)(Y,{asChild:!0,variant:`outline`,children:(0,Q.jsx)(X,{to:`/`,children:`Back to tasks`})})})})}var kE={issue:`issue`,pr:`pull request`};function AE({kind:e,number:t,heading:n=`h1`}){let r=(0,Q.jsx)(`div`,{"data-slot":`task-github-loading`,className:`flex min-h-full flex-1 flex-col`,children:(0,Q.jsx)(tc,{icon:(0,Q.jsx)(xa,{className:`motion-safe:animate-spin`}),tone:`neutral`,heading:n,title:`Loading ${kE[e]}${t===void 0?``:` #${t}`}…`,subtitle:t===void 0?`Fetching the run record.`:`Asking GitHub.`})});return n===`h2`?r:(0,Q.jsx)(ds,{route:`task-github-item`,density:`sparse`,flushPadding:!0,children:r})}function jE(){return(0,Q.jsx)(ds,{route:`task-thread`,density:`sparse`,flushPadding:!0,children:(0,Q.jsx)(tc,{icon:(0,Q.jsx)(xa,{className:`motion-safe:animate-spin`}),tone:`neutral`,title:`Loading task…`,subtitle:`Fetching the run and its session transcript.`})})}var ME=(0,Z.createContext)(null),NE=/^[0-9a-f-]{36}$/i,PE=/^(\/p\/[^/?#]+\/tasks\/[^/?#]+)\/files\?(artifact=[^&#]*)$/;function FE(e){let t=new URLSearchParams(e);return[...t.keys()].length===1&&NE.test(t.get(`artifact`)??``)}function IE(e,t,n){if(e.startsWith(`${t}?artifact=`))return FE(e.slice(t.length+1))?n+e.slice(t.length):null;let r=PE.exec(e);return r&&FE(r[2])?`${r[1]}/report?${r[2]}`:void 0}var LE=/^\/(?:api|p|tasks|new|settings|skills|workflows|git|github|inbox|automations)(?:\/|[?#]|$)/;function RE(e,t){let n=/^[a-z]:[\\/]/i.test(e),r=/^file:/i.test(e);if(!n&&/^[a-z][a-z\d+.-]*:/i.test(e)&&!r)return null;let i=r?e:decodeURIComponent(e);if(/[\u0000-\u001f]/.test(i))return null;if(!t||i.startsWith(`/`)||n||r)return i;let a=t.replaceAll(`\\`,`/`);return a.slice(0,a.lastIndexOf(`/`)+1)+i}function zE(e,t){if(!e||/[\u0000-\u001f]/.test(e)||e.startsWith(`#`)||e.startsWith(`//`))return null;let n=e.indexOf(`#`),r=n<0?e:e.slice(0,n),i=n<0?``:e.slice(n),a=t.projectId?`/p/${encodeURIComponent(t.projectId)}`:``,o=`/tasks/${encodeURIComponent(t.runId)}/files`,s=`/tasks/${encodeURIComponent(t.runId)}/report`,c=IE(r,o,a+s);if(c!==void 0)return c===null?null:c+i;if(LE.test(r))return null;let l=RE(r,t.basePath);return l===null?null:`${a}${nc(l)?s:o}?path=${encodeURIComponent(l)}${i}`}function BE(e,t){let n=e.replace(/^\.\//,``);if(!t)return n;let r=`${t.replace(/\/+$/,``)}/`;return n.startsWith(r)?n.slice(r.length):n}function VE(e,t=!1){return e.status===`review`&&!t&&!at(e)}var HE=e=>`${e} ${e===1?`check`:`checks`}`;function UE(e){let t=e.steps.filter(e=>e.kind===`check`),n=t.filter(e=>e.status===`done`).length,r=t.filter(e=>e.status===`failed`).length,i=r>0?`${HE(r)} failed${n>0?`, ${n} passed`:``}`:n>0?`${HE(n)} passed`:void 0;return{...e.diffStat&&e.diffStat.files>0?{diff:e.diffStat}:{},...i===void 0?{}:{checks:{label:i,failed:r>0}}}}async function WE(e,t,n,r,i){try{return await vc(e,{queryKey:[t,`runs`,`artifact-metadata`,n,r],queryFn:({signal:e})=>wn(n,r,{signal:e})},i),!0}catch(e){if(e instanceof Tn&&e.status===404)return!1;throw e}}async function GE(e,t,n,r,i,a){if(await WE(e,t,n,r,i))return n;i.throwIfAborted();let o=await vc(e,{queryKey:[t,`runs`,`relationships`,n],queryFn:({signal:e})=>pt(n,{signal:e})},i),s=new Set(o.workers.map(e=>e.workerId));a&&s.add(a),s.delete(n);for(let n of s){if(i.aborted)throw i.reason;if(await WE(e,t,n,r,i))return n}throw new Tn(404,`Report missing or deleted`)}function KE(e,t,n){let r=U(),i=Ie();return Jt({queryKey:[i,`runs`,`report-source`,e,t,n],queryFn:({signal:a})=>GE(r,i,e,t,a,n),enabled:!!(e&&t),retry:!1})}var qE=`cez-preview-tasks`,JE=`cez.preview.pane-width`,YE=e=>Math.min(75,Math.max(30,Math.round(e)));function XE(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function ZE(e){if(!XE(e))return;let{port:t,agent:n,url:r}=e;if(typeof t==`number`&&Number.isInteger(t)&&t>=1&&t<=65535)return{port:t};if(n===!0)return{agent:!0};if(typeof r==`string`&&/^https?:\/\//i.test(r))return{url:r}}function QE(e){if(!XE(e))return;let t=ZE(e.target),n=typeof e.percent==`number`&&Number.isFinite(e.percent)?e.percent:void 0;return{open:e.open===!0,...t?{target:t}:{},...n===void 0?{}:{percent:n},at:typeof e.at==`number`?e.at:0}}function $E(){try{let e=localStorage.getItem(qE),t=e===null?null:JSON.parse(e);return XE(t)?t:{}}catch{return{}}}function eD(e){let t=QE($E()[e]);if(!t)return;let{at:n,...r}=t;return r}function tD(e,t,n=Date.now()){let r=$E(),i={open:!1,...QE(r[e]),...t,at:n};for(let e of Object.keys(i))i[e]===void 0&&delete i[e];r[e]=i;let a=Object.keys(r);if(a.length>100){let e=e=>QE(r[e])?.at??0;for(let t of a.sort((t,n)=>e(t)-e(n)).slice(0,a.length-100))delete r[t]}try{localStorage.setItem(qE,JSON.stringify(r))}catch{}}function nD(){try{let e=Number(localStorage.getItem(JE));return e>0?e:void 0}catch{return}}function rD(e){let t=(e===void 0?void 0:eD(e)?.percent)??nD();return t===void 0?58:YE(t)}function iD(e,t){try{localStorage.setItem(JE,String(t))}catch{}e!==void 0&&tD(e,{percent:t})}var aD=`cez-split-workbench`;function oD(){try{return localStorage.getItem(aD)===`on`}catch{return!1}}function sD(e){try{e?localStorage.setItem(aD,`on`):localStorage.removeItem(aD)}catch{}}var cD=`(min-width: 1180px)`,lD=`(min-width: 1280px)`,uD=`(max-width: 767px)`;function dD(e,t){let[n,r]=(0,Z.useState)(()=>window.matchMedia?.(e).matches??t);return(0,Z.useEffect)(()=>{let t=window.matchMedia?.(e);if(!t)return;let n=()=>r(t.matches);return n(),t.addEventListener(`change`,n),()=>t.removeEventListener(`change`,n)},[e]),n}function fD(e){if(!e.worktreePath||e.worktreeReclaimedAt)return!0;let t=e.delegation?.role===`worker`?e.delegation.destroy:void 0;return t!==void 0&&!t.remaining.includes(`worktree`)}function pD(e){let{state:t,server:n}=e,r=ys(e.stateAt);switch(t){case`registered`:return n.answeredAtRegistration?{tone:`neutral`,ring:!1,pulse:!1,text:`was running when registered`}:{tone:`neutral`,ring:!0,pulse:!1,text:`registered · not started`};case`adopted`:return{tone:`neutral`,ring:!1,pulse:!1,text:`was running when registered`};case`starting`:return{tone:`pending`,ring:!1,pulse:!0,text:`starting`};case`up`:return{tone:`success`,ring:!1,pulse:!1,text:r?`up · ${r}`:`up`};case`stalled`:return{tone:`pending`,ring:!1,pulse:!1,text:`stalled · port silent 2 min`};case`exited`:return{tone:`danger`,ring:!1,pulse:!1,text:e.exitCode===void 0?`exited`:`exited · code ${e.exitCode}`};case`stopped`:return{tone:`neutral`,ring:!0,pulse:!1,text:e.reason===`idle`?`stopped after 15 min idle`:`stopped`};case`unavailable`:return{tone:`neutral`,ring:!0,pulse:!1,text:`unavailable`}}}function mD(e){return{kind:`preview-server`,id:`preview-server:${e.port}`,server:e,state:`registered`,stateAt:e.registeredAt}}function hD(e,t){return t?.get(e.port)??mD(e)}function gD(e){return e.state===`registered`?e.server.answeredAtRegistration:e.state===`up`||e.state===`starting`||e.state===`adopted`}function _D(e){return e.split(` -- `)[0].trim()}var vD=(0,Z.createContext)(null);function yD(){return(0,Z.useContext)(vD)}function bD(e){return e.report?`report`:e.preview?`preview`:e.changes?`changes`:null}var xD=(0,Z.createContext)(null);function SD(){return(0,Z.useContext)(xD)}var CD=e=>e&&`port`in e?e.port:void 0;function wD(){return typeof window.matchMedia!=`function`||window.matchMedia(`(min-width: 1180px)`).matches}function TD(e){let t=e===void 0?void 0:eD(e),n=t?.open===!0,r=n?t.target:void 0;return{open:n,target:r,request:n?{...r,restored:!0}:void 0,session:n&&!wD(),percent:rD(e)}}function ED(e,t=!1){let[n]=(0,Z.useState)(()=>TD(e)),[r,i]=(0,Z.useState)(n.open),[a,o]=(0,Z.useState)(!1),[s,c]=(0,Z.useState)(n.target),[l,u]=(0,Z.useState)(n.session),[d,f]=(0,Z.useState)(n.request),[p,m]=(0,Z.useState)(n.percent),[h,g]=(0,Z.useState)(oD),[_,v]=(0,Z.useState)(e),y=(0,Z.useRef)(r);if(y.current=r,_!==e){let t=TD(e);v(e),i(t.open),o(!1),c(t.target),u(t.session),f(t.request),m(t.percent)}t&&r&&d?.restored&&(i(!1),c(void 0),f(void 0),u(!1));let b=(0,Z.useCallback)(t=>{e!==void 0&&tD(e,t)},[e]),x=(0,Z.useRef)(h);x.current=h;let S=(0,Z.useCallback)(e=>{g(e),sD(e)},[]),C=(0,Z.useCallback)(e=>{x.current&&S(!1),f({...e});let t=e.port===void 0?e.agent?{agent:!0}:void 0:{port:e.port};u(!1),i(!0),t?(c(t),b({open:!0,target:t})):y.current?b({open:!0}):(c(void 0),b({open:!0,target:void 0}))},[b,S]),w=(0,Z.useCallback)(()=>{i(!1),o(!1),u(!1),c(void 0),b({open:!1})},[b]),T=(0,Z.useCallback)(e=>{c(e),b({target:e})},[b]),E=(0,Z.useCallback)(t=>{m(t),iD(e,t)},[e]),D=(0,Z.useCallback)(()=>u(!0),[]),O=CD(s),k=(0,Z.useCallback)(e=>{e&&y.current&&w(),S(e)},[w,S]);return(0,Z.useMemo)(()=>({open:r,live:a,port:O,target:s,percent:p,request:d,session:l,changes:h,openPane:C,closePane:w,showSession:D,setLive:o,setTarget:T,setPercent:E,setChanges:k}),[r,a,O,s,p,d,l,h,C,w,D,T,E,k])}var DD=(0,Z.lazy)(()=>W(()=>import(`./preview-pane-connected-Km1_yTQu.js`).then(e=>({default:e.ConnectedPreviewPane})),__vite__mapDeps([76,1,2,7,8,9,10,11,16,77,78,79,80,42,81,82,60,83,84,85,20,43,44,15,24,31,33,34,46,13,14,25,26,86,87,88]))),OD=2,kD=(0,Z.createContext)(null);function AD(){return(0,Z.useContext)(kD)!==null}function jD(){return(0,Z.useContext)(kD)}function MD(e){let[t,n]=(0,Z.useState)(void 0);return(0,Z.useEffect)(()=>{let t=e.current?.closest(`[data-slot="main"]`);if(!t)return;let r=()=>n(t.clientHeight||void 0);if(r(),typeof ResizeObserver>`u`)return;let i=new ResizeObserver(r);return i.observe(t),()=>i.disconnect()},[e]),t}function ND({run:e,state:t,children:n,report:r,changes:i}){let a=dD(cD,!0),o=dD(uD,!1),s=(0,Z.useRef)(null),c=MD(s),{percent:l,setPercent:u}=t,d=bD({report:!!r,preview:t.open&&e!==void 0,changes:!!i}),f=d!==null,p=f&&!a,m=!r&&t.session,h=p&&!m,g=p&&m,_={"--preview-pane":`${l}%`,...c===void 0?{}:{"--preview-h":`${c}px`}};return(0,Q.jsxs)(`div`,{ref:s,"data-slot":`task-split`,"data-pane":f?`open`:`closed`,"data-takeover":h?``:void 0,className:`preview-split flex min-h-full w-full min-w-0`,style:_,children:[(0,Q.jsx)(`div`,{"data-slot":`task-main`,hidden:h&&o,"data-collapsed":h&&!o?``:void 0,className:`min-w-0 flex-1`,children:(0,Q.jsx)(kD.Provider,{value:d,children:n})}),f?(0,Q.jsxs)(Q.Fragment,{children:[a?(0,Q.jsx)(PD,{wrapper:s,percent:l,setPercent:u,label:d===`changes`?`Resize changes`:`Resize preview`}):null,(0,Q.jsxs)(`aside`,{"data-slot":`preview-pane`,"data-kind":d,"data-phone":o?``:void 0,hidden:g,className:`preview-pane`,children:[r,d===`changes`?i:null,(0,Q.jsx)(`div`,{hidden:d!==`preview`,className:`h-full`,children:t.open&&e?(0,Q.jsx)(FD,{run:e,state:t,inFront:h}):null})]})]}):null]})}function PD({wrapper:e,percent:t,setPercent:n,label:r}){let i=t=>{let r=e.current?.getBoundingClientRect();!r||r.width===0||n(YE((r.right-t)/r.width*100))};return(0,Q.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,"aria-label":r,"aria-valuemin":30,"aria-valuemax":75,"aria-valuenow":t,tabIndex:0,"data-slot":`preview-divider`,className:`preview-divider`,onPointerDown:e=>{e.currentTarget.setPointerCapture?.(e.pointerId)},onPointerMove:e=>{e.currentTarget.hasPointerCapture?.(e.pointerId)&&i(e.clientX)},onKeyDown:e=>{if(e.key===`ArrowLeft`)n(YE(t+OD));else if(e.key===`ArrowRight`)n(YE(t-OD));else return;e.preventDefault()}})}function FD({run:e,state:t,inFront:n}){return(0,Q.jsx)(wa,{onClose:t.closePane,children:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(`p`,{role:`status`,className:`p-6 text-sm text-muted-foreground`,children:`Opening the preview…`}),children:(0,Q.jsx)(DD,{run:e,servers:e.previewServers??[],request:t.request,onSession:n?t.showSession:void 0,onTarget:t.setTarget,onLive:t.setLive,onClose:t.closePane},e.id)})})}function ID(e){for(let t=e.length-1;t>=0;--t){let n=Ke.safeParse(e[t]);if(n.success)return n.data.state===`connected`}return!1}function LD(e){let{currentEvents:t}=Ea(e);return(0,Z.useMemo)(()=>ID(t),[t])}var RD=(0,Z.lazy)(()=>W(()=>import(`./report-reader-BXPtT3jw.js`).then(e=>({default:e.ReportReader})),__vite__mapDeps([89,1,2,6,7,8,9,10,11,12,13,14,15,90,16,91,20,44,24,31,33,34,28,92,51,45,93,94,95,96]))),zD=(0,Z.lazy)(()=>W(()=>import(`./review-strip-lK-KV-Bh.js`).then(e=>e.n).then(e=>({default:e.ReviewStrip})),__vite__mapDeps([97,1,2,6,7,8,9,10,11,12,13,14,15,16,41,98,20,46,57,99,100,101,56,102]))),BD=(0,Z.lazy)(()=>W(()=>import(`./review-panel-WjhjBT-O.js`).then(e=>e.n).then(e=>({default:e.AcceptCelebration})),__vite__mapDeps([103,1,2,6,7,8,9,10,11,12,97,13,14,15,16,41,98,20,46,57,99,100,101,56,102,28,104,18,105,24,51,45,106,21]))),VD=(0,Z.lazy)(()=>W(()=>import(`./task-changes-BZiv3oW9.js`).then(e=>({default:e.ChangesPane})),__vite__mapDeps([107,1,2,6,7,8,9,10,11,12,13,14,15,108,109,62,24,33,34,100,101,16,87,40,26,41,19,42,43,20,44,31,45,81,110,22,23,46,25,88,56,57,93,94,95,51,111,112,113,114,91,115,116,64,65,28,117,106,21,102,118,119,120,121,122,123])));function HD(){let{id:e}=Hn(),t=j(e),n=qn(),r=Sm(c().data),i=t.data?fD(t.data):!1,a=ED(e,i),o=ns(e),s=KE(e,o.selection?.artifactId,o.sourceRunId),l=o.selection?(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(`p`,{role:`status`,children:`Loading report…`}),children:(0,Q.jsx)(RD,{runId:s.data??e??``,selection:{artifactId:o.selection.artifactId},fragment:n.hash,onBack:o.close,variant:`pane`,sourceLookup:s},`${e}:${o.selection.artifactId}`)}):void 0,{workbench:u,changes:d}=KD(t.data,a,o,{previewOpen:r&&a.open,reportOpen:l!==void 0}),f=r?(0,Q.jsx)(qD,{id:e,run:t.data,pane:a,removed:i,report:l,changes:d,children:(0,Q.jsx)(Bn,{})}):(0,Q.jsx)(ND,{run:t.data,state:{...a,open:!1},report:l,changes:d,children:(0,Q.jsx)(Bn,{})}),p=t.data&&VE(t.data)&&!UD.test(n.pathname)?t.data:void 0;return(0,Q.jsxs)(as.Provider,{value:o.registry,children:[(0,Q.jsx)(xD.Provider,{value:u,children:(0,Q.jsxs)(`div`,{"data-slot":`task-layout`,children:[f,p?(0,Q.jsx)(Z.Suspense,{fallback:null,children:(0,Q.jsx)(zD,{run:p},p.id)}):null]})}),t.data?(0,Q.jsx)(Z.Suspense,{fallback:null,children:(0,Q.jsx)(BD,{status:t.data.status},t.data.id)}):null]})}var UD=/\/report\/?$/,WD=/\/tasks\/[^/]+\/?$/,GD=/\/tasks\/[^/]+\/changes\/?$/;function KD(e,t,n,r){let i=qn(),a=Kn(),o=dD(lD,!1),s=(0,Z.useRef)(null),c=WD.test(i.pathname),l=o&&c&&t.changes?e:void 0,u=l!==void 0&&bD({report:r.reportOpen,preview:r.previewOpen,changes:!0})===`changes`,{setChanges:d}=t,f=n.close,p=(0,Z.useMemo)(()=>({available:o,showing:u,setOn:e=>{d(e),e&&(GD.test(i.pathname)?a(i.pathname.replace(/\/changes\/?$/,``)):r.reportOpen&&f())},revealChange:t=>u&&(s.current?.(BE(t,e?.worktreePath))??!1)}),[o,u,d,i.pathname,a,r.reportOpen,f,e?.worktreePath]);return{workbench:p,changes:l?(0,Q.jsxs)(`div`,{"data-slot":`changes-split-pane`,"data-scroll-root":!0,className:`h-full overflow-y-auto overscroll-contain`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-2 border-b border-border bg-background ps-4 pe-1 md:ps-9`,children:[(0,Q.jsx)(`h2`,{className:`text-xs font-semibold`,children:`Changes`}),(0,Q.jsx)(Y,{variant:`ghost`,size:`icon`,"aria-label":`Close split view`,onClick:()=>p.setOn(!1),children:(0,Q.jsx)(Fi,{"aria-hidden":`true`})})]}),(0,Q.jsx)(`div`,{className:`pt-4`,children:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(`p`,{role:`status`,className:`p-6 text-sm text-muted-foreground`,children:`Loading changes…`}),children:(0,Q.jsx)(VD,{run:l,revealRef:s},l.id)})})]}):void 0}}function qD({id:e,run:t,pane:n,removed:r,children:i,report:a,changes:o}){let s=LD(e),c=(0,Z.useMemo)(()=>({...n,worktreeRemoved:r,agentLive:s}),[n,r,s]);return(0,Q.jsx)(vD.Provider,{value:c,children:(0,Q.jsx)(ND,{run:t,state:n,report:a,changes:o,children:i})})}var JD=[`task`,`runner`,`workflow`,`branch`,`diff`,`reference`,`usage`,`started`],YD=[`status`,`task`,`workflow`,`branch`,`diff`,`reference`,`tokens`,`cost`,`cpu`,`memory`,`started`],XD=[{id:`status`,label:`Status`,canFold:!1,defaultExpanded:!0,align:`left`,width:`180px`},{id:`task`,label:`Task`,canFold:!1,defaultExpanded:!0,align:`left`,width:`320px`},{id:`runner`,label:`Runner`,canFold:!0,defaultExpanded:!1,align:`left`,width:`132px`,icon:`runner`},{id:`workflow`,label:`Workflow`,canFold:!0,defaultExpanded:!0,align:`left`,width:`108px`,icon:`workflow`},{id:`branch`,label:`Branch`,canFold:!0,defaultExpanded:!1,align:`left`,width:`76px`,icon:`branch`},{id:`diff`,label:`±`,summaryLabel:`Changes`,canFold:!0,defaultExpanded:!0,align:`left`,width:`80px`,resourceWidth:`70px`,icon:`diff`},{id:`reference`,label:`Ref`,summaryLabel:`Reference`,canFold:!0,defaultExpanded:!0,align:`left`,width:`76px`,icon:`reference`},{id:`usage`,label:`Usage`,canFold:!0,defaultExpanded:!0,align:`right`,width:`144px`,icon:`usage`},{id:`tokens`,label:`IN / OUT`,canFold:!0,defaultExpanded:!0,align:`right`,width:`96px`,icon:`tokens`,capability:`tokens`},{id:`cost`,label:`Cost`,canFold:!0,defaultExpanded:!0,align:`right`,width:`52px`,icon:`cost`,capability:`cost`},{id:`cpu`,label:`CPU`,canFold:!0,defaultExpanded:!0,align:`right`,width:`42px`,icon:`cpu`},{id:`memory`,label:`Mem`,canFold:!0,defaultExpanded:!0,align:`right`,width:`80px`,icon:`memory`},{id:`started`,label:`Started`,canFold:!0,defaultExpanded:!0,align:`right`,width:`64px`,resourceWidth:`42px`,icon:`started`}],ZD=new Map(XD.map(e=>[e.id,e]));function QD(e){return typeof e!=`object`||!e||Array.isArray(e)?{}:Object.fromEntries(Object.entries(e).filter(e=>typeof e[1]==`boolean`))}function $D(e){let t={};for(let[n,r]of Object.entries(QD(e))){let e=ZD.get(n);e?.canFold&&(t[e.id]=r)}return t}function eO(e,t){let n=ZD.get(e);return!n||!n.canFold?!0:t[e]??n.defaultExpanded}function tO(e,t){let n=QD(e);return ZD.get(t)?.canFold?{...n,[t]:!eO(t,$D(e))}:n}var nO=new Set(YD),rO=new Set(JD);function iO(){return XD.filter(e=>rO.has(e.id))}function aO(e){return XD.filter(t=>nO.has(t.id)&&(t.capability===void 0||e[t.capability]))}function oO(e,t){return t===`flat`?!1:t===`virtual`||e>=100}function sO(e,t){let n=t===null?-1:e.indexOf(t);return n<0?[]:[n-1,n,n+1].filter(t=>t>=0&&t<e.length)}function cO(e,t){let n=e.map(e=>eO(e.id,t)?Number.parseFloat(e.resourceWidth??e.width??`100`):42);return{"--task-columns":e.map((e,t)=>e.id===`task`?`minmax(220px, 1fr)`:`${n[t]}px`).join(` `),minInlineSize:n.reduce((t,n,r)=>t+(e[r]?.id===`task`?220:n),0)}}var lO=null,{min:uO,max:dO,abs:fO,floor:pO}=Math,mO=(e,t,n)=>uO(n,dO(t,e)),hO=e=>[...e].sort((e,t)=>e-t),gO=typeof queueMicrotask==`function`?queueMicrotask:e=>{Promise.resolve().then(e)},_O=()=>{let e;return[new Promise(t=>{e=t}),e]},vO=e=>{let t;return()=>(e&&=(t=e(),void 0),t)},yO=(e,t,n)=>{let r=n?`unshift`:`push`;for(let n=0;n<t;n++)e[r](-1);return e},bO=(e,t)=>{let n=e.t[t];return n===-1?e.o:n},xO=(e,t,n)=>{let r=e.t[t]===-1;return e.t[t]=n,e.i=uO(t,e.i),r},SO=(e,t)=>{if(!e.l)return 0;if(e.i>=t)return e.u[t];e.i<0&&(e.u[0]=0,e.i=0);let n=e.i,r=e.u[n];for(;n<t;)r+=bO(e,n),e.u[++n]=r;return e.i=t,r},CO=(e,t,n=0,r=e.l-1)=>{let i=n;for(;n<=r;){let a=pO((n+r)/2);SO(e,a)<=t?(i=a,n=a+1):r=a-1}return mO(i,0,e.l-1)},wO=(e,t,n)=>{let r=t-e.l;return e.i=n?-1:uO(t-1,e.i),e.l=t,r>0?(yO(e.u,r),yO(e.t,r,n),e.o*r):(e.u.splice(r),(n?e.t.splice(0,-r):e.t.splice(r)).reduce((t,n)=>t-(n===-1?e.o:n),0))},TO=typeof window<`u`,EO=e=>e.documentElement,DO=e=>e.ownerDocument,OO=e=>e.defaultView,kO=vO(()=>!!/iP(hone|od|ad)/.test(navigator.userAgent)||navigator.platform===`MacIntel`&&navigator.maxTouchPoints>0),AO=vO(()=>`scrollBehavior`in EO(document).style),jO=e=>dO(e.h(),e.p()),MO=(e,t=40,n=0,r,i=!1)=>{let a=!!n,o=1,s=0,c=0,l=0,u=0,d=0,f=0,p=0,m=0,h=lO,g=[0,a?dO(n-1,0):-1],_=0,v=!1,y=((e,t,n)=>({o:t,t:n?yO(n.slice(0,uO(e,n.length)),dO(0,e-n.length)):yO([],e),l:e,i:-1,u:yO([],e+1)}))(e,r?r[1]:t,r&&r[0]),b=new Set,x=()=>l-c,S=()=>x()+d+u,C=(e,t)=>((e,t,n,r)=>{if(r=uO(r,e.l-1),SO(e,r)<=t){let i=CO(e,n,r);return[CO(e,t,r,i),i]}{let i=CO(e,t,void 0,r);return[i,CO(e,n,i)]}})(y,e,t,g[0]),w=()=>SO(y,y.l),T=(e,t)=>{let n=SO(y,e)-d;return t?w()-n-E(e):n},E=e=>bO(y,e),D=(e,t=-1)=>y.t[e]===t,O=e=>{e&&(kO()&&p!==0||h&&m===1?d+=e:u+=e)};return{v:()=>{b.clear()},m:()=>o,_:()=>(e=>[e.t.slice(),e.o])(y),S:(e=200)=>{if(!v||a)return g;let t,n;if(f)[t,n]=g;else{let r=dO(0,S()),a=r+s;i||(e=dO(0,e),p!==1&&(r-=e),p!==2&&(a+=e)),[t,n]=g=C(dO(0,r),dO(0,a)),h&&(t=uO(t,h[0]),n=dO(n,h[1]))}return[dO(t,0),uO(n,y.l-1)]},$:e=>CO(y,e-c),I:D,k:T,R:E,T:()=>y.l,C:()=>l,M:()=>p!==0,p:()=>s,O:()=>c,h:w,H:()=>(f=u,u=0,[f,m===2]),W:(e,t)=>{let n=[e,t];return b.add(n),()=>{b.delete(n)}},B:(e,t)=>{let n,r,g=0;switch(e){case 1:{if(t===l&&m===0)break;let e=f;f=0;let n=t-l,i=fO(n);e&&i<fO(e)+1||m!==0||(p=n<0?2:1),a&&=!1,l=t,g=4;let o=x();o>=-s&&o<=w()&&(g+=1,r=i>s);break}case 2:g=8,p!==0&&(n=!0,g+=1),p=0,m=0,h=lO;break;case 3:{let e=t.filter(([e,t])=>!D(e,t));if(!e.length)break;O(e.reduce((e,[t,n])=>{let r;if(m===2)r=!0;else if(h&&m===1)r=t<h[0];else{let e=x(),n=T(t),i=E(t);r=p!==1&&m===0?n+i<=e:n<e&&n+i<e+s}return r&&(e+=n-E(t)),e},0));for(let[t,n]of e){let e=E(t),r=xO(y,t,n);i&&(_+=r?n:n-e)}i&&s&&_>s&&(O(((e,t)=>{let n=0,r=[];e.t.forEach((e,i)=>{e!==-1&&(r.push(e),i<t&&n++)}),e.i=-1;let i=hO(r),a=i.length,o=a/2|0,s=a%2==0?(i[o-1]+i[o])/2:i[o],c=e.o;return((e.o=s)-c)*dO(t-n,0)})(y,CO(y,S()))),i=!1),g=3,r=!0;break}case 4:s!==t&&(s||(v=r=!0),s=t,g=3);break;case 5:t[1]?(O(wO(y,t[0],!0)),m=2,g=1):(wO(y,t[0]),g=1);break;case 6:c=t;break;case 7:m=1;break;case 8:h=C(t,t+s),g=1}g&&(o=1+(2147483647&o),n&&d&&(u+=d,d=0),b.forEach(([e,t])=>{g&e&&t(r)}))}}},NO=setTimeout,PO=(e,t)=>t?-e:e,FO=(e,t,n,r,i,a)=>{let o=Date.now,s=0,c=!1,l=!1,u=!1,d=!1,f=(()=>{let t,n=()=>{t!=lO&&clearTimeout(t)},r=()=>{n(),t=NO(()=>{t=lO,(()=>{if(c||l)return c=!1,void f();u=!1,e.B(2)})()},150)};return r.J=n,r})(),p=()=>{s=o(),u&&(d=!0),a&&e.B(6,a()),e.B(1,r()),f()},m=t=>{if(c||!e.M()||t.ctrlKey)return;let r=o()-s;150>r&&50<r&&(n?t.deltaX:t.deltaY)&&(c=!0)},h=()=>{l=!0,u=d=!1},g=()=>{l=!1,kO()&&(u=!0)};return t.addEventListener(`scroll`,p),t.addEventListener(`wheel`,m,{passive:!0}),t.addEventListener(`touchstart`,h,{passive:!0}),t.addEventListener(`touchend`,g,{passive:!0}),{A:()=>{t.removeEventListener(`scroll`,p),t.removeEventListener(`wheel`,m),t.removeEventListener(`touchstart`,h),t.removeEventListener(`touchend`,g),f.J()},L:()=>{let[t,n]=e.H();t&&(i(t,n,d),d=!1,n&&e.p()>e.h()&&e.B(1,r()))}}},IO=(e,t,n)=>{let r;return[async(i,a)=>{if(!await t())return;r&&r();let o=()=>{let[t,n]=_O();return r=()=>{n(!1)},e.p()&&NO(r,150),[t,e.W(2,()=>{n(!0)})]};if(a&&AO())e.B(8,i()),gO(async()=>{for(;;){let t=!0;for(let[n,r]=e.S();n<=r;n++)if(e.I(n)){t=!1;break}if(t)break;let[n,r]=o();try{if(!await n)return}finally{r()}}e.B(7),n(i(),a)});else for(;;){let[t,r]=o();try{if(e.B(7),n(i()),!await t)return}finally{r()}}},()=>{r&&r()}]},LO=(e,t)=>{let n,r,i=_O(),a=!1,o=t?`scrollLeft`:`scrollTop`,s=t?`overflowX`:`overflowY`,[c,l]=IO(e,()=>i[0],(e,r)=>{e=PO(e,a),r?n.scrollTo({[t?`left`:`top`]:e,behavior:`smooth`}):n[o]=e});return{N(c,u){n=u,t&&(a=getComputedStyle(u).direction===`rtl`),r=FO(e,u,t,()=>PO(u[o],a),(t,n,r)=>{if(r){let e=u.style,t=e[s];e[s]=`hidden`,NO(()=>{e[s]=t})}u[o]=PO(e.C()+t,a),n&&l()}),i[1](!0)},v(){r&&r.A(),i[1](!1),i=_O()},P:()=>a,V(e){c(()=>e)},X(t){t+=e.C(),c(()=>t)},Y(t,{align:n,smooth:r,offset:i=0}={}){if(t=mO(t,0,e.T()-1),n===`nearest`){let r=e.k(t),i=e.C();if(r<i)n=`start`;else{if(!(r+e.R(t)>i+e.p()))return;n=`end`}}c(()=>i+e.O()+e.k(t)+(n===`end`?e.R(t)-e.p():n===`center`?(e.R(t)-e.p())/2:0),r)},q:()=>{r&&r.L()}}},RO=e=>{let t;return{j(n){(t||=new(OO(DO(n))).ResizeObserver(e)).observe(n)},D(e){t.unobserve(e)},A(){t&&t.disconnect()}}},zO=(e,t)=>{let n,r=t?`width`:`height`,i=new WeakMap,a=RO(t=>{let a=[];for(let{target:o,contentRect:s}of t)if(o.offsetParent)if(o===n)e.B(4,s[r]);else{let e=i.get(o);e!=lO&&a.push([e,s[r]])}a.length&&e.B(3,a)});return{G(e){a.j(n=e)},U:(e,t)=>(i.set(e,t),a.j(e),()=>{i.delete(e),a.D(e)}),v:a.A}},BO=TO?Z.useLayoutEffect:Z.useEffect,VO=`current`,HO=(e,t)=>{if(Array.isArray(e))for(let n of e)HO(n,t);else e==null||typeof e==`boolean`||t.push(e)},UO=(e,t)=>e.key??`_`+t,WO=e=>{let t=(0,Z.useRef)(null);return t[VO]||(t[VO]=e())},GO=e=>{let t=(0,Z.useRef)(e);return BO(()=>{t[VO]=e},[e]),t},KO=(0,Z.memo)(({Z:e,ee:t,te:n,oe:r,ne:i,re:a,se:o,ie:s})=>{let c=(0,Z.useRef)(null);BO(()=>t(c[VO],n),[n]);let l=(0,Z.useMemo)(()=>{let e={contain:`layout style`,position:i&&s?void 0:`absolute`,[o?`height`:`width`]:`100%`,[o?`top`:`left`]:0,[o?`left`:`top`]:r,visibility:!i||s?void 0:`hidden`};return o&&(e.display=`inline-flex`),e},[r,i,s,o]);return(0,Q.jsx)(a,typeof a==`string`?{ref:c,style:l,children:e}:{ref:c,style:l,index:n,children:e})}),qO=(e,t)=>(0,Z.useMemo)(()=>{if(typeof e==`function`)return[n=>e(t[n],n),t.length];let n=(e=>{let t=[];return HO(e,t),t})(e);return[e=>n[e],n.length]},[e,t]),JO=(0,Z.forwardRef)(({children:e,data:t,bufferSize:n,itemSize:r,shift:i,horizontal:a,keepMounted:o,cache:s,startMargin:c=0,ssrCount:l,as:u=`div`,item:d=`div`,scrollRef:f,onScroll:p,onScrollEnd:m},h)=>{let[g,_]=qO(e,t),v=(0,Z.useRef)(null),y=(0,Z.useRef)(!!l),b=GO(p),x=GO(m),[S,C,w,T]=WO(()=>{let e=!!a,t=MO(_,r,l,s,!r);return[t,zO(t,e),LO(t,e),e]});_!==S.T()&&S.B(5,[_,i]),c!==S.O()&&S.B(6,c);let[E,D]=(0,Z.useReducer)(S.m,void 0,S.m),O=S.M(),k=S.h(),A=w.P(),j=[],M=e=>{let t=g(e);return(0,Q.jsx)(KO,{ee:C.U,te:e,oe:S.k(e,A),ne:S.I(e),re:d,Z:t,se:T,ie:y[VO]},UO(t,e))};if(BO(()=>{y[VO]=!1,S.W(1,e=>{e?(0,Of.flushSync)(D):D()}),S.W(4,()=>{b[VO]&&b[VO](S.C())}),S.W(8,()=>{x[VO]&&x[VO]()});let e=v[VO],t=t=>{C.G(t),w.N(e,t)};return f?gO(()=>{f[VO]&&t(f[VO])}):t(e.parentElement),()=>{S.v(),C.v(),w.v()}},[]),BO(()=>{w.q()},[E]),(0,Z.useImperativeHandle)(h,()=>({get cache(){return S._()},get scrollOffset(){return S.C()},get scrollSize(){return jO(S)},get viewportSize(){return S.p()},findItemIndex:S.$,getItemOffset:S.k,getItemSize:S.R,scrollToIndex:w.Y,scrollTo:w.V,scrollBy:w.X}),[]),o){let e=new Set(o);for(let[t,r]=S.S(n);t<=r;t++)e.add(t);hO([...e]).forEach(e=>{j.push(M(e))})}else for(let[e,t]=S.S(n);e<=t;e++)j.push(M(e));return(0,Q.jsx)(u,{ref:v,style:{contain:`size style`,overflowAnchor:`none`,flex:`none`,position:`relative`,width:T?k:`100%`,height:T?`100%`:k,pointerEvents:O?`none`:void 0},children:j})});function YO(e,t){let[n,r]=(0,Z.useState)(!1),[i,a]=(0,Z.useState)(``),o=(0,Z.useRef)(!1);return{editing:n,draft:i,setDraft:a,begin:()=>{a(e),o.current=!1,r(!0)},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 XO({editor:e,className:t}){return(0,Q.jsx)(`input`,{"data-slot":`title-input`,"aria-label":`Task title`,autoFocus:!0,value:e.draft,onChange:t=>e.setDraft(t.target.value),onBlur:e.commit,onKeyDown:t=>{t.key===`Enter`?(t.preventDefault(),e.commit()):t.key===`Escape`&&(t.preventDefault(),e.cancel())},className:q(`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)})}function ZO(e){let t=new Map,n=new Set,r;return{begin:e,editingId:()=>r?.id??null,subscribeSelection(e){return n.add(e),()=>{n.delete(e)}},snapshot:e=>r?.id===e?r.editor:null,subscribe(e,n){let r=t.get(e);return r||(r=new Set,t.set(e,r)),r.add(n),()=>{r.delete(n),r.size||t.delete(e)}},publish(e,i){let a=r?.id;if(r=e&&i.editing?{id:e,editor:i}:void 0,a!==r?.id)for(let e of n)e();for(let e of new Set([a,r?.id]))if(e)for(let n of t.get(e)??[])n()}}}var QO=(0,Z.createContext)(null),$O={editing:!1,draft:``,begin(){},setDraft(){},commit(){},cancel(){}};function ek({children:e,runs:t,onRename:n}){let[r,i]=(0,Z.useState)(),[a]=(0,Z.useState)(()=>ZO(e=>i({run:e}))),o=t.find(e=>e.id===r?.run.id),s=YO(o?Ro(o):``,e=>{o&&n(o.id,e)});return(0,Z.useEffect)(()=>{r&&s.begin()},[r]),(0,Z.useEffect)(()=>{r&&!o&&(s.cancel(),i(void 0))},[r,o,s]),(0,Z.useLayoutEffect)(()=>{a.publish(o?.id,s)},[a,o?.id,s]),(0,Q.jsx)(QO,{value:a,children:e})}function tk(e){let t=(0,Z.useContext)(QO);if(!t)throw Error(`Task title editor needs its page provider`);return{...(0,Z.useSyncExternalStore)((0,Z.useCallback)(n=>t.subscribe(e.id,n),[t,e.id]),(0,Z.useCallback)(()=>t.snapshot(e.id),[t,e.id]))??$O,begin:()=>t.begin(e)}}var nk=()=>null;function rk(){return ik}function ik(){}function ak(){let e=(0,Z.useContext)(QO);return(0,Z.useSyncExternalStore)(e?.subscribeSelection??rk,e?.editingId??nk)}function ok(e,t,n){return n===void 0?e===void 0?t:`${e}/${t}`:`host:${n}/${e??``}/${t}`}var sk=new Set([`done`,`failed`,`cancelled`]);function ck(e,t=240){let n=e.replace(/\s+/g,` `).trim();return n.length<=t?n:`${n.slice(0,t-1).trimEnd()}…`}function lk(e,t){if(e.statePreview)return e.statePreview;if(!e.archived){if(e.hasPendingPermission)return{kind:`permission`,text:`Permission requested`};if(t.rung===`needs-you`)return{kind:`ask`,text:`Waiting for your reply`};if(e.status===`review`)return{kind:`review`,text:`Ready for review`}}if(e.status===`failed`&&!lt(e)&&e.error){let t=ck(e.error);if(t)return{kind:`error`,text:t}}}function uk(e,t){let n=e.runner?ye(t,e.runner):void 0,r=e.model?.trim()||void 0;return n&&r?`${n} · ${r}`:n??r}function dk(e,t){let n=[],r=t.showTokens&&(e.inputTokens!==void 0||e.outputTokens!==void 0)?(e.inputTokens??0)+(e.outputTokens??0):0;r>0&&n.push(Cs(r));let i=t.showCost?_r(e.costUsd):``;return i&&n.push(i),n}function fk(e,t,n){return e.inputTokens!==void 0||e.outputTokens!==void 0||e.costUsd!==void 0||!!(t||n||e.branch)}function pk(e,t,n){let r=dk(e,n),i=tr(e,t);return r.length<2&&i.cpu.kind===`live`&&i.cpu.text?r.push(i.cpu.text):r.length===0&&i.mem.text&&r.push(i.mem.text),{label:r.length>0?r.join(` · `):`Usage`,hasData:r.length>0||fk(e,i.cpu.text,i.mem.text)}}function mk({run:e,queuePosition:t=null,runners:n,automationName:r,repoBase:i,now:a,showTokens:o=!0,showCost:s=!0}){let c=qe(e),l=zm(e,c),u=Ar(e,a===void 0?void 0:new Date(a)),d=pk(e,e.usage,{showTokens:o,showCost:s}),f=e.automationId;return{key:e.id,runId:e.id,tags:[],run:e,href:`/tasks/${e.id}`,title:Ro(e),isWorker:No(e),unread:mn(e),readDone:Zo(e),canToggleRead:xt(e),unreadTone:Xo(e),attention:c,status:l,urgent:Nt(e),scheduled:u,pinned:!!e.pinned,queuePosition:t,automationBadge:f===void 0?void 0:{id:f,label:r?.(f)??f},runnerModel:uk(e,n),statePreview:lk(e,c),workflow:cr(e),branch:e.branch,diffStat:e.diffStat,references:nr(e,i),repoBase:i,startedAt:e.startedAt??e.createdAt,usageSummary:d.label,hasUsageData:d.hasData,snapshotUsage:e.usage,canArchive:e.archived||sk.has(e.status)}}function hk(e){return typeof e==`string`?e:e.pathname??``}var gk=new WeakMap;function _k(e){let t=new Date(e);return`${t.getFullYear()}-${t.getMonth()}-${t.getDate()}`}function vk(e,t){return!!(e&&e.queuePosition===t.queuePosition&&e.runners===t.runners&&e.autoLabel===t.autoLabel&&e.showTokens===t.showTokens&&e.showCost===t.showCost&&e.dayKey===t.dayKey)}function yk(e){return e.hostId===void 0?{}:{hostId:e.hostId,hostLabel:e.hostLabel??e.hostId,hostStale:!!e.hostStale,hostState:e.hostState,fullPageNav:!0}}function bk({task:e,queuePosition:t=null,runners:n,automationName:r,now:i,showTokens:a=!0,showCost:o=!0}){let s=e.run,c=s.automationId===void 0?void 0:r?.(e),l=lt(s)?i??Date.now():void 0,u={queuePosition:t,runners:n,autoLabel:c,showTokens:a,showCost:o,dayKey:l===void 0?``:_k(l)},d=gk.get(e);if(vk(d,u))return d.model;let f=mk({run:s,queuePosition:t,runners:n,automationName:c===void 0?void 0:()=>c,repoBase:e.project?.repoUrl,now:l,showTokens:a,showCost:o}),p=e.hostId!==void 0,m={...f,key:ok(s.projectId,s.id,e.hostId),...yk(e),projectId:s.projectId,projectName:e.projectName,projectHref:p?Ne(e.hostId,s.projectId):hk(wo(s.projectId,`/`)),tags:e.tags,href:p?Re(e.hostId,s.projectId,s.id):hk(wo(s.projectId,`/tasks/${s.id}`)),references:nr(s,e.project?.repoUrl,s.projectId)};return gk.set(e,{...u,model:m}),m}var xk=(0,Z.createContext)(null);function Sk(e,t,n=!1){let[r,i]=(0,Z.useState)(null),a=(0,Z.useRef)(new Map),o=(0,Z.useCallback)((e,t)=>{t?a.current.set(e,t):a.current.delete(e)},[]),s=(0,Z.useCallback)(e=>[...a.current.values()].some(t=>t.includes(e)),[]);return{props:Ck(e,t,i,n?s:void 0),value:(0,Z.useMemo)(()=>({focused:r,revision:t,registerList:n?o:void 0}),[r,t,o,n])}}function Ck(e,t,n,r){let i=(0,Z.useRef)(r);(0,Z.useLayoutEffect)(()=>{i.current=r});let a=(0,Z.useRef)(null),o=(0,Z.useRef)(null);return(0,Z.useLayoutEffect)(()=>{let e=o.current;if(!e||e.element.isConnected||document.activeElement!==document.body)return;let t=()=>{o.current===e&&(o.current=null,n?.(null))},r=()=>{let n=ok(e.project,e.runId,e.hostId);if(i.current&&!i.current(n)||document.activeElement!==document.body||e.element.isConnected)return t(),!0;let r=[...a.current?.querySelectorAll(`[data-run-id]`)??[]].filter(t=>t.dataset.runId===e.runId&&t.dataset.project===e.project&&t.dataset.hostId===e.hostId).flatMap(e=>[...e.querySelectorAll(`a,button,input`)]),o=r.find(t=>e.control?t.dataset.taskControl===e.control:t.tagName===e.tag&&t.getAttribute(`aria-label`)===e.label)??r.find(e=>e.tagName===`A`);return o?.focus({preventScroll:!0}),!!o&&document.activeElement===o};if(r()||!a.current)return;let s=()=>{l.disconnect(),document.removeEventListener(`pointerdown`,c,!0),document.removeEventListener(`keydown`,c,!0)},c=()=>{t(),s()},l=new MutationObserver(()=>{r()&&s()});return document.addEventListener(`pointerdown`,c,!0),document.addEventListener(`keydown`,c,!0),l.observe(a.current,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[`style`]}),s},[e,t]),{ref:a,onFocusCapture:e=>{let t=e.target,r=t.closest(`[data-run-id]`);o.current=r?{element:t,runId:r.dataset.runId,project:r.dataset.project,hostId:r.dataset.hostId,control:t.dataset.taskControl??null,label:t.getAttribute(`aria-label`),tag:t.tagName}:null,n?.(r?ok(r.dataset.project,r.dataset.runId,r.dataset.hostId):null)},onBlurCapture:e=>{let t=e.target,r=e.currentTarget;queueMicrotask(()=>{o.current?.element===t&&t.isConnected&&!r.contains(document.activeElement)&&(o.current=null,n?.(null))})}}}var wk=new WeakMap;function Tk({items:e,itemKey:t,children:n,itemSize:r}){let[i]=zn(),a=(0,Z.useRef)(null),o=(0,Z.useRef)(null),[s,c]=(0,Z.useState)({available:null,margin:0}),[l,u]=(0,Z.useState)(null),d=ak(),f=(0,Z.useContext)(xk),p=e.map(t),m=oO(e.length,i.get(`tasks`)),h=s.available===!0&&m,g=(0,Z.useRef)(Symbol(`task-list`)),_=(0,Z.useRef)(()=>{});(0,Z.useLayoutEffect)(()=>{f?.registerList?.(g.current,p);let e=y.current;return e&&wk.set(e,{keys:p,handle:o,measure:()=>_.current()}),()=>{f?.registerList?.(g.current,null),e&&wk.delete(e)}});let v=Ck(String(h),void 0,void 0,e=>p.includes(e)),y=v.ref;return(0,Z.useLayoutEffect)(()=>{let e=y.current,t=e?.closest(`[data-slot="main"]`);if(a.current=t??null,!e||!t){c(e=>e.available===!1?e:{available:!1,margin:0});return}let n=null,r=()=>{let r=Math.max(0,e.getBoundingClientRect().top-t.getBoundingClientRect().top+t.scrollTop);r!==n&&(n=r,c(e=>e.available===!0&&e.margin===r?e:{available:!0,margin:r}))};r(),_.current=r;let i=new ResizeObserver(r);for(let n=e;n&&n!==t;n=n.parentElement){i.observe(n);for(let e of n.parentElement?.children??[])i.observe(e)}return i.observe(t),()=>i.disconnect()},[]),(0,Q.jsx)(`div`,{ref:y,"data-slot":`task-list-items`,"data-virtualized":h,onFocusCapture:e=>{v.onFocusCapture(e),u(e.target.closest(`[data-task-item]`)?.dataset.taskItem??null)},onBlurCapture:e=>{v.onBlurCapture(e),e.relatedTarget&&!e.currentTarget.contains(e.relatedTarget)&&u(null)},children:h?(0,Q.jsx)(Dk,{itemSize:r,items:e,keys:p,handle:o,scroll:a,margin:s.margin,focused:f?.focused??l,editing:d,children:n}):(s.available===null&&m?[]:e).map((t,r)=>(0,Q.jsx)(`div`,{"data-task-item":p[r],"data-first":r===0,"data-last":r===e.length-1,className:`task-list-flat-item`,children:n(t,r)},p[r]))})}function Ek({layout:e,revision:t,visibilityRevision:n=``,children:r,...i}){let a=Sk(e,t,!0);return(0,Q.jsx)(xk,{value:a.value,children:(0,Q.jsx)(kk,{revision:t,visibilityRevision:`${e}:${n}`,children:(0,Q.jsx)(`div`,{...i,...a.props,children:r})})})}function Dk({items:e,keys:t,handle:n,scroll:r,margin:i,focused:a,editing:o,children:s,itemSize:c}){let[l,u]=(0,Z.useState)(!1),d=Ok(r);return(0,Z.useLayoutEffect)(()=>{let e=r.current;if(!e)return;let t=new ResizeObserver(e=>{e.some(e=>e.contentRect.height>0)&&(u(!0),t.disconnect())});return t.observe(e),()=>t.disconnect()},[r]),(0,Q.jsx)(JO,{ref:n,...c===void 0?{}:{itemSize:c},scrollRef:r,startMargin:i,keepMounted:[...new Set([...!l&&e.length?[0]:[],...sO(t,a),...sO(t,d),...sO(t,o)])],data:e,children:(n,r)=>(0,Q.jsx)(`div`,{"data-task-item":t[r],"data-first":r===0,"data-last":r===e.length-1,children:s(n,r)},t[r])})}function Ok(e){let[t,n]=(0,Z.useState)(null),r=(0,Z.useRef)(t);return(0,Z.useLayoutEffect)(()=>{let t=e.current;if(!t)return;let i=e=>{if(e.target!==t)return;let i=t.contains(document.activeElement)?document.activeElement.closest(`[data-task-item]`)?.dataset.taskItem??null:null;i!==r.current&&(r.current=i,(0,Of.flushSync)(()=>n(i)))};return document.addEventListener(`scroll`,i,{capture:!0,passive:!0}),()=>document.removeEventListener(`scroll`,i,{capture:!0})},[e]),t}var kk=class extends Z.Component{root={current:null};owner(){return this.root.current?.closest(`[data-slot="main"]`)??null}getSnapshotBeforeUpdate(e){if(e.revision===this.props.revision&&e.visibilityRevision===this.props.visibilityRevision)return null;let t=this.owner();if(!t||!this.root.current)return null;let n=t.getBoundingClientRect();for(let e of this.root.current.querySelectorAll(`[data-task-item]`)){let r=e.getBoundingClientRect();if(r.bottom>n.top&&r.top<n.bottom)return{key:e.dataset.taskItem,top:r.top,scrollTop:t.scrollTop}}return{key:null,top:0,scrollTop:t.scrollTop}}componentDidUpdate(e,t,n){let r=this.owner();if(!n||!r)return;let i=n.key===null?null:this.currentTop(n.key);i!==null&&Math.abs(i-n.top)>.5&&(r.scrollTop+=i-n.top),queueMicrotask(()=>{r.isConnected&&(0,Of.flushSync)(()=>{for(let e of this.root.current?.querySelectorAll(`[data-slot="task-list-items"]`)??[])wk.get(e)?.measure();r.scrollTop!==n.scrollTop&&r.dispatchEvent(new Event(`scroll`))})})}currentTop(e){for(let t of this.root.current?.querySelectorAll(`[data-task-item]`)??[])if(t.dataset.taskItem===e)return t.getBoundingClientRect().top;for(let t of this.root.current?.querySelectorAll(`[data-slot="task-list-items"]`)??[]){let n=wk.get(t),r=n?.keys.indexOf(e)??-1,i=n?.handle.current;if(r>=0&&i)return t.getBoundingClientRect().top+i.getItemOffset(r)}return null}render(){return(0,Q.jsx)(`div`,{ref:this.root,style:{display:`contents`},children:this.props.children})}},Ak=/^- \S+ — (?:(?:turn complete|step ".*" complete|step ".*" ended without done|session idle-closed) — |worktree setup (?:done in|failed —|skipped —) )/;function jk(e,t=3){let n=an(e,`## Progress log`);if(n<0)return[];let r=[];for(let i of e.slice(Gt(e,n)).split(`
|
|
21
|
+
`)){if(r.length>=t||i.startsWith(`## `))break;let e=i.trim();!e||Ak.test(e)||r.push(e.replace(/^[-*] /,``))}return r}function Mk({origin:e,counts:t,automations:n,onChange:r,compact:i=!1}){return(0,Q.jsx)(`div`,{role:`group`,"aria-label":`Task origin`,"data-slot":`origin-filter`,className:q(`flex flex-wrap items-center`,i?`inline-flex rounded-md border border-border bg-card p-0.5 gap-0.5`:`gap-1.5`),children:pr(n).map(n=>{let a=n.value===e;return(0,Q.jsxs)(`button`,{type:`button`,"data-origin":n.value,"aria-pressed":a,onClick:()=>r(n.value),className:q(i?`inline-flex min-h-11 items-center gap-1 rounded-sm px-2.5 text-xs font-medium text-muted-foreground hover:bg-muted hover:text-foreground focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-link-foreground md:min-h-0 md:h-8`:`inline-flex min-h-11 items-center gap-1.5 rounded-full border border-border px-3 text-[13px] font-medium text-muted-foreground hover:bg-muted hover:text-foreground focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-link-foreground`,a&&(i?`bg-accent-strong/15 text-accent-text`:`border-accent-strong bg-accent-strong/10 text-accent-text`)),children:[n.label,` `,(0,Q.jsx)(Am,{value:t[n.value]})]},n.value)})})}function Nk({onExpand:e,onCollapse:t,compact:n=!1,allCollapsed:r=!1}){return n?(0,Q.jsx)(`div`,{"data-slot":`group-fold-controls`,className:`hidden items-center md:flex`,children:r?(0,Q.jsx)(Y,{type:`button`,variant:`ghost`,size:`sm`,className:`px-2 text-xs text-muted-foreground`,"data-action":`expand-groups`,onClick:e,children:`Expand all`}):(0,Q.jsx)(Y,{type:`button`,variant:`ghost`,size:`sm`,className:`px-2 text-xs text-muted-foreground`,"data-action":`collapse-groups`,onClick:t,children:`Collapse all`})}):(0,Q.jsxs)(`div`,{"data-slot":`group-fold-controls`,className:`hidden flex-wrap items-center gap-1 md:ml-auto md:flex md:gap-2`,children:[(0,Q.jsx)(Y,{type:`button`,variant:`ghost`,size:`default`,"data-action":`expand-groups`,onClick:e,children:`Expand groups`}),(0,Q.jsx)(Y,{type:`button`,variant:`ghost`,size:`default`,"data-action":`collapse-groups`,onClick:t,children:`Collapse groups`})]})}function Pk(e,t){if(t===`danger`)return`contains failed tasks`;switch(e){case`Needs you`:return`needs you`;case`Working`:return`working`;case`Finished`:return`finished`;case`Archived`:return`archived`}}function Fk({id:e,label:t,count:n,tone:r,folded:i,collapsed:a,onToggle:o,children:s}){let c=a?Ti:Ki;return(0,Q.jsxs)(`section`,{"data-slot":`task-status-group`,"data-bucket":t,"data-folded":i,"data-tone":r,"aria-labelledby":`${e}-heading`,className:`flex flex-col gap-2.5`,children:[(0,Q.jsx)(`h2`,{id:`${e}-heading`,className:`text-[13px] font-semibold text-foreground`,children:(0,Q.jsxs)(`button`,{type:`button`,"data-slot":`status-group-toggle`,"aria-expanded":!a,"aria-controls":`${e}-rows`,"aria-label":`${t} ${n}${r===`danger`?`, contains failed tasks`:``}`,onClick:o,className:`inline-flex min-h-11 items-center gap-2 rounded-md pr-2 hover:text-foreground focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-link-foreground`,children:[(0,Q.jsx)(c,{className:`size-3.5 shrink-0 text-muted-foreground`,"aria-hidden":`true`}),(0,Q.jsx)(Qo,{tone:r,role:`img`,"aria-label":Pk(t,r),title:Pk(t,r)}),(0,Q.jsx)(`span`,{children:t}),` `,(0,Q.jsx)(Am,{value:n,className:`font-normal text-muted-foreground`})]})}),(0,Q.jsx)(`div`,{id:`${e}-rows`,hidden:a,children:a?null:s})]})}function Ik({projectId:e,hostId:t,runId:n,status:r,error:i,open:a,compact:o=!1}){let s=he(e,n,!0,t),c=s.data===void 0?[]:jk(s.data);return o?(0,Q.jsxs)(`div`,{"data-slot":`task-preview`,className:`flex flex-col gap-2 text-xs`,children:[i?(0,Q.jsx)(`p`,{"data-slot":`task-preview-error`,className:`break-words text-semantic-red`,children:i}):null,s.isPending?(0,Q.jsx)(`p`,{role:`status`,className:`text-muted-foreground`,children:`Loading latest progress…`}):s.isError?(0,Q.jsx)(`p`,{"data-slot":`task-preview-unavailable`,className:`text-muted-foreground`,children:`Latest progress is unavailable.`}):c.length>0?(0,Q.jsx)(`ul`,{"aria-label":`Latest progress`,className:`flex flex-col gap-1 text-muted-foreground`,children:c.map((e,t)=>(0,Q.jsx)(`li`,{className:`break-words`,children:e},t))}):null,(0,Q.jsx)(`div`,{children:a})]}):(0,Q.jsxs)(`div`,{"data-slot":`task-preview`,className:`flex flex-col gap-3 rounded-md bg-muted/50 p-4 text-xs`,children:[(0,Q.jsx)(`p`,{className:`font-medium text-foreground`,children:r}),i?(0,Q.jsx)(`p`,{"data-slot":`task-preview-error`,className:`break-words text-semantic-red`,children:i}):null,s.isPending?(0,Q.jsx)(`p`,{role:`status`,className:`text-muted-foreground`,children:`Loading latest progress…`}):s.isError?(0,Q.jsx)(`p`,{"data-slot":`task-preview-unavailable`,className:`text-muted-foreground`,children:`Latest progress is unavailable.`}):c.length===0?(0,Q.jsx)(`p`,{className:`text-muted-foreground`,children:`No progress recorded yet.`}):(0,Q.jsx)(`ul`,{"aria-label":`Latest progress`,className:`flex flex-col gap-1 text-muted-foreground`,children:c.map((e,t)=>(0,Q.jsx)(`li`,{className:`break-words`,children:e},t))}),(0,Q.jsx)(`div`,{children:a})]})}function Lk(e,t){return e===`Finished`?`neutral`:rr(e,t)}var Rk=`inline-flex min-h-11 max-md:min-w-11 max-md:-mb-px md:min-h-0 md:h-8 items-center justify-center gap-1.5 border-b-2 border-transparent px-1 text-[13px] text-muted-foreground transition-colors hover:text-foreground focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring`,zk=`border-accent-text font-medium text-foreground`;function Bk({view:e,current:t,onSelect:n,count:r,children:i}){let a=e===t;return(0,Q.jsxs)(`button`,{type:`button`,"data-slot":`overview-tab`,"data-view":e,"aria-pressed":a,onClick:()=>n(e),className:q(Rk,a&&zk),children:[i,r===0?null:(0,Q.jsxs)(`span`,{className:`tabular-nums`,children:[` · `,(0,Q.jsx)(Am,{value:r})]})]})}function Vk({view:e,onSelect:t,activeCount:n,archivedCount:r,trailing:i}){return(0,Q.jsxs)(`div`,{"data-slot":`tasks-view-tabs`,className:`flex flex-wrap items-center gap-x-4 gap-y-1`,children:[(0,Q.jsx)(Bk,{view:`active`,current:e,onSelect:t,count:n,children:`Active`}),(0,Q.jsx)(Bk,{view:`archived`,current:e,onSelect:t,count:r,children:`Archived`}),i]})}function Hk(){return(0,Q.jsx)(`span`,{className:`text-xs text-soft-foreground`,children:`—`})}function Uk(e,t,n){return`${e} ${e===1?`task`:`tasks`}${t?` loaded`:``}${n?` matching “${n}”`:``}`}function Wk({count:e,incomplete:t,needle:n}){return(0,Q.jsx)(`span`,{"data-slot":`tasks-result-count`,className:q(`self-center truncate text-xs text-soft-foreground tabular-nums`,n===``&&!t&&`sr-only`),children:Uk(e,t,n)})}function Gk({branch:e}){return(0,Q.jsx)(Mm,{value:e,variant:`chip`})}function Kk({view:e,unread:t,finished:n,archivePending:r,markReadPending:i=!1,onMarkAllRead:a,onArchiveFinished:o,focusReturnRef:s,surface:c=`both`}){let l=Z.useRef(!1),[u,d]=Z.useState(!1),f=n>0||r,p=c!==`mobile`,m=c!==`desktop`;return Z.useEffect(()=>{let e=window.matchMedia?.(hs);if(!e)return;let t=()=>{e.matches&&d(!1)};return t(),e.addEventListener(`change`,t),()=>e.removeEventListener(`change`,t)},[]),(0,Q.jsxs)(Q.Fragment,{children:[p&&t>0?(0,Q.jsxs)(Y,{type:`button`,variant:`outline`,"data-slot":`mark-all-read`,disabled:i,"aria-busy":i,className:`hidden md:inline-flex`,onClick:a,children:[(0,Q.jsx)(Ic,{className:`size-3.5`,"aria-hidden":`true`}),`Mark all read `,(0,Q.jsx)(Am,{value:t,className:`text-muted-foreground`})]}):null,p&&e===`active`&&n>0?(0,Q.jsxs)(Y,{type:`button`,variant:`outline`,"data-slot":`archive-finished`,className:`hidden md:inline-flex`,disabled:r,"aria-busy":r,onClick:o,children:[(0,Q.jsx)(Wi,{className:`size-3.5`,"aria-hidden":`true`}),`Archive finished `,(0,Q.jsx)(Am,{value:n,className:`text-muted-foreground`})]}):null,m&&e===`active`&&(f||t>0)?(0,Q.jsxs)(oo,{open:u,onOpenChange:d,children:[(0,Q.jsx)(ro,{asChild:!0,children:(0,Q.jsx)(Y,{type:`button`,variant:`outline`,size:`icon`,className:`md:hidden`,"aria-label":`Task actions`,"aria-busy":r||i,children:(0,Q.jsx)(Kc,{"aria-hidden":`true`})})}),(0,Q.jsxs)(io,{align:`end`,className:`md:hidden`,onCloseAutoFocus:e=>{(l.current||window.matchMedia?.(`(min-width: 48rem)`).matches)&&(e.preventDefault(),l.current=!1,(s?.current??document).querySelector(`[data-slot="overview-tab"][data-view="active"]`)?.focus())},children:[f?(0,Q.jsxs)(eo,{disabled:r||n===0,onSelect:()=>{l.current=!0,o()},children:[(0,Q.jsx)(Wi,{"aria-hidden":`true`}),r?`Archiving…`:`Archive finished (${n})`]}):null,t>0?(0,Q.jsxs)(eo,{disabled:i,onSelect:a,children:[(0,Q.jsx)(Ic,{"aria-hidden":`true`}),`Mark all read (${t})`]}):null]})]}):null]})}function qk(e){return e.id===`reference`?`Reference`:e.id===`memory`?`Memory`:e.summaryLabel??e.label}function Jk({columns:e,expandedColumns:t,columnsPending:n,onToggleColumn:r,detailedTable:i,onToggleDetailed:a,showReferences:o=!0}){return(0,Q.jsxs)(po,{children:[(0,Q.jsx)(co,{asChild:!0,children:(0,Q.jsx)(Y,{"data-slot":`task-columns-trigger`,variant:`outline`,className:`hidden md:inline-flex`,children:`Columns`})}),(0,Q.jsxs)(uo,{align:`end`,className:`w-72`,children:[(0,Q.jsx)(`h2`,{className:`mb-2 text-base font-medium`,children:`Visible columns`}),(0,Q.jsx)(`p`,{className:`mb-4 text-xs text-muted-foreground`,children:`Task · Always visible`}),(0,Q.jsx)(`div`,{className:`grid grid-cols-2 gap-3`,children:e.filter(e=>e.canFold).map(e=>(0,Q.jsxs)(`label`,{className:`flex items-center gap-2 text-xs`,children:[(0,Q.jsx)(`input`,{"data-column-toggle":e.id,type:`checkbox`,checked:eO(e.id,t)&&(e.id!==`reference`||o),disabled:n||e.id===`reference`&&!o,onChange:()=>r(e.id)}),qk(e),e.id===`reference`&&!o?(0,Q.jsx)(`span`,{className:`text-muted-foreground`,children:`(no references)`}):null]},e.id))}),(0,Q.jsx)(`p`,{className:`mt-4 text-xs text-muted-foreground`,children:`Saved automatically across task lists.`}),a?(0,Q.jsx)(Y,{variant:`outline`,className:`mt-4`,onClick:a,children:i?`Summary view`:`Resource columns`}):null]})]})}function Yk({query:e,onQueryChange:t,searchPlaceholder:n,searchLabel:r,origin:i,originCounts:a,automations:o,onOriginChange:s,columns:c,expandedColumns:l,columnsPending:u,onToggleColumn:d,detailedTable:f,onToggleDetailed:p,showReferences:m=!0,groupLabels:h,allGroupsCollapsed:g=!1,onSetAllFolds:_,extraControls:v,mobileOriginOpen:y,mobileActions:b}){let x=(0,Z.useRef)(null),[S,C]=Z.useState(i!==`all`),w=y===void 0&&(o||a.automations>0||i!==`all`),T=y??S;return(0,Q.jsxs)(`div`,{"data-slot":`tasks-toolbar`,className:`flex flex-wrap items-center gap-2`,children:[(0,Q.jsxs)(`div`,{className:`flex min-w-0 basis-full items-center gap-2 md:contents`,children:[(0,Q.jsxs)(`div`,{className:`relative min-w-0 flex-1 md:order-1 md:min-w-48`,children:[(0,Q.jsx)(mi,{className:`pointer-events-none absolute top-1/2 left-2.5 size-3.5 -translate-y-1/2 text-soft-foreground`,"aria-hidden":`true`}),(0,Q.jsx)(`input`,{type:`text`,value:e,onChange:e=>t(e.target.value),placeholder:n,"aria-label":r,ref:x,className:q(`h-11 w-full rounded-md border border-input bg-card pl-8 text-base text-foreground outline-none placeholder:text-soft-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 md:h-9 md:text-[13px]`,e?`pr-11 md:pr-9`:`pr-3`)}),e?(0,Q.jsx)(`button`,{type:`button`,"data-slot":`task-search-clear`,"aria-label":`Clear search`,onClick:()=>{t(``),x.current?.focus()},className:`absolute top-1/2 right-0 flex size-11 -translate-y-1/2 items-center justify-center rounded-md text-soft-foreground hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none md:size-9`,children:(0,Q.jsx)(dl,{className:`size-3.5`,"aria-hidden":`true`})}):null]}),v?(0,Q.jsx)(`div`,{className:`shrink-0 md:order-3`,children:v}):null,w?(0,Q.jsx)(Y,{type:`button`,variant:`outline`,size:`icon`,"data-slot":`origin-filter-toggle`,"data-active":S||i!==`all`,"aria-label":`Filter by origin`,"aria-expanded":S,onClick:()=>C(e=>!e),className:q(`shrink-0 md:hidden`,(S||i!==`all`)&&`border-accent-strong bg-accent-strong/10 text-accent-text hover:bg-accent-strong/15 hover:text-accent-text`),children:(0,Q.jsx)(Li,{"aria-hidden":`true`})}):null,b?(0,Q.jsx)(`div`,{className:`shrink-0 md:hidden`,children:b}):null]}),(0,Q.jsx)(`div`,{className:q(`md:order-2`,!T&&`max-md:hidden`),children:(0,Q.jsx)(Mk,{origin:i,counts:a,automations:o,onChange:s,compact:!0})}),(0,Q.jsx)(`div`,{className:`hidden md:order-4 md:block`,children:(0,Q.jsx)(Jk,{columns:c,showReferences:m,expandedColumns:l,columnsPending:u,onToggleColumn:d,detailedTable:f,onToggleDetailed:p})}),h.length>0?(0,Q.jsx)(`div`,{className:`hidden md:order-5 md:block`,children:(0,Q.jsx)(Nk,{onExpand:()=>_(h,!1),onCollapse:()=>_(h,!0),compact:!0,allCollapsed:g})}):null]})}var Xk=1e3;function Zk(e){return e.isPending&&e.failureCount===0}function Qk({scope:e,scopePending:t,children:n}){let[r,i]=Z.useState(!1);return Z.useEffect(()=>{if(!t||r)return;let e=setTimeout(()=>i(!0),Xk);return()=>clearTimeout(e)},[t,r]),t&&!r?(0,Q.jsx)(`div`,{"data-slot":`tasks-header-status`,"aria-busy":`true`,className:`min-h-11 md:min-h-8`}):(!e&&!r&&i(!0),(0,Q.jsxs)(`div`,{"data-slot":`tasks-header-status`,className:`flex flex-wrap items-center gap-x-3 gap-y-1`,children:[e&&!r?(0,Q.jsxs)(`span`,{className:`hidden items-center gap-1.5 whitespace-nowrap text-xs font-medium text-muted-foreground md:inline-flex`,children:[(0,Q.jsx)(`span`,{"data-slot":`tasks-project-scope`,children:e}),n?(0,Q.jsx)(`span`,{"aria-hidden":`true`,"data-slot":`tasks-scope-separator`,className:`text-soft-foreground`,children:`·`}):null]}):null,n]}))}function $k({projectName:e,projectScopePending:t,status:n,secondaryActions:r}){return{title:`Project tasks`,status:(0,Q.jsx)(Qk,{scope:e,scopePending:t,children:n}),secondaryActions:r,primaryAction:(0,Q.jsx)(cs,{asChild:!0,variant:`primary`,"data-slot":`new-task-inline`,children:(0,Q.jsxs)(X,{to:`/new`,children:[(0,Q.jsx)(vi,{"aria-hidden":`true`}),`New task`]})})}}function eA(e,t,n,r){if(!(!e||t<=0||r!==``))return(0,Q.jsx)(ps,{summary:`${t} ${n} ${t===1?`task`:`tasks`} in this project.`,actions:(0,Q.jsx)(Y,{variant:`outline`,size:`sm`,asChild:!0,children:(0,Q.jsx)(X,{to:`/new`,children:`Start another task`})})})}function tA(e,t){return e===void 0?`full`:us(t)}function nA(e){return{"data-presentation":e?`resources`:`summary`}}var rA=150;function iA(e,t){se();let n=U(),[r,i]=Z.useState(``),[a,o]=Z.useState(``);Z.useEffect(()=>{let e=setTimeout(()=>o(r),rA);return()=>clearTimeout(e)},[r]);let s=e!==void 0&&Lo(e).archived>=200,{data:c,isError:l,isPlaceholderData:u,hasNextPage:f,isFetchingNextPage:p,fetchNextPage:m,refetch:h}=d(a,t===`archived`&&(a!==``||s)),g=c?.pages,_=Z.useMemo(()=>g||l?{runs:(g??[]).flatMap(e=>e.runs),query:u?null:a,hasMore:f,loading:p,onLoadMore:()=>void(g?m():h()),failed:l}:void 0,[g,l,u,a,f,p,m,h]),v=a===``?g:n.getQueryData(ge.runs.archived(``))?.pages,y=v===void 0?void 0:v.at(-1)?.nextCursor!=null;return{pages:Z.useMemo(()=>_&&{..._,plainHasMore:y},[_,y]),total:v?.[0]?.total,search:i}}function aA({pages:e}){return e.failed?(0,Q.jsxs)(`p`,{role:`alert`,"data-slot":`archived-older-error`,className:`mt-3.5 flex items-center justify-center gap-2.5 text-[13px] text-muted-foreground`,children:[`Could not load older archived tasks.`,(0,Q.jsx)(Y,{variant:`outline`,onClick:e.onLoadMore,children:`Retry`})]}):e.hasMore?(0,Q.jsx)(Y,{"data-slot":`archived-older`,variant:`outline`,className:`mt-3.5 self-center`,disabled:e.loading,onClick:e.onLoadMore,children:e.loading?`Loading older archived…`:`Show older archived`}):null}function oA({error:e,onRetry:t}){return e?(0,Q.jsxs)(`div`,{role:`alert`,className:`rounded-xl border border-border bg-card p-6`,children:[(0,Q.jsx)(`h2`,{className:`text-lg`,children:`Could not load tasks`}),(0,Q.jsx)(`p`,{className:`mt-2 text-sm text-muted-foreground`,children:e}),(0,Q.jsx)(Y,{variant:`outline`,className:`mt-4`,onClick:t,children:`Retry`})]}):(0,Q.jsx)(`div`,{role:`status`,"aria-label":`Loading tasks`,className:`rounded-xl border border-border bg-card p-6 text-sm text-muted-foreground`,children:`Loading tasks…`})}function sA(e,t){return e.length>0&&e.every(t)}function cA(e,t){return n=>(t===null?n.delete(e):n.set(e,t),n)}function lA(e){return e===void 0?`unknown`:new Intl.NumberFormat().format(e)}function uA(e,t){return`Input tokens: ${lA(e)}; output tokens: ${lA(t)}`}function dA(e,t,n=`compact`){let r=e===void 0?`—`:Cs(e),i=t===void 0?`—`:Cs(t);return n===`table`?`${r} / ${i}`:`IN ${r} · OUT ${i}`}function fA({inputTokens:e,outputTokens:t,variant:n=`compact`,omitWhenUnknown:r=!0,className:i,title:a}){return r&&e===void 0&&t===void 0?null:(0,Q.jsx)(`span`,{"data-slot":`directional-usage`,"aria-label":uA(e,t),title:a,className:q(`font-mono tabular-nums`,i),children:dA(e,t,n)})}function pA({model:e,showTokens:t,showCost:n,liveUsageSource:r=`stream`,openLink:i,extraActions:a,className:o}){let[s,c]=Z.useState(!1);return(0,Q.jsxs)(po,{open:s,onOpenChange:c,children:[(0,Q.jsx)(co,{asChild:!0,children:(0,Q.jsxs)(`button`,{type:`button`,"data-slot":`task-usage-trigger`,"data-task-control":`usage`,"aria-expanded":s,"aria-label":`Usage and telemetry for ${e.title}`,className:q(`inline-flex h-7 max-w-full items-center gap-1 rounded-md border border-border bg-background px-2 font-mono text-xs text-muted-foreground tabular-nums transition-colors hover:border-control-border hover:bg-muted hover:text-foreground focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring max-md:min-h-11 max-md:px-2.5`,s&&`border-accent-strong bg-accent-strong/10 text-foreground`,o),children:[(0,Q.jsx)(`span`,{className:`min-w-0 truncate`,children:e.usageSummary}),(0,Q.jsx)(ta,{className:q(`size-3 shrink-0 opacity-70 transition-transform motion-reduce:transition-none`,s&&`rotate-180`),"aria-hidden":`true`})]})}),s?(0,Q.jsx)(uo,{align:`end`,collisionPadding:8,"data-slot":`task-telemetry-popover`,className:`max-h-(--radix-popover-content-available-height) w-80 max-w-[calc(100vw-16px)] overflow-y-auto overscroll-contain p-3.5`,children:(0,Q.jsx)(gA,{model:e,showTokens:t,showCost:n,liveUsageSource:r,openLink:i,extraActions:a})}):null]})}function mA({model:e,showTokens:t,showCost:n}){return(0,Q.jsx)(hA,{model:e,sample:Nr(e.runId),showTokens:t,showCost:n})}function hA({model:e,sample:t,showTokens:n,showCost:r}){let{run:i}=e,a=tr(i,t),o=a.cpu.kind===`live`||a.mem.kind===`live`;return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2.5`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,Q.jsx)(`span`,{className:`text-xs font-semibold tracking-[0.05em] text-accent-text uppercase`,children:`Task telemetry`}),(0,Q.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e.hostStale?`Stale`:o?`Live`:`Recorded`})]}),(0,Q.jsxs)(`dl`,{className:`grid grid-cols-2 gap-x-3 gap-y-2.5 text-xs`,children:[n?(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`dt`,{className:`text-xs text-muted-foreground`,children:`Tokens IN / OUT`}),(0,Q.jsx)(`dd`,{className:`mt-0.5 font-mono text-foreground`,children:(0,Q.jsx)(fA,{inputTokens:i.inputTokens,outputTokens:i.outputTokens,variant:`table`,omitWhenUnknown:!1,className:`whitespace-nowrap`})})]}):null,r?(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`dt`,{className:`text-xs text-muted-foreground`,children:`Cost`}),(0,Q.jsx)(`dd`,{className:`mt-0.5 font-mono text-foreground tabular-nums`,children:_r(i.costUsd)||`—`})]}):null,(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`dt`,{className:`text-xs text-muted-foreground`,children:`CPU`}),(0,Q.jsx)(`dd`,{"data-usage":`cpu`,"data-usage-kind":a.cpu.kind,title:a.cpu.title,className:`mt-0.5 font-mono text-foreground tabular-nums`,children:a.cpu.text||`—`})]}),(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`dt`,{className:`text-xs text-muted-foreground`,children:`Memory`}),(0,Q.jsx)(`dd`,{"data-usage":`mem`,"data-usage-kind":a.mem.kind,title:a.mem.title,className:`mt-0.5 font-mono text-foreground tabular-nums`,children:a.mem.text||`—`})]}),e.branch?(0,Q.jsxs)(`div`,{className:`col-span-2 border-t border-border pt-2`,children:[(0,Q.jsx)(`dt`,{className:`text-xs text-muted-foreground`,children:`Branch`}),(0,Q.jsx)(`dd`,{className:`mt-1`,children:(0,Q.jsx)(Mm,{value:e.branch,variant:`chip`})})]}):null]})]})}function gA({model:e,showTokens:t,showCost:n,liveUsageSource:r,openLink:i,extraActions:a}){return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[r===`stream`?(0,Q.jsx)(mA,{model:e,showTokens:t,showCost:n}):(0,Q.jsx)(hA,{model:e,sample:e.snapshotUsage,showTokens:t,showCost:n}),(0,Q.jsx)(`div`,{className:`border-t border-border pt-2.5`,children:(0,Q.jsx)(Ik,{compact:!0,projectId:e.projectId,hostId:e.hostId,runId:e.runId,status:e.status.label,error:e.run.error,open:(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[i,a]})})})]})}function _A({children:e}){return(0,Q.jsx)(Y,{asChild:!0,variant:`outline`,size:`sm`,children:e})}var vA=new Set(JD);function yA(e,t){return XD.filter(n=>vA.has(n.id)?n.id===`task`?!0:n.id===`reference`&&!t?!1:eO(n.id,e):!1)}var bA=240,xA=10,SA=32;function CA(e){return e.map(e=>e.id===`task`?`minmax(0, 1fr)`:e.width??`100px`).join(` `)}function wA(e){return e.reduce((e,t)=>e+(t.id===`task`?bA:Number.parseFloat(t.width??`100`)||100),0)+Math.max(0,e.length-1)*xA+SA}function TA(e,t,n){return q(n?`line-clamp-2 min-w-0 whitespace-normal rounded-sm text-[13.5px] leading-[1.35]`:`min-w-0 truncate rounded-sm text-[13px] leading-[18px]`,e?`font-semibold text-foreground`:t?`font-normal text-foreground`:`font-medium text-foreground`,`focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-link-foreground`)}var EA={ask:{label:`Ask`,tone:`text-semantic-amber`},permission:{label:`Permission`,tone:`text-semantic-amber`},review:{label:`Review`,tone:`text-accent-text`},error:{label:`Error`,tone:`text-semantic-red`}};function DA({preview:e}){if(!e)return null;let t=EA[e.kind];return(0,Q.jsxs)(`p`,{"data-slot":`task-state-preview`,"data-preview-kind":e.kind,title:e.text,className:`mt-1 flex min-w-0 items-baseline gap-1.5 text-xs leading-[1.35] text-muted-foreground`,children:[(0,Q.jsx)(`span`,{className:q(`shrink-0 text-xs font-semibold`,t.tone),children:t.label}),(0,Q.jsx)(`span`,{className:`min-w-0 truncate`,children:e.text})]})}function OA({badge:e}){return(0,Q.jsxs)(`span`,{"data-slot":`task-automation-badge`,"data-origin":`automation`,title:`Automation ${e.id}`,className:`inline-flex max-w-[180px] shrink-0 items-center gap-1 truncate rounded-full border border-info/30 bg-info/10 px-2 py-px text-xs font-medium text-semantic-info`,children:[(0,Q.jsx)(Zi,{className:`size-2.5 shrink-0`,"aria-hidden":`true`}),(0,Q.jsx)(`span`,{className:`truncate`,children:e.label})]})}function kA({name:e,href:t,fullPage:n=!1}){let r=`inline-flex h-[18px] max-w-[140px] shrink-0 items-center truncate rounded-md border border-border bg-muted px-1.5 font-mono text-xs leading-none font-medium text-foreground`;return t?n?(0,Q.jsx)(`a`,{href:t,"data-slot":`task-project`,title:e,className:q(r,`hover:border-control-border hover:bg-muted/80`),children:e}):(0,Q.jsx)(G,{to:t,"data-slot":`task-project`,title:e,className:q(r,`hover:border-control-border hover:bg-muted/80`),children:e}):(0,Q.jsx)(`span`,{"data-slot":`task-project`,className:r,title:e,children:e})}function AA({scoped:e,fullPage:t=!1,to:n,className:r,title:i,children:a,...o}){return t?(0,Q.jsx)(`a`,{href:n,title:i,className:r,...o,children:a}):e?(0,Q.jsx)(X,{to:n,title:i,className:r,...o,children:a}):(0,Q.jsx)(G,{to:n,title:i,className:r,...o,children:a})}function jA({run:e,to:t,title:n,unread:r,unreadTone:i,readDone:a,isWorker:o,pinned:s,automationBadge:c,scoped:l=!0,onTogglePin:u,lines:d=1,compact:f=!1}){let p=tk(e);if(p.editing)return(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,"data-slot":`table-title-editor`,children:[(0,Q.jsx)(XO,{editor:p,className:`basis-full text-[13px] font-medium`}),(0,Q.jsx)(Y,{size:`sm`,"aria-label":`Save title`,onMouseDown:e=>e.preventDefault(),onClick:p.commit,children:`Save`}),(0,Q.jsx)(Y,{size:`sm`,variant:`outline`,"aria-label":`Cancel rename`,onMouseDown:e=>e.preventDefault(),onClick:p.cancel,children:`Cancel`})]});let m=q(d===2?`line-clamp-2 min-w-0 whitespace-normal rounded-sm text-[13px] leading-[18px]`:`min-w-0 truncate rounded-sm text-[13px] leading-[18px]`,r?`font-semibold text-foreground`:a?`font-normal text-foreground`:`font-medium text-foreground`,`focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-link-foreground`);return(0,Q.jsxs)(`span`,{className:q(`flex min-w-0 items-center gap-1.5`,f||d===1?`h-[18px]`:`min-h-[18px]`),children:[o?(0,Q.jsx)(`span`,{className:`shrink-0 text-xs text-muted-foreground`,children:`Worker`}):null,(0,Q.jsx)(AA,{scoped:l,to:t,title:n,"data-task-control":`title`,className:m,children:n}),c?(0,Q.jsx)(OA,{badge:c}):null,r?(0,Q.jsx)(Qo,{tone:i,role:`img`,"aria-label":`unread`,title:`Unread — not opened since it finished`,className:`shrink-0`}):null,(0,Q.jsx)(`button`,{type:`button`,"data-slot":`row-rename`,"aria-label":`Rename task`,onClick:p.begin,className:`shrink-0 rounded-sm p-0.5 text-soft-foreground opacity-0 transition-opacity group-hover/row:opacity-100 hover:text-foreground focus-visible:opacity-100 focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`,children:(0,Q.jsx)(ol,{className:`size-3`,"aria-hidden":`true`})}),(0,Q.jsx)(`span`,{"aria-hidden":`true`,className:`flex-1`}),u?(0,Q.jsx)(N_,{pinned:s,onToggle:u,className:`size-[19px] opacity-0 group-hover/row:opacity-100 focus-visible:opacity-100 no-hover:opacity-100 data-[pinned=true]:text-semantic-amber data-[pinned=true]:opacity-100`}):null]})}function MA({model:e,scoped:t,onTogglePin:n,compact:r}){return(0,Q.jsx)(jA,{run:e.run,to:e.href,title:e.title,unread:e.unread,unreadTone:e.unreadTone,readDone:e.readDone,isWorker:e.isWorker,pinned:e.pinned,automationBadge:e.automationBadge,scoped:t,onTogglePin:n?t=>n(e,t):void 0,compact:r})}function NA({model:e,scoped:t,showProject:n,onTogglePin:r,clamp:i}){return(0,Q.jsxs)(`span`,{className:q(`flex min-w-0 items-center gap-1.5`,i?`items-start`:`min-h-[18px]`),children:[n&&e.hostLabel?(0,Q.jsx)(Dd,{label:e.hostLabel,hostId:e.hostId}):null,n&&e.projectName?(0,Q.jsx)(kA,{name:e.projectName,href:e.projectHref,fullPage:e.fullPageNav}):null,e.isWorker?(0,Q.jsx)(`span`,{className:`shrink-0 text-xs text-muted-foreground`,children:`Worker`}):null,(0,Q.jsx)(AA,{scoped:t,fullPage:e.fullPageNav,to:e.href,title:e.title,"data-task-control":`title`,className:q(TA(e.unread,e.readDone,i),i&&`flex-1`),children:e.title}),!i&&e.automationBadge?(0,Q.jsx)(OA,{badge:e.automationBadge}):null,e.unread?(0,Q.jsx)(Qo,{tone:e.unreadTone,role:`img`,"aria-label":`unread`,title:`Unread — not opened since it finished`,className:q(`shrink-0`,i&&`mt-1.5`)}):null,i?null:(0,Q.jsx)(`span`,{"aria-hidden":`true`,className:`flex-1`}),r?(0,Q.jsx)(N_,{pinned:e.pinned,onToggle:t=>r(e,t),className:i?`-mt-0.5 shrink-0 data-[pinned=true]:text-semantic-amber`:`size-[19px] opacity-0 group-hover/row:opacity-100 focus-visible:opacity-100 no-hover:opacity-100 data-[pinned=true]:text-semantic-amber data-[pinned=true]:opacity-100`}):null]})}function PA({model:e,showProject:t,showAutomationOnMeta:n,trailing:r}){let{status:i,scheduled:a,queuePosition:o,runnerModel:s,tags:c}=e;return(0,Q.jsxs)(`div`,{"data-slot":`task-meta-line`,className:`mt-1 flex min-w-0 flex-wrap items-center gap-x-1.5 gap-y-1 text-xs text-muted-foreground`,children:[(0,Q.jsxs)(Td,{dot:i.tone,shape:i.shape,pulse:!e.hostStale&&i.pulse,title:a?.title??i.label,className:`shrink-0 py-0.5`,children:[i.label,a?(0,Q.jsxs)(`span`,{className:`tabular-nums`,children:[` `,a.label]}):null]}),e.hostStale?(0,Q.jsx)(Od,{}):null,t&&e.hostLabel?(0,Q.jsx)(Dd,{label:e.hostLabel,hostId:e.hostId}):null,t&&e.projectName?(0,Q.jsx)(kA,{name:e.projectName,href:e.projectHref,fullPage:e.fullPageNav}):null,n&&e.automationBadge?(0,Q.jsx)(OA,{badge:e.automationBadge}):null,s?(0,Q.jsxs)(`span`,{className:`inline-flex min-w-0 items-center gap-1.5`,children:[(0,Q.jsx)(`span`,{"aria-hidden":`true`,className:`max-md:hidden`,children:`·`}),(0,Q.jsx)(`span`,{"data-slot":`task-runner-model`,className:`min-w-0 truncate`,children:s})]}):null,e.run.status===`queued`&&o!==null?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),(0,Q.jsxs)(`span`,{"data-slot":`queue-note`,className:`shrink-0 tabular-nums`,children:[`#`,o,` in queue`]})]}):null,c.map(e=>(0,Q.jsx)(`span`,{"data-slot":`task-tag`,className:`rounded bg-muted px-1.5 py-px text-xs text-soft-foreground`,children:e},e)),r]})}function FA({model:e,onSetRead:t,onArchive:n,busy:r}){return!t&&!n?null:(0,Q.jsxs)(Q.Fragment,{children:[t&&e.canToggleRead?(0,Q.jsxs)(Y,{type:`button`,variant:`outline`,size:`sm`,"data-action":e.unread?`mark-read`:`mark-unread`,"aria-label":e.unread?`Mark ${e.title} read`:`Mark ${e.title} unread`,disabled:r,onClick:()=>t(e,e.unread),children:[e.unread?(0,Q.jsx)(ba,{className:`size-3.5`,"aria-hidden":`true`}):(0,Q.jsx)(qc,{className:`size-3.5`,"aria-hidden":`true`}),e.unread?`Mark read`:`Mark unread`]}):null,n&&e.canArchive?(0,Q.jsxs)(Y,{type:`button`,variant:`outline`,size:`sm`,"data-action":e.run.archived?`unarchive-run`:`archive-run`,"aria-label":e.run.archived?`Restore ${e.title} to the active list`:`Archive ${e.title}`,disabled:r,onClick:()=>n(e,!e.run.archived),children:[e.run.archived?(0,Q.jsx)(Pc,{className:`size-3.5`,"aria-hidden":`true`}):(0,Q.jsx)(Wi,{className:`size-3.5`,"aria-hidden":`true`}),e.run.archived?`Unarchive`:`Archive`]}):null]})}function IA({model:e,scoped:t}){return e.references.length===0?(0,Q.jsx)(`span`,{className:`text-xs text-soft-foreground`,children:`—`}):t?(0,Q.jsx)(D_,{run:e.run,reference:e.references[0],compact:!0}):(0,Q.jsx)(M_,{references:e.references,maxVisible:1,taskTitle:e.title,projectId:e.projectId,hostId:e.hostId,runId:e.runId,repoBase:e.repoBase,compact:!0})}function LA({model:e,scoped:t,showTokens:n,showCost:r,liveUsageSource:i,onSetRead:a,onArchive:o,busy:s,className:c}){return(0,Q.jsx)(pA,{model:e,showTokens:n,showCost:r,liveUsageSource:i,className:c,openLink:(0,Q.jsx)(_A,{children:(0,Q.jsxs)(AA,{scoped:t,fullPage:e.fullPageNav,to:e.href,"data-task-control":`open`,children:[`Open task`,(0,Q.jsxs)(`span`,{className:`sr-only`,children:[`: `,e.title]})]})}),extraActions:(0,Q.jsx)(FA,{model:e,onSetRead:a,onArchive:o,busy:s})})}function RA({column:e,hasUsageColumn:t,...n}){let{model:r,now:i,scoped:a,showProject:o,allowRename:s,compact:c,onTogglePin:l}=n;switch(e.id){case`task`:return(0,Q.jsxs)(`div`,{role:`cell`,"data-column-id":`task`,className:q(`min-w-0 pr-1`,c?`py-1.5`:`py-2.5`),children:[s?(0,Q.jsx)(MA,{model:r,scoped:a,onTogglePin:l,compact:c}):(0,Q.jsx)(NA,{model:r,scoped:a,showProject:o,onTogglePin:l,clamp:!1}),(0,Q.jsx)(PA,{model:r,showProject:!1,showAutomationOnMeta:!1,trailing:t?null:(0,Q.jsx)(LA,{...n,className:`ml-auto h-6 px-1.5 text-xs`})}),(0,Q.jsx)(DA,{preview:r.statePreview})]});case`runner`:return(0,Q.jsx)(`div`,{role:`cell`,"data-column-id":`runner`,className:`min-w-0 truncate text-xs text-muted-foreground`,title:r.runnerModel,children:r.runnerModel??(0,Q.jsx)(`span`,{className:`text-soft-foreground`,children:`—`})});case`workflow`:return(0,Q.jsx)(`div`,{role:`cell`,"data-column-id":`workflow`,className:`min-w-0 truncate text-xs text-muted-foreground`,title:r.workflow,children:r.workflow});case`branch`:return(0,Q.jsx)(`div`,{role:`cell`,"data-column-id":`branch`,className:`min-w-0 overflow-hidden`,children:r.branch?(0,Q.jsx)(Mm,{value:r.branch,variant:`chip`}):(0,Q.jsx)(`span`,{className:`text-xs text-soft-foreground`,children:`—`})});case`diff`:return(0,Q.jsx)(`div`,{role:`cell`,"data-column-id":`diff`,className:`text-xs`,children:r.diffStat?(0,Q.jsx)(km,{stat:r.diffStat}):(0,Q.jsx)(`span`,{className:`text-soft-foreground`,children:`—`})});case`reference`:return(0,Q.jsx)(`div`,{role:`cell`,"data-column-id":`reference`,className:`min-w-0`,children:(0,Q.jsx)(IA,{model:r,scoped:a})});case`usage`:return(0,Q.jsx)(`div`,{role:`cell`,"data-column-id":`usage`,className:`flex justify-end`,children:(0,Q.jsx)(LA,{...n})});case`started`:return(0,Q.jsx)(`div`,{role:`cell`,"data-column-id":`started`,className:`text-right text-xs whitespace-nowrap text-muted-foreground tabular-nums`,children:(0,Q.jsx)(jm,{iso:r.startedAt,now:i})});default:return null}}function zA(e){return e instanceof Element&&!!e.closest(`a, button, input, [role="dialog"]`)}function BA(e,t){return e===t||e.run===t.run&&e.hostId===t.hostId&&e.hostLabel===t.hostLabel&&e.hostStale===t.hostStale&&e.href===t.href&&e.projectName===t.projectName&&e.projectHref===t.projectHref&&e.runnerModel===t.runnerModel&&e.usageSummary===t.usageSummary&&e.queuePosition===t.queuePosition&&e.automationBadge?.label===t.automationBadge?.label&&e.tags.length===t.tags.length&&e.tags.every((e,n)=>e===t.tags[n])}function VA(e,t){let{model:n,...r}=e,{model:i,...a}=t;return BA(n,i)&&Object.keys(r).every(e=>r[e]===a[e])}function HA(e){let t=To(),n=Kn();return(r,i)=>{if(i){window.location.assign(r);return}e?t(r):n(r)}}function UA(e,t){return{"data-slot":t,"data-task-row":`true`,"data-status":e.run.status,"data-urgent":e.urgent?`true`:void 0,"data-run-id":e.runId,"data-project":e.projectId,"data-host-id":e.hostId,"data-host-stale":e.hostStale?`true`:void 0,"data-host-live":e.hostId===void 0?void 0:String(!e.hostStale)}}var WA=Z.memo(function({rowIndex:e,columns:t,gridTemplate:n,rowSlot:r,...i}){let{model:a,scoped:o}=i,s=HA(o),c=t.some(e=>e.id===`usage`);return(0,Q.jsx)(`div`,{role:`row`,"aria-rowindex":e,...UA(a,r),style:{gridTemplateColumns:n},onClick:e=>{zA(e.target)||s(a.href,a.fullPageNav)},className:q(`group/row grid cursor-pointer items-center gap-x-2.5 border-b border-border px-4 transition-colors hover:bg-muted/70`,a.hostStale?`bg-muted/30 hover:bg-muted/50`:a.urgent&&`bg-pending/[0.07] hover:bg-pending/[0.11]`),children:t.map(e=>(0,Q.jsx)(RA,{column:e,hasUsageColumn:c,...i},e.id))})},VA),GA=Z.memo(function({model:e,now:t,scoped:n,showProject:r,showTokens:i,showCost:a,liveUsageSource:o,onTogglePin:s,onSetRead:c,onArchive:l,busy:u,cardSlot:d}){let f=HA(n);return(0,Q.jsxs)(`article`,{...UA(e,d),onClick:t=>{zA(t.target)||f(e.href,e.fullPageNav)},className:q(`flex cursor-pointer flex-col gap-1.5 border-b border-border px-3 py-2.5 transition-colors`,e.hostStale?`bg-muted/30`:e.urgent&&`bg-pending/[0.07]`),children:[(0,Q.jsx)(`div`,{"data-slot":`mobile-task-title-row`,children:(0,Q.jsx)(NA,{model:e,scoped:n,showProject:!1,onTogglePin:s,clamp:!0})}),(0,Q.jsx)(PA,{model:e,showProject:r,showAutomationOnMeta:!0,trailing:e.runnerModel?null:(0,Q.jsx)(`span`,{"data-slot":`mobile-task-workflow`,className:`min-w-0 truncate`,children:e.workflow})}),(0,Q.jsx)(DA,{preview:e.statePreview}),(0,Q.jsxs)(`div`,{"data-slot":`mobile-task-meta`,className:`-my-1 flex min-w-0 items-center justify-between gap-2 text-xs text-muted-foreground`,children:[(0,Q.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5 overflow-hidden`,children:[e.references.length>0?(0,Q.jsx)(IA,{model:e,scoped:n}):null,e.references.length>0&&(e.queuePosition!==null||e.diffStat)?(0,Q.jsx)(`span`,{"aria-hidden":`true`,className:`shrink-0 text-soft-foreground`,children:`·`}):null,e.queuePosition===null?e.diffStat?(0,Q.jsx)(km,{stat:e.diffStat}):e.references.length===0?(0,Q.jsx)(`span`,{"data-slot":`mobile-task-workflow`,className:`min-w-0 truncate`,children:e.workflow}):null:(0,Q.jsxs)(`span`,{"data-slot":`queue-note`,className:`shrink-0 tabular-nums`,children:[`#`,e.queuePosition,` in queue`]})]}),(0,Q.jsxs)(`span`,{className:`flex shrink-0 items-center gap-2`,children:[(0,Q.jsx)(pA,{model:e,showTokens:i,showCost:a,liveUsageSource:o,className:`max-md:px-2`,openLink:(0,Q.jsx)(_A,{children:(0,Q.jsxs)(AA,{scoped:n,fullPage:e.fullPageNav,to:e.href,"data-task-control":`open`,children:[`Open task`,(0,Q.jsxs)(`span`,{className:`sr-only`,children:[`: `,e.title]})]})}),extraActions:(0,Q.jsx)(FA,{model:e,onSetRead:c,onArchive:l,busy:u})}),(0,Q.jsx)(jm,{iso:e.startedAt,now:t})]})]})]})},VA);function KA({items:e,density:t,now:n,showHeader:r=!0,showProject:i=!1,showReferences:a=!0,expandedColumns:o=$D(void 0),showTokens:s=!0,showCost:c=!0,scopedLinks:l=!0,liveUsageSource:u=`stream`,allowRename:d=!1,onTogglePin:f,onArchive:p,onSetRead:m,busy:h=!1,tableSlot:g=`tasks-summary`,rowSlot:_=`task-summary-row`,cardSlot:v=`task-card`}){let y=Z.useMemo(()=>yA(o,a),[o,a]),b=Z.useMemo(()=>CA(y),[y]),x=Z.useMemo(()=>wA(y),[y]);if(t===`card`)return(0,Q.jsx)(Pf,{children:(0,Q.jsx)(`div`,{"data-slot":`task-cards`,"data-task-table":`true`,"data-density":`card`,className:`flex flex-col overflow-hidden rounded-lg border border-card-edge bg-card shadow-card`,children:(0,Q.jsx)(Tk,{itemSize:107,items:e,itemKey:e=>e.key,children:e=>(0,Q.jsx)(GA,{model:e,now:n,scoped:l,showProject:i,showTokens:s,showCost:c,liveUsageSource:u,onTogglePin:f,onSetRead:m,onArchive:p,busy:h,cardSlot:v},e.key)})})});let S=t===`compact`;return(0,Q.jsx)(Pf,{children:(0,Q.jsx)(`div`,{"data-slot":g,"data-task-table":`true`,"data-density":t,"data-head":r,"data-reference-column":a,className:`overflow-x-auto rounded-lg border border-card-edge bg-card shadow-card`,children:(0,Q.jsxs)(`div`,{role:`table`,"aria-rowcount":e.length+1,style:{minWidth:`${x}px`},className:`w-full`,children:[(0,Q.jsx)(`div`,{role:`row`,"aria-rowindex":1,"data-slot":`task-table-head`,style:{gridTemplateColumns:b},className:q(`grid items-center gap-x-2.5 border-b border-border px-4`,!r&&`sr-only`),children:y.map(e=>(0,Q.jsx)(`div`,{role:`columnheader`,"data-column-id":e.id,className:q(`flex h-8 items-center text-xs font-medium tracking-[0.04em] whitespace-nowrap text-muted-foreground uppercase`,e.align===`right`&&`justify-end text-right`),children:e.summaryLabel??e.label},e.id))}),(0,Q.jsx)(Tk,{itemSize:S?56:63,items:e,itemKey:e=>e.key,children:(e,t)=>(0,Q.jsx)(WA,{model:e,rowIndex:t+2,columns:y,gridTemplate:b,now:n,scoped:l,showProject:i,allowRename:d,showTokens:s,showCost:c,liveUsageSource:u,compact:S,onTogglePin:f,onSetRead:m,onArchive:p,busy:h,rowSlot:_},e.key)})]})})})}function qA(){let[e,t]=rc(),n=e.get(`archived`)===`1`?`archived`:`active`,r=Mr(e.get(`origin`)),[i,a]=Z.useState(n),[o,s]=Z.useState(r);Z.useEffect(()=>a(n),[n]),Z.useEffect(()=>s(r),[r]);let c=e.get(`q`)??``,l=Z.useRef(void 0);return Z.useEffect(()=>{let e=l;return()=>clearTimeout(e.current)},[]),{view:i,setView:e=>{a(e),t(cA(`archived`,e===`archived`?`1`:null))},origin:o,setOrigin:e=>{s(e),t(cA(`origin`,e===`all`?null:e))},urlQuery:c,writeQuery:Z.useCallback((e,n)=>{clearTimeout(l.current);let r=e.trim();l.current=setTimeout(()=>t(e=>{let t=e.get(`q`),i=cA(`q`,r===``?null:r)(e);return i.get(`q`)!==t&&n(r),i}),JA)},[t])}}var JA=250,YA=`cez-task-list-folds`,XA=`cez-task-list-folds-changed`;function ZA(e,t,n=new Set){let[r,i]=(0,Z.useState)(()=>tv(YA));(0,Z.useEffect)(()=>{let e=e=>{e instanceof StorageEvent&&e.key!==null&&e.key!==Qr(`cez-task-list-folds`)||i(e instanceof CustomEvent?e.detail:tv(YA))};return window.addEventListener(`storage`,e),window.addEventListener(XA,e),()=>{window.removeEventListener(`storage`,e),window.removeEventListener(XA,e)}},[]);let a=(0,Z.useCallback)(n=>JSON.stringify([e,t,n]),[e,t]),o=(0,Z.useCallback)(e=>{i(t=>{let n=e(t);return nv(n,YA),queueMicrotask(()=>window.dispatchEvent(new CustomEvent(XA,{detail:n}))),n})},[]),s=e=>r[a(e)]===!0;return{isFolded:s,isCollapsed:e=>s(e)&&!n.has(e),toggle:e=>o(t=>({...t,[a(e)]:t[a(e)]!==!0})),setAll:(e,t)=>o(n=>({...n,...Object.fromEntries(e.map(e=>[a(e),t]))})),only:(0,Z.useCallback)((e,t)=>o(n=>({...n,...Object.fromEntries(t.map(t=>[a(t),t!==e]))})),[o,a])}}function QA(e,t,n,r){let i=ZA(e,t,n),a=(0,Z.useRef)(r);a.current=r;let[o,s]=rc(),c=t===`active`?Po(o.get(zo)):null,{only:l}=i;return(0,Z.useEffect)(()=>{c!==null&&(l(c,Vo),a.current?.(),s(e=>(e.delete(zo),e)))},[c,l,s]),i}function $A(e){let t=e?.capabilities,n=t?.tokenMetrics!==!1;return{tokens:t?.tokenUsageMetrics??n,cost:t?.costMetrics??n}}function ej(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:{}}function tj(){let e=U(),t=ce(),n=Z.useRef(0),r=Z.useRef(0),i=Z.useRef(Promise.resolve()),a=Z.useMemo(()=>$D(t.data?.taskTable?.expandedColumns),[t.data?.taskTable?.expandedColumns]),o=Z.useCallback(t=>{if(!XD.find(e=>e.id===t)?.canFold)return;let a=e.getQueryData(V.uiState);if(a===void 0)return;let o=ej(a?.taskTable),s={...o,expandedColumns:tO(o.expandedColumns,t)};e.setQueryData(V.uiState,{...a,taskTable:s});let c=++n.current;r.current=c;let l=i.current.then(async()=>{let t=await Ht({taskTable:s},{keepalive:!0});c===r.current&&e.setQueryData(V.uiState,t)});i.current=l.catch(t=>{H(t instanceof Error?t.message:String(t),{tone:`danger`}),c===r.current&&e.invalidateQueries({queryKey:V.uiState})})},[e]);return{expandedColumns:a,isExpanded:Z.useCallback(e=>eO(e,a),[a]),toggleColumn:o,isPending:t.isPending}}var nj=()=>void 0;function rj({runs:e,view:t,onViewChange:n,onArchiveFinished:r,archivePending:i=!1,onMarkAllRead:a,onRename:o,onTogglePin:s,now:c=Date.now(),showTokens:l=!0,showCost:u=!0,expandedColumns:d=$D(void 0),onToggleColumn:f=()=>void 0,columnsPending:p=!1,projectName:m,projectScopePending:h,runners:g,error:_,onRetry:v,archivedPages:y,archivedTotal:b,onArchivedSearch:x,origin:S,onOriginChange:C,automations:w,urlQuery:T=``,onQueryChange:E,foldScope:D=`project`,automationName:O=nj}){let[k,A]=ij(T,E);Z.useEffect(()=>{x?.(k.trim())},[x,k]);let[j,M]=aj(S,C,w),[N,ee]=Z.useState(!1),P=fs(),F=Z.useMemo(()=>e??[],[e]),I=Z.useMemo(()=>oj({all:F,view:t,query:k,origin:j,archivedPages:y,archivedTotal:b,automationName:O}),[F,t,k,j,y,b,O]),{groups:L,needle:R}=I,te=Z.useMemo(()=>aO({tokens:l,cost:u}),[l,u]),ne=Z.useMemo(()=>iO(),[]),re=QA(D,t,new Set(R?L.map(e=>e.label):[]),()=>A(``)),z=t===`archived`?void 0:s,ie={view:t,unread:I.unread,finished:I.finished,archivePending:i,onMarkAllRead:()=>a(ar(j)),onArchiveFinished:()=>r(ar(j))};return(0,Q.jsx)(ek,{runs:y?[...F,...y.runs]:F,onRename:o,children:(0,Q.jsx)(ls,{route:`tasks`,density:tA(e,I.visibleCount),headerSpacing:`compact`,rootProps:nA(N),bodyClassName:`gap-3`,header:$k({projectName:m,projectScopePending:h,status:(0,Q.jsx)(Vk,{view:t,onSelect:n,activeCount:I.activeCount,archivedCount:I.archivedCount,trailing:e!==void 0&&L.length>0?(0,Q.jsx)(Wk,{count:I.visibleCount,incomplete:I.incomplete,needle:R}):null}),secondaryActions:(0,Q.jsx)(Kk,{surface:`desktop`,...ie})}),sparseFooter:eA(e!==void 0,I.visibleCount,t,R),children:(0,Q.jsxs)(Ek,{layout:`${P}:${N}`,revision:L,visibilityRevision:JSON.stringify([Uo.map(re.isCollapsed),t,d]),className:`flex min-w-0 flex-1 flex-col gap-3`,children:[(0,Q.jsx)(Yk,{query:k,onQueryChange:A,searchPlaceholder:`Search tasks or automations…`,searchLabel:`Search tasks`,origin:j,originCounts:I.originTotals,automations:w,onOriginChange:M,showReferences:yr(L,re.isCollapsed,N),columns:N?te:ne,expandedColumns:d,columnsPending:p,onToggleColumn:f,detailedTable:N,onToggleDetailed:()=>ee(e=>!e),groupLabels:L.map(e=>e.label),allGroupsCollapsed:sA(L.map(e=>e.label),re.isCollapsed),onSetAllFolds:re.setAll,mobileActions:(0,Q.jsx)(Kk,{surface:`mobile`,...ie})}),(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col`,children:[e===void 0?(0,Q.jsx)(oA,{error:_,onRetry:v}):(0,Q.jsx)(sj,{view:t,query:k,origin:j,onShowAll:()=>{A(``),M(`all`)},groups:L,folds:re,grouped:{desktop:P,detailedTable:N,columns:te,expandedColumns:d,onToggleColumn:f,columnsPending:p,onRename:o,onTogglePin:z,now:c,showTokens:l,showCost:u,runners:g,automationName:O}}),t===`archived`&&y?(0,Q.jsx)(aA,{pages:y}):null]})]})})})}function ij(e,t){let[n,r]=Z.useState(e),i=Z.useRef(e),a=Z.useRef(e),o=Z.useRef([]);return Z.useEffect(()=>{if(e===i.current)return;i.current=e;let t=o.current.indexOf(e);o.current=t===-1?[]:o.current.slice(t+1),t===-1&&e!==a.current&&r(e)},[e]),Z.useEffect(()=>{a.current=n.trim(),t?.(n,e=>{o.current.push(e)})},[t,n]),[n,r]}function aj(e,t,n){let[r,i]=Z.useState(`all`);return[xr(e??r,n),t??i]}function oj({all:e,view:t,query:n,origin:r,archivedPages:i,archivedTotal:a,automationName:o}){let s=n.trim(),c=e=>e.automationId===void 0?``:o(e.automationId)??e.automationId,l=i?.query===s,u=new Set(l?i.runs.map(e=>e.id):[]),d=Ko(e,l||s===``?i?.runs??[]:[]).slice(e.length),f=Cr(e,n,c),p=new Set(f.map(e=>e.id)),m=Cr(e.filter(e=>u.has(e.id)&&!p.has(e.id)),``),h=e=>ir(e,r),g=lr([...f,...m,...Cr(d,``)].filter(h),t,e),_=Ko(e,i?.query===``?i.runs:[]),v=Lo(e).archived>=200,y=e.filter(h);return{groups:g,needle:s,visibleCount:g.reduce((e,t)=>e+sr(t).length,0),originTotals:ur(_,t),activeCount:ur(e,`active`)[r],archivedCount:Qn(e,_,r,i?.plainHasMore,a),incomplete:t===`archived`&&v&&i?.hasMore!==!1,finished:kr(y),unread:Yo(y)}}function sj({view:e,query:t,origin:n,onShowAll:r,groups:i,folds:a,grouped:o}){if(i.length===0)return(0,Q.jsx)(cj,{view:e,query:t,origin:n,onShowAll:r});let s=i.filter(e=>!a.isCollapsed(e.label)),c=yr(i,a.isCollapsed);return(0,Q.jsx)(`div`,{className:`flex flex-col gap-3`,children:i.map(t=>{let n=sr(t);return(0,Q.jsx)(Fk,{id:`tasks-group-${e}-${t.label.replaceAll(` `,`-`)}`,label:t.label,count:n.length,tone:Lk(t.label,n),folded:a.isFolded(t.label),collapsed:a.isCollapsed(t.label),onToggle:()=>a.toggle(t.label),children:(0,Q.jsx)(lj,{group:t,showHeader:t===s[0],showReference:c,...o})},t.label)})})}function cj({view:e,query:t,origin:n=`all`,onShowAll:r}){let i=t.trim(),a=i||n!==`all`?`search-miss`:e===`archived`?`archive`:`no-tasks`;return(0,Q.jsx)(`div`,{"data-slot":`tasks-empty`,"data-empty-kind":a,className:`flex flex-1 flex-col`,children:a===`search-miss`?(0,Q.jsx)(tc,{heading:`h2`,icon:(0,Q.jsx)(Ca,{}),tone:`neutral`,title:`No matching tasks`,subtitle:i?`No tasks match “${i}”.`:n===`automations`?`No automation started a task here.`:`No task here was started directly.`,actions:r?(0,Q.jsx)(Y,{variant:`outline`,"data-action":`clear-task-filters`,onClick:r,children:`Show all tasks`}):void 0}):a===`archive`?(0,Q.jsx)(tc,{heading:`h2`,icon:(0,Q.jsx)(Wi,{}),tone:`neutral`,title:`Nothing archived yet`,subtitle:`Finished tasks you archive land here.`}):(0,Q.jsx)(tc,{heading:`h2`,icon:(0,Q.jsx)(nl,{}),tone:`primary`,backdrop:!0,title:`No tasks yet`,subtitle:`Describe a task to get started.`,actions:(0,Q.jsx)(Y,{asChild:!0,children:(0,Q.jsxs)(X,{to:`/new`,children:[(0,Q.jsx)(vi,{"aria-hidden":`true`}),`New task`]})})})})}function lj({showHeader:e,showReference:t,desktop:n,group:r,detailedTable:i,columns:a,expandedColumns:o,onToggleColumn:s,columnsPending:c,onRename:l,onTogglePin:u,now:d,showTokens:f,showCost:p,runners:m,automationName:h}){let g=Z.useMemo(()=>r.rows.flatMap(e=>$n(e).map(t=>({run:t,queuePosition:t.status===`queued`?e.queuePosition:null}))),[r.rows]),_=Z.useMemo(()=>g.map(({run:e,queuePosition:t})=>mk({run:e,queuePosition:t,runners:m,automationName:h,now:d,showTokens:f,showCost:p})),[g,m,h,d,f,p]),v=Z.useCallback((e,t)=>{u?.(e.run,t)},[u]);return n&&i?(0,Q.jsx)(`div`,{"data-slot":`tasks-table`,className:`overflow-x-auto rounded-lg border border-card-edge bg-card shadow-card`,children:(0,Q.jsx)(Pf,{children:(0,Q.jsxs)(`div`,{role:`table`,"aria-rowcount":g.length+1,className:`task-resource-grid`,style:cO(a,o),children:[(0,Q.jsx)(`div`,{role:`row`,"aria-rowindex":1,className:`task-resource-row`,children:a.map(e=>(0,Q.jsx)(dj,{column:e,expanded:eO(e.id,o),onToggle:s,disabled:c},e.id))}),(0,Q.jsx)(Tk,{itemSize:76,items:g,itemKey:({run:e})=>e.id,children:({run:e,queuePosition:t},n)=>(0,Q.jsx)(mj,{rowIndex:n+2,run:e,queuePosition:t,onRename:l,onTogglePin:u,now:d,columns:a,expandedColumns:o,automationName:h})})]})})}):(0,Q.jsx)(KA,{items:_,density:n?`table`:`card`,now:d,showHeader:e,showProject:!1,showReferences:t,expandedColumns:o,showTokens:f,showCost:p,scopedLinks:!0,liveUsageSource:`stream`,allowRename:n,onTogglePin:u?v:void 0})}function uj({children:e,right:t=!1,columnId:n,folded:r=!1}){return(0,Q.jsx)(`div`,{role:`columnheader`,"data-column-id":n,"data-folded":r||void 0,className:q(`h-[38px] border-b border-border px-2.5 text-left text-xs font-semibold tracking-[0.05em] whitespace-nowrap text-supporting-foreground uppercase first:pl-4 last:pr-4`,t&&`text-right`,r&&`px-0 first:pl-0 last:pr-0`),children:e})}function dj({column:e,expanded:t,onToggle:n,disabled:r}){if(!e.canFold)return(0,Q.jsx)(uj,{columnId:e.id,right:e.align===`right`,children:e.label});let i=t?`Fold`:`Expand`;return(0,Q.jsx)(uj,{columnId:e.id,right:e.align===`right`,folded:!t,children:(0,Q.jsxs)(Ff,{children:[(0,Q.jsx)(If,{asChild:!0,children:(0,Q.jsx)(`button`,{type:`button`,"aria-label":`${i} ${e.label} column`,"aria-pressed":t,disabled:r,onClick:()=>n(e.id),className:q(`inline-flex h-8 w-full items-center gap-1 rounded-sm px-0.5 text-inherit outline-none hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:cursor-wait disabled:opacity-60`,e.align===`right`?`justify-end`:`justify-start`,!t&&`justify-center px-0`),children:t?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`span`,{className:`min-w-0 truncate`,children:e.label}),(0,Q.jsx)(Rc,{className:`size-3 opacity-55`,"aria-hidden":`true`})]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(fj,{icon:e.icon}),(0,Q.jsx)(zc,{className:`size-3 opacity-70`,"aria-hidden":`true`})]})})}),(0,Q.jsxs)(Lf,{side:`top`,children:[e.label,` · `,i,` column`]})]})})}function fj({icon:e}){let t=`size-3.5`;switch(e){case`workflow`:return(0,Q.jsx)(Di,{className:t,"aria-hidden":`true`});case`branch`:return(0,Q.jsx)(ji,{className:t,"aria-hidden":`true`});case`diff`:return(0,Q.jsx)(Ji,{className:t,"aria-hidden":`true`});case`reference`:return(0,Q.jsx)(tl,{className:t,"aria-hidden":`true`});case`tokens`:return(0,Q.jsx)(Hc,{className:t,"aria-hidden":`true`});case`cost`:return(0,Q.jsx)(Gc,{className:t,"aria-hidden":`true`});case`cpu`:return(0,Q.jsx)(Si,{className:t,"aria-hidden":`true`});case`memory`:return(0,Q.jsx)(rl,{className:t,"aria-hidden":`true`});case`started`:return(0,Q.jsx)(Vc,{className:t,"aria-hidden":`true`});default:return null}}var pj=`h-[88px] border-b border-border px-2.5 whitespace-nowrap first:pl-4 last:pr-4`,mj=Z.memo(function({rowIndex:e,run:t,queuePosition:n,onRename:r,onTogglePin:i,now:a,columns:o,expandedColumns:s,automationName:c}){let l=To(),u=qe(t),d=Ar(t),f=`/tasks/${t.id}`,p=_r(t.costUsd),m=fr(t);return(0,Q.jsx)(`div`,{role:`row`,"aria-rowindex":e,"data-slot":`task-table-row`,"data-run-id":t.id,onClick:e=>{e.target.closest(`a, button, input`)||l(f)},className:`task-resource-row group/row cursor-pointer hover:bg-muted`,children:o.map(e=>{if(e.id===`memory`)return null;if(e.id===`cpu`){let r=eO(`cpu`,s),i=eO(`memory`,s);return n!==null&&(r||i)?(0,Q.jsxs)(`div`,{role:`cell`,"data-slot":`queue-note`,"data-column-id":`cpu-memory`,"aria-colspan":2,style:{gridColumn:`span 2`},className:q(pj,`text-right font-mono text-xs text-supporting-foreground`),children:[`#`,n,` in queue`]},e.id):(0,Q.jsx)(bj,{run:t,cpuExpanded:r,memoryExpanded:i},e.id)}return(0,Q.jsx)(_j,{column:e,expanded:eO(e.id,s),run:t,attention:u,scheduled:d,reference:m,cost:p,to:f,onRename:r,onTogglePin:i,now:a,automationName:c},e.id)})})});function hj({run:e,to:t,onRename:n,onTogglePin:r,automationName:i}){let a=e.automationId===void 0?void 0:i(e.automationId)??e.automationId;return(0,Q.jsxs)(`div`,{role:`cell`,"data-column-id":`task`,className:q(pj,`min-w-0 whitespace-normal`),children:[(0,Q.jsx)(yj,{lines:2,run:e,to:t,onRename:n,onTogglePin:r}),a?(0,Q.jsx)(`div`,{className:`mt-1`,children:(0,Q.jsxs)(`span`,{"data-slot":`task-automation-badge`,"data-origin":`automation`,className:`inline-flex max-w-[180px] items-center gap-1 truncate rounded-full border border-info/30 bg-info/10 px-2 py-px text-xs font-medium text-semantic-info`,children:[(0,Q.jsx)(Zi,{className:`size-2.5 shrink-0`,"aria-hidden":`true`}),(0,Q.jsx)(`span`,{className:`truncate`,children:a})]})}):null]})}function gj({run:e,attention:t,scheduled:n}){let r=zm(e,t);return(0,Q.jsx)(`div`,{role:`cell`,"data-column-id":`status`,className:q(pj,`overflow-hidden`),children:(0,Q.jsx)(Td,{dot:r.tone,shape:r.shape,pulse:r.pulse,title:n?.title??r.label,className:`w-full max-w-full overflow-hidden`,children:(0,Q.jsxs)(`span`,{className:`min-w-0 whitespace-normal`,children:[r.label,n?(0,Q.jsxs)(Q.Fragment,{children:[` `,(0,Q.jsx)(`span`,{className:`block tabular-nums`,children:n.label})]}):null]})})})}function _j({column:e,expanded:t,run:n,attention:r,scheduled:i,reference:a,cost:o,to:s,onRename:c,onTogglePin:l,now:u,automationName:d}){if(!t)return(0,Q.jsx)(vj,{column:e.id});switch(e.id){case`status`:return(0,Q.jsx)(gj,{run:n,attention:r,scheduled:i});case`task`:return(0,Q.jsx)(hj,{run:n,to:s,onRename:c,onTogglePin:l,automationName:d});case`workflow`:return(0,Q.jsx)(`div`,{role:`cell`,"data-column-id":e.id,className:q(pj,`max-w-0 truncate text-[13px] text-muted-foreground`),children:cr(n)});case`branch`:return(0,Q.jsx)(`div`,{role:`cell`,"data-column-id":e.id,className:q(pj,`max-w-0 overflow-hidden`),children:n.branch?(0,Q.jsx)(Gk,{branch:n.branch}):(0,Q.jsx)(Hk,{})});case`diff`:return(0,Q.jsx)(`div`,{role:`cell`,"data-column-id":e.id,className:q(pj,`overflow-hidden`),children:n.diffStat?(0,Q.jsx)(km,{stat:n.diffStat,compact:!0,className:`block max-w-full`}):(0,Q.jsx)(Hk,{})});case`reference`:return(0,Q.jsx)(`div`,{role:`cell`,"data-column-id":e.id,className:q(pj,`overflow-hidden`),children:a?(0,Q.jsx)(D_,{run:n,reference:a,compact:!0,className:`max-w-full overflow-hidden`}):(0,Q.jsx)(Hk,{})});case`tokens`:{let t=uA(n.inputTokens,n.outputTokens);return(0,Q.jsx)(`div`,{role:`cell`,"data-column-id":e.id,className:q(pj,`text-right text-xs text-muted-foreground`),children:(0,Q.jsx)(fA,{inputTokens:n.inputTokens,outputTokens:n.outputTokens,variant:`table`,omitWhenUnknown:!1,title:t,className:`block max-w-full overflow-hidden text-ellipsis`})})}case`cost`:return(0,Q.jsx)(`div`,{role:`cell`,"data-column-id":e.id,className:q(pj,`text-right font-mono text-xs text-muted-foreground tabular-nums`),children:o?(0,Q.jsx)(Sj,{text:o,accessibleText:`$${n.costUsd}`}):(0,Q.jsx)(Hk,{})});case`started`:return(0,Q.jsx)(`div`,{role:`cell`,"data-column-id":e.id,className:q(pj,`text-right text-xs text-supporting-foreground`),children:(0,Q.jsx)(jm,{iso:n.startedAt??n.createdAt,now:u})});default:return null}}function vj({column:e}){return(0,Q.jsx)(`div`,{role:`cell`,"aria-hidden":`true`,"data-column-id":e,"data-folded":`true`,className:q(pj,`px-0 first:pl-0 last:pr-0`)})}function yj({run:e,to:t,onTogglePin:n,lines:r=1}){return(0,Q.jsx)(jA,{run:e,to:t,title:Ro(e),unread:mn(e),unreadTone:Xo(e),readDone:Zo(e),isWorker:e.delegation?.role===`worker`,pinned:!!e.pinned,onTogglePin:n?t=>n(e,t):void 0,lines:r})}function bj({run:e,cpuExpanded:t,memoryExpanded:n}){let r=tr(e,Nr(e.id));return(0,Q.jsxs)(Q.Fragment,{children:[t?(0,Q.jsx)(xj,{column:`cpu`,cell:r.cpu}):(0,Q.jsx)(vj,{column:`cpu`}),n?(0,Q.jsx)(xj,{column:`memory`,cell:r.mem}):(0,Q.jsx)(vj,{column:`memory`})]})}function xj({column:e,cell:t}){let n=t.text&&t.title?`${t.text}; ${t.title}`:t.text;return(0,Q.jsx)(`div`,{role:`cell`,"data-usage":e===`memory`?`mem`:e,"data-column-id":e,"data-usage-kind":t.kind,className:q(pj,`overflow-hidden text-right font-mono tabular-nums`,t.kind===`live`&&`bg-accent-strong/5 text-xs font-medium text-foreground`,t.kind===`peak`&&`text-xs text-supporting-foreground`,t.kind===`none`&&`text-xs text-soft-foreground`),children:(0,Q.jsx)(Sj,{text:t.text||`—`,accessibleText:n||void 0})})}function Sj({text:e,accessibleText:t}){return(0,Q.jsx)(`span`,{"data-slot":`bounded-metric`,...t?{"aria-label":t,title:t}:{},className:`block max-w-full overflow-hidden text-ellipsis`,children:e})}function Cj(){let e=T(),t=L(),n=c(),r=$A(n.data),i=_m(),{view:a,setView:o,origin:u,setOrigin:d,urlQuery:f,writeQuery:p}=qA(),h=se(),g=U(),_=iA(e.data,a),y=je({mutationFn:e=>ln(v(),void 0,e),onSuccess:()=>h.invalidateAfter(`runs`,()=>v()),onError:e=>H(e.message,{tone:`danger`})}),b=je({mutationFn:e=>ct(e),onSuccess:()=>g.invalidateQueries({queryKey:ge.runs.all}),onError:e=>H(e.message,{tone:`danger`})}),x=je({mutationFn:({id:e,title:t})=>ot(e,{title:t}),onSuccess:()=>g.invalidateQueries({queryKey:ge.runs.all}),onError:e=>H(e.message,{tone:`danger`})}),S=l(),C=is(3e4),w=tj(),E=te(),D=m(void 0,{retryOnMount:!1}),O=A({retryOnMount:!1}),k=O.data?.projects?.find(e=>e.id===E)?.name,j=k===void 0&&(Zk(O)||E===void 0&&Zk(n)),M=[...e.data??[],..._.pages?.runs??[]].some(e=>e.automationId!==void 0),N=s([void 0],i&&M),ee=Z.useCallback(e=>N(void 0,e),[N]),P=Z.useMemo(()=>E===void 0?[]:(e.data??[]).flatMap(e=>{let t=fr(e);return t?[{projectId:E,kind:t.kind,number:t.number}]:[]}),[e.data,E]),F=Z.useCallback((e,t)=>x.mutate({id:e,title:t}),[x.mutate]),I=Z.useCallback((e,t)=>S.mutate({id:e.id,pinned:t}),[S.mutate]);return(0,Q.jsx)(br,{projectId:E,repoBase:D,requests:P,children:(0,Q.jsx)(rj,{runs:e.data,runners:t.data,projectName:k,projectScopePending:j,error:e.error?.message,onRetry:()=>void e.refetch(),view:a,onViewChange:o,origin:u,onOriginChange:d,automations:i,urlQuery:f,onQueryChange:p,foldScope:`project:${E??`default`}`,automationName:ee,onArchiveFinished:e=>{y.isPending||y.mutate(e)},archivePending:y.isPending,onMarkAllRead:e=>b.mutate(e),onRename:F,onTogglePin:I,now:C,showTokens:r.tokens,showCost:r.cost,expandedColumns:w.expandedColumns,onToggleColumn:w.toggleColumn,columnsPending:w.isPending,archivedPages:_.pages,archivedTotal:_.total,onArchivedSearch:_.search})})}function wj(e){return e.kind===`loading`?`Loading tasks from this host…`:e.kind===`stale`?e.state===`connected`?`Not live — showing last known tasks while syncing.`:`Not live — showing last known tasks.`:`No tasks loaded yet.`}function Tj({entries:e,excludedBulkHosts:t=[],searchUnanswered:n=[],searchTruncated:r=[],searchError:i=!1,searchWarning:a,error:o,onRetry:s}){let c=n.length>0||r.length>0||i||!!a;return e.length===0&&t.length===0&&!o&&!c?null:(0,Q.jsxs)(`div`,{"data-slot":`global-hosts-status`,className:`flex flex-col gap-1.5 rounded-lg border border-border bg-card px-3.5 py-2.5 text-xs text-muted-foreground`,children:[o?(0,Q.jsxs)(`div`,{role:`alert`,"data-slot":`global-hosts-error`,className:`flex flex-wrap items-center justify-between gap-2 text-semantic-red`,children:[(0,Q.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,Q.jsx)(Bc,{className:`size-3.5 shrink-0`,"aria-hidden":`true`}),(0,Q.jsxs)(`span`,{children:[`Could not load tasks from remote hosts: `,o]})]}),s?(0,Q.jsx)(Y,{type:`button`,variant:`outline`,size:`sm`,onClick:s,children:`Retry`}):null]}):null,e.map(e=>(0,Q.jsxs)(`div`,{"data-slot":`global-host-status-row`,"data-host-id":e.id,"data-host-status":e.kind,className:`flex flex-wrap items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:`font-medium text-foreground`,children:e.label}),e.kind===`loading`?(0,Q.jsx)(Td,{"data-slot":`host-loading-pill`,dot:`pending`,pulse:!0,className:`py-0.5 text-muted-foreground`,children:`Loading`}):e.kind===`stale`?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(Ed,{state:e.state}),(0,Q.jsx)(Od,{})]}):(0,Q.jsx)(Ed,{state:e.state}),(0,Q.jsx)(`span`,{children:wj(e)})]},e.id)),(0,Q.jsx)(Dp,{unanswered:n,error:i,warning:a,className:`text-muted-foreground`}),r.length>0?(0,Q.jsxs)(`p`,{"data-slot":`host-search-truncated`,role:`status`,className:`text-muted-foreground`,children:[`More matches in `,r.join(`, `),`. Type more to narrow them.`]}):null,t.length>0?(0,Q.jsxs)(`p`,{"data-slot":`global-bulk-excluded-hosts`,className:`text-muted-foreground`,children:[`Bulk actions skip hosts that are not live: `,t.join(`, `),`.`]}):null]})}function Ej({hits:e,now:t}){return e.length===0?null:(0,Q.jsxs)(`section`,{"data-slot":`host-search-more-matches`,"aria-labelledby":`host-search-more-matches-heading`,className:`rounded-lg border border-border bg-card p-4`,children:[(0,Q.jsx)(`h2`,{id:`host-search-more-matches-heading`,className:`text-sm font-semibold text-foreground`,children:`More matches on hosts`}),(0,Q.jsx)(`div`,{className:`mt-2 flex flex-col divide-y divide-border`,children:e.map(({run:e,hostLabel:n,projectName:r})=>{let i=zm(e,qe(e));return(0,Q.jsxs)(`a`,{href:Re(e.hostId,e.projectId,e.id),"data-slot":`host-search-extra-row`,"data-host-id":e.hostId,"data-project-id":e.projectId,"data-run-id":e.id,className:`flex min-h-11 items-center gap-2.5 py-2 text-sm text-foreground hover:text-accent-text`,children:[(0,Q.jsx)(Qo,{tone:i.tone,shape:i.shape,pulse:i.pulse,"aria-label":i.label,role:`img`}),(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-medium`,children:Ro(e)}),(0,Q.jsx)(Dd,{label:n,hostId:e.hostId}),(0,Q.jsx)(`span`,{className:`shrink-0 truncate text-xs text-soft-foreground max-sm:hidden`,children:r}),(0,Q.jsx)(jm,{iso:e.finishedAt??e.createdAt,now:t,className:`shrink-0 text-xs text-soft-foreground`})]},`${e.hostId}/${e.projectId}/${e.id}`)})})]})}function Dj({message:e,onDismiss:t}){return e?(0,Q.jsxs)(`div`,{role:`alert`,"data-slot":`global-bulk-error`,className:`flex items-center justify-between gap-2 rounded-lg border border-danger/35 bg-danger/10 py-1.5 pr-1.5 pl-3.5 text-xs text-semantic-red`,children:[(0,Q.jsxs)(`span`,{className:`inline-flex min-w-0 items-start gap-2`,children:[(0,Q.jsx)(Bc,{className:`mt-0.5 size-3.5 shrink-0`,"aria-hidden":`true`}),(0,Q.jsx)(`span`,{className:`min-w-0 break-words`,children:e})]}),(0,Q.jsx)(Y,{type:`button`,variant:`ghost`,size:`icon`,"aria-label":`Dismiss error`,onClick:t,className:`shrink-0 text-semantic-red/80 hover:bg-danger/15 hover:text-semantic-red`,children:(0,Q.jsx)(Fi,{className:`size-3.5`,"aria-hidden":`true`})})]}):null}function Oj({projects:e,perProjectLimit:t}){return e.length===0?null:(0,Q.jsxs)(`p`,{"data-slot":`global-tasks-truncated`,className:`text-xs text-soft-foreground`,children:[`Showing every active task and the newest `,t,` archived tasks per project — older archived tasks in`,` `,e.join(`, `),` are in that project’s own Tasks page.`]})}function kj({registry:e}){return e.length<=1?null:(0,Q.jsxs)(`section`,{"data-slot":`other-projects`,className:`rounded-lg border border-border bg-card p-5`,children:[(0,Q.jsx)(`h2`,{className:`text-base font-semibold`,children:`Other projects`}),(0,Q.jsx)(`div`,{className:`mt-3 flex flex-col divide-y divide-border`,children:e.map(e=>(0,Q.jsxs)(`div`,{className:`flex min-h-14 items-center justify-between gap-3`,children:[(0,Q.jsx)(`span`,{className:`min-w-0 truncate text-[13px]`,children:e.name}),(0,Q.jsxs)(G,{to:wo(e.id,`/`),className:`inline-flex min-h-11 shrink-0 items-center rounded-md px-3 text-xs text-accent-text hover:bg-accent-strong/10`,children:[`View tasks`,(0,Q.jsxs)(`span`,{className:`sr-only`,children:[` for `,e.name]})]})]},e.id))})]})}function Aj({view:e,filtered:t,unloadedHosts:n=[]}){if(t)return(0,Q.jsx)(tc,{heading:`h2`,icon:(0,Q.jsx)(Ca,{}),tone:`neutral`,title:`No matching tasks`,subtitle:`No task in any project matches these filters.`});let r=n.some(e=>e.kind===`loading`),i=n.some(e=>e.kind===`offline`);return r||i?(0,Q.jsx)(tc,{heading:`h2`,icon:(0,Q.jsx)(nl,{}),tone:`neutral`,title:r&&!i?`Loading remote host tasks…`:`No tasks available yet`,subtitle:r&&i?`Connected hosts are loading and offline hosts have no cached tasks.`:r?`No local tasks yet. Tasks from connected remote hosts are loading.`:`No local tasks yet. Offline hosts are not connected and have no cached tasks.`}):e===`archived`?(0,Q.jsx)(tc,{heading:`h2`,icon:(0,Q.jsx)(Wi,{}),tone:`neutral`,title:`Nothing archived yet`,subtitle:`Finished tasks you archive land here, from every project.`}):(0,Q.jsx)(tc,{heading:`h2`,icon:(0,Q.jsx)(nl,{}),tone:`neutral`,title:`No tasks yet`,subtitle:`Start a task in any project and it shows up here.`})}function jj({groupBy:e,filterDetailsOpen:t,message:n,onRetry:r}){return(0,Q.jsx)(ls,{route:`global-tasks`,density:`empty`,rootProps:{"data-presentation":e===`none`?`summary`:`cards`,"data-filter-details":String(t)},className:`pb-[calc(90px+env(safe-area-inset-bottom))]`,bodyClassName:`gap-[22px]`,children:(0,Q.jsx)(tc,{icon:(0,Q.jsx)(ri,{}),tone:`danger`,title:`Tasks across projects did not load`,subtitle:n,actions:(0,Q.jsx)(Y,{variant:`outline`,onClick:r,children:`Retry`})})})}function Mj({slot:e,label:t,options:n,selected:r,onToggle:i,onClear:a,searchPlaceholder:o,emptyLabel:s=`Nothing to filter by`}){let[c,l]=Z.useState(!1),u=r.length>0,d=r.length===1?n.find(e=>e.value===r[0])?.label??r[0]:`${r.length} selected`;return(0,Q.jsxs)(po,{open:c,onOpenChange:l,children:[(0,Q.jsx)(co,{asChild:!0,children:(0,Q.jsxs)(`button`,{type:`button`,"data-slot":`facet-${e}`,"data-active":u?`true`:void 0,"aria-label":`Filter by ${t.toLowerCase()}`,className:q(`inline-flex h-7 items-center gap-1.5 rounded-full border border-border bg-card px-2.5 text-xs font-medium text-muted-foreground transition-colors hover:bg-muted hover:text-foreground`,u&&`border-accent-strong/40 bg-accent-strong/10 text-foreground`),children:[(0,Q.jsx)(`span`,{className:q(u&&`text-soft-foreground`),children:t}),u?(0,Q.jsx)(`span`,{className:`max-w-[140px] truncate font-semibold`,children:d}):null,(0,Q.jsx)(ta,{"aria-hidden":`true`,className:`size-2.5 shrink-0 text-soft-foreground`})]})}),(0,Q.jsxs)(uo,{align:`start`,className:`w-64 p-0`,"data-testid":`facet-${e}-menu`,children:[(0,Q.jsxs)(Ns,{children:[(0,Q.jsx)(Ts,{placeholder:o??`Search ${t.toLowerCase()}…`}),(0,Q.jsxs)(Ms,{children:[(0,Q.jsx)(js,{children:s}),(0,Q.jsx)(Ds,{children:n.map(e=>{let t=r.includes(e.value);return(0,Q.jsxs)(As,{value:e.label,onSelect:()=>i(e.value),"data-slot":`facet-option`,"data-value":e.value,"aria-checked":t,role:`option`,children:[(0,Q.jsx)(`span`,{"aria-hidden":`true`,className:q(`flex size-4 shrink-0 items-center justify-center rounded-[4px] border`,t?`border-accent-strong bg-accent-strong text-accent-strong-foreground`:`border-input`),children:t?(0,Q.jsx)(ea,{className:`size-3`}):null}),(0,Q.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:e.label}),e.count===void 0?null:(0,Q.jsx)(`span`,{className:`shrink-0 font-mono text-xs text-soft-foreground tabular-nums`,children:e.count})]},e.value)})})]})]}),u?(0,Q.jsx)(`div`,{className:`border-t border-border p-1`,children:(0,Q.jsxs)(`button`,{type:`button`,"data-action":`facet-${e}-clear`,onClick:()=>a(),className:`w-full rounded-sm px-2 py-1.5 text-left text-xs font-medium text-muted-foreground hover:bg-muted hover:text-foreground`,children:[`Clear `,t.toLowerCase()]})}):null]})]})}function Nj({label:e,count:t,selected:n,onToggle:r,slot:i,tone:a=`neutral`}){return(0,Q.jsxs)(`button`,{type:`button`,"data-slot":i,"data-selected":n?`true`:void 0,"aria-pressed":n,onClick:r,className:q(`inline-flex h-7 items-center gap-1.5 rounded-full border px-2.5 text-xs font-medium transition-colors`,a===`tag`?`border-accent-strong/25 bg-accent-strong/10 text-accent-text hover:bg-accent-strong/20`:`border-border bg-card text-muted-foreground hover:bg-muted hover:text-foreground`,n&&`border-accent-strong bg-accent-strong text-accent-strong-foreground hover:bg-accent-strong`),children:[e,t===void 0?null:(0,Q.jsx)(`span`,{className:q(`font-mono text-xs tabular-nums`,!n&&`text-soft-foreground`),children:t})]})}function Pj({slot:e,label:t,value:n,options:r,onChange:i,size:a=`compact`}){return(0,Q.jsx)(`div`,{"data-slot":e,role:`group`,"aria-label":t,className:`inline-flex gap-0.5 rounded-md bg-muted p-[3px]`,children:r.map(e=>{let t=e.value===n;return(0,Q.jsx)(`button`,{type:`button`,"data-value":e.value,"aria-pressed":t,disabled:e.disabled,title:e.title,onClick:()=>i(e.value),className:q(`flex h-6 items-center justify-center rounded-[6px] px-2.5 text-[12px] font-medium text-muted-foreground transition-colors hover:text-foreground disabled:pointer-events-none disabled:opacity-50`,a===`touch`&&`h-11 px-4 text-[13px]`,t&&`bg-card font-semibold text-foreground shadow-xs`),children:e.label},e.value)})})}var Fj=ft;function Ij(e){return e.hostId??Fj}function Lj(e,t){return t===void 0?e:`${t}/${e}`}var Rj=` untagged`,zj=[{value:`project`,label:`Project`},{value:`tag`,label:`Tag`},{value:`status`,label:`Status`},{value:`workflow`,label:`Workflow`}];function Bj(e,t){return e===t?`none`:t}var Vj={query:``,tags:[],statuses:[],workflows:[]};function Hj(e,t){let{origin:n,...r}=e;return t===`all`?r:{...r,origin:t}}function Uj(e,t){return e.includes(t)?e.filter(e=>e!==t):[...e,t]}function Wj(e){return(e.hosts?.length??0)+(e.projects?.length??0)+e.tags.length+e.statuses.length+e.workflows.length+(e.origin===void 0||e.origin===`all`?0:1)}function Gj(e){return e.query.trim()!==``||Wj(e)>0}function Kj(e){return Wj(e.filters)+(e.filters.query.trim()===``?0:1)}function qj(e){return Kj(e)>0||e.groupBy!==`none`}var Jj=new WeakMap;function Yj(e,t,n){let r=Jj.get(e);if(r&&r.project===t&&r.hostId===n?.id&&r.hostLabel===n?.label&&r.hostStale===n?.stale&&r.hostState===n?.state)return r.task;let i={run:e,...n?{hostId:n.id,hostLabel:n.label,hostStale:n.stale,hostState:n.state}:{},project:t,projectName:t?.name||e.projectId,tags:t?.tags??[]};return Jj.set(e,{project:t,hostId:n?.id,hostLabel:n?.label,hostStale:n?.stale,hostState:n?.state,task:i}),i}function Xj(e,t){if(t.length===0)return e;if(e.length===0)return t;let n=[],r=0,i=0;for(;r<e.length&&i<t.length;)(e[r].run.createdAt??``)>=t[i].run.createdAt?n.push(e[r++]):n.push(t[i++]);for(;r<e.length;)n.push(e[r++]);for(;i<t.length;)n.push(t[i++]);return n}function Zj(e,t,n){let r=new Map(t.map(e=>[e.id,e])),i=[];for(let t of e)No(t)||i.push(Yj(t,r.get(t.projectId)));if(!n||n.runs.length===0)return i;let a=new Map(n.hosts.map(e=>[e.id,e])),o=new Map;for(let[e,t]of n.projectsByHost)o.set(e,new Map(t.map(e=>[e.id,e])));let s=[];for(let e of n.runs){if(No(e))continue;let t=a.get(e.hostId),n=o.get(e.hostId)?.get(e.projectId);s.push(Yj(e,n,{id:e.hostId,label:t?.label??e.hostId,stale:t?.stale??!1,state:t?.state??`connected`}))}return Xj(i,s)}function Qj(e,t){let n=new Map;for(let r of e)for(let e of t(r))n.set(e,(n.get(e)??0)+1);return n}var $j=e=>e.tags.length===0?[Rj]:e.tags,eM=(e,t)=>e.length===0||t.some(t=>e.includes(t)),tM=(e,t)=>{if(t.length===0)return!0;let n=$j(e).map(e=>e.toLowerCase());return t.some(e=>n.includes(e.toLowerCase()))};function nM(e,t){return{displayTitle:Ro(e.run),projectName:e.hostLabel?`${e.projectName} ${e.hostLabel}`:e.projectName,tags:e.tags,automation:e.run.automationId===void 0?void 0:t(e)??e.run.automationId,references:()=>jr(e.run)}}function rM(e,t,n,r=()=>void 0){let i=t.query.trim()!==``,a=t.hosts??[],o=t.projects??[];return e.filter(e=>(n===`archived`?!e.run.archived:e.run.archived)||!ir(e.run,t.origin??`all`)||!eM(a,[Ij(e)])||!eM(o,[Lj(e.run.projectId,e.hostId)])||!eM(t.statuses,[e.run.status])||!eM(t.workflows,[e.run.workflow])||!tM(e,t.tags)?!1:!i||Sr(e.run,t.query,{scope:`shown`,extras:nM(e,r)}))}function iM(e,t,n,r,i){return rM(e,r===`origin`?{...t,origin:`all`}:{...t,[r]:[]},n,i)}function aM(e,t){if(t===`none`)return[{key:`all`,label:``,tasks:[...e]}];let n=new Map,r=(e,t,r,i)=>{let a=n.get(e);a?a.tasks.push(r):n.set(e,{key:e,label:t,...i,tasks:[r]})};for(let n of e)if(t===`project`)r(n.hostId===void 0?n.run.projectId:`host:${n.hostId}/${n.run.projectId}`,n.projectName,n,{projectId:n.run.projectId,...n.hostId===void 0?{}:{hostId:n.hostId,hostLabel:n.hostLabel}});else if(t===`status`)r(n.run.status,Um(n.run.status),n);else if(t===`workflow`)r(n.run.workflow,n.run.workflow,n);else if(n.tags.length===0)r(Rj,`Untagged`,n);else for(let e of n.tags)r(e.toLowerCase(),e,n);return[...n.values()].sort((e,t)=>e.key===` untagged`?1:t.key===` untagged`?-1:t.tasks.length-e.tasks.length||e.label.localeCompare(t.label))}function oM(e,t){let n=new Map(t.map(e=>[e.id,e.name]));return e.map(e=>n.get(e)||e)}var $={query:`q`,host:`host`,project:`project`,tag:`tag`,untagged:`untagged`,status:`status`,workflow:`workflow`,groupBy:`group`,archived:`archived`,origin:`origin`},sM=new Set(zj.map(e=>e.value));function cM(e){let t=new URLSearchParams,n=e.filters.query.trim();n!==``&&t.set($.query,n);for(let n of e.filters.tags)n===` untagged`?t.set($.untagged,`1`):t.append($.tag,n);for(let n of e.filters.hosts??[])t.append($.host,n);for(let n of e.filters.projects??[])t.append($.project,n);for(let n of e.filters.statuses)t.append($.status,n);for(let n of e.filters.workflows)t.append($.workflow,n);return e.groupBy!==`none`&&t.set($.groupBy,e.groupBy),e.view===`archived`&&t.set($.archived,`1`),e.filters.origin!==void 0&&e.filters.origin!==`all`&&t.set($.origin,e.filters.origin),t}function lM(e,t){let n=e.getAll($.tag).filter(e=>e!==``);e.get($.untagged)===`1`&&n.push(Rj);let r=e.get($.groupBy)??``,i=xr(Mr(e.get($.origin)),t);return{filters:{query:e.get($.query)??``,...e.has($.host)?{hosts:e.getAll($.host).filter(Boolean)}:{},...e.has($.project)?{projects:e.getAll($.project).filter(Boolean)}:{},tags:n,statuses:e.getAll($.status).filter(e=>e!==``),workflows:e.getAll($.workflow).filter(e=>e!==``),...i===`all`?{}:{origin:i}},groupBy:sM.has(r)?r:`none`,view:e.get($.archived)===`1`?`archived`:`active`}}function uM(e){return(e.hosts?.length??0)+(e.projects?.length??0)+e.tags.length+e.statuses.length+e.workflows.length}function dM(e,t){e.set(t,(e.get(t)??0)+1)}function fM(e,t,n){let r=new Map,i=new Map,a=new Map,o=new Map,s=new Map,c=n&&(!t.hosts||t.hosts.length===0),l=!t.projects||t.projects.length===0,u=t.tags.length===0,d=t.statuses.length===0,f=t.workflows.length===0;if(c||l||u||d||f)for(let t of e){if(c&&dM(r,Ij(t)),l&&dM(i,Lj(t.run.projectId,t.hostId)),u)for(let e of $j(t))dM(a,e);d&&dM(o,t.run.status),f&&dM(s,t.run.workflow)}return{hosts:r,projects:i,tags:a,statuses:o,workflows:s}}function pM(e,t){let n=new Map,r=new Set,i=new Set;for(let a of e){let e=Lj(a.run.projectId,a.hostId);n.has(e)||n.set(e,t&&a.hostLabel?`${a.projectName} · ${a.hostLabel}`:a.projectName),r.add(a.run.status),i.add(a.run.workflow)}return{projects:[...n.entries()],statuses:[...r].sort((e,t)=>e.localeCompare(t)),workflows:[...i].sort((e,t)=>e.localeCompare(t))}}function mM({filters:e,onToggle:t,onClearFacet:n,onClearAll:r,groupBy:i,onGroupByChange:a,projects:o,hosts:s=[],tasks:c,visible:l,view:u,automationName:d}){let f=Z.useMemo(()=>_e(o),[o]),p=s.length>0,m=Z.useMemo(()=>{let t=l===void 0?{hosts:new Map,projects:new Map,tags:new Map,statuses:new Map,workflows:new Map}:fM(l,e,p),n=(t,n,r,i)=>l!==void 0&&(!n||n.length===0)?i:Qj(iM(c,e,u,t,d),r);return{hosts:p?n(`hosts`,e.hosts,e=>[Ij(e)],t.hosts):t.hosts,projects:n(`projects`,e.projects,e=>[Lj(e.run.projectId,e.hostId)],t.projects),tags:n(`tags`,e.tags,$j,t.tags),statuses:n(`statuses`,e.statuses,e=>[e.run.status],t.statuses),workflows:n(`workflows`,e.workflows,e=>[e.run.workflow],t.workflows)}},[c,l,e,u,d,p]),h=Z.useMemo(()=>pM(c,p),[c,p]),g=Z.useMemo(()=>h.projects.map(([e,t])=>({value:e,label:t,count:m.projects.get(e)??0})),[h.projects,m.projects]),_=Z.useMemo(()=>p?[{value:Fj,label:`This server`,count:m.hosts.get(Fj)??0},...s.map(e=>({value:e.id,label:e.label,count:m.hosts.get(e.id)??0}))]:[],[p,s,m.hosts]),v=Z.useMemo(()=>h.statuses.map(e=>({value:e,label:Um(e),count:m.statuses.get(e)??0})),[h.statuses,m.statuses]),y=Z.useMemo(()=>h.workflows.map(e=>({value:e,label:e,count:m.workflows.get(e)??0})),[c,m.workflows]);return(0,Q.jsxs)(`div`,{id:`global-tasks-filters`,"data-slot":`global-tasks-filters`,className:`flex flex-col gap-2`,children:[(0,Q.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[p?(0,Q.jsx)(Mj,{slot:`host`,label:`Host`,selected:e.hosts??[],onToggle:e=>t(`hosts`,e),onClear:()=>n(`hosts`),options:_,emptyLabel:`No hosts`}):null,(0,Q.jsx)(Mj,{slot:`project`,label:`Project`,selected:e.projects??[],onToggle:e=>t(`projects`,e),onClear:()=>n(`projects`),options:g,emptyLabel:`No tasks to filter`}),(0,Q.jsx)(Mj,{slot:`status`,label:`Status`,selected:e.statuses,onToggle:e=>t(`statuses`,e),onClear:()=>n(`statuses`),options:v,emptyLabel:`No tasks to filter`}),(0,Q.jsx)(Mj,{slot:`workflow`,label:`Workflow`,selected:e.workflows,onToggle:e=>t(`workflows`,e),onClear:()=>n(`workflows`),options:y,emptyLabel:`No tasks to filter`}),(0,Q.jsxs)(`div`,{"data-slot":`group-controls`,className:`flex flex-wrap items-center gap-2`,children:[(0,Q.jsx)(`span`,{className:`mx-1 h-5 w-px bg-border`,"aria-hidden":`true`}),(0,Q.jsx)(`span`,{className:`text-xs font-medium text-soft-foreground`,children:`Group by`}),(0,Q.jsx)(Pj,{slot:`group-by`,label:`Group tasks by`,value:i,options:zj,onChange:e=>a(Bj(i,e))})]}),qj({filters:e,groupBy:i})?(0,Q.jsxs)(`button`,{type:`button`,"data-action":`clear-filters`,onClick:r,className:`ml-auto inline-flex h-7 items-center gap-1 rounded-full px-2 text-xs font-medium text-muted-foreground hover:bg-muted hover:text-foreground`,children:[(0,Q.jsx)(Fi,{className:`size-3`,"aria-hidden":`true`}),`Clear`,Kj({filters:e,groupBy:i})>0?` (${Kj({filters:e,groupBy:i})})`:null]}):null]}),f.length>0?(0,Q.jsxs)(`div`,{"data-slot":`tag-filters`,className:`flex flex-wrap items-center gap-1.5`,children:[(0,Q.jsx)(`span`,{className:`text-xs font-medium text-soft-foreground`,children:`Tags`}),f.map(n=>(0,Q.jsx)(Nj,{slot:`tag-filter`,tone:`tag`,label:n,count:m.tags.get(n)??0,selected:e.tags.some(e=>e.toLowerCase()===n.toLowerCase()),onToggle:()=>t(`tags`,n)},n)),(0,Q.jsx)(Nj,{slot:`tag-filter`,label:`Untagged`,count:m.tags.get(` untagged`)??0,selected:e.tags.includes(Rj),onToggle:()=>t(`tags`,Rj)})]}):(0,Q.jsxs)(`p`,{"data-slot":`no-tags-hint`,className:`text-xs text-soft-foreground`,children:[`Tag connected repositories in`,` `,(0,Q.jsx)(G,{to:`/settings/global/projects`,className:`font-medium text-accent-text hover:underline`,children:Qs(`projects`)}),` `,`to group their tasks together here.`]})]})}var hM=new Set([`done`,`failed`,`cancelled`]);async function gM(e,t){if(e.length===0)return{succeeded:[],failures:[]};let n=await Promise.allSettled(e.map(e=>t(e))),r=[],i=[];return n.forEach((t,n)=>{let a=e[n];if(t.status===`fulfilled`)r.push(a);else{let e=t.reason instanceof Error?t.reason.message:String(t.reason);i.push({hostId:a.hostId,hostLabel:a.hostLabel,message:e})}}),{succeeded:r,failures:i}}function _M(e,t){let n=new Map;for(let e of t.failures)n.has(e.hostLabel)||n.set(e.hostLabel,e.message);return`${e} failed on ${[...n.entries()].map(([e,t])=>`${e} (${t})`).join(`, `)}.${t.succeeded.length>0?` Other hosts were updated.`:``}`}function vM(e,t,n){let r=n.hosts&&n.hosts.length>0?new Set(n.hosts):void 0,i=n.projects&&n.projects.length>0?new Set(n.projects):void 0,a=n.tags.length>0?new Set(n.tags.map(e=>e.toLowerCase())):void 0;return e.filter(e=>!(!ir(e.run,t)||r&&!r.has(Ij(e))||i&&!i.has(Lj(e.run.projectId,e.hostId))||a&&!$j(e).some(e=>a.has(e.toLowerCase()))))}function yM(e){let t=new Map;for(let n of e){let e=`${n.hostId??``}\u0000${n.run.projectId}`;t.has(e)||t.set(e,{...n.hostId===void 0?{}:{hostId:n.hostId},hostLabel:n.hostLabel??`This server`,projectId:n.run.projectId})}return[...t.values()]}var bM=e=>e.hostId===void 0||e.hostState===`connected`&&!e.hostStale;function xM({tasks:e,origin:t,filters:n}){let r=U(),[i,a]=Z.useState(null),o=Z.useMemo(()=>vM(e,t,n),[e,t,n]),s=Z.useMemo(()=>o.filter(bM),[o]),c=Z.useMemo(()=>{let e=new Set;for(let t of o)bM(t)||(mn(t.run)||!t.run.archived&&hM.has(t.run.status))&&e.add(t.hostLabel??t.hostId??`Remote host`);return[...e]},[o]),l=Z.useMemo(()=>s.map(e=>e.run),[s]),u=Z.useMemo(()=>Yo(l),[l]),d=Z.useMemo(()=>kr(l),[l]),f=Z.useCallback((e,t,n)=>{t.some(e=>e.hostId===void 0)&&(r.invalidateQueries({queryKey:V.runsIndex}),r.invalidateQueries({queryKey:ge.runs.all}));let i=[...new Set(t.map(e=>e.hostId).filter(e=>e!==void 0))];i.length>0&&pe(r).reconcileHosts(i),n.failures.length>0?a(_M(e,n)):a(null)},[r]),p=je({mutationFn:({targets:e,origin:t})=>gM(e,({projectId:e,hostId:n})=>ct(ar(t),v({projectId:e,hostId:n}))),onSuccess:(e,{targets:t})=>f(`Mark all read`,t,e),onError:e=>{a(nt(e))}}),m=je({mutationFn:({targets:e,origin:t})=>gM(e,({projectId:e,hostId:n})=>ln(v({projectId:e,hostId:n}),void 0,ar(t))),onSuccess:(e,{targets:t})=>f(`Archive finished`,t,e),onError:e=>{a(nt(e))}}),h=Z.useCallback(()=>{if(p.isPending)return;let e=yM(s.filter(e=>mn(e.run)));e.length>0&&p.mutate({targets:e,origin:t})},[s,p,t]),g=Z.useCallback(()=>{if(m.isPending)return;let e=yM(s.filter(e=>!e.run.archived&&hM.has(e.run.status)));e.length>0&&m.mutate({targets:e,origin:t})},[s,m,t]);return{unread:u,finished:d,archivePending:m.isPending,markReadPending:p.isPending,onMarkAllRead:h,onArchiveFinished:g,excludedBulkHosts:c,bulkError:i,dismissBulkError:Z.useCallback(()=>a(null),[])}}function SM(e,t,n){if(e.length===0)return[];let r=new Map((t??[]).map(e=>[e.id,e])),i=[];for(let t of e){let e=r.get(t.id),a=e?.state??t.state,o=e?.loaded??!1,s=e?.stale??a!==`connected`;o?s&&i.push({id:t.id,label:e?.label??t.label,state:a,kind:`stale`}):i.push({id:t.id,label:e?.label??t.label,state:a,kind:a===`connected`||n&&a===`connecting`?`loading`:`offline`})}return i}function CM(e,t){let n=[];for(let r of e??[])if(r.truncated.length!==0)for(let e of oM(r.truncated,t.get(r.id)??[]))n.push(`${e} (${r.label})`);return n}function wM(e,t,n){if(e)return{statusError:void 0,retryStatus:void 0};let r=t.data?.warning;return{statusError:t.error?.message??r??n.error?.message,retryStatus:t.isError||r?()=>{t.refetch()}:n.isError?()=>{n.refetch()}:void 0}}function TM(e,t,n,r){let i=e.hosts;if(!i||i.length===0)return e;if(t)return{...e,hosts:[]};if(!n)return e;if(r.length===0)return{...e,hosts:[]};let a=new Set([Fj,...r.map(e=>e.id)]),o=i.filter(e=>a.has(e));return o.length===i.length?e:{...e,hosts:o}}function EM(e,t,n,r,i,a,o){if(e.length===0)return[];let s=t.length===0?e:e.filter(e=>!ne(t,e.hostId,e.projectId,e.id));return s.length===0?[]:rM(Zj([],[],{runs:s,hosts:n,projectsByHost:i}),{...a,query:``},o).map(e=>{let t=e.run;return{run:t,hostLabel:r.get(t.hostId)??e.hostLabel??t.hostId,projectName:e.projectName}})}function DM(e,t,n=`active`){let r=U(),{mainHostsProjects:i,savedHosts:a,hasHosts:o,hostLabels:s,projectsByHost:c}=Jr(e),l=e||i.isSuccess,u=Z.useMemo(()=>TM(t,e,l,a),[t,e,l,a]),d=u.hosts??[],f=qr(o),p=d.length>0&&!d.some(e=>e!==Fj),m=u.query.trim(),h=!e&&o&&!p&&m.length>=2,g=Zr(m,h),_=h&&!g.isPlaceholderData?g.data:void 0,v=f.data?.hosts;Z.useEffect(()=>{if(v)for(let e of v)Se(e.referenceStatuses,e.id)},[v]);let y=Z.useMemo(()=>{if(!(!o||!f.data))return{runs:f.data.runs,hosts:f.data.hosts,projectsByHost:c}},[o,f.data,c]),b=f.data!==void 0||f.isError,x=Z.useMemo(()=>{if(!_||_.runs.length===0||!b)return[];let e=r.getQueryData(Xr.hostsRunsIndex)?.runs??[];return Tp(_.runs,e)},[_,b,r]),S=Z.useMemo(()=>x.length===0?[]:EM(x,f.data?.runs??[],f.data?.hosts??[],s,c,u,n),[x,f.data?.runs,f.data?.hosts,s,c,u,n]),C=Z.useMemo(()=>SM(a,f.data?.hosts,f.isPending),[a,f.data?.hosts,f.isPending]),w=Z.useMemo(()=>a.flatMap(e=>e.projects??[]),[a]),T=Z.useMemo(()=>CM(f.data?.hosts,c),[f.data?.hosts,c]),E=Z.useMemo(()=>_?wp(_.truncated,s,c):[],[_,s,c]),D=Z.useMemo(()=>{let e=_?.unanswered??[];if(d.length===0)return e;let t=new Set(d);return e.filter(e=>t.has(e.hostId))},[_,d]),O=Z.useMemo(()=>a.map(e=>({id:e.id,label:e.label})),[a]),{statusError:k,retryStatus:A}=wM(e,i,f);return{filters:u,hasHosts:o,hostsResolved:l,savedHosts:a,hostsIndex:f,remoteInput:y,extraSearchHits:S,hostStatusEntries:C,remoteProjectsFlat:w,remoteTruncated:T,searchTruncated:E,hostFilterOptions:O,statusError:k,retryStatus:A,searchUnanswered:D,searchError:h&&g.isError&&!g.isPlaceholderData,searchWarning:_?.warning}}var OM=15e3,kM=250;function AM(){return NM({request:({hostId:e,projectId:t,runId:n,archived:r})=>gn(E(n,{projectId:t,hostId:e}),r),patch:({archived:e})=>t=>({...t,archived:e})})}function jM(){return NM({request:({hostId:e,projectId:t,runId:n,read:r})=>Lt(E(n,{projectId:t,hostId:e}),r),patch:({read:e})=>t=>{if(e)return{...t,seenAt:new Date().toISOString()};let{seenAt:n,...r}=t;return r}})}function MM(){return NM({request:({hostId:e,projectId:t,runId:n,pinned:r})=>Mt(E(n,{projectId:t,hostId:e}),r),patch:({pinned:e})=>t=>({...t,pinned:e})})}function NM({request:e,patch:t}){let n=se();return je({mutationFn:e,onMutate:e=>n.patchIndex(E(e.runId,{projectId:e.projectId,hostId:e.hostId}),()=>t(e)),onError:(e,t,n)=>{n?.rollback(),H(nt(e),{tone:`danger`})},onSettled:(e,t,{hostId:r,projectId:i,runId:a},o)=>{o?o.settle():n.invalidateAfter(`indexed`,E(a,{projectId:i,hostId:r}))}})}function PM({projectCount:e,hostCount:t,projectsPending:n,newTaskProject:r,status:i,secondaryActions:a}){return{title:`All tasks`,status:(0,Q.jsx)(Qk,{scope:e>0||t>0?(0,Q.jsxs)(`span`,{className:`tabular-nums`,children:[e,` `,e===1?`project`:`projects`,t>0?` · ${t} ${t===1?`host`:`hosts`}`:``]}):null,scopePending:n,children:i}),secondaryActions:a,...r===null?{}:{primaryAction:(0,Q.jsx)(cs,{asChild:!0,variant:`primary`,"data-slot":`new-task-inline`,children:(0,Q.jsxs)(G,{to:wo(r??`default`,`/new`),children:[(0,Q.jsx)(vi,{"aria-hidden":`true`}),`New task`]})})}}}function FM({visible:e,total:t,filtered:n,truncated:r}){return(0,Q.jsxs)(`span`,{"data-slot":`global-tasks-count`,className:q(`self-center text-xs text-soft-foreground tabular-nums`,!n&&!r&&`sr-only`),children:[e,` of `,t,r?` loaded`:``]})}function IM(e){if(e!==void 0)return e.bootProject===null?e.projects.find(e=>e.status!==`missing`)?.id??e.projects[0]?.id??null:e.bootProject}function LM(e,t,n,r){if(!(!e||t<=0||n))return(0,Q.jsx)(ps,{summary:`Showing ${t} ${t===1?`task`:`tasks`} across registered projects.`,actions:r===null?void 0:(0,Q.jsx)(Y,{variant:`outline`,size:`sm`,asChild:!0,children:(0,Q.jsx)(G,{to:wo(r??`default`,`/new`),children:`Start a task`})})})}function RM(){let{mutate:e,isPending:t}=AM(),{mutate:n,isPending:r}=jM(),{mutate:i,isPending:a}=MM();return{onArchive:Z.useCallback((t,n)=>{t.projectId&&e({hostId:t.hostId,projectId:t.projectId,runId:t.runId,archived:n})},[e]),onSetRead:Z.useCallback((e,t)=>{e.projectId&&n({hostId:e.hostId,projectId:e.projectId,runId:e.runId,read:t})},[n]),onTogglePin:Z.useCallback((e,t)=>{e.projectId&&i({hostId:e.hostId,projectId:e.projectId,runId:e.runId,pinned:t})},[i]),busy:t||r||a}}function zM(){let e=fs(),t=Pe(),n=A(),r=L(),i=$A(c().data),o=a(!0,OM),s=tj(),l=Z.useMemo(()=>iO(),[]),[u,d]=rc(),f=_m(),{filters:p,groupBy:m,view:h}=Z.useMemo(()=>lM(u,f),[u,f]),g=DM(t,p,h),_=g.filters,v=is(3e4),y=e=>d(t=>{let n=cM(e(lM(t,!0))),r=t.get(`tasks`);return(r===`flat`||r===`virtual`)&&n.set(`tasks`,r),n}),b=e=>y(t=>({...t,filters:e(t.filters)})),x=e=>y(t=>({...t,groupBy:e})),S=e=>y(t=>({...t,view:e})),C=uM(_),[w,T]=Z.useState(C>0),[E,D]=HM(_.query,e=>b(t=>({...t,query:e}))),O=o.data?.referenceStatuses;Z.useEffect(()=>{O&&Se(O)},[O]);let k=Z.useMemo(()=>n.data?.projects??[],[n.data]),j=Z.useMemo(()=>g.remoteProjectsFlat.length===0?k:[...k,...g.remoteProjectsFlat],[k,g.remoteProjectsFlat]),M=Z.useMemo(()=>{if(g.savedHosts.length===0)return k.length;let e=new Set(k.map(e=>`\u0000${e.id}`));for(let t of g.savedHosts)for(let n of t.projects??[])e.add(`${t.id}\u0000${n.id}`);for(let t of g.remoteInput?.runs??[])e.add(`${t.hostId}\u0000${t.projectId}`);return e.size},[k,g.savedHosts,g.remoteInput]),N=Z.useMemo(()=>o.data?.runs??[],[o.data]),ee=Z.useMemo(()=>g.remoteInput?[...N,...g.remoteInput.runs]:N,[N,g.remoteInput]),P=Z.useMemo(()=>Zj(N,k,g.remoteInput),[N,k,g.remoteInput]),{nameOf:F,visible:I,originTotals:R,statusGroups:te,folds:ne}=UM({tasks:P,filters:_,view:h,groupBy:m,index:ee,automationsOn:f}),re=Z.useMemo(()=>aM(I,m),[I,m]),z=Z.useMemo(()=>m===`none`?te.some(e=>!ne.isCollapsed(e.label)&&e.rows.some(e=>$n(e).some(e=>nr(e.run,e.project?.repoUrl).length>0))):re.some(e=>e.tasks.some(e=>nr(e.run,e.project?.repoUrl).length>0)),[m,te,re,ne]),ie=_.origin??`all`,ae=Z.useMemo(()=>{let e=P.map(e=>e.run);return{active:ur(e,`active`)[ie],archived:ur(e,`archived`)[ie]}},[P,ie]),oe=e=>b(t=>Hj(t,e)),B=xM({tasks:P,origin:ie,filters:_}),se=RM(),ce=Z.useMemo(()=>{let e=new Set,t=[];for(let n of I){if(n.hostStale)continue;let r=wr(n.run,n.project?.repoUrl);for(let i of r){let r=`${n.hostId??``}\u0000${n.run.projectId}\u0000${i.kind}\u0000${i.number}`;e.has(r)||(e.add(r),t.push({...n.hostId===void 0?{}:{hostId:n.hostId},projectId:n.run.projectId,kind:i.kind,number:i.number}))}}return t},[I]),le=Z.useMemo(()=>[...oM(o.data?.truncated??[],k),...g.remoteTruncated],[o.data?.truncated,k,g.remoteTruncated]),ue=(e,t)=>b(n=>({...n,[e]:Uj(n[e]??[],t)})),de=e=>b(t=>({...t,[e]:[]})),fe=o.error??n.error;if(fe)return(0,Q.jsx)(jj,{groupBy:m,filterDetailsOpen:w,message:fe.message,onRetry:()=>{o.refetch(),n.refetch()}});let pe=o.data===void 0?`full`:us(I.length),me=(0,Q.jsxs)(Y,{variant:`outline`,"data-slot":`filters-toggle`,"data-active":w||C>0,className:q(`max-md:px-2.5`,(w||C>0)&&`border-accent-strong bg-accent-strong/10 text-accent-text hover:bg-accent-strong/15 hover:text-accent-text`),"aria-expanded":w,"aria-controls":`global-tasks-filters`,onClick:()=>T(e=>!e),children:[(0,Q.jsx)(Li,{"aria-hidden":`true`}),(0,Q.jsx)(`span`,{className:`max-md:sr-only`,children:`Filters`}),C>0?(0,Q.jsx)(Am,{variant:`accent`,"data-slot":`filters-count`,"aria-hidden":`true`,value:C}):null]}),he={view:h,unread:B.unread,finished:B.finished,archivePending:B.archivePending,markReadPending:B.markReadPending,onMarkAllRead:B.onMarkAllRead,onArchiveFinished:B.onArchiveFinished},ge=IM(n.data),_e=g.hostStatusEntries.filter(e=>e.kind!==`stale`);return(0,Q.jsx)(ls,{route:`global-tasks`,density:pe,headerSpacing:`compact`,rootProps:{"data-presentation":m===`none`?`summary`:`cards`,"data-filter-details":String(w)},bodyClassName:`gap-3`,header:PM({projectCount:M,hostCount:g.savedHosts.length,projectsPending:Zk(n),newTaskProject:ge,status:(0,Q.jsx)(Vk,{view:h,onSelect:S,activeCount:ae.active,archivedCount:ae.archived,trailing:(0,Q.jsx)(FM,{visible:I.length,total:P.length,filtered:Gj(_),truncated:le.length>0})}),secondaryActions:(0,Q.jsx)(Kk,{surface:`desktop`,...he})}),sparseFooter:LM(o.data!==void 0,I.length,Gj(_),ge),children:(0,Q.jsxs)(Ek,{layout:`${m}:${e}`,revision:re,visibilityRevision:JSON.stringify([Uo.map(ne.isCollapsed),h,s.expandedColumns]),className:`flex min-w-0 flex-1 flex-col gap-3`,children:[(0,Q.jsx)(Yk,{query:E,onQueryChange:D,searchPlaceholder:`Search every project…`,searchLabel:`Search tasks across projects`,origin:ie,originCounts:R,automations:f,onOriginChange:oe,columns:l,showReferences:z,expandedColumns:s.expandedColumns,columnsPending:s.isPending,onToggleColumn:s.toggleColumn,groupLabels:te.map(e=>e.label),allGroupsCollapsed:sA(te.map(e=>e.label),ne.isCollapsed),onSetAllFolds:ne.setAll,extraControls:me,mobileOriginOpen:w||ie!==`all`,mobileActions:(0,Q.jsx)(Kk,{surface:`mobile`,...he})}),(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-3`,children:[(0,Q.jsx)(mM,{filters:_,onToggle:ue,onClearFacet:de,onClearAll:()=>{D(``),y(e=>({...e,filters:Vj,groupBy:`none`}))},groupBy:m,onGroupByChange:x,projects:j,hosts:g.hostFilterOptions,tasks:P,visible:I,view:h,automationName:F}),(0,Q.jsx)(Dj,{message:B.bulkError,onDismiss:B.dismissBulkError}),(0,Q.jsx)(Tj,{entries:g.hostStatusEntries,excludedBulkHosts:B.excludedBulkHosts,searchUnanswered:g.searchUnanswered,searchTruncated:g.searchTruncated,searchError:g.searchError,searchWarning:g.searchWarning,error:g.statusError,onRetry:g.retryStatus}),(0,Q.jsx)(Oj,{projects:le,perProjectLimit:o.data?.perProjectLimit}),o.data===void 0?(0,Q.jsx)(`div`,{role:`status`,className:`rounded-xl border border-border bg-card p-6 text-sm text-muted-foreground`,children:`Loading tasks…`}):(0,Q.jsxs)(Q.Fragment,{children:[I.length===0&&g.extraSearchHits.length>0?null:(0,Q.jsx)(BM,{view:h,filtered:Gj(_),visibleCount:I.length,unloadedHosts:_e,referenceRequests:ce,lists:{desktop:e,groupBy:m,view:h,statusGroups:te,groups:re,folds:ne,showReferences:z,expandedColumns:s.expandedColumns,now:v,runners:r.data,showTokens:i.tokens,showCost:i.cost,automationName:F,onTogglePin:h===`archived`?void 0:se.onTogglePin,onArchive:se.onArchive,onSetRead:se.onSetRead,busy:se.busy}}),(0,Q.jsx)(Ej,{hits:g.extraSearchHits,now:v})]}),(0,Q.jsx)(kj,{registry:k})]})]})})}function BM({view:e,filtered:t,visibleCount:n,unloadedHosts:r,referenceRequests:i,lists:a}){return n===0?(0,Q.jsx)(Aj,{view:e,filtered:t,unloadedHosts:r}):(0,Q.jsx)(br,{requests:i,children:(0,Q.jsx)(VM,{...a})})}function VM({desktop:e,groupBy:t,view:n,statusGroups:r,groups:i,folds:a,expandedColumns:o,now:s,runners:c,showTokens:l,showCost:u,automationName:d,onTogglePin:f,onArchive:p,onSetRead:m,busy:h,showReferences:g}){let _=r.filter(e=>!a.isCollapsed(e.label)),v=e?`table`:`card`,y=e=>e.map(({task:e,queuePosition:t})=>bk({task:e,queuePosition:t,runners:c,automationName:d,now:s,showTokens:l,showCost:u})),b={density:v,now:s,showReferences:g,expandedColumns:o,showTokens:l,showCost:u,scopedLinks:!1,liveUsageSource:`snapshot`,onTogglePin:f,onArchive:p,onSetRead:m,busy:h,tableSlot:`global-tasks-table`,rowSlot:`global-task-row`,cardSlot:`global-task-row`};return(0,Q.jsx)(Q.Fragment,{children:t===`none`?r.map(e=>{let t=a.isCollapsed(e.label);return(0,Q.jsx)(Fk,{id:`global-group-${n}-${e.label.replaceAll(` `,`-`)}`,label:e.label,count:e.rows.length,tone:Lk(e.label,e.label===`Finished`?e.rows.map(e=>e.run.run):[]),folded:a.isFolded(e.label),collapsed:t,onToggle:()=>a.toggle(e.label),children:t?null:(0,Q.jsx)(KA,{...b,items:e.rows.map(e=>bk({task:e.run,queuePosition:e.run.run.status===`queued`?e.queuePosition:null,runners:c,automationName:d,now:s,showTokens:l,showCost:u})),showHeader:e===_[0],showProject:!0})},e.label)}):i.map((e,r)=>{let i=n===`archived`?e.tasks:[...e.tasks].sort((e,t)=>Number(!!t.run.pinned)-Number(!!e.run.pinned));return(0,Q.jsxs)(`section`,{"data-slot":`task-group`,"data-group-key":e.key,children:[(0,Q.jsxs)(`h2`,{className:`mb-1.5 flex items-center gap-2 text-[12px] font-semibold tracking-[0.04em] text-soft-foreground uppercase`,children:[t===`project`?e.hostId===void 0?(0,Q.jsx)(G,{to:wo(e.projectId??e.key,`/`),"data-slot":`group-project-link`,className:`hover:text-foreground hover:underline`,children:e.label}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(`a`,{href:Ne(e.hostId,e.projectId??e.key),"data-slot":`group-project-link`,className:`hover:text-foreground hover:underline`,children:e.label}),(0,Q.jsx)(Dd,{label:e.hostLabel??e.hostId,hostId:e.hostId,className:`normal-case tracking-normal`})]}):e.label,(0,Q.jsx)(Am,{value:i.length,className:`font-mono text-xs font-medium`})]}),(0,Q.jsx)(KA,{...b,items:y(i.map(e=>({task:e,queuePosition:null}))),showHeader:r===0,showProject:t!==`project`})]},e.key)})})}function HM(e,t){let[n,r]=Z.useState(e),i=Z.useRef(e);return Z.useEffect(()=>{e!==i.current&&r(e),i.current=e},[e]),Z.useEffect(()=>{if(n===i.current)return;let e=setTimeout(()=>{i.current=n,t(n)},kM);return()=>clearTimeout(e)},[n]),[n,r]}function UM({tasks:e,filters:t,view:n,groupBy:r,index:i,automationsOn:a}){let o=Z.useMemo(()=>{let t=new Map;for(let n of e){if(n.run.automationId===void 0||n.hostStale)continue;let e=`${n.hostId??``}\u0000${n.run.projectId}`;t.has(e)||t.set(e,{projectId:n.run.projectId,...n.hostId===void 0?{}:{hostId:n.hostId}})}return[...t.values()]},[e]),c=s(o,a&&o.length>0),l=Z.useCallback(e=>e.run.automationId===void 0?void 0:c(e.run.projectId,e.run.automationId,e.hostId),[c]),u=Z.useMemo(()=>rM(e,t,n,l),[e,t,n,l]),d=Z.useMemo(()=>ur((t.origin===void 0||t.origin===`all`?u:iM(e,t,n,`origin`,l)).map(e=>e.run),n),[e,u,t,n,l]),f=Z.useMemo(()=>r===`none`?or(u,n,i):[],[r,u,n,i]);return{nameOf:l,visible:u,originTotals:d,statusGroups:f,folds:ZA(`global`,n,Z.useMemo(()=>new Set(t.query.trim()===``?[]:f.map(e=>e.label)),[t.query,f]))}}var WM=(0,Z.lazy)(()=>W(()=>import(`./automations-route-DhkRC_XY.js`).then(e=>({default:e.AutomationsRoute})),__vite__mapDeps([124,1,2,6,7,8,9,10,11,12,13,14,125,126,127,128,24,15,78,16,20,105,30,31,32,33,34,55,46,64,65,56,27,28,57,129,130]))),GM=(0,Z.lazy)(()=>W(()=>import(`./workspace-tools-CCQ42oji.js`).then(e=>({default:e.WorkspaceToolsRoute})),__vite__mapDeps([131,1,2,6,7,8,9,10,11,12,13,14,18,16,41,20,25,26,64,65,27]))),KM=(0,Z.lazy)(()=>W(()=>import(`./settings-shell-BvkTyfyu.js`).then(e=>({default:e.SettingsIndexRoute})),__vite__mapDeps([132,1,2,6,7,8,9,10,11,12,13,14,15,71,16,20,105,24,55,32,34,21,46,101,64,65,57,37,47,39,40,26,41,19,42,43,44,31,33,45,53,58,75,29,30,61,62,28,38,63,133]))),qM=(0,Z.lazy)(()=>W(()=>import(`./settings-shell-BvkTyfyu.js`).then(e=>({default:e.SettingsSectionRoute})),__vite__mapDeps([132,1,2,6,7,8,9,10,11,12,13,14,15,71,16,20,105,24,55,32,34,21,46,101,64,65,57,37,47,39,40,26,41,19,42,43,44,31,33,45,53,58,75,29,30,61,62,28,38,63,133]))),JM=(0,Z.lazy)(()=>W(()=>import(`./task-thread-D_Yc4SUV.js`).then(e=>({default:e.TaskThreadRoute})),__vite__mapDeps([134,1,2,6,7,8,9,10,11,12,13,14,109,15,62,24,33,34,100,101,16,135,78,18,42,82,110,84,43,20,105,46,136,23,137,92,120,57,93,94,95,51,45,111,138,108,87,40,26,41,19,44,31,81,22,25,88,56,112,113,98,139,85,140,64,65,28,104,106,21,99,129,86,83,141]))),YM=(0,Z.lazy)(()=>W(()=>import(`./task-changes-BZiv3oW9.js`).then(e=>({default:e.TaskChangesRoute})),__vite__mapDeps([107,1,2,6,7,8,9,10,11,12,13,14,15,108,109,62,24,33,34,100,101,16,87,40,26,41,19,42,43,20,44,31,45,81,110,22,23,46,25,88,56,57,93,94,95,51,111,112,113,114,91,115,116,64,65,28,117,106,21,102,118,119,120,121,122,123]))),XM=(0,Z.lazy)(()=>W(()=>import(`./task-files-BwWE5iwD.js`).then(e=>({default:e.TaskFilesRoute})),__vite__mapDeps([142,1,2,6,7,8,9,10,11,12,13,14,15,16,108,109,62,24,33,34,100,101,87,40,26,41,19,42,43,20,44,31,45,81,110,22,23,46,25,88,56,57,93,94,95,51,111,112,113,90,91,28,92,96,64,65,137,121,116,123]))),ZM=(0,Z.lazy)(async()=>{let{TaskReportRoute:e}=await W(async()=>{let{TaskReportRoute:e}=await import(`./report-reader-BXPtT3jw.js`);return{TaskReportRoute:e}},__vite__mapDeps([89,1,2,6,7,8,9,10,11,12,13,14,15,90,16,91,20,44,24,31,33,34,28,92,51,45,93,94,95,96]));return{default:e}}),QM=(0,Z.lazy)(()=>W(()=>import(`./task-commits-C319iu69.js`).then(e=>({default:e.TaskCommitsRoute})),__vite__mapDeps([143,1,2,6,7,8,9,10,11,12,13,14,15,108,109,62,24,33,34,100,101,16,87,40,26,41,19,42,43,20,44,31,45,81,110,22,23,46,25,88,56,57,93,94,95,51,111,112,113,64,65,28,144,121,122,145,91,139,118,115,119,120,123]))),$M=(0,Z.lazy)(()=>W(()=>import(`./task-github-item--JaIohoc.js`).then(e=>({default:e.TaskGithubItemRoute})),__vite__mapDeps([146,2,1,6,7,8,9,10,11,12,13,14,109,15,62,24,33,34,100,101,108,16,87,40,26,41,19,42,43,20,44,31,45,81,110,22,23,46,25,88,56,57,93,94,95,51,111,112,113,139,64,65,28,147,98,82,83,67,68,118,115,119,120,144,29,30,32,148]))),eN=(0,Z.lazy)(()=>W(()=>import(`./repo-git-Dr-LPs33.js`).then(e=>({default:e.RepoGitRoute})),__vite__mapDeps([149,1,2,6,7,8,9,10,11,12,13,14,109,15,62,24,33,34,100,101,16,80,150,114,41,91,20,44,31,43,115,116,81,82,22,23,46,25,26,64,65,88,151,28,117,118,119,120,144,121,122,145,139,152]))),tN=(0,Z.lazy)(()=>W(()=>import(`./github-BFdjku0b.js`).then(e=>({default:e.GithubRoute})),__vite__mapDeps([153,1,2,6,7,8,9,10,11,12,13,14,109,15,62,24,33,34,100,101,79,16,18,82,83,20,30,31,32,46,25,26,64,65,67,23,22,28,137,93,94,95,51,45,147,41,98,110,68,56,57,118,115,119,120,144,29,112,148]))),nN=(0,Z.lazy)(()=>W(()=>import(`./reports-BztUxdF1.js`).then(e=>({default:e.ReportsRoute})),__vite__mapDeps([154,1,2,6,7,8,9,10,11,12,13,14,15,155,16,18,98,20,46,64,65,137,138,96,92,156]))),rN=(0,Z.lazy)(()=>W(()=>import(`./workflows-D5gUtDwQ.js`).then(e=>({default:e.WorkflowsRoute})),__vite__mapDeps([157,1,2,6,7,8,9,10,11,12,13,14,15,20,44,24,31,33,34,22,23,64,65,68,28,57,4,29,30,32,52,158]))),iN=(0,Z.lazy)(()=>W(()=>import(`./activity-route-CYn-qQq2.js`).then(e=>({default:e.ProjectActivityRoute})),__vite__mapDeps([159,1,2,7,160,6,8,9,10,11,12,13,14,128,15,16,135,78,18,42,82,110,84,43,20,105,24,46,136,23,137,92,120,57,93,94,95,51,45,111,138,77,155,26,41,81,62,33,34,101,25,64,65,99,100,56,103,97,98,102,28,104,106,21,161]))),aN=(0,Z.lazy)(()=>W(()=>import(`./global-activity-route-CYV5tNqR.js`).then(e=>({default:e.GlobalActivityRoute})),__vite__mapDeps([162,1,2,6,7,8,9,10,11,12,13,14,160,128,15,16,135,78,18,42,82,110,84,43,20,105,24,46,136,23,137,92,120,57,93,94,95,51,45,111,138,77,155,26,41,81,62,33,34,101,25,64,65,99,100,56,103,97,98,102,28,104,106,21,161,3]))),oN=(0,Z.lazy)(()=>W(()=>import(`./skills-khuz63Be.js`).then(e=>({default:e.SkillsRoute})),__vite__mapDeps([163,1,2,6,7,8,9,10,11,12,13,14,15,20,46,64,65,68,56,29,30,24,31,32,33,34])));function sN(){let e=qn();return(0,Q.jsx)(ko,{to:{pathname:`/skills`,search:e.search,hash:e.hash},replace:!0})}function cN({sectionId:e}){let t=qn();return(0,Q.jsx)(Wn,{to:{pathname:mb(`global`,e),search:t.search,hash:t.hash},replace:!0})}function lN(){return(0,Q.jsx)(`div`,{"data-route":`scope-resolving`,className:`flex min-h-full flex-col`,children:(0,Q.jsx)(`p`,{className:`px-4 py-6 text-center text-xs text-soft-foreground`,children:`Loading…`})})}function uN(e,t,n){let r=e.data===void 0?e.isError?t.data?.bootProject:void 0:e.data.bootProject;if(typeof r==`string`){let e=n.pathname.replace(/^\/p\/default(?=\/|$)/,``);return(0,Q.jsx)(Wn,{to:`/p/${encodeURIComponent(r)}${e||`/`}${n.search}${n.hash}`,replace:!0})}return r===null?e.data&&e.data.projects.length>0?(0,Q.jsx)(TE,{projectId:`default`,registry:e.data}):(0,Q.jsx)(bE,{}):e.isError?void 0:(0,Q.jsx)(lN,{})}function dN(){let{projectId:e=``}=Hn(),t=qn(),n=A(),r=c();if(e==="default"){let e=uN(n,r,t);if(e!==void 0)return e}if(n.data){if(!(n.data.bootProject!==null&&n.data.bootProject===e||n.data.projects.some(t=>t.id===e)))return(0,Q.jsx)(TE,{projectId:e,registry:n.data})}else if(!n.isError)return(0,Q.jsx)(lN,{});return(0,Q.jsx)(sn,{projectId:n.data?.bootProject!==null&&n.data?.bootProject===e?null:e,children:(0,Q.jsx)(Bn,{},e)})}function fN(){let{projectId:e=``}=Hn();return(0,Q.jsx)(rE,{},e)}var pN=/^\/tasks\/([0-9a-f-]{36})(?=\/|$)/i;function mN(e,t){let n=e.data===void 0?t.data===void 0?void 0:t.data.bootProject:e.data.bootProject;return{resolved:n,settled:(e.data!==void 0||e.isError)&&(t.data!==void 0||t.isError),boot:n===void 0?`default`:n}}function hN(e){let t=e.data?.projects??[];return t.find(e=>e.status!==`missing`)?.id??t[0]?.id??null}function gN(e,t,n){if(!(e.pathname===`/`&&e.search===``&&e.hash===``))return;if(t.data===void 0&&!t.isError)return(0,Q.jsx)(lN,{});let r=zp(kp(),t.data,n??void 0,{preserveRemovedProject:Pe()});if(r!==null)return(0,Q.jsx)(Wn,{to:r,replace:!0})}function _N(e,t,n,r,i,a){if(!n)return{state:`pending`};let o=i.data?.runs.find(t=>t.id===e)?.projectId;return o===void 0?r?a.data===void 0&&!a.isError?{state:`pending`}:{state:`resolved`,projectId:a.data?.runs.find(t=>t.id===e)?.projectId??t}:{state:`resolved`,projectId:t}:{state:`resolved`,projectId:o}}function vN(e,t){let n=t.pathname===`/p`||t.pathname===`/p/`?`/`:t.pathname;return(0,Q.jsx)(Wn,{to:`/p/${encodeURIComponent(e)}${n}${t.search}${t.hash}`,replace:!0})}function yN(){let e=qn(),t=c(),n=A(),r=pN.exec(e.pathname)?.[1]??null,i=a(r!==null),o=i.data!==void 0||i.isError,s=i.data!==void 0&&!i.data.runs.some(e=>e.id===r),l=z(r!==null&&s?r:``),{resolved:u,settled:d,boot:f}=mN(t,n);if(u===void 0&&!d)return(0,Q.jsx)(lN,{});let p=gN(e,n,u);if(p!==void 0)return p;if(f===null&&n.data===void 0&&!n.isError)return(0,Q.jsx)(lN,{});let m=f??hN(n),h=m;if(r!==null){let e=_N(r,m,o,s,i,l);if(e.state===`pending`)return(0,Q.jsx)(lN,{});h=e.projectId}return h===null?(0,Q.jsx)(bE,{}):vN(h,e)}function bN(){return(0,Q.jsxs)(K,{path:`/p/:projectId`,element:(0,Q.jsx)(dN,{}),children:[(0,Q.jsx)(K,{index:!0,element:(0,Q.jsx)(Cj,{})}),(0,Q.jsx)(K,{path:`new`,element:(0,Q.jsx)(fN,{})}),(0,Q.jsx)(K,{path:`activity`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(sx,{}),children:(0,Q.jsx)(iN,{})})}),(0,Q.jsxs)(K,{path:`tasks/:id`,element:(0,Q.jsx)(HD,{}),children:[(0,Q.jsx)(K,{index:!0,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(jE,{}),children:(0,Q.jsx)(JM,{})})}),(0,Q.jsx)(K,{path:`changes`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(DE,{tab:`changes`}),children:(0,Q.jsx)(YM,{})})}),(0,Q.jsx)(K,{path:`files`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(DE,{tab:`files`}),children:(0,Q.jsx)(XM,{})})}),(0,Q.jsx)(K,{path:`report`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(`div`,{"data-route":`task-report`,children:(0,Q.jsx)(`h1`,{className:`p-4 text-sm text-soft-foreground`,children:`Loading report…`})}),children:(0,Q.jsx)(ZM,{})})}),(0,Q.jsx)(K,{path:`commits`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(DE,{tab:`changes`}),children:(0,Q.jsx)(QM,{})})}),(0,Q.jsx)(K,{path:`commits/:sha`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(DE,{tab:`changes`}),children:(0,Q.jsx)(QM,{})})}),(0,Q.jsx)(K,{path:`issue/:n`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(AE,{kind:`issue`}),children:(0,Q.jsx)($M,{kind:`issue`})})}),(0,Q.jsx)(K,{path:`pr/:n`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(AE,{kind:`pr`}),children:(0,Q.jsx)($M,{kind:`pr`})})})]}),(0,Q.jsx)(K,{path:`git`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(CE,{}),children:(0,Q.jsx)(eN,{section:`main`,index:!0})})}),(0,Q.jsx)(K,{path:`git/commits`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(CE,{}),children:(0,Q.jsx)(eN,{section:`main`})})}),(0,Q.jsx)(K,{path:`git/commits/:sha`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(CE,{}),children:(0,Q.jsx)(eN,{section:`main`})})}),(0,Q.jsx)(K,{path:`git/not-landed`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(CE,{}),children:(0,Q.jsx)(eN,{section:`not-landed`})})}),(0,Q.jsx)(K,{path:`git/cleanup`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(CE,{}),children:(0,Q.jsx)(eN,{section:`cleanup`})})}),(0,Q.jsx)(K,{path:`git/branches`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(CE,{}),children:(0,Q.jsx)(eN,{section:`branches`})})}),(0,Q.jsx)(K,{path:`git/changes`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(CE,{}),children:(0,Q.jsx)(eN,{section:`changes`})})}),(0,Q.jsx)(K,{path:`github`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(cx,{}),children:(0,Q.jsx)(tN,{view:`issues`,index:!0})})}),(0,Q.jsx)(K,{path:`github/prs`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(cx,{}),children:(0,Q.jsx)(tN,{view:`prs`})})}),(0,Q.jsx)(K,{path:`github/issues/:n`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(cx,{}),children:(0,Q.jsx)(tN,{view:`issues`})})}),(0,Q.jsx)(K,{path:`github/prs/:n`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(cx,{}),children:(0,Q.jsx)(tN,{view:`prs`})})}),(0,Q.jsx)(K,{path:`github/prs/:n/changes`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(cx,{}),children:(0,Q.jsx)(tN,{view:`prs`,changes:!0})})}),(0,Q.jsx)(K,{path:`automations`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(`p`,{role:`status`,children:`Loading automations…`}),children:(0,Q.jsx)(WM,{})})}),(0,Q.jsx)(K,{path:`automations/new`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(`p`,{role:`status`,children:`Loading automations…`}),children:(0,Q.jsx)(WM,{mode:`new`})})}),(0,Q.jsx)(K,{path:`automations/:automationId`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(`p`,{role:`status`,children:`Loading automations…`}),children:(0,Q.jsx)(WM,{mode:`edit`})})}),(0,Q.jsx)(K,{path:`automations/:automationId/log`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(`p`,{role:`status`,children:`Loading automations…`}),children:(0,Q.jsx)(WM,{mode:`log`})})}),(0,Q.jsx)(K,{path:`skills`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(wE,{}),children:(0,Q.jsx)(oN,{})})}),(0,Q.jsx)(K,{path:`reports`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(`p`,{role:`status`,children:`Loading reports…`}),children:(0,Q.jsx)(nN,{})})}),(0,Q.jsx)(K,{path:`workflows`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(EE,{}),children:(0,Q.jsx)(rN,{})})}),(0,Q.jsx)(K,{path:`workflows/:name`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(EE,{}),children:(0,Q.jsx)(rN,{})})}),(0,Q.jsx)(K,{path:`settings`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(`p`,{role:`status`,children:`Loading settings…`}),children:(0,Q.jsx)(KM,{})})}),(0,Q.jsx)(K,{path:`settings/skills`,element:(0,Q.jsx)(sN,{})}),pb(`project`).map(e=>(0,Q.jsx)(K,{path:`settings/${e.id}`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(`p`,{role:`status`,children:`Loading settings…`}),children:(0,Q.jsx)(qM,{section:e,scope:`project`})})},e.id)),pb(`global`).map(e=>(0,Q.jsx)(K,{path:`settings/${e.id}`,element:(0,Q.jsx)(cN,{sectionId:e.id})},e.id)),(0,Q.jsx)(K,{path:`*`,element:(0,Q.jsx)(xE,{})})]})}function xN(e){let t=Zn(Vn(bN()),e),n=t?.at(-1);return!t||!n||n.route.path===`*`?null:{pattern:`/${t.slice(1).map(e=>e.route.path).filter(e=>e!==void 0).join(`/`)}`.replace(/\/$/,``)||`/`,params:n.params}}function SN(){return(0,Q.jsxs)(Yn,{children:[bN(),(0,Q.jsx)(K,{path:`/tasks`,element:(0,Q.jsx)(zM,{})}),(0,Q.jsx)(K,{path:`/tools`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(`p`,{role:`status`,children:`Loading workspace tools…`}),children:(0,Q.jsx)(GM,{})})}),(0,Q.jsx)(K,{path:`/activity`,element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(sx,{}),children:(0,Q.jsx)(aN,{})})}),(0,Q.jsx)(K,{path:`/settings/global`,element:(0,Q.jsx)(Wn,{to:hb,replace:!0})}),(0,Q.jsx)(K,{path:`/settings/global/skills`,element:(0,Q.jsx)(Wn,{to:`/skills`,replace:!0})}),pb(`global`).map(e=>(0,Q.jsx)(K,{path:mb(`global`,e.id),element:(0,Q.jsx)(Z.Suspense,{fallback:(0,Q.jsx)(`p`,{role:`status`,children:`Loading settings…`}),children:(0,Q.jsx)(qM,{section:e,scope:`global`})})},e.id)),(0,Q.jsx)(K,{path:`*`,element:(0,Q.jsx)(yN,{})})]})}function CN(){let[e]=(0,Z.useState)(Ac);(0,Z.useEffect)(()=>Lr(e),[e]);let t=Be(),n=Le();return(0,Q.jsx)(Mc,{children:(0,Q.jsx)(rn,{client:e,children:(0,Q.jsx)(cf,{children:(0,Q.jsx)(Yb,{children:(0,Q.jsx)(Qb,{hostId:t,children:(0,Q.jsxs)(Pr,{children:[(0,Q.jsx)(kc,{}),(0,Q.jsx)(ax,{}),(0,Q.jsxs)(Xn,{...n?{basename:n}:{},children:[(0,Q.jsx)($b,{}),(0,Q.jsx)(jc.Provider,{value:xN,children:(0,Q.jsx)(hr,{children:(0,Q.jsx)(Pb,{children:(0,Q.jsx)(SN,{})})})}),(0,Q.jsx)(qt,{})]})]})})})})})})}var wN=document.querySelector(`meta[name="cez-api-base"]`)?.getAttribute(`content`),TN=h(wN,void 0,void 0);Ue({pathname:window.location.pathname,mainApiBase:TN});var EN=document.getElementById(`root`);if(!EN)throw Error(`Squawk: #root container is missing from index.html`);(0,dc.createRoot)(EN).render((0,Q.jsx)(Z.StrictMode,{children:(0,Q.jsx)(CN,{})}));export{PC as $,If as $n,Pv as $t,SE as A,Rm as An,jy as At,Qw as B,Om as Bn,hy as Bt,BE as C,qh as Cn,Vc as Cr,Ly as Ct,DE as D,Nm as Dn,Iy as Dt,OE as E,$m as En,Pc as Er,Fy as Et,Yw as F,zm as Fn,ky as Ft,HC as G,gm as Gn,sy as Gt,Zw as H,Tm as Hn,py as Ht,Jw as I,Ym as In,Ky as It,VC as J,xm as Jn,ny as Jt,WC as K,_m as Kn,Kv as Kt,Hw as L,km as Ln,Oy as Lt,FT as M,Zm as Mn,Hy as Mt,NT as N,Um as Nn,Wy as Nt,EE as O,Pm as On,Ty as Ot,qw as P,Hm as Pn,Gy as Pt,NC as Q,Pf as Qn,ey as Qt,Gw as R,Mm as Rn,by as Rt,zE as S,e_ as Sn,Wc as Sr,Zy as St,AE as T,Fh as Tn,Fc as Tr,Ay as Tt,Lw as U,mm as Un,ly as Ut,Xw as V,Em as Vn,dy as Vt,UC as W,Sm as Wn,cy as Wt,jC as X,Ff as Xn,Jv as Xt,FC as Y,xp as Yn,ry as Yt,TC as Z,Lf as Zn,Yv as Zt,uD as _,d_ as _n,Zc as _r,Xb as _t,YO as a,Rv as an,hd as ar,hx as at,VE as b,u_ as bn,Jc as br,pb as bt,jD as c,Cv as cn,Ku as cr,Sx as ct,gD as d,a_ as dn,xl as dr,wx as dt,Hv as en,jf as er,vC as et,_D as f,p_ as fn,dl as fr,lx as ft,cD as g,n_ as gn,$c as gr,tx as gt,SD as h,r_ as hn,tl as hr,ex as ht,XO as i,zv as in,Td as ir,kx as it,xE as j,qm as jn,Dy as jt,CE as k,Gm as kn,My as kt,AD as l,C_ as ln,Wu as lr,_x as lt,yD as m,c_ as mn,ol as mr,sx as mt,$A as n,Lv as nn,Af as nr,Bx as nt,JO as o,Bv as on,ld as or,bx as ot,pD as p,l_ as pn,cl as pr,cx as pt,RC as q,ym as qn,Gv as qt,fA as r,Vv as rn,lf as rr,Ox as rt,LD as s,xv as sn,Xu as sr,Cx as st,Pj as t,Uv as tn,Nf as tr,_C as tt,hD as u,S_ as un,Hu as ur,xx as ut,dD as v,m_ as vn,Xc as vr,hb as vt,jE as w,Jh as wn,Lc as wr,Ey as wt,ME as x,qg as xn,Kc as xr,Qy as xt,UE as y,i_ as yn,Yc as yr,mb as yt,Uw as z,jm as zn,_y as zt};
|