@hearsay-tools/squawk 0.19.0-dev.8980 → 0.19.0-dev.8984

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 (108) hide show
  1. package/dist/ci-wait/controller.d.ts +7 -7
  2. package/dist/contract/index.js +13 -1
  3. package/dist/contract/repo.d.ts +19 -0
  4. package/dist/core/forge-registry.d.ts +9 -0
  5. package/dist/core/forge-registry.js.map +1 -1
  6. package/dist/delegation/transport.d.ts +65 -65
  7. package/dist/features/automations/tools.d.ts +8 -8
  8. package/dist/features/github/github-branch-forge.d.ts +14 -2
  9. package/dist/features/github/github-branch-forge.js +68 -2
  10. package/dist/features/github/github-branch-forge.js.map +1 -1
  11. package/dist/features/github/github-forge.js +1 -0
  12. package/dist/features/github/github-forge.js.map +1 -1
  13. package/dist/server/activity-routes.d.ts +23 -23
  14. package/dist/server/repo-branch-forge.d.ts +10 -2
  15. package/dist/server/repo-branch-forge.js +25 -2
  16. package/dist/server/repo-branch-forge.js.map +1 -1
  17. package/dist/server/repo-branch-git.d.ts +6 -0
  18. package/dist/server/repo-branch-git.js +35 -0
  19. package/dist/server/repo-branch-git.js.map +1 -0
  20. package/dist/server/repo-branches.js +66 -47
  21. package/dist/server/repo-branches.js.map +1 -1
  22. package/dist/server/repo-routes.d.ts +2 -0
  23. package/dist/server/runs-routes.d.ts +719 -719
  24. package/dist/server/server.d.ts +44 -40
  25. package/package.json +4 -4
  26. package/web/dist/assets/{accounts-section-D4JcHFyu.js → accounts-section-C0MLZW_M.js} +1 -1
  27. package/web/dist/assets/{activity-motion-CkFrDHAS.js → activity-motion-DGWsLSV_.js} +1 -1
  28. package/web/dist/assets/{activity-route-9l7HbN61.js → activity-route-DbRrSGTZ.js} +1 -1
  29. package/web/dist/assets/{agent-config-section-D0yOFooo.js → agent-config-section-S-NNHyTj.js} +2 -2
  30. package/web/dist/assets/agent-defaults-section-D47ydO6M.js +1 -0
  31. package/web/dist/assets/{appearance-CPSQmzD9.js → appearance-BVzMVCDZ.js} +1 -1
  32. package/web/dist/assets/{archive-on-merge-field-BJM7BDf3.js → archive-on-merge-field-C7bZaOku.js} +1 -1
  33. package/web/dist/assets/attention-vW5nmGoK.js +1 -0
  34. package/web/dist/assets/{automations-route-C1IpJvWC.js → automations-route-DGTAb8A_.js} +2 -2
  35. package/web/dist/assets/{commit-list-BBJ7Igij.js → commit-list-Bt4Z1k-3.js} +1 -1
  36. package/web/dist/assets/{diff-C1JIcjiI.js → diff-Chs69ao_.js} +2 -2
  37. package/web/dist/assets/{diff-controls-eMh8T2wX.js → diff-controls-M-rIqFWN.js} +1 -1
  38. package/web/dist/assets/{diff-view-CSYxKGKP.js → diff-view-bLKcANO6.js} +1 -1
  39. package/web/dist/assets/discard-changes-dialog-CZ-BAjRM.js +1 -0
  40. package/web/dist/assets/file-preview-QXwZnRnZ.js +2 -0
  41. package/web/dist/assets/{folder-browser-BgGSB2gk.js → folder-browser-DcR_vo2i.js} +1 -1
  42. package/web/dist/assets/{git-toolbar-BY1yZKBF.js → git-toolbar-xBysCptA.js} +1 -1
  43. package/web/dist/assets/github-Dq8Qn_Dk.js +1 -0
  44. package/web/dist/assets/{global-activity-route-DP_yBJsq.js → global-activity-route-D7OxyX_e.js} +2 -2
  45. package/web/dist/assets/{index-BXyNYltk.css → index-CzyjmihQ.css} +1 -1
  46. package/web/dist/assets/index-DDtQlxLH.js +21 -0
  47. package/web/dist/assets/{label-CxJpzeLL.js → label-CqoNP6Yh.js} +1 -1
  48. package/web/dist/assets/{markdown-pTQo8h1T.js → markdown-B4GFEGdE.js} +1 -1
  49. package/web/dist/assets/{open-in-menu-CmsJeSrD.js → open-in-menu-CsH3KL0z.js} +1 -1
  50. package/web/dist/assets/{option-select-CZ0au33L.js → option-select-BOeViuCv.js} +1 -1
  51. package/web/dist/assets/{preferences-section-DCwUztp1.js → preferences-section-DqsNZiXr.js} +1 -1
  52. package/web/dist/assets/preview-pane-connected-lQ_w4jh_.js +3 -0
  53. package/web/dist/assets/{project-location-DgXLFHie.js → project-location-DeNUqsgL.js} +1 -1
  54. package/web/dist/assets/{project-router-BNcdL2CI.js → project-router-DvfVUjon.js} +1 -1
  55. package/web/dist/assets/{projects-section-4zkjhDuP.js → projects-section-Bne5q9Zl.js} +1 -1
  56. package/web/dist/assets/{prompt-templates-section-BfWXmMv2.js → prompt-templates-section-wEXQFITb.js} +2 -2
  57. package/web/dist/assets/{queries-BSxNcgZm.js → queries-B8INH8MM.js} +1 -1
  58. package/web/dist/assets/{reference-chip-DFwi97Ps.js → reference-chip-DDv209Ry.js} +1 -1
  59. package/web/dist/assets/{remote-settings-notice-v8nM4EFt.js → remote-settings-notice-ZPTZta4J.js} +1 -1
  60. package/web/dist/assets/repo-git-DFbTe7cL.css +1 -0
  61. package/web/dist/assets/repo-git-orRzt9hM.js +1 -0
  62. package/web/dist/assets/{report-reader-br4qr_cf.js → report-reader-7LXPgypR.js} +1 -1
  63. package/web/dist/assets/{report-selection-CaEdb2HO.js → report-selection-fGMhVMQi.js} +1 -1
  64. package/web/dist/assets/{reports-BmW0MxQS.js → reports-BLzMjV0A.js} +1 -1
  65. package/web/dist/assets/{resources-section-4Nbu6SX9.js → resources-section-Bg0CLNs0.js} +1 -1
  66. package/web/dist/assets/{review-panel-BScCegzK.js → review-panel-Bmxlc-qL.js} +5 -5
  67. package/web/dist/assets/{run-detail-refresh-GbAx5_Mn.js → run-detail-refresh-CMG0OiqX.js} +1 -1
  68. package/web/dist/assets/{run-header-DPiJgSo-.js → run-header-GC4sCqc9.js} +2 -2
  69. package/web/dist/assets/{select-C1DuBMH_.js → select-DJ96FKkN.js} +1 -1
  70. package/web/dist/assets/{session-context-section-D3cboKUj.js → session-context-section-J5dOI7wy.js} +2 -2
  71. package/web/dist/assets/{settings-agent-picker-Dfpkb1BV.js → settings-agent-picker-AIys0-g4.js} +1 -1
  72. package/web/dist/assets/{settings-save-bar-D6_OuAVS.js → settings-save-bar-hxduqYzV.js} +1 -1
  73. package/web/dist/assets/{settings-shell-1mamrmf4.js → settings-shell-BKrwxtH3.js} +1 -1
  74. package/web/dist/assets/{sidebar-section-b6sRM7jE.js → sidebar-section-BOLBt6ht.js} +1 -1
  75. package/web/dist/assets/{skills-C30XIl36.js → skills-cirmZTle.js} +1 -1
  76. package/web/dist/assets/{tab-link-BrzzZnhE.js → tab-link-D97ij5JR.js} +1 -1
  77. package/web/dist/assets/{task-changes-DddXsOz9.js → task-changes-n6YG81dZ.js} +1 -1
  78. package/web/dist/assets/task-commits-B2kRm9wv.js +1 -0
  79. package/web/dist/assets/{task-file-scope-iKAyonAT.js → task-file-scope-VqZwLAhF.js} +1 -1
  80. package/web/dist/assets/task-files-DQnLpO6C.js +1 -0
  81. package/web/dist/assets/task-github-item-BCa7NBSF.js +1 -0
  82. package/web/dist/assets/{task-groups-CsjJ9R5Y.js → task-groups-COb-xWM_.js} +1 -1
  83. package/web/dist/assets/{task-thread-Dnr-230B.js → task-thread-BVuc26YV.js} +2 -2
  84. package/web/dist/assets/{tasks-table--jkwCj2N.js → tasks-table-CyUTCD9k.js} +1 -1
  85. package/web/dist/assets/thread-state-Cu3lYPx3.js +4 -0
  86. package/web/dist/assets/{toaster-BJG79kO8.js → toaster-Cjr2jC1Q.js} +1 -1
  87. package/web/dist/assets/{use-hand-to-agent-state-L5WXggAl.js → use-hand-to-agent-state-DC_mgEa8.js} +1 -1
  88. package/web/dist/assets/use-path-bases-BNiDz4sw.js +1 -0
  89. package/web/dist/assets/use-workspace-config-save-Do4bGg72.js +1 -0
  90. package/web/dist/assets/{workflows-BY8BG_hN.js → workflows-DcsG1apu.js} +3 -3
  91. package/web/dist/assets/{workspace-tools-DVnZs_qc.js → workspace-tools-BlsGt8_D.js} +1 -1
  92. package/web/dist/assets/{worktrees-section-C3y-OvKl.js → worktrees-section-CGN4CXhC.js} +1 -1
  93. package/web/dist/index.html +14 -14
  94. package/web/dist/assets/agent-defaults-section-DsQc_03b.js +0 -1
  95. package/web/dist/assets/attention-BHNhUrnd.js +0 -1
  96. package/web/dist/assets/discard-changes-dialog-CXo5mwrr.js +0 -1
  97. package/web/dist/assets/file-preview-CnmQ7Rsa.js +0 -2
  98. package/web/dist/assets/github-SKF8V2qz.js +0 -1
  99. package/web/dist/assets/index-CoM783-U.js +0 -21
  100. package/web/dist/assets/preview-pane-connected-TpVEOykT.js +0 -3
  101. package/web/dist/assets/repo-git-CQJSTkjN.js +0 -1
  102. package/web/dist/assets/repo-git-DVXNOJDT.css +0 -1
  103. package/web/dist/assets/task-commits-DI1DvelD.js +0 -1
  104. package/web/dist/assets/task-files-BHJJfNnG.js +0 -1
  105. package/web/dist/assets/task-github-item-CB8waROc.js +0 -1
  106. package/web/dist/assets/thread-state-CHJmKJ6J.js +0 -4
  107. package/web/dist/assets/use-path-bases-CIQDEHqC.js +0 -1
  108. package/web/dist/assets/use-workspace-config-save-DF7JuKqF.js +0 -1
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t}from"./react-runtime-CCIEwYL0.js";import{d as n,p as r}from"./dist-C_rn70hE.js";import{$ as i,$t as a,A as o,Ai as s,Bn as c,C as l,Ct as u,D as d,Di as f,Dt as p,E as m,Et as h,F as g,Fi as _,G as v,Hn as ee,Ht as te,It as ne,J as re,Jt as ie,K as ae,Kt as oe,L as se,Mi as ce,Mt as le,N as ue,Nt as de,O as fe,Ot as pe,Pi as me,Pt as he,Q as ge,Qt as _e,Ri as ve,Rn as ye,S as be,Si as xe,Sn as Se,St as Ce,Ti as we,Tr as Te,Un as Ee,Ur as De,Vn as Oe,Vr as ke,Vt as Ae,Wn as je,Wr as Me,Wt as Ne,X as Pe,Xr as Fe,Xt as Ie,Y as Le,Yr as Re,Yt as ze,Zt as Be,_n as Ve,_t as He,a as Ue,an as We,b as Ge,bn as Ke,br as qe,bt as Je,ci as Ye,cn as Xe,ct as Ze,di as Qe,en as $e,et,fi as tt,fn as nt,gn as rt,gt as it,h as at,hi as ot,hn as st,ii as ct,in as lt,k as ut,kt as dt,li as ft,ln as pt,m as mt,mi as ht,mn as gt,n as _t,nn as vt,oi as yt,on as bt,pi as xt,pn as St,pt as Ct,q as wt,qt as Tt,si as y,sn as Et,tn as Dt,ui as Ot,v as kt,vi as b,vt as At,wt as jt,x as Mt,xi as Nt,xn as Pt,xt as Ft,y as It,yi as Lt,yn as Rt,yt as zt,zn as Bt}from"./toaster-BJG79kO8.js";import{A as Vt,B as x,F as S,H as C,I as w,N as T,P as E,W as D,Z as O,a as Ht,j as k,z as A}from"./live-protocol-DMhTnCmf.js";function Ut(e,t){return e??t}function Wt(e,t){let n=Ut(e,t);return n===`1`||n===`true`}function Gt(e,t,n){return e?.trim()||Ut(t,n)||``}var Kt=class extends Nt{#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||qt(),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=xe({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),O.batch(()=>{this.#t.forEach(t=>{t.onMutationUpdate(e)}),this.#n.notify({mutation:this,type:`updated`,action:e})})}};function qt(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:`idle`,variables:void 0,submittedAt:0}}var Jt=class extends ve{#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),me(this.options,t)||this.#e.getMutationCache().notify({type:`observerOptionsUpdated`,mutation:this.#n,observer:this}),t?.mutationKey&&this.options.mutationKey&&we(t.mutationKey)!==we(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??qt();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){O.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 Yt(e,t){let n=new Set(t);return e.filter(e=>!n.has(e))}function Xt(e,t,n){let r=e.slice(0);return r[t]=n,r}var Zt=class extends ve{#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,O.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||!me(e,n)});!o&&!s||(o&&(this.#l=t,this.#i=n),this.#t=r,this.hasListeners()&&(o&&(Yt(e,n).forEach(e=>{e.destroy()}),Yt(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=ce(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 Lt(this.#e,r);n.push({defaultedQueryOptions:r,observer:i})}),n}#m(e,t){let n=this.#i.indexOf(e);n!==-1&&(this.#t=Xt(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)&&O.batch(()=>{this.listeners.forEach(e=>{e(this.#t)})})}}},j=e(t(),1);function M({queries:e,...t},n){let r=b(n),i=ot(),a=ht(),o=j.useMemo(()=>e.map(e=>{let t=r.defaultQueryOptions(e);return t._optimisticResults=i?`isRestoring`:`optimistic`,t}),[e,r,i]);o.forEach(e=>{Ye(e);let t=r.getQueryCache().get(e.queryHash);Qe(e,a,t)}),xt(a);let[c]=j.useState(()=>new Zt(r,o,t)),[l,u,d]=c.getOptimisticResult(o,t.combine),f=!i&&t.subscribed!==!1;j.useSyncExternalStore(j.useCallback(e=>f?c.subscribe(O.batchCalls(e)):s,[c,f]),()=>c.getCurrentResult(),()=>c.getCurrentResult()),j.useEffect(()=>{c.setQueries(o,t)},[o,t,c]);let p=l.some((e,t)=>Ot(o[t],e))?l.flatMap((e,t)=>{let n=o[t];return n&&Ot(n,e)?ft(n,new Lt(r,n),a):[]}):[];if(p.length>0)throw Promise.all(p);let m=l.find((e,t)=>{let n=o[t];return n&&tt({result:e,errorResetBoundary:a,throwOnError:n.throwOnError,query:r.getQueryCache().get(n.queryHash),suspense:n.suspense})});if(m?.error)throw m.error;return u(d())}function N(e,t){let n=b(t),[r]=j.useState(()=>new Jt(n,e));j.useEffect(()=>{r.setOptions(e)},[r,e]);let i=j.useSyncExternalStore(j.useCallback(e=>r.subscribe(O.batchCalls(e)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),a=j.useCallback((e,t)=>{r.mutate(e,t).catch(s)},[r]);if(i.error&&_(r.options.throwOnError,[i.error]))throw i.error;return{...i,mutate:a,mutateAsync:i.mutate}}function P(e={}){let t=e.projectId??r();return{projectId:t,cacheScope:e.cacheScope??(e.boot?`default`:t)}}function F(e,t={}){return{...P(t),runId:e}}function Qt(e,t=!0,n=!1,r){return y({queryKey:[P({projectId:e,boot:n}).cacheScope,`runs`,`list`],queryFn:({signal:t})=>de(P({projectId:e,boot:n}),{signal:t}),enabled:t,...r?{select:r}:{},placeholderData:(t,r)=>n&&r?.queryKey[0]===e?t:void 0})}function I(e,t,n=`active`){return e.invalidateQueries({queryKey:t===void 0?[`workspace`,`models`]:W.models(t),refetchType:n})}function $t(e,t=!0,n){return y({...en(e,n),enabled:t})}var en=(e,t)=>({queryKey:W.models(e,t),queryFn:({signal:n})=>je(e,{signal:n},t),staleTime:300*1e3});function tn(e,t=!0){let n=M({queries:e.map(e=>({...en(e),enabled:t}))});return Object.fromEntries(e.map((e,t)=>[e,n[t]]))}function nn(e,t){return JSON.stringify([e,t])}function rn(e){return e.type===`run`?e.run.id:e.id}function L(e,t){return{...e,runs:t}}function an(e,t){let n=0;for(let r of e)r.projectId===t&&r.archived&&(n+=1);return n}var on=class{runs;copied=!1;positions=new Map;constructor(e){this.runs=e,this.reindex()}reindex(){this.positions.clear(),this.runs.forEach((e,t)=>this.positions.set(nn(e.projectId,e.id),t))}at(e,t){return this.positions.get(nn(e,t))??-1}mutable(){return this.copied||=(this.runs=[...this.runs],!0),this.runs}replace(e,t){return this.mutable()[e]=t,this.runs}remove(e){return this.mutable().splice(e,1),this.reindex(),this.runs}insert(e){let t=this.runs.findIndex(t=>(t.createdAt??``).localeCompare(e.createdAt)<0);return this.mutable().splice(t<0?this.runs.length:t,0,e),this.reindex(),this.runs}};function sn(e,t,n){let r=new on(e.runs),i=e,a=!1;for(let e of t)if(e.type===`usage`)i=pn(i,e.project,e.usage,r);else{let t=un(i,e.change,n,r);i=t.index,a||=t.reconcile}return{index:i,reconcile:a}}function cn(e,t,n){return n?n.has(t):e.runs.some(e=>e.projectId===t)}function ln(e,t,n){return un(e,t,n,new on(e.runs))}function un(e,t,n,r){let{project:i}=t,a=r.at(i,rn(t)),o=a>=0?e.runs[a]:void 0,s=e.truncated.includes(i);if(t.type===`deleted`)return o?{index:L(e,r.remove(a)),reconcile:s&&o.archived}:{index:e,reconcile:!1};let{run:c}=t;if(c.delegation?.role===`worker`)return o?{index:L(e,r.remove(a)),reconcile:!1}:{index:e,reconcile:!1};if(!o&&!cn(e,i,n))return{index:e,reconcile:!0};let l=ce(o,{projectId:i,...c});if(o){if(l===o)return{index:e,reconcile:!1};let t=r.replace(a,l),n=o.archived!==l.archived&&(s||an(t,i)>e.perProjectLimit);return{index:L(e,t),reconcile:n}}if(s)return fn(e,l,r);let u=r.insert(l);return{index:L(e,u),reconcile:l.archived&&an(u,i)>e.perProjectLimit}}function dn(e,t){let n;for(let r of e)r.projectId===t&&r.archived&&(n===void 0||r.createdAt<n)&&(n=r.createdAt);return n}function fn(e,t,n){let r=dn(e.runs,t.projectId),i=r!==void 0&&t.createdAt>r;return t.archived&&!i?{index:e,reconcile:!1}:{index:L(e,n.insert(t)),reconcile:t.archived||r===void 0||t.createdAt<r}}function pn(e,t,n,r){let i=!1;return e.runs.forEach((e,a)=>{if(e.projectId!==t)return;let o=n[e.id];if(o){let t=ce(e.usage,o);if(t===e.usage)return;r.replace(a,{...e,usage:t})}else{if(e.usage===void 0)return;let{usage:t,...n}=e;r.replace(a,n)}i=!0}),i?L(e,r.runs):e}function mn(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 hn(){return{stream:void 0,lastStream:void 0,mismatch:void 0,floor:void 0,changes:new Map}}function gn(e,t,n){if(e.lastStream===t)e.floor=Math.max(e.floor??n,n);else{for(let[n,r]of e.changes)r.generation!==t&&e.changes.delete(n);e.floor=n}e.stream=t,e.lastStream=t,e.mismatch=void 0}function _n(e){e.stream=void 0}function vn(e,t,n=!1){let r=e.stream;if(r===void 0)return!1;(e.floor===void 0||n)&&(e.floor=t.seq-1);let i=JSON.stringify([r,t.project,rn(t)]),a=e.changes.get(i);return(!a||a.seq<t.seq)&&e.changes.set(i,{...t,generation:r}),!0}function yn(e,t){for(let[n,r]of e.changes)r.project===t&&e.changes.delete(n)}function bn(e){return typeof e.generation==`string`&&typeof e.eventSeq==`number`}function xn(e,t,n){if(!bn(t))return{index:t,reconcile:!1};let{generation:r,eventSeq:i}=t;if(e.stream!==void 0&&e.stream!==r){let n=e.mismatch!==r;return e.mismatch=r,{index:t,reconcile:n}}let a=e.lastStream===r&&e.floor!==void 0,o=a&&i<e.floor,s=t,c=o,l=[...e.changes.entries()].filter(([,e])=>e.generation===r),u=l.map(([,e])=>e).filter(e=>e.seq>i).sort((e,t)=>e.seq-t.seq);for(let e of u){let t=ln(s,e,n);s=t.index,c||=t.reconcile}for(let[t,n]of l)n.seq<=i&&e.changes.delete(t);return a&&!o&&(e.floor=i),{index:s,reconcile:c}}var R=[`workspace`,`runs-index`],Sn=[`workspace`,`projects`],Cn=6e4,wn=100,Tn=new WeakMap;function En(e){let t=Tn.get(e);return t||(t=jn(e),Tn.set(e,t)),t}function Dn(e,t){return typeof e!=`object`||!e||!Array.isArray(e.runs)?e:En(t).merge(e)}function On(e){let t=e.getQueryData(Sn)?.projects;return t?new Set(t.map(e=>e.id)):void 0}function kn(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 An(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 jn(e){let t=hn(),n=[],r,i,a,o,s=!1,c=-1/0,l=new Set,u=!1,d,f=!1,p=()=>{if(!u){if(u=!0,d?.()){f=!0;return}_({hold:!0})}},m=t=>{c=Date.now(),e.setQueryData(R,t)},h=()=>e.getQueryData(R),g=()=>{clearTimeout(a),a=void 0;let t=e.getQueryCache().find({queryKey:R,exact:!0}),n=(t!==void 0&&t.state.data===void 0&&t.state.fetchStatus!==`idle`?e.cancelQueries({queryKey:R,exact:!0}).then(()=>e.invalidateQueries({queryKey:R})):e.invalidateQueries({queryKey:R})).catch(()=>void 0).finally(()=>{o===n&&(o=void 0,s&&(s=!1,g()))});return o=n,n},_=(e={})=>o?(s=!0,o):e.hold?(a??=setTimeout(()=>{g()},400),Promise.resolve()):g(),v=()=>{r!==void 0&&typeof cancelAnimationFrame==`function`&&cancelAnimationFrame(r),r=void 0,clearTimeout(i),i=void 0;let t=n;n=[];let a=h();if(!a||t.length===0)return;let o=On(e),{index:s,reconcile:c}=sn(a,t.filter(e=>e.generation===a.generation?e.type===`usage`?!l.has(e.project):!l.has(e.change.project)&&e.change.seq>a.eventSeq:!1),o);s!==a&&m(s),c&&_({hold:!0})},ee=()=>{if(i!==void 0)return;let e=c+250-Date.now();if(e>0){i=setTimeout(v,e);return}i=setTimeout(v,wn),typeof requestAnimationFrame==`function`&&(r=requestAnimationFrame(v))};return{ready(e,n){gn(t,e,n),u=!1,f&&(f=!1,_({hold:!0}))},detach(){_n(t)},run(e,r,i=!1){if(l.has(e))return;let a=An(e,r);if(!vn(t,a,i)){p();return}n.push({type:`change`,change:a,generation:t.stream}),ee()},usage(e,r){if(!l.has(e)){if(t.stream===void 0){p();return}n.push({type:`usage`,project:e,usage:r,generation:t.stream}),ee()}},dropProject(e){l.add(e),yn(t,e),n=n.filter(t=>(t.type===`change`?t.change.project:t.project)!==e);let r=h();if(!r)return;let i=mn(r,e);i!==r&&m(i)},setUnknownGenerationHandler(e){d=e},restoreProject(e){l.delete(e)},merge(n){let r=h(),i=xn(t,n,On(e));for(let e of l)i.index=mn(i.index,e);return i.reconcile&&queueMicrotask(()=>{_({hold:!0})}),kn(r,n,t.stream)??i.index},reconcile:_,flush:v,stop(){r!==void 0&&typeof cancelAnimationFrame==`function`&&cancelAnimationFrame(r),r=void 0,clearTimeout(i),i=void 0,clearTimeout(a),a=void 0,n=[],s=!1}}}var Mn=k([`own`,`provider-spanning`]),Nn=x({suggested:T(x({id:D(),label:D(),desc:D()})),retired:T(D())}),Pn=x({id:k([`settings`,`mcp`,`memory`]),label:D(),note:D().optional(),empty:D().optional(),showsUserMcp:w(!0).optional()}),Fn=x({label:D(),note:D().optional(),groups:T(Pn)}),In=x({runners:T(x({id:ct,displayName:D(),modelListName:D(),modelIdScope:Mn,pickerLabel:D(),pickerDescription:D(),icon:D(),installHint:D(),loginCommand:D(),terminalLogin:E().optional(),browserLogin:E().optional(),managedInstall:w(!0).optional(),accountFolderExample:D().optional(),models:Nn,agentConfig:Fn}))}),Ln=[`workspace`,`runners`];async function Rn(e){return Ee(await Bt.api.v1.runners.$get({},c(e)),`/runners`,In)}var zn={queryKey:Ln,queryFn:({signal:e})=>Rn({signal:e}),staleTime:1/0};function Bn(){return y(zn)}function Vn(e){return e?.runners??[]}function Hn(e){return Vn(e).map(e=>e.id)}function Un(e,t){if(e!==void 0)return t.includes(e)?e:t[0]}function Wn(e){let t=Bn();return{runner:t.isSuccess?Un(e,Hn(t.data))??e:e,ready:!t.isPending}}function z(e,t){return e?.runners.find(e=>e.id===t)}function Gn(e,t){return z(e,t)?.displayName??t}function Kn(e,t){return z(e,t)?.pickerLabel??t}function qn(e,t){return z(e,t)?.modelListName}function Jn(e,t,n=!0){let i=Ii(),a=q(),{runner:o,ready:s}=Wn(e??i.data?.defaultRunner??`claude`),c=a.data?.capabilities?.localHandoff===!1?null:t,l=r(),u=y({queryKey:U.runnerSkills(o,c),queryFn:({signal:e})=>m(o,c,{signal:e,projectId:l}),enabled:n&&s&&(e!==void 0||!i.isPending)&&(!t||!a.isPending),retry:!1});return{...u,runner:o,account:c,data:u.data?.skills,list:u.data,unchecked:u.isError||!u.data||u.data.source===`unavailable`}}var Yn={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`}},Xn={label:`Merge conflicts`,hint:`this branch no longer merges cleanly into its base — rebase or merge the base in`,tone:`conflict`};function Zn(e){return typeof e==`string`&&Object.hasOwn(Yn,e)}function Qn(e){return e!==void 0&&Zn(e)?Yn[e]:void 0}var $n=`cez.reference-statuses.v1`,er=`cez.reference-conflicts.v1`,B=new Map(ir()),tr=1e3;function nr(e,t){if(B.get(e)!==t){for(B.delete(e),B.set(e,t);B.size>tr;){let e=B.keys().next().value;if(e===void 0)break;B.delete(e)}sr()}}var V=new Set(ar());function rr(e,t){if(V.has(e)!==t){if(t)for(V.add(e);V.size>tr;){let e=V.values().next().value;if(e===void 0)break;V.delete(e)}else V.delete(e);sr()}}function ir(){try{let e=globalThis.sessionStorage?.getItem($n);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`&&Zn(e[1])):[]}catch{return[]}}function ar(){try{let e=globalThis.sessionStorage?.getItem(er);if(!e)return[];let t=JSON.parse(e);return Array.isArray(t)?t.filter(e=>typeof e==`string`):[]}catch{return[]}}var or;function sr(){or===void 0&&(or=setTimeout(()=>{or=void 0;try{globalThis.sessionStorage?.setItem($n,JSON.stringify([...B])),globalThis.sessionStorage?.setItem(er,JSON.stringify([...V]))}catch{}},250))}var H=e=>`${e.projectId}\u0000${e.kind}#${e.number}`;function cr(e,t){return{...e?{status:e}:{},...t?{conflicting:!0}:{}}}function lr(e){return[...e.prs.map(t=>({projectId:e.projectId,kind:`PR`,number:t})),...e.issues.map(t=>({projectId:e.projectId,kind:`Issue`,number:t}))]}function ur(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;nr(t,o),s!==void 0&&rr(t,s),e.set(t,{state:`ready`,status:o,...s??a?{conflicting:!0}:{}})}function dr(e,t,n){let r=H(t),i=B.get(r),a=V.has(r)?!0:void 0,o=n.data;if(o?.available){ur(e,r,t,o,i,a);return}if(o){e.set(r,{state:`unavailable`,reason:o.reason,...cr(i,a)});return}if(n.isError){e.set(r,{state:`unavailable`,reason:n.error instanceof Error?n.error.message:void 0,...cr(i,a)});return}e.set(r,{state:`loading`,...cr(i,a)})}function fr(e,t){let n=new Map;return t.forEach((t,r)=>{let i=e[r];if(i)for(let e of lr(i))dr(n,e,t)}),n}var U={get health(){return[r(),`health`]},runs:{get all(){return[r(),`runs`]},relationships:e=>[r(),`runs`,`relationships`,e],list:(e=r())=>[e,`runs`,`list`],archived:e=>[r(),`runs`,`archived`,e],detail:(e,t=r())=>[t,`runs`,`detail`,e],diff:e=>[r(),`runs`,`diff`,e],changes:e=>[r(),`runs`,`changes`,e],file:(e,t)=>[r(),`runs`,`files`,e,t],handoff:e=>[r(),`runs`,`handoff`,e],commits:e=>[r(),`runs`,`commits`,e],commit:(e,t)=>[r(),`runs`,`commit`,e,t]},get workflows(){return[r(),`workflows`]},runnerSkills:(e,t)=>[r(),`runner-skills`,e,t??null],get repo(){return[r(),`repo`]},get repoChanges(){return[r(),`repo`,`changes`]},repoCommit:e=>[r(),`repo`,`commit`,e],get repoBranches(){return[r(),`repo`,`branches`]},get uiState(){return[r(),`ui-state`]},get config(){return[r(),`config`]},get agentConfig(){return[r(),`agent-config`]},agentConfigFile:e=>[r(),`agent-config`,`file`,e],get sessionContext(){return[r(),`session-context`]},sessionContextPreview:(e,t,n=``)=>[r(),`session-context`,`preview`,t,e,n],get worktrees(){return[r(),`worktrees`]},github:(e={})=>[r(),`github`,e.limit??null],githubPages:e=>[r(),`github`,`pages`,e],githubPagesHead:e=>[r(),`github`,`pages-head`,e],githubCommentCounts:(e,t)=>[r(),`github`,`comment-counts`,e,[...t].sort((e,t)=>e-t).join(`,`)],githubChecks:e=>[r(),`github`,`checks`,[...e].sort((e,t)=>e-t).join(`,`)],githubSearch:(e,t)=>[r(),`github`,`search`,e,t],githubRefStatus:(e,t,n)=>[e,`github`,`ref-status`,[...t].sort((e,t)=>e-t).join(`,`),[...n].sort((e,t)=>e-t).join(`,`)],githubComments:(e,t)=>[r(),`github`,`comments`,e,t],githubItem:(e,t)=>[r(),`github`,`item`,e,t],githubRefStatusOf:e=>[e,`github`,`ref-status`],githubPrChanges:e=>[r(),`github`,`pr-changes`,e],githubMergeState:e=>[r(),`github`,`merge-state`,e],get openTargets(){return[r(),`open-targets`]}},W={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:R,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)=>[...W.fsBrowseRoot,e,t]};function pr(){return Wt(void 0,void 0)}function G(e){return!pr()&&e}function mr(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 hr(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 gr(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 _r(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 vr(e,t){return Fe({kind:`topic`,topic:e},{value:t})}function yr(){let e=b();return y({queryKey:W.providerStatus,queryFn:async({signal:t})=>{let n=e.getQueryData(W.providerStatus),r=await Et(!1,{signal:t});return Te(n,e.getQueryData(W.providerStatus),r)},staleTime:5*6e4,refetchInterval:G(!1),refetchOnWindowFocus:!0})}function br(){let e=b();return N({mutationFn:()=>Et(!0),onMutate:()=>e.getQueryData(W.providerStatus),onSuccess:(t,n,r)=>{e.setQueryData(W.providerStatus,e=>Te(r,e,t)),I(e)}})}function xr(){let e=b();return N({mutationFn:({provider:e,authFailureId:t})=>rt(e,t),onMutate:()=>e.getQueryData(W.providerStatus),onSuccess:(t,n,r)=>{e.setQueryData(W.providerStatus,e=>Te(r,e,t,n.authFailureId)),I(e,n.provider)}})}function Sr(e={}){return y({queryKey:W.projects,queryFn:({signal:e})=>bt({signal:e}),...e})}function Cr(e,t=!1){return y({queryKey:W.fsBrowse(e,t),queryFn:({signal:n})=>ze(e??void 0,{signal:n,showHidden:t}),retry:!1})}function wr(){let e=b();return N({mutationFn:e=>nt(e),onSuccess:()=>e.invalidateQueries({queryKey:W.projects})})}function Tr(){let e=b();return N({mutationFn:e=>gt(e),retry:!1,onSuccess:()=>{e.invalidateQueries({queryKey:W.projects})}})}function Er(){let e=b();return N({mutationFn:e=>{let{id:t,...n}=e;return Pt(t,n)},retry:!1,onMutate:async({id:t,...n})=>{await e.cancelQueries({queryKey:W.projects});let r=e.getQueryData(W.projects);return e.setQueryData(W.projects,e=>e===void 0?e:{...e,projects:e.projects.map(e=>e.id===t?Dr(e,n):e)}),{previous:r}},onError:(t,n,r)=>{r?.previous&&e.setQueryData(W.projects,r.previous)},onSuccess:({project:t})=>{e.setQueryData(W.projects,e=>e===void 0?e:{...e,projects:e.projects.map(e=>e.id===t.id?t:e)})},onSettled:()=>e.invalidateQueries({queryKey:W.projects})})}function Dr(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?[]:_r(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 Or(e){let t=b();return N({mutationFn:e,retry:!1,onSuccess:({project:e})=>{t.setQueryData(W.projects,t=>t===void 0?t:{...t,projects:t.projects.map(t=>t.id===e.id?e:t)})},onSettled:()=>t.invalidateQueries({queryKey:W.projects})})}function kr(){return Or(e=>{let{projectId:t,...n}=e;return $e(t,n)})}function Ar(){return Or(e=>{let{projectId:t,webhookId:n,...r}=e;return Se(t,n,r)})}function jr(){return Or(({projectId:e,webhookId:t})=>st(e,t))}function Mr(){return N({mutationFn:({projectId:e,webhookId:t})=>Rt(e,t),retry:!1})}function K(e){let t=b();return N({mutationFn:e,retry:!1,onSuccess:async()=>{await Promise.all([t.invalidateQueries({queryKey:W.agentProfiles}),t.invalidateQueries({queryKey:W.projects}),t.invalidateQueries({predicate:({queryKey:e})=>e[1]===`runner-skills`}),I(t)])},onError:()=>{t.invalidateQueries({queryKey:U.health}),t.invalidateQueries({queryKey:W.agentProfiles,exact:!0})}})}function Nr(){return K(e=>_e(e))}function Pr(){return K(e=>{let{id:t,...n}=e;return Ke(t,n)})}function Fr(){return K(e=>St(e))}function Ir(){return K(e=>Ve(e))}function Lr(e,t){return y({queryKey:W.agentAccountStatus(e),queryFn:({signal:t})=>Dt(e,{signal:t}),enabled:t,staleTime:6e4,retry:!1})}function Rr(){let e=b();return N({mutationFn:({provider:e,profileId:t})=>Be(e,t),retry:!1,onSuccess:async(t,{provider:n})=>{await Promise.all([e.invalidateQueries({queryKey:W.agentProfiles}),e.invalidateQueries({queryKey:W.providerStatus}),I(e,n,`none`)])},onError:()=>{e.invalidateQueries({queryKey:U.health}),e.invalidateQueries({queryKey:W.agentProfiles,exact:!0})}})}function zr(){let e=b();return N({mutationFn:e=>Dt(e,{refresh:!0}),retry:!1,onSuccess:(t,n)=>{e.setQueryData(W.agentAccountStatus(n),t),e.invalidateQueries({queryKey:W.agentProfiles}),I(e,t.status.provider)}})}function Br(){let e=b();return N({mutationFn:e=>Ie(e),retry:!1,onSuccess:()=>e.invalidateQueries({queryKey:W.projects})})}function Vr(){let e=b();return N({mutationFn:e=>a(e),retry:!1,onSuccess:()=>e.invalidateQueries({queryKey:W.projects})})}function Hr({enabled:e}){return y({queryKey:W.githubOwners,queryFn:({signal:e})=>lt({signal:e}),enabled:e,staleTime:6e4,retry:!1})}function Ur(){let e=b();(0,j.useEffect)(()=>{let t,r=()=>{let r=e.getQueryData(U.health);r&&(De({bootProject:r.bootProject??`default`,apiBase:n()}),t??=vr(`health`,t=>{e.setQueryData(U.health,t)}))};r();let i=e.getQueryCache().subscribe(r);return()=>{i(),t?.(),Re()}},[e])}function q(){return y({queryKey:U.health,queryFn:({signal:e})=>We({signal:e})})}function Wr(e,t){let n=q().data,r=Sr(t).data?.projects,i=Ue(),a=e??i.projectId,o=a??n?.bootProject,s=o===void 0?void 0:r?.find(e=>e.id===o);return s?.repoUrl?s.repoUrl:a===null||a===n?.bootProject?mr(n?.repo?.remote):void 0}function Gr(){return y({queryKey:W.uiState,queryFn:({signal:e})=>pt({signal:e})})}function Kr(){return y({queryKey:W.config,queryFn:({signal:e})=>Xe({signal:e})})}function qr(){return y({queryKey:W.agentProfiles,queryFn:({signal:e})=>vt({signal:e})})}var J=[`workspace`,`runs-index`],Y=e=>[e.cacheScope,`runs`,`list`],X=e=>[e.cacheScope,`runs`,`detail`,e.runId],Z=e=>typeof e==`function`?e():e;function Jr(e){let{seenAt:t,...n}=e;return n}function Yr(e,t){let n=Jr(e);return t.seenAt===void 0?n:{...n,seenAt:t.seenAt}}function Xr(e,t,n){return t?{...e,seenAt:n}:Jr(e)}function Zr(e){let t=()=>{e.invalidateQueries({queryKey:J})};function n(n,i){if(n===`index`)return t();let a=typeof i==`function`?i():i;if(n===`indexed`){t(),e.invalidateQueries({queryKey:[r(),`runs`]}),e.invalidateQueries({queryKey:[a.projectId,`runs`,`list`]});return}if(n===`runs`)return e.invalidateQueries({queryKey:[a.cacheScope,`runs`]});let o=Me(),s=[a.projectId,a.cacheScope],c=o!==void 0&&s.some(e=>e===o||e==="default")?[o,`default`]:[],l=new Set([...s,...c,r()]);return Promise.all([...l].map(t=>e.invalidateQueries({queryKey:[t,`runs`]}))).then(()=>void 0)}async function i(n,r){await e.cancelQueries({queryKey:Y(Z(n))}),await e.cancelQueries({queryKey:X(Z(n))});let i=e.getQueryData(Y(Z(n))),a=e.getQueryData(X(Z(n))),o=Z(n).runId,s=new Date().toISOString();return e.setQueryData(Y(Z(n)),e=>e?.map(e=>e.id===o?Xr(e,r,s):e)),e.setQueryData(X(Z(n)),e=>e&&Xr(e,r,s)),{id:o,prevList:i,prevDetail:a,rollback(){if(!r){i&&e.setQueryData(Y(Z(n)),i),a&&e.setQueryData(X(Z(n)),a);return}let t=i?.find(e=>e.id===o);t&&e.setQueryData(Y(Z(n)),e=>e?.map(e=>e.id===o?Yr(e,t):e)),a&&e.setQueryData(X(Z(n)),e=>e&&Yr(e,a))},settle(i){let a=e=>e.id===(r?o:i.id)?Xr(e,r,i.seenAt):e;e.setQueryData(Y(Z(n)),e=>e?.map(a));let s={...Z(n),runId:r?o:i.id};e.setQueryData(X(s),e=>e?a(e):i),t()}}}async function a(t,r){await e.cancelQueries({queryKey:J});let i=e.getQueryData(J),a=r();return e.setQueryData(J,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(J,i)},settle(){n(`indexed`,t)}}}return{patchRead:i,patchIndex:a,invalidateAfter:n}}function Q(){let e=b();return(0,j.useMemo)(()=>Zr(e),[e])}function Qr(e,t){if(!Ht(e.path))throw Error(`unsupported shared read`);let n=new URL(e.path,`http://cezar.invalid`);return n.searchParams.sort(),Fe({kind:`read`,path:`${n.pathname}${n.search}`,intervalMs:e.intervalMs},{value:t})}function $(e,t,n,r){let i=b(),a=JSON.stringify(t),o=(0,j.useMemo)(()=>JSON.parse(a),[a]);(0,j.useEffect)(()=>{if(!e||n===!1)return;let t=!0,a=Qr({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 $r(e,t=!1){return ee(await Bt.api.v1.p[`:projectId`].runs[`:id`][`worker-destroy`].$post({param:{projectId:r(),id:encodeURIComponent(e)},query:{},json:t?{discardWork:!0}:{}}),Oe(e,`/worker-destroy`))}function ei(){return y({queryKey:U.openTargets,queryFn:({signal:e})=>Ft({signal:e}),staleTime:5*6e4})}function ti(){return y({queryKey:U.runs.list(),queryFn:({signal:e})=>de(P(),{signal:e})})}function ni(e,t){return yt({queryKey:U.runs.archived(e),enabled:t,initialPageParam:void 0,queryFn:({pageParam:t,signal:n})=>it({before:t,limit:200,q:e},{signal:n}),getNextPageParam:e=>e.nextCursor??void 0,placeholderData:(e,t)=>t?.queryKey[0]===r()?e:void 0})}function ri(e){let t=e.trim();return y({queryKey:W.runsSearch(t),queryFn:({signal:e})=>oe(t,{signal:e}),enabled:t.length>=2,placeholderData:f,staleTime:1e4})}function ii(e=!0,t=Cn,n){let r=En(b());return $(`/api/v1/workspace/runs-index`,W.runsIndex,G(e?t:!1),Dn),y({queryKey:W.runsIndex,queryFn:({signal:e})=>he({signal:e}).then(r.merge),enabled:e,...n?{select:n}:{},staleTime:3e4,refetchInterval:!1})}function ai(e){let t=b();return N({mutationFn:({workerId:e,discardWork:t=!1})=>$r(e,t),onSettled:()=>t.invalidateQueries({queryKey:U.runs.relationships(e)})})}function oi(e,t={}){return y({queryKey:U.runs.relationships(e),queryFn:({signal:t})=>le(e,{signal:t}),enabled:t.enabled??!0})}function si(e){return y({queryKey:U.runs.detail(e??``),queryFn:({signal:t})=>Ce(F(e),{signal:t}),enabled:!!e})}function ci(e,t,n=!0,r){return y({queryKey:[e??`default`,`runs`,`detail`,t??``],queryFn:({signal:n})=>Ce(F(t,{projectId:e}),{signal:n}),enabled:n&&!!e&&!!t,...r?.staleTime===void 0?{}:{staleTime:r.staleTime},...r?.refetchOnMount===void 0?{}:{refetchOnMount:r.refetchOnMount}})}function li(e,t){return y({queryKey:t?[t,`runs`,`diff`,e??``]:U.runs.diff(e??``),queryFn:({signal:n})=>p(e,{signal:n,...t?{projectId:t}:{}}),enabled:!!e})}function ui(e,t=!1){return $(e?`/api/v1/p/${r()}/runs/${encodeURIComponent(e)}/changes`:void 0,U.runs.changes(e??``),G(t?4e3:!1)),y({queryKey:U.runs.changes(e??``),queryFn:({signal:t})=>u(e,{signal:t}),enabled:!!e,retry:!1,refetchInterval:!1,refetchOnWindowFocus:!0,staleTime:0})}function di(e,t){return y({queryKey:U.runs.file(e??``,t??``),queryFn:({signal:n})=>pe(e,t,{signal:n}),enabled:!!e&&t!==void 0,retry:!1})}function fi(e,t){return y({queryKey:[r(),`runs`,`file-link`,e,t],queryFn:({signal:n})=>Je(e,t,{signal:n}),enabled:t!==null,retry:!1})}function pi(e,t){return y({queryKey:[r(),`runs`,`artifact`,e,t],queryFn:({signal:n})=>He(e,t,{signal:n}),enabled:t!==null,retry:!1})}function mi(e,t){return y({queryKey:[r(),`runs`,`artifact-metadata`,e,t],queryFn:({signal:n})=>At(e,t,{signal:n}),enabled:t!==null,retry:!1})}function hi(e){return y({queryKey:[r(),`runs`,`artifacts`,e],queryFn:({signal:t})=>zt(e,{signal:t}),retry:!1,staleTime:0,refetchOnWindowFocus:!0})}function gi(e,t=!1){return $(e?`/api/v1/p/${r()}/runs/${encodeURIComponent(e)}/commits`:void 0,U.runs.commits(e??``),G(t?5e3:!1)),y({queryKey:U.runs.commits(e??``),queryFn:({signal:t})=>h(e,{signal:t}),enabled:!!e,retry:!1,refetchInterval:!1})}function _i(e,t){return y({queryKey:U.runs.commit(e??``,t??``),queryFn:({signal:n})=>jt(e,t,{signal:n}),enabled:!!e&&!!t,retry:!1})}function vi(e,t=!0){return y({queryKey:U.runs.handoff(e??``),queryFn:({signal:t})=>dt(F(e),{signal:t}),enabled:!!e&&t})}function yi(e,t,n){return y({queryKey:e===void 0?U.runs.handoff(t):[e,`runs`,`handoff`,t],queryFn:({signal:n})=>dt(F(t,{projectId:e}),{signal:n}),enabled:n,staleTime:15e3})}function bi(e,t){let n=[...new Set(e)],i=M({queries:n.map(e=>({queryKey:[e??r(),`automations`,`names`],queryFn:({signal:t})=>kt({signal:t,archived:`include`,...e===void 0?{}:{projectId:e}}),enabled:t,staleTime:6e4,retry:!1}))}),a=i.map(e=>e.data);return(0,j.useMemo)(()=>{let e=new Map;return a.forEach((t,r)=>{if(t?.available)for(let i of t.automations)e.set(JSON.stringify([n[r]??null,i.id]),i.name)}),(t,n)=>e.get(JSON.stringify([t??null,n]))},[JSON.stringify([n,i.map(e=>e.dataUpdatedAt)])])}function xi(e){let t=b();return N({mutationFn:t=>ne(e,t),retry:!1,onSuccess:()=>t.invalidateQueries({queryKey:U.runs.all})})}function Si(e){let t=b();return N({mutationFn:t=>Ae(e,t),onSuccess:()=>t.invalidateQueries({queryKey:U.runs.all})})}function Ci(e){let t=Q(),n=e?.projectId,r=e?.cacheScope,i=N({mutationFn:e=>ie(e,!0),onMutate:e=>t.patchRead(e,!0),onError:(e,t,n)=>n?.rollback(),onSuccess:(e,t,n)=>n?.settle(e)}),a=(0,j.useCallback)(e=>({...F(e,{projectId:n,cacheScope:r}),id:e}),[n,r]),o=(0,j.useCallback)(e=>({onSuccess:(t,n,r,i)=>e?.onSuccess?.(t,n.id,r,i),onError:(t,n,r,i)=>e?.onError?.(t,n.id,r,i),onSettled:(t,n,r,i,a)=>e?.onSettled?.(t,n,r.id,i,a)}),[]),{mutate:s,mutateAsync:c}=i,l=(0,j.useCallback)((e,t)=>s(a(e),o(t)),[s,a,o]),u=(0,j.useCallback)((e,t)=>c(a(e),o(t)),[c,a,o]);return{...i,variables:i.variables?.id,mutate:l,mutateAsync:u}}function wi(){let e=Q();return N({mutationFn:e=>ie(F(e),!1),onMutate:t=>e.patchRead(()=>F(t),!1),onError:(e,t,n)=>n?.rollback(),onSuccess:(e,t,n)=>n?.settle(e)})}function Ti(e){let t=Q();return N({mutationFn:({id:t,pinned:n})=>te(F(t,e),n),onError:e=>_t(`Could not update pin. ${e.message} Please retry.`,{tone:`danger`}),onMutate:()=>e??P(),onSuccess:(e,n,r)=>t.invalidateAfter(`runs`,r)})}function Ei(e,t){let n=Q();return N({mutationFn:n=>Tt(F(e,{projectId:t}),n),onMutate:()=>P({projectId:t}),onSuccess:(e,t,r)=>n.invalidateAfter(`send`,r),onError:(e,t,r)=>{e instanceof ye&&e.status===409&&r&&n.invalidateAfter(`send`,r)}})}function Di(e,t){let n=Q();return N({mutationFn:(n={})=>Ze(F(e,{projectId:t}),n),onMutate:()=>P({projectId:t}),onSuccess:(e,t,r)=>n.invalidateAfter(`continue`,r)})}function Oi(e){let t=b();return N({mutationFn:({msgId:t,message:n})=>Ct(e,t,n),onSuccess:()=>t.invalidateQueries({queryKey:U.runs.all})})}function ki(e){let t=b();return N({mutationFn:t=>Ne(e,t),onSuccess:()=>t.invalidateQueries({queryKey:U.runs.all})})}function Ai(){return y({queryKey:U.workflows,queryFn:({signal:e})=>ut({signal:e})})}function ji(e){return y({queryKey:e?[e,`repo`]:U.repo,queryFn:({signal:t})=>Ge({signal:t},e)})}function Mi(e){return y({queryKey:[e,`repo`],queryFn:({signal:t})=>Ge({signal:t},e)})}function Ni(){return y({queryKey:U.repoBranches,queryFn:({signal:e})=>Mt({signal:e})})}function Pi(){return y({queryKey:U.repoChanges,queryFn:({signal:e})=>be({signal:e}),retry:!1})}function Fi(e){return y({queryKey:U.repoCommit(e??``),queryFn:({signal:t})=>l(e,{signal:t}),enabled:!!e,retry:!1})}function Ii(e){return y({queryKey:e?[e,`config`]:U.config,queryFn:({signal:t})=>It({signal:t,...e?{projectId:e}:{}})})}function Li(){return y({queryKey:U.worktrees,queryFn:({signal:e})=>o({signal:e})})}function Ri(e){return y({queryKey:[e,`worktrees`],queryFn:({signal:t})=>o({signal:t},e),staleTime:0})}function zi(e,t=!0,n=!1){return y({queryKey:[P({projectId:e,boot:n}).cacheScope,`ui-state`],queryFn:({signal:t})=>fe({signal:t},e),select:e=>e.sidebarLimits===void 0?e:{...e,sidebarLimits:ke(e.sidebarLimits)},enabled:t})}function Bi(){return zi(r())}function Vi(){return y({queryKey:U.agentConfig,queryFn:({signal:e})=>mt({signal:e})})}function Hi(e){return y({queryKey:U.agentConfigFile(e??``),queryFn:({signal:t})=>at(e,{signal:t}),enabled:e!==null})}function Ui(){return y({queryKey:U.sessionContext,queryFn:({signal:e})=>d({signal:e})})}function Wi(e,t,n=``){return y({queryKey:U.sessionContextPreview(e,t,n),queryFn:({signal:n})=>ue({content:e,role:t},{signal:n}),placeholderData:f,staleTime:0,retry:!1})}function Gi(){let e=b();return N({onMutate:()=>({fileKey:U.sessionContext}),mutationFn:e=>se(e),onSuccess:(t,n,r)=>{r&&e.setQueryData(r.fileKey,t)}})}function Ki(e){let t=b(),n=U.agentConfig,r=U.agentConfigFile(e);return N({mutationFn:t=>g(e,t),onSuccess:e=>{t.setQueryData(r,e),t.invalidateQueries({queryKey:n})}})}var qi=k([`passing`,`failing`,`pending`]).nullable(),Ji=x({kind:k([`issue`,`pr`]),number:A(),title:D(),author:D(),createdAt:D(),labels:T(D()),body:D().optional(),url:D(),comments:A(),assignees:T(D()).optional(),projectIds:T(D()).optional(),isDraft:E().optional(),additions:A().optional(),deletions:A().optional(),checks:qi.optional()});S(`available`,[x({available:w(!0),item:Ji.nullable(),labelColors:C(D(),D()).optional()}),x({available:w(!1),reason:D()})]),x({kind:k([`issue`,`pr`]),number:Vt().int().positive().safe()});var Yi=x({id:D(),title:D(),url:D()});x({available:E(),reason:D().optional(),repo:D().optional(),syncedAt:D().optional(),issues:T(Ji),prs:T(Ji),labelColors:C(D(),D()).optional(),viewerLogin:D().optional(),projects:T(Yi).optional(),projectsReason:D().optional(),projectsState:k([`refreshing`,`ready`,`unavailable`]).optional(),projectsGeneration:D().optional(),issuesTotal:A().int().nonnegative().optional(),prsTotal:A().int().nonnegative().optional(),issuesNextCursor:D().nullable().optional(),prsNextCursor:D().nullable().optional(),commentsDeferred:w(!0).optional()});var Xi=D().min(1).max(2e3).optional();x({limit:D().optional(),refresh:D().optional(),issuesCursor:Xi,prsCursor:Xi,issuesDone:w(`1`).optional(),prsDone:w(`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`})}),x({kind:k([`issue`,`pr`]),numbers:D().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:w(`1`).optional()}),S(`available`,[x({available:w(!0),counts:C(A(),A().int().nonnegative())}),x({available:w(!1),reason:D()})]),S(`available`,[x({available:w(!0),checks:C(A(),qi)}),x({available:w(!1),reason:D()})]),x({kind:k([`issue`,`pr`]),q:D().trim().min(1).max(256),limit:Vt().int().positive().max(50).optional()}),x({available:E(),projectsReason:D().optional(),reason:D().optional(),items:T(Ji),truncated:E().optional(),labelColors:C(D(),D()).optional()});var Zi=A().nullable();S(`available`,[x({available:w(!0),prs:C(A(),qe),issues:C(A(),qe),conflicts:T(A()).optional(),recheckAfterMs:Zi}),x({available:w(!1),reason:D(),recheckAfterMs:Zi})]);var Qi=x({id:A(),author:D(),avatarUrl:D().optional(),createdAt:D(),body:D(),kind:k([`comment`,`review`]),reviewState:k([`approved`,`changes_requested`,`commented`,`dismissed`]).optional(),url:D()}),$i=k([`committed`,`labeled`,`unlabeled`,`assigned`,`unassigned`,`merged`,`closed`,`reopened`,`head_ref_force_pushed`,`cross-referenced`,`renamed`]),ea=x({id:D(),kind:$i,actor:D(),avatarUrl:D().optional(),createdAt:D(),url:D().optional(),sha:D().optional(),message:D().optional(),checks:qi.optional(),label:x({name:D(),color:D().optional()}).optional(),subject:D().optional(),refNumber:A().optional(),refTitle:D().optional(),refIsPr:E().optional()});x({available:E(),reason:D().optional(),comments:T(Qi),truncated:E().optional(),events:T(ea).optional(),detail:x({body:D(),additions:A().int().nonnegative().optional(),deletions:A().int().nonnegative().optional()}).optional()});var ta=k([`merge`,`squash`,`rebase`]),na=x({name:D(),state:k([`passing`,`failing`,`pending`,`unknown`]),required:E().nullable(),url:D().optional()}),ra=x({number:A(),title:D(),url:D(),state:k([`open`,`closed`,`merged`]),isDraft:E(),headRef:D(),baseRef:D(),headSha:D(),mergeable:k([`mergeable`,`conflicting`,`unknown`]),reviewDecision:k([`approved`,`changes-requested`,`review-required`,`not-required`,`unknown`]),checks:T(na),methods:T(ta),defaultMethod:ta.nullable(),eligibility:k([`ready`,`blocked`,`pending`,`unauthorized`,`terminal`,`unknown`]),blockers:T(x({code:D(),message:D()})),canMerge:E(),canOverride:E()});S(`available`,[x({available:w(!0),mergeState:ra}),x({available:w(!1),reason:D()})]),x({merged:w(!0),number:A(),url:D(),method:ta,mergeCommitSha:D().optional()});var ia=x({path:D(),previousPath:D().optional(),status:k([`added`,`modified`,`removed`,`renamed`,`copied`,`changed`]),additions:A(),deletions:A(),patch:D().optional(),patchUnavailableReason:k([`binary`,`too-large`,`not-provided`]).optional(),truncated:E().optional()});S(`available`,[x({available:w(!0),number:A(),headSha:D(),files:T(ia),additions:A(),deletions:A(),truncated:E(),reason:D().optional()}),x({available:w(!1),reason:D()})]),x({generation:D().uuid()}),S(`state`,[x({generation:D().uuid(),state:w(`ready`),projects:T(Yi),membership:C(D(),T(D()))}),x({generation:D().uuid(),state:w(`unavailable`),reason:D()})]);function aa(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 oa(e,t){return e?(t===`issues`?e.issuesNextCursor:e.prsNextCursor)==null:!1}function sa(e,t,n){for(let r of e)t.has(r.number)||(t.add(r.number),n.push(r))}function ca(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){sa(t.issues,a,r),sa(t.prs,o,i);for(let[e,n]of Object.entries(t.labelColors??{}))s[e]??=n}let c=e.find(e=>e.projects)?.projects,l=e.map(e=>e.projectsState),u=e.find(e=>e.projectsState===`unavailable`),d=l.includes(`refreshing`)?`refreshing`:u?`unavailable`:l.some(e=>e===`ready`)?`ready`:void 0,{projectsGeneration:f,projectsReason:p,...m}=t;return{...m,issues:r,prs:i,...Object.keys(s).length>0?{labelColors:s}:{},...c?{projects:c}:{},...d?{projectsState:d}:{},...d===`unavailable`&&u?.projectsReason?{projectsReason:u.projectsReason}:{},...`issuesNextCursor`in n?{issuesNextCursor:n.issuesNextCursor}:{},...`prsNextCursor`in n?{prsNextCursor:n.prsNextCursor}:{}}}var la=e=>e.map(e=>e.number).join(`,`);function ua(e,t){let n=e[0];if(e.length>1&&n&&(la(n.issues)!==la(t.issues)||la(n.prs)!==la(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)]}function da(e={},t=!0){let n=b(),i=U.github(e);$(`/api/v1/p/${r()}/github${e.limit===void 0?``:`?limit=${e.limit}`}`,i,G(t?6e4:!1));let a=y({queryKey:U.github(e),queryFn:({signal:t})=>v({limit:e.limit},{signal:t}),enabled:t,staleTime:6e4,refetchInterval:!1,refetchIntervalInBackground:!1,refetchOnWindowFocus:!0}),o=a.data?.projectsGeneration,s=y({queryKey:[...i,`projects`,o],queryFn:({signal:e})=>ge(o,{signal:e}),enabled:t&&a.data?.projectsState===`refreshing`&&!!o,staleTime:1/0,retry:!1});return(0,j.useEffect)(()=>{!o||!s.data&&!s.error||n.setQueryData(i,e=>{if(!e||e.projectsGeneration!==o||e.projectsState!==`refreshing`)return e;let t=s.data;return t?.generation&&t.generation!==o?e:t?.state===`ready`?{...e,projectsState:`ready`,projects:t.projects,issues:e.issues.map(e=>({...e,projectIds:t.membership?.[e.number]??[]}))}:{...e,projectsState:`unavailable`,projectsReason:t?.reason??`Project boards unavailable. Refresh to try again.`}})},[n,o,s.data,s.error,i]),a}var fa=class extends Error{};function pa(e,t,n){return{queryKey:e,initialPageParam:{},queryFn:async({pageParam:e,signal:r})=>{let i=await v({limit:t,...e,...n?{projectId:n}:{}},{signal:r});if(!i.available&&Object.keys(e).length>0)throw new fa(i.reason??`GitHub is unavailable.`);return i},getNextPageParam:e=>aa(e),retry:(e,t)=>!(t instanceof fa)&&!(t instanceof ye&&t.status>=400&&t.status<500)&&e<1,staleTime:6e4,refetchOnWindowFocus:!0}}function ma(e=50,t=!0){let n=b(),i=U.githubPages(e),a=U.githubPagesHead(e);$(`/api/v1/p/${r()}/github?limit=${e}`,a,G(t?6e4:!1));let o=yt({...pa(i,e),enabled:t,refetchInterval:!1,refetchIntervalInBackground:!1}),s=y({queryKey:a,queryFn:({signal:t})=>v({limit:e},{signal:t}),enabled:!1,staleTime:1/0}),{refetch:c}=o;(0,j.useEffect)(()=>{if(!s.data)return;let e=n.getQueryData(i);if(!e||e.pages.length===0)return;let t=ua(e.pages,s.data);t===`refetch`?c():n.setQueryData(i,{...e,pages:t})},[n,s.dataUpdatedAt,c]);let l=(o.data?.pages??[]).flatMap(e=>e.projectsState===`refreshing`&&e.projectsGeneration?[e.projectsGeneration]:[]),u=M({queries:l.map(e=>({queryKey:[...i,`projects`,e],queryFn:({signal:t})=>ge(e,{signal:t}),enabled:t,staleTime:1/0,retry:!1}))});return(0,j.useEffect)(()=>{u.forEach((e,t)=>{let r=l[t];!r||!e.data&&!e.error||n.setQueryData(i,t=>{if(!t)return t;let n=!1,i=t.pages.map(t=>{if(t.projectsGeneration!==r||t.projectsState!==`refreshing`)return t;let i=e.data;return i?.generation&&i.generation!==r?t:(n=!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 n?{...t,pages:i}:t})})},[n,u.map((e,t)=>e.data||e.error?l[t]:``).join(`,`)]),{pages:o,data:(0,j.useMemo)(()=>ca(o.data?.pages??[]),[o.data])}}function ha(e,t=50,n=!0){let r=yt({...pa([e,`github`,`pages`,t],t,e),enabled:n});return{pages:r,data:(0,j.useMemo)(()=>ca(r.data?.pages??[]),[r.data])}}function ga(e,t,n=!0){let r=M({queries:t.filter(e=>e.length>0).map(t=>({queryKey:U.githubCommentCounts(e,t),queryFn:({signal:n})=>wt(e,t,{},{signal:n}),enabled:n,staleTime:6e4}))});return(0,j.useMemo)(()=>{let e={};for(let t of r)t.data?.available&&Object.assign(e,t.data.counts);return e},[r.map(e=>e.dataUpdatedAt).join(`,`)])}function _a(e,t,n,r=!0){return y({queryKey:[e,`github`,`search`,t,n],queryFn:({signal:r})=>et(t,n,{projectId:e},{signal:r}),enabled:r&&n.trim()!==``,staleTime:6e4})}function va(e,t=!0){return y({queryKey:U.githubChecks(e),queryFn:({signal:t})=>ae(e,{signal:t}),enabled:t&&e.length>0,staleTime:6e4})}function ya(e,t,n=!0){return y({queryKey:U.githubSearch(e,t),queryFn:({signal:n})=>et(e,t,{},{signal:n}),enabled:n&&t.trim()!==``,staleTime:6e4})}var ba=100;function xa(e){return[...e].sort((e,t)=>t-e).slice(0,ba).sort((e,t)=>e-t)}function Sa(){let e=Ue(),t=q();return e.projectId??t.data?.bootProject}function Ca(e){for(let[t,n]of Object.entries(e)){for(let[e,r]of Object.entries(n.prs))nr(H({projectId:t,kind:`PR`,number:Number(e)}),r);for(let[e,r]of Object.entries(n.issues))nr(H({projectId:t,kind:`Issue`,number:Number(e)}),r)}}var wa=5*6e4;function Ta(e){return e?e.recheckAfterMs:wa}function Ea(e,t=!0){let n=(0,j.useMemo)(()=>{let t=new Map;for(let n of e){let e=t.get(n.projectId)??{prs:new Set,issues:new Set};e[n.kind===`PR`?`prs`:`issues`].add(n.number),t.set(n.projectId,e)}return[...t.entries()].map(([e,t])=>({projectId:e,prs:xa(t.prs),issues:xa(t.issues)}))},[e.map(H).sort().join(`|`)]),r=M({queries:n.map(e=>({queryKey:U.githubRefStatus(e.projectId,e.prs,e.issues),queryFn:({signal:t})=>i(e.projectId,{prs:e.prs,issues:e.issues},{signal:t}),enabled:t&&e.prs.length+e.issues.length>0,staleTime:e=>Ta(e.state.data)??1/0,refetchInterval:!1,refetchOnWindowFocus:!0}))}),a=b(),o=JSON.stringify(n.map((e,t)=>({...e,interval:Ta(r[t]?.data)??!1})));(0,j.useEffect)(()=>{if(!t||pr())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=U.githubRefStatus(t.projectId,t.prs,t.issues);return Qr({path:`/api/v1/p/${t.projectId}/github/ref-status?${n}`,intervalMs:t.interval},(t,n)=>{n||a.cancelQueries({queryKey:r,exact:!0}).then(()=>{e&&a.setQueryData(r,t)})})});return()=>{e=!1;for(let e of n)e()}},[t,o,a]);let s=(0,j.useMemo)(()=>fr(n,r),[n,r.map(e=>`${e.dataUpdatedAt}:${e.status}`).join(`,`)]);return(0,j.useCallback)(e=>{let t=H(e),n=s.get(t);if(n)return n;let r=B.get(t);return{state:`idle`,...r?{status:r}:{},...V.has(t)?{conflicting:!0}:{}}},[s])}function Da(e,t,n=!0){return y({queryKey:U.githubComments(e,t),queryFn:({signal:n})=>re(e,t,{},{signal:n}),enabled:n,staleTime:6e4})}function Oa(e,t,n=!0){return y({queryKey:U.githubItem(e,t),queryFn:({signal:n})=>Le(e,t,{},{signal:n}),enabled:n,staleTime:6e4})}function ka(e){return y({queryKey:U.githubPrChanges(e??0),queryFn:({signal:t})=>Pe(e,{},{signal:t}),enabled:e!==void 0,staleTime:6e4,retry:!1})}export{li as $,Hn as $t,Ai as A,xr as At,fi as B,gr as Bt,ji as C,yr as Ct,Ui as D,Fr as Dt,Fi as E,wr as Et,hi as F,Ar as Ft,Si as G,W as Gt,wi as H,G as Ht,bi as I,Kr as It,ki as J,Jn as Jt,Ti as K,Xn as Kt,Di as L,Gr as Lt,ni as M,Mr as Mt,pi as N,Pr as Nt,Wi as O,Tr as Ot,mi as P,Er as Pt,gi as Q,z as Qt,ai as R,vr as Rt,Gi as S,Sr as St,Pi as T,br as Tt,xi as U,pr as Ut,Ci as V,mr as Vt,ei as W,U as Wt,ui as X,Gn as Xt,si as Y,Un as Yt,_i as Z,Vn as Zt,Ii as _,Cr as _t,Da as a,I as an,ri as at,Ri as b,Ur as bt,ka as c,Qt as cn,Qr as ct,_a as d,N as dn,qr as dt,qn as en,di as et,Sa as f,M as fn,Br as ft,Hi as g,kr as gt,Vi as h,Vr as ht,ga as i,En as in,ii as it,Li as j,Ir as jt,Bi as k,jr as kt,ya as l,P as ln,Q as lt,oa as m,Gt as mn,Nr as mt,da as n,Wn as nn,oi as nt,Oa as o,tn as on,Ei as ot,Ea as p,Kt as pn,Rr as pt,ci as q,Qn as qt,va as r,Bn as rn,ti as rt,ma as s,$t as sn,yi as st,Ca as t,Kn as tn,vi as tt,ha as u,F as un,Lr as ut,Mi as v,Hr as vt,Ni as w,zr as wt,Ki as x,Wr as xt,zi as y,q as yt,Oi as z,hr as zt};
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t}from"./react-runtime-CCIEwYL0.js";import{d as n,p as r}from"./dist-C_rn70hE.js";import{$ as i,$t as a,A as o,Ai as s,Bn as c,C as l,Ct as u,D as d,Di as f,Dt as p,E as m,Et as h,F as g,Fi as _,G as v,Hn as ee,Ht as te,It as ne,J as re,Jt as ie,K as ae,Kt as oe,L as se,Mi as ce,Mt as le,N as ue,Nt as de,O as fe,Ot as pe,Pi as me,Pt as he,Q as ge,Qt as _e,Ri as ve,Rn as ye,S as be,Si as xe,Sn as Se,St as Ce,Ti as we,Tr as Te,Un as Ee,Ur as De,Vn as Oe,Vr as ke,Vt as Ae,Wn as je,Wr as Me,Wt as Ne,X as Pe,Xr as Fe,Xt as Ie,Y as Le,Yr as Re,Yt as ze,Zt as Be,_n as Ve,_t as He,a as Ue,an as We,b as Ge,bn as Ke,br as qe,bt as Je,ci as Ye,cn as Xe,ct as Ze,di as Qe,en as $e,et,fi as tt,fn as nt,gn as rt,gt as it,h as at,hi as ot,hn as st,ii as ct,in as lt,k as ut,kt as dt,li as ft,ln as pt,m as mt,mi as ht,mn as gt,n as _t,nn as vt,oi as yt,on as bt,pi as xt,pn as St,pt as Ct,q as wt,qt as Tt,si as y,sn as Et,tn as Dt,ui as Ot,v as kt,vi as b,vt as At,wt as jt,x as Mt,xi as Nt,xn as Pt,xt as Ft,y as It,yi as Lt,yn as Rt,yt as zt,zn as Bt}from"./toaster-Cjr2jC1Q.js";import{A as Vt,B as x,F as S,H as C,I as w,N as T,P as E,W as D,Z as O,a as Ht,j as k,z as A}from"./live-protocol-DMhTnCmf.js";function Ut(e,t){return e??t}function Wt(e,t){let n=Ut(e,t);return n===`1`||n===`true`}function Gt(e,t,n){return e?.trim()||Ut(t,n)||``}var Kt=class extends Nt{#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||qt(),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=xe({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),O.batch(()=>{this.#t.forEach(t=>{t.onMutationUpdate(e)}),this.#n.notify({mutation:this,type:`updated`,action:e})})}};function qt(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:`idle`,variables:void 0,submittedAt:0}}var Jt=class extends ve{#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),me(this.options,t)||this.#e.getMutationCache().notify({type:`observerOptionsUpdated`,mutation:this.#n,observer:this}),t?.mutationKey&&this.options.mutationKey&&we(t.mutationKey)!==we(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??qt();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){O.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 Yt(e,t){let n=new Set(t);return e.filter(e=>!n.has(e))}function Xt(e,t,n){let r=e.slice(0);return r[t]=n,r}var Zt=class extends ve{#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,O.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||!me(e,n)});!o&&!s||(o&&(this.#l=t,this.#i=n),this.#t=r,this.hasListeners()&&(o&&(Yt(e,n).forEach(e=>{e.destroy()}),Yt(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=ce(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 Lt(this.#e,r);n.push({defaultedQueryOptions:r,observer:i})}),n}#m(e,t){let n=this.#i.indexOf(e);n!==-1&&(this.#t=Xt(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)&&O.batch(()=>{this.listeners.forEach(e=>{e(this.#t)})})}}},j=e(t(),1);function M({queries:e,...t},n){let r=b(n),i=ot(),a=ht(),o=j.useMemo(()=>e.map(e=>{let t=r.defaultQueryOptions(e);return t._optimisticResults=i?`isRestoring`:`optimistic`,t}),[e,r,i]);o.forEach(e=>{Ye(e);let t=r.getQueryCache().get(e.queryHash);Qe(e,a,t)}),xt(a);let[c]=j.useState(()=>new Zt(r,o,t)),[l,u,d]=c.getOptimisticResult(o,t.combine),f=!i&&t.subscribed!==!1;j.useSyncExternalStore(j.useCallback(e=>f?c.subscribe(O.batchCalls(e)):s,[c,f]),()=>c.getCurrentResult(),()=>c.getCurrentResult()),j.useEffect(()=>{c.setQueries(o,t)},[o,t,c]);let p=l.some((e,t)=>Ot(o[t],e))?l.flatMap((e,t)=>{let n=o[t];return n&&Ot(n,e)?ft(n,new Lt(r,n),a):[]}):[];if(p.length>0)throw Promise.all(p);let m=l.find((e,t)=>{let n=o[t];return n&&tt({result:e,errorResetBoundary:a,throwOnError:n.throwOnError,query:r.getQueryCache().get(n.queryHash),suspense:n.suspense})});if(m?.error)throw m.error;return u(d())}function N(e,t){let n=b(t),[r]=j.useState(()=>new Jt(n,e));j.useEffect(()=>{r.setOptions(e)},[r,e]);let i=j.useSyncExternalStore(j.useCallback(e=>r.subscribe(O.batchCalls(e)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),a=j.useCallback((e,t)=>{r.mutate(e,t).catch(s)},[r]);if(i.error&&_(r.options.throwOnError,[i.error]))throw i.error;return{...i,mutate:a,mutateAsync:i.mutate}}function P(e={}){let t=e.projectId??r();return{projectId:t,cacheScope:e.cacheScope??(e.boot?`default`:t)}}function F(e,t={}){return{...P(t),runId:e}}function Qt(e,t=!0,n=!1,r){return y({queryKey:[P({projectId:e,boot:n}).cacheScope,`runs`,`list`],queryFn:({signal:t})=>de(P({projectId:e,boot:n}),{signal:t}),enabled:t,...r?{select:r}:{},placeholderData:(t,r)=>n&&r?.queryKey[0]===e?t:void 0})}function I(e,t,n=`active`){return e.invalidateQueries({queryKey:t===void 0?[`workspace`,`models`]:W.models(t),refetchType:n})}function $t(e,t=!0,n){return y({...en(e,n),enabled:t})}var en=(e,t)=>({queryKey:W.models(e,t),queryFn:({signal:n})=>je(e,{signal:n},t),staleTime:300*1e3});function tn(e,t=!0){let n=M({queries:e.map(e=>({...en(e),enabled:t}))});return Object.fromEntries(e.map((e,t)=>[e,n[t]]))}function nn(e,t){return JSON.stringify([e,t])}function rn(e){return e.type===`run`?e.run.id:e.id}function L(e,t){return{...e,runs:t}}function an(e,t){let n=0;for(let r of e)r.projectId===t&&r.archived&&(n+=1);return n}var on=class{runs;copied=!1;positions=new Map;constructor(e){this.runs=e,this.reindex()}reindex(){this.positions.clear(),this.runs.forEach((e,t)=>this.positions.set(nn(e.projectId,e.id),t))}at(e,t){return this.positions.get(nn(e,t))??-1}mutable(){return this.copied||=(this.runs=[...this.runs],!0),this.runs}replace(e,t){return this.mutable()[e]=t,this.runs}remove(e){return this.mutable().splice(e,1),this.reindex(),this.runs}insert(e){let t=this.runs.findIndex(t=>(t.createdAt??``).localeCompare(e.createdAt)<0);return this.mutable().splice(t<0?this.runs.length:t,0,e),this.reindex(),this.runs}};function sn(e,t,n){let r=new on(e.runs),i=e,a=!1;for(let e of t)if(e.type===`usage`)i=pn(i,e.project,e.usage,r);else{let t=un(i,e.change,n,r);i=t.index,a||=t.reconcile}return{index:i,reconcile:a}}function cn(e,t,n){return n?n.has(t):e.runs.some(e=>e.projectId===t)}function ln(e,t,n){return un(e,t,n,new on(e.runs))}function un(e,t,n,r){let{project:i}=t,a=r.at(i,rn(t)),o=a>=0?e.runs[a]:void 0,s=e.truncated.includes(i);if(t.type===`deleted`)return o?{index:L(e,r.remove(a)),reconcile:s&&o.archived}:{index:e,reconcile:!1};let{run:c}=t;if(c.delegation?.role===`worker`)return o?{index:L(e,r.remove(a)),reconcile:!1}:{index:e,reconcile:!1};if(!o&&!cn(e,i,n))return{index:e,reconcile:!0};let l=ce(o,{projectId:i,...c});if(o){if(l===o)return{index:e,reconcile:!1};let t=r.replace(a,l),n=o.archived!==l.archived&&(s||an(t,i)>e.perProjectLimit);return{index:L(e,t),reconcile:n}}if(s)return fn(e,l,r);let u=r.insert(l);return{index:L(e,u),reconcile:l.archived&&an(u,i)>e.perProjectLimit}}function dn(e,t){let n;for(let r of e)r.projectId===t&&r.archived&&(n===void 0||r.createdAt<n)&&(n=r.createdAt);return n}function fn(e,t,n){let r=dn(e.runs,t.projectId),i=r!==void 0&&t.createdAt>r;return t.archived&&!i?{index:e,reconcile:!1}:{index:L(e,n.insert(t)),reconcile:t.archived||r===void 0||t.createdAt<r}}function pn(e,t,n,r){let i=!1;return e.runs.forEach((e,a)=>{if(e.projectId!==t)return;let o=n[e.id];if(o){let t=ce(e.usage,o);if(t===e.usage)return;r.replace(a,{...e,usage:t})}else{if(e.usage===void 0)return;let{usage:t,...n}=e;r.replace(a,n)}i=!0}),i?L(e,r.runs):e}function mn(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 hn(){return{stream:void 0,lastStream:void 0,mismatch:void 0,floor:void 0,changes:new Map}}function gn(e,t,n){if(e.lastStream===t)e.floor=Math.max(e.floor??n,n);else{for(let[n,r]of e.changes)r.generation!==t&&e.changes.delete(n);e.floor=n}e.stream=t,e.lastStream=t,e.mismatch=void 0}function _n(e){e.stream=void 0}function vn(e,t,n=!1){let r=e.stream;if(r===void 0)return!1;(e.floor===void 0||n)&&(e.floor=t.seq-1);let i=JSON.stringify([r,t.project,rn(t)]),a=e.changes.get(i);return(!a||a.seq<t.seq)&&e.changes.set(i,{...t,generation:r}),!0}function yn(e,t){for(let[n,r]of e.changes)r.project===t&&e.changes.delete(n)}function bn(e){return typeof e.generation==`string`&&typeof e.eventSeq==`number`}function xn(e,t,n){if(!bn(t))return{index:t,reconcile:!1};let{generation:r,eventSeq:i}=t;if(e.stream!==void 0&&e.stream!==r){let n=e.mismatch!==r;return e.mismatch=r,{index:t,reconcile:n}}let a=e.lastStream===r&&e.floor!==void 0,o=a&&i<e.floor,s=t,c=o,l=[...e.changes.entries()].filter(([,e])=>e.generation===r),u=l.map(([,e])=>e).filter(e=>e.seq>i).sort((e,t)=>e.seq-t.seq);for(let e of u){let t=ln(s,e,n);s=t.index,c||=t.reconcile}for(let[t,n]of l)n.seq<=i&&e.changes.delete(t);return a&&!o&&(e.floor=i),{index:s,reconcile:c}}var R=[`workspace`,`runs-index`],Sn=[`workspace`,`projects`],Cn=6e4,wn=100,Tn=new WeakMap;function En(e){let t=Tn.get(e);return t||(t=jn(e),Tn.set(e,t)),t}function Dn(e,t){return typeof e!=`object`||!e||!Array.isArray(e.runs)?e:En(t).merge(e)}function On(e){let t=e.getQueryData(Sn)?.projects;return t?new Set(t.map(e=>e.id)):void 0}function kn(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 An(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 jn(e){let t=hn(),n=[],r,i,a,o,s=!1,c=-1/0,l=new Set,u=!1,d,f=!1,p=()=>{if(!u){if(u=!0,d?.()){f=!0;return}_({hold:!0})}},m=t=>{c=Date.now(),e.setQueryData(R,t)},h=()=>e.getQueryData(R),g=()=>{clearTimeout(a),a=void 0;let t=e.getQueryCache().find({queryKey:R,exact:!0}),n=(t!==void 0&&t.state.data===void 0&&t.state.fetchStatus!==`idle`?e.cancelQueries({queryKey:R,exact:!0}).then(()=>e.invalidateQueries({queryKey:R})):e.invalidateQueries({queryKey:R})).catch(()=>void 0).finally(()=>{o===n&&(o=void 0,s&&(s=!1,g()))});return o=n,n},_=(e={})=>o?(s=!0,o):e.hold?(a??=setTimeout(()=>{g()},400),Promise.resolve()):g(),v=()=>{r!==void 0&&typeof cancelAnimationFrame==`function`&&cancelAnimationFrame(r),r=void 0,clearTimeout(i),i=void 0;let t=n;n=[];let a=h();if(!a||t.length===0)return;let o=On(e),{index:s,reconcile:c}=sn(a,t.filter(e=>e.generation===a.generation?e.type===`usage`?!l.has(e.project):!l.has(e.change.project)&&e.change.seq>a.eventSeq:!1),o);s!==a&&m(s),c&&_({hold:!0})},ee=()=>{if(i!==void 0)return;let e=c+250-Date.now();if(e>0){i=setTimeout(v,e);return}i=setTimeout(v,wn),typeof requestAnimationFrame==`function`&&(r=requestAnimationFrame(v))};return{ready(e,n){gn(t,e,n),u=!1,f&&(f=!1,_({hold:!0}))},detach(){_n(t)},run(e,r,i=!1){if(l.has(e))return;let a=An(e,r);if(!vn(t,a,i)){p();return}n.push({type:`change`,change:a,generation:t.stream}),ee()},usage(e,r){if(!l.has(e)){if(t.stream===void 0){p();return}n.push({type:`usage`,project:e,usage:r,generation:t.stream}),ee()}},dropProject(e){l.add(e),yn(t,e),n=n.filter(t=>(t.type===`change`?t.change.project:t.project)!==e);let r=h();if(!r)return;let i=mn(r,e);i!==r&&m(i)},setUnknownGenerationHandler(e){d=e},restoreProject(e){l.delete(e)},merge(n){let r=h(),i=xn(t,n,On(e));for(let e of l)i.index=mn(i.index,e);return i.reconcile&&queueMicrotask(()=>{_({hold:!0})}),kn(r,n,t.stream)??i.index},reconcile:_,flush:v,stop(){r!==void 0&&typeof cancelAnimationFrame==`function`&&cancelAnimationFrame(r),r=void 0,clearTimeout(i),i=void 0,clearTimeout(a),a=void 0,n=[],s=!1}}}var Mn=k([`own`,`provider-spanning`]),Nn=x({suggested:T(x({id:D(),label:D(),desc:D()})),retired:T(D())}),Pn=x({id:k([`settings`,`mcp`,`memory`]),label:D(),note:D().optional(),empty:D().optional(),showsUserMcp:w(!0).optional()}),Fn=x({label:D(),note:D().optional(),groups:T(Pn)}),In=x({runners:T(x({id:ct,displayName:D(),modelListName:D(),modelIdScope:Mn,pickerLabel:D(),pickerDescription:D(),icon:D(),installHint:D(),loginCommand:D(),terminalLogin:E().optional(),browserLogin:E().optional(),managedInstall:w(!0).optional(),accountFolderExample:D().optional(),models:Nn,agentConfig:Fn}))}),Ln=[`workspace`,`runners`];async function Rn(e){return Ee(await Bt.api.v1.runners.$get({},c(e)),`/runners`,In)}var zn={queryKey:Ln,queryFn:({signal:e})=>Rn({signal:e}),staleTime:1/0};function Bn(){return y(zn)}function Vn(e){return e?.runners??[]}function Hn(e){return Vn(e).map(e=>e.id)}function Un(e,t){if(e!==void 0)return t.includes(e)?e:t[0]}function Wn(e){let t=Bn();return{runner:t.isSuccess?Un(e,Hn(t.data))??e:e,ready:!t.isPending}}function z(e,t){return e?.runners.find(e=>e.id===t)}function Gn(e,t){return z(e,t)?.displayName??t}function Kn(e,t){return z(e,t)?.pickerLabel??t}function qn(e,t){return z(e,t)?.modelListName}function Jn(e,t,n=!0){let i=Ii(),a=q(),{runner:o,ready:s}=Wn(e??i.data?.defaultRunner??`claude`),c=a.data?.capabilities?.localHandoff===!1?null:t,l=r(),u=y({queryKey:U.runnerSkills(o,c),queryFn:({signal:e})=>m(o,c,{signal:e,projectId:l}),enabled:n&&s&&(e!==void 0||!i.isPending)&&(!t||!a.isPending),retry:!1});return{...u,runner:o,account:c,data:u.data?.skills,list:u.data,unchecked:u.isError||!u.data||u.data.source===`unavailable`}}var Yn={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`}},Xn={label:`Merge conflicts`,hint:`this branch no longer merges cleanly into its base — rebase or merge the base in`,tone:`conflict`};function Zn(e){return typeof e==`string`&&Object.hasOwn(Yn,e)}function Qn(e){return e!==void 0&&Zn(e)?Yn[e]:void 0}var $n=`cez.reference-statuses.v1`,er=`cez.reference-conflicts.v1`,B=new Map(ir()),tr=1e3;function nr(e,t){if(B.get(e)!==t){for(B.delete(e),B.set(e,t);B.size>tr;){let e=B.keys().next().value;if(e===void 0)break;B.delete(e)}sr()}}var V=new Set(ar());function rr(e,t){if(V.has(e)!==t){if(t)for(V.add(e);V.size>tr;){let e=V.values().next().value;if(e===void 0)break;V.delete(e)}else V.delete(e);sr()}}function ir(){try{let e=globalThis.sessionStorage?.getItem($n);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`&&Zn(e[1])):[]}catch{return[]}}function ar(){try{let e=globalThis.sessionStorage?.getItem(er);if(!e)return[];let t=JSON.parse(e);return Array.isArray(t)?t.filter(e=>typeof e==`string`):[]}catch{return[]}}var or;function sr(){or===void 0&&(or=setTimeout(()=>{or=void 0;try{globalThis.sessionStorage?.setItem($n,JSON.stringify([...B])),globalThis.sessionStorage?.setItem(er,JSON.stringify([...V]))}catch{}},250))}var H=e=>`${e.projectId}\u0000${e.kind}#${e.number}`;function cr(e,t){return{...e?{status:e}:{},...t?{conflicting:!0}:{}}}function lr(e){return[...e.prs.map(t=>({projectId:e.projectId,kind:`PR`,number:t})),...e.issues.map(t=>({projectId:e.projectId,kind:`Issue`,number:t}))]}function ur(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;nr(t,o),s!==void 0&&rr(t,s),e.set(t,{state:`ready`,status:o,...s??a?{conflicting:!0}:{}})}function dr(e,t,n){let r=H(t),i=B.get(r),a=V.has(r)?!0:void 0,o=n.data;if(o?.available){ur(e,r,t,o,i,a);return}if(o){e.set(r,{state:`unavailable`,reason:o.reason,...cr(i,a)});return}if(n.isError){e.set(r,{state:`unavailable`,reason:n.error instanceof Error?n.error.message:void 0,...cr(i,a)});return}e.set(r,{state:`loading`,...cr(i,a)})}function fr(e,t){let n=new Map;return t.forEach((t,r)=>{let i=e[r];if(i)for(let e of lr(i))dr(n,e,t)}),n}var U={get health(){return[r(),`health`]},runs:{get all(){return[r(),`runs`]},relationships:e=>[r(),`runs`,`relationships`,e],list:(e=r())=>[e,`runs`,`list`],archived:e=>[r(),`runs`,`archived`,e],detail:(e,t=r())=>[t,`runs`,`detail`,e],diff:e=>[r(),`runs`,`diff`,e],changes:e=>[r(),`runs`,`changes`,e],file:(e,t)=>[r(),`runs`,`files`,e,t],handoff:e=>[r(),`runs`,`handoff`,e],commits:e=>[r(),`runs`,`commits`,e],commit:(e,t)=>[r(),`runs`,`commit`,e,t]},get workflows(){return[r(),`workflows`]},runnerSkills:(e,t)=>[r(),`runner-skills`,e,t??null],get repo(){return[r(),`repo`]},get repoChanges(){return[r(),`repo`,`changes`]},repoCommit:e=>[r(),`repo`,`commit`,e],get repoBranches(){return[r(),`repo`,`branches`]},get uiState(){return[r(),`ui-state`]},get config(){return[r(),`config`]},get agentConfig(){return[r(),`agent-config`]},agentConfigFile:e=>[r(),`agent-config`,`file`,e],get sessionContext(){return[r(),`session-context`]},sessionContextPreview:(e,t,n=``)=>[r(),`session-context`,`preview`,t,e,n],get worktrees(){return[r(),`worktrees`]},github:(e={})=>[r(),`github`,e.limit??null],githubPages:e=>[r(),`github`,`pages`,e],githubPagesHead:e=>[r(),`github`,`pages-head`,e],githubCommentCounts:(e,t)=>[r(),`github`,`comment-counts`,e,[...t].sort((e,t)=>e-t).join(`,`)],githubChecks:e=>[r(),`github`,`checks`,[...e].sort((e,t)=>e-t).join(`,`)],githubSearch:(e,t)=>[r(),`github`,`search`,e,t],githubRefStatus:(e,t,n)=>[e,`github`,`ref-status`,[...t].sort((e,t)=>e-t).join(`,`),[...n].sort((e,t)=>e-t).join(`,`)],githubComments:(e,t)=>[r(),`github`,`comments`,e,t],githubItem:(e,t)=>[r(),`github`,`item`,e,t],githubRefStatusOf:e=>[e,`github`,`ref-status`],githubPrChanges:e=>[r(),`github`,`pr-changes`,e],githubMergeState:e=>[r(),`github`,`merge-state`,e],get openTargets(){return[r(),`open-targets`]}},W={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:R,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)=>[...W.fsBrowseRoot,e,t]};function pr(){return Wt(void 0,void 0)}function G(e){return!pr()&&e}function mr(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 hr(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 gr(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 _r(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 vr(e,t){return Fe({kind:`topic`,topic:e},{value:t})}function yr(){let e=b();return y({queryKey:W.providerStatus,queryFn:async({signal:t})=>{let n=e.getQueryData(W.providerStatus),r=await Et(!1,{signal:t});return Te(n,e.getQueryData(W.providerStatus),r)},staleTime:5*6e4,refetchInterval:G(!1),refetchOnWindowFocus:!0})}function br(){let e=b();return N({mutationFn:()=>Et(!0),onMutate:()=>e.getQueryData(W.providerStatus),onSuccess:(t,n,r)=>{e.setQueryData(W.providerStatus,e=>Te(r,e,t)),I(e)}})}function xr(){let e=b();return N({mutationFn:({provider:e,authFailureId:t})=>rt(e,t),onMutate:()=>e.getQueryData(W.providerStatus),onSuccess:(t,n,r)=>{e.setQueryData(W.providerStatus,e=>Te(r,e,t,n.authFailureId)),I(e,n.provider)}})}function Sr(e={}){return y({queryKey:W.projects,queryFn:({signal:e})=>bt({signal:e}),...e})}function Cr(e,t=!1){return y({queryKey:W.fsBrowse(e,t),queryFn:({signal:n})=>ze(e??void 0,{signal:n,showHidden:t}),retry:!1})}function wr(){let e=b();return N({mutationFn:e=>nt(e),onSuccess:()=>e.invalidateQueries({queryKey:W.projects})})}function Tr(){let e=b();return N({mutationFn:e=>gt(e),retry:!1,onSuccess:()=>{e.invalidateQueries({queryKey:W.projects})}})}function Er(){let e=b();return N({mutationFn:e=>{let{id:t,...n}=e;return Pt(t,n)},retry:!1,onMutate:async({id:t,...n})=>{await e.cancelQueries({queryKey:W.projects});let r=e.getQueryData(W.projects);return e.setQueryData(W.projects,e=>e===void 0?e:{...e,projects:e.projects.map(e=>e.id===t?Dr(e,n):e)}),{previous:r}},onError:(t,n,r)=>{r?.previous&&e.setQueryData(W.projects,r.previous)},onSuccess:({project:t})=>{e.setQueryData(W.projects,e=>e===void 0?e:{...e,projects:e.projects.map(e=>e.id===t.id?t:e)})},onSettled:()=>e.invalidateQueries({queryKey:W.projects})})}function Dr(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?[]:_r(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 Or(e){let t=b();return N({mutationFn:e,retry:!1,onSuccess:({project:e})=>{t.setQueryData(W.projects,t=>t===void 0?t:{...t,projects:t.projects.map(t=>t.id===e.id?e:t)})},onSettled:()=>t.invalidateQueries({queryKey:W.projects})})}function kr(){return Or(e=>{let{projectId:t,...n}=e;return $e(t,n)})}function Ar(){return Or(e=>{let{projectId:t,webhookId:n,...r}=e;return Se(t,n,r)})}function jr(){return Or(({projectId:e,webhookId:t})=>st(e,t))}function Mr(){return N({mutationFn:({projectId:e,webhookId:t})=>Rt(e,t),retry:!1})}function K(e){let t=b();return N({mutationFn:e,retry:!1,onSuccess:async()=>{await Promise.all([t.invalidateQueries({queryKey:W.agentProfiles}),t.invalidateQueries({queryKey:W.projects}),t.invalidateQueries({predicate:({queryKey:e})=>e[1]===`runner-skills`}),I(t)])},onError:()=>{t.invalidateQueries({queryKey:U.health}),t.invalidateQueries({queryKey:W.agentProfiles,exact:!0})}})}function Nr(){return K(e=>_e(e))}function Pr(){return K(e=>{let{id:t,...n}=e;return Ke(t,n)})}function Fr(){return K(e=>St(e))}function Ir(){return K(e=>Ve(e))}function Lr(e,t){return y({queryKey:W.agentAccountStatus(e),queryFn:({signal:t})=>Dt(e,{signal:t}),enabled:t,staleTime:6e4,retry:!1})}function Rr(){let e=b();return N({mutationFn:({provider:e,profileId:t})=>Be(e,t),retry:!1,onSuccess:async(t,{provider:n})=>{await Promise.all([e.invalidateQueries({queryKey:W.agentProfiles}),e.invalidateQueries({queryKey:W.providerStatus}),I(e,n,`none`)])},onError:()=>{e.invalidateQueries({queryKey:U.health}),e.invalidateQueries({queryKey:W.agentProfiles,exact:!0})}})}function zr(){let e=b();return N({mutationFn:e=>Dt(e,{refresh:!0}),retry:!1,onSuccess:(t,n)=>{e.setQueryData(W.agentAccountStatus(n),t),e.invalidateQueries({queryKey:W.agentProfiles}),I(e,t.status.provider)}})}function Br(){let e=b();return N({mutationFn:e=>Ie(e),retry:!1,onSuccess:()=>e.invalidateQueries({queryKey:W.projects})})}function Vr(){let e=b();return N({mutationFn:e=>a(e),retry:!1,onSuccess:()=>e.invalidateQueries({queryKey:W.projects})})}function Hr({enabled:e}){return y({queryKey:W.githubOwners,queryFn:({signal:e})=>lt({signal:e}),enabled:e,staleTime:6e4,retry:!1})}function Ur(){let e=b();(0,j.useEffect)(()=>{let t,r=()=>{let r=e.getQueryData(U.health);r&&(De({bootProject:r.bootProject??`default`,apiBase:n()}),t??=vr(`health`,t=>{e.setQueryData(U.health,t)}))};r();let i=e.getQueryCache().subscribe(r);return()=>{i(),t?.(),Re()}},[e])}function q(){return y({queryKey:U.health,queryFn:({signal:e})=>We({signal:e})})}function Wr(e,t){let n=q().data,r=Sr(t).data?.projects,i=Ue(),a=e??i.projectId,o=a??n?.bootProject,s=o===void 0?void 0:r?.find(e=>e.id===o);return s?.repoUrl?s.repoUrl:a===null||a===n?.bootProject?mr(n?.repo?.remote):void 0}function Gr(){return y({queryKey:W.uiState,queryFn:({signal:e})=>pt({signal:e})})}function Kr(){return y({queryKey:W.config,queryFn:({signal:e})=>Xe({signal:e})})}function qr(){return y({queryKey:W.agentProfiles,queryFn:({signal:e})=>vt({signal:e})})}var J=[`workspace`,`runs-index`],Y=e=>[e.cacheScope,`runs`,`list`],X=e=>[e.cacheScope,`runs`,`detail`,e.runId],Z=e=>typeof e==`function`?e():e;function Jr(e){let{seenAt:t,...n}=e;return n}function Yr(e,t){let n=Jr(e);return t.seenAt===void 0?n:{...n,seenAt:t.seenAt}}function Xr(e,t,n){return t?{...e,seenAt:n}:Jr(e)}function Zr(e){let t=()=>{e.invalidateQueries({queryKey:J})};function n(n,i){if(n===`index`)return t();let a=typeof i==`function`?i():i;if(n===`indexed`){t(),e.invalidateQueries({queryKey:[r(),`runs`]}),e.invalidateQueries({queryKey:[a.projectId,`runs`,`list`]});return}if(n===`runs`)return e.invalidateQueries({queryKey:[a.cacheScope,`runs`]});let o=Me(),s=[a.projectId,a.cacheScope],c=o!==void 0&&s.some(e=>e===o||e==="default")?[o,`default`]:[],l=new Set([...s,...c,r()]);return Promise.all([...l].map(t=>e.invalidateQueries({queryKey:[t,`runs`]}))).then(()=>void 0)}async function i(n,r){await e.cancelQueries({queryKey:Y(Z(n))}),await e.cancelQueries({queryKey:X(Z(n))});let i=e.getQueryData(Y(Z(n))),a=e.getQueryData(X(Z(n))),o=Z(n).runId,s=new Date().toISOString();return e.setQueryData(Y(Z(n)),e=>e?.map(e=>e.id===o?Xr(e,r,s):e)),e.setQueryData(X(Z(n)),e=>e&&Xr(e,r,s)),{id:o,prevList:i,prevDetail:a,rollback(){if(!r){i&&e.setQueryData(Y(Z(n)),i),a&&e.setQueryData(X(Z(n)),a);return}let t=i?.find(e=>e.id===o);t&&e.setQueryData(Y(Z(n)),e=>e?.map(e=>e.id===o?Yr(e,t):e)),a&&e.setQueryData(X(Z(n)),e=>e&&Yr(e,a))},settle(i){let a=e=>e.id===(r?o:i.id)?Xr(e,r,i.seenAt):e;e.setQueryData(Y(Z(n)),e=>e?.map(a));let s={...Z(n),runId:r?o:i.id};e.setQueryData(X(s),e=>e?a(e):i),t()}}}async function a(t,r){await e.cancelQueries({queryKey:J});let i=e.getQueryData(J),a=r();return e.setQueryData(J,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(J,i)},settle(){n(`indexed`,t)}}}return{patchRead:i,patchIndex:a,invalidateAfter:n}}function Q(){let e=b();return(0,j.useMemo)(()=>Zr(e),[e])}function Qr(e,t){if(!Ht(e.path))throw Error(`unsupported shared read`);let n=new URL(e.path,`http://cezar.invalid`);return n.searchParams.sort(),Fe({kind:`read`,path:`${n.pathname}${n.search}`,intervalMs:e.intervalMs},{value:t})}function $(e,t,n,r){let i=b(),a=JSON.stringify(t),o=(0,j.useMemo)(()=>JSON.parse(a),[a]);(0,j.useEffect)(()=>{if(!e||n===!1)return;let t=!0,a=Qr({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 $r(e,t=!1){return ee(await Bt.api.v1.p[`:projectId`].runs[`:id`][`worker-destroy`].$post({param:{projectId:r(),id:encodeURIComponent(e)},query:{},json:t?{discardWork:!0}:{}}),Oe(e,`/worker-destroy`))}function ei(){return y({queryKey:U.openTargets,queryFn:({signal:e})=>Ft({signal:e}),staleTime:5*6e4})}function ti(){return y({queryKey:U.runs.list(),queryFn:({signal:e})=>de(P(),{signal:e})})}function ni(e,t){return yt({queryKey:U.runs.archived(e),enabled:t,initialPageParam:void 0,queryFn:({pageParam:t,signal:n})=>it({before:t,limit:200,q:e},{signal:n}),getNextPageParam:e=>e.nextCursor??void 0,placeholderData:(e,t)=>t?.queryKey[0]===r()?e:void 0})}function ri(e){let t=e.trim();return y({queryKey:W.runsSearch(t),queryFn:({signal:e})=>oe(t,{signal:e}),enabled:t.length>=2,placeholderData:f,staleTime:1e4})}function ii(e=!0,t=Cn,n){let r=En(b());return $(`/api/v1/workspace/runs-index`,W.runsIndex,G(e?t:!1),Dn),y({queryKey:W.runsIndex,queryFn:({signal:e})=>he({signal:e}).then(r.merge),enabled:e,...n?{select:n}:{},staleTime:3e4,refetchInterval:!1})}function ai(e){let t=b();return N({mutationFn:({workerId:e,discardWork:t=!1})=>$r(e,t),onSettled:()=>t.invalidateQueries({queryKey:U.runs.relationships(e)})})}function oi(e,t={}){return y({queryKey:U.runs.relationships(e),queryFn:({signal:t})=>le(e,{signal:t}),enabled:t.enabled??!0})}function si(e){return y({queryKey:U.runs.detail(e??``),queryFn:({signal:t})=>Ce(F(e),{signal:t}),enabled:!!e})}function ci(e,t,n=!0,r){return y({queryKey:[e??`default`,`runs`,`detail`,t??``],queryFn:({signal:n})=>Ce(F(t,{projectId:e}),{signal:n}),enabled:n&&!!e&&!!t,...r?.staleTime===void 0?{}:{staleTime:r.staleTime},...r?.refetchOnMount===void 0?{}:{refetchOnMount:r.refetchOnMount}})}function li(e,t){return y({queryKey:t?[t,`runs`,`diff`,e??``]:U.runs.diff(e??``),queryFn:({signal:n})=>p(e,{signal:n,...t?{projectId:t}:{}}),enabled:!!e})}function ui(e,t=!1){return $(e?`/api/v1/p/${r()}/runs/${encodeURIComponent(e)}/changes`:void 0,U.runs.changes(e??``),G(t?4e3:!1)),y({queryKey:U.runs.changes(e??``),queryFn:({signal:t})=>u(e,{signal:t}),enabled:!!e,retry:!1,refetchInterval:!1,refetchOnWindowFocus:!0,staleTime:0})}function di(e,t){return y({queryKey:U.runs.file(e??``,t??``),queryFn:({signal:n})=>pe(e,t,{signal:n}),enabled:!!e&&t!==void 0,retry:!1})}function fi(e,t){return y({queryKey:[r(),`runs`,`file-link`,e,t],queryFn:({signal:n})=>Je(e,t,{signal:n}),enabled:t!==null,retry:!1})}function pi(e,t){return y({queryKey:[r(),`runs`,`artifact`,e,t],queryFn:({signal:n})=>He(e,t,{signal:n}),enabled:t!==null,retry:!1})}function mi(e,t){return y({queryKey:[r(),`runs`,`artifact-metadata`,e,t],queryFn:({signal:n})=>At(e,t,{signal:n}),enabled:t!==null,retry:!1})}function hi(e){return y({queryKey:[r(),`runs`,`artifacts`,e],queryFn:({signal:t})=>zt(e,{signal:t}),retry:!1,staleTime:0,refetchOnWindowFocus:!0})}function gi(e,t=!1){return $(e?`/api/v1/p/${r()}/runs/${encodeURIComponent(e)}/commits`:void 0,U.runs.commits(e??``),G(t?5e3:!1)),y({queryKey:U.runs.commits(e??``),queryFn:({signal:t})=>h(e,{signal:t}),enabled:!!e,retry:!1,refetchInterval:!1})}function _i(e,t){return y({queryKey:U.runs.commit(e??``,t??``),queryFn:({signal:n})=>jt(e,t,{signal:n}),enabled:!!e&&!!t,retry:!1})}function vi(e,t=!0){return y({queryKey:U.runs.handoff(e??``),queryFn:({signal:t})=>dt(F(e),{signal:t}),enabled:!!e&&t})}function yi(e,t,n){return y({queryKey:e===void 0?U.runs.handoff(t):[e,`runs`,`handoff`,t],queryFn:({signal:n})=>dt(F(t,{projectId:e}),{signal:n}),enabled:n,staleTime:15e3})}function bi(e,t){let n=[...new Set(e)],i=M({queries:n.map(e=>({queryKey:[e??r(),`automations`,`names`],queryFn:({signal:t})=>kt({signal:t,archived:`include`,...e===void 0?{}:{projectId:e}}),enabled:t,staleTime:6e4,retry:!1}))}),a=i.map(e=>e.data);return(0,j.useMemo)(()=>{let e=new Map;return a.forEach((t,r)=>{if(t?.available)for(let i of t.automations)e.set(JSON.stringify([n[r]??null,i.id]),i.name)}),(t,n)=>e.get(JSON.stringify([t??null,n]))},[JSON.stringify([n,i.map(e=>e.dataUpdatedAt)])])}function xi(e){let t=b();return N({mutationFn:t=>ne(e,t),retry:!1,onSuccess:()=>t.invalidateQueries({queryKey:U.runs.all})})}function Si(e){let t=b();return N({mutationFn:t=>Ae(e,t),onSuccess:()=>t.invalidateQueries({queryKey:U.runs.all})})}function Ci(e){let t=Q(),n=e?.projectId,r=e?.cacheScope,i=N({mutationFn:e=>ie(e,!0),onMutate:e=>t.patchRead(e,!0),onError:(e,t,n)=>n?.rollback(),onSuccess:(e,t,n)=>n?.settle(e)}),a=(0,j.useCallback)(e=>({...F(e,{projectId:n,cacheScope:r}),id:e}),[n,r]),o=(0,j.useCallback)(e=>({onSuccess:(t,n,r,i)=>e?.onSuccess?.(t,n.id,r,i),onError:(t,n,r,i)=>e?.onError?.(t,n.id,r,i),onSettled:(t,n,r,i,a)=>e?.onSettled?.(t,n,r.id,i,a)}),[]),{mutate:s,mutateAsync:c}=i,l=(0,j.useCallback)((e,t)=>s(a(e),o(t)),[s,a,o]),u=(0,j.useCallback)((e,t)=>c(a(e),o(t)),[c,a,o]);return{...i,variables:i.variables?.id,mutate:l,mutateAsync:u}}function wi(){let e=Q();return N({mutationFn:e=>ie(F(e),!1),onMutate:t=>e.patchRead(()=>F(t),!1),onError:(e,t,n)=>n?.rollback(),onSuccess:(e,t,n)=>n?.settle(e)})}function Ti(e){let t=Q();return N({mutationFn:({id:t,pinned:n})=>te(F(t,e),n),onError:e=>_t(`Could not update pin. ${e.message} Please retry.`,{tone:`danger`}),onMutate:()=>e??P(),onSuccess:(e,n,r)=>t.invalidateAfter(`runs`,r)})}function Ei(e,t){let n=Q();return N({mutationFn:n=>Tt(F(e,{projectId:t}),n),onMutate:()=>P({projectId:t}),onSuccess:(e,t,r)=>n.invalidateAfter(`send`,r),onError:(e,t,r)=>{e instanceof ye&&e.status===409&&r&&n.invalidateAfter(`send`,r)}})}function Di(e,t){let n=Q();return N({mutationFn:(n={})=>Ze(F(e,{projectId:t}),n),onMutate:()=>P({projectId:t}),onSuccess:(e,t,r)=>n.invalidateAfter(`continue`,r)})}function Oi(e){let t=b();return N({mutationFn:({msgId:t,message:n})=>Ct(e,t,n),onSuccess:()=>t.invalidateQueries({queryKey:U.runs.all})})}function ki(e){let t=b();return N({mutationFn:t=>Ne(e,t),onSuccess:()=>t.invalidateQueries({queryKey:U.runs.all})})}function Ai(){return y({queryKey:U.workflows,queryFn:({signal:e})=>ut({signal:e})})}function ji(e){return y({queryKey:e?[e,`repo`]:U.repo,queryFn:({signal:t})=>Ge({signal:t},e)})}function Mi(e){return y({queryKey:[e,`repo`],queryFn:({signal:t})=>Ge({signal:t},e)})}function Ni(){return y({queryKey:U.repoBranches,queryFn:({signal:e})=>Mt({signal:e})})}function Pi(){return y({queryKey:U.repoChanges,queryFn:({signal:e})=>be({signal:e}),retry:!1})}function Fi(e){return y({queryKey:U.repoCommit(e??``),queryFn:({signal:t})=>l(e,{signal:t}),enabled:!!e,retry:!1})}function Ii(e){return y({queryKey:e?[e,`config`]:U.config,queryFn:({signal:t})=>It({signal:t,...e?{projectId:e}:{}})})}function Li(){return y({queryKey:U.worktrees,queryFn:({signal:e})=>o({signal:e})})}function Ri(e){return y({queryKey:[e,`worktrees`],queryFn:({signal:t})=>o({signal:t},e),staleTime:0})}function zi(e,t=!0,n=!1){return y({queryKey:[P({projectId:e,boot:n}).cacheScope,`ui-state`],queryFn:({signal:t})=>fe({signal:t},e),select:e=>e.sidebarLimits===void 0?e:{...e,sidebarLimits:ke(e.sidebarLimits)},enabled:t})}function Bi(){return zi(r())}function Vi(){return y({queryKey:U.agentConfig,queryFn:({signal:e})=>mt({signal:e})})}function Hi(e){return y({queryKey:U.agentConfigFile(e??``),queryFn:({signal:t})=>at(e,{signal:t}),enabled:e!==null})}function Ui(){return y({queryKey:U.sessionContext,queryFn:({signal:e})=>d({signal:e})})}function Wi(e,t,n=``){return y({queryKey:U.sessionContextPreview(e,t,n),queryFn:({signal:n})=>ue({content:e,role:t},{signal:n}),placeholderData:f,staleTime:0,retry:!1})}function Gi(){let e=b();return N({onMutate:()=>({fileKey:U.sessionContext}),mutationFn:e=>se(e),onSuccess:(t,n,r)=>{r&&e.setQueryData(r.fileKey,t)}})}function Ki(e){let t=b(),n=U.agentConfig,r=U.agentConfigFile(e);return N({mutationFn:t=>g(e,t),onSuccess:e=>{t.setQueryData(r,e),t.invalidateQueries({queryKey:n})}})}var qi=k([`passing`,`failing`,`pending`]).nullable(),Ji=x({kind:k([`issue`,`pr`]),number:A(),title:D(),author:D(),createdAt:D(),labels:T(D()),body:D().optional(),url:D(),comments:A(),assignees:T(D()).optional(),projectIds:T(D()).optional(),isDraft:E().optional(),additions:A().optional(),deletions:A().optional(),checks:qi.optional()});S(`available`,[x({available:w(!0),item:Ji.nullable(),labelColors:C(D(),D()).optional()}),x({available:w(!1),reason:D()})]),x({kind:k([`issue`,`pr`]),number:Vt().int().positive().safe()});var Yi=x({id:D(),title:D(),url:D()});x({available:E(),reason:D().optional(),repo:D().optional(),syncedAt:D().optional(),issues:T(Ji),prs:T(Ji),labelColors:C(D(),D()).optional(),viewerLogin:D().optional(),projects:T(Yi).optional(),projectsReason:D().optional(),projectsState:k([`refreshing`,`ready`,`unavailable`]).optional(),projectsGeneration:D().optional(),issuesTotal:A().int().nonnegative().optional(),prsTotal:A().int().nonnegative().optional(),issuesNextCursor:D().nullable().optional(),prsNextCursor:D().nullable().optional(),commentsDeferred:w(!0).optional()});var Xi=D().min(1).max(2e3).optional();x({limit:D().optional(),refresh:D().optional(),issuesCursor:Xi,prsCursor:Xi,issuesDone:w(`1`).optional(),prsDone:w(`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`})}),x({kind:k([`issue`,`pr`]),numbers:D().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:w(`1`).optional()}),S(`available`,[x({available:w(!0),counts:C(A(),A().int().nonnegative())}),x({available:w(!1),reason:D()})]),S(`available`,[x({available:w(!0),checks:C(A(),qi)}),x({available:w(!1),reason:D()})]),x({kind:k([`issue`,`pr`]),q:D().trim().min(1).max(256),limit:Vt().int().positive().max(50).optional()}),x({available:E(),projectsReason:D().optional(),reason:D().optional(),items:T(Ji),truncated:E().optional(),labelColors:C(D(),D()).optional()});var Zi=A().nullable();S(`available`,[x({available:w(!0),prs:C(A(),qe),issues:C(A(),qe),conflicts:T(A()).optional(),recheckAfterMs:Zi}),x({available:w(!1),reason:D(),recheckAfterMs:Zi})]);var Qi=x({id:A(),author:D(),avatarUrl:D().optional(),createdAt:D(),body:D(),kind:k([`comment`,`review`]),reviewState:k([`approved`,`changes_requested`,`commented`,`dismissed`]).optional(),url:D()}),$i=k([`committed`,`labeled`,`unlabeled`,`assigned`,`unassigned`,`merged`,`closed`,`reopened`,`head_ref_force_pushed`,`cross-referenced`,`renamed`]),ea=x({id:D(),kind:$i,actor:D(),avatarUrl:D().optional(),createdAt:D(),url:D().optional(),sha:D().optional(),message:D().optional(),checks:qi.optional(),label:x({name:D(),color:D().optional()}).optional(),subject:D().optional(),refNumber:A().optional(),refTitle:D().optional(),refIsPr:E().optional()});x({available:E(),reason:D().optional(),comments:T(Qi),truncated:E().optional(),events:T(ea).optional(),detail:x({body:D(),additions:A().int().nonnegative().optional(),deletions:A().int().nonnegative().optional()}).optional()});var ta=k([`merge`,`squash`,`rebase`]),na=x({name:D(),state:k([`passing`,`failing`,`pending`,`unknown`]),required:E().nullable(),url:D().optional()}),ra=x({number:A(),title:D(),url:D(),state:k([`open`,`closed`,`merged`]),isDraft:E(),headRef:D(),baseRef:D(),headSha:D(),mergeable:k([`mergeable`,`conflicting`,`unknown`]),reviewDecision:k([`approved`,`changes-requested`,`review-required`,`not-required`,`unknown`]),checks:T(na),methods:T(ta),defaultMethod:ta.nullable(),eligibility:k([`ready`,`blocked`,`pending`,`unauthorized`,`terminal`,`unknown`]),blockers:T(x({code:D(),message:D()})),canMerge:E(),canOverride:E()});S(`available`,[x({available:w(!0),mergeState:ra}),x({available:w(!1),reason:D()})]),x({merged:w(!0),number:A(),url:D(),method:ta,mergeCommitSha:D().optional()});var ia=x({path:D(),previousPath:D().optional(),status:k([`added`,`modified`,`removed`,`renamed`,`copied`,`changed`]),additions:A(),deletions:A(),patch:D().optional(),patchUnavailableReason:k([`binary`,`too-large`,`not-provided`]).optional(),truncated:E().optional()});S(`available`,[x({available:w(!0),number:A(),headSha:D(),files:T(ia),additions:A(),deletions:A(),truncated:E(),reason:D().optional()}),x({available:w(!1),reason:D()})]),x({generation:D().uuid()}),S(`state`,[x({generation:D().uuid(),state:w(`ready`),projects:T(Yi),membership:C(D(),T(D()))}),x({generation:D().uuid(),state:w(`unavailable`),reason:D()})]);function aa(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 oa(e,t){return e?(t===`issues`?e.issuesNextCursor:e.prsNextCursor)==null:!1}function sa(e,t,n){for(let r of e)t.has(r.number)||(t.add(r.number),n.push(r))}function ca(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){sa(t.issues,a,r),sa(t.prs,o,i);for(let[e,n]of Object.entries(t.labelColors??{}))s[e]??=n}let c=e.find(e=>e.projects)?.projects,l=e.map(e=>e.projectsState),u=e.find(e=>e.projectsState===`unavailable`),d=l.includes(`refreshing`)?`refreshing`:u?`unavailable`:l.some(e=>e===`ready`)?`ready`:void 0,{projectsGeneration:f,projectsReason:p,...m}=t;return{...m,issues:r,prs:i,...Object.keys(s).length>0?{labelColors:s}:{},...c?{projects:c}:{},...d?{projectsState:d}:{},...d===`unavailable`&&u?.projectsReason?{projectsReason:u.projectsReason}:{},...`issuesNextCursor`in n?{issuesNextCursor:n.issuesNextCursor}:{},...`prsNextCursor`in n?{prsNextCursor:n.prsNextCursor}:{}}}var la=e=>e.map(e=>e.number).join(`,`);function ua(e,t){let n=e[0];if(e.length>1&&n&&(la(n.issues)!==la(t.issues)||la(n.prs)!==la(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 da=class extends Error{};function fa(e,t,n){return{queryKey:e,initialPageParam:{},queryFn:async({pageParam:e,signal:r})=>{let i=await v({limit:t,...e,...n?{projectId:n}:{}},{signal:r});if(!i.available&&Object.keys(e).length>0)throw new da(i.reason??`GitHub is unavailable.`);return i},getNextPageParam:e=>aa(e),retry:(e,t)=>!(t instanceof da)&&!(t instanceof ye&&t.status>=400&&t.status<500)&&e<1,staleTime:6e4,refetchOnWindowFocus:!0}}function pa(e=50,t=!0){let n=b(),i=U.githubPages(e),a=U.githubPagesHead(e);$(`/api/v1/p/${r()}/github?limit=${e}`,a,G(t?6e4:!1));let o=yt({...fa(i,e),enabled:t,refetchInterval:!1,refetchIntervalInBackground:!1}),s=y({queryKey:a,queryFn:({signal:t})=>v({limit:e},{signal:t}),enabled:!1,staleTime:1/0}),{refetch:c}=o;(0,j.useEffect)(()=>{if(!s.data)return;let e=n.getQueryData(i);if(!e||e.pages.length===0)return;let t=ua(e.pages,s.data);t===`refetch`?c():n.setQueryData(i,{...e,pages:t})},[n,s.dataUpdatedAt,c]);let l=(o.data?.pages??[]).flatMap(e=>e.projectsState===`refreshing`&&e.projectsGeneration?[e.projectsGeneration]:[]),u=M({queries:l.map(e=>({queryKey:[...i,`projects`,e],queryFn:({signal:t})=>ge(e,{signal:t}),enabled:t,staleTime:1/0,retry:!1}))});return(0,j.useEffect)(()=>{u.forEach((e,t)=>{let r=l[t];!r||!e.data&&!e.error||n.setQueryData(i,t=>{if(!t)return t;let n=!1,i=t.pages.map(t=>{if(t.projectsGeneration!==r||t.projectsState!==`refreshing`)return t;let i=e.data;return i?.generation&&i.generation!==r?t:(n=!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 n?{...t,pages:i}:t})})},[n,u.map((e,t)=>e.data||e.error?l[t]:``).join(`,`)]),{pages:o,data:(0,j.useMemo)(()=>ca(o.data?.pages??[]),[o.data])}}function ma(e,t=50,n=!0){let r=yt({...fa([e,`github`,`pages`,t],t,e),enabled:n});return{pages:r,data:(0,j.useMemo)(()=>ca(r.data?.pages??[]),[r.data])}}function ha(e,t,n=!0){let r=M({queries:t.filter(e=>e.length>0).map(t=>({queryKey:U.githubCommentCounts(e,t),queryFn:({signal:n})=>wt(e,t,{},{signal:n}),enabled:n,staleTime:6e4}))});return(0,j.useMemo)(()=>{let e={};for(let t of r)t.data?.available&&Object.assign(e,t.data.counts);return e},[r.map(e=>e.dataUpdatedAt).join(`,`)])}function ga(e,t,n,r=!0){return y({queryKey:[e,`github`,`search`,t,n],queryFn:({signal:r})=>et(t,n,{projectId:e},{signal:r}),enabled:r&&n.trim()!==``,staleTime:6e4})}function _a(e,t=!0){return y({queryKey:U.githubChecks(e),queryFn:({signal:t})=>ae(e,{signal:t}),enabled:t&&e.length>0,staleTime:6e4})}function va(e,t,n=!0){return y({queryKey:U.githubSearch(e,t),queryFn:({signal:n})=>et(e,t,{},{signal:n}),enabled:n&&t.trim()!==``,staleTime:6e4})}var ya=100;function ba(e){return[...e].sort((e,t)=>t-e).slice(0,ya).sort((e,t)=>e-t)}function xa(){let e=Ue(),t=q();return e.projectId??t.data?.bootProject}function Sa(e){for(let[t,n]of Object.entries(e)){for(let[e,r]of Object.entries(n.prs))nr(H({projectId:t,kind:`PR`,number:Number(e)}),r);for(let[e,r]of Object.entries(n.issues))nr(H({projectId:t,kind:`Issue`,number:Number(e)}),r)}}var Ca=5*6e4;function wa(e){return e?e.recheckAfterMs:Ca}function Ta(e,t=!0){let n=(0,j.useMemo)(()=>{let t=new Map;for(let n of e){let e=t.get(n.projectId)??{prs:new Set,issues:new Set};e[n.kind===`PR`?`prs`:`issues`].add(n.number),t.set(n.projectId,e)}return[...t.entries()].map(([e,t])=>({projectId:e,prs:ba(t.prs),issues:ba(t.issues)}))},[e.map(H).sort().join(`|`)]),r=M({queries:n.map(e=>({queryKey:U.githubRefStatus(e.projectId,e.prs,e.issues),queryFn:({signal:t})=>i(e.projectId,{prs:e.prs,issues:e.issues},{signal:t}),enabled:t&&e.prs.length+e.issues.length>0,staleTime:e=>wa(e.state.data)??1/0,refetchInterval:!1,refetchOnWindowFocus:!0}))}),a=b(),o=JSON.stringify(n.map((e,t)=>({...e,interval:wa(r[t]?.data)??!1})));(0,j.useEffect)(()=>{if(!t||pr())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=U.githubRefStatus(t.projectId,t.prs,t.issues);return Qr({path:`/api/v1/p/${t.projectId}/github/ref-status?${n}`,intervalMs:t.interval},(t,n)=>{n||a.cancelQueries({queryKey:r,exact:!0}).then(()=>{e&&a.setQueryData(r,t)})})});return()=>{e=!1;for(let e of n)e()}},[t,o,a]);let s=(0,j.useMemo)(()=>fr(n,r),[n,r.map(e=>`${e.dataUpdatedAt}:${e.status}`).join(`,`)]);return(0,j.useCallback)(e=>{let t=H(e),n=s.get(t);if(n)return n;let r=B.get(t);return{state:`idle`,...r?{status:r}:{},...V.has(t)?{conflicting:!0}:{}}},[s])}function Ea(e,t,n=!0){return y({queryKey:U.githubComments(e,t),queryFn:({signal:n})=>re(e,t,{},{signal:n}),enabled:n,staleTime:6e4})}function Da(e,t,n=!0){return y({queryKey:U.githubItem(e,t),queryFn:({signal:n})=>Le(e,t,{},{signal:n}),enabled:n,staleTime:6e4})}function Oa(e){return y({queryKey:U.githubPrChanges(e??0),queryFn:({signal:t})=>Pe(e,{},{signal:t}),enabled:e!==void 0,staleTime:6e4,retry:!1})}export{di as $,qn as $t,Li as A,Ir as At,Ci as B,mr as Bt,Ni as C,zr as Ct,Wi as D,Tr as Dt,Ui as E,Fr as Et,bi as F,Kr as Ft,Ti as G,Xn as Gt,xi as H,pr as Ht,Di as I,Gr as It,si as J,Un as Jt,ci as K,Qn as Kt,ai as L,vr as Lt,pi as M,Pr as Mt,mi as N,Er as Nt,Bi as O,jr as Ot,hi as P,Ar as Pt,li as Q,Hn as Qt,Oi as R,hr as Rt,ji as S,yr as St,Fi as T,wr as Tt,ei as U,U as Ut,wi as V,G as Vt,Si as W,W as Wt,_i as X,Vn as Xt,ui as Y,Gn as Yt,gi as Z,z as Zt,Mi as _,Hr as _t,Da as a,tn as an,Ei as at,Ki as b,Wr as bt,va as c,P as cn,Q as ct,xa as d,M as dn,Br as dt,Kn as en,vi as et,Ta as f,Kt as fn,Rr as ft,Ii as g,Cr as gt,Hi as h,kr as ht,Ea as i,I as in,ri as it,ni as j,Mr as jt,Ai as k,xr as kt,ma as l,F as ln,Lr as lt,Vi as m,Vr as mt,_a as n,Bn as nn,ti as nt,pa as o,$t as on,yi as ot,oa as p,Gt as pn,Nr as pt,ki as q,Jn as qt,ha as r,En as rn,ii as rt,Oa as s,Qt as sn,Qr as st,Sa as t,Wn as tn,oi as tt,ga as u,N as un,qr as ut,zi as v,q as vt,Pi as w,br as wt,Gi as x,Sr as xt,Ri as y,Ur as yt,fi as z,gr as zt};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{o as r,s as i}from"./dist-C_rn70hE.js";import{Kt as a,p as o,qt as s}from"./queries-BSxNcgZm.js";import{n as c}from"./chunk-KS7C4IRE-Cg8l-LDN.js";import{a as l}from"./tasks-table--jkwCj2N.js";import{F as u,I as d,N as f,P as p,U as m,_ as h,ct as g,g as _,h as v,m as y,p as b}from"./design-icons-QbNMZniQ.js";import{t as x}from"./createLucideIcon-BHp8sXmF.js";import{n as S,r as C,t as w}from"./popover-CvL6hQ5c.js";var T=x(`search-x`,[[`path`,{d:`m13.5 8.5-5 5`,key:`1cs55j`}],[`path`,{d:`m8.5 8.5 5 5`,key:`a8mexj`}],[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}],[`path`,{d:`m21 21-4.3-4.3`,key:`1qie3q`}]]),E=e(t(),1),D=n(),O=(0,E.createContext)(null);function k({children:e}){let[t,n]=(0,E.useState)(()=>new Map),r=(0,E.useCallback)((e,t)=>{n(n=>{let r=new Map(n);return r.set(e,t),r})},[]),i=(0,E.useCallback)(e=>{n(t=>{if(!t.has(e))return t;let n=new Map(t);return n.delete(e),n})},[]),a=o((0,E.useMemo)(()=>[...t.values()].flat(),[t])),s=(0,E.useMemo)(()=>({publish:r,retract:i,lookup:a}),[r,i,a]);return(0,D.jsx)(O.Provider,{value:s,children:e})}var A=(0,E.createContext)(null);function j({projectId:e,repoBase:t,requests:n,children:r}){let i=(0,E.useContext)(O),a=(0,E.useContext)(A),s=(0,E.useId)();(0,E.useEffect)(()=>{if(i)return i.publish(s,n),()=>i.retract(s)},[i,s,n.map(e=>`${e.projectId} ${e.kind}#${e.number}`).sort().join(`|`)]);let c=o(i?M:n),l=i?.lookup??c,u=t??(a&&a.projectId===e?a.repoBase:void 0),d=(0,E.useMemo)(()=>({lookup:l,projectId:e,repoBase:u}),[l,e,u]);return(0,D.jsx)(A.Provider,{value:d,children:r})}var M=[];function N(e,t,n){let r=(0,E.useContext)(A),i=n??r?.projectId;return!r||!i||t===void 0?te:r.lookup({projectId:i,kind:e,number:t})}function ee(e,t){let n=(0,E.useContext)(A),r=t??n?.projectId;return!n||!r?[]:e.filter(e=>n.lookup({projectId:r,kind:`PR`,number:e}).conflicting===!0)}function P(){let e=(0,E.useContext)(A);return{projectId:e?.projectId,repoBase:e?.repoBase}}var te=Object.freeze({state:`idle`}),F={success:`border-success/40 text-semantic-green`,danger:`border-danger/40 text-semantic-red`,accent:`border-accent-strong/35 text-accent-text`,merged:`border-merged-strong/35 text-merged-text`,info:`border-info/40 text-semantic-info`,neutral:`border-border text-muted-foreground`,pending:`border-pending-strong/45 text-semantic-amber`,conflict:`border-conflict/45 text-semantic-conflict`},I={success:`text-semantic-green`,danger:`text-semantic-red`,accent:`text-merged-text`,merged:`text-merged-text`,info:`text-semantic-info`,neutral:`text-soft-foreground`,pending:`text-semantic-amber`,conflict:`text-semantic-conflict`},ne={success:`hover:bg-success/10`,danger:`hover:bg-danger/10`,accent:`hover:bg-accent-strong/10`,merged:`hover:bg-merged-strong/10`,info:`hover:bg-info/10`,neutral:`hover:bg-muted`,pending:`hover:bg-pending-strong/10`,conflict:`hover:bg-conflict/10`},re={draft:u,"review-required":d,"changes-requested":m,"checks-pending":null,"checks-failing":h,ready:b,merged:f,closed:p,open:y,completed:b,"not-planned":_};function L(e){return e===`PR`?`pr-chip`:`issue-chip`}function R(e){return e?{"data-conflicting":`true`}:{}}function z(e,t,n,r){return!n||r!==void 0&&l({kind:e,number:t??0,url:n},r)}function B(e,t,n){return e===`PR`&&(t??n)===!0}function V({plain:e,inert:t,conflicting:n,className:i,tone:a}){return e?r(`inline-flex items-center gap-1 rounded-[2px] text-inherit`,n&&`text-conflict font-medium`,!t&&`group/reference focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-link-foreground`,i):r(`inline-flex h-[22px] items-center gap-1 rounded-md border px-1.5 font-mono text-[12px] font-normal`,F[a],i)}function H(e,t,n,r){return n&&!r?t?`${e===`PR`?`PR `:``}#${t}`:e:t?`${!r&&e===`Issue`?`Issue `:``}#${t}`:e}function U(e){return e===`PR`?`pull request`:`issue`}function W(e,t,n,r){return`Open the ${e}${t?` #${t}`:``} for ${n}${r?` — ${r.label}`:``}`}function G(e,t){return e&&t?I[t.tone]:void 0}function K(e,t){return!e&&(!t||!i(t))}function q({conflicting:e,presentation:t,status:n,plain:i,compact:a,inert:o,kind:s,label:c,glyphClass:l}){return(0,D.jsxs)(D.Fragment,{children:[e?(0,D.jsx)(g,{className:r(`size-2.5 shrink-0`,l),"aria-hidden":`true`}):(0,D.jsx)($,{status:t?n:void 0,className:i?r(`size-2.5`,l):void 0}),i&&a?s===`PR`?(0,D.jsx)(d,{"data-slot":`reference-kind`,className:`size-2.5 shrink-0`,"aria-hidden":`true`}):(0,D.jsx)(y,{"data-slot":`reference-kind`,className:`size-2.5 shrink-0`,"aria-hidden":`true`}):null,i?(0,D.jsx)(`span`,{className:o?void 0:`underline-offset-2 group-hover/reference:underline group-focus-visible/reference:underline`,children:c}):c]})}function J({kind:e,status:t,conflicting:n,chipClass:r,body:i}){return(0,D.jsx)(`span`,{"data-slot":L(e),"data-status":t,"data-inert":`true`,...R(n),className:r,children:i})}function Y({kind:e,number:t,tooltip:n,url:r}){return(0,D.jsxs)(D.Fragment,{children:[(0,D.jsxs)(`span`,{className:`block font-medium`,children:[e===`PR`?`Pull request`:`Issue`,t?` #${t}`:``,` · `,n.headline]}),(0,D.jsx)(`span`,{className:`block`,children:n.detail}),n.also?(0,D.jsx)(`span`,{className:`block text-muted-foreground`,children:n.also}):null,r&&i(r)?(0,D.jsx)(`span`,{className:`block text-muted-foreground`,children:r.replace(/^https?:\/\//,``)}):null]})}function ie({reference:e,taskTitle:t,status:n,conflicting:i,conflictAction:o,projectId:c,repoBase:l,to:u,className:d,compact:f=!1,plain:p=!1,inert:m=!1}){let{kind:h,number:g,url:_}=e,v=P(),y=N(h,z(h,g,_,l??v.repoBase)?g:void 0,c),b=n??y.status,x=s(b),S=B(h,i,y.conflicting),C=S?a:x,w=C?.tone??`accent`,T=V({plain:p,inert:m,conflicting:S,className:d,tone:w}),E=le(y,C,S?x:void 0),O=H(h,g,p,f),k=U(h),A=W(k,g,t,C),j=(0,D.jsx)(q,{conflicting:S,presentation:C,status:b,plain:p,compact:f,inert:m,kind:h,label:O,glyphClass:G(p,C)});if(m)return(0,D.jsx)(J,{kind:h,status:b,conflicting:S,chipClass:T,body:j});let M=K(u,_)?(0,D.jsx)(`span`,{"data-slot":L(h),"data-status":b,...R(S),"aria-label":C?`${k} ${O} — ${C.label}`:void 0,className:T,children:j}):(0,D.jsx)(ae,{to:u,url:_,"data-slot":L(h),"data-status":b,...R(S),title:E?void 0:_,"aria-label":A,className:p?T:r(T,ne[w]),children:j});return E?(0,D.jsx)(ce,{chip:M,action:S?o:void 0,state:y.state,children:(0,D.jsx)(Y,{kind:h,number:g,tooltip:E,url:_})}):M}function ae({to:e,url:t,children:n,...r}){return e?(0,D.jsx)(c,{to:e,...r,children:n}):(0,D.jsx)(`a`,{href:t,target:`_blank`,rel:`noopener noreferrer`,...r,children:n})}var X=(0,E.createContext)(()=>{});function oe(){return(0,E.useContext)(X)}var se=150,Z=120;function ce({chip:e,action:t,state:n,children:r}){let[i,a]=(0,E.useState)(!1),o=(0,E.useRef)(null),s=(0,E.useRef)(null),c=(0,E.useRef)(void 0),l=(0,E.useCallback)((e,t)=>{clearTimeout(c.current),c.current=setTimeout(()=>a(e),t)},[]),u=(0,E.useCallback)(()=>{clearTimeout(c.current),a(!1)},[]);(0,E.useEffect)(()=>()=>clearTimeout(c.current),[]);let d=e=>e instanceof Node&&(s.current?.contains(e)||o.current?.contains(e));return(0,D.jsxs)(w,{open:i,onOpenChange:e=>e?a(!0):u(),children:[(0,D.jsx)(S,{asChild:!0,ref:o,onPointerEnter:e=>{e.pointerType!==`touch`&&l(!0,se)},onPointerLeave:e=>{e.pointerType!==`touch`&&l(!1,Z)},onFocus:()=>a(!0),onBlur:e=>{d(e.relatedTarget)||u()},onKeyDown:e=>{if(e.key===`Escape`)return u();if(e.key!==`Tab`||e.shiftKey||!t)return;let n=s.current?.querySelector(`button:not([disabled]), [href], input, select, textarea, [tabindex]:not([tabindex="-1"])`);n&&(e.preventDefault(),n.focus())},...t?{"aria-haspopup":`dialog`,"aria-expanded":i}:{},children:e}),(0,D.jsxs)(C,{ref:s,side:`top`,role:t?`dialog`:`tooltip`,"data-slot":`reference-status-card`,"data-tooltip-state":n,className:`w-64 space-y-2 p-3 text-xs`,onOpenAutoFocus:e=>e.preventDefault(),onCloseAutoFocus:e=>{e.preventDefault(),d(document.activeElement)&&o.current?.focus()},onPointerEnter:()=>clearTimeout(c.current),onPointerLeave:e=>{e.pointerType!==`touch`&&l(!1,Z)},children:[(0,D.jsx)(`div`,{className:`space-y-0.5`,children:r}),t?(0,D.jsx)(X.Provider,{value:u,children:t}):null]})]})}function le(e,t,n){if(t){let{label:r,hint:i}=t,a=n?`also ${ue(n.label)} — ${n.hint}`:void 0;return e.state===`unavailable`?{headline:r,detail:`last known — GitHub is unreachable${e.reason?` (${e.reason})`:``}`,...a?{also:a}:{}}:{headline:r,detail:i,...a?{also:a}:{}}}switch(e.state){case`loading`:return{headline:`Checking GitHub…`,detail:`the status of this reference is on its way`};case`unavailable`:return{headline:`Status unavailable`,detail:e.reason??`GitHub could not be reached — the chip says nothing rather than guessing`};case`unknown`:return{headline:`Not found on this repository`,detail:`GitHub has no such number here — the reference may point at another repo`};default:return null}}function ue(e){return e.charAt(0).toLowerCase()+e.slice(1)}function Q({kind:e,number:t,className:n}){let i=N(e,t),o=s(i.status),c=e===`PR`&&i.conflicting===!0,l=c?a:o;if(!l)return null;let u=r(`size-2.5`,I[l.tone]);return(0,D.jsx)(`span`,{"data-slot":`reference-status-glyph`,"data-status":i.status,...c?{"data-conflicting":`true`}:{},"aria-hidden":`true`,className:r(`inline-flex items-center`,n),children:c?(0,D.jsx)(g,{className:r(`shrink-0`,u),"aria-hidden":`true`}):(0,D.jsx)($,{status:i.status,className:u})})}function $({status:e,className:t}){if(!e)return null;if(e===`checks-pending`)return(0,D.jsx)(v,{"data-slot":`status-dot`,"data-tone":`pending`,className:r(`size-3 animate-pulse motion-reduce:animate-none`,t),"aria-hidden":`true`});let n=re[e];return n?(0,D.jsx)(n,{className:r(`size-2.5 shrink-0`,t),"aria-hidden":`true`}):null}export{k as a,N as c,j as i,T as l,Q as n,ee as o,oe as r,P as s,ie as t};
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{o as r,s as i}from"./dist-C_rn70hE.js";import{Gt as a,Kt as o,f as s}from"./queries-B8INH8MM.js";import{n as c}from"./chunk-KS7C4IRE-Cg8l-LDN.js";import{a as l}from"./tasks-table-CyUTCD9k.js";import{F as u,I as d,N as f,P as p,U as m,_ as h,ct as g,g as _,h as v,m as y,p as b}from"./design-icons-QbNMZniQ.js";import{t as x}from"./createLucideIcon-BHp8sXmF.js";import{n as S,r as C,t as w}from"./popover-CvL6hQ5c.js";var T=x(`search-x`,[[`path`,{d:`m13.5 8.5-5 5`,key:`1cs55j`}],[`path`,{d:`m8.5 8.5 5 5`,key:`a8mexj`}],[`circle`,{cx:`11`,cy:`11`,r:`8`,key:`4ej97u`}],[`path`,{d:`m21 21-4.3-4.3`,key:`1qie3q`}]]),E=e(t(),1),D=n(),O=(0,E.createContext)(null);function k({children:e}){let[t,n]=(0,E.useState)(()=>new Map),r=(0,E.useCallback)((e,t)=>{n(n=>{let r=new Map(n);return r.set(e,t),r})},[]),i=(0,E.useCallback)(e=>{n(t=>{if(!t.has(e))return t;let n=new Map(t);return n.delete(e),n})},[]),a=s((0,E.useMemo)(()=>[...t.values()].flat(),[t])),o=(0,E.useMemo)(()=>({publish:r,retract:i,lookup:a}),[r,i,a]);return(0,D.jsx)(O.Provider,{value:o,children:e})}var A=(0,E.createContext)(null);function j({projectId:e,repoBase:t,requests:n,children:r}){let i=(0,E.useContext)(O),a=(0,E.useContext)(A),o=(0,E.useId)();(0,E.useEffect)(()=>{if(i)return i.publish(o,n),()=>i.retract(o)},[i,o,n.map(e=>`${e.projectId} ${e.kind}#${e.number}`).sort().join(`|`)]);let c=s(i?M:n),l=i?.lookup??c,u=t??(a&&a.projectId===e?a.repoBase:void 0),d=(0,E.useMemo)(()=>({lookup:l,projectId:e,repoBase:u}),[l,e,u]);return(0,D.jsx)(A.Provider,{value:d,children:r})}var M=[];function N(e,t,n){let r=(0,E.useContext)(A),i=n??r?.projectId;return!r||!i||t===void 0?te:r.lookup({projectId:i,kind:e,number:t})}function ee(e,t){let n=(0,E.useContext)(A),r=t??n?.projectId;return!n||!r?[]:e.filter(e=>n.lookup({projectId:r,kind:`PR`,number:e}).conflicting===!0)}function P(){let e=(0,E.useContext)(A);return{projectId:e?.projectId,repoBase:e?.repoBase}}var te=Object.freeze({state:`idle`}),F={success:`border-success/40 text-semantic-green`,danger:`border-danger/40 text-semantic-red`,accent:`border-accent-strong/35 text-accent-text`,merged:`border-merged-strong/35 text-merged-text`,info:`border-info/40 text-semantic-info`,neutral:`border-border text-muted-foreground`,pending:`border-pending-strong/45 text-semantic-amber`,conflict:`border-conflict/45 text-semantic-conflict`},I={success:`text-semantic-green`,danger:`text-semantic-red`,accent:`text-merged-text`,merged:`text-merged-text`,info:`text-semantic-info`,neutral:`text-soft-foreground`,pending:`text-semantic-amber`,conflict:`text-semantic-conflict`},ne={success:`hover:bg-success/10`,danger:`hover:bg-danger/10`,accent:`hover:bg-accent-strong/10`,merged:`hover:bg-merged-strong/10`,info:`hover:bg-info/10`,neutral:`hover:bg-muted`,pending:`hover:bg-pending-strong/10`,conflict:`hover:bg-conflict/10`},re={draft:u,"review-required":d,"changes-requested":m,"checks-pending":null,"checks-failing":h,ready:b,merged:f,closed:p,open:y,completed:b,"not-planned":_};function L(e){return e===`PR`?`pr-chip`:`issue-chip`}function R(e){return e?{"data-conflicting":`true`}:{}}function z(e,t,n,r){return!n||r!==void 0&&l({kind:e,number:t??0,url:n},r)}function B(e,t,n){return e===`PR`&&(t??n)===!0}function V({plain:e,inert:t,conflicting:n,className:i,tone:a}){return e?r(`inline-flex items-center gap-1 rounded-[2px] text-inherit`,n&&`text-conflict font-medium`,!t&&`group/reference focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-link-foreground`,i):r(`inline-flex h-[22px] items-center gap-1 rounded-md border px-1.5 font-mono text-[12px] font-normal`,F[a],i)}function H(e,t,n,r){return n&&!r?t?`${e===`PR`?`PR `:``}#${t}`:e:t?`${!r&&e===`Issue`?`Issue `:``}#${t}`:e}function U(e){return e===`PR`?`pull request`:`issue`}function W(e,t,n,r){return`Open the ${e}${t?` #${t}`:``} for ${n}${r?` — ${r.label}`:``}`}function G(e,t){return e&&t?I[t.tone]:void 0}function K(e,t){return!e&&(!t||!i(t))}function q({conflicting:e,presentation:t,status:n,plain:i,compact:a,inert:o,kind:s,label:c,glyphClass:l}){return(0,D.jsxs)(D.Fragment,{children:[e?(0,D.jsx)(g,{className:r(`size-2.5 shrink-0`,l),"aria-hidden":`true`}):(0,D.jsx)($,{status:t?n:void 0,className:i?r(`size-2.5`,l):void 0}),i&&a?s===`PR`?(0,D.jsx)(d,{"data-slot":`reference-kind`,className:`size-2.5 shrink-0`,"aria-hidden":`true`}):(0,D.jsx)(y,{"data-slot":`reference-kind`,className:`size-2.5 shrink-0`,"aria-hidden":`true`}):null,i?(0,D.jsx)(`span`,{className:o?void 0:`underline-offset-2 group-hover/reference:underline group-focus-visible/reference:underline`,children:c}):c]})}function J({kind:e,status:t,conflicting:n,chipClass:r,body:i}){return(0,D.jsx)(`span`,{"data-slot":L(e),"data-status":t,"data-inert":`true`,...R(n),className:r,children:i})}function Y({kind:e,number:t,tooltip:n,url:r}){return(0,D.jsxs)(D.Fragment,{children:[(0,D.jsxs)(`span`,{className:`block font-medium`,children:[e===`PR`?`Pull request`:`Issue`,t?` #${t}`:``,` · `,n.headline]}),(0,D.jsx)(`span`,{className:`block`,children:n.detail}),n.also?(0,D.jsx)(`span`,{className:`block text-muted-foreground`,children:n.also}):null,r&&i(r)?(0,D.jsx)(`span`,{className:`block text-muted-foreground`,children:r.replace(/^https?:\/\//,``)}):null]})}function ie({reference:e,taskTitle:t,status:n,conflicting:i,conflictAction:s,projectId:c,repoBase:l,to:u,className:d,compact:f=!1,plain:p=!1,inert:m=!1}){let{kind:h,number:g,url:_}=e,v=P(),y=N(h,z(h,g,_,l??v.repoBase)?g:void 0,c),b=n??y.status,x=o(b),S=B(h,i,y.conflicting),C=S?a:x,w=C?.tone??`accent`,T=V({plain:p,inert:m,conflicting:S,className:d,tone:w}),E=le(y,C,S?x:void 0),O=H(h,g,p,f),k=U(h),A=W(k,g,t,C),j=(0,D.jsx)(q,{conflicting:S,presentation:C,status:b,plain:p,compact:f,inert:m,kind:h,label:O,glyphClass:G(p,C)});if(m)return(0,D.jsx)(J,{kind:h,status:b,conflicting:S,chipClass:T,body:j});let M=K(u,_)?(0,D.jsx)(`span`,{"data-slot":L(h),"data-status":b,...R(S),"aria-label":C?`${k} ${O} — ${C.label}`:void 0,className:T,children:j}):(0,D.jsx)(ae,{to:u,url:_,"data-slot":L(h),"data-status":b,...R(S),title:E?void 0:_,"aria-label":A,className:p?T:r(T,ne[w]),children:j});return E?(0,D.jsx)(ce,{chip:M,action:S?s:void 0,state:y.state,children:(0,D.jsx)(Y,{kind:h,number:g,tooltip:E,url:_})}):M}function ae({to:e,url:t,children:n,...r}){return e?(0,D.jsx)(c,{to:e,...r,children:n}):(0,D.jsx)(`a`,{href:t,target:`_blank`,rel:`noopener noreferrer`,...r,children:n})}var X=(0,E.createContext)(()=>{});function oe(){return(0,E.useContext)(X)}var se=150,Z=120;function ce({chip:e,action:t,state:n,children:r}){let[i,a]=(0,E.useState)(!1),o=(0,E.useRef)(null),s=(0,E.useRef)(null),c=(0,E.useRef)(void 0),l=(0,E.useCallback)((e,t)=>{clearTimeout(c.current),c.current=setTimeout(()=>a(e),t)},[]),u=(0,E.useCallback)(()=>{clearTimeout(c.current),a(!1)},[]);(0,E.useEffect)(()=>()=>clearTimeout(c.current),[]);let d=e=>e instanceof Node&&(s.current?.contains(e)||o.current?.contains(e));return(0,D.jsxs)(w,{open:i,onOpenChange:e=>e?a(!0):u(),children:[(0,D.jsx)(S,{asChild:!0,ref:o,onPointerEnter:e=>{e.pointerType!==`touch`&&l(!0,se)},onPointerLeave:e=>{e.pointerType!==`touch`&&l(!1,Z)},onFocus:()=>a(!0),onBlur:e=>{d(e.relatedTarget)||u()},onKeyDown:e=>{if(e.key===`Escape`)return u();if(e.key!==`Tab`||e.shiftKey||!t)return;let n=s.current?.querySelector(`button:not([disabled]), [href], input, select, textarea, [tabindex]:not([tabindex="-1"])`);n&&(e.preventDefault(),n.focus())},...t?{"aria-haspopup":`dialog`,"aria-expanded":i}:{},children:e}),(0,D.jsxs)(C,{ref:s,side:`top`,role:t?`dialog`:`tooltip`,"data-slot":`reference-status-card`,"data-tooltip-state":n,className:`w-64 space-y-2 p-3 text-xs`,onOpenAutoFocus:e=>e.preventDefault(),onCloseAutoFocus:e=>{e.preventDefault(),d(document.activeElement)&&o.current?.focus()},onPointerEnter:()=>clearTimeout(c.current),onPointerLeave:e=>{e.pointerType!==`touch`&&l(!1,Z)},children:[(0,D.jsx)(`div`,{className:`space-y-0.5`,children:r}),t?(0,D.jsx)(X.Provider,{value:u,children:t}):null]})]})}function le(e,t,n){if(t){let{label:r,hint:i}=t,a=n?`also ${ue(n.label)} — ${n.hint}`:void 0;return e.state===`unavailable`?{headline:r,detail:`last known — GitHub is unreachable${e.reason?` (${e.reason})`:``}`,...a?{also:a}:{}}:{headline:r,detail:i,...a?{also:a}:{}}}switch(e.state){case`loading`:return{headline:`Checking GitHub…`,detail:`the status of this reference is on its way`};case`unavailable`:return{headline:`Status unavailable`,detail:e.reason??`GitHub could not be reached — the chip says nothing rather than guessing`};case`unknown`:return{headline:`Not found on this repository`,detail:`GitHub has no such number here — the reference may point at another repo`};default:return null}}function ue(e){return e.charAt(0).toLowerCase()+e.slice(1)}function Q({kind:e,number:t,className:n}){let i=N(e,t),s=o(i.status),c=e===`PR`&&i.conflicting===!0,l=c?a:s;if(!l)return null;let u=r(`size-2.5`,I[l.tone]);return(0,D.jsx)(`span`,{"data-slot":`reference-status-glyph`,"data-status":i.status,...c?{"data-conflicting":`true`}:{},"aria-hidden":`true`,className:r(`inline-flex items-center`,n),children:c?(0,D.jsx)(g,{className:r(`shrink-0`,u),"aria-hidden":`true`}):(0,D.jsx)($,{status:i.status,className:u})})}function $({status:e,className:t}){if(!e)return null;if(e===`checks-pending`)return(0,D.jsx)(v,{"data-slot":`status-dot`,"data-tone":`pending`,className:r(`size-3 animate-pulse motion-reduce:animate-none`,t),"aria-hidden":`true`});let n=re[e];return n?(0,D.jsx)(n,{className:r(`size-2.5 shrink-0`,t),"aria-hidden":`true`}):null}export{k as a,N as c,j as i,T as l,Q as n,ee as o,oe as r,P as s,ie as t};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{Gt as r,Wt as i,yt as a}from"./queries-BSxNcgZm.js";import{vi as o}from"./toaster-BJG79kO8.js";import{yn as s}from"./index-CoM783-U.js";var c=e(t(),1),l=n();function u(){let e=o(),t=(0,c.useCallback)(async()=>{await Promise.all([e.invalidateQueries({queryKey:i.health}),e.invalidateQueries({queryKey:i.agentConfig,exact:!0}),e.invalidateQueries({queryKey:r.agentProfiles,exact:!0})])},[e]);return(0,c.useEffect)(()=>{t()},[t]),t}var d=`${s()} remote-settings enable`;function f({risk:e}){return a().data?.capabilities?.remoteSettingsAdmin===!0?(0,l.jsxs)(`p`,{role:`note`,"data-slot":`remote-settings-notice`,className:`rounded-md border border-pending-strong/40 bg-pending/10 px-3 py-2 text-[13px] text-foreground`,children:[`Remote settings administration is on. `,e,`, and anyone who can open this cockpit can change them. The host operator turns this off with`,` `,(0,l.jsxs)(`code`,{children:[s(),` remote-settings disable`]}),`.`]}):null}export{f as n,u as r,d as t};
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{Ut as r,Wt as i,vt as a}from"./queries-B8INH8MM.js";import{vi as o}from"./toaster-Cjr2jC1Q.js";import{bn as s}from"./index-DDtQlxLH.js";var c=e(t(),1),l=n();function u(){let e=o(),t=(0,c.useCallback)(async()=>{await Promise.all([e.invalidateQueries({queryKey:r.health}),e.invalidateQueries({queryKey:r.agentConfig,exact:!0}),e.invalidateQueries({queryKey:i.agentProfiles,exact:!0})])},[e]);return(0,c.useEffect)(()=>{t()},[t]),t}var d=`${s()} remote-settings enable`;function f({risk:e}){return a().data?.capabilities?.remoteSettingsAdmin===!0?(0,l.jsxs)(`p`,{role:`note`,"data-slot":`remote-settings-notice`,className:`rounded-md border border-pending-strong/40 bg-pending/10 px-3 py-2 text-[13px] text-foreground`,children:[`Remote settings administration is on. `,e,`, and anyone who can open this cockpit can change them. The host operator turns this off with`,` `,(0,l.jsxs)(`code`,{children:[s(),` remote-settings disable`]}),`.`]}):null}export{f as n,u as r,d as t};
@@ -0,0 +1 @@
1
+ [data-slot=repo-tabs]>a{padding-inline:0}[data-slot=repo-branches]>div{border-radius:10px}[data-slot=repo-branches] [data-action=switch-branch]{font-weight:500}[data-slot=repo-branches] input[aria-label=Filter\ branches]{background:var(--card)}
@@ -0,0 +1 @@
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{o as r,p as i,s as a}from"./dist-C_rn70hE.js";import{A as o,C as s,Kt as c,S as l,T as u,U as d,Ut as f,bt as p,nt as m,un as h,w as g}from"./queries-B8INH8MM.js";import{B as ee,Rn as _,T as te,f as v,n as y,ut as b,vi as x,w as S,z as ne,zt as re}from"./toaster-Cjr2jC1Q.js";import{Z as C}from"./live-protocol-DMhTnCmf.js";import{g as w,h as T}from"./chunk-KS7C4IRE-Cg8l-LDN.js";import{i as E}from"./tasks-table-CyUTCD9k.js";import{D,F as ie,I as O,M as ae,N as k,P as A,Q as oe,S as se,X as ce,Z as le,c as ue,ct as j,d as de,j as fe,l as pe,n as me,st as he,w as ge,y as _e}from"./design-icons-QbNMZniQ.js";import{t as ve}from"./createLucideIcon-BHp8sXmF.js";import{n as ye,t as be}from"./circle-x-7nTlobAF.js";import{_ as xe}from"./nav-row-styles-CgP5uNp4.js";import{i as Se,r as Ce,t as we}from"./git-toolbar-xBysCptA.js";import{t as M}from"./info-DA1x_4bz.js";import{t as Te}from"./loader-circle-CPBhhDbB.js";import{a as Ee,i as De,n as Oe,r as ke}from"./diff-controls-M-rIqFWN.js";import{c as Ae,i as je,t as Me}from"./reference-chip-DDv209Ry.js";import{t as N}from"./button-C8jUIs8Q.js";import{i as P,l as Ne,p as Pe,r as Fe,t as Ie}from"./dropdown-menu-DjtKUK8F.js";import{a as Le,i as Re,n as ze,o as Be,r as Ve,s as He,t as Ue}from"./dialog-DRZuXvul.js";import{t as F}from"./project-router-DvfVUjon.js";import{t as We}from"./status-dot-BXf-Ubd0.js";import{c as Ge,d as Ke,f as qe,m as I,n as Je,s as Ye,t as Xe}from"./page-shell-Dky5crRl.js";import{a as Ze,o as Qe}from"./format-BU7D3IfE.js";import{t as L}from"./centered-state-BgSV4e79.js";import{$t as R,Bt as $e,E as z,Ft as et,Gt as tt,Ht as nt,It as rt,Jt as B,Kt as it,Ln as at,Lt as ot,Mt as st,Nn as ct,Nt as lt,Pt as ut,Qt as V,Rn as dt,Rt as ft,T as pt,Ut as mt,Vt as H,Wt as ht,Xt as U,Yt as W,Zt as G,_n as gt,br as K,dr as _t,en as q,ir as vt,qt as J,vr as yt,zn as bt,zt as xt}from"./index-DDtQlxLH.js";import{t as St}from"./markdown-BBDDg-4t.js";import{t as Ct}from"./diff-Chs69ao_.js";import{t as wt}from"./change-counts-wqSYI3W8.js";import{t as Tt}from"./code-workbench-CUkiQ1pF.js";import{t as Et}from"./file-text-nGpo7MVd.js";import{i as Dt,n as Ot,r as kt}from"./commit-list-Bt4Z1k-3.js";var Y=e(t(),1);function At(e,t){let n=x(t),r=n.getQueryCache();return Y.useSyncExternalStore(Y.useCallback(e=>r.subscribe(C.batchCalls(e)),[r]),()=>n.isFetching(e),()=>n.isFetching(e))}var jt=ve(`arrow-down-to-line`,[[`path`,{d:`M12 17V3`,key:`1cwfxf`}],[`path`,{d:`m6 11 6 6 6-6`,key:`12ii2o`}],[`path`,{d:`M19 21H5`,key:`150jfl`}]]),Mt=ve(`git-pull-request-create`,[[`circle`,{cx:`6`,cy:`6`,r:`3`,key:`1lh9wr`}],[`path`,{d:`M6 9v12`,key:`1sc30k`}],[`path`,{d:`M13 6h3a2 2 0 0 1 2 2v3`,key:`1jb6z3`}],[`path`,{d:`M18 15v6`,key:`9wciyi`}],[`path`,{d:`M21 18h-6`,key:`139f0c`}]]),X=n();function Nt(){let e=i(),t=l(),n=x(),a=At({queryKey:f.repo})>0,o=t.data?.info?t.data:null,s=st(e,o,`screen`);return(0,X.jsx)(Ke,{route:`repo-git`,density:o?.info?`full`:`empty`,headerSpacing:`compact`,header:{title:`Git`,secondaryActions:(0,X.jsx)(Ge,{type:`button`,variant:`ghost`,"data-slot":`git-screen-refresh`,"aria-label":`Refresh the repository`,title:`Refresh the repository`,disabled:a,onClick:()=>{n.invalidateQueries({queryKey:f.repo}),n.invalidateQueries({queryKey:f.worktrees})},children:(0,X.jsx)(le,{size:17,"aria-hidden":`true`,className:r(`size-[17px]`,a&&`motion-safe:animate-spin`)})})},children:(0,X.jsxs)(`div`,{"data-slot":`git-screen`,children:[o?.info?(0,X.jsx)(`div`,{className:`mb-[16px]`,children:(0,X.jsx)(et,{scope:e,repo:o,info:o.info,variant:`screen`},e)}):t.isPending?(0,X.jsx)(`p`,{"data-slot":`git-screen-loading`,role:`status`,className:`mb-[16px] px-[10px] text-[13px] text-soft-foreground`,children:`Loading the checkout…`}):t.isError?(0,X.jsxs)(`p`,{"data-slot":`git-screen-error`,role:`alert`,className:`mb-[16px] px-[10px] text-[13px] text-danger`,children:[`Could not load the repository: `,t.error.message]}):(0,X.jsx)(`p`,{"data-slot":`git-screen-not-git`,className:`mb-[16px] px-[10px] text-[13px] text-soft-foreground`,children:`Not a git repository.`}),t.isPending?null:(0,X.jsx)(lt,{branch:o?.info?.branch??null,counts:s,variant:`screen`})]})})}function Pt(e){if(e===``)return null;if(e===`@`)return`A branch cannot be named “@”.`;if(e.startsWith(`-`))return`A branch name cannot start with “-”.`;if(/\s/.test(e))return`A branch name cannot contain spaces.`;if(/[\u0000-\u001f\u007f]/.test(e))return`A branch name cannot contain control characters.`;let t=/[~^:?*[\\]/.exec(e);if(t)return`A branch name cannot contain “${t[0]}”.`;if(e.includes(`..`))return`A branch name cannot contain “..”.`;if(e.includes(`@{`))return`A branch name cannot contain “@{”.`;if(e.startsWith(`/`)||e.endsWith(`/`))return`A branch name cannot start or end with “/”.`;if(e.includes(`//`))return`A branch name cannot contain “//”.`;if(e.endsWith(`.`))return`A branch name cannot end with “.”.`;for(let t of e.split(`/`)){if(t.startsWith(`.`))return`A part of a branch name cannot start with “.”.`;if(t.endsWith(`.lock`))return`A part of a branch name cannot end with “.lock”.`}return null}function Ft({from:e}){let[t,n]=(0,Y.useState)(!1),r=(0,Y.useRef)(null);return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(Ge,{ref:r,variant:`primary`,"data-action":`new-branch`,disabled:xt(i())&&!t,onClick:()=>n(!0),children:[(0,X.jsx)(ce,{size:16,"aria-hidden":`true`}),`New branch`]}),t?(0,X.jsx)(It,{from:e,returnFocus:r,onClose:()=>n(!1)}):null]})}function It({from:e,returnFocus:t,onClose:n}){let r=ft(i()),a=xt(i()),[o,s]=(0,Y.useState)(``),[c,l]=(0,Y.useState)(null),u=o.trim(),d=Pt(u),f=d??c;return(0,X.jsx)(Ue,{open:!0,onOpenChange:e=>{!e&&!r.isPending&&n()},children:(0,X.jsx)(Ve,{"data-slot":`new-branch-dialog`,className:`sm:max-w-md`,onCloseAutoFocus:e=>{e.preventDefault(),t.current?.focus()},children:(0,X.jsxs)(`form`,{className:`grid min-w-0 gap-4`,onSubmit:e=>{e.preventDefault(),!(!u||d||a)&&(l(null),r.mutate(u,{onSuccess:n,onError:e=>l(e.message)}))},children:[(0,X.jsxs)(Be,{children:[(0,X.jsx)(He,{children:`New branch`}),(0,X.jsxs)(Re,{"data-slot":`new-branch-base`,children:[`Create from `,(0,X.jsx)(`span`,{className:`font-mono text-foreground`,children:e}),` and switch to it. Switching changes your working tree.`]})]}),(0,X.jsxs)(ze,{className:`flex flex-col gap-2`,children:[(0,X.jsx)(`label`,{htmlFor:`new-branch-name`,className:`text-sm font-medium`,children:`Branch name`}),(0,X.jsx)(vt,{id:`new-branch-name`,autoComplete:`off`,spellCheck:!1,placeholder:`new-branch-name`,className:`h-11 bg-background font-mono md:text-base placeholder:text-soft-foreground`,value:o,"aria-invalid":f?!0:void 0,"aria-describedby":f?`new-branch-name-hint`:void 0,onChange:e=>{s(e.target.value),l(null)}}),f?(0,X.jsx)(`p`,{id:`new-branch-name-hint`,"data-slot":d?`branch-name-hint`:`branch-create-refusal`,role:`alert`,className:`text-xs text-danger`,children:f}):null]}),(0,X.jsxs)(Le,{children:[(0,X.jsx)(N,{type:`button`,variant:`outline`,className:`min-h-11`,disabled:r.isPending,onClick:n,children:`Cancel`}),(0,X.jsx)(N,{type:`submit`,variant:`primary`,className:`min-h-11`,"data-action":`create-branch`,disabled:!u||d!==null||a,children:r.isPending?`Creating…`:`Create`})]})]})})})}function Lt({entry:e}){return e.keptReason?(0,X.jsx)(`span`,{"data-slot":`branch-kept-reason`,className:`min-w-0 text-xs text-muted-foreground`,children:e.keptReason}):null}function Rt({repo:e,info:t}){let n=s(),a=new Map((n.data?.branches??[]).map(e=>[e.name,e])),o=n.data?.base??e.baseBranch??t.branch,c=ft(i(),e=>y(e.message,{tone:`danger`})),l=xt(i()),[u,d]=(0,Y.useState)(``),f=u.trim().toLowerCase(),p=Gt(e,n.data?.branches),m=f?p.filter(e=>e.toLowerCase().includes(f)):p;return(0,X.jsx)(`section`,{"data-slot":`repo-branches`,className:`min-w-0`,children:(0,X.jsxs)(`div`,{className:`min-w-0 rounded-xl border border-border bg-card p-5`,children:[(0,X.jsx)(`h2`,{className:`sr-only`,children:`Branches`}),(0,X.jsxs)(`label`,{className:`relative block`,children:[(0,X.jsx)(oe,{size:16,"aria-hidden":`true`,className:`pointer-events-none absolute left-3 top-3 size-4 text-muted-foreground`}),(0,X.jsx)(vt,{"aria-label":`Filter branches`,placeholder:`Filter branches…`,value:u,onChange:e=>d(e.target.value),className:`h-10 rounded-lg border-border bg-card pl-10`})]}),(0,X.jsxs)(`ul`,{"data-slot":`repo-branch-list`,className:`mt-3.5 flex min-w-0 flex-col divide-y divide-border border-t border-border md:max-h-[40rem] md:overflow-y-auto md:overscroll-contain`,children:[m.map(e=>{let n=e===t.branch,i=a.get(e);return(0,X.jsxs)(`li`,{"data-slot":`branch-row`,"data-branch":e,"data-branch-class":i?.class,className:`flex min-h-[60px] flex-col items-start justify-center gap-1.5 py-2 md:flex-row md:items-center md:justify-start md:gap-2.5`,children:[(0,X.jsxs)(`span`,{className:`flex min-w-0 max-w-full items-center gap-[8px]`,children:[i?.runId?(0,X.jsx)(F,{to:`/tasks/${i.runId}`,"data-slot":`branch-task-link`,title:i.title?`Open the task ${i.title}`:`Open the task`,className:`min-w-0 truncate rounded-[2px] font-mono text-[12px] underline-offset-2 hover:underline focus-visible:outline-2 focus-visible:outline-ring`,children:e}):(0,X.jsx)(`span`,{className:r(`min-w-0 truncate font-mono text-[12px]`,n&&`font-medium`),children:e}),i&&!(n&&i.class===`active`)?(0,X.jsx)(Wt,{entry:i}):null]}),i?(0,X.jsx)(zt,{entry:i,base:o}):null,i?(0,X.jsx)(Lt,{entry:i}):null,e.startsWith(`cez/`)&&!n?null:n?(0,X.jsx)(`span`,{"data-slot":`branch-current`,className:`flex h-8 shrink-0 items-center rounded-md bg-accent-strong/10 px-2.5 text-[12px] font-medium text-accent-text md:ml-auto`,children:`Current`}):(0,X.jsxs)(N,{variant:`outline`,size:`sm`,"data-action":`switch-branch`,className:`h-8 max-md:h-11 no-hover:h-11 md:ml-auto`,disabled:l,onClick:()=>c.mutate(e),children:[(0,X.jsx)(fe,{size:16,"aria-hidden":`true`}),`Switch`]})]},e)}),m.length===0?(0,X.jsxs)(`li`,{"data-slot":`branch-empty`,className:`py-3 text-xs text-muted-foreground`,children:[`No branches match “`,u.trim(),`”.`]}):null]})]})})}function zt({entry:e,base:t}){let n=e.pr?.state===`open`||e.pr?.state===`draft`;return(0,X.jsxs)(`span`,{"data-slot":`branch-facts`,className:`flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1 text-xs text-muted-foreground`,children:[(0,X.jsxs)(`span`,{"data-slot":`branch-counts`,title:`${Z(e.ahead)} ahead of ${t}, ${Z(e.behind)} behind`,className:`shrink-0 font-mono tabular-nums`,children:[(0,X.jsxs)(`span`,{"aria-hidden":`true`,children:[`↑`,e.ahead,` ↓`,e.behind]}),(0,X.jsxs)(`span`,{className:`sr-only`,children:[Z(e.ahead),` ahead of `,t,`, `,Z(e.behind),` behind`]})]}),e.pr?(0,X.jsx)(Vt,{pr:e.pr}):null,n&&e.pr?.checks?(0,X.jsx)(Ht,{checks:e.pr.checks}):null]})}var Z=e=>`${e} commit${e===1?``:`s`}`,Bt={open:{icon:O,className:`border-success/40 text-semantic-green`},draft:{icon:ie,className:`border-border text-muted-foreground`},merged:{icon:k,className:`border-merged-strong/35 text-merged-text`},closed:{icon:A,className:`border-danger/40 text-semantic-red`}};function Vt({pr:e}){let{icon:t,className:n}=Bt[e.state],i=(0,X.jsxs)(`span`,{className:r(`inline-flex h-6 items-center gap-1 rounded-[4px] border px-1.5 text-xs font-medium group-hover:bg-muted`,n),children:[(0,X.jsx)(t,{size:12,"aria-hidden":`true`,className:`size-3 shrink-0`}),(0,X.jsxs)(`span`,{className:`font-mono`,children:[`#`,e.number]}),(0,X.jsx)(`span`,{children:e.state})]}),o=`inline-flex shrink-0 items-center rounded-[4px] max-md:min-h-11 no-hover:min-h-11`;return a(e.url)?(0,X.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,"data-slot":`branch-pr`,"data-pr-state":e.state,title:`Open pull request #${e.number}`,className:r(o,`group focus-visible:outline-2 focus-visible:outline-ring`),children:i}):(0,X.jsx)(`span`,{"data-slot":`branch-pr`,"data-pr-state":e.state,className:o,children:i})}function Ht({checks:e}){let t=e===`passing`?ye:e===`failing`?be:yt;return(0,X.jsxs)(`span`,{"data-slot":`pr-checks`,"data-checks":e,className:r(`inline-flex shrink-0 items-center gap-1 text-[12px] font-medium`,e===`passing`&&`text-success`,e===`failing`&&`text-danger`,e===`pending`&&`text-muted-foreground`),children:[(0,X.jsx)(t,{"aria-hidden":`true`,className:`size-3.5 shrink-0`}),e]})}var Ut={active:`in use`,"not-landed":`not landed`,orphan:`not landed`,merged:`merged`,empty:`empty`,other:`yours`};function Wt({entry:e}){return(0,X.jsx)(`span`,{"data-slot":`branch-class`,className:r(`shrink-0 rounded-[4px] border px-1.5 py-px text-xs leading-4 font-medium`,e.class===`active`?`border-status-running/40 text-status-running`:e.class===`not-landed`||e.class===`orphan`?`border-inbox-count-foreground/40 text-inbox-count-foreground`:`border-border text-soft-foreground`),children:Ut[e.class]})}function Gt(e,t){let n=new Set(e.branches);for(let e of t??[])n.add(e.name);return[...n].sort((e,t)=>e.localeCompare(t))}function Kt(){let e=g(),t=I(),[n,r]=(0,Y.useState)(`unified`),[i,a]=(0,Y.useState)(!0),[o,s]=(0,Y.useState)(!1),[c,l]=(0,Y.useState)(null),u=(0,Y.useRef)(null),d=e.isError&&e.error instanceof _&&e.error.status===409,f=e.data?.files??[],p=(0,Y.useMemo)(()=>Ce(f),[f]),m=(0,Y.useMemo)(()=>f.some(St),[f]),h=t?n:`unified`;return(0,X.jsx)(`section`,{"data-slot":`repo-changes`,className:`flex min-h-0 flex-1 flex-col`,children:e.isPending?(0,X.jsx)(`p`,{"data-slot":`changes-loading`,className:`py-6 text-center text-xs text-muted-foreground`,children:`Loading changes…`}):e.isError?(0,X.jsx)(L,{icon:d?(0,X.jsx)(ge,{size:16}):(0,X.jsx)(j,{size:16}),tone:d?`neutral`:`danger`,heading:`h2`,title:d?`No changes to show`:`Could not load the changes`,subtitle:e.error.message}):f.length===0?(0,X.jsx)(L,{icon:(0,X.jsx)(ge,{size:16}),tone:`neutral`,heading:`h2`,title:`Working tree clean`,subtitle:`No uncommitted changes in the main working tree. Edits show up here as they happen.`}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{"data-slot":`repo-changes-toolbar`,className:`flex flex-wrap items-center gap-x-3 gap-y-2 pb-4 [&_button]:min-h-11`,children:[e.data?(0,X.jsx)(we,{stat:e.data.stat}):null,(0,X.jsxs)(`span`,{className:`ml-auto flex items-center gap-2`,children:[m&&o?(0,X.jsx)(De,{}):null,m?(0,X.jsx)(`span`,{className:`max-md:hidden`,children:(0,X.jsx)(Ee,{preview:o,onPreviewChange:s})}):null,(0,X.jsx)(ke,{mode:n,wrap:i,onModeChange:r,onWrapChange:a,disabled:m&&o}),(0,X.jsx)(Oe,{wrap:i,onWrapChange:a,preview:o,onPreviewChange:m?s:void 0,disabled:m&&o})]})]}),(0,X.jsx)(Tt,{className:`gap-5 [--diff-sticky-top:0px] md:gap-0`,treeSlot:`changes-tree-pane`,treeClassName:`overflow-y-auto overscroll-contain rounded-xl border border-border bg-card p-3.5 md:sticky md:top-4 md:max-h-[calc(100dvh_-_64px_-_2rem)]`,tree:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`h2`,{"data-slot":`changes-tree-heading`,className:`mb-3 border-b border-border pb-3 text-xs font-semibold`,children:`Changed files`}),(0,X.jsx)(Se,{root:p,selected:c,onSelect:e=>{l(e),u.current?.scrollToPath(e)}})]}),children:(0,X.jsx)(Ct,{files:f,viewRef:u,mode:h,wrap:i,preview:o,loadFileText:e=>Et(()=>te(e)),totals:!1,className:`min-w-0 flex-1`})})]})})}function qt({repo:e,info:t}){let{sha:n}=T(),r=I(),i=e.log,a=(0,Y.useMemo)(()=>it(i),[i]);if(n&&(!r||i.length===0))return(0,X.jsx)(Qt,{sha:n});let o=nt(e,t),s=o&&o.behind>0?(0,X.jsx)(Xt,{info:t,tracking:o}):null;if(i.length===0)return(0,X.jsxs)(X.Fragment,{children:[s?(0,X.jsx)(`div`,{children:s}):null,(0,X.jsx)(L,{icon:(0,X.jsx)(ae,{size:16}),tone:`neutral`,heading:`h2`,title:`No commits yet`,subtitle:`The log is empty — this repository has no commits to show.`})]});let c=(0,X.jsxs)(`div`,{"data-slot":`repo-commits`,className:`flex flex-col gap-4`,children:[s,a.map(e=>(0,X.jsxs)(`section`,{"data-slot":`repo-commit-day`,"aria-label":e.label,className:`flex flex-col gap-1.5`,children:[(0,X.jsx)(`h2`,{className:`text-xs font-medium text-muted-foreground`,children:e.label}),(0,X.jsx)(`ul`,{className:`flex flex-col divide-y divide-border rounded-xl border border-border bg-card`,children:e.commits.map(e=>(0,X.jsx)(Jt,{commit:e,selected:r&&e.hash===(n??i[0]?.hash),stacked:r},e.hash))})]},e.label))]});return r?(0,X.jsx)(Tt,{className:`flex-none`,treeSlot:`repo-commits-pane`,tree:c,children:(0,X.jsx)(Zt,{sha:n??i[0]?.hash})}):c}function Jt({commit:e,selected:t,stacked:n}){return(0,X.jsxs)(`li`,{"data-selected":t?`true`:void 0,className:r(`flex min-h-[52px] gap-3.5 first:rounded-t-xl last:rounded-b-xl hover:bg-sidebar-row-hover`,n?`flex-col items-stretch gap-0`:`items-center`,t&&`bg-muted/70`),children:[(0,X.jsxs)(F,{to:`/git/commits/${e.hash}`,"data-slot":`commit-row`,"data-sha":e.hash,"aria-current":t?`true`:void 0,className:`flex min-h-[52px] min-w-0 flex-1 flex-col justify-center gap-0.5 px-4 py-2 focus-visible:outline-2 focus-visible:outline-ring`,children:[(0,X.jsx)(`span`,{"data-slot":`commit-row-subject`,className:`truncate text-[13px] font-medium text-foreground`,children:e.subject}),(0,X.jsxs)(`span`,{"data-slot":`commit-row-meta`,className:`flex min-w-0 items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,X.jsx)(Ot,{sha:e.hash}),(0,X.jsx)(`span`,{"aria-hidden":`true`,className:`shrink-0`,children:`·`}),(0,X.jsxs)(`span`,{className:`truncate`,children:[e.author,` · `,(0,X.jsx)(`span`,{title:tt(e.when,e.at),children:ht(e.when,e.at)})]})]})]}),(0,X.jsx)(Yt,{source:e.source,stacked:n})]})}function Yt({source:e,stacked:t}){let n=r(`hidden shrink-0 items-center gap-[5px] text-xs text-muted-foreground md:flex`,t?`-mt-1.5 max-w-full self-start px-4 pb-2.5`:`max-w-[45%] pr-4`);return e?(0,X.jsxs)(F,{to:`/tasks/${e.runId}`,"data-slot":`commit-source`,"data-source":`task`,"aria-label":`From the task ${e.title}${e.prNumber===null?``:`, pull request #${e.prNumber}`}`,className:r(n,`rounded-[4px] hover:text-foreground focus-visible:outline-2 focus-visible:outline-ring`),children:[e.prNumber===null?null:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(k,{"aria-hidden":`true`,className:`size-[11px] shrink-0 text-merged-text`}),(0,X.jsxs)(`span`,{className:`shrink-0 text-muted-foreground`,children:[`PR #`,e.prNumber]})]}),(0,X.jsx)(ue,{"aria-hidden":`true`,className:`size-[12px] shrink-0`}),(0,X.jsx)(`span`,{className:`min-w-0 truncate`,children:e.title})]}):(0,X.jsx)(`span`,{"data-slot":`commit-source`,"data-source":`unknown`,className:n,children:`no task found`})}function Xt({info:e,tracking:t}){let n=ot(i(),e),r=(0,Y.useRef)(null);return(0,X.jsxs)(`div`,{"data-slot":`git-incoming`,className:`flex min-h-[44px] items-center gap-2.5 rounded-xl border border-border bg-card px-4 py-2`,children:[(0,X.jsx)(jt,{"aria-hidden":`true`,className:`size-[14px] shrink-0 text-inbox-count-foreground`}),(0,X.jsxs)(`span`,{className:`min-w-0 flex-1 text-[12.5px] text-muted-foreground`,children:[t.behind,` commit`,t.behind===1?``:`s`,` on `,t.ref,` `,t.behind===1?`is`:`are`,` not in your checkout yet`]}),(0,X.jsxs)(`button`,{ref:r,type:`button`,"data-action":`repo-pull-incoming`,disabled:!n.hasRemote||n.pulling,onClick:()=>void n.pull(),className:`inline-flex h-[28px] shrink-0 items-center gap-[4px] rounded-[6px] bg-muted px-[10px] text-[12px] font-medium text-foreground hover:brightness-110 focus-visible:outline-2 focus-visible:outline-ring disabled:opacity-50 max-md:h-11 [&>svg]:size-[12px]`,children:[n.pulling?(0,X.jsx)(Te,{"aria-hidden":`true`,className:`motion-safe:animate-spin`}):(0,X.jsx)(me,{"aria-hidden":`true`}),`Pull`]}),(0,X.jsx)(rt,{checkout:n,returnFocus:r})]})}function Zt({sha:e}){return(0,X.jsx)(Dt,{commit:u(e),sha:e,slot:`repo-commit-preview`,loadFileText:t=>Et(()=>S(e,t))})}function Qt({sha:e}){return(0,X.jsx)(kt,{commit:u(e),sha:e,backTo:$e,backLabel:`All recent commits`,slot:`repo-commit`,loadFileText:t=>Et(()=>S(e,t))})}var $t=`Squash-merged branches may show as not landed without GitHub`;function en(e){let t=[],n=[],r=[];for(let i of e)if(i.class===`orphan`)r.push(i);else if(i.class!==`not-landed`)continue;else i.pr&&(i.pr.state===`open`||i.pr.state===`draft`)?n.push(i):t.push(i);return[{key:`no-pr`,title:`No pull request`,note:`nobody sees this work until you act`,rows:t},{key:`pr-open`,title:`Pull request open`,rows:n},{key:`deleted`,title:`Task deleted`,note:`this branch is the only copy of the work`,rows:r}].filter(e=>e.rows.length>0)}function tn(e){return e.filter(e=>e.class===`active`&&e.runId!==null&&e.ahead>0&&(e.runStatus===`done`||e.runStatus===`failed`||e.runStatus===`cancelled`)).length}function nn(){let e=s(),t=m(),n=i(),r=p(),[a,o]=(0,Y.useState)(null);if(e.isPending)return(0,X.jsx)(`p`,{"data-slot":`not-landed-loading`,role:`status`,className:`py-5 text-[13px] text-muted-foreground`,children:`Loading branches…`});if(e.isError)return(0,X.jsx)(L,{icon:(0,X.jsx)(j,{size:16}),tone:`danger`,heading:`h2`,title:`Could not classify the branches`,subtitle:e.error.message});let c=en(e.data.branches),l=c.reduce((e,t)=>e+t.rows.length,0),u=tn(e.data.branches),d=u>0?(0,X.jsxs)(`p`,{"data-slot":`not-landed-retained`,className:`flex items-start gap-2 text-xs leading-relaxed text-muted-foreground`,children:[(0,X.jsx)(M,{"aria-hidden":`true`,className:`mt-0.5 size-3.5 shrink-0`}),(0,X.jsxs)(`span`,{children:[u,` finished task`,u===1?` still has its`:`s still have their`,` worktree and commits not on the base, so `,u===1?`it is`:`they are`,` not listed here.`,` `,`They show here once the worktree is reclaimed in `,(0,X.jsx)(F,{to:H.cleanup,className:`underline underline-offset-2 hover:text-foreground`,children:`Cleanup`}),`.`]})]}):null,f=new Map((t.data??[]).map(e=>[e.id,e.finishedAt]));return(0,X.jsxs)(je,{projectId:n,repoBase:r,requests:c.flatMap(e=>e.rows).flatMap(e=>e.pr?[{projectId:n,kind:`PR`,number:e.pr.number}]:[]),children:[(0,X.jsxs)(`div`,{"data-slot":`repo-not-landed`,className:`flex flex-col gap-4 pb-[calc(90px+env(safe-area-inset-bottom))] md:pb-0`,children:[e.data.prStateKnown?null:(0,X.jsx)(rn,{}),d,c.length===0?(0,X.jsx)(Xe,{icon:(0,X.jsx)(_t,{size:16}),title:u>0?`Nothing else waiting to land`:`Everything landed`,description:u>0?`Every other finished task's commits are on the base branch, or it made none.`:`Every finished task's commits are on the base branch, or it made none.`,actions:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(N,{variant:`outline`,size:`sm`,asChild:!0,className:`max-md:min-h-11`,children:(0,X.jsx)(F,{to:H.cleanup,children:`Check cleanup`})}),(0,X.jsx)(N,{variant:`outline`,size:`sm`,asChild:!0,className:`max-md:min-h-11`,children:(0,X.jsx)(F,{to:`/`,children:`View tasks`})})]})}):(0,X.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,X.jsx)(`div`,{className:`flex flex-col gap-5`,children:c.map(e=>(0,X.jsxs)(`section`,{"data-slot":`not-landed-group`,"data-group":e.key,"aria-label":e.title,className:`flex flex-col gap-1.5`,children:[(0,X.jsxs)(`h2`,{className:`flex min-w-0 flex-wrap items-baseline gap-x-1.5 text-xs text-muted-foreground`,children:[(0,X.jsx)(`span`,{className:`font-semibold text-foreground`,children:e.title}),(0,X.jsx)(`span`,{className:`tabular-nums`,children:e.rows.length}),e.note?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Q,{}),(0,X.jsx)(`span`,{children:e.note})]}):null]}),(0,X.jsx)(`ul`,{className:`flex flex-col divide-y divide-border rounded-xl border border-border bg-card`,children:e.rows.map(e=>(0,X.jsx)(an,{entry:e,finishedAt:e.runId?f.get(e.runId):void 0,onDelete:()=>o(e)},e.name))})]},e.key))}),(0,X.jsxs)(`p`,{"data-slot":`not-landed-note`,className:`flex items-start gap-1.5 px-1 text-xs leading-snug text-muted-foreground`,children:[(0,X.jsx)(M,{"aria-hidden":`true`,className:`mt-px size-3 shrink-0`}),`Delete a branch from its row's … menu. It confirms and names the commits it drops; nothing here is bulk-deleted.`]}),l<=3?(0,X.jsx)(Je,{summary:`${l} ${l===1?`branch`:`branches`} waiting to land. Open a draft PR or inspect worktrees in Cleanup.`,actions:(0,X.jsx)(N,{variant:`outline`,size:`sm`,asChild:!0,className:`max-md:min-h-11`,children:(0,X.jsx)(F,{to:H.cleanup,children:`Open cleanup`})})}):null]})]}),(0,X.jsx)(un,{entry:a,onClose:()=>o(null)})]})}function rn({className:e}){return(0,X.jsxs)(`p`,{"data-slot":`git-no-forge`,className:r(`flex items-start gap-2 text-xs leading-relaxed text-muted-foreground`,e),children:[(0,X.jsx)(M,{"aria-hidden":`true`,className:`mt-0.5 size-3.5 shrink-0`}),$t,`.`]})}function an({entry:e,finishedAt:t,onDelete:n}){return(0,X.jsxs)(`li`,{"data-slot":`not-landed-row`,"data-branch":e.name,"data-branch-class":e.class,className:`flex min-h-[60px] items-center gap-3 px-4 py-3 first:rounded-t-xl last:rounded-b-xl hover:bg-sidebar-row-hover`,children:[(0,X.jsx)(cn,{entry:e,finishedAt:t}),(0,X.jsx)(on,{entry:e}),(0,X.jsx)(sn,{entry:e,onDelete:n})]})}function on({entry:e}){return(0,X.jsx)(X.Fragment,{children:e.pr?(0,X.jsxs)(`span`,{"data-slot":`not-landed-pr`,className:`hidden shrink-0 items-center gap-1.5 text-xs text-muted-foreground md:flex`,children:[(0,X.jsx)(Me,{plain:!0,reference:{kind:`PR`,number:e.pr.number,url:e.pr.url},taskTitle:e.title??e.name,status:e.pr.state===`draft`?`draft`:e.pr.state===`closed`?`closed`:void 0}),(0,X.jsx)(ln,{entry:e})]}):null})}function sn({entry:e,onDelete:t}){let n=x(),i=e.class===`orphan`,a=e.pr&&(e.pr.state===`open`||e.pr.state===`draft`)?e.pr:null,o=!i&&e.runId!==null&&!a,s=h({mutationFn:()=>b(e.runId),onSuccess:e=>{y(`Draft PR created — ${e.url}`),n.invalidateQueries({queryKey:f.repoBranches}),n.invalidateQueries({queryKey:f.runs.all})},onError:e=>y(e instanceof _&&e.manual?`${e.message} — ${e.manual}`:e.message,{tone:`danger`})}),[c,l]=(0,Y.useState)(!1),u=(0,Y.useRef)(null);(0,Y.useEffect)(()=>()=>{u.current!==null&&clearTimeout(u.current)},[]);let d=()=>void navigator.clipboard.writeText(e.name).then(()=>{y(`Copied ${e.name}`),u.current!==null&&clearTimeout(u.current),l(!0),u.current=setTimeout(()=>l(!1),2e3)},()=>y(`Could not copy the branch name`,{tone:`danger`})),p=`inline-flex h-8 shrink-0 items-center gap-1.5 rounded-sm px-2.5 text-[12.5px] font-medium text-foreground focus-visible:outline-2 focus-visible:outline-ring disabled:opacity-50 [&>svg]:size-[12px]`;return(0,X.jsxs)(X.Fragment,{children:[e.runId?(0,X.jsx)(F,{to:`/tasks/${e.runId}`,"data-action":`not-landed-open`,className:r(p,`hidden border border-border bg-card hover:bg-muted md:inline-flex`),children:`Open task`}):null,o?(0,X.jsxs)(`button`,{type:`button`,"data-action":`not-landed-create-pr`,disabled:s.isPending,onClick:()=>s.mutate(),className:r(p,`hidden border border-border bg-card hover:bg-muted md:inline-flex`),children:[(0,X.jsx)(Mt,{"aria-hidden":`true`}),s.isPending?`Creating…`:`Draft PR`]}):null,i?(0,X.jsxs)(`button`,{type:`button`,"data-action":`not-landed-copy`,"data-copied":c||void 0,"aria-live":`polite`,onClick:d,className:r(p,`hidden border border-border bg-card hover:bg-muted md:inline-flex`),children:[c?(0,X.jsx)(pe,{"aria-hidden":`true`}):(0,X.jsx)(_e,{"aria-hidden":`true`}),c?`Copied`:`Copy branch`]}):null,(0,X.jsxs)(Ie,{children:[(0,X.jsx)(Pe,{"data-action":`not-landed-more`,"aria-label":`More actions for ${e.name}`,className:`flex size-8 shrink-0 items-center justify-center rounded-sm text-soft-foreground outline-none hover:bg-muted hover:text-foreground focus-visible:outline-2 focus-visible:outline-ring max-md:size-11`,children:(0,X.jsx)(se,{"aria-hidden":`true`,className:`size-[14px]`})}),(0,X.jsxs)(Fe,{align:`end`,className:`w-52`,children:[e.runId?(0,X.jsx)(P,{asChild:!0,className:`md:hidden`,children:(0,X.jsx)(F,{to:`/tasks/${e.runId}`,children:`Open task`})}):null,o?(0,X.jsx)(P,{className:`md:hidden`,disabled:s.isPending,onSelect:()=>s.mutate(),children:`Draft PR`}):null,(0,X.jsx)(P,{className:r(!i&&`md:hidden`),onSelect:d,children:`Copy branch`}),(0,X.jsx)(Ne,{className:`md:hidden`}),(0,X.jsx)(P,{"data-action":`not-landed-delete`,variant:`destructive`,onSelect:t,children:`Delete branch…`})]})]})]})}function cn({entry:e,finishedAt:t}){let n=e.class===`orphan`,r=n?`No task · last commit “${e.lastCommit.subject}”`:e.title??e.name,i=t??e.lastCommit.at,a=Ze(i),o=e.runStatus?ct(e.runStatus):void 0,s=n||!o?a:`${o.label}${a?` ${a}`:``}`,c=Number.isFinite(Date.parse(i))?new Date(i).toLocaleString():void 0;return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{className:`flex size-[12px] shrink-0 items-center justify-center`,children:n?(0,X.jsx)(xe,{"aria-label":`Task deleted`,className:`size-[12px] text-muted-foreground`}):(0,X.jsx)(We,{tone:o?.tone??`neutral`,shape:o?.shape??`filled`,"aria-label":o?.label})}),(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[e.runId?(0,X.jsx)(F,{to:`/tasks/${e.runId}`,"data-slot":`not-landed-title`,className:`min-w-0 truncate rounded-[2px] text-[13px] font-medium text-foreground hover:underline underline-offset-2 focus-visible:outline-2 focus-visible:outline-ring`,children:r}):(0,X.jsx)(`span`,{"data-slot":`not-landed-title`,className:`min-w-0 truncate text-[13px] font-medium text-foreground`,title:r,children:r}),(0,X.jsxs)(`span`,{"data-slot":`not-landed-meta`,className:`flex min-w-0 items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,X.jsx)(`span`,{className:`shrink-0 font-mono text-xs`,children:e.name}),(0,X.jsx)(Q,{}),(0,X.jsxs)(`span`,{className:`shrink-0`,children:[e.ahead,` commit`,e.ahead===1?``:`s`]}),e.diffStat?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Q,{}),(0,X.jsx)(wt,{adds:e.diffStat.additions,dels:e.diffStat.deletions})]}):null,s?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Q,{}),(0,X.jsx)(`span`,{className:`truncate`,title:c,children:s})]}):null]}),e.parentRunId?(0,X.jsx)(F,{to:`/tasks/${e.parentRunId}`,"data-slot":`not-landed-parent`,className:`w-fit rounded-[2px] text-xs text-muted-foreground hover:underline underline-offset-2 focus-visible:outline-2 focus-visible:outline-ring`,children:`Worker of its parent task`}):null,(0,X.jsx)(Lt,{entry:e})]})]})}function Q(){return(0,X.jsx)(`span`,{"aria-hidden":`true`,className:`shrink-0`,children:`·`})}function ln({entry:e}){let t=c(Ae(`PR`,e.pr?.number).status),n=e.pr?.state,r=n===`draft`||n===`closed`?n:t?t.label.toLowerCase():`open`;return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Q,{}),(0,X.jsx)(`span`,{"data-slot":`not-landed-pr-state`,children:r})]})}function un({entry:e,onClose:t}){let n=x(),[r,i]=(0,Y.useState)(``),a=(0,Y.useId)(),o=h({mutationFn:e=>v({names:[e],confirm:e}),onSuccess:e=>{let t=e.dropped?.length??0;y(e.deleted.length>0?`Deleted ${e.deleted[0]}${t?` and ${t} commit${t===1?``:`s`} with it`:``}`:e.refused[0]?.reason??`Nothing was deleted`),n.invalidateQueries({queryKey:f.repo}),s()},onError:e=>y(e.message,{tone:`danger`})}),s=()=>{i(``),t()},c=e!==null&&r.trim()===e.name,l=e&&`${e.ahead} commit${e.ahead===1?``:`s`}`;return(0,X.jsx)(J,{open:e!==null,onOpenChange:e=>!e&&!o.isPending&&s(),children:(0,X.jsxs)(U,{"data-slot":`delete-branch-dialog`,children:[(0,X.jsxs)(R,{children:[(0,X.jsxs)(q,{children:[`Delete `,e?.name,`?`]}),(0,X.jsx)(G,{asChild:!0,children:(0,X.jsxs)(`div`,{className:`space-y-2`,children:[(0,X.jsx)(`p`,{children:e?.class===`orphan`?`Its task was deleted, so this branch is the only copy of the work.`:(0,X.jsxs)(X.Fragment,{children:[`This drops the work of `,(0,X.jsx)(`span`,{className:`font-medium text-foreground`,children:e?.title??e?.name}),`. It is not on the base branch`,e?.pr?``:` and no pull request carries it`,`.`]})}),(0,X.jsxs)(`p`,{"data-slot":`delete-branch-dropped`,children:[l,` will be dropped`,e?.diffStat?` (+${e.diffStat.additions} −${e.diffStat.deletions})`:``,`, the latest “`,e?.lastCommit.subject,`”`,e?.lastCommit.sha?(0,X.jsxs)(X.Fragment,{children:[` (`,(0,X.jsx)(bt,{sha:e.lastCommit.sha,variant:`inline`}),`)`]}):null,`.`]})]})})]}),(0,X.jsxs)(`form`,{onSubmit:t=>{t.preventDefault(),c&&e&&!o.isPending&&o.mutate(e.name)},className:`flex flex-col gap-[6px]`,children:[(0,X.jsxs)(`label`,{htmlFor:a,className:`text-[12.5px] text-muted-foreground`,children:[`Type `,(0,X.jsx)(`span`,{className:`font-mono text-foreground`,children:e?.name}),` to confirm`]}),(0,X.jsx)(vt,{id:a,"data-slot":`delete-branch-confirm`,autoComplete:`off`,spellCheck:!1,value:r,onChange:e=>i(e.target.value),className:`h-11 font-mono`})]}),(0,X.jsxs)(V,{children:[(0,X.jsx)(W,{className:`h-11`,disabled:o.isPending,children:`Keep it`}),(0,X.jsx)(B,{"data-action":`delete-branch-confirm`,className:`h-11 bg-danger text-danger-foreground hover:brightness-[0.96]`,disabled:!c||o.isPending,onClick:t=>{t.preventDefault(),e&&o.mutate(e.name)},children:o.isPending?`Deleting…`:`Delete branch`})]})]})})}function dn({base:e}){let t=s(),n=x(),[r,i]=(0,Y.useState)({merged:!1,empty:!1}),[a,o]=(0,Y.useState)(!1),c=(t.data?.branches??[]).filter(e=>e.class===`merged`),l=(t.data?.branches??[]).filter(e=>e.class===`empty`),u=[...c,...l],d=h({mutationFn:e=>v({names:e}),onSuccess:e=>{let t=e.refused.length;y(`Deleted ${e.deleted.length} branch${e.deleted.length===1?``:`es`}${t?`; kept ${t} that ${t===1?`is`:`are`} no longer safe to delete`:``}`),n.invalidateQueries({queryKey:f.repo})},onError:e=>{n.invalidateQueries({queryKey:f.repo}),y(e.message,{tone:`danger`})}});if(t.isPending)return(0,X.jsx)(`p`,{"data-slot":`cleanup-branches-loading`,className:`text-[13px] text-soft-foreground`,children:`Loading branches…`});if(t.isError)return(0,X.jsxs)(`p`,{"data-slot":`cleanup-branches-error`,className:`text-[13px] text-danger`,children:[`Branches did not load: `,t.error.message]});let p=u.length,m=`branch${p===1?``:`es`}`;return(0,X.jsxs)(`section`,{"data-slot":`cleanup-branches`,"aria-labelledby":`cleanup-branches-title`,className:`flex flex-col rounded-[8px] border border-border`,children:[(0,X.jsxs)(`div`,{className:`flex flex-col gap-[10px] border-b border-border px-[14px] py-[12px] md:flex-row md:items-center`,children:[(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-[2px]`,children:[(0,X.jsxs)(`h2`,{id:`cleanup-branches-title`,className:`text-[13px] font-semibold text-foreground`,children:[`Branches safe to delete · `,p]}),(0,X.jsxs)(`p`,{className:`text-xs leading-[17px] text-soft-foreground`,children:[`Their work is already on `,e,`, or they have none. Deleting loses nothing.`]})]}),(0,X.jsxs)(`button`,{type:`button`,"data-action":`cleanup-branches-delete`,disabled:p===0||d.isPending,onClick:()=>o(!0),className:`inline-flex h-[28px] shrink-0 items-center gap-[5px] self-start rounded-[6px] bg-muted px-[10px] text-[12px] font-medium text-foreground hover:brightness-110 focus-visible:outline-2 focus-visible:outline-ring disabled:opacity-50 disabled:hover:brightness-100 max-md:h-11 md:self-center`,children:[(0,X.jsx)(he,{"aria-hidden":`true`,className:`size-[12px]`}),d.isPending?`Deleting…`:`Delete ${p} ${m}`]})]}),(0,X.jsx)(fn,{kind:`merged`,title:`Merged into ${e}`,hint:t.data.prStateKnown?`including squash-merged PRs, read from the PR state`:$t.toLowerCase(),rows:c,open:r.merged,onToggle:()=>i(e=>({...e,merged:!e.merged}))}),(0,X.jsx)(fn,{kind:`empty`,title:`Empty`,hint:`no commits beyond the fork point`,rows:l,open:r.empty,onToggle:()=>i(e=>({...e,empty:!e.empty}))}),(0,X.jsx)(J,{open:a,onOpenChange:o,children:(0,X.jsxs)(U,{children:[(0,X.jsxs)(R,{children:[(0,X.jsxs)(q,{children:[`Delete `,p,` `,m,`?`]}),(0,X.jsxs)(G,{children:[c.length,` merged into `,e,` and `,l.length,` empty. Their work is already on `,e,`, or they have none. Anything that stopped being safe since this list loaded is kept.`]})]}),(0,X.jsxs)(V,{children:[(0,X.jsx)(W,{children:`Keep them`}),(0,X.jsxs)(B,{"data-action":`cleanup-branches-confirm`,className:`bg-danger text-danger-foreground hover:brightness-[0.96]`,onClick:()=>{d.mutate(u.map(e=>e.name)),o(!1)},children:[`Delete `,p,` `,m]})]})]})})]})}function fn({kind:e,title:t,hint:n,rows:i,open:a,onToggle:o}){let s=`cleanup-branches-${e}`;return(0,X.jsxs)(`div`,{"data-slot":`cleanup-branch-group`,"data-group":e,className:`border-b border-border last:border-0`,children:[(0,X.jsxs)(`button`,{type:`button`,"aria-expanded":a,"aria-controls":s,disabled:i.length===0,onClick:o,className:`flex min-h-[44px] w-full items-center gap-[12px] px-[14px] py-[4px] text-left hover:bg-sidebar-row-hover focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-ring disabled:hover:bg-transparent`,children:[(0,X.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-[2px]`,children:[(0,X.jsxs)(`span`,{className:`truncate text-[12.5px] text-foreground`,children:[t,` · `,i.length]}),(0,X.jsx)(`span`,{className:`truncate text-xs text-soft-foreground`,children:n})]}),i.length>0?(0,X.jsx)(de,{"aria-hidden":`true`,className:r(`size-[13px] shrink-0 text-soft-foreground transition-transform motion-reduce:transition-none`,a&&`rotate-90`)}):null]}),a?(0,X.jsx)(`ul`,{id:s,"aria-label":t,className:`flex flex-col pb-[6px]`,children:i.map(e=>(0,X.jsxs)(`li`,{"data-slot":`cleanup-branch-row`,"data-branch":e.name,className:`flex min-h-[32px] items-center gap-[10px] px-[14px] pl-[26px] text-xs`,children:[(0,X.jsx)(at,{value:e.name,className:`shrink-0 text-muted-foreground`}),e.runId?(0,X.jsx)(F,{to:`/tasks/${e.runId}`,className:`min-w-0 flex-1 truncate text-soft-foreground underline-offset-2 hover:text-foreground hover:underline`,children:e.title??`Open the task`}):(0,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-soft-foreground`,children:e.lastCommit.subject}),e.pr?(0,X.jsxs)(`span`,{className:`shrink-0 text-soft-foreground`,children:[`PR #`,e.pr.number]}):null,(0,X.jsx)(dt,{iso:e.lastCommit.at,className:`shrink-0 text-soft-foreground`})]},e.name))}):null]})}function $(e){return e.some(e=>e.sizeBytes===null)?null:e.reduce((e,t)=>e+(t.sizeBytes??0),0)}function pn(e){return e.kind===`dirty`?`${e.uncommittedFiles} uncommitted`:e.kind===`detached-head`?`detached HEAD`:e.kind===`submodules`?`has submodules`:`broken worktree`}function mn(e){if(e.kind===`dirty`){let t=`${e.uncommittedFiles} uncommitted file${e.uncommittedFiles===1?``:`s`}`;return e.detachedHead?`${t} and a detached HEAD on no branch`:t}return e.kind===`detached-head`?`a detached HEAD whose commit is on no branch`:e.kind===`submodules`?`initialized submodules that Git will not remove without force`:`an unregistered or broken Git worktree directory`}function hn(e){let t=e.some(e=>e.reclaimBlocker?.kind===`dirty`),n=e.some(e=>e.reclaimBlocker?.kind===`detached-head`||e.reclaimBlocker?.kind===`dirty`&&e.reclaimBlocker.detachedHead),r=e.some(e=>e.reclaimBlocker?.kind===`submodules`),i=e.some(e=>e.reclaimBlocker?.kind===`invalid`),a=[...t?[`uncommitted work`]:[],...n?[`a detached HEAD`]:[],...r?[`initialized submodules`]:[],...i?[`a broken checkout`]:[]];return a.length<=1?a[0]??`uncommitted work`:`${a.slice(0,-1).join(`, `)} or ${a.at(-1)}`}function gn(e,t,n){let r=Math.max(0,t-e);return e===0?r===0?`Nothing to reclaim — no finished worktrees exceed the keep limit`:n?`Nothing was reclaimed — the worktrees past the keep limit are in use or could not be removed`:`Nothing was reclaimed — the worktrees past the keep limit have uncommitted work or are in use`:`Reclaimed ${e} worktree${e===1?``:`s`} (branch kept)${r>0?` · ${r} kept: ${n?`in use or could not be removed`:`uncommitted work or in use`}`:``}`}function _n(e,t){return e===0?`Reclaim now`:t?`Reclaim ${E(t)} now`:`Reclaim ${e} now`}function vn(e,t,n){let r=t?E(t):String(e);return n?`Discard & reclaim all ${r}`:`Discard & reclaim ${r}`}function yn(e,t){if(!e)return t>0?`No clean worktrees past the keep limit — use Discard & reclaim for blocked worktrees`:`Nothing past the keep limit to reclaim`}function bn(e){return e===0?{prefix:`Retention is unlimited (`,suffix:`), so nothing is reclaimed on its own.`}:{prefix:`Retention keeps the newest ${e} finished checkout${e===1?``:`s`} (`,suffix:`) and reclaims the rest.`}}function xn({blocked:e,discardLabel:t,disabled:n,onDiscard:r}){let i=$(e),a=e.length===1?``:`s`,o=e.length===1?`it has`:`they have`;return(0,X.jsxs)(`div`,{"data-slot":`worktrees-blocked-banner`,className:`flex flex-col gap-[10px] border-b border-border bg-muted/40 px-[14px] py-[10px] md:flex-row md:items-center`,children:[(0,X.jsxs)(`p`,{className:`min-w-0 flex-1 text-[12px] leading-[17px] text-foreground`,children:[e.length,` worktree`,a,` past the keep limit`,i?` (${E(i)})`:``,` `,`cannot be reclaimed automatically because `,o,` `,hn(e),`.`]}),(0,X.jsxs)(`button`,{type:`button`,"data-action":`worktrees-discard-reclaim`,disabled:n,onClick:r,className:`inline-flex h-[28px] shrink-0 items-center gap-[5px] self-start rounded-[6px] border border-danger/40 px-[10px] text-[12px] font-medium text-danger hover:bg-danger/10 focus-visible:outline-2 focus-visible:outline-ring disabled:opacity-50 max-md:h-11 md:self-center`,children:[(0,X.jsx)(K,{"aria-hidden":`true`,className:`size-[12px]`}),t]})]})}function Sn({confirmClean:e,onCloseClean:t,cleanCount:n,cleanBytes:r,reclaimLabel:i,onConfirmClean:a,discardBatch:o,onCloseDiscardBatch:s,onConfirmDiscardBatch:c,discardRow:l,onCloseRow:u,onConfirmRow:d}){let f=o?$(o):null,p=o?o.filter(e=>e.reclaimBlocker!==null).length:0,m=o?o.some(e=>!e.reclaimBlocker):!1,h=o?vn(o.length,f,m):``;return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(J,{open:e,onOpenChange:e=>{e||t()},children:(0,X.jsxs)(U,{children:[(0,X.jsxs)(R,{children:[(0,X.jsx)(q,{children:`Reclaim old worktrees?`}),(0,X.jsxs)(G,{children:[n,` finished worktree`,n===1?``:`s`,` beyond the keep limit`,r?` (${E(r)})`:``,` `,n===1?`is`:`are`,` reclaimed now, directory only. Their branches are kept, so the work stays recoverable.`]})]}),(0,X.jsxs)(V,{children:[(0,X.jsx)(W,{children:`Keep them`}),(0,X.jsx)(B,{"data-action":`worktrees-confirm`,onClick:a,children:i})]})]})}),(0,X.jsx)(J,{open:o!==null,onOpenChange:e=>{e||s()},children:(0,X.jsxs)(U,{children:[(0,X.jsxs)(R,{children:[(0,X.jsx)(q,{children:`Discard changes and reclaim worktrees?`}),(0,X.jsx)(G,{children:o?(0,X.jsxs)(X.Fragment,{children:[o.length,` finished worktree`,o.length===1?``:`s`,` beyond the keep limit`,f?` (${E(f)})`:``,` will be reclaimed now.`,` `,`Uncommitted files and detached-HEAD commits in `,p,` blocked checkout`,p===1?``:`s`,` will be permanently discarded. Each task’s branch is kept.`]}):null})]}),(0,X.jsxs)(V,{children:[(0,X.jsx)(W,{children:`Keep them`}),(0,X.jsx)(B,{"data-action":`worktrees-discard-confirm`,className:`bg-danger text-danger-foreground hover:brightness-[0.96]`,onClick:()=>{o&&c(o),s()},children:h})]})]})}),(0,X.jsx)(J,{open:l!==null,onOpenChange:e=>{e||u()},children:(0,X.jsxs)(U,{children:[(0,X.jsxs)(R,{children:[(0,X.jsx)(q,{children:`Discard changes and reclaim worktree?`}),(0,X.jsx)(G,{children:l?.reclaimBlocker?(0,X.jsxs)(X.Fragment,{children:[l.title,` has `,mn(l.reclaimBlocker),`. Reclaiming removes the directory and permanently discards uncommitted or unbranched changes in it. The branch (`,l.branch??l.runId.slice(0,8),`) is kept.`]}):null})]}),(0,X.jsxs)(V,{children:[(0,X.jsx)(W,{children:`Keep it`}),(0,X.jsx)(B,{"data-action":`worktree-discard-confirm`,className:`bg-danger text-danger-foreground hover:brightness-[0.96]`,onClick:()=>{l&&d(l),u()},children:`Discard & reclaim`})]})]})})]})}function Cn(){let e=o(),t=d().data?.targets.find(e=>e.id===`finder`),n=h({mutationFn:e=>re(e,t.id),onError:e=>y(e.message,{tone:`danger`})}),r=x(),[i,a]=(0,Y.useState)(!1),[s,c]=(0,Y.useState)(null),[l,u]=(0,Y.useState)(null),p=()=>Promise.all([r.invalidateQueries({queryKey:f.worktrees}),r.invalidateQueries({queryKey:f.repoBranches})]),m=h({mutationFn:({runIds:e})=>ee(e?{discardWork:!0,runIds:e}:void 0),onSuccess:(e,{expected:t,runIds:n})=>{p(),y(gn(e.reclaimed.length,t,!!n))},onError:e=>y(e.message,{tone:`danger`})}),g=h({mutationFn:({worktree:e,discardWork:t})=>ne(e.runId,t?{discardWork:!0}:void 0),onSuccess:(e,{worktree:t})=>{p(),y(`Reclaimed the worktree of ${t.title} (branch kept)`)},onError:e=>{p(),y(e.message,{tone:`danger`})}});if(e.isPending)return(0,X.jsx)(`p`,{"data-slot":`worktrees-loading`,className:`text-[13px] text-soft-foreground`,children:`Loading worktrees…`});if(e.isError)return(0,X.jsxs)(`p`,{"data-slot":`worktrees-error`,className:`text-[13px] text-danger`,children:[`Worktrees did not load: `,e.error.message]});let{worktrees:_,totalBytes:te,keep:v}=e.data,b=m.isPending||g.isPending,S=_.filter(e=>e.pastKeep),C=S.filter(e=>!e.reclaimBlocker),w=S.filter(e=>e.reclaimBlocker!==null),T=C.length>0,D=$(C),ie=$(S),O=_n(C.length,D),ae=vn(S.length,ie,T),k=te?E(te):null,A=bn(v);return(0,X.jsxs)(`section`,{"data-slot":`worktrees-panel`,"aria-labelledby":`worktrees-panel-title`,className:`flex flex-col rounded-[8px] border border-border`,children:[(0,X.jsxs)(`div`,{className:`flex flex-col gap-[10px] border-b border-border px-[14px] py-[12px] md:flex-row md:items-center`,children:[(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-[2px]`,children:[(0,X.jsxs)(`h2`,{id:`worktrees-panel-title`,className:`text-[13px] font-semibold text-foreground`,children:[`Worktrees on disk`,k?` · ${k}`:``]}),(0,X.jsxs)(`p`,{"data-slot":`worktrees-retention`,className:`text-xs leading-[17px] text-soft-foreground`,children:[A.prefix,(0,X.jsx)(F,{to:`/settings/worktrees`,"data-slot":`worktrees-retention-link`,className:`underline-offset-2 hover:text-foreground hover:underline`,children:gt(`worktrees`,` › `)}),A.suffix,` `,`Reclaim removes the directory only; the branch stays, so its work stays recoverable.`]})]}),(0,X.jsxs)(`button`,{type:`button`,"data-action":`worktrees-reclaim-now`,disabled:b||!T,title:yn(T,w.length),onClick:()=>a(!0),className:`inline-flex h-[28px] shrink-0 items-center gap-[5px] self-start rounded-[6px] bg-muted px-[10px] text-[12px] font-medium text-foreground hover:brightness-110 focus-visible:outline-2 focus-visible:outline-ring disabled:opacity-50 disabled:hover:brightness-100 max-md:h-11 md:self-center`,children:[(0,X.jsx)(K,{"aria-hidden":`true`,className:`size-[12px]`}),O]})]}),w.length>0?(0,X.jsx)(xn,{blocked:w,discardLabel:ae,disabled:b,onDiscard:()=>c(S)}):null,_.length===0?(0,X.jsx)(`p`,{"data-slot":`worktrees-empty`,className:`px-[14px] py-[12px] text-[12.5px] text-soft-foreground`,children:`No task worktrees on disk.`}):(0,X.jsx)(`ul`,{"aria-label":`Task worktrees on disk`,className:`flex flex-col`,children:_.map(e=>(0,X.jsx)(En,{worktree:e,keep:v,disabled:b,onOpen:t?()=>n.mutate(e.runId):void 0,opening:n.isPending,onReclaim:()=>{e.reclaimBlocker?u(e):g.mutate({worktree:e,discardWork:!1})}},e.runId))}),(0,X.jsx)(Sn,{confirmClean:i,onCloseClean:()=>a(!1),cleanCount:C.length,cleanBytes:D,reclaimLabel:O,onConfirmClean:()=>{m.mutate({expected:C.length}),a(!1)},discardBatch:s,onCloseDiscardBatch:()=>c(null),onConfirmDiscardBatch:e=>{m.mutate({expected:e.length,runIds:e.map(e=>e.runId)})},discardRow:l,onCloseRow:()=>u(null),onConfirmRow:e=>g.mutate({worktree:e,discardWork:!0})})]})}var wn=new Set([`queued`,`running`,`waiting`,`review`]);function Tn(e,t){return wn.has(e.status)||!e.reclaimable?{label:`in use`,tone:`in-use`,state:`in-use`}:e.reclaimBlocker?{label:pn(e.reclaimBlocker),tone:`blocked`,state:`blocked`}:e.pastKeep?{label:`reclaimable`,tone:`plain`,state:`reclaimable`}:{label:t>0?`kept · newest ${t}`:`kept`,tone:`plain`,state:`kept`}}function En({worktree:e,keep:t,disabled:n,onOpen:i,opening:a,onReclaim:o}){let s=Tn(e,t),c=Ze(e.finishedAt??void 0),l=e.status===`review`?`at review`:c?`${e.status} ${Qe(c)}`:e.status,u=s.tone===`in-use`?`text-status-running`:s.tone===`blocked`?`text-danger`:`text-soft-foreground`,d=e.reclaimBlocker?`Cannot auto-reclaim: ${mn(e.reclaimBlocker)}`:void 0,f=(0,X.jsx)(`span`,{"data-slot":`worktree-state`,"data-state":s.state,title:d,className:r(`text-xs`,u),children:s.label}),p=`flex size-[28px] shrink-0 items-center justify-center rounded-[6px] text-soft-foreground hover:bg-muted hover:text-foreground focus-visible:outline-2 focus-visible:outline-ring disabled:opacity-50 max-md:size-11`,m=e.reclaimBlocker?`Discard changes and reclaim the worktree of ${e.title} (branch kept)`:`Reclaim the worktree of ${e.title} (branch kept)`,h=e.reclaimBlocker?`Discard changes and reclaim the directory (branch kept)`:`Reclaim the directory (branch kept)`;return(0,X.jsxs)(`li`,{"data-slot":`worktree-row`,"data-run":e.runId,className:`flex min-h-[44px] items-center gap-[12px] border-b border-border px-[14px] py-[4px] last:border-0`,children:[(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-[2px]`,children:[(0,X.jsx)(`span`,{className:`truncate text-[12.5px] text-foreground`,title:e.title,children:e.title}),(0,X.jsxs)(`span`,{className:`truncate font-mono text-xs text-soft-foreground`,children:[e.branch??e.runId.slice(0,8),` · `,l,(0,X.jsxs)(`span`,{className:`md:hidden`,children:[` · `,s.label]})]})]}),(0,X.jsx)(`span`,{"data-slot":`worktree-size`,className:`shrink-0 text-xs tabular-nums text-muted-foreground`,children:e.sizeBytes===null?`—`:E(e.sizeBytes)||`0 kB`}),(0,X.jsx)(`span`,{className:`hidden shrink-0 md:inline`,children:f}),i?(0,X.jsx)(`button`,{type:`button`,className:p,"aria-label":`Open folder for ${e.title}`,title:`Open folder`,disabled:a,onClick:i,children:(0,X.jsx)(D,{"aria-hidden":`true`,className:`size-[13px]`})}):null,s.tone===`in-use`?null:(0,X.jsx)(`button`,{type:`button`,"data-action":`worktree-reclaim`,"aria-label":m,title:h,disabled:n,onClick:o,className:r(p,e.reclaimBlocker&&`text-danger hover:text-danger`),children:(0,X.jsx)(K,{"aria-hidden":`true`,className:`size-[13px]`})})]})}function Dn(e){return e===`main`||e===`changes`?`Split`:`Table`}function On({section:e,index:t=!1}){let n=l(),r=I(),[i]=w(),a=Dn(e);if(t&&!r&&i.get(`view`)!==`repo`)return(0,X.jsx)(Nt,{});if(n.isPending)return(0,X.jsx)(pt,{});if(n.isError)return(0,X.jsx)(Ye,{template:a,route:`repo-git`,density:`empty`,beforeHeader:(0,X.jsx)(z,{}),children:(0,X.jsx)(L,{icon:(0,X.jsx)(j,{size:16}),tone:`danger`,title:`Could not load the repository`,subtitle:n.error.message})});let o=n.data.info;return o?(0,X.jsx)(kn,{repo:n.data,info:o,section:e}):(0,X.jsx)(Ye,{template:a,route:`repo-git`,density:`empty`,beforeHeader:(0,X.jsx)(z,{}),children:(0,X.jsx)(L,{icon:(0,X.jsx)(fe,{size:16}),tone:`neutral`,title:`Not a git repository`,subtitle:`Squawk is running outside a git repository — start it inside one to browse changes, commits and branches.`})})}function kn({repo:e,info:t,section:n}){let r=Dn(n),i=s(),a=An(n),o=n===`main`?e.log.length:n===`changes`?e.status.length:n===`branches`?Gt(e,i.data?.branches).length:n===`not-landed`?i.data?.branches.filter(e=>e.class===`not-landed`||e.class===`orphan`).length??0:4;return(0,X.jsx)(Ye,{template:r,route:`repo-git`,density:n===`not-landed`&&i.isPending?`full`:qe(o),rootProps:{"data-git-section":n},beforeHeader:(0,X.jsx)(z,{}),header:{title:a?.title??ut(n,t.branch),headerSlot:`repo-header`,subtitle:a?(0,X.jsxs)(X.Fragment,{children:[`Commit `,a.shortSha,` on `,t.branch]}):(0,X.jsx)(jn,{repo:e,info:t,section:n}),subtitleSlot:`repo-meta`,...n===`branches`?{primaryAction:(0,X.jsx)(Ft,{from:t.branch})}:{}},children:n===`main`?(0,X.jsx)(qt,{repo:e,info:t}):n===`not-landed`?(0,X.jsx)(nn,{}):n===`cleanup`?(0,X.jsxs)(`div`,{"data-slot":`repo-cleanup`,className:`flex flex-col gap-4 pb-[calc(90px+env(safe-area-inset-bottom))] md:pb-0`,children:[(0,X.jsx)(Cn,{}),(0,X.jsx)(dn,{base:e.baseBranch??t.branch})]}):n===`branches`?(0,X.jsx)(Rt,{repo:e,info:t}):(0,X.jsx)(Kt,{})})}function An(e){let{sha:t}=T(),n=I(),r=e===`main`&&!n?t:void 0,i=u(r);if(!r)return;let a=r.slice(0,8);return{title:i.data?.subject??`Commit ${a}`,shortSha:a}}function jn({repo:e,info:t,section:n}){let r=e.baseBranch??t.branch;switch(n){case`main`:return(0,X.jsxs)(X.Fragment,{children:[e.log.length===0?`No commits yet`:`Latest ${e.log.length} commit${e.log.length===1?``:`s`} in the main checkout`,e.tracking?` · ${mt(e.tracking)}`:``]});case`not-landed`:return(0,X.jsxs)(X.Fragment,{children:[`Finished tasks whose commits are not on `,r]});case`branches`:return(0,X.jsx)(Mn,{repo:e,info:t});case`changes`:return(0,X.jsxs)(X.Fragment,{children:[e.status.length,` uncommitted file`,e.status.length===1?``:`s`,` in the main checkout`]});case`cleanup`:return(0,X.jsxs)(X.Fragment,{children:[`Nothing here can delete work that is not on `,r]})}}function Mn({repo:e,info:t}){let n=Gt(e,s().data?.branches).length;return(0,X.jsxs)(X.Fragment,{children:[n,` branch`,n===1?``:`es`,` · on `,t.branch]})}export{On as RepoGitRoute};
@@ -1 +1 @@
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,N as i}from"./queries-BSxNcgZm.js";import{Rn as a,it as o}from"./toaster-BJG79kO8.js";import{f as s,g as c,h as l,i as u,n as d,p as f}from"./chunk-KS7C4IRE-Cg8l-LDN.js";import{ct as p,r as m}from"./design-icons-QbNMZniQ.js";import{a as h,c as g,l as _,s as v,t as y}from"./file-preview-CnmQ7Rsa.js";import{t as b}from"./button-C8jUIs8Q.js";import{t as x}from"./centered-state-BgSV4e79.js";import{Ln as S,_ as C,g as w,v as T}from"./index-CoM783-U.js";import{r as E}from"./html-report-BX3msvci.js";import{t as D}from"./html-report-frame-Ck76gKfA.js";var O=e(t(),1),k=n();function A(){let e=s(),t=f();return()=>{if(e.key==="default"||window.history.state?.idx===0){t({pathname:e.pathname.replace(/\/report\/?$/,``)},{replace:!0});return}let n=window.navigation,r=j(e.state);n?.canGoBack?n.back():r?t(r,{state:{filesRestoreKey:e.state?.filesRestoreKey}}):t(-1)}}function j(e){let t=e?.readerFrom;return typeof t==`string`&&t.startsWith(`/`)&&!t.startsWith(`//`)?t:null}function M(e){return e?.type===`file`?e:null}function N(){let[e]=c(),t=e.get(`path`),n=e.get(`artifact`);return{path:t,artifactId:n,conflict:e.getAll(`path`).length>1||e.getAll(`artifact`).length>1||t!==null&&n!==null||t===``||n===``}}function P(){let{id:e=``}=l(),t=N(),n=s(),r=A();return(0,k.jsx)(F,{runId:e,selection:t,fragment:n.hash,onBack:r,variant:`route`})}function F({runId:e,selection:t,fragment:n,onBack:r,variant:i,sourceLookup:a}){let{path:o,conflict:c,selected:l,result:d}=L(e,t,a),f=T(w,!0),p=T(C,!1),m=s(),[h,g]=(0,O.useState)(!1),_=M(d.data);if(i===`route`&&R(_))return(0,k.jsx)(u,{replace:!0,to:{pathname:m.pathname.replace(/\/report\/?$/,`/files`),search:m.search,hash:m.hash}});let v=B(_,o),y=i===`pane`&&!p&&!f?`Conversation`:`Back`,b=i===`pane`&&!h&&z(_),x=I(m.pathname,e,t);return(0,k.jsxs)(`div`,{"data-route":`task-report`,"data-variant":i,onKeyDown:e=>{i!==`pane`||e.key!==`Escape`||e.defaultPrevented||(e.preventDefault(),e.stopPropagation(),r())},className:i===`route`?`fixed inset-0 z-50 flex flex-col bg-background [padding-block-start:env(safe-area-inset-top)] [padding-inline-end:env(safe-area-inset-right)] [padding-block-end:env(safe-area-inset-bottom)] [padding-inline-start:env(safe-area-inset-left)] md:static md:z-auto md:h-full md:p-0`:`flex h-full min-h-0 flex-col bg-background max-md:[padding-block-start:env(safe-area-inset-top)] max-md:[padding-inline-start:env(safe-area-inset-left)] max-md:[padding-inline-end:env(safe-area-inset-right)]`,children:[(0,k.jsx)(V,{runId:e,file:_,name:v,source:h,onSource:()=>g(e=>!e),onBack:r,backLabel:y,hideDownload:i===`pane`&&p,focusBack:i===`pane`}),(0,k.jsx)(`div`,{"data-slot":`report-body`,className:b?`flex min-h-0 flex-1 flex-col overflow-clip`:`flex min-h-0 flex-1 flex-col overflow-auto`,children:(0,k.jsx)(H,{conflict:c,selected:l,result:d,source:h,name:v,fragment:n,pane:i===`pane`,filesHref:x})})]})}function I(e,t,n){let r=/^\/p\/[^/]+/.exec(e)?.[0]??``,i=n.artifactId?new URLSearchParams({artifact:n.artifactId}):new URLSearchParams({path:n.path??``});return`${r}/tasks/${encodeURIComponent(t)}/files?${i}`}function L(e,t,n){let{path:a=null,artifactId:o=null,conflict:s=!1}=t,c=n?.isPending||n?.isError,l=r(e,o||s||c?null:a),u=i(e,s||c?null:o),d=c&&n?{...n,data:void 0}:o?u:l;return{path:a,conflict:s,selected:a!==null||o!==null,result:d}}function R(e){return e!==null&&(!E(e.path)||!e.artifact&&(e.tooLarge||e.binary))}function z(e){return e!==null&&!e.tooLarge&&!e.binary}function B(e,t){return e?e.artifact?.name??e.path.split(/[\\/]/).at(-1)??e.path:t??`Report`}function V({runId:e,file:t,name:n,source:r,onSource:i,onBack:a,backLabel:s,hideDownload:c,focusBack:l}){let u=(0,O.useRef)(null);(0,O.useEffect)(()=>{l&&u.current?.focus({preventScroll:!0})},[l]);let d=t?.artifact;return(0,k.jsxs)(`header`,{"data-slot":`report-bar`,className:`flex min-h-14 shrink-0 items-center gap-2 border-b border-border bg-card px-2 md:px-4`,children:[(0,k.jsxs)(b,{ref:u,variant:`ghost`,className:`min-h-11 min-w-11 gap-1.5 px-2`,onClick:a,"aria-label":s,children:[(0,k.jsx)(m,{size:18,"aria-hidden":`true`}),(0,k.jsx)(`span`,{className:`max-sm:sr-only`,children:s})]}),(0,k.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,k.jsx)(`h1`,{className:`truncate text-sm font-medium`,children:n}),t?(0,k.jsxs)(`p`,{className:`truncate text-xs text-soft-foreground`,children:[d?(0,k.jsxs)(k.Fragment,{children:[`Published snapshot · `,(0,k.jsx)(S,{iso:d.createdAt})]}):`Live file`,` · `,h(t.size)]}):null]}),t&&!t.tooLarge&&!t.binary?(0,k.jsx)(b,{variant:`ghost`,className:`min-h-11 px-3 text-accent-text`,onClick:i,children:r?`Preview`:`Source`}):null,d&&!c?(0,k.jsx)(`a`,{className:`inline-flex min-h-11 items-center rounded-md px-3 text-sm text-accent-text underline focus-visible:ring-2`,href:o(e,d.id,`download`),children:`Download`}):null]})}function H({conflict:e,selected:t,result:n,source:r,name:i,fragment:a,pane:o,filesHref:s}){if(e)return(0,k.jsx)(W,{icon:(0,k.jsx)(v,{}),title:`Invalid report link`,subtitle:`Choose either a path or a published artifact.`});if(!t)return(0,k.jsx)(W,{icon:(0,k.jsx)(g,{}),title:`No report selected`,subtitle:`Open a report from a link in the conversation or from Files.`});if(n.isPending)return(0,k.jsx)(`p`,{role:`status`,"data-slot":`report-loading`,className:`px-4 py-6 text-center text-sm text-soft-foreground`,children:`Loading report…`});if(n.isError)return(0,k.jsx)(U,{result:n});let c=n.data;return c.type===`file`?o&&!E(c.path)?(0,k.jsx)(W,{icon:(0,k.jsx)(g,{}),title:`Not an HTML report`,subtitle:`Open this published file in Files.`,action:(0,k.jsx)(d,{to:s,className:`inline-flex min-h-11 items-center rounded-md px-3 text-sm text-accent-text underline active:bg-muted focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring`,children:`Open in Files`})}):c.tooLarge?(0,k.jsx)(W,{icon:(0,k.jsx)(_,{}),title:`Too large to preview`,subtitle:`${h(c.size)} is past the 500 kB preview limit. Download it to read it.`}):c.binary?(0,k.jsx)(W,{icon:(0,k.jsx)(g,{}),title:`Binary file`,subtitle:`This file holds binary data, not readable HTML.`}):r?(0,k.jsx)(`div`,{className:`bg-card`,children:(0,k.jsx)(y,{path:c.path,text:c.content??``})}):(0,k.jsx)(D,{html:c.content??``,title:`Report: ${i}`,fragment:a,className:o?`min-h-0 flex-1`:`min-h-[60dvh] flex-1`}):(0,k.jsx)(W,{icon:(0,k.jsx)(v,{}),title:c.type===`unpublished`?`Report not published`:`Report unavailable`,subtitle:c.reason})}function U({result:e}){let t=e.error instanceof a&&e.error.status===404;return(0,k.jsx)(W,{icon:t?(0,k.jsx)(v,{}):(0,k.jsx)(p,{size:16}),tone:t?`neutral`:`danger`,title:t?`Report missing or deleted`:`Could not load this report`,subtitle:e.error?.message??`Try again.`,action:(0,k.jsx)(b,{variant:`outline`,className:`min-h-11`,onClick:()=>void e.refetch(),children:`Retry`})})}function W({icon:e,title:t,subtitle:n,tone:r=`neutral`,action:i}){return(0,k.jsxs)(`div`,{"data-slot":`report-state`,className:`flex flex-col items-center gap-3 p-6`,children:[(0,k.jsx)(x,{icon:e,tone:r,heading:`h2`,title:t,subtitle:n}),i]})}export{F as ReportReader,P as TaskReportRoute};
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{M as r,z as i}from"./queries-B8INH8MM.js";import{Rn as a,it as o}from"./toaster-Cjr2jC1Q.js";import{f as s,g as c,h as l,i as u,n as d,p as f}from"./chunk-KS7C4IRE-Cg8l-LDN.js";import{ct as p,r as m}from"./design-icons-QbNMZniQ.js";import{a as h,c as g,l as _,s as v,t as y}from"./file-preview-QXwZnRnZ.js";import{t as b}from"./button-C8jUIs8Q.js";import{t as x}from"./centered-state-BgSV4e79.js";import{Rn as S,_ as C,g as w,v as T}from"./index-DDtQlxLH.js";import{r as E}from"./html-report-BX3msvci.js";import{t as D}from"./html-report-frame-Ck76gKfA.js";var O=e(t(),1),k=n();function A(){let e=s(),t=f();return()=>{if(e.key==="default"||window.history.state?.idx===0){t({pathname:e.pathname.replace(/\/report\/?$/,``)},{replace:!0});return}let n=window.navigation,r=j(e.state);n?.canGoBack?n.back():r?t(r,{state:{filesRestoreKey:e.state?.filesRestoreKey}}):t(-1)}}function j(e){let t=e?.readerFrom;return typeof t==`string`&&t.startsWith(`/`)&&!t.startsWith(`//`)?t:null}function M(e){return e?.type===`file`?e:null}function N(){let[e]=c(),t=e.get(`path`),n=e.get(`artifact`);return{path:t,artifactId:n,conflict:e.getAll(`path`).length>1||e.getAll(`artifact`).length>1||t!==null&&n!==null||t===``||n===``}}function P(){let{id:e=``}=l(),t=N(),n=s(),r=A();return(0,k.jsx)(F,{runId:e,selection:t,fragment:n.hash,onBack:r,variant:`route`})}function F({runId:e,selection:t,fragment:n,onBack:r,variant:i,sourceLookup:a}){let{path:o,conflict:c,selected:l,result:d}=L(e,t,a),f=T(w,!0),p=T(C,!1),m=s(),[h,g]=(0,O.useState)(!1),_=M(d.data);if(i===`route`&&R(_))return(0,k.jsx)(u,{replace:!0,to:{pathname:m.pathname.replace(/\/report\/?$/,`/files`),search:m.search,hash:m.hash}});let v=B(_,o),y=i===`pane`&&!p&&!f?`Conversation`:`Back`,b=i===`pane`&&!h&&z(_),x=I(m.pathname,e,t);return(0,k.jsxs)(`div`,{"data-route":`task-report`,"data-variant":i,onKeyDown:e=>{i!==`pane`||e.key!==`Escape`||e.defaultPrevented||(e.preventDefault(),e.stopPropagation(),r())},className:i===`route`?`fixed inset-0 z-50 flex flex-col bg-background [padding-block-start:env(safe-area-inset-top)] [padding-inline-end:env(safe-area-inset-right)] [padding-block-end:env(safe-area-inset-bottom)] [padding-inline-start:env(safe-area-inset-left)] md:static md:z-auto md:h-full md:p-0`:`flex h-full min-h-0 flex-col bg-background max-md:[padding-block-start:env(safe-area-inset-top)] max-md:[padding-inline-start:env(safe-area-inset-left)] max-md:[padding-inline-end:env(safe-area-inset-right)]`,children:[(0,k.jsx)(V,{runId:e,file:_,name:v,source:h,onSource:()=>g(e=>!e),onBack:r,backLabel:y,hideDownload:i===`pane`&&p,focusBack:i===`pane`}),(0,k.jsx)(`div`,{"data-slot":`report-body`,className:b?`flex min-h-0 flex-1 flex-col overflow-clip`:`flex min-h-0 flex-1 flex-col overflow-auto`,children:(0,k.jsx)(H,{conflict:c,selected:l,result:d,source:h,name:v,fragment:n,pane:i===`pane`,filesHref:x})})]})}function I(e,t,n){let r=/^\/p\/[^/]+/.exec(e)?.[0]??``,i=n.artifactId?new URLSearchParams({artifact:n.artifactId}):new URLSearchParams({path:n.path??``});return`${r}/tasks/${encodeURIComponent(t)}/files?${i}`}function L(e,t,n){let{path:a=null,artifactId:o=null,conflict:s=!1}=t,c=n?.isPending||n?.isError,l=i(e,o||s||c?null:a),u=r(e,s||c?null:o),d=c&&n?{...n,data:void 0}:o?u:l;return{path:a,conflict:s,selected:a!==null||o!==null,result:d}}function R(e){return e!==null&&(!E(e.path)||!e.artifact&&(e.tooLarge||e.binary))}function z(e){return e!==null&&!e.tooLarge&&!e.binary}function B(e,t){return e?e.artifact?.name??e.path.split(/[\\/]/).at(-1)??e.path:t??`Report`}function V({runId:e,file:t,name:n,source:r,onSource:i,onBack:a,backLabel:s,hideDownload:c,focusBack:l}){let u=(0,O.useRef)(null);(0,O.useEffect)(()=>{l&&u.current?.focus({preventScroll:!0})},[l]);let d=t?.artifact;return(0,k.jsxs)(`header`,{"data-slot":`report-bar`,className:`flex min-h-14 shrink-0 items-center gap-2 border-b border-border bg-card px-2 md:px-4`,children:[(0,k.jsxs)(b,{ref:u,variant:`ghost`,className:`min-h-11 min-w-11 gap-1.5 px-2`,onClick:a,"aria-label":s,children:[(0,k.jsx)(m,{size:18,"aria-hidden":`true`}),(0,k.jsx)(`span`,{className:`max-sm:sr-only`,children:s})]}),(0,k.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,k.jsx)(`h1`,{className:`truncate text-sm font-medium`,children:n}),t?(0,k.jsxs)(`p`,{className:`truncate text-xs text-soft-foreground`,children:[d?(0,k.jsxs)(k.Fragment,{children:[`Published snapshot · `,(0,k.jsx)(S,{iso:d.createdAt})]}):`Live file`,` · `,h(t.size)]}):null]}),t&&!t.tooLarge&&!t.binary?(0,k.jsx)(b,{variant:`ghost`,className:`min-h-11 px-3 text-accent-text`,onClick:i,children:r?`Preview`:`Source`}):null,d&&!c?(0,k.jsx)(`a`,{className:`inline-flex min-h-11 items-center rounded-md px-3 text-sm text-accent-text underline focus-visible:ring-2`,href:o(e,d.id,`download`),children:`Download`}):null]})}function H({conflict:e,selected:t,result:n,source:r,name:i,fragment:a,pane:o,filesHref:s}){if(e)return(0,k.jsx)(W,{icon:(0,k.jsx)(v,{}),title:`Invalid report link`,subtitle:`Choose either a path or a published artifact.`});if(!t)return(0,k.jsx)(W,{icon:(0,k.jsx)(g,{}),title:`No report selected`,subtitle:`Open a report from a link in the conversation or from Files.`});if(n.isPending)return(0,k.jsx)(`p`,{role:`status`,"data-slot":`report-loading`,className:`px-4 py-6 text-center text-sm text-soft-foreground`,children:`Loading report…`});if(n.isError)return(0,k.jsx)(U,{result:n});let c=n.data;return c.type===`file`?o&&!E(c.path)?(0,k.jsx)(W,{icon:(0,k.jsx)(g,{}),title:`Not an HTML report`,subtitle:`Open this published file in Files.`,action:(0,k.jsx)(d,{to:s,className:`inline-flex min-h-11 items-center rounded-md px-3 text-sm text-accent-text underline active:bg-muted focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring`,children:`Open in Files`})}):c.tooLarge?(0,k.jsx)(W,{icon:(0,k.jsx)(_,{}),title:`Too large to preview`,subtitle:`${h(c.size)} is past the 500 kB preview limit. Download it to read it.`}):c.binary?(0,k.jsx)(W,{icon:(0,k.jsx)(g,{}),title:`Binary file`,subtitle:`This file holds binary data, not readable HTML.`}):r?(0,k.jsx)(`div`,{className:`bg-card`,children:(0,k.jsx)(y,{path:c.path,text:c.content??``})}):(0,k.jsx)(D,{html:c.content??``,title:`Report: ${i}`,fragment:a,className:o?`min-h-0 flex-1`:`min-h-[60dvh] flex-1`}):(0,k.jsx)(W,{icon:(0,k.jsx)(v,{}),title:c.type===`unpublished`?`Report not published`:`Report unavailable`,subtitle:c.reason})}function U({result:e}){let t=e.error instanceof a&&e.error.status===404;return(0,k.jsx)(W,{icon:t?(0,k.jsx)(v,{}):(0,k.jsx)(p,{size:16}),tone:t?`neutral`:`danger`,title:t?`Report missing or deleted`:`Could not load this report`,subtitle:e.error?.message??`Try again.`,action:(0,k.jsx)(b,{variant:`outline`,className:`min-h-11`,onClick:()=>void e.refetch(),children:`Retry`})})}function W({icon:e,title:t,subtitle:n,tone:r=`neutral`,action:i}){return(0,k.jsxs)(`div`,{"data-slot":`report-state`,className:`flex flex-col items-center gap-3 p-6`,children:[(0,k.jsx)(x,{icon:e,tone:r,heading:`h2`,title:t,subtitle:n}),i]})}export{F as ReportReader,P as TaskReportRoute};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{o as r}from"./dist-C_rn70hE.js";import{Ut as i}from"./queries-BSxNcgZm.js";import{f as a,p as o}from"./chunk-KS7C4IRE-Cg8l-LDN.js";import{mt as s}from"./design-icons-QbNMZniQ.js";import{a as c,c as l,i as u,n as d,o as f,r as p,s as m,t as h}from"./dist--f2yFdPY.js";import{t as g}from"./use-search-params-writer-ClMScnNe.js";var _=e(t(),1),v=n();function y({...e}){return(0,v.jsx)(h,{"data-slot":`sheet`,...e})}function b({...e}){return(0,v.jsx)(l,{"data-slot":`sheet-trigger`,...e})}function x({...e}){return(0,v.jsx)(d,{"data-slot":`sheet-close`,...e})}function S({...e}){return(0,v.jsx)(f,{"data-slot":`sheet-portal`,...e})}function C({className:e,...t}){return(0,v.jsx)(c,{"data-slot":`sheet-overlay`,className:r(`fixed inset-0 z-50 bg-black/50 motion-safe:data-[state=closed]:animate-out data-[state=closed]:fade-out-0 motion-safe:data-[state=open]:animate-in data-[state=open]:fade-in-0`,e),...t})}function w({className:e,children:t,side:n=`right`,showCloseButton:i=!0,overlayClassName:a,...o}){return(0,v.jsxs)(S,{children:[(0,v.jsx)(C,{className:a}),(0,v.jsxs)(p,{"data-slot":`sheet-content`,className:r(`fixed z-50 flex flex-col gap-4 bg-background shadow-modal transition-colors ease-in-out motion-safe:data-[state=closed]:animate-out data-[state=closed]:duration-300 motion-safe:data-[state=open]:animate-in data-[state=open]:duration-500`,n===`right`&&`inset-y-0 end-0 h-full w-3/4 border-s motion-safe:data-[state=closed]:slide-out-to-right motion-safe:data-[state=open]:slide-in-from-right sm:max-w-sm`,n===`left`&&`inset-y-0 start-0 h-full w-3/4 border-e motion-safe:data-[state=closed]:slide-out-to-left motion-safe:data-[state=open]:slide-in-from-left sm:max-w-sm`,n===`top`&&`inset-x-0 inset-bs-0 h-auto border-be motion-safe:data-[state=closed]:slide-out-to-top motion-safe:data-[state=open]:slide-in-from-top`,n===`bottom`&&`inset-x-0 inset-be-0 h-auto border-bs motion-safe:data-[state=closed]:slide-out-to-bottom motion-safe:data-[state=open]:slide-in-from-bottom`,e),...o,children:[t,i&&(0,v.jsxs)(d,{className:`absolute inset-bs-4 end-4 rounded-sm opacity-70 ring-offset-background transition-opacity pointer-hover:opacity-100 focus:ring-2 focus:ring-ring focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none data-[state=open]:bg-secondary`,children:[(0,v.jsx)(s,{className:`size-4`}),(0,v.jsx)(`span`,{className:`sr-only`,children:`Close`})]})]})]})}function T({className:e,...t}){return(0,v.jsx)(`div`,{"data-slot":`sheet-header`,className:r(`flex flex-col gap-1.5 p-4`,e),...t})}function E({className:e,...t}){return(0,v.jsx)(m,{"data-slot":`sheet-title`,className:r(`font-semibold text-foreground`,e),...t})}function D({className:e,...t}){return(0,v.jsx)(u,{"data-slot":`sheet-description`,className:r(`text-sm text-muted-foreground`,e),...t})}function O(e){let[t,n]=_.useState(()=>Date.now());return _.useEffect(()=>{if(i())return;let t=setInterval(()=>n(Date.now()),e);return()=>clearInterval(t)},[e]),t}var k=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function A(e){let t=e.get(`report`);return!t||!k.test(t)||e.getAll(`report`).length!==1||e.getAll(`card`).length>1?null:{artifactId:t,card:e.get(`card`)||null}}var j=(0,_.createContext)(null);function M(e){let t=a(),n=o(),[r,i]=g(),s=A(r),[c,l]=(0,_.useState)(()=>({runId:e,entries:new Map}));c.runId!==e&&l({runId:e,entries:new Map});let u=(0,_.useCallback)((t,n)=>(l(r=>{if(r.runId===e&&r.entries.get(t)===n)return r;let i=new Map(r.runId===e?r.entries:[]);return i.set(t,n),{runId:e,entries:i}}),()=>void 0),[e]),d=(0,_.useRef)({runId:e,callbacks:new Map});d.current.runId!==e&&(d.current={runId:e,callbacks:new Map});let f=(0,_.useCallback)((e,t)=>(d.current.callbacks.set(e,t),()=>{d.current.callbacks.get(e)===t&&d.current.callbacks.delete(e)}),[]),p=(0,_.useMemo)(()=>({register:u,registerOpener:f}),[u,f]),m=(0,_.useRef)(null);return(0,_.useEffect)(()=>{r.has(`report`)&&!s&&i(e=>(e.delete(`report`),e.delete(`card`),e))},[r,s,i]),(0,_.useEffect)(()=>{let n=m.current;!s&&n&&n.runId===e&&n.card&&d.current.callbacks.get(n.card)?.(n.artifactId,n.scrollTop),m.current=s?{...s,runId:e,scrollTop:t.state?.reportScrollTop}:null},[e,s,t.state]),{selection:s,sourceRunId:c.runId===e&&s?c.entries.get(s.artifactId)??(s.card?void 0:e):void 0,registry:p,close:()=>{let e=t.state,r=window.navigation;if(e?.reportReturnKey&&r){r.traverseTo(e.reportReturnKey);return}if(e?.reportReturnTo){n(e.reportReturnTo,{replace:!0});return}i(e=>(e.delete(`report`),e.delete(`card`),e))}}}export{x as a,T as c,y as i,E as l,M as n,w as o,O as r,D as s,j as t,b as u};
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{o as r}from"./dist-C_rn70hE.js";import{Ht as i}from"./queries-B8INH8MM.js";import{f as a,p as o}from"./chunk-KS7C4IRE-Cg8l-LDN.js";import{mt as s}from"./design-icons-QbNMZniQ.js";import{a as c,c as l,i as u,n as d,o as f,r as p,s as m,t as h}from"./dist--f2yFdPY.js";import{t as g}from"./use-search-params-writer-ClMScnNe.js";var _=e(t(),1),v=n();function y({...e}){return(0,v.jsx)(h,{"data-slot":`sheet`,...e})}function b({...e}){return(0,v.jsx)(l,{"data-slot":`sheet-trigger`,...e})}function x({...e}){return(0,v.jsx)(d,{"data-slot":`sheet-close`,...e})}function S({...e}){return(0,v.jsx)(f,{"data-slot":`sheet-portal`,...e})}function C({className:e,...t}){return(0,v.jsx)(c,{"data-slot":`sheet-overlay`,className:r(`fixed inset-0 z-50 bg-black/50 motion-safe:data-[state=closed]:animate-out data-[state=closed]:fade-out-0 motion-safe:data-[state=open]:animate-in data-[state=open]:fade-in-0`,e),...t})}function w({className:e,children:t,side:n=`right`,showCloseButton:i=!0,overlayClassName:a,...o}){return(0,v.jsxs)(S,{children:[(0,v.jsx)(C,{className:a}),(0,v.jsxs)(p,{"data-slot":`sheet-content`,className:r(`fixed z-50 flex flex-col gap-4 bg-background shadow-modal transition-colors ease-in-out motion-safe:data-[state=closed]:animate-out data-[state=closed]:duration-300 motion-safe:data-[state=open]:animate-in data-[state=open]:duration-500`,n===`right`&&`inset-y-0 end-0 h-full w-3/4 border-s motion-safe:data-[state=closed]:slide-out-to-right motion-safe:data-[state=open]:slide-in-from-right sm:max-w-sm`,n===`left`&&`inset-y-0 start-0 h-full w-3/4 border-e motion-safe:data-[state=closed]:slide-out-to-left motion-safe:data-[state=open]:slide-in-from-left sm:max-w-sm`,n===`top`&&`inset-x-0 inset-bs-0 h-auto border-be motion-safe:data-[state=closed]:slide-out-to-top motion-safe:data-[state=open]:slide-in-from-top`,n===`bottom`&&`inset-x-0 inset-be-0 h-auto border-bs motion-safe:data-[state=closed]:slide-out-to-bottom motion-safe:data-[state=open]:slide-in-from-bottom`,e),...o,children:[t,i&&(0,v.jsxs)(d,{className:`absolute inset-bs-4 end-4 rounded-sm opacity-70 ring-offset-background transition-opacity pointer-hover:opacity-100 focus:ring-2 focus:ring-ring focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none data-[state=open]:bg-secondary`,children:[(0,v.jsx)(s,{className:`size-4`}),(0,v.jsx)(`span`,{className:`sr-only`,children:`Close`})]})]})]})}function T({className:e,...t}){return(0,v.jsx)(`div`,{"data-slot":`sheet-header`,className:r(`flex flex-col gap-1.5 p-4`,e),...t})}function E({className:e,...t}){return(0,v.jsx)(m,{"data-slot":`sheet-title`,className:r(`font-semibold text-foreground`,e),...t})}function D({className:e,...t}){return(0,v.jsx)(u,{"data-slot":`sheet-description`,className:r(`text-sm text-muted-foreground`,e),...t})}function O(e){let[t,n]=_.useState(()=>Date.now());return _.useEffect(()=>{if(i())return;let t=setInterval(()=>n(Date.now()),e);return()=>clearInterval(t)},[e]),t}var k=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function A(e){let t=e.get(`report`);return!t||!k.test(t)||e.getAll(`report`).length!==1||e.getAll(`card`).length>1?null:{artifactId:t,card:e.get(`card`)||null}}var j=(0,_.createContext)(null);function M(e){let t=a(),n=o(),[r,i]=g(),s=A(r),[c,l]=(0,_.useState)(()=>({runId:e,entries:new Map}));c.runId!==e&&l({runId:e,entries:new Map});let u=(0,_.useCallback)((t,n)=>(l(r=>{if(r.runId===e&&r.entries.get(t)===n)return r;let i=new Map(r.runId===e?r.entries:[]);return i.set(t,n),{runId:e,entries:i}}),()=>void 0),[e]),d=(0,_.useRef)({runId:e,callbacks:new Map});d.current.runId!==e&&(d.current={runId:e,callbacks:new Map});let f=(0,_.useCallback)((e,t)=>(d.current.callbacks.set(e,t),()=>{d.current.callbacks.get(e)===t&&d.current.callbacks.delete(e)}),[]),p=(0,_.useMemo)(()=>({register:u,registerOpener:f}),[u,f]),m=(0,_.useRef)(null);return(0,_.useEffect)(()=>{r.has(`report`)&&!s&&i(e=>(e.delete(`report`),e.delete(`card`),e))},[r,s,i]),(0,_.useEffect)(()=>{let n=m.current;!s&&n&&n.runId===e&&n.card&&d.current.callbacks.get(n.card)?.(n.artifactId,n.scrollTop),m.current=s?{...s,runId:e,scrollTop:t.state?.reportScrollTop}:null},[e,s,t.state]),{selection:s,sourceRunId:c.runId===e&&s?c.entries.get(s.artifactId)??(s.card?void 0:e):void 0,registry:p,close:()=>{let e=t.state,r=window.navigation;if(e?.reportReturnKey&&r){r.traverseTo(e.reportReturnKey);return}if(e?.reportReturnTo){n(e.reportReturnTo,{replace:!0});return}i(e=>(e.delete(`report`),e.delete(`card`),e))}}}export{x as a,T as c,y as i,E as l,M as n,w as o,O as r,D as s,j as t,b as u};