@hearsay-tools/squawk 0.19.0-dev.9172 → 0.19.0-dev.9180

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 (150) hide show
  1. package/dist/ci-wait/controller.d.ts +7 -7
  2. package/dist/contract/hosts.d.ts +925 -0
  3. package/dist/contract/index.js +104 -2
  4. package/dist/core/server-hook-registry.d.ts +13 -0
  5. package/dist/core/server-hook-registry.js.map +1 -1
  6. package/dist/delegation/routes.d.ts +78 -78
  7. package/dist/features/hosts/admission.d.ts +52 -0
  8. package/dist/features/hosts/admission.js +89 -0
  9. package/dist/features/hosts/admission.js.map +1 -0
  10. package/dist/features/hosts/gateway.d.ts +14 -3
  11. package/dist/features/hosts/gateway.js +35 -21
  12. package/dist/features/hosts/gateway.js.map +1 -1
  13. package/dist/features/hosts/index.d.ts +7 -3
  14. package/dist/features/hosts/index.js +41 -7
  15. package/dist/features/hosts/index.js.map +1 -1
  16. package/dist/features/hosts/registry-reconciler.d.ts +41 -0
  17. package/dist/features/hosts/registry-reconciler.js +168 -0
  18. package/dist/features/hosts/registry-reconciler.js.map +1 -0
  19. package/dist/features/hosts/routes.d.ts +414 -48
  20. package/dist/features/hosts/routes.js +72 -62
  21. package/dist/features/hosts/routes.js.map +1 -1
  22. package/dist/features/hosts/runs-index-events.d.ts +23 -0
  23. package/dist/features/hosts/runs-index-events.js +116 -0
  24. package/dist/features/hosts/runs-index-events.js.map +1 -0
  25. package/dist/features/hosts/runs-index-patch.d.ts +203 -0
  26. package/dist/features/hosts/runs-index-patch.js +798 -0
  27. package/dist/features/hosts/runs-index-patch.js.map +1 -0
  28. package/dist/features/hosts/runs-index.d.ts +149 -0
  29. package/dist/features/hosts/runs-index.js +762 -0
  30. package/dist/features/hosts/runs-index.js.map +1 -0
  31. package/dist/features/hosts/runs-search.d.ts +28 -0
  32. package/dist/features/hosts/runs-search.js +151 -0
  33. package/dist/features/hosts/runs-search.js.map +1 -0
  34. package/dist/features/hosts/supervisor.d.ts +4 -0
  35. package/dist/features/hosts/supervisor.js +14 -6
  36. package/dist/features/hosts/supervisor.js.map +1 -1
  37. package/dist/features/reports/routes.d.ts +2 -2
  38. package/dist/features/webhooks/routes.d.ts +38 -38
  39. package/dist/plugin/index.d.ts +1 -1
  40. package/dist/plugin/index.js.map +1 -1
  41. package/dist/server/activity-routes.d.ts +23 -23
  42. package/dist/server/models-routes.d.ts +12 -12
  43. package/dist/server/project-settings-routes.d.ts +107 -107
  44. package/dist/server/projects-routes.d.ts +41 -41
  45. package/dist/server/provider-sign-in-routes.d.ts +2 -2
  46. package/dist/server/providers-routes.d.ts +58 -58
  47. package/dist/server/runner-install-routes.d.ts +10 -10
  48. package/dist/server/runners-routes.d.ts +10 -10
  49. package/dist/server/runs-routes.d.ts +344 -344
  50. package/dist/server/server.d.ts +1195 -1195
  51. package/dist/server/server.js +7 -1
  52. package/dist/server/server.js.map +1 -1
  53. package/dist/server/workspace-identity-routes.d.ts +5 -5
  54. package/dist/server/workspace-live-routes.d.ts +5 -5
  55. package/dist/server/workspace-routes.d.ts +85 -85
  56. package/dist/server/workspace-run-feed.d.ts +4 -0
  57. package/dist/server/workspace-run-feed.js +13 -0
  58. package/dist/server/workspace-run-feed.js.map +1 -1
  59. package/package.json +4 -4
  60. package/scripts/benchmark-hosts-runs-index-probes.ts +242 -0
  61. package/scripts/benchmark-hosts-runs-index.ts +776 -0
  62. package/web/dist/assets/accounts-section-BDUoikVg.js +1 -0
  63. package/web/dist/assets/activity-motion-CYdEr0hu.js +1 -0
  64. package/web/dist/assets/{activity-route-C2zP5vVV.js → activity-route-D8BPLoZj.js} +1 -1
  65. package/web/dist/assets/{agent-accounts-D_ZKAmaW.js → agent-accounts-C2ILQhZy.js} +1 -1
  66. package/web/dist/assets/{agent-config-section-CwK_izpU.js → agent-config-section-BO8w2cry.js} +2 -2
  67. package/web/dist/assets/agent-defaults-section-BBcv7Vbh.js +1 -0
  68. package/web/dist/assets/{appearance-DvoRcoRX.js → appearance-yF_NXlq5.js} +1 -1
  69. package/web/dist/assets/{archive-on-merge-field-DWPtF9dh.js → archive-on-merge-field-Dh1M21D6.js} +1 -1
  70. package/web/dist/assets/{ask-card-D-om0EtP.js → ask-card-2E9m5VRA.js} +1 -1
  71. package/web/dist/assets/attention-C7BUdd2s.js +1 -0
  72. package/web/dist/assets/automations-route-D27bK2j6.js +2 -0
  73. package/web/dist/assets/{commit-list-CPJLP4DU.js → commit-list-sFxchD2V.js} +1 -1
  74. package/web/dist/assets/{diff-BQJN6jzN.js → diff-C5-32cRp.js} +2 -2
  75. package/web/dist/assets/{diff-controls-AsSX7gfO.js → diff-controls-Ci36iPlK.js} +1 -1
  76. package/web/dist/assets/{diff-view-BW5bbiaq.js → diff-view-CCtuYJNL.js} +1 -1
  77. package/web/dist/assets/{discard-changes-dialog-Bv4yc0N1.js → discard-changes-dialog-BACqR1hj.js} +1 -1
  78. package/web/dist/assets/{file-preview-CnrFxbea.js → file-preview-B7T7jFYo.js} +1 -1
  79. package/web/dist/assets/{folder-browser-CFd1U5hn.js → folder-browser-3cBLlnE9.js} +1 -1
  80. package/web/dist/assets/{git-toolbar-C7iolhIi.js → git-toolbar-UkRnjuDs.js} +1 -1
  81. package/web/dist/assets/github-CkbZgMnJ.js +1 -0
  82. package/web/dist/assets/{global-activity-route-Dijwg4OL.js → global-activity-route-j37l-BQU.js} +1 -1
  83. package/web/dist/assets/hosts-iUyg8S3j.js +1 -0
  84. package/web/dist/assets/index-DkQ5xrLr.js +21 -0
  85. package/web/dist/assets/{label-CgU9vxuM.js → label-CWlxyeC-.js} +1 -1
  86. package/web/dist/assets/{markdown-Cljq4S1h.js → markdown-FIfZPsax.js} +1 -1
  87. package/web/dist/assets/{open-in-menu-BI7mnPPf.js → open-in-menu-Bf8JA2DJ.js} +1 -1
  88. package/web/dist/assets/{option-select-BcTkv-7t.js → option-select-DylfDjGi.js} +1 -1
  89. package/web/dist/assets/{preferences-section-CEKXGhEj.js → preferences-section-DjWfc1i-.js} +1 -1
  90. package/web/dist/assets/{preview-EtD19mg1.js → preview-BSFJfN4s.js} +1 -1
  91. package/web/dist/assets/{preview-pane-connected-CKRBfx7t.js → preview-pane-connected-CfiPFvTH.js} +2 -2
  92. package/web/dist/assets/{project-location-hufc_p8y.js → project-location-CEX0-MZp.js} +1 -1
  93. package/web/dist/assets/{project-router-Dc6KBQsv.js → project-router-CwD1firw.js} +1 -1
  94. package/web/dist/assets/{projects-section-vOFZ4lbx.js → projects-section-Czmf0wFK.js} +1 -1
  95. package/web/dist/assets/{prompt-templates-section-Caash2nq.js → prompt-templates-section-DK4CV73w.js} +1 -1
  96. package/web/dist/assets/queries-D9mg7sFY.js +1 -0
  97. package/web/dist/assets/{read-state-BeVNfGkB.js → read-state-BsTfJki5.js} +1 -1
  98. package/web/dist/assets/{reference-chip-BjerVjzM.js → reference-chip-CZKBU_Ud.js} +1 -1
  99. package/web/dist/assets/{remote-settings-notice-fNgh5LdN.js → remote-settings-notice-Dott-jyP.js} +1 -1
  100. package/web/dist/assets/repo-git-Djt3N2wP.js +1 -0
  101. package/web/dist/assets/{report-reader-CK1WDtEH.js → report-reader-CrdDix7Z.js} +1 -1
  102. package/web/dist/assets/{report-selection-CZ8eb9QP.js → report-selection-Y2F9NTAs.js} +1 -1
  103. package/web/dist/assets/{reports-B-GImLAo.js → reports-Iw4LUvz2.js} +1 -1
  104. package/web/dist/assets/{resources-section-ApF3gXrw.js → resources-section-D3wUzdUQ.js} +1 -1
  105. package/web/dist/assets/{review-notes-drafts-BdjEFs1G.js → review-notes-drafts-xyC7GvRB.js} +1 -1
  106. package/web/dist/assets/{review-panel-D4zmYH8O.js → review-panel-3x_2lbej.js} +1 -1
  107. package/web/dist/assets/{review-strip-BpHXklAn.js → review-strip-CDYpq9_S.js} +1 -1
  108. package/web/dist/assets/{run-detail-refresh-CE0vyYYA.js → run-detail-refresh-SYZM94ch.js} +1 -1
  109. package/web/dist/assets/{run-diff-ClfLRsHF.js → run-diff-D26PXp6r.js} +1 -1
  110. package/web/dist/assets/run-header-DZ0rkryR.js +2 -0
  111. package/web/dist/assets/{select-CwDhRDtw.js → select-DC_G2no3.js} +1 -1
  112. package/web/dist/assets/{session-context-section-C87jx7RB.js → session-context-section-DEUv-ISr.js} +1 -1
  113. package/web/dist/assets/{settings-agent-picker-Dk8yJ57U.js → settings-agent-picker-BrFN2RaQ.js} +1 -1
  114. package/web/dist/assets/{settings-save-bar-cu8BKCGT.js → settings-save-bar-C0pFHqte.js} +1 -1
  115. package/web/dist/assets/{settings-shell-mhQfQKf1.js → settings-shell-BWWbVxv-.js} +1 -1
  116. package/web/dist/assets/{sidebar-section-DOQ5N1L6.js → sidebar-section-BGo1zjJt.js} +1 -1
  117. package/web/dist/assets/{skills-DXJ1gQBD.js → skills-qFMQz6sm.js} +1 -1
  118. package/web/dist/assets/{status-dot-Bmn4xhch.js → status-dot-DTU7afRv.js} +1 -1
  119. package/web/dist/assets/{tab-link-6TltE1jl.js → tab-link-BJDe5cT4.js} +1 -1
  120. package/web/dist/assets/{task-changes-D9Sdmpmw.js → task-changes-DKJHAtKC.js} +2 -2
  121. package/web/dist/assets/{task-commits-A0UIqxpL.js → task-commits-Dtt60D0o.js} +1 -1
  122. package/web/dist/assets/{task-file-scope-ID220XKo.js → task-file-scope-FTt7SiGn.js} +1 -1
  123. package/web/dist/assets/{task-files-Id2tuAAG.js → task-files-DVz4222z.js} +1 -1
  124. package/web/dist/assets/{task-github-item-YKUcwp2o.js → task-github-item-CJpKQ6cU.js} +1 -1
  125. package/web/dist/assets/{task-groups-DCg4iOB9.js → task-groups-BvVfsQKd.js} +1 -1
  126. package/web/dist/assets/{task-thread-A_vkygGX.js → task-thread-DiYtqka4.js} +2 -2
  127. package/web/dist/assets/{thread-state-6-BzRrJ_.js → thread-state-pO7Wy_7R.js} +1 -1
  128. package/web/dist/assets/toaster-2ud_VdfV.js +4 -0
  129. package/web/dist/assets/{use-finish-run-DO-nnAaa.js → use-finish-run-5S30Eu3d.js} +1 -1
  130. package/web/dist/assets/{use-hand-to-agent-state-CADaL8U8.js → use-hand-to-agent-state-BB_VmbF7.js} +1 -1
  131. package/web/dist/assets/use-path-bases-npA-uKvg.js +1 -0
  132. package/web/dist/assets/use-workspace-config-save-DDI7_WtK.js +1 -0
  133. package/web/dist/assets/{workflows-DOLG-Rns.js → workflows-DLuBawpi.js} +2 -2
  134. package/web/dist/assets/{workspace-tools-DTCJVDTE.js → workspace-tools-D4jshe-2.js} +1 -1
  135. package/web/dist/assets/{worktrees-section-BOHDbywt.js → worktrees-section-CESTBOem.js} +5 -5
  136. package/web/dist/index.html +19 -19
  137. package/web/dist/assets/accounts-section-Bnr89jmC.js +0 -1
  138. package/web/dist/assets/activity-motion-BW0tAmYF.js +0 -1
  139. package/web/dist/assets/agent-defaults-section-RyEogH0g.js +0 -1
  140. package/web/dist/assets/attention-BI6592lk.js +0 -1
  141. package/web/dist/assets/automations-route-DfGE4xWT.js +0 -2
  142. package/web/dist/assets/github-DGElvfMU.js +0 -1
  143. package/web/dist/assets/hosts-CpDMDiQW.js +0 -1
  144. package/web/dist/assets/index-DPfg7xSB.js +0 -21
  145. package/web/dist/assets/queries-IlC9MZgh.js +0 -1
  146. package/web/dist/assets/repo-git-5MK_RAR6.js +0 -1
  147. package/web/dist/assets/run-header-BUe92WWr.js +0 -2
  148. package/web/dist/assets/toaster-DNnL8v10.js +0 -4
  149. package/web/dist/assets/use-path-bases-CFAmFn_E.js +0 -1
  150. package/web/dist/assets/use-workspace-config-save-DScW6_8J.js +0 -1
