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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (103) hide show
  1. package/dist/contract/hosts.d.ts +3 -0
  2. package/dist/contract/index.js +8 -0
  3. package/dist/contract/projects.d.ts +6 -0
  4. package/dist/core/forge-registry.d.ts +8 -0
  5. package/dist/core/forge-registry.js +36 -13
  6. package/dist/core/forge-registry.js.map +1 -1
  7. package/dist/features/hosts/routes.d.ts +2 -0
  8. package/dist/features/webhooks/routes.d.ts +3 -0
  9. package/dist/server/projects-routes.d.ts +6 -0
  10. package/dist/server/runs-routes.d.ts +16 -16
  11. package/dist/server/server.d.ts +6 -0
  12. package/dist/workspace/projects.d.ts +5 -0
  13. package/dist/workspace/projects.js +8 -2
  14. package/dist/workspace/projects.js.map +1 -1
  15. package/package.json +4 -4
  16. package/web/dist/assets/accounts-section-lnMwvHTo.js +1 -0
  17. package/web/dist/assets/{activity-motion-CXlbNrMI.js → activity-motion-DBxIOskd.js} +1 -1
  18. package/web/dist/assets/{activity-route-BL-QWLNp.js → activity-route-BYf5OD8Y.js} +1 -1
  19. package/web/dist/assets/{agent-accounts-Du8CHfFX.js → agent-accounts-BzD14qLU.js} +1 -1
  20. package/web/dist/assets/{agent-config-section-BzMSlPK0.js → agent-config-section-BwmBjoad.js} +1 -1
  21. package/web/dist/assets/{agent-defaults-section-CqEVmRK0.js → agent-defaults-section-BbFvw0IO.js} +1 -1
  22. package/web/dist/assets/{appearance-vI6ae_So.js → appearance-CkohbKAs.js} +1 -1
  23. package/web/dist/assets/{archive-on-merge-field-C4hrO55O.js → archive-on-merge-field-CQ8DBqiG.js} +1 -1
  24. package/web/dist/assets/{ask-card-hEb8IHjL.js → ask-card-Bli7vYif.js} +3 -3
  25. package/web/dist/assets/automations-route-BNYFQeuu.js +2 -0
  26. package/web/dist/assets/{commit-list-Jr1_04RS.js → commit-list-CJZtpbaw.js} +1 -1
  27. package/web/dist/assets/{diff-BOF9OXhn.js → diff-DPSOaO5_.js} +2 -2
  28. package/web/dist/assets/{diff-controls-CkxtRrbB.js → diff-controls-rfNgY_Dd.js} +1 -1
  29. package/web/dist/assets/{diff-view-Chu6rn_i.js → diff-view-CswchTTd.js} +1 -1
  30. package/web/dist/assets/{discard-changes-dialog-BB47RqdX.js → discard-changes-dialog-BMT0YtWx.js} +1 -1
  31. package/web/dist/assets/{file-preview-DNM-krBZ.js → file-preview-DoaMlVS3.js} +1 -1
  32. package/web/dist/assets/{folder-browser-TNWat5kt.js → folder-browser-D_q7aPq-.js} +1 -1
  33. package/web/dist/assets/{git-toolbar-CoKBTzNV.js → git-toolbar-BCqNvkr5.js} +1 -1
  34. package/web/dist/assets/{github-t611QkCi.js → github-Bv1h-3dP.js} +1 -1
  35. package/web/dist/assets/{global-activity-route-B9DMoviv.js → global-activity-route-CrAG-ji7.js} +1 -1
  36. package/web/dist/assets/{host-context-iTMFRMT5.js → host-context-KsSKxKbI.js} +1 -1
  37. package/web/dist/assets/host-storage-BHtMSWBL.js +1 -0
  38. package/web/dist/assets/{hosts-rdWe_OBc.js → hosts-pzCm30ta.js} +1 -1
  39. package/web/dist/assets/{image-preview-C_xACQXI.js → image-preview-CvcSCCBU.js} +1 -1
  40. package/web/dist/assets/index-D9hyWO4C.js +21 -0
  41. package/web/dist/assets/index-DZXi-K2N.css +1 -0
  42. package/web/dist/assets/{label-B_s8eiYA.js → label-DEZnEIpB.js} +1 -1
  43. package/web/dist/assets/{markdown-Bmdr6MIa.js → markdown-BRE9fTUI.js} +1 -1
  44. package/web/dist/assets/{open-in-menu-DkFneOWr.js → open-in-menu-DomSOC26.js} +1 -1
  45. package/web/dist/assets/{option-select-BxTmKg8G.js → option-select-Cqnmt-CB.js} +1 -1
  46. package/web/dist/assets/{preferences-section-B_yl_o-g.js → preferences-section-CC4m45tb.js} +1 -1
  47. package/web/dist/assets/{preview-D3zYSmIA.js → preview-DFL4D2C_.js} +1 -1
  48. package/web/dist/assets/{preview-pane-connected-s9LvCVbp.js → preview-pane-connected-CvF3zJ9A.js} +2 -2
  49. package/web/dist/assets/{project-location-BczZtNyO.js → project-location-D6-Lo1vY.js} +1 -1
  50. package/web/dist/assets/{project-router-CfEuKuz1.js → project-router-CARDbdMX.js} +1 -1
  51. package/web/dist/assets/{project-scope-context-DNrHbqd2.js → project-scope-context-Bz7AAyJ4.js} +2 -2
  52. package/web/dist/assets/{projects-section-C6DnyUa2.js → projects-section-zeGtqnI3.js} +1 -1
  53. package/web/dist/assets/{prompt-templates-section-BQvKWcaX.js → prompt-templates-section--ygct2zC.js} +2 -2
  54. package/web/dist/assets/queries-D7W-eGim.js +1 -0
  55. package/web/dist/assets/{reference-chip-e-fG4-yW.js → reference-chip-D8ckcrda.js} +1 -1
  56. package/web/dist/assets/{remote-settings-notice-CUqI2DdF.js → remote-settings-notice-MxDxNXXw.js} +1 -1
  57. package/web/dist/assets/{repo-git-NG_TxE7N.js → repo-git-VfTEbVO3.js} +1 -1
  58. package/web/dist/assets/{report-reader-LYNHrAe-.js → report-reader-DLCLUfdH.js} +1 -1
  59. package/web/dist/assets/{report-selection-nUbQVjJu.js → report-selection-BcsbTczw.js} +1 -1
  60. package/web/dist/assets/{reports-DuT4m7i5.js → reports-QoDlngjL.js} +1 -1
  61. package/web/dist/assets/{resources-section-CT48TCXY.js → resources-section-CBL0htm5.js} +1 -1
  62. package/web/dist/assets/{review-notes-drafts-C7HCRebB.js → review-notes-drafts-DJDQNemf.js} +1 -1
  63. package/web/dist/assets/{review-panel-BffLSkRo.js → review-panel-BY05CuXd.js} +1 -1
  64. package/web/dist/assets/{review-strip-COa0ir6V.js → review-strip-BWhQ5CIC.js} +1 -1
  65. package/web/dist/assets/{run-detail-refresh-Db5HOGMX.js → run-detail-refresh-CecZhU-h.js} +1 -1
  66. package/web/dist/assets/{run-diff-DldSY8BJ.js → run-diff-CpwwrpXO.js} +1 -1
  67. package/web/dist/assets/run-header-CZU3e9Xk.js +2 -0
  68. package/web/dist/assets/{select-Cd8wvwvm.js → select-C72KGfnK.js} +1 -1
  69. package/web/dist/assets/{session-context-section-CW8DS0dW.js → session-context-section-D8v30mSp.js} +1 -1
  70. package/web/dist/assets/{settings-agent-picker-an3ysM1B.js → settings-agent-picker-DGhJwDIY.js} +1 -1
  71. package/web/dist/assets/{settings-save-bar-BiHFQ4c0.js → settings-save-bar-Dp-eEIEF.js} +1 -1
  72. package/web/dist/assets/{settings-shell-KZ801oLH.js → settings-shell-DZzgCmSz.js} +1 -1
  73. package/web/dist/assets/{sidebar-section-BRMO7aY4.js → sidebar-section-B94mdYUS.js} +1 -1
  74. package/web/dist/assets/{skills-DHkLoxXb.js → skills-B6jO_f1w.js} +1 -1
  75. package/web/dist/assets/{status-dot-Da1M54kK.js → status-dot-B5MkhHDP.js} +1 -1
  76. package/web/dist/assets/{tab-link-DL1UtKVR.js → tab-link-zXPa9LIz.js} +1 -1
  77. package/web/dist/assets/{task-changes-CQhwyj0L.js → task-changes-B_2BDWIf.js} +2 -2
  78. package/web/dist/assets/{task-commits-CTP8izpc.js → task-commits-kxDG4T81.js} +1 -1
  79. package/web/dist/assets/{task-file-scope-CDIfOvl-.js → task-file-scope-DVACyrij.js} +1 -1
  80. package/web/dist/assets/{task-files-CGlRH86B.js → task-files-4CxXkPOx.js} +1 -1
  81. package/web/dist/assets/{task-github-item-ChgjULzj.js → task-github-item-C8hMZej3.js} +1 -1
  82. package/web/dist/assets/task-thread-Bv_Fjceh.js +2 -0
  83. package/web/dist/assets/{thread-state-D2KJrZ1o.js → thread-state-CufNf_fC.js} +1 -1
  84. package/web/dist/assets/{use-finish-run-DifixlCM.js → use-finish-run-CjYc6ovQ.js} +1 -1
  85. package/web/dist/assets/{use-hand-to-agent-state-Bjh1EnB3.js → use-hand-to-agent-state-B_j_e1kD.js} +1 -1
  86. package/web/dist/assets/use-path-bases-BfjK7tem.js +1 -0
  87. package/web/dist/assets/use-workspace-config-save-toCmvqtz.js +1 -0
  88. package/web/dist/assets/{workflows-BDc-MpiC.js → workflows-iMfDerlK.js} +1 -1
  89. package/web/dist/assets/{workspace-tools-D7kUSb-0.js → workspace-tools-CgYFRggf.js} +1 -1
  90. package/web/dist/assets/{worktrees-section-Cv65NBgq.js → worktrees-section-CtT9bwKK.js} +4 -4
  91. package/web/dist/assets/{zoomable-image-DJ1lJEMc.js → zoomable-image-Dv85Vr4A.js} +1 -1
  92. package/web/dist/index.html +17 -17
  93. package/web/dist/live-worker.js +1 -1
  94. package/web/dist/assets/accounts-section-s6sAdUT8.js +0 -1
  95. package/web/dist/assets/automations-route-Bd6crv15.js +0 -2
  96. package/web/dist/assets/host-storage-Cr_NKfWy.js +0 -1
  97. package/web/dist/assets/index-C3kap2_j.js +0 -21
  98. package/web/dist/assets/index-CWmMYQdT.css +0 -1
  99. package/web/dist/assets/queries-DD_9iITj.js +0 -1
  100. package/web/dist/assets/run-header-DxpN6yVQ.js +0 -2
  101. package/web/dist/assets/task-thread-Cj9B2ISO.js +0 -2
  102. package/web/dist/assets/use-path-bases-AV9YYh2B.js +0 -1
  103. package/web/dist/assets/use-workspace-config-save-02qlUK8v.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{h as n,n as r,p as i}from"./host-context-iTMFRMT5.js";import{$ as a,$n as o,$t as s,A as c,Ai as l,An as u,Bi as d,Br as f,C as ee,Ci as p,Cn as m,Ct as te,D as ne,Dn as h,Dr as g,Dt as _,E as v,En as y,Et as re,F as b,Fr as x,G as S,Gi as C,Hi as ie,Hr as ae,Ht as oe,Ir as se,It as w,J as ce,Ji as le,Jt as ue,K as de,Ki as fe,Kt as pe,L as me,Li as T,Lr as E,Mn as he,Mr as ge,Mt as _e,N as ve,Nr as ye,Nt as be,O as xe,Or as Se,Ot as Ce,Pn as we,Pr as Te,Pt as Ee,Q as De,Qi as Oe,Qn as ke,Qt as Ae,Rr as je,S as Me,Si as Ne,Sn as Pe,St as Fe,Tn as Ie,Tr as Le,Ui as Re,Ur as ze,Vi as Be,Vr as Ve,Vt as He,Wi as Ue,Wr as We,Wt as Ge,X as Ke,Xn as qe,Xt as Je,Y as Ye,Yt as Xe,Zi as D,Zt as Ze,_a as Qe,_i as $e,_n as et,_t as tt,a as nt,an as rt,ar as it,b as at,bn as ot,bt as st,cn as ct,ct as lt,da as O,di as ut,ea as dt,en as ft,et as pt,fn as mt,gn as ht,gt,h as _t,hn as vt,ia as yt,in as bt,ir as xt,jn as St,k as Ct,kn as wt,kr as Tt,kt as Et,la as Dt,ln as Ot,m as kt,ma as At,mn as jt,nn as Mt,oa as Nt,on as Pt,pa as Ft,pn as It,pt as Lt,q as Rt,qi as zt,qt as Bt,r as Vt,sn as Ht,ta as Ut,tn as Wt,v as Gt,vt as Kt,wn as qt,wt as Jt,x as Yt,xn as Xt,xt as Zt,y as Qt,yn as $t,yt as en,zi as tn,zr as nn}from"./project-scope-context-DNrHbqd2.js";import{A as rn,B as k,F as A,H as j,I as M,N,P,W as F,Z as an,a as on,j as I,z as L}from"./live-protocol-CNUmr-VT.js";import{c as sn}from"./dist-CCX8mhHc.js";import{t as cn}from"./host-storage-Cr_NKfWy.js";function ln(e,t){return e??t}function un(e,t){let n=ln(e,t);return n===`1`||n===`true`}function dn(e,t,n){return e?.trim()||ln(t,n)||``}var fn=class extends dt{#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||pn(),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=Ut({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),an.batch(()=>{this.#t.forEach(t=>{t.onMutationUpdate(e)}),this.#n.notify({mutation:this,type:`updated`,action:e})})}};function pn(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:`idle`,variables:void 0,submittedAt:0}}var mn=class extends Qe{#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),Ft(this.options,t)||this.#e.getMutationCache().notify({type:`observerOptionsUpdated`,mutation:this.#n,observer:this}),t?.mutationKey&&this.options.mutationKey&&yt(t.mutationKey)!==yt(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??pn();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){an.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 hn(e,t){let n=new Set(t);return e.filter(e=>!n.has(e))}function gn(e,t,n){let r=e.slice(0);return r[t]=n,r}var _n=class extends Qe{#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,an.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||!Ft(e,n)});!o&&!s||(o&&(this.#l=t,this.#i=n),this.#t=r,this.hasListeners()&&(o&&(hn(e,n).forEach(e=>{e.destroy()}),hn(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=O(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 Oe(this.#e,r);n.push({defaultedQueryOptions:r,observer:i})}),n}#m(e,t){let n=this.#i.indexOf(e);n!==-1&&(this.#t=gn(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)&&an.batch(()=>{this.listeners.forEach(e=>{e(this.#t)})})}}},R=e(t(),1);function z({queries:e,...t},n){let r=D(n),i=le(),a=zt(),o=R.useMemo(()=>e.map(e=>{let t=r.defaultQueryOptions(e);return t._optimisticResults=i?`isRestoring`:`optimistic`,t}),[e,r,i]);o.forEach(e=>{Be(e);let t=r.getQueryCache().get(e.queryHash);Ue(e,a,t)}),fe(a);let[s]=R.useState(()=>new _n(r,o,t)),[c,l,u]=s.getOptimisticResult(o,t.combine),d=!i&&t.subscribed!==!1;R.useSyncExternalStore(R.useCallback(e=>d?s.subscribe(an.batchCalls(e)):Dt,[s,d]),()=>s.getCurrentResult(),()=>s.getCurrentResult()),R.useEffect(()=>{s.setQueries(o,t)},[o,t,s]);let f=c.some((e,t)=>Re(o[t],e))?c.flatMap((e,t)=>{let n=o[t];return n&&Re(n,e)?ie(n,new Oe(r,n),a):[]}):[];if(f.length>0)throw Promise.all(f);let ee=c.find((e,t)=>{let n=o[t];return n&&C({result:e,errorResetBoundary:a,throwOnError:n.throwOnError,query:r.getQueryCache().get(n.queryHash),suspense:n.suspense})});if(ee?.error)throw ee.error;return l(u())}function B(e,t){let n=D(t),[r]=R.useState(()=>new mn(n,e));R.useEffect(()=>{r.setOptions(e)},[r,e]);let i=R.useSyncExternalStore(R.useCallback(e=>r.subscribe(an.batchCalls(e)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),a=R.useCallback((e,t)=>{r.mutate(e,t).catch(Dt)},[r]);if(i.error&&At(r.options.throwOnError,[i.error]))throw i.error;return{...i,mutate:a,mutateAsync:i.mutate}}function V(e={}){let t=e.projectId??n(),r=e.cacheScope??(e.boot?`default`:t);return e.hostId===void 0?{projectId:t,cacheScope:r}:{projectId:t,cacheScope:r,hostId:e.hostId}}function H(e,t={}){return{...V(t),runId:e}}function vn(){return un(void 0,void 0)}function U(e){return!vn()&&e}async function yn(e){return u(await h.api.v1.health.$get({},y(e)),`/health`)}async function bn(e){return St(await h.api.v1.hosts.$get({},y(e)),`/hosts`,se)}async function xn(e){return St(await h.api.v1.hosts.projects.$get({},y(e)),`/hosts/projects`,E)}async function Sn(e){return St(await h.api.v1.hosts[`runs-index`].$get({query:e?.hostId?{hostId:e.hostId}:{}},y(e)),`/hosts/runs-index`,je)}async function Cn(e,t){return St(await h.api.v1.hosts[`runs-search`].$get({query:{q:e,...t?.limit===void 0?{}:{limit:t.limit}}},y(t)),`/hosts/runs-search`,nn)}async function wn(e){return u(await h.api.v1.workspace[`ui-state`].$get({},y(e)),`/workspace/ui-state`)}async function Tn(e,t={}){return u(await h.api.v1.workspace[`ui-state`].$put({json:e},{init:{...sn({keepalive:t.keepalive})}}),`/workspace/ui-state`)}k({runs:M(`summary`).optional()});var En=F().min(1),Dn=L().int().positive(),On=k({project:En,seq:Dn,run:We,relationships:F().min(1)}),kn=k({project:En,seq:Dn,id:F().min(1)}),An=k({generation:F().min(1),seq:L().int().nonnegative()}),jn=k({project:En,usage:j(F(),Ve)});k({runs:N(ze),referenceStatuses:ae,perProjectLimit:L(),truncated:N(F()),generation:F().min(1),eventSeq:L().int().nonnegative()});function Mn(e,t){if(e===`ping`)return{project:null,event:{type:`ping`}};let n;try{n=JSON.parse(t)}catch{return null}switch(e){case`run-summary`:{let e=On.safeParse(n);return e.success?{project:e.data.project,event:{type:`run-summary`,summary:e.data.run,seq:e.data.seq,relationships:e.data.relationships}}:null}case`run-deleted`:{let e=kn.safeParse(n);return e.success?{project:e.data.project,event:{type:`run-deleted`,id:e.data.id,seq:e.data.seq}}:null}case`usage`:{let e=jn.safeParse(n);return e.success?{project:e.data.project,event:{type:`usage`,usage:e.data.usage}}:null}case`ready`:{let e=An.safeParse(n);return e.success?{project:null,event:{type:`ready`,generation:e.data.generation,seq:e.data.seq}}:null}default:return null}}var Nn=[Se,g,Tt,Le];function Pn(e,t){let n;try{n=JSON.parse(t)}catch{return null}switch(e){case Se:{let e=ye.safeParse(n);return e.success?{type:`host-run-summary`,hostId:e.data.hostId,project:e.data.project,seq:e.data.seq,summary:e.data.run}:null}case g:{let e=ge.safeParse(n);return e.success?{type:`host-run-deleted`,hostId:e.data.hostId,project:e.data.project,seq:e.data.seq,id:e.data.id}:null}case Tt:{let e=Te.safeParse(n);return e.success?{type:`host-usage`,hostId:e.data.hostId,project:e.data.project,usage:e.data.usage}:null}case Le:{let e=x.safeParse(n);return e.success?{type:`hosts-changed`,...e.data}:null}default:return null}}function Fn(){let e,t;return{ready(n){t=void 0;let r=e!==void 0&&n>e;return e=n,r},frame(n){if(t!==void 0&&n<=t)return!1;let r=e!==void 0&&n!==e+1;return e=n,r},seed(n){t=t===void 0?n:Math.max(t,n),e=e===void 0?n:Math.max(e,n)},reset(){e=void 0,t=void 0}}}function In(e,t){if(!e)return;let n=e.findIndex(e=>e.id===t.id);if(n>=0){let r=[...e];return r[n]=t,r}let r=e.findIndex(e=>(e.createdAt??``).localeCompare(t.createdAt)<0),i=[...e];return i.splice(r<0?e.length:r,0,t),i}function Ln(e,t){if(!e)return;let n=e.filter(e=>e.id!==t);return n.length===e.length?e:n}var Rn=Object.freeze({});function zn(){let e=Rn,t=new Set;return{subscribe(e){return t.add(e),()=>t.delete(e)},get:()=>e,set(n){e=n;for(let e of t)e()}}}function Bn(e){return $e[Ne(e).bucket]<=$e.waiting}function Vn(e,t){let n;for(let r of e)!r.sessionId||r.id===t||(!n||!r.startedAt||!n.startedAt||r.startedAt>=n.startedAt)&&(n=r);return n}function Hn(e,t){return e?.backend??t?.runner??`claude`}function Un(e,t){let n;for(let r of e)r.removedBackend===void 0&&(t===void 0||r.sessionId!==t)||(!n||!r.startedAt||!n.startedAt||r.startedAt>=n.startedAt)&&(n=r);return n?.removedBackend===void 0?void 0:n}function Wn(e){let t=Vn(e.steps),n=Un(e.steps,t?.sessionId)?void 0:t;return{sessionId:n?.sessionId,backend:Hn(n,e),profileId:n?.profileId}}function Gn(e){return e.command===void 0&&e.kind!==`plugin`}function Kn(e){let t=e.workflowCursor?.mode===`resume`?e.workflowCursor.stepId:void 0;if(t&&e.steps.find(e=>e.id===t)?.status===`failed`)return t;let n=Vn(e.steps);if(n)return n.synthetic===`continuation`&&n.continuesStepId!==void 0?n.continuesStepId:e.steps.find(e=>e.sessionId===n.sessionId)?.id??n.id}function qn(e,t=!1){if(e.delegation?.role!==`worker`)return;let n=e.workflowDef?.steps;if(!n?.length)return;if(t)return n.find(Gn);let r=Kn(e);return(r?n.find(e=>e.id===r&&Gn(e)):void 0)??[...n].reverse().find(Gn)}var Jn=new Set([`queued`,`running`,`waiting`]);function Yn(e){return Jn.has(e)}function Xn(e){return l(e)?!1:e.status===`queued`||e.status===`running`||e.status===`waiting`}function Zn(e){return Xn(e)&&e.status!==`queued`}function Qn(e,t,n){return e.archived||!(e.status===`done`||e.status===`failed`||e.status===`cancelled`)||e.delegation?.role===`worker`||n!==void 0&&f(e)!==n?!1:t===`unpinned`?!e.pinned:t!==`pinned`||e.pinned===!0}var $n=[`done`,`failed`];function er(e){return e.archived||l(e)||!$n.includes(e.status)?!1:e.finishedAt!==void 0}function tr(e){let t=e.finishedAt;return t===void 0||!er(e)?!1:e.seenAt===void 0||e.seenAt<t}var nr=[`Needs you`,`Finished`,`Working`,`Archived`],rr={waiting:0,review:1,running:2,queued:4,done:5,failed:6,cancelled:7},ir=3,ar=e=>l(e)?ir:rr[e.status]??9;function or(e){let t=e=>$e[Ne(e).bucket];return[...e].sort((e,n)=>t(e)-t(n)||ar(e)-ar(n))[0]}function sr(e,t){return t===`archived`?`Archived`:p(e)?`Needs you`:e.status===`waiting`||e.status===`running`||e.status===`queued`?`Working`:`Finished`}function cr(e){let t=e.titleSummary;return t===void 0||!(e.titleOrigin===`user`||e.titleOrigin===`marker`)&&/[.!?][A-Z]/.test(t)?e.title:t}function lr(e){let t=/^(\d{1,9}): (.+)$/.exec(e),n=t?.[1],r=t?.[2];return n===void 0||r===void 0?{ref:null,rest:e}:{ref:Number(n),rest:r}}function ur(e,t){return t!==void 0&&lr(e).ref===t}var dr=(e,t)=>e<t?-1:+(e>t);function fr(e){let t=e.filter(e=>!e.archived&&e.status===`queued`).sort((e,t)=>dr(e.createdAt,t.createdAt));return new Map(t.map((e,t)=>[e.id,t+1]))}function pr(e,t,n){if(n!==`archived`){let n=Number(!!t.pinned)-Number(!!e.pinned);if(n!==0)return n}let r=ar(e)-ar(t);if(r!==0)return r;if(l(e)&&l(t)){let n=dr(e.autoResumeAt,t.autoResumeAt);if(n!==0)return n}return e.status===`queued`&&t.status===`queued`?dr(e.createdAt,t.createdAt):dr(t.createdAt,e.createdAt)}function mr(e,t){return e.filter(e=>t===`archived`?e.archived:!e.archived).sort((e,n)=>pr(e,n,t))}function W(e){return e.delegation?.role===`worker`}function hr(e,t){if(e==null)return null;let n=t.find(t=>t.id===e);return!n||!W(n)?e:n.delegation?.parentRunId??e}function gr(e,t,n=fr(e)){let r=mr(e,t).filter(e=>!W(e)),i=new Map,a=(e,t)=>{let n=i.get(e);n?n.push(t):i.set(e,[t])};for(let e of r)a(sr(e,t),{kind:`run`,run:e,queuePosition:n.get(e.id)??null});return nr.filter(e=>i.has(e)).map(e=>({label:e,rows:i.get(e)}))}function _r(e,t={}){let n=typeof t==`number`?{overall:t}:qe(t),r={"Needs you":`needsYou`,Finished:`finished`,Working:`working`},i=[],a=n.overall===void 0?10:n.overall??1/0;for(let t of e){let e=t.label===`Archived`?1/0:n[r[t.label]]??1/0,o=t.rows.filter(n=>{let r=n.run.pinned;return t.label!==`Archived`&&r?!0:a<=0||e<=0?!1:(--a,--e,!0)});o.length&&i.push({label:t.label,rows:o})}return i}function vr(e,t){if(t.length===0)return[...e];let n=new Set(e.map(e=>e.id)),r=new Set,i=t.filter(e=>n.has(e.id)||r.has(e.id)?!1:(r.add(e.id),!0));return[...e,...i]}function yr(e){let t=0,n=0,r=0;for(let i of e)if(!W(i)){if(i.archived){n+=1;continue}t+=1,p(i)&&(r+=1)}return{active:t,archived:n,waiting:r}}function br(e,t,n){return e.filter(e=>!e.archived&&(!n||f(e)===(t===`automations`)))}var xr={"Needs you":`needs-you`,Finished:`finished`,Working:`working`},Sr=Object.keys(xr),Cr=`section`;function wr(e,t,n){let r=`${Cr}=${xr[e]}`;return n?`/?origin=${t===`automations`?`automations`:`direct`}&${r}`:`/?${r}`}function Tr(e){return Sr.find(t=>xr[t]===e)??null}function Er(e,t){let n={active:0,automations:0,activeWaiting:0,automationsWaiting:0};for(let r of e){if(W(r)||r.archived)continue;let e=+!!p(r);t&&f(r)?(n.automations+=1,n.automationsWaiting+=e):(n.active+=1,n.activeWaiting+=e)}return n}var Dr=[`done`,`failed`,`cancelled`];function Or(e){return Dr.includes(e)}function kr(e){return!l(e)&&Or(e.status)&&!tr(e)}function Ar(e){return e.reduce((e,t)=>W(t)||!tr(t)?e:e+1,0)}function jr(e){return e.status===`failed`?`danger`:`success`}var Mr={needsYou:0,failedUnread:0,inMotion:0,finishedUnread:0};function Nr(e){if(e.archived||W(e))return null;if(p(e))return`needsYou`;if(Ne(e).tone===`running`)return`inMotion`;if(tr(e)){if(e.status===`failed`)return`failedUnread`;if(e.status===`done`)return`finishedUnread`}return null}function Pr(e,t){return e===t?!0:!e||!t?!1:e.needsYou===t.needsYou&&e.failedUnread===t.failedUnread&&e.inMotion===t.inMotion&&e.finishedUnread===t.finishedUnread}function Fr(e){let t={...Mr};for(let n of e){let e=Nr(n);e&&(t[e]+=1)}return t}function Ir(e){let t=new Map;for(let n of e){let e=t.get(n.projectId);e?e.push(n):t.set(n.projectId,[n])}return new Map([...t].map(([e,t])=>[e,Fr(t)]))}function Lr(e,t,n={}){if(n.unknown)return`${e} · activity unknown`;let r=Rr(t).map(e=>e.text);return[e,r.length>0?r.join(` · `):`idle`].join(` · `)}function Rr(e){let{needsYou:t,failedUnread:n,inMotion:r,finishedUnread:i}=e??Mr,a=[];return t>0&&a.push({tone:`amber`,text:`${t} needs you`}),n>0&&a.push({tone:`red`,text:`${n} failed`}),r>0&&a.push({tone:`violet`,text:`${r} working`}),i>0&&a.push({tone:`green`,text:`${i} finished`}),a}function zr(e){let t={...Mr};for(let n of e)n&&(t.needsYou+=n.needsYou,t.failedUnread+=n.failedUnread,t.inMotion+=n.inMotion,t.finishedUnread+=n.finishedUnread);return t}function Br(e){let t=e.split(/[-_ .]+/).filter(e=>e!==``);return(t.length>=2?[t[0],t[1]].map(e=>[...e][0]):[...t[0]??``].slice(0,2)).join(``).toLowerCase()}var G=new WeakMap;function Vr(){return{needsYou:0,failedUnread:0,inMotion:0,finishedUnread:0}}function Hr(e){return e.needsYou===0&&e.failedUnread===0&&e.inMotion===0&&e.finishedUnread===0}function Ur(e,t,n,r){let i=e.get(t),a=i?{...i}:Vr();a[n]=Math.max(0,a[n]+r),Hr(a)?e.delete(t):e.set(t,a)}function Wr(e){let t=new Map;for(let n of e){let e=Nr(n);if(!e)continue;let r=t.get(n.projectId);r||(r=Vr(),t.set(n.projectId,r)),r[e]+=1}return t}function Gr(e){let t=new Map;for(let n of e){let e=Nr(n);if(!e)continue;let r=t.get(n.hostId);r||(r=new Map,t.set(n.hostId,r));let i=r.get(n.projectId);i||(i=Vr(),r.set(n.projectId,i)),i[e]+=1}return t}function Kr(e,t){if(e===t)return;let n=G.get(e);n&&G.set(t,n)}function qr(e,t,n){if(e===t)return;let r=G.get(e);if(!r)return;if(n.length===0){G.set(t,r);return}let i=null,a=new Set,o=e=>{if(i||=new Map(r),!a.has(e)){let t=i.get(e),n=t?new Map(t):new Map;return i.set(e,n),a.add(e),n}return i.get(e)};for(let e of n){let t=e.previous?Nr(e.previous):null,n=e.next?Nr(e.next):null;if(t===n)continue;let r=o(e.hostId);t&&Ur(r,e.projectId,t,-1),n&&Ur(r,e.projectId,n,1)}let s=i;if(s)for(let e of a)s.get(e)?.size===0&&s.delete(e);G.set(t,s??r)}function Jr(e,t,n,r){if(e===t)return;let i=G.get(e);if(!i)return;let a=new Map(i),o=Wr(r);o.size===0?a.delete(n):a.set(n,o),G.set(t,a)}function Yr(e){let t=G.get(e.runs);t||(t=Gr(e.runs),G.set(e.runs,t));let n=new Map,r=new Set;for(let i of e.hosts){if(i.state!==`connected`||!i.loaded||i.stale)continue;r.add(i.id);let e=t.get(i.id);e&&e.size>0&&n.set(i.id,e)}return{byHost:n,knownHosts:r}}function Xr(e,t){if(e===t)return!0;if(!e||!t||e.knownHosts.size!==t.knownHosts.size||e.byHost.size!==t.byHost.size)return!1;for(let n of e.knownHosts)if(!t.knownHosts.has(n))return!1;for(let[n,r]of e.byHost){let e=t.byHost.get(n);if(!e)return!1;if(r!==e){if(r.size!==e.size)return!1;for(let[t,n]of r)if(!Pr(n,e.get(t)))return!1}}return!0}function Zr(e){return e.type===`run`?e.run.id:e.id}function Qr(e,t){return{...e,runs:t}}function $r(e,t){let n=0;for(let r of e)t(r)&&r.archived&&(n+=1);return n}var ei=new WeakMap,ti=new WeakMap;function ni(e,t){let n=new Map,r=new Map;for(let i=0;i<e.length;i+=1){let a=e[i],o=t(a),s=n.get(o);if(s||(s=new Map,n.set(o,s)),s.set(a.id,i),a.usage!==void 0){let e=r.get(o);e||(e=new Set,r.set(o,e)),e.add(a.id)}}return ei.set(e,n),ti.set(e,r),{positions:n,liveUsage:r}}var ri=class{runs;copied=!1;positions;liveUsage;liveUsageCopied=!1;scopeOf;constructor(e,t){this.runs=e,this.scopeOf=t;let n=ei.get(e),r=ti.get(e);if(n&&r)this.positions=n,this.liveUsage=r;else{let n=ni(e,t);this.positions=n.positions,this.liveUsage=n.liveUsage}}reindex(){let e=ni(this.runs,this.scopeOf);this.positions=e.positions,this.liveUsage=e.liveUsage,this.liveUsageCopied=!0}mutableLiveUsage(){if(!this.liveUsageCopied){let e=new Map;for(let[t,n]of this.liveUsage)e.set(t,new Set(n));this.liveUsage=e,this.liveUsageCopied=!0,this.copied&&ti.set(this.runs,this.liveUsage)}return this.liveUsage}at(e,t){return this.positions.get(e)?.get(t)??-1}liveUsageIds(e){return this.liveUsage.get(e)}setLiveUsage(e,t,n){let r=this.mutableLiveUsage();if(n){let n=r.get(e);n||(n=new Set,r.set(e,n)),n.add(t)}else{let n=r.get(e);if(!n)return;n.delete(t),n.size===0&&r.delete(e)}}mutable(){return this.copied||(this.runs=[...this.runs],this.copied=!0,ei.set(this.runs,this.positions),ti.set(this.runs,this.liveUsage)),this.runs}replace(e,t){let n=this.runs[e];return this.mutable()[e]=t,n?.usage!==void 0!=(t.usage!==void 0)&&this.setLiveUsage(this.scopeOf(t),t.id,t.usage!==void 0),this.runs}remove(e){return this.mutable().splice(e,1),this.reindex(),this.runs}insert(e){let t=this.runs.findIndex(t=>(t.createdAt??``).localeCompare(e.createdAt)<0);return this.mutable().splice(t<0?this.runs.length:t,0,e),this.reindex(),this.runs}},ii=e=>e.projectId,ai=(e,t)=>`${e}\u0000${t}`,oi=e=>ai(e.hostId,e.projectId);function si(e,t,n,r){return e.length===0?!1:(ei.get(e)??ni(e,oi).positions).get(ai(t,n))?.has(r)??!1}function ci(e,t,n){let r=new ri(e.runs,ii),i=e,a=!1;for(let e of t)if(e.type===`usage`)i=_i(i,e.project,e.usage,r);else{let t=pi(i,e.change,n,r);i=t.index,a||=t.reconcile}return{index:i,reconcile:a}}function li(e,t,n){let r=new ri(e.runs,oi),i=e.runs,a=new Set,o=[],s=!1;for(let c of t){if(c.type===`usage`){i=gi(i,ai(c.hostId,c.project),c.usage,r);continue}let{hostId:t,project:l}=c.change,u=e.hosts.find(e=>e.id===t);if(!u||!u.loaded){a.add(t);continue}let d=n?.(t,l);c.change.type===`run`&&d===!1&&(s=!0);let f=fi(i,c.change,{scope:ai(t,l),id:Zr(c.change),inScope:e=>e.hostId===t&&e.projectId===l,truncated:u.truncated.includes(l),perProjectLimit:u.perProjectLimit,isKnownScope:()=>!0,buildRow:e=>({hostId:t,projectId:l,...e}),onDelta:(e,n)=>o.push({hostId:t,projectId:l,previous:e,next:n})},r);i=f.runs,f.reconcile&&a.add(t)}return i!==e.runs&&(o.length===0?Kr(e.runs,i):qr(e.runs,i,o)),{index:i===e.runs?e:{...e,runs:i},reconcile:!1,reconcileHosts:[...a],refreshProjects:s}}function ui(e,t,n){return n?n.has(t):e.runs.some(e=>e.projectId===t)}function di(e,t,n,r,i,a){return n?(i.onDelta?.(n,void 0),{runs:a.remove(t),reconcile:r}):{runs:e,reconcile:!1}}function fi(e,t,n,r){let i=r.at(n.scope,n.id),a=i>=0?e[i]:void 0;if(t.type===`deleted`)return di(e,i,a,!!(n.truncated&&a?.archived),n,r);let{run:o}=t;if(o.delegation?.role===`worker`)return di(e,i,a,!1,n,r);if(!a&&!n.isKnownScope())return{runs:e,reconcile:!0};let s=O(a,n.buildRow(o));if(a){if(s===a)return{runs:e,reconcile:!1};n.onDelta?.(a,s);let t=r.replace(i,s);return{runs:t,reconcile:a.archived!==s.archived&&(n.truncated||n.perProjectLimit!==void 0&&$r(t,n.inScope)>n.perProjectLimit)}}if(n.truncated)return hi(e,s,n.inScope,r,n.onDelta);n.onDelta?.(void 0,s);let c=r.insert(s);return{runs:c,reconcile:s.archived&&n.perProjectLimit!==void 0&&$r(c,n.inScope)>n.perProjectLimit}}function pi(e,t,n,r){let{project:i}=t,a=fi(e.runs,t,{scope:i,id:Zr(t),inScope:e=>e.projectId===i,truncated:e.truncated.includes(i),perProjectLimit:e.perProjectLimit,isKnownScope:()=>ui(e,i,n),buildRow:e=>({projectId:i,...e})},r);return{index:a.runs===e.runs?e:Qr(e,a.runs),reconcile:a.reconcile}}function mi(e,t){let n;for(let r of e)t(r)&&r.archived&&(n===void 0||r.createdAt<n)&&(n=r.createdAt);return n}function hi(e,t,n,r,i){let a=mi(e,n),o=a!==void 0&&t.createdAt>a;return t.archived&&!o?{runs:e,reconcile:!1}:(i?.(void 0,t),{runs:r.insert(t),reconcile:t.archived||a===void 0||t.createdAt<a})}function gi(e,t,n,r){let i=!1;for(let[e,a]of Object.entries(n)){let n=r.at(t,e);if(n<0)continue;let o=r.runs[n],s=O(o.usage,a);s!==o.usage&&(r.replace(n,{...o,usage:s}),i=!0)}let a=r.liveUsageIds(t);if(a)for(let e of[...a]){if(Object.prototype.hasOwnProperty.call(n,e))continue;let a=r.at(t,e);if(a<0)continue;let o=r.runs[a];if(o.usage===void 0)continue;let{usage:s,...c}=o;r.replace(a,c),i=!0}return i?r.runs:e}function _i(e,t,n,r){let i=gi(e.runs,t,n,r);return i===e.runs?e:Qr(e,i)}function vi(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 yi(){return{stream:void 0,lastStream:void 0,mismatch:void 0,floor:void 0,changes:new Map}}function bi(e,t,n){if(e.lastStream===t)e.floor=n===void 0?void 0:Math.max(e.floor??n,n);else{for(let[n,r]of e.changes)r.generation!==t&&e.changes.delete(n);e.floor=n}e.stream=t,e.lastStream=t,e.mismatch=void 0}function xi(e){e.stream=void 0}function Si(e,t){return`hostId`in t?JSON.stringify([e,t.hostId,t.project,Zr(t)]):JSON.stringify([e,t.project,Zr(t)])}function Ci(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=Si(r,t),a=e.changes.get(i);return(!a||a.seq<t.seq)&&e.changes.set(i,{...t,generation:r}),!0}var wi=1e3;function Ti(e,t=wi){if(e.changes.size<=t)return;let n=[...e.changes.entries()].sort((e,t)=>e[1].seq-t[1].seq),r=n.length-t,i;for(let t=0;t<r;t+=1){let[r,a]=n[t];e.changes.delete(r),a.generation===e.lastStream&&(i=i===void 0?a.seq:Math.max(i,a.seq))}i!==void 0&&(e.floor=e.floor===void 0?i:Math.max(e.floor,i))}function Ei(e,t){for(let[n,r]of e.changes)r.project===t&&e.changes.delete(n)}function Di(e){return typeof e.generation==`string`&&typeof e.eventSeq==`number`}function Oi(e,t,n){if(e.stream!==void 0&&e.stream!==t){let n=e.mismatch!==t;return e.mismatch=t,{mismatch:!0,first:n}}let r=e.lastStream===t&&e.floor!==void 0,i=r&&n<e.floor,a=[...e.changes.entries()].filter(([,e])=>e.generation===t);return{mismatch:!1,covered:r,missed:i,own:a,newer:a.map(([,e])=>e).filter(e=>e.seq>n).sort((e,t)=>e.seq-t.seq)}}function ki(e,t,n){if(!Di(t))return{index:t,reconcile:!1};let{generation:r,eventSeq:i}=t,a=Oi(e,r,i);if(a.mismatch)return{index:t,reconcile:a.first};let o=ci(t,a.newer.map(e=>({type:`change`,change:e})),n);for(let[t,n]of a.own)n.seq<=i&&e.changes.delete(t);return a.covered&&!a.missed&&(e.floor=i),{index:o.index,reconcile:a.missed||o.reconcile}}function Ai(e,t,n){if(!Di(t))return{index:t,reconcile:!1,reconcileHosts:[]};let{generation:r,eventSeq:i}=t,a=Oi(e,r,i);if(a.mismatch)return{index:t,reconcile:a.first,reconcileHosts:[]};let o=li(t,a.newer.map(e=>({type:`change`,change:e})),n);for(let[t,n]of a.own)n.seq<=i&&e.changes.delete(t);return(a.covered&&!a.missed||e.lastStream===r&&e.floor===void 0)&&(e.floor=i),{index:o.index,reconcile:a.missed,reconcileHosts:o.reconcileHosts,refreshProjects:o.refreshProjects}}function ji(e,t,n){if(e.length===0)return t;let r=ei.get(e)??ni(e,n).positions,i=e.length===t.length,a=!1,o=[];for(let s=0;s<t.length;s+=1){let c=t[s],l=r.get(n(c))?.get(c.id),u=l===void 0?void 0:e[l],d=u===void 0?c:O(u,c);d===u&&(a=!0),i&&d!==e[s]&&(i=!1),o.push(d)}return i?e:a?o:t}function Mi(e,t){if(!e||e.generation!==t.generation)return t;let n=ji(e.runs,t.runs,ii),r=O(e.referenceStatuses,t.referenceStatuses),i=O(e.truncated,t.truncated);return n===e.runs&&r===e.referenceStatuses&&i===e.truncated&&t.perProjectLimit===e.perProjectLimit&&t.eventSeq===e.eventSeq?e:n===t.runs&&r===t.referenceStatuses&&i===t.truncated?t:{...t,runs:n,referenceStatuses:r,truncated:i}}function Ni(e,t){if(!e||e.generation!==t.generation)return t;let n=ji(e.runs,t.runs,oi),r=O(e.hosts,t.hosts);return n===e.runs&&r===e.hosts&&t.eventSeq===e.eventSeq&&t.warning===e.warning?e:n===t.runs&&r===t.hosts?t:{...t,runs:n,hosts:r}}function Pi(e,t){if(t.length===0)return e;if(e.length===0)return[...t];let n=[],r=0,i=0;for(;r<e.length&&i<t.length;)(e[r].createdAt??``)>=t[i].createdAt?n.push(e[r++]):n.push(t[i++]);for(;r<e.length;)n.push(e[r++]);for(;i<t.length;)n.push(t[i++]);return n}function Fi(e,t,n,r,i){if(t.generation!==e.generation||r.stream!==void 0&&r.stream!==t.generation)return{index:e,fullReconcile:!0,reconcileHosts:[]};let a=[...r.changes.entries()].filter(([,e])=>e.generation===t.generation&&e.hostId===n),o=li(t,a.map(([,e])=>e).filter(e=>e.seq>t.eventSeq).sort((e,t)=>e.seq-t.seq).map(e=>({type:`change`,change:e})),i);for(let[e,n]of a)n.seq<=t.eventSeq&&r.changes.delete(e);let s=o.index.hosts.find(e=>e.id===n),c=e.hosts.some(e=>e.id===n),l=s?c?e.hosts.map(e=>e.id===n?s:e):[...e.hosts,s]:e.hosts.filter(e=>e.id!==n),u=e.runs.filter(e=>e.hostId!==n),d=o.index.runs.filter(e=>e.hostId===n),f=Pi(u,d);return Jr(e.runs,f,n,d),{index:{runs:f,hosts:l,generation:e.generation,eventSeq:e.eventSeq,...t.warning===void 0?{}:{warning:t.warning}},fullReconcile:!1,reconcileHosts:o.reconcileHosts}}var Ii=[`workspace`,`runs-index`],K=[`main`,`hosts`,`runs-index`],Li=[`workspace`,`projects`],Ri=[`main`,`hosts`,`projects`],zi=6e4,Bi=100,Vi=new WeakMap,Hi=new WeakMap;function Ui(e){let t=Vi.get(e);return t||(t=ea(e),Vi.set(e,t)),t}function Wi(e){let t=Hi.get(e);return t||(t=ia(e),Hi.set(e,t)),t}function Gi(e,t){return typeof e!=`object`||!e||!Array.isArray(e.runs)?e:Ui(t).merge(e)}function Ki(e){let t=e.getQueryData(Li)?.projects;return t?new Set(t.map(e=>e.id)):void 0}function qi(e){let t=e.getQueryData(Ri)?.hosts;if(!t)return;let n=new Map;for(let e of t)e.projects!==null&&n.set(e.id,new Set(e.projects.map(e=>e.id)));return(e,t)=>n.get(e)?.has(t)}function Ji(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 Yi(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 Xi(e){return e.type===`host-run-summary`?{type:`run`,hostId:e.hostId,project:e.project,seq:e.seq,run:e.summary}:{type:`deleted`,hostId:e.hostId,project:e.project,seq:e.seq,id:e.id}}function Zi(e){let t,n,r=-1/0;return{markWrite(){r=Date.now()},cancelPending:()=>{t!==void 0&&typeof cancelAnimationFrame==`function`&&cancelAnimationFrame(t),t=void 0,clearTimeout(n),n=void 0},schedule(){if(n!==void 0)return;let i=r+250-Date.now();if(i>0){n=setTimeout(e,i);return}n=setTimeout(e,Bi),typeof requestAnimationFrame==`function`&&(t=requestAnimationFrame(e))}}}function Qi(e){let t,n,r=!1,i=()=>{clearTimeout(t),t=void 0;let a=e().catch(()=>void 0).finally(()=>{n===a&&(n=void 0,r&&(r=!1,i()))});return n=a,a};return{isInFlight(){return n!==void 0},reconcile(e={}){return n?(r=!0,n):e.hold?(t??=setTimeout(()=>{i()},400),Promise.resolve()):i()},stop(){clearTimeout(t),t=void 0,r=!1}}}function $i(e,t){let n=e.getQueryCache().find({queryKey:t,exact:!0});return n!==void 0&&n.state.data===void 0&&n.state.fetchStatus!==`idle`?e.cancelQueries({queryKey:t,exact:!0}).then(()=>e.invalidateQueries({queryKey:t})):e.invalidateQueries({queryKey:t})}function ea(e){let t=yi(),n=[],r=new Set,i=!1,a,o=!1,s=()=>e.getQueryData(Ii),c=Qi(()=>$i(e,Ii)),l=()=>{if(!i){if(i=!0,a?.()){o=!0;return}c.reconcile({hold:!0})}},u=()=>{d.cancelPending();let t=n;n=[];let i=s();if(!i||t.length===0)return;let a=Ki(e),{index:o,reconcile:l}=ci(i,t.filter(e=>e.generation===i.generation?e.type===`usage`?!r.has(e.project):!r.has(e.change.project)&&e.change.seq>i.eventSeq:!1),a);o!==i&&f(o),l&&c.reconcile({hold:!0})},d=Zi(u),f=t=>{d.markWrite(),e.setQueryData(Ii,t)};return{ready(e,n){bi(t,e,n),i=!1,o&&(o=!1,c.reconcile({hold:!0}))},detach(){xi(t)},run(e,i,a=!1){if(r.has(e))return;let o=Yi(e,i);if(!Ci(t,o,a)){l();return}n.push({type:`change`,change:o,generation:t.stream}),d.schedule()},usage(e,i){if(!r.has(e)){if(t.stream===void 0){l();return}n.push({type:`usage`,project:e,usage:i,generation:t.stream}),d.schedule()}},dropProject(e){r.add(e),Ei(t,e),n=n.filter(t=>(t.type===`change`?t.change.project:t.project)!==e);let i=s();if(!i)return;let a=vi(i,e);a!==i&&f(a)},setUnknownGenerationHandler(e){a=e},restoreProject(e){r.delete(e)},merge(n){let i=s(),a=ki(t,n,Ki(e));for(let e of r)a.index=vi(a.index,e);return a.reconcile&&queueMicrotask(()=>{c.reconcile({hold:!0})}),Ji(i,n,t.stream)??Mi(i,a.index)},reconcile:c.reconcile,flush:u,stop(){d.cancelPending(),c.stop(),n=[]}}}var ta=[1e3,2e3,4e3,8e3,15e3],na=6e4;function ra(e,t){e.setQueryData(K,e=>{if(!e)return e;let n=e.hosts.find(e=>e.id===t);return!n||n.stale?e:{...e,hosts:e.hosts.map(e=>e.id===t?{...e,stale:!0}:e)}})}function ia(e,t=e=>Sn({hostId:e}),n=ta,r=na,i=e=>Sn({signal:e})){let a=yi(),o=Fn(),s=new Map,c=new Map,l=new Map,u=0,d,f=[],ee=!1,p,m=!1,te=!1,ne=!1,h,g,_,v=!1,y=0,re=0,b=!1,x=new Map,S=()=>e.getQueryData(K),C=()=>e.getQueryCache().find({queryKey:K,exact:!0}),ie=()=>{ne||(ne=!0,e.invalidateQueries({queryKey:Ri,exact:!0}).finally(()=>{ne=!1}))},ae=e=>{let t=l.get(e);t!==void 0&&(clearTimeout(t),l.delete(e))},oe=()=>{d!==void 0&&(clearTimeout(d),d=void 0),u=0},se=()=>{for(let e of l.values())clearTimeout(e);l.clear(),c.clear(),oe()},w=Qi(()=>C()?(te=!0,$i(e,K)):Promise.resolve()),ce=()=>{if(!ee){if(ee=!0,p?.()){m=!0;return}w.reconcile({hold:!0})}},le=()=>{if((C()?.getObserversCount()??0)===0)return;let e=n[u]??r;u+=1,d!==void 0&&clearTimeout(d),d=setTimeout(()=>{d=void 0,w.reconcile()},e)},ue=e=>{if((C()?.getObserversCount()??0)===0)return;let t=c.get(e)??0,i=n[t]??r;c.set(e,t+1),ae(e),l.set(e,setTimeout(()=>{l.delete(e),E([e])},i))},de=t=>{ra(e,t),ue(t)},fe=(t,n)=>{let r=S();if(!r)return!1;if(n.generation!==r.generation||a.stream!==void 0&&a.stream!==n.generation)return w.reconcile(),!0;let i=s.get(t)??r.eventSeq;if(n.eventSeq<i)return de(t),!1;let o=Fi(r,n,t,a,qi(e));if(o.fullReconcile)return w.reconcile(),!0;let l=o.index.hosts.find(e=>e.id===t);l?(s.set(t,n.eventSeq),l.state===`connected`&&l.stale?ue(t):(ae(t),c.delete(t))):(ae(t),c.delete(t),s.delete(t));let u=Ni(r,o.index);return u!==r&&_e(u),o.reconcileHosts.length>0&&E(o.reconcileHosts,{hold:!0}),!1},pe=(t={})=>{let n=C();if(!n)return Promise.resolve();if(n.getObserversCount()===0)return e.invalidateQueries({queryKey:K,exact:!0,refetchType:`none`}),Promise.resolve();if(!S())return w.reconcile(t)},me=()=>{let t=C();return!t||t.state.fetchStatus!==`fetching`?Promise.resolve():new Promise(n=>{let r=e.getQueryCache().subscribe(e=>{e.query===t&&t.state.fetchStatus!==`fetching`&&(r(),n())})})},T=()=>{clearTimeout(h),h=void 0;let e=y;if(_||v)return(_??Promise.resolve()).then(()=>{if(!(y!==e||x.size===0))return T()});if(g)return g;let n=[...x.entries()];if(x.clear(),b=!1,n.length===0)return Promise.resolve();let r=pe();if(r)return r;let i=e=>{for(let t=e;t<n.length;t+=1){let[e,r]=n[t];x.has(e)||x.set(e,r)}},a=(async()=>{for(let r=0;r<n.length;r+=1){let[a]=n[r];if(y!==e)break;if(v){i(r);break}try{let n=await t(a);if(y!==e)break;if(fe(a,n)){i(r+1);break}}catch{if(y===e){if(v){i(r);break}de(a)}}}})().finally(()=>{g===a&&(g=void 0,!v&&!_&&y===e&&x.size>0&&(b?T():h??=setTimeout(()=>{T()},400)))});return g=a,a},E=(e,t={})=>{if(e.length===0)return Promise.resolve();let n=pe(t);if(n)return n;for(let t of e)x.set(t,++re);return t.hold||(b=!0),g||(t.hold&&!b&&!_&&!v?(h??=setTimeout(()=>{T()},400),Promise.resolve()):T())},he=()=>{ge.cancelPending();let t=f;f=[];let n=S();if(!n||t.length===0)return;let{index:r,reconcileHosts:i,refreshProjects:a}=li(n,t.filter(e=>{if(e.generation!==n.generation)return!1;if(e.type===`usage`)return!0;let t=s.get(e.change.hostId)??n.eventSeq;return e.change.seq>t}),qi(e));r!==n&&_e(r),a&&ie(),i.length>0&&E(i,{hold:!0})},ge=Zi(he),_e=t=>{ge.markWrite(),e.setQueryData(K,t)},ve=e=>{let t=new Set(e.filter(e=>e.state===`connected`&&e.stale).map(e=>e.id));for(let e of[...l.keys()])t.has(e)||(ae(e),c.delete(e));for(let e of[...c.keys()])t.has(e)||c.delete(e);for(let e of t)l.has(e)||ue(e)},ye=t=>{let n=S(),r=Ai(a,t,qi(e)),i=Ji(n,t,a.stream)??(s.clear(),ve(r.index.hosts),(a.stream===t.generation||a.lastStream===t.generation)&&o.seed(t.eventSeq),Ni(n,r.index)),c=y;return r.refreshProjects&&queueMicrotask(()=>{y===c&&ie()}),r.reconcile?queueMicrotask(()=>{y===c&&w.reconcile({hold:!0})}):r.reconcileHosts.length>0&&queueMicrotask(()=>{y===c&&E(r.reconcileHosts,{hold:!0})}),i};return{ready(e){let t=a.lastStream;bi(a,e),ee=!1;let n=S(),r=t!==void 0&&t!==e||n!==void 0&&n.generation!==e,i=t===void 0&&(n!==void 0||C()?.state.fetchStatus===`fetching`),s=te&&w.isInFlight();te=!1,r?o.reset():i&&n&&o.seed(n.eventSeq),(r||m||i)&&!s?(m=!1,w.reconcile({hold:!0})):s&&(m=!1)},detach(){xi(a),o.reset(),te=!1},run(e){let t=o.frame(e.seq),n=Xi(e);if(!Ci(a,n,t)){ce();return}Ti(a),f.push({type:`change`,change:n,generation:a.stream}),ge.schedule(),t&&w.reconcile({hold:!0})},usage(e,t,n){if(a.stream===void 0){ce();return}f.push({type:`usage`,hostId:e,project:t,usage:n,generation:a.stream}),ge.schedule()},setUnknownGenerationHandler(e){p=e},fetchFull:e=>{v=!0,clearTimeout(h),h=void 0;let t=y,n=_,r=g,a=(async()=>{if(n&&await n,r&&await r.catch(()=>void 0),y!==t||e?.aborted)throw e?.reason??new DOMException(`Aborted`,`AbortError`);let a=re,o;try{o=await i(e)}catch(n){throw y===t&&!e?.aborted&&le(),n}if(y!==t||e?.aborted)throw e?.reason??new DOMException(`Aborted`,`AbortError`);oe();for(let[e,t]of[...x.entries()])t<=a&&x.delete(e);return ye(o)})(),o;return o=a.then(()=>me(),()=>void 0).then(()=>{_===o&&(_=void 0,v=!1,y===t&&x.size>0&&T())}),_=o,a},merge:ye,reconcile:w.reconcile,reconcileHosts:E,reconcileFinite(){let t=S();if(!t)return w.reconcile();let n=e.getQueryData(Ri)?.hosts??[],r=[...new Set([...t.hosts.map(e=>e.id),...n.map(e=>e.id)])];return r.length===0?w.reconcile():E(r)},flush:he,stop(){y+=1,v=!1,_=void 0,g=void 0,ge.cancelPending(),w.stop(),clearTimeout(h),h=void 0,se(),b=!1,x.clear(),f=[]}}}var aa=(e,t,n)=>[`host`,e,t,`runs`,`detail`,n],q={get health(){return[n(),`health`]},runs:{get all(){return[n(),`runs`]},relationships:e=>[n(),`runs`,`relationships`,e],list:(e=n())=>[e,`runs`,`list`],archived:e=>[n(),`runs`,`archived`,e],detail:(e,t=n())=>[t,`runs`,`detail`,e],diff:e=>[n(),`runs`,`diff`,e],changes:e=>[n(),`runs`,`changes`,e],file:(e,t)=>[n(),`runs`,`files`,e,t],handoff:e=>[n(),`runs`,`handoff`,e],commits:e=>[n(),`runs`,`commits`,e],commit:(e,t)=>[n(),`runs`,`commit`,e,t]},get workflows(){return[n(),`workflows`]},runnerSkills:(e,t,r=n())=>[r,`runner-skills`,e,t??null],get repo(){return[n(),`repo`]},get repoChanges(){return[n(),`repo`,`changes`]},repoCommit:e=>[n(),`repo`,`commit`,e],get repoBranches(){return[n(),`repo`,`branches`]},get uiState(){return[n(),`ui-state`]},get config(){return[n(),`config`]},get agentConfig(){return[n(),`agent-config`]},agentConfigFile:e=>[n(),`agent-config`,`file`,e],get sessionContext(){return[n(),`session-context`]},sessionContextPreview:(e,t,r=``)=>[n(),`session-context`,`preview`,t,e,r],get worktrees(){return[n(),`worktrees`]},github:(e={})=>[n(),`github`,e.limit??null],githubPages:e=>[n(),`github`,`pages`,e],githubPagesHead:e=>[n(),`github`,`pages-head`,e],githubCommentCounts:(e,t)=>[n(),`github`,`comment-counts`,e,[...t].sort((e,t)=>e-t).join(`,`)],githubChecks:e=>[n(),`github`,`checks`,[...e].sort((e,t)=>e-t).join(`,`)],githubSearch:(e,t)=>[n(),`github`,`search`,e,t],githubRefStatus:(e,t,n,r)=>{let i=[e,`github`,`ref-status`,[...t].sort((e,t)=>e-t).join(`,`),[...n].sort((e,t)=>e-t).join(`,`)];return r===void 0?i:[`host`,r,...i]},githubComments:(e,t)=>[n(),`github`,`comments`,e,t],githubItem:(e,t)=>[n(),`github`,`item`,e,t],githubRefStatusOf:e=>[e,`github`,`ref-status`],githubPrChanges:e=>[n(),`github`,`pr-changes`,e],githubMergeState:e=>[n(),`github`,`merge-state`,e],get openTargets(){return[n(),`open-targets`]}},J={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:Ii,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)=>[...J.fsBrowseRoot,e,t]},oa=[`workspace`,`runs-index`],Y=e=>[e.cacheScope,`runs`,`list`],X=e=>e.hostId===void 0?[e.cacheScope,`runs`,`detail`,e.runId]:aa(e.hostId,e.projectId,e.runId),Z=e=>typeof e==`function`?e():e;function sa(e){let{seenAt:t,...n}=e;return n}function ca(e,t){let n=sa(e);return t.seenAt===void 0?n:{...n,seenAt:t.seenAt}}function la(e,t,n){return t?{...e,seenAt:n}:sa(e)}function ua(e,t,n){let r={...e},i=t;for(let e of n)Object.prototype.hasOwnProperty.call(i,e)&&i[e]!==void 0?r[e]=i[e]:delete r[e];return r}function da(e,t){let n=new Set([...Object.keys(e),...Object.keys(t)]),r=[];for(let i of n)Object.is(e[i],t[i])||r.push(i);return r}function fa(e){let t=()=>{e.invalidateQueries({queryKey:oa})};function r(r,i){if(r===`index`)return t();let a=typeof i==`function`?i():i;if(a.hostId!==void 0)return r===`indexed`?void 0:e.invalidateQueries({queryKey:[`host`,a.hostId,a.projectId,`runs`]});if(r===`indexed`){t(),e.invalidateQueries({queryKey:[n(),`runs`]}),e.invalidateQueries({queryKey:[a.projectId,`runs`,`list`]});return}if(r===`runs`)return e.invalidateQueries({queryKey:[a.cacheScope,`runs`]});let s=o(),c=[a.projectId,a.cacheScope],l=s!==void 0&&c.some(e=>e===s||e==="default")?[s,`default`]:[],u=new Set([...c,...l,n()]);return Promise.all([...u].map(t=>e.invalidateQueries({queryKey:[t,`runs`]}))).then(()=>void 0)}let i=(e,t,n)=>r=>r.id===(e?t:n.id)?la(r,e,n.seenAt):r;async function a(t,n){let r=t.runId,a=new Date().toISOString(),o=e=>e.hostId===t.hostId&&e.projectId===t.projectId&&e.id===r,s=t=>{e.setQueryData(K,e=>e===void 0?e:{...e,runs:e.runs.map(e=>o(e)?t(e):e)})},c=e.getQueryData(X(t)),l=e.getQueryData(K)?.runs.find(o);return e.setQueryData(X(t),e=>e&&la(e,n,a)),s(e=>la(e,n,a)),{id:r,prevList:void 0,prevDetail:c,rollback(){c&&e.setQueryData(X(t),e=>e&&ca(e,c)),l&&s(e=>ca(e,l))},settle(a){let o=i(n,r,a);e.setQueryData(X(t),e=>e?o(e):a),s(o)}}}async function s(n,r){let o=Z(n);if(o.hostId!==void 0)return a(o,r);await e.cancelQueries({queryKey:Y(Z(n))}),await e.cancelQueries({queryKey:X(Z(n))});let s=e.getQueryData(Y(Z(n))),c=e.getQueryData(X(Z(n))),l=Z(n).runId,u=new Date().toISOString();return e.setQueryData(Y(Z(n)),e=>e?.map(e=>e.id===l?la(e,r,u):e)),e.setQueryData(X(Z(n)),e=>e&&la(e,r,u)),{id:l,prevList:s,prevDetail:c,rollback(){if(!r){s&&e.setQueryData(Y(Z(n)),s),c&&e.setQueryData(X(Z(n)),c);return}let t=s?.find(e=>e.id===l);t&&e.setQueryData(Y(Z(n)),e=>e?.map(e=>e.id===l?ca(e,t):e)),c&&e.setQueryData(X(Z(n)),e=>e&&ca(e,c))},settle(a){let o=i(r,l,a);e.setQueryData(Y(Z(n)),e=>e?.map(o));let s={...Z(n),runId:r?l:a.id};e.setQueryData(X(s),e=>e?o(e):a),t()}}}async function c(t,n){if(t.hostId!==void 0){let r=e.getQueryData(K),i=r?.runs.find(e=>e.hostId===t.hostId&&e.projectId===t.projectId&&e.id===t.runId),a=n(),o=i?a(i):void 0,s=i&&o?da(i,o):[];return e.setQueryData(K,e=>e===void 0?e:{...e,runs:e.runs.map(e=>e.hostId===t.hostId&&e.projectId===t.projectId&&e.id===t.runId?{...a(e),hostId:e.hostId}:e)}),{previous:r,rollback(){!i||s.length===0||e.setQueryData(K,e=>e===void 0?e:{...e,runs:e.runs.map(e=>e.hostId===t.hostId&&e.projectId===t.projectId&&e.id===t.runId?ua(e,i,s):e)})},settle(){}}}await e.cancelQueries({queryKey:oa});let i=e.getQueryData(oa),a=n();return e.setQueryData(oa,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(oa,i)},settle(){r(`indexed`,t)}}}return{patchRead:s,patchIndex:c,invalidateAfter:r}}function pa(){let e=D();return(0,R.useMemo)(()=>fa(e),[e])}function ma(e,t){if(!on(e.path))throw Error(`unsupported shared read`);let n=new URL(e.path,`http://cezar.invalid`);return n.searchParams.sort(),it({kind:`read`,path:`${n.pathname}${n.search}`,intervalMs:e.intervalMs},{value:t})}function ha(e,t,n,r){let i=D(),a=JSON.stringify(t),o=(0,R.useMemo)(()=>JSON.parse(a),[a]);(0,R.useEffect)(()=>{if(!e||n===!1)return;let t=!0,a=ma({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 ga(e,t=!1){return u(await qt.api.v1.p[`:projectId`].runs[`:id`][`worker-destroy`].$post({param:{projectId:n(),id:encodeURIComponent(e)},query:{},json:t?{discardWork:!0}:{}}),wt(e,`/worker-destroy`))}function _a(){return d({queryKey:q.openTargets,queryFn:({signal:e})=>Zt({signal:e}),staleTime:5*6e4})}function va(e=!0,t){return d({queryKey:t?q.runs.list(t):q.runs.list(),queryFn:({signal:e})=>be(V(t?{projectId:t}:void 0),{signal:e}),enabled:e})}function ya(e,t){return tn({queryKey:q.runs.archived(e),enabled:t,initialPageParam:void 0,queryFn:({pageParam:t,signal:n})=>gt({before:t,limit:200,q:e},{signal:n}),getNextPageParam:e=>e.nextCursor??void 0,placeholderData:(e,t)=>t?.queryKey[0]===n()?e:void 0})}function ba(e){let t=e.trim();return d({queryKey:J.runsSearch(t),queryFn:({signal:e})=>pe(t,{signal:e}),enabled:t.length>=2,placeholderData:Nt,staleTime:1e4})}function xa(e=!0,t=zi,n){let r=Ui(D());return ha(`/api/v1/workspace/runs-index`,J.runsIndex,U(e?t:!1),Gi),d({queryKey:J.runsIndex,queryFn:({signal:e})=>Ee({signal:e}).then(r.merge),enabled:e,...n?{select:n}:{},structuralSharing:!1,staleTime:3e4,refetchInterval:!1})}function Sa(e){let t=D();return B({mutationFn:({workerId:e,discardWork:t=!1})=>ga(e,t),onSettled:()=>t.invalidateQueries({queryKey:q.runs.relationships(e)})})}function Ca(e,t={}){return d({queryKey:q.runs.relationships(e),queryFn:({signal:t})=>_e(e,{signal:t}),enabled:t.enabled??!0})}function wa(e){return d({queryKey:q.runs.detail(e??``),queryFn:({signal:t})=>Fe(H(e),{signal:t}),enabled:!!e})}function Ta(e,t,n=!0,r){let i=r?.hostId;return d({queryKey:i===void 0?[e??`default`,`runs`,`detail`,t??``]:aa(i,e??`default`,t??``),queryFn:({signal:n})=>Fe(H(t,{projectId:e,hostId:i}),{signal:n}),enabled:n&&!!e&&!!t,...r?.staleTime===void 0?{}:{staleTime:r.staleTime},...r?.refetchOnMount===void 0?{}:{refetchOnMount:r.refetchOnMount}})}function Ea(e,t){return d({queryKey:t?[t,`runs`,`diff`,e??``]:q.runs.diff(e??``),queryFn:({signal:n})=>_(e,{signal:n,...t?{projectId:t}:{}}),enabled:!!e})}function Da(e,t=!1){return ha(e?`/api/v1/p/${n()}/runs/${encodeURIComponent(e)}/changes`:void 0,q.runs.changes(e??``),U(t?4e3:!1)),d({queryKey:q.runs.changes(e??``),queryFn:({signal:t})=>te(e,{signal:t}),enabled:!!e,retry:!1,refetchInterval:!1,refetchOnWindowFocus:!0,staleTime:0})}function Oa(e,t){return d({queryKey:q.runs.file(e??``,t??``),queryFn:({signal:n})=>Ce(e,t,{signal:n}),enabled:!!e&&t!==void 0,retry:!1})}function ka(e,t){return d({queryKey:[n(),`runs`,`file-link`,e,t],queryFn:({signal:n})=>st(e,t,{signal:n}),enabled:t!==null,retry:!1})}function Aa(e,t){return d({queryKey:[n(),`runs`,`artifact`,e,t],queryFn:({signal:n})=>tt(e,t,{signal:n}),enabled:t!==null,retry:!1})}function ja(e,t){return d({queryKey:[n(),`runs`,`artifact-metadata`,e,t],queryFn:({signal:n})=>Kt(e,t,{signal:n}),enabled:t!==null,retry:!1})}function Ma(e){return d({queryKey:[n(),`runs`,`artifacts`,e],queryFn:({signal:t})=>en(e,{signal:t}),retry:!1,staleTime:0,refetchOnWindowFocus:!0})}function Na(e,t=!1){return ha(e?`/api/v1/p/${n()}/runs/${encodeURIComponent(e)}/commits`:void 0,q.runs.commits(e??``),U(t?5e3:!1)),d({queryKey:q.runs.commits(e??``),queryFn:({signal:t})=>re(e,{signal:t}),enabled:!!e,retry:!1,refetchInterval:!1})}function Pa(e,t){return d({queryKey:q.runs.commit(e??``,t??``),queryFn:({signal:n})=>Jt(e,t,{signal:n}),enabled:!!e&&!!t,retry:!1})}function Fa(e,t=!0){return d({queryKey:q.runs.handoff(e??``),queryFn:({signal:t})=>Et(H(e),{signal:t}),enabled:!!e&&t})}function Ia(e,t,n,r){return d({queryKey:r===void 0?e===void 0?q.runs.handoff(t):[e,`runs`,`handoff`,t]:[`host`,r,e??`default`,`runs`,`handoff`,t],queryFn:({signal:n})=>Et(H(t,{projectId:e,hostId:r}),{signal:n}),enabled:n,staleTime:15e3})}function La(e){return typeof e==`object`&&e?{projectId:e.projectId,hostId:e.hostId}:{projectId:e,hostId:void 0}}function Ra(e,t){let r=new Map;for(let t of e){let e=La(t);r.set(JSON.stringify([e.hostId??null,e.projectId??null]),e)}let i=[...r.values()],a=z({queries:i.map(({projectId:e,hostId:r})=>({queryKey:r===void 0?[e??n(),`automations`,`names`]:[`host`,r,e??n(),`automations`,`names`],queryFn:({signal:t})=>Gt({signal:t,archived:`include`,...e===void 0?{}:{projectId:e},...r===void 0?{}:{hostId:r}}),enabled:t,staleTime:6e4,retry:!1}))}),o=a.map(e=>e.data);return(0,R.useMemo)(()=>{let e=new Map;return o.forEach((t,n)=>{if(!t?.available)return;let r=i[n];for(let n of t.automations)e.set(JSON.stringify([r.hostId??null,r.projectId??null,n.id]),n.name)}),(t,n,r)=>e.get(JSON.stringify([r??null,t??null,n]))},[JSON.stringify([i,a.map(e=>e.dataUpdatedAt)])])}function za(e){let t=D();return B({mutationFn:t=>w(e,t),retry:!1,onSuccess:()=>t.invalidateQueries({queryKey:q.runs.all})})}function Ba(e){let t=D();return B({mutationFn:t=>He(e,t),onSuccess:()=>t.invalidateQueries({queryKey:q.runs.all})})}function Va(e){let t=pa(),n=e?.projectId,r=e?.cacheScope,i=e?.hostId,a=B({mutationFn:e=>ue(e,!0),onMutate:e=>t.patchRead(e,!0),onError:(e,t,n)=>n?.rollback(),onSuccess:(e,t,n)=>n?.settle(e)}),o=(0,R.useCallback)(e=>({...H(e,{projectId:n,cacheScope:r,hostId:i}),id:e}),[n,r,i]),s=(0,R.useCallback)(e=>({onSuccess:(t,n,r,i)=>e?.onSuccess?.(t,n.id,r,i),onError:(t,n,r,i)=>e?.onError?.(t,n.id,r,i),onSettled:(t,n,r,i,a)=>e?.onSettled?.(t,n,r.id,i,a)}),[]),{mutate:c,mutateAsync:l}=a,u=(0,R.useCallback)((e,t)=>c(o(e),s(t)),[c,o,s]),d=(0,R.useCallback)((e,t)=>l(o(e),s(t)),[l,o,s]);return{...a,variables:a.variables?.id,mutate:u,mutateAsync:d}}function Ha(e){let t=pa(),n=e?.projectId,r=e?.cacheScope,i=e?.hostId;return B({mutationFn:e=>ue(H(e,{projectId:n,cacheScope:r,hostId:i}),!1),onMutate:e=>t.patchRead(()=>H(e,{projectId:n,cacheScope:r,hostId:i}),!1),onError:(e,t,n)=>n?.rollback(),onSuccess:(e,t,n)=>n?.settle(e)})}function Ua(e){let t=pa();return B({mutationFn:({id:t,pinned:n})=>oe(H(t,e),n),onError:e=>nt(`Could not update pin. ${Ie(e)} Please retry.`,{tone:`danger`}),onMutate:()=>e??V(),onSuccess:(e,n,r)=>t.invalidateAfter(`runs`,r)})}function Wa(e,t,r){let i=pa();return B({...r===void 0?{}:{mutationKey:aa(r,t??n(),e)},mutationFn:n=>Bt(H(e,{projectId:t,hostId:r}),n),onMutate:()=>V({projectId:t,hostId:r}),onSuccess:(e,t,n)=>i.invalidateAfter(`send`,n),onError:(e,t,n)=>{e instanceof m&&e.status===409&&n&&i.invalidateAfter(`send`,n)}})}function Ga(e,t,r){let i=pa();return B({...r===void 0?{}:{mutationKey:aa(r,t??n(),e)},mutationFn:(n={})=>lt(H(e,{projectId:t,hostId:r}),n),onMutate:()=>V({projectId:t,hostId:r}),onSuccess:(e,t,n)=>i.invalidateAfter(`continue`,n)})}function Ka(e){let t=D();return B({mutationFn:({msgId:t,message:n})=>Lt(e,t,n),onSuccess:()=>t.invalidateQueries({queryKey:q.runs.all})})}function qa(e){let t=D();return B({mutationFn:t=>Ge(e,t),onSuccess:()=>t.invalidateQueries({queryKey:q.runs.all})})}function Ja(e,t=!0,n=!1,r){return d({queryKey:[V({projectId:e,boot:n}).cacheScope,`runs`,`list`],queryFn:({signal:t})=>be(V({projectId:e,boot:n}),{signal:t}),enabled:t,...r?{select:r}:{},placeholderData:(t,r)=>n&&r?.queryKey[0]===e?t:void 0})}function Ya(e,t,n=`active`){return e.invalidateQueries({queryKey:t===void 0?[`workspace`,`models`]:J.models(t),refetchType:n})}function Xa(e,t=!0,n){return d({...Za(e,n),enabled:t})}var Za=(e,t)=>({queryKey:J.models(e,t),queryFn:({signal:n})=>he(e,{signal:n},t),staleTime:300*1e3});function Qa(e,t=!0){let n=z({queries:e.map(e=>({...Za(e),enabled:t}))});return Object.fromEntries(e.map((e,t)=>[e,n[t]]))}var $a=I([`own`,`provider-spanning`]),eo=k({suggested:N(k({id:F(),label:F(),desc:F()})),retired:N(F())}),to=k({id:I([`settings`,`mcp`,`memory`]),label:F(),note:F().optional(),empty:F().optional(),showsUserMcp:M(!0).optional()}),no=k({label:F(),note:F().optional(),groups:N(to)}),ro=k({runners:N(k({id:T,displayName:F(),modelListName:F(),modelIdScope:$a,pickerLabel:F(),pickerDescription:F(),icon:F(),installHint:F(),loginCommand:F(),terminalLogin:P().optional(),browserLogin:P().optional(),managedInstall:M(!0).optional(),accountFolderExample:F().optional(),models:eo,agentConfig:no}))}),io=[`workspace`,`runners`];async function ao(e){return St(await qt.api.v1.runners.$get({},y(e)),`/runners`,ro)}var oo={queryKey:io,queryFn:({signal:e})=>ao({signal:e}),staleTime:1/0};function so(){return d(oo)}function co(e){return e?.runners??[]}function lo(e){return co(e).map(e=>e.id)}function uo(e,t){if(e!==void 0)return t.includes(e)?e:t[0]}function fo(e){let t=so();return{runner:t.isSuccess?uo(e,lo(t.data))??e:e,ready:!t.isPending}}function po(e,t){return e?.runners.find(e=>e.id===t)}function mo(e,t){return po(e,t)?.displayName??t}function ho(e,t){return po(e,t)?.pickerLabel??t}function go(e,t){return po(e,t)?.modelListName}function _o(e,t,r=!0,i){let a=Ds(i,r),o=gs(),{runner:s,ready:c}=fo(e??a.data?.defaultRunner??`claude`),l=o.data?.capabilities?.localHandoff===!1?null:t,u=i??n(),f=d({queryKey:q.runnerSkills(s,l,u),queryFn:({signal:e})=>v(s,l,{signal:e,projectId:u}),enabled:r&&c&&(e!==void 0||!a.isPending)&&(!t||!o.isPending),retry:!1});return{...f,runner:s,account:l,data:f.data?.skills,list:f.data,unchecked:f.isError||!f.data||f.data.source===`unavailable`}}var vo={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`}},yo={label:`Merge conflicts`,hint:`this branch no longer merges cleanly into its base — rebase or merge the base in`,tone:`conflict`};function bo(e){return typeof e==`string`&&Object.hasOwn(vo,e)}function xo(e){return e!==void 0&&bo(e)?vo[e]:void 0}var So=`cez.reference-statuses.v1`,Co=`cez.reference-conflicts.v1`,Q=new Map(ko()),wo=1e3,$=new Set(Ao()),To=r()??`__local__`;function Eo(){let e=r()??`__local__`;if(To!==e){To=e,clearTimeout(jo),jo=void 0,Q.clear();for(let[e,t]of ko())Q.set(e,t);$.clear();for(let e of Ao())$.add(e)}}function Do(e,t){if(Eo(),Q.get(e)!==t){for(Q.delete(e),Q.set(e,t);Q.size>wo;){let e=Q.keys().next().value;if(e===void 0)break;Q.delete(e)}Mo()}}function Oo(e,t){if(Eo(),$.has(e)!==t){if(t)for($.add(e);$.size>wo;){let e=$.values().next().value;if(e===void 0)break;$.delete(e)}else $.delete(e);Mo()}}function ko(){try{let e=globalThis.sessionStorage?.getItem(cn(So));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`&&bo(e[1])):[]}catch{return[]}}function Ao(){try{let e=globalThis.sessionStorage?.getItem(cn(Co));if(!e)return[];let t=JSON.parse(e);return Array.isArray(t)?t.filter(e=>typeof e==`string`):[]}catch{return[]}}var jo;function Mo(){if(jo!==void 0)return;let e=cn(So),t=cn(Co);jo=setTimeout(()=>{jo=void 0;try{globalThis.sessionStorage?.setItem(e,JSON.stringify([...Q])),globalThis.sessionStorage?.setItem(t,JSON.stringify([...$]))}catch{}},250)}var No=e=>e.hostId===void 0?`${e.projectId}\u0000${e.kind}#${e.number}`:`host:${e.hostId}\u0000${e.projectId}\u0000${e.kind}#${e.number}`;function Po(e,t){return{...e?{status:e}:{},...t?{conflicting:!0}:{}}}function Fo(e){let t=e.hostId===void 0?{}:{hostId:e.hostId};return[...e.prs.map(n=>({...t,projectId:e.projectId,kind:`PR`,number:n})),...e.issues.map(n=>({...t,projectId:e.projectId,kind:`Issue`,number:n}))]}function Io(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;Do(t,o),s!==void 0&&Oo(t,s),e.set(t,{state:`ready`,status:o,...s??a?{conflicting:!0}:{}})}function Lo(e,t,n){Eo();let r=No(t),i=Q.get(r),a=$.has(r)?!0:void 0,o=n.data;if(o?.available){Io(e,r,t,o,i,a);return}if(o){e.set(r,{state:`unavailable`,reason:o.reason,...Po(i,a)});return}if(n.isError){e.set(r,{state:`unavailable`,reason:n.error instanceof Error?n.error.message:void 0,...Po(i,a)});return}e.set(r,{state:`loading`,...Po(i,a)})}function Ro(e,t){let n=new Map;return t.forEach((t,r)=>{let i=e[r];if(i)for(let e of Fo(i))Lo(n,e,t)}),n}function zo(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 Bo(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 Vo(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 Ho(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 Uo(e,t){return it({kind:`topic`,topic:e},{value:t})}function Wo(){let e=D();return d({queryKey:J.providerStatus,queryFn:async({signal:t})=>{let n=e.getQueryData(J.providerStatus),r=await Ht(!1,{signal:t});return we(n,e.getQueryData(J.providerStatus),r)},staleTime:5*6e4,refetchInterval:U(!1),refetchOnWindowFocus:!0})}function Go(){let e=D();return B({mutationFn:()=>Ht(!0),onMutate:()=>e.getQueryData(J.providerStatus),onSuccess:(t,n,r)=>{e.setQueryData(J.providerStatus,e=>we(r,e,t)),Ya(e)}})}function Ko(){let e=D();return B({mutationFn:({provider:e,authFailureId:t})=>ht(e,t),onMutate:()=>e.getQueryData(J.providerStatus),onSuccess:(t,n,r)=>{e.setQueryData(J.providerStatus,e=>we(r,e,t,n.authFailureId)),Ya(e,n.provider)}})}function qo(e={}){return d({queryKey:J.projects,queryFn:({signal:e})=>Pt({signal:e}),...e})}function Jo(e,t=!1){return d({queryKey:J.fsBrowse(e,t),queryFn:({signal:n})=>Xe(e??void 0,{signal:n,showHidden:t}),retry:!1})}function Yo(){let e=D();return B({mutationFn:e=>mt(e),onSuccess:()=>e.invalidateQueries({queryKey:J.projects})})}function Xo(){let e=D();return B({mutationFn:e=>jt(e),retry:!1,onSuccess:(t,n)=>{e.setQueryData(J.projects,e=>e&&{...e,projects:e.projects.filter(e=>e.id!==n)}),e.invalidateQueries({queryKey:J.projects})}})}function Zo(){let e=D();return B({mutationFn:e=>{let{id:t,...n}=e;return Xt(t,n)},retry:!1,onMutate:async({id:t,...n})=>{await e.cancelQueries({queryKey:J.projects});let r=e.getQueryData(J.projects);return e.setQueryData(J.projects,e=>e===void 0?e:{...e,projects:e.projects.map(e=>e.id===t?Qo(e,n):e)}),{previous:r}},onError:(t,n,r)=>{r?.previous&&e.setQueryData(J.projects,r.previous)},onSuccess:({project:t})=>{e.setQueryData(J.projects,e=>e===void 0?e:{...e,projects:e.projects.map(e=>e.id===t.id?t:e)})},onSettled:()=>e.invalidateQueries({queryKey:J.projects})})}function Qo(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?[]:Ho(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 $o(e){let t=D();return B({mutationFn:e,retry:!1,onSuccess:({project:e})=>{t.setQueryData(J.projects,t=>t===void 0?t:{...t,projects:t.projects.map(t=>t.id===e.id?e:t)})},onSettled:()=>t.invalidateQueries({queryKey:J.projects})})}function es(){return $o(e=>{let{projectId:t,...n}=e;return ft(t,n)})}function ts(){return $o(e=>{let{projectId:t,webhookId:n,...r}=e;return Pe(t,n,r)})}function ns(){return $o(({projectId:e,webhookId:t})=>vt(e,t))}function rs(){return B({mutationFn:({projectId:e,webhookId:t})=>$t(e,t),retry:!1})}function is(e){let t=D();return B({mutationFn:e,retry:!1,onSuccess:async()=>{await Promise.all([t.invalidateQueries({queryKey:J.agentProfiles}),t.invalidateQueries({queryKey:J.projects}),t.invalidateQueries({predicate:({queryKey:e})=>e[1]===`runner-skills`}),Ya(t)])},onError:()=>{t.invalidateQueries({queryKey:q.health}),t.invalidateQueries({queryKey:J.agentProfiles,exact:!0})}})}function as(){return is(e=>Ae(e))}function os(){return is(e=>{let{id:t,...n}=e;return ot(t,n)})}function ss(){return is(e=>It(e))}function cs(){return is(e=>et(e))}function ls(e,t){return d({queryKey:J.agentAccountStatus(e),queryFn:({signal:t})=>Wt(e,{signal:t}),enabled:t,staleTime:6e4,retry:!1})}function us(){let e=D();return B({mutationFn:({provider:e,profileId:t})=>Ze(e,t),retry:!1,onSuccess:async(t,{provider:n})=>{await Promise.all([e.invalidateQueries({queryKey:J.agentProfiles}),e.invalidateQueries({queryKey:J.providerStatus}),Ya(e,n,`none`)])},onError:()=>{e.invalidateQueries({queryKey:q.health}),e.invalidateQueries({queryKey:J.agentProfiles,exact:!0})}})}function ds(){let e=D();return B({mutationFn:e=>Wt(e,{refresh:!0}),retry:!1,onSuccess:(t,n)=>{e.setQueryData(J.agentAccountStatus(n),t),e.invalidateQueries({queryKey:J.agentProfiles}),Ya(e,t.status.provider)}})}function fs(){let e=D();return B({mutationFn:e=>Je(e),retry:!1,onSuccess:()=>e.invalidateQueries({queryKey:J.projects})})}function ps(){let e=D();return B({mutationFn:e=>s(e),retry:!1,onSuccess:()=>e.invalidateQueries({queryKey:J.projects})})}function ms({enabled:e}){return d({queryKey:J.githubOwners,queryFn:({signal:e})=>bt({signal:e}),enabled:e,staleTime:6e4,retry:!1})}function hs(){let e=D();(0,R.useEffect)(()=>{let t,n=()=>{let n=e.getQueryData(q.health);n&&(ke({bootProject:n.bootProject===void 0?`default`:n.bootProject,apiBase:i()}),t??=Uo(`health`,t=>{e.setQueryData(q.health,t)}))};n();let r=e.getQueryCache().subscribe(n);return()=>{r(),t?.(),xt()}},[e])}function gs(){return d({queryKey:q.health,queryFn:({signal:e})=>rt({signal:e})})}function _s(e,t){let n=gs().data,r=qo(t).data?.projects,i=Vt(),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)?zo(n?.repo?.remote):void 0}function vs(e=!0){return d({queryKey:J.uiState,queryFn:({signal:e})=>Ot({signal:e}),enabled:e})}function ys(){return d({queryKey:J.config,queryFn:({signal:e})=>ct({signal:e})})}function bs(){return d({queryKey:J.agentProfiles,queryFn:({signal:e})=>Mt({signal:e})})}function xs(){return d({queryKey:q.workflows,queryFn:({signal:e})=>Ct({signal:e})})}function Ss(e){return d({queryKey:e?[e,`repo`]:q.repo,queryFn:({signal:t})=>at({signal:t},e)})}function Cs(e){return d({queryKey:[e,`repo`],queryFn:({signal:t})=>at({signal:t},e)})}function ws(){return d({queryKey:q.repoBranches,queryFn:({signal:e})=>Yt({signal:e})})}function Ts(){return d({queryKey:q.repoChanges,queryFn:({signal:e})=>Me({signal:e}),retry:!1})}function Es(e){return d({queryKey:q.repoCommit(e??``),queryFn:({signal:t})=>ee(e,{signal:t}),enabled:!!e,retry:!1})}function Ds(e,t=!0){return d({queryKey:e?[e,`config`]:q.config,queryFn:({signal:t})=>Qt({signal:t,...e?{projectId:e}:{}}),enabled:t})}function Os(){return d({queryKey:q.worktrees,queryFn:({signal:e})=>c({signal:e})})}function ks(e){return d({queryKey:[e,`worktrees`],queryFn:({signal:t})=>c({signal:t},e),staleTime:0})}function As(e,t=!0,n=!1){return d({queryKey:[V({projectId:e,boot:n}).cacheScope,`ui-state`],queryFn:({signal:t})=>xe({signal:t},e),select:e=>e.sidebarLimits===void 0?e:{...e,sidebarLimits:qe(e.sidebarLimits)},enabled:t})}function js(e=!0,t){return As(t??n(),e)}function Ms(){return d({queryKey:q.agentConfig,queryFn:({signal:e})=>kt({signal:e})})}function Ns(e){return d({queryKey:q.agentConfigFile(e??``),queryFn:({signal:t})=>_t(e,{signal:t}),enabled:e!==null})}function Ps(){return d({queryKey:q.sessionContext,queryFn:({signal:e})=>ne({signal:e})})}function Fs(e,t,n=``){return d({queryKey:q.sessionContextPreview(e,t,n),queryFn:({signal:n})=>ve({content:e,role:t},{signal:n}),placeholderData:Nt,staleTime:0,retry:!1})}function Is(){let e=D();return B({onMutate:()=>({fileKey:q.sessionContext}),mutationFn:e=>me(e),onSuccess:(t,n,r)=>{r&&e.setQueryData(r.fileKey,t)}})}function Ls(e){let t=D(),n=q.agentConfig,r=q.agentConfigFile(e);return B({mutationFn:t=>b(e,t),onSuccess:e=>{t.setQueryData(r,e),t.invalidateQueries({queryKey:n})}})}var Rs=I([`passing`,`failing`,`pending`]).nullable(),zs=k({kind:I([`issue`,`pr`]),number:L(),title:F(),author:F(),createdAt:F(),labels:N(F()),body:F().optional(),url:F(),comments:L(),assignees:N(F()).optional(),projectIds:N(F()).optional(),isDraft:P().optional(),additions:L().optional(),deletions:L().optional(),checks:Rs.optional()});A(`available`,[k({available:M(!0),item:zs.nullable(),labelColors:j(F(),F()).optional()}),k({available:M(!1),reason:F()})]),k({kind:I([`issue`,`pr`]),number:rn().int().positive().safe()});var Bs=k({id:F(),title:F(),url:F()});k({available:P(),reason:F().optional(),repo:F().optional(),syncedAt:F().optional(),issues:N(zs),prs:N(zs),labelColors:j(F(),F()).optional(),viewerLogin:F().optional(),projects:N(Bs).optional(),projectsReason:F().optional(),projectsState:I([`refreshing`,`ready`,`unavailable`]).optional(),projectsGeneration:F().optional(),issuesTotal:L().int().nonnegative().optional(),prsTotal:L().int().nonnegative().optional(),issuesNextCursor:F().nullable().optional(),prsNextCursor:F().nullable().optional(),commentsDeferred:M(!0).optional()});var Vs=F().min(1).max(2e3).optional();k({limit:F().optional(),refresh:F().optional(),issuesCursor:Vs,prsCursor:Vs,issuesDone:M(`1`).optional(),prsDone:M(`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`})}),k({kind:I([`issue`,`pr`]),numbers:F().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:M(`1`).optional()}),A(`available`,[k({available:M(!0),counts:j(L(),L().int().nonnegative())}),k({available:M(!1),reason:F()})]),A(`available`,[k({available:M(!0),checks:j(L(),Rs)}),k({available:M(!1),reason:F()})]),k({kind:I([`issue`,`pr`]),q:F().trim().min(1).max(256),limit:rn().int().positive().max(50).optional()}),k({available:P(),projectsReason:F().optional(),reason:F().optional(),items:N(zs),truncated:P().optional(),labelColors:j(F(),F()).optional()});var Hs=L().nullable();A(`available`,[k({available:M(!0),prs:j(L(),ut),issues:j(L(),ut),conflicts:N(L()).optional(),recheckAfterMs:Hs}),k({available:M(!1),reason:F(),recheckAfterMs:Hs})]);var Us=k({id:L(),author:F(),avatarUrl:F().optional(),createdAt:F(),body:F(),kind:I([`comment`,`review`]),reviewState:I([`approved`,`changes_requested`,`commented`,`dismissed`]).optional(),url:F()}),Ws=I([`committed`,`labeled`,`unlabeled`,`assigned`,`unassigned`,`merged`,`closed`,`reopened`,`head_ref_force_pushed`,`cross-referenced`,`renamed`]),Gs=k({id:F(),kind:Ws,actor:F(),avatarUrl:F().optional(),createdAt:F(),url:F().optional(),sha:F().optional(),message:F().optional(),checks:Rs.optional(),label:k({name:F(),color:F().optional()}).optional(),subject:F().optional(),refNumber:L().optional(),refTitle:F().optional(),refIsPr:P().optional()});k({available:P(),reason:F().optional(),comments:N(Us),truncated:P().optional(),events:N(Gs).optional(),detail:k({body:F(),additions:L().int().nonnegative().optional(),deletions:L().int().nonnegative().optional()}).optional()});var Ks=I([`merge`,`squash`,`rebase`]),qs=k({name:F(),state:I([`passing`,`failing`,`pending`,`unknown`]),required:P().nullable(),url:F().optional()}),Js=k({number:L(),title:F(),url:F(),state:I([`open`,`closed`,`merged`]),isDraft:P(),headRef:F(),baseRef:F(),headSha:F(),mergeable:I([`mergeable`,`conflicting`,`unknown`]),reviewDecision:I([`approved`,`changes-requested`,`review-required`,`not-required`,`unknown`]),checks:N(qs),methods:N(Ks),defaultMethod:Ks.nullable(),eligibility:I([`ready`,`blocked`,`pending`,`unauthorized`,`terminal`,`unknown`]),blockers:N(k({code:F(),message:F()})),canMerge:P(),canOverride:P()});A(`available`,[k({available:M(!0),mergeState:Js}),k({available:M(!1),reason:F()})]),k({merged:M(!0),number:L(),url:F(),method:Ks,mergeCommitSha:F().optional()});var Ys=k({path:F(),previousPath:F().optional(),status:I([`added`,`modified`,`removed`,`renamed`,`copied`,`changed`]),additions:L(),deletions:L(),patch:F().optional(),patchUnavailableReason:I([`binary`,`too-large`,`not-provided`]).optional(),truncated:P().optional()});A(`available`,[k({available:M(!0),number:L(),headSha:F(),files:N(Ys),additions:L(),deletions:L(),truncated:P(),reason:F().optional()}),k({available:M(!1),reason:F()})]),k({generation:F().uuid()}),A(`state`,[k({generation:F().uuid(),state:M(`ready`),projects:N(Bs),membership:j(F(),N(F()))}),k({generation:F().uuid(),state:M(`unavailable`),reason:F()})]);function Xs(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 Zs(e,t){return e?(t===`issues`?e.issuesNextCursor:e.prsNextCursor)==null:!1}function Qs(e,t,n){for(let r of e)t.has(r.number)||(t.add(r.number),n.push(r))}function $s(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){Qs(t.issues,a,r),Qs(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:ee,...p}=t;return{...p,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 ec=e=>e.map(e=>e.number).join(`,`);function tc(e,t){let n=e[0];if(e.length>1&&n&&(ec(n.issues)!==ec(t.issues)||ec(n.prs)!==ec(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 nc=class extends Error{};function rc(e,t,n){return{queryKey:e,initialPageParam:{},queryFn:async({pageParam:e,signal:r})=>{let i=await S({limit:t,...e,...n?{projectId:n}:{}},{signal:r});if(!i.available&&Object.keys(e).length>0)throw new nc(i.reason??`GitHub is unavailable.`);return i},getNextPageParam:e=>Xs(e),retry:(e,t)=>!(t instanceof nc)&&!(t instanceof m&&t.status>=400&&t.status<500)&&e<1,staleTime:6e4,refetchOnWindowFocus:!0}}function ic(e=50,t=!0){let r=D(),i=q.githubPages(e),a=q.githubPagesHead(e);ha(`/api/v1/p/${n()}/github?limit=${e}`,a,U(t?6e4:!1));let o=tn({...rc(i,e),enabled:t,refetchInterval:!1,refetchIntervalInBackground:!1}),s=d({queryKey:a,queryFn:({signal:t})=>S({limit:e},{signal:t}),enabled:!1,staleTime:1/0}),{refetch:c}=o;(0,R.useEffect)(()=>{if(!s.data)return;let e=r.getQueryData(i);if(!e||e.pages.length===0)return;let t=tc(e.pages,s.data);t===`refetch`?c():r.setQueryData(i,{...e,pages:t})},[r,s.dataUpdatedAt,c]);let l=(o.data?.pages??[]).flatMap(e=>e.projectsState===`refreshing`&&e.projectsGeneration?[e.projectsGeneration]:[]),u=z({queries:l.map(e=>({queryKey:[...i,`projects`,e],queryFn:({signal:t})=>De(e,{signal:t}),enabled:t,staleTime:1/0,retry:!1}))});return(0,R.useEffect)(()=>{u.forEach((e,t)=>{let n=l[t];!n||!e.data&&!e.error||r.setQueryData(i,t=>{if(!t)return t;let r=!1,i=t.pages.map(t=>{if(t.projectsGeneration!==n||t.projectsState!==`refreshing`)return t;let i=e.data;return i?.generation&&i.generation!==n?t:(r=!0,i?.state===`ready`?{...t,projectsState:`ready`,projects:i.projects,issues:t.issues.map(e=>({...e,projectIds:i.membership?.[e.number]??[]}))}:{...t,projectsState:`unavailable`,projectsReason:i?.reason??`Project boards unavailable. Refresh to try again.`})});return r?{...t,pages:i}:t})})},[r,u.map((e,t)=>e.data||e.error?l[t]:``).join(`,`)]),{pages:o,data:(0,R.useMemo)(()=>$s(o.data?.pages??[]),[o.data])}}function ac(e,t=50,n=!0){let r=tn({...rc([e,`github`,`pages`,t],t,e),enabled:n});return{pages:r,data:(0,R.useMemo)(()=>$s(r.data?.pages??[]),[r.data])}}function oc(e,t,n=!0){let r=z({queries:t.filter(e=>e.length>0).map(t=>({queryKey:q.githubCommentCounts(e,t),queryFn:({signal:n})=>Rt(e,t,{},{signal:n}),enabled:n,staleTime:6e4}))});return(0,R.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 sc(e,t,n,r=!0){return d({queryKey:[e,`github`,`search`,t,n],queryFn:({signal:r})=>pt(t,n,{projectId:e},{signal:r}),enabled:r&&n.trim()!==``,staleTime:6e4})}function cc(e,t=!0){return d({queryKey:q.githubChecks(e),queryFn:({signal:t})=>de(e,{signal:t}),enabled:t&&e.length>0,staleTime:6e4})}function lc(e,t,n=!0){return d({queryKey:q.githubSearch(e,t),queryFn:({signal:n})=>pt(e,t,{},{signal:n}),enabled:n&&t.trim()!==``,staleTime:6e4})}var uc=100;function dc(e){return[...e].sort((e,t)=>t-e).slice(0,uc).sort((e,t)=>e-t)}function fc(){let e=Vt(),t=gs();return e.projectId??t.data?.bootProject??void 0}function pc(e,t){let n=t===void 0?{}:{hostId:t};for(let[t,r]of Object.entries(e)){for(let[e,i]of Object.entries(r.prs))Do(No({...n,projectId:t,kind:`PR`,number:Number(e)}),i);for(let[e,i]of Object.entries(r.issues))Do(No({...n,projectId:t,kind:`Issue`,number:Number(e)}),i)}}var mc=5*6e4;function hc(e){return e?e.recheckAfterMs:mc}function gc(e,t=!0){let n=(0,R.useMemo)(()=>{let t=new Map;for(let n of e){let e=n.hostId===void 0?n.projectId:`host:${n.hostId}\u0000${n.projectId}`,r=t.get(e)??{...n.hostId===void 0?{}:{hostId:n.hostId},projectId:n.projectId,prs:new Set,issues:new Set};r[n.kind===`PR`?`prs`:`issues`].add(n.number),t.set(e,r)}return[...t.values()].map(e=>({...e.hostId===void 0?{}:{hostId:e.hostId},projectId:e.projectId,prs:dc(e.prs),issues:dc(e.issues)}))},[e.map(No).sort().join(`|`)]),r=z({queries:n.map(e=>({queryKey:q.githubRefStatus(e.projectId,e.prs,e.issues,e.hostId),queryFn:({signal:t})=>a(e.projectId,{prs:e.prs,issues:e.issues},{signal:t,...e.hostId===void 0?{}:{hostId:e.hostId}}),enabled:t&&e.prs.length+e.issues.length>0,staleTime:e=>hc(e.state.data)??1/0,refetchInterval:e.hostId===void 0?!1:e=>U(t&&!vn()?hc(e.state.data)??!1:!1),refetchOnWindowFocus:!0}))}),i=D(),o=JSON.stringify(n.flatMap((e,t)=>e.hostId===void 0?[{projectId:e.projectId,prs:e.prs,issues:e.issues,interval:hc(r[t]?.data)??!1}]:[]));(0,R.useEffect)(()=>{if(!t||vn())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=q.githubRefStatus(t.projectId,t.prs,t.issues);return ma({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,R.useMemo)(()=>Ro(n,r),[n,r.map(e=>`${e.dataUpdatedAt}:${e.status}`).join(`,`)]);return(0,R.useCallback)(e=>{let t=No(e),n=s.get(t);if(n)return n;let r=Q.get(t);return{state:`idle`,...r?{status:r}:{},...$.has(t)?{conflicting:!0}:{}}},[s])}function _c(e,t,n=!0){return d({queryKey:q.githubComments(e,t),queryFn:({signal:n})=>ce(e,t,{},{signal:n}),enabled:n,staleTime:6e4})}function vc(e,t,n=!0){return d({queryKey:q.githubItem(e,t),queryFn:({signal:n})=>Ye(e,t,{},{signal:n}),enabled:n,staleTime:6e4})}function yc(e){return d({queryKey:q.githubPrChanges(e??0),queryFn:({signal:t})=>Ke(e,{},{signal:t}),enabled:e!==void 0,staleTime:6e4,retry:!1})}export{rs as $,Rn as $n,Wa as $t,Os as A,or as An,Ga as At,gs as B,ar as Bn,Ta as Bt,ws as C,Sr as Cn,Xa as Ct,Fs as D,gr as Dn,ja as Dt,Ps as E,pr as En,Aa as Et,as as F,wr as Fn,Ha as Ft,ds as G,Zn as Gn,Na as Gt,_s as H,er as Hn,wa as Ht,ps as I,hr as In,za as It,ss as J,Wn as Jn,Fa as Jt,Go as K,Qn as Kn,Ea as Kt,es as L,Er as Ln,_a as Lt,bs as M,fr as Mn,Ka as Mt,fs as N,ur as Nn,ka as Nt,js as O,W as On,Ma as Ot,us as P,cr as Pn,Va as Pt,cs as Q,Bn as Qn,ba as Qt,Jo as R,br as Rn,Ba as Rt,Ss as S,Cr as Sn,Qa as St,Es as T,_r as Tn,ya as Tt,qo as U,Xn as Un,Da as Ut,hs as V,vr as Vn,qa as Vt,Wo as W,Yn as Wn,Pa as Wt,ns as X,Hn as Xn,va as Xt,Xo as Y,Vn as Yn,Ca as Yt,Ko as Z,qn as Zn,xa as Zt,Cs as _,zr as _n,B as _r,go as _t,vc as a,J as an,Pn as ar,Uo as at,Ls as b,jr as bn,dn as br,so as bt,lc as c,Ui as cn,bn as cr,zo as ct,fc as d,Xr as dn,Tn as dr,_o as dt,Ia as en,Nn as er,os as et,gc as f,Br as fn,Cn as fr,uo as ft,Ds as g,Ir as gn,H as gr,lo as gt,Ns as h,Pr as hn,V as hr,po as ht,_c as i,q as in,Fn as ir,vs as it,ls as j,Tr as jn,Sa as jt,xs as k,yr as kn,Ra as kt,ac as l,si as ln,xn as lr,yo as lt,Ms as m,Rr as mn,vn as mr,co as mt,cc as n,pa as nn,In as nr,ts as nt,ic as o,K as on,Mn as or,Bo as ot,Zs as p,Lr as pn,U as pr,mo as pt,Yo as q,tr as qn,Oa as qt,oc as r,aa as rn,zn as rr,ys as rt,yc as s,Wi as sn,yn as sr,Vo as st,pc as t,ma as tn,Ln as tr,Zo as tt,sc as u,Yr as un,wn as ur,xo as ut,As as v,kr as vn,z as vr,ho as vt,Ts as w,sr as wn,Ja as wt,Is as x,nr as xn,Ya as xt,ks as y,Ar as yn,fn as yr,fo as yt,ms as z,lr as zn,Ua as zt};
@@ -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{B as r,Ft as i,H as a,Ht as o,It as s,Jn as c,Jt as l,Lt as u,Mn as d,Pn as f,Rt as p,U as m,W as h,Xt as g,_r as _,bt as v,d as y,gr as ee,hr as b,in as x,nn as S,zt as te}from"./queries-DD_9iITj.js";import{Bt as C,Cn as ne,Mi as re,Si as ie,Zi as w,a as T,ei as ae,ft as E,ni as D,rt as oe,yr as se,zt as O}from"./project-scope-context-DNrHbqd2.js";import{C as ce,E as k,S as le,_ as ue,h as de,i as fe,n as pe,p as me,t as A,w as he,x as ge}from"./reference-chip-e-fG4-yW.js";import{o as j,s as M}from"./dist-CCX8mhHc.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 N}from"./design-icons-QbNMZniQ.js";import{t as P}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-DkFneOWr.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 F}from"./button-BV_AiLj2.js";import{a as I,i as L,l as R,n as z,p as B,r as V,t as H}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 U}from"./project-router-CfEuKuz1.js";import{t as W}from"./status-dot-Da1M54kK.js";import{t as qe}from"./format-BU7D3IfE.js";import{a as Je}from"./agent-accounts-Du8CHfFX.js";import{$t as Ye,Dn as G,Er as Xe,Fn as Ze,G as Qe,Jn as $e,K,W as et,Wn as tt,a as nt,an as rt,bn as q,dn as it,en as at,er as ot,h as st,hn as ct,i as lt,in as ut,ir as J,ln as dt,m as ft,mr as pt,nn as mt,nr as ht,on as gt,pr as _t,rn as vt,tn as yt,tr as bt,vr as xt,yn as St}from"./index-C3kap2_j.js";import{t as Ct}from"./textarea-BGp28xFr.js";import{t as wt}from"./markdown-Bmdr6MIa.js";import{t as Tt}from"./task-file-scope-CDIfOvl-.js";import{t as Y}from"./tab-link-DL1UtKVR.js";var Et=P(`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=P(`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=P(`panel-right`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M15 3v18`,key:`14nvp0`}]]),kt=P(`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=S();return _({mutationFn:t=>oe(ee(e),t),onSuccess:()=>t.invalidateAfter(`runs`,()=>b()),onError:e=>T(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)(Ye,{open:t,onOpenChange:n,children:(0,Z.jsxs)(mt,{"data-slot":`task-confirmation`,className:`sm:max-w-[660px]`,children:[(0,Z.jsxs)(rt,{children:[(0,Z.jsx)(gt,{children:`Archive task?`}),(0,Z.jsxs)(vt,{children:[`Move “`,(0,Z.jsx)(`span`,{className:`font-medium text-foreground`,title:f(e),children:f(e)}),`” out of Active tasks. You can restore it from Archived.`]})]}),(0,Z.jsxs)(ut,{children:[(0,Z.jsx)(yt,{children:`Cancel`}),(0,Z.jsx)(at,{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)(F,{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:j(`gap-[7px] px-3`,t),onClick:()=>e.archived?a.mutate(!1):i(!0),children:[e.archived?(0,Z.jsx)(Xe,{"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&&M(n)?(0,Z.jsx)(F,{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)(F,{variant:`outline`,disabled:r.isPending,onClick:()=>r.mutate({autoMergePr:!1},{onError:e=>T(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)(F,{variant:`outline`,asChild:!0,children:(0,Z.jsx)(U,{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&&M(t.pullRequestUrl)?(0,Z.jsx)(F,{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:j(`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:j(`size-4 shrink-0 text-muted-foreground`,t&&`rotate-180`)})]}),(0,Z.jsx)(`div`,{id:r,className:j(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:j(!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=p(e.id),n=bt(),r=q(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=ie(e),i=Ze(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:qe(n,t)}}async function Q(e,t){try{await navigator.clipboard.writeText(e),T(t)}catch{T(`Run manually: ${e}`)}}function qt(e){let t=a(),n=y(),r=(0,X.useMemo)(()=>k(e,t),[e,t]);return{referenceProjectId:n,repoBase:t,references:r,requests:(0,X.useMemo)(()=>n===void 0?[]:r.filter(e=>me(e,t)).map(e=>({projectId:n,kind:e.kind,number:e.number})),[r,n,t])}}function Jt(e){return _({mutationFn:()=>C(e.id),onError:e=>{if(e instanceof ne&&e.command){Q(e.command,`No terminal found — command copied to clipboard.`);return}T(e.message,{tone:`danger`})}})}function Yt(e,t){let n=u(),r=h(),i=v(),a=_({mutationFn:t=>O(e.id,t),onError:e=>T(e.message,{tone:`danger`})}),o=Je(),s=c(e),l=o.runnersOn(e=>t&&s.sessionId!==void 0&&e===s.backend?s.profileId??`default`:o.repoAccount?.[e]).runners,d=e=>!r.isSuccess||!i.isSuccess||l.includes(e??`claude`);return{canResumeHere:t&&d(ct(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,...it(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=v().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)(F,{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)(F,{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)(F,{variant:`outline`,onClick:()=>{let t=e.worktreePath;t&&navigator.clipboard.writeText(t).then(()=>T(`Worktree path copied`)).catch(()=>T(`Path: ${t}`))},children:[(0,Z.jsx)(N,{}),`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)(F,{variant:`outline`,onClick:()=>void Q(s,`Command copied to clipboard.`),children:[(0,Z.jsx)(N,{}),`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)(L,{"data-target":`terminal-resume`,onSelect:n,children:[(0,Z.jsx)(Fe,{"aria-hidden":`true`}),`Terminal (resume session)`]}):void 0}):null,s?(0,Z.jsxs)(F,{variant:`outline`,size:`sm`,onClick:()=>void Q(s,`Worktree path copied`),children:[(0,Z.jsx)(N,{"aria-hidden":`true`}),`Copy worktree path`]}):null,o?(0,Z.jsxs)(F,{variant:`outline`,size:`sm`,"data-slot":`resume-command`,title:o,onClick:()=>void Q(o,`Command copied to clipboard.`),children:[(0,Z.jsx)(N,{"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)(L,{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)(F,{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{T(`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)(N,{className:`size-3.5`,"aria-hidden":`true`}),(0,Z.jsx)(`span`,{"aria-live":`polite`,children:i?`Copied`:`Copy`})]})]})}function en({run:e}){let t=a(),n=y(),r=r=>n===void 0?void 0:le(n,e.id,r,t),i=(0,X.useMemo)(()=>k(e,t),[e,t]),o=[],s=[],c=i.filter(e=>e.kind===`PR`);for(let t of c)o.push((0,Z.jsx)(A,{reference:t,to:r(t),taskTitle:f(e),className:`h-5 no-hover:min-h-[44px] no-hover:min-w-[44px]`,conflictAction:(0,Z.jsx)(dt,{run:e,prNumber:t.number})},ue(t)));let l=he(e);l&&M(l)&&!c.some(e=>e.url===l)&&o.push((0,Z.jsx)(A,{reference:{kind:`PR`,url:l},taskTitle:f(e),className:`h-5 no-hover:min-h-[44px] no-hover:min-w-[44px]`},`pr`));let u=i.filter(e=>e.kind===`Issue`);for(let t of u)s.push((0,Z.jsx)(A,{reference:t,to:r(t),taskTitle:f(e),className:`h-5 no-hover:min-h-[44px] no-hover:min-w-[44px]`},ue(t)));let d=ge(e,t);if(d&&M(d)&&!u.some(e=>e.url===d)){let t=de(d);s.push((0,Z.jsx)(A,{reference:{kind:`Issue`,...t?{number:Number(t)}:{},url:d},to:t?r({kind:`Issue`,number:Number(t),url:d}):void 0,taskTitle:f(e),className:`h-5 no-hover:min-h-[44px] no-hover:min-w-[44px]`},`issue`))}return o.length===0&&s.length===0?null:(0,Z.jsx)(`div`,{"data-slot":`linked-references`,className:`flex min-w-0 flex-col gap-3`,children:[[`PR`,`PRs`,o],[`Issue`,`Issues`,s]].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=m();return et(t.data?.projects?.find(n=>n.id===(e??t.data?.bootProject)))}var $=e=>e.map(e=>`${e.name}: ${Qe(e.url)}`).join(`
2
- `);function nn(e){let t=$e(),n=tn(),r=n.length>0,i=s(e.id),[a,o]=(0,X.useState)(null),c=e.notify===!0,l=()=>i.mutate({notify:!1},{onSuccess:()=>T(`Stopped notifying the webhook`),onError:e=>T(`Could not stop notifying. ${e.message}`,{tone:`danger`})}),u=r?(0,Z.jsx)(sn,{mode:a,targets:n,pending:i.isPending,onOpenChange:e=>!e&&o(null),onSubmit:e=>i.mutate({notify:!0,...e?{message:e}:{}},{onSuccess:()=>{o(null),T(a===`note`?`Note sent to the webhook`:`Handed off to the webhook`)},onError:e=>T(`Could not hand off. ${e.message}`,{tone:`danger`})})}):null;return{visible:t!==`absent`&&(r||c),notifying:c,reachable:r,targets:n,pending:i.isPending,open:o,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)(H,{children:[(0,Z.jsx)(B,{asChild:!0,children:(0,Z.jsxs)(F,{variant:`outline`,"data-slot":`notifying-chip`,className:`gap-1.5`,"aria-label":r?`Notifying ${K(i)} — webhook actions`:`Notifying — webhook actions`,title:r?$(i):void 0,children:[(0,Z.jsx)(W,{tone:`success`}),(0,Z.jsx)(`span`,{children:`Notifying`}),(0,Z.jsx)(Oe,{"aria-hidden":`true`,className:`size-3.5`})]})}),(0,Z.jsxs)(V,{align:`end`,"data-slot":`notifying-menu`,className:`w-[240px] max-w-[calc(100vw-2rem)] p-2`,children:[r?(0,Z.jsx)(I,{"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:Qe(e.url),children:e.name},e.id))}):null,r?(0,Z.jsxs)(L,{className:`min-h-11`,onSelect:()=>t.open(`note`),children:[(0,Z.jsx)(Pe,{"aria-hidden":`true`}),` Send a note…`]}):null,(0,Z.jsxs)(L,{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)(F,{variant:`outline`,"data-action":`handoff`,className:`max-md:px-0`,"aria-label":`Hand off to webhook`,onClick:()=>t.open(`handoff`),children:[(0,Z.jsx)(_t,{"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)(R,{}),(0,Z.jsx)(I,{"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 · ${K(r)}`:`Webhook`}),t?(0,Z.jsxs)(Z.Fragment,{children:[n?(0,Z.jsx)(L,{"data-action":`handoff-note`,className:`min-h-11`,onSelect:()=>e.open(`note`),children:`Send a note…`}):null,(0,Z.jsx)(L,{"data-action":`handoff-stop`,variant:`destructive`,className:`min-h-11`,disabled:e.pending,onSelect:e.stop,children:`Stop notifying`})]}):(0,Z.jsx)(L,{"data-action":`handoff`,className:`min-h-11`,onSelect:()=>e.open(`handoff`),children:`Hand off to webhook…`})]})}function on({run:e}){let t=$e(),n=tn();return e.notify!==!0||t===`absent`?null:(0,Z.jsx)(J,{"data-slot":`notifying-status`,role:`img`,"aria-label":n.length>0?`Notifying ${K(n)}`:`Notifying`,title:n.length>0?$(n):void 0,className:`shrink-0 px-2 py-px leading-4`,children:(0,Z.jsx)(_t,{"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=K(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)(F,{type:`button`,variant:`ghost`,onClick:()=>r(!1),children:`Cancel`}),(0,Z.jsxs)(F,{type:`submit`,variant:`contrast`,"data-action":`handoff-submit`,disabled:n||l&&s.trim()===``,children:[(0,Z.jsx)(_t,{"aria-hidden":`true`}),l?`Send note`:`Hand off`]})]})]})})})}function cn({id:e}){return(0,Z.jsxs)(U,{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=o(e),n=t.data?f(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)(U,{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)(F,{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)(pe,{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=ft();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)(F,{variant:`ghost`,size:`icon`,"data-slot":`preview-toggle`,"data-entries":a,"aria-pressed":n.open,"aria-label":hn(e,r),className:j(`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)(W,{tone:`success`,"aria-hidden":`true`,"data-slot":`preview-live-dot`,className:`absolute top-2 right-2`}):null]}):(0,Z.jsxs)(F,{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)(W,{tone:`success`,"aria-label":`Preview is live`}):null]})}function _n({tab:e}){let t=st();return!t?.available||e!==`session`&&e!==`changes`?null:(0,Z.jsxs)(F,{variant:`outline`,"data-slot":`split-view-toggle`,className:j(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)(J,{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)(J,{"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)(J,{"data-slot":`run-archived-pill`,dot:G.tone,shape:G.shape,className:t,children:G.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)(J,{"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:j(`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)(H,{children:[(0,Z.jsxs)(B,{"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)(V,{align:`end`,children:i.map(t=>(0,Z.jsx)(L,{asChild:!0,children:(0,Z.jsx)(U,{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:i,mobileActivitySlot:a}){let o=ie(e),s=q(e),[c,l]=(0,X.useState)(!1),[u,f]=(0,X.useState)(!1),p=kn(e,n),m=An(e),h=(0,X.useRef)(null),_=g(),v=r(),y=Wt(e,{queuePosition:e.status===`queued`?d(_.data??[]).get(e.id):void 0}),ee=ht(),b=bt(),x=ee!==null&&!b?ee:null,S=x!==null,{referenceProjectId:te,repoBase:C,requests:ne}=qt(e),re=(0,X.useMemo)(()=>ce(e,C),[e,C]),w=typeof t==`object`?t:null,{inline:T,overflow:ae}=fn(re,w),E=tt(v.data),D=se(),oe=xn(e,E,!1),O=(0,Z.jsx)(Nn,{run:e,actions:p,triggerRef:h,onRename:S?m.editor.begin:void 0,onOpenChooser:()=>f(!0),onToggleNotes:()=>l(e=>!e)}),k=Sn(e,s,b);return(0,Z.jsx)(fe,{projectId:te,repoBase:C,requests:ne,children:(0,Z.jsxs)(`header`,{"data-slot":`run-header`,"data-sticky":t===`session`||void 0,className:j(`relative z-20 shrink-0 bg-background px-4 md:px-9 md:pt-7`,S?`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}),x?(0,Z.jsxs)(ot,{slot:x,children:[(0,Z.jsx)(Mn,{run:e,title:m,returnFocus:h,status:(0,Z.jsx)(En,{run:e,statusLine:y,activityTrigger:a,hostOffline:D})}),xn(e,E,!0),(0,Z.jsx)(yn,{run:e,compact:!0}),O]}):(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:b,desktopActivitySlot:i,attention:o,statusLine:y,hostOffline:D}),(0,Z.jsx)(Cn,{offline:D,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:[k,(0,Z.jsx)(_n,{tab:t}),oe,(0,Z.jsx)(rn,{run:e}),O]})]}),(0,Z.jsx)(Dn,{run:e,tab:t,activeItem:w,inlineItemTabs:T,overflowItemTabs:ae,phoneBar:S,isDesktop:b}),c?(0,Z.jsx)(In,{runId:e.id,onClose:()=>l(!1)}):null,u?(0,Z.jsx)(Qt,{run:e,canResume:q(e).terminal,onResume:()=>p.terminal.mutate(),onClose:()=>f(!1)}):null]}),(0,Z.jsx)(Fn,{run:e,actions:p})]})})}function kn(e,t){let n=w(),r=Ge(),[a,o]=(0,X.useState)(null),s=()=>n.invalidateQueries({queryKey:x.runs.all}),c=e=>T(e.message,{tone:`danger`}),l=te(),u={isPending:l.isPending,mutate:()=>l.mutate({id:e.id,pinned:!e.pinned})},d=i();return{pin:u,markUnread:{isPending:d.isPending,mutate:()=>{t?.(),d.mutate(e.id,{onError:c})}},delete:_({mutationFn:()=>E(e.id),onSuccess:()=>{s(),r(`/`)},onError:c}),terminal:Jt(e),confirming:a,setConfirming:o}}function An(e){let t=p(e.id),n=f(e);return{title:n,editor:nt(n,e=>t.mutate({title:e},{onError:e=>T(e.message,{tone:`danger`})}))}}function jn({run:e}){let{title:t,editor:n}=An(e);return n.editing?(0,Z.jsx)(lt,{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)(pt,{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)(lt,{editor:n,className:`text-[16px] font-semibold`})})]})}function Nn({run:e,actions:t,triggerRef:n,onRename:r,onToggleNotes:i,onOpenChooser:a}){let o=q(e),s=St(e),c=bt(),l=At(e.id),[u,d]=(0,X.useState)(!1),f=p(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:u,onOpenChange:d,onConfirm:()=>{l.mutate(!0),d(!1)}}),c?null:h.dialog,(0,Z.jsxs)(H,{children:[(0,Z.jsx)(B,{asChild:!0,children:(0,Z.jsx)(F,{ref:n,variant:`ghost`,size:`icon`,"aria-label":`Run actions`,children:(0,Z.jsx)(ve,{"aria-hidden":`true`})})}),(0,Z.jsxs)(V,{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)(I,{className:`px-2 py-3 text-[12px] font-normal text-muted-foreground`,children:`TASK ACTIONS`}),r?(0,Z.jsxs)(L,{"data-action":`rename-task`,className:`min-h-11`,onSelect:()=>{g.current=!0},children:[(0,Z.jsx)(pt,{"aria-hidden":`true`}),` Rename`]}):null,!c&&o.archive&&!e.archiveBlocker?(0,Z.jsx)(L,{disabled:l.isPending,onSelect:()=>e.archived?l.mutate(!1):d(!0),children:Mt(e)}):null,(0,Z.jsxs)(L,{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)(L,{onSelect:()=>void Q(s,`Command copied to clipboard.`),children:[(0,Z.jsx)(N,{"aria-hidden":`true`}),` Copy resume command`]}):null,o.markUnread?(0,Z.jsxs)(L,{disabled:t.markUnread.isPending,onSelect:()=>t.markUnread.mutate(),children:[(0,Z.jsx)(Dt,{"aria-hidden":`true`}),` Mark unread`]}):null,o.pin?(0,Z.jsxs)(z,{"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)(R,{}),(0,Z.jsx)(I,{className:`text-xs text-muted-foreground`,children:`AFTER DONE`}),(0,Z.jsx)(z,{"data-slot":`archive-when-done`,className:`min-h-11`,checked:e.archiveWhenDone===!0,disabled:f.isPending,onCheckedChange:e=>f.mutate({archiveWhenDone:e},{onError:e=>T(e.message,{tone:`danger`})}),children:`Archive when Done`}),(0,Z.jsx)(z,{"data-slot":`auto-merge-pr`,className:`min-h-11`,checked:e.autoMergePr===!0,disabled:f.isPending,"aria-describedby":m,onCheckedChange:e=>f.mutate({autoMergePr:e},{onError:e=>T(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:f}),o.deleteRun?(0,Z.jsx)(R,{}):null,o.deleteRun?(0,Z.jsxs)(L,{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=>T(e.message,{tone:`danger`});return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(R,{}),(0,Z.jsx)(I,{className:`text-xs text-muted-foreground`,children:`TASK ACCESS`}),(0,Z.jsx)(z,{"data-slot":`allow-workers`,className:`min-h-11`,checked:D(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)(z,{"data-slot":`allow-messaging`,className:`min-h-11`,checked:ae(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)(Ye,{open:n!==null,onOpenChange:e=>!e&&t.setConfirming(null),children:(0,Z.jsxs)(mt,{"data-slot":`task-confirmation`,className:`sm:max-w-[660px]`,children:[(0,Z.jsxs)(rt,{children:[(0,Z.jsx)(gt,{className:`text-danger`,children:`Delete task permanently?`}),(0,Z.jsx)(vt,{children:(0,Z.jsxs)(Z.Fragment,{children:[`Delete “`,(0,Z.jsx)(`span`,{className:`font-medium text-foreground`,title:f(e),children:f(e)}),`” and its transcript`,e.delegation?.role===`worker`&&!re(e.delegation.workspace)?``:`, worktree and branch`,`. This cannot be undone.`]})})]}),(0,Z.jsxs)(ut,{children:[(0,Z.jsx)(yt,{children:`Cancel`}),(0,Z.jsx)(at,{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=l(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)(F,{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)(F,{variant:`outline`,disabled:!n.data?.trim(),onClick:()=>void Q(n.data??``,`Notes copied`),children:`Copy notes`}),(0,Z.jsx)(F,{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};