@hearsay-tools/squawk 0.19.0-dev.9216 → 0.19.0-dev.9229.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (148) hide show
  1. package/dist/ci-wait/controller.d.ts +7 -7
  2. package/dist/contract/hosts.d.ts +3 -0
  3. package/dist/contract/index.js +8 -0
  4. package/dist/contract/projects.d.ts +6 -0
  5. package/dist/core/forge-registry.d.ts +8 -0
  6. package/dist/core/forge-registry.js +36 -13
  7. package/dist/core/forge-registry.js.map +1 -1
  8. package/dist/features/hosts/routes.d.ts +66 -64
  9. package/dist/features/webhooks/routes.d.ts +41 -38
  10. package/dist/server/activity-routes.d.ts +23 -23
  11. package/dist/server/projects-routes.d.ts +47 -41
  12. package/dist/server/repo-routes.d.ts +13 -13
  13. package/dist/server/runs-routes.d.ts +326 -326
  14. package/dist/server/server.d.ts +6 -0
  15. package/dist/workspace/projects.d.ts +5 -0
  16. package/dist/workspace/projects.js +8 -2
  17. package/dist/workspace/projects.js.map +1 -1
  18. package/package.json +4 -4
  19. package/web/dist/assets/accounts-section-lnMwvHTo.js +1 -0
  20. package/web/dist/assets/activity-motion-DBxIOskd.js +1 -0
  21. package/web/dist/assets/{activity-route-Bmig0E18.js → activity-route-BYf5OD8Y.js} +1 -1
  22. package/web/dist/assets/agent-accounts-BzD14qLU.js +1 -0
  23. package/web/dist/assets/agent-config-section-BwmBjoad.js +7 -0
  24. package/web/dist/assets/agent-defaults-section-BbFvw0IO.js +1 -0
  25. package/web/dist/assets/appearance-CkohbKAs.js +1 -0
  26. package/web/dist/assets/archive-on-merge-field-CQ8DBqiG.js +1 -0
  27. package/web/dist/assets/ask-card-Bli7vYif.js +9 -0
  28. package/web/dist/assets/automations-route-BNYFQeuu.js +2 -0
  29. package/web/dist/assets/commit-list-CJZtpbaw.js +1 -0
  30. package/web/dist/assets/diff-DPSOaO5_.js +3 -0
  31. package/web/dist/assets/{diff-controls-Bb70UBsP.js → diff-controls-rfNgY_Dd.js} +1 -1
  32. package/web/dist/assets/{diff-view-DLcxtXIH.js → diff-view-CswchTTd.js} +1 -1
  33. package/web/dist/assets/{discard-changes-dialog-BzypT4vb.js → discard-changes-dialog-BMT0YtWx.js} +1 -1
  34. package/web/dist/assets/file-preview-DoaMlVS3.js +2 -0
  35. package/web/dist/assets/folder-browser-D_q7aPq-.js +1 -0
  36. package/web/dist/assets/{git-toolbar-DPkpAaKz.js → git-toolbar-BCqNvkr5.js} +1 -1
  37. package/web/dist/assets/github-Bv1h-3dP.js +1 -0
  38. package/web/dist/assets/{global-activity-route-CQULPYKA.js → global-activity-route-CrAG-ji7.js} +1 -1
  39. package/web/dist/assets/{host-context-iTMFRMT5.js → host-context-KsSKxKbI.js} +1 -1
  40. package/web/dist/assets/host-storage-BHtMSWBL.js +1 -0
  41. package/web/dist/assets/hosts-pzCm30ta.js +1 -0
  42. package/web/dist/assets/{image-preview-C_xACQXI.js → image-preview-CvcSCCBU.js} +1 -1
  43. package/web/dist/assets/index-D9hyWO4C.js +21 -0
  44. package/web/dist/assets/index-DZXi-K2N.css +1 -0
  45. package/web/dist/assets/label-DEZnEIpB.js +1 -0
  46. package/web/dist/assets/{markdown-C1p1PDmF.js → markdown-BRE9fTUI.js} +1 -1
  47. package/web/dist/assets/{open-in-menu-CbPtuWnJ.js → open-in-menu-DomSOC26.js} +1 -1
  48. package/web/dist/assets/{option-select-C6d3jHce.js → option-select-Cqnmt-CB.js} +1 -1
  49. package/web/dist/assets/preferences-section-CC4m45tb.js +1 -0
  50. package/web/dist/assets/preview-DFL4D2C_.js +1 -0
  51. package/web/dist/assets/{preview-pane-connected-ELLewN-g.js → preview-pane-connected-CvF3zJ9A.js} +2 -2
  52. package/web/dist/assets/project-location-D6-Lo1vY.js +1 -0
  53. package/web/dist/assets/project-router-CARDbdMX.js +1 -0
  54. package/web/dist/assets/project-scope-context-Bz7AAyJ4.js +4 -0
  55. package/web/dist/assets/projects-section-zeGtqnI3.js +1 -0
  56. package/web/dist/assets/{prompt-templates-section-D3GzKJMf.js → prompt-templates-section--ygct2zC.js} +2 -2
  57. package/web/dist/assets/queries-D7W-eGim.js +1 -0
  58. package/web/dist/assets/reference-chip-D8ckcrda.js +1 -0
  59. package/web/dist/assets/remote-settings-notice-MxDxNXXw.js +1 -0
  60. package/web/dist/assets/repo-git-VfTEbVO3.js +1 -0
  61. package/web/dist/assets/report-reader-DLCLUfdH.js +1 -0
  62. package/web/dist/assets/{report-selection-DxBxW6dz.js → report-selection-BcsbTczw.js} +1 -1
  63. package/web/dist/assets/reports-QoDlngjL.js +1 -0
  64. package/web/dist/assets/{resources-section-CpAOY20Z.js → resources-section-CBL0htm5.js} +1 -1
  65. package/web/dist/assets/{review-notes-drafts-D25BaEEb.js → review-notes-drafts-DJDQNemf.js} +1 -1
  66. package/web/dist/assets/{review-panel-CS9wTfAu.js → review-panel-BY05CuXd.js} +1 -1
  67. package/web/dist/assets/review-strip-BWhQ5CIC.js +1 -0
  68. package/web/dist/assets/{run-detail-refresh-wJr0M04e.js → run-detail-refresh-CecZhU-h.js} +1 -1
  69. package/web/dist/assets/{run-diff-BBASqHSE.js → run-diff-CpwwrpXO.js} +1 -1
  70. package/web/dist/assets/run-header-CZU3e9Xk.js +2 -0
  71. package/web/dist/assets/{select-CEEeAH4k.js → select-C72KGfnK.js} +1 -1
  72. package/web/dist/assets/{session-context-section-F1umLA86.js → session-context-section-D8v30mSp.js} +1 -1
  73. package/web/dist/assets/settings-agent-picker-DGhJwDIY.js +1 -0
  74. package/web/dist/assets/{settings-save-bar-BkU1JDt3.js → settings-save-bar-Dp-eEIEF.js} +1 -1
  75. package/web/dist/assets/settings-shell-DZzgCmSz.js +1 -0
  76. package/web/dist/assets/sidebar-section-B94mdYUS.js +1 -0
  77. package/web/dist/assets/skills-B6jO_f1w.js +1 -0
  78. package/web/dist/assets/status-dot-B5MkhHDP.js +1 -0
  79. package/web/dist/assets/{tab-link-CiKWtkK_.js → tab-link-zXPa9LIz.js} +1 -1
  80. package/web/dist/assets/task-changes-B_2BDWIf.js +5 -0
  81. package/web/dist/assets/task-commits-kxDG4T81.js +1 -0
  82. package/web/dist/assets/{task-file-scope-DU8AkDkr.js → task-file-scope-DVACyrij.js} +1 -1
  83. package/web/dist/assets/task-files-4CxXkPOx.js +1 -0
  84. package/web/dist/assets/task-github-item-C8hMZej3.js +1 -0
  85. package/web/dist/assets/task-thread-Bv_Fjceh.js +2 -0
  86. package/web/dist/assets/thread-state-CufNf_fC.js +4 -0
  87. package/web/dist/assets/use-finish-run-CjYc6ovQ.js +1 -0
  88. package/web/dist/assets/use-hand-to-agent-state-B_j_e1kD.js +1 -0
  89. package/web/dist/assets/use-path-bases-BfjK7tem.js +1 -0
  90. package/web/dist/assets/use-workspace-config-save-toCmvqtz.js +1 -0
  91. package/web/dist/assets/{workflows-DdKRMlHR.js → workflows-iMfDerlK.js} +2 -2
  92. package/web/dist/assets/workspace-tools-CgYFRggf.js +1 -0
  93. package/web/dist/assets/{worktrees-section-CCgqbLAh.js → worktrees-section-CtT9bwKK.js} +5 -5
  94. package/web/dist/assets/{zoomable-image-DJ1lJEMc.js → zoomable-image-Dv85Vr4A.js} +1 -1
  95. package/web/dist/index.html +17 -20
  96. package/web/dist/live-worker.js +1 -1
  97. package/web/dist/assets/accounts-section-BJcwTmko.js +0 -1
  98. package/web/dist/assets/activity-motion-D7ylxNSA.js +0 -1
  99. package/web/dist/assets/agent-accounts-DaaS69XB.js +0 -1
  100. package/web/dist/assets/agent-config-section-BOXqQyTv.js +0 -7
  101. package/web/dist/assets/agent-defaults-section-Bxfreo-n.js +0 -1
  102. package/web/dist/assets/appearance-BRqSFVDC.js +0 -1
  103. package/web/dist/assets/archive-on-merge-field-hDSXItUf.js +0 -1
  104. package/web/dist/assets/ask-card-CWrAEuZE.js +0 -9
  105. package/web/dist/assets/attention-CFW302LY.js +0 -1
  106. package/web/dist/assets/automations-route-BBsU9yBn.js +0 -2
  107. package/web/dist/assets/commit-list-5iHD08NO.js +0 -1
  108. package/web/dist/assets/diff-CkIsqgZZ.js +0 -3
  109. package/web/dist/assets/file-preview-CJVN0cBa.js +0 -2
  110. package/web/dist/assets/folder-browser-Cdm2WZOB.js +0 -1
  111. package/web/dist/assets/github-DXBAYLfd.js +0 -1
  112. package/web/dist/assets/host-storage-Cr_NKfWy.js +0 -1
  113. package/web/dist/assets/hosts-IKDCpyJQ.js +0 -1
  114. package/web/dist/assets/index-D1E0Dmck.css +0 -1
  115. package/web/dist/assets/index-k2m-s5zD.js +0 -21
  116. package/web/dist/assets/label-ODcSLYVj.js +0 -1
  117. package/web/dist/assets/preferences-section-ChS8Q-Lu.js +0 -1
  118. package/web/dist/assets/preview-B5bPk6HT.js +0 -1
  119. package/web/dist/assets/project-location-D8vnqA4E.js +0 -1
  120. package/web/dist/assets/project-router-CPgPVoBJ.js +0 -1
  121. package/web/dist/assets/projects-section-L3QxEiRK.js +0 -1
  122. package/web/dist/assets/queries-DHjNE2es.js +0 -1
  123. package/web/dist/assets/read-state-jUDTdM3R.js +0 -1
  124. package/web/dist/assets/reference-chip-kvc51N1L.js +0 -1
  125. package/web/dist/assets/remote-settings-notice-BtVKQ2vp.js +0 -1
  126. package/web/dist/assets/repo-git-BGSxevNj.js +0 -1
  127. package/web/dist/assets/report-reader-CvEkEEwN.js +0 -1
  128. package/web/dist/assets/reports-1vI74Z6R.js +0 -1
  129. package/web/dist/assets/review-strip-nrpQBfNI.js +0 -1
  130. package/web/dist/assets/run-header-DVnksnr4.js +0 -2
  131. package/web/dist/assets/settings-agent-picker-sUQdIon3.js +0 -1
  132. package/web/dist/assets/settings-shell-DodTPpjl.js +0 -1
  133. package/web/dist/assets/sidebar-section-DspuARa_.js +0 -1
  134. package/web/dist/assets/skills-CrHHdPjJ.js +0 -1
  135. package/web/dist/assets/status-dot-DuorWA5M.js +0 -1
  136. package/web/dist/assets/task-changes-U1cnUd83.js +0 -5
  137. package/web/dist/assets/task-commits-DxuX8SZp.js +0 -1
  138. package/web/dist/assets/task-files-DaDM9FRg.js +0 -1
  139. package/web/dist/assets/task-github-item-CXzzVHXw.js +0 -1
  140. package/web/dist/assets/task-groups-BapM4YcT.js +0 -1
  141. package/web/dist/assets/task-thread-9WIv4rPC.js +0 -2
  142. package/web/dist/assets/thread-state-IooDEE0b.js +0 -4
  143. package/web/dist/assets/toaster-Dglox5F-.js +0 -4
  144. package/web/dist/assets/use-finish-run-jVAqsGkV.js +0 -1
  145. package/web/dist/assets/use-hand-to-agent-state-DfucUGAH.js +0 -1
  146. package/web/dist/assets/use-path-bases-C7DRxlRi.js +0 -1
  147. package/web/dist/assets/use-workspace-config-save-B2eroiEx.js +0 -1
  148. package/web/dist/assets/workspace-tools-CePJG7uG.js +0 -1