@@ -1 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t}from"./react-runtime-CCIEwYL0.js";import{d as n,n as r,p as i}from"./host-context-DDbYAKpm.js";import{$ as a,$n as o,A as s,Ai as c,An as l,Bn as u,C as d,Ci as f,Cn as p,Cr as m,Ct as ee,D as h,Di as g,Dn as _,Dt as te,E as ne,Ei as re,En as ie,Et as ae,F as oe,Fi as v,Fn as se,G as ce,Gn as le,Hi as ue,Hn as de,Ht as fe,Ii as pe,It as me,J as he,Jn as ge,Jt as _e,K as ve,Kn as ye,Kt as be,L as xe,Mi as Se,Mn as Ce,Mt as we,N as Te,Nn as Ee,Nt as De,O as Oe,Oi as ke,On as Ae,Or as je,Ot as Me,Pn as Ne,Pt as Pe,Q as Fe,Qi as Ie,Ri as Le,Rn as Re,S as ze,Sn as Be,Sr as Ve,St as He,Ti as Ue,Tn as We,Un as Ge,Vn as Ke,Vt as qe,Wi as Je,Wt as Ye,X as Xe,Xn as Ze,Y as Qe,Yi as $e,Yn as et,Zi as tt,Zn as nt,_t as rt,a as it,b as at,bn as ot,br as st,bt as ct,ct as lt,er as ut,et as dt,gt as ft,h as pt,ir as mt,ji as ht,jn as gt,k as _t,ki as vt,kr as yt,kt as bt,m as xt,n as St,nr as Ct,pt as wt,q as Tt,qi as Et,qn as Dt,qt as Ot,ta as kt,tr as At,v as jt,vt as Mt,wi as y,wn as Nt,wt as Pt,x as Ft,xi as It,xn as Lt,xt as Rt,y as zt,yt as Bt,zi as Vt,zn as Ht}from"./toaster-DNnL8v10.js";import{A as Ut,B as b,F as x,H as S,I as C,N as w,P as T,W as E,Z as D,a as Wt,j as O,z as k}from"./live-protocol-CNUmr-VT.js";import{t as A}from"./host-storage-B72yoDU1.js";function Gt(e,t){return e??t}function Kt(e,t){let n=Gt(e,t);return n===`1`||n===`true`}function qt(e,t,n){return e?.trim()||Gt(t,n)||``}var Jt=class extends Le{#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||Yt(),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=Vt({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),D.batch(()=>{this.#t.forEach(t=>{t.onMutationUpdate(e)}),this.#n.notify({mutation:this,type:`updated`,action:e})})}};function Yt(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:`idle`,variables:void 0,submittedAt:0}}var Xt=class extends kt{#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),tt(this.options,t)||this.#e.getMutationCache().notify({type:`observerOptionsUpdated`,mutation:this.#n,observer:this}),t?.mutationKey&&this.options.mutationKey&&ue(t.mutationKey)!==ue(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??Yt();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){D.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 Zt(e,t){let n=new Set(t);return e.filter(e=>!n.has(e))}function Qt(e,t,n){let r=e.slice(0);return r[t]=n,r}var $t=class extends kt{#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,D.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||!tt(e,n)});!o&&!s||(o&&(this.#l=t,this.#i=n),this.#t=r,this.hasListeners()&&(o&&(Zt(e,n).forEach(e=>{e.destroy()}),Zt(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=$e(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 pe(this.#e,r);n.push({defaultedQueryOptions:r,observer:i})}),n}#m(e,t){let n=this.#i.indexOf(e);n!==-1&&(this.#t=Qt(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)&&D.batch(()=>{this.listeners.forEach(e=>{e(this.#t)})})}}},j=e(t(),1);function M({queries:e,...t},n){let r=v(n),i=Se(),a=ht(),o=j.useMemo(()=>e.map(e=>{let t=r.defaultQueryOptions(e);return t._optimisticResults=i?`isRestoring`:`optimistic`,t}),[e,r,i]);o.forEach(e=>{Ue(e);let t=r.getQueryCache().get(e.queryHash);ke(e,a,t)}),c(a);let[s]=j.useState(()=>new $t(r,o,t)),[l,u,d]=s.getOptimisticResult(o,t.combine),f=!i&&t.subscribed!==!1;j.useSyncExternalStore(j.useCallback(e=>f?s.subscribe(D.batchCalls(e)):Et,[s,f]),()=>s.getCurrentResult(),()=>s.getCurrentResult()),j.useEffect(()=>{s.setQueries(o,t)},[o,t,s]);let p=l.some((e,t)=>g(o[t],e))?l.flatMap((e,t)=>{let n=o[t];return n&&g(n,e)?re(n,new pe(r,n),a):[]}):[];if(p.length>0)throw Promise.all(p);let m=l.find((e,t)=>{let n=o[t];return n&&vt({result:e,errorResetBoundary:a,throwOnError:n.throwOnError,query:r.getQueryCache().get(n.queryHash),suspense:n.suspense})});if(m?.error)throw m.error;return u(d())}function N(e,t){let n=v(t),[r]=j.useState(()=>new Xt(n,e));j.useEffect(()=>{r.setOptions(e)},[r,e]);let i=j.useSyncExternalStore(j.useCallback(e=>r.subscribe(D.batchCalls(e)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),a=j.useCallback((e,t)=>{r.mutate(e,t).catch(Et)},[r]);if(i.error&&Ie(r.options.throwOnError,[i.error]))throw i.error;return{...i,mutate:a,mutateAsync:i.mutate}}function P(e={}){let t=e.projectId??i();return{projectId:t,cacheScope:e.cacheScope??(e.boot?`default`:t)}}function F(e,t={}){return{...P(t),runId:e}}function en(){return Kt(void 0,void 0)}function I(e){return!en()&&e}function tn(e,t=!0,n=!1,r){return y({queryKey:[P({projectId:e,boot:n}).cacheScope,`runs`,`list`],queryFn:({signal:t})=>De(P({projectId:e,boot:n}),{signal:t}),enabled:t,...r?{select:r}:{},placeholderData:(t,r)=>n&&r?.queryKey[0]===e?t:void 0})}function L(e,t,n=`active`){return e.invalidateQueries({queryKey:t===void 0?[`workspace`,`models`]:K.models(t),refetchType:n})}function nn(e,t=!0,n){return y({...rn(e,n),enabled:t})}var rn=(e,t)=>({queryKey:K.models(e,t),queryFn:({signal:n})=>Ct(e,{signal:n},t),staleTime:300*1e3});function an(e,t=!0){let n=M({queries:e.map(e=>({...rn(e),enabled:t}))});return Object.fromEntries(e.map((e,t)=>[e,n[t]]))}function on(e,t){return JSON.stringify([e,t])}function sn(e){return e.type===`run`?e.run.id:e.id}function R(e,t){return{...e,runs:t}}function cn(e,t){let n=0;for(let r of e)r.projectId===t&&r.archived&&(n+=1);return n}var ln=class{runs;copied=!1;positions=new Map;constructor(e){this.runs=e,this.reindex()}reindex(){this.positions.clear(),this.runs.forEach((e,t)=>this.positions.set(on(e.projectId,e.id),t))}at(e,t){return this.positions.get(on(e,t))??-1}mutable(){return this.copied||=(this.runs=[...this.runs],!0),this.runs}replace(e,t){return this.mutable()[e]=t,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}};function un(e,t,n){let r=new ln(e.runs),i=e,a=!1;for(let e of t)if(e.type===`usage`)i=gn(i,e.project,e.usage,r);else{let t=pn(i,e.change,n,r);i=t.index,a||=t.reconcile}return{index:i,reconcile:a}}function dn(e,t,n){return n?n.has(t):e.runs.some(e=>e.projectId===t)}function fn(e,t,n){return pn(e,t,n,new ln(e.runs))}function pn(e,t,n,r){let{project:i}=t,a=r.at(i,sn(t)),o=a>=0?e.runs[a]:void 0,s=e.truncated.includes(i);if(t.type===`deleted`)return o?{index:R(e,r.remove(a)),reconcile:s&&o.archived}:{index:e,reconcile:!1};let{run:c}=t;if(c.delegation?.role===`worker`)return o?{index:R(e,r.remove(a)),reconcile:!1}:{index:e,reconcile:!1};if(!o&&!dn(e,i,n))return{index:e,reconcile:!0};let l=$e(o,{projectId:i,...c});if(o){if(l===o)return{index:e,reconcile:!1};let t=r.replace(a,l),n=o.archived!==l.archived&&(s||cn(t,i)>e.perProjectLimit);return{index:R(e,t),reconcile:n}}if(s)return hn(e,l,r);let u=r.insert(l);return{index:R(e,u),reconcile:l.archived&&cn(u,i)>e.perProjectLimit}}function mn(e,t){let n;for(let r of e)r.projectId===t&&r.archived&&(n===void 0||r.createdAt<n)&&(n=r.createdAt);return n}function hn(e,t,n){let r=mn(e.runs,t.projectId),i=r!==void 0&&t.createdAt>r;return t.archived&&!i?{index:e,reconcile:!1}:{index:R(e,n.insert(t)),reconcile:t.archived||r===void 0||t.createdAt<r}}function gn(e,t,n,r){let i=!1;return e.runs.forEach((e,a)=>{if(e.projectId!==t)return;let o=n[e.id];if(o){let t=$e(e.usage,o);if(t===e.usage)return;r.replace(a,{...e,usage:t})}else{if(e.usage===void 0)return;let{usage:t,...n}=e;r.replace(a,n)}i=!0}),i?R(e,r.runs):e}function _n(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 vn(){return{stream:void 0,lastStream:void 0,mismatch:void 0,floor:void 0,changes:new Map}}function yn(e,t,n){if(e.lastStream===t)e.floor=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 bn(e){e.stream=void 0}function xn(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=JSON.stringify([r,t.project,sn(t)]),a=e.changes.get(i);return(!a||a.seq<t.seq)&&e.changes.set(i,{...t,generation:r}),!0}function Sn(e,t){for(let[n,r]of e.changes)r.project===t&&e.changes.delete(n)}function Cn(e){return typeof e.generation==`string`&&typeof e.eventSeq==`number`}function wn(e,t,n){if(!Cn(t))return{index:t,reconcile:!1};let{generation:r,eventSeq:i}=t;if(e.stream!==void 0&&e.stream!==r){let n=e.mismatch!==r;return e.mismatch=r,{index:t,reconcile:n}}let a=e.lastStream===r&&e.floor!==void 0,o=a&&i<e.floor,s=t,c=o,l=[...e.changes.entries()].filter(([,e])=>e.generation===r),u=l.map(([,e])=>e).filter(e=>e.seq>i).sort((e,t)=>e.seq-t.seq);for(let e of u){let t=fn(s,e,n);s=t.index,c||=t.reconcile}for(let[t,n]of l)n.seq<=i&&e.changes.delete(t);return a&&!o&&(e.floor=i),{index:s,reconcile:c}}var z=[`workspace`,`runs-index`],Tn=[`workspace`,`projects`],En=6e4,Dn=100,On=new WeakMap;function kn(e){let t=On.get(e);return t||(t=Pn(e),On.set(e,t)),t}function An(e,t){return typeof e!=`object`||!e||!Array.isArray(e.runs)?e:kn(t).merge(e)}function jn(e){let t=e.getQueryData(Tn)?.projects;return t?new Set(t.map(e=>e.id)):void 0}function Mn(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 Nn(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 Pn(e){let t=vn(),n=[],r,i,a,o,s=!1,c=-1/0,l=new Set,u=!1,d,f=!1,p=()=>{if(!u){if(u=!0,d?.()){f=!0;return}g({hold:!0})}},m=t=>{c=Date.now(),e.setQueryData(z,t)},ee=()=>e.getQueryData(z),h=()=>{clearTimeout(a),a=void 0;let t=e.getQueryCache().find({queryKey:z,exact:!0}),n=(t!==void 0&&t.state.data===void 0&&t.state.fetchStatus!==`idle`?e.cancelQueries({queryKey:z,exact:!0}).then(()=>e.invalidateQueries({queryKey:z})):e.invalidateQueries({queryKey:z})).catch(()=>void 0).finally(()=>{o===n&&(o=void 0,s&&(s=!1,h()))});return o=n,n},g=(e={})=>o?(s=!0,o):e.hold?(a??=setTimeout(()=>{h()},400),Promise.resolve()):h(),_=()=>{r!==void 0&&typeof cancelAnimationFrame==`function`&&cancelAnimationFrame(r),r=void 0,clearTimeout(i),i=void 0;let t=n;n=[];let a=ee();if(!a||t.length===0)return;let o=jn(e),{index:s,reconcile:c}=un(a,t.filter(e=>e.generation===a.generation?e.type===`usage`?!l.has(e.project):!l.has(e.change.project)&&e.change.seq>a.eventSeq:!1),o);s!==a&&m(s),c&&g({hold:!0})},te=()=>{if(i!==void 0)return;let e=c+250-Date.now();if(e>0){i=setTimeout(_,e);return}i=setTimeout(_,Dn),typeof requestAnimationFrame==`function`&&(r=requestAnimationFrame(_))};return{ready(e,n){yn(t,e,n),u=!1,f&&(f=!1,g({hold:!0}))},detach(){bn(t)},run(e,r,i=!1){if(l.has(e))return;let a=Nn(e,r);if(!xn(t,a,i)){p();return}n.push({type:`change`,change:a,generation:t.stream}),te()},usage(e,r){if(!l.has(e)){if(t.stream===void 0){p();return}n.push({type:`usage`,project:e,usage:r,generation:t.stream}),te()}},dropProject(e){l.add(e),Sn(t,e),n=n.filter(t=>(t.type===`change`?t.change.project:t.project)!==e);let r=ee();if(!r)return;let i=_n(r,e);i!==r&&m(i)},setUnknownGenerationHandler(e){d=e},restoreProject(e){l.delete(e)},merge(n){let r=ee(),i=wn(t,n,jn(e));for(let e of l)i.index=_n(i.index,e);return i.reconcile&&queueMicrotask(()=>{g({hold:!0})}),Mn(r,n,t.stream)??i.index},reconcile:g,flush:_,stop(){r!==void 0&&typeof cancelAnimationFrame==`function`&&cancelAnimationFrame(r),r=void 0,clearTimeout(i),i=void 0,clearTimeout(a),a=void 0,n=[],s=!1}}}var Fn=O([`own`,`provider-spanning`]),In=b({suggested:w(b({id:E(),label:E(),desc:E()})),retired:w(E())}),Ln=b({id:O([`settings`,`mcp`,`memory`]),label:E(),note:E().optional(),empty:E().optional(),showsUserMcp:C(!0).optional()}),Rn=b({label:E(),note:E().optional(),groups:w(Ln)}),zn=b({runners:w(b({id:It,displayName:E(),modelListName:E(),modelIdScope:Fn,pickerLabel:E(),pickerDescription:E(),icon:E(),installHint:E(),loginCommand:E(),terminalLogin:T().optional(),browserLogin:T().optional(),managedInstall:C(!0).optional(),accountFolderExample:E().optional(),models:In,agentConfig:Rn}))}),Bn=[`workspace`,`runners`];async function Vn(e){return At(await Ze.api.v1.runners.$get({},nt(e)),`/runners`,zn)}var Hn={queryKey:Bn,queryFn:({signal:e})=>Vn({signal:e}),staleTime:1/0};function Un(){return y(Hn)}function Wn(e){return e?.runners??[]}function Gn(e){return Wn(e).map(e=>e.id)}function Kn(e,t){if(e!==void 0)return t.includes(e)?e:t[0]}function qn(e){let t=Un();return{runner:t.isSuccess?Kn(e,Gn(t.data))??e:e,ready:!t.isPending}}function B(e,t){return e?.runners.find(e=>e.id===t)}function Jn(e,t){return B(e,t)?.displayName??t}function Yn(e,t){return B(e,t)?.pickerLabel??t}function Xn(e,t){return B(e,t)?.modelListName}function Zn(e,t,n=!0,r){let a=Bi(r,n),o=J(),{runner:s,ready:c}=qn(e??a.data?.defaultRunner??`claude`),l=o.data?.capabilities?.localHandoff===!1?null:t,u=r??i(),d=y({queryKey:G.runnerSkills(s,l,u),queryFn:({signal:e})=>ne(s,l,{signal:e,projectId:u}),enabled:n&&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 Qn={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`}},$n={label:`Merge conflicts`,hint:`this branch no longer merges cleanly into its base — rebase or merge the base in`,tone:`conflict`};function er(e){return typeof e==`string`&&Object.hasOwn(Qn,e)}function tr(e){return e!==void 0&&er(e)?Qn[e]:void 0}var nr=`cez.reference-statuses.v1`,rr=`cez.reference-conflicts.v1`,V=new Map(lr()),ir=1e3,H=new Set(ur()),ar=r()??`__local__`;function or(){let e=r()??`__local__`;if(ar!==e){ar=e,clearTimeout(U),U=void 0,V.clear();for(let[e,t]of lr())V.set(e,t);H.clear();for(let e of ur())H.add(e)}}function sr(e,t){if(or(),V.get(e)!==t){for(V.delete(e),V.set(e,t);V.size>ir;){let e=V.keys().next().value;if(e===void 0)break;V.delete(e)}dr()}}function cr(e,t){if(or(),H.has(e)!==t){if(t)for(H.add(e);H.size>ir;){let e=H.values().next().value;if(e===void 0)break;H.delete(e)}else H.delete(e);dr()}}function lr(){try{let e=globalThis.sessionStorage?.getItem(A(nr));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`&&er(e[1])):[]}catch{return[]}}function ur(){try{let e=globalThis.sessionStorage?.getItem(A(rr));if(!e)return[];let t=JSON.parse(e);return Array.isArray(t)?t.filter(e=>typeof e==`string`):[]}catch{return[]}}var U;function dr(){if(U!==void 0)return;let e=A(nr),t=A(rr);U=setTimeout(()=>{U=void 0;try{globalThis.sessionStorage?.setItem(e,JSON.stringify([...V])),globalThis.sessionStorage?.setItem(t,JSON.stringify([...H]))}catch{}},250)}var W=e=>`${e.projectId}\u0000${e.kind}#${e.number}`;function fr(e,t){return{...e?{status:e}:{},...t?{conflicting:!0}:{}}}function pr(e){return[...e.prs.map(t=>({projectId:e.projectId,kind:`PR`,number:t})),...e.issues.map(t=>({projectId:e.projectId,kind:`Issue`,number:t}))]}function mr(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;sr(t,o),s!==void 0&&cr(t,s),e.set(t,{state:`ready`,status:o,...s??a?{conflicting:!0}:{}})}function hr(e,t,n){or();let r=W(t),i=V.get(r),a=H.has(r)?!0:void 0,o=n.data;if(o?.available){mr(e,r,t,o,i,a);return}if(o){e.set(r,{state:`unavailable`,reason:o.reason,...fr(i,a)});return}if(n.isError){e.set(r,{state:`unavailable`,reason:n.error instanceof Error?n.error.message:void 0,...fr(i,a)});return}e.set(r,{state:`loading`,...fr(i,a)})}function gr(e,t){let n=new Map;return t.forEach((t,r)=>{let i=e[r];if(i)for(let e of pr(i))hr(n,e,t)}),n}var G={get health(){return[i(),`health`]},runs:{get all(){return[i(),`runs`]},relationships:e=>[i(),`runs`,`relationships`,e],list:(e=i())=>[e,`runs`,`list`],archived:e=>[i(),`runs`,`archived`,e],detail:(e,t=i())=>[t,`runs`,`detail`,e],diff:e=>[i(),`runs`,`diff`,e],changes:e=>[i(),`runs`,`changes`,e],file:(e,t)=>[i(),`runs`,`files`,e,t],handoff:e=>[i(),`runs`,`handoff`,e],commits:e=>[i(),`runs`,`commits`,e],commit:(e,t)=>[i(),`runs`,`commit`,e,t]},get workflows(){return[i(),`workflows`]},runnerSkills:(e,t,n=i())=>[n,`runner-skills`,e,t??null],get repo(){return[i(),`repo`]},get repoChanges(){return[i(),`repo`,`changes`]},repoCommit:e=>[i(),`repo`,`commit`,e],get repoBranches(){return[i(),`repo`,`branches`]},get uiState(){return[i(),`ui-state`]},get config(){return[i(),`config`]},get agentConfig(){return[i(),`agent-config`]},agentConfigFile:e=>[i(),`agent-config`,`file`,e],get sessionContext(){return[i(),`session-context`]},sessionContextPreview:(e,t,n=``)=>[i(),`session-context`,`preview`,t,e,n],get worktrees(){return[i(),`worktrees`]},github:(e={})=>[i(),`github`,e.limit??null],githubPages:e=>[i(),`github`,`pages`,e],githubPagesHead:e=>[i(),`github`,`pages-head`,e],githubCommentCounts:(e,t)=>[i(),`github`,`comment-counts`,e,[...t].sort((e,t)=>e-t).join(`,`)],githubChecks:e=>[i(),`github`,`checks`,[...e].sort((e,t)=>e-t).join(`,`)],githubSearch:(e,t)=>[i(),`github`,`search`,e,t],githubRefStatus:(e,t,n)=>[e,`github`,`ref-status`,[...t].sort((e,t)=>e-t).join(`,`),[...n].sort((e,t)=>e-t).join(`,`)],githubComments:(e,t)=>[i(),`github`,`comments`,e,t],githubItem:(e,t)=>[i(),`github`,`item`,e,t],githubRefStatusOf:e=>[e,`github`,`ref-status`],githubPrChanges:e=>[i(),`github`,`pr-changes`,e],githubMergeState:e=>[i(),`github`,`merge-state`,e],get openTargets(){return[i(),`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:z,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 _r(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 vr(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 yr(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 br(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 xr(e,t){return yt({kind:`topic`,topic:e},{value:t})}function Sr(){let e=v();return y({queryKey:K.providerStatus,queryFn:async({signal:t})=>{let n=e.getQueryData(K.providerStatus),r=await Ee(!1,{signal:t});return mt(n,e.getQueryData(K.providerStatus),r)},staleTime:5*6e4,refetchInterval:I(!1),refetchOnWindowFocus:!0})}function Cr(){let e=v();return N({mutationFn:()=>Ee(!0),onMutate:()=>e.getQueryData(K.providerStatus),onSuccess:(t,n,r)=>{e.setQueryData(K.providerStatus,e=>mt(r,e,t)),L(e)}})}function wr(){let e=v();return N({mutationFn:({provider:e,authFailureId:t})=>de(e,t),onMutate:()=>e.getQueryData(K.providerStatus),onSuccess:(t,n,r)=>{e.setQueryData(K.providerStatus,e=>mt(r,e,t,n.authFailureId)),L(e,n.provider)}})}function Tr(e={}){return y({queryKey:K.projects,queryFn:({signal:e})=>Ce({signal:e}),...e})}function Er(e,t=!1){return y({queryKey:K.fsBrowse(e,t),queryFn:({signal:n})=>Lt(e??void 0,{signal:n,showHidden:t}),retry:!1})}function Dr(){let e=v();return N({mutationFn:e=>Re(e),onSuccess:()=>e.invalidateQueries({queryKey:K.projects})})}function Or(){let e=v();return N({mutationFn:e=>u(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 kr(){let e=v();return N({mutationFn:e=>{let{id:t,...n}=e;return Dt(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?Ar(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 Ar(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?[]:br(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 jr(e){let t=v();return N({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 Mr(){return jr(e=>{let{projectId:t,...n}=e;return ie(t,n)})}function Nr(){return jr(e=>{let{projectId:t,webhookId:n,...r}=e;return ge(t,n,r)})}function Pr(){return jr(({projectId:e,webhookId:t})=>Ke(e,t))}function Fr(){return N({mutationFn:({projectId:e,webhookId:t})=>le(e,t),retry:!1})}function q(e){let t=v();return N({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`}),L(t)])},onError:()=>{t.invalidateQueries({queryKey:G.health}),t.invalidateQueries({queryKey:K.agentProfiles,exact:!0})}})}function Ir(){return q(e=>Nt(e))}function Lr(){return q(e=>{let{id:t,...n}=e;return ye(t,n)})}function Rr(){return q(e=>Ht(e))}function zr(){return q(e=>Ge(e))}function Br(e,t){return y({queryKey:K.agentAccountStatus(e),queryFn:({signal:t})=>_(e,{signal:t}),enabled:t,staleTime:6e4,retry:!1})}function Vr(){let e=v();return N({mutationFn:({provider:e,profileId:t})=>p(e,t),retry:!1,onSuccess:async(t,{provider:n})=>{await Promise.all([e.invalidateQueries({queryKey:K.agentProfiles}),e.invalidateQueries({queryKey:K.providerStatus}),L(e,n,`none`)])},onError:()=>{e.invalidateQueries({queryKey:G.health}),e.invalidateQueries({queryKey:K.agentProfiles,exact:!0})}})}function Hr(){let e=v();return N({mutationFn:e=>_(e,{refresh:!0}),retry:!1,onSuccess:(t,n)=>{e.setQueryData(K.agentAccountStatus(n),t),e.invalidateQueries({queryKey:K.agentProfiles}),L(e,t.status.provider)}})}function Ur(){let e=v();return N({mutationFn:e=>Be(e),retry:!1,onSuccess:()=>e.invalidateQueries({queryKey:K.projects})})}function Wr(){let e=v();return N({mutationFn:e=>We(e),retry:!1,onSuccess:()=>e.invalidateQueries({queryKey:K.projects})})}function Gr({enabled:e}){return y({queryKey:K.githubOwners,queryFn:({signal:e})=>l({signal:e}),enabled:e,staleTime:6e4,retry:!1})}function Kr(){let e=v();(0,j.useEffect)(()=>{let t,r=()=>{let r=e.getQueryData(G.health);r&&(Ve({bootProject:r.bootProject===void 0?`default`:r.bootProject,apiBase:n()}),t??=xr(`health`,t=>{e.setQueryData(G.health,t)}))};r();let i=e.getQueryCache().subscribe(r);return()=>{i(),t?.(),je()}},[e])}function J(){return y({queryKey:G.health,queryFn:({signal:e})=>gt({signal:e})})}function qr(e,t){let n=J().data,r=Tr(t).data?.projects,i=it(),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)?_r(n?.repo?.remote):void 0}function Jr(e=!0){return y({queryKey:K.uiState,queryFn:({signal:e})=>se({signal:e}),enabled:e})}function Yr(){return y({queryKey:K.config,queryFn:({signal:e})=>Ne({signal:e})})}function Xr(){return y({queryKey:K.agentProfiles,queryFn:({signal:e})=>Ae({signal:e})})}var Y=[`workspace`,`runs-index`],X=e=>[e.cacheScope,`runs`,`list`],Z=e=>[e.cacheScope,`runs`,`detail`,e.runId],Q=e=>typeof e==`function`?e():e;function Zr(e){let{seenAt:t,...n}=e;return n}function Qr(e,t){let n=Zr(e);return t.seenAt===void 0?n:{...n,seenAt:t.seenAt}}function $r(e,t,n){return t?{...e,seenAt:n}:Zr(e)}function ei(e){let t=()=>{e.invalidateQueries({queryKey:Y})};function n(n,r){if(n===`index`)return t();let a=typeof r==`function`?r():r;if(n===`indexed`){t(),e.invalidateQueries({queryKey:[i(),`runs`]}),e.invalidateQueries({queryKey:[a.projectId,`runs`,`list`]});return}if(n===`runs`)return e.invalidateQueries({queryKey:[a.cacheScope,`runs`]});let o=m(),s=[a.projectId,a.cacheScope],c=o!==void 0&&s.some(e=>e===o||e==="default")?[o,`default`]:[],l=new Set([...s,...c,i()]);return Promise.all([...l].map(t=>e.invalidateQueries({queryKey:[t,`runs`]}))).then(()=>void 0)}async function r(n,r){await e.cancelQueries({queryKey:X(Q(n))}),await e.cancelQueries({queryKey:Z(Q(n))});let i=e.getQueryData(X(Q(n))),a=e.getQueryData(Z(Q(n))),o=Q(n).runId,s=new Date().toISOString();return e.setQueryData(X(Q(n)),e=>e?.map(e=>e.id===o?$r(e,r,s):e)),e.setQueryData(Z(Q(n)),e=>e&&$r(e,r,s)),{id:o,prevList:i,prevDetail:a,rollback(){if(!r){i&&e.setQueryData(X(Q(n)),i),a&&e.setQueryData(Z(Q(n)),a);return}let t=i?.find(e=>e.id===o);t&&e.setQueryData(X(Q(n)),e=>e?.map(e=>e.id===o?Qr(e,t):e)),a&&e.setQueryData(Z(Q(n)),e=>e&&Qr(e,a))},settle(i){let a=e=>e.id===(r?o:i.id)?$r(e,r,i.seenAt):e;e.setQueryData(X(Q(n)),e=>e?.map(a));let s={...Q(n),runId:r?o:i.id};e.setQueryData(Z(s),e=>e?a(e):i),t()}}}async function a(t,r){await e.cancelQueries({queryKey:Y});let i=e.getQueryData(Y),a=r();return e.setQueryData(Y,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(Y,i)},settle(){n(`indexed`,t)}}}return{patchRead:r,patchIndex:a,invalidateAfter:n}}function $(){let e=v();return(0,j.useMemo)(()=>ei(e),[e])}function ti(e,t){if(!Wt(e.path))throw Error(`unsupported shared read`);let n=new URL(e.path,`http://cezar.invalid`);return n.searchParams.sort(),yt({kind:`read`,path:`${n.pathname}${n.search}`,intervalMs:e.intervalMs},{value:t})}function ni(e,t,n,r){let i=v(),a=JSON.stringify(t),o=(0,j.useMemo)(()=>JSON.parse(a),[a]);(0,j.useEffect)(()=>{if(!e||n===!1)return;let t=!0,a=ti({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 ri(e,t=!1){return ut(await Ze.api.v1.p[`:projectId`].runs[`:id`][`worker-destroy`].$post({param:{projectId:i(),id:encodeURIComponent(e)},query:{},json:t?{discardWork:!0}:{}}),o(e,`/worker-destroy`))}function ii(){return y({queryKey:G.openTargets,queryFn:({signal:e})=>Rt({signal:e}),staleTime:5*6e4})}function ai(e=!0,t){return y({queryKey:t?G.runs.list(t):G.runs.list(),queryFn:({signal:e})=>De(P(t?{projectId:t}:void 0),{signal:e}),enabled:e})}function oi(e,t){return f({queryKey:G.runs.archived(e),enabled:t,initialPageParam:void 0,queryFn:({pageParam:t,signal:n})=>ft({before:t,limit:200,q:e},{signal:n}),getNextPageParam:e=>e.nextCursor??void 0,placeholderData:(e,t)=>t?.queryKey[0]===i()?e:void 0})}function si(e){let t=e.trim();return y({queryKey:K.runsSearch(t),queryFn:({signal:e})=>be(t,{signal:e}),enabled:t.length>=2,placeholderData:Je,staleTime:1e4})}function ci(e=!0,t=En,n){let r=kn(v());return ni(`/api/v1/workspace/runs-index`,K.runsIndex,I(e?t:!1),An),y({queryKey:K.runsIndex,queryFn:({signal:e})=>Pe({signal:e}).then(r.merge),enabled:e,...n?{select:n}:{},staleTime:3e4,refetchInterval:!1})}function li(e){let t=v();return N({mutationFn:({workerId:e,discardWork:t=!1})=>ri(e,t),onSettled:()=>t.invalidateQueries({queryKey:G.runs.relationships(e)})})}function ui(e,t={}){return y({queryKey:G.runs.relationships(e),queryFn:({signal:t})=>we(e,{signal:t}),enabled:t.enabled??!0})}function di(e){return y({queryKey:G.runs.detail(e??``),queryFn:({signal:t})=>He(F(e),{signal:t}),enabled:!!e})}function fi(e,t,n=!0,r){return y({queryKey:[e??`default`,`runs`,`detail`,t??``],queryFn:({signal:n})=>He(F(t,{projectId:e}),{signal:n}),enabled:n&&!!e&&!!t,...r?.staleTime===void 0?{}:{staleTime:r.staleTime},...r?.refetchOnMount===void 0?{}:{refetchOnMount:r.refetchOnMount}})}function pi(e,t){return y({queryKey:t?[t,`runs`,`diff`,e??``]:G.runs.diff(e??``),queryFn:({signal:n})=>te(e,{signal:n,...t?{projectId:t}:{}}),enabled:!!e})}function mi(e,t=!1){return ni(e?`/api/v1/p/${i()}/runs/${encodeURIComponent(e)}/changes`:void 0,G.runs.changes(e??``),I(t?4e3:!1)),y({queryKey:G.runs.changes(e??``),queryFn:({signal:t})=>ee(e,{signal:t}),enabled:!!e,retry:!1,refetchInterval:!1,refetchOnWindowFocus:!0,staleTime:0})}function hi(e,t){return y({queryKey:G.runs.file(e??``,t??``),queryFn:({signal:n})=>Me(e,t,{signal:n}),enabled:!!e&&t!==void 0,retry:!1})}function gi(e,t){return y({queryKey:[i(),`runs`,`file-link`,e,t],queryFn:({signal:n})=>ct(e,t,{signal:n}),enabled:t!==null,retry:!1})}function _i(e,t){return y({queryKey:[i(),`runs`,`artifact`,e,t],queryFn:({signal:n})=>rt(e,t,{signal:n}),enabled:t!==null,retry:!1})}function vi(e,t){return y({queryKey:[i(),`runs`,`artifact-metadata`,e,t],queryFn:({signal:n})=>Mt(e,t,{signal:n}),enabled:t!==null,retry:!1})}function yi(e){return y({queryKey:[i(),`runs`,`artifacts`,e],queryFn:({signal:t})=>Bt(e,{signal:t}),retry:!1,staleTime:0,refetchOnWindowFocus:!0})}function bi(e,t=!1){return ni(e?`/api/v1/p/${i()}/runs/${encodeURIComponent(e)}/commits`:void 0,G.runs.commits(e??``),I(t?5e3:!1)),y({queryKey:G.runs.commits(e??``),queryFn:({signal:t})=>ae(e,{signal:t}),enabled:!!e,retry:!1,refetchInterval:!1})}function xi(e,t){return y({queryKey:G.runs.commit(e??``,t??``),queryFn:({signal:n})=>Pt(e,t,{signal:n}),enabled:!!e&&!!t,retry:!1})}function Si(e,t=!0){return y({queryKey:G.runs.handoff(e??``),queryFn:({signal:t})=>bt(F(e),{signal:t}),enabled:!!e&&t})}function Ci(e,t,n){return y({queryKey:e===void 0?G.runs.handoff(t):[e,`runs`,`handoff`,t],queryFn:({signal:n})=>bt(F(t,{projectId:e}),{signal:n}),enabled:n,staleTime:15e3})}function wi(e,t){let n=[...new Set(e)],r=M({queries:n.map(e=>({queryKey:[e??i(),`automations`,`names`],queryFn:({signal:t})=>jt({signal:t,archived:`include`,...e===void 0?{}:{projectId:e}}),enabled:t,staleTime:6e4,retry:!1}))}),a=r.map(e=>e.data);return(0,j.useMemo)(()=>{let e=new Map;return a.forEach((t,r)=>{if(t?.available)for(let i of t.automations)e.set(JSON.stringify([n[r]??null,i.id]),i.name)}),(t,n)=>e.get(JSON.stringify([t??null,n]))},[JSON.stringify([n,r.map(e=>e.dataUpdatedAt)])])}function Ti(e){let t=v();return N({mutationFn:t=>me(e,t),retry:!1,onSuccess:()=>t.invalidateQueries({queryKey:G.runs.all})})}function Ei(e){let t=v();return N({mutationFn:t=>qe(e,t),onSuccess:()=>t.invalidateQueries({queryKey:G.runs.all})})}function Di(e){let t=$(),n=e?.projectId,r=e?.cacheScope,i=N({mutationFn:e=>_e(e,!0),onMutate:e=>t.patchRead(e,!0),onError:(e,t,n)=>n?.rollback(),onSuccess:(e,t,n)=>n?.settle(e)}),a=(0,j.useCallback)(e=>({...F(e,{projectId:n,cacheScope:r}),id:e}),[n,r]),o=(0,j.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:s,mutateAsync:c}=i,l=(0,j.useCallback)((e,t)=>s(a(e),o(t)),[s,a,o]),u=(0,j.useCallback)((e,t)=>c(a(e),o(t)),[c,a,o]);return{...i,variables:i.variables?.id,mutate:l,mutateAsync:u}}function Oi(){let e=$();return N({mutationFn:e=>_e(F(e),!1),onMutate:t=>e.patchRead(()=>F(t),!1),onError:(e,t,n)=>n?.rollback(),onSuccess:(e,t,n)=>n?.settle(e)})}function ki(e){let t=$();return N({mutationFn:({id:t,pinned:n})=>fe(F(t,e),n),onError:e=>St(`Could not update pin. ${e.message} Please retry.`,{tone:`danger`}),onMutate:()=>e??P(),onSuccess:(e,n,r)=>t.invalidateAfter(`runs`,r)})}function Ai(e,t){let n=$();return N({mutationFn:n=>Ot(F(e,{projectId:t}),n),onMutate:()=>P({projectId:t}),onSuccess:(e,t,r)=>n.invalidateAfter(`send`,r),onError:(e,t,r)=>{e instanceof et&&e.status===409&&r&&n.invalidateAfter(`send`,r)}})}function ji(e,t){let n=$();return N({mutationFn:(n={})=>lt(F(e,{projectId:t}),n),onMutate:()=>P({projectId:t}),onSuccess:(e,t,r)=>n.invalidateAfter(`continue`,r)})}function Mi(e){let t=v();return N({mutationFn:({msgId:t,message:n})=>wt(e,t,n),onSuccess:()=>t.invalidateQueries({queryKey:G.runs.all})})}function Ni(e){let t=v();return N({mutationFn:t=>Ye(e,t),onSuccess:()=>t.invalidateQueries({queryKey:G.runs.all})})}function Pi(){return y({queryKey:G.workflows,queryFn:({signal:e})=>_t({signal:e})})}function Fi(e){return y({queryKey:e?[e,`repo`]:G.repo,queryFn:({signal:t})=>at({signal:t},e)})}function Ii(e){return y({queryKey:[e,`repo`],queryFn:({signal:t})=>at({signal:t},e)})}function Li(){return y({queryKey:G.repoBranches,queryFn:({signal:e})=>Ft({signal:e})})}function Ri(){return y({queryKey:G.repoChanges,queryFn:({signal:e})=>ze({signal:e}),retry:!1})}function zi(e){return y({queryKey:G.repoCommit(e??``),queryFn:({signal:t})=>d(e,{signal:t}),enabled:!!e,retry:!1})}function Bi(e,t=!0){return y({queryKey:e?[e,`config`]:G.config,queryFn:({signal:t})=>zt({signal:t,...e?{projectId:e}:{}}),enabled:t})}function Vi(){return y({queryKey:G.worktrees,queryFn:({signal:e})=>s({signal:e})})}function Hi(e){return y({queryKey:[e,`worktrees`],queryFn:({signal:t})=>s({signal:t},e),staleTime:0})}function Ui(e,t=!0,n=!1){return y({queryKey:[P({projectId:e,boot:n}).cacheScope,`ui-state`],queryFn:({signal:t})=>Oe({signal:t},e),select:e=>e.sidebarLimits===void 0?e:{...e,sidebarLimits:st(e.sidebarLimits)},enabled:t})}function Wi(e=!0,t){return Ui(t??i(),e)}function Gi(){return y({queryKey:G.agentConfig,queryFn:({signal:e})=>xt({signal:e})})}function Ki(e){return y({queryKey:G.agentConfigFile(e??``),queryFn:({signal:t})=>pt(e,{signal:t}),enabled:e!==null})}function qi(){return y({queryKey:G.sessionContext,queryFn:({signal:e})=>h({signal:e})})}function Ji(e,t,n=``){return y({queryKey:G.sessionContextPreview(e,t,n),queryFn:({signal:n})=>Te({content:e,role:t},{signal:n}),placeholderData:Je,staleTime:0,retry:!1})}function Yi(){let e=v();return N({onMutate:()=>({fileKey:G.sessionContext}),mutationFn:e=>xe(e),onSuccess:(t,n,r)=>{r&&e.setQueryData(r.fileKey,t)}})}function Xi(e){let t=v(),n=G.agentConfig,r=G.agentConfigFile(e);return N({mutationFn:t=>oe(e,t),onSuccess:e=>{t.setQueryData(r,e),t.invalidateQueries({queryKey:n})}})}var Zi=O([`passing`,`failing`,`pending`]).nullable(),Qi=b({kind:O([`issue`,`pr`]),number:k(),title:E(),author:E(),createdAt:E(),labels:w(E()),body:E().optional(),url:E(),comments:k(),assignees:w(E()).optional(),projectIds:w(E()).optional(),isDraft:T().optional(),additions:k().optional(),deletions:k().optional(),checks:Zi.optional()});x(`available`,[b({available:C(!0),item:Qi.nullable(),labelColors:S(E(),E()).optional()}),b({available:C(!1),reason:E()})]),b({kind:O([`issue`,`pr`]),number:Ut().int().positive().safe()});var $i=b({id:E(),title:E(),url:E()});b({available:T(),reason:E().optional(),repo:E().optional(),syncedAt:E().optional(),issues:w(Qi),prs:w(Qi),labelColors:S(E(),E()).optional(),viewerLogin:E().optional(),projects:w($i).optional(),projectsReason:E().optional(),projectsState:O([`refreshing`,`ready`,`unavailable`]).optional(),projectsGeneration:E().optional(),issuesTotal:k().int().nonnegative().optional(),prsTotal:k().int().nonnegative().optional(),issuesNextCursor:E().nullable().optional(),prsNextCursor:E().nullable().optional(),commentsDeferred:C(!0).optional()});var ea=E().min(1).max(2e3).optional();b({limit:E().optional(),refresh:E().optional(),issuesCursor:ea,prsCursor:ea,issuesDone:C(`1`).optional(),prsDone:C(`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`})}),b({kind:O([`issue`,`pr`]),numbers:E().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:C(`1`).optional()}),x(`available`,[b({available:C(!0),counts:S(k(),k().int().nonnegative())}),b({available:C(!1),reason:E()})]),x(`available`,[b({available:C(!0),checks:S(k(),Zi)}),b({available:C(!1),reason:E()})]),b({kind:O([`issue`,`pr`]),q:E().trim().min(1).max(256),limit:Ut().int().positive().max(50).optional()}),b({available:T(),projectsReason:E().optional(),reason:E().optional(),items:w(Qi),truncated:T().optional(),labelColors:S(E(),E()).optional()});var ta=k().nullable();x(`available`,[b({available:C(!0),prs:S(k(),ot),issues:S(k(),ot),conflicts:w(k()).optional(),recheckAfterMs:ta}),b({available:C(!1),reason:E(),recheckAfterMs:ta})]);var na=b({id:k(),author:E(),avatarUrl:E().optional(),createdAt:E(),body:E(),kind:O([`comment`,`review`]),reviewState:O([`approved`,`changes_requested`,`commented`,`dismissed`]).optional(),url:E()}),ra=O([`committed`,`labeled`,`unlabeled`,`assigned`,`unassigned`,`merged`,`closed`,`reopened`,`head_ref_force_pushed`,`cross-referenced`,`renamed`]),ia=b({id:E(),kind:ra,actor:E(),avatarUrl:E().optional(),createdAt:E(),url:E().optional(),sha:E().optional(),message:E().optional(),checks:Zi.optional(),label:b({name:E(),color:E().optional()}).optional(),subject:E().optional(),refNumber:k().optional(),refTitle:E().optional(),refIsPr:T().optional()});b({available:T(),reason:E().optional(),comments:w(na),truncated:T().optional(),events:w(ia).optional(),detail:b({body:E(),additions:k().int().nonnegative().optional(),deletions:k().int().nonnegative().optional()}).optional()});var aa=O([`merge`,`squash`,`rebase`]),oa=b({name:E(),state:O([`passing`,`failing`,`pending`,`unknown`]),required:T().nullable(),url:E().optional()}),sa=b({number:k(),title:E(),url:E(),state:O([`open`,`closed`,`merged`]),isDraft:T(),headRef:E(),baseRef:E(),headSha:E(),mergeable:O([`mergeable`,`conflicting`,`unknown`]),reviewDecision:O([`approved`,`changes-requested`,`review-required`,`not-required`,`unknown`]),checks:w(oa),methods:w(aa),defaultMethod:aa.nullable(),eligibility:O([`ready`,`blocked`,`pending`,`unauthorized`,`terminal`,`unknown`]),blockers:w(b({code:E(),message:E()})),canMerge:T(),canOverride:T()});x(`available`,[b({available:C(!0),mergeState:sa}),b({available:C(!1),reason:E()})]),b({merged:C(!0),number:k(),url:E(),method:aa,mergeCommitSha:E().optional()});var ca=b({path:E(),previousPath:E().optional(),status:O([`added`,`modified`,`removed`,`renamed`,`copied`,`changed`]),additions:k(),deletions:k(),patch:E().optional(),patchUnavailableReason:O([`binary`,`too-large`,`not-provided`]).optional(),truncated:T().optional()});x(`available`,[b({available:C(!0),number:k(),headSha:E(),files:w(ca),additions:k(),deletions:k(),truncated:T(),reason:E().optional()}),b({available:C(!1),reason:E()})]),b({generation:E().uuid()}),x(`state`,[b({generation:E().uuid(),state:C(`ready`),projects:w($i),membership:S(E(),w(E()))}),b({generation:E().uuid(),state:C(`unavailable`),reason:E()})]);function la(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 ua(e,t){return e?(t===`issues`?e.issuesNextCursor:e.prsNextCursor)==null:!1}function da(e,t,n){for(let r of e)t.has(r.number)||(t.add(r.number),n.push(r))}function fa(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){da(t.issues,a,r),da(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 pa=e=>e.map(e=>e.number).join(`,`);function ma(e,t){let n=e[0];if(e.length>1&&n&&(pa(n.issues)!==pa(t.issues)||pa(n.prs)!==pa(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 ha=class extends Error{};function ga(e,t,n){return{queryKey:e,initialPageParam:{},queryFn:async({pageParam:e,signal:r})=>{let i=await ce({limit:t,...e,...n?{projectId:n}:{}},{signal:r});if(!i.available&&Object.keys(e).length>0)throw new ha(i.reason??`GitHub is unavailable.`);return i},getNextPageParam:e=>la(e),retry:(e,t)=>!(t instanceof ha)&&!(t instanceof et&&t.status>=400&&t.status<500)&&e<1,staleTime:6e4,refetchOnWindowFocus:!0}}function _a(e=50,t=!0){let n=v(),r=G.githubPages(e),a=G.githubPagesHead(e);ni(`/api/v1/p/${i()}/github?limit=${e}`,a,I(t?6e4:!1));let o=f({...ga(r,e),enabled:t,refetchInterval:!1,refetchIntervalInBackground:!1}),s=y({queryKey:a,queryFn:({signal:t})=>ce({limit:e},{signal:t}),enabled:!1,staleTime:1/0}),{refetch:c}=o;(0,j.useEffect)(()=>{if(!s.data)return;let e=n.getQueryData(r);if(!e||e.pages.length===0)return;let t=ma(e.pages,s.data);t===`refetch`?c():n.setQueryData(r,{...e,pages:t})},[n,s.dataUpdatedAt,c]);let l=(o.data?.pages??[]).flatMap(e=>e.projectsState===`refreshing`&&e.projectsGeneration?[e.projectsGeneration]:[]),u=M({queries:l.map(e=>({queryKey:[...r,`projects`,e],queryFn:({signal:t})=>Fe(e,{signal:t}),enabled:t,staleTime:1/0,retry:!1}))});return(0,j.useEffect)(()=>{u.forEach((e,t)=>{let i=l[t];!i||!e.data&&!e.error||n.setQueryData(r,t=>{if(!t)return t;let n=!1,r=t.pages.map(t=>{if(t.projectsGeneration!==i||t.projectsState!==`refreshing`)return t;let r=e.data;return r?.generation&&r.generation!==i?t:(n=!0,r?.state===`ready`?{...t,projectsState:`ready`,projects:r.projects,issues:t.issues.map(e=>({...e,projectIds:r.membership?.[e.number]??[]}))}:{...t,projectsState:`unavailable`,projectsReason:r?.reason??`Project boards unavailable. Refresh to try again.`})});return n?{...t,pages:r}:t})})},[n,u.map((e,t)=>e.data||e.error?l[t]:``).join(`,`)]),{pages:o,data:(0,j.useMemo)(()=>fa(o.data?.pages??[]),[o.data])}}function va(e,t=50,n=!0){let r=f({...ga([e,`github`,`pages`,t],t,e),enabled:n});return{pages:r,data:(0,j.useMemo)(()=>fa(r.data?.pages??[]),[r.data])}}function ya(e,t,n=!0){let r=M({queries:t.filter(e=>e.length>0).map(t=>({queryKey:G.githubCommentCounts(e,t),queryFn:({signal:n})=>Tt(e,t,{},{signal:n}),enabled:n,staleTime:6e4}))});return(0,j.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 ba(e,t,n,r=!0){return y({queryKey:[e,`github`,`search`,t,n],queryFn:({signal:r})=>dt(t,n,{projectId:e},{signal:r}),enabled:r&&n.trim()!==``,staleTime:6e4})}function xa(e,t=!0){return y({queryKey:G.githubChecks(e),queryFn:({signal:t})=>ve(e,{signal:t}),enabled:t&&e.length>0,staleTime:6e4})}function Sa(e,t,n=!0){return y({queryKey:G.githubSearch(e,t),queryFn:({signal:n})=>dt(e,t,{},{signal:n}),enabled:n&&t.trim()!==``,staleTime:6e4})}var Ca=100;function wa(e){return[...e].sort((e,t)=>t-e).slice(0,Ca).sort((e,t)=>e-t)}function Ta(){let e=it(),t=J();return e.projectId??t.data?.bootProject??void 0}function Ea(e){for(let[t,n]of Object.entries(e)){for(let[e,r]of Object.entries(n.prs))sr(W({projectId:t,kind:`PR`,number:Number(e)}),r);for(let[e,r]of Object.entries(n.issues))sr(W({projectId:t,kind:`Issue`,number:Number(e)}),r)}}var Da=5*6e4;function Oa(e){return e?e.recheckAfterMs:Da}function ka(e,t=!0){let n=(0,j.useMemo)(()=>{let t=new Map;for(let n of e){let e=t.get(n.projectId)??{prs:new Set,issues:new Set};e[n.kind===`PR`?`prs`:`issues`].add(n.number),t.set(n.projectId,e)}return[...t.entries()].map(([e,t])=>({projectId:e,prs:wa(t.prs),issues:wa(t.issues)}))},[e.map(W).sort().join(`|`)]),r=M({queries:n.map(e=>({queryKey:G.githubRefStatus(e.projectId,e.prs,e.issues),queryFn:({signal:t})=>a(e.projectId,{prs:e.prs,issues:e.issues},{signal:t}),enabled:t&&e.prs.length+e.issues.length>0,staleTime:e=>Oa(e.state.data)??1/0,refetchInterval:!1,refetchOnWindowFocus:!0}))}),i=v(),o=JSON.stringify(n.map((e,t)=>({...e,interval:Oa(r[t]?.data)??!1})));(0,j.useEffect)(()=>{if(!t||en())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 ti({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,j.useMemo)(()=>gr(n,r),[n,r.map(e=>`${e.dataUpdatedAt}:${e.status}`).join(`,`)]);return(0,j.useCallback)(e=>{let t=W(e),n=s.get(t);if(n)return n;let r=V.get(t);return{state:`idle`,...r?{status:r}:{},...H.has(t)?{conflicting:!0}:{}}},[s])}function Aa(e,t,n=!0){return y({queryKey:G.githubComments(e,t),queryFn:({signal:n})=>he(e,t,{},{signal:n}),enabled:n,staleTime:6e4})}function ja(e,t,n=!0){return y({queryKey:G.githubItem(e,t),queryFn:({signal:n})=>Qe(e,t,{},{signal:n}),enabled:n,staleTime:6e4})}function Ma(e){return y({queryKey:G.githubPrChanges(e??0),queryFn:({signal:t})=>Xe(e,{},{signal:t}),enabled:e!==void 0,staleTime:6e4,retry:!1})}export{hi as $,qn as $t,Vi as A,zr as At,Di as B,_r as Bt,Li as C,Hr as Ct,Ji as D,Or as Dt,qi as E,Rr as Et,wi as F,Yr as Ft,ki as G,Zn as Gt,Ti as H,K as Ht,ji as I,Jr as It,di as J,Wn as Jt,fi as K,Kn as Kt,li as L,xr as Lt,_i as M,Lr as Mt,vi as N,kr as Nt,Wi as O,Pr as Ot,yi as P,Nr as Pt,pi as Q,Yn as Qt,Mi as R,vr as Rt,Fi as S,Sr as St,zi as T,Dr as Tt,ii as U,$n as Ut,Oi as V,G as Vt,Ei as W,tr as Wt,xi as X,Gn as Xt,mi as Y,B as Yt,bi as Z,Xn as Zt,Ii as _,Gr as _t,ja as a,tn as an,Ai as at,Xi as b,qr as bt,Sa as c,P as cn,$ as ct,Ta as d,M as dn,Ur as dt,Un as en,Si as et,ka as f,Jt as fn,Vr as ft,Bi as g,Er as gt,Ki as h,Mr as ht,Aa as i,nn as in,si as it,oi as j,Fr as jt,Pi as k,wr as kt,va as l,F as ln,Br as lt,Gi as m,Wr as mt,xa as n,L as nn,ai as nt,_a as o,I as on,Ci as ot,ua as p,qt as pn,Ir as pt,Ni as q,Jn as qt,ya as r,an as rn,ci as rt,Ma as s,en as sn,ti as st,Ea as t,kn as tn,ui as tt,ba as u,N as un,Xr as ut,Ui as v,J as vt,Ri as w,Cr as wt,Yi as x,Tr as xt,Hi as y,Kr as yt,gi as z,yr as zt};
@@ -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,S as a,T as o,U as s,Vt as c,Wt as l,bt as u,nt as d,un as f,w as p}from"./queries-IlC9MZgh.js";import{p as m}from"./host-context-DDbYAKpm.js";import{B as h,Fi as g,T as _,Yn as v,f as y,n as b,ut as ee,w as x,z as te,zt as ne}from"./toaster-DNnL8v10.js";import{Z as S}from"./live-protocol-CNUmr-VT.js";import{_ as C,g as w}from"./chunk-KS7C4IRE-BdLLx37K.js";import{o as T,s as E}from"./dist-CCX8mhHc.js";import{c as re,f as D,i as ie,t as O}from"./reference-chip-BjerVjzM.js";import{D as ae,F as k,I as A,M as oe,N as se,P as ce,Q as le,S as ue,X as de,Z as fe,c as pe,ct as j,d as me,j as he,l as ge,n as _e,st as ve,w as ye,y as be}from"./design-icons-QbNMZniQ.js";import{t as xe}from"./createLucideIcon-BHp8sXmF.js";import{n as Se,t as Ce}from"./circle-x-7nTlobAF.js";import{_ as we}from"./nav-row-styles-CIedRn3A.js";import{i as Te,r as Ee,t as De}from"./git-toolbar-C7iolhIi.js";import{t as M}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-AsSX7gfO.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-Dc6KBQsv.js";import{t as We}from"./status-dot-Bmn4xhch.js";import{c as Ge,d as Ke,f as qe,m as I,n as Je,s as Ye,t as Xe}from"./page-shell-BdjH5hyc.js";import{a as Ze,o as Qe}from"./format-BU7D3IfE.js";import{t as $e}from"./control-locations-kCPVEtOM.js";import{t as L}from"./centered-state-N8vWM_Hw.js";import{$t as R,A as z,Bn as et,Bt as tt,Cr as nt,Gt as B,Ht as rt,Jt as it,Kt as at,Pn as ot,Qt as st,Rn as ct,Rt as lt,Tr as V,Ut as ut,Vt as dt,Wt as ft,Xt as pt,Yt as mt,Zt as ht,an as H,en as U,gr as gt,in as W,k as _t,lr as vt,nn as G,on as K,qt as yt,rn as q,tn as J,zn as bt,zt as xt}from"./index-DPfg7xSB.js";import{t as St}from"./markdown-BBDDg-4t.js";import{t as Ct}from"./diff-BQJN6jzN.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-CPJLP4DU.js";var Y=e(t(),1);function At(e,t){let n=g(t),r=n.getQueryCache();return Y.useSyncExternalStore(Y.useCallback(e=>r.subscribe(S.batchCalls(e)),[r]),()=>n.isFetching(e),()=>n.isFetching(e))}var jt=xe(`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=xe(`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=a(),n=g(),r=At({queryKey:c.repo})>0,i=t.data?.info?t.data:null,o=lt(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:c.repo}),n.invalidateQueries({queryKey:c.worktrees})},children:(0,X.jsx)(fe,{size:17,"aria-hidden":`true`,className:T(`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)(dt,{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:o,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:B(m())&&!t,onClick:()=>n(!0),children:[(0,X.jsx)(de,{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=ft(m()),i=B(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)(vt,{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=ft(m(),e=>b(e.message,{tone:`danger`})),s=B(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)(le,{size:16,"aria-hidden":`true`,className:`pointer-events-none absolute left-3 top-3 size-4 text-muted-foreground`}),(0,X.jsx)(vt,{"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:T(`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)(he,{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:A,className:`border-success/40 text-semantic-green`},draft:{icon:k,className:`border-border text-muted-foreground`},merged:{icon:se,className:`border-merged-strong/35 text-merged-text`},closed:{icon:ce,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:T(`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 E(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:T(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`?Se:e===`failing`?Ce:nt;return(0,X.jsxs)(`span`,{"data-slot":`pr-checks`,"data-checks":e,className:T(`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:T(`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 v&&e.error.status===409,f=e.data?.files??[],m=(0,Y.useMemo)(()=>Ee(f),[f]),h=(0,Y.useMemo)(()=>f.some(St),[f]),g=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)(L,{icon:d?(0,X.jsx)(ye,{size:16}):(0,X.jsx)(j,{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)(L,{icon:(0,X.jsx)(ye,{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)(De,{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)(Te,{root:m,selected:c,onSelect:e=>{l(e),u.current?.scrollToPath(e)}})]}),children:(0,X.jsx)(Ct,{files:f,viewRef:u,mode:g,wrap:i,preview:o,loadFileText:e=>Et(()=>_(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)(()=>st(i),[i]);if(n&&(!r||i.length===0))return(0,X.jsx)(Qt,{sha:n});let o=it(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)(L,{icon:(0,X.jsx)(oe,{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:T(`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:ht(e.when,e.at),children:pt(e.when,e.at)})]})]})]}),(0,X.jsx)(Yt,{source:e.source,stacked:n})]})}function Yt({source:e,stacked:t}){let n=T(`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:T(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)(se,{"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)(pe,{"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=ut(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)(_e,{"aria-hidden":`true`}),`Pull`]}),(0,X.jsx)(rt,{checkout:n,returnFocus:r})]})}function Zt({sha:e}){return(0,X.jsx)(Dt,{commit:o(e),sha:e,slot:`repo-commit-preview`,loadFileText:t=>Et(()=>x(e,t))})}function Qt({sha:e}){return(0,X.jsx)(kt,{commit:o(e),sha:e,backTo:at,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=d(),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)(L,{icon:(0,X.jsx)(j,{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),f=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)(M,{"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:yt.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)(ie,{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,{}),f,s.length===0?(0,X.jsx)(Xe,{icon:(0,X.jsx)(gt,{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:yt.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)(M,{"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:yt.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:T(`flex items-start gap-2 text-xs leading-relaxed text-muted-foreground`,e),children:[(0,X.jsx)(M,{"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)(O,{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=g(),r=e.class===`orphan`,i=e.pr&&(e.pr.state===`open`||e.pr.state===`draft`)?e.pr:null,a=!r&&e.runId!==null&&!i,o=f({mutationFn:()=>ee(e.runId),onSuccess:e=>{b(`Draft PR created — ${e.url}`),n.invalidateQueries({queryKey:c.repoBranches}),n.invalidateQueries({queryKey:c.runs.all})},onError:e=>b(e instanceof v&&e.manual?`${e.message} — ${e.manual}`:e.message,{tone:`danger`})}),[s,l]=(0,Y.useState)(!1),u=(0,Y.useRef)(null);(0,Y.useEffect)(()=>()=>{u.current!==null&&clearTimeout(u.current)},[]);let d=()=>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:T(p,`hidden border border-border bg-card hover:bg-muted md:inline-flex`),children:`Open task`}):null,a?(0,X.jsxs)(`button`,{type:`button`,"data-action":`not-landed-create-pr`,disabled:o.isPending,onClick:()=>o.mutate(),className:T(p,`hidden border border-border bg-card hover:bg-muted md:inline-flex`),children:[(0,X.jsx)(Mt,{"aria-hidden":`true`}),o.isPending?`Creating…`:`Draft PR`]}):null,r?(0,X.jsxs)(`button`,{type:`button`,"data-action":`not-landed-copy`,"data-copied":s||void 0,"aria-live":`polite`,onClick:d,className:T(p,`hidden border border-border bg-card hover:bg-muted md:inline-flex`),children:[s?(0,X.jsx)(ge,{"aria-hidden":`true`}):(0,X.jsx)(be,{"aria-hidden":`true`}),s?`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)(ue,{"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,a?(0,X.jsx)(P,{className:`md:hidden`,disabled:o.isPending,onSelect:()=>o.mutate(),children:`Draft PR`}):null,(0,X.jsx)(P,{className:T(!r&&`md:hidden`),onSelect:d,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=Ze(i),o=e.runStatus?ot(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)(we,{"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=l(re(`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=g(),[r,i]=(0,Y.useState)(``),a=(0,Y.useId)(),o=f({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:c.repo}),s()},onError:e=>b(e.message,{tone:`danger`})}),s=()=>{i(``),t()},l=e!==null&&r.trim()===e.name,u=e&&`${e.ahead} commit${e.ahead===1?``:`s`}`;return(0,X.jsx)(R,{open:e!==null,onOpenChange:e=>!e&&!o.isPending&&s(),children:(0,X.jsxs)(G,{"data-slot":`delete-branch-dialog`,children:[(0,X.jsxs)(H,{children:[(0,X.jsxs)(K,{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&&!o.isPending&&o.mutate(e.name)},className:`flex flex-col gap-[6px]`,children:[(0,X.jsxs)(`label`,{htmlFor:a,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)(vt,{id:a,"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)(W,{children:[(0,X.jsx)(J,{className:`h-11`,disabled:o.isPending,children:`Keep it`}),(0,X.jsx)(U,{"data-action":`delete-branch-confirm`,className:`h-11 bg-danger text-danger-foreground hover:brightness-[0.96]`,disabled:!l||o.isPending,onClick:t=>{t.preventDefault(),e&&o.mutate(e.name)},children:o.isPending?`Deleting…`:`Delete branch`})]})]})})}function dn({base:e}){let t=i(),n=g(),[r,a]=(0,Y.useState)({merged:!1,empty:!1}),[o,s]=(0,Y.useState)(!1),l=(t.data?.branches??[]).filter(e=>e.class===`merged`),u=(t.data?.branches??[]).filter(e=>e.class===`empty`),d=[...l,...u],p=f({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:c.repo})},onError:e=>{n.invalidateQueries({queryKey:c.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=d.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:()=>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)(ve,{"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:()=>a(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:()=>a(e=>({...e,empty:!e.empty}))}),(0,X.jsx)(R,{open:o,onOpenChange:s,children:(0,X.jsxs)(G,{children:[(0,X.jsxs)(H,{children:[(0,X.jsxs)(K,{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)(W,{children:[(0,X.jsx)(J,{children:`Keep them`}),(0,X.jsxs)(U,{"data-action":`cleanup-branches-confirm`,className:`bg-danger text-danger-foreground hover:brightness-[0.96]`,onClick:()=>{p.mutate(d.map(e=>e.name)),s(!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)(me,{"aria-hidden":`true`,className:T(`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)(ct,{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 ${D(t)} now`:`Reclaim ${e} now`}function vn(e,t,n){let r=t?D(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?` (${D(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)(V,{"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)(R,{open:e,onOpenChange:e=>{e||t()},children:(0,X.jsxs)(G,{children:[(0,X.jsxs)(H,{children:[(0,X.jsx)(K,{children:`Reclaim old worktrees?`}),(0,X.jsxs)(q,{children:[n,` finished worktree`,n===1?``:`s`,` beyond the keep limit`,r?` (${D(r)})`:``,` `,n===1?`is`:`are`,` reclaimed now, directory only. Their branches are kept, so the work stays recoverable.`]})]}),(0,X.jsxs)(W,{children:[(0,X.jsx)(J,{children:`Keep them`}),(0,X.jsx)(U,{"data-action":`worktrees-confirm`,onClick:a,children:i})]})]})}),(0,X.jsx)(R,{open:o!==null,onOpenChange:e=>{e||s()},children:(0,X.jsxs)(G,{children:[(0,X.jsxs)(H,{children:[(0,X.jsx)(K,{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?` (${D(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)(W,{children:[(0,X.jsx)(J,{children:`Keep them`}),(0,X.jsx)(U,{"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)(R,{open:l!==null,onOpenChange:e=>{e||u()},children:(0,X.jsxs)(G,{children:[(0,X.jsxs)(H,{children:[(0,X.jsx)(K,{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)(W,{children:[(0,X.jsx)(J,{children:`Keep it`}),(0,X.jsx)(U,{"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=s().data?.targets.find(e=>e.id===`finder`),n=f({mutationFn:e=>ne(e,t.id),onError:e=>b(e.message,{tone:`danger`})}),i=g(),[a,o]=(0,Y.useState)(!1),[l,u]=(0,Y.useState)(null),[d,p]=(0,Y.useState)(null),m=()=>Promise.all([i.invalidateQueries({queryKey:c.worktrees}),i.invalidateQueries({queryKey:c.repoBranches})]),_=f({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=f({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=_.isPending||v.isPending,C=y.filter(e=>e.pastKeep),w=C.filter(e=>!e.reclaimBlocker),T=C.filter(e=>e.reclaimBlocker!==null),E=w.length>0,re=$(w),ie=$(C),O=_n(w.length,re),ae=vn(C.length,ie,E),k=ee?D(ee):null,A=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`,k?` · ${k}`:``]}),(0,X.jsxs)(`p`,{"data-slot":`worktrees-retention`,className:`text-xs leading-[17px] text-soft-foreground`,children:[A.prefix,(0,X.jsx)(F,{to:`/settings/worktrees`,"data-slot":`worktrees-retention-link`,className:`underline-offset-2 hover:text-foreground hover:underline`,children:$e(`worktrees`,` › `)}),A.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||!E,title:yn(E,T.length),onClick:()=>o(!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)(V,{"aria-hidden":`true`,className:`size-[12px]`}),O]})]}),T.length>0?(0,X.jsx)(xn,{blocked:T,discardLabel:ae,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:a,onCloseClean:()=>o(!1),cleanCount:w.length,cleanBytes:re,reclaimLabel:O,onConfirmClean:()=>{_.mutate({expected:w.length}),o(!1)},discardBatch:l,onCloseDiscardBatch:()=>u(null),onConfirmDiscardBatch:e=>{_.mutate({expected:e.length,runIds:e.map(e=>e.runId)})},discardRow:d,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=Ze(e.finishedAt??void 0),c=e.status===`review`?`at review`:s?`${e.status} ${Qe(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:T(`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?`—`:D(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)(ae,{"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:T(f,e.reclaimBlocker&&`text-danger hover:text-danger`),children:(0,X.jsx)(V,{"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=a(),r=I(),[i]=C(),o=Dn(e);if(t&&!r&&i.get(`view`)!==`repo`)return(0,X.jsx)(Nt,{});if(n.isPending)return(0,X.jsx)(_t,{});if(n.isError)return(0,X.jsx)(Ye,{template:o,route:`repo-git`,density:`empty`,beforeHeader:(0,X.jsx)(z,{}),children:(0,X.jsx)(L,{icon:(0,X.jsx)(j,{size:16}),tone:`danger`,title:`Could not load the repository`,subtitle:n.error.message})});let s=n.data.info;return s?(0,X.jsx)(kn,{repo:n.data,info:s,section:e}):(0,X.jsx)(Ye,{template:o,route:`repo-git`,density:`empty`,beforeHeader:(0,X.jsx)(z,{}),children:(0,X.jsx)(L,{icon:(0,X.jsx)(he,{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)(Ye,{template:r,route:`repo-git`,density:n===`not-landed`&&a.isPending?`full`:qe(s),rootProps:{"data-git-section":n},beforeHeader:(0,X.jsx)(z,{}),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=o(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?` · ${mt(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,2 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{G as r,H as i,J as a,St as o,U as s,V as c,Vt as l,W as u,bt as d,cn as f,ct as p,d as m,en as h,et as g,ln as _,nt as ee,un as v,vt as te,xt as y}from"./queries-IlC9MZgh.js";import{Bt as b,Fi as ne,Hr as re,Yn as x,dn as ie,ft as ae,gi as S,ln as oe,n as C,oi as se,rt as ce,zt as w}from"./toaster-DNnL8v10.js";import{o as T,s as E}from"./dist-CCX8mhHc.js";import{C as D,S as le,T as O,b as ue,g as de,i as fe,m as pe,n as me,p as he,t as k,x as ge}from"./reference-chip-BjerVjzM.js";import{I as _e,S as ve,Y as ye,Z as be,a as xe,ct as Se,m as Ce,mt as we,o as Te,st as Ee,t as De,u as Oe,y as A}from"./design-icons-QbNMZniQ.js";import{t as j}from"./createLucideIcon-BHp8sXmF.js";import{t as ke}from"./app-window-CSHwDX9N.js";import{n as Ae,r as je,t as Me}from"./open-in-menu-BI7mnPPf.js";import{t as Ne}from"./info-DA1x_4bz.js";import{t as Pe}from"./message-square-B-MD-8rD.js";import{t as Fe}from"./square-terminal-B6RYYieR.js";import{t as M}from"./button-BV_AiLj2.js";import{a as N,i as P,l as F,n as I,p as L,r as R,t as z}from"./dropdown-menu-NJZfnQCU.js";import{n as Ie,r as Le,t as Re}from"./popover-BQolmvDR.js";import{a as ze,i as Be,o as Ve,r as He,s as Ue,t as We}from"./dialog-DKr-j9S6.js";import{c as Ge,s as Ke,t as B}from"./project-router-Dc6KBQsv.js";import"./attention-BI6592lk.js";import{T as qe,f as V,u as Je}from"./task-groups-DCg4iOB9.js";import{t as H}from"./status-dot-Bmn4xhch.js";import{t as Ye}from"./format-BU7D3IfE.js";import{a as Xe}from"./agent-accounts-D_ZKAmaW.js";import{$t as Ze,Dn as U,Er as Qe,Fn as $e,G as et,Jn as tt,K as W,W as nt,Wn as rt,a as it,an as at,bn as G,dn as ot,en as st,er as ct,h as lt,hn as ut,i as dt,in as ft,ir as K,ln as pt,m as mt,mr as ht,nn as gt,nr as _t,on as vt,pr as q,rn as yt,tn as bt,tr as J,vr as xt,yn as St}from"./index-DPfg7xSB.js";import{t as Ct}from"./textarea-BGp28xFr.js";import{t as wt}from"./markdown-Cljq4S1h.js";import{t as Tt}from"./task-file-scope-ID220XKo.js";import{t as Y}from"./tab-link-6TltE1jl.js";var Et=j(`bell-off`,[[`path`,{d:`M10.268 21a2 2 0 0 0 3.464 0`,key:`vwvbt9`}],[`path`,{d:`M17 17H4a1 1 0 0 1-.74-1.673C4.59 13.956 6 12.499 6 8a6 6 0 0 1 .258-1.742`,key:`178tsu`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}],[`path`,{d:`M8.668 3.01A6 6 0 0 1 18 8c0 2.687.77 4.653 1.707 6.05`,key:`1hqiys`}]]),Dt=j(`mail`,[[`path`,{d:`m22 7-8.991 5.727a2 2 0 0 1-2.009 0L2 7`,key:`132q7q`}],[`rect`,{x:`2`,y:`4`,width:`20`,height:`16`,rx:`2`,key:`izxlao`}]]),Ot=j(`panel-right`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M15 3v18`,key:`14nvp0`}]]),kt=j(`pin-off`,[[`path`,{d:`M12 17v5`,key:`bb1du9`}],[`path`,{d:`M15 9.34V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H7.89`,key:`znwnzq`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}],[`path`,{d:`M9 9v1.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h11`,key:`c9qhm2`}]]),X=e(t(),1),Z=n();function At(e){let t=p();return v({mutationFn:t=>ce(_(e),t),onSuccess:()=>t.invalidateAfter(`runs`,()=>f()),onError:e=>C(e.message,{tone:`danger`})})}var jt={archive:{full:`Archive task`,compact:`Archive`},unarchive:{full:`Unarchive`,compact:`Unarchive`}};function Mt(e){return jt[e.archived?`unarchive`:`archive`].full}function Nt(e){return jt[e.archived?`unarchive`:`archive`].compact}function Pt({run:e,open:t,onOpenChange:n,onConfirm:r}){return(0,Z.jsx)(Ze,{open:t,onOpenChange:n,children:(0,Z.jsxs)(gt,{"data-slot":`task-confirmation`,className:`sm:max-w-[660px]`,children:[(0,Z.jsxs)(at,{children:[(0,Z.jsx)(vt,{children:`Archive task?`}),(0,Z.jsxs)(yt,{children:[`Move “`,(0,Z.jsx)(`span`,{className:`font-medium text-foreground`,title:V(e),children:V(e)}),`” out of Active tasks. You can restore it from Archived.`]})]}),(0,Z.jsxs)(ft,{children:[(0,Z.jsx)(bt,{children:`Cancel`}),(0,Z.jsx)(st,{className:`bg-accent-strong text-accent-strong-foreground hover:brightness-[0.96]`,onClick:r,children:`Archive task`})]})]})})}function Ft({run:e,className:t,compact:n=!1}){let[r,i]=(0,X.useState)(!1),a=At(e.id),o=Mt(e);return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(M,{type:`button`,variant:`outline`,"data-slot":`archive-action`,"aria-label":o,title:e.archived?`Put this task back in Active tasks`:`Move this task out of Active tasks`,disabled:a.isPending,className:T(`gap-[7px] px-3`,t),onClick:()=>e.archived?a.mutate(!1):i(!0),children:[e.archived?(0,Z.jsx)(Qe,{"aria-hidden":`true`}):(0,Z.jsx)(De,{"aria-hidden":`true`}),(0,Z.jsx)(`span`,{children:n?Nt(e):o})]}),(0,Z.jsx)(Pt,{run:e,open:r,onOpenChange:i,onConfirm:()=>{a.mutate(!0),i(!1)}})]})}function It({phone:e}){return e?(0,Z.jsx)(Te,{"aria-hidden":`true`}):null}function Lt({run:e,action:t,prUrl:n,patch:r,phone:i}){let a=t.phase===`blocked`;return{key:`completion`,heading:a?`Completion blocked`:`Completion pending`,reason:t.message||(a?`Completion needs attention.`:`Checking completion actions.`),pending:!a,actions:(0,Z.jsxs)(Z.Fragment,{children:[n&&E(n)?(0,Z.jsx)(M,{variant:`outline`,asChild:!0,children:(0,Z.jsxs)(`a`,{href:n,target:`_blank`,rel:`noopener noreferrer`,children:[`Open PR`,(0,Z.jsx)(It,{phone:i})]})}):null,e.autoMergePr?(0,Z.jsx)(M,{variant:`outline`,disabled:r.isPending,onClick:()=>r.mutate({autoMergePr:!1},{onError:e=>C(e.message,{tone:`danger`})}),children:r.isPending?`Saving…`:`Disable auto-merge`}):null]})}}function Rt({run:e,blocker:t,flags:n,phone:r}){return{key:`archive`,heading:`Archive blocked`,reason:t.message,actions:(0,Z.jsxs)(Z.Fragment,{children:[t.runId?(0,Z.jsx)(M,{variant:`outline`,asChild:!0,children:(0,Z.jsx)(B,{to:`/tasks/${t.runId}`,"aria-label":r?`Open task that blocks the archive`:void 0,children:r?`Open task`:`Open blocking task`})}):null,t.pullRequestUrl&&E(t.pullRequestUrl)?(0,Z.jsx)(M,{variant:`outline`,asChild:!0,children:(0,Z.jsxs)(`a`,{href:t.pullRequestUrl,target:`_blank`,rel:`noopener noreferrer`,"aria-label":r?`Open PR that blocks the archive`:void 0,children:[r?`Open PR`:`Open blocking PR`,(0,Z.jsx)(It,{phone:r})]})}):null,n.archive?(0,Z.jsx)(Ft,{run:e,compact:r}):null]})}}function zt({heading:e,reason:t,className:n,hideHeading:r}){return(0,Z.jsxs)(`p`,{role:`status`,"aria-live":`polite`,"aria-atomic":`true`,className:T(`text-sm [overflow-wrap:anywhere]`,n),children:[r?(0,Z.jsxs)(`span`,{className:`sr-only`,children:[e,` · `]}):(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`span`,{className:`font-medium`,children:e}),` · `]}),t]})}function Bt({blocks:e}){return(0,Z.jsx)(`section`,{"data-slot":`completion-status`,"aria-label":`Completion action`,className:`grid min-w-0 gap-2 rounded-lg border border-card-edge bg-card p-3 shadow-card [margin-block:0.75rem]`,children:e.map(e=>(0,Z.jsxs)(X.Fragment,{children:[(0,Z.jsx)(zt,{heading:e.heading,reason:e.reason}),(0,Z.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:e.actions})]},e.key))})}function Vt({blocks:e}){let[t,n]=(0,X.useState)(!1),r=(0,X.useId)(),[i]=e;if(!i)return null;let a=e.length-1;return(0,Z.jsxs)(`section`,{"data-slot":`completion-status`,"aria-label":`Completion action`,className:`-mx-4 min-w-0 border-b border-card-edge bg-card`,children:[(0,Z.jsxs)(`button`,{type:`button`,"data-slot":`completion-status-toggle`,"aria-expanded":t,"aria-controls":r,onClick:()=>n(e=>!e),className:`flex min-h-11 w-full items-center gap-2 px-4 text-start text-sm outline-hidden focus-visible:ring-[3px] focus-visible:ring-inset focus-visible:ring-ring/50`,children:[i.pending?(0,Z.jsx)(be,{"aria-hidden":`true`,className:`size-4 shrink-0 text-muted-foreground`}):(0,Z.jsx)(Se,{"aria-hidden":`true`,className:`size-4 shrink-0 text-semantic-amber`}),(0,Z.jsx)(`span`,{className:`shrink-0 font-medium`,children:i.heading}),t?(0,Z.jsx)(`span`,{className:`flex-1`}):(0,Z.jsxs)(`span`,{"aria-hidden":`true`,className:`min-w-0 flex-1 truncate text-muted-foreground`,children:[`· `,i.reason]}),a>0?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`span`,{"aria-hidden":`true`,className:`shrink-0 text-muted-foreground`,children:[`+`,a]}),(0,Z.jsxs)(`span`,{className:`sr-only`,children:[`and `,a,` more`]})]}):null,(0,Z.jsx)(Oe,{"aria-hidden":`true`,className:T(`size-4 shrink-0 text-muted-foreground`,t&&`rotate-180`)})]}),(0,Z.jsx)(`div`,{id:r,className:T(t&&`grid gap-2 px-4 pb-3`),children:e.map((e,n)=>(0,Z.jsxs)(X.Fragment,{children:[(0,Z.jsx)(zt,{heading:e.heading,reason:e.reason,className:T(!t&&`sr-only`),hideHeading:n===0}),t?(0,Z.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:e.actions}):null]},e.key))})]})}function Ht({run:e}){let t=u(e.id),n=J(),r=G(e),i=e.status===`done`?e.completionAction:void 0,a=r.archive?e.archiveBlocker:void 0,o=i&&i.phase!==`complete`?i:void 0;if(!o&&!a)return null;let s=e.pullRequestUrl??e.pullRequests?.find(e=>e.url)?.url,c=!n,l=[o?Lt({run:e,action:o,prUrl:s,patch:t,phone:c}):void 0,a?Rt({run:e,blocker:a,flags:r,phone:c}):void 0].filter(e=>e!==void 0);return n?(0,Z.jsx)(Bt,{blocks:l}):(0,Z.jsx)(Vt,{blocks:l})}var Ut=[`running`,`queued`,`waiting`];function Wt(e,{queuePosition:t,now:n=new Date}){let r=se(e),i=$e(e,r).label,a=t===void 0?i:`${i} #${t}`,o=Ut.includes(e.status)?Kt(e,n):void 0;return o?{attention:r,label:a,nextCheck:o}:{attention:r,label:a}}function Gt(e){return e.nextCheck?`${e.label} · Next check ${e.nextCheck.text}`:e.label}function Kt(e,t){let n;for(let t of Array.isArray(e.waits)?e.waits:[]){if(t?.kind!==`timer`||t.phase!==`open`)continue;let e=new Date(t.deadline);Number.isFinite(e.getTime())&&(!n||e<n)&&(n=e)}if(n)return{at:n.toISOString(),text:Ye(n,t)}}async function Q(e,t){try{await navigator.clipboard.writeText(e),C(t)}catch{C(`Run manually: ${e}`)}}function qt(e){let t=d(),n=m(),r=(0,X.useMemo)(()=>O(e,t),[e,t]);return{referenceProjectId:n,repoBase:t,references:r,requests:(0,X.useMemo)(()=>n===void 0?[]:r.filter(e=>he(e,t)).map(e=>({projectId:n,kind:e.kind,number:e.number})),[r,n,t])}}function Jt(e){return v({mutationFn:()=>b(e.id),onError:e=>{if(e instanceof x&&e.command){Q(e.command,`No terminal found — command copied to clipboard.`);return}C(e.message,{tone:`danger`})}})}function Yt(e,t){let n=s(),r=o(),i=h(),a=v({mutationFn:t=>w(e.id,t),onError:e=>C(e.message,{tone:`danger`})}),c=Xe(),l=qe(e),u=c.runnersOn(e=>t&&l.sessionId!==void 0&&e===l.backend?l.profileId??`default`:c.repoAccount?.[e]).runners,d=e=>!r.isSuccess||!i.isSuccess||u.includes(e??`claude`);return{canResumeHere:t&&d(ut(e)),choices:e.worktreePath?(n.data?.targets??[]).filter(e=>{let t=Ae(e.id);return t===void 0||i.isSuccess&&d(t)}).map(t=>({target:t,...ot(e,t.id)?{suffix:` (resume)`,title:`Resume this run's session`}:{}})):[],open:a}}function Xt({run:e,canResume:t,onResume:n}){let{canResumeHere:r,choices:i,open:a}=Yt(e,t),o=h().data,s=St(e);return!r&&i.length===0&&!s?null:(0,Z.jsxs)(Z.Fragment,{children:[r||i.length>0?(0,Z.jsxs)(`div`,{className:`task-open-targets flex flex-wrap gap-3`,children:[r?(0,Z.jsxs)(M,{variant:`outline`,"data-target":`terminal-resume`,onClick:n,children:[(0,Z.jsx)(Fe,{}),`Terminal (resume session)`]}):null,i.map(({target:e,suffix:t,title:n})=>{let r=je(e,o);return(0,Z.jsxs)(M,{variant:`outline`,"data-target":e.id,title:n,disabled:a.isPending,onClick:()=>a.mutate(e.id),children:[(0,Z.jsx)(r,{"aria-hidden":`true`}),e.label,t??``]},e.id)}),e.worktreePath?(0,Z.jsxs)(M,{variant:`outline`,onClick:()=>{let t=e.worktreePath;t&&navigator.clipboard.writeText(t).then(()=>C(`Worktree path copied`)).catch(()=>C(`Path: ${t}`))},children:[(0,Z.jsx)(A,{}),`Copy worktree path`]}):null]}):null,s?(0,Z.jsxs)(`div`,{"data-slot":`resume-command`,className:`mt-5 border-t border-border pt-5`,children:[(0,Z.jsx)(`h3`,{className:`text-base font-medium`,children:`Resume in a terminal`}),(0,Z.jsx)(`pre`,{className:`my-4 whitespace-pre-wrap break-all rounded-lg border border-border bg-background p-4 text-xs`,children:s}),(0,Z.jsxs)(M,{variant:`outline`,onClick:()=>void Q(s,`Command copied to clipboard.`),children:[(0,Z.jsx)(A,{}),`Copy resume command`]})]}):null]})}function Zt({run:e,canResume:t,onResume:n}){let{canResumeHere:r,choices:i,open:a}=Yt(e,t),o=St(e),s=e.worktreePath;return!r&&i.length===0&&!o&&!s?null:(0,Z.jsxs)(`div`,{"data-slot":`workspace-tools`,className:`flex min-w-0 flex-wrap gap-2`,children:[r||i.length>0?(0,Z.jsx)(Me,{choices:i,onPick:e=>a.mutate(e),disabled:a.isPending,triggerVariant:`outline`,leading:r?(0,Z.jsxs)(P,{"data-target":`terminal-resume`,onSelect:n,children:[(0,Z.jsx)(Fe,{"aria-hidden":`true`}),`Terminal (resume session)`]}):void 0}):null,s?(0,Z.jsxs)(M,{variant:`outline`,size:`sm`,onClick:()=>void Q(s,`Worktree path copied`),children:[(0,Z.jsx)(A,{"aria-hidden":`true`}),`Copy worktree path`]}):null,o?(0,Z.jsxs)(M,{variant:`outline`,size:`sm`,"data-slot":`resume-command`,title:o,onClick:()=>void Q(o,`Command copied to clipboard.`),children:[(0,Z.jsx)(A,{"aria-hidden":`true`}),`Copy resume command`]}):null]})}function Qt({run:e,canResume:t,onResume:n,onOpen:r,onClose:i}){let{canResumeHere:a,choices:o}=Yt(e,t);return!a&&o.length===0?null:r?(0,Z.jsx)(P,{onSelect:r,children:`Open in…`}):(0,Z.jsxs)(`section`,{"aria-label":`Open task worktree in…`,className:`task-action-panel my-5 rounded-xl border border-border bg-card p-6`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,Z.jsx)(`h2`,{className:`text-lg font-medium`,children:`Open task worktree in…`}),(0,Z.jsx)(M,{variant:`ghost`,size:`icon`,"aria-label":`Close worktree chooser`,onClick:i,children:(0,Z.jsx)(we,{})})]}),e.worktreePath?(0,Z.jsx)(`p`,{className:`my-4 break-all text-xs text-muted-foreground`,children:e.worktreePath}):null,(0,Z.jsx)(`div`,{className:`mt-4`,children:(0,Z.jsx)(Xt,{run:e,canResume:t,onResume:n})})]})}function $t({branch:e}){let[t,n]=(0,X.useState)(null),r=(0,X.useRef)(null);(0,X.useEffect)(()=>()=>{r.current!==null&&clearTimeout(r.current)},[]);let i=t===e,a=async()=>{r.current!==null&&clearTimeout(r.current),n(null);try{if(!navigator.clipboard?.writeText)throw Error(`Clipboard unavailable`);await navigator.clipboard.writeText(e),n(e),r.current=setTimeout(()=>n(null),2e3)}catch{C(`Could not copy branch. Select and copy: ${e}`)}};return(0,Z.jsxs)(`span`,{className:`inline-flex min-w-0 max-w-full items-center gap-1`,children:[(0,Z.jsx)(`span`,{"data-slot":`branch-chip`,className:`min-w-0 rounded-sm border border-border bg-card px-1.5 py-px font-mono text-xs font-medium break-all`,children:e}),(0,Z.jsxs)(`button`,{type:`button`,"aria-label":i?`Copied branch name`:`Copy branch name`,onClick:()=>void a(),className:`inline-flex min-h-11 shrink-0 items-center gap-1 rounded-sm px-2 text-xs font-medium text-foreground hover:bg-muted focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-link-foreground md:min-h-8`,children:[(0,Z.jsx)(A,{className:`size-3.5`,"aria-hidden":`true`}),(0,Z.jsx)(`span`,{"aria-live":`polite`,children:i?`Copied`:`Copy`})]})]})}function en({run:e}){let t=d(),n=m(),r=r=>n===void 0?void 0:ge(n,e.id,r,t),i=(0,X.useMemo)(()=>O(e,t),[e,t]),a=[],o=[],s=i.filter(e=>e.kind===`PR`);for(let t of s)a.push((0,Z.jsx)(k,{reference:t,to:r(t),taskTitle:V(e),className:`h-5 no-hover:min-h-[44px] no-hover:min-w-[44px]`,conflictAction:(0,Z.jsx)(pt,{run:e,prNumber:t.number})},de(t)));let c=D(e);c&&E(c)&&!s.some(e=>e.url===c)&&a.push((0,Z.jsx)(k,{reference:{kind:`PR`,url:c},taskTitle:V(e),className:`h-5 no-hover:min-h-[44px] no-hover:min-w-[44px]`},`pr`));let l=i.filter(e=>e.kind===`Issue`);for(let t of l)o.push((0,Z.jsx)(k,{reference:t,to:r(t),taskTitle:V(e),className:`h-5 no-hover:min-h-[44px] no-hover:min-w-[44px]`},de(t)));let u=ue(e,t);if(u&&E(u)&&!l.some(e=>e.url===u)){let t=pe(u);o.push((0,Z.jsx)(k,{reference:{kind:`Issue`,...t?{number:Number(t)}:{},url:u},to:t?r({kind:`Issue`,number:Number(t),url:u}):void 0,taskTitle:V(e),className:`h-5 no-hover:min-h-[44px] no-hover:min-w-[44px]`},`issue`))}return a.length===0&&o.length===0?null:(0,Z.jsx)(`div`,{"data-slot":`linked-references`,className:`flex min-w-0 flex-col gap-3`,children:[[`PR`,`PRs`,a],[`Issue`,`Issues`,o]].map(([e,t,n])=>n.length>0?(0,Z.jsxs)(`div`,{"data-reference-kind":e,className:`grid min-w-0 grid-cols-[5rem_minmax(0,1fr)] items-center gap-x-2 gap-y-1`,children:[(0,Z.jsx)(`span`,{className:`font-medium text-foreground`,children:t}),(0,Z.jsx)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-2`,children:n})]},e):null)})}function tn(){let e=Ke(),t=y();return nt(t.data?.projects?.find(n=>n.id===(e??t.data?.bootProject)))}var $=e=>e.map(e=>`${e.name}: ${et(e.url)}`).join(`
2
- `);function nn(e){let t=tt(),n=tn(),r=n.length>0,a=i(e.id),[o,s]=(0,X.useState)(null),c=e.notify===!0,l=()=>a.mutate({notify:!1},{onSuccess:()=>C(`Stopped notifying the webhook`),onError:e=>C(`Could not stop notifying. ${e.message}`,{tone:`danger`})}),u=r?(0,Z.jsx)(sn,{mode:o,targets:n,pending:a.isPending,onOpenChange:e=>!e&&s(null),onSubmit:e=>a.mutate({notify:!0,...e?{message:e}:{}},{onSuccess:()=>{s(null),C(o===`note`?`Note sent to the webhook`:`Handed off to the webhook`)},onError:e=>C(`Could not hand off. ${e.message}`,{tone:`danger`})})}):null;return{visible:t!==`absent`&&(r||c),notifying:c,reachable:r,targets:n,pending:a.isPending,open:s,stop:l,dialog:u}}function rn({run:e}){let t=nn(e);if(!t.visible)return null;let{notifying:n,reachable:r,targets:i}=t;return(0,Z.jsxs)(Z.Fragment,{children:[n?(0,Z.jsxs)(z,{children:[(0,Z.jsx)(L,{asChild:!0,children:(0,Z.jsxs)(M,{variant:`outline`,"data-slot":`notifying-chip`,className:`gap-1.5`,"aria-label":r?`Notifying ${W(i)} — webhook actions`:`Notifying — webhook actions`,title:r?$(i):void 0,children:[(0,Z.jsx)(H,{tone:`success`}),(0,Z.jsx)(`span`,{children:`Notifying`}),(0,Z.jsx)(Oe,{"aria-hidden":`true`,className:`size-3.5`})]})}),(0,Z.jsxs)(R,{align:`end`,"data-slot":`notifying-menu`,className:`w-[240px] max-w-[calc(100vw-2rem)] p-2`,children:[r?(0,Z.jsx)(N,{"data-slot":`notifying-targets`,className:`flex flex-col gap-0.5 px-2 py-1.5 text-xs font-normal text-muted-foreground`,children:i.map(e=>(0,Z.jsx)(`span`,{"data-webhook-target":e.id,className:`truncate`,title:et(e.url),children:e.name},e.id))}):null,r?(0,Z.jsxs)(P,{className:`min-h-11`,onSelect:()=>t.open(`note`),children:[(0,Z.jsx)(Pe,{"aria-hidden":`true`}),` Send a note…`]}):null,(0,Z.jsxs)(P,{variant:`destructive`,className:`min-h-11`,disabled:t.pending,onSelect:t.stop,children:[(0,Z.jsx)(Et,{"aria-hidden":`true`}),` Stop notifying`]})]})]}):(0,Z.jsxs)(M,{variant:`outline`,"data-action":`handoff`,className:`max-md:px-0`,"aria-label":`Hand off to webhook`,onClick:()=>t.open(`handoff`),children:[(0,Z.jsx)(q,{"aria-hidden":`true`}),(0,Z.jsx)(`span`,{className:`max-md:sr-only`,children:`Hand off`})]}),t.dialog]})}function an({handoff:e}){if(!e.visible)return null;let{notifying:t,reachable:n,targets:r}=e;return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(F,{}),(0,Z.jsx)(N,{"data-slot":`handoff-menu-label`,className:`truncate px-2 py-3 text-[12px] font-normal text-muted-foreground uppercase`,title:n?$(r):void 0,children:n?`Webhook · ${W(r)}`:`Webhook`}),t?(0,Z.jsxs)(Z.Fragment,{children:[n?(0,Z.jsx)(P,{"data-action":`handoff-note`,className:`min-h-11`,onSelect:()=>e.open(`note`),children:`Send a note…`}):null,(0,Z.jsx)(P,{"data-action":`handoff-stop`,variant:`destructive`,className:`min-h-11`,disabled:e.pending,onSelect:e.stop,children:`Stop notifying`})]}):(0,Z.jsx)(P,{"data-action":`handoff`,className:`min-h-11`,onSelect:()=>e.open(`handoff`),children:`Hand off to webhook…`})]})}function on({run:e}){let t=tt(),n=tn();return e.notify!==!0||t===`absent`?null:(0,Z.jsx)(K,{"data-slot":`notifying-status`,role:`img`,"aria-label":n.length>0?`Notifying ${W(n)}`:`Notifying`,title:n.length>0?$(n):void 0,className:`shrink-0 px-2 py-px leading-4`,children:(0,Z.jsx)(q,{"aria-hidden":`true`,className:`size-3 text-success`})})}function sn({mode:e,targets:t,pending:n,onOpenChange:r,onSubmit:i}){let a=(0,X.useId)(),o=(0,X.useId)(),[s,c]=(0,X.useState)(``);(0,X.useEffect)(()=>{e!==null&&c(``)},[e]);let l=e===`note`,u=W(t);return(0,Z.jsx)(We,{open:e!==null,onOpenChange:e=>{e||c(``),r(e)},children:(0,Z.jsx)(He,{"data-slot":`handoff-dialog`,className:`max-sm:top-auto max-sm:bottom-0 max-sm:left-0 max-sm:max-w-none max-sm:translate-x-0 max-sm:translate-y-0 max-sm:rounded-b-none max-sm:rounded-t-xl max-sm:border-x-0 max-sm:border-b-0 max-sm:pb-[max(1.5rem,env(safe-area-inset-bottom))] max-sm:data-[state=open]:slide-in-from-bottom max-sm:data-[state=open]:zoom-in-100 max-sm:data-[state=closed]:slide-out-to-bottom max-sm:data-[state=closed]:zoom-out-100`,children:(0,Z.jsxs)(`form`,{className:`grid gap-4`,onSubmit:e=>{e.preventDefault(),i(s.trim())},children:[(0,Z.jsxs)(Ve,{className:`text-left`,children:[(0,Z.jsx)(Ue,{children:l?`Send a note to ${t.length===1?`the webhook`:`the webhooks`}`:`Hand off to webhook`}),(0,Z.jsx)(Be,{children:(0,Z.jsx)(`span`,{"data-webhook-destination":``,title:$(t),children:l?`${u} ${t.length===1?`gets`:`get`} this note with the task's current status.`:`${u} will start receiving this task's status updates. Add a note (optional).`})})]}),(0,Z.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,Z.jsx)(`label`,{htmlFor:a,className:`text-[13px] font-medium`,children:`Note`}),(0,Z.jsx)(Ct,{id:a,"data-slot":`handoff-note`,"aria-describedby":o,rows:4,maxLength:1e5,className:`min-h-24`,placeholder:`e.g. Take over from here, ping me when the PR is green`,value:s,onChange:e=>c(e.target.value)}),(0,Z.jsxs)(`p`,{id:o,className:`flex items-center gap-1.5 text-[12px] text-muted-foreground`,children:[(0,Z.jsx)(Ne,{"aria-hidden":`true`,className:`size-3.5 shrink-0`}),`The note goes to the webhook only, not to the agent.`]})]}),(0,Z.jsxs)(ze,{className:`gap-2 max-sm:flex-col-reverse max-sm:[&>button]:w-full`,children:[(0,Z.jsx)(M,{type:`button`,variant:`ghost`,onClick:()=>r(!1),children:`Cancel`}),(0,Z.jsxs)(M,{type:`submit`,variant:`contrast`,"data-action":`handoff-submit`,disabled:n||l&&s.trim()===``,children:[(0,Z.jsx)(q,{"aria-hidden":`true`}),l?`Send note`:`Hand off`]})]})]})})})}function cn({id:e}){return(0,Z.jsxs)(B,{to:`/tasks/${e}`,"aria-label":`Parent task ${e}`,"data-slot":`mobile-parent-task-link`,className:`inline-flex shrink-0 items-center justify-center gap-1 rounded-sm px-2 text-[13px] text-muted-foreground [min-block-size:2.75rem] [min-inline-size:2.75rem] focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring active:bg-muted active:text-foreground`,children:[(0,Z.jsx)(xe,{"aria-hidden":!0,className:`shrink-0 [block-size:1.2cap] [inline-size:auto]`}),`Parent`]})}function ln({id:e}){let t=a(e),n=t.data?V(t.data):e;return(0,Z.jsxs)(`div`,{"data-slot":`parent-task`,className:`flex min-w-0 flex-wrap items-center gap-x-2 text-[13px] text-muted-foreground`,children:[(0,Z.jsxs)(B,{to:`/tasks/${e}`,"aria-label":`Parent task ${e}`,title:`Parent · ${n}`,"data-slot":`parent-task-link`,className:`flex min-h-11 min-w-0 max-w-full items-center gap-2 rounded-sm text-muted-foreground focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring active:text-foreground`,children:[(0,Z.jsx)(xe,{"aria-hidden":!0,className:`h-[1.2cap] w-auto shrink-0`}),(0,Z.jsx)(`span`,{className:`shrink-0`,children:`Parent`}),(0,Z.jsx)(`span`,{"aria-hidden":!0,children:`·`}),(0,Z.jsx)(`span`,{className:`min-w-0 overflow-clip text-ellipsis whitespace-nowrap`,children:n})]}),t.isError?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(`span`,{children:`Parent record unavailable or deleted`}),(0,Z.jsx)(M,{variant:`outline`,onClick:()=>void t.refetch(),children:`Retry parent task`})]}):null]})}var un=3,dn=(e,t)=>e.kind===t.kind&&e.number===t.number;function fn(e,t,n=un){let r=t?e.findIndex(e=>dn(e,t)):-1;if(e.length<=n||r<n)return{inline:e.slice(0,n),overflow:e.slice(n)};let i=[...e.slice(0,n-1),e[r]];return{inline:i,overflow:e.filter(e=>!i.includes(e))}}var pn=(e,t)=>`/tasks/${e}/${t.kind}/${t.number}`;function mn({tab:e}){return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(e.kind===`pr`?_e:Ce,{"aria-hidden":`true`,className:`mr-1 size-3.5 shrink-0`}),(0,Z.jsx)(`span`,{className:`sr-only`,children:e.kind===`pr`?`Pull request`:`Issue`}),` #`,e.number,(0,Z.jsx)(me,{kind:e.kind===`pr`?`PR`:`Issue`,number:e.number,className:`ml-1`})]})}function hn(e,t){let n=e[0],r=e.length+ +!!t;return n?`Preview :${n.port}${r>1?` +${r-1}`:``}`:t?`Preview · agent`:`Preview`}function gn({servers:e,icon:t=!1}){let n=mt();if(n===null)return null;let r=n.agentLive===!0,i=e[0],a=e.length+ +!!r,o=a===1?i?{port:i.port}:{agent:!0}:{};return t?(0,Z.jsxs)(M,{variant:`ghost`,size:`icon`,"data-slot":`preview-toggle`,"data-entries":a,"aria-pressed":n.open,"aria-label":hn(e,r),className:T(`relative`,a>0?`text-foreground`:`text-soft-foreground`),onClick:()=>n.openPane(o),children:[(0,Z.jsx)(ke,{"aria-hidden":`true`}),n.live?(0,Z.jsx)(H,{tone:`success`,"aria-hidden":`true`,"data-slot":`preview-live-dot`,className:`absolute top-2 right-2`}):null]}):(0,Z.jsxs)(M,{variant:`outline`,"data-slot":`preview-toggle`,"aria-pressed":n.open,onClick:()=>n.openPane(o),children:[(0,Z.jsx)(ke,{"aria-hidden":`true`}),hn(e,r),n.live?(0,Z.jsx)(H,{tone:`success`,"aria-label":`Preview is live`}):null]})}function _n({tab:e}){let t=lt();return!t?.available||e!==`session`&&e!==`changes`?null:(0,Z.jsxs)(M,{variant:`outline`,"data-slot":`split-view-toggle`,className:T(t.showing&&`border-accent-text/40 bg-muted text-accent-text`),"aria-pressed":t.showing,title:t.showing?`Show Session alone`:`Show Changes beside Session`,onClick:()=>t.setOn(!t.showing),children:[(0,Z.jsx)(Ot,{"aria-hidden":`true`}),`Split view`]})}function vn(e){return e?.role===`worker`?`Worker session`:e?.role===`root`?`Parent session`:`Task session`}function yn({run:e,compact:t=!1}){if(e.delegation?.role!==`worker`)return null;let n=e.delegation.supervisorRunId??e.delegation.parentRunId;return t?(0,Z.jsx)(cn,{id:n}):(0,Z.jsx)(ln,{id:n})}function bn({isDesktop:e,desktopActivitySlot:t,attention:n,statusLine:r,hostOffline:i}){return e&&t?(0,Z.jsx)(Z.Fragment,{children:t}):(0,Z.jsx)(`span`,{"data-slot":`run-status-slot`,className:`hidden`,children:(0,Z.jsx)(K,{dot:n.tone,shape:n.shape,pulse:n.pulse&&!i,children:Gt(r)})})}function xn(e,t,n){return e.worktreePath&&t?(0,Z.jsx)(gn,{servers:e.previewServers??[],icon:n}):null}function Sn(e,t,n){return n&&!e.archiveBlocker&&t.archive?(0,Z.jsx)(Ft,{run:e}):null}function Cn({offline:e,className:t}){return e?(0,Z.jsx)(K,{"data-slot":`host-not-live-pill`,dot:`neutral`,shape:`ring`,className:t,children:`Not live`}):null}function wn({archived:e,className:t}){return e?(0,Z.jsx)(K,{"data-slot":`run-archived-pill`,dot:U.tone,shape:U.shape,className:t,children:U.label}):null}function Tn({run:e}){return e.archived&&e.autoArchive?.reason===`pull-requests-merged`&&e.autoArchive.archivedAt===e.archivedAt?(0,Z.jsx)(`p`,{"data-slot":`auto-archive-reason`,className:`text-[13px] text-muted-foreground`,children:`Archived automatically after all associated PRs merged.`}):null}function En({run:e,statusLine:t,activityTrigger:n,hostOffline:r}){let{attention:i}=t;return(0,Z.jsx)(`span`,{"data-slot":`mobile-status-room`,className:`flex min-w-0`,children:(0,Z.jsxs)(`span`,{className:`inline-flex max-w-full min-w-0 items-center gap-1.5`,children:[n??(0,Z.jsx)(K,{"data-slot":`mobile-run-status`,dot:i.tone,shape:i.shape,pulse:i.pulse&&!r,className:`min-w-0 px-2 py-px text-xs leading-4`,children:(0,Z.jsx)(`span`,{className:`truncate`,children:t.label})}),(0,Z.jsx)(Cn,{offline:r,className:`shrink-0 px-2 py-px text-xs leading-4`}),(0,Z.jsx)(wn,{archived:e.archived,className:`shrink-0 px-2 py-px text-xs leading-4`}),(0,Z.jsx)(on,{run:e})]})})}function Dn({run:e,tab:t,activeItem:n,inlineItemTabs:r,overflowItemTabs:i,phoneBar:a,isDesktop:o}){let s=(0,X.useRef)(null),[c,l]=(0,X.useState)(!1);(0,X.useEffect)(()=>{let e=s.current;if(!e||o){l(!1);return}let t=()=>l(e.scrollWidth-e.clientWidth-e.scrollLeft>1),n=new ResizeObserver(t);n.observe(e);for(let t of e.children)n.observe(t);return e.addEventListener(`scroll`,t,{passive:!0}),t(),()=>{n.disconnect(),e.removeEventListener(`scroll`,t)}},[o,r,i,e.diffStat?.files]);let u=n?`${n.kind}#${n.number}`:null;return(0,X.useEffect)(()=>{!u||o||s.current?.querySelector(`[aria-current="page"]`)?.scrollIntoView?.({block:`nearest`,inline:`nearest`})},[u,r.map(e=>`${e.kind}#${e.number}`).join(`,`),o]),(0,Z.jsxs)(`div`,{ref:s,"data-slot":`run-tabs`,"data-phone-bar":a||void 0,"data-overflow-end":c||void 0,className:T(`flex flex-wrap items-end gap-1 border-b border-border md:mt-5 max-md:flex-nowrap max-md:overflow-x-auto max-md:border-b-0 max-md:shadow-[inset_0_-1px_0_var(--border)] max-md:gap-0 max-md:[&>*]:mb-0 max-md:[&>*]:shrink-0 max-md:[&>a]:min-h-11 max-md:[&>a]:px-2 max-md:[&>a]:text-[13.5px]`,a?`mt-0`:`mt-3`),children:[(0,Z.jsx)(Y,{to:`/tasks/${e.id}`,active:t===`session`,replace:a,children:`Session`}),(0,Z.jsx)(Y,{to:`/tasks/${e.id}/changes`,active:t===`changes`,replace:a,count:e.diffStat&&e.diffStat.files>0?e.diffStat.files:void 0,children:`Changes`}),(0,Z.jsx)(Y,{to:`/tasks/${e.id}/commits`,active:t===`commits`,replace:a,children:`Commits`}),(0,Z.jsx)(Y,{to:`/tasks/${e.id}/files`,active:t===`files`,replace:a,children:`Files`}),r.map(t=>(0,Z.jsx)(Y,{to:pn(e.id,t),active:n!==null&&dn(t,n),replace:a,children:(0,Z.jsx)(mn,{tab:t})},`${t.kind}-${t.number}`)),i.length>0?(0,Z.jsxs)(z,{children:[(0,Z.jsxs)(L,{"data-slot":`run-tabs-more`,"aria-label":`${i.length} more linked items`,className:`-mb-px flex h-8 items-center rounded-t-md border-b-2 border-transparent px-3 text-[13px] font-medium text-muted-foreground hover:bg-muted hover:text-foreground focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-link-foreground max-md:min-h-11 max-md:px-3.5 max-md:text-[13.5px]`,children:[`+`,i.length]}),(0,Z.jsx)(R,{align:`end`,children:i.map(t=>(0,Z.jsx)(P,{asChild:!0,children:(0,Z.jsx)(B,{to:pn(e.id,t),replace:a,children:(0,Z.jsx)(mn,{tab:t})})},`${t.kind}-${t.number}`))})]}):null]})}function On({run:e,tab:t=`session`,onMarkedUnread:n,desktopActivitySlot:r,mobileActivitySlot:i}){let a=se(e),o=G(e),[s,c]=(0,X.useState)(!1),[l,u]=(0,X.useState)(!1),d=kn(e,n),f=An(e),p=(0,X.useRef)(null),m=ee(),h=te(),g=Wt(e,{queuePosition:e.status===`queued`?Je(m.data??[]).get(e.id):void 0}),_=_t(),v=J(),y=_!==null&&!v?_:null,b=y!==null,{referenceProjectId:ne,repoBase:x,requests:ie}=qt(e),ae=(0,X.useMemo)(()=>le(e,x),[e,x]),S=typeof t==`object`?t:null,{inline:oe,overflow:C}=fn(ae,S),ce=rt(h.data),w=re(),E=xn(e,ce,!1),D=(0,Z.jsx)(Nn,{run:e,actions:d,triggerRef:p,onRename:b?f.editor.begin:void 0,onOpenChooser:()=>u(!0),onToggleNotes:()=>c(e=>!e)}),O=Sn(e,o,v);return(0,Z.jsx)(fe,{projectId:ne,repoBase:x,requests:ie,children:(0,Z.jsxs)(`header`,{"data-slot":`run-header`,"data-sticky":t===`session`||void 0,className:T(`relative z-20 shrink-0 bg-background px-4 md:px-9 md:pt-7`,b?`pt-0`:`pt-[18px]`,t===`session`&&`border-b border-border`),children:[(0,Z.jsx)(Tn,{run:e}),(0,Z.jsx)(Ht,{run:e}),(0,Z.jsxs)(`div`,{className:`w-full`,children:[(0,Z.jsx)(yn,{run:e}),y?(0,Z.jsxs)(ct,{slot:y,children:[(0,Z.jsx)(Mn,{run:e,title:f,returnFocus:p,status:(0,Z.jsx)(En,{run:e,statusLine:g,activityTrigger:i,hostOffline:w})}),xn(e,ce,!0),(0,Z.jsx)(yn,{run:e,compact:!0}),D]}):(0,Z.jsxs)(`div`,{"data-slot":`run-title-row`,className:`flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1 md:flex-nowrap`,children:[(0,Z.jsx)(`p`,{"data-slot":`session-kind`,className:`text-[12px] font-semibold tracking-[0.14em] text-muted-foreground uppercase md:hidden`,children:vn(e.delegation)}),(0,Z.jsx)(jn,{run:e}),(0,Z.jsx)(bn,{isDesktop:v,desktopActivitySlot:r,attention:a,statusLine:g,hostOffline:w}),(0,Z.jsx)(Cn,{offline:w,className:`max-md:hidden`}),(0,Z.jsx)(wn,{archived:e.archived,className:`max-md:hidden`}),(0,Z.jsxs)(`span`,{className:`ml-auto flex shrink-0 items-center gap-1 md:gap-2.5`,children:[O,(0,Z.jsx)(_n,{tab:t}),E,(0,Z.jsx)(rn,{run:e}),D]})]}),(0,Z.jsx)(Dn,{run:e,tab:t,activeItem:S,inlineItemTabs:oe,overflowItemTabs:C,phoneBar:b,isDesktop:v}),s?(0,Z.jsx)(In,{runId:e.id,onClose:()=>c(!1)}):null,l?(0,Z.jsx)(Qt,{run:e,canResume:G(e).terminal,onResume:()=>d.terminal.mutate(),onClose:()=>u(!1)}):null]}),(0,Z.jsx)(Fn,{run:e,actions:d})]})})}function kn(e,t){let n=ne(),i=Ge(),[a,o]=(0,X.useState)(null),s=()=>n.invalidateQueries({queryKey:l.runs.all}),u=e=>C(e.message,{tone:`danger`}),d=r(),f={isPending:d.isPending,mutate:()=>d.mutate({id:e.id,pinned:!e.pinned})},p=c();return{pin:f,markUnread:{isPending:p.isPending,mutate:()=>{t?.(),p.mutate(e.id,{onError:u})}},delete:v({mutationFn:()=>ae(e.id),onSuccess:()=>{s(),i(`/`)},onError:u}),terminal:Jt(e),confirming:a,setConfirming:o}}function An(e){let t=u(e.id),n=V(e);return{title:n,editor:it(n,e=>t.mutate({title:e},{onError:e=>C(e.message,{tone:`danger`})}))}}function jn({run:e}){let{title:t,editor:n}=An(e);return n.editing?(0,Z.jsx)(dt,{editor:n,className:`flex-1 text-[16px] font-semibold`}):(0,Z.jsxs)(`span`,{className:`group flex min-w-0 items-center gap-1`,children:[(0,Z.jsx)(`h1`,{className:`line-clamp-2 min-w-0 break-words text-2xl font-semibold tracking-tight`,title:e.task,children:t}),(0,Z.jsx)(`button`,{type:`button`,"aria-label":`Rename task`,onClick:n.begin,className:`shrink-0 rounded-sm p-1 text-soft-foreground opacity-0 transition-opacity group-hover:opacity-100 hover:bg-muted hover:text-foreground focus-visible:opacity-100 focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`,children:(0,Z.jsx)(ht,{className:`size-3.5`,"aria-hidden":`true`})})]})}function Mn({run:e,title:{title:t,editor:n},returnFocus:r,status:i}){return(0,Z.jsxs)(Re,{open:n.editing,onOpenChange:e=>{e||n.commit()},children:[(0,Z.jsx)(Ie,{asChild:!0,children:(0,Z.jsxs)(`div`,{"data-slot":`mobile-run-title`,className:`flex min-w-0 flex-1 flex-col gap-1`,children:[(0,Z.jsx)(`h1`,{className:`line-clamp-2 break-words text-[15px] leading-[18px] font-semibold text-foreground`,title:e.task,children:t}),i]})}),(0,Z.jsx)(Le,{align:`start`,sideOffset:12,className:`w-64 max-w-[calc(100vw-16px)] p-2`,onEscapeKeyDown:e=>{e.preventDefault(),n.cancel()},onCloseAutoFocus:e=>{e.preventDefault(),r.current?.focus()},children:(0,Z.jsx)(dt,{editor:n,className:`text-[16px] font-semibold`})})]})}function Nn({run:e,actions:t,triggerRef:n,onRename:r,onToggleNotes:i,onOpenChooser:a}){let o=G(e),s=St(e),c=J(),l=At(e.id),[d,f]=(0,X.useState)(!1),p=u(e.id),m=(0,X.useId)(),h=nn(e),g=(0,X.useRef)(!1);return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(Pt,{run:e,open:d,onOpenChange:f,onConfirm:()=>{l.mutate(!0),f(!1)}}),c?null:h.dialog,(0,Z.jsxs)(z,{children:[(0,Z.jsx)(L,{asChild:!0,children:(0,Z.jsx)(M,{ref:n,variant:`ghost`,size:`icon`,"aria-label":`Run actions`,children:(0,Z.jsx)(ve,{"aria-hidden":`true`})})}),(0,Z.jsxs)(R,{align:`end`,"data-slot":`run-actions-menu`,className:`w-[270px] max-w-[calc(100vw-2rem)] p-3`,onCloseAutoFocus:e=>{g.current&&(g.current=!1,e.preventDefault(),r?.())},children:[(0,Z.jsx)(N,{className:`px-2 py-3 text-[12px] font-normal text-muted-foreground`,children:`TASK ACTIONS`}),r?(0,Z.jsxs)(P,{"data-action":`rename-task`,className:`min-h-11`,onSelect:()=>{g.current=!0},children:[(0,Z.jsx)(ht,{"aria-hidden":`true`}),` Rename`]}):null,!c&&o.archive&&!e.archiveBlocker?(0,Z.jsx)(P,{disabled:l.isPending,onSelect:()=>e.archived?l.mutate(!1):f(!0),children:Mt(e)}):null,(0,Z.jsxs)(P,{onSelect:i,children:[(0,Z.jsx)(xt,{"aria-hidden":`true`}),` Notes / handoff`]}),(0,Z.jsx)(Qt,{run:e,canResume:o.terminal,onResume:()=>t.terminal.mutate(),onOpen:a}),s?(0,Z.jsxs)(P,{onSelect:()=>void Q(s,`Command copied to clipboard.`),children:[(0,Z.jsx)(A,{"aria-hidden":`true`}),` Copy resume command`]}):null,o.markUnread?(0,Z.jsxs)(P,{disabled:t.markUnread.isPending,onSelect:()=>t.markUnread.mutate(),children:[(0,Z.jsx)(Dt,{"aria-hidden":`true`}),` Mark unread`]}):null,o.pin?(0,Z.jsxs)(I,{"data-slot":`pin-run`,className:`min-h-11`,checked:!!e.pinned,disabled:t.pin.isPending,onCheckedChange:()=>t.pin.mutate(),children:[e.pinned?(0,Z.jsx)(kt,{"aria-hidden":`true`}):(0,Z.jsx)(ye,{"aria-hidden":`true`}),e.pinned?`Unpin task`:`Pin task`]}):null,c?null:(0,Z.jsx)(an,{handoff:h}),(0,Z.jsx)(F,{}),(0,Z.jsx)(N,{className:`text-xs text-muted-foreground`,children:`AFTER DONE`}),(0,Z.jsx)(I,{"data-slot":`archive-when-done`,className:`min-h-11`,checked:e.archiveWhenDone===!0,disabled:p.isPending,onCheckedChange:e=>p.mutate({archiveWhenDone:e},{onError:e=>C(e.message,{tone:`danger`})}),children:`Archive when Done`}),(0,Z.jsx)(I,{"data-slot":`auto-merge-pr`,className:`min-h-11`,checked:e.autoMergePr===!0,disabled:p.isPending,"aria-describedby":m,onCheckedChange:e=>p.mutate({autoMergePr:e},{onError:e=>C(e.message,{tone:`danger`})}),children:`Auto-merge PR`}),(0,Z.jsx)(`p`,{id:m,className:`text-xs text-muted-foreground [padding-inline:0.5rem] [padding-block:0.5rem]`,children:`After Done, auto-merge can mark a draft PR ready. It waits for current-head CI and GitHub rules. Merge comes before archive.`}),e.delegation?.role===`worker`?null:(0,Z.jsx)(Pn,{run:e,patch:p}),o.deleteRun?(0,Z.jsx)(F,{}):null,o.deleteRun?(0,Z.jsxs)(P,{variant:`destructive`,onSelect:()=>t.setConfirming(`delete`),children:[(0,Z.jsx)(Ee,{"aria-hidden":`true`}),` Delete task…`]}):null]})]})]})}function Pn({run:e,patch:t}){let n=(0,X.useId)(),r=(0,X.useId)(),i=(0,X.useId)(),a=e=>C(e.message,{tone:`danger`});return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(F,{}),(0,Z.jsx)(N,{className:`text-xs text-muted-foreground`,children:`TASK ACCESS`}),(0,Z.jsx)(I,{"data-slot":`allow-workers`,className:`min-h-11`,checked:ie(e),disabled:t.isPending,"aria-describedby":`${n} ${i}`,onCheckedChange:e=>t.mutate({allowWorkers:e},{onError:a}),children:`Allow Squawk workers`}),(0,Z.jsx)(`p`,{id:n,className:`text-xs text-muted-foreground [padding-inline:0.5rem] [padding-block-end:0.5rem]`,children:`Agents in this task can start Squawk workers. Each worker is a separate paid agent session. Worker limits cap resources, not spending.`}),(0,Z.jsx)(I,{"data-slot":`allow-messaging`,className:`min-h-11`,checked:oe(e),disabled:t.isPending,"aria-describedby":`${r} ${i}`,onCheckedChange:e=>t.mutate({allowMessaging:e},{onError:a}),children:`Allow task messaging`}),(0,Z.jsx)(`p`,{id:r,className:`text-xs text-muted-foreground [padding-inline:0.5rem] [padding-block-end:0.5rem]`,children:`Agents in this task can message other tasks in this project.`}),(0,Z.jsx)(`p`,{id:i,"data-slot":`task-access-session-note`,className:`text-xs text-muted-foreground [padding-inline:0.5rem] [padding-block-end:0.5rem]`,children:`Turning one off applies at once. Turning one on reaches a running agent at its next session.`})]})}function Fn({run:e,actions:t}){let n=t.confirming;return(0,Z.jsx)(Ze,{open:n!==null,onOpenChange:e=>!e&&t.setConfirming(null),children:(0,Z.jsxs)(gt,{"data-slot":`task-confirmation`,className:`sm:max-w-[660px]`,children:[(0,Z.jsxs)(at,{children:[(0,Z.jsx)(vt,{className:`text-danger`,children:`Delete task permanently?`}),(0,Z.jsx)(yt,{children:(0,Z.jsxs)(Z.Fragment,{children:[`Delete “`,(0,Z.jsx)(`span`,{className:`font-medium text-foreground`,title:V(e),children:V(e)}),`” and its transcript`,e.delegation?.role===`worker`&&!S(e.delegation.workspace)?``:`, worktree and branch`,`. This cannot be undone.`]})})]}),(0,Z.jsxs)(ft,{children:[(0,Z.jsx)(bt,{children:`Cancel`}),(0,Z.jsx)(st,{className:`bg-danger text-danger-foreground hover:brightness-[0.96]`,onClick:()=>{t.delete.mutate(),t.setConfirming(null)},children:`Delete task`})]})]})})}function In({runId:e,onClose:t}){let n=g(e);return(0,Z.jsxs)(`div`,{"data-slot":`notes-panel`,className:`my-5 flex max-h-[min(45dvh,420px)] flex-col overflow-hidden rounded-xl border border-border bg-card p-6`,children:[(0,Z.jsxs)(`div`,{className:`mb-4 flex shrink-0 items-center justify-between gap-3`,children:[(0,Z.jsx)(`h2`,{className:`text-lg font-medium`,children:`Notes / handoff`}),(0,Z.jsx)(M,{variant:`ghost`,size:`icon`,"aria-label":`Close notes`,onClick:t,children:(0,Z.jsx)(we,{})})]}),(0,Z.jsx)(`div`,{"data-slot":`notes-panel-body`,className:`min-h-0 flex-1 overflow-y-auto overscroll-contain`,children:n.isPending?(0,Z.jsx)(`p`,{className:`text-xs text-soft-foreground`,children:`Loading notes…`}):n.isError?(0,Z.jsx)(`p`,{className:`text-xs text-danger`,children:n.error.message}):n.data.trim().length>0?(0,Z.jsx)(Tt,{runId:e,children:(0,Z.jsx)(wt,{children:n.data})}):(0,Z.jsx)(`p`,{className:`text-xs text-soft-foreground`,children:`No notes yet — the handoff file is seeded when the task starts.`})}),(0,Z.jsxs)(`div`,{className:`mt-4 flex shrink-0 gap-3`,children:[(0,Z.jsx)(M,{variant:`outline`,disabled:!n.data?.trim(),onClick:()=>void Q(n.data??``,`Notes copied`),children:`Copy notes`}),(0,Z.jsx)(M,{variant:`outline`,onClick:t,children:`Close`})]})]})}export{Jt as a,Zt as i,$t as n,qt as o,en as r,Wt as s,On as t};