@@ -1 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{an as r,cn as i,dn as a,fn as o,gn as s,hn as c,in as l,ln as u,mn as d,on as f,pn as p,rn as m,sn as h,un as g,wn as _,yt as v}from"./queries-DHjNE2es.js";import{f as y,h as b,m as x,u as S}from"./host-context-iTMFRMT5.js";import{Fn as ee,Ji as C,Nn as te,ar as w,ji as ne,or as T,rr as E,tr as re}from"./toaster-Dglox5F-.js";import{i as D,r as O}from"./cez-idle-C0drOeLs.js";import{o as k}from"./dist-CCX8mhHc.js";import{n as ie,t as A}from"./hosts-IKDCpyJQ.js";import{n as ae,r as j,t as M}from"./run-detail-refresh-wJr0M04e.js";import{h as N}from"./es2015-BHonSvOU.js";var oe=class extends EventTarget{readyState=0;release;constructor(e,t){super(),this.release=this.subscribe()}subscribe(){let e=()=>queueMicrotask(()=>{this.readyState===0&&(this.readyState=1,this.dispatchEvent(new Event(`open`)))});return w({kind:`workspace`},{ready:e,reset:()=>{this.readyState!==2&&(this.readyState=0,e())},frame:t=>{if(`data`in t&&t.event===`reconnect`){this.readyState=0,e();return}if(`data`in t&&t.event===`disconnect`){this.readyState===1&&(this.readyState=0,this.dispatchEvent(new Event(`error`)));return}`data`in t&&t.event===`ready`&&T(),`data`in t&&this.dispatchEvent(new MessageEvent(t.event,{data:t.data}))}})}requestReady(){return this.readyState!==2&&E()}close(){this.readyState=2,this.release()}},P=e(t(),1);function F(e,t){let n=e.getQueryCache().find({queryKey:t,exact:!0});return n&&n.state.fetchStatus!==`idle`?e.cancelQueries({queryKey:t,exact:!0}).then(()=>e.invalidateQueries({queryKey:t,exact:!0})):e.invalidateQueries({queryKey:t,exact:!0})}function I(e,t,n,r){let i=m(t,n,r);return e.isMutating({mutationKey:i,exact:!0})>0||e.getMutationCache().getAll().some(e=>{if(e.state.status!==`pending`)return!1;let i=e.state.variables;return i?.hostId===t&&i?.projectId===n&&i?.runId===r})}function se(e,t){if(S()||t)return[];let n=[h(e).reconcile()];return e.getQueryState(A.hosts)&&n.push(F(e,A.hosts)),e.getQueryState(A.hostsProjects)&&n.push(F(e,A.hostsProjects)),n}function ce(e,t,n){if(!S())for(let r of g)e.addEventListener(r,e=>{let i=c(r,e.data);if(i)if(i.type===`host-run-summary`||i.type===`host-run-deleted`){n.run(i);let e=i.type===`host-run-summary`?i.summary.id:i.id,r=m(i.hostId,i.project,e);i.type===`host-run-deleted`?t.getQueryState(r)&&t.removeQueries({queryKey:r,exact:!0}):t.getQueryState(r)&&!I(t,i.hostId,i.project,e)&&t.invalidateQueries({queryKey:r,exact:!0})}else i.type===`host-usage`?n.usage(i.hostId,i.project,i.usage):(i.stateChanged&&F(t,A.hosts),(i.stateChanged||i.indexChanged)&&F(t,A.hostsProjects),i.indexChanged&&n.reconcileHosts(i.hostIds))})}var L=n(),le=`/workspace/events?runs=summary`,R=2,ue=3e3,de=[`run-summary`,`run-deleted`,`usage`,`ping`,`ready`],z=[`project-added`,`project-removed`,`checkout-progress`,`automation-change`,`project-ready`],B=new Set;function V(e){return B.add(e),()=>{B.delete(e)}}function H(e){return e[1]===`runs`&&e[2]===`list`}function U(e,t){return e.cancelQueries({queryKey:t}).then(()=>e.invalidateQueries({queryKey:t}))}function W(e){return e.invalidateQueries({predicate:e=>H(e.queryKey),refetchType:`none`}),e.getQueryCache().findAll({predicate:e=>H(e.queryKey)&&(e.state.data!==void 0||e.state.fetchStatus!==`idle`)}).map(t=>U(e,t.queryKey))}var fe=1e3,G=new WeakMap;function K(e){let t=l.repoBranches,n=G.get(e);if(n){n.set(JSON.stringify(t),t);return}G.set(e,new Map([[JSON.stringify(t),t]])),setTimeout(()=>{let t=G.get(e);G.delete(e);for(let n of t?.values()??[])e.invalidateQueries({queryKey:n})},fe)}function q(e,t,n=!1){if(t?.aborted)return Promise.resolve();let a=[l.runs.all,r.runsIndex,r.projects,l.health,l.worktrees,l.repoBranches,r.providerStatus],o=S()||n?[]:[A.hosts,A.hostsProjects,f],s=()=>{for(let t of a)e.cancelQueries({queryKey:t});for(let t of o)e.cancelQueries({queryKey:t,exact:!0})};return t?.addEventListener(`abort`,s,{once:!0}),D(()=>{for(let t of e.getQueryCache().findAll({predicate:e=>H(e.queryKey)}))t.state.data===void 0&&t.state.fetchStatus!==`idle`&&e.cancelQueries({queryKey:t.queryKey,exact:!0});return[e.invalidateQueries({queryKey:l.runs.all,...n?{predicate:e=>[`list`,`detail`,`relationships`,`archived`].includes(String(e.queryKey[2]))}:{}}),e.invalidateQueries({predicate:e=>H(e.queryKey)}),i(e).reconcile(),...se(e,n),e.invalidateQueries({queryKey:r.projects}),U(e,l.health),e.invalidateQueries({queryKey:l.worktrees}),e.invalidateQueries({queryKey:l.repoBranches}),e.invalidateQueries({queryKey:r.providerStatus}),n?void 0:e.invalidateQueries({predicate:({queryKey:e})=>e.length===3&&e[1]===`github`&&(e[2]===null||typeof e[2]==`number`)})]}).finally(()=>t?.removeEventListener(`abort`,s))}function J(e){return x()??Y(e)}function Y(e){let t=e.getQueryData(r.projects);if(t?.bootProject!==null)return typeof t?.bootProject==`string`&&t.bootProject!==``?t.bootProject:e.getQueryData(l.health)?.bootProject??e.getQueryData([`default`,`health`])?.bootProject??void 0}function pe(e,t){return[_({projectId:e,boot:e===t}).cacheScope,`runs`,`list`]}function me(e){let t=new Map,n=new Map,r=t=>{let r=n.get(JSON.stringify(t));if(!r)return;let i=e.getQueryCache().find({queryKey:t,exact:!0}),a=i?.promise;r.phase=`awaiting-fetch`,r.dirty=!1,e.invalidateQueries({queryKey:t,exact:!0}),i?.promise&&i.promise!==a&&(r.phase=`fetching`)},i=e.getQueryCache().subscribe(t=>{if(!n.size||t.type!==`updated`)return;let i=JSON.stringify(t.query.queryKey),a=n.get(i);if(a){if(t.action.type===`setState`){t.query.state.isInvalidated||e.invalidateQueries({queryKey:a.key,exact:!0,refetchType:`none`});return}if(t.action.type===`fetch`){a.phase===`awaiting-fetch`&&(a.phase=`fetching`),a.dirty=!1;return}if(t.action.type===`success`){if(!t.action.manual){a.phase===`fetching`&&!a.dirty?n.delete(i):r(a.key);return}a.phase!==`needs-start`&&(a.phase===`fetching`&&(a.dirty=!0),e.invalidateQueries({queryKey:a.key,exact:!0},{cancelRefetch:!1}))}}}),s=(t,r)=>{let i=JSON.stringify(t),a=e.getQueryCache().find({queryKey:t,exact:!0});if(!a)return;let o=n.get(i);!o&&(a.state.fetchStatus!==`idle`||a.state.isInvalidated)||o&&a.state.fetchStatus===`idle`?(n.set(i,{key:t,phase:`needs-start`,dirty:!1}),a.state.fetchStatus!==`idle`&&e.cancelQueries({queryKey:t,exact:!0}),r.some(e=>JSON.stringify(e)===i)||r.push(t)):o?.phase===`fetching`&&(o.dirty=!0)},c,u,d=(i=!1)=>{u!==void 0&&clearTimeout(u),u=void 0,c!==void 0&&cancelAnimationFrame(c),c=void 0;let a=[];for(let{key:r,baseList:i,baseQuery:c,baseUpdateCount:l,runs:u}of t.values()){let t=e.getQueryCache().find({queryKey:r,exact:!0});if(t!==c||t?.state.dataUpdateCount!==l||t?.state.data!==i){a.push(r),n.set(JSON.stringify(r),{key:r,phase:`needs-start`,dirty:!1}),e.cancelQueries({queryKey:r,exact:!0});continue}s(r,a),e.setQueryData(r,e=>{let t=e;for(let e of u.values())t=o(t,e);return t})}if(t.clear(),!i)for(let e of a)r(e);return a},f=t=>{let n=[pe(t,Y(e))],r=[t,`runs`,`list`];return(t===J(e)||e.getQueryState(r))&&n.push(r),t===J(e)&&n.push(l.runs.list()),[...new Map(n.map(e=>[JSON.stringify(e),e])).values()]};return{onEvent(i,l){let p=f(i);if(l.type===`run-summary`&&l.summary.archived&&p.every(t=>!e.getQueryData(t)?.find(e=>e.id===l.summary.id)?.archived)&&l.type===`run-summary`){for(let r of p){let i=JSON.stringify(r),a=n.get(i);a?.phase===`fetching`&&(a.dirty=!0);let o=t.get(i);if(!o){let n=e.getQueryCache().find({queryKey:r,exact:!0});o={key:r,baseList:n?.state.data,baseQuery:n,baseUpdateCount:n?.state.dataUpdateCount,runs:new Map},t.set(i,o)}o.runs.set(l.summary.id,l.summary)}u===void 0&&(u=setTimeout(()=>{d()},50),typeof requestAnimationFrame==`function`&&(c=requestAnimationFrame(()=>{d()})));return}let m=d(!0);for(let t of p)s(t,m),l.type===`run-summary`?e.setQueryData(t,e=>o(e,l.summary)):e.setQueryData(t,e=>a(e,l.id));for(let e of m)r(e)},flush:d,cancel(){i(),n.clear()}}}var he=400;function ge(e){let t=new Map,n=new Map,r=(t,r)=>{if(r&&!e.getQueryState(t))return;let i=JSON.stringify(t);n.has(i)||n.set(i,setTimeout(()=>{n.delete(i),e.invalidateQueries({queryKey:t})},he))};return{onSummary(e,n){let i=e.delegation?.role===`worker`?e.delegation.parentRunId:void 0,a=e.delegation?.role===`worker`?e.delegation.supervisorRunId:void 0,o=t.get(e.id);if(t.set(e.id,{shape:n,...i===void 0?{}:{parentRunId:i},...a===void 0?{}:{supervisorRunId:a}}),o?.shape!==n){r(l.runs.relationships(e.id),!0);for(let e of[i,a])e!==void 0&&r(l.runs.relationships(e),!0)}},onDeleted(n){let i=t.get(n);t.delete(n),e.removeQueries({queryKey:l.runs.relationships(n)}),i?.supervisorRunId!==void 0&&r(l.runs.relationships(i.supervisorRunId),!0),i?.parentRunId===void 0?r([...l.runs.all,`relationships`],!1):r(l.runs.relationships(i.parentRunId),!0)},cancel(){for(let e of n.values())clearTimeout(e);n.clear(),t.clear()}}}var X={predicate:e=>e.queryKey[1]===`runs`&&e.queryKey[2]===`archived`};function _e(e,t){if(t.delegation?.role===`worker`)return;let n=!1;for(let r of e.getQueryCache().findAll(X)){let i=r.state.data;i&&(i.pages.some(e=>e.runs.some(e=>e.id===t.id))?(e.setQueryData(r.queryKey,{...i,pages:i.pages.map(e=>({...e,runs:e.runs.map(e=>e.id===t.id?t:e)}))}),(!t.archived||r.queryKey[3]!==``)&&(n=!0)):t.archived&&(n=!0))}n&&e.invalidateQueries(X)}function ve(e,t,n,r,i){switch(n.type){case`run-summary`:{let t=n.summary;if(_e(e,t),i.onSummary(t,n.relationships),r.fetcher.onEvent(t.id),t.delegation?.role===`worker`){let n=t.delegation.parentRunId;j(e,l.runs.detail(n)),r.refreshParent(n)}let a=l.runs.changes(t.id);e.getQueryData(a)!==void 0&&e.invalidateQueries({queryKey:a}),e.invalidateQueries({queryKey:l.worktrees}),K(e);return}case`run-deleted`:i.onDeleted(n.id),r.fetcher.forget(n.id),e.removeQueries({queryKey:l.runs.detail(n.id)}),e.removeQueries({queryKey:l.runs.diff(n.id)}),e.setQueriesData(X,e=>e&&e.pages.some(e=>e.runs.some(e=>e.id===n.id))?{...e,pages:e.pages.map(e=>({...e,runs:e.runs.filter(e=>e.id!==n.id)}))}:e),e.invalidateQueries(X),e.invalidateQueries({queryKey:l.worktrees}),K(e);return;case`usage`:t.set(n.usage);return;case`ping`:case`ready`:return}}function ye(e,t,n,r){if(n!==b()){if(r.type===`run-summary`){let i=r.summary;if(t.fetcher.onEvent(i.id,n),i.delegation?.role===`worker`){let r=i.delegation.parentRunId;j(e,[n,`runs`,`detail`,r]),t.refreshParent(r,n)}return}t.fetcher.forget(r.id,n),e.removeQueries({queryKey:[n,`runs`,`detail`,r.id]}),e.removeQueries({queryKey:[n,`runs`,`diff`,r.id]})}}function be(e,t=y(le)){let n=C();(0,P.useEffect)(()=>{let a=oe;if(typeof a!=`function`)return;let o=null,c=i(n),u=S()?null:h(n),f=()=>{let e=o?.requestReady;return typeof e==`function`&&e.call(o)};c.setUnknownGenerationHandler(f),u?.setUnknownGenerationHandler(f);let p=ae(n),m=M(n),g={fetcher:m,refreshParent:p.refresh},_=d(),v=me(n),y=ge(n),b=!1,x,C=!1,w=!1,T=!1,E=!1,k=()=>{T=!0,E=!1;let e=r.providerStatus;n.cancelQueries({queryKey:e,exact:!0}).then(()=>n.invalidateQueries({queryKey:e,exact:!0,refetchType:`active`})).finally(()=>{if(w||!E){T=!1;return}k()})},j=()=>{w||x!==void 0||(x=setTimeout(()=>{x=void 0,w||N()},ue))},N=()=>{o?.close(),o=new a(t,{withCredentials:!0}),o.addEventListener(`open`,()=>{b=!0,_.reset(),c.detach(),u?.detach(),O(!1),C&&(v.flush(),q(n)),C||(D(()=>W(n)),n.cancelQueries({queryKey:l.health}).then(()=>{w||n.invalidateQueries({queryKey:l.health})}),c.reconcile()),C=!0});for(let t of de)o.addEventListener(t,r=>{let i=s(t,r.data);if(!i)return;if(i.event.type===`ready`){let e=_.ready(i.event.seq);c.ready(i.event.generation,i.event.seq),u?.ready(i.event.generation),e&&(v.flush(),q(n));return}let a=(i.event.type===`run-summary`||i.event.type===`run-deleted`)&&_.frame(i.event.seq);i.event.type===`ping`&&b&&(b=!1,D(()=>W(n)),O(!0)),i.project!==null&&(i.event.type===`run-summary`||i.event.type===`run-deleted`?c.run(i.project,i.event,a):i.event.type===`usage`&&c.usage(i.project,i.event.usage)),i.project!==null&&(i.event.type===`run-summary`||i.event.type===`run-deleted`)&&(v.onEvent(i.project,i.event),ye(n,g,i.project,i.event)),(i.project===null||i.project===J(n))&&ve(n,e,i.event,g,y),a&&(v.flush(),q(n))});u&&ce(o,n,u);for(let e of z)o.addEventListener(e,t=>{let i;try{i=JSON.parse(t.data)}catch{return}if(e===`project-ready`)c.reconcile({hold:!0});else if(e!==`checkout-progress`&&e!==`automation-change`){n.invalidateQueries({queryKey:r.projects});let e=n.getQueryState(A.hostsProjects);e&&ie(e.data,e.status===`error`)&&n.invalidateQueries({queryKey:A.hostsProjects,exact:!0})}if(e===`project-added`){let e=i?.project?.id;typeof e==`string`&&e!==``&&c.restoreProject(e),c.reconcile({hold:!0})}if(e===`project-removed`){let e=i?.id;typeof e==`string`&&e!==``&&c.dropProject(e)}for(let t of[...B])t(e,i)});o.addEventListener(`health`,e=>{let t;try{t=JSON.parse(e.data)}catch{return}let r=ne.safeParse(t);r.success&&(n.cancelQueries({queryKey:l.health}),n.setQueryData(l.health,r.data))}),o.addEventListener(`provider-status`,e=>{let t;try{t=JSON.parse(e.data)}catch{return}let i=ee(t);if(!i)return;let a=r.providerStatus,o=te(n.getQueryData(a),i);if(o!==void 0){n.setQueryData(a,o);return}if(T){E=!0;return}k()}),o.addEventListener(`error`,()=>{O(!1),c.detach(),u?.detach(),o?.readyState===R&&j()})},P=()=>{document.visibilityState===`visible`&&(v.flush(),c.flush(),u?.flush(),(!o||o.readyState===R)&&(clearTimeout(x),x=void 0,N()))},F=()=>{clearTimeout(x),x=void 0,v.flush()};document.addEventListener(`visibilitychange`,P),window.addEventListener(`pagehide`,F);let I=re((e,t)=>(v.flush(),q(n,e,t)));return N(),()=>{I(),w=!0,O(!1),clearTimeout(x),v.flush(),v.cancel(),c.stop(),u?.stop(),p.cancel(),m.cancel(),c.setUnknownGenerationHandler(void 0),u?.setUnknownGenerationHandler(void 0),y.cancel(),document.removeEventListener(`visibilitychange`,P),window.removeEventListener(`pagehide`,F),o?.close(),o=null}},[n,e,t])}var Z=(0,P.createContext)(null);function xe({children:e}){let[t]=(0,P.useState)(p);return be(t),v(),(0,L.jsx)(Z.Provider,{value:t,children:e})}function Q(e){let t=(0,P.useContext)(Z),n=t?t.get:Ce;return(0,P.useSyncExternalStore)(t?t.subscribe:Se,()=>e?n()[e]:void 0,()=>void 0)}var Se=()=>()=>void 0,Ce=()=>u,we=`Label`,$=P.forwardRef((e,t)=>(0,L.jsx)(N.label,{...e,ref:t,onMouseDown:t=>{t.target.closest(`button, input, select, textarea`)||(e.onMouseDown?.(t),!t.defaultPrevented&&t.detail>1&&t.preventDefault())}}));$.displayName=we;var Te=$;function Ee({className:e,...t}){return(0,L.jsx)(Te,{"data-slot":`label`,className:k(`flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50`,e),...t})}export{Q as i,xe as n,V as r,Ee as t};
@@ -1 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{It as r,an as i}from"./queries-DHjNE2es.js";import{Ji as a,dn as o,n as s}from"./toaster-Dglox5F-.js";import{t as c}from"./switch-B9OfOEzC.js";import{gt as l,ht as u}from"./index-k2m-s5zD.js";import{n as d,t as f}from"./save-cue-CpHgT93o.js";import{n as p}from"./archive-on-merge-field-hDSXItUf.js";var m=e(t(),1),h=n();function g(){let e=a(),t=r(),[n,p]=m.useState(!1),[g,_]=m.useState(l),v=d(),y=t.data;m.useEffect(()=>{y!==void 0&&p(u(y.notifications).enabled)},[y]);let b=m.useCallback(t=>{p(t),o({notifications:{enabled:t}}).then(t=>{e.setQueryData(i.uiState,t),v.flash()}).catch(t=>{s(t instanceof Error?t.message:String(t),{tone:`danger`}),e.invalidateQueries({queryKey:i.uiState})})},[e,v.flash]),x=m.useCallback(e=>{if(!e){b(!1);return}if(l()!=="default"){b(!0);return}b(!0),Notification.requestPermission().then(e=>_(e)).catch(()=>_(l()))},[b]),S=g===`unsupported`;return(0,h.jsxs)(`section`,{"data-slot":`notifications-section`,className:`settings-field flex flex-col gap-2`,children:[(0,h.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,h.jsxs)(`div`,{children:[(0,h.jsx)(`h2`,{className:`text-sm font-semibold text-foreground`,children:(0,h.jsx)(`label`,{htmlFor:`notifications-enabled`,children:`Notify when an agent needs you`})}),(0,h.jsxs)(`p`,{className:`text-[13px] text-muted-foreground`,children:[`A browser notification when a task starts waiting, asks for review, or fails — only while this tab is in the background. Off by default. `,(0,h.jsx)(f,{saved:v.saved})]})]}),(0,h.jsx)(c,{id:`notifications-enabled`,"data-slot":`notifications-toggle`,checked:n,disabled:S,onCheckedChange:x})]}),S?null:(0,h.jsxs)(`p`,{"data-slot":`notifications-permission`,"data-permission":g,className:`mt-4 text-[13px] text-muted-foreground`,children:[`Browser permission · `,g===`granted`?`Allowed`:g===`denied`?`Blocked`:`Not requested`]}),(0,h.jsx)(`p`,{className:`text-[13px] text-muted-foreground`,children:`Permission is requested only when you enable notifications.`}),S?(0,h.jsx)(`p`,{"data-slot":`notifications-unsupported`,className:`text-[13px] text-muted-foreground`,children:`This browser does not support notifications, so the toggle is unavailable here.`}):null,!S&&n&&g===`denied`?(0,h.jsxs)(`div`,{"data-slot":`notifications-denied`,className:`mt-5 flex flex-col gap-2`,children:[(0,h.jsx)(`h3`,{className:`text-sm`,children:`Allow notifications in your browser`}),(0,h.jsx)(`p`,{className:`text-[13px] text-muted-foreground`,children:`This browser is blocking notifications. Your preference is saved. Allow notifications in the browser’s site settings to receive them.`}),(0,h.jsx)(`p`,{className:`settings-readout`,children:`Notifications are blocked for this site.`})]}):null]})}function _(){return(0,h.jsxs)(`div`,{"data-slot":`preferences-section`,className:`flex w-full flex-col gap-7`,children:[(0,h.jsx)(g,{}),(0,h.jsx)(p,{})]})}export{_ as PreferencesSection};
@@ -1 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{h as r}from"./host-context-iTMFRMT5.js";import{At as i,Ii as a,Ji as o,Li as s,ar as c,jt as l}from"./toaster-Dglox5F-.js";import{t as u}from"./createLucideIcon-BHp8sXmF.js";import{t as d}from"./button-BV_AiLj2.js";var f=u(`server`,[[`rect`,{width:`20`,height:`8`,x:`2`,y:`2`,rx:`2`,ry:`2`,key:`ngkwjq`}],[`rect`,{width:`20`,height:`8`,x:`2`,y:`14`,rx:`2`,ry:`2`,key:`iecqi9`}],[`line`,{x1:`6`,x2:`6.01`,y1:`6`,y2:`6`,key:`16zg32`}],[`line`,{x1:`6`,x2:`6.01`,y1:`18`,y2:`18`,key:`nzw8ys`}]]),p=e(t(),1),m=n(),h=class extends p.Component{state={failed:!1};static getDerivedStateFromError(){return{failed:!0}}componentDidCatch(e,t){console.error(`Squawk cockpit: the preview pane crashed`,e,t.componentStack)}render(){return this.state.failed?(0,m.jsxs)(`div`,{"data-slot":`preview-pane-error`,role:`alert`,className:`flex h-full flex-col items-center justify-center gap-3 p-6 text-center`,children:[(0,m.jsx)(`p`,{className:`text-sm font-semibold text-foreground`,children:`The preview hit an error`}),(0,m.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`The task is unaffected. Close the preview and open it again.`}),(0,m.jsx)(d,{variant:`outline`,onClick:this.props.onClose,children:`Close preview`})]}):this.props.children}};function g(...e){let t=[],n=-1/0,r=!0;for(let i of e){for(let e of i){if(e.seq<=n){r=!1;break}t.push(e),n=e.seq}if(!r)break}if(r)return t;let i=new Map;for(let t of e)for(let e of t)i.set(e.seq,e);return[...i.values()].sort((e,t)=>e.seq-t.seq)}var _=(e,t)=>JSON.stringify([e.stepId??null,t]);function v(e,t){if(typeof t.delta!=`string`)return;let n=e.item.kind===`tool`?t.field===`output`?`output`:void 0:t.field!==`output`&&(e.item.kind===`message`||e.item.kind===`reasoning`)?`text`:void 0;if(!n)return;let r=e.item[n];e.item={...e.item,[n]:(typeof r==`string`?r:``)+t.delta},e.event={...e.event,seq:t.seq,ts:t.ts}}function y(e,t){for(let[n,r]of e)r.event.stepId===t&&e.delete(n)}function b(e,t,n){let r=t.item;if(t.type===`item.delta`){let r=e.get(_(t,t.itemId));r&&(v(r,t),r.touched||=n)}else t.type===`item.completed`&&r&&typeof r==`object`?e.delete(_(t,r.id)):(t.type===`item.started`||t.type===`item.updated`)&&r&&typeof r==`object`&&`kind`in r?e.set(_(t,r.id),{event:t,item:r,touched:n&&t.type===`item.updated`}):(t.type===`turn.completed`||t.type===`session.started`||t.type===`session.ended`)&&y(e,t.stepId)}function x(e,t){let n=new Set(t.map(({seq:e})=>e)),r=new Map;for(let t of e)b(r,t,n.has(t.seq));return[...r.values()].filter(({touched:e})=>e).map(({event:e,item:t})=>({...e,type:`item.updated`,item:t})).sort((e,t)=>e.seq-t.seq)}function S(e,t={}){let[n,i]=(0,p.useState)([]),{cursor:a,afterSeq:o=0,maxEvents:s,compactAt:l,onCompact:u,onReset:d,carryOver:f}=t,m=(0,p.useRef)(void 0),h=(0,p.useRef)(f);return h.current=f,(0,p.useEffect)(()=>{let t=r(),n=e===void 0?void 0:`${t}/${e}`,f=n!==void 0&&m.current===n;if(m.current=n,i(e=>f&&h.current?h.current(e):[]),!e)return;let p=o,_=!1,v=!1,y=0,b=[],x,S,C=()=>{if(x!==void 0&&globalThis.cancelAnimationFrame?.(x),clearTimeout(S),x=void 0,S=void 0,_||b.length===0)return;let e=b;b=[],y+=e.length,i(t=>{let n=g(t,e);return!v&&l!==void 0&&y>=l&&(v=!0,queueMicrotask(()=>{_||u?.()})),s===void 0||n.length<=s?n:n.slice(-s)})},w=()=>{S===void 0&&(S=setTimeout(C,50),typeof globalThis.requestAnimationFrame==`function`&&(x=globalThis.requestAnimationFrame(C)))},T=c({kind:`run`,projectId:t,runId:e,afterSeq:o,...a?{cursor:a}:{}},{frame:e=>{if(`type`in e){if(e.type===`event`&&e.event.seq>p)p=e.event.seq;else if(e.type!==`snapshot`)return;b.push(e.event),w()}},reset:async(e,t)=>{C();let n=await d?.(e,t);return n&&(p=Math.max(p,n.afterSeq)),n}});return()=>{_=!0,x!==void 0&&globalThis.cancelAnimationFrame?.(x),clearTimeout(S),T()}},[e,a,o,s,l,u,d]),n}var C=5,w=200,T=5e3;function E(e,t,n){e.setQueryData(t,e=>{if(!e)return{pages:[n],pageParams:[void 0]};let t=[...e.pages],r=[...e.pageParams],i=-1;for(let e=0;e<t.length;e+=1)(i===-1||t[e].asOfSeq>t[i].asOfSeq)&&(i=e);if(i>=0&&t[i].asOfSeq>n.asOfSeq)return e;for(i>=0&&t[i].newerCursor===void 0?(t[i]=n,r[i]=void 0):(t.push(n),r.push(void 0));t.length>C;)t.shift(),r.shift();return{pages:t,pageParams:r}})}function D(e,t){return e!==void 0&&(t===void 0||e.asOfSeq>=t.asOfSeq)}function O(e,t,n,r){let i=(0,p.useRef)(void 0),a=r&&t.data!==void 0&&!t.isFetching&&!D(t.data,n),o=e===void 0||n===void 0?void 0:`${e}:${n.asOfSeq}`;(0,p.useEffect)(()=>{!a||o===void 0||i.current===o||(i.current=o,t.refetch())},[a,t,o])}function k(e,t){return e!==void 0&&e.asOfSeq>t.asOfSeq?e:t}function A(e){let t=r(),n=o(),c=[`run-history`,t,e],u=[`run-history-context`,t,e],d=a({queryKey:c,enabled:e!==void 0,initialPageParam:void 0,queryFn:({pageParam:t,signal:n})=>i(e,t,{signal:n}),getPreviousPageParam:e=>e.olderCursor,getNextPageParam:e=>e.newerCursor,maxPages:C,staleTime:1/0,retry:1}),f=s({queryKey:u,enabled:e!==void 0,queryFn:async({signal:t})=>{let r=await l(e,{signal:t});return k(n.getQueryData(u),r)},retry:1}),m=(0,p.useCallback)(async r=>{let a=r?{signal:r}:void 0,o=await i(e,void 0,a),s=await l(e,a);return r?.throwIfAborted(),E(n,[`run-history`,t,e],o),n.setQueryData([`run-history-context`,t,e],e=>k(e,s)),o},[n,e,t]),h=(0,p.useCallback)(async(t,n)=>{if(e===void 0)return;let r=await m(n);return{cursor:r.liveCursor,afterSeq:r.asOfSeq}},[m,e]),_=d.isError||f.isError,v=S(_?e:void 0,{onReset:h}),y=d.data?.pages??[],b=y.reduce((e,t)=>t.newerCursor===void 0?t:e??t,void 0),A=(0,p.useRef)(!1),j=(0,p.useCallback)(()=>{e===void 0||A.current||(A.current=!0,m().catch(()=>{}).finally(()=>{A.current=!1}))},[m,e]),M=e=>e!==void 0&&n.getQueryData([`run-history`,t,e])!==void 0,[N,P]=(0,p.useState)(()=>({runId:e,pending:M(e)})),F=N.pending;N.runId!==e&&(F=M(e),P({runId:e,pending:F})),(0,p.useEffect)(()=>{if(!F||e===void 0)return;let t=!1,n=new AbortController;return m(n.signal).catch(()=>{}).finally(()=>{t||P({runId:e,pending:!1})}),()=>{t=!0,n.abort()}},[m,F,e]);let I=(0,p.useMemo)(()=>g(...y.map(e=>e.events)),[y]),L=(0,p.useRef)({runId:e,current:I,previous:[]});(L.current.current!==I||L.current.runId!==e)&&(L.current={runId:e,current:I,previous:L.current.runId===e?L.current.current:[]});let R=(0,p.useCallback)(e=>{let{current:t,previous:n}=L.current;return x(g(n,t,e),e)},[]),z=S(!_&&b&&!F?e:void 0,{cursor:b?.liveCursor,afterSeq:b?.asOfSeq,maxEvents:T,compactAt:w,onCompact:j,onReset:h,carryOver:R}),B=(0,p.useRef)(0);B.current=z.length,(0,p.useEffect)(()=>()=>{B.current>0&&j()},[j]);let V=(0,p.useMemo)(()=>_?v:g(I,z),[_,v,I,z]);O(e,f,b,!_);let H=_||D(f.data,b),U=(0,p.useMemo)(()=>{if(_)return v;let e=f.data?.contextEvents??[],t=f.data?.asOfSeq??0;return g(e,V.filter(({seq:e})=>e>t))},[f.data,_,v,V]),W=(0,p.useCallback)(async()=>{await d.fetchPreviousPage()},[d.fetchPreviousPage]),G=(0,p.useCallback)(async()=>{_||(await n.resetQueries({queryKey:[`run-history`,t,e],exact:!0}),n.invalidateQueries({queryKey:[`run-history-context`,t,e],exact:!0}))},[_,n,e,t]);return{visibleEvents:V,currentEvents:U,currentComplete:H,isPending:!_&&d.isPending,contextPending:!_&&f.isPending,fallback:_,hasOlder:!_&&!!d.hasPreviousPage,isFetchingOlder:d.isFetchingPreviousPage,olderError:d.isFetchPreviousPageError?d.error instanceof Error?d.error.message:`Could not load earlier items`:void 0,loadOlder:W,jumpToLatest:G,retainedPages:y.length}}export{h as n,f as r,A as t};
@@ -1 +0,0 @@
1
- import{t as e}from"./react-runtime-CCIEwYL0.js";import{En as t,Ft as n,U as r,xt as i}from"./queries-DHjNE2es.js";import{Lt as a,n as o}from"./toaster-Dglox5F-.js";import{y as s}from"./design-icons-QbNMZniQ.js";import{n as c,t as l}from"./open-in-menu-CbPtuWnJ.js";import{s as u}from"./project-router-CPgPVoBJ.js";import{Rn as d}from"./index-k2m-s5zD.js";import{n as f}from"./settings-field-AyinSFR_.js";var p=e();function m(){let e=u(),t=i().data;return e===null?null:t?.projects.find(t=>t.id===e)?.root??null}function h(e){navigator.clipboard.writeText(e).then(()=>o(`Project folder copied`)).catch(()=>o(e))}function g(){let e=m(),t=n().data?.homeDir??null;return e===null?null:(0,p.jsx)(f,{wide:!0,title:`Project folder`,hint:`Where this project lives on disk. Every task worktree, git command and agent run resolves against it.`,children:(0,p.jsxs)(`div`,{"data-slot":`project-location`,"data-variant":`field`,className:`flex flex-col gap-3`,children:[(0,p.jsx)(d,{"data-slot":`project-location-path`,value:e,bases:{home:t,root:null},wrap:!0,className:`w-full min-w-0 rounded-md border border-border bg-background p-3 text-[13px] text-foreground`}),(0,p.jsxs)(`div`,{className:`flex w-full flex-wrap items-center gap-2 border-t border-border pt-4`,children:[(0,p.jsxs)(`button`,{type:`button`,"data-action":`project-location-copy`,title:`Copy the project folder path`,onClick:()=>h(e),className:`inline-flex min-h-11 items-center gap-2 rounded-md border border-border bg-card px-3 text-xs text-foreground transition-colors hover:bg-muted`,children:[(0,p.jsx)(s,{"aria-hidden":`true`,className:`size-4`}),`Copy path`]}),(0,p.jsx)(_,{root:e})]})]})})}function _({root:e}){let n=r(),i=t({mutationFn:e=>a(e),onError:e=>o(e.message,{tone:`danger`})}),s=(n.data?.targets??[]).filter(e=>c(e.id)===void 0).map(e=>({target:e}));return s.length===0?null:(0,p.jsx)(l,{slot:`project-location-open`,label:`Open with`,triggerVariant:`outline`,title:e,disabled:i.isPending,choices:s,onPick:e=>i.mutate(e,{onSuccess:()=>o(`Opening the project folder in ${s.find(t=>t.target.id===e)?.target.label??e}`)})})}export{m as n,g as t};
@@ -1 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{a as r}from"./toaster-Dglox5F-.js";import{i,l as a,m as o,n as s,p as c,r as l}from"./chunk-KS7C4IRE-BdLLx37K.js";var u=e(t(),1),d=n(),f=/^\/p\/([^/]+)(?=\/|$)/;function p(e){let t=f.exec(e)?.[1];return t===void 0?null:decodeURIComponent(t)}function m(e){let t=f.exec(e);if(!t)return e;let n=e.slice(t[0].length);return n===``?`/`:n}function h(e,t){return!t.startsWith(`/`)||t===`/p`||t.startsWith(`/p/`)?t:`/p/${encodeURIComponent(e)}${t}`}function g(e,t){return e===null?t:typeof t==`string`?h(e,t):t.pathname===void 0?t:{...t,pathname:h(e,t.pathname)}}function _(){let{projectId:e}=r(),{pathname:t}=c();return e??p(t)}function v(){let e=_();return(0,u.useCallback)(t=>g(e,t),[e])}function y(e){let{pathname:t}=c();return(0,u.useMemo)(()=>a(e,m(t)),[e,t])}function b({to:e,...t}){let n=v();return(0,d.jsx)(s,{...t,to:n(e)})}function x({to:e,...t}){let n=v();return(0,d.jsx)(l,{...t,to:n(e)})}function S({to:e,...t}){let n=v();return(0,d.jsx)(i,{...t,to:n(e)})}function C(){let e=o(),t=v();return(0,u.useMemo)(()=>((n,r)=>typeof n==`number`?e(n):e(t(n),r)),[e,t])}export{g as a,C as c,p as i,y as l,x as n,m as o,S as r,_ as s,b as t};
@@ -1 +0,0 @@
1
- import{n as e,r as t}from"./rolldown-runtime-QTnfLwEv.js";import{i as n,t as r}from"./react-runtime-CCIEwYL0.js";import{Dt as i,En as a,Ft as o,Nt as s,Rt as c,an as l,xt as u,zt as d}from"./queries-DHjNE2es.js";import{Ji as f,n as p,un as m}from"./toaster-Dglox5F-.js";import{n as h}from"./chunk-KS7C4IRE-BdLLx37K.js";import{o as g}from"./dist-CCX8mhHc.js";import{k as _,mt as v}from"./design-icons-QbNMZniQ.js";import{t as y}from"./button-BV_AiLj2.js";import{n as b,r as x,t as S}from"./popover-BQolmvDR.js";import{t as C}from"./centered-state-N8vWM_Hw.js";import{$t as w,Rn as T,an as ee,en as te,in as E,nn as D,on as O,rn as k,tn as A,ur as j}from"./index-k2m-s5zD.js";import{t as M}from"./option-select-C6d3jHce.js";import{n as N,t as P}from"./save-cue-CpHgT93o.js";import{n as F,t as I}from"./settings-field-AyinSFR_.js";import{t as L}from"./use-path-bases-C7DRxlRi.js";import{r as R}from"./settings-save-bar-BkU1JDt3.js";import{n as z}from"./saved-draft-BwzBc-_Y.js";import{t as B}from"./settings-list-detail-BlEEuyae.js";var V=t(n(),1),H=r();function U(){let e=i();return{isPending:e.isPending,confirm:(t,n)=>e.mutate(t.id,{onSuccess:()=>{p(`${t.name} removed from the workspace — its files are untouched`),n?.()},onError:e=>p(e.message,{tone:`danger`})})}}function W({project:e,onOpenChange:t,onConfirm:n}){let r={home:o().data?.homeDir??null,root:null};return(0,H.jsx)(w,{open:e!==null,onOpenChange:t,children:(0,H.jsxs)(D,{children:[(0,H.jsxs)(ee,{children:[(0,H.jsxs)(O,{children:[`Remove `,e?.name,` from the workspace?`]}),(0,H.jsxs)(k,{children:[`This only unregisters the project — `,(0,H.jsx)(`strong`,{children:`nothing on disk is deleted`}),`. The folder, its git history and its task history all stay exactly where they are, and opening it again re-registers it with everything intact.`,e?(0,H.jsx)(T,{value:e.root,bases:r,className:`mt-1 text-xs text-foreground`}):null]})]}),(0,H.jsxs)(E,{children:[(0,H.jsx)(A,{children:`Keep it`}),(0,H.jsx)(te,{"data-action":`projects-confirm-remove`,className:`bg-danger text-danger-foreground hover:brightness-[0.96]`,onClick:n,children:`Remove from list`})]})]})})}var G=e({MaxParallelSelect:()=>$,ProjectTagsEditor:()=>Q,ProjectsSection:()=>Y,STATUS_LABEL:()=>q}),K=1,q={ok:`ok`,"not-git":`no git repo`,missing:`folder not found`};function J(e){let t=new Date(e);return Number.isNaN(t.getTime())?`—`:t.toLocaleDateString(void 0,{month:`short`,day:`numeric`})}function Y(){let e=o(),t=u();return e.isPending||t.isPending?(0,H.jsx)(`p`,{"data-slot":`projects-loading`,className:`p-4 text-[13px] text-soft-foreground md:p-6`,children:`Loading projects…`}):e.isError||t.isError?(0,H.jsx)(C,{icon:(0,H.jsx)(_,{}),tone:`danger`,title:`Project settings did not load`,subtitle:(e.error??t.error)?.message,heading:`h2`}):(0,H.jsx)(X,{config:e.data,registry:t.data})}function X({config:e,registry:t}){let[n,r]=(0,V.useState)(!1);return(0,H.jsxs)(`div`,{"data-slot":`projects-section`,className:`flex w-full flex-col gap-7`,children:[(0,H.jsx)(Z,{configKey:`browseRoot`,value:e.browseRoot,title:`Default browse folder`,hint:`Where “Open local folder…” starts. The picker cannot navigate above this folder.`,placeholder:`~/`,slot:`browse`,footer:`Only affects folder browsing; GitHub checkouts use the separate checkout folder.`}),(0,H.jsx)(Z,{configKey:`projectsDir`,value:e.projectsDir,title:`Default checkout folder`,hint:`Where “Clone from GitHub” puts new projects: <folder>/<project name>.`,placeholder:`~/squawk/projects`,slot:`checkout`,footer:`Only affects new checkouts; projects already registered keep their location.`,refreshProjects:!0}),(0,H.jsx)(ne,{registry:t,workspaceMax:e.resources.maxParallel}),(0,H.jsx)(y,{className:`self-start`,onClick:()=>r(!0),children:`Add project`}),n?(0,H.jsx)(j,{open:!0,onOpenChange:r}):null]})}function Z({configKey:e,value:t,title:n,hint:r,placeholder:i,slot:o,footer:s,refreshProjects:c=!1}){let u=f(),d=a({mutationFn:t=>m(e===`browseRoot`?{browseRoot:t}:{projectsDir:t}),onSuccess:t=>{u.setQueryData(l.config,t),e===`browseRoot`?u.invalidateQueries({queryKey:l.fsBrowseRoot}):c&&u.invalidateQueries({queryKey:l.projects})}}),[p,h]=z(t),g=p.trim();R({dirty:g!==t,invalid:g===``,save:()=>d.mutateAsync(g),discard:()=>{h(t),d.reset()}});let _=d.isError?d.error.message:null;return(0,H.jsxs)(F,{title:n,hint:`${r} ${e===`browseRoot`?`Choose an existing folder; it is verified writable before saving.`:`The folder is created recursively if needed, then verified writable before saving.`}`,children:[(0,H.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,H.jsx)(`input`,{type:`text`,spellCheck:!1,"aria-label":n,"aria-invalid":_!==null,"data-slot":`projects-${o}-root`,value:p,disabled:d.isPending,placeholder:i,onChange:e=>{h(e.target.value),d.isError&&d.reset()},className:`block w-full max-w-sm rounded-md border border-input bg-card px-3 py-1.5 font-mono text-sm shadow-xs outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 aria-invalid:border-danger disabled:opacity-50`})}),_===null?(0,H.jsx)(`p`,{className:`text-xs text-soft-foreground`,children:s}):(0,H.jsxs)(`p`,{"data-slot":`projects-${o}-root-error`,role:`alert`,className:`text-xs text-danger`,children:[_,` — setting unchanged`]})]})}function ne({registry:e,workspaceMax:t}){let[n,r]=(0,V.useState)(null),[i,a]=(0,V.useState)(null),o=U(),s=(0,V.useMemo)(()=>c(e.projects),[e.projects]);return(0,H.jsxs)(F,{wide:!0,title:`Registered projects`,hint:`Connected repositories. Removing a project only unregisters it — no files on disk are deleted.`,children:[(0,H.jsx)(B,{slot:`project-list`,label:`Projects registered in this workspace`,items:e.projects,itemKey:e=>e.id,selectedKey:i,onSelect:a,empty:(0,H.jsx)(`p`,{"data-slot":`projects-empty`,className:`text-[13px] text-soft-foreground`,children:`No projects registered yet.`}),row:e=>(0,H.jsx)(ie,{project:e}),detail:n=>(0,H.jsx)(ae,{project:n,isBoot:n.id===e.bootProject,workspaceMax:t,vocabulary:s,disabled:o.isPending,onRemove:()=>r(n)})}),(0,H.jsx)(W,{project:n,onOpenChange:e=>!e&&r(null),onConfirm:()=>{if(!n)return;let e=n;r(null),o.confirm(e)}})]})}function re({project:e}){return(0,H.jsxs)(`span`,{"data-slot":`project-status-pill`,className:`inline-flex shrink-0 items-center gap-1.5 rounded-full border border-border bg-muted px-2.5 py-0.5 text-[12px] leading-5`,children:[(0,H.jsx)(`span`,{"data-slot":`project-status`,className:e.status===`missing`?`text-danger`:`text-foreground`,children:q[e.status]}),e.status===`missing`?null:(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`span`,{"aria-hidden":`true`,className:`text-soft-foreground`,children:`·`}),(0,H.jsx)(`span`,{className:`text-soft-foreground`,children:e.source})]})]})}function ie({project:e}){let t=L(),n=e.tags?.length??0;return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,H.jsx)(`span`,{className:`settings-list-row-title min-w-0 flex-1`,children:e.name}),(0,H.jsx)(`span`,{"data-slot":`project-row-status`,className:e.status===`missing`?`shrink-0 text-[12px] text-danger`:`shrink-0 text-[12px] text-soft-foreground`,children:q[e.status]})]}),(0,H.jsxs)(`span`,{className:`settings-list-row-meta`,children:[(0,H.jsx)(T,{value:e.root,bases:t,className:`text-[12px]`}),n>0?` · ${n} tag${n===1?``:`s`}`:``]})]})}function ae({project:e,isBoot:t,workspaceMax:n,vocabulary:r,disabled:i,onRemove:a}){let o=N(),s=N(),c=L();return(0,H.jsxs)(`div`,{"data-slot":`project-row`,"data-project":e.id,className:`flex min-w-0 flex-col gap-4`,children:[(0,H.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1.5`,children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,H.jsx)(`h3`,{className:`min-w-0 break-words text-sm font-medium text-foreground`,children:e.name}),(0,H.jsx)(re,{project:e})]}),(0,H.jsx)(T,{value:e.root,bases:c,wrap:!0,className:`text-xs text-soft-foreground`}),(0,H.jsxs)(`span`,{className:`text-[12px] text-soft-foreground`,children:[`Added `,J(e.addedAt)]})]}),(0,H.jsxs)(`div`,{"data-slot":`project-tags-field`,className:`flex flex-col gap-1.5`,children:[(0,H.jsxs)(`span`,{className:I,children:[`Tags `,(0,H.jsx)(P,{saved:o.saved})]}),(0,H.jsx)(Q,{project:e,vocabulary:r,onSaved:o.flash})]}),(0,H.jsxs)(`label`,{"data-slot":`project-max-parallel-field`,className:`flex flex-col gap-1.5`,children:[(0,H.jsxs)(`span`,{className:I,children:[`Max parallel tasks `,(0,H.jsx)(P,{saved:s.saved})]}),(0,H.jsx)($,{project:e,workspaceMax:n,onSaved:s.flash})]}),(0,H.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 border-t border-border pt-3`,children:[e.status===`missing`?null:(0,H.jsx)(y,{asChild:!0,variant:`outline`,children:(0,H.jsx)(h,{to:`/p/${encodeURIComponent(e.id)}`,children:`Open`})}),(0,H.jsx)(y,{type:`button`,variant:`ghost`,size:`sm`,"data-action":`project-remove`,"aria-label":`Remove ${e.name} from the workspace — unregisters it, no files are deleted`,title:t?`Squawk is serving this project — it re-registers itself at every start`:void 0,disabled:i||t,onClick:a,children:`Remove`})]})]})}function Q({project:e,vocabulary:t,onSaved:n}){let r=s(),[i,a]=(0,V.useState)(``),[o,c]=(0,V.useState)(!1),[l,u]=(0,V.useState)(-1),f=(0,V.useRef)(null),m=e.tags??[],h=d(t,m,i),_=o&&h.length>0,y=t=>{r.mutate({id:e.id,tags:t},{onSuccess:()=>n?.(),onError:e=>p(e.message,{tone:`danger`})})},C=t=>{let n=t.trim().slice(0,32);if(u(-1),n){if(m.some(e=>e.toLowerCase()===n.toLowerCase())){a(``);return}if(m.length>=20){p(`${e.name} already has the maximum of 20 tags`,{tone:`danger`});return}a(``),y([...m,n])}},w=e=>{y(m.filter(t=>t!==e))},T=`project-tag-suggestions-${e.id}`;return(0,H.jsxs)(`div`,{"data-slot":`project-tags`,className:`flex flex-wrap items-center gap-1`,children:[m.map(t=>(0,H.jsxs)(`span`,{"data-slot":`project-tag`,className:`inline-flex max-w-full items-center gap-1 rounded-full bg-accent-strong/15 py-px pr-1 pl-2 text-xs font-medium whitespace-nowrap text-accent-text`,children:[t,(0,H.jsx)(`button`,{type:`button`,"data-action":`project-tag-remove`,"aria-label":`Remove tag ${t} from ${e.name}`,disabled:r.isPending,onClick:()=>w(t),className:`rounded-full p-0.5 hover:bg-accent-strong/25 disabled:opacity-50`,children:(0,H.jsx)(v,{className:`size-3`,"aria-hidden":`true`})})]},t)),(0,H.jsxs)(S,{open:_,onOpenChange:c,children:[(0,H.jsx)(b,{asChild:!0,children:(0,H.jsx)(`input`,{ref:f,type:`text`,"data-slot":`project-tag-input`,"aria-label":`Add a tag to ${e.name}`,role:`combobox`,"aria-expanded":_,"aria-controls":_?T:void 0,"aria-autocomplete":`list`,"aria-activedescendant":_&&l>=0?`${T}-${l}`:void 0,placeholder:m.length===0?`Add tag…`:`+`,value:i,maxLength:32,disabled:r.isPending,onFocus:()=>c(!0),onBlur:()=>c(!1),onChange:e=>{if(c(!0),u(-1),e.target.value.includes(`,`)){a(e.target.value.replace(/,/g,``));return}a(e.target.value)},onKeyDown:e=>{if(e.key===`ArrowDown`||e.key===`ArrowUp`){if(h.length===0)return;e.preventDefault(),c(!0);let t=e.key===`ArrowDown`?1:-1,n=l+t;u(n>=h.length?-1:n<-1?h.length-1:n);return}if(e.key===`Escape`&&_){e.preventDefault(),c(!1),u(-1);return}if(e.key===`Enter`||e.key===`,`){e.preventDefault(),C(l>=0?h[l]??i:i);return}if(e.key===`Tab`){c(!1);return}if(e.key===`Backspace`&&i===``&&m.length>0){e.preventDefault();let t=m[m.length-1];t!==void 0&&w(t)}},className:`h-6 w-16 min-w-0 flex-1 rounded-md border border-input bg-card px-1.5 text-[12px] outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:opacity-50`})}),(0,H.jsxs)(x,{align:`start`,sideOffset:4,id:T,role:`listbox`,"data-slot":`project-tag-suggestions`,className:`w-56 p-1`,onOpenAutoFocus:e=>e.preventDefault(),onCloseAutoFocus:e=>e.preventDefault(),onInteractOutside:e=>e.preventDefault(),children:[(0,H.jsx)(`p`,{className:`px-2 pt-1 pb-1.5 text-xs text-soft-foreground`,children:`Tags used in this workspace`}),h.map((e,t)=>(0,H.jsx)(`button`,{type:`button`,id:`${T}-${t}`,role:`option`,"aria-selected":t===l,"data-slot":`project-tag-suggestion`,onMouseDown:e=>e.preventDefault(),onClick:()=>{C(e),f.current?.focus()},onMouseEnter:()=>u(t),className:g(`flex w-full items-center rounded-sm px-2 py-1 text-left text-[12px] font-medium text-accent-text`,t===l&&`bg-muted`),children:e},e))]})]})]})}function $({project:e,workspaceMax:t,onSaved:n}){let r=s(),i=e.maxParallel===void 0?``:String(e.maxParallel);return(0,H.jsx)(M,{"aria-label":`Max parallel tasks for ${e.name}`,"data-slot":`project-max-parallel`,value:i,disabled:r.isPending,onValueChange:t=>{let i=t===``?null:Number(t);r.mutate({id:e.id,maxParallel:i},{onSuccess:()=>n?.(),onError:e=>p(e.message,{tone:`danger`})})},className:`settings-select w-full max-w-full bg-card`,options:[{value:``,label:`Inherit workspace (${t})`},...Array.from({length:16},(e,t)=>t+K).map(e=>({value:String(e),label:String(e)}))]})}export{U as a,W as i,q as n,G as r,$ as t};
@@ -1 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t}from"./react-runtime-CCIEwYL0.js";import{h as n,n as r,p as i}from"./host-context-iTMFRMT5.js";import{$ as a,$n as o,$t as s,A as c,An as l,Ar as u,Bi as d,Br as f,C as p,Cn as m,Cr as ee,Ct as te,D as ne,Dn as h,Dr as g,Dt as _,E as v,En as y,Er as re,Et as b,F as x,Fr as S,G as C,Gi as ie,Hi as ae,Ht as oe,Ii as se,Ir as w,It as ce,J as le,Ji as T,Jt as ue,K as de,Kt as fe,L as pe,Li as E,Mn as D,Mr as me,Mt as O,N as he,Nr as ge,Nt as _e,O as ve,Ot as ye,Pi as be,Pn as xe,Pr as Se,Pt as Ce,Q as we,Qi as Te,Qn as Ee,Qt as De,Ri as Oe,Rr as ke,S as Ae,Sn as je,St as Me,Tn as Ne,Tr as Pe,Ui as Fe,Vi as Ie,Vr as Le,Vt as Re,Wi as ze,Wt as Be,X as Ve,Xn as He,Xt as Ue,Y as We,Yi as Ge,Yt as Ke,Zi as qe,Zt as Je,_n as Ye,_t as Xe,a as Ze,an as Qe,ar as $e,b as et,bn as tt,bt as nt,ca as k,ci as rt,cn as it,ct as at,da as ot,en as st,et as ct,fn as lt,gn as ut,gt as dt,h as ft,hn as pt,in as mt,ir as ht,jn as gt,jr as _t,k as vt,kn as yt,kt as bt,ln as xt,m as St,ma as Ct,mn as wt,n as Tt,nn as Et,oa as Dt,on as Ot,pn as kt,pt as At,q as jt,qt as Mt,ra as Nt,sn as Pt,ta as Ft,tn as It,ua as Lt,v as Rt,vt as zt,wn as Bt,wt as Vt,x as Ht,xn as Ut,xt as Wt,y as Gt,yn as Kt,yt as qt,zi as Jt,zr as Yt}from"./toaster-Dglox5F-.js";import{A as Xt,B as A,F as j,H as M,I as N,N as P,P as F,W as I,Z as Zt,a as Qt,j as L,z as R}from"./live-protocol-CNUmr-VT.js";import{c as $t}from"./dist-CCX8mhHc.js";import{t as en}from"./host-storage-Cr_NKfWy.js";function tn(e,t){return e??t}function nn(e,t){let n=tn(e,t);return n===`1`||n===`true`}function rn(e,t,n){return e?.trim()||tn(t,n)||``}var an=class extends qe{#e;#t;#n;#r;constructor(e){super(),this.#e=e.client,this.mutationId=e.mutationId,this.#n=e.mutationCache,this.#t=[],this.state=e.state||on(),this.setOptions(e.options),this.scheduleGc()}setOptions(e){this.options=e,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(e){this.#t.includes(e)||(this.#t.push(e),this.clearGcTimeout(),this.#n.notify({type:`observerAdded`,mutation:this,observer:e}))}removeObserver(e){this.#t=this.#t.filter(t=>t!==e),this.scheduleGc(),this.#n.notify({type:`observerRemoved`,mutation:this,observer:e})}optionalRemove(){this.#t.length||(this.state.status===`pending`?this.scheduleGc():this.#n.remove(this))}continue(){return this.#r?.continue()??this.execute(this.state.variables)}async execute(e){let t=()=>{this.#i({type:`continue`})},n={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey};this.#r=Te({fn:()=>this.options.mutationFn?this.options.mutationFn(e,n):Promise.reject(Error(`No mutationFn found`)),onFail:(e,t)=>{this.#i({type:`failed`,failureCount:e,error:t})},onPause:()=>{this.#i({type:`pause`})},onContinue:t,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>this.#n.canRun(this)});let r=this.state.status===`pending`,i=!this.#r.canStart();try{if(r)t();else{this.#i({type:`pending`,variables:e,isPaused:i}),this.#n.config.onMutate&&await this.#n.config.onMutate(e,this,n);let t=await this.options.onMutate?.(e,n);t!==this.state.context&&this.#i({type:`pending`,context:t,variables:e,isPaused:i})}let a=await this.#r.start();return await this.#n.config.onSuccess?.(a,e,this.state.context,this,n),await this.options.onSuccess?.(a,e,this.state.context,n),await this.#n.config.onSettled?.(a,null,this.state.variables,this.state.context,this,n),await this.options.onSettled?.(a,null,e,this.state.context,n),this.#i({type:`success`,data:a}),a}catch(t){try{await this.#n.config.onError?.(t,e,this.state.context,this,n)}catch(e){Promise.reject(e)}try{await this.options.onError?.(t,e,this.state.context,n)}catch(e){Promise.reject(e)}try{await this.#n.config.onSettled?.(void 0,t,this.state.variables,this.state.context,this,n)}catch(e){Promise.reject(e)}try{await this.options.onSettled?.(void 0,t,e,this.state.context,n)}catch(e){Promise.reject(e)}throw this.#i({type:`error`,error:t}),t}finally{this.#n.runNext(this)}}#i(e){let t=t=>{switch(e.type){case`failed`:return{...t,failureCount:e.failureCount,failureReason:e.error};case`pause`:return{...t,isPaused:!0};case`continue`:return{...t,isPaused:!1};case`pending`:return{...t,context:e.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:e.isPaused,status:`pending`,variables:e.variables,submittedAt:Date.now()};case`success`:return{...t,data:e.data,failureCount:0,failureReason:null,error:null,status:`success`,isPaused:!1};case`error`:return{...t,data:void 0,error:e.error,failureCount:t.failureCount+1,failureReason:e.error,isPaused:!1,status:`error`}}};this.state=t(this.state),Zt.batch(()=>{this.#t.forEach(t=>{t.onMutationUpdate(e)}),this.#n.notify({mutation:this,type:`updated`,action:e})})}};function on(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:`idle`,variables:void 0,submittedAt:0}}var sn=class extends Ct{#e;#t=void 0;#n;#r;constructor(e,t){super(),this.#e=e,this.setOptions(t),this.bindMethods(),this.#i()}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(e){let t=this.options;this.options=this.#e.defaultMutationOptions(e),Lt(this.options,t)||this.#e.getMutationCache().notify({type:`observerOptionsUpdated`,mutation:this.#n,observer:this}),t?.mutationKey&&this.options.mutationKey&&Ft(t.mutationKey)!==Ft(this.options.mutationKey)?this.reset():this.#n?.state.status===`pending`&&this.#n.setOptions(this.options)}onUnsubscribe(){this.hasListeners()||this.#n?.removeObserver(this)}onMutationUpdate(e){this.#i(),this.#a(e)}getCurrentResult(){return this.#t}reset(){this.#n?.removeObserver(this),this.#n=void 0,this.#i(),this.#a()}mutate(e,t){return this.#r=t,this.#n?.removeObserver(this),this.#n=this.#e.getMutationCache().build(this.#e,this.options),this.#n.addObserver(this),this.#n.execute(e)}#i(){let e=this.#n?.state??on();this.#t={...e,isPending:e.status===`pending`,isSuccess:e.status===`success`,isError:e.status===`error`,isIdle:e.status===`idle`,mutate:this.mutate,reset:this.reset}}#a(e){Zt.batch(()=>{if(this.#r&&this.hasListeners()){let t=this.#t.variables,n=this.#t.context,r={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey};if(e?.type===`success`){try{this.#r.onSuccess?.(e.data,t,n,r)}catch(e){Promise.reject(e)}try{this.#r.onSettled?.(e.data,null,t,n,r)}catch(e){Promise.reject(e)}}else if(e?.type===`error`){try{this.#r.onError?.(e.error,t,n,r)}catch(e){Promise.reject(e)}try{this.#r.onSettled?.(void 0,e.error,t,n,r)}catch(e){Promise.reject(e)}}}this.listeners.forEach(e=>{e(this.#t)})})}};function cn(e,t){let n=new Set(t);return e.filter(e=>!n.has(e))}function ln(e,t,n){let r=e.slice(0);return r[t]=n,r}var un=class extends Ct{#e;#t;#n;#r;#i;#a;#o;#s;#c;#l=[];constructor(e,t,n){super(),this.#e=e,this.#r=n,this.#n=[],this.#i=[],this.#t=[],this.setQueries(t)}onSubscribe(){this.listeners.size===1&&this.#i.forEach(e=>{e.subscribe(t=>{this.#m(e,t)})})}onUnsubscribe(){this.listeners.size||this.destroy()}destroy(){this.listeners=new Set,this.#i.forEach(e=>{e.destroy()})}setQueries(e,t){this.#n=e,this.#r=t,Zt.batch(()=>{let e=this.#i,t=this.#p(this.#n);t.forEach(e=>e.observer.setOptions(e.defaultedQueryOptions));let n=t.map(e=>e.observer),r=n.map(e=>e.getCurrentResult()),i=e.length!==n.length,a=n.some((t,n)=>t!==e[n]),o=i||a,s=o?!0:r.some((e,t)=>{let n=this.#t[t];return!n||!Lt(e,n)});!o&&!s||(o&&(this.#l=t,this.#i=n),this.#t=r,this.hasListeners()&&(o&&(cn(e,n).forEach(e=>{e.destroy()}),cn(n,e).forEach(e=>{e.subscribe(t=>{this.#m(e,t)})})),this.#h()))})}getCurrentResult(){return this.#t}getQueries(){return this.#i.map(e=>e.getCurrentQuery())}getObservers(){return this.#i}getOptimisticResult(e,t){let n=this.#p(e),r=n.map(e=>e.observer.getOptimisticResult(e.defaultedQueryOptions)),i=n.map(e=>e.defaultedQueryOptions.queryHash);return[r,e=>this.#d(e??r,t,i),()=>this.#u(r,n)]}#u(e,t){return t.map((n,r)=>{let i=e[r];return n.defaultedQueryOptions.notifyOnChangeProps?i:n.observer.trackResult(i,e=>{t.forEach(t=>{t.observer.trackProp(e)})})})}#d(e,t,n){if(t){let r=this.#c,i=n!==void 0&&r!==void 0&&(r.length!==n.length||n.some((e,t)=>e!==r[t]));return(!this.#a||this.#t!==this.#s||i||t!==this.#o)&&(this.#o=t,this.#s=this.#t,n!==void 0&&(this.#c=n),this.#a=k(this.#a,t(e))),this.#a}return e}#f(){return this.#r?.combine!==void 0&&this.#i.some((e,t)=>e.options.suspense&&this.#t[t]?.data===void 0)}#p(e){let t=new Map;this.#i.forEach(e=>{let n=e.options.queryHash;if(!n)return;let r=t.get(n);r?r.push(e):t.set(n,[e])});let n=[];return e.forEach(e=>{let r=this.#e.defaultQueryOptions(e),i=t.get(r.queryHash)?.shift()??new Ge(this.#e,r);n.push({defaultedQueryOptions:r,observer:i})}),n}#m(e,t){let n=this.#i.indexOf(e);n!==-1&&(this.#t=ln(this.#t,n,t),this.#h())}#h(){if(this.hasListeners()){let e=this.#u(this.#t,this.#l),t=this.#f(),n=this.#a,r=t?n:this.#d(e,this.#r?.combine);(t||n!==r)&&Zt.batch(()=>{this.listeners.forEach(e=>{e(this.#t)})})}}},z=e(t(),1);function dn({queries:e,...t},n){let r=T(n),i=ie(),a=ze(),o=z.useMemo(()=>e.map(e=>{let t=r.defaultQueryOptions(e);return t._optimisticResults=i?`isRestoring`:`optimistic`,t}),[e,r,i]);o.forEach(e=>{Oe(e);let t=r.getQueryCache().get(e.queryHash);Ie(e,a,t)}),Fe(a);let[s]=z.useState(()=>new un(r,o,t)),[c,l,u]=s.getOptimisticResult(o,t.combine),f=!i&&t.subscribed!==!1;z.useSyncExternalStore(z.useCallback(e=>f?s.subscribe(Zt.batchCalls(e)):Dt,[s,f]),()=>s.getCurrentResult(),()=>s.getCurrentResult()),z.useEffect(()=>{s.setQueries(o,t)},[o,t,s]);let p=c.some((e,t)=>d(o[t],e))?c.flatMap((e,t)=>{let n=o[t];return n&&d(n,e)?Jt(n,new Ge(r,n),a):[]}):[];if(p.length>0)throw Promise.all(p);let m=c.find((e,t)=>{let n=o[t];return n&&ae({result:e,errorResetBoundary:a,throwOnError:n.throwOnError,query:r.getQueryCache().get(n.queryHash),suspense:n.suspense})});if(m?.error)throw m.error;return l(u())}function B(e,t){let n=T(t),[r]=z.useState(()=>new sn(n,e));z.useEffect(()=>{r.setOptions(e)},[r,e]);let i=z.useSyncExternalStore(z.useCallback(e=>r.subscribe(Zt.batchCalls(e)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),a=z.useCallback((e,t)=>{r.mutate(e,t).catch(Dt)},[r]);if(i.error&&ot(r.options.throwOnError,[i.error]))throw i.error;return{...i,mutate:a,mutateAsync:i.mutate}}function V(e={}){let t=e.projectId??n(),r=e.cacheScope??(e.boot?`default`:t);return e.hostId===void 0?{projectId:t,cacheScope:r}:{projectId:t,cacheScope:r,hostId:e.hostId}}function H(e,t={}){return{...V(t),runId:e}}function fn(){return nn(void 0,void 0)}function U(e){return!fn()&&e}async function pn(e){return l(await h.api.v1.health.$get({},y(e)),`/health`)}async function mn(e){return gt(await h.api.v1.hosts.$get({},y(e)),`/hosts`,Se)}async function hn(e){return gt(await h.api.v1.hosts.projects.$get({},y(e)),`/hosts/projects`,S)}async function gn(e){return gt(await h.api.v1.hosts[`runs-index`].$get({query:e?.hostId?{hostId:e.hostId}:{}},y(e)),`/hosts/runs-index`,w)}async function _n(e){return l(await h.api.v1.workspace[`ui-state`].$get({},y(e)),`/workspace/ui-state`)}async function vn(e,t={}){return l(await h.api.v1.workspace[`ui-state`].$put({json:e},{init:{...$t({keepalive:t.keepalive})}}),`/workspace/ui-state`)}A({runs:N(`summary`).optional()});var yn=I().min(1),bn=R().int().positive(),xn=A({project:yn,seq:bn,run:Le,relationships:I().min(1)}),Sn=A({project:yn,seq:bn,id:I().min(1)}),Cn=A({generation:I().min(1),seq:R().int().nonnegative()}),wn=A({project:yn,usage:M(I(),ke)});A({runs:P(f),referenceStatuses:Yt,perProjectLimit:R(),truncated:P(I()),generation:I().min(1),eventSeq:R().int().nonnegative()});function Tn(e,t){if(e===`ping`)return{project:null,event:{type:`ping`}};let n;try{n=JSON.parse(t)}catch{return null}switch(e){case`run-summary`:{let e=xn.safeParse(n);return e.success?{project:e.data.project,event:{type:`run-summary`,summary:e.data.run,seq:e.data.seq,relationships:e.data.relationships}}:null}case`run-deleted`:{let e=Sn.safeParse(n);return e.success?{project:e.data.project,event:{type:`run-deleted`,id:e.data.id,seq:e.data.seq}}:null}case`usage`:{let e=wn.safeParse(n);return e.success?{project:e.data.project,event:{type:`usage`,usage:e.data.usage}}:null}case`ready`:{let e=Cn.safeParse(n);return e.success?{project:null,event:{type:`ready`,generation:e.data.generation,seq:e.data.seq}}:null}default:return null}}var En=[re,Pe,g,ee];function Dn(e,t){let n;try{n=JSON.parse(t)}catch{return null}switch(e){case re:{let e=_t.safeParse(n);return e.success?{type:`host-run-summary`,hostId:e.data.hostId,project:e.data.project,seq:e.data.seq,summary:e.data.run}:null}case Pe:{let e=u.safeParse(n);return e.success?{type:`host-run-deleted`,hostId:e.data.hostId,project:e.data.project,seq:e.data.seq,id:e.data.id}:null}case g:{let e=me.safeParse(n);return e.success?{type:`host-usage`,hostId:e.data.hostId,project:e.data.project,usage:e.data.usage}:null}case ee:{let e=ge.safeParse(n);return e.success?{type:`hosts-changed`,...e.data}:null}default:return null}}function On(){let e,t;return{ready(n){t=void 0;let r=e!==void 0&&n>e;return e=n,r},frame(n){if(t!==void 0&&n<=t)return!1;let r=e!==void 0&&n!==e+1;return e=n,r},seed(n){t=t===void 0?n:Math.max(t,n),e=e===void 0?n:Math.max(e,n)},reset(){e=void 0,t=void 0}}}function kn(e,t){if(!e)return;let n=e.findIndex(e=>e.id===t.id);if(n>=0){let r=[...e];return r[n]=t,r}let r=e.findIndex(e=>(e.createdAt??``).localeCompare(t.createdAt)<0),i=[...e];return i.splice(r<0?e.length:r,0,t),i}function An(e,t){if(!e)return;let n=e.filter(e=>e.id!==t);return n.length===e.length?e:n}var jn=Object.freeze({});function Mn(){let e=jn,t=new Set;return{subscribe(e){return t.add(e),()=>t.delete(e)},get:()=>e,set(n){e=n;for(let e of t)e()}}}function Nn(e){return e.type===`run`?e.run.id:e.id}function Pn(e,t){return{...e,runs:t}}function Fn(e,t){let n=0;for(let r of e)t(r)&&r.archived&&(n+=1);return n}var In=new WeakMap,Ln=new WeakMap;function Rn(e,t){let n=new Map,r=new Map;for(let i=0;i<e.length;i+=1){let a=e[i],o=t(a),s=n.get(o);if(s||(s=new Map,n.set(o,s)),s.set(a.id,i),a.usage!==void 0){let e=r.get(o);e||(e=new Set,r.set(o,e)),e.add(a.id)}}return In.set(e,n),Ln.set(e,r),{positions:n,liveUsage:r}}var zn=class{runs;copied=!1;positions;liveUsage;liveUsageCopied=!1;scopeOf;constructor(e,t){this.runs=e,this.scopeOf=t;let n=In.get(e),r=Ln.get(e);if(n&&r)this.positions=n,this.liveUsage=r;else{let n=Rn(e,t);this.positions=n.positions,this.liveUsage=n.liveUsage}}reindex(){let e=Rn(this.runs,this.scopeOf);this.positions=e.positions,this.liveUsage=e.liveUsage,this.liveUsageCopied=!0}mutableLiveUsage(){if(!this.liveUsageCopied){let e=new Map;for(let[t,n]of this.liveUsage)e.set(t,new Set(n));this.liveUsage=e,this.liveUsageCopied=!0,this.copied&&Ln.set(this.runs,this.liveUsage)}return this.liveUsage}at(e,t){return this.positions.get(e)?.get(t)??-1}liveUsageIds(e){return this.liveUsage.get(e)}setLiveUsage(e,t,n){let r=this.mutableLiveUsage();if(n){let n=r.get(e);n||(n=new Set,r.set(e,n)),n.add(t)}else{let n=r.get(e);if(!n)return;n.delete(t),n.size===0&&r.delete(e)}}mutable(){return this.copied||(this.runs=[...this.runs],this.copied=!0,In.set(this.runs,this.positions),Ln.set(this.runs,this.liveUsage)),this.runs}replace(e,t){let n=this.runs[e];return this.mutable()[e]=t,n?.usage!==void 0!=(t.usage!==void 0)&&this.setLiveUsage(this.scopeOf(t),t.id,t.usage!==void 0),this.runs}remove(e){return this.mutable().splice(e,1),this.reindex(),this.runs}insert(e){let t=this.runs.findIndex(t=>(t.createdAt??``).localeCompare(e.createdAt)<0);return this.mutable().splice(t<0?this.runs.length:t,0,e),this.reindex(),this.runs}},Bn=e=>e.projectId,Vn=(e,t)=>`${e}\u0000${t}`,Hn=e=>Vn(e.hostId,e.projectId);function Un(e,t,n){let r=new zn(e.runs,Bn),i=e,a=!1;for(let e of t)if(e.type===`usage`)i=Zn(i,e.project,e.usage,r);else{let t=qn(i,e.change,n,r);i=t.index,a||=t.reconcile}return{index:i,reconcile:a}}function Wn(e,t,n){let r=new zn(e.runs,Hn),i=e.runs,a=new Set,o=!1;for(let s of t){if(s.type===`usage`){i=Xn(i,Vn(s.hostId,s.project),s.usage,r);continue}let{hostId:t,project:c}=s.change,l=e.hosts.find(e=>e.id===t);if(!l||!l.loaded){a.add(t);continue}let u=n?.(t,c);s.change.type===`run`&&u===!1&&(o=!0);let d=Kn(i,s.change,{scope:Vn(t,c),id:Nn(s.change),inScope:e=>e.hostId===t&&e.projectId===c,truncated:l.truncated.includes(c),perProjectLimit:l.perProjectLimit,isKnownScope:()=>!0,buildRow:e=>({hostId:t,projectId:c,...e})},r);i=d.runs,d.reconcile&&a.add(t)}return{index:i===e.runs?e:{...e,runs:i},reconcile:!1,reconcileHosts:[...a],refreshProjects:o}}function Gn(e,t,n){return n?n.has(t):e.runs.some(e=>e.projectId===t)}function Kn(e,t,n,r){let i=r.at(n.scope,n.id),a=i>=0?e[i]:void 0;if(t.type===`deleted`)return a?{runs:r.remove(i),reconcile:n.truncated&&a.archived}:{runs:e,reconcile:!1};let{run:o}=t;if(o.delegation?.role===`worker`)return a?{runs:r.remove(i),reconcile:!1}:{runs:e,reconcile:!1};if(!a&&!n.isKnownScope())return{runs:e,reconcile:!0};let s=k(a,n.buildRow(o));if(a){if(s===a)return{runs:e,reconcile:!1};let t=r.replace(i,s);return{runs:t,reconcile:a.archived!==s.archived&&(n.truncated||n.perProjectLimit!==void 0&&Fn(t,n.inScope)>n.perProjectLimit)}}if(n.truncated)return Yn(e,s,n.inScope,r);let c=r.insert(s);return{runs:c,reconcile:s.archived&&n.perProjectLimit!==void 0&&Fn(c,n.inScope)>n.perProjectLimit}}function qn(e,t,n,r){let{project:i}=t,a=Kn(e.runs,t,{scope:i,id:Nn(t),inScope:e=>e.projectId===i,truncated:e.truncated.includes(i),perProjectLimit:e.perProjectLimit,isKnownScope:()=>Gn(e,i,n),buildRow:e=>({projectId:i,...e})},r);return{index:a.runs===e.runs?e:Pn(e,a.runs),reconcile:a.reconcile}}function Jn(e,t){let n;for(let r of e)t(r)&&r.archived&&(n===void 0||r.createdAt<n)&&(n=r.createdAt);return n}function Yn(e,t,n,r){let i=Jn(e,n),a=i!==void 0&&t.createdAt>i;return t.archived&&!a?{runs:e,reconcile:!1}:{runs:r.insert(t),reconcile:t.archived||i===void 0||t.createdAt<i}}function Xn(e,t,n,r){let i=!1;for(let[e,a]of Object.entries(n)){let n=r.at(t,e);if(n<0)continue;let o=r.runs[n],s=k(o.usage,a);s!==o.usage&&(r.replace(n,{...o,usage:s}),i=!0)}let a=r.liveUsageIds(t);if(a)for(let e of[...a]){if(Object.prototype.hasOwnProperty.call(n,e))continue;let a=r.at(t,e);if(a<0)continue;let o=r.runs[a];if(o.usage===void 0)continue;let{usage:s,...c}=o;r.replace(a,c),i=!0}return i?r.runs:e}function Zn(e,t,n,r){let i=Xn(e.runs,t,n,r);return i===e.runs?e:Pn(e,i)}function Qn(e,t){let n=e.runs.filter(e=>e.projectId!==t),r=e.truncated.filter(e=>e!==t),i=Object.prototype.hasOwnProperty.call(e.referenceStatuses,t);if(n.length===e.runs.length&&r.length===e.truncated.length&&!i)return e;let a={...e.referenceStatuses};return delete a[t],{...e,runs:n,truncated:r,referenceStatuses:a}}function $n(){return{stream:void 0,lastStream:void 0,mismatch:void 0,floor:void 0,changes:new Map}}function er(e,t,n){if(e.lastStream===t)e.floor=n===void 0?void 0:Math.max(e.floor??n,n);else{for(let[n,r]of e.changes)r.generation!==t&&e.changes.delete(n);e.floor=n}e.stream=t,e.lastStream=t,e.mismatch=void 0}function tr(e){e.stream=void 0}function nr(e,t){return`hostId`in t?JSON.stringify([e,t.hostId,t.project,Nn(t)]):JSON.stringify([e,t.project,Nn(t)])}function rr(e,t,n=!1){let r=e.stream;if(r===void 0)return!1;(e.floor===void 0||n)&&(e.floor=t.seq-1);let i=nr(r,t),a=e.changes.get(i);return(!a||a.seq<t.seq)&&e.changes.set(i,{...t,generation:r}),!0}var ir=1e3;function ar(e,t=ir){if(e.changes.size<=t)return;let n=[...e.changes.entries()].sort((e,t)=>e[1].seq-t[1].seq),r=n.length-t,i;for(let t=0;t<r;t+=1){let[r,a]=n[t];e.changes.delete(r),a.generation===e.lastStream&&(i=i===void 0?a.seq:Math.max(i,a.seq))}i!==void 0&&(e.floor=e.floor===void 0?i:Math.max(e.floor,i))}function or(e,t){for(let[n,r]of e.changes)r.project===t&&e.changes.delete(n)}function sr(e){return typeof e.generation==`string`&&typeof e.eventSeq==`number`}function cr(e,t,n){if(e.stream!==void 0&&e.stream!==t){let n=e.mismatch!==t;return e.mismatch=t,{mismatch:!0,first:n}}let r=e.lastStream===t&&e.floor!==void 0,i=r&&n<e.floor,a=[...e.changes.entries()].filter(([,e])=>e.generation===t);return{mismatch:!1,covered:r,missed:i,own:a,newer:a.map(([,e])=>e).filter(e=>e.seq>n).sort((e,t)=>e.seq-t.seq)}}function lr(e,t,n){if(!sr(t))return{index:t,reconcile:!1};let{generation:r,eventSeq:i}=t,a=cr(e,r,i);if(a.mismatch)return{index:t,reconcile:a.first};let o=Un(t,a.newer.map(e=>({type:`change`,change:e})),n);for(let[t,n]of a.own)n.seq<=i&&e.changes.delete(t);return a.covered&&!a.missed&&(e.floor=i),{index:o.index,reconcile:a.missed||o.reconcile}}function ur(e,t,n){if(!sr(t))return{index:t,reconcile:!1,reconcileHosts:[]};let{generation:r,eventSeq:i}=t,a=cr(e,r,i);if(a.mismatch)return{index:t,reconcile:a.first,reconcileHosts:[]};let o=Wn(t,a.newer.map(e=>({type:`change`,change:e})),n);for(let[t,n]of a.own)n.seq<=i&&e.changes.delete(t);return(a.covered&&!a.missed||e.lastStream===r&&e.floor===void 0)&&(e.floor=i),{index:o.index,reconcile:a.missed,reconcileHosts:o.reconcileHosts,refreshProjects:o.refreshProjects}}function dr(e,t,n){if(e.length===0)return t;let r=In.get(e)??Rn(e,n).positions,i=e.length===t.length,a=!1,o=[];for(let s=0;s<t.length;s+=1){let c=t[s],l=r.get(n(c))?.get(c.id),u=l===void 0?void 0:e[l],d=u===void 0?c:k(u,c);d===u&&(a=!0),i&&d!==e[s]&&(i=!1),o.push(d)}return i?e:a?o:t}function fr(e,t){if(!e||e.generation!==t.generation)return t;let n=dr(e.runs,t.runs,Bn),r=k(e.referenceStatuses,t.referenceStatuses),i=k(e.truncated,t.truncated);return n===e.runs&&r===e.referenceStatuses&&i===e.truncated&&t.perProjectLimit===e.perProjectLimit&&t.eventSeq===e.eventSeq?e:n===t.runs&&r===t.referenceStatuses&&i===t.truncated?t:{...t,runs:n,referenceStatuses:r,truncated:i}}function pr(e,t){if(!e||e.generation!==t.generation)return t;let n=dr(e.runs,t.runs,Hn),r=k(e.hosts,t.hosts);return n===e.runs&&r===e.hosts&&t.eventSeq===e.eventSeq&&t.warning===e.warning?e:n===t.runs&&r===t.hosts?t:{...t,runs:n,hosts:r}}function mr(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].createdAt??``)>=t[i].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 hr(e,t,n,r,i){if(t.generation!==e.generation||r.stream!==void 0&&r.stream!==t.generation)return{index:e,fullReconcile:!0,reconcileHosts:[]};let a=[...r.changes.entries()].filter(([,e])=>e.generation===t.generation&&e.hostId===n),o=Wn(t,a.map(([,e])=>e).filter(e=>e.seq>t.eventSeq).sort((e,t)=>e.seq-t.seq).map(e=>({type:`change`,change:e})),i);for(let[e,n]of a)n.seq<=t.eventSeq&&r.changes.delete(e);let s=o.index.hosts.find(e=>e.id===n),c=e.hosts.some(e=>e.id===n),l=s?c?e.hosts.map(e=>e.id===n?s:e):[...e.hosts,s]:e.hosts.filter(e=>e.id!==n);return{index:{runs:mr(e.runs.filter(e=>e.hostId!==n),o.index.runs.filter(e=>e.hostId===n)),hosts:l,generation:e.generation,eventSeq:e.eventSeq,...t.warning===void 0?{}:{warning:t.warning}},fullReconcile:!1,reconcileHosts:o.reconcileHosts}}var gr=[`workspace`,`runs-index`],W=[`main`,`hosts`,`runs-index`],_r=[`workspace`,`projects`],vr=[`main`,`hosts`,`projects`],yr=6e4,br=100,xr=new WeakMap,Sr=new WeakMap;function Cr(e){let t=xr.get(e);return t||(t=Pr(e),xr.set(e,t)),t}function wr(e){let t=Sr.get(e);return t||(t=Rr(e),Sr.set(e,t)),t}function Tr(e,t){return typeof e!=`object`||!e||!Array.isArray(e.runs)?e:Cr(t).merge(e)}function Er(e){let t=e.getQueryData(_r)?.projects;return t?new Set(t.map(e=>e.id)):void 0}function Dr(e){let t=e.getQueryData(vr)?.hosts;if(!t)return;let n=new Map;for(let e of t)e.projects!==null&&n.set(e.id,new Set(e.projects.map(e=>e.id)));return(e,t)=>n.get(e)?.has(t)}function Or(e,t,n){if(!(!e||typeof e.eventSeq!=`number`||typeof t.eventSeq!=`number`))return e.generation===t.generation?t.eventSeq<e.eventSeq?e:void 0:n!==void 0&&e.generation===n&&t.generation!==n?e:void 0}function kr(e,t){return t.type===`run-summary`?{type:`run`,project:e,seq:t.seq,run:t.summary}:{type:`deleted`,project:e,seq:t.seq,id:t.id}}function Ar(e){return e.type===`host-run-summary`?{type:`run`,hostId:e.hostId,project:e.project,seq:e.seq,run:e.summary}:{type:`deleted`,hostId:e.hostId,project:e.project,seq:e.seq,id:e.id}}function jr(e){let t,n,r=-1/0;return{markWrite(){r=Date.now()},cancelPending:()=>{t!==void 0&&typeof cancelAnimationFrame==`function`&&cancelAnimationFrame(t),t=void 0,clearTimeout(n),n=void 0},schedule(){if(n!==void 0)return;let i=r+250-Date.now();if(i>0){n=setTimeout(e,i);return}n=setTimeout(e,br),typeof requestAnimationFrame==`function`&&(t=requestAnimationFrame(e))}}}function Mr(e){let t,n,r=!1,i=()=>{clearTimeout(t),t=void 0;let a=e().catch(()=>void 0).finally(()=>{n===a&&(n=void 0,r&&(r=!1,i()))});return n=a,a};return{isInFlight(){return n!==void 0},reconcile(e={}){return n?(r=!0,n):e.hold?(t??=setTimeout(()=>{i()},400),Promise.resolve()):i()},stop(){clearTimeout(t),t=void 0,r=!1}}}function Nr(e,t){let n=e.getQueryCache().find({queryKey:t,exact:!0});return n!==void 0&&n.state.data===void 0&&n.state.fetchStatus!==`idle`?e.cancelQueries({queryKey:t,exact:!0}).then(()=>e.invalidateQueries({queryKey:t})):e.invalidateQueries({queryKey:t})}function Pr(e){let t=$n(),n=[],r=new Set,i=!1,a,o=!1,s=()=>e.getQueryData(gr),c=Mr(()=>Nr(e,gr)),l=()=>{if(!i){if(i=!0,a?.()){o=!0;return}c.reconcile({hold:!0})}},u=()=>{d.cancelPending();let t=n;n=[];let i=s();if(!i||t.length===0)return;let a=Er(e),{index:o,reconcile:l}=Un(i,t.filter(e=>e.generation===i.generation?e.type===`usage`?!r.has(e.project):!r.has(e.change.project)&&e.change.seq>i.eventSeq:!1),a);o!==i&&f(o),l&&c.reconcile({hold:!0})},d=jr(u),f=t=>{d.markWrite(),e.setQueryData(gr,t)};return{ready(e,n){er(t,e,n),i=!1,o&&(o=!1,c.reconcile({hold:!0}))},detach(){tr(t)},run(e,i,a=!1){if(r.has(e))return;let o=kr(e,i);if(!rr(t,o,a)){l();return}n.push({type:`change`,change:o,generation:t.stream}),d.schedule()},usage(e,i){if(!r.has(e)){if(t.stream===void 0){l();return}n.push({type:`usage`,project:e,usage:i,generation:t.stream}),d.schedule()}},dropProject(e){r.add(e),or(t,e),n=n.filter(t=>(t.type===`change`?t.change.project:t.project)!==e);let i=s();if(!i)return;let a=Qn(i,e);a!==i&&f(a)},setUnknownGenerationHandler(e){a=e},restoreProject(e){r.delete(e)},merge(n){let i=s(),a=lr(t,n,Er(e));for(let e of r)a.index=Qn(a.index,e);return a.reconcile&&queueMicrotask(()=>{c.reconcile({hold:!0})}),Or(i,n,t.stream)??fr(i,a.index)},reconcile:c.reconcile,flush:u,stop(){d.cancelPending(),c.stop(),n=[]}}}var Fr=[1e3,2e3,4e3,8e3,15e3],Ir=6e4;function Lr(e,t){e.setQueryData(W,e=>{if(!e)return e;let n=e.hosts.find(e=>e.id===t);return!n||n.stale?e:{...e,hosts:e.hosts.map(e=>e.id===t?{...e,stale:!0}:e)}})}function Rr(e,t=e=>gn({hostId:e}),n=Fr,r=Ir,i=e=>gn({signal:e})){let a=$n(),o=On(),s=new Map,c=new Map,l=new Map,u=0,d,f=[],p=!1,m,ee=!1,te=!1,ne=!1,h,g,_,v=!1,y=0,re=0,b=!1,x=new Map,S=()=>e.getQueryData(W),C=()=>e.getQueryCache().find({queryKey:W,exact:!0}),ie=()=>{ne||(ne=!0,e.invalidateQueries({queryKey:vr,exact:!0}).finally(()=>{ne=!1}))},ae=e=>{let t=l.get(e);t!==void 0&&(clearTimeout(t),l.delete(e))},oe=()=>{d!==void 0&&(clearTimeout(d),d=void 0),u=0},se=()=>{for(let e of l.values())clearTimeout(e);l.clear(),c.clear(),oe()},w=Mr(()=>C()?(te=!0,Nr(e,W)):Promise.resolve()),ce=()=>{if(!p){if(p=!0,m?.()){ee=!0;return}w.reconcile({hold:!0})}},le=()=>{if((C()?.getObserversCount()??0)===0)return;let e=n[u]??r;u+=1,d!==void 0&&clearTimeout(d),d=setTimeout(()=>{d=void 0,w.reconcile()},e)},T=e=>{if((C()?.getObserversCount()??0)===0)return;let t=c.get(e)??0,i=n[t]??r;c.set(e,t+1),ae(e),l.set(e,setTimeout(()=>{l.delete(e),D([e])},i))},ue=t=>{Lr(e,t),T(t)},de=(t,n)=>{let r=S();if(!r)return!1;if(n.generation!==r.generation||a.stream!==void 0&&a.stream!==n.generation)return w.reconcile(),!0;let i=s.get(t)??r.eventSeq;if(n.eventSeq<i)return ue(t),!1;let o=hr(r,n,t,a,Dr(e));if(o.fullReconcile)return w.reconcile(),!0;let l=o.index.hosts.find(e=>e.id===t);l?(s.set(t,n.eventSeq),l.state===`connected`&&l.stale?T(t):(ae(t),c.delete(t))):(ae(t),c.delete(t),s.delete(t));let u=pr(r,o.index);return u!==r&&he(u),o.reconcileHosts.length>0&&D(o.reconcileHosts,{hold:!0}),!1},fe=(t={})=>{let n=C();if(!n)return Promise.resolve();if(n.getObserversCount()===0)return e.invalidateQueries({queryKey:W,exact:!0,refetchType:`none`}),Promise.resolve();if(!S())return w.reconcile(t)},pe=()=>{let t=C();return!t||t.state.fetchStatus!==`fetching`?Promise.resolve():new Promise(n=>{let r=e.getQueryCache().subscribe(e=>{e.query===t&&t.state.fetchStatus!==`fetching`&&(r(),n())})})},E=()=>{clearTimeout(h),h=void 0;let e=y;if(_||v)return(_??Promise.resolve()).then(()=>{if(!(y!==e||x.size===0))return E()});if(g)return g;let n=[...x.entries()];if(x.clear(),b=!1,n.length===0)return Promise.resolve();let r=fe();if(r)return r;let i=e=>{for(let t=e;t<n.length;t+=1){let[e,r]=n[t];x.has(e)||x.set(e,r)}},a=(async()=>{for(let r=0;r<n.length;r+=1){let[a]=n[r];if(y!==e)break;if(v){i(r);break}try{let n=await t(a);if(y!==e)break;if(de(a,n)){i(r+1);break}}catch{if(y===e){if(v){i(r);break}ue(a)}}}})().finally(()=>{g===a&&(g=void 0,!v&&!_&&y===e&&x.size>0&&(b?E():h??=setTimeout(()=>{E()},400)))});return g=a,a},D=(e,t={})=>{if(e.length===0)return Promise.resolve();let n=fe(t);if(n)return n;for(let t of e)x.set(t,++re);return t.hold||(b=!0),g||(t.hold&&!b&&!_&&!v?(h??=setTimeout(()=>{E()},400),Promise.resolve()):E())},me=()=>{O.cancelPending();let t=f;f=[];let n=S();if(!n||t.length===0)return;let{index:r,reconcileHosts:i,refreshProjects:a}=Wn(n,t.filter(e=>{if(e.generation!==n.generation)return!1;if(e.type===`usage`)return!0;let t=s.get(e.change.hostId)??n.eventSeq;return e.change.seq>t}),Dr(e));r!==n&&he(r),a&&ie(),i.length>0&&D(i,{hold:!0})},O=jr(me),he=t=>{O.markWrite(),e.setQueryData(W,t)},ge=e=>{let t=new Set(e.filter(e=>e.state===`connected`&&e.stale).map(e=>e.id));for(let e of[...l.keys()])t.has(e)||(ae(e),c.delete(e));for(let e of[...c.keys()])t.has(e)||c.delete(e);for(let e of t)l.has(e)||T(e)},_e=t=>{let n=S(),r=ur(a,t,Dr(e)),i=Or(n,t,a.stream)??(s.clear(),ge(r.index.hosts),(a.stream===t.generation||a.lastStream===t.generation)&&o.seed(t.eventSeq),pr(n,r.index)),c=y;return r.refreshProjects&&queueMicrotask(()=>{y===c&&ie()}),r.reconcile?queueMicrotask(()=>{y===c&&w.reconcile({hold:!0})}):r.reconcileHosts.length>0&&queueMicrotask(()=>{y===c&&D(r.reconcileHosts,{hold:!0})}),i};return{ready(e){let t=a.lastStream;er(a,e),p=!1;let n=S(),r=t!==void 0&&t!==e||n!==void 0&&n.generation!==e,i=t===void 0&&(n!==void 0||C()?.state.fetchStatus===`fetching`),s=te&&w.isInFlight();te=!1,r?o.reset():i&&n&&o.seed(n.eventSeq),(r||ee||i)&&!s?(ee=!1,w.reconcile({hold:!0})):s&&(ee=!1)},detach(){tr(a),o.reset(),te=!1},run(e){let t=o.frame(e.seq),n=Ar(e);if(!rr(a,n,t)){ce();return}ar(a),f.push({type:`change`,change:n,generation:a.stream}),O.schedule(),t&&w.reconcile({hold:!0})},usage(e,t,n){if(a.stream===void 0){ce();return}f.push({type:`usage`,hostId:e,project:t,usage:n,generation:a.stream}),O.schedule()},setUnknownGenerationHandler(e){m=e},fetchFull:e=>{v=!0,clearTimeout(h),h=void 0;let t=y,n=_,r=g,a=(async()=>{if(n&&await n,r&&await r.catch(()=>void 0),y!==t||e?.aborted)throw e?.reason??new DOMException(`Aborted`,`AbortError`);let a=re,o;try{o=await i(e)}catch(n){throw y===t&&!e?.aborted&&le(),n}if(y!==t||e?.aborted)throw e?.reason??new DOMException(`Aborted`,`AbortError`);oe();for(let[e,t]of[...x.entries()])t<=a&&x.delete(e);return _e(o)})(),o;return o=a.then(()=>pe(),()=>void 0).then(()=>{_===o&&(_=void 0,v=!1,y===t&&x.size>0&&E())}),_=o,a},merge:_e,reconcile:w.reconcile,reconcileHosts:D,reconcileFinite(){let t=S();if(!t)return w.reconcile();let n=e.getQueryData(vr)?.hosts??[],r=[...new Set([...t.hosts.map(e=>e.id),...n.map(e=>e.id)])];return r.length===0?w.reconcile():D(r)},flush:me,stop(){y+=1,v=!1,_=void 0,g=void 0,O.cancelPending(),w.stop(),clearTimeout(h),h=void 0,se(),b=!1,x.clear(),f=[]}}}var zr=(e,t,n)=>[`host`,e,t,`runs`,`detail`,n],G={get health(){return[n(),`health`]},runs:{get all(){return[n(),`runs`]},relationships:e=>[n(),`runs`,`relationships`,e],list:(e=n())=>[e,`runs`,`list`],archived:e=>[n(),`runs`,`archived`,e],detail:(e,t=n())=>[t,`runs`,`detail`,e],diff:e=>[n(),`runs`,`diff`,e],changes:e=>[n(),`runs`,`changes`,e],file:(e,t)=>[n(),`runs`,`files`,e,t],handoff:e=>[n(),`runs`,`handoff`,e],commits:e=>[n(),`runs`,`commits`,e],commit:(e,t)=>[n(),`runs`,`commit`,e,t]},get workflows(){return[n(),`workflows`]},runnerSkills:(e,t,r=n())=>[r,`runner-skills`,e,t??null],get repo(){return[n(),`repo`]},get repoChanges(){return[n(),`repo`,`changes`]},repoCommit:e=>[n(),`repo`,`commit`,e],get repoBranches(){return[n(),`repo`,`branches`]},get uiState(){return[n(),`ui-state`]},get config(){return[n(),`config`]},get agentConfig(){return[n(),`agent-config`]},agentConfigFile:e=>[n(),`agent-config`,`file`,e],get sessionContext(){return[n(),`session-context`]},sessionContextPreview:(e,t,r=``)=>[n(),`session-context`,`preview`,t,e,r],get worktrees(){return[n(),`worktrees`]},github:(e={})=>[n(),`github`,e.limit??null],githubPages:e=>[n(),`github`,`pages`,e],githubPagesHead:e=>[n(),`github`,`pages-head`,e],githubCommentCounts:(e,t)=>[n(),`github`,`comment-counts`,e,[...t].sort((e,t)=>e-t).join(`,`)],githubChecks:e=>[n(),`github`,`checks`,[...e].sort((e,t)=>e-t).join(`,`)],githubSearch:(e,t)=>[n(),`github`,`search`,e,t],githubRefStatus:(e,t,n,r)=>{let i=[e,`github`,`ref-status`,[...t].sort((e,t)=>e-t).join(`,`),[...n].sort((e,t)=>e-t).join(`,`)];return r===void 0?i:[`host`,r,...i]},githubComments:(e,t)=>[n(),`github`,`comments`,e,t],githubItem:(e,t)=>[n(),`github`,`item`,e,t],githubRefStatusOf:e=>[e,`github`,`ref-status`],githubPrChanges:e=>[n(),`github`,`pr-changes`,e],githubMergeState:e=>[n(),`github`,`merge-state`,e],get openTargets(){return[n(),`open-targets`]}},K={models:(e,t)=>t&&t!=="default"?[`workspace`,`models`,e,t]:[`workspace`,`models`,e],providerStatus:[`workspace`,`providers`,`status`],projects:[`workspace`,`projects`],githubOwners:[`workspace`,`github-owners`],runsIndex:gr,runsSearch:e=>[`workspace`,`runs-search`,e],uiState:[`workspace`,`ui-state`],config:[`workspace`,`config`],agentProfiles:[`workspace`,`agent-profiles`],agentAccountStatus:e=>[`workspace`,`agent-profiles`,`status`,e],fsBrowseRoot:[`workspace`,`fs-browse`],fsBrowse:(e,t=!1)=>[...K.fsBrowseRoot,e,t]};function Br(e,t=!0,n=!1,r){return E({queryKey:[V({projectId:e,boot:n}).cacheScope,`runs`,`list`],queryFn:({signal:t})=>_e(V({projectId:e,boot:n}),{signal:t}),enabled:t,...r?{select:r}:{},placeholderData:(t,r)=>n&&r?.queryKey[0]===e?t:void 0})}function q(e,t,n=`active`){return e.invalidateQueries({queryKey:t===void 0?[`workspace`,`models`]:K.models(t),refetchType:n})}function Vr(e,t=!0,n){return E({...Hr(e,n),enabled:t})}var Hr=(e,t)=>({queryKey:K.models(e,t),queryFn:({signal:n})=>D(e,{signal:n},t),staleTime:300*1e3});function Ur(e,t=!0){let n=dn({queries:e.map(e=>({...Hr(e),enabled:t}))});return Object.fromEntries(e.map((e,t)=>[e,n[t]]))}var Wr=L([`own`,`provider-spanning`]),Gr=A({suggested:P(A({id:I(),label:I(),desc:I()})),retired:P(I())}),Kr=A({id:L([`settings`,`mcp`,`memory`]),label:I(),note:I().optional(),empty:I().optional(),showsUserMcp:N(!0).optional()}),qr=A({label:I(),note:I().optional(),groups:P(Kr)}),Jr=A({runners:P(A({id:be,displayName:I(),modelListName:I(),modelIdScope:Wr,pickerLabel:I(),pickerDescription:I(),icon:I(),installHint:I(),loginCommand:I(),terminalLogin:F().optional(),browserLogin:F().optional(),managedInstall:N(!0).optional(),accountFolderExample:I().optional(),models:Gr,agentConfig:qr}))}),Yr=[`workspace`,`runners`];async function Xr(e){return gt(await Bt.api.v1.runners.$get({},y(e)),`/runners`,Jr)}var Zr={queryKey:Yr,queryFn:({signal:e})=>Xr({signal:e}),staleTime:1/0};function Qr(){return E(Zr)}function $r(e){return e?.runners??[]}function ei(e){return $r(e).map(e=>e.id)}function ti(e,t){if(e!==void 0)return t.includes(e)?e:t[0]}function ni(e){let t=Qr();return{runner:t.isSuccess?ti(e,ei(t.data))??e:e,ready:!t.isPending}}function ri(e,t){return e?.runners.find(e=>e.id===t)}function ii(e,t){return ri(e,t)?.displayName??t}function ai(e,t){return ri(e,t)?.pickerLabel??t}function oi(e,t){return ri(e,t)?.modelListName}function si(e,t,r=!0,i){let a=io(i,r),o=oa(),{runner:s,ready:c}=ni(e??a.data?.defaultRunner??`claude`),l=o.data?.capabilities?.localHandoff===!1?null:t,u=i??n(),d=E({queryKey:G.runnerSkills(s,l,u),queryFn:({signal:e})=>v(s,l,{signal:e,projectId:u}),enabled:r&&c&&(e!==void 0||!a.isPending)&&(!t||!o.isPending),retry:!1});return{...d,runner:s,account:l,data:d.data?.skills,list:d.data,unchecked:d.isError||!d.data||d.data.source===`unavailable`}}var ci={draft:{label:`Draft`,hint:`the author has not marked it ready for review`,tone:`neutral`},"review-required":{label:`Waiting for review`,hint:`checks are fine, no one has reviewed it yet`,tone:`info`},"changes-requested":{label:`Changes requested`,hint:`a reviewer asked for edits before this can merge`,tone:`danger`},"checks-pending":{label:`Checks running`,hint:`CI has not finished on the latest commit`,tone:`pending`},"checks-failing":{label:`Checks failing`,hint:`CI is red on the latest commit`,tone:`danger`},ready:{label:`Ready to merge`,hint:`open, checks pass, nothing is waiting on a reviewer`,tone:`success`},merged:{label:`Merged`,hint:`this landed on its base branch`,tone:`merged`},closed:{label:`Closed`,hint:`closed without merging — the work did not land`,tone:`danger`},open:{label:`Open`,hint:`still open on the tracker`,tone:`success`},completed:{label:`Closed as completed`,hint:`the issue was resolved`,tone:`accent`},"not-planned":{label:`Closed as not planned`,hint:`the issue was declined — nothing shipped for it`,tone:`neutral`}},li={label:`Merge conflicts`,hint:`this branch no longer merges cleanly into its base — rebase or merge the base in`,tone:`conflict`};function ui(e){return typeof e==`string`&&Object.hasOwn(ci,e)}function di(e){return e!==void 0&&ui(e)?ci[e]:void 0}var fi=`cez.reference-statuses.v1`,pi=`cez.reference-conflicts.v1`,J=new Map(yi()),mi=1e3,Y=new Set(bi()),hi=r()??`__local__`;function gi(){let e=r()??`__local__`;if(hi!==e){hi=e,clearTimeout(xi),xi=void 0,J.clear();for(let[e,t]of yi())J.set(e,t);Y.clear();for(let e of bi())Y.add(e)}}function _i(e,t){if(gi(),J.get(e)!==t){for(J.delete(e),J.set(e,t);J.size>mi;){let e=J.keys().next().value;if(e===void 0)break;J.delete(e)}Si()}}function vi(e,t){if(gi(),Y.has(e)!==t){if(t)for(Y.add(e);Y.size>mi;){let e=Y.values().next().value;if(e===void 0)break;Y.delete(e)}else Y.delete(e);Si()}}function yi(){try{let e=globalThis.sessionStorage?.getItem(en(fi));if(!e)return[];let t=JSON.parse(e);return Array.isArray(t)?t.filter(e=>Array.isArray(e)&&e.length===2&&typeof e[0]==`string`&&ui(e[1])):[]}catch{return[]}}function bi(){try{let e=globalThis.sessionStorage?.getItem(en(pi));if(!e)return[];let t=JSON.parse(e);return Array.isArray(t)?t.filter(e=>typeof e==`string`):[]}catch{return[]}}var xi;function Si(){if(xi!==void 0)return;let e=en(fi),t=en(pi);xi=setTimeout(()=>{xi=void 0;try{globalThis.sessionStorage?.setItem(e,JSON.stringify([...J])),globalThis.sessionStorage?.setItem(t,JSON.stringify([...Y]))}catch{}},250)}var Ci=e=>e.hostId===void 0?`${e.projectId}\u0000${e.kind}#${e.number}`:`host:${e.hostId}\u0000${e.projectId}\u0000${e.kind}#${e.number}`;function wi(e,t){return{...e?{status:e}:{},...t?{conflicting:!0}:{}}}function Ti(e){let t=e.hostId===void 0?{}:{hostId:e.hostId};return[...e.prs.map(n=>({...t,projectId:e.projectId,kind:`PR`,number:n})),...e.issues.map(n=>({...t,projectId:e.projectId,kind:`Issue`,number:n}))]}function Ei(e,t,n,r,i,a){let o=r.prs[n.number]??r.issues[n.number];if(!o){e.set(t,{state:`unknown`,...i?{status:i}:{}});return}let s=r.conflicts?r.conflicts.includes(n.number):void 0;_i(t,o),s!==void 0&&vi(t,s),e.set(t,{state:`ready`,status:o,...s??a?{conflicting:!0}:{}})}function Di(e,t,n){gi();let r=Ci(t),i=J.get(r),a=Y.has(r)?!0:void 0,o=n.data;if(o?.available){Ei(e,r,t,o,i,a);return}if(o){e.set(r,{state:`unavailable`,reason:o.reason,...wi(i,a)});return}if(n.isError){e.set(r,{state:`unavailable`,reason:n.error instanceof Error?n.error.message:void 0,...wi(i,a)});return}e.set(r,{state:`loading`,...wi(i,a)})}function Oi(e,t){let n=new Map;return t.forEach((t,r)=>{let i=e[r];if(i)for(let e of Ti(i))Di(n,e,t)}),n}function ki(e){if(!e)return;let t=e.trim().replace(/\/+$/,``),n=/^(?:https?|ssh|git|git\+ssh):\/\/(?:[^@/]+@)?([^/:]+)(?::\d+)?\/(.+)$/.exec(t),r=n?null:/^(?:[^@/:]+@)?([^:/]+):(.+)$/.exec(t),i=n??r;if(!i)return;let[,a,o]=i;if(!o||a?.toLowerCase()!==`github.com`)return;let s=o.replace(/\.git$/i,``).split(`/`).filter(Boolean),c=s[s.length-2],l=s[s.length-1];return c&&l?`https://github.com/${c}/${l}`:void 0}function Ai(e){let t=new Map;for(let n of e)for(let e of n.tags??[]){let n=e.toLowerCase();t.has(n)||t.set(n,e)}return[...t.values()].sort((e,t)=>e.localeCompare(t,void 0,{sensitivity:`base`}))}function ji(e,t,n,r=8){let i=n.trim().toLowerCase(),a=new Set(t.map(e=>e.toLowerCase())),o=e.filter(e=>{let t=e.toLowerCase();return a.has(t)?!1:i===``||t.includes(i)&&t!==i});return i===``?o.slice(0,r):o.sort((e,t)=>Number(t.toLowerCase().startsWith(i))-Number(e.toLowerCase().startsWith(i))||e.localeCompare(t,void 0,{sensitivity:`base`})).slice(0,r)}function Mi(e){let t=new Map;for(let n of e){let e=n.trim();if(!e)continue;let r=e.toLowerCase();t.has(r)||t.set(r,e)}return[...t.values()].sort((e,t)=>e.localeCompare(t,void 0,{sensitivity:`base`}))}function Ni(e,t){return $e({kind:`topic`,topic:e},{value:t})}function Pi(){let e=T();return E({queryKey:K.providerStatus,queryFn:async({signal:t})=>{let n=e.getQueryData(K.providerStatus),r=await Pt(!1,{signal:t});return xe(n,e.getQueryData(K.providerStatus),r)},staleTime:5*6e4,refetchInterval:U(!1),refetchOnWindowFocus:!0})}function Fi(){let e=T();return B({mutationFn:()=>Pt(!0),onMutate:()=>e.getQueryData(K.providerStatus),onSuccess:(t,n,r)=>{e.setQueryData(K.providerStatus,e=>xe(r,e,t)),q(e)}})}function Ii(){let e=T();return B({mutationFn:({provider:e,authFailureId:t})=>ut(e,t),onMutate:()=>e.getQueryData(K.providerStatus),onSuccess:(t,n,r)=>{e.setQueryData(K.providerStatus,e=>xe(r,e,t,n.authFailureId)),q(e,n.provider)}})}function Li(e={}){return E({queryKey:K.projects,queryFn:({signal:e})=>Ot({signal:e}),...e})}function Ri(e,t=!1){return E({queryKey:K.fsBrowse(e,t),queryFn:({signal:n})=>Ke(e??void 0,{signal:n,showHidden:t}),retry:!1})}function zi(){let e=T();return B({mutationFn:e=>lt(e),onSuccess:()=>e.invalidateQueries({queryKey:K.projects})})}function Bi(){let e=T();return B({mutationFn:e=>wt(e),retry:!1,onSuccess:(t,n)=>{e.setQueryData(K.projects,e=>e&&{...e,projects:e.projects.filter(e=>e.id!==n)}),e.invalidateQueries({queryKey:K.projects})}})}function Vi(){let e=T();return B({mutationFn:e=>{let{id:t,...n}=e;return Ut(t,n)},retry:!1,onMutate:async({id:t,...n})=>{await e.cancelQueries({queryKey:K.projects});let r=e.getQueryData(K.projects);return e.setQueryData(K.projects,e=>e===void 0?e:{...e,projects:e.projects.map(e=>e.id===t?Hi(e,n):e)}),{previous:r}},onError:(t,n,r)=>{r?.previous&&e.setQueryData(K.projects,r.previous)},onSuccess:({project:t})=>{e.setQueryData(K.projects,e=>e===void 0?e:{...e,projects:e.projects.map(e=>e.id===t.id?t:e)})},onSettled:()=>e.invalidateQueries({queryKey:K.projects})})}function Hi(e,t){let{maxParallel:n,tags:r,...i}=e,a={...i},o=`maxParallel`in t?t.maxParallel:e.maxParallel;o!=null&&(a.maxParallel=o);let s=`tags`in t&&t.tags!==void 0?t.tags:e.tags,c=s==null?[]:Mi(s);if(c.length>0&&(a.tags=c),`webhook`in t&&t.webhook!==void 0)if(t.webhook===null)delete a.webhook;else{let n=t.webhook.token===void 0?e.webhook?.tokenSet??!1:t.webhook.token!==``;a.webhook={url:t.webhook.url,tokenSet:n}}return a}function Ui(e){let t=T();return B({mutationFn:e,retry:!1,onSuccess:({project:e})=>{t.setQueryData(K.projects,t=>t===void 0?t:{...t,projects:t.projects.map(t=>t.id===e.id?e:t)})},onSettled:()=>t.invalidateQueries({queryKey:K.projects})})}function Wi(){return Ui(e=>{let{projectId:t,...n}=e;return st(t,n)})}function Gi(){return Ui(e=>{let{projectId:t,webhookId:n,...r}=e;return je(t,n,r)})}function Ki(){return Ui(({projectId:e,webhookId:t})=>pt(e,t))}function qi(){return B({mutationFn:({projectId:e,webhookId:t})=>Kt(e,t),retry:!1})}function Ji(e){let t=T();return B({mutationFn:e,retry:!1,onSuccess:async()=>{await Promise.all([t.invalidateQueries({queryKey:K.agentProfiles}),t.invalidateQueries({queryKey:K.projects}),t.invalidateQueries({predicate:({queryKey:e})=>e[1]===`runner-skills`}),q(t)])},onError:()=>{t.invalidateQueries({queryKey:G.health}),t.invalidateQueries({queryKey:K.agentProfiles,exact:!0})}})}function Yi(){return Ji(e=>De(e))}function Xi(){return Ji(e=>{let{id:t,...n}=e;return tt(t,n)})}function Zi(){return Ji(e=>kt(e))}function Qi(){return Ji(e=>Ye(e))}function $i(e,t){return E({queryKey:K.agentAccountStatus(e),queryFn:({signal:t})=>It(e,{signal:t}),enabled:t,staleTime:6e4,retry:!1})}function ea(){let e=T();return B({mutationFn:({provider:e,profileId:t})=>Je(e,t),retry:!1,onSuccess:async(t,{provider:n})=>{await Promise.all([e.invalidateQueries({queryKey:K.agentProfiles}),e.invalidateQueries({queryKey:K.providerStatus}),q(e,n,`none`)])},onError:()=>{e.invalidateQueries({queryKey:G.health}),e.invalidateQueries({queryKey:K.agentProfiles,exact:!0})}})}function ta(){let e=T();return B({mutationFn:e=>It(e,{refresh:!0}),retry:!1,onSuccess:(t,n)=>{e.setQueryData(K.agentAccountStatus(n),t),e.invalidateQueries({queryKey:K.agentProfiles}),q(e,t.status.provider)}})}function na(){let e=T();return B({mutationFn:e=>Ue(e),retry:!1,onSuccess:()=>e.invalidateQueries({queryKey:K.projects})})}function ra(){let e=T();return B({mutationFn:e=>s(e),retry:!1,onSuccess:()=>e.invalidateQueries({queryKey:K.projects})})}function ia({enabled:e}){return E({queryKey:K.githubOwners,queryFn:({signal:e})=>mt({signal:e}),enabled:e,staleTime:6e4,retry:!1})}function aa(){let e=T();(0,z.useEffect)(()=>{let t,n=()=>{let n=e.getQueryData(G.health);n&&(Ee({bootProject:n.bootProject===void 0?`default`:n.bootProject,apiBase:i()}),t??=Ni(`health`,t=>{e.setQueryData(G.health,t)}))};n();let r=e.getQueryCache().subscribe(n);return()=>{r(),t?.(),ht()}},[e])}function oa(){return E({queryKey:G.health,queryFn:({signal:e})=>Qe({signal:e})})}function sa(e,t){let n=oa().data,r=Li(t).data?.projects,i=Ze(),a=e??i.projectId,o=a??n?.bootProject??void 0,s=o===void 0?void 0:r?.find(e=>e.id===o);return s?.repoUrl?s.repoUrl:n?.bootProject!==null&&(a===null||a===n?.bootProject)?ki(n?.repo?.remote):void 0}function ca(e=!0){return E({queryKey:K.uiState,queryFn:({signal:e})=>xt({signal:e}),enabled:e})}function la(){return E({queryKey:K.config,queryFn:({signal:e})=>it({signal:e})})}function ua(){return E({queryKey:K.agentProfiles,queryFn:({signal:e})=>Et({signal:e})})}var da=[`workspace`,`runs-index`],X=e=>[e.cacheScope,`runs`,`list`],Z=e=>e.hostId===void 0?[e.cacheScope,`runs`,`detail`,e.runId]:zr(e.hostId,e.projectId,e.runId),Q=e=>typeof e==`function`?e():e;function fa(e){let{seenAt:t,...n}=e;return n}function pa(e,t){let n=fa(e);return t.seenAt===void 0?n:{...n,seenAt:t.seenAt}}function ma(e,t,n){return t?{...e,seenAt:n}:fa(e)}function ha(e,t,n){let r={...e},i=t;for(let e of n)Object.prototype.hasOwnProperty.call(i,e)&&i[e]!==void 0?r[e]=i[e]:delete r[e];return r}function ga(e,t){let n=new Set([...Object.keys(e),...Object.keys(t)]),r=[];for(let i of n)Object.is(e[i],t[i])||r.push(i);return r}function _a(e){let t=()=>{e.invalidateQueries({queryKey:da})};function r(r,i){if(r===`index`)return t();let a=typeof i==`function`?i():i;if(a.hostId!==void 0)return r===`indexed`?void 0:e.invalidateQueries({queryKey:[`host`,a.hostId,a.projectId,`runs`]});if(r===`indexed`){t(),e.invalidateQueries({queryKey:[n(),`runs`]}),e.invalidateQueries({queryKey:[a.projectId,`runs`,`list`]});return}if(r===`runs`)return e.invalidateQueries({queryKey:[a.cacheScope,`runs`]});let s=o(),c=[a.projectId,a.cacheScope],l=s!==void 0&&c.some(e=>e===s||e==="default")?[s,`default`]:[],u=new Set([...c,...l,n()]);return Promise.all([...u].map(t=>e.invalidateQueries({queryKey:[t,`runs`]}))).then(()=>void 0)}let i=(e,t,n)=>r=>r.id===(e?t:n.id)?ma(r,e,n.seenAt):r;async function a(t,n){let r=t.runId,a=new Date().toISOString(),o=e=>e.hostId===t.hostId&&e.projectId===t.projectId&&e.id===r,s=t=>{e.setQueryData(W,e=>e===void 0?e:{...e,runs:e.runs.map(e=>o(e)?t(e):e)})},c=e.getQueryData(Z(t)),l=e.getQueryData(W)?.runs.find(o);return e.setQueryData(Z(t),e=>e&&ma(e,n,a)),s(e=>ma(e,n,a)),{id:r,prevList:void 0,prevDetail:c,rollback(){c&&e.setQueryData(Z(t),e=>e&&pa(e,c)),l&&s(e=>pa(e,l))},settle(a){let o=i(n,r,a);e.setQueryData(Z(t),e=>e?o(e):a),s(o)}}}async function s(n,r){let o=Q(n);if(o.hostId!==void 0)return a(o,r);await e.cancelQueries({queryKey:X(Q(n))}),await e.cancelQueries({queryKey:Z(Q(n))});let s=e.getQueryData(X(Q(n))),c=e.getQueryData(Z(Q(n))),l=Q(n).runId,u=new Date().toISOString();return e.setQueryData(X(Q(n)),e=>e?.map(e=>e.id===l?ma(e,r,u):e)),e.setQueryData(Z(Q(n)),e=>e&&ma(e,r,u)),{id:l,prevList:s,prevDetail:c,rollback(){if(!r){s&&e.setQueryData(X(Q(n)),s),c&&e.setQueryData(Z(Q(n)),c);return}let t=s?.find(e=>e.id===l);t&&e.setQueryData(X(Q(n)),e=>e?.map(e=>e.id===l?pa(e,t):e)),c&&e.setQueryData(Z(Q(n)),e=>e&&pa(e,c))},settle(a){let o=i(r,l,a);e.setQueryData(X(Q(n)),e=>e?.map(o));let s={...Q(n),runId:r?l:a.id};e.setQueryData(Z(s),e=>e?o(e):a),t()}}}async function c(t,n){if(t.hostId!==void 0){let r=e.getQueryData(W),i=r?.runs.find(e=>e.hostId===t.hostId&&e.projectId===t.projectId&&e.id===t.runId),a=n(),o=i?a(i):void 0,s=i&&o?ga(i,o):[];return e.setQueryData(W,e=>e===void 0?e:{...e,runs:e.runs.map(e=>e.hostId===t.hostId&&e.projectId===t.projectId&&e.id===t.runId?{...a(e),hostId:e.hostId}:e)}),{previous:r,rollback(){!i||s.length===0||e.setQueryData(W,e=>e===void 0?e:{...e,runs:e.runs.map(e=>e.hostId===t.hostId&&e.projectId===t.projectId&&e.id===t.runId?ha(e,i,s):e)})},settle(){}}}await e.cancelQueries({queryKey:da});let i=e.getQueryData(da),a=n();return e.setQueryData(da,e=>e===void 0?e:{...e,runs:e.runs.map(e=>e.projectId===t.projectId&&e.id===t.runId?a(e):e)}),{previous:i,rollback(){i&&e.setQueryData(da,i)},settle(){r(`indexed`,t)}}}return{patchRead:s,patchIndex:c,invalidateAfter:r}}function $(){let e=T();return(0,z.useMemo)(()=>_a(e),[e])}function va(e,t){if(!Qt(e.path))throw Error(`unsupported shared read`);let n=new URL(e.path,`http://cezar.invalid`);return n.searchParams.sort(),$e({kind:`read`,path:`${n.pathname}${n.search}`,intervalMs:e.intervalMs},{value:t})}function ya(e,t,n,r){let i=T(),a=JSON.stringify(t),o=(0,z.useMemo)(()=>JSON.parse(a),[a]);(0,z.useEffect)(()=>{if(!e||n===!1)return;let t=!0,a=va({path:e,intervalMs:n},(e,n)=>{n||i.cancelQueries({queryKey:o,exact:!0}).then(()=>{t&&i.setQueryData(o,r?r(e,i):e)})});return()=>{t=!1,a()}},[i,e,o,n,r])}async function ba(e,t=!1){return l(await Bt.api.v1.p[`:projectId`].runs[`:id`][`worker-destroy`].$post({param:{projectId:n(),id:encodeURIComponent(e)},query:{},json:t?{discardWork:!0}:{}}),yt(e,`/worker-destroy`))}function xa(){return E({queryKey:G.openTargets,queryFn:({signal:e})=>Wt({signal:e}),staleTime:5*6e4})}function Sa(e=!0,t){return E({queryKey:t?G.runs.list(t):G.runs.list(),queryFn:({signal:e})=>_e(V(t?{projectId:t}:void 0),{signal:e}),enabled:e})}function Ca(e,t){return se({queryKey:G.runs.archived(e),enabled:t,initialPageParam:void 0,queryFn:({pageParam:t,signal:n})=>dt({before:t,limit:200,q:e},{signal:n}),getNextPageParam:e=>e.nextCursor??void 0,placeholderData:(e,t)=>t?.queryKey[0]===n()?e:void 0})}function wa(e){let t=e.trim();return E({queryKey:K.runsSearch(t),queryFn:({signal:e})=>fe(t,{signal:e}),enabled:t.length>=2,placeholderData:Nt,staleTime:1e4})}function Ta(e=!0,t=yr,n){let r=Cr(T());return ya(`/api/v1/workspace/runs-index`,K.runsIndex,U(e?t:!1),Tr),E({queryKey:K.runsIndex,queryFn:({signal:e})=>Ce({signal:e}).then(r.merge),enabled:e,...n?{select:n}:{},structuralSharing:!1,staleTime:3e4,refetchInterval:!1})}function Ea(e){let t=T();return B({mutationFn:({workerId:e,discardWork:t=!1})=>ba(e,t),onSettled:()=>t.invalidateQueries({queryKey:G.runs.relationships(e)})})}function Da(e,t={}){return E({queryKey:G.runs.relationships(e),queryFn:({signal:t})=>O(e,{signal:t}),enabled:t.enabled??!0})}function Oa(e){return E({queryKey:G.runs.detail(e??``),queryFn:({signal:t})=>Me(H(e),{signal:t}),enabled:!!e})}function ka(e,t,n=!0,r){let i=r?.hostId;return E({queryKey:i===void 0?[e??`default`,`runs`,`detail`,t??``]:zr(i,e??`default`,t??``),queryFn:({signal:n})=>Me(H(t,{projectId:e,hostId:i}),{signal:n}),enabled:n&&!!e&&!!t,...r?.staleTime===void 0?{}:{staleTime:r.staleTime},...r?.refetchOnMount===void 0?{}:{refetchOnMount:r.refetchOnMount}})}function Aa(e,t){return E({queryKey:t?[t,`runs`,`diff`,e??``]:G.runs.diff(e??``),queryFn:({signal:n})=>_(e,{signal:n,...t?{projectId:t}:{}}),enabled:!!e})}function ja(e,t=!1){return ya(e?`/api/v1/p/${n()}/runs/${encodeURIComponent(e)}/changes`:void 0,G.runs.changes(e??``),U(t?4e3:!1)),E({queryKey:G.runs.changes(e??``),queryFn:({signal:t})=>te(e,{signal:t}),enabled:!!e,retry:!1,refetchInterval:!1,refetchOnWindowFocus:!0,staleTime:0})}function Ma(e,t){return E({queryKey:G.runs.file(e??``,t??``),queryFn:({signal:n})=>ye(e,t,{signal:n}),enabled:!!e&&t!==void 0,retry:!1})}function Na(e,t){return E({queryKey:[n(),`runs`,`file-link`,e,t],queryFn:({signal:n})=>nt(e,t,{signal:n}),enabled:t!==null,retry:!1})}function Pa(e,t){return E({queryKey:[n(),`runs`,`artifact`,e,t],queryFn:({signal:n})=>Xe(e,t,{signal:n}),enabled:t!==null,retry:!1})}function Fa(e,t){return E({queryKey:[n(),`runs`,`artifact-metadata`,e,t],queryFn:({signal:n})=>zt(e,t,{signal:n}),enabled:t!==null,retry:!1})}function Ia(e){return E({queryKey:[n(),`runs`,`artifacts`,e],queryFn:({signal:t})=>qt(e,{signal:t}),retry:!1,staleTime:0,refetchOnWindowFocus:!0})}function La(e,t=!1){return ya(e?`/api/v1/p/${n()}/runs/${encodeURIComponent(e)}/commits`:void 0,G.runs.commits(e??``),U(t?5e3:!1)),E({queryKey:G.runs.commits(e??``),queryFn:({signal:t})=>b(e,{signal:t}),enabled:!!e,retry:!1,refetchInterval:!1})}function Ra(e,t){return E({queryKey:G.runs.commit(e??``,t??``),queryFn:({signal:n})=>Vt(e,t,{signal:n}),enabled:!!e&&!!t,retry:!1})}function za(e,t=!0){return E({queryKey:G.runs.handoff(e??``),queryFn:({signal:t})=>bt(H(e),{signal:t}),enabled:!!e&&t})}function Ba(e,t,n,r){return E({queryKey:r===void 0?e===void 0?G.runs.handoff(t):[e,`runs`,`handoff`,t]:[`host`,r,e??`default`,`runs`,`handoff`,t],queryFn:({signal:n})=>bt(H(t,{projectId:e,hostId:r}),{signal:n}),enabled:n,staleTime:15e3})}function Va(e){return typeof e==`object`&&e?{projectId:e.projectId,hostId:e.hostId}:{projectId:e,hostId:void 0}}function Ha(e,t){let r=new Map;for(let t of e){let e=Va(t);r.set(JSON.stringify([e.hostId??null,e.projectId??null]),e)}let i=[...r.values()],a=dn({queries:i.map(({projectId:e,hostId:r})=>({queryKey:r===void 0?[e??n(),`automations`,`names`]:[`host`,r,e??n(),`automations`,`names`],queryFn:({signal:t})=>Rt({signal:t,archived:`include`,...e===void 0?{}:{projectId:e},...r===void 0?{}:{hostId:r}}),enabled:t,staleTime:6e4,retry:!1}))}),o=a.map(e=>e.data);return(0,z.useMemo)(()=>{let e=new Map;return o.forEach((t,n)=>{if(!t?.available)return;let r=i[n];for(let n of t.automations)e.set(JSON.stringify([r.hostId??null,r.projectId??null,n.id]),n.name)}),(t,n,r)=>e.get(JSON.stringify([r??null,t??null,n]))},[JSON.stringify([i,a.map(e=>e.dataUpdatedAt)])])}function Ua(e){let t=T();return B({mutationFn:t=>ce(e,t),retry:!1,onSuccess:()=>t.invalidateQueries({queryKey:G.runs.all})})}function Wa(e){let t=T();return B({mutationFn:t=>Re(e,t),onSuccess:()=>t.invalidateQueries({queryKey:G.runs.all})})}function Ga(e){let t=$(),n=e?.projectId,r=e?.cacheScope,i=e?.hostId,a=B({mutationFn:e=>ue(e,!0),onMutate:e=>t.patchRead(e,!0),onError:(e,t,n)=>n?.rollback(),onSuccess:(e,t,n)=>n?.settle(e)}),o=(0,z.useCallback)(e=>({...H(e,{projectId:n,cacheScope:r,hostId:i}),id:e}),[n,r,i]),s=(0,z.useCallback)(e=>({onSuccess:(t,n,r,i)=>e?.onSuccess?.(t,n.id,r,i),onError:(t,n,r,i)=>e?.onError?.(t,n.id,r,i),onSettled:(t,n,r,i,a)=>e?.onSettled?.(t,n,r.id,i,a)}),[]),{mutate:c,mutateAsync:l}=a,u=(0,z.useCallback)((e,t)=>c(o(e),s(t)),[c,o,s]),d=(0,z.useCallback)((e,t)=>l(o(e),s(t)),[l,o,s]);return{...a,variables:a.variables?.id,mutate:u,mutateAsync:d}}function Ka(e){let t=$(),n=e?.projectId,r=e?.cacheScope,i=e?.hostId;return B({mutationFn:e=>ue(H(e,{projectId:n,cacheScope:r,hostId:i}),!1),onMutate:e=>t.patchRead(()=>H(e,{projectId:n,cacheScope:r,hostId:i}),!1),onError:(e,t,n)=>n?.rollback(),onSuccess:(e,t,n)=>n?.settle(e)})}function qa(e){let t=$();return B({mutationFn:({id:t,pinned:n})=>oe(H(t,e),n),onError:e=>Tt(`Could not update pin. ${Ne(e)} Please retry.`,{tone:`danger`}),onMutate:()=>e??V(),onSuccess:(e,n,r)=>t.invalidateAfter(`runs`,r)})}function Ja(e,t,r){let i=$();return B({...r===void 0?{}:{mutationKey:zr(r,t??n(),e)},mutationFn:n=>Mt(H(e,{projectId:t,hostId:r}),n),onMutate:()=>V({projectId:t,hostId:r}),onSuccess:(e,t,n)=>i.invalidateAfter(`send`,n),onError:(e,t,n)=>{e instanceof m&&e.status===409&&n&&i.invalidateAfter(`send`,n)}})}function Ya(e,t,r){let i=$();return B({...r===void 0?{}:{mutationKey:zr(r,t??n(),e)},mutationFn:(n={})=>at(H(e,{projectId:t,hostId:r}),n),onMutate:()=>V({projectId:t,hostId:r}),onSuccess:(e,t,n)=>i.invalidateAfter(`continue`,n)})}function Xa(e){let t=T();return B({mutationFn:({msgId:t,message:n})=>At(e,t,n),onSuccess:()=>t.invalidateQueries({queryKey:G.runs.all})})}function Za(e){let t=T();return B({mutationFn:t=>Be(e,t),onSuccess:()=>t.invalidateQueries({queryKey:G.runs.all})})}function Qa(){return E({queryKey:G.workflows,queryFn:({signal:e})=>vt({signal:e})})}function $a(e){return E({queryKey:e?[e,`repo`]:G.repo,queryFn:({signal:t})=>et({signal:t},e)})}function eo(e){return E({queryKey:[e,`repo`],queryFn:({signal:t})=>et({signal:t},e)})}function to(){return E({queryKey:G.repoBranches,queryFn:({signal:e})=>Ht({signal:e})})}function no(){return E({queryKey:G.repoChanges,queryFn:({signal:e})=>Ae({signal:e}),retry:!1})}function ro(e){return E({queryKey:G.repoCommit(e??``),queryFn:({signal:t})=>p(e,{signal:t}),enabled:!!e,retry:!1})}function io(e,t=!0){return E({queryKey:e?[e,`config`]:G.config,queryFn:({signal:t})=>Gt({signal:t,...e?{projectId:e}:{}}),enabled:t})}function ao(){return E({queryKey:G.worktrees,queryFn:({signal:e})=>c({signal:e})})}function oo(e){return E({queryKey:[e,`worktrees`],queryFn:({signal:t})=>c({signal:t},e),staleTime:0})}function so(e,t=!0,n=!1){return E({queryKey:[V({projectId:e,boot:n}).cacheScope,`ui-state`],queryFn:({signal:t})=>ve({signal:t},e),select:e=>e.sidebarLimits===void 0?e:{...e,sidebarLimits:He(e.sidebarLimits)},enabled:t})}function co(e=!0,t){return so(t??n(),e)}function lo(){return E({queryKey:G.agentConfig,queryFn:({signal:e})=>St({signal:e})})}function uo(e){return E({queryKey:G.agentConfigFile(e??``),queryFn:({signal:t})=>ft(e,{signal:t}),enabled:e!==null})}function fo(){return E({queryKey:G.sessionContext,queryFn:({signal:e})=>ne({signal:e})})}function po(e,t,n=``){return E({queryKey:G.sessionContextPreview(e,t,n),queryFn:({signal:n})=>he({content:e,role:t},{signal:n}),placeholderData:Nt,staleTime:0,retry:!1})}function mo(){let e=T();return B({onMutate:()=>({fileKey:G.sessionContext}),mutationFn:e=>pe(e),onSuccess:(t,n,r)=>{r&&e.setQueryData(r.fileKey,t)}})}function ho(e){let t=T(),n=G.agentConfig,r=G.agentConfigFile(e);return B({mutationFn:t=>x(e,t),onSuccess:e=>{t.setQueryData(r,e),t.invalidateQueries({queryKey:n})}})}var go=L([`passing`,`failing`,`pending`]).nullable(),_o=A({kind:L([`issue`,`pr`]),number:R(),title:I(),author:I(),createdAt:I(),labels:P(I()),body:I().optional(),url:I(),comments:R(),assignees:P(I()).optional(),projectIds:P(I()).optional(),isDraft:F().optional(),additions:R().optional(),deletions:R().optional(),checks:go.optional()});j(`available`,[A({available:N(!0),item:_o.nullable(),labelColors:M(I(),I()).optional()}),A({available:N(!1),reason:I()})]),A({kind:L([`issue`,`pr`]),number:Xt().int().positive().safe()});var vo=A({id:I(),title:I(),url:I()});A({available:F(),reason:I().optional(),repo:I().optional(),syncedAt:I().optional(),issues:P(_o),prs:P(_o),labelColors:M(I(),I()).optional(),viewerLogin:I().optional(),projects:P(vo).optional(),projectsReason:I().optional(),projectsState:L([`refreshing`,`ready`,`unavailable`]).optional(),projectsGeneration:I().optional(),issuesTotal:R().int().nonnegative().optional(),prsTotal:R().int().nonnegative().optional(),issuesNextCursor:I().nullable().optional(),prsNextCursor:I().nullable().optional(),commentsDeferred:N(!0).optional()});var yo=I().min(1).max(2e3).optional();A({limit:I().optional(),refresh:I().optional(),issuesCursor:yo,prsCursor:yo,issuesDone:N(`1`).optional(),prsDone:N(`1`).optional()}).superRefine((e,t)=>{e.issuesDone&&e.issuesCursor&&t.addIssue({code:`custom`,message:`issuesDone and issuesCursor are exclusive`}),e.prsDone&&e.prsCursor&&t.addIssue({code:`custom`,message:`prsDone and prsCursor are exclusive`}),e.issuesDone&&e.prsDone&&t.addIssue({code:`custom`,message:`both sides are done; there is no page to ask for`})}),A({kind:L([`issue`,`pr`]),numbers:I().regex(/^[1-9]\d{0,15}(,[1-9]\d{0,15})*$/).refine(e=>{let t=e.split(`,`);return t.length<=100&&t.every(e=>Number.isSafeInteger(Number(e)))},{message:`at most 100 safe positive integers`}),refresh:N(`1`).optional()}),j(`available`,[A({available:N(!0),counts:M(R(),R().int().nonnegative())}),A({available:N(!1),reason:I()})]),j(`available`,[A({available:N(!0),checks:M(R(),go)}),A({available:N(!1),reason:I()})]),A({kind:L([`issue`,`pr`]),q:I().trim().min(1).max(256),limit:Xt().int().positive().max(50).optional()}),A({available:F(),projectsReason:I().optional(),reason:I().optional(),items:P(_o),truncated:F().optional(),labelColors:M(I(),I()).optional()});var bo=R().nullable();j(`available`,[A({available:N(!0),prs:M(R(),rt),issues:M(R(),rt),conflicts:P(R()).optional(),recheckAfterMs:bo}),A({available:N(!1),reason:I(),recheckAfterMs:bo})]);var xo=A({id:R(),author:I(),avatarUrl:I().optional(),createdAt:I(),body:I(),kind:L([`comment`,`review`]),reviewState:L([`approved`,`changes_requested`,`commented`,`dismissed`]).optional(),url:I()}),So=L([`committed`,`labeled`,`unlabeled`,`assigned`,`unassigned`,`merged`,`closed`,`reopened`,`head_ref_force_pushed`,`cross-referenced`,`renamed`]),Co=A({id:I(),kind:So,actor:I(),avatarUrl:I().optional(),createdAt:I(),url:I().optional(),sha:I().optional(),message:I().optional(),checks:go.optional(),label:A({name:I(),color:I().optional()}).optional(),subject:I().optional(),refNumber:R().optional(),refTitle:I().optional(),refIsPr:F().optional()});A({available:F(),reason:I().optional(),comments:P(xo),truncated:F().optional(),events:P(Co).optional(),detail:A({body:I(),additions:R().int().nonnegative().optional(),deletions:R().int().nonnegative().optional()}).optional()});var wo=L([`merge`,`squash`,`rebase`]),To=A({name:I(),state:L([`passing`,`failing`,`pending`,`unknown`]),required:F().nullable(),url:I().optional()}),Eo=A({number:R(),title:I(),url:I(),state:L([`open`,`closed`,`merged`]),isDraft:F(),headRef:I(),baseRef:I(),headSha:I(),mergeable:L([`mergeable`,`conflicting`,`unknown`]),reviewDecision:L([`approved`,`changes-requested`,`review-required`,`not-required`,`unknown`]),checks:P(To),methods:P(wo),defaultMethod:wo.nullable(),eligibility:L([`ready`,`blocked`,`pending`,`unauthorized`,`terminal`,`unknown`]),blockers:P(A({code:I(),message:I()})),canMerge:F(),canOverride:F()});j(`available`,[A({available:N(!0),mergeState:Eo}),A({available:N(!1),reason:I()})]),A({merged:N(!0),number:R(),url:I(),method:wo,mergeCommitSha:I().optional()});var Do=A({path:I(),previousPath:I().optional(),status:L([`added`,`modified`,`removed`,`renamed`,`copied`,`changed`]),additions:R(),deletions:R(),patch:I().optional(),patchUnavailableReason:L([`binary`,`too-large`,`not-provided`]).optional(),truncated:F().optional()});j(`available`,[A({available:N(!0),number:R(),headSha:I(),files:P(Do),additions:R(),deletions:R(),truncated:F(),reason:I().optional()}),A({available:N(!1),reason:I()})]),A({generation:I().uuid()}),j(`state`,[A({generation:I().uuid(),state:N(`ready`),projects:P(vo),membership:M(I(),P(I()))}),A({generation:I().uuid(),state:N(`unavailable`),reason:I()})]);function Oo(e){if(!e.available)return;let t=e.issuesNextCursor,n=e.prsNextCursor;if(!(t===void 0&&n===void 0)&&!(!t&&!n))return{...t?{issuesCursor:t}:{issuesDone:!0},...n?{prsCursor:n}:{prsDone:!0}}}function ko(e,t){return e?(t===`issues`?e.issuesNextCursor:e.prsNextCursor)==null:!1}function Ao(e,t,n){for(let r of e)t.has(r.number)||(t.add(r.number),n.push(r))}function jo(e){let t=e[0];if(!t)return;let n=e[e.length-1],r=[],i=[],a=new Set,o=new Set,s={};for(let t of e){Ao(t.issues,a,r),Ao(t.prs,o,i);for(let[e,n]of Object.entries(t.labelColors??{}))s[e]??=n}let c=e.find(e=>e.projects)?.projects,l=e.map(e=>e.projectsState),u=e.find(e=>e.projectsState===`unavailable`),d=l.includes(`refreshing`)?`refreshing`:u?`unavailable`:l.some(e=>e===`ready`)?`ready`:void 0,{projectsGeneration:f,projectsReason:p,...m}=t;return{...m,issues:r,prs:i,...Object.keys(s).length>0?{labelColors:s}:{},...c?{projects:c}:{},...d?{projectsState:d}:{},...d===`unavailable`&&u?.projectsReason?{projectsReason:u.projectsReason}:{},...`issuesNextCursor`in n?{issuesNextCursor:n.issuesNextCursor}:{},...`prsNextCursor`in n?{prsNextCursor:n.prsNextCursor}:{}}}var Mo=e=>e.map(e=>e.number).join(`,`);function No(e,t){let n=e[0];if(e.length>1&&n&&(Mo(n.issues)!==Mo(t.issues)||Mo(n.prs)!==Mo(t.prs)||n.issuesTotal!==t.issuesTotal||n.prsTotal!==t.prsTotal))return`refetch`;let r=t;if(n&&t.available&&t.projectsState===`refreshing`&&n.repo===t.repo){let e=new Map(n.issues.map(e=>[e.number,e.projectIds]));r={...t,issues:t.issues.map(t=>{let n=e.get(t.number);return t.projectIds===void 0&&n!==void 0?{...t,projectIds:n}:t})}}return[r,...e.slice(1)]}var Po=class extends Error{};function Fo(e,t,n){return{queryKey:e,initialPageParam:{},queryFn:async({pageParam:e,signal:r})=>{let i=await C({limit:t,...e,...n?{projectId:n}:{}},{signal:r});if(!i.available&&Object.keys(e).length>0)throw new Po(i.reason??`GitHub is unavailable.`);return i},getNextPageParam:e=>Oo(e),retry:(e,t)=>!(t instanceof Po)&&!(t instanceof m&&t.status>=400&&t.status<500)&&e<1,staleTime:6e4,refetchOnWindowFocus:!0}}function Io(e=50,t=!0){let r=T(),i=G.githubPages(e),a=G.githubPagesHead(e);ya(`/api/v1/p/${n()}/github?limit=${e}`,a,U(t?6e4:!1));let o=se({...Fo(i,e),enabled:t,refetchInterval:!1,refetchIntervalInBackground:!1}),s=E({queryKey:a,queryFn:({signal:t})=>C({limit:e},{signal:t}),enabled:!1,staleTime:1/0}),{refetch:c}=o;(0,z.useEffect)(()=>{if(!s.data)return;let e=r.getQueryData(i);if(!e||e.pages.length===0)return;let t=No(e.pages,s.data);t===`refetch`?c():r.setQueryData(i,{...e,pages:t})},[r,s.dataUpdatedAt,c]);let l=(o.data?.pages??[]).flatMap(e=>e.projectsState===`refreshing`&&e.projectsGeneration?[e.projectsGeneration]:[]),u=dn({queries:l.map(e=>({queryKey:[...i,`projects`,e],queryFn:({signal:t})=>we(e,{signal:t}),enabled:t,staleTime:1/0,retry:!1}))});return(0,z.useEffect)(()=>{u.forEach((e,t)=>{let n=l[t];!n||!e.data&&!e.error||r.setQueryData(i,t=>{if(!t)return t;let r=!1,i=t.pages.map(t=>{if(t.projectsGeneration!==n||t.projectsState!==`refreshing`)return t;let i=e.data;return i?.generation&&i.generation!==n?t:(r=!0,i?.state===`ready`?{...t,projectsState:`ready`,projects:i.projects,issues:t.issues.map(e=>({...e,projectIds:i.membership?.[e.number]??[]}))}:{...t,projectsState:`unavailable`,projectsReason:i?.reason??`Project boards unavailable. Refresh to try again.`})});return r?{...t,pages:i}:t})})},[r,u.map((e,t)=>e.data||e.error?l[t]:``).join(`,`)]),{pages:o,data:(0,z.useMemo)(()=>jo(o.data?.pages??[]),[o.data])}}function Lo(e,t=50,n=!0){let r=se({...Fo([e,`github`,`pages`,t],t,e),enabled:n});return{pages:r,data:(0,z.useMemo)(()=>jo(r.data?.pages??[]),[r.data])}}function Ro(e,t,n=!0){let r=dn({queries:t.filter(e=>e.length>0).map(t=>({queryKey:G.githubCommentCounts(e,t),queryFn:({signal:n})=>jt(e,t,{},{signal:n}),enabled:n,staleTime:6e4}))});return(0,z.useMemo)(()=>{let e={};for(let t of r)t.data?.available&&Object.assign(e,t.data.counts);return e},[r.map(e=>e.dataUpdatedAt).join(`,`)])}function zo(e,t,n,r=!0){return E({queryKey:[e,`github`,`search`,t,n],queryFn:({signal:r})=>ct(t,n,{projectId:e},{signal:r}),enabled:r&&n.trim()!==``,staleTime:6e4})}function Bo(e,t=!0){return E({queryKey:G.githubChecks(e),queryFn:({signal:t})=>de(e,{signal:t}),enabled:t&&e.length>0,staleTime:6e4})}function Vo(e,t,n=!0){return E({queryKey:G.githubSearch(e,t),queryFn:({signal:n})=>ct(e,t,{},{signal:n}),enabled:n&&t.trim()!==``,staleTime:6e4})}var Ho=100;function Uo(e){return[...e].sort((e,t)=>t-e).slice(0,Ho).sort((e,t)=>e-t)}function Wo(){let e=Ze(),t=oa();return e.projectId??t.data?.bootProject??void 0}function Go(e,t){let n=t===void 0?{}:{hostId:t};for(let[t,r]of Object.entries(e)){for(let[e,i]of Object.entries(r.prs))_i(Ci({...n,projectId:t,kind:`PR`,number:Number(e)}),i);for(let[e,i]of Object.entries(r.issues))_i(Ci({...n,projectId:t,kind:`Issue`,number:Number(e)}),i)}}var Ko=5*6e4;function qo(e){return e?e.recheckAfterMs:Ko}function Jo(e,t=!0){let n=(0,z.useMemo)(()=>{let t=new Map;for(let n of e){let e=n.hostId===void 0?n.projectId:`host:${n.hostId}\u0000${n.projectId}`,r=t.get(e)??{...n.hostId===void 0?{}:{hostId:n.hostId},projectId:n.projectId,prs:new Set,issues:new Set};r[n.kind===`PR`?`prs`:`issues`].add(n.number),t.set(e,r)}return[...t.values()].map(e=>({...e.hostId===void 0?{}:{hostId:e.hostId},projectId:e.projectId,prs:Uo(e.prs),issues:Uo(e.issues)}))},[e.map(Ci).sort().join(`|`)]),r=dn({queries:n.map(e=>({queryKey:G.githubRefStatus(e.projectId,e.prs,e.issues,e.hostId),queryFn:({signal:t})=>a(e.projectId,{prs:e.prs,issues:e.issues},{signal:t,...e.hostId===void 0?{}:{hostId:e.hostId}}),enabled:t&&e.prs.length+e.issues.length>0,staleTime:e=>qo(e.state.data)??1/0,refetchInterval:e.hostId===void 0?!1:e=>U(t&&!fn()?qo(e.state.data)??!1:!1),refetchOnWindowFocus:!0}))}),i=T(),o=JSON.stringify(n.flatMap((e,t)=>e.hostId===void 0?[{projectId:e.projectId,prs:e.prs,issues:e.issues,interval:qo(r[t]?.data)??!1}]:[]));(0,z.useEffect)(()=>{if(!t||fn())return;let e=!0,n=JSON.parse(o).filter(e=>e.interval!==!1).map(t=>{let n=new URLSearchParams;t.prs.length&&n.set(`prs`,t.prs.join(`,`)),t.issues.length&&n.set(`issues`,t.issues.join(`,`));let r=G.githubRefStatus(t.projectId,t.prs,t.issues);return va({path:`/api/v1/p/${t.projectId}/github/ref-status?${n}`,intervalMs:t.interval},(t,n)=>{n||i.cancelQueries({queryKey:r,exact:!0}).then(()=>{e&&i.setQueryData(r,t)})})});return()=>{e=!1;for(let e of n)e()}},[t,o,i]);let s=(0,z.useMemo)(()=>Oi(n,r),[n,r.map(e=>`${e.dataUpdatedAt}:${e.status}`).join(`,`)]);return(0,z.useCallback)(e=>{let t=Ci(e),n=s.get(t);if(n)return n;let r=J.get(t);return{state:`idle`,...r?{status:r}:{},...Y.has(t)?{conflicting:!0}:{}}},[s])}function Yo(e,t,n=!0){return E({queryKey:G.githubComments(e,t),queryFn:({signal:n})=>le(e,t,{},{signal:n}),enabled:n,staleTime:6e4})}function Xo(e,t,n=!0){return E({queryKey:G.githubItem(e,t),queryFn:({signal:n})=>We(e,t,{},{signal:n}),enabled:n,staleTime:6e4})}function Zo(e){return E({queryKey:G.githubPrChanges(e??0),queryFn:({signal:t})=>Ve(e,{},{signal:t}),enabled:e!==void 0,staleTime:6e4,retry:!1})}export{Ma as $,q as $t,ao as A,Qi as At,Ga as B,ki as Bt,to as C,fn as Cn,ta as Ct,po as D,dn as Dn,Bi as Dt,fo as E,B as En,Zi as Et,Ha as F,la as Ft,qa as G,ii as Gt,Ua as H,di as Ht,Ya as I,ca as It,Oa as J,ei as Jt,ka as K,$r as Kt,Ea as L,Ni as Lt,Pa as M,Xi as Mt,Fa as N,Vi as Nt,co as O,an as On,Ki as Ot,Ia as P,Gi as Pt,Aa as Q,Qr as Qt,Xa as R,Ai as Rt,$a as S,U as Sn,Pi as St,ro as T,H as Tn,zi as Tt,xa as U,si as Ut,Ka as V,li as Vt,Wa as W,ti as Wt,Ra as X,ai as Xt,ja as Y,oi as Yt,La as Z,ni as Zt,eo as _,pn as _n,ia as _t,Xo as a,K as an,Ja as at,ho as b,_n as bn,sa as bt,Vo as c,Cr as cn,$ as ct,Wo as d,An as dn,na as dt,Ur as en,za as et,Jo as f,kn as fn,ea as ft,io as g,Tn as gn,Ri as gt,uo as h,Dn as hn,Wi as ht,Yo as i,G as in,wa as it,Ca as j,qi as jt,Qa as k,rn as kn,Ii as kt,Lo as l,jn as ln,$i as lt,lo as m,On as mn,ra as mt,Bo as n,Br as nn,Sa as nt,Io as o,W as on,Ba as ot,ko as p,Mn as pn,Yi as pt,Za as q,ri as qt,Ro as r,zr as rn,Ta as rt,Zo as s,wr as sn,va as st,Go as t,Vr as tn,Da as tt,zo as u,En as un,ua as ut,so as v,mn as vn,oa as vt,no as w,V as wn,Fi as wt,mo as x,vn as xn,Li as xt,oo as y,hn as yn,aa as yt,Na as z,ji as zt};
@@ -1 +0,0 @@
1
- import{Di as e}from"./toaster-Dglox5F-.js";import{D as t,c as n}from"./task-groups-BapM4YcT.js";var r=[`done`,`failed`,`cancelled`];function i(e){return r.includes(e)}function a(n){return!e(n)&&i(n.status)&&!t(n)}function o(e){return e.reduce((e,r)=>n(r)||!t(r)?e:e+1,0)}function s(e){return e.status===`failed`?`danger`:`success`}export{o as n,s as r,a as t};
@@ -1 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{Ht as r,Vt as i,f as a}from"./queries-DHjNE2es.js";import{Di as o,Lr as s,yi as c}from"./toaster-Dglox5F-.js";import{n as l}from"./chunk-KS7C4IRE-BdLLx37K.js";import{o as u,s as d}from"./dist-CCX8mhHc.js";import{F as f,I as p,N as m,P as h,U as g,_,ct as v,g as y,h as b,m as x,p as S}from"./design-icons-QbNMZniQ.js";import{n as C,r as w,t as T}from"./popover-BQolmvDR.js";import"./attention-CFW302LY.js";import{E,b as D,c as O,f as k,i as A,l as ee,m as j,o as M,s as te,t as ne}from"./task-groups-BapM4YcT.js";function re(e){if(e.workflow===`(planned)`||e.workflow===`(inbox)`){let t=(e.steps??[]).find(e=>e.kind===`agent`);if(t?.name)return t.name}return e.workflow}var N=e(t(),1),P=[{value:`all`,label:`All`},{value:`direct`,label:`Direct`},{value:`automations`,label:`Automations`}];function ie(e){return e?P:P.filter(e=>e.value!==`automations`)}function ae(e,t){return e===`automations`&&!t?`all`:e}function oe(e){return e===`direct`||e===`automations`?e:`all`}function se(e,t){return t===`all`||s(e)===(t===`automations`)}function ce(e){return e===`all`?void 0:e===`automations`}function F(e,t){let n={all:0,direct:0,automations:0};for(let r of e)O(r)||r.archived!==(t===`archived`)||(n.all+=1,s(r)?n.automations+=1:n.direct+=1);return n}function le(e,t,n,r,i){let a=ee(e).archived,o=a>=200;if(n===`all`)return i??(o?`200+`:a);let s=F(t,`archived`)[n];return o&&r!==!1?`${s}+`:s}function ue(e){return e.rows.map(e=>e.run)}function de(e,t){switch(e){case`Needs you`:return`pending`;case`Working`:return`running`;case`Archived`:return`neutral`;case`Finished`:return t.some(e=>c(e).bucket===`error`)?`danger`:`success`}}function fe(e,t,n){return te(e,t,k(n))}var I=(e,t,n)=>n===void 0?`\u0000${e}\u0000${t}`:`${n}\u0000${e}\u0000${t}`,pe=(e,t)=>t===void 0?`\u0000${e}`:`${t}\u0000${e}`;function me(e){let t=new Map;for(let n of e){if(n.archived||n.status!==`queued`)continue;let e=pe(n.projectId,n.hostId),r=t.get(e);r||(r={projectId:n.projectId,hostId:n.hostId,runs:[]},t.set(e,r)),r.runs.push(n)}let n=new Map;for(let{projectId:e,hostId:r,runs:i}of t.values())for(let[t,a]of k(i))n.set(I(e,t,r),a);return n}function he(e){let t=Array.from({length:20},()=>[]);for(let n of e){let e=D(n.run);t[(n.run.pinned?0:10)+e].push(n)}let n=[];for(let e=0;e<t.length;e+=1){let r=t[e];if(r.length===0)continue;let i=e%10;(i===3||i===4)&&r.length>1&&r.sort((e,t)=>M(e.run,t.run,`active`));for(let e of r)n.push(e)}return n}function ge(e,t){let n=t===`archived`,r=[],i,a=!0;for(let t of e)t.run.archived!==n||O(t.run)||(a&&i!==void 0&&t.run.createdAt>i&&(a=!1),i=t.run.createdAt,r.push(t));return n||!a?r.sort((e,n)=>M(e.run,n.run,t)):he(r)}function _e(e,t,n){let r=ge(e,t),i=me(n),a=new Map;for(let e of r){let n=A(e.run,t),r={kind:`run`,run:e,queuePosition:e.run.status===`queued`?i.get(I(e.run.projectId,e.run.id,e.hostId))??null:null},o=a.get(n);o?o.push(r):a.set(n,[r])}return ne.filter(e=>a.has(e)).map(e=>({label:e,rows:a.get(e)}))}function L(e){return[e.run]}function ve(e){let t=/\/(\d+)\/?$/.exec(e.trim()),n=t?Number(t[1]):NaN;return Number.isInteger(n)&&n>0?n:null}function ye(e){let t=new Set;for(let n of[e.pullRequestUrl,e.referencedPullRequestUrl,e.referencedIssueUrl]){let e=n?ve(n):null;e!==null&&t.add(e)}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);for(let n of e.pullRequests??[])t.add(n.number);return[...t]}var be=[{id:`title`,kind:`text`,scopes:[`stored`],source:`summary`,texts:e=>[e.title]},{id:`titleSummary`,kind:`text`,scopes:[`stored`],source:`summary`,texts:e=>[e.titleSummary]},{id:`displayTitle`,kind:`text`,scopes:[`shown`],source:`reader`,texts:(e,t)=>[t.displayTitle]},{id:`branch`,kind:`text`,scopes:[`stored`,`shown`],source:`summary`,texts:e=>[e.branch]},{id:`workflow`,kind:`text`,scopes:[`stored`,`shown`],source:`summary`,texts:e=>[e.workflow]},{id:`workflowLabel`,kind:`text`,scopes:[`stored`,`shown`],source:`summary`,texts:e=>[e.workflowLabel]},{id:`automation`,kind:`text`,scopes:[`stored`,`shown`],source:`reader`,texts:(e,t)=>[t.automation],universe:e=>[...e.automationNames?.values()??[]]},{id:`projectName`,kind:`text`,scopes:[`shown`],source:`reader`,texts:(e,t)=>[t.projectName]},{id:`tags`,kind:`text`,scopes:[`shown`],source:`reader`,texts:(e,t)=>t.tags??[]},{id:`id`,kind:`identifier`,scopes:[`stored`],source:`summary`,texts:e=>[e.id]},{id:`urls`,kind:`link`,scopes:[`stored`],source:`summary`,texts:e=>[e.pullRequestUrl,e.referencedPullRequestUrl,e.referencedIssueUrl,...(e.pullRequests??[]).map(e=>e.url)]},{id:`heldReferences`,kind:`reference`,scopes:[`stored`],source:`summary`,numbers:ye},{id:`shownReferences`,kind:`reference`,scopes:[`shown`],source:`reader`,numbers:(e,t)=>t.references?.()??[]}];function xe(e){return e.trim().toLowerCase().split(/\s+/).filter(e=>e!==``)}function Se(e,t){return t&&e.automationId!==void 0?t.get(e.automationId)??e.automationId:void 0}function Ce(e,t){let n=t.scope??`stored`,r=t.scope===`shown`?t.extras:{automation:Se(e,t.automationNames)},i=[],a=[],o=[],s={text:i,identifier:a,link:o},c=[];for(let t of be)if(t.scopes.includes(n)){if(t.kind===`reference`){c.push(()=>t.numbers(e,r));continue}for(let n of t.texts(e,r))typeof n==`string`&&s[t.kind].push(n.toLowerCase())}let l;return{prose:i,ids:a,links:o,references:()=>l??=new Set(c.flatMap(e=>e().map(String)))}}function R(e,t,n={}){let r=xe(t);if(r.length===0)return!1;let{prose:i,ids:a,links:o,references:s}=Ce(e,n);return r.every(e=>{if(i.some(t=>t.includes(e)))return!0;let t=e.replace(/^#/,``);return/^\d+$/.test(t)?s().has(String(Number(t)))||a.some(e=>e.startsWith(t)):a.some(t=>t.includes(e))||o.some(t=>t.includes(e))})}var we=new Set([`running`,`waiting`]);function z(e){return e?e>=1024**3?`${(e/1024**3).toFixed(1)} GB`:e>=1024**2?`${Math.round(e/1024**2)} MB`:`${Math.round(e/1024)} kB`:``}function Te(e){return e===void 0?``:`$${e>=10?e.toFixed(0):e.toFixed(2)}`}function Ee(e,t=new Date){if(!o(e))return;let n=new Date(e.autoResumeAt);if(!Number.isFinite(n.getTime()))return;let r=n.toDateString()===t.toDateString(),i=new Intl.DateTimeFormat(void 0,{hour:`numeric`,minute:`2-digit`}).format(n);return{label:r?i:`${new Intl.DateTimeFormat(void 0,{month:`short`,day:`numeric`}).format(n)} ${i}`,title:`Resumes automatically at ${new Intl.DateTimeFormat(void 0,{dateStyle:`medium`,timeStyle:`long`}).format(n)}`}}function De(e){return e.steps?re({workflow:e.workflow,steps:e.steps}):e.workflowLabel??e.workflow}function Oe(e,t,n=()=>``){let r=e.filter(e=>!O(e));return t.trim()?r.filter(e=>R(e,t,{scope:`shown`,extras:{displayTitle:j(e),automation:n(e),references:()=>B(e)}})):[...r]}function B(e){return K(e).map(e=>e.number)}function V(e,t){return e.filter(e=>E(e,t)).length}function ke(e){return V(e)}function Ae(e){return H(e)[0]??e.pullRequests?.find(e=>e.url)?.url}function H(e){let t=[];return e.pullRequestUrl&&t.push(e.pullRequestUrl),!(e.markerRefs?.issue!==void 0&&e.markerRefs?.pr===void 0)&&e.referencedPullRequestUrl&&t.push(e.referencedPullRequestUrl),t}function U(e,t){if(e.referencedIssueUrl)return e.referencedIssueUrl;let n=e.issueNumber??e.markerRefs?.issue;if(!(!n||!t))return`${t}/issues/${n}`}function W(e){let t=`${e.kind}#${e.number}`;if(!e.url)return`${t}@project:${e.projectId??`default`}`;try{let n=new URL(e.url),r=n.pathname.split(`/`).filter(Boolean).slice(0,2).join(`/`);return`${t}@${n.host.toLowerCase()}/${r.toLowerCase()}`}catch{return`${t}@${e.url}`}}var G=new WeakMap;function K(e,t,n=e.projectId){let r=G.get(e);if(r&&r.repoBase===t&&r.projectId===n)return r.refs;let i=je(e,t,n);return G.set(e,{repoBase:t,projectId:n,refs:i}),i}function je(e,t,n){let r=H(e),i=e.markerRefs?.pr,a=[...i===void 0||[...r,...(e.pullRequests??[]).flatMap(e=>e.url?[e.url]:[])].some(e=>J(e)===String(i))?[]:[{kind:`PR`,number:i}],...r.map(e=>({kind:`PR`,url:e})),{kind:`PR`,number:e.prNumber},...(e.pullRequests??[]).map(e=>({kind:`PR`,number:e.number,...e.url?{url:e.url}:{},authoritative:!0})),{kind:`Issue`,url:U(e,t)},{kind:`Issue`,number:e.issueNumber}],o=new Set,s=[];for(let e of a){let r=e.url?Number(J(e.url)):e.number;if(!r||!Number.isInteger(r)||!e.url&&!e.authoritative&&s.some(t=>t.url&&t.kind===e.kind&&t.number===r))continue;let i=e.url??Me(e.kind,r,t),a={kind:e.kind,number:r,...i?{url:i}:n===void 0?{}:{projectId:n}},c=W(a);o.has(c)||(o.add(c),s.push(a))}return s}function Me(e,t,n){if(n)return`${n}/${e===`PR`?`pull`:`issues`}/${t}`}function Ne(e){return K(e)[0]}function q(e,t){if(!e.url)return!0;if(!t)return!1;let n=Ie(t);return n!==void 0&&Ie(e.url)===n}var Pe=new WeakMap;function Fe(e,t,n=e.projectId){let r=Pe.get(e);if(r&&r.repoBase===t&&r.projectId===n)return r.refs;let i=K(e,t,n).filter(e=>q(e,t));return Pe.set(e,{repoBase:t,projectId:n,refs:i}),i}function Ie(e){try{let t=new URL(e),[n,r]=t.pathname.split(`/`).filter(Boolean);return n&&r?`${t.host}/${n}/${r}`.toLowerCase():void 0}catch{return}}function Le(e,t){let n=[];for(let r of K(e,t)){if(!q(r,t))continue;let e=r.kind===`PR`?`pr`:`issue`;n.some(t=>t.kind===e&&t.number===r.number)||n.push({kind:e,number:r.number})}return n}function Re(e,t,n,r){if(q(n,r))return`/p/${e}/tasks/${t}/${n.kind===`PR`?`pr`:`issue`}/${n.number}`}function J(e){return/\/(\d+)\/?(?:[?#].*)?$/.exec(e)?.[1]??null}function ze(e,t){let n=we.has(e.status)?t:void 0;if(n)return{cpu:{text:`${n.cpuPct.toFixed(0)}%`,kind:`live`},mem:{text:z(n.rssBytes),kind:`live`}};let r=z(e.peakRssBytes);return{cpu:{text:``,kind:`none`},mem:r?{text:`peak ${r}`,kind:`peak`,title:`peak — run finished${e.peakProcCount?` · ${e.peakProcCount} procs`:``}`}:{text:``,kind:`none`}}}function Be(e,t,n=!1){return n||e.filter(e=>!t(e.label)).some(e=>e.rows.flatMap(L).some(e=>Ne(e)!==void 0))}var Y=n(),Ve=(0,N.createContext)(null);function He({children:e}){let[t,n]=(0,N.useState)(()=>new Map),r=(0,N.useCallback)((e,t)=>{n(n=>{let r=new Map(n);return r.set(e,t),r})},[]),i=(0,N.useCallback)(e=>{n(t=>{if(!t.has(e))return t;let n=new Map(t);return n.delete(e),n})},[]),o=a((0,N.useMemo)(()=>[...t.values()].flat(),[t])),s=(0,N.useMemo)(()=>({publish:r,retract:i,lookup:o}),[r,i,o]);return(0,Y.jsx)(Ve.Provider,{value:s,children:e})}var X=(0,N.createContext)(null);function Ue({projectId:e,repoBase:t,requests:n,children:r}){let i=(0,N.useContext)(Ve),o=(0,N.useContext)(X),s=(0,N.useId)();(0,N.useEffect)(()=>{if(i)return i.publish(s,n),()=>i.retract(s)},[i,s,(0,N.useMemo)(()=>n.map(e=>`${e.hostId??``}:${e.projectId} ${e.kind}#${e.number}`).sort().join(`|`),[n])]);let c=a(i?We:n),l=i?.lookup??c,u=t??(o&&o.projectId===e?o.repoBase:void 0),d=(0,N.useMemo)(()=>({lookup:l,projectId:e,repoBase:u}),[l,e,u]);return(0,Y.jsx)(X.Provider,{value:d,children:r})}var We=[];function Z(e,t,n,r){let i=(0,N.useContext)(X),a=n??i?.projectId;return!i||!a||t===void 0?qe:i.lookup({...r===void 0?{}:{hostId:r},projectId:a,kind:e,number:t})}function Ge(e,t,n){let r=(0,N.useContext)(X),i=t??r?.projectId;return!r||!i?[]:e.filter(e=>r.lookup({...n===void 0?{}:{hostId:n},projectId:i,kind:`PR`,number:e}).conflicting===!0)}function Ke(){let e=(0,N.useContext)(X);return{projectId:e?.projectId,repoBase:e?.repoBase}}var qe=Object.freeze({state:`idle`}),Je={success:`border-success/40 text-semantic-green`,danger:`border-danger/40 text-semantic-red`,accent:`border-accent-strong/35 text-accent-text`,merged:`border-merged-strong/35 text-merged-text`,info:`border-info/40 text-semantic-info`,neutral:`border-border text-muted-foreground`,pending:`border-pending-strong/45 text-semantic-amber`,conflict:`border-conflict/45 text-semantic-conflict`},Ye={success:`text-semantic-green`,danger:`text-semantic-red`,accent:`text-merged-text`,merged:`text-merged-text`,info:`text-semantic-info`,neutral:`text-soft-foreground`,pending:`text-semantic-amber`,conflict:`text-semantic-conflict`},Xe={success:`hover:bg-success/10`,danger:`hover:bg-danger/10`,accent:`hover:bg-accent-strong/10`,merged:`hover:bg-merged-strong/10`,info:`hover:bg-info/10`,neutral:`hover:bg-muted`,pending:`hover:bg-pending-strong/10`,conflict:`hover:bg-conflict/10`},Ze={draft:f,"review-required":p,"changes-requested":g,"checks-pending":null,"checks-failing":_,ready:S,merged:m,closed:h,open:x,completed:S,"not-planned":y};function Q(e){return e===`PR`?`pr-chip`:`issue-chip`}function $(e){return e?{"data-conflicting":`true`}:{}}function Qe(e,t,n,r){return!n||r!==void 0&&q({kind:e,number:t??0,url:n},r)}function $e(e,t,n){return e===`PR`&&(t??n)===!0}function et({plain:e,inert:t,conflicting:n,className:r,tone:i}){return e?u(`inline-flex items-center gap-1 rounded-[2px] text-inherit`,n&&`text-conflict font-medium`,!t&&`group/reference focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-link-foreground`,r):u(`inline-flex h-[22px] items-center gap-1 rounded-md border px-1.5 font-mono text-[12px] font-normal`,Je[i],r)}function tt(e,t,n,r){return n&&!r?t?`${e===`PR`?`PR `:``}#${t}`:e:t?`${!r&&e===`Issue`?`Issue `:``}#${t}`:e}function nt(e){return e===`PR`?`pull request`:`issue`}function rt(e,t,n,r){return`Open the ${e}${t?` #${t}`:``} for ${n}${r?` — ${r.label}`:``}`}function it(e,t){return e&&t?Ye[t.tone]:void 0}function at(e,t){return!e&&(!t||!d(t))}function ot({conflicting:e,presentation:t,status:n,plain:r,compact:i,inert:a,kind:o,label:s,glyphClass:c}){return(0,Y.jsxs)(Y.Fragment,{children:[e?(0,Y.jsx)(v,{className:u(`size-2.5 shrink-0`,c),"aria-hidden":`true`}):(0,Y.jsx)(yt,{status:t?n:void 0,className:r?u(`size-2.5`,c):void 0}),r&&i?o===`PR`?(0,Y.jsx)(p,{"data-slot":`reference-kind`,className:`size-2.5 shrink-0`,"aria-hidden":`true`}):(0,Y.jsx)(x,{"data-slot":`reference-kind`,className:`size-2.5 shrink-0`,"aria-hidden":`true`}):null,r?(0,Y.jsx)(`span`,{className:a?void 0:`underline-offset-2 group-hover/reference:underline group-focus-visible/reference:underline`,children:s}):s]})}function st({kind:e,status:t,conflicting:n,chipClass:r,body:i}){return(0,Y.jsx)(`span`,{"data-slot":Q(e),"data-status":t,"data-inert":`true`,...$(n),className:r,children:i})}function ct({kind:e,number:t,tooltip:n,url:r}){return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`span`,{className:`block font-medium`,children:[e===`PR`?`Pull request`:`Issue`,t?` #${t}`:``,` · `,n.headline]}),(0,Y.jsx)(`span`,{className:`block`,children:n.detail}),n.also?(0,Y.jsx)(`span`,{className:`block text-muted-foreground`,children:n.also}):null,r&&d(r)?(0,Y.jsx)(`span`,{className:`block text-muted-foreground`,children:r.replace(/^https?:\/\//,``)}):null]})}function lt({reference:e,taskTitle:t,status:n,conflicting:a,conflictAction:o,projectId:s,hostId:c,repoBase:l,to:d,fullPage:f=!1,className:p,compact:m=!1,plain:h=!1,inert:g=!1}){let{kind:_,number:v,url:y}=e,b=Ke(),x=Z(_,Qe(_,v,y,l??b.repoBase)?v:void 0,s,c),S=n??x.status,C=r(S),w=$e(_,a,x.conflicting),T=w?i:C,E=T?.tone??`accent`,D=et({plain:h,inert:g,conflicting:w,className:p,tone:E}),O=gt(x,T,w?C:void 0),k=tt(_,v,h,m),A=nt(_),ee=rt(A,v,t,T),j=(0,Y.jsx)(ot,{conflicting:w,presentation:T,status:S,plain:h,compact:m,inert:g,kind:_,label:k,glyphClass:it(h,T)});if(g)return(0,Y.jsx)(st,{kind:_,status:S,conflicting:w,chipClass:D,body:j});let M=at(d,y)?(0,Y.jsx)(`span`,{"data-slot":Q(_),"data-status":S,...$(w),"aria-label":T?`${A} ${k} — ${T.label}`:void 0,className:D,children:j}):(0,Y.jsx)(ut,{to:d,fullPage:f,url:y,"data-slot":Q(_),"data-status":S,...$(w),title:O?void 0:y,"aria-label":ee,className:h?D:u(D,Xe[E]),children:j});return O?(0,Y.jsx)(ht,{chip:M,action:w?o:void 0,state:x.state,children:(0,Y.jsx)(ct,{kind:_,number:v,tooltip:O,url:y})}):M}function ut({to:e,fullPage:t,url:n,children:r,...i}){return e?t?(0,Y.jsx)(`a`,{href:e,...i,children:r}):(0,Y.jsx)(l,{to:e,...i,children:r}):(0,Y.jsx)(`a`,{href:n,target:`_blank`,rel:`noopener noreferrer`,...i,children:r})}var dt=(0,N.createContext)(()=>{});function ft(){return(0,N.useContext)(dt)}var pt=150,mt=120;function ht({chip:e,action:t,state:n,children:r}){let[i,a]=(0,N.useState)(!1),o=(0,N.useRef)(null),s=(0,N.useRef)(null),c=(0,N.useRef)(void 0),l=(0,N.useCallback)((e,t)=>{clearTimeout(c.current),c.current=setTimeout(()=>a(e),t)},[]),u=(0,N.useCallback)(()=>{clearTimeout(c.current),a(!1)},[]);(0,N.useEffect)(()=>()=>clearTimeout(c.current),[]);let d=e=>e instanceof Node&&(s.current?.contains(e)||o.current?.contains(e));return(0,Y.jsxs)(T,{open:i,onOpenChange:e=>e?a(!0):u(),children:[(0,Y.jsx)(C,{asChild:!0,ref:o,onPointerEnter:e=>{e.pointerType!==`touch`&&l(!0,pt)},onPointerLeave:e=>{e.pointerType!==`touch`&&l(!1,mt)},onFocus:()=>a(!0),onBlur:e=>{d(e.relatedTarget)||u()},onKeyDown:e=>{if(e.key===`Escape`)return u();if(e.key!==`Tab`||e.shiftKey||!t)return;let n=s.current?.querySelector(`button:not([disabled]), [href], input, select, textarea, [tabindex]:not([tabindex="-1"])`);n&&(e.preventDefault(),n.focus())},...t?{"aria-haspopup":`dialog`,"aria-expanded":i}:{},children:e}),(0,Y.jsxs)(w,{ref:s,side:`top`,role:t?`dialog`:`tooltip`,"data-slot":`reference-status-card`,"data-tooltip-state":n,className:`w-64 space-y-2 p-3 text-xs`,onOpenAutoFocus:e=>e.preventDefault(),onCloseAutoFocus:e=>{e.preventDefault(),d(document.activeElement)&&o.current?.focus()},onPointerEnter:()=>clearTimeout(c.current),onPointerLeave:e=>{e.pointerType!==`touch`&&l(!1,mt)},children:[(0,Y.jsx)(`div`,{className:`space-y-0.5`,children:r}),t?(0,Y.jsx)(dt.Provider,{value:u,children:t}):null]})]})}function gt(e,t,n){if(t){let{label:r,hint:i}=t,a=n?`also ${_t(n.label)} — ${n.hint}`:void 0;return e.state===`unavailable`?{headline:r,detail:`last known — GitHub is unreachable${e.reason?` (${e.reason})`:``}`,...a?{also:a}:{}}:{headline:r,detail:i,...a?{also:a}:{}}}switch(e.state){case`loading`:return{headline:`Checking GitHub…`,detail:`the status of this reference is on its way`};case`unavailable`:return{headline:`Status unavailable`,detail:e.reason??`GitHub could not be reached — the chip says nothing rather than guessing`};case`unknown`:return{headline:`Not found on this repository`,detail:`GitHub has no such number here — the reference may point at another repo`};default:return null}}function _t(e){return e.charAt(0).toLowerCase()+e.slice(1)}function vt({kind:e,number:t,className:n}){let a=Z(e,t),o=r(a.status),s=e===`PR`&&a.conflicting===!0,c=s?i:o;if(!c)return null;let l=u(`size-2.5`,Ye[c.tone]);return(0,Y.jsx)(`span`,{"data-slot":`reference-status-glyph`,"data-status":a.status,...s?{"data-conflicting":`true`}:{},"aria-hidden":`true`,className:u(`inline-flex items-center`,n),children:s?(0,Y.jsx)(v,{className:u(`shrink-0`,l),"aria-hidden":`true`}):(0,Y.jsx)(yt,{status:a.status,className:l})})}function yt({status:e,className:t}){if(!e)return null;if(e===`checks-pending`)return(0,Y.jsx)(b,{"data-slot":`status-dot`,"data-tone":`pending`,className:u(`size-3 animate-pulse motion-reduce:animate-none`,t),"aria-hidden":`true`});let n=Ze[e];return n?(0,Y.jsx)(n,{className:u(`size-2.5 shrink-0`,t),"aria-hidden":`true`}):null}export{le as A,L as B,Le as C,ze as D,K as E,de as F,se as I,ce as L,_e as M,ue as N,De as O,fe as P,F as R,Re as S,Ne as T,ie as V,W as _,He as a,V as b,Z as c,Te as d,z as f,Be as g,J as h,Ue as i,ae as j,R as k,Oe as l,Fe as m,vt as n,Ge as o,q as p,ft as r,Ke as s,lt as t,ke as u,Ee as v,Ae as w,U as x,B as y,oe as z};
@@ -1 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{an as r,in as i,vt as a}from"./queries-DHjNE2es.js";import{Ji as o}from"./toaster-Dglox5F-.js";import{Tn as s}from"./index-k2m-s5zD.js";var c=e(t(),1),l=n();function u(){let e=o(),t=(0,c.useCallback)(async()=>{await Promise.all([e.invalidateQueries({queryKey:i.health}),e.invalidateQueries({queryKey:i.agentConfig,exact:!0}),e.invalidateQueries({queryKey:r.agentProfiles,exact:!0})])},[e]);return(0,c.useEffect)(()=>{t()},[t]),t}var d=`${s()} remote-settings enable`;function f({risk:e}){return a().data?.capabilities?.remoteSettingsAdmin===!0?(0,l.jsxs)(`p`,{role:`note`,"data-slot":`remote-settings-notice`,className:`rounded-md border border-pending-strong/40 bg-pending/10 px-3 py-2 text-[13px] text-foreground`,children:[`Remote settings administration is on. `,e,`, and anyone who can open this cockpit can change them. The host operator turns this off with`,` `,(0,l.jsxs)(`code`,{children:[s(),` remote-settings disable`]}),`.`]}):null}export{f as n,u as r,d as t};
@@ -1 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{A as r,C as i,En as a,Ht as o,S as s,T as c,U as l,bt as u,in as d,nt as f,w as p}from"./queries-DHjNE2es.js";import{h as m}from"./host-context-iTMFRMT5.js";import{B as h,Cn as g,Ji as _,T as v,f as y,n as b,ut as ee,w as x,z as te,zt as ne}from"./toaster-Dglox5F-.js";import{Z as S}from"./live-protocol-CNUmr-VT.js";import{_ as C,g as w}from"./chunk-KS7C4IRE-BdLLx37K.js";import{c as T,f as E,i as D,t as re}from"./reference-chip-kvc51N1L.js";import{o as O,s as k}from"./dist-CCX8mhHc.js";import{D as ie,F as A,I as j,M as ae,N as oe,P as se,Q as ce,S as le,X as ue,Z as de,c as fe,ct as M,d as pe,j as me,l as he,n as ge,st as _e,w as ve,y as ye}from"./design-icons-QbNMZniQ.js";import{t as be}from"./createLucideIcon-BHp8sXmF.js";import{n as xe,t as Se}from"./circle-x-7nTlobAF.js";import{_ as Ce}from"./nav-row-styles-CIedRn3A.js";import{i as we,r as Te,t as Ee}from"./git-toolbar-DPkpAaKz.js";import{t as De}from"./info-DA1x_4bz.js";import{t as Oe}from"./loader-circle-CPBhhDbB.js";import{a as ke,i as Ae,n as je,r as Me}from"./diff-controls-Bb70UBsP.js";import{t as N}from"./button-BV_AiLj2.js";import{i as P,l as Ne,p as Pe,r as Fe,t as Ie}from"./dropdown-menu-NJZfnQCU.js";import{a as Le,i as Re,n as ze,o as Be,r as Ve,s as He,t as Ue}from"./dialog-DKr-j9S6.js";import{t as F}from"./project-router-CPgPVoBJ.js";import{t as We}from"./status-dot-DuorWA5M.js";import{c as Ge,d as Ke,f as qe,m as I,n as Je,s as L,t as Ye}from"./page-shell-BdjH5hyc.js";import{a as Xe,o as Ze}from"./format-BU7D3IfE.js";import{t as Qe}from"./control-locations-kCPVEtOM.js";import{t as R}from"./centered-state-N8vWM_Hw.js";import{$t as z,A as $e,Bn as et,Bt as tt,Cr as nt,Gt as rt,Ht as it,Jt as at,Kt as ot,Pn as st,Qt as ct,Rn as lt,Rt as ut,Tr as dt,Ut as ft,Vt as pt,Wt as mt,Xt as ht,Yt as gt,Zt as _t,an as B,en as V,gr as vt,in as H,k as yt,lr as U,nn as W,on as G,qt as K,rn as q,tn as J,zn as bt,zt as xt}from"./index-k2m-s5zD.js";import{t as St}from"./markdown-BBDDg-4t.js";import{t as Ct}from"./diff-CkIsqgZZ.js";import{t as wt}from"./change-counts-BLLRvt46.js";import{t as Tt}from"./code-workbench-B0GIezrD.js";import{t as Et}from"./file-text-nGpo7MVd.js";import{i as Dt,n as Ot,r as kt}from"./commit-list-5iHD08NO.js";var Y=e(t(),1);function At(e,t){let n=_(t),r=n.getQueryCache();return Y.useSyncExternalStore(Y.useCallback(e=>r.subscribe(S.batchCalls(e)),[r]),()=>n.isFetching(e),()=>n.isFetching(e))}var jt=be(`arrow-down-to-line`,[[`path`,{d:`M12 17V3`,key:`1cwfxf`}],[`path`,{d:`m6 11 6 6 6-6`,key:`12ii2o`}],[`path`,{d:`M19 21H5`,key:`150jfl`}]]),Mt=be(`git-pull-request-create`,[[`circle`,{cx:`6`,cy:`6`,r:`3`,key:`1lh9wr`}],[`path`,{d:`M6 9v12`,key:`1sc30k`}],[`path`,{d:`M13 6h3a2 2 0 0 1 2 2v3`,key:`1jb6z3`}],[`path`,{d:`M18 15v6`,key:`9wciyi`}],[`path`,{d:`M21 18h-6`,key:`139f0c`}]]),X=n();function Nt(){let e=m(),t=s(),n=_(),r=At({queryKey:d.repo})>0,i=t.data?.info?t.data:null,a=ut(e,i,`screen`);return(0,X.jsx)(Ke,{route:`repo-git`,density:i?.info?`full`:`empty`,headerSpacing:`compact`,header:{title:`Git`,secondaryActions:(0,X.jsx)(Ge,{type:`button`,variant:`ghost`,"data-slot":`git-screen-refresh`,"aria-label":`Refresh the repository`,title:`Refresh the repository`,disabled:r,onClick:()=>{n.invalidateQueries({queryKey:d.repo}),n.invalidateQueries({queryKey:d.worktrees})},children:(0,X.jsx)(de,{size:17,"aria-hidden":`true`,className:O(`size-[17px]`,r&&`motion-safe:animate-spin`)})})},children:(0,X.jsxs)(`div`,{"data-slot":`git-screen`,children:[i?.info?(0,X.jsx)(`div`,{className:`mb-[16px]`,children:(0,X.jsx)(pt,{scope:e,repo:i,info:i.info,variant:`screen`},e)}):t.isPending?(0,X.jsx)(`p`,{"data-slot":`git-screen-loading`,role:`status`,className:`mb-[16px] px-[10px] text-[13px] text-soft-foreground`,children:`Loading the checkout…`}):t.isError?(0,X.jsxs)(`p`,{"data-slot":`git-screen-error`,role:`alert`,className:`mb-[16px] px-[10px] text-[13px] text-danger`,children:[`Could not load the repository: `,t.error.message]}):(0,X.jsx)(`p`,{"data-slot":`git-screen-not-git`,className:`mb-[16px] px-[10px] text-[13px] text-soft-foreground`,children:`Not a git repository.`}),t.isPending?null:(0,X.jsx)(xt,{branch:i?.info?.branch??null,counts:a,variant:`screen`})]})})}function Pt(e){if(e===``)return null;if(e===`@`)return`A branch cannot be named “@”.`;if(e.startsWith(`-`))return`A branch name cannot start with “-”.`;if(/\s/.test(e))return`A branch name cannot contain spaces.`;if(/[\u0000-\u001f\u007f]/.test(e))return`A branch name cannot contain control characters.`;let t=/[~^:?*[\\]/.exec(e);if(t)return`A branch name cannot contain “${t[0]}”.`;if(e.includes(`..`))return`A branch name cannot contain “..”.`;if(e.includes(`@{`))return`A branch name cannot contain “@{”.`;if(e.startsWith(`/`)||e.endsWith(`/`))return`A branch name cannot start or end with “/”.`;if(e.includes(`//`))return`A branch name cannot contain “//”.`;if(e.endsWith(`.`))return`A branch name cannot end with “.”.`;for(let t of e.split(`/`)){if(t.startsWith(`.`))return`A part of a branch name cannot start with “.”.`;if(t.endsWith(`.lock`))return`A part of a branch name cannot end with “.lock”.`}return null}function Ft({from:e}){let[t,n]=(0,Y.useState)(!1),r=(0,Y.useRef)(null);return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(Ge,{ref:r,variant:`primary`,"data-action":`new-branch`,disabled:rt(m())&&!t,onClick:()=>n(!0),children:[(0,X.jsx)(ue,{size:16,"aria-hidden":`true`}),`New branch`]}),t?(0,X.jsx)(It,{from:e,returnFocus:r,onClose:()=>n(!1)}):null]})}function It({from:e,returnFocus:t,onClose:n}){let r=mt(m()),i=rt(m()),[a,o]=(0,Y.useState)(``),[s,c]=(0,Y.useState)(null),l=a.trim(),u=Pt(l),d=u??s;return(0,X.jsx)(Ue,{open:!0,onOpenChange:e=>{!e&&!r.isPending&&n()},children:(0,X.jsx)(Ve,{"data-slot":`new-branch-dialog`,className:`sm:max-w-md`,onCloseAutoFocus:e=>{e.preventDefault(),t.current?.focus()},children:(0,X.jsxs)(`form`,{className:`grid min-w-0 gap-4`,onSubmit:e=>{e.preventDefault(),!(!l||u||i)&&(c(null),r.mutate(l,{onSuccess:n,onError:e=>c(e.message)}))},children:[(0,X.jsxs)(Be,{children:[(0,X.jsx)(He,{children:`New branch`}),(0,X.jsxs)(Re,{"data-slot":`new-branch-base`,children:[`Create from `,(0,X.jsx)(`span`,{className:`font-mono text-foreground`,children:e}),` and switch to it. Switching changes your working tree.`]})]}),(0,X.jsxs)(ze,{className:`flex flex-col gap-2`,children:[(0,X.jsx)(`label`,{htmlFor:`new-branch-name`,className:`text-sm font-medium`,children:`Branch name`}),(0,X.jsx)(U,{id:`new-branch-name`,autoComplete:`off`,spellCheck:!1,placeholder:`new-branch-name`,className:`h-11 bg-background font-mono md:text-base placeholder:text-soft-foreground`,value:a,"aria-invalid":d?!0:void 0,"aria-describedby":d?`new-branch-name-hint`:void 0,onChange:e=>{o(e.target.value),c(null)}}),d?(0,X.jsx)(`p`,{id:`new-branch-name-hint`,"data-slot":u?`branch-name-hint`:`branch-create-refusal`,role:`alert`,className:`text-xs text-danger`,children:d}):null]}),(0,X.jsxs)(Le,{children:[(0,X.jsx)(N,{type:`button`,variant:`outline`,disabled:r.isPending,onClick:n,children:`Cancel`}),(0,X.jsx)(N,{type:`submit`,variant:`primary`,"data-action":`create-branch`,disabled:!l||u!==null||i,children:r.isPending?`Creating…`:`Create`})]})]})})})}function Lt({entry:e}){return e.keptReason?(0,X.jsx)(`span`,{"data-slot":`branch-kept-reason`,className:`min-w-0 text-xs text-muted-foreground`,children:e.keptReason}):null}function Rt({repo:e,info:t}){let n=i(),r=new Map((n.data?.branches??[]).map(e=>[e.name,e])),a=n.data?.base??e.baseBranch??t.branch,o=mt(m(),e=>b(e.message,{tone:`danger`})),s=rt(m()),[c,l]=(0,Y.useState)(``),u=c.trim().toLowerCase(),d=Gt(e,n.data?.branches),f=u?d.filter(e=>e.toLowerCase().includes(u)):d;return(0,X.jsx)(`section`,{"data-slot":`repo-branches`,className:`min-w-0`,children:(0,X.jsxs)(`div`,{className:`min-w-0 rounded-xl border border-border bg-card p-5`,children:[(0,X.jsx)(`h2`,{className:`sr-only`,children:`Branches`}),(0,X.jsxs)(`label`,{className:`relative block`,children:[(0,X.jsx)(ce,{size:16,"aria-hidden":`true`,className:`pointer-events-none absolute left-3 top-3 size-4 text-muted-foreground`}),(0,X.jsx)(U,{"aria-label":`Filter branches`,placeholder:`Filter branches…`,value:c,onChange:e=>l(e.target.value),className:`h-10 rounded-lg border-border bg-card pl-10`})]}),(0,X.jsxs)(`ul`,{"data-slot":`repo-branch-list`,className:`mt-3.5 flex min-w-0 flex-col divide-y divide-border border-t border-border md:max-h-[40rem] md:overflow-y-auto md:overscroll-contain`,children:[f.map(e=>{let n=e===t.branch,i=r.get(e);return(0,X.jsxs)(`li`,{"data-slot":`branch-row`,"data-branch":e,"data-branch-class":i?.class,className:`flex min-h-[60px] flex-col items-start justify-center gap-1.5 py-2 md:flex-row md:items-center md:justify-start md:gap-2.5`,children:[(0,X.jsxs)(`span`,{className:`flex min-w-0 max-w-full items-center gap-[8px]`,children:[i?.runId?(0,X.jsx)(F,{to:`/tasks/${i.runId}`,"data-slot":`branch-task-link`,title:i.title?`Open the task ${i.title}`:`Open the task`,className:`min-w-0 truncate rounded-[2px] font-mono text-[12px] underline-offset-2 hover:underline focus-visible:outline-2 focus-visible:outline-ring`,children:e}):(0,X.jsx)(`span`,{className:O(`min-w-0 truncate font-mono text-[12px]`,n&&`font-medium`),children:e}),i&&!(n&&i.class===`active`)?(0,X.jsx)(Wt,{entry:i}):null]}),i?(0,X.jsx)(zt,{entry:i,base:a}):null,i?(0,X.jsx)(Lt,{entry:i}):null,e.startsWith(`cez/`)&&!n?null:n?(0,X.jsx)(`span`,{"data-slot":`branch-current`,className:`flex h-8 shrink-0 items-center rounded-md bg-accent-strong/10 px-2.5 text-[12px] font-medium text-accent-text md:ml-auto`,children:`Current`}):(0,X.jsxs)(N,{variant:`outline`,size:`sm`,"data-action":`switch-branch`,className:`md:ml-auto`,disabled:s,onClick:()=>o.mutate(e),children:[(0,X.jsx)(me,{size:16,"aria-hidden":`true`}),`Switch`]})]},e)}),f.length===0?(0,X.jsxs)(`li`,{"data-slot":`branch-empty`,className:`py-3 text-xs text-muted-foreground`,children:[`No branches match “`,c.trim(),`”.`]}):null]})]})})}function zt({entry:e,base:t}){let n=e.pr?.state===`open`||e.pr?.state===`draft`;return(0,X.jsxs)(`span`,{"data-slot":`branch-facts`,className:`flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1 text-xs text-muted-foreground`,children:[(0,X.jsxs)(`span`,{"data-slot":`branch-counts`,title:`${Z(e.ahead)} ahead of ${t}, ${Z(e.behind)} behind`,className:`shrink-0 font-mono tabular-nums`,children:[(0,X.jsxs)(`span`,{"aria-hidden":`true`,children:[`↑`,e.ahead,` ↓`,e.behind]}),(0,X.jsxs)(`span`,{className:`sr-only`,children:[Z(e.ahead),` ahead of `,t,`, `,Z(e.behind),` behind`]})]}),e.pr?(0,X.jsx)(Vt,{pr:e.pr}):null,n&&e.pr?.checks?(0,X.jsx)(Ht,{checks:e.pr.checks}):null]})}var Z=e=>`${e} commit${e===1?``:`s`}`,Bt={open:{icon:j,className:`border-success/40 text-semantic-green`},draft:{icon:A,className:`border-border text-muted-foreground`},merged:{icon:oe,className:`border-merged-strong/35 text-merged-text`},closed:{icon:se,className:`border-danger/40 text-semantic-red`}};function Vt({pr:e}){let{icon:t,className:n}=Bt[e.state],r=(0,X.jsxs)(`span`,{className:O(`inline-flex h-6 items-center gap-1 rounded-[4px] border px-1.5 text-xs font-medium group-hover:bg-muted`,n),children:[(0,X.jsx)(t,{size:12,"aria-hidden":`true`,className:`size-3 shrink-0`}),(0,X.jsxs)(`span`,{className:`font-mono`,children:[`#`,e.number]}),(0,X.jsx)(`span`,{children:e.state})]}),i=`inline-flex shrink-0 items-center rounded-[4px] max-md:min-h-11 no-hover:min-h-11`;return k(e.url)?(0,X.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,"data-slot":`branch-pr`,"data-pr-state":e.state,title:`Open pull request #${e.number}`,className:O(i,`group focus-visible:outline-2 focus-visible:outline-ring`),children:r}):(0,X.jsx)(`span`,{"data-slot":`branch-pr`,"data-pr-state":e.state,className:i,children:r})}function Ht({checks:e}){let t=e===`passing`?xe:e===`failing`?Se:nt;return(0,X.jsxs)(`span`,{"data-slot":`pr-checks`,"data-checks":e,className:O(`inline-flex shrink-0 items-center gap-1 text-[12px] font-medium`,e===`passing`&&`text-success`,e===`failing`&&`text-danger`,e===`pending`&&`text-muted-foreground`),children:[(0,X.jsx)(t,{"aria-hidden":`true`,className:`size-3.5 shrink-0`}),e]})}var Ut={active:`in use`,"not-landed":`not landed`,orphan:`not landed`,merged:`merged`,empty:`empty`,other:`yours`};function Wt({entry:e}){return(0,X.jsx)(`span`,{"data-slot":`branch-class`,className:O(`shrink-0 rounded-[4px] border px-1.5 py-px text-xs leading-4 font-medium`,e.class===`active`?`border-status-running/40 text-status-running`:e.class===`not-landed`||e.class===`orphan`?`border-inbox-count-foreground/40 text-inbox-count-foreground`:`border-border text-soft-foreground`),children:Ut[e.class]})}function Gt(e,t){let n=new Set(e.branches);for(let e of t??[])n.add(e.name);return[...n].sort((e,t)=>e.localeCompare(t))}function Kt(){let e=p(),t=I(),[n,r]=(0,Y.useState)(`unified`),[i,a]=(0,Y.useState)(!0),[o,s]=(0,Y.useState)(!1),[c,l]=(0,Y.useState)(null),u=(0,Y.useRef)(null),d=e.isError&&e.error instanceof g&&e.error.status===409,f=e.data?.files??[],m=(0,Y.useMemo)(()=>Te(f),[f]),h=(0,Y.useMemo)(()=>f.some(St),[f]),_=t?n:`unified`;return(0,X.jsx)(`section`,{"data-slot":`repo-changes`,className:`flex min-h-0 flex-1 flex-col`,children:e.isPending?(0,X.jsx)(`p`,{"data-slot":`changes-loading`,className:`py-6 text-center text-xs text-muted-foreground`,children:`Loading changes…`}):e.isError?(0,X.jsx)(R,{icon:d?(0,X.jsx)(ve,{size:16}):(0,X.jsx)(M,{size:16}),tone:d?`neutral`:`danger`,heading:`h2`,title:d?`No changes to show`:`Could not load the changes`,subtitle:e.error.message}):f.length===0?(0,X.jsx)(R,{icon:(0,X.jsx)(ve,{size:16}),tone:`neutral`,heading:`h2`,title:`Working tree clean`,subtitle:`No uncommitted changes in the main working tree. Edits show up here as they happen.`}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{"data-slot":`repo-changes-toolbar`,className:`flex flex-wrap items-center gap-x-3 gap-y-2 pb-4 [&_button:not([data-button-size])]:min-h-11`,children:[e.data?(0,X.jsx)(Ee,{stat:e.data.stat}):null,(0,X.jsxs)(`span`,{className:`ml-auto flex items-center gap-2`,children:[h&&o?(0,X.jsx)(Ae,{}):null,h?(0,X.jsx)(`span`,{className:`max-md:hidden`,children:(0,X.jsx)(ke,{preview:o,onPreviewChange:s})}):null,(0,X.jsx)(Me,{mode:n,wrap:i,onModeChange:r,onWrapChange:a,disabled:h&&o}),(0,X.jsx)(je,{wrap:i,onWrapChange:a,preview:o,onPreviewChange:h?s:void 0,disabled:h&&o})]})]}),(0,X.jsx)(Tt,{className:`gap-5 [--diff-sticky-top:0px] md:gap-0`,treeSlot:`changes-tree-pane`,treeClassName:`overflow-y-auto overscroll-contain rounded-xl border border-border bg-card p-3.5 md:sticky md:top-4 md:max-h-[calc(100dvh_-_64px_-_2rem)]`,tree:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`h2`,{"data-slot":`changes-tree-heading`,className:`mb-3 border-b border-border pb-3 text-xs font-semibold`,children:`Changed files`}),(0,X.jsx)(we,{root:m,selected:c,onSelect:e=>{l(e),u.current?.scrollToPath(e)}})]}),children:(0,X.jsx)(Ct,{files:f,viewRef:u,mode:_,wrap:i,preview:o,loadFileText:e=>Et(()=>v(e)),totals:!1,className:`min-w-0 flex-1`})})]})})}function qt({repo:e,info:t}){let{sha:n}=w(),r=I(),i=e.log,a=(0,Y.useMemo)(()=>ct(i),[i]);if(n&&(!r||i.length===0))return(0,X.jsx)(Qt,{sha:n});let o=at(e,t),s=o&&o.behind>0?(0,X.jsx)(Xt,{info:t,tracking:o}):null;if(i.length===0)return(0,X.jsxs)(X.Fragment,{children:[s?(0,X.jsx)(`div`,{children:s}):null,(0,X.jsx)(R,{icon:(0,X.jsx)(ae,{size:16}),tone:`neutral`,heading:`h2`,title:`No commits yet`,subtitle:`The log is empty — this repository has no commits to show.`})]});let c=(0,X.jsxs)(`div`,{"data-slot":`repo-commits`,className:`flex flex-col gap-4`,children:[s,a.map(e=>(0,X.jsxs)(`section`,{"data-slot":`repo-commit-day`,"aria-label":e.label,className:`flex flex-col gap-1.5`,children:[(0,X.jsx)(`h2`,{className:`text-xs font-medium text-muted-foreground`,children:e.label}),(0,X.jsx)(`ul`,{className:`flex flex-col divide-y divide-border rounded-xl border border-border bg-card`,children:e.commits.map(e=>(0,X.jsx)(Jt,{commit:e,selected:r&&e.hash===(n??i[0]?.hash),stacked:r},e.hash))})]},e.label))]});return r?(0,X.jsx)(Tt,{className:`flex-none`,treeSlot:`repo-commits-pane`,tree:c,children:(0,X.jsx)(Zt,{sha:n??i[0]?.hash})}):c}function Jt({commit:e,selected:t,stacked:n}){return(0,X.jsxs)(`li`,{"data-selected":t?`true`:void 0,className:O(`flex min-h-[52px] gap-3.5 first:rounded-t-xl last:rounded-b-xl hover:bg-sidebar-row-hover`,n?`flex-col items-stretch gap-0`:`items-center`,t&&`bg-muted/70`),children:[(0,X.jsxs)(F,{to:`/git/commits/${e.hash}`,"data-slot":`commit-row`,"data-sha":e.hash,"aria-current":t?`true`:void 0,className:`flex min-h-[52px] min-w-0 flex-1 flex-col justify-center gap-0.5 px-4 py-2 focus-visible:outline-2 focus-visible:outline-ring`,children:[(0,X.jsx)(`span`,{"data-slot":`commit-row-subject`,className:`truncate text-[13px] font-medium text-foreground`,children:e.subject}),(0,X.jsxs)(`span`,{"data-slot":`commit-row-meta`,className:`flex min-w-0 items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,X.jsx)(Ot,{sha:e.hash}),(0,X.jsx)(`span`,{"aria-hidden":`true`,className:`shrink-0`,children:`·`}),(0,X.jsxs)(`span`,{className:`truncate`,children:[e.author,` · `,(0,X.jsx)(`span`,{title:_t(e.when,e.at),children:ht(e.when,e.at)})]})]})]}),(0,X.jsx)(Yt,{source:e.source,stacked:n})]})}function Yt({source:e,stacked:t}){let n=O(`hidden shrink-0 items-center gap-[5px] text-xs text-muted-foreground md:flex`,t?`-mt-1.5 max-w-full self-start px-4 pb-2.5`:`max-w-[45%] pr-4`);return e?(0,X.jsxs)(F,{to:`/tasks/${e.runId}`,"data-slot":`commit-source`,"data-source":`task`,"aria-label":`From the task ${e.title}${e.prNumber===null?``:`, pull request #${e.prNumber}`}`,className:O(n,`rounded-[4px] hover:text-foreground focus-visible:outline-2 focus-visible:outline-ring`),children:[e.prNumber===null?null:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(oe,{"aria-hidden":`true`,className:`size-[11px] shrink-0 text-merged-text`}),(0,X.jsxs)(`span`,{className:`shrink-0 text-muted-foreground`,children:[`PR #`,e.prNumber]})]}),(0,X.jsx)(fe,{"aria-hidden":`true`,className:`size-[12px] shrink-0`}),(0,X.jsx)(`span`,{className:`min-w-0 truncate`,children:e.title})]}):(0,X.jsx)(`span`,{"data-slot":`commit-source`,"data-source":`unknown`,className:n,children:`no task found`})}function Xt({info:e,tracking:t}){let n=ft(m(),e),r=(0,Y.useRef)(null);return(0,X.jsxs)(`div`,{"data-slot":`git-incoming`,className:`flex min-h-[44px] items-center gap-2.5 rounded-xl border border-border bg-card px-4 py-2`,children:[(0,X.jsx)(jt,{"aria-hidden":`true`,className:`size-[14px] shrink-0 text-inbox-count-foreground`}),(0,X.jsxs)(`span`,{className:`min-w-0 flex-1 text-[12.5px] text-muted-foreground`,children:[t.behind,` commit`,t.behind===1?``:`s`,` on `,t.ref,` `,t.behind===1?`is`:`are`,` not in your checkout yet`]}),(0,X.jsxs)(`button`,{ref:r,type:`button`,"data-action":`repo-pull-incoming`,disabled:!n.hasRemote||n.pulling,onClick:()=>void n.pull(),className:`inline-flex h-[28px] shrink-0 items-center gap-[4px] rounded-[6px] bg-muted px-[10px] text-[12px] font-medium text-foreground hover:brightness-110 focus-visible:outline-2 focus-visible:outline-ring disabled:opacity-50 max-md:h-11 [&>svg]:size-[12px]`,children:[n.pulling?(0,X.jsx)(Oe,{"aria-hidden":`true`,className:`motion-safe:animate-spin`}):(0,X.jsx)(ge,{"aria-hidden":`true`}),`Pull`]}),(0,X.jsx)(it,{checkout:n,returnFocus:r})]})}function Zt({sha:e}){return(0,X.jsx)(Dt,{commit:c(e),sha:e,slot:`repo-commit-preview`,loadFileText:t=>Et(()=>x(e,t))})}function Qt({sha:e}){return(0,X.jsx)(kt,{commit:c(e),sha:e,backTo:ot,backLabel:`All recent commits`,slot:`repo-commit`,loadFileText:t=>Et(()=>x(e,t))})}var $t=`Squash-merged branches may show as not landed without GitHub`;function en(e){let t=[],n=[],r=[];for(let i of e)if(i.class===`orphan`)r.push(i);else if(i.class!==`not-landed`)continue;else i.pr&&(i.pr.state===`open`||i.pr.state===`draft`)?n.push(i):t.push(i);return[{key:`no-pr`,title:`No pull request`,note:`nobody sees this work until you act`,rows:t},{key:`pr-open`,title:`Pull request open`,rows:n},{key:`deleted`,title:`Task deleted`,note:`this branch is the only copy of the work`,rows:r}].filter(e=>e.rows.length>0)}function tn(e){return e.filter(e=>e.class===`active`&&e.runId!==null&&e.ahead>0&&(e.runStatus===`done`||e.runStatus===`failed`||e.runStatus===`cancelled`)).length}function nn(){let e=i(),t=f(),n=m(),r=u(),[a,o]=(0,Y.useState)(null);if(e.isPending)return(0,X.jsx)(`p`,{"data-slot":`not-landed-loading`,role:`status`,className:`py-5 text-[13px] text-muted-foreground`,children:`Loading branches…`});if(e.isError)return(0,X.jsx)(R,{icon:(0,X.jsx)(M,{size:16}),tone:`danger`,heading:`h2`,title:`Could not classify the branches`,subtitle:e.error.message});let s=en(e.data.branches),c=s.reduce((e,t)=>e+t.rows.length,0),l=tn(e.data.branches),d=l>0?(0,X.jsxs)(`p`,{"data-slot":`not-landed-retained`,className:`flex items-start gap-2 text-xs leading-relaxed text-muted-foreground`,children:[(0,X.jsx)(De,{"aria-hidden":`true`,className:`mt-0.5 size-3.5 shrink-0`}),(0,X.jsxs)(`span`,{children:[l,` finished task`,l===1?` still has its`:`s still have their`,` worktree and commits not on the base, so `,l===1?`it is`:`they are`,` not listed here.`,` `,`They show here once the worktree is reclaimed in `,(0,X.jsx)(F,{to:K.cleanup,className:`underline underline-offset-2 hover:text-foreground`,children:`Cleanup`}),`.`]})]}):null,p=new Map((t.data??[]).map(e=>[e.id,e.finishedAt]));return(0,X.jsxs)(D,{projectId:n,repoBase:r,requests:s.flatMap(e=>e.rows).flatMap(e=>e.pr?[{projectId:n,kind:`PR`,number:e.pr.number}]:[]),children:[(0,X.jsxs)(`div`,{"data-slot":`repo-not-landed`,className:`flex flex-col gap-4 pb-[calc(90px+env(safe-area-inset-bottom))] md:pb-0`,children:[e.data.prStateKnown?null:(0,X.jsx)(rn,{}),d,s.length===0?(0,X.jsx)(Ye,{icon:(0,X.jsx)(vt,{size:16}),title:l>0?`Nothing else waiting to land`:`Everything landed`,description:l>0?`Every other finished task's commits are on the base branch, or it made none.`:`Every finished task's commits are on the base branch, or it made none.`,actions:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(N,{variant:`outline`,size:`sm`,asChild:!0,children:(0,X.jsx)(F,{to:K.cleanup,children:`Check cleanup`})}),(0,X.jsx)(N,{variant:`outline`,size:`sm`,asChild:!0,children:(0,X.jsx)(F,{to:`/`,children:`View tasks`})})]})}):(0,X.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,X.jsx)(`div`,{className:`flex flex-col gap-5`,children:s.map(e=>(0,X.jsxs)(`section`,{"data-slot":`not-landed-group`,"data-group":e.key,"aria-label":e.title,className:`flex flex-col gap-1.5`,children:[(0,X.jsxs)(`h2`,{className:`flex min-w-0 flex-wrap items-baseline gap-x-1.5 text-xs text-muted-foreground`,children:[(0,X.jsx)(`span`,{className:`font-semibold text-foreground`,children:e.title}),(0,X.jsx)(`span`,{className:`tabular-nums`,children:e.rows.length}),e.note?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Q,{}),(0,X.jsx)(`span`,{children:e.note})]}):null]}),(0,X.jsx)(`ul`,{className:`flex flex-col divide-y divide-border rounded-xl border border-border bg-card`,children:e.rows.map(e=>(0,X.jsx)(an,{entry:e,finishedAt:e.runId?p.get(e.runId):void 0,onDelete:()=>o(e)},e.name))})]},e.key))}),(0,X.jsxs)(`p`,{"data-slot":`not-landed-note`,className:`flex items-start gap-1.5 px-1 text-xs leading-snug text-muted-foreground`,children:[(0,X.jsx)(De,{"aria-hidden":`true`,className:`mt-px size-3 shrink-0`}),`Delete a branch from its row's … menu. It confirms and names the commits it drops; nothing here is bulk-deleted.`]}),c<=3?(0,X.jsx)(Je,{summary:`${c} ${c===1?`branch`:`branches`} waiting to land. Open a draft PR or inspect worktrees in Cleanup.`,actions:(0,X.jsx)(N,{variant:`outline`,size:`sm`,asChild:!0,children:(0,X.jsx)(F,{to:K.cleanup,children:`Open cleanup`})})}):null]})]}),(0,X.jsx)(un,{entry:a,onClose:()=>o(null)})]})}function rn({className:e}){return(0,X.jsxs)(`p`,{"data-slot":`git-no-forge`,className:O(`flex items-start gap-2 text-xs leading-relaxed text-muted-foreground`,e),children:[(0,X.jsx)(De,{"aria-hidden":`true`,className:`mt-0.5 size-3.5 shrink-0`}),$t,`.`]})}function an({entry:e,finishedAt:t,onDelete:n}){return(0,X.jsxs)(`li`,{"data-slot":`not-landed-row`,"data-branch":e.name,"data-branch-class":e.class,className:`flex min-h-[60px] items-center gap-3 px-4 py-3 first:rounded-t-xl last:rounded-b-xl hover:bg-sidebar-row-hover`,children:[(0,X.jsx)(cn,{entry:e,finishedAt:t}),(0,X.jsx)(on,{entry:e}),(0,X.jsx)(sn,{entry:e,onDelete:n})]})}function on({entry:e}){return(0,X.jsx)(X.Fragment,{children:e.pr?(0,X.jsxs)(`span`,{"data-slot":`not-landed-pr`,className:`hidden shrink-0 items-center gap-1.5 text-xs text-muted-foreground md:flex`,children:[(0,X.jsx)(re,{plain:!0,reference:{kind:`PR`,number:e.pr.number,url:e.pr.url},taskTitle:e.title??e.name,status:e.pr.state===`draft`?`draft`:e.pr.state===`closed`?`closed`:void 0}),(0,X.jsx)(ln,{entry:e})]}):null})}function sn({entry:e,onDelete:t}){let n=_(),r=e.class===`orphan`,i=e.pr&&(e.pr.state===`open`||e.pr.state===`draft`)?e.pr:null,o=!r&&e.runId!==null&&!i,s=a({mutationFn:()=>ee(e.runId),onSuccess:e=>{b(`Draft PR created — ${e.url}`),n.invalidateQueries({queryKey:d.repoBranches}),n.invalidateQueries({queryKey:d.runs.all})},onError:e=>b(e instanceof g&&e.manual?`${e.message} — ${e.manual}`:e.message,{tone:`danger`})}),[c,l]=(0,Y.useState)(!1),u=(0,Y.useRef)(null);(0,Y.useEffect)(()=>()=>{u.current!==null&&clearTimeout(u.current)},[]);let f=()=>void navigator.clipboard.writeText(e.name).then(()=>{b(`Copied ${e.name}`),u.current!==null&&clearTimeout(u.current),l(!0),u.current=setTimeout(()=>l(!1),2e3)},()=>b(`Could not copy the branch name`,{tone:`danger`})),p=`inline-flex h-8 shrink-0 items-center gap-1.5 rounded-sm px-2.5 text-[12.5px] font-medium text-foreground focus-visible:outline-2 focus-visible:outline-ring disabled:opacity-50 [&>svg]:size-[12px]`;return(0,X.jsxs)(X.Fragment,{children:[e.runId?(0,X.jsx)(F,{to:`/tasks/${e.runId}`,"data-action":`not-landed-open`,className:O(p,`hidden border border-border bg-card hover:bg-muted md:inline-flex`),children:`Open task`}):null,o?(0,X.jsxs)(`button`,{type:`button`,"data-action":`not-landed-create-pr`,disabled:s.isPending,onClick:()=>s.mutate(),className:O(p,`hidden border border-border bg-card hover:bg-muted md:inline-flex`),children:[(0,X.jsx)(Mt,{"aria-hidden":`true`}),s.isPending?`Creating…`:`Draft PR`]}):null,r?(0,X.jsxs)(`button`,{type:`button`,"data-action":`not-landed-copy`,"data-copied":c||void 0,"aria-live":`polite`,onClick:f,className:O(p,`hidden border border-border bg-card hover:bg-muted md:inline-flex`),children:[c?(0,X.jsx)(he,{"aria-hidden":`true`}):(0,X.jsx)(ye,{"aria-hidden":`true`}),c?`Copied`:`Copy branch`]}):null,(0,X.jsxs)(Ie,{children:[(0,X.jsx)(Pe,{"data-action":`not-landed-more`,"aria-label":`More actions for ${e.name}`,className:`flex size-8 shrink-0 items-center justify-center rounded-sm text-soft-foreground outline-none hover:bg-muted hover:text-foreground focus-visible:outline-2 focus-visible:outline-ring max-md:size-11`,children:(0,X.jsx)(le,{"aria-hidden":`true`,className:`size-[14px]`})}),(0,X.jsxs)(Fe,{align:`end`,className:`w-52`,children:[e.runId?(0,X.jsx)(P,{asChild:!0,className:`md:hidden`,children:(0,X.jsx)(F,{to:`/tasks/${e.runId}`,children:`Open task`})}):null,o?(0,X.jsx)(P,{className:`md:hidden`,disabled:s.isPending,onSelect:()=>s.mutate(),children:`Draft PR`}):null,(0,X.jsx)(P,{className:O(!r&&`md:hidden`),onSelect:f,children:`Copy branch`}),(0,X.jsx)(Ne,{className:`md:hidden`}),(0,X.jsx)(P,{"data-action":`not-landed-delete`,variant:`destructive`,onSelect:t,children:`Delete branch…`})]})]})]})}function cn({entry:e,finishedAt:t}){let n=e.class===`orphan`,r=n?`No task · last commit “${e.lastCommit.subject}”`:e.title??e.name,i=t??e.lastCommit.at,a=Xe(i),o=e.runStatus?st(e.runStatus):void 0,s=n||!o?a:`${o.label}${a?` ${a}`:``}`,c=Number.isFinite(Date.parse(i))?new Date(i).toLocaleString():void 0;return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{className:`flex size-[12px] shrink-0 items-center justify-center`,children:n?(0,X.jsx)(Ce,{"aria-label":`Task deleted`,className:`size-[12px] text-muted-foreground`}):(0,X.jsx)(We,{tone:o?.tone??`neutral`,shape:o?.shape??`filled`,"aria-label":o?.label})}),(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[e.runId?(0,X.jsx)(F,{to:`/tasks/${e.runId}`,"data-slot":`not-landed-title`,className:`min-w-0 truncate rounded-[2px] text-[13px] font-medium text-foreground hover:underline underline-offset-2 focus-visible:outline-2 focus-visible:outline-ring`,children:r}):(0,X.jsx)(`span`,{"data-slot":`not-landed-title`,className:`min-w-0 truncate text-[13px] font-medium text-foreground`,title:r,children:r}),(0,X.jsxs)(`span`,{"data-slot":`not-landed-meta`,className:`flex min-w-0 items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,X.jsx)(`span`,{className:`shrink-0 font-mono text-xs`,children:e.name}),(0,X.jsx)(Q,{}),(0,X.jsxs)(`span`,{className:`shrink-0`,children:[e.ahead,` commit`,e.ahead===1?``:`s`]}),e.diffStat?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Q,{}),(0,X.jsx)(wt,{adds:e.diffStat.additions,dels:e.diffStat.deletions})]}):null,s?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Q,{}),(0,X.jsx)(`span`,{className:`truncate`,title:c,children:s})]}):null]}),e.parentRunId?(0,X.jsx)(F,{to:`/tasks/${e.parentRunId}`,"data-slot":`not-landed-parent`,className:`w-fit rounded-[2px] text-xs text-muted-foreground hover:underline underline-offset-2 focus-visible:outline-2 focus-visible:outline-ring`,children:`Worker of its parent task`}):null,(0,X.jsx)(Lt,{entry:e})]})]})}function Q(){return(0,X.jsx)(`span`,{"aria-hidden":`true`,className:`shrink-0`,children:`·`})}function ln({entry:e}){let t=o(T(`PR`,e.pr?.number).status),n=e.pr?.state,r=n===`draft`||n===`closed`?n:t?t.label.toLowerCase():`open`;return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Q,{}),(0,X.jsx)(`span`,{"data-slot":`not-landed-pr-state`,children:r})]})}function un({entry:e,onClose:t}){let n=_(),[r,i]=(0,Y.useState)(``),o=(0,Y.useId)(),s=a({mutationFn:e=>y({names:[e],confirm:e}),onSuccess:e=>{let t=e.dropped?.length??0;b(e.deleted.length>0?`Deleted ${e.deleted[0]}${t?` and ${t} commit${t===1?``:`s`} with it`:``}`:e.refused[0]?.reason??`Nothing was deleted`),n.invalidateQueries({queryKey:d.repo}),c()},onError:e=>b(e.message,{tone:`danger`})}),c=()=>{i(``),t()},l=e!==null&&r.trim()===e.name,u=e&&`${e.ahead} commit${e.ahead===1?``:`s`}`;return(0,X.jsx)(z,{open:e!==null,onOpenChange:e=>!e&&!s.isPending&&c(),children:(0,X.jsxs)(W,{"data-slot":`delete-branch-dialog`,children:[(0,X.jsxs)(B,{children:[(0,X.jsxs)(G,{children:[`Delete `,e?.name,`?`]}),(0,X.jsx)(q,{asChild:!0,children:(0,X.jsxs)(`div`,{className:`space-y-2`,children:[(0,X.jsx)(`p`,{children:e?.class===`orphan`?`Its task was deleted, so this branch is the only copy of the work.`:(0,X.jsxs)(X.Fragment,{children:[`This drops the work of `,(0,X.jsx)(`span`,{className:`font-medium text-foreground`,children:e?.title??e?.name}),`. It is not on the base branch`,e?.pr?``:` and no pull request carries it`,`.`]})}),(0,X.jsxs)(`p`,{"data-slot":`delete-branch-dropped`,children:[u,` will be dropped`,e?.diffStat?` (+${e.diffStat.additions} −${e.diffStat.deletions})`:``,`, the latest “`,e?.lastCommit.subject,`”`,e?.lastCommit.sha?(0,X.jsxs)(X.Fragment,{children:[` (`,(0,X.jsx)(et,{sha:e.lastCommit.sha,variant:`inline`}),`)`]}):null,`.`]})]})})]}),(0,X.jsxs)(`form`,{onSubmit:t=>{t.preventDefault(),l&&e&&!s.isPending&&s.mutate(e.name)},className:`flex flex-col gap-[6px]`,children:[(0,X.jsxs)(`label`,{htmlFor:o,className:`text-[12.5px] text-muted-foreground`,children:[`Type `,(0,X.jsx)(`span`,{className:`font-mono text-foreground`,children:e?.name}),` to confirm`]}),(0,X.jsx)(U,{id:o,"data-slot":`delete-branch-confirm`,autoComplete:`off`,spellCheck:!1,value:r,onChange:e=>i(e.target.value),className:`h-11 font-mono`})]}),(0,X.jsxs)(H,{children:[(0,X.jsx)(J,{className:`h-11`,disabled:s.isPending,children:`Keep it`}),(0,X.jsx)(V,{"data-action":`delete-branch-confirm`,className:`h-11 bg-danger text-danger-foreground hover:brightness-[0.96]`,disabled:!l||s.isPending,onClick:t=>{t.preventDefault(),e&&s.mutate(e.name)},children:s.isPending?`Deleting…`:`Delete branch`})]})]})})}function dn({base:e}){let t=i(),n=_(),[r,o]=(0,Y.useState)({merged:!1,empty:!1}),[s,c]=(0,Y.useState)(!1),l=(t.data?.branches??[]).filter(e=>e.class===`merged`),u=(t.data?.branches??[]).filter(e=>e.class===`empty`),f=[...l,...u],p=a({mutationFn:e=>y({names:e}),onSuccess:e=>{let t=e.refused.length;b(`Deleted ${e.deleted.length} branch${e.deleted.length===1?``:`es`}${t?`; kept ${t} that ${t===1?`is`:`are`} no longer safe to delete`:``}`),n.invalidateQueries({queryKey:d.repo})},onError:e=>{n.invalidateQueries({queryKey:d.repo}),b(e.message,{tone:`danger`})}});if(t.isPending)return(0,X.jsx)(`p`,{"data-slot":`cleanup-branches-loading`,className:`text-[13px] text-soft-foreground`,children:`Loading branches…`});if(t.isError)return(0,X.jsxs)(`p`,{"data-slot":`cleanup-branches-error`,className:`text-[13px] text-danger`,children:[`Branches did not load: `,t.error.message]});let m=f.length,h=`branch${m===1?``:`es`}`;return(0,X.jsxs)(`section`,{"data-slot":`cleanup-branches`,"aria-labelledby":`cleanup-branches-title`,className:`flex flex-col rounded-[8px] border border-border`,children:[(0,X.jsxs)(`div`,{className:`flex flex-col gap-[10px] border-b border-border px-[14px] py-[12px] md:flex-row md:items-center`,children:[(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-[2px]`,children:[(0,X.jsxs)(`h2`,{id:`cleanup-branches-title`,className:`text-[13px] font-semibold text-foreground`,children:[`Branches safe to delete · `,m]}),(0,X.jsxs)(`p`,{className:`text-xs leading-[17px] text-soft-foreground`,children:[`Their work is already on `,e,`, or they have none. Deleting loses nothing.`]})]}),(0,X.jsxs)(`button`,{type:`button`,"data-action":`cleanup-branches-delete`,disabled:m===0||p.isPending,onClick:()=>c(!0),className:`inline-flex h-[28px] shrink-0 items-center gap-[5px] self-start rounded-[6px] bg-muted px-[10px] text-[12px] font-medium text-foreground hover:brightness-110 focus-visible:outline-2 focus-visible:outline-ring disabled:opacity-50 disabled:hover:brightness-100 max-md:h-11 md:self-center`,children:[(0,X.jsx)(_e,{"aria-hidden":`true`,className:`size-[12px]`}),p.isPending?`Deleting…`:`Delete ${m} ${h}`]})]}),(0,X.jsx)(fn,{kind:`merged`,title:`Merged into ${e}`,hint:t.data.prStateKnown?`including squash-merged PRs, read from the PR state`:$t.toLowerCase(),rows:l,open:r.merged,onToggle:()=>o(e=>({...e,merged:!e.merged}))}),(0,X.jsx)(fn,{kind:`empty`,title:`Empty`,hint:`no commits beyond the fork point`,rows:u,open:r.empty,onToggle:()=>o(e=>({...e,empty:!e.empty}))}),(0,X.jsx)(z,{open:s,onOpenChange:c,children:(0,X.jsxs)(W,{children:[(0,X.jsxs)(B,{children:[(0,X.jsxs)(G,{children:[`Delete `,m,` `,h,`?`]}),(0,X.jsxs)(q,{children:[l.length,` merged into `,e,` and `,u.length,` empty. Their work is already on `,e,`, or they have none. Anything that stopped being safe since this list loaded is kept.`]})]}),(0,X.jsxs)(H,{children:[(0,X.jsx)(J,{children:`Keep them`}),(0,X.jsxs)(V,{"data-action":`cleanup-branches-confirm`,className:`bg-danger text-danger-foreground hover:brightness-[0.96]`,onClick:()=>{p.mutate(f.map(e=>e.name)),c(!1)},children:[`Delete `,m,` `,h]})]})]})})]})}function fn({kind:e,title:t,hint:n,rows:r,open:i,onToggle:a}){let o=`cleanup-branches-${e}`;return(0,X.jsxs)(`div`,{"data-slot":`cleanup-branch-group`,"data-group":e,className:`border-b border-border last:border-0`,children:[(0,X.jsxs)(`button`,{type:`button`,"aria-expanded":i,"aria-controls":o,disabled:r.length===0,onClick:a,className:`flex min-h-[44px] w-full items-center gap-[12px] px-[14px] py-[4px] text-left hover:bg-sidebar-row-hover focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-ring disabled:hover:bg-transparent`,children:[(0,X.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-[2px]`,children:[(0,X.jsxs)(`span`,{className:`truncate text-[12.5px] text-foreground`,children:[t,` · `,r.length]}),(0,X.jsx)(`span`,{className:`truncate text-xs text-soft-foreground`,children:n})]}),r.length>0?(0,X.jsx)(pe,{"aria-hidden":`true`,className:O(`size-[13px] shrink-0 text-soft-foreground transition-transform motion-reduce:transition-none`,i&&`rotate-90`)}):null]}),i?(0,X.jsx)(`ul`,{id:o,"aria-label":t,className:`flex flex-col pb-[6px]`,children:r.map(e=>(0,X.jsxs)(`li`,{"data-slot":`cleanup-branch-row`,"data-branch":e.name,className:`flex min-h-[32px] items-center gap-[10px] px-[14px] pl-[26px] text-xs`,children:[(0,X.jsx)(lt,{value:e.name,className:`shrink-0 text-muted-foreground`}),e.runId?(0,X.jsx)(F,{to:`/tasks/${e.runId}`,className:`min-w-0 flex-1 truncate text-soft-foreground underline-offset-2 hover:text-foreground hover:underline`,children:e.title??`Open the task`}):(0,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-soft-foreground`,children:e.lastCommit.subject}),e.pr?(0,X.jsxs)(`span`,{className:`shrink-0 text-soft-foreground`,children:[`PR #`,e.pr.number]}):null,(0,X.jsx)(bt,{iso:e.lastCommit.at,className:`shrink-0 text-soft-foreground`})]},e.name))}):null]})}function $(e){return e.some(e=>e.sizeBytes===null)?null:e.reduce((e,t)=>e+(t.sizeBytes??0),0)}function pn(e){return e.kind===`dirty`?`${e.uncommittedFiles} uncommitted`:e.kind===`detached-head`?`detached HEAD`:e.kind===`submodules`?`has submodules`:`broken worktree`}function mn(e){if(e.kind===`dirty`){let t=`${e.uncommittedFiles} uncommitted file${e.uncommittedFiles===1?``:`s`}`;return e.detachedHead?`${t} and a detached HEAD on no branch`:t}return e.kind===`detached-head`?`a detached HEAD whose commit is on no branch`:e.kind===`submodules`?`initialized submodules that Git will not remove without force`:`an unregistered or broken Git worktree directory`}function hn(e){let t=e.some(e=>e.reclaimBlocker?.kind===`dirty`),n=e.some(e=>e.reclaimBlocker?.kind===`detached-head`||e.reclaimBlocker?.kind===`dirty`&&e.reclaimBlocker.detachedHead),r=e.some(e=>e.reclaimBlocker?.kind===`submodules`),i=e.some(e=>e.reclaimBlocker?.kind===`invalid`),a=[...t?[`uncommitted work`]:[],...n?[`a detached HEAD`]:[],...r?[`initialized submodules`]:[],...i?[`a broken checkout`]:[]];return a.length<=1?a[0]??`uncommitted work`:`${a.slice(0,-1).join(`, `)} or ${a.at(-1)}`}function gn(e,t,n){let r=Math.max(0,t-e);return e===0?r===0?`Nothing to reclaim — no finished worktrees exceed the keep limit`:n?`Nothing was reclaimed — the worktrees past the keep limit are in use or could not be removed`:`Nothing was reclaimed — the worktrees past the keep limit have uncommitted work or are in use`:`Reclaimed ${e} worktree${e===1?``:`s`} (branch kept)${r>0?` · ${r} kept: ${n?`in use or could not be removed`:`uncommitted work or in use`}`:``}`}function _n(e,t){return e===0?`Reclaim now`:t?`Reclaim ${E(t)} now`:`Reclaim ${e} now`}function vn(e,t,n){let r=t?E(t):String(e);return n?`Discard & reclaim all ${r}`:`Discard & reclaim ${r}`}function yn(e,t){if(!e)return t>0?`No clean worktrees past the keep limit — use Discard & reclaim for blocked worktrees`:`Nothing past the keep limit to reclaim`}function bn(e){return e===0?{prefix:`Retention is unlimited (`,suffix:`), so nothing is reclaimed on its own.`}:{prefix:`Retention keeps the newest ${e} finished checkout${e===1?``:`s`} (`,suffix:`) and reclaims the rest.`}}function xn({blocked:e,discardLabel:t,disabled:n,onDiscard:r}){let i=$(e),a=e.length===1?``:`s`,o=e.length===1?`it has`:`they have`;return(0,X.jsxs)(`div`,{"data-slot":`worktrees-blocked-banner`,className:`flex flex-col gap-[10px] border-b border-border bg-muted/40 px-[14px] py-[10px] md:flex-row md:items-center`,children:[(0,X.jsxs)(`p`,{className:`min-w-0 flex-1 text-[12px] leading-[17px] text-foreground`,children:[e.length,` worktree`,a,` past the keep limit`,i?` (${E(i)})`:``,` `,`cannot be reclaimed automatically because `,o,` `,hn(e),`.`]}),(0,X.jsxs)(`button`,{type:`button`,"data-action":`worktrees-discard-reclaim`,disabled:n,onClick:r,className:`inline-flex h-[28px] shrink-0 items-center gap-[5px] self-start rounded-[6px] border border-danger/40 px-[10px] text-[12px] font-medium text-danger hover:bg-danger/10 focus-visible:outline-2 focus-visible:outline-ring disabled:opacity-50 max-md:h-11 md:self-center`,children:[(0,X.jsx)(dt,{"aria-hidden":`true`,className:`size-[12px]`}),t]})]})}function Sn({confirmClean:e,onCloseClean:t,cleanCount:n,cleanBytes:r,reclaimLabel:i,onConfirmClean:a,discardBatch:o,onCloseDiscardBatch:s,onConfirmDiscardBatch:c,discardRow:l,onCloseRow:u,onConfirmRow:d}){let f=o?$(o):null,p=o?o.filter(e=>e.reclaimBlocker!==null).length:0,m=o?o.some(e=>!e.reclaimBlocker):!1,h=o?vn(o.length,f,m):``;return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(z,{open:e,onOpenChange:e=>{e||t()},children:(0,X.jsxs)(W,{children:[(0,X.jsxs)(B,{children:[(0,X.jsx)(G,{children:`Reclaim old worktrees?`}),(0,X.jsxs)(q,{children:[n,` finished worktree`,n===1?``:`s`,` beyond the keep limit`,r?` (${E(r)})`:``,` `,n===1?`is`:`are`,` reclaimed now, directory only. Their branches are kept, so the work stays recoverable.`]})]}),(0,X.jsxs)(H,{children:[(0,X.jsx)(J,{children:`Keep them`}),(0,X.jsx)(V,{"data-action":`worktrees-confirm`,onClick:a,children:i})]})]})}),(0,X.jsx)(z,{open:o!==null,onOpenChange:e=>{e||s()},children:(0,X.jsxs)(W,{children:[(0,X.jsxs)(B,{children:[(0,X.jsx)(G,{children:`Discard changes and reclaim worktrees?`}),(0,X.jsx)(q,{children:o?(0,X.jsxs)(X.Fragment,{children:[o.length,` finished worktree`,o.length===1?``:`s`,` beyond the keep limit`,f?` (${E(f)})`:``,` will be reclaimed now.`,` `,`Uncommitted files and detached-HEAD commits in `,p,` blocked checkout`,p===1?``:`s`,` will be permanently discarded. Each task’s branch is kept.`]}):null})]}),(0,X.jsxs)(H,{children:[(0,X.jsx)(J,{children:`Keep them`}),(0,X.jsx)(V,{"data-action":`worktrees-discard-confirm`,className:`bg-danger text-danger-foreground hover:brightness-[0.96]`,onClick:()=>{o&&c(o),s()},children:h})]})]})}),(0,X.jsx)(z,{open:l!==null,onOpenChange:e=>{e||u()},children:(0,X.jsxs)(W,{children:[(0,X.jsxs)(B,{children:[(0,X.jsx)(G,{children:`Discard changes and reclaim worktree?`}),(0,X.jsx)(q,{children:l?.reclaimBlocker?(0,X.jsxs)(X.Fragment,{children:[l.title,` has `,mn(l.reclaimBlocker),`. Reclaiming removes the directory and permanently discards uncommitted or unbranched changes in it. The branch (`,l.branch??l.runId.slice(0,8),`) is kept.`]}):null})]}),(0,X.jsxs)(H,{children:[(0,X.jsx)(J,{children:`Keep it`}),(0,X.jsx)(V,{"data-action":`worktree-discard-confirm`,className:`bg-danger text-danger-foreground hover:brightness-[0.96]`,onClick:()=>{l&&d(l),u()},children:`Discard & reclaim`})]})]})})]})}function Cn(){let e=r(),t=l().data?.targets.find(e=>e.id===`finder`),n=a({mutationFn:e=>ne(e,t.id),onError:e=>b(e.message,{tone:`danger`})}),i=_(),[o,s]=(0,Y.useState)(!1),[c,u]=(0,Y.useState)(null),[f,p]=(0,Y.useState)(null),m=()=>Promise.all([i.invalidateQueries({queryKey:d.worktrees}),i.invalidateQueries({queryKey:d.repoBranches})]),g=a({mutationFn:({runIds:e})=>h(e?{discardWork:!0,runIds:e}:void 0),onSuccess:(e,{expected:t,runIds:n})=>{m(),b(gn(e.reclaimed.length,t,!!n))},onError:e=>b(e.message,{tone:`danger`})}),v=a({mutationFn:({worktree:e,discardWork:t})=>te(e.runId,t?{discardWork:!0}:void 0),onSuccess:(e,{worktree:t})=>{m(),b(`Reclaimed the worktree of ${t.title} (branch kept)`)},onError:e=>{m(),b(e.message,{tone:`danger`})}});if(e.isPending)return(0,X.jsx)(`p`,{"data-slot":`worktrees-loading`,className:`text-[13px] text-soft-foreground`,children:`Loading worktrees…`});if(e.isError)return(0,X.jsxs)(`p`,{"data-slot":`worktrees-error`,className:`text-[13px] text-danger`,children:[`Worktrees did not load: `,e.error.message]});let{worktrees:y,totalBytes:ee,keep:x}=e.data,S=g.isPending||v.isPending,C=y.filter(e=>e.pastKeep),w=C.filter(e=>!e.reclaimBlocker),T=C.filter(e=>e.reclaimBlocker!==null),D=w.length>0,re=$(w),O=$(C),k=_n(w.length,re),ie=vn(C.length,O,D),A=ee?E(ee):null,j=bn(x);return(0,X.jsxs)(`section`,{"data-slot":`worktrees-panel`,"aria-labelledby":`worktrees-panel-title`,className:`flex flex-col rounded-[8px] border border-border`,children:[(0,X.jsxs)(`div`,{className:`flex flex-col gap-[10px] border-b border-border px-[14px] py-[12px] md:flex-row md:items-center`,children:[(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-[2px]`,children:[(0,X.jsxs)(`h2`,{id:`worktrees-panel-title`,className:`text-[13px] font-semibold text-foreground`,children:[`Worktrees on disk`,A?` · ${A}`:``]}),(0,X.jsxs)(`p`,{"data-slot":`worktrees-retention`,className:`text-xs leading-[17px] text-soft-foreground`,children:[j.prefix,(0,X.jsx)(F,{to:`/settings/worktrees`,"data-slot":`worktrees-retention-link`,className:`underline-offset-2 hover:text-foreground hover:underline`,children:Qe(`worktrees`,` › `)}),j.suffix,` `,`Reclaim removes the directory only; the branch stays, so its work stays recoverable.`]})]}),(0,X.jsxs)(`button`,{type:`button`,"data-action":`worktrees-reclaim-now`,disabled:S||!D,title:yn(D,T.length),onClick:()=>s(!0),className:`inline-flex h-[28px] shrink-0 items-center gap-[5px] self-start rounded-[6px] bg-muted px-[10px] text-[12px] font-medium text-foreground hover:brightness-110 focus-visible:outline-2 focus-visible:outline-ring disabled:opacity-50 disabled:hover:brightness-100 max-md:h-11 md:self-center`,children:[(0,X.jsx)(dt,{"aria-hidden":`true`,className:`size-[12px]`}),k]})]}),T.length>0?(0,X.jsx)(xn,{blocked:T,discardLabel:ie,disabled:S,onDiscard:()=>u(C)}):null,y.length===0?(0,X.jsx)(`p`,{"data-slot":`worktrees-empty`,className:`px-[14px] py-[12px] text-[12.5px] text-soft-foreground`,children:`No task worktrees on disk.`}):(0,X.jsx)(`ul`,{"aria-label":`Task worktrees on disk`,className:`flex flex-col`,children:y.map(e=>(0,X.jsx)(En,{worktree:e,keep:x,disabled:S,onOpen:t?()=>n.mutate(e.runId):void 0,opening:n.isPending,onReclaim:()=>{e.reclaimBlocker?p(e):v.mutate({worktree:e,discardWork:!1})}},e.runId))}),(0,X.jsx)(Sn,{confirmClean:o,onCloseClean:()=>s(!1),cleanCount:w.length,cleanBytes:re,reclaimLabel:k,onConfirmClean:()=>{g.mutate({expected:w.length}),s(!1)},discardBatch:c,onCloseDiscardBatch:()=>u(null),onConfirmDiscardBatch:e=>{g.mutate({expected:e.length,runIds:e.map(e=>e.runId)})},discardRow:f,onCloseRow:()=>p(null),onConfirmRow:e=>v.mutate({worktree:e,discardWork:!0})})]})}var wn=new Set([`queued`,`running`,`waiting`,`review`]);function Tn(e,t){return wn.has(e.status)||!e.reclaimable?{label:`in use`,tone:`in-use`,state:`in-use`}:e.reclaimBlocker?{label:pn(e.reclaimBlocker),tone:`blocked`,state:`blocked`}:e.pastKeep?{label:`reclaimable`,tone:`plain`,state:`reclaimable`}:{label:t>0?`kept · newest ${t}`:`kept`,tone:`plain`,state:`kept`}}function En({worktree:e,keep:t,disabled:n,onOpen:r,opening:i,onReclaim:a}){let o=Tn(e,t),s=Xe(e.finishedAt??void 0),c=e.status===`review`?`at review`:s?`${e.status} ${Ze(s)}`:e.status,l=o.tone===`in-use`?`text-status-running`:o.tone===`blocked`?`text-danger`:`text-soft-foreground`,u=e.reclaimBlocker?`Cannot auto-reclaim: ${mn(e.reclaimBlocker)}`:void 0,d=(0,X.jsx)(`span`,{"data-slot":`worktree-state`,"data-state":o.state,title:u,className:O(`text-xs`,l),children:o.label}),f=`flex size-[28px] shrink-0 items-center justify-center rounded-[6px] text-soft-foreground hover:bg-muted hover:text-foreground focus-visible:outline-2 focus-visible:outline-ring disabled:opacity-50 max-md:size-11`,p=e.reclaimBlocker?`Discard changes and reclaim the worktree of ${e.title} (branch kept)`:`Reclaim the worktree of ${e.title} (branch kept)`,m=e.reclaimBlocker?`Discard changes and reclaim the directory (branch kept)`:`Reclaim the directory (branch kept)`;return(0,X.jsxs)(`li`,{"data-slot":`worktree-row`,"data-run":e.runId,className:`flex min-h-[44px] items-center gap-[12px] border-b border-border px-[14px] py-[4px] last:border-0`,children:[(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-[2px]`,children:[(0,X.jsx)(`span`,{className:`truncate text-[12.5px] text-foreground`,title:e.title,children:e.title}),(0,X.jsxs)(`span`,{className:`truncate font-mono text-xs text-soft-foreground`,children:[e.branch??e.runId.slice(0,8),` · `,c,(0,X.jsxs)(`span`,{className:`md:hidden`,children:[` · `,o.label]})]})]}),(0,X.jsx)(`span`,{"data-slot":`worktree-size`,className:`shrink-0 text-xs tabular-nums text-muted-foreground`,children:e.sizeBytes===null?`—`:E(e.sizeBytes)||`0 kB`}),(0,X.jsx)(`span`,{className:`hidden shrink-0 md:inline`,children:d}),r?(0,X.jsx)(`button`,{type:`button`,className:f,"aria-label":`Open folder for ${e.title}`,title:`Open folder`,disabled:i,onClick:r,children:(0,X.jsx)(ie,{"aria-hidden":`true`,className:`size-[13px]`})}):null,o.tone===`in-use`?null:(0,X.jsx)(`button`,{type:`button`,"data-action":`worktree-reclaim`,"aria-label":p,title:m,disabled:n,onClick:a,className:O(f,e.reclaimBlocker&&`text-danger hover:text-danger`),children:(0,X.jsx)(dt,{"aria-hidden":`true`,className:`size-[13px]`})})]})}function Dn(e){return e===`main`||e===`changes`?`Split`:`Table`}function On({section:e,index:t=!1}){let n=s(),r=I(),[i]=C(),a=Dn(e);if(t&&!r&&i.get(`view`)!==`repo`)return(0,X.jsx)(Nt,{});if(n.isPending)return(0,X.jsx)(yt,{});if(n.isError)return(0,X.jsx)(L,{template:a,route:`repo-git`,density:`empty`,beforeHeader:(0,X.jsx)($e,{}),children:(0,X.jsx)(R,{icon:(0,X.jsx)(M,{size:16}),tone:`danger`,title:`Could not load the repository`,subtitle:n.error.message})});let o=n.data.info;return o?(0,X.jsx)(kn,{repo:n.data,info:o,section:e}):(0,X.jsx)(L,{template:a,route:`repo-git`,density:`empty`,beforeHeader:(0,X.jsx)($e,{}),children:(0,X.jsx)(R,{icon:(0,X.jsx)(me,{size:16}),tone:`neutral`,title:`Not a git repository`,subtitle:`Squawk is running outside a git repository — start it inside one to browse changes, commits and branches.`})})}function kn({repo:e,info:t,section:n}){let r=Dn(n),a=i(),o=An(n),s=n===`main`?e.log.length:n===`changes`?e.status.length:n===`branches`?Gt(e,a.data?.branches).length:n===`not-landed`?a.data?.branches.filter(e=>e.class===`not-landed`||e.class===`orphan`).length??0:4;return(0,X.jsx)(L,{template:r,route:`repo-git`,density:n===`not-landed`&&a.isPending?`full`:qe(s),rootProps:{"data-git-section":n},beforeHeader:(0,X.jsx)($e,{}),header:{title:o?.title??tt(n,t.branch),headerSlot:`repo-header`,subtitle:o?(0,X.jsxs)(X.Fragment,{children:[`Commit `,o.shortSha,` on `,t.branch]}):(0,X.jsx)(jn,{repo:e,info:t,section:n}),subtitleSlot:`repo-meta`,...n===`branches`?{primaryAction:(0,X.jsx)(Ft,{from:t.branch})}:{}},children:n===`main`?(0,X.jsx)(qt,{repo:e,info:t}):n===`not-landed`?(0,X.jsx)(nn,{}):n===`cleanup`?(0,X.jsxs)(`div`,{"data-slot":`repo-cleanup`,className:`flex flex-col gap-4 pb-[calc(90px+env(safe-area-inset-bottom))] md:pb-0`,children:[(0,X.jsx)(Cn,{}),(0,X.jsx)(dn,{base:e.baseBranch??t.branch})]}):n===`branches`?(0,X.jsx)(Rt,{repo:e,info:t}):(0,X.jsx)(Kt,{})})}function An(e){let{sha:t}=w(),n=I(),r=e===`main`&&!n?t:void 0,i=c(r);if(!r)return;let a=r.slice(0,8);return{title:i.data?.subject??`Commit ${a}`,shortSha:a}}function jn({repo:e,info:t,section:n}){let r=e.baseBranch??t.branch;switch(n){case`main`:return(0,X.jsxs)(X.Fragment,{children:[e.log.length===0?`No commits yet`:`Latest ${e.log.length} commit${e.log.length===1?``:`s`} in the main checkout`,e.tracking?` · ${gt(e.tracking)}`:``]});case`not-landed`:return(0,X.jsxs)(X.Fragment,{children:[`Finished tasks whose commits are not on `,r]});case`branches`:return(0,X.jsx)(Mn,{repo:e,info:t});case`changes`:return(0,X.jsxs)(X.Fragment,{children:[e.status.length,` uncommitted file`,e.status.length===1?``:`s`,` in the main checkout`]});case`cleanup`:return(0,X.jsxs)(X.Fragment,{children:[`Nothing here can delete work that is not on `,r]})}}function Mn({repo:e,info:t}){let n=Gt(e,i().data?.branches).length;return(0,X.jsxs)(X.Fragment,{children:[n,` branch`,n===1?``:`es`,` · on `,t.branch]})}export{On as RepoGitRoute};
@@ -1 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{M as r,z as i}from"./queries-DHjNE2es.js";import{Cn as a,it as o}from"./toaster-Dglox5F-.js";import{_ as s,g as c,i as l,m as u,n as d,p as f}from"./chunk-KS7C4IRE-BdLLx37K.js";import{ct as p,r as m}from"./design-icons-QbNMZniQ.js";import{a as h,c as g,l as _,s as v,t as y}from"./file-preview-CJVN0cBa.js";import{t as b}from"./button-BV_AiLj2.js";import{t as x}from"./centered-state-N8vWM_Hw.js";import{r as S}from"./html-report-BX3msvci.js";import{_ as C,g as w,v as T,zn as E}from"./index-k2m-s5zD.js";import{t as D}from"./html-report-frame-Bk6UkqKa.js";var O=e(t(),1),k=n();function A(){let e=f(),t=u();return()=>{if(e.key==="default"||window.history.state?.idx===0){t({pathname:e.pathname.replace(/\/report\/?$/,``)},{replace:!0});return}let n=window.navigation,r=j(e.state);n?.canGoBack?n.back():r?t(r,{state:{filesRestoreKey:e.state?.filesRestoreKey}}):t(-1)}}function j(e){let t=e?.readerFrom;return typeof t==`string`&&t.startsWith(`/`)&&!t.startsWith(`//`)?t:null}function M(e){return e?.type===`file`?e:null}function N(){let[e]=s(),t=e.get(`path`),n=e.get(`artifact`);return{path:t,artifactId:n,conflict:e.getAll(`path`).length>1||e.getAll(`artifact`).length>1||t!==null&&n!==null||t===``||n===``}}function P(){let{id:e=``}=c(),t=N(),n=f(),r=A();return(0,k.jsx)(F,{runId:e,selection:t,fragment:n.hash,onBack:r,variant:`route`})}function F({runId:e,selection:t,fragment:n,onBack:r,variant:i,sourceLookup:a}){let{path:o,conflict:s,selected:c,result:u}=L(e,t,a),d=T(w,!0),p=T(C,!1),m=f(),[h,g]=(0,O.useState)(!1),_=M(u.data);if(i===`route`&&R(_))return(0,k.jsx)(l,{replace:!0,to:{pathname:m.pathname.replace(/\/report\/?$/,`/files`),search:m.search,hash:m.hash}});let v=B(_,o),y=i===`pane`&&!p&&!d?`Conversation`:`Back`,b=i===`pane`&&!h&&z(_),x=I(m.pathname,e,t);return(0,k.jsxs)(`div`,{"data-route":`task-report`,"data-variant":i,onKeyDown:e=>{i!==`pane`||e.key!==`Escape`||e.defaultPrevented||(e.preventDefault(),e.stopPropagation(),r())},className:i===`route`?`fixed inset-0 z-50 flex flex-col bg-background [padding-block-start:env(safe-area-inset-top)] [padding-inline-end:env(safe-area-inset-right)] [padding-block-end:env(safe-area-inset-bottom)] [padding-inline-start:env(safe-area-inset-left)] md:static md:z-auto md:h-full md:p-0`:`flex h-full min-h-0 flex-col bg-background max-md:[padding-block-start:env(safe-area-inset-top)] max-md:[padding-inline-start:env(safe-area-inset-left)] max-md:[padding-inline-end:env(safe-area-inset-right)]`,children:[(0,k.jsx)(V,{runId:e,file:_,name:v,source:h,onSource:()=>g(e=>!e),onBack:r,backLabel:y,hideDownload:i===`pane`&&p,focusBack:i===`pane`}),(0,k.jsx)(`div`,{"data-slot":`report-body`,className:b?`flex min-h-0 flex-1 flex-col overflow-clip`:`flex min-h-0 flex-1 flex-col overflow-auto`,children:(0,k.jsx)(H,{conflict:s,selected:c,result:u,source:h,name:v,fragment:n,pane:i===`pane`,filesHref:x})})]})}function I(e,t,n){let r=/^\/p\/[^/]+/.exec(e)?.[0]??``,i=n.artifactId?new URLSearchParams({artifact:n.artifactId}):new URLSearchParams({path:n.path??``});return`${r}/tasks/${encodeURIComponent(t)}/files?${i}`}function L(e,t,n){let{path:a=null,artifactId:o=null,conflict:s=!1}=t,c=n?.isPending||n?.isError,l=i(e,o||s||c?null:a),u=r(e,s||c?null:o),d=c&&n?{...n,data:void 0}:o?u:l;return{path:a,conflict:s,selected:a!==null||o!==null,result:d}}function R(e){return e!==null&&(!S(e.path)||!e.artifact&&(e.tooLarge||e.binary))}function z(e){return e!==null&&!e.tooLarge&&!e.binary}function B(e,t){return e?e.artifact?.name??e.path.split(/[\\/]/).at(-1)??e.path:t??`Report`}function V({runId:e,file:t,name:n,source:r,onSource:i,onBack:a,backLabel:s,hideDownload:c,focusBack:l}){let u=(0,O.useRef)(null);(0,O.useEffect)(()=>{l&&u.current?.focus({preventScroll:!0})},[l]);let d=t?.artifact;return(0,k.jsxs)(`header`,{"data-slot":`report-bar`,className:`flex min-h-14 shrink-0 items-center gap-2 border-b border-border bg-card px-2 md:px-4`,children:[(0,k.jsxs)(b,{ref:u,variant:`ghost`,className:`gap-1.5 px-2`,onClick:a,"aria-label":s,children:[(0,k.jsx)(m,{size:18,"aria-hidden":`true`}),(0,k.jsx)(`span`,{className:`max-sm:sr-only`,children:s})]}),(0,k.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,k.jsx)(`h1`,{className:`truncate text-sm font-medium`,children:n}),t?(0,k.jsxs)(`p`,{className:`truncate text-xs text-soft-foreground`,children:[d?(0,k.jsxs)(k.Fragment,{children:[`Published snapshot · `,(0,k.jsx)(E,{iso:d.createdAt})]}):`Live file`,` · `,h(t.size)]}):null]}),t&&!t.tooLarge&&!t.binary?(0,k.jsx)(b,{variant:`ghost`,className:`px-3 text-accent-text`,onClick:i,children:r?`Preview`:`Source`}):null,d&&!c?(0,k.jsx)(`a`,{className:`inline-flex min-h-11 items-center rounded-md px-3 text-sm text-accent-text underline focus-visible:ring-2`,href:o(e,d.id,`download`),children:`Download`}):null]})}function H({conflict:e,selected:t,result:n,source:r,name:i,fragment:a,pane:o,filesHref:s}){if(e)return(0,k.jsx)(W,{icon:(0,k.jsx)(v,{}),title:`Invalid report link`,subtitle:`Choose either a path or a published artifact.`});if(!t)return(0,k.jsx)(W,{icon:(0,k.jsx)(g,{}),title:`No report selected`,subtitle:`Open a report from a link in the conversation or from Files.`});if(n.isPending)return(0,k.jsx)(`p`,{role:`status`,"data-slot":`report-loading`,className:`px-4 py-6 text-center text-sm text-soft-foreground`,children:`Loading report…`});if(n.isError)return(0,k.jsx)(U,{result:n});let c=n.data;return c.type===`file`?o&&!S(c.path)?(0,k.jsx)(W,{icon:(0,k.jsx)(g,{}),title:`Not an HTML report`,subtitle:`Open this published file in Files.`,action:(0,k.jsx)(d,{to:s,className:`inline-flex min-h-11 items-center rounded-md px-3 text-sm text-accent-text underline active:bg-muted focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring`,children:`Open in Files`})}):c.tooLarge?(0,k.jsx)(W,{icon:(0,k.jsx)(_,{}),title:`Too large to preview`,subtitle:`${h(c.size)} is past the 500 kB preview limit. Download it to read it.`}):c.binary?(0,k.jsx)(W,{icon:(0,k.jsx)(g,{}),title:`Binary file`,subtitle:`This file holds binary data, not readable HTML.`}):r?(0,k.jsx)(`div`,{className:`bg-card`,children:(0,k.jsx)(y,{path:c.path,text:c.content??``})}):(0,k.jsx)(D,{html:c.content??``,title:`Report: ${i}`,fragment:a,className:o?`min-h-0 flex-1`:`min-h-[60dvh] flex-1`}):(0,k.jsx)(W,{icon:(0,k.jsx)(v,{}),title:c.type===`unpublished`?`Report not published`:`Report unavailable`,subtitle:c.reason})}function U({result:e}){let t=e.error instanceof a&&e.error.status===404;return(0,k.jsx)(W,{icon:t?(0,k.jsx)(v,{}):(0,k.jsx)(p,{size:16}),tone:t?`neutral`:`danger`,title:t?`Report missing or deleted`:`Could not load this report`,subtitle:e.error?.message??`Try again.`,action:(0,k.jsx)(b,{variant:`outline`,onClick:()=>void e.refetch(),children:`Retry`})})}function W({icon:e,title:t,subtitle:n,tone:r=`neutral`,action:i}){return(0,k.jsxs)(`div`,{"data-slot":`report-state`,className:`flex flex-col items-center gap-3 p-6`,children:[(0,k.jsx)(x,{icon:e,tone:r,heading:`h2`,title:t,subtitle:n}),i]})}export{F as ReportReader,P as TaskReportRoute};
@@ -1 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{Lt as r,M as i,st as a,vt as o}from"./queries-DHjNE2es.js";import{h as s}from"./host-context-iTMFRMT5.js";import{Ai as c,An as l,En as u,Ii as d,Ji as f,Ki as p,er as m,nr as h,wn as g}from"./toaster-Dglox5F-.js";import{B as _,F as v,I as y,J as b,N as x,W as S,Y as C,z as w}from"./live-protocol-CNUmr-VT.js";import{h as T,p as E}from"./chunk-KS7C4IRE-BdLLx37K.js";import{o as D}from"./dist-CCX8mhHc.js";import{Q as ee}from"./design-icons-QbNMZniQ.js";import{t as te}from"./arrow-up-right-DKGzsMqY.js";import{t as O}from"./chevron-right-BENZ-1ZN.js";import{t as k}from"./eye-B8okNWXU.js";import{t as A}from"./button-BV_AiLj2.js";import{t as j}from"./project-router-CPgPVoBJ.js";import{f as M,i as N,n as P,r as ne,t as re,u as F}from"./page-shell-BdjH5hyc.js";import{t as I}from"./use-search-params-writer-DD5PEEZw.js";import{Tn as L,j as R,lr as z,qn as B,vr as V,zn as H}from"./index-k2m-s5zD.js";import{t as U}from"./report-title-D4Mbu2Er.js";import{t as W}from"./html-report-frame-Bk6UkqKa.js";var G=e(t(),1),K=1e3,q=S().min(1).max(1024);_({q:S().max(K).optional(),before:q.optional(),limit:S().regex(/^(?:[1-9]|[1-9][0-9]|100)$/).transform(Number).optional()}).strict();var J=_({reports:x(_({id:b(),runId:b(),name:S(),title:S(),createdAt:C(),size:w().int().nonnegative(),taskTitle:S(),taskStatus:c}).strict()),nextCursor:q.nullable(),total:w().int().nonnegative()}).strict(),Y=_({epoch:b(),generation:w().int().nonnegative(),metadataGeneration:w().int().nonnegative()}).strict(),ie=_({runId:b(),taskTitle:S(),taskStatus:c}).strict(),ae=v(`type`,[Y.extend({type:y(`snapshot`)}),Y.extend({type:y(`content`)}),Y.extend({type:y(`metadata`),runs:x(ie)})]),X=new WeakMap;function oe(e,t){if(!e)return{content:t.type===`content`,metadata:t.type===`metadata`,reset:!1};if(e.epoch!==t.epoch)return{content:!0,metadata:!0,reset:!0};if(!(t.generation<e.generation||t.metadataGeneration<e.metadataGeneration)&&!(e.generation===t.generation&&e.metadataGeneration===t.metadataGeneration))return{content:t.generation!==e.generation,metadata:t.metadataGeneration!==e.metadataGeneration,reset:!1}}var se=class{client;project;state;content=0;metadata=0;patches=new Map;trailing=new Set;flights=new Map;constructor(e,t){this.client=e,this.project=t,e.getQueryCache().subscribe(n=>{if(n.type===`removed`){this.trailing.delete(n.query),this.flights.delete(n.query);return}if(!(n.query.queryKey[0]!==t||n.query.queryKey[1]!==`reports`)){if(n.type===`updated`&&n.action.type===`fetch`&&this.flights.set(n.query,this.metadata),n.query.state.fetchStatus===`idle`&&this.flights.has(n.query)){let e=this.flights.get(n.query);this.flights.delete(n.query),e!==this.metadata&&String(n.query.queryKey[2]??``).trim()===``&&this.client.setQueryData(n.query.queryKey,t=>t&&{...t,pages:t.pages.map(t=>this.patch(t,e))})}!this.trailing.has(n.query)||n.query.state.fetchStatus!==`idle`||(this.trailing.delete(n.query),queueMicrotask(()=>{e.invalidateQueries({queryKey:n.query.queryKey,exact:!0,refetchType:`active`},{cancelRefetch:!1})}))}})}patch(e,t=-1){return{...e,reports:e.reports.map(e=>{let n=this.patches.get(e.runId);return n&&n.version>t?{...e,taskTitle:n.value.taskTitle,taskStatus:n.value.taskStatus}:e})}}async read(e,t){for(;;){let n=this.content,r=this.metadata,i=await t();if(!(n!==this.content||e.trim()!==``&&r!==this.metadata))return e.trim()===``?this.patch(i,r):i}}receive(e,t=!1){let n=this.state;if(!n&&e.type===`snapshot`){this.state=e,this.content++,this.client.getQueryCache().findAll({queryKey:[this.project,`reports`]}).some(e=>e.state.data!==void 0)&&this.invalidate(!0);return}let r=oe(n,e);if(!r){t&&e.type===`snapshot`&&(this.content++,this.invalidate(!0));return}let{metadata:i,reset:a}=r,o=r.content||t&&e.type===`snapshot`;this.state=e,a&&this.patches.clear(),i&&this.metadata++,o&&this.content++,e.type===`metadata`&&!a&&this.patchCaches(e);let s=o||i&&e.type!==`metadata`;(s||i)&&this.invalidate(s)}patchCaches(e){for(let t of e.runs)this.patches.set(t.runId,{value:t,version:this.metadata});this.client.setQueriesData({queryKey:[this.project,`reports`],predicate:e=>String(e.queryKey[2]??``).trim()===``},e=>e&&{...e,pages:e.pages.map(e=>this.patch(e,this.metadata-1))})}invalidate(e){let t={queryKey:[this.project,`reports`],refetchType:`active`,...e?{}:{predicate:e=>String(e.queryKey[2]??``).trim()!==``}};for(let e of this.client.getQueryCache().findAll(t))e.state.fetchStatus===`fetching`&&this.trailing.add(e);this.client.invalidateQueries(t,{cancelRefetch:!1})}};function ce(e,t){let n=X.get(e);n||(n=new Map,X.set(e,n));let r=n.get(t);return r||(r=new se(e,t),n.set(t,r)),r}async function le(e,t){let n=await g.api.v1.p[`:projectId`].reports.state.$get({param:{projectId:e}},u({signal:t}));return Y.parse(await l(n,`/reports/state`))}function ue(e){let t=ce(f(),e);return(0,G.useEffect)(()=>{let n=r(`reports:project:${e}`,e=>{let n=ae.safeParse(e);n.success&&t.receive(n.data,n.data.type===`snapshot`)}),i,o,s=()=>{if(m()===`finite`&&!i){o=new AbortController;let n=o.signal;le(e,n).then(e=>{n.aborted||t.receive({type:`snapshot`,...e})}).catch(()=>void 0),i=a({path:`/api/v1/p/${encodeURIComponent(e)}/reports/state`,intervalMs:5e3},(e,n)=>{let r=Y.safeParse(e);!n&&r.success&&t.receive({type:`snapshot`,...r.data})})}else m()!==`finite`&&(o?.abort(),i?.(),i=void 0)};s();let c=h(s);return()=>{c(),o?.abort(),i?.(),n()}},[t,e]),t}async function de(e,t,n,r){let i=await g.api.v1.p[`:projectId`].reports.$get({param:{projectId:e},query:{q:t.slice(0,K),...n?{before:n}:{}}},u(r?{signal:r}:void 0));return J.parse(await l(i,`/reports`))}function fe(e){let t=s(),n=ue(t);return d({queryKey:[t,`reports`,e],initialPageParam:void 0,queryFn:({pageParam:r,signal:i})=>n.read(e,()=>de(t,e,r,i)),getNextPageParam:e=>e.nextCursor??void 0,staleTime:0,refetchOnWindowFocus:!0})}var Z=n(),Q=new Map,$={title:`Reports`,subtitle:`Published HTML snapshots from tasks in this project.`};function pe(){let e=B(),t=o();return e===`unknown`?(0,Z.jsx)(F,{route:`reports`,density:`full`,fillHeight:!0,bodyClassName:`gap-4`,header:$,children:(0,Z.jsx)(`div`,{"data-slot":`reports-list`,className:`min-h-0 flex-1 overflow-y-auto overscroll-contain`,children:t.isError&&!t.isFetching?(0,Z.jsxs)(`div`,{role:`alert`,className:`flex flex-col items-start gap-3 rounded-xl border border-border bg-card p-5`,children:[(0,Z.jsx)(`p`,{className:`text-sm font-medium text-foreground`,children:`Could not load reports`}),(0,Z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:t.error instanceof Error?t.error.message:`Could not reach the server`}),(0,Z.jsx)(A,{variant:`outline`,onClick:()=>void t.refetch(),children:`Retry`})]}):(0,Z.jsx)(`p`,{role:`status`,className:`py-4 text-sm text-muted-foreground`,children:`Loading reports…`})})}):e===`absent`?(0,Z.jsx)(R,{}):(0,Z.jsx)(me,{})}function me(){let e=E(),t=T(),[n,r]=I(),i=(n.get(`q`)??``).slice(0,K),a=fe(i),o=(0,G.useRef)(null),s=(0,G.useRef)(null),c=(0,G.useRef)(``),l=e.pathname+e.search,u=a.data?.pages.flatMap(e=>e.reports)??[],d=e=>{Q.set(l,{scroll:s.current?.scrollTop??0,row:e,pages:a.data?.pages.length??1})},[f,p]=(0,G.useState)(null),m=N(o);(0,G.useLayoutEffect)(()=>{if(!a.data||c.current===l)return;let n=Q.get(l),r=e.state?.filesRestoreKey===l;if(!n||!s.current||t!==`POP`&&!r){c.current=l;return}let i=s.current.querySelector(`[data-report-id="${n.row}"]`);if(a.isFetchNextPageError){c.current=l,s.current.scrollTop=0;return}if((!i||a.data.pages.length<n.pages)&&a.hasNextPage){a.isFetchingNextPage||a.fetchNextPage();return}c.current=l,s.current.scrollTop=i?n.scroll:0,i?.focus({preventScroll:!0})},[l,a.data,a.hasNextPage,a.isFetchingNextPage,a.isFetchNextPageError,a.fetchNextPage,e.state,t]);let h=t=>r(n=>(t?n.set(`q`,t.slice(0,K)):n.delete(`q`),Q.delete(e.pathname+`?`+n.toString()),n)),g=u.find(e=>e.id===f)??u[0]??null,_=a.isPending?`full`:M(u.length);return(0,Z.jsx)(F,{route:`reports`,density:_,fillHeight:!0,bodyClassName:`gap-4`,header:$,children:(0,Z.jsxs)(`div`,{ref:o,"data-slot":`reports-content`,className:`flex min-h-0 min-w-0 flex-1 flex-col gap-4`,children:[(0,Z.jsxs)(`div`,{className:`relative w-full shrink-0`,children:[(0,Z.jsx)(ee,{"aria-hidden":`true`,className:`pointer-events-none absolute top-1/2 left-3 size-4 -translate-y-1/2 text-muted-foreground`}),(0,Z.jsx)(z,{maxLength:K,"aria-label":`Search reports`,placeholder:`Search reports or source tasks…`,value:i,onChange:e=>h(e.target.value),className:`h-10 w-full rounded-lg border-border bg-card pl-9 text-sm max-md:h-11`})]}),a.isPending?(0,Z.jsx)(`div`,{ref:s,"data-slot":`reports-list`,className:`min-h-0 flex-1 overflow-y-auto overscroll-contain`,children:(0,Z.jsx)(`p`,{role:`status`,className:`py-4 text-sm text-muted-foreground`,children:`Loading reports…`})}):a.isError&&u.length===0?(0,Z.jsx)(`div`,{ref:s,"data-slot":`reports-list`,className:`min-h-0 flex-1 overflow-y-auto overscroll-contain`,children:(0,Z.jsxs)(`div`,{role:`alert`,className:`flex flex-col items-start gap-3 rounded-xl border border-border bg-card p-5`,children:[(0,Z.jsx)(`p`,{className:`text-sm font-medium text-foreground`,children:`Could not load reports`}),(0,Z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:a.error.message}),(0,Z.jsx)(A,{variant:`outline`,onClick:()=>void a.refetch(),children:`Retry`})]})}):u.length===0?(0,Z.jsx)(`div`,{ref:s,"data-slot":`reports-list`,className:`min-h-0 flex-1 overflow-y-auto overscroll-contain`,children:(0,Z.jsx)(re,{icon:(0,Z.jsx)(V,{}),title:i?`No matching reports`:`No published reports yet`,description:i?`Try a different keyword or clear the search filter.`:(0,Z.jsxs)(Z.Fragment,{children:[`Publish an HTML snapshot with`,` `,(0,Z.jsxs)(`code`,{className:`rounded bg-muted px-1.5 py-0.5 font-mono text-xs text-foreground`,children:[L(),` artifact publish`]}),` `,`to list it here.`]}),actions:i?(0,Z.jsx)(A,{"data-slot":`reports-clear-search`,variant:`outline`,onClick:()=>h(``),children:`Clear search`}):(0,Z.jsx)(A,{variant:`outline`,asChild:!0,children:(0,Z.jsx)(j,{to:`/new`,children:`Start a task`})})})}):(0,Z.jsx)(ne,{list:(0,Z.jsxs)(`div`,{ref:s,"data-slot":`reports-list`,className:`min-h-0 flex-1 overflow-y-auto overscroll-contain`,children:[(0,Z.jsx)(`ul`,{className:`flex flex-col gap-1.5`,"aria-label":`Reports`,children:u.map(e=>{let t=g?.id===e.id;return(0,Z.jsxs)(`li`,{"data-slot":`report-row`,"data-selected":m&&t?`true`:void 0,className:D(`reports-row flex items-center gap-3 rounded-xl border border-border bg-card px-4 py-3 transition-colors`,m&&t&&`border-accent-strong/60 bg-sidebar-row-selected/40`),children:[(0,Z.jsx)(V,{"aria-hidden":`true`,className:`reports-icon mt-0.5 size-4 shrink-0 self-start text-accent-text`}),(0,Z.jsxs)(`div`,{className:`reports-lines flex min-w-0 flex-1 flex-col gap-1`,children:[(0,Z.jsx)(`h2`,{className:`flex min-w-0 text-[14px] leading-5 font-semibold text-foreground`,title:U(e),children:(0,Z.jsx)(j,{"data-report-id":e.id,className:`reports-open text-foreground no-underline`,to:`/tasks/${e.runId}/report?artifact=${e.id}`,state:{readerFrom:l,filesRestoreKey:l},onClick:()=>d(e.id),children:(0,Z.jsx)(`span`,{className:`min-w-0 truncate`,children:U(e)})})}),(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5 text-xs leading-4 text-muted-foreground`,children:[(0,Z.jsx)(j,{className:`reports-task min-w-0 truncate text-xs text-muted-foreground no-underline hover:text-foreground hover:underline`,to:`/tasks/${e.runId}`,children:(0,Z.jsx)(`span`,{className:`min-w-0 truncate`,title:e.taskTitle,children:e.taskTitle})}),(0,Z.jsx)(`span`,{"aria-hidden":`true`,className:`shrink-0`,children:`·`}),(0,Z.jsx)(H,{className:`shrink-0`,iso:e.createdAt,prefix:`Published · `})]})]}),m?(0,Z.jsx)(`button`,{type:`button`,"data-slot":`report-preview-select`,"aria-label":`Preview ${U(e)}`,"aria-pressed":t,onClick:()=>p(e.id),className:`reports-preview-btn inline-flex min-h-8 min-w-8 shrink-0 items-center justify-center gap-1 rounded-md border border-border bg-background px-2 py-1.5 text-xs text-muted-foreground hover:text-foreground focus-visible:outline-2 focus-visible:outline-ring`,children:(0,Z.jsx)(k,{"aria-hidden":`true`,className:`size-3.5`})}):(0,Z.jsx)(O,{"aria-hidden":`true`,"data-slot":`report-open-cue`,className:`reports-cue size-4 shrink-0 text-muted-foreground`})]},e.id)})}),a.hasNextPage?(0,Z.jsx)(`div`,{className:`mt-4`,children:(0,Z.jsx)(A,{variant:`outline`,disabled:a.isFetchingNextPage,onClick:()=>void a.fetchNextPage(),children:`Load more reports`})}):null,_===`sparse`?(0,Z.jsx)(P,{summary:`${u.length} published ${u.length===1?`report`:`reports`}. Select a row to open full screen or preview beside the list.`}):null]}),detail:m&&g?(0,Z.jsx)(he,{report:g,restoreKey:l,onOpenReader:()=>d(g.id)}):null})]})})}function he({report:e,restoreKey:t,onOpenReader:n}){let r=(0,G.useContext)(p)!==void 0;return(0,Z.jsxs)(`section`,{"data-slot":`reports-preview-pane`,"aria-label":`Preview of ${U(e)}`,className:`flex min-h-0 flex-1 flex-col overflow-hidden rounded-xl border border-border bg-card`,children:[(0,Z.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center justify-between gap-2 border-b border-border px-4 py-3`,children:[(0,Z.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Z.jsx)(`h2`,{className:`truncate text-sm font-semibold text-foreground`,children:U(e)}),(0,Z.jsxs)(`p`,{className:`mt-0.5 truncate text-xs text-muted-foreground`,children:[e.taskTitle,` · `,(0,Z.jsx)(H,{iso:e.createdAt,prefix:`Published · `})]})]}),(0,Z.jsx)(A,{variant:`outline`,size:`sm`,asChild:!0,className:`shrink-0 py-1.5`,children:(0,Z.jsxs)(j,{"data-slot":`reports-preview-open`,to:`/tasks/${e.runId}/report?artifact=${e.id}`,state:{readerFrom:t,filesRestoreKey:t},onClick:n,children:[`Open reader`,(0,Z.jsx)(te,{"aria-hidden":`true`,className:`size-3.5`})]})})]}),r?(0,Z.jsx)(ge,{report:e}):(0,Z.jsx)(`div`,{className:`flex flex-1 items-center justify-center p-6 text-xs text-muted-foreground`,children:`Open reader to view this HTML report.`})]})}function ge({report:e}){let t=i(e.runId,e.id);if(t.isPending)return(0,Z.jsx)(`p`,{role:`status`,className:`p-6 text-xs text-muted-foreground`,children:`Loading preview…`});if(t.isError)return(0,Z.jsxs)(`div`,{role:`alert`,className:`flex flex-col items-start gap-2 p-6 text-xs text-muted-foreground`,children:[(0,Z.jsx)(`p`,{className:`font-medium text-foreground`,children:`Could not load report preview`}),(0,Z.jsx)(`p`,{children:t.error.message}),(0,Z.jsx)(A,{variant:`outline`,size:`sm`,onClick:()=>void t.refetch(),children:`Retry`})]});let n=t.data;return!n||n.type!==`file`||n.binary||n.content===void 0?(0,Z.jsx)(`p`,{className:`p-6 text-xs text-muted-foreground`,children:`Preview unavailable for this artifact.`}):(0,Z.jsx)(W,{html:n.content,title:U(e),className:`min-h-0 flex-1`})}export{pe as ReportsRoute};
@@ -1 +0,0 @@
1
- import{n as e,r as t}from"./rolldown-runtime-QTnfLwEv.js";import{i as n,t as r}from"./react-runtime-CCIEwYL0.js";import{En as i,Tn as a,ct as o,in as s}from"./queries-DHjNE2es.js";import{Cn as c,Ji as l,ct as u,n as d,ut as f}from"./toaster-Dglox5F-.js";import{n as p}from"./chunk-KS7C4IRE-BdLLx37K.js";import{o as m,s as h}from"./dist-CCX8mhHc.js";import{I as g,l as _,y as v}from"./design-icons-QbNMZniQ.js";import{t as y}from"./createLucideIcon-BHp8sXmF.js";import{t as b}from"./external-link-BE6y205O.js";import{t as x}from"./eye-B8okNWXU.js";import{t as S}from"./button-BV_AiLj2.js";import{t as C}from"./project-router-CPgPVoBJ.js";import{Ln as w,fn as T,rt as E,y as D}from"./index-k2m-s5zD.js";import{t as O}from"./textarea-BGp28xFr.js";import{n as k,t as A}from"./use-finish-run-jVAqsGkV.js";import{r as j,t as M}from"./review-notes-drafts-D25BaEEb.js";var N=y(`corner-up-left`,[[`path`,{d:`M20 20v-7a4 4 0 0 0-4-4H4`,key:`1nkjon`}],[`path`,{d:`M9 14 4 9l5-5`,key:`102s5s`}]]),P=e({ReviewActions:()=>R,ReviewStrip:()=>L}),F=t(n(),1),I=r();function L({run:e,projectId:t}){let n=D(e);return(0,I.jsx)(`section`,{"data-slot":`review-strip`,"aria-label":`Review the changes`,className:`sticky bottom-0 z-20 shrink-0 border-t border-info/35 bg-background`,children:(0,I.jsxs)(`div`,{className:`flex flex-col gap-2 bg-info/10 px-4 py-2 md:flex-row md:items-start md:gap-4 md:px-9`,children:[(0,I.jsxs)(`p`,{"data-slot":`review-evidence`,className:`flex min-h-11 min-w-0 shrink-0 items-center gap-2 text-xs text-muted-foreground max-md:hidden`,children:[(0,I.jsx)(x,{className:`size-4 shrink-0 text-semantic-info`,"aria-hidden":`true`}),(0,I.jsx)(`span`,{className:`font-semibold text-foreground`,children:`Needs review`}),n.diff?(0,I.jsxs)(`span`,{"data-slot":`review-evidence-diff`,className:`flex items-center gap-1.5`,children:[(0,I.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),n.diff.files,` `,n.diff.files===1?`file`:`files`,(0,I.jsx)(w,{stat:n.diff})]}):null,n.checks?(0,I.jsxs)(`span`,{"data-slot":`review-evidence-checks`,className:m(`flex items-center gap-1.5`,n.checks.failed&&`font-medium text-semantic-red`),children:[(0,I.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),n.checks.label]}):null]}),(0,I.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,I.jsx)(R,{run:e,projectId:t,reviewLink:!1})})]})})}function R({run:e,projectId:t,onResolved:n,reviewLink:r=!0}){let m=o(),v=l(),y=(0,F.useRef)(null),w=j(e.id),{notes:D,open:P,clear:L}=w,R=e=>w.update({notes:e}),[B,V]=(0,F.useState)(null),[H,U]=(0,F.useState)(null),W=A(e.id,{projectId:t,onSuccess:()=>{L(),n?.()}}),G=k(e,null,t),K=()=>v.invalidateQueries({queryKey:s.runs.all}),q=i({mutationFn:async n=>G.canContinue?u(a(e.id,{projectId:t}),{text:`Review feedback:\n${n}`,runner:G.runnerOverride}):null,onMutate:()=>a(e.id,{projectId:t}),onSuccess:(t,r,i)=>{t!==null&&(M(e.id).notes.trim()===r&&L(),m.invalidateAfter(`continue`,i),n?.())},onError:e=>d(e.message,{tone:`danger`})}),J=i({mutationFn:()=>f(e.id,t),onSuccess:e=>{d(`Draft PR created — ${e.url}`),L(),K(),n?.()},onError:e=>{e instanceof c&&e.manual!==void 0&&U(e.manual),d(e.message,{tone:`danger`})}}),Y=()=>{if(!P){w.update({open:!0}),requestAnimationFrame(()=>y.current?.focus());return}let e=D.trim();if(e.length===0){V(`Write what to change first.`),y.current?.focus();return}V(null),q.mutate(e)};return(0,I.jsxs)(`div`,{"data-slot":`review-actions`,className:`flex flex-col gap-2`,children:[G.canContinue?null:(0,I.jsxs)(`p`,{id:`review-provider-guidance`,className:`flex flex-wrap items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,I.jsx)(`span`,{children:G.reason}),G.providerPending?null:(0,I.jsx)(C,{to:`/settings/agent-defaults#providers`,className:`font-medium text-foreground underline underline-offset-4`,children:`Configure providers`})]}),(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 [&_button:not([data-button-size])]:min-h-11 [&_a:not([data-button-size])]:min-h-11`,children:[r?(0,I.jsx)(S,{asChild:!0,variant:`outline`,size:`sm`,children:t?(0,I.jsxs)(p,{to:`/p/${encodeURIComponent(t)}/tasks/${encodeURIComponent(e.id)}/changes`,children:[(0,I.jsx)(x,{"aria-hidden":`true`}),`Review changes`]}):(0,I.jsxs)(C,{to:`/tasks/${e.id}/changes`,children:[(0,I.jsx)(x,{"aria-hidden":`true`}),`Review changes`]})}):null,(0,I.jsxs)(S,{"data-slot":`review-send-back`,variant:`outline`,size:`sm`,title:G.reason??(P?`Send the notes back into the agent's session`:`Write notes for the agent`),"aria-describedby":G.canContinue?void 0:`review-provider-guidance`,"aria-expanded":P,"aria-controls":P?`review-notes`:void 0,disabled:q.isPending||!G.canContinue,onClick:Y,children:[(0,I.jsx)(N,{"aria-hidden":`true`}),P?`Send back with notes`:`Send back`]}),h(e.pullRequestUrl)?(0,I.jsx)(S,{asChild:!0,variant:`outline`,size:`sm`,children:(0,I.jsxs)(`a`,{"data-slot":`pr-link`,href:e.pullRequestUrl,target:`_blank`,rel:`noopener noreferrer`,title:`The PR for this task is already open`,children:[(0,I.jsx)(b,{"aria-hidden":`true`}),`PR ↗`]})}):(0,I.jsxs)(S,{"data-slot":`review-draft-pr`,variant:`outline`,size:`sm`,title:`Push the branch and open a draft PR`,disabled:J.isPending,onClick:()=>J.mutate(),children:[(0,I.jsx)(g,{"aria-hidden":`true`}),`Draft PR`]}),e.finishBlocked===null?(0,I.jsxs)(S,{"data-slot":`review-accept`,variant:`primary`,size:`sm`,className:`[margin-inline-start:auto]`,title:T(`review`),disabled:W.isPending,onClick:()=>W.mutate(),children:[(0,I.jsx)(_,{"aria-hidden":`true`}),`Accept`]}):null]}),P?(0,I.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,I.jsx)(O,{ref:y,id:`review-notes`,"data-slot":`review-notes`,"aria-label":`Notes for the agent`,"aria-invalid":B!==null||void 0,"aria-describedby":B===null?void 0:`review-notes-error`,placeholder:`Notes for the agent — what should change?`,rows:1,value:D,onChange:e=>{let t=e.target.value;R(t),B!==null&&t.trim().length>0&&V(null)},onKeyDown:e=>{E(e)&&(e.preventDefault(),Y())},className:`max-h-[min(24dvh,180px)] min-h-11 overflow-y-auto overscroll-contain text-base md:text-[13px]`}),(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[B===null?(0,I.jsx)(`span`,{}):(0,I.jsx)(`p`,{id:`review-notes-error`,"data-slot":`review-notes-error`,role:`alert`,className:`text-xs font-medium text-semantic-red`,children:B}),(0,I.jsx)(S,{"data-slot":`review-notes-cancel`,variant:`ghost`,size:`sm`,title:`Fold the notes box and drop the notes`,onClick:()=>{V(null),L()},children:`Cancel`})]})]}):null,H===null?null:(0,I.jsx)(z,{command:H})]})}function z({command:e}){return(0,I.jsxs)(`button`,{type:`button`,"data-slot":`review-manual`,title:`Copy the command`,onClick:()=>{navigator.clipboard.writeText(e).then(()=>d(`Command copied to clipboard.`)).catch(()=>d(`Run manually: ${e}`))},className:`flex w-full min-w-0 items-center gap-1.5 rounded-sm px-1 py-0.5 text-left font-mono text-xs text-soft-foreground hover:bg-muted hover:text-foreground`,children:[(0,I.jsx)(v,{className:`size-3 shrink-0`,"aria-hidden":`true`}),(0,I.jsxs)(`span`,{className:`truncate`,children:[`manual path: `,e]})]})}export{P as n,R as t